diff --git a/docs/generated/packages/angular/generators/application.json b/docs/generated/packages/angular/generators/application.json index aba0a20dc87dd..27845a6855f38 100644 --- a/docs/generated/packages/angular/generators/application.json +++ b/docs/generated/packages/angular/generators/application.json @@ -181,7 +181,7 @@ }, "additionalProperties": false, "required": ["directory"], - "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Application\" %}\n\nCreate an application named `my-app`:\n\n```bash\nnx g @nx/angular:application apps/my-app\n```\n\n{% /tab %}\n\n{% tab label=\"Specify directory and style extension\" %}\n\nCreate an application named `my-app` in the `my-dir` directory and use `scss` for styles:\n\n{% callout type=\"note\" title=\"Directory Flag Behavior Changes\" %}\nThe command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=my-dir`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details.\n{% /callout %}\n\n```bash\nnx g @nx/angular:app my-dir/my-app --style=scss\n```\n\n{% /tab %}\n\n{% tab label=\"Single File Components application\" %}\n\nCreate an application with Single File Components (inline styles and inline templates):\n\n```bash\nnx g @nx/angular:app apps/my-app --inlineStyle --inlineTemplate\n```\n\n{% /tab %}\n\n{% tab label=\"Set custom prefix and tags\" %}\n\nSet the prefix to apply to generated selectors and add tags to the application (used for linting).\n\n```bash\nnx g @nx/angular:app apps/my-app --prefix=admin --tags=scope:admin,type:ui\n```\n\n{% /tab %}\n{% /tabs %}\n", + "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Application\" %}\n\nCreate an application named `my-app`:\n\n```bash\nnx g @nx/angular:application apps/my-app\n```\n\n{% /tab %}\n\n{% tab label=\"Specify style extension\" %}\n\nCreate an application named `my-app` in the `my-dir` directory and use `scss` for styles:\n\n```bash\nnx g @nx/angular:app my-dir/my-app --style=scss\n```\n\n{% /tab %}\n\n{% tab label=\"Single File Components application\" %}\n\nCreate an application with Single File Components (inline styles and inline templates):\n\n```bash\nnx g @nx/angular:app apps/my-app --inlineStyle --inlineTemplate\n```\n\n{% /tab %}\n\n{% tab label=\"Set custom prefix and tags\" %}\n\nSet the prefix to apply to generated selectors and add tags to the application (used for linting).\n\n```bash\nnx g @nx/angular:app apps/my-app --prefix=admin --tags=scope:admin,type:ui\n```\n\n{% /tab %}\n{% /tabs %}\n", "presets": [] }, "aliases": ["app"], diff --git a/docs/generated/packages/angular/generators/component.json b/docs/generated/packages/angular/generators/component.json index be266a909d550..bea59dcc8c6e3 100644 --- a/docs/generated/packages/angular/generators/component.json +++ b/docs/generated/packages/angular/generators/component.json @@ -12,14 +12,13 @@ "properties": { "path": { "type": "string", - "description": "The path at which to create the component file, relative to the workspace root. By default, it is set to the root of the project.", + "description": "The file path to the component without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where to create the component?" + "x-prompt": "What is the component file path?" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "prefix": { "type": "string", @@ -113,7 +112,7 @@ } }, "required": ["path"], - "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Component\" %}\n\nCreate a component named `my-component`:\n\n```bash\nnx g @nx/angular:component apps/my-app/src/lib/my-component/my-component\n```\n\n{% /tab %}\n\n{% tab label=\"Single File Component\" %}\n\nCreate a component named `my-component` with inline styles and inline template:\n\n```bash\nnx g @nx/angular:component apps/my-app/src/lib/my-component/my-component --inlineStyle --inlineTemplate\n```\n\n{% /tab %}\n\n{% tab label=\"Component with OnPush Change Detection Strategy\" %}\n\nCreate a component named `my-component` with OnPush Change Detection Strategy:\n\n```bash\nnx g @nx/angular:component apps/my-app/src/lib/my-component/my-component --changeDetection=OnPush\n```\n\n{% /tab %}\n", + "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Component\" %}\n\nGenerate a component named `MyComponent` at `apps/my-app/src/lib/my-component/my-component.component.ts`:\n\n```bash\nnx g @nx/angular:component apps/my-app/src/lib/my-component/my-component\n```\n\n{% /tab %}\n\n{% tab label=\"With Different Symbol Name\" %}\n\nGenerate a component named `CustomComponent` at `apps/my-app/src/lib/my-component/my-component.component.ts`:\n\n```bash\nnx g @nx/angular:component apps/my-app/src/lib/my-component/my-component --name=custom\n```\n\n{% /tab %}\n\n{% tab label=\"Single File Component\" %}\n\nCreate a component named `my-component` with inline styles and inline template:\n\n```bash\nnx g @nx/angular:component apps/my-app/src/lib/my-component/my-component --inlineStyle --inlineTemplate\n```\n\n{% /tab %}\n\n{% tab label=\"Component with OnPush Change Detection Strategy\" %}\n\nCreate a component named `my-component` with OnPush Change Detection Strategy:\n\n```bash\nnx g @nx/angular:component apps/my-app/src/lib/my-component/my-component --changeDetection=OnPush\n```\n\n{% /tab %}\n", "presets": [] }, "aliases": ["c"], diff --git a/docs/generated/packages/angular/generators/directive.json b/docs/generated/packages/angular/generators/directive.json index e0ec9fd36e1cf..8bf52bce9760c 100644 --- a/docs/generated/packages/angular/generators/directive.json +++ b/docs/generated/packages/angular/generators/directive.json @@ -9,17 +9,26 @@ "type": "object", "description": "Creates a new Angular directive.", "additionalProperties": false, + "examples": [ + { + "description": "Generate a directive with the exported symbol matching the file name. It results in the directive `FooDirective` at `mylib/src/lib/foo.directive.ts`", + "command": "nx g @nx/angular:directive mylib/src/lib/foo" + }, + { + "description": "Generate a directive with the exported symbol different from the file name. It results in the directive `CustomDirective` at `mylib/src/lib/foo.directive.ts`", + "command": "nx g @nx/angular:directive mylib/src/lib/foo --name=custom" + } + ], "properties": { "path": { "type": "string", - "description": "The path at which to create the directive file.", - "x-prompt": "Where to put the directive?", - "$default": { "$source": "argv", "index": 0 } + "description": "The file path to the directive without the file extension and suffix. Relative to the current working directory.", + "$default": { "$source": "argv", "index": 0 }, + "x-prompt": "What is the directive file path?" }, "name": { "type": "string", - "description": "The name of the new directive.", - "x-prompt": "What name would you like to use for the directive?" + "description": "The directive symbol name. Defaults to the last segment of the file path." }, "prefix": { "type": "string", diff --git a/docs/generated/packages/angular/generators/library.json b/docs/generated/packages/angular/generators/library.json index 8ee7fb9dba2dc..cf7318b5024fd 100644 --- a/docs/generated/packages/angular/generators/library.json +++ b/docs/generated/packages/angular/generators/library.json @@ -199,7 +199,7 @@ }, "additionalProperties": false, "required": ["directory"], - "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Library\" %}\n\nCreates the `my-ui-lib` library with an `ui` tag:\n\n```bash\nnx g @nx/angular:library libs/my-ui-lib --tags=ui\n```\n\n{% /tab %}\n\n{% tab label=\"Publishable Library\" %}\n\nCreates the `my-lib` library that can be built producing an output following the Angular Package Format (APF) to be distributed as an NPM package:\n\n```bash\nnx g @nx/angular:library libs/my-lib --publishable --import-path=@my-org/my-lib\n```\n\n{% /tab %}\n\n{% tab label=\"Buildable Library\" %}\n\nCreates the `my-lib` library with support for incremental builds:\n\n```bash\nnx g @nx/angular:library libs/my-lib --buildable\n```\n\n{% /tab %}\n\n{% tab label=\"Nested Folder & Import\"%}\nCreates the `my-lib` library in the `nested` directory and sets the import path to `@myorg/nested/my-lib`:\n\n{% callout type=\"note\" title=\"Directory Flag Behavior Changes\" %}\nThe command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=nested`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details.\n{% /callout %}\n\n```bash\nnx g @nx/angular:library libs/nested/my-lib --importPath=@myorg/nested/my-lib\n```\n\n{% /tab %}\n", + "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Library\" %}\n\nCreates the `my-ui-lib` library with an `ui` tag:\n\n```bash\nnx g @nx/angular:library libs/my-ui-lib --tags=ui\n```\n\n{% /tab %}\n\n{% tab label=\"Publishable Library\" %}\n\nCreates the `my-lib` library that can be built producing an output following the Angular Package Format (APF) to be distributed as an NPM package:\n\n```bash\nnx g @nx/angular:library libs/my-lib --publishable --import-path=@my-org/my-lib\n```\n\n{% /tab %}\n\n{% tab label=\"Buildable Library\" %}\n\nCreates the `my-lib` library with support for incremental builds:\n\n```bash\nnx g @nx/angular:library libs/my-lib --buildable\n```\n\n{% /tab %}\n\n{% tab label=\"Nested Folder & Import\"%}\nCreates the `my-lib` library in the `nested` directory and sets the import path to `@myorg/nested/my-lib`:\n\n```bash\nnx g @nx/angular:library libs/nested/my-lib --importPath=@myorg/nested/my-lib\n```\n\n{% /tab %}\n", "presets": [] }, "aliases": ["lib"], diff --git a/docs/generated/packages/angular/generators/pipe.json b/docs/generated/packages/angular/generators/pipe.json index f661141a1ccfb..8f01183961b94 100644 --- a/docs/generated/packages/angular/generators/pipe.json +++ b/docs/generated/packages/angular/generators/pipe.json @@ -9,17 +9,26 @@ "cli": "nx", "additionalProperties": false, "description": "Creates an Angular pipe.", + "examples": [ + { + "description": "Generate a pipe with the exported symbol matching the file name. It results in the pipe `FooPipe` at `mylib/src/lib/foo.pipe.ts`", + "command": "nx g @nx/angular:pipe mylib/src/lib/foo" + }, + { + "description": "Generate a pipe with the exported symbol different from the file name. It results in the pipe `CustomPipe` at `mylib/src/lib/foo.pipe.ts`", + "command": "nx g @nx/angular:pipe mylib/src/lib/foo --name=custom" + } + ], "properties": { "path": { "type": "string", - "description": "The path at which to create the pipe file, relative to the workspace root.", + "description": "The file path to the pipe without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "What is the path of the new pipe?" + "x-prompt": "What is the pipe file path?" }, "name": { "type": "string", - "description": "The name of the pipe.", - "x-prompt": "What name would you like to use for the pipe?" + "description": "The pipe symbol name. Defaults to the last segment of the file path." }, "skipTests": { "type": "boolean", diff --git a/docs/generated/packages/angular/generators/scam-directive.json b/docs/generated/packages/angular/generators/scam-directive.json index f575915d47df6..b1d5db9ec57dd 100644 --- a/docs/generated/packages/angular/generators/scam-directive.json +++ b/docs/generated/packages/angular/generators/scam-directive.json @@ -9,8 +9,12 @@ "type": "object", "examples": [ { - "command": "nx g @nx/angular:scam-directive my-sample --directory=my-lib/src/lib/my-sample", - "description": "Generate a `MySampleDirective` directive in a `my-sample` folder in the `my-lib` library" + "description": "Generate a directive with the exported symbol matching the file name. It results in the directive `FooDirective` at `mylib/src/lib/foo.directive.ts`", + "command": "nx g @nx/angular:scam-directive mylib/src/lib/foo" + }, + { + "description": "Generate a directive with the exported symbol different from the file name. It results in the directive `CustomDirective` at `mylib/src/lib/foo.directive.ts`", + "command": "nx g @nx/angular:scam-directive mylib/src/lib/foo --name=custom" } ], "description": "Creates a new, generic Angular directive definition in the given or default project.", @@ -18,33 +22,13 @@ "properties": { "path": { "type": "string", - "description": "The path at which to create the SCAM Directive files, relative to the workspace root.", + "description": "The file path to the SCAM directive without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "What is the path of the new directive?" + "x-prompt": "What is the SCAM directive file path?" }, "name": { "type": "string", - "description": "The name of the directive.", - "x-prompt": "What name would you like to use for the directive?", - "x-priority": "important" - }, - "directory": { - "type": "string", - "description": "The directory at which to create the SCAM Directive files. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.", - "aliases": ["dir", "path"], - "x-priority": "important" - }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] - }, - "project": { - "type": "string", - "description": "The name of the project.", - "$default": { "$source": "projectName" }, - "x-dropdown": "projects", - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20." + "description": "The directive symbol name. Defaults to the last segment of the file path." }, "skipTests": { "type": "boolean", @@ -57,12 +41,6 @@ "default": true, "x-priority": "important" }, - "flat": { - "type": "boolean", - "description": "Create the new files at the top level of the current project.", - "default": true, - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20." - }, "selector": { "type": "string", "format": "html-selector", diff --git a/docs/generated/packages/angular/generators/scam-pipe.json b/docs/generated/packages/angular/generators/scam-pipe.json index 89e0c344e8996..a12009cac3964 100644 --- a/docs/generated/packages/angular/generators/scam-pipe.json +++ b/docs/generated/packages/angular/generators/scam-pipe.json @@ -9,8 +9,12 @@ "type": "object", "examples": [ { - "command": "nx g @nx/angular:scam-pipe mylib/src/lib/my-transformation/my-transformation", - "description": "Generates a `MyTransformationPipe` in a `my-transformation` folder in the `my-lib` project" + "description": "Generate a pipe with the exported symbol matching the file name. It results in the pipe `FooPipe` at `mylib/src/lib/foo.pipe.ts`", + "command": "nx g @nx/angular:scam-pipe mylib/src/lib/foo" + }, + { + "description": "Generate a pipe with the exported symbol different from the file name. It results in the pipe `CustomPipe` at `mylib/src/lib/foo.pipe.ts`", + "command": "nx g @nx/angular:scam-pipe mylib/src/lib/foo --name=custom" } ], "description": "Creates a new, generic Angular pipe definition in the given or default project.", @@ -18,15 +22,13 @@ "properties": { "path": { "type": "string", - "description": "The path at which to create the pipe file, relative to the workspace root.", + "description": "The file path to the SCAM pipe without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "What is the path of the new pipe?" + "x-prompt": "What is the SCAM pipe file path?" }, "name": { "type": "string", - "description": "The name of the pipe.", - "x-prompt": "What name would you like to use for the pipe?", - "x-priority": "important" + "description": "The pipe symbol name. Defaults to the last segment of the file path." }, "skipTests": { "type": "boolean", @@ -39,12 +41,6 @@ "default": true, "x-priority": "important" }, - "flat": { - "type": "boolean", - "description": "Create the new files at the top level of the current project.", - "default": true, - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20." - }, "export": { "type": "boolean", "description": "Specifies if the SCAM should be exported from the project's entry point (normally `index.ts`). It only applies to libraries.", diff --git a/docs/generated/packages/angular/generators/scam.json b/docs/generated/packages/angular/generators/scam.json index 6c24321806c95..0bc374ec6e408 100644 --- a/docs/generated/packages/angular/generators/scam.json +++ b/docs/generated/packages/angular/generators/scam.json @@ -9,8 +9,12 @@ "type": "object", "examples": [ { - "command": "nx g @nx/angular:scam my-lib/src/lib/my-sample/my-sample", - "description": "Generate a `MySampleComponent` component in the `my-lib` library." + "description": "Generate a component with the exported symbol matching the file name. It results in the component `FooComponent` at `mylib/src/lib/foo.component.ts`", + "command": "nx g @nx/angular:scam mylib/src/lib/foo" + }, + { + "description": "Generate a component with the exported symbol different from the file name. It results in the component `CustomComponent` at `mylib/src/lib/foo.component.ts`", + "command": "nx g @nx/angular:scam mylib/src/lib/foo --name=custom" } ], "description": "Creates a new Angular SCAM.", @@ -18,14 +22,13 @@ "properties": { "path": { "type": "string", - "description": "The path at which to create the SCAM file, relative to the workspace root.", + "description": "The file path to the SCAM without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "What is the path of the new SCAM?" + "x-prompt": "What is the SCAM file path?" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "displayBlock": { "description": "Specifies if the style will contain `:host { display: block; }`.", diff --git a/docs/generated/packages/esbuild/documents/overview.md b/docs/generated/packages/esbuild/documents/overview.md index 7adb9ddb10766..7ca5e597aa44f 100644 --- a/docs/generated/packages/esbuild/documents/overview.md +++ b/docs/generated/packages/esbuild/documents/overview.md @@ -47,10 +47,6 @@ npm add -D @nx/esbuild ### Creating a new JS library -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - You can add a new library that builds using esbuild with: ```shell diff --git a/docs/generated/packages/expo/generators/application.json b/docs/generated/packages/expo/generators/application.json index 2207ca6aa84d7..7eb94e7915e40 100644 --- a/docs/generated/packages/expo/generators/application.json +++ b/docs/generated/packages/expo/generators/application.json @@ -8,11 +8,11 @@ "description": "Create an Expo Application for Nx.", "examples": [ { - "command": "g @nx/expo:app myapp --directory=nested", + "command": "nx g @nx/expo:app myapp --directory=nested", "description": "Generate apps/nested/myapp" }, { - "command": "g @nx/expo:app myapp --classComponent", + "command": "nx g @nx/expo:app myapp --classComponent", "description": "Use class components instead of functional components" } ], diff --git a/docs/generated/packages/expo/generators/component.json b/docs/generated/packages/expo/generators/component.json index d16cd914ca5a9..e89226db41cc5 100644 --- a/docs/generated/packages/expo/generators/component.json +++ b/docs/generated/packages/expo/generators/component.json @@ -9,26 +9,28 @@ "type": "object", "examples": [ { - "command": "g @nx/expo:component mylib/my-component --name my-component", - "description": "Generate a component in the mylib library" + "description": "Generate a component with the exported symbol matching the file name. It results in the component `Foo` at `mylib/src/foo.tsx`", + "command": "nx g @nx/expo:component mylib/src/foo" }, { - "command": "g @nx/expo:component mylib/my-component --name my-component --classComponent", - "description": "Generate a class component in the mylib library" + "description": "Generate a component with the exported symbol different from the file name. It results in the component `Custom` at `mylib/src/foo.tsx`", + "command": "nx g @nx/expo:component mylib/src/foo --name=custom" + }, + { + "description": "Generate a class component at `mylib/src/foo.tsx`", + "command": "nx g @nx/expo:component mylib/src/foo --classComponent" } ], "properties": { "path": { "type": "string", - "description": "Path where the component will be generated.", + "description": "The file path to the component without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the component be generated?", - "x-priority": "important" + "x-prompt": "What is the component file path?" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "js": { "type": "boolean", diff --git a/docs/generated/packages/expo/generators/library.json b/docs/generated/packages/expo/generators/library.json index ec955911b9797..ce7f139f379e4 100644 --- a/docs/generated/packages/expo/generators/library.json +++ b/docs/generated/packages/expo/generators/library.json @@ -9,7 +9,7 @@ "type": "object", "examples": [ { - "command": "g @nx/expo:lib mylib --directory=myapp", + "command": "nx g @nx/expo:lib mylib --directory=myapp", "description": "Generate libs/myapp/mylib" } ], diff --git a/docs/generated/packages/js/generators/library.json b/docs/generated/packages/js/generators/library.json index 78de6d28cea80..1f15de9846de3 100644 --- a/docs/generated/packages/js/generators/library.json +++ b/docs/generated/packages/js/generators/library.json @@ -138,7 +138,7 @@ } }, "required": ["directory"], - "examplesFile": "---\ntitle: JS library generator examples\ndescription: This page contains examples for the @nx/js:lib generator.\n---\n\nThe `@nx/js:lib` generator will generate a library for you, and it will configure it according to the options you provide.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib\n```\n\nBy default, the library that is generated when you use this executor without passing any options, like the example above, will be a buildable library, using the `@nx/js:tsc` executor as a builder.\n\nYou may configure the tools you want to use to build your library, or bundle it too, by passing the `--bundler` flag. The `--bundler` flag controls the compiler and/or the bundler that will be used to build your library. If you choose `tsc` or `swc`, the result will be a buildable library using either `tsc` or `swc` as the compiler. If you choose `rollup` or `vite`, the result will be a buildable library using `rollup` or `vite` as the bundler. In the case of `rollup`, it will default to the `tsc` compiler. If you choose `esbuild`, you may use the [`esbuildOptions` property](https://esbuild.github.io/api/) in your `project.json` under the `build` target options to specify whether you wish to bundle your library or not.\n\n## Examples\n\n{% tabs %}\n\n{% tab label=\"Buildable with default compiler (tsc)\" %}\n\nGenerate a buildable library using the `@nx/js:tsc` executor. This uses `tsc` as the compiler.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib\n```\n\n{% /tab %}\n\n{% tab label=\"Buildable with SWC compiler\" %}\n\nGenerate a buildable library using [SWC](https://swc.rs) as the compiler. This will use the `@nx/js:swc` executor.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=swc\n```\n\n{% /tab %}\n\n{% tab label=\"Buildable with tsc\" %}\n\nGenerate a buildable library using tsc as the compiler. This will use the `@nx/js:tsc` executor.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=tsc\n```\n\n{% /tab %}\n\n{% tab label=\"Buildable, with Rollup as a bundler\" %}\n\nGenerate a buildable library using [Rollup](https://rollupjs.org) as the bundler. This will use the `@nx/rollup:rollup` executor. It will also use [SWC](https://swc.rs) as the compiler.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=rollup\n```\n\nIf you do not want to use `swc` as the compiler, and want to use the default `babel` compiler, you can do so in your `project.json` under the `build` target options, using the [`compiler` property](/nx-api/rollup/executors/rollup#compiler):\n\n```jsonc {% fileName=\"libs/mylib/project.json\" %}\n\"build\": {\n \"executor\": \"@nx/rollup:rollup\",\n \"options\": {\n //...\n \"compiler\": \"babel\"\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"Buildable, with Vite as a bundler\" %}\n\nGenerate a buildable library using [Vite](https://vitejs.dev/) as the bundler. This will use the `@nx/vite:build` executor.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=vite\n```\n\n{% /tab %}\n\n{% tab label=\"Using ESBuild\" %}\n\nGenerate a buildable library using [ESBuild](https://esbuild.github.io/) as the bundler. This will use the `@nx/esbuild:esbuild` executor.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=esbuild\n```\n\nIf you want to specify whether you want to bundle your library or not, you can do so in your `project.json` under the `build` target options, using the [`esbuildOptions` property](https://esbuild.github.io/api/):\n\n```jsonc {% fileName=\"libs/mylib/project.json\" %}\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n //...\n \"esbuildOptions\": {\n \"bundle\": true\n }\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"Minimal publishing target\" %}\n\nGenerate a **publishable** library with a minimal publishing target. The result will be a buildable library using the `@nx/js:tsc` executor, using `tsc` as the compiler. You can change the compiler or the bundler by passing the `--bundler` flag.\n\n```bash\nnpx nx g lib libs/mylib --publishable\n```\n\n{% /tab %}\n\n{% tab label=\"Using directory flag\" %}\n\nGenerate a library named `mylib` and put it under a directory named `myapp` (`libs/myapp/mylib`)\n\n{% callout type=\"note\" title=\"Directory Flag Behavior Changes\" %}\nThe command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=myapp`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details.\n{% /callout %}\n\n```shell\nnpx nx g lib libs/nested/mylib\n```\n\n{% /tab %}\n\n{% tab label=\"Non-buildable library\" %}\n\nGenerate a non-buildable library.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=none\n```\n\n{% /tab %}\n\n{% /tabs %}\n", + "examplesFile": "---\ntitle: JS library generator examples\ndescription: This page contains examples for the @nx/js:lib generator.\n---\n\nThe `@nx/js:lib` generator will generate a library for you, and it will configure it according to the options you provide.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib\n```\n\nBy default, the library that is generated when you use this executor without passing any options, like the example above, will be a buildable library, using the `@nx/js:tsc` executor as a builder.\n\nYou may configure the tools you want to use to build your library, or bundle it too, by passing the `--bundler` flag. The `--bundler` flag controls the compiler and/or the bundler that will be used to build your library. If you choose `tsc` or `swc`, the result will be a buildable library using either `tsc` or `swc` as the compiler. If you choose `rollup` or `vite`, the result will be a buildable library using `rollup` or `vite` as the bundler. In the case of `rollup`, it will default to the `tsc` compiler. If you choose `esbuild`, you may use the [`esbuildOptions` property](https://esbuild.github.io/api/) in your `project.json` under the `build` target options to specify whether you wish to bundle your library or not.\n\n## Examples\n\n{% tabs %}\n\n{% tab label=\"Buildable with default compiler (tsc)\" %}\n\nGenerate a buildable library using the `@nx/js:tsc` executor. This uses `tsc` as the compiler.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib\n```\n\n{% /tab %}\n\n{% tab label=\"Buildable with SWC compiler\" %}\n\nGenerate a buildable library using [SWC](https://swc.rs) as the compiler. This will use the `@nx/js:swc` executor.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=swc\n```\n\n{% /tab %}\n\n{% tab label=\"Buildable with tsc\" %}\n\nGenerate a buildable library using tsc as the compiler. This will use the `@nx/js:tsc` executor.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=tsc\n```\n\n{% /tab %}\n\n{% tab label=\"Buildable, with Rollup as a bundler\" %}\n\nGenerate a buildable library using [Rollup](https://rollupjs.org) as the bundler. This will use the `@nx/rollup:rollup` executor. It will also use [SWC](https://swc.rs) as the compiler.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=rollup\n```\n\nIf you do not want to use `swc` as the compiler, and want to use the default `babel` compiler, you can do so in your `project.json` under the `build` target options, using the [`compiler` property](/nx-api/rollup/executors/rollup#compiler):\n\n```jsonc {% fileName=\"libs/mylib/project.json\" %}\n\"build\": {\n \"executor\": \"@nx/rollup:rollup\",\n \"options\": {\n //...\n \"compiler\": \"babel\"\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"Buildable, with Vite as a bundler\" %}\n\nGenerate a buildable library using [Vite](https://vitejs.dev/) as the bundler. This will use the `@nx/vite:build` executor.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=vite\n```\n\n{% /tab %}\n\n{% tab label=\"Using ESBuild\" %}\n\nGenerate a buildable library using [ESBuild](https://esbuild.github.io/) as the bundler. This will use the `@nx/esbuild:esbuild` executor.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=esbuild\n```\n\nIf you want to specify whether you want to bundle your library or not, you can do so in your `project.json` under the `build` target options, using the [`esbuildOptions` property](https://esbuild.github.io/api/):\n\n```jsonc {% fileName=\"libs/mylib/project.json\" %}\n\"build\": {\n \"executor\": \"@nx/esbuild:esbuild\",\n \"options\": {\n //...\n \"esbuildOptions\": {\n \"bundle\": true\n }\n }\n}\n```\n\n{% /tab %}\n\n{% tab label=\"Minimal publishing target\" %}\n\nGenerate a **publishable** library with a minimal publishing target. The result will be a buildable library using the `@nx/js:tsc` executor, using `tsc` as the compiler. You can change the compiler or the bundler by passing the `--bundler` flag.\n\n```bash\nnpx nx g lib libs/mylib --publishable\n```\n\n{% /tab %}\n\n{% tab label=\"In a nested directory\" %}\n\nGenerate a library named `mylib` and put it under a directory named `nested` (`libs/nested/mylib`).\n\n```shell\nnpx nx g lib libs/nested/mylib\n```\n\n{% /tab %}\n\n{% tab label=\"Non-buildable library\" %}\n\nGenerate a non-buildable library.\n\n```bash\nnpx nx g @nx/js:lib libs/mylib --bundler=none\n```\n\n{% /tab %}\n\n{% /tabs %}\n", "presets": [] }, "aliases": ["lib"], diff --git a/docs/generated/packages/nest/generators/class.json b/docs/generated/packages/nest/generators/class.json index 10871b75ce26d..8cb77da4265d6 100644 --- a/docs/generated/packages/nest/generators/class.json +++ b/docs/generated/packages/nest/generators/class.json @@ -8,17 +8,18 @@ "description": "Nest Class Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the class `Foo` at `myapp/src/app/foo.ts`", + "command": "nx g @nx/nest:class myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the class will be generated.", + "description": "The file path to the class without the file extension. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the class be generated?" - }, - "name": { - "description": "The name of the class.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the class file path?" }, "skipFormat": { "description": "Skip formatting files.", @@ -32,12 +33,6 @@ "enum": ["jest", "none"], "default": "jest" }, - "flat": { - "description": "Flag to indicate if a directory is created.", - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.", - "type": "boolean", - "default": true - }, "language": { "description": "Nest class language.", "type": "string", diff --git a/docs/generated/packages/nest/generators/controller.json b/docs/generated/packages/nest/generators/controller.json index 1a66a35660415..58c64fccc5b1a 100644 --- a/docs/generated/packages/nest/generators/controller.json +++ b/docs/generated/packages/nest/generators/controller.json @@ -8,17 +8,18 @@ "description": "Nest Controller Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the controller `FooController` at `myapp/src/app/foo.controller.ts`", + "command": "nx g @nx/nest:controller myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the controller will be generated.", + "description": "The file path to the controller without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the controller be generated?" - }, - "name": { - "description": "The name of the controller.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the controller file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/decorator.json b/docs/generated/packages/nest/generators/decorator.json index c5ceade825ed5..218a1b364dc1c 100644 --- a/docs/generated/packages/nest/generators/decorator.json +++ b/docs/generated/packages/nest/generators/decorator.json @@ -8,17 +8,18 @@ "description": "Nest Decorator Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the decorator `Foo` at `myapp/src/app/foo.decorator.ts`", + "command": "nx g @nx/nest:decorator myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the decorator will be generated.", + "description": "The file path to the decorator without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the decorator be generated?" - }, - "name": { - "description": "The name of the decorator.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the decorator file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/filter.json b/docs/generated/packages/nest/generators/filter.json index 2d8bcdb67cf23..02c70a46572f9 100644 --- a/docs/generated/packages/nest/generators/filter.json +++ b/docs/generated/packages/nest/generators/filter.json @@ -8,17 +8,18 @@ "description": "Nest Filter Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the filter `FooFilter` at `myapp/src/app/foo.filter.ts`", + "command": "nx g @nx/nest:filter myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the filter will be generated.", + "description": "The file path to the filter without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the filter be generated?" - }, - "name": { - "description": "The name of the filter.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the filter file path?" }, "skipFormat": { "type": "boolean", diff --git a/docs/generated/packages/nest/generators/gateway.json b/docs/generated/packages/nest/generators/gateway.json index e13b281e47892..54899663ce7b5 100644 --- a/docs/generated/packages/nest/generators/gateway.json +++ b/docs/generated/packages/nest/generators/gateway.json @@ -8,17 +8,18 @@ "description": "Nest Gateway Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the gateway `FooGateway` at `myapp/src/app/foo.gateway.ts`", + "command": "nx g @nx/nest:gateway myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the gateway will be generated.", + "description": "The file path to the gateway without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the gateway be generated?" - }, - "name": { - "description": "The name of the gateway.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the gateway file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/guard.json b/docs/generated/packages/nest/generators/guard.json index 689e354e2c156..4731a5d9a2045 100644 --- a/docs/generated/packages/nest/generators/guard.json +++ b/docs/generated/packages/nest/generators/guard.json @@ -8,17 +8,18 @@ "description": "Nest Guard Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the guard `FooGuard` at `myapp/src/app/foo.guard.ts`", + "command": "nx g @nx/nest:guard myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the guard will be generated.", + "description": "The file path to the guard without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the guard be generated?" - }, - "name": { - "description": "The name of the guard.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the guard file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/interceptor.json b/docs/generated/packages/nest/generators/interceptor.json index f456859882db1..656d5f9ce4fa4 100644 --- a/docs/generated/packages/nest/generators/interceptor.json +++ b/docs/generated/packages/nest/generators/interceptor.json @@ -8,17 +8,18 @@ "description": "Nest Interceptor Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the interceptor `FooInterceptor` at `myapp/src/app/foo.interceptor.ts`", + "command": "nx g @nx/nest:interceptor myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the interceptor will be generated.", + "description": "The file path to the interceptor without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the interceptor be generated?" - }, - "name": { - "description": "The name of the interceptor.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the interceptor file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/interface.json b/docs/generated/packages/nest/generators/interface.json index 0aea7f7a6b399..a9cba7590699c 100644 --- a/docs/generated/packages/nest/generators/interface.json +++ b/docs/generated/packages/nest/generators/interface.json @@ -8,29 +8,24 @@ "description": "Nest Interface Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the interface `Foo` at `myapp/src/app/foo.interface.ts`", + "command": "nx g @nx/nest:interface myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the interface will be generated.", + "description": "The file path to the interface without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the interface be generated?" - }, - "name": { - "description": "The name of the interface.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the interface file path?" }, "skipFormat": { "description": "Skip formatting files.", "type": "boolean", "default": false, "x-priority": "internal" - }, - "flat": { - "description": "Flag to indicate if a directory is created.", - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.", - "type": "boolean", - "default": true } }, "additionalProperties": false, diff --git a/docs/generated/packages/nest/generators/middleware.json b/docs/generated/packages/nest/generators/middleware.json index 52a7e8d3154f3..23bcfd22b9083 100644 --- a/docs/generated/packages/nest/generators/middleware.json +++ b/docs/generated/packages/nest/generators/middleware.json @@ -8,17 +8,18 @@ "description": "Nest Middleware Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the middleware `FooMiddleware` at `myapp/src/app/foo.middleware.ts`", + "command": "nx g @nx/nest:middleware myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the middleware will be generated.", + "description": "The file path to the middleware without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the middleware be generated?" - }, - "name": { - "description": "The name of the middleware.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the middleware file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/module.json b/docs/generated/packages/nest/generators/module.json index 1b9bc2bee58e1..40c3e0aaf07b6 100644 --- a/docs/generated/packages/nest/generators/module.json +++ b/docs/generated/packages/nest/generators/module.json @@ -8,17 +8,18 @@ "description": "Nest Module Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the module `FooModule` at `myapp/src/app/foo.module.ts`", + "command": "nx g @nx/nest:module myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the module will be generated.", + "description": "The file path to the module without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the module be generated?" - }, - "name": { - "description": "The name of the module.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the module file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/pipe.json b/docs/generated/packages/nest/generators/pipe.json index b5c93c8f605be..e35abd415bd78 100644 --- a/docs/generated/packages/nest/generators/pipe.json +++ b/docs/generated/packages/nest/generators/pipe.json @@ -8,17 +8,18 @@ "description": "Nest Pipe Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the pipe `FooPipe` at `myapp/src/app/foo.pipe.ts`", + "command": "nx g @nx/nest:pipe myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the pipe will be generated.", + "description": "The file path to the pipe without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the pipe be generated?" - }, - "name": { - "description": "The name of the pipe.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the pipe file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/provider.json b/docs/generated/packages/nest/generators/provider.json index d4859280945df..afa111b68ef87 100644 --- a/docs/generated/packages/nest/generators/provider.json +++ b/docs/generated/packages/nest/generators/provider.json @@ -8,17 +8,18 @@ "description": "Nest Provider Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the provider `Foo` at `myapp/src/app/foo.ts`", + "command": "nx g @nx/nest:provider myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the provider will be generated.", + "description": "The file path to the provider without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the provider be generated?" - }, - "name": { - "description": "The name of the provider.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the provider file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/resolver.json b/docs/generated/packages/nest/generators/resolver.json index eb3db3d2a2fdb..83aed6442ff14 100644 --- a/docs/generated/packages/nest/generators/resolver.json +++ b/docs/generated/packages/nest/generators/resolver.json @@ -8,17 +8,18 @@ "description": "Nest Resolver Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the resolver `FooResolver` at `myapp/src/app/foo.resolver.ts`", + "command": "nx g @nx/nest:resolver myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the resolver will be generated.", + "description": "The file path to the resolver without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the resolver be generated?" - }, - "name": { - "description": "The name of the resolver.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the resolver file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/resource.json b/docs/generated/packages/nest/generators/resource.json index fedb9bb9fd6aa..083e6135cc869 100644 --- a/docs/generated/packages/nest/generators/resource.json +++ b/docs/generated/packages/nest/generators/resource.json @@ -8,17 +8,18 @@ "description": "Nest Resource Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate `myapp/src/app/entities/foo.entity.ts`, `myapp/src/app/dto/create-foo.dto.ts`, `myapp/src/app/dto/update-foo.dto.ts`, `myapp/src/app/foo.service.ts`, `myapp/src/app/foo.controller.ts`, and `myapp/src/app/foo.module.ts`", + "command": "nx g @nx/nest:resource myapp/src/app/foo" + } + ], "properties": { "path": { "type": "string", - "description": "Path where the resource will be generated.", + "description": "The file path to the resource without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the resource be generated?" - }, - "name": { - "type": "string", - "description": "The name of the resource.", - "x-prompt": "What name would you like to use for this resource (plural, e.g., `users`)?" + "x-prompt": "What is the resource file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/nest/generators/service.json b/docs/generated/packages/nest/generators/service.json index 4c8543e37ccf0..f55e04fbb4d2b 100644 --- a/docs/generated/packages/nest/generators/service.json +++ b/docs/generated/packages/nest/generators/service.json @@ -8,17 +8,18 @@ "description": "Nest Service Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the service `FooService` at `myapp/src/app/foo.service.ts`", + "command": "nx g @nx/nest:service myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the service will be generated.", + "description": "The file path to the service without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the service be generated?" - }, - "name": { - "description": "The name of the service.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the service file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/docs/generated/packages/next/generators/application.json b/docs/generated/packages/next/generators/application.json index 9fdb8144b2d59..f78caf9f89447 100644 --- a/docs/generated/packages/next/generators/application.json +++ b/docs/generated/packages/next/generators/application.json @@ -137,7 +137,7 @@ } }, "required": ["directory"], - "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Create app in a directory\" %}\n\n{% callout type=\"note\" title=\"Directory Flag Behavior Changes\" %}\nThe command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=nested`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details.\n{% /callout %}\n\n```shell\nnx g app apps/nested/myapp\n```\n\n{% /tab %}\n{% tab label=\"Use a custom Express server\" %}\n\n```shell\nnx g app apps/myapp --custom-server\n```\n\n{% /tab %}\n{% tab label=\"Use plain JavaScript (not TypeScript)\" %}\n\n```shell\nnx g app apps/myapp --js\n```\n\n{% /tab %}\n{% /tabs %}\n", + "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Create app in a nested directory\" %}\n\n```shell\nnx g app apps/nested/myapp\n```\n\n{% /tab %}\n{% tab label=\"Use a custom Express server\" %}\n\n```shell\nnx g app apps/myapp --custom-server\n```\n\n{% /tab %}\n{% tab label=\"Use plain JavaScript (not TypeScript)\" %}\n\n```shell\nnx g app apps/myapp --js\n```\n\n{% /tab %}\n{% /tabs %}\n", "presets": [] }, "aliases": ["app"], diff --git a/docs/generated/packages/next/generators/component.json b/docs/generated/packages/next/generators/component.json index 76a55c804db53..be5ecf0e4b594 100644 --- a/docs/generated/packages/next/generators/component.json +++ b/docs/generated/packages/next/generators/component.json @@ -11,16 +11,14 @@ "properties": { "path": { "type": "string", - "description": "Path where the component will be generated.", + "description": "The file path to the component without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the component be generated?", + "x-prompt": "What is the component file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?", - "x-priority": "important" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "style": { "description": "The file extension to be used for style files.", @@ -81,7 +79,7 @@ } }, "required": ["path"], - "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Create an app component\" %}\n\n```shell\nnx g component apps/my-app/src/lib/my-cmp/my-cmp\n```\n\n{% /tab %}\n{% tab label=\"Create a component without its own folder\" %}\n\nRunning the following will create a component under `apps/my-app/components/my-cmp.tsx` rather than `apps/my-app/components/my-cmp/my-cmp.tsx`.\n\n```shell\nnx g component apps/my-app/src/lib/my-cmp\n```\n\n{% /tab %}\n{% tab label=\"Create component in a custom directory\" %}\n\nRunning the following will create a component under `apps/my-app/foo/my-cmp.tsx` rather than `apps/my-app/my-cmp/my-cmp.tsx`.\n\n```shell\nnx g component apps/my-app/foo/my-cmp\n```\n\n{% /tab %}\n{% /tabs %}\n", + "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Create a Component\" %}\n\nGenerate a component named `MyComponent` at `apps/my-app/src/app/my-component/my-component.tsx`:\n\n```shell\nnx g component apps/my-app/src/app/my-component/my-component\n```\n\n{% /tab %}\n{% tab label=\"Create a Component with a Different Symbol Name\" %}\n\nGenerate a component named `Custom` at `apps/my-app/src/app/my-component/my-component.tsx`:\n\n```shell\nnx g component apps/my-app/src/app/my-component/my-component --name=custom\n```\n\n{% /tab %}\n{% /tabs %}\n", "presets": [] }, "description": "Create a component.", diff --git a/docs/generated/packages/next/generators/page.json b/docs/generated/packages/next/generators/page.json index 054554d4b86fb..74f658610d3f9 100644 --- a/docs/generated/packages/next/generators/page.json +++ b/docs/generated/packages/next/generators/page.json @@ -11,16 +11,14 @@ "properties": { "path": { "type": "string", - "description": "Path where the page will be generated.", + "description": "The path to the directory where the page will be generated. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the page be generated?", + "x-prompt": "Which directory do you want to create the page in?", "x-priority": "important" }, "name": { "type": "string", - "description": "The name of the page.", - "x-prompt": "What name would you like to use for the page?", - "x-priority": "important" + "description": "The page symbol name. Defaults to the page directory name." }, "style": { "description": "The file extension to be used for style files.", @@ -73,12 +71,6 @@ "description": "Generate JavaScript files rather than TypeScript files.", "default": false }, - "flat": { - "type": "boolean", - "description": "Create component at the source root rather than its own directory.", - "default": false, - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20." - }, "skipFormat": { "description": "Skip formatting files.", "type": "boolean", @@ -87,7 +79,7 @@ } }, "required": ["path"], - "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Create static page in an app\" %}\n\n```shell\nnx g page apps/my-app/pages/my-page\n```\n\n{% /tab %}\n{% tab label=\"Create dynamic page in an app\" %}\n\nThe following creates a page under `apps/my-app/pages/products/[id].tsx`.\n\n```shell\nnx g page \"apps/my-app/pages/products/[id]\"\n```\n\n{% /tab %}\n\n{% /tabs %}\n", + "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Create a Static Page\" %}\n\nGenerate a static page named `MyPage` at `apps/my-app/pages/my-page/page.tsx`:\n\n```shell\nnx g page apps/my-app/pages/my-page\n```\n\n{% /tab %}\n{% tab label=\"Create a Dynamic Page\" %}\n\nGenerate a dynamic page at `apps/my-app/pages/products/[id]/page.tsx`:\n\n```shell\nnx g page \"apps/my-app/pages/products/[id]\"\n```\n\n{% /tab %}\n\n{% /tabs %}\n", "presets": [] }, "description": "Create a page.", diff --git a/docs/generated/packages/nuxt/generators/application.json b/docs/generated/packages/nuxt/generators/application.json index f13819fe0bea5..16e17b76a4f83 100644 --- a/docs/generated/packages/nuxt/generators/application.json +++ b/docs/generated/packages/nuxt/generators/application.json @@ -100,7 +100,7 @@ } }, "required": ["directory"], - "examplesFile": "---\ntitle: Nuxt application generator examples\ndescription: This page contains examples for the @nx/nuxt:app generator.\n---\n\nYour new Nuxt application will be generated with the following directory structure, following the suggested [directory structure](https://nuxt.com/docs/guide/directory-structure) for Nuxt applications:\n\n```text\nmy-nuxt-app\n├── nuxt.config.ts\n├── project.json\n├── src\n│   ├── app.vue\n│   ├── assets\n│   │   └── css\n│   │   └── styles.css\n│   ├── components\n│   │   └── NxWelcome.vue\n│   ├── pages\n│   │   ├── about.vue\n│   │   └── index.vue\n│   ├── public\n│   │   └── favicon.ico\n│   └── server\n│   ├── api\n│   │   └── greet.ts\n│   └── tsconfig.json\n├── tsconfig.app.json\n├── tsconfig.json\n├── tsconfig.spec.json\n└── vitest.config.ts\n```\n\nYour new app will contain the following:\n\n- Two pages (home and about) under `pages`\n- A component (`NxWelcome`) under `components`\n- A `greet` API endpoint that returns a JSON response under `/api/greet`\n- Configuration for `vitest`\n- Your app's entrypoint (`app.vue`) will contain the navigation links to the home and about pages, and the `nuxt-page` component to display the contents of your pages.\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Create app in a directory\" %}\n\n{% callout type=\"note\" title=\"Directory Flag Behavior Changes\" %}\nThe command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=nested`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details.\n{% /callout %}\n\n```shell\nnx g @nx/nuxt:app =apps/nested/myapp\n```\n\n{% /tab %}\n\n{% tab label=\"Create app with vitest configured\" %}\n\n```shell\nnx g @nx/nuxt:app apps/nested/myapp --unitTestRunner=vitest\n```\n\n{% /tab %}\n\n{% tab label=\"Use plain JavaScript (not TypeScript)\" %}\n\n```shell\nnx g @nx/nuxt:app apps/myapp --js\n```\n\n{% /tab %}\n{% /tabs %}\n\n## Generate pages and components\n\nYou can use the the [`@nx/vue:component` generator](/nx-api/vue/generators/component) to generate new pages and components for your application. You can read more on the [`@nx/vue:component` generator documentation page](/nx-api/vue/generators/component), but here are some examples:\n\n{% tabs %}\n{% tab label=\"New page\" %}\n\n```shell\nnx g @nx/nuxt:component my-app/src/pages/my-page\n```\n\n{% /tab %}\n\n{% tab label=\"New component\" %}\n\n```shell\nnx g @nx/nuxt:component my-app/src/components/my-cmp\n```\n\n{% /tab %}\n{% /tabs %}\n", + "examplesFile": "---\ntitle: Nuxt application generator examples\ndescription: This page contains examples for the @nx/nuxt:app generator.\n---\n\nYour new Nuxt application will be generated with the following directory structure, following the suggested [directory structure](https://nuxt.com/docs/guide/directory-structure) for Nuxt applications:\n\n```text\nmy-nuxt-app\n├── nuxt.config.ts\n├── project.json\n├── src\n│   ├── app.vue\n│   ├── assets\n│   │   └── css\n│   │   └── styles.css\n│   ├── components\n│   │   └── NxWelcome.vue\n│   ├── pages\n│   │   ├── about.vue\n│   │   └── index.vue\n│   ├── public\n│   │   └── favicon.ico\n│   └── server\n│   ├── api\n│   │   └── greet.ts\n│   └── tsconfig.json\n├── tsconfig.app.json\n├── tsconfig.json\n├── tsconfig.spec.json\n└── vitest.config.ts\n```\n\nYour new app will contain the following:\n\n- Two pages (home and about) under `pages`\n- A component (`NxWelcome`) under `components`\n- A `greet` API endpoint that returns a JSON response under `/api/greet`\n- Configuration for `vitest`\n- Your app's entrypoint (`app.vue`) will contain the navigation links to the home and about pages, and the `nuxt-page` component to display the contents of your pages.\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Create app in a nested directory\" %}\n\n```shell\nnx g @nx/nuxt:app apps/nested/myapp\n```\n\n{% /tab %}\n\n{% tab label=\"Create app with vitest configured\" %}\n\n```shell\nnx g @nx/nuxt:app apps/nested/myapp --unitTestRunner=vitest\n```\n\n{% /tab %}\n\n{% tab label=\"Use plain JavaScript (not TypeScript)\" %}\n\n```shell\nnx g @nx/nuxt:app apps/myapp --js\n```\n\n{% /tab %}\n{% /tabs %}\n\n## Generate pages and components\n\nYou can use the the [`@nx/vue:component` generator](/nx-api/vue/generators/component) to generate new pages and components for your application. You can read more on the [`@nx/vue:component` generator documentation page](/nx-api/vue/generators/component), but here are some examples:\n\n{% tabs %}\n{% tab label=\"New page\" %}\n\n```shell\nnx g @nx/nuxt:component my-app/src/pages/my-page\n```\n\n{% /tab %}\n\n{% tab label=\"New component\" %}\n\n```shell\nnx g @nx/nuxt:component my-app/src/components/my-cmp\n```\n\n{% /tab %}\n{% /tabs %}\n", "presets": [] }, "aliases": ["app"], diff --git a/docs/generated/packages/plugin/generators/executor.json b/docs/generated/packages/plugin/generators/executor.json index c4711e983a315..afbc23662ccd6 100644 --- a/docs/generated/packages/plugin/generators/executor.json +++ b/docs/generated/packages/plugin/generators/executor.json @@ -7,27 +7,19 @@ "$id": "NxPluginExecutor", "title": "Create an Executor for an Nx Plugin", "description": "Create an Executor for an Nx Plugin.", - "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Basic executor\" %}\n\nCreate a new executor called `build` inside the plugin `my-plugin`:\n\n```bash\nnx g @nx/plugin:executor tools/my-plugin/src/executors/build\n```\n\n{% /tab %}\n{% tab label=\"With custom hashing\" %}\n\nCreate a new executor called `build` inside the plugin `my-plugin`, that uses a custom hashing function:\n\n```bash\nnx g @nx/plugin:executor tools/my-plugin/src/executors/build --includeHasher\n```\n\n{% /tab %}\n{% /tabs %}\n", + "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Basic executor\" %}\n\nCreate a new executor called `build` at `tools/my-plugin/src/executors/build.ts`:\n\n```bash\nnx g @nx/plugin:executor tools/my-plugin/src/executors/build\n```\n\n{% /tab %}\n{% tab label=\"With different exported name\" %}\n\nCreate a new executor called `custom` at `tools/my-plugin/src/executors/build.ts`:\n\n```bash\nnx g @nx/plugin:executor tools/my-plugin/src/executors/build --name=custom\n```\n\n{% /tab %}\n{% tab label=\"With custom hashing\" %}\n\nCreate a new executor called `build` at `tools/my-plugin/src/executors/build.ts`, that uses a custom hashing function:\n\n```bash\nnx g @nx/plugin:executor tools/my-plugin/src/executors/build --includeHasher\n```\n\n{% /tab %}\n{% /tabs %}\n", "type": "object", - "examples": [ - { - "command": "nx g executor my-executor --project=my-plugin", - "description": "Generate `libs/my-plugin/src/executors/my-executor`" - } - ], "properties": { "path": { "type": "string", - "description": "Path at which to generate the executor file.", - "x-prompt": "What path would you like to use for the executor?", + "description": "The file path to the executor without the file extension. Relative to the current working directory.", + "x-prompt": "What is the executor file path?", "$default": { "$source": "argv", "index": 0 }, "x-priority": "important" }, "name": { "type": "string", - "description": "Executor name.", - "x-prompt": "What name would you like to use for the executor?", - "x-priority": "important" + "description": "The executor name to export in the plugin executors collection." }, "description": { "type": "string", diff --git a/docs/generated/packages/plugin/generators/generator.json b/docs/generated/packages/plugin/generators/generator.json index 140b522e4cfc3..37f5350d58118 100644 --- a/docs/generated/packages/plugin/generators/generator.json +++ b/docs/generated/packages/plugin/generators/generator.json @@ -10,23 +10,25 @@ "type": "object", "examples": [ { - "command": "nx g generator libs/my-plugin/src/generators//my-generator", - "description": "Generate `libs/my-plugin/src/generators/my-generator`" + "description": "Generate a generator exported with the name matching the file name. It results in the generator `foo` at `mylib/src/generators/foo.ts`", + "command": "nx g @nx/plugin:generator mylib/src/generators/foo" + }, + { + "description": "Generate a generator exported with a different name from the file name. It results in the generator `custom` at `mylib/src/generators/foo.ts`", + "command": "nx g @nx/plugin:generator mylib/src/generators/foo --name=custom" } ], "properties": { "path": { "type": "string", - "description": "Path where the generator will be generated.", + "description": "The file path to the generator without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the generator be generated?", + "x-prompt": "What is the generator file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "Generator name.", - "x-prompt": "What name would you like to use for the generator?", - "x-priority": "important" + "description": "The generator name to export in the plugin generators collection." }, "description": { "type": "string", diff --git a/docs/generated/packages/plugin/generators/migration.json b/docs/generated/packages/plugin/generators/migration.json index e79a0dab51186..e86d1e1f0da72 100644 --- a/docs/generated/packages/plugin/generators/migration.json +++ b/docs/generated/packages/plugin/generators/migration.json @@ -10,22 +10,25 @@ "type": "object", "examples": [ { - "command": "nx g migration my-plugin/my-migration --version=1.0.0", - "description": "Adds a new migration inside `my-plugin`, which will be triggered when migrating to version 1.0.0 or above from a previous version." + "description": "Generate a migration exported with the name matching the file name, which will be triggered when migrating to version 1.0.0 or above from a previous version. It results in the migration `foo` at `mylib/src/migrations/foo.ts`", + "command": "nx g @nx/plugin:migration mylib/src/migrations/foo -v=1.0.0" + }, + { + "description": "Generate a migration exported with a different name from the file name, which will be triggered when migrating to version 1.0.0 or above from a previous version. It results in the migration `custom` at `mylib/src/migrations/foo.ts`", + "command": "nx g @nx/plugin:migration mylib/src/migrations/foo --name=custom -v=1.0.0" } ], "properties": { "path": { "type": "string", - "description": "Path where the migration will be generated.", + "description": "The file path to the migration without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the migration be generated?", + "x-prompt": "What is the migration file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "Migration name.", - "x-priority": "important" + "description": "The migration name to export in the plugin migrations collection." }, "description": { "type": "string", diff --git a/docs/generated/packages/react-native/generators/component.json b/docs/generated/packages/react-native/generators/component.json index 22e4f0bbdd068..b8110eae0c65b 100644 --- a/docs/generated/packages/react-native/generators/component.json +++ b/docs/generated/packages/react-native/generators/component.json @@ -10,25 +10,28 @@ "type": "object", "examples": [ { - "command": "nx g @nx/react-native:component mylib/src/lib/my-component/my-component ", - "description": "Generate a component in the `mylib` library" + "description": "Generate a component with the exported symbol matching the file name. It results in the component `Foo` at `mylib/src/lib/foo.tsx`", + "command": "nx g @nx/react-native:component mylib/src/lib/foo" }, { - "command": "nx g @nx/react-native:component mylib/src/lib/my-component/my-component --classComponent", - "description": "Generate a class component in the `mylib` library" + "description": "Generate a component with the exported symbol different from the file name. It results in the component `Custom` at `mylib/src/lib/foo.tsx`", + "command": "nx g @nx/react-native:component mylib/src/lib/foo --name=custom" + }, + { + "description": "Generate a class component at `mylib/src/lib/foo.tsx`", + "command": "nx g @nx/react-native:component mylib/src/lib/foo --classComponent" } ], "properties": { "path": { "type": "string", - "description": "The path at which to create the component file.", + "description": "The file path to the component without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "What path would you like to use for the component?" + "x-prompt": "What is the component file path?" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "js": { "type": "boolean", diff --git a/docs/generated/packages/react/generators/application.json b/docs/generated/packages/react/generators/application.json index 0103fc3d12a2b..4ecfc1f541a6f 100644 --- a/docs/generated/packages/react/generators/application.json +++ b/docs/generated/packages/react/generators/application.json @@ -180,7 +180,7 @@ } }, "required": ["directory"], - "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Application\" %}\n\nCreate an application named `my-app`:\n\n```bash\nnx g @nx/react:application apps/my-app\n```\n\n{% /tab %}\n\n{% tab label=\"Application using Vite as bundler\" %}\n\nCreate an application named `my-app`:\n\n```bash\nnx g @nx/react:app apps/my-app --bundler=vite\n```\n\nWhen choosing `vite` as the bundler, your unit tests will be set up with `vitest`, unless you choose `none` for `unitTestRunner`.\n\n{% /tab %}\n\n{% tab label=\"Specify directory and style extension\" %}\n\nCreate an application named `my-app` in the `my-dir` directory and use `scss` for styles:\n\n{% callout type=\"note\" title=\"Directory Flag Behavior Changes\" %}\nThe command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=my-dir`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details.\n{% /callout %}\n\n```bash\nnx g @nx/react:app apps/my-dir/my-app --style=scss\n```\n\n{% /tab %}\n\n{% tab label=\"Add tags\" %}\n\nAdd tags to the application (used for linting).\n\n```bash\nnx g @nx/react:app apps/my-app --tags=scope:admin,type:ui\n```\n\n{% /tab %}\n{% /tabs %}\n", + "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Application\" %}\n\nCreate an application named `my-app`:\n\n```bash\nnx g @nx/react:application apps/my-app\n```\n\n{% /tab %}\n\n{% tab label=\"Application using Vite as bundler\" %}\n\nCreate an application named `my-app`:\n\n```bash\nnx g @nx/react:app apps/my-app --bundler=vite\n```\n\nWhen choosing `vite` as the bundler, your unit tests will be set up with `vitest`, unless you choose `none` for `unitTestRunner`.\n\n{% /tab %}\n\n{% tab label=\"Specify style extension\" %}\n\nCreate an application named `my-app` in the `my-dir` directory and use `scss` for styles:\n\n```bash\nnx g @nx/react:app apps/my-dir/my-app --style=scss\n```\n\n{% /tab %}\n\n{% tab label=\"Add tags\" %}\n\nAdd tags to the application (used for linting).\n\n```bash\nnx g @nx/react:app apps/my-app --tags=scope:admin,type:ui\n```\n\n{% /tab %}\n{% /tabs %}\n", "presets": [] }, "aliases": ["app"], diff --git a/docs/generated/packages/react/generators/component.json b/docs/generated/packages/react/generators/component.json index 088c160dc0461..53432b4bc212a 100644 --- a/docs/generated/packages/react/generators/component.json +++ b/docs/generated/packages/react/generators/component.json @@ -11,16 +11,14 @@ "properties": { "path": { "type": "string", - "description": "Path where the component will be generated.", + "description": "The file path to the component without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the component be generated?", + "x-prompt": "What is the component file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?", - "x-priority": "important" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "style": { "description": "The file extension to be used for style files.", @@ -106,7 +104,7 @@ } }, "required": ["path"], - "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Component\" %}\n\nCreate a component named `my-component` under the `libs/ui` project:\n\n```shell\nnx g @nx/react:component libs/ui/src/my-component\n```\n\n{% /tab %}\n\n{% tab label=\"Standalone Component\" %}\n\nCreate a class component named `my-component` under the `libs/ui` project:\n\n```shell\nnx g @nx/react:component libs/ui/src/my-component --classComponent\n```\n\n{% /tab %}\n", + "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Component\" %}\n\nCreate a component named `MyComponent` at `libs/ui/src/my-component.tsx`:\n\n```shell\nnx g @nx/react:component libs/ui/src/my-component\n```\n\n{% /tab %}\n\n{% tab label=\"With a Different Symbol Name\" %}\n\nCreate a component named `Custom` at `libs/ui/src/my-component.tsx`:\n\n```shell\nnx g @nx/react:component libs/ui/src/my-component --name=custom\n```\n\n{% /tab %}\n\n{% tab label=\"Class Component\" %}\n\nCreate a class component named `MyComponent` at `libs/ui/src/my-component.tsx`:\n\n```shell\nnx g @nx/react:component libs/ui/src/my-component --classComponent\n```\n\n{% /tab %}\n", "presets": [] }, "description": "Create a React component.", diff --git a/docs/generated/packages/react/generators/hook.json b/docs/generated/packages/react/generators/hook.json index 6eeadd46e52ea..e95adfe3f908d 100644 --- a/docs/generated/packages/react/generators/hook.json +++ b/docs/generated/packages/react/generators/hook.json @@ -10,23 +10,25 @@ "type": "object", "examples": [ { - "command": "nx g hook mylib/my-hook", - "description": "Generate a hook `my-hook` in the `mylib` library" + "description": "Generate a hook with the exported symbol matching the file name. It results in the hook `useFoo` at `mylib/src/lib/foo.ts`", + "command": "nx g @nx/react:hook mylib/src/lib/foo" + }, + { + "description": "Generate a hook with the exported symbol different from the file name. It results in the hook `useCustom` at `mylib/src/lib/foo.ts`", + "command": "nx g @nx/react:hook mylib/src/lib/foo --name=useCustom" } ], "properties": { "path": { "type": "string", - "description": "Path where the hook will be generated.", + "description": "The file path to the hook without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the hook be generated?", + "x-prompt": "What is the hook file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "The name of the hook.", - "x-prompt": "What name would you like to use for the hook?", - "x-priority": "important" + "description": "The hook symbol name. Defaults to the last segment of the file path." }, "js": { "type": "boolean", @@ -39,16 +41,6 @@ "default": false, "x-priority": "internal" }, - "directory": { - "type": "string", - "description": "The directory at which to create the hook file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.", - "x-priority": "important" - }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] - }, "export": { "type": "boolean", "description": "When true, the hook is exported from the project `index.ts` (if it exists).", @@ -57,7 +49,7 @@ "x-prompt": "Should this hook be exported in the project?" } }, - "required": ["name"], + "required": ["path"], "presets": [] }, "description": "Create a hook.", diff --git a/docs/generated/packages/react/generators/redux.json b/docs/generated/packages/react/generators/redux.json index 34ce1a48c94b9..893c4845dc2df 100644 --- a/docs/generated/packages/react/generators/redux.json +++ b/docs/generated/packages/react/generators/redux.json @@ -8,18 +8,27 @@ "title": "Create Redux state", "description": "Create a Redux state slice for a React project.", "type": "object", + "examples": [ + { + "description": "Generate a Redux state slice with the exported symbol matching the file name. It results in the slice `fooSlice` at `mylib/src/lib/foo.slice.ts`", + "command": "nx g @nx/react:redux mylib/src/lib/foo" + }, + { + "description": "Generate a Redux state slice with the exported symbol different from the file name. It results in the slice `customSlice` at `mylib/src/lib/foo.slice.ts`", + "command": "nx g @nx/react:redux mylib/src/lib/foo --name=custom" + } + ], "properties": { "path": { "type": "string", - "description": "Path where the Redux slice will be generated.", + "description": "The file path to the Redux state slice without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the Redux slice be generated?", + "x-prompt": "What is the Redux stateslice file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "Redux slice name.", - "x-priority": "important" + "description": "The Redux state slice symbol name. Defaults to the last segment of the file path." }, "appProject": { "type": "string", diff --git a/docs/generated/packages/remix/documents/overview.md b/docs/generated/packages/remix/documents/overview.md index 15f34303c78bd..59b3b1820e480 100644 --- a/docs/generated/packages/remix/documents/overview.md +++ b/docs/generated/packages/remix/documents/overview.md @@ -84,10 +84,6 @@ npm add -D @nx/remix ## Generate a Remix Application -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```{% command="nx g @nx/remix:app apps/myapp" path="~/acme" %} NX Generating @nx/remix:application diff --git a/docs/generated/packages/remix/generators/action.json b/docs/generated/packages/remix/generators/action.json index 0a65385096053..17bcc13560f2e 100644 --- a/docs/generated/packages/remix/generators/action.json +++ b/docs/generated/packages/remix/generators/action.json @@ -12,11 +12,6 @@ "description": "The route path or path to the filename of the route.", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')" - }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the action in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] } }, "required": ["path"], diff --git a/docs/generated/packages/remix/generators/error-boundary.json b/docs/generated/packages/remix/generators/error-boundary.json index 51f26af095943..1b03eaf4f3b7b 100644 --- a/docs/generated/packages/remix/generators/error-boundary.json +++ b/docs/generated/packages/remix/generators/error-boundary.json @@ -18,11 +18,6 @@ "type": "string", "description": "The path to route file relative to the project root." }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the error boundary in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] - }, "skipFormat": { "type": "boolean", "description": "Skip formatting files after generation.", diff --git a/docs/generated/packages/remix/generators/loader.json b/docs/generated/packages/remix/generators/loader.json index 8624d1c616b02..791db7bb392b2 100644 --- a/docs/generated/packages/remix/generators/loader.json +++ b/docs/generated/packages/remix/generators/loader.json @@ -12,11 +12,6 @@ "description": "The route path or path to the filename of the route.", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')" - }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the loader in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] } }, "required": ["path"], diff --git a/docs/generated/packages/remix/generators/meta.json b/docs/generated/packages/remix/generators/meta.json index d167c5a147381..40c8da32151e5 100644 --- a/docs/generated/packages/remix/generators/meta.json +++ b/docs/generated/packages/remix/generators/meta.json @@ -12,11 +12,6 @@ "description": "The route path or path to the filename of the route.", "$default": { "$source": "argv", "index": 0 }, "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')" - }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the meta function in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] } }, "required": ["path"], diff --git a/docs/generated/packages/vue/generators/application.json b/docs/generated/packages/vue/generators/application.json index 0a194f4fc05dc..70212ea56f8e9 100644 --- a/docs/generated/packages/vue/generators/application.json +++ b/docs/generated/packages/vue/generators/application.json @@ -125,7 +125,7 @@ } }, "required": ["directory"], - "examplesFile": "---\ntitle: Vue application generator examples\ndescription: This page contains examples for the @nx/vue:app generator.\n---\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Simple Application\" %}\n\nCreate an application named `my-app`:\n\n```shell\nnx g @nx/vue:app apps/my-app\n```\n\n{% /tab %}\n\n{% tab label=\"Specify directory and style extension\" %}\n\nCreate an application named `my-app` in the `my-dir` directory and use `scss` for styles:\n\n{% callout type=\"note\" title=\"Directory Flag Behavior Changes\" %}\nThe command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=my-dir`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details.\n{% /callout %}\n\n```shell\nnx g @nx/vue:app apps/my-dir/my-app --style=scss\n```\n\n{% /tab %}\n\n{% tab label=\"Add tags\" %}\n\nAdd tags to the application (used for linting).\n\n```shell\nnx g @nx/vue:app apps/my-app --tags=scope:admin,type:ui\n```\n\n{% /tab %}\n{% /tabs %}\n", + "examplesFile": "---\ntitle: Vue application generator examples\ndescription: This page contains examples for the @nx/vue:app generator.\n---\n\n## Examples\n\n{% tabs %}\n{% tab label=\"Simple Application\" %}\n\nCreate an application named `my-app`:\n\n```shell\nnx g @nx/vue:app apps/my-app\n```\n\n{% /tab %}\n\n{% tab label=\"Specify style extension\" %}\n\nCreate an application named `my-app` in the `my-dir` directory and use `scss` for styles:\n\n```shell\nnx g @nx/vue:app apps/my-dir/my-app --style=scss\n```\n\n{% /tab %}\n\n{% tab label=\"Add tags\" %}\n\nAdd tags to the application (used for linting).\n\n```shell\nnx g @nx/vue:app apps/my-app --tags=scope:admin,type:ui\n```\n\n{% /tab %}\n{% /tabs %}\n", "presets": [] }, "aliases": ["app"], diff --git a/docs/generated/packages/vue/generators/component.json b/docs/generated/packages/vue/generators/component.json index f0c496ae731c3..6eb4e14372287 100644 --- a/docs/generated/packages/vue/generators/component.json +++ b/docs/generated/packages/vue/generators/component.json @@ -10,26 +10,16 @@ "type": "object", "examples": [ { - "command": "nx g @nx/vue:component my-app/src/app/one --name=one --unitTestRunner=vitest", - "description": "Generate a component `one` in the `my-app` application at my-app/src/app/one" - }, - { - "command": "nx g @nx/vue:component my-app/src/app/one", - "description": "Generate a component `one` in the `my-app` application at my-app/src/app/one" + "description": "Generate a component at `mylib/src/lib/foo.vue` with `vitest` as the unit test runner", + "command": "nx g @nx/vue:component mylib/src/lib/foo --unitTestRunner=vitest" } ], "properties": { "path": { "type": "string", - "description": "Path where the component will be generated.", + "description": "The file path to the component without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the component be generated?", - "x-priority": "important" - }, - "name": { - "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?" + "x-prompt": "What is the component file path?" }, "js": { "type": "boolean", diff --git a/docs/generated/packages/web/generators/application.json b/docs/generated/packages/web/generators/application.json index 17ad23a39f77e..6dfd5c1c50007 100644 --- a/docs/generated/packages/web/generators/application.json +++ b/docs/generated/packages/web/generators/application.json @@ -108,7 +108,7 @@ } }, "required": ["directory"], - "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Application\" %}\n\nCreate an application named `my-app`:\n\n```bash\nnx g @nx/web:application apps/my-app\n```\n\n{% /tab %}\n\n{% tab label=\"Application using Vite as bundler\" %}\n\nCreate an application named `my-app`:\n\n```bash\nnx g @nx/web:app apps/my-app --bundler=vite\n```\n\nWhen choosing `vite` as the bundler, your unit tests will be set up with `vitest`, unless you choose `none` for `unitTestRunner`.\n\n{% /tab %}\n\n{% tab label=\"Specify directory\" %}\n\nCreate an application named `my-app` in the `my-dir` directory:\n\n{% callout type=\"note\" title=\"Directory Flag Behavior Changes\" %}\nThe command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=my-dir`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details.\n{% /callout %}\n\n```bash\nnx g @nx/web:app apps/my-dir/my-app\n```\n\n{% /tab %}\n\n{% tab label=\"Add tags\" %}\n\nAdd tags to the application (used for linting).\n\n```bash\nnx g @nx/web:app apps/my-app --tags=scope:admin,type:ui\n```\n\n{% /tab %}\n{% /tabs %}\n", + "examplesFile": "## Examples\n\n{% tabs %}\n{% tab label=\"Simple Application\" %}\n\nCreate an application named `my-app`:\n\n```bash\nnx g @nx/web:application apps/my-app\n```\n\n{% /tab %}\n\n{% tab label=\"Application using Vite as bundler\" %}\n\nCreate an application named `my-app`:\n\n```bash\nnx g @nx/web:app apps/my-app --bundler=vite\n```\n\nWhen choosing `vite` as the bundler, your unit tests will be set up with `vitest`, unless you choose `none` for `unitTestRunner`.\n\n{% /tab %}\n\n{% tab label=\"In a nested directory\" %}\n\nCreate an application named `my-app` in the `my-dir` directory:\n\n```bash\nnx g @nx/web:app apps/my-dir/my-app\n```\n\n{% /tab %}\n\n{% tab label=\"Add tags\" %}\n\nAdd tags to the application (used for linting).\n\n```bash\nnx g @nx/web:app apps/my-app --tags=scope:admin,type:ui\n```\n\n{% /tab %}\n{% /tabs %}\n", "presets": [] }, "aliases": ["app"], diff --git a/docs/shared/guides/remix.md b/docs/shared/guides/remix.md index 60b17b23caac5..090ac5193be25 100644 --- a/docs/shared/guides/remix.md +++ b/docs/shared/guides/remix.md @@ -24,10 +24,6 @@ nx add @nx/remix ## Generate a Remix Application -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```{% command="nx g @nx/remix:app apps/myapp" path="~/acme" %} NX Generating @nx/remix:application diff --git a/docs/shared/guides/setup-incremental-builds-angular.md b/docs/shared/guides/setup-incremental-builds-angular.md index 3efafd8f2be7c..b50579ff9def1 100644 --- a/docs/shared/guides/setup-incremental-builds-angular.md +++ b/docs/shared/guides/setup-incremental-builds-angular.md @@ -7,12 +7,6 @@ applications. To enable incremental builds you need to use buildable libraries. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an -earlier version of Nx or using the `derived` option, omit the `--directory` flag. See -the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - You can generate a new buildable library with: ```shell diff --git a/docs/shared/packages/esbuild/esbuild-plugin.md b/docs/shared/packages/esbuild/esbuild-plugin.md index 7adb9ddb10766..7ca5e597aa44f 100644 --- a/docs/shared/packages/esbuild/esbuild-plugin.md +++ b/docs/shared/packages/esbuild/esbuild-plugin.md @@ -47,10 +47,6 @@ npm add -D @nx/esbuild ### Creating a new JS library -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - You can add a new library that builds using esbuild with: ```shell diff --git a/docs/shared/packages/remix/remix-plugin.md b/docs/shared/packages/remix/remix-plugin.md index 15f34303c78bd..59b3b1820e480 100644 --- a/docs/shared/packages/remix/remix-plugin.md +++ b/docs/shared/packages/remix/remix-plugin.md @@ -84,10 +84,6 @@ npm add -D @nx/remix ## Generate a Remix Application -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```{% command="nx g @nx/remix:app apps/myapp" path="~/acme" %} NX Generating @nx/remix:application diff --git a/docs/shared/recipes/add-stack/add-astro.md b/docs/shared/recipes/add-stack/add-astro.md index 896420c774bfd..8affc1c836451 100644 --- a/docs/shared/recipes/add-stack/add-astro.md +++ b/docs/shared/recipes/add-stack/add-astro.md @@ -88,10 +88,6 @@ nx add @nx/js@ Then generate a project -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```{% command="nx g @nx/js:lib libs/ui --minimal" path="~/astro-app" %} NX Generating @nx/js:library diff --git a/docs/shared/recipes/add-stack/add-dotnet.md b/docs/shared/recipes/add-stack/add-dotnet.md index 0334d7312df73..df053df8ef071 100644 --- a/docs/shared/recipes/add-stack/add-dotnet.md +++ b/docs/shared/recipes/add-stack/add-dotnet.md @@ -119,10 +119,6 @@ This generates the following files: Use the `app` generator to create a new .NET app. For this demo, use the `nx` path naming convention and the `web-api` project template. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g @nx-dotnet/core:app my-api --directory=apps/my-api --test-template nunit --language C# ``` @@ -137,10 +133,6 @@ nx serve my-api To create a new library, run the library generator. Use the `classlib` template. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g @nx-dotnet/core:lib dotnet-lib --directory=libs/dotnet-lib ``` diff --git a/docs/shared/recipes/add-stack/add-express.md b/docs/shared/recipes/add-stack/add-express.md index 2adb5b4f4ab22..f51c3def66953 100644 --- a/docs/shared/recipes/add-stack/add-express.md +++ b/docs/shared/recipes/add-stack/add-express.md @@ -29,10 +29,6 @@ nx add @nx/express Use the `app` generator to create a new Express app. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g @nx/express:app apps/my-express-api ``` @@ -49,10 +45,6 @@ This starts the application on localhost:3333/api by default. The `@nx/express` plugin does not have a `library` generator, but we can use the `library` generator from the `@nx/js` plugin. To create a new library, install the `@nx/js` package and run: -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g @nx/js:lib libs/my-lib ``` diff --git a/docs/shared/recipes/add-stack/add-fastify.md b/docs/shared/recipes/add-stack/add-fastify.md index 16d744190bfe3..3664af134e1f7 100644 --- a/docs/shared/recipes/add-stack/add-fastify.md +++ b/docs/shared/recipes/add-stack/add-fastify.md @@ -42,10 +42,6 @@ nx add @nx/node Use the `app` generator to create a new Fastify app. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g @nx/node:app apps/fastify-api ``` @@ -62,10 +58,6 @@ This starts the application on localhost:3000/api by default. To create a new library, run: -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g @nx/node:lib libs/my-lib ``` diff --git a/docs/shared/recipes/add-stack/add-lit.md b/docs/shared/recipes/add-stack/add-lit.md index 6d9cf4bbecd97..5338e51d23828 100644 --- a/docs/shared/recipes/add-stack/add-lit.md +++ b/docs/shared/recipes/add-stack/add-lit.md @@ -61,10 +61,6 @@ bun add -D lit http-server ## Create an Application -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - We'll start with a node application and then tweak the settings to match what we need. Add a new node application to your workspace with the following command: ```shell @@ -185,10 +181,6 @@ nx serve my-lit-app ## Create a Library -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - Let's create a library that our Lit application is going to consume. To create a new library, install the `@nx/js` package and run: ```shell diff --git a/docs/shared/recipes/add-stack/add-qwik.md b/docs/shared/recipes/add-stack/add-qwik.md index d7c8af225c212..35d841f736142 100644 --- a/docs/shared/recipes/add-stack/add-qwik.md +++ b/docs/shared/recipes/add-stack/add-qwik.md @@ -67,10 +67,6 @@ If you need help finding the version of `nx` you are currently using, run `nx re Let's generate a new application using `qwik-nx`. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g qwik-nx:app todo --directory=apps/todo ``` @@ -79,10 +75,6 @@ nx g qwik-nx:app todo --directory=apps/todo Let's generate a new library using `qwik-nx`. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g qwik-nx:lib data-access --directory=libs/data-access ``` diff --git a/docs/shared/recipes/add-stack/add-rust.md b/docs/shared/recipes/add-stack/add-rust.md index a0e85bf830e74..6e7b17fbf4477 100644 --- a/docs/shared/recipes/add-stack/add-rust.md +++ b/docs/shared/recipes/add-stack/add-rust.md @@ -59,10 +59,6 @@ Using the preset provided by `@monodon/rust` will: Let's generate a new application using `@monodon/rust`. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g @monodon/rust:binary myapp --directory=apps/myapp ``` @@ -71,10 +67,6 @@ nx g @monodon/rust:binary myapp --directory=apps/myapp Let's generate a new library using `@monodon/rust`. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g @monodon/rust:library cats --directory=libs/cats ``` diff --git a/docs/shared/recipes/add-stack/add-solid.md b/docs/shared/recipes/add-stack/add-solid.md index 0f459c7d3c02e..ca56659204ce1 100644 --- a/docs/shared/recipes/add-stack/add-solid.md +++ b/docs/shared/recipes/add-stack/add-solid.md @@ -65,10 +65,6 @@ nx add @nx/web ## Create an Application -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - We'll start with a web application and then tweak the settings to match what we need. Add a new web application to your workspace with the following command: @@ -244,10 +240,6 @@ You can now run `nx serve my-solid-app` and your Solid application can be viewed ## Create a Library -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - Let's create a library that our Solid application is going to consume. To create a new library, install the `@nx/js` package and run: diff --git a/docs/shared/recipes/add-stack/add-svelte.md b/docs/shared/recipes/add-stack/add-svelte.md index f601c84e973fb..b91fa39bd8d45 100644 --- a/docs/shared/recipes/add-stack/add-svelte.md +++ b/docs/shared/recipes/add-stack/add-svelte.md @@ -264,10 +264,6 @@ Navigate to `http://localhost:4200` and you should see your application. Instead of having our Counter directly defined in `App.svelte` file, let's create a library that we can import into our application. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx generate @nx/js:library libs/counter --unitTestRunner=vitest --bundler=vite --importPath=@acme/counter ``` diff --git a/docs/shared/recipes/module-federation/federate-a-module.md b/docs/shared/recipes/module-federation/federate-a-module.md index 3e4f47675bfaa..1d0b0a2a36eeb 100644 --- a/docs/shared/recipes/module-federation/federate-a-module.md +++ b/docs/shared/recipes/module-federation/federate-a-module.md @@ -21,7 +21,7 @@ Since we are using Nx, we will create a library for this module. **Create a library** ```shell -nx generate @nx/js:library hello --unitTestRunner=jest --projectNameAndRootFormat=as-provided +nx generate @nx/js:library hello --unitTestRunner=jest ``` Update the `hello.ts` file with the following code: diff --git a/docs/shared/recipes/storybook/one-storybook-for-all.md b/docs/shared/recipes/storybook/one-storybook-for-all.md index 44a7d66f045f3..cd76d34f3b0b8 100644 --- a/docs/shared/recipes/storybook/one-storybook-for-all.md +++ b/docs/shared/recipes/storybook/one-storybook-for-all.md @@ -20,12 +20,8 @@ Let’s see how we can implement this solution: According to the framework you are using, use the corresponding generator to generate a new library. Let’s suppose that you are using React and all your stories are using the `@storybook/react-vite` framework: -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell -nx g @nx/react:library lib/storybook-host --bundler=none --unitTestRunner=none --projectNameAndRootFormat=as-provided +nx g @nx/react:library lib/storybook-host --bundler=none --unitTestRunner=none ``` Now, you have a new library, which will act as a shell/host for all your stories. diff --git a/docs/shared/recipes/storybook/one-storybook-per-scope.md b/docs/shared/recipes/storybook/one-storybook-per-scope.md index 7ced8c6299cfc..7d6076a816684 100644 --- a/docs/shared/recipes/storybook/one-storybook-per-scope.md +++ b/docs/shared/recipes/storybook/one-storybook-per-scope.md @@ -86,10 +86,6 @@ Let's assume in this case that all our libraries are using Angular. Let's generate three Angular libraries, one for each scope, and let's call them `storybook-host-client`, `storybook-host-admin`, and `storybook-host-shared`. We can do this by running the following commands: -{% callout type="note" title="Directory Flag Behavior Changes" %} -The commands below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g @nx/angular:lib libs/storybook-host-client ``` diff --git a/docs/shared/recipes/storybook/one-storybook-with-composition.md b/docs/shared/recipes/storybook/one-storybook-with-composition.md index 9b789a89d7481..cdde54a956f64 100644 --- a/docs/shared/recipes/storybook/one-storybook-with-composition.md +++ b/docs/shared/recipes/storybook/one-storybook-with-composition.md @@ -28,10 +28,6 @@ We are going to assume that you are at the state where you already have your `st It does not matter which framework you use for the host Storybook library. It can be any framework really, and it does not have to be one of the frameworks that are used in the hosted apps. The only thing that is important is for this host library to have _at least one story_. This is important, or else Storybook will not load. The one story can be a component, for example, which would work like a title for the application, or any other introduction to your Storybook you see fit. -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, omit the `--directory` flag. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - So, let’s use React for the Storybook Composition host library: ```shell diff --git a/packages/angular/docs/application-examples.md b/packages/angular/docs/application-examples.md index a4a8d5956c8db..7128bb0de98c3 100644 --- a/packages/angular/docs/application-examples.md +++ b/packages/angular/docs/application-examples.md @@ -11,14 +11,10 @@ nx g @nx/angular:application apps/my-app {% /tab %} -{% tab label="Specify directory and style extension" %} +{% tab label="Specify style extension" %} Create an application named `my-app` in the `my-dir` directory and use `scss` for styles: -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=my-dir`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```bash nx g @nx/angular:app my-dir/my-app --style=scss ``` diff --git a/packages/angular/docs/component-examples.md b/packages/angular/docs/component-examples.md index 22bc7481ca5a1..08e0ae5a7dbdd 100644 --- a/packages/angular/docs/component-examples.md +++ b/packages/angular/docs/component-examples.md @@ -3,7 +3,7 @@ {% tabs %} {% tab label="Simple Component" %} -Create a component named `my-component`: +Generate a component named `MyComponent` at `apps/my-app/src/lib/my-component/my-component.component.ts`: ```bash nx g @nx/angular:component apps/my-app/src/lib/my-component/my-component @@ -11,6 +11,16 @@ nx g @nx/angular:component apps/my-app/src/lib/my-component/my-component {% /tab %} +{% tab label="With Different Symbol Name" %} + +Generate a component named `CustomComponent` at `apps/my-app/src/lib/my-component/my-component.component.ts`: + +```bash +nx g @nx/angular:component apps/my-app/src/lib/my-component/my-component --name=custom +``` + +{% /tab %} + {% tab label="Single File Component" %} Create a component named `my-component` with inline styles and inline template: diff --git a/packages/angular/docs/library-examples.md b/packages/angular/docs/library-examples.md index ecf6516873281..e43f169ab3642 100644 --- a/packages/angular/docs/library-examples.md +++ b/packages/angular/docs/library-examples.md @@ -34,10 +34,6 @@ nx g @nx/angular:library libs/my-lib --buildable {% tab label="Nested Folder & Import"%} Creates the `my-lib` library in the `nested` directory and sets the import path to `@myorg/nested/my-lib`: -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=nested`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```bash nx g @nx/angular:library libs/nested/my-lib --importPath=@myorg/nested/my-lib ``` diff --git a/packages/angular/src/generators/component/schema.json b/packages/angular/src/generators/component/schema.json index a66a47c47870e..d7e569eb17a30 100644 --- a/packages/angular/src/generators/component/schema.json +++ b/packages/angular/src/generators/component/schema.json @@ -9,17 +9,16 @@ "properties": { "path": { "type": "string", - "description": "The path at which to create the component file, relative to the workspace root. By default, it is set to the root of the project.", + "description": "The file path to the component without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where to create the component?" + "x-prompt": "What is the component file path?" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "prefix": { "type": "string", diff --git a/packages/angular/src/generators/directive/schema.d.ts b/packages/angular/src/generators/directive/schema.d.ts index 3f644baf81f01..29745e8a1dd9c 100644 --- a/packages/angular/src/generators/directive/schema.d.ts +++ b/packages/angular/src/generators/directive/schema.d.ts @@ -1,5 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface Schema { path: string; name?: string; diff --git a/packages/angular/src/generators/directive/schema.json b/packages/angular/src/generators/directive/schema.json index 1a44992cdc35f..28d3e29bae9b8 100644 --- a/packages/angular/src/generators/directive/schema.json +++ b/packages/angular/src/generators/directive/schema.json @@ -6,20 +6,29 @@ "type": "object", "description": "Creates a new Angular directive.", "additionalProperties": false, + "examples": [ + { + "description": "Generate a directive with the exported symbol matching the file name. It results in the directive `FooDirective` at `mylib/src/lib/foo.directive.ts`", + "command": "nx g @nx/angular:directive mylib/src/lib/foo" + }, + { + "description": "Generate a directive with the exported symbol different from the file name. It results in the directive `CustomDirective` at `mylib/src/lib/foo.directive.ts`", + "command": "nx g @nx/angular:directive mylib/src/lib/foo --name=custom" + } + ], "properties": { "path": { "type": "string", - "description": "The path at which to create the directive file.", - "x-prompt": "Where to put the directive?", + "description": "The file path to the directive without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 - } + }, + "x-prompt": "What is the directive file path?" }, "name": { "type": "string", - "description": "The name of the new directive.", - "x-prompt": "What name would you like to use for the directive?" + "description": "The directive symbol name. Defaults to the last segment of the file path." }, "prefix": { "type": "string", diff --git a/packages/angular/src/generators/pipe/schema.d.ts b/packages/angular/src/generators/pipe/schema.d.ts index f9f75543d4af8..15d061553ded5 100644 --- a/packages/angular/src/generators/pipe/schema.d.ts +++ b/packages/angular/src/generators/pipe/schema.d.ts @@ -1,5 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface Schema { path: string; name?: string; diff --git a/packages/angular/src/generators/pipe/schema.json b/packages/angular/src/generators/pipe/schema.json index cb65888a309bd..6698b4fa83eec 100644 --- a/packages/angular/src/generators/pipe/schema.json +++ b/packages/angular/src/generators/pipe/schema.json @@ -6,20 +6,29 @@ "cli": "nx", "additionalProperties": false, "description": "Creates an Angular pipe.", + "examples": [ + { + "description": "Generate a pipe with the exported symbol matching the file name. It results in the pipe `FooPipe` at `mylib/src/lib/foo.pipe.ts`", + "command": "nx g @nx/angular:pipe mylib/src/lib/foo" + }, + { + "description": "Generate a pipe with the exported symbol different from the file name. It results in the pipe `CustomPipe` at `mylib/src/lib/foo.pipe.ts`", + "command": "nx g @nx/angular:pipe mylib/src/lib/foo --name=custom" + } + ], "properties": { "path": { "type": "string", - "description": "The path at which to create the pipe file, relative to the workspace root.", + "description": "The file path to the pipe without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "What is the path of the new pipe?" + "x-prompt": "What is the pipe file path?" }, "name": { "type": "string", - "description": "The name of the pipe.", - "x-prompt": "What name would you like to use for the pipe?" + "description": "The pipe symbol name. Defaults to the last segment of the file path." }, "skipTests": { "type": "boolean", diff --git a/packages/angular/src/generators/scam-directive/schema.d.ts b/packages/angular/src/generators/scam-directive/schema.d.ts index b6e962b00bf46..ed335ab8dff6b 100644 --- a/packages/angular/src/generators/scam-directive/schema.d.ts +++ b/packages/angular/src/generators/scam-directive/schema.d.ts @@ -1,5 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface Schema { path: string; name?: string; diff --git a/packages/angular/src/generators/scam-directive/schema.json b/packages/angular/src/generators/scam-directive/schema.json index 0d3565b3d2554..79ad26713c7e9 100644 --- a/packages/angular/src/generators/scam-directive/schema.json +++ b/packages/angular/src/generators/scam-directive/schema.json @@ -6,8 +6,12 @@ "type": "object", "examples": [ { - "command": "nx g @nx/angular:scam-directive my-sample --directory=my-lib/src/lib/my-sample", - "description": "Generate a `MySampleDirective` directive in a `my-sample` folder in the `my-lib` library" + "description": "Generate a directive with the exported symbol matching the file name. It results in the directive `FooDirective` at `mylib/src/lib/foo.directive.ts`", + "command": "nx g @nx/angular:scam-directive mylib/src/lib/foo" + }, + { + "description": "Generate a directive with the exported symbol different from the file name. It results in the directive `CustomDirective` at `mylib/src/lib/foo.directive.ts`", + "command": "nx g @nx/angular:scam-directive mylib/src/lib/foo --name=custom" } ], "description": "Creates a new, generic Angular directive definition in the given or default project.", @@ -15,38 +19,16 @@ "properties": { "path": { "type": "string", - "description": "The path at which to create the SCAM Directive files, relative to the workspace root.", + "description": "The file path to the SCAM directive without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "What is the path of the new directive?" + "x-prompt": "What is the SCAM directive file path?" }, "name": { "type": "string", - "description": "The name of the directive.", - "x-prompt": "What name would you like to use for the directive?", - "x-priority": "important" - }, - "directory": { - "type": "string", - "description": "The directory at which to create the SCAM Directive files. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.", - "aliases": ["dir", "path"], - "x-priority": "important" - }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] - }, - "project": { - "type": "string", - "description": "The name of the project.", - "$default": { - "$source": "projectName" - }, - "x-dropdown": "projects", - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20." + "description": "The directive symbol name. Defaults to the last segment of the file path." }, "skipTests": { "type": "boolean", @@ -59,12 +41,6 @@ "default": true, "x-priority": "important" }, - "flat": { - "type": "boolean", - "description": "Create the new files at the top level of the current project.", - "default": true, - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20." - }, "selector": { "type": "string", "format": "html-selector", diff --git a/packages/angular/src/generators/scam-pipe/schema.d.ts b/packages/angular/src/generators/scam-pipe/schema.d.ts index 5467debe7f0a5..1d8c717ba8509 100644 --- a/packages/angular/src/generators/scam-pipe/schema.d.ts +++ b/packages/angular/src/generators/scam-pipe/schema.d.ts @@ -1,5 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface Schema { path: string; name?: string; diff --git a/packages/angular/src/generators/scam-pipe/schema.json b/packages/angular/src/generators/scam-pipe/schema.json index 4ad72492c063f..90e0982352cf4 100644 --- a/packages/angular/src/generators/scam-pipe/schema.json +++ b/packages/angular/src/generators/scam-pipe/schema.json @@ -6,8 +6,12 @@ "type": "object", "examples": [ { - "command": "nx g @nx/angular:scam-pipe mylib/src/lib/my-transformation/my-transformation", - "description": "Generates a `MyTransformationPipe` in a `my-transformation` folder in the `my-lib` project" + "description": "Generate a pipe with the exported symbol matching the file name. It results in the pipe `FooPipe` at `mylib/src/lib/foo.pipe.ts`", + "command": "nx g @nx/angular:scam-pipe mylib/src/lib/foo" + }, + { + "description": "Generate a pipe with the exported symbol different from the file name. It results in the pipe `CustomPipe` at `mylib/src/lib/foo.pipe.ts`", + "command": "nx g @nx/angular:scam-pipe mylib/src/lib/foo --name=custom" } ], "description": "Creates a new, generic Angular pipe definition in the given or default project.", @@ -15,18 +19,16 @@ "properties": { "path": { "type": "string", - "description": "The path at which to create the pipe file, relative to the workspace root.", + "description": "The file path to the SCAM pipe without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "What is the path of the new pipe?" + "x-prompt": "What is the SCAM pipe file path?" }, "name": { "type": "string", - "description": "The name of the pipe.", - "x-prompt": "What name would you like to use for the pipe?", - "x-priority": "important" + "description": "The pipe symbol name. Defaults to the last segment of the file path." }, "skipTests": { "type": "boolean", @@ -39,12 +41,6 @@ "default": true, "x-priority": "important" }, - "flat": { - "type": "boolean", - "description": "Create the new files at the top level of the current project.", - "default": true, - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20." - }, "export": { "type": "boolean", "description": "Specifies if the SCAM should be exported from the project's entry point (normally `index.ts`). It only applies to libraries.", diff --git a/packages/angular/src/generators/scam/schema.d.ts b/packages/angular/src/generators/scam/schema.d.ts index 8f5f4a54e9782..621e09425c9f5 100644 --- a/packages/angular/src/generators/scam/schema.d.ts +++ b/packages/angular/src/generators/scam/schema.d.ts @@ -1,5 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface Schema { path: string; name?: string; diff --git a/packages/angular/src/generators/scam/schema.json b/packages/angular/src/generators/scam/schema.json index 92dd8d5cf1c88..2d005a07bac00 100644 --- a/packages/angular/src/generators/scam/schema.json +++ b/packages/angular/src/generators/scam/schema.json @@ -6,8 +6,12 @@ "type": "object", "examples": [ { - "command": "nx g @nx/angular:scam my-lib/src/lib/my-sample/my-sample", - "description": "Generate a `MySampleComponent` component in the `my-lib` library." + "description": "Generate a component with the exported symbol matching the file name. It results in the component `FooComponent` at `mylib/src/lib/foo.component.ts`", + "command": "nx g @nx/angular:scam mylib/src/lib/foo" + }, + { + "description": "Generate a component with the exported symbol different from the file name. It results in the component `CustomComponent` at `mylib/src/lib/foo.component.ts`", + "command": "nx g @nx/angular:scam mylib/src/lib/foo --name=custom" } ], "description": "Creates a new Angular SCAM.", @@ -15,17 +19,16 @@ "properties": { "path": { "type": "string", - "description": "The path at which to create the SCAM file, relative to the workspace root.", + "description": "The file path to the SCAM without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "What is the path of the new SCAM?" + "x-prompt": "What is the SCAM file path?" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "displayBlock": { "description": "Specifies if the style will contain `:host { display: block; }`.", diff --git a/packages/expo/src/generators/application/schema.json b/packages/expo/src/generators/application/schema.json index bbfcb6875fe6e..197f2a7840c05 100644 --- a/packages/expo/src/generators/application/schema.json +++ b/packages/expo/src/generators/application/schema.json @@ -5,11 +5,11 @@ "description": "Create an Expo Application for Nx.", "examples": [ { - "command": "g @nx/expo:app myapp --directory=nested", + "command": "nx g @nx/expo:app myapp --directory=nested", "description": "Generate apps/nested/myapp" }, { - "command": "g @nx/expo:app myapp --classComponent", + "command": "nx g @nx/expo:app myapp --classComponent", "description": "Use class components instead of functional components" } ], diff --git a/packages/expo/src/generators/component/component.spec.ts b/packages/expo/src/generators/component/component.spec.ts index 004cbb2f0566d..bb617cdfadd94 100644 --- a/packages/expo/src/generators/component/component.spec.ts +++ b/packages/expo/src/generators/component/component.spec.ts @@ -19,7 +19,6 @@ describe('component', () => { appTree = createTreeWithEmptyWorkspace(); appTree.write('.gitignore', ''); defaultSchema = { - name: 'hello', path: 'my-lib/src/lib/hello/hello', skipTests: false, export: false, diff --git a/packages/expo/src/generators/component/lib/normalize-options.ts b/packages/expo/src/generators/component/lib/normalize-options.ts index fbf3dc027a48c..25ee293b7b75b 100644 --- a/packages/expo/src/generators/component/lib/normalize-options.ts +++ b/packages/expo/src/generators/component/lib/normalize-options.ts @@ -15,8 +15,6 @@ export async function normalizeOptions( host: Tree, options: Schema ): Promise { - assertValidOptions(options); - const { artifactName: name, fileName, @@ -45,6 +43,7 @@ export async function normalizeOptions( return { ...options, + name, directory, className, fileName, @@ -53,19 +52,3 @@ export async function normalizeOptions( projectName, }; } - -function assertValidOptions(options: Schema) { - const slashes = ['/', '\\']; - slashes.forEach((s) => { - if (options.name.indexOf(s) !== -1) { - const [name, ...rest] = options.name.split(s).reverse(); - let suggestion = rest.map((x) => x.toLowerCase()).join(s); - if (options.path) { - suggestion = `${options.path}${s}${suggestion}`; - } - throw new Error( - `Found "${s}" in the component name. Did you mean to use the --directory option (e.g. \`nx g c ${name} --directory ${suggestion}\`)?` - ); - } - }); -} diff --git a/packages/expo/src/generators/component/schema.d.ts b/packages/expo/src/generators/component/schema.d.ts index 48a5bcfc9b955..09bf7caea01f5 100644 --- a/packages/expo/src/generators/component/schema.d.ts +++ b/packages/expo/src/generators/component/schema.d.ts @@ -9,5 +9,4 @@ export interface Schema { export: boolean; // default is false classComponent: boolean; // default is false js: boolean; // default is false - nameAndDirectoryFormat?: NameAndDirectoryFormat; } diff --git a/packages/expo/src/generators/component/schema.json b/packages/expo/src/generators/component/schema.json index 810e34e8f63ca..4d9ae633828fd 100644 --- a/packages/expo/src/generators/component/schema.json +++ b/packages/expo/src/generators/component/schema.json @@ -6,29 +6,31 @@ "type": "object", "examples": [ { - "command": "g @nx/expo:component mylib/my-component --name my-component", - "description": "Generate a component in the mylib library" + "description": "Generate a component with the exported symbol matching the file name. It results in the component `Foo` at `mylib/src/foo.tsx`", + "command": "nx g @nx/expo:component mylib/src/foo" }, { - "command": "g @nx/expo:component mylib/my-component --name my-component --classComponent", - "description": "Generate a class component in the mylib library" + "description": "Generate a component with the exported symbol different from the file name. It results in the component `Custom` at `mylib/src/foo.tsx`", + "command": "nx g @nx/expo:component mylib/src/foo --name=custom" + }, + { + "description": "Generate a class component at `mylib/src/foo.tsx`", + "command": "nx g @nx/expo:component mylib/src/foo --classComponent" } ], "properties": { "path": { "type": "string", - "description": "Path where the component will be generated.", + "description": "The file path to the component without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the component be generated?", - "x-priority": "important" + "x-prompt": "What is the component file path?" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "js": { "type": "boolean", diff --git a/packages/expo/src/generators/library/schema.json b/packages/expo/src/generators/library/schema.json index 5425019828b83..11c7c50439b39 100644 --- a/packages/expo/src/generators/library/schema.json +++ b/packages/expo/src/generators/library/schema.json @@ -6,7 +6,7 @@ "type": "object", "examples": [ { - "command": "g @nx/expo:lib mylib --directory=myapp", + "command": "nx g @nx/expo:lib mylib --directory=myapp", "description": "Generate libs/myapp/mylib" } ], diff --git a/packages/js/docs/library-examples.md b/packages/js/docs/library-examples.md index 8982810531200..16b68cb3c79ec 100644 --- a/packages/js/docs/library-examples.md +++ b/packages/js/docs/library-examples.md @@ -113,13 +113,9 @@ npx nx g lib libs/mylib --publishable {% /tab %} -{% tab label="Using directory flag" %} +{% tab label="In a nested directory" %} -Generate a library named `mylib` and put it under a directory named `myapp` (`libs/myapp/mylib`) - -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=myapp`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} +Generate a library named `mylib` and put it under a directory named `nested` (`libs/nested/mylib`). ```shell npx nx g lib libs/nested/mylib diff --git a/packages/js/src/generators/library/schema.d.ts b/packages/js/src/generators/library/schema.d.ts index 4112a4445dfe9..e4202f2ba444c 100644 --- a/packages/js/src/generators/library/schema.d.ts +++ b/packages/js/src/generators/library/schema.d.ts @@ -1,7 +1,4 @@ -import type { - ProjectNameAndRootFormat, - ProjectNameAndRootOptions, -} from '@nx/devkit/src/generators/project-name-and-root-utils'; +import type { ProjectNameAndRootOptions } from '@nx/devkit/src/generators/project-name-and-root-utils'; // nx-ignore-next-line const { Linter, LinterType } = require('@nx/eslint'); // use require to import to avoid circular dependency import type { ProjectPackageManagerWorkspaceState } from '../../utils/package-manager-workspaces'; @@ -12,7 +9,6 @@ export type Bundler = 'swc' | 'tsc' | 'rollup' | 'vite' | 'esbuild' | 'none'; export interface LibraryGeneratorSchema { directory: string; name?: string; - projectNameAndRootFormat?: ProjectNameAndRootFormat; skipFormat?: boolean; tags?: string; skipTsConfig?: boolean; diff --git a/packages/nest/src/generators/class/class.spec.ts b/packages/nest/src/generators/class/class.spec.ts index 583f6e0d0685e..efd97588ad073 100644 --- a/packages/nest/src/generators/class/class.spec.ts +++ b/packages/nest/src/generators/class/class.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { ClassGeneratorOptions } from './class'; import { classGenerator } from './class'; describe('class generator', () => { let tree: Tree; - const path = 'api'; - const options: ClassGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - classGenerator(tree, { ...options, path: 'api/test' }) + classGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/class/schema.json b/packages/nest/src/generators/class/schema.json index 85eedcaecc6f6..55188ad976881 100644 --- a/packages/nest/src/generators/class/schema.json +++ b/packages/nest/src/generators/class/schema.json @@ -5,20 +5,21 @@ "description": "Nest Class Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the class `Foo` at `myapp/src/app/foo.ts`", + "command": "nx g @nx/nest:class myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the class will be generated.", + "description": "The file path to the class without the file extension. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the class be generated?" - }, - "name": { - "description": "The name of the class.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the class file path?" }, "skipFormat": { "description": "Skip formatting files.", @@ -32,12 +33,6 @@ "enum": ["jest", "none"], "default": "jest" }, - "flat": { - "description": "Flag to indicate if a directory is created.", - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.", - "type": "boolean", - "default": true - }, "language": { "description": "Nest class language.", "type": "string", diff --git a/packages/nest/src/generators/controller/controller.spec.ts b/packages/nest/src/generators/controller/controller.spec.ts index 1779ace4056fd..e0ddd6a0e2790 100644 --- a/packages/nest/src/generators/controller/controller.spec.ts +++ b/packages/nest/src/generators/controller/controller.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { ControllerGeneratorOptions } from './controller'; import { controllerGenerator } from './controller'; describe('controller generator', () => { let tree: Tree; - const path = 'api'; - const options: ControllerGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - controllerGenerator(tree, { ...options, path: 'api/test' }) + controllerGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/controller/schema.json b/packages/nest/src/generators/controller/schema.json index 38fd1e5c387ee..c583a1627f42c 100644 --- a/packages/nest/src/generators/controller/schema.json +++ b/packages/nest/src/generators/controller/schema.json @@ -5,20 +5,21 @@ "description": "Nest Controller Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the controller `FooController` at `myapp/src/app/foo.controller.ts`", + "command": "nx g @nx/nest:controller myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the controller will be generated.", + "description": "The file path to the controller without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the controller be generated?" - }, - "name": { - "description": "The name of the controller.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the controller file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/decorator/decorator.spec.ts b/packages/nest/src/generators/decorator/decorator.spec.ts index 137f7b74db92e..cf06cf7e9611f 100644 --- a/packages/nest/src/generators/decorator/decorator.spec.ts +++ b/packages/nest/src/generators/decorator/decorator.spec.ts @@ -1,24 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { DecoratorGeneratorOptions } from './decorator'; import { decoratorGenerator } from './decorator'; describe('decorator generator', () => { let tree: Tree; - const path = 'api'; - const options: DecoratorGeneratorOptions = { - name: 'test', - path, - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - decoratorGenerator(tree, { ...options, path: 'api/test' }) + decoratorGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/decorator/schema.json b/packages/nest/src/generators/decorator/schema.json index c92473f7e10ef..bd481761fb0fc 100644 --- a/packages/nest/src/generators/decorator/schema.json +++ b/packages/nest/src/generators/decorator/schema.json @@ -5,20 +5,21 @@ "description": "Nest Decorator Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the decorator `Foo` at `myapp/src/app/foo.decorator.ts`", + "command": "nx g @nx/nest:decorator myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the decorator will be generated.", + "description": "The file path to the decorator without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the decorator be generated?" - }, - "name": { - "description": "The name of the decorator.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the decorator file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/filter/filter.spec.ts b/packages/nest/src/generators/filter/filter.spec.ts index 52525ef08befa..fc419498c38a7 100644 --- a/packages/nest/src/generators/filter/filter.spec.ts +++ b/packages/nest/src/generators/filter/filter.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { FilterGeneratorOptions } from './filter'; import { filterGenerator } from './filter'; describe('filter generator', () => { let tree: Tree; - const path = 'api'; - const options: FilterGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - filterGenerator(tree, { ...options, path: 'api/test' }) + filterGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/filter/schema.json b/packages/nest/src/generators/filter/schema.json index 331ed9ab57776..9ed282afb9d51 100644 --- a/packages/nest/src/generators/filter/schema.json +++ b/packages/nest/src/generators/filter/schema.json @@ -5,20 +5,21 @@ "description": "Nest Filter Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the filter `FooFilter` at `myapp/src/app/foo.filter.ts`", + "command": "nx g @nx/nest:filter myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the filter will be generated.", + "description": "The file path to the filter without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the filter be generated?" - }, - "name": { - "description": "The name of the filter.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the filter file path?" }, "skipFormat": { "type": "boolean", diff --git a/packages/nest/src/generators/gateway/gateway.spec.ts b/packages/nest/src/generators/gateway/gateway.spec.ts index 9d0593173a931..143b08630df41 100644 --- a/packages/nest/src/generators/gateway/gateway.spec.ts +++ b/packages/nest/src/generators/gateway/gateway.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { GatewayGeneratorOptions } from './gateway'; import { gatewayGenerator } from './gateway'; describe('gateway generator', () => { let tree: Tree; - const path = 'api'; - const options: GatewayGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - gatewayGenerator(tree, { ...options, path: 'api/test' }) + gatewayGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/gateway/schema.json b/packages/nest/src/generators/gateway/schema.json index 0e596bc311d32..16550c2fb98a4 100644 --- a/packages/nest/src/generators/gateway/schema.json +++ b/packages/nest/src/generators/gateway/schema.json @@ -5,20 +5,21 @@ "description": "Nest Gateway Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the gateway `FooGateway` at `myapp/src/app/foo.gateway.ts`", + "command": "nx g @nx/nest:gateway myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the gateway will be generated.", + "description": "The file path to the gateway without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the gateway be generated?" - }, - "name": { - "description": "The name of the gateway.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the gateway file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/guard/guard.spec.ts b/packages/nest/src/generators/guard/guard.spec.ts index 23ac6597845eb..8e91182379887 100644 --- a/packages/nest/src/generators/guard/guard.spec.ts +++ b/packages/nest/src/generators/guard/guard.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { GuardGeneratorOptions } from './guard'; import { guardGenerator } from './guard'; describe('guard generator', () => { let tree: Tree; - const path = 'api'; - const options: GuardGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - guardGenerator(tree, { ...options, path: 'api/test' }) + guardGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/guard/schema.json b/packages/nest/src/generators/guard/schema.json index 4a1ef99e4356d..388f8246e3ca6 100644 --- a/packages/nest/src/generators/guard/schema.json +++ b/packages/nest/src/generators/guard/schema.json @@ -5,20 +5,21 @@ "description": "Nest Guard Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the guard `FooGuard` at `myapp/src/app/foo.guard.ts`", + "command": "nx g @nx/nest:guard myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the guard will be generated.", + "description": "The file path to the guard without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the guard be generated?" - }, - "name": { - "description": "The name of the guard.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the guard file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/interceptor/interceptor.spec.ts b/packages/nest/src/generators/interceptor/interceptor.spec.ts index 3c2ff341d5b83..812a102771978 100644 --- a/packages/nest/src/generators/interceptor/interceptor.spec.ts +++ b/packages/nest/src/generators/interceptor/interceptor.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { InterceptorGeneratorOptions } from './interceptor'; import { interceptorGenerator } from './interceptor'; describe('interceptor generator', () => { let tree: Tree; - const path = 'api'; - const options: InterceptorGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - interceptorGenerator(tree, { ...options, path: 'api/test' }) + interceptorGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/interceptor/schema.json b/packages/nest/src/generators/interceptor/schema.json index 20a16606a3d81..21604cc5fbe63 100644 --- a/packages/nest/src/generators/interceptor/schema.json +++ b/packages/nest/src/generators/interceptor/schema.json @@ -5,20 +5,21 @@ "description": "Nest Interceptor Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the interceptor `FooInterceptor` at `myapp/src/app/foo.interceptor.ts`", + "command": "nx g @nx/nest:interceptor myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the interceptor will be generated.", + "description": "The file path to the interceptor without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the interceptor be generated?" - }, - "name": { - "description": "The name of the interceptor.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the interceptor file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/interface/interface.spec.ts b/packages/nest/src/generators/interface/interface.spec.ts index 9dcc54284d444..cdec1233b6c56 100644 --- a/packages/nest/src/generators/interface/interface.spec.ts +++ b/packages/nest/src/generators/interface/interface.spec.ts @@ -1,24 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { InterfaceGeneratorOptions } from './interface'; import { interfaceGenerator } from './interface'; describe('interface generator', () => { let tree: Tree; - const path = 'api'; - const options: InterfaceGeneratorOptions = { - name: 'test', - path, - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - interfaceGenerator(tree, { ...options, path: 'api/test' }) + interfaceGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/interface/schema.json b/packages/nest/src/generators/interface/schema.json index dc3ab941b8a06..c8bfd3fe6ff2a 100644 --- a/packages/nest/src/generators/interface/schema.json +++ b/packages/nest/src/generators/interface/schema.json @@ -5,32 +5,27 @@ "description": "Nest Interface Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the interface `Foo` at `myapp/src/app/foo.interface.ts`", + "command": "nx g @nx/nest:interface myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the interface will be generated.", + "description": "The file path to the interface without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the interface be generated?" - }, - "name": { - "description": "The name of the interface.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the interface file path?" }, "skipFormat": { "description": "Skip formatting files.", "type": "boolean", "default": false, "x-priority": "internal" - }, - "flat": { - "description": "Flag to indicate if a directory is created.", - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20.", - "type": "boolean", - "default": true } }, "additionalProperties": false, diff --git a/packages/nest/src/generators/middleware/middleware.spec.ts b/packages/nest/src/generators/middleware/middleware.spec.ts index 3ea6f9f57d0b9..077d452a53ce1 100644 --- a/packages/nest/src/generators/middleware/middleware.spec.ts +++ b/packages/nest/src/generators/middleware/middleware.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { MiddlewareGeneratorOptions } from './middleware'; import { middlewareGenerator } from './middleware'; describe('middleware generator', () => { let tree: Tree; - const path = 'api'; - const options: MiddlewareGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - middlewareGenerator(tree, { ...options, path: 'api/test' }) + middlewareGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/middleware/schema.json b/packages/nest/src/generators/middleware/schema.json index 16e63aa5e9a0d..fba06ed958b89 100644 --- a/packages/nest/src/generators/middleware/schema.json +++ b/packages/nest/src/generators/middleware/schema.json @@ -5,20 +5,21 @@ "description": "Nest Middleware Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the middleware `FooMiddleware` at `myapp/src/app/foo.middleware.ts`", + "command": "nx g @nx/nest:middleware myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the middleware will be generated.", + "description": "The file path to the middleware without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the middleware be generated?" - }, - "name": { - "description": "The name of the middleware.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the middleware file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/module/module.spec.ts b/packages/nest/src/generators/module/module.spec.ts index 6ccb6c0132785..ef5212ac4eaed 100644 --- a/packages/nest/src/generators/module/module.spec.ts +++ b/packages/nest/src/generators/module/module.spec.ts @@ -1,24 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { ModuleGeneratorOptions } from './module'; import { moduleGenerator } from './module'; describe('module generator', () => { let tree: Tree; - const path = 'api'; - const options: ModuleGeneratorOptions = { - name: 'test', - path, - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - moduleGenerator(tree, { ...options, path: 'api/test' }) + moduleGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/module/schema.json b/packages/nest/src/generators/module/schema.json index 562072ab86767..f730ac1d1c15a 100644 --- a/packages/nest/src/generators/module/schema.json +++ b/packages/nest/src/generators/module/schema.json @@ -5,20 +5,21 @@ "description": "Nest Module Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the module `FooModule` at `myapp/src/app/foo.module.ts`", + "command": "nx g @nx/nest:module myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the module will be generated.", + "description": "The file path to the module without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the module be generated?" - }, - "name": { - "description": "The name of the module.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the module file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/pipe/pipe.spec.ts b/packages/nest/src/generators/pipe/pipe.spec.ts index c03e7c5fbbbeb..be59af7819acd 100644 --- a/packages/nest/src/generators/pipe/pipe.spec.ts +++ b/packages/nest/src/generators/pipe/pipe.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { PipeGeneratorOptions } from './pipe'; import { pipeGenerator } from './pipe'; describe('pipe generator', () => { let tree: Tree; - const path = 'api'; - const options: PipeGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - pipeGenerator(tree, { ...options, path: 'api/test' }) + pipeGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/pipe/schema.json b/packages/nest/src/generators/pipe/schema.json index 3c01463dc6b68..f7da5a8c95dea 100644 --- a/packages/nest/src/generators/pipe/schema.json +++ b/packages/nest/src/generators/pipe/schema.json @@ -5,20 +5,21 @@ "description": "Nest Pipe Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the pipe `FooPipe` at `myapp/src/app/foo.pipe.ts`", + "command": "nx g @nx/nest:pipe myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the pipe will be generated.", + "description": "The file path to the pipe without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the pipe be generated?" - }, - "name": { - "description": "The name of the pipe.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the pipe file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/provider/provider.spec.ts b/packages/nest/src/generators/provider/provider.spec.ts index 4e1deb4e4b460..0940a212164b8 100644 --- a/packages/nest/src/generators/provider/provider.spec.ts +++ b/packages/nest/src/generators/provider/provider.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { ProviderGeneratorOptions } from './provider'; import { providerGenerator } from './provider'; describe('provider generator', () => { let tree: Tree; - const path = 'api'; - const options: ProviderGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - providerGenerator(tree, { ...options, path: 'api/test' }) + providerGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/provider/schema.json b/packages/nest/src/generators/provider/schema.json index 56667810e0b8c..ab1bcf9472ed1 100644 --- a/packages/nest/src/generators/provider/schema.json +++ b/packages/nest/src/generators/provider/schema.json @@ -5,20 +5,21 @@ "description": "Nest Provider Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the provider `Foo` at `myapp/src/app/foo.ts`", + "command": "nx g @nx/nest:provider myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the provider will be generated.", + "description": "The file path to the provider without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the provider be generated?" - }, - "name": { - "description": "The name of the provider.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the provider file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/resolver/resolver.spec.ts b/packages/nest/src/generators/resolver/resolver.spec.ts index 212434d7ae859..948fa542a3d85 100644 --- a/packages/nest/src/generators/resolver/resolver.spec.ts +++ b/packages/nest/src/generators/resolver/resolver.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { ResolverGeneratorOptions } from './resolver'; import { resolverGenerator } from './resolver'; describe('resolver generator', () => { let tree: Tree; - const path = 'api'; - const options: ResolverGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - resolverGenerator(tree, { ...options, path: 'api/test' }) + resolverGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/resolver/schema.json b/packages/nest/src/generators/resolver/schema.json index a69e86fc864e0..3226b4a078fb3 100644 --- a/packages/nest/src/generators/resolver/schema.json +++ b/packages/nest/src/generators/resolver/schema.json @@ -5,20 +5,21 @@ "description": "Nest Resolver Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the resolver `FooResolver` at `myapp/src/app/foo.resolver.ts`", + "command": "nx g @nx/nest:resolver myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the resolver will be generated.", + "description": "The file path to the resolver without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the resolver be generated?" - }, - "name": { - "description": "The name of the resolver.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the resolver file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/resource/resource.spec.ts b/packages/nest/src/generators/resource/resource.spec.ts index 2b35515127586..7dfe0106841db 100644 --- a/packages/nest/src/generators/resource/resource.spec.ts +++ b/packages/nest/src/generators/resource/resource.spec.ts @@ -1,26 +1,18 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { ResourceGeneratorOptions } from './resource'; import { resourceGenerator } from './resource'; // TODO (nicolas) fix the tests current fails with Error: spawn /bin/sh ENOENT)... Also fails on master from utils/run-nest-schematic.spec.ts xdescribe('resource generator', () => { let tree: Tree; - const path = 'api'; - const options: ResourceGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - resourceGenerator(tree, { ...options, path: 'api/test' }) + resourceGenerator(tree, { path: 'api/test' }) ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/resource/schema.json b/packages/nest/src/generators/resource/schema.json index fb09866789649..304567d33d38a 100644 --- a/packages/nest/src/generators/resource/schema.json +++ b/packages/nest/src/generators/resource/schema.json @@ -5,20 +5,21 @@ "description": "Nest Resource Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate `myapp/src/app/entities/foo.entity.ts`, `myapp/src/app/dto/create-foo.dto.ts`, `myapp/src/app/dto/update-foo.dto.ts`, `myapp/src/app/foo.service.ts`, `myapp/src/app/foo.controller.ts`, and `myapp/src/app/foo.module.ts`", + "command": "nx g @nx/nest:resource myapp/src/app/foo" + } + ], "properties": { "path": { "type": "string", - "description": "Path where the resource will be generated.", + "description": "The file path to the resource without the file extension and suffix. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the resource be generated?" - }, - "name": { - "type": "string", - "description": "The name of the resource.", - "x-prompt": "What name would you like to use for this resource (plural, e.g., `users`)?" + "x-prompt": "What is the resource file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/service/schema.json b/packages/nest/src/generators/service/schema.json index 3755f64e98cd6..4d96311886dfd 100644 --- a/packages/nest/src/generators/service/schema.json +++ b/packages/nest/src/generators/service/schema.json @@ -5,20 +5,21 @@ "description": "Nest Service Options Schema.", "cli": "nx", "type": "object", + "examples": [ + { + "description": "Generate the service `FooService` at `myapp/src/app/foo.service.ts`", + "command": "nx g @nx/nest:service myapp/src/app/foo" + } + ], "properties": { "path": { - "description": "Path where the service will be generated.", + "description": "The file path to the service without the file extension and suffix. Relative to the current working directory.", "type": "string", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the service be generated?" - }, - "name": { - "description": "The name of the service.", - "type": "string", - "x-prompt": "What name would you like to use?" + "x-prompt": "What is the service file path?" }, "skipFormat": { "description": "Skip formatting files.", diff --git a/packages/nest/src/generators/service/service.spec.ts b/packages/nest/src/generators/service/service.spec.ts index 9e46c6860acfd..da39830f04b53 100644 --- a/packages/nest/src/generators/service/service.spec.ts +++ b/packages/nest/src/generators/service/service.spec.ts @@ -1,25 +1,17 @@ import type { Tree } from '@nx/devkit'; import { createTreeWithNestApplication } from '../utils/testing'; -import type { ServiceGeneratorOptions } from './service'; import { serviceGenerator } from './service'; describe('service generator', () => { let tree: Tree; - const path = 'api'; - const options: ServiceGeneratorOptions = { - name: 'test', - path, - unitTestRunner: 'jest', - }; beforeEach(() => { - tree = createTreeWithNestApplication(path); - jest.clearAllMocks(); + tree = createTreeWithNestApplication('api'); }); it('should run successfully', async () => { await expect( - serviceGenerator(tree, { ...options, path: 'api/test' }) - ).resolves.not.toThrowError(); + serviceGenerator(tree, { path: 'api/test' }) + ).resolves.not.toThrow(); }); }); diff --git a/packages/nest/src/generators/utils/normalize-options.ts b/packages/nest/src/generators/utils/normalize-options.ts index a17980124001d..cd0d2baa063dd 100644 --- a/packages/nest/src/generators/utils/normalize-options.ts +++ b/packages/nest/src/generators/utils/normalize-options.ts @@ -12,7 +12,6 @@ export async function normalizeOptions( ): Promise { const { directory, artifactName } = await determineArtifactNameAndDirectoryOptions(tree, { - name: options.name, path: options.path, }); diff --git a/packages/nest/src/generators/utils/types.ts b/packages/nest/src/generators/utils/types.ts index ee171caab2c17..d0210b7e3883d 100644 --- a/packages/nest/src/generators/utils/types.ts +++ b/packages/nest/src/generators/utils/types.ts @@ -25,7 +25,6 @@ export type TransportLayer = export type NestGeneratorOptions = { path: string; - name?: string; skipFormat?: boolean; }; diff --git a/packages/next/docs/application-examples.md b/packages/next/docs/application-examples.md index 1fe7a98fe494d..1e19500c03316 100644 --- a/packages/next/docs/application-examples.md +++ b/packages/next/docs/application-examples.md @@ -1,11 +1,7 @@ ## Examples {% tabs %} -{% tab label="Create app in a directory" %} - -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=nested`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} +{% tab label="Create app in a nested directory" %} ```shell nx g app apps/nested/myapp diff --git a/packages/next/docs/component-examples.md b/packages/next/docs/component-examples.md index 75b1bf30b1731..44d508d5ba3b0 100644 --- a/packages/next/docs/component-examples.md +++ b/packages/next/docs/component-examples.md @@ -1,28 +1,21 @@ ## Examples {% tabs %} -{% tab label="Create an app component" %} +{% tab label="Create a Component" %} -```shell -nx g component apps/my-app/src/lib/my-cmp/my-cmp -``` - -{% /tab %} -{% tab label="Create a component without its own folder" %} - -Running the following will create a component under `apps/my-app/components/my-cmp.tsx` rather than `apps/my-app/components/my-cmp/my-cmp.tsx`. +Generate a component named `MyComponent` at `apps/my-app/src/app/my-component/my-component.tsx`: ```shell -nx g component apps/my-app/src/lib/my-cmp +nx g component apps/my-app/src/app/my-component/my-component ``` {% /tab %} -{% tab label="Create component in a custom directory" %} +{% tab label="Create a Component with a Different Symbol Name" %} -Running the following will create a component under `apps/my-app/foo/my-cmp.tsx` rather than `apps/my-app/my-cmp/my-cmp.tsx`. +Generate a component named `Custom` at `apps/my-app/src/app/my-component/my-component.tsx`: ```shell -nx g component apps/my-app/foo/my-cmp +nx g component apps/my-app/src/app/my-component/my-component --name=custom ``` {% /tab %} diff --git a/packages/next/docs/page-examples.md b/packages/next/docs/page-examples.md index 6fe460e925e5b..fcea7385706fb 100644 --- a/packages/next/docs/page-examples.md +++ b/packages/next/docs/page-examples.md @@ -1,16 +1,18 @@ ## Examples {% tabs %} -{% tab label="Create static page in an app" %} +{% tab label="Create a Static Page" %} + +Generate a static page named `MyPage` at `apps/my-app/pages/my-page/page.tsx`: ```shell nx g page apps/my-app/pages/my-page ``` {% /tab %} -{% tab label="Create dynamic page in an app" %} +{% tab label="Create a Dynamic Page" %} -The following creates a page under `apps/my-app/pages/products/[id].tsx`. +Generate a dynamic page at `apps/my-app/pages/products/[id]/page.tsx`: ```shell nx g page "apps/my-app/pages/products/[id]" diff --git a/packages/next/src/generators/component/schema.json b/packages/next/src/generators/component/schema.json index d35d3e70cf241..feed4a894384a 100644 --- a/packages/next/src/generators/component/schema.json +++ b/packages/next/src/generators/component/schema.json @@ -8,19 +8,17 @@ "properties": { "path": { "type": "string", - "description": "Path where the component will be generated.", + "description": "The file path to the component without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the component be generated?", + "x-prompt": "What is the component file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?", - "x-priority": "important" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "style": { "description": "The file extension to be used for style files.", diff --git a/packages/next/src/generators/page/page.spec.ts b/packages/next/src/generators/page/page.spec.ts index 0fc16cce702de..00b330f6d48a4 100644 --- a/packages/next/src/generators/page/page.spec.ts +++ b/packages/next/src/generators/page/page.spec.ts @@ -28,7 +28,7 @@ describe('component', () => { it('should generate component in pages directory', async () => { await pageGenerator(tree, { name: 'hello', - path: 'my-app/pages/hello/index', + path: 'my-app/pages/hello', style: 'css', }); @@ -39,7 +39,7 @@ describe('component', () => { it('should support dynamic routes and directories', async () => { await pageGenerator(tree, { name: '[dynamic]', - path: 'my-app/pages/posts/[dynamic]/index', + path: 'my-app/pages/posts/[dynamic]', style: 'css', }); @@ -56,7 +56,7 @@ describe('component', () => { it('should generate component in app directory', async () => { await pageGenerator(tree, { name: 'about', - path: `${appRouterProjectName}/app/about/about`, + path: `${appRouterProjectName}/app/about`, style: 'css', }); @@ -71,7 +71,7 @@ describe('component', () => { it('should support dynamic routes and directories', async () => { await pageGenerator(tree, { name: '[dynamic]', - path: `${appRouterProjectName}/app/posts/[dynamic]/page`, + path: `${appRouterProjectName}/app/posts/[dynamic]`, style: 'css', }); diff --git a/packages/next/src/generators/page/page.ts b/packages/next/src/generators/page/page.ts index d1ce46118e534..95f16f6fa9c07 100644 --- a/packages/next/src/generators/page/page.ts +++ b/packages/next/src/generators/page/page.ts @@ -9,7 +9,10 @@ import { import { addStyleDependencies } from '../../utils/styles'; import { Schema } from './schema'; -import { determineArtifactNameAndDirectoryOptions } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; +import { + determineArtifactNameAndDirectoryOptions, + getRelativeCwd, +} from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; /* * This schematic is basically the React component one, but for Next we need @@ -56,9 +59,34 @@ async function normalizeOptions(host: Tree, options: Schema) { host.exists(`${project.root}/app`) || host.exists(`${project.root}/src/app`); + let pageSymbolName = options.name; + if (!pageSymbolName) { + // if `name` is not provided, we use the last segment of the path + if (options.path !== '.' && options.path !== '') { + pageSymbolName = options.path.split('/').pop(); + } else { + // the user must have cd into a previously created directory, we need to + // resolve the cwd to get it + const cwd = getRelativeCwd(); + if (cwd !== '.' && cwd !== '') { + pageSymbolName = cwd.split('/').pop(); + } else { + // this can only happen when running from the workspace root, in which + // case, we don't have a good way to automatically determine the name + throw new Error( + 'Cannot determine the page name, please provide a `name` or `path` option.' + ); + } + } + } + + // the helper below expects a path to a file, but the `path` option here + // represents a directory, so we artificially add the symbol name to it + options.path = joinPathFragments(options.path, pageSymbolName); + const { project: projectName, fileName } = await determineArtifactNameAndDirectoryOptions(host, { - name: options.name, + name: pageSymbolName, fileName: isAppRouter ? 'page' : 'index', path: options.path, fileExtension: 'tsx', diff --git a/packages/next/src/generators/page/schema.d.ts b/packages/next/src/generators/page/schema.d.ts index 75de165e8f827..00d1924e5fa70 100644 --- a/packages/next/src/generators/page/schema.d.ts +++ b/packages/next/src/generators/page/schema.d.ts @@ -1,4 +1,3 @@ -import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; import { SupportedStyles } from '@nx/react'; export interface Schema { diff --git a/packages/next/src/generators/page/schema.json b/packages/next/src/generators/page/schema.json index 745b421c90329..4c5dc0fc821f2 100644 --- a/packages/next/src/generators/page/schema.json +++ b/packages/next/src/generators/page/schema.json @@ -8,19 +8,17 @@ "properties": { "path": { "type": "string", - "description": "Path where the page will be generated.", + "description": "The path to the directory where the page will be generated. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the page be generated?", + "x-prompt": "Which directory do you want to create the page in?", "x-priority": "important" }, "name": { "type": "string", - "description": "The name of the page.", - "x-prompt": "What name would you like to use for the page?", - "x-priority": "important" + "description": "The page symbol name. Defaults to the page directory name." }, "style": { "description": "The file extension to be used for style files.", @@ -79,12 +77,6 @@ "description": "Generate JavaScript files rather than TypeScript files.", "default": false }, - "flat": { - "type": "boolean", - "description": "Create component at the source root rather than its own directory.", - "default": false, - "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v20." - }, "skipFormat": { "description": "Skip formatting files.", "type": "boolean", diff --git a/packages/nuxt/docs/application-examples.md b/packages/nuxt/docs/application-examples.md index d09b67a3df980..a22dd0352ee6f 100644 --- a/packages/nuxt/docs/application-examples.md +++ b/packages/nuxt/docs/application-examples.md @@ -42,14 +42,10 @@ Your new app will contain the following: ## Examples {% tabs %} -{% tab label="Create app in a directory" %} - -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=nested`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} +{% tab label="Create app in a nested directory" %} ```shell -nx g @nx/nuxt:app =apps/nested/myapp +nx g @nx/nuxt:app apps/nested/myapp ``` {% /tab %} diff --git a/packages/nuxt/src/generators/storybook-configuration/configuration.spec.ts b/packages/nuxt/src/generators/storybook-configuration/configuration.spec.ts index 9c7d6e3505de2..ae9e94ff32fe5 100644 --- a/packages/nuxt/src/generators/storybook-configuration/configuration.spec.ts +++ b/packages/nuxt/src/generators/storybook-configuration/configuration.spec.ts @@ -93,7 +93,6 @@ export async function createTestApp( }); await componentGenerator(appTree, { - name: 'my-component', path: `${appName}/src/components/my-component`, }); diff --git a/packages/plugin/docs/generators/executor-examples.md b/packages/plugin/docs/generators/executor-examples.md index 95e88baa14485..a904ba6d86caf 100644 --- a/packages/plugin/docs/generators/executor-examples.md +++ b/packages/plugin/docs/generators/executor-examples.md @@ -3,16 +3,25 @@ {% tabs %} {% tab label="Basic executor" %} -Create a new executor called `build` inside the plugin `my-plugin`: +Create a new executor called `build` at `tools/my-plugin/src/executors/build.ts`: ```bash nx g @nx/plugin:executor tools/my-plugin/src/executors/build ``` +{% /tab %} +{% tab label="With different exported name" %} + +Create a new executor called `custom` at `tools/my-plugin/src/executors/build.ts`: + +```bash +nx g @nx/plugin:executor tools/my-plugin/src/executors/build --name=custom +``` + {% /tab %} {% tab label="With custom hashing" %} -Create a new executor called `build` inside the plugin `my-plugin`, that uses a custom hashing function: +Create a new executor called `build` at `tools/my-plugin/src/executors/build.ts`, that uses a custom hashing function: ```bash nx g @nx/plugin:executor tools/my-plugin/src/executors/build --includeHasher diff --git a/packages/plugin/src/generators/executor/schema.json b/packages/plugin/src/generators/executor/schema.json index 6795af1bf29a6..2ee691e2bc859 100644 --- a/packages/plugin/src/generators/executor/schema.json +++ b/packages/plugin/src/generators/executor/schema.json @@ -6,17 +6,11 @@ "description": "Create an Executor for an Nx Plugin.", "examplesFile": "../../../docs/generators/executor-examples.md", "type": "object", - "examples": [ - { - "command": "nx g executor my-executor --project=my-plugin", - "description": "Generate `libs/my-plugin/src/executors/my-executor`" - } - ], "properties": { "path": { "type": "string", - "description": "Path at which to generate the executor file.", - "x-prompt": "What path would you like to use for the executor?", + "description": "The file path to the executor without the file extension. Relative to the current working directory.", + "x-prompt": "What is the executor file path?", "$default": { "$source": "argv", "index": 0 @@ -25,9 +19,7 @@ }, "name": { "type": "string", - "description": "Executor name.", - "x-prompt": "What name would you like to use for the executor?", - "x-priority": "important" + "description": "The executor name to export in the plugin executors collection." }, "description": { "type": "string", diff --git a/packages/plugin/src/generators/generator/schema.d.ts b/packages/plugin/src/generators/generator/schema.d.ts index 8b1a660e68ab2..b8b4e3fbf9ecd 100644 --- a/packages/plugin/src/generators/generator/schema.d.ts +++ b/packages/plugin/src/generators/generator/schema.d.ts @@ -1,5 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface Schema { path: string; name?: string; diff --git a/packages/plugin/src/generators/generator/schema.json b/packages/plugin/src/generators/generator/schema.json index 30ec3d285fe1f..206b0e0a1e1f0 100644 --- a/packages/plugin/src/generators/generator/schema.json +++ b/packages/plugin/src/generators/generator/schema.json @@ -7,26 +7,28 @@ "type": "object", "examples": [ { - "command": "nx g generator libs/my-plugin/src/generators//my-generator", - "description": "Generate `libs/my-plugin/src/generators/my-generator`" + "description": "Generate a generator exported with the name matching the file name. It results in the generator `foo` at `mylib/src/generators/foo.ts`", + "command": "nx g @nx/plugin:generator mylib/src/generators/foo" + }, + { + "description": "Generate a generator exported with a different name from the file name. It results in the generator `custom` at `mylib/src/generators/foo.ts`", + "command": "nx g @nx/plugin:generator mylib/src/generators/foo --name=custom" } ], "properties": { "path": { "type": "string", - "description": "Path where the generator will be generated.", + "description": "The file path to the generator without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the generator be generated?", + "x-prompt": "What is the generator file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "Generator name.", - "x-prompt": "What name would you like to use for the generator?", - "x-priority": "important" + "description": "The generator name to export in the plugin generators collection." }, "description": { "type": "string", diff --git a/packages/plugin/src/generators/migration/schema.d.ts b/packages/plugin/src/generators/migration/schema.d.ts index 565fdd8936d29..a139912fa3a07 100644 --- a/packages/plugin/src/generators/migration/schema.d.ts +++ b/packages/plugin/src/generators/migration/schema.d.ts @@ -1,5 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface Schema { path: string; name?: string; diff --git a/packages/plugin/src/generators/migration/schema.json b/packages/plugin/src/generators/migration/schema.json index 9a2bf57f03f31..7c158677e7b3a 100644 --- a/packages/plugin/src/generators/migration/schema.json +++ b/packages/plugin/src/generators/migration/schema.json @@ -7,25 +7,28 @@ "type": "object", "examples": [ { - "command": "nx g migration my-plugin/my-migration --version=1.0.0", - "description": "Adds a new migration inside `my-plugin`, which will be triggered when migrating to version 1.0.0 or above from a previous version." + "description": "Generate a migration exported with the name matching the file name, which will be triggered when migrating to version 1.0.0 or above from a previous version. It results in the migration `foo` at `mylib/src/migrations/foo.ts`", + "command": "nx g @nx/plugin:migration mylib/src/migrations/foo -v=1.0.0" + }, + { + "description": "Generate a migration exported with a different name from the file name, which will be triggered when migrating to version 1.0.0 or above from a previous version. It results in the migration `custom` at `mylib/src/migrations/foo.ts`", + "command": "nx g @nx/plugin:migration mylib/src/migrations/foo --name=custom -v=1.0.0" } ], "properties": { "path": { "type": "string", - "description": "Path where the migration will be generated.", + "description": "The file path to the migration without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the migration be generated?", + "x-prompt": "What is the migration file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "Migration name.", - "x-priority": "important" + "description": "The migration name to export in the plugin migrations collection." }, "description": { "type": "string", diff --git a/packages/react-native/src/generators/component/schema.json b/packages/react-native/src/generators/component/schema.json index 3b8b3f55d3663..adde83800b39f 100644 --- a/packages/react-native/src/generators/component/schema.json +++ b/packages/react-native/src/generators/component/schema.json @@ -7,28 +7,31 @@ "type": "object", "examples": [ { - "command": "nx g @nx/react-native:component mylib/src/lib/my-component/my-component ", - "description": "Generate a component in the `mylib` library" + "description": "Generate a component with the exported symbol matching the file name. It results in the component `Foo` at `mylib/src/lib/foo.tsx`", + "command": "nx g @nx/react-native:component mylib/src/lib/foo" }, { - "command": "nx g @nx/react-native:component mylib/src/lib/my-component/my-component --classComponent", - "description": "Generate a class component in the `mylib` library" + "description": "Generate a component with the exported symbol different from the file name. It results in the component `Custom` at `mylib/src/lib/foo.tsx`", + "command": "nx g @nx/react-native:component mylib/src/lib/foo --name=custom" + }, + { + "description": "Generate a class component at `mylib/src/lib/foo.tsx`", + "command": "nx g @nx/react-native:component mylib/src/lib/foo --classComponent" } ], "properties": { "path": { "type": "string", - "description": "The path at which to create the component file.", + "description": "The file path to the component without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "What path would you like to use for the component?" + "x-prompt": "What is the component file path?" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "js": { "type": "boolean", diff --git a/packages/react/docs/application-examples.md b/packages/react/docs/application-examples.md index e5f267f4a8a42..77e23f31d1c46 100644 --- a/packages/react/docs/application-examples.md +++ b/packages/react/docs/application-examples.md @@ -23,14 +23,10 @@ When choosing `vite` as the bundler, your unit tests will be set up with `vitest {% /tab %} -{% tab label="Specify directory and style extension" %} +{% tab label="Specify style extension" %} Create an application named `my-app` in the `my-dir` directory and use `scss` for styles: -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=my-dir`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```bash nx g @nx/react:app apps/my-dir/my-app --style=scss ``` diff --git a/packages/react/docs/component-examples.md b/packages/react/docs/component-examples.md index a8839c24eba44..efbc7daea600c 100644 --- a/packages/react/docs/component-examples.md +++ b/packages/react/docs/component-examples.md @@ -3,7 +3,7 @@ {% tabs %} {% tab label="Simple Component" %} -Create a component named `my-component` under the `libs/ui` project: +Create a component named `MyComponent` at `libs/ui/src/my-component.tsx`: ```shell nx g @nx/react:component libs/ui/src/my-component @@ -11,9 +11,19 @@ nx g @nx/react:component libs/ui/src/my-component {% /tab %} -{% tab label="Standalone Component" %} +{% tab label="With a Different Symbol Name" %} -Create a class component named `my-component` under the `libs/ui` project: +Create a component named `Custom` at `libs/ui/src/my-component.tsx`: + +```shell +nx g @nx/react:component libs/ui/src/my-component --name=custom +``` + +{% /tab %} + +{% tab label="Class Component" %} + +Create a class component named `MyComponent` at `libs/ui/src/my-component.tsx`: ```shell nx g @nx/react:component libs/ui/src/my-component --classComponent diff --git a/packages/react/src/generators/component/schema.d.ts b/packages/react/src/generators/component/schema.d.ts index 186b90a2fed5b..f3860e29acadf 100644 --- a/packages/react/src/generators/component/schema.d.ts +++ b/packages/react/src/generators/component/schema.d.ts @@ -1,4 +1,3 @@ -import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; import { SupportedStyles } from '../../../typings/style'; export interface Schema { diff --git a/packages/react/src/generators/component/schema.json b/packages/react/src/generators/component/schema.json index c8d98cf4b6069..e5af0634c2743 100644 --- a/packages/react/src/generators/component/schema.json +++ b/packages/react/src/generators/component/schema.json @@ -8,19 +8,17 @@ "properties": { "path": { "type": "string", - "description": "Path where the component will be generated.", + "description": "The file path to the component without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the component be generated?", + "x-prompt": "What is the component file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?", - "x-priority": "important" + "description": "The component symbol name. Defaults to the last segment of the file path." }, "style": { "description": "The file extension to be used for style files.", diff --git a/packages/react/src/generators/hook/hook.ts b/packages/react/src/generators/hook/hook.ts index 93d9f4cda263b..0240b9d19c19b 100644 --- a/packages/react/src/generators/hook/hook.ts +++ b/packages/react/src/generators/hook/hook.ts @@ -23,6 +23,7 @@ interface NormalizedSchema extends Schema { hookTypeName: string; fileName: string; projectName: string; + directory: string; } export async function hookGenerator(host: Tree, schema: Schema) { @@ -96,11 +97,10 @@ async function normalizeOptions( host: Tree, options: Schema ): Promise { - assertValidOptions(options); - const { + artifactName, directory, - fileName: _fileName, + fileName: hookFilename, project: projectName, } = await determineArtifactNameAndDirectoryOptions(host, { path: options.path, @@ -108,17 +108,16 @@ async function normalizeOptions( fileExtension: 'tsx', }); - const { className, fileName } = names(_fileName); + const { className } = names(hookFilename); - // If using `as-provided` file and directory, then don't normalize. - // Otherwise, support legacy behavior of prefixing filename with `use-`. - const hookFilename = fileName; - const hookName = className.toLocaleLowerCase().startsWith('use') + // if name is provided, use it as is for the hook name, otherwise prepend + // `use` to the pascal-cased file name if it doesn't already start with `use` + const hookName = options.name + ? artifactName + : className.toLocaleLowerCase().startsWith('use') ? className - : 'use'.concat(className); - const hookTypeName = className.toLocaleLowerCase().startsWith('use') - ? className - : 'Use'.concat(className); + : `use${className}`; + const hookTypeName = names(hookName).className; const project = getProjects(host).get(projectName); const { sourceRoot: projectSourceRoot, projectType } = project; @@ -140,20 +139,4 @@ async function normalizeOptions( }; } -function assertValidOptions(options: Schema) { - const slashes = ['/', '\\']; - slashes.forEach((s) => { - if (options.name.indexOf(s) !== -1) { - const [name, ...rest] = options.name.split(s).reverse(); - let suggestion = rest.map((x) => x.toLowerCase()).join(s); - if (options.directory) { - suggestion = `${options.directory}${s}${suggestion}`; - } - throw new Error( - `Found "${s}" in the hook name. Did you mean to use the --directory option (e.g. \`nx g c ${name} --directory ${suggestion}\`)?` - ); - } - }); -} - export default hookGenerator; diff --git a/packages/react/src/generators/hook/schema.d.ts b/packages/react/src/generators/hook/schema.d.ts index c4ae961e2cccf..79d65055c1a23 100644 --- a/packages/react/src/generators/hook/schema.d.ts +++ b/packages/react/src/generators/hook/schema.d.ts @@ -2,8 +2,6 @@ export interface Schema { path: string; name?: string; skipTests?: boolean; - directory?: string; export?: boolean; js?: boolean; - nameAndDirectoryFormat?: NameAndDirectoryFormat; } diff --git a/packages/react/src/generators/hook/schema.json b/packages/react/src/generators/hook/schema.json index 18e228edf357f..88336f4273791 100644 --- a/packages/react/src/generators/hook/schema.json +++ b/packages/react/src/generators/hook/schema.json @@ -7,26 +7,28 @@ "type": "object", "examples": [ { - "command": "nx g hook mylib/my-hook", - "description": "Generate a hook `my-hook` in the `mylib` library" + "description": "Generate a hook with the exported symbol matching the file name. It results in the hook `useFoo` at `mylib/src/lib/foo.ts`", + "command": "nx g @nx/react:hook mylib/src/lib/foo" + }, + { + "description": "Generate a hook with the exported symbol different from the file name. It results in the hook `useCustom` at `mylib/src/lib/foo.ts`", + "command": "nx g @nx/react:hook mylib/src/lib/foo --name=useCustom" } ], "properties": { "path": { "type": "string", - "description": "Path where the hook will be generated.", + "description": "The file path to the hook without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the hook be generated?", + "x-prompt": "What is the hook file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "The name of the hook.", - "x-prompt": "What name would you like to use for the hook?", - "x-priority": "important" + "description": "The hook symbol name. Defaults to the last segment of the file path." }, "js": { "type": "boolean", @@ -39,16 +41,6 @@ "default": false, "x-priority": "internal" }, - "directory": { - "type": "string", - "description": "The directory at which to create the hook file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the project root.", - "x-priority": "important" - }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] - }, "export": { "type": "boolean", "description": "When true, the hook is exported from the project `index.ts` (if it exists).", @@ -57,5 +49,5 @@ "x-prompt": "Should this hook be exported in the project?" } }, - "required": ["name"] + "required": ["path"] } diff --git a/packages/react/src/generators/redux/schema.json b/packages/react/src/generators/redux/schema.json index 3410f2003a7a4..034548d79004e 100644 --- a/packages/react/src/generators/redux/schema.json +++ b/packages/react/src/generators/redux/schema.json @@ -5,21 +5,30 @@ "title": "Create Redux state", "description": "Create a Redux state slice for a React project.", "type": "object", + "examples": [ + { + "description": "Generate a Redux state slice with the exported symbol matching the file name. It results in the slice `fooSlice` at `mylib/src/lib/foo.slice.ts`", + "command": "nx g @nx/react:redux mylib/src/lib/foo" + }, + { + "description": "Generate a Redux state slice with the exported symbol different from the file name. It results in the slice `customSlice` at `mylib/src/lib/foo.slice.ts`", + "command": "nx g @nx/react:redux mylib/src/lib/foo --name=custom" + } + ], "properties": { "path": { "type": "string", - "description": "Path where the Redux slice will be generated.", + "description": "The file path to the Redux state slice without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the Redux slice be generated?", + "x-prompt": "What is the Redux stateslice file path?", "x-priority": "important" }, "name": { "type": "string", - "description": "Redux slice name.", - "x-priority": "important" + "description": "The Redux state slice symbol name. Defaults to the last segment of the file path." }, "appProject": { "type": "string", diff --git a/packages/remix/src/generators/action/action.impl.spec.ts b/packages/remix/src/generators/action/action.impl.spec.ts index 556a4d739f413..13bfd94d485c9 100644 --- a/packages/remix/src/generators/action/action.impl.spec.ts +++ b/packages/remix/src/generators/action/action.impl.spec.ts @@ -69,24 +69,4 @@ describe('action', () => { }); }); }); - - it('--nameAndDirectoryFormat=as-provided', async () => { - // ACT - await actionGenerator(tree, { - path: 'apps/demo/app/routes/example.tsx', - }); - // ASSERT - const content = tree.read('apps/demo/app/routes/example.tsx', 'utf-8'); - const useActionData = `const actionMessage = useActionData();`; - const actionFunction = `export const action = async ({ request }: ActionFunctionArgs)`; - expect(content).toMatch(`import { json } from '@remix-run/node';`); - expect(content).toMatch( - `import type { ActionFunctionArgs } from '@remix-run/node';` - ); - expect(content).toMatch( - `import { useActionData } from '@remix-run/react';` - ); - expect(content).toMatch(useActionData); - expect(content).toMatch(actionFunction); - }); }); diff --git a/packages/remix/src/generators/action/schema.d.ts b/packages/remix/src/generators/action/schema.d.ts index 31790d4cf7767..f8d6e13618618 100644 --- a/packages/remix/src/generators/action/schema.d.ts +++ b/packages/remix/src/generators/action/schema.d.ts @@ -1,6 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface LoaderSchema { path: string; - nameAndDirectoryFormat?: NameAndDirectoryFormat; } diff --git a/packages/remix/src/generators/action/schema.json b/packages/remix/src/generators/action/schema.json index ec1070f942c74..4375f951f8f71 100644 --- a/packages/remix/src/generators/action/schema.json +++ b/packages/remix/src/generators/action/schema.json @@ -12,11 +12,6 @@ "index": 0 }, "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')" - }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the action in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] } }, "required": ["path"] diff --git a/packages/remix/src/generators/error-boundary/error-boundary.impl.spec.ts b/packages/remix/src/generators/error-boundary/error-boundary.impl.spec.ts index 7e88cf873f4c1..d56fe36a6ac1d 100644 --- a/packages/remix/src/generators/error-boundary/error-boundary.impl.spec.ts +++ b/packages/remix/src/generators/error-boundary/error-boundary.impl.spec.ts @@ -14,7 +14,6 @@ describe('ErrorBoundary', () => { ); }); describe('--apiVersion=2', () => { - const nameAndDirectoryFormat = 'as-provided'; it('should correctly add the ErrorBoundary to the route file', async () => { // ARRANGE const tree = createTreeWithEmptyWorkspace(); @@ -30,7 +29,6 @@ describe('ErrorBoundary', () => { // ACT await errorBoundaryGenerator(tree, { - nameAndDirectoryFormat, path: routeFilePath, }); @@ -54,7 +52,6 @@ describe('ErrorBoundary', () => { // ACT & ASSERT await expect( errorBoundaryGenerator(tree, { - nameAndDirectoryFormat, path: `my-route.tsx`, }) ).rejects.toThrow(); diff --git a/packages/remix/src/generators/error-boundary/schema.d.ts b/packages/remix/src/generators/error-boundary/schema.d.ts index a299b1c142413..561a87cd370f3 100644 --- a/packages/remix/src/generators/error-boundary/schema.d.ts +++ b/packages/remix/src/generators/error-boundary/schema.d.ts @@ -1,7 +1,4 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface ErrorBoundarySchema { path: string; skipFormat?: false; - nameAndDirectoryFormat?: NameAndDirectoryFormat; } diff --git a/packages/remix/src/generators/error-boundary/schema.json b/packages/remix/src/generators/error-boundary/schema.json index 7b413b306dd4a..6205088cd7f82 100644 --- a/packages/remix/src/generators/error-boundary/schema.json +++ b/packages/remix/src/generators/error-boundary/schema.json @@ -15,11 +15,6 @@ "type": "string", "description": "The path to route file relative to the project root." }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the error boundary in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] - }, "skipFormat": { "type": "boolean", "description": "Skip formatting files after generation.", diff --git a/packages/remix/src/generators/loader/loader.impl.spec.ts b/packages/remix/src/generators/loader/loader.impl.spec.ts index b914f33d4a51a..0a18a1241a4fd 100644 --- a/packages/remix/src/generators/loader/loader.impl.spec.ts +++ b/packages/remix/src/generators/loader/loader.impl.spec.ts @@ -70,24 +70,4 @@ describe('loader', () => { }); }); }); - - describe('--nameAndDirectoryFormat=as-provided', () => { - it('should add imports', async () => { - // ACT - await loaderGenerator(tree, { - path: 'apps/demo/app/routes/example.tsx', - nameAndDirectoryFormat: 'as-provided', - }); - - // ASSERT - const content = tree.read('apps/demo/app/routes/example.tsx', 'utf-8'); - expect(content).toMatch(`import { json } from '@remix-run/node';`); - expect(content).toMatch( - `import type { LoaderFunctionArgs } from '@remix-run/node';` - ); - expect(content).toMatch( - `import { useLoaderData } from '@remix-run/react';` - ); - }); - }); }); diff --git a/packages/remix/src/generators/loader/schema.d.ts b/packages/remix/src/generators/loader/schema.d.ts index 31790d4cf7767..f8d6e13618618 100644 --- a/packages/remix/src/generators/loader/schema.d.ts +++ b/packages/remix/src/generators/loader/schema.d.ts @@ -1,6 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface LoaderSchema { path: string; - nameAndDirectoryFormat?: NameAndDirectoryFormat; } diff --git a/packages/remix/src/generators/loader/schema.json b/packages/remix/src/generators/loader/schema.json index 9de2f617a44ad..70c125548bb0a 100644 --- a/packages/remix/src/generators/loader/schema.json +++ b/packages/remix/src/generators/loader/schema.json @@ -12,11 +12,6 @@ "index": 0 }, "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')" - }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the loader in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] } }, "required": ["path"] diff --git a/packages/remix/src/generators/meta/meta.impl.spec.ts b/packages/remix/src/generators/meta/meta.impl.spec.ts index b226956807a9d..09b17ce0b6bd0 100644 --- a/packages/remix/src/generators/meta/meta.impl.spec.ts +++ b/packages/remix/src/generators/meta/meta.impl.spec.ts @@ -45,19 +45,4 @@ describe('meta', () => { expect(content).toMatch(`export const meta: MetaFunction`); expect(content).toMatch(`return [`); }); - - it('--nameAndDirectoryFormat=as=provided', async () => { - await metaGenerator(tree, { - path: 'apps/demo/app/routes/example.tsx', - nameAndDirectoryFormat: 'as-provided', - }); - - const content = tree.read('apps/demo/app/routes/example.tsx', 'utf-8'); - expect(content).toMatch( - `import type { MetaFunction } from '@remix-run/node';` - ); - - expect(content).toMatch(`export const meta: MetaFunction`); - expect(content).toMatch(`return [`); - }); }); diff --git a/packages/remix/src/generators/meta/schema.d.ts b/packages/remix/src/generators/meta/schema.d.ts index 5ec8d906dbfec..7864fde343b43 100644 --- a/packages/remix/src/generators/meta/schema.d.ts +++ b/packages/remix/src/generators/meta/schema.d.ts @@ -1,6 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface MetaSchema { path: string; - nameAndDirectoryFormat?: NameAndDirectoryFormat; } diff --git a/packages/remix/src/generators/meta/schema.json b/packages/remix/src/generators/meta/schema.json index 6f54238e08013..2278db673d943 100644 --- a/packages/remix/src/generators/meta/schema.json +++ b/packages/remix/src/generators/meta/schema.json @@ -12,11 +12,6 @@ "index": 0 }, "x-prompt": "What is the path of the route? (e.g. 'apps/demo/app/routes/foo/bar.tsx')" - }, - "nameAndDirectoryFormat": { - "description": "Whether to generate the meta function in the path as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).", - "type": "string", - "enum": ["as-provided", "derived"] } }, "required": ["path"] diff --git a/packages/remix/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap b/packages/remix/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap index 992a493ec66f4..7d1f67295bfeb 100644 --- a/packages/remix/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +++ b/packages/remix/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`resource route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 1`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`; +exports[`resource route should error if it detects a possible missing route param because of un-escaped dollar sign 1`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`; -exports[`resource route --nameAndDirectoryFormat=as-provided should error if it detects a possible missing route param because of un-escaped dollar sign 3`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`; +exports[`resource route should error if it detects a possible missing route param because of un-escaped dollar sign 3`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`; diff --git a/packages/remix/src/generators/resource-route/resource-route.impl.spec.ts b/packages/remix/src/generators/resource-route/resource-route.impl.spec.ts index 7b5e32c99c31a..513c89d159a2c 100644 --- a/packages/remix/src/generators/resource-route/resource-route.impl.spec.ts +++ b/packages/remix/src/generators/resource-route/resource-route.impl.spec.ts @@ -11,6 +11,7 @@ import resourceRouteGenerator from './resource-route.impl'; describe('resource route', () => { let tree: Tree; + let path = 'apps/demo/app/routes/example.ts'; beforeEach(async () => { tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' }); @@ -29,7 +30,7 @@ describe('resource route', () => { await expect( async () => await resourceRouteGenerator(tree, { - path: 'apps/demo/app/routes/example.ts', + path, action: false, loader: false, skipChecks: false, @@ -39,90 +40,73 @@ describe('resource route', () => { ); }); - describe.each([['as-provided', 'apps/demo/app/routes/example.ts', '']])( - '--nameAndDirectoryFormat=%s', - (nameAndDirectoryFormat, path: string) => { - it(`should create correct file for path ${path}`, async () => { - await resourceRouteGenerator(tree, { - path, - action: false, - loader: true, - skipChecks: false, - }); - - expect(tree.exists('apps/demo/app/routes/example.ts')).toBeTruthy(); - }); + it(`should create correct file for path ${path}`, async () => { + await resourceRouteGenerator(tree, { + path, + action: false, + loader: true, + skipChecks: false, + }); - it('should error if it detects a possible missing route param because of un-escaped dollar sign', async () => { - expect.assertions(3); - - await resourceRouteGenerator(tree, { - path: `${dirname(path)}/route1/.ts`, // route.$withParams.tsx => route..tsx - loader: true, - action: true, - skipChecks: false, - }).catch((e) => expect(e).toMatchSnapshot()); - - await resourceRouteGenerator(tree, { - path: `${dirname(path)}/route2//index.ts`, // route/$withParams/index.tsx => route//index.tsx - loader: true, - action: true, - skipChecks: false, - }).catch((e) => - expect(e).toMatchInlineSnapshot( - `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]` - ) - ); - - await resourceRouteGenerator(tree, { - path: `${dirname(path)}/route3/.ts`, // route/$withParams.tsx => route/.tsx - loader: true, - action: true, - skipChecks: false, - }).catch((e) => expect(e).toMatchSnapshot()); - }); - - it(`should succeed if skipChecks flag is passed, and it detects a possible missing route param because of un-escaped dollar sign for ${path}`, async () => { - const basePath = - nameAndDirectoryFormat === 'as-provided' - ? '' - : 'apps/demo/app/routes'; - const normalizedPath = ( - dirname(path) === '' ? '' : `${dirname(path)}/` - ).replace(basePath, ''); - await resourceRouteGenerator(tree, { - path: `${normalizedPath}route1/..ts`, // route.$withParams.tsx => route..tsx - loader: true, - action: true, - skipChecks: true, - }); - - expect(tree.exists(`${basePath}/${normalizedPath}route1/..ts`)).toBe( - true - ); + expect(tree.exists('apps/demo/app/routes/example.ts')).toBeTruthy(); + }); - await resourceRouteGenerator(tree, { - path: `${normalizedPath}route2//index.ts`, // route/$withParams/index.tsx => route//index.tsx - loader: true, - action: true, - skipChecks: true, - }); + it('should error if it detects a possible missing route param because of un-escaped dollar sign', async () => { + expect.assertions(3); + + await resourceRouteGenerator(tree, { + path: `${dirname(path)}/route1/.ts`, // route.$withParams.tsx => route..tsx + loader: true, + action: true, + skipChecks: false, + }).catch((e) => expect(e).toMatchSnapshot()); + + await resourceRouteGenerator(tree, { + path: `${dirname(path)}/route2//index.ts`, // route/$withParams/index.tsx => route//index.tsx + loader: true, + action: true, + skipChecks: false, + }).catch((e) => + expect(e).toMatchInlineSnapshot( + `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]` + ) + ); - expect( - tree.exists(`${basePath}/${normalizedPath}route2/index.ts`) - ).toBe(true); + await resourceRouteGenerator(tree, { + path: `${dirname(path)}/route3/.ts`, // route/$withParams.tsx => route/.tsx + loader: true, + action: true, + skipChecks: false, + }).catch((e) => expect(e).toMatchSnapshot()); + }); - await resourceRouteGenerator(tree, { - path: `${normalizedPath}route3/.ts`, // route/$withParams.tsx => route/.tsx - loader: true, - action: true, - skipChecks: true, - }); - - expect(tree.exists(`${basePath}/${normalizedPath}route3/.ts`)).toBe( - true - ); - }); - } - ); + it(`should succeed if skipChecks flag is passed, and it detects a possible missing route param because of un-escaped dollar sign for ${path}`, async () => { + const normalizedPath = `${dirname(path)}/`; + await resourceRouteGenerator(tree, { + path: `${normalizedPath}route1/..ts`, // route.$withParams.tsx => route..tsx + loader: true, + action: true, + skipChecks: true, + }); + + expect(tree.exists(`${normalizedPath}route1/..ts`)).toBe(true); + + await resourceRouteGenerator(tree, { + path: `${normalizedPath}route2//index.ts`, // route/$withParams/index.tsx => route//index.tsx + loader: true, + action: true, + skipChecks: true, + }); + + expect(tree.exists(`${normalizedPath}route2/index.ts`)).toBe(true); + + await resourceRouteGenerator(tree, { + path: `${normalizedPath}route3/.ts`, // route/$withParams.tsx => route/.tsx + loader: true, + action: true, + skipChecks: true, + }); + + expect(tree.exists(`${normalizedPath}route3/.ts`)).toBe(true); + }); }); diff --git a/packages/remix/src/generators/resource-route/resource-route.impl.ts b/packages/remix/src/generators/resource-route/resource-route.impl.ts index c1b5bb406d3ad..dc0f1fb6cc8e6 100644 --- a/packages/remix/src/generators/resource-route/resource-route.impl.ts +++ b/packages/remix/src/generators/resource-route/resource-route.impl.ts @@ -39,14 +39,12 @@ export default async function (tree: Tree, options: RemixRouteSchema) { if (options.loader) { await loaderGenerator(tree, { path: routeFilePath, - nameAndDirectoryFormat: 'as-provided', }); } if (options.action) { await actionGenerator(tree, { path: routeFilePath, - nameAndDirectoryFormat: 'as-provided', }); } diff --git a/packages/remix/src/generators/resource-route/schema.d.ts b/packages/remix/src/generators/resource-route/schema.d.ts index 3c7b8735f4550..48ec380738c7c 100644 --- a/packages/remix/src/generators/resource-route/schema.d.ts +++ b/packages/remix/src/generators/resource-route/schema.d.ts @@ -1,5 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface RemixRouteSchema { path: string; action: boolean; diff --git a/packages/remix/src/generators/route/__snapshots__/route.impl.spec.ts.snap b/packages/remix/src/generators/route/__snapshots__/route.impl.spec.ts.snap index 1671e13439b3a..16e7124ac2fc7 100644 --- a/packages/remix/src/generators/route/__snapshots__/route.impl.spec.ts.snap +++ b/packages/remix/src/generators/route/__snapshots__/route.impl.spec.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`route --nameAndDirectoryFormat=apps/demo/app/routes/path/to/example should add route component 1`] = ` +exports[`route should add route component 1`] = ` "import { useLoaderData, useActionData } from '@remix-run/react'; import { json } from '@remix-run/node'; import type { @@ -41,8 +41,8 @@ export default function Example() { " `; -exports[`route --nameAndDirectoryFormat=apps/demo/app/routes/path/to/example should error if it detects a possible missing route param because of un-escaped dollar sign 1`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`; +exports[`route should error if it detects a possible missing route param because of un-escaped dollar sign 1`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`; -exports[`route --nameAndDirectoryFormat=apps/demo/app/routes/path/to/example should error if it detects a possible missing route param because of un-escaped dollar sign 2`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`; +exports[`route should error if it detects a possible missing route param because of un-escaped dollar sign 2`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`; -exports[`route --nameAndDirectoryFormat=apps/demo/app/routes/path/to/example should error if it detects a possible missing route param because of un-escaped dollar sign 3`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`; +exports[`route should error if it detects a possible missing route param because of un-escaped dollar sign 3`] = `[Error: Your route path has an indicator of an un-escaped dollar sign for a route param. If this was intended, include the --skipChecks flag.]`; diff --git a/packages/remix/src/generators/route/route.impl.spec.ts b/packages/remix/src/generators/route/route.impl.spec.ts index 49c3b97c339a3..4481bfb9dd544 100644 --- a/packages/remix/src/generators/route/route.impl.spec.ts +++ b/packages/remix/src/generators/route/route.impl.spec.ts @@ -10,6 +10,11 @@ import routeGenerator from './route.impl'; describe('route', () => { let tree: Tree; + const path = 'apps/demo/app/routes/path/to/example'; + const standalonePath = 'app/routes'; + const expectedRoutePath = 'apps/demo/app/routes/path/to/example.tsx'; + const expectedStylePath = 'apps/demo/app/styles/path/to/example.css'; + const expectedComponentName = 'Example'; beforeEach(() => { tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' }); @@ -21,217 +26,198 @@ describe('route', () => { }) ); }); - describe.each([ - [ - 'apps/demo/app/routes/path/to/example', - 'app/routes', - 'apps/demo/app/routes/path/to/example.tsx', - 'apps/demo/app/styles/path/to/example.css', - 'Example', - '', - ], - ])( - `--nameAndDirectoryFormat=%s`, - ( + + it('should add route component', async () => { + await applicationGenerator(tree, { + name: 'demo', + directory: 'apps/demo', + }); + await routeGenerator(tree, { + path, + style: 'css', + loader: true, + action: true, + meta: true, + skipChecks: false, + }); + + const content = tree.read(expectedRoutePath, 'utf-8'); + expect(content).toMatchSnapshot(); + expect(content).toMatch('LinksFunction'); + expect(content).toMatch(`function ${expectedComponentName}(`); + expect(tree.exists(expectedStylePath)).toBeTruthy(); + }, 25_000); + + it('should support --style=none', async () => { + await applicationGenerator(tree, { + name: 'demo', + directory: 'apps/demo', + }); + await routeGenerator(tree, { path, - standalonePath, - expectedRoutePath, - expectedStylePath, - expectedComponentName - ) => { - it('should add route component', async () => { - await applicationGenerator(tree, { - name: 'demo', - directory: 'apps/demo', - }); - await routeGenerator(tree, { - path, - style: 'css', - loader: true, - action: true, - meta: true, - skipChecks: false, - }); - - const content = tree.read(expectedRoutePath, 'utf-8'); - expect(content).toMatchSnapshot(); - expect(content).toMatch('LinksFunction'); - expect(content).toMatch(`function ${expectedComponentName}(`); - expect(tree.exists(expectedStylePath)).toBeTruthy(); - }, 25_000); - - it('should support --style=none', async () => { - await applicationGenerator(tree, { - name: 'demo', - directory: 'apps/demo', - }); - await routeGenerator(tree, { - path, - style: 'none', - loader: true, - action: true, - meta: true, - skipChecks: false, - }); - - const content = tree.read(expectedRoutePath).toString(); - expect(content).not.toMatch('LinksFunction'); - expect(tree.exists(expectedStylePath)).toBeFalsy(); - }); - - it('should handle trailing and prefix slashes', async () => { - await applicationGenerator(tree, { - name: 'demo', - directory: 'apps/demo', - }); - await routeGenerator(tree, { - path: `/${path}/`, - style: 'css', - loader: true, - action: true, - meta: true, - skipChecks: false, - }); - - const content = tree.read(expectedRoutePath).toString(); - expect(content).toMatch(`function ${expectedComponentName}(`); - }); - - it('should handle routes that end in a file', async () => { - await applicationGenerator(tree, { - name: 'demo', - directory: 'apps/demo', - }); - await routeGenerator(tree, { - path: `${path}.tsx`, - style: 'css', - loader: true, - action: true, - meta: true, - skipChecks: false, - }); - - const content = tree.read(expectedRoutePath).toString(); - expect(content).toMatch(`function ${expectedComponentName}(`); - }); - - it('should handle routes that have a param', async () => { - const componentName = 'WithParam'; - - await applicationGenerator(tree, { - name: 'demo', - directory: 'apps/demo', - }); - await routeGenerator(tree, { - path: `/${path}/$withParam.tsx`, - style: 'css', - loader: true, - action: true, - meta: true, - skipChecks: false, - }); - - const content = tree - .read('apps/demo/app/routes/path/to/example/$withParam.tsx') - .toString(); - expect(content).toMatch(`function ${componentName}(`); - }); - - it('should error if it detects a possible missing route param because of un-escaped dollar sign', async () => { - await applicationGenerator(tree, { - name: 'demo', - directory: 'apps/demo', - }); - - expect.assertions(3); - - await routeGenerator(tree, { - path: `${path}/route1/.tsx`, // route.$withParams.tsx => route..tsx - style: 'css', - loader: true, - action: true, - meta: true, - skipChecks: false, - }).catch((e) => expect(e).toMatchSnapshot()); - - await routeGenerator(tree, { - path: `${path}/route2//index.tsx`, // route/$withParams/index.tsx => route//index.tsx - style: 'css', - loader: true, - action: true, - meta: true, - skipChecks: false, - }).catch((e) => expect(e).toMatchSnapshot()); - - await routeGenerator(tree, { - path: `${path}/route3/.tsx`, // route/$withParams.tsx => route/.tsx - style: 'css', - loader: true, - action: true, - meta: true, - skipChecks: false, - }).catch((e) => expect(e).toMatchSnapshot()); - }); - - it('should succeed if skipChecks flag is passed, and it detects a possible missing route param because of un-escaped dollar sign', async () => { - await applicationGenerator(tree, { - name: 'demo', - directory: 'apps/demo', - }); - - await routeGenerator(tree, { - path: `${path}/route1/..tsx`, // route.$withParams.tsx => route..tsx - style: 'css', - loader: true, - action: true, - meta: true, - skipChecks: true, - }); - - expect( - tree.exists('apps/demo/app/routes/path/to/example/route1/..tsx') - ).toBe(true); - - await routeGenerator(tree, { - path: `${path}/route2//index.tsx`, // route/$withParams/index.tsx => route//index.tsx - style: 'css', - loader: true, - action: true, - meta: true, - skipChecks: true, - }); - - expect( - tree.exists('apps/demo/app/routes/path/to/example/route2/index.tsx') - ).toBe(true); - - await routeGenerator(tree, { - path: `${path}/route3/.tsx`, // route/$withParams.tsx => route/.tsx - style: 'css', - loader: true, - action: true, - meta: true, - skipChecks: true, - }); - - expect( - tree.exists('apps/demo/app/routes/path/to/example/route3/.tsx') - ).toBe(true); - }, 120000); - it('should place the route correctly in a standalone app', async () => { - await presetGenerator(tree, { name: 'demo' }); - - await routeGenerator(tree, { - path: `${standalonePath}/route.tsx`, - style: 'none', - loader: true, - action: true, - meta: true, - skipChecks: false, - }); - - expect(tree.exists('app/routes/route.tsx')).toBe(true); - }); - } - ); + style: 'none', + loader: true, + action: true, + meta: true, + skipChecks: false, + }); + + const content = tree.read(expectedRoutePath).toString(); + expect(content).not.toMatch('LinksFunction'); + expect(tree.exists(expectedStylePath)).toBeFalsy(); + }); + + it('should handle trailing and prefix slashes', async () => { + await applicationGenerator(tree, { + name: 'demo', + directory: 'apps/demo', + }); + await routeGenerator(tree, { + path: `/${path}/`, + style: 'css', + loader: true, + action: true, + meta: true, + skipChecks: false, + }); + + const content = tree.read(expectedRoutePath).toString(); + expect(content).toMatch(`function ${expectedComponentName}(`); + }); + + it('should handle routes that end in a file', async () => { + await applicationGenerator(tree, { + name: 'demo', + directory: 'apps/demo', + }); + await routeGenerator(tree, { + path: `${path}.tsx`, + style: 'css', + loader: true, + action: true, + meta: true, + skipChecks: false, + }); + + const content = tree.read(expectedRoutePath).toString(); + expect(content).toMatch(`function ${expectedComponentName}(`); + }); + + it('should handle routes that have a param', async () => { + const componentName = 'WithParam'; + + await applicationGenerator(tree, { + name: 'demo', + directory: 'apps/demo', + }); + await routeGenerator(tree, { + path: `/${path}/$withParam.tsx`, + style: 'css', + loader: true, + action: true, + meta: true, + skipChecks: false, + }); + + const content = tree + .read('apps/demo/app/routes/path/to/example/$withParam.tsx') + .toString(); + expect(content).toMatch(`function ${componentName}(`); + }); + + it('should error if it detects a possible missing route param because of un-escaped dollar sign', async () => { + await applicationGenerator(tree, { + name: 'demo', + directory: 'apps/demo', + }); + + expect.assertions(3); + + await routeGenerator(tree, { + path: `${path}/route1/.tsx`, // route.$withParams.tsx => route..tsx + style: 'css', + loader: true, + action: true, + meta: true, + skipChecks: false, + }).catch((e) => expect(e).toMatchSnapshot()); + + await routeGenerator(tree, { + path: `${path}/route2//index.tsx`, // route/$withParams/index.tsx => route//index.tsx + style: 'css', + loader: true, + action: true, + meta: true, + skipChecks: false, + }).catch((e) => expect(e).toMatchSnapshot()); + + await routeGenerator(tree, { + path: `${path}/route3/.tsx`, // route/$withParams.tsx => route/.tsx + style: 'css', + loader: true, + action: true, + meta: true, + skipChecks: false, + }).catch((e) => expect(e).toMatchSnapshot()); + }); + + it('should succeed if skipChecks flag is passed, and it detects a possible missing route param because of un-escaped dollar sign', async () => { + await applicationGenerator(tree, { + name: 'demo', + directory: 'apps/demo', + }); + + await routeGenerator(tree, { + path: `${path}/route1/..tsx`, // route.$withParams.tsx => route..tsx + style: 'css', + loader: true, + action: true, + meta: true, + skipChecks: true, + }); + + expect( + tree.exists('apps/demo/app/routes/path/to/example/route1/..tsx') + ).toBe(true); + + await routeGenerator(tree, { + path: `${path}/route2//index.tsx`, // route/$withParams/index.tsx => route//index.tsx + style: 'css', + loader: true, + action: true, + meta: true, + skipChecks: true, + }); + + expect( + tree.exists('apps/demo/app/routes/path/to/example/route2/index.tsx') + ).toBe(true); + + await routeGenerator(tree, { + path: `${path}/route3/.tsx`, // route/$withParams.tsx => route/.tsx + style: 'css', + loader: true, + action: true, + meta: true, + skipChecks: true, + }); + + expect( + tree.exists('apps/demo/app/routes/path/to/example/route3/.tsx') + ).toBe(true); + }, 120000); + it('should place the route correctly in a standalone app', async () => { + await presetGenerator(tree, { name: 'demo' }); + + await routeGenerator(tree, { + path: `${standalonePath}/route.tsx`, + style: 'none', + loader: true, + action: true, + meta: true, + skipChecks: false, + }); + + expect(tree.exists('app/routes/route.tsx')).toBe(true); + }); }); diff --git a/packages/remix/src/generators/route/route.impl.ts b/packages/remix/src/generators/route/route.impl.ts index bed9f8677cfed..f5a5cb6bbbae8 100644 --- a/packages/remix/src/generators/route/route.impl.ts +++ b/packages/remix/src/generators/route/route.impl.ts @@ -77,21 +77,18 @@ export default async function (tree: Tree, options: RemixRouteSchema) { if (options.loader) { await LoaderGenerator(tree, { path: routeFilePath, - nameAndDirectoryFormat: 'as-provided', }); } if (options.meta) { await MetaGenerator(tree, { path: routeFilePath, - nameAndDirectoryFormat: 'as-provided', }); } if (options.action) { await ActionGenerator(tree, { path: routeFilePath, - nameAndDirectoryFormat: 'as-provided', }); } diff --git a/packages/remix/src/generators/route/schema.d.ts b/packages/remix/src/generators/route/schema.d.ts index c3e18fbfe6460..419d711f9e409 100644 --- a/packages/remix/src/generators/route/schema.d.ts +++ b/packages/remix/src/generators/route/schema.d.ts @@ -1,5 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface RemixRouteSchema { path: string; style: 'css' | 'none'; diff --git a/packages/remix/src/generators/style/schema.d.ts b/packages/remix/src/generators/style/schema.d.ts index 1179f9acee41c..3645156475264 100644 --- a/packages/remix/src/generators/style/schema.d.ts +++ b/packages/remix/src/generators/style/schema.d.ts @@ -1,5 +1,3 @@ -import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils'; - export interface RemixStyleSchema { path: string; } diff --git a/packages/remix/src/generators/style/style.impl.spec.ts b/packages/remix/src/generators/style/style.impl.spec.ts index 3033d88a94436..83074d8b82ae2 100644 --- a/packages/remix/src/generators/style/style.impl.spec.ts +++ b/packages/remix/src/generators/style/style.impl.spec.ts @@ -129,27 +129,4 @@ describe('style', () => { "import stylesUrl from '~/styles/example/$withParam.css';" ); }); - - it('--nameAndDirectoryFormat=as-provided', async () => { - await applicationGenerator(tree, { name: 'demo', directory: 'apps/demo' }); - await routeGenerator(tree, { - path: 'apps/demo/app/routes/example/$withParam.tsx', - style: 'none', - loader: false, - action: false, - meta: false, - skipChecks: false, - }); - await styleGenerator(tree, { - path: 'apps/demo/app/routes/example/$withParam.tsx', - }); - const content = tree.read( - 'apps/demo/app/routes/example/$withParam.tsx', - 'utf-8' - ); - - expect(content).toMatch( - "import stylesUrl from '../../styles/example/$withParam.css';" - ); - }); }); diff --git a/packages/vue/docs/application-examples.md b/packages/vue/docs/application-examples.md index ec66ddd9945ed..bdc1ad622a72b 100644 --- a/packages/vue/docs/application-examples.md +++ b/packages/vue/docs/application-examples.md @@ -16,14 +16,10 @@ nx g @nx/vue:app apps/my-app {% /tab %} -{% tab label="Specify directory and style extension" %} +{% tab label="Specify style extension" %} Create an application named `my-app` in the `my-dir` directory and use `scss` for styles: -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=my-dir`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```shell nx g @nx/vue:app apps/my-dir/my-app --style=scss ``` diff --git a/packages/vue/src/generators/component/component.spec.ts b/packages/vue/src/generators/component/component.spec.ts index 95717566c731c..e023e6f6e2250 100644 --- a/packages/vue/src/generators/component/component.spec.ts +++ b/packages/vue/src/generators/component/component.spec.ts @@ -24,7 +24,6 @@ describe('component', () => { it('should generate files with vitest', async () => { await componentGenerator(appTree, { - name: 'hello', path: `${libName}/src/lib/hello/hello`, }); @@ -58,7 +57,6 @@ describe('component', () => { it('should have correct component name based on directory', async () => { await componentGenerator(appTree, { - name: 'hello-world', path: `${libName}/src/foo/bar/hello-world/hello-world`, }); @@ -72,7 +70,6 @@ describe('component', () => { it('should generate files for an app', async () => { await componentGenerator(appTree, { - name: 'hello', path: `${appName}/src/app/hello/hello`, }); @@ -87,7 +84,6 @@ describe('component', () => { describe('--export', () => { it('should add to index.ts barrel', async () => { await componentGenerator(appTree, { - name: 'hello', path: `${libName}/src/lib/hello/hello`, export: true, }); @@ -100,7 +96,6 @@ describe('component', () => { it('should not export from an app', async () => { await componentGenerator(appTree, { - name: 'hello', path: `${appName}/src/app/hello/hello`, export: true, }); diff --git a/packages/vue/src/generators/component/lib/utils.ts b/packages/vue/src/generators/component/lib/utils.ts index 583ee57a12205..d2f458d0ae279 100644 --- a/packages/vue/src/generators/component/lib/utils.ts +++ b/packages/vue/src/generators/component/lib/utils.ts @@ -26,7 +26,6 @@ export async function normalizeOptions( directory, project: projectName, } = await determineArtifactNameAndDirectoryOptions(host, { - name: options.name, path: options.path, fileExtension: 'vue', }); diff --git a/packages/vue/src/generators/component/schema.d.ts b/packages/vue/src/generators/component/schema.d.ts index 7aab8ca539eab..d0dc390799618 100644 --- a/packages/vue/src/generators/component/schema.d.ts +++ b/packages/vue/src/generators/component/schema.d.ts @@ -1,6 +1,5 @@ export interface ComponentGeneratorSchema { path: string; - name?: string; skipTests?: boolean; export?: boolean; routing?: boolean; diff --git a/packages/vue/src/generators/component/schema.json b/packages/vue/src/generators/component/schema.json index cb366f5de2f55..980176fce8071 100644 --- a/packages/vue/src/generators/component/schema.json +++ b/packages/vue/src/generators/component/schema.json @@ -7,29 +7,19 @@ "type": "object", "examples": [ { - "command": "nx g @nx/vue:component my-app/src/app/one --name=one --unitTestRunner=vitest", - "description": "Generate a component `one` in the `my-app` application at my-app/src/app/one" - }, - { - "command": "nx g @nx/vue:component my-app/src/app/one", - "description": "Generate a component `one` in the `my-app` application at my-app/src/app/one" + "description": "Generate a component at `mylib/src/lib/foo.vue` with `vitest` as the unit test runner", + "command": "nx g @nx/vue:component mylib/src/lib/foo --unitTestRunner=vitest" } ], "properties": { "path": { "type": "string", - "description": "Path where the component will be generated.", + "description": "The file path to the component without the file extension. Relative to the current working directory.", "$default": { "$source": "argv", "index": 0 }, - "x-prompt": "Where should the component be generated?", - "x-priority": "important" - }, - "name": { - "type": "string", - "description": "The name of the component.", - "x-prompt": "What name would you like to use for the component?" + "x-prompt": "What is the component file path?" }, "js": { "type": "boolean", diff --git a/packages/vue/src/generators/storybook-configuration/configuration.spec.ts b/packages/vue/src/generators/storybook-configuration/configuration.spec.ts index 7866fccd315f0..afd7832e9efe5 100644 --- a/packages/vue/src/generators/storybook-configuration/configuration.spec.ts +++ b/packages/vue/src/generators/storybook-configuration/configuration.spec.ts @@ -168,7 +168,6 @@ export async function createTestAppLib( }); await componentGenerator(appTree, { - name: 'my-component', path: `${libName}/src/app/my-component/my-component`, }); diff --git a/packages/web/docs/application-examples.md b/packages/web/docs/application-examples.md index 7fc44d7716474..16d34c0ae11fc 100644 --- a/packages/web/docs/application-examples.md +++ b/packages/web/docs/application-examples.md @@ -23,14 +23,10 @@ When choosing `vite` as the bundler, your unit tests will be set up with `vitest {% /tab %} -{% tab label="Specify directory" %} +{% tab label="In a nested directory" %} Create an application named `my-app` in the `my-dir` directory: -{% callout type="note" title="Directory Flag Behavior Changes" %} -The command below uses the `as-provided` directory flag behavior, which is the default in Nx 16.8.0. If you're on an earlier version of Nx or using the `derived` option, use `--directory=my-dir`. See the [as-provided vs. derived documentation](/deprecated/as-provided-vs-derived) for more details. -{% /callout %} - ```bash nx g @nx/web:app apps/my-dir/my-app ```