docs(core): read package names from package.json rather than inferrin… (#11520)

This commit is contained in:
Jack Hsu 2022-08-09 12:42:13 -04:00 committed by GitHub
parent 522dcdd339
commit 520e5852f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 68 additions and 42 deletions

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "add-nx-to-monorepo",
"packageName": "add-nx-to-monorepo",
"description": "Make any monorepo faster by adding Nx to it",
"root": "/packages/add-nx-to-monorepo",
"source": "/packages/add-nx-to-monorepo/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "angular",
"packageName": "@nrwl/angular",
"description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Cypress, Karma, and Protractor. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
"root": "/packages/angular",
"source": "/packages/angular/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "cra-to-nx",
"packageName": "cra-to-nx",
"root": "/packages/cra-to-nx",
"source": "/packages/cra-to-nx/src",
"documentation": [],

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "create-nx-plugin",
"packageName": "create-nx-plugin",
"description": "Smart, Fast and Extensible Build System",
"root": "/packages/create-nx-plugin",
"source": "/packages/create-nx-plugin/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "create-nx-workspace",
"packageName": "create-nx-workspace",
"description": "Smart, Fast and Extensible Build System",
"root": "/packages/create-nx-workspace",
"source": "/packages/create-nx-workspace/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "cypress",
"packageName": "@nrwl/cypress",
"description": "The Nx Plugin for Cypress contains executors and generators allowing your workspace to use the powerful Cypress integration testing capabilities.",
"root": "/packages/cypress",
"source": "/packages/cypress/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "detox",
"packageName": "@nrwl/detox",
"description": "The Nx Plugin for Detox that contains executors and generators for allowing your workspace to use the powerful Detox integration testing capabilities.",
"root": "/packages/detox",
"source": "/packages/detox/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "devkit",
"packageName": "@nrwl/devkit",
"description": "Smart, Fast and Extensible Build System",
"root": "/packages/devkit",
"source": "/packages/devkit/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "eslint-plugin-nx",
"packageName": "@nrwl/eslint-plugin-nx",
"description": "ESLint Plugin for Nx",
"root": "/packages/eslint-plugin-nx",
"source": "/packages/eslint-plugin-nx/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "express",
"packageName": "@nrwl/express",
"description": "The Nx Plugin for Express that contains executors and generators for allowing your workspace to create powerful Express Node applications and APIs.",
"root": "/packages/express",
"source": "/packages/express/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "jest",
"packageName": "@nrwl/jest",
"description": "The Nx Plugin for Jest contains executors and generators allowing your workspace to use the powerful Jest testing capabilities.",
"root": "/packages/jest",
"source": "/packages/jest/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "js",
"packageName": "@nrwl/js",
"description": "The Nx plugin that provides the best experience for developing JavaScript and TypeScript projects.",
"root": "/packages/js",
"source": "/packages/js/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "linter",
"packageName": "@nrwl/linter",
"description": "The Linter plugin contains executors, generator, plugin and utilities used for linting JavaScript/TypeScript projects within an Nx workspace.",
"root": "/packages/linter",
"source": "/packages/linter/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "make-angular-cli-faster",
"packageName": "make-angular-cli-faster",
"description": "Make Angular CLI faster by enabling distributed computation caching",
"root": "/packages/make-angular-cli-faster",
"source": "/packages/make-angular-cli-faster/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "nest",
"packageName": "@nrwl/nest",
"description": "The Nx Plugin for Nest that contains executors and generators for allowing your workspace to create powerful Nest best in class APIs.",
"root": "/packages/nest",
"source": "/packages/nest/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "next",
"packageName": "@nrwl/next",
"description": "When using Next.js in Nx, you get the out-of-the-box support for TypeScript, Cypress, and Jest. No need to configure anything: watch mode, source maps, and typings just work.\n\nThe Next.js plugin contains executors and generators for managing Next.js applications and libraries within an Nx workspace. It provides:\n\n\n- Scaffolding for creating, building, serving, linting, and testing Next.js applications.\n\n- Integration with building, serving, and exporting a Next.js application.\n\n- Integration with React libraries within the workspace.",
"root": "/packages/next",
"source": "/packages/next/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "node",
"packageName": "@nrwl/node",
"description": "The Node Plugin contains generators and executors to manage Node applications within an Nx workspace.",
"root": "/packages/node",
"source": "/packages/node/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "nx-plugin",
"packageName": "@nrwl/nx-plugin",
"description": "Plugin for creating plugins for Nx :)",
"root": "/packages/nx-plugin",
"source": "/packages/nx-plugin/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "nx",
"packageName": "nx",
"description": "Smart, Fast and Extensible Build System",
"root": "/packages/nx",
"source": "/packages/nx/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "react-native",
"packageName": "@nrwl/react-native",
"description": "React Native brings React's declarative UI framework to iOS and Android. With React Native, you use native UI controls and have full access to the native platform.\n\nThe Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Detox, and Storybook.\n\n- Scaffolding for creating buildable libraries that can be published to npm.\n\n- Utilities for automatic workspace refactoring.",
"root": "/packages/react-native",
"source": "/packages/react-native/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "react",
"packageName": "@nrwl/react",
"description": "The React plugin contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
"root": "/packages/react",
"source": "/packages/react/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "storybook",
"packageName": "@nrwl/storybook",
"description": "The Nx Plugin for Storybook that contains executors and generators for allowing your workspace to use the powerful Storybook integration testing & documenting capabilities.",
"root": "/packages/storybook",
"source": "/packages/storybook/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "tao",
"packageName": "@nrwl/tao",
"description": "CLI for generating code and running commands",
"root": "/packages/tao",
"source": "/packages/tao/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "web",
"packageName": "@nrwl/web",
"description": "The Nx Plugin for Web Components contains generators for managing Web Component applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Cypress, and Storybook.\n\n- Scaffolding for creating buildable libraries that can be published to npm.\n\n- Utilities for automatic workspace refactoring.",
"root": "/packages/web",
"source": "/packages/web/src",

View File

@ -1,6 +1,7 @@
{
"githubRoot": "https://github.com/nrwl/nx/blob/master",
"name": "workspace",
"packageName": "@nrwl/workspace",
"description": "Smart, Fast and Extensible Build System.",
"root": "/packages/workspace",
"source": "/packages/workspace/src",

View File

@ -1,11 +1,13 @@
[
{
"name": "add-nx-to-monorepo",
"packageName": "add-nx-to-monorepo",
"path": "generated/packages/add-nx-to-monorepo.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "angular",
"packageName": "angular",
"path": "generated/packages/angular.json",
"schemas": {
"executors": [
@ -51,21 +53,25 @@
},
{
"name": "cra-to-nx",
"packageName": "cra-to-nx",
"path": "generated/packages/cra-to-nx.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "create-nx-plugin",
"packageName": "create-nx-plugin",
"path": "generated/packages/create-nx-plugin.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "create-nx-workspace",
"packageName": "create-nx-workspace",
"path": "generated/packages/create-nx-workspace.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "cypress",
"packageName": "cypress",
"path": "generated/packages/cypress.json",
"schemas": {
"executors": ["cypress"],
@ -79,6 +85,7 @@
},
{
"name": "detox",
"packageName": "detox",
"path": "generated/packages/detox.json",
"schemas": {
"executors": ["build", "test"],
@ -87,26 +94,31 @@
},
{
"name": "devkit",
"packageName": "devkit",
"path": "generated/packages/devkit.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "eslint-plugin-nx",
"packageName": "eslint-plugin-nx",
"path": "generated/packages/eslint-plugin-nx.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "express",
"packageName": "express",
"path": "generated/packages/express.json",
"schemas": { "executors": [], "generators": ["init", "application"] }
},
{
"name": "jest",
"packageName": "jest",
"path": "generated/packages/jest.json",
"schemas": { "executors": ["jest"], "generators": ["init", "jest-project"] }
},
{
"name": "js",
"packageName": "js",
"path": "generated/packages/js.json",
"schemas": {
"executors": ["tsc", "swc", "node"],
@ -115,6 +127,7 @@
},
{
"name": "linter",
"packageName": "linter",
"path": "generated/packages/linter.json",
"schemas": {
"executors": ["lint", "eslint"],
@ -123,11 +136,13 @@
},
{
"name": "make-angular-cli-faster",
"packageName": "make-angular-cli-faster",
"path": "generated/packages/make-angular-cli-faster.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "nest",
"packageName": "nest",
"path": "generated/packages/nest.json",
"schemas": {
"executors": [],
@ -156,6 +171,7 @@
},
{
"name": "next",
"packageName": "next",
"path": "generated/packages/next.json",
"schemas": {
"executors": ["build", "server", "export"],
@ -171,6 +187,7 @@
},
{
"name": "node",
"packageName": "node",
"path": "generated/packages/node.json",
"schemas": {
"executors": ["webpack", "node"],
@ -179,6 +196,7 @@
},
{
"name": "nx",
"packageName": "nx",
"path": "generated/packages/nx.json",
"schemas": {
"executors": ["noop", "run-commands", "run-script"],
@ -187,6 +205,7 @@
},
{
"name": "nx-plugin",
"packageName": "nx-plugin",
"path": "generated/packages/nx-plugin.json",
"schemas": {
"executors": ["e2e"],
@ -202,6 +221,7 @@
},
{
"name": "react",
"packageName": "react",
"path": "generated/packages/react.json",
"schemas": {
"executors": ["module-federation-dev-server"],
@ -226,6 +246,7 @@
},
{
"name": "react-native",
"packageName": "react-native",
"path": "generated/packages/react-native.json",
"schemas": {
"executors": [
@ -252,6 +273,7 @@
},
{
"name": "storybook",
"packageName": "storybook",
"path": "generated/packages/storybook.json",
"schemas": {
"executors": ["storybook", "build"],
@ -265,11 +287,13 @@
},
{
"name": "tao",
"packageName": "tao",
"path": "generated/packages/tao.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "web",
"packageName": "web",
"path": "generated/packages/web.json",
"schemas": {
"executors": ["webpack", "rollup", "dev-server", "file-server"],
@ -278,6 +302,7 @@
},
{
"name": "workspace",
"packageName": "workspace",
"path": "generated/packages/workspace.json",
"schemas": {
"executors": ["run-commands", "counter", "run-script"],

View File

@ -15,6 +15,7 @@ export class PackagesApi {
// packages.json content file
packagesIndex: {
name: string;
packageName: string;
path: string;
schemas: { executors: string[]; generators: string[] };
}[];
@ -76,6 +77,7 @@ export class PackagesApi {
itemList: this.options.packagesIndex.map((p) => ({
id: p.name,
name: p.name.replace(/-/gi, ' '),
packageName: p.packageName,
path: `/packages/${p.name}`,
itemList: this.getPackage(p.name)
.documentation.map((d) => ({

View File

@ -1,15 +0,0 @@
/**
* Simple utility to get the public name of a package handling arbitrary use cases
* @param packageName
* @param prefix
*/
export function getPublicPackageName(
packageName: string,
prefix: string = '@nrwl/'
): string {
/**
* Core Nx package is not prefixed by "@nrwl/" on NPM
*/
const isNxCorePackage = packageName === 'nx';
return isNxCorePackage ? packageName : prefix + packageName;
}

View File

@ -10,7 +10,6 @@ import {
} from '@nrwl/nx-dev/models-package';
import { ParsedUrlQuery } from 'querystring';
import { Errors, Example, generateJsonExampleFor } from './examples';
import { getPublicPackageName } from './get-public-package-name';
import { SchemaRequest } from './schema-request.models';
function getReferenceFromQuery(query: string): string {
@ -41,7 +40,7 @@ export function getSchemaViewModel(
return {
schemaMetadata,
packageName: getPublicPackageName(schemaRequest.pkg.name),
packageName: schemaRequest.pkg.packageName,
packageUrl: `/packages/${schemaRequest.pkg.name}`,
schemaGithubUrl: schemaRequest.pkg.githubRoot + schemaMetadata.path,
rootReference: '#',

View File

@ -5,7 +5,6 @@ import { NextSeo } from 'next-seo';
import { useRouter } from 'next/router';
import { ReactNode } from 'react';
import { Breadcrumbs } from '@nrwl/nx-dev/ui-common';
import { getPublicPackageName } from './get-public-package-name';
import { Heading1 } from './ui/headings';
import { PackageReference } from './ui/package-reference';
@ -28,7 +27,7 @@ export function PackageSchemaList({
markdown: ReactNode;
} = {
pkg: {
name: getPublicPackageName(pkg.name),
name: pkg.packageName,
description: pkg.description,
githubUrl: pkg.githubRoot + pkg.root,
id: pkg.name,
@ -43,7 +42,7 @@ export function PackageSchemaList({
},
},
seo: {
title: `${getPublicPackageName(pkg.name)} | Nx`,
title: `${pkg.packageName} | Nx`,
description: pkg.description,
imageUrl: `https://nx.dev/images/open-graph/${router.asPath
.replace('/', '')

View File

@ -3,7 +3,6 @@ import cx from 'classnames';
import { NextSeo } from 'next-seo';
import { useRouter } from 'next/router';
import Content from './content';
import { getPublicPackageName } from './get-public-package-name';
import { getSchemaViewModel, SchemaViewModel } from './get-schema-view-model';
import { SchemaRequest } from './schema-request.models';
@ -21,9 +20,7 @@ export function PackageSchemaViewer({
// Process the request and make available the needed schema information
schema: getSchemaViewModel(router.query, schemaRequest),
seo: {
title: `${getPublicPackageName(schemaRequest.pkg.name)}:${
schemaRequest.schemaName
} | Nx`,
title: `${schemaRequest.pkg.packageName}:${schemaRequest.schemaName} | Nx`,
description:
'Next generation build system with first class monorepo support and powerful integrations.',
imageUrl: `https://nx.dev/images/open-graph/${router.asPath

View File

@ -7,6 +7,7 @@ export interface DocumentData {
export interface DocumentMetadata {
id: string;
name?: string;
packageName?: string;
file?: string;
path?: string;
itemList?: DocumentMetadata[];

View File

@ -7,6 +7,7 @@ import { JsonSchema1 } from './json-schema.models';
export interface PackageMetadata {
githubRoot: string;
name: string;
packageName: string;
description: string;
documentation: {
id: string;

View File

@ -128,10 +128,10 @@ describe('nx-dev: Packages Section', () => {
title: '@nrwl/angular:file-server',
path: '/packages/angular/executors/file-server',
},
{ title: '@nrwl/cra-to-nx', path: '/packages/cra-to-nx' },
{ title: '@nrwl/create-nx-plugin', path: '/packages/create-nx-plugin' },
{ title: 'cra-to-nx', path: '/packages/cra-to-nx' },
{ title: 'create-nx-plugin', path: '/packages/create-nx-plugin' },
{
title: '@nrwl/create-nx-workspace',
title: 'create-nx-workspace',
path: '/packages/create-nx-workspace',
},
{ title: '@nrwl/cypress', path: '/packages/cypress' },
@ -188,7 +188,7 @@ describe('nx-dev: Packages Section', () => {
{ title: '@nrwl/linter', path: '/packages/linter/executors/lint' },
{ title: '@nrwl/linter', path: '/packages/linter/executors/eslint' },
{
title: '@nrwl/make-angular-cli-faster',
title: 'make-angular-cli-faster',
path: '/packages/make-angular-cli-faster',
},
{ title: '@nrwl/nest', path: '/packages/nest' },

View File

@ -11,6 +11,7 @@ const documents: any[] = [
const packages: {
name: string;
packageName: string;
path: string;
schemas: { executors: string[]; generators: string[] };
}[] = readJSONSync('./docs/packages.json');
@ -33,20 +34,20 @@ documents.map((category) => {
packages.map((pkg) => {
data.push({
title: 'Package details',
content: getPublicPackageName(pkg.name),
content: pkg.packageName,
filename: ['packages', pkg.name].join('-'),
});
pkg.schemas.executors.map((schema) => {
data.push({
title: 'Executor details',
content: `${getPublicPackageName(pkg.name)}:${schema}`,
content: `${pkg.packageName}:${schema}`,
filename: ['packages', pkg.name, 'executors', schema].join('-'),
});
});
pkg.schemas.generators.map((schema) => {
data.push({
title: 'Generator details',
content: `${getPublicPackageName(pkg.name)}:${schema}`,
content: `${pkg.packageName}:${schema}`,
filename: ['packages', pkg.name, 'generators', schema].join('-'),
});
});
@ -137,14 +138,3 @@ ensureDir(targetFolder).then(() =>
)
)
);
export function getPublicPackageName(
packageName: string,
prefix: string = '@nrwl/'
): string {
/**
* Core Nx package is not prefixed by "@nrwl/" on NPM
*/
const isNxCorePackage = packageName === 'nx';
return isNxCorePackage ? packageName : prefix + packageName;
}

View File

@ -69,6 +69,7 @@ export function generatePackageSchemas(): Promise<void>[] {
*/
const packageList = packages.map((p) => ({
name: p.name,
packageName: p.name,
path: join('generated', 'packages', p.name + '.json'),
schemas: {
executors: p.executors.map((s) => s.name),

View File

@ -105,6 +105,7 @@ export function getPackageMetadataList(
return {
githubRoot: 'https://github.com/nrwl/nx/blob/master',
name: folderName,
packageName: packageJson.name,
description: packageJson.description,
root: relativeFolderPath,
source: join(relativeFolderPath, '/src'),