Jack Hsu 57e70d0e91
feat(js): deprecate simpleName option in library generator (#31673)
The simpleName option is no longer useful as we've moved to using
options "as provided" without transformation. Users should provide the
exact name, directory, and import path they want to use.

## Changes
- Add x-deprecated to schema.json marking for removal in Nx 22
- Add runtime warning when simpleName is used


🤖 Generated with [Claude Code](https://claude.ai/code)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
Users are confused with `--simpleName` with using `--name` AND
`--directory`

## Expected Behavior
We should tell users that only `--name` should be used.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #29508

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-06-20 21:39:55 -04:00

208 lines
9.2 KiB
JSON

{
"name": "library",
"factory": "./src/generators/library/library",
"schema": {
"$schema": "https://json-schema.org/schema",
"$id": "GeneratorAngularLibrary",
"title": "Create a library",
"description": "Creates an Angular library.",
"type": "object",
"cli": "nx",
"properties": {
"name": {
"type": "string",
"description": "The name of the library.",
"x-priority": "important"
},
"directory": {
"type": "string",
"description": "A directory where the library is placed.",
"$default": { "$source": "argv", "index": 0 },
"x-prompt": "Which directory do you want to create the library in?"
},
"publishable": {
"type": "boolean",
"default": false,
"description": "Generate a publishable library.",
"x-priority": "important"
},
"buildable": {
"type": "boolean",
"default": false,
"description": "Generate a buildable library.",
"x-priority": "important"
},
"prefix": {
"type": "string",
"format": "html-selector",
"description": "The prefix to apply to generated selectors.",
"alias": "p"
},
"skipFormat": {
"description": "Skip formatting files.",
"type": "boolean",
"default": false,
"x-priority": "internal"
},
"simpleName": {
"description": "Don't include the directory in the name of the module or standalone component entry of the library.",
"type": "boolean",
"default": false,
"x-deprecated": "Use the --name option to provide the exact name instead. This option will be removed in Nx 22."
},
"addModuleSpec": {
"description": "Add a module spec file.",
"type": "boolean",
"default": false
},
"skipPackageJson": {
"type": "boolean",
"default": false,
"description": "Do not add dependencies to `package.json`.",
"x-priority": "internal"
},
"skipTsConfig": {
"type": "boolean",
"default": false,
"description": "Do not update `tsconfig.json` for development experience."
},
"routing": {
"type": "boolean",
"default": false,
"description": "Add router configuration. See `lazy` for more information.",
"x-priority": "important"
},
"lazy": {
"type": "boolean",
"default": false,
"description": "Add `RouterModule.forChild` when set to true, and a simple array of routes when set to false.",
"x-priority": "important"
},
"parent": {
"type": "string",
"description": "Path to the parent route configuration using `loadChildren` or `children`, depending on what `lazy` is set to.",
"x-priority": "important"
},
"tags": {
"type": "string",
"description": "Add tags to the library (used for linting)."
},
"unitTestRunner": {
"type": "string",
"enum": ["jest", "vitest", "none"],
"description": "Test runner to use for unit tests.",
"x-prompt": "Which unit test runner would you like to use?",
"default": "jest"
},
"importPath": {
"type": "string",
"description": "The library name used to import it, like `@myorg/my-awesome-lib`. Must be a valid npm name."
},
"strict": {
"type": "boolean",
"description": "Create a library with stricter type checking and build optimization options.",
"default": true
},
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "none"],
"default": "eslint"
},
"compilationMode": {
"description": "Specifies the compilation mode to use. If not specified, it will default to `partial` for publishable libraries and to `full` for buildable libraries. The `full` value can not be used for publishable libraries.",
"type": "string",
"enum": ["full", "partial"]
},
"setParserOptionsProject": {
"type": "boolean",
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
"default": false
},
"addTailwind": {
"type": "boolean",
"description": "Whether to configure Tailwind CSS for the application. It can only be used with buildable and publishable libraries. Non-buildable libraries will use the application's Tailwind configuration.",
"default": false
},
"skipModule": {
"type": "boolean",
"description": "Whether to skip the creation of a default module when generating the library.",
"default": false
},
"standalone": {
"type": "boolean",
"description": "Generate a library that uses a standalone component instead of a module as the entry point.",
"default": true
},
"displayBlock": {
"description": "Specifies if the component generated style will contain `:host { display: block; }`. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
"type": "boolean",
"default": false,
"alias": "b"
},
"inlineStyle": {
"description": "Include styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
"type": "boolean",
"default": false,
"alias": "s"
},
"inlineTemplate": {
"description": "Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
"type": "boolean",
"default": false,
"alias": "t"
},
"viewEncapsulation": {
"description": "The view encapsulation strategy to use in the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
"enum": ["Emulated", "None", "ShadowDom"],
"type": "string",
"alias": "v"
},
"changeDetection": {
"description": "The change detection strategy to use in the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
"enum": ["Default", "OnPush"],
"type": "string",
"default": "Default",
"alias": "c"
},
"style": {
"description": "The file extension or preprocessor to use for style files, or `none` to skip generating the style file. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
"type": "string",
"default": "css",
"enum": ["css", "scss", "sass", "less", "none"]
},
"skipTests": {
"type": "boolean",
"description": "Do not create `spec.ts` test files for the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
"default": false
},
"selector": {
"type": "string",
"format": "html-selector",
"description": "The HTML selector to use for this component. Disclaimer: This option is only valid when `--standalone` is set to `true`."
},
"skipSelector": {
"type": "boolean",
"default": false,
"description": "Specifies if the component should have a selector or not. Disclaimer: This option is only valid when `--standalone` is set to `true`."
},
"flat": {
"type": "boolean",
"default": false,
"description": "Ensure the generated standalone component is not placed in a subdirectory. Disclaimer: This option is only valid when `--standalone` is set to `true`."
}
},
"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```bash\nnx g @nx/angular:library libs/nested/my-lib --importPath=@myorg/nested/my-lib\n```\n\n{% /tab %}\n",
"presets": []
},
"aliases": ["lib"],
"x-type": "library",
"description": "Creates an Angular library.",
"implementation": "/packages/angular/src/generators/library/library.ts",
"hidden": false,
"path": "/packages/angular/src/generators/library/schema.json",
"type": "generator"
}