docs(core): fix mistakes in @nrwl/workspace usage (#11776)

* docs(core): fix mistakes in @nrwl/workspace usage

@nrwl/workspace docs included a command for generators in the 'nx' package that doesn't contain
generators
update the usage of the 'move' generator to have the usage for the --destination arg

* docs(angular): update examples and add $default for project name
This commit is contained in:
Caleb Ukle 2022-08-30 11:19:33 -05:00 committed by GitHub
parent a04b13dfd7
commit b63893d1cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 12 deletions

View File

@ -1122,7 +1122,7 @@
"type": "object",
"examples": [
{
"command": "nx g @nrwl/angular:move --project my-feature-lib shared/my-feature-lib",
"command": "nx g @nrwl/angular:move --project my-feature-lib --destination shared/my-feature-lib",
"description": "Move libs/my-feature-lib to libs/shared/my-feature-lib."
}
],
@ -1130,7 +1130,8 @@
"projectName": {
"type": "string",
"alias": "project",
"description": "The name of the Angular project to move."
"description": "The name of the Angular project to move.",
"x-dropdown": "projects"
},
"destination": {
"type": "string",

View File

@ -11,7 +11,7 @@
"id": "overview",
"path": "/packages/workspace",
"file": "shared/workspace-plugin",
"content": "The workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.\n\n## Creating Workspace Generators\n\nCodifying your organization's best practices into workspace generators is a great way to ensure that the best practices are easy to follow and implement. Running `nx g @nrwl/workspace:workspace-generator feature` will create a workspace generator which is written the same way generators are written for Nx plugins. The workspace generator can then be run with `nx workspace-generator feature`.\n\n> See more about [workspace generators](/recipe/workspace-generators)\n\n## Reorganizing Projects\n\nAfter some time of working within a workspace, projects might need to be moved or sometimes even removed.\nThe workspace plugin provides the [`@nrwl/workspace:move`](/packages/workspace/generators/move) and [`@nrwl/workspace:remove`](/packages/workspace/generators/remove) generators to help aid with this.\n\n### Moving Projects\n\nRunning `nx g @nrwl/workspace:move new/location/my-lib --projectName my-lib` will move the `my-lib` library to `libs/new/location/my-lib`.\n\nMoving the files manually can be done easily but a lot of steps are often missed when projects are moved. This generator will also handle the following:\n\n1. The project's files will be moved\n2. The project will be renamed to `new-location-my-lib`\n3. The path mapping in `tsconfig.base.json` will be changed to `@npmScope/new/location/my-lib`\n4. Imports in other projects will be changed to `@npmScope/new/location/my-lib`\n5. Paths in target options such as output path will be changed\n6. Other configuration will be updated too, such as `extends` in `tsconfig.json`, the name of the project in `jest.config.js`, and the extends in `.eslintrc.json`\n\n> See more about [`@nrwl/workspace:move`](/packages/workspace/generators/move)\n\n### Removing Projects\n\nRunning `nx g @nrwl/workspace:remove my-lib` will remove the `my-lib` from the workspace. It is important to note that sometimes, projects cannot be removed if they are still depended on by other projects.\n\nLike when moving projects, some steps are often missed when removing projects. This generator will also handle the following:\n\n1. Checks if other projects depend on the project being removed. This can be ignored via the `--forceRemove` flag.\n2. The project's files will be deleted.\n3. The project's configuration will be removed.\n4. The path mapping in `tsconfig.base.json` will be removed.\n\n> See more about [`@nrwl/workspace:remove`](/packages/workspace/generators/remove)\n\n## Running custom commands\n\nExecutors provide an optimized way of running targets but unfortunately, not every target has an executor written for it. The [`nx:run-commands`](/packages/nx/executors/run-commands) executor is an executor that runs any command or multiple commands in the shell. This can be useful when integrating with other tools which do not have an executor provided. There is also a generator to help configure this executor.\n\nRunning `nx g nx:run-commands printhello --project my-feature-lib --command 'echo hello'` will create a `my-feature-lib:printhello` target that executes `echo hello` in the shell.\n\n> See more about [`nx:run-commands`](/packages/nx/executors/run-commands)\n"
"content": "The workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.\n\n## Creating Workspace Generators\n\nCodifying your organization's best practices into workspace generators is a great way to ensure that the best practices are easy to follow and implement. Running `nx g @nrwl/workspace:workspace-generator feature` will create a workspace generator which is written the same way generators are written for Nx plugins. The workspace generator can then be run with `nx workspace-generator feature`.\n\n> See more about [workspace generators](/recipe/workspace-generators)\n\n## Reorganizing Projects\n\nAfter some time of working within a workspace, projects might need to be moved or sometimes even removed.\nThe workspace plugin provides the [`@nrwl/workspace:move`](/packages/workspace/generators/move) and [`@nrwl/workspace:remove`](/packages/workspace/generators/remove) generators to help aid with this.\n\n### Moving Projects\n\nRunning `nx g @nrwl/workspace:move --projectName my-lib --destination new/location/my-lib` will move the `my-lib` library to `libs/new/location/my-lib`.\n\nMoving the files manually can be done easily but a lot of steps are often missed when projects are moved. This generator will also handle the following:\n\n1. The project's files will be moved\n2. The project will be renamed to `new-location-my-lib`\n3. The path mapping in `tsconfig.base.json` will be changed to `@npmScope/new/location/my-lib`\n4. Imports in other projects will be changed to `@npmScope/new/location/my-lib`\n5. Paths in target options such as output path will be changed\n6. Other configuration will be updated too, such as `extends` in `tsconfig.json`, the name of the project in `jest.config.js`, and the extends in `.eslintrc.json`\n\n> See more about [`@nrwl/workspace:move`](/packages/workspace/generators/move)\n\n### Removing Projects\n\nRunning `nx g @nrwl/workspace:remove my-lib` will remove the `my-lib` from the workspace. It is important to note that sometimes, projects cannot be removed if they are still depended on by other projects.\n\nLike when moving projects, some steps are often missed when removing projects. This generator will also handle the following:\n\n1. Checks if other projects depend on the project being removed. This can be ignored via the `--forceRemove` flag.\n2. The project's files will be deleted.\n3. The project's configuration will be removed.\n4. The path mapping in `tsconfig.base.json` will be removed.\n\n> See more about [`@nrwl/workspace:remove`](/packages/workspace/generators/remove)\n\n## Running custom commands\n\nExecutors provide an optimized way of running targets but unfortunately, not every target has an executor written for it. The [`nx:run-commands`](/packages/nx/executors/run-commands) executor is an executor that runs any command or multiple commands in the shell. This can be useful when integrating with other tools which do not have an executor provided. There is also a generator to help configure this executor.\n\nRunning `nx g @nrwl/workspace:run-commands printhello --project my-feature-lib --command 'echo hello'` will create a `my-feature-lib:printhello` target that executes `echo hello` in the shell.\n\n> See more about [`nx:run-commands`](/packages/nx/executors/run-commands)\n"
},
{
"name": "Nx, NodeJS and Typescript Versions",
@ -192,7 +192,7 @@
"type": "object",
"examples": [
{
"command": "nx g @nrwl/workspace:move --project my-feature-lib shared/my-feature-lib",
"command": "nx g @nrwl/workspace:move --project my-feature-lib --destination shared/my-feature-lib",
"description": "Move `libs/my-feature-lib` to `libs/shared/my-feature-lib`"
}
],
@ -200,7 +200,8 @@
"projectName": {
"type": "string",
"alias": "project",
"description": "The name of the project to move."
"description": "The name of the project to move.",
"x-dropdown": "projects"
},
"destination": {
"type": "string",

View File

@ -302,7 +302,7 @@ dist/apps
Now, we can add a simple deploy command to simulate deploying this folder to production.
```bash
nx g nx:run-commands \
nx g @nrwl/workspace:run-commands \
deploy \
--project=host \
--command="rm -rf production && mkdir production && cp -r dist/apps/host/* production && cp -r dist/apps/{shop,cart,about} production && http-server -p 3000 -a localhost production"

View File

@ -13,7 +13,7 @@ The workspace plugin provides the [`@nrwl/workspace:move`](/packages/workspace/g
### Moving Projects
Running `nx g @nrwl/workspace:move new/location/my-lib --projectName my-lib` will move the `my-lib` library to `libs/new/location/my-lib`.
Running `nx g @nrwl/workspace:move --projectName my-lib --destination new/location/my-lib` will move the `my-lib` library to `libs/new/location/my-lib`.
Moving the files manually can be done easily but a lot of steps are often missed when projects are moved. This generator will also handle the following:
@ -43,6 +43,6 @@ Like when moving projects, some steps are often missed when removing projects. T
Executors provide an optimized way of running targets but unfortunately, not every target has an executor written for it. The [`nx:run-commands`](/packages/nx/executors/run-commands) executor is an executor that runs any command or multiple commands in the shell. This can be useful when integrating with other tools which do not have an executor provided. There is also a generator to help configure this executor.
Running `nx g nx:run-commands printhello --project my-feature-lib --command 'echo hello'` will create a `my-feature-lib:printhello` target that executes `echo hello` in the shell.
Running `nx g @nrwl/workspace:run-commands printhello --project my-feature-lib --command 'echo hello'` will create a `my-feature-lib:printhello` target that executes `echo hello` in the shell.
> See more about [`nx:run-commands`](/packages/nx/executors/run-commands)

View File

@ -7,7 +7,7 @@
"type": "object",
"examples": [
{
"command": "nx g @nrwl/angular:move --project my-feature-lib shared/my-feature-lib",
"command": "nx g @nrwl/angular:move --project my-feature-lib --destination shared/my-feature-lib",
"description": "Move libs/my-feature-lib to libs/shared/my-feature-lib."
}
],
@ -15,7 +15,8 @@
"projectName": {
"type": "string",
"alias": "project",
"description": "The name of the Angular project to move."
"description": "The name of the Angular project to move.",
"x-dropdown": "projects"
},
"destination": {
"type": "string",

View File

@ -7,7 +7,7 @@
"type": "object",
"examples": [
{
"command": "nx g @nrwl/workspace:move --project my-feature-lib shared/my-feature-lib",
"command": "nx g @nrwl/workspace:move --project my-feature-lib --destination shared/my-feature-lib",
"description": "Move `libs/my-feature-lib` to `libs/shared/my-feature-lib`"
}
],
@ -15,7 +15,8 @@
"projectName": {
"type": "string",
"alias": "project",
"description": "The name of the project to move."
"description": "The name of the project to move.",
"x-dropdown": "projects"
},
"destination": {
"type": "string",