Skip to content

Commit

Permalink
docs(nxdev): move content from cli into nx (nrwl#11085)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcabanes committed Jul 13, 2022
1 parent 9933d91 commit f08d4ab
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 220 deletions.
137 changes: 0 additions & 137 deletions docs/generated/packages/cli.json

This file was deleted.

129 changes: 128 additions & 1 deletion docs/generated/packages/nx.json

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions docs/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,8 @@
"id": "additional-api-references",
"itemList": [
{
"name": "cli",
"id": "cli",
"name": "nx",
"id": "nx",
"itemList": [
{
"name": "create-nx-workspace",
Expand Down Expand Up @@ -946,6 +946,34 @@
}
]
},
{
"name": "Nx Plugin",
"id": "nx-plugin",
"itemList": [
{
"id": "overview",
"name": "Overview",
"path": "/packages/nx-plugin",
"file": "shared/nx-plugin"
}
]
},
{
"name": "Nx Devkit",
"id": "devkit",
"itemList": [
{
"id": "index",
"name": "Overview",
"file": "generated/devkit/index"
},
{
"id": "ngcli_adapter",
"name": "Ng CLI Adapter",
"file": "generated/devkit/ngcli_adapter"
}
]
},
{
"name": "js",
"id": "js",
Expand Down Expand Up @@ -1180,34 +1208,6 @@
"file": "shared/react-native-plugin"
}
]
},
{
"name": "Nx Plugin",
"id": "nx-plugin",
"itemList": [
{
"id": "overview",
"name": "Overview",
"path": "/packages/nx-plugin",
"file": "shared/nx-plugin"
}
]
},
{
"name": "Nx Devkit",
"id": "devkit",
"itemList": [
{
"id": "index",
"name": "Overview",
"file": "generated/devkit/index"
},
{
"id": "ngcli_adapter",
"name": "Ng CLI Adapter",
"file": "generated/devkit/ngcli_adapter"
}
]
}
]
}
Expand Down
5 changes: 0 additions & 5 deletions docs/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@
]
}
},
{
"name": "cli",
"path": "generated/packages/cli.json",
"schemas": { "executors": [], "generators": [] }
},
{
"name": "cra-to-nx",
"path": "generated/packages/cra-to-nx.json",
Expand Down
1 change: 0 additions & 1 deletion nx-dev/nx-dev-e2e/src/integration/packages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ describe('nx-dev: Packages Section', () => {
title: '@nrwl/angular:file-server',
path: '/packages/angular/executors/file-server',
},
{ title: '@nrwl/cli', path: '/packages/cli' },
{ title: '@nrwl/cra-to-nx', path: '/packages/cra-to-nx' },
{ title: '@nrwl/create-nx-plugin', path: '/packages/create-nx-plugin' },
{
Expand Down
8 changes: 8 additions & 0 deletions nx-dev/nx-dev/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ module.exports = withNx({
permanent: true,
});
}
// Api CLI redirection to Nx
for (let s of Object.keys(redirectRules.cliUrls)) {
rules.push({
source: s,
destination: redirectRules.cliUrls[s],
permanent: true,
});
}

// Landing pages
rules.push({
Expand Down
27 changes: 27 additions & 0 deletions nx-dev/nx-dev/redirect-rules.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,38 @@ const overviewUrls = {
'/nx-plugin/overview': '/packages/nx-plugin',
};

/**
* API removing CLI and putting the content into Nx
*/
const cliUrls = {
'/cli/create-nx-workspace': '/nx/create-nx-workspace',
'/cli/generate': '/nx/generate',
'/cli/run': '/nx/run',
'/cli/daemon': '/nx/daemon',
'/cli/dep-graph': '/nx/dep-graph',
'/cli/run-many': '/nx/run-many',
'/cli/affected': '/nx/affected',
'/cli/affected-dep-graph': '/nx/affected-dep-graph',
'/cli/affected-apps': '/nx/affected-apps',
'/cli/affected-libs': '/nx/affected-libs',
'/cli/print-affected': '/nx/print-affected',
'/cli/format-check': '/nx/format-check',
'/cli/format-write': '/nx/format-write',
'/cli/migrate': '/nx/migrate',
'/cli/report': '/nx/report',
'/cli/list': '/nx/list',
'/cli/workspace-lint': '/nx/workspace-lint',
'/cli/workspace-generator': '/nx/workspace-generator',
'/cli/connect-to-nx-cloud': '/nx/connect-to-nx-cloud',
'/cli/reset': '/nx/reset',
};

/**
* Public export API
*/
module.exports = {
schemaUrls,
guideUrls,
overviewUrls,
cliUrls,
};
9 changes: 4 additions & 5 deletions scripts/documentation/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { generatePackageSchemas } from './package-schemas/generatePackageSchemas
async function generate() {
try {
console.log(`${chalk.blue('i')} Generating Documentation`);
generatePackageSchemas();
generateDevkitDocumentation();

const commandsOutputDirectory = join(
__dirname,
Expand All @@ -23,6 +21,9 @@ async function generate() {
await generateCNWocumentation(commandsOutputDirectory);
await generateCLIDocumentation(commandsOutputDirectory);

generateDevkitDocumentation();
await Promise.all(generatePackageSchemas());

console.log(`\n${chalk.green('✓')} Generated Documentation\n`);
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -51,9 +52,7 @@ function checkDocumentation() {
}
}

generate().then(() => {
checkDocumentation();
});
generate().then(() => checkDocumentation());

function printInfo(
str: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ function pathResolver(root: string): (path: string) => string {
return (path) => join(root, path.replace('schema.json', ''));
}

export function generatePackageSchemas(): void {
export function generatePackageSchemas(): Promise<void>[] {
console.log(`${chalk.blue('i')} Generating Package Schemas`);
const absoluteRoot = resolve(join(__dirname, '../../../'));

const packages = getPackageMetadataList(absoluteRoot, 'packages', 'docs').map(
(packageMetadata) => {
const getCurrentSchemaPath = pathResolver(absoluteRoot);
Expand Down Expand Up @@ -79,7 +80,7 @@ export function generatePackageSchemas(): void {
/**
* Generates each package metadata in an `/packages` sub-folder.
*/
packages.forEach(
return packages.map(
(p): Promise<void> =>
generateJsonFile(
join(outputPath, 'generated', 'packages', p.name + '.json'),
Expand Down
83 changes: 44 additions & 39 deletions scripts/documentation/package-schemas/package-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,44 +90,49 @@ export function getPackageMetadataList(
).itemList;

// Do not use map.json, but add a documentation property on the package.json directly that can be easily resolved
return sync(`${packagesDir}/*`).map((folderPath): PackageMetadata => {
const folderName = folderPath.substring(packagesDir.length + 1);
const relativeFolderPath = folderPath.replace(absoluteRoot, '');
const packageJson = readJsonSync(join(folderPath, 'package.json'), 'utf8');
const hasDocumentation = additionalApiReferences.find(
(pkg) => pkg.id === folderName
);
return sync(`${packagesDir}/*`, { ignore: [`${packagesDir}/cli`] }).map(
(folderPath): PackageMetadata => {
const folderName = folderPath.substring(packagesDir.length + 1);
const relativeFolderPath = folderPath.replace(absoluteRoot, '');
const packageJson = readJsonSync(
join(folderPath, 'package.json'),
'utf8'
);
const hasDocumentation = additionalApiReferences.find(
(pkg) => pkg.id === folderName
);

return {
githubRoot: 'https://github.com/nrwl/nx/blob/master',
name: folderName,
description: packageJson.description,
root: relativeFolderPath,
source: join(relativeFolderPath, '/src'),
documentation: !!hasDocumentation
? hasDocumentation.itemList.map((item) => ({
...item,
path: item.path,
file: item.file,
content: readFileSync(join('docs', item.file + '.md'), 'utf8'),
}))
: [],
generators: getSchemaList(
{
absoluteRoot,
folderName,
root: relativeFolderPath,
},
'generators'
),
executors: getSchemaList(
{
absoluteRoot,
folderName,
root: relativeFolderPath,
},
'executors'
),
};
});
return {
githubRoot: 'https://github.com/nrwl/nx/blob/master',
name: folderName,
description: packageJson.description,
root: relativeFolderPath,
source: join(relativeFolderPath, '/src'),
documentation: !!hasDocumentation
? hasDocumentation.itemList.map((item) => ({
...item,
path: item.path,
file: item.file,
content: readFileSync(join('docs', item.file + '.md'), 'utf8'),
}))
: [],
generators: getSchemaList(
{
absoluteRoot,
folderName,
root: relativeFolderPath,
},
'generators'
),
executors: getSchemaList(
{
absoluteRoot,
folderName,
root: relativeFolderPath,
},
'executors'
),
};
}
);
}

0 comments on commit f08d4ab

Please sign in to comment.