feat(core): remove deprecated workspace generator command (#19541)

This commit is contained in:
Craigory Coppola 2023-10-11 23:24:19 -04:00 committed by GitHub
parent c0027de971
commit f10da6e1fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 1 additions and 338 deletions

View File

@ -1,66 +0,0 @@
---
title: 'workspace-generator - CLI command'
description: 'Runs a workspace generator from the tools/generators directory'
---
# workspace-generator
**Deprecated:** Use a local plugin instead. See: https://nx.dev/deprecated/workspace-generators
Runs a workspace generator from the tools/generators directory
## Usage
```shell
nx workspace-generator [generator]
```
Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`.
## Options
### dryRun
Type: `boolean`
Default: `false`
Preview the changes without updating files
### generator
Type: `string`
Name of the generator (e.g., @nx/js:library, library)
### help
Type: `boolean`
Show help
### interactive
Type: `boolean`
Default: `true`
When false disables interactive input prompts for options
### quiet
Type: `boolean`
Hides logs from tree operations (e.g. `CREATE package.json`)
### verbose
Type: `boolean`
Prints additional information about the commands (e.g., stack traces)
### version
Type: `boolean`
Show version number

View File

@ -7582,14 +7582,6 @@
"children": [],
"disableCollapsible": false
},
{
"name": "workspace-generator",
"path": "/nx-api/nx/documents/workspace-generator",
"id": "workspace-generator",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "connect-to-nx-cloud",
"path": "/nx-api/nx/documents/connect-to-nx-cloud",
@ -8782,14 +8774,6 @@
"isExternal": false,
"disableCollapsible": false
},
{
"id": "workspace-generator",
"path": "/nx-api/workspace/generators/workspace-generator",
"name": "workspace-generator",
"children": [],
"isExternal": false,
"disableCollapsible": false
},
{
"id": "run-commands",
"path": "/nx-api/workspace/generators/run-commands",

View File

@ -1686,17 +1686,6 @@
"tags": ["enforce-module-boundaries"],
"originalFilePath": "generated/cli/workspace-lint"
},
"/nx-api/nx/documents/workspace-generator": {
"id": "workspace-generator",
"name": "workspace-generator",
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
"file": "generated/packages/nx/documents/workspace-generator",
"itemList": [],
"isExternal": false,
"path": "/nx-api/nx/documents/workspace-generator",
"tags": [],
"originalFilePath": "generated/cli/workspace-generator"
},
"/nx-api/nx/documents/connect-to-nx-cloud": {
"id": "connect-to-nx-cloud",
"name": "connect-to-nx-cloud",
@ -2830,15 +2819,6 @@
"path": "/nx-api/workspace/generators/new",
"type": "generator"
},
"/nx-api/workspace/generators/workspace-generator": {
"description": "Generates a workspace generator.",
"file": "generated/packages/workspace/generators/workspace-generator.json",
"hidden": false,
"name": "workspace-generator",
"originalFilePath": "/packages/workspace/src/generators/workspace-generator/schema.json",
"path": "/nx-api/workspace/generators/workspace-generator",
"type": "generator"
},
"/nx-api/workspace/generators/run-commands": {
"description": "Generates a target to run any command in the terminal.",
"file": "generated/packages/workspace/generators/run-commands.json",

View File

@ -1667,17 +1667,6 @@
"tags": ["enforce-module-boundaries"],
"originalFilePath": "generated/cli/workspace-lint"
},
{
"id": "workspace-generator",
"name": "workspace-generator",
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
"file": "generated/packages/nx/documents/workspace-generator",
"itemList": [],
"isExternal": false,
"path": "nx/documents/workspace-generator",
"tags": [],
"originalFilePath": "generated/cli/workspace-generator"
},
{
"id": "connect-to-nx-cloud",
"name": "connect-to-nx-cloud",
@ -2798,15 +2787,6 @@
"path": "workspace/generators/new",
"type": "generator"
},
{
"description": "Generates a workspace generator.",
"file": "generated/packages/workspace/generators/workspace-generator.json",
"hidden": false,
"name": "workspace-generator",
"originalFilePath": "/packages/workspace/src/generators/workspace-generator/schema.json",
"path": "workspace/generators/workspace-generator",
"type": "generator"
},
{
"description": "Generates a target to run any command in the terminal.",
"file": "generated/packages/workspace/generators/run-commands.json",

View File

@ -1,66 +0,0 @@
---
title: 'workspace-generator - CLI command'
description: 'Runs a workspace generator from the tools/generators directory'
---
# workspace-generator
**Deprecated:** Use a local plugin instead. See: https://nx.dev/deprecated/workspace-generators
Runs a workspace generator from the tools/generators directory
## Usage
```shell
nx workspace-generator [generator]
```
Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`.
## Options
### dryRun
Type: `boolean`
Default: `false`
Preview the changes without updating files
### generator
Type: `string`
Name of the generator (e.g., @nx/js:library, library)
### help
Type: `boolean`
Show help
### interactive
Type: `boolean`
Default: `true`
When false disables interactive input prompts for options
### quiet
Type: `boolean`
Hides logs from tree operations (e.g. `CREATE package.json`)
### verbose
Type: `boolean`
Prints additional information about the commands (e.g., stack traces)
### version
Type: `boolean`
Show version number

View File

@ -1,20 +0,0 @@
{
"name": "workspace-generator",
"factory": "./src/generators/workspace-generator/workspace-generator",
"schema": {
"cli": "nx",
"$id": "SchematicsNxWorkspaceSchematic",
"title": "Create a custom generator",
"description": "Create a custom generator.",
"type": "object",
"properties": {},
"required": [],
"presets": []
},
"aliases": ["workspace-schematic"],
"description": "Generates a workspace generator.",
"implementation": "/packages/workspace/src/generators/workspace-generator/workspace-generator.ts",
"hidden": false,
"path": "/packages/workspace/src/generators/workspace-generator/schema.json",
"type": "generator"
}

View File

@ -1868,11 +1868,6 @@
"tags": ["enforce-module-boundaries"],
"file": "generated/cli/workspace-lint"
},
{
"name": "workspace-generator",
"id": "workspace-generator",
"file": "generated/cli/workspace-generator"
},
{
"name": "connect-to-nx-cloud",
"id": "connect-to-nx-cloud",

View File

@ -499,7 +499,6 @@
- [report](/nx-api/nx/documents/report)
- [list](/nx-api/nx/documents/list)
- [workspace-lint](/nx-api/nx/documents/workspace-lint)
- [workspace-generator](/nx-api/nx/documents/workspace-generator)
- [connect-to-nx-cloud](/nx-api/nx/documents/connect-to-nx-cloud)
- [reset](/nx-api/nx/documents/reset)
- [repair](/nx-api/nx/documents/repair)
@ -644,7 +643,6 @@
- [remove](/nx-api/workspace/generators/remove)
- [convert-to-monorepo](/nx-api/workspace/generators/convert-to-monorepo)
- [new](/nx-api/workspace/generators/new)
- [workspace-generator](/nx-api/workspace/generators/workspace-generator)
- [run-commands](/nx-api/workspace/generators/run-commands)
- [fix-configuration](/nx-api/workspace/generators/fix-configuration)
- [npm-package](/nx-api/workspace/generators/npm-package)

View File

@ -358,28 +358,6 @@ describe('Nx Plugin', () => {
});
});
describe('workspace-generator', () => {
let custom: string;
it('should work with generate wrapper', () => {
custom = uniq('custom');
const project = uniq('generated-project');
runCLI(`g @nx/plugin:plugin workspace-plugin --no-interactive`);
runCLI(
`g @nx/plugin:generator ${custom} --project workspace-plugin --no-interactive`
);
runCLI(
`workspace-generator ${custom} --name ${project} --no-interactive`
);
expect(() => {
checkFilesExist(
`libs/${project}/src/index.ts`,
`libs/${project}/project.json`
);
});
});
});
describe('--directory', () => {
it('should create a plugin in the specified directory', async () => {
const plugin = uniq('plugin');

View File

@ -17,7 +17,6 @@ const pages: Array<{ title: string; path: string }> = [
{ title: 'report', path: '/cli/report' },
{ title: 'list', path: '/cli/list' },
{ title: 'workspace-lint', path: '/cli/workspace-lint' },
{ title: 'workspace-generator', path: '/cli/workspace-generator' },
{ title: 'connect', path: '/cli/connect-to-nx-cloud' },
{ title: 'reset', path: '/cli/reset' },
{ title: 'Storybook', path: '/storybook/overview-react' },

View File

@ -435,10 +435,6 @@ const pages: Array<{ title: string; path: string }> = [
title: '@nx/workspace:new',
path: '/packages/workspace/generators/new',
},
{
title: '@nx/workspace:workspace-generator',
path: '/packages/workspace/generators/workspace-generator',
},
{
title: '@nx/workspace:run-command',
path: '/packages/workspace/generators/run-commands',

View File

@ -8,8 +8,6 @@ const schemaUrls = {
'/workspace/remove': '/packages/workspace/generators/remove',
'/workspace/run-commands-generator':
'/packages/workspace/generators/run-commands',
'/workspace/workspace-generator':
'/packages/workspace/generators/workspace-generator',
'/workspace/convert-to-nx-project-generator':
'/packages/workspace/generators/convert-to-nx-project',
@ -340,7 +338,6 @@ const cliUrls = {
'/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',
};

View File

@ -225,7 +225,6 @@ export const examples: Record<string, Example[]> = {
'Open the project graph of the workspace in the browser, highlight the projects affected, but exclude project-one and project-two',
},
],
'workspace-generator': [],
list: [
{
command: 'list',

View File

@ -16,23 +16,6 @@ export const yargsGenerateCommand: CommandModule = {
},
};
/**
* @deprecated(v17): Remove `workspace-generator in v17. Use local plugins.
*/
export const yargsWorkspaceGeneratorCommand: CommandModule = {
command: 'workspace-generator [generator]',
describe: 'Runs a workspace generator from the tools/generators directory',
deprecated:
'Use a local plugin instead. See: https://nx.dev/deprecated/workspace-generators',
aliases: ['workspace-schematic [schematic]'],
builder: async (yargs) =>
linkToNxDevAndExamples(withGenerateOptions(yargs), 'workspace-generator'),
handler: async (args) => {
await (await import('./generate')).workspaceGenerators(args);
process.exit(0);
},
};
function withGenerateOptions(yargs: Argv) {
const generatorWillShowHelp =
process.argv[3] && !process.argv[3].startsWith('-');

View File

@ -417,34 +417,3 @@ export async function generate(cwd: string, args: { [k: string]: any }) {
}
});
}
/**
* Wraps `workspace-generator` to invoke `generate`.
*
* @deprecated(v17): Remove `workspace-generator in v17. Use local plugins.
*/
export async function workspaceGenerators(args: Arguments) {
const generator = process.argv.slice(3);
output.warn({
title: `Workspace Generators are no longer supported`,
bodyLines: [
'Instead, Nx now supports executing generators or executors from ',
'local plugins. To run a generator from a local plugin, ',
'use `nx generate` like you would with any other generator.',
'',
'For more information, see: https://nx.dev/deprecated/workspace-generators',
],
});
const nxJson: NxJsonConfiguration = readNxJson();
const collection = nxJson.npmScope
? `@${nxJson.npmScope}/workspace-plugin`
: 'workspace-plugin';
args._ = args._.slice(1);
args.generator = `${collection}:${generator}`;
return generate(process.cwd(), args);
}

View File

@ -21,10 +21,7 @@ import {
yargsFormatCheckCommand,
yargsFormatWriteCommand,
} from './format/command-object';
import {
yargsGenerateCommand,
yargsWorkspaceGeneratorCommand,
} from './generate/command-object';
import { yargsGenerateCommand } from './generate/command-object';
import { yargsInitCommand } from './init/command-object';
import { yargsListCommand } from './list/command-object';
import {
@ -88,7 +85,6 @@ export const commandsObject = yargs
.command(yargsShowCommand)
.command(yargsViewLogsCommand)
.command(yargsWatchCommand)
.command(yargsWorkspaceGeneratorCommand)
.command(yargsWorkspaceLintCommand)
.scriptName('nx')
.help()

View File

@ -19,12 +19,6 @@
"schema": "./src/generators/convert-to-monorepo/schema.json",
"description": "Convert a Nx project to a monorepo."
},
"workspace-generator": {
"factory": "./src/generators/workspace-generator/workspace-generator",
"schema": "./src/generators/workspace-generator/schema.json",
"aliases": ["workspace-schematic"],
"description": "Generates a workspace generator."
},
"run-commands": {
"factory": "./src/generators/run-commands/run-commands#runCommandsSchematic",
"schema": "./src/generators/run-commands/schema.json",
@ -69,12 +63,6 @@
"description": "Create a workspace.",
"hidden": true
},
"workspace-generator": {
"factory": "./src/generators/workspace-generator/workspace-generator",
"schema": "./src/generators/workspace-generator/schema.json",
"aliases": ["workspace-schematic"],
"description": "Generates a workspace generator."
},
"run-commands": {
"factory": "./src/generators/run-commands/run-commands#runCommandsGenerator",
"schema": "./src/generators/run-commands/schema.json",

View File

@ -1 +0,0 @@
export interface Schema {}

View File

@ -1,9 +0,0 @@
{
"cli": "nx",
"$id": "SchematicsNxWorkspaceSchematic",
"title": "Create a custom generator",
"description": "Create a custom generator.",
"type": "object",
"properties": {},
"required": []
}

View File

@ -1,15 +0,0 @@
import { Schema } from './schema';
import { Tree, stripIndents } from '@nx/devkit';
export default async function (host: Tree, schema: Schema) {
const message = stripIndents`Workspace Generators are no longer supported. Instead,
Nx now supports executing generators or executors from local plugins. To get
started, install @nx/plugin and run \`nx g plugin\`.
Afterwards, or if you already have an Nx plugin, you can run
\`nx g generator --project {my-plugin}\` to add a new generator.
For more information, see: https://nx.dev/deprecated/workspace-generators`;
throw new Error(message);
}

View File

@ -7,7 +7,6 @@ import {
GeneratorsJson,
ProjectConfiguration,
stripIndents,
getProjects,
} from '@nx/devkit';
import generator from './move-workspace-generators-to-local-plugin';

View File

@ -11,7 +11,6 @@ import {
readProjectConfiguration,
Tree,
updateJson,
writeJson,
} from '@nx/devkit';
// nx-ignore-next-line
import * as path from 'path';