Jack Hsu 27edf71cef
feat(misc): make directory a required option for generators (#28093)
<!-- 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
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

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

Fixes #

---------

Co-authored-by: Colum Ferry <cferry09@gmail.com>
Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
2024-10-01 09:29:44 -04:00

212 lines
9.6 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
},
"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", "none"],
"description": "Test runner to use for unit tests.",
"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"
},
"standaloneConfig": {
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
"type": "boolean",
"default": true,
"x-deprecated": "Nx only supports standaloneConfig"
},
"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{% 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",
"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"
}