@nx/angular 17.0.0-beta.1 → 17.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/executors.json +0 -20
- package/generators.d.ts +1 -0
- package/generators.js +1 -0
- package/generators.json +7 -149
- package/package.json +11 -11
- package/src/executors/ng-packagr-lite/schema.json +0 -13
- package/src/executors/package/package.impl.js +2 -8
- package/src/executors/package/schema.d.ts +0 -12
- package/src/executors/package/schema.json +0 -13
- package/src/generators/component/component.d.ts +1 -0
- package/src/generators/component/component.js +17 -13
- package/src/generators/component/files/__fileName__.html__tpl__ +1 -0
- package/src/generators/component/files/__fileName__.spec.ts__tpl__ +22 -0
- package/src/generators/component/files/{__fileName__.__type__.ts__tpl__ → __fileName__.ts__tpl__} +4 -4
- package/src/generators/component/lib/module.js +2 -2
- package/src/generators/component/lib/normalize-options.d.ts +1 -1
- package/src/generators/component/lib/normalize-options.js +19 -6
- package/src/generators/component/lib/validate-options.js +0 -2
- package/src/generators/component/schema.d.ts +21 -3
- package/src/generators/component/schema.json +24 -17
- package/src/generators/directive/directive.js +6 -7
- package/src/generators/directive/files/__fileName__.spec.ts__tpl__ +8 -0
- package/src/generators/directive/files/{__directiveFileName__.directive.ts__tpl__ → __fileName__.ts__tpl__} +1 -1
- package/src/generators/directive/lib/normalize-options.d.ts +1 -1
- package/src/generators/directive/lib/normalize-options.js +20 -8
- package/src/generators/directive/lib/validate-options.js +0 -2
- package/src/generators/directive/schema.d.ts +20 -4
- package/src/generators/directive/schema.json +15 -11
- package/src/generators/federate-module/federate-module.d.ts +4 -0
- package/src/generators/federate-module/federate-module.js +39 -0
- package/src/generators/federate-module/lib/add-file-to-remote-tsconfig.d.ts +2 -0
- package/src/generators/federate-module/lib/add-file-to-remote-tsconfig.js +15 -0
- package/src/generators/federate-module/lib/add-path-to-exposes.d.ts +8 -0
- package/src/generators/federate-module/lib/add-path-to-exposes.js +78 -0
- package/src/generators/federate-module/lib/add-path-to-ts-config.d.ts +8 -0
- package/src/generators/federate-module/lib/add-path-to-ts-config.js +12 -0
- package/src/generators/federate-module/lib/add-remote.d.ts +7 -0
- package/src/generators/federate-module/lib/add-remote.js +47 -0
- package/src/generators/federate-module/lib/check-remote-exists.d.ts +2 -0
- package/src/generators/federate-module/lib/check-remote-exists.js +22 -0
- package/src/generators/federate-module/lib/index.d.ts +4 -0
- package/src/generators/federate-module/lib/index.js +7 -0
- package/src/generators/federate-module/schema.d.ts +14 -0
- package/src/generators/federate-module/schema.json +77 -0
- package/src/generators/move/lib/update-ng-package.js +3 -6
- package/src/generators/pipe/files/__fileName__.spec.ts__tpl__ +8 -0
- package/src/generators/pipe/files/{__pipeFileName__.pipe.ts__tpl__ → __fileName__.ts__tpl__} +2 -2
- package/src/generators/pipe/lib/normalize-options.d.ts +1 -1
- package/src/generators/pipe/lib/normalize-options.js +20 -7
- package/src/generators/pipe/lib/validate-options.js +0 -2
- package/src/generators/pipe/pipe.js +7 -7
- package/src/generators/pipe/schema.d.ts +20 -4
- package/src/generators/pipe/schema.json +15 -11
- package/src/generators/scam/lib/convert-component-to-scam.js +3 -6
- package/src/generators/scam/lib/normalize-options.d.ts +1 -1
- package/src/generators/scam/lib/normalize-options.js +18 -5
- package/src/generators/scam/scam.js +1 -1
- package/src/generators/scam/schema.d.ts +18 -3
- package/src/generators/scam/schema.json +25 -18
- package/src/generators/scam-directive/lib/convert-directive-to-scam.js +3 -6
- package/src/generators/scam-directive/lib/normalize-options.d.ts +1 -1
- package/src/generators/scam-directive/lib/normalize-options.js +17 -7
- package/src/generators/scam-directive/scam-directive.js +1 -1
- package/src/generators/scam-directive/schema.d.ts +18 -5
- package/src/generators/scam-directive/schema.json +24 -17
- package/src/generators/scam-pipe/lib/convert-pipe-to-scam.js +3 -6
- package/src/generators/scam-pipe/lib/normalize-options.d.ts +1 -1
- package/src/generators/scam-pipe/lib/normalize-options.js +17 -7
- package/src/generators/scam-pipe/scam-pipe.js +1 -1
- package/src/generators/scam-pipe/schema.d.ts +18 -5
- package/src/generators/scam-pipe/schema.json +23 -16
- package/src/generators/utils/find-module.js +4 -1
- package/src/executors/browser-esbuild/compat.d.ts +0 -2
- package/src/executors/browser-esbuild/compat.js +0 -5
- package/src/executors/delegate-build/compat.d.ts +0 -2
- package/src/executors/delegate-build/compat.js +0 -5
- package/src/executors/ng-packagr-lite/compat.d.ts +0 -2
- package/src/executors/ng-packagr-lite/compat.js +0 -5
- package/src/executors/package/compat.d.ts +0 -2
- package/src/executors/package/compat.js +0 -5
- package/src/generators/add-linting/compat.d.ts +0 -2
- package/src/generators/add-linting/compat.js +0 -6
- package/src/generators/application/application.compat.d.ts +0 -1
- package/src/generators/application/application.compat.js +0 -7
- package/src/generators/component/component.compat.d.ts +0 -2
- package/src/generators/component/component.compat.js +0 -6
- package/src/generators/component/files/__fileName__.__type__.html__tpl__ +0 -1
- package/src/generators/component/files/__fileName__.__type__.spec.ts__tpl__ +0 -22
- package/src/generators/component-cypress-spec/compat.d.ts +0 -2
- package/src/generators/component-cypress-spec/compat.js +0 -6
- package/src/generators/component-story/compat.d.ts +0 -2
- package/src/generators/component-story/compat.js +0 -6
- package/src/generators/component-test/compat.d.ts +0 -2
- package/src/generators/component-test/compat.js +0 -6
- package/src/generators/convert-to-with-mf/convert-to-with-mf.compat.d.ts +0 -2
- package/src/generators/convert-to-with-mf/convert-to-with-mf.compat.js +0 -6
- package/src/generators/cypress-component-configuration/compat.d.ts +0 -2
- package/src/generators/cypress-component-configuration/compat.js +0 -6
- package/src/generators/directive/files/__directiveFileName__.directive.spec.ts__tpl__ +0 -8
- package/src/generators/host/host.compat.d.ts +0 -2
- package/src/generators/host/host.compat.js +0 -6
- package/src/generators/init/init.compat.d.ts +0 -1
- package/src/generators/init/init.compat.js +0 -7
- package/src/generators/library/library.compat.d.ts +0 -1
- package/src/generators/library/library.compat.js +0 -7
- package/src/generators/library-secondary-entry-point/compat.d.ts +0 -2
- package/src/generators/library-secondary-entry-point/compat.js +0 -6
- package/src/generators/move/compat.d.ts +0 -1
- package/src/generators/move/compat.js +0 -7
- package/src/generators/ng-add/compat.d.ts +0 -2
- package/src/generators/ng-add/compat.js +0 -5
- package/src/generators/ngrx/compat.d.ts +0 -2
- package/src/generators/ngrx/compat.js +0 -6
- package/src/generators/pipe/files/__pipeFileName__.pipe.spec.ts__tpl__ +0 -8
- package/src/generators/remote/remote.compat.d.ts +0 -2
- package/src/generators/remote/remote.compat.js +0 -6
- package/src/generators/scam/scam.compat.d.ts +0 -2
- package/src/generators/scam/scam.compat.js +0 -6
- package/src/generators/scam-directive/scam-directive.compat.d.ts +0 -2
- package/src/generators/scam-directive/scam-directive.compat.js +0 -6
- package/src/generators/scam-pipe/scam-pipe.compat.d.ts +0 -2
- package/src/generators/scam-pipe/scam-pipe.compat.js +0 -6
- package/src/generators/scam-to-standalone/compat.d.ts +0 -2
- package/src/generators/scam-to-standalone/compat.js +0 -6
- package/src/generators/setup-mf/setup-mf.compat.d.ts +0 -2
- package/src/generators/setup-mf/setup-mf.compat.js +0 -6
- package/src/generators/setup-ssr/setup-ssr.compat.d.ts +0 -2
- package/src/generators/setup-ssr/setup-ssr.compat.js +0 -6
- package/src/generators/setup-tailwind/setup-tailwind.compat.d.ts +0 -2
- package/src/generators/setup-tailwind/setup-tailwind.compat.js +0 -6
- package/src/generators/stories/compat.d.ts +0 -2
- package/src/generators/stories/compat.js +0 -6
- package/src/generators/storybook-configuration/compat.d.ts +0 -2
- package/src/generators/storybook-configuration/compat.js +0 -6
- package/src/generators/utils/warn-for-schematic-usage.d.ts +0 -1
- package/src/generators/utils/warn-for-schematic-usage.js +0 -8
- package/src/generators/web-worker/compat.d.ts +0 -2
- package/src/generators/web-worker/compat.js +0 -6
- /package/src/generators/component/files/{__fileName__.__type__.__style__ → __fileName__.__style__} +0 -0
|
@@ -14,12 +14,9 @@ function updateNgPackage(tree, schema) {
|
|
|
14
14
|
}
|
|
15
15
|
const rootOffset = (0, devkit_1.normalizePath)((0, path_1.relative)((0, path_1.join)(devkit_1.workspaceRoot, project.root), devkit_1.workspaceRoot));
|
|
16
16
|
const outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
overrides: {},
|
|
22
|
-
}, {
|
|
17
|
+
project: schema.newProjectName,
|
|
18
|
+
target: 'build',
|
|
19
|
+
}, {}, {
|
|
23
20
|
name: schema.newProjectName,
|
|
24
21
|
type: 'lib',
|
|
25
22
|
data: {
|
package/src/generators/pipe/files/{__pipeFileName__.pipe.ts__tpl__ → __fileName__.ts__tpl__}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
@Pipe({
|
|
4
|
-
name: '<%=
|
|
4
|
+
name: '<%= selector %>'<% if(standalone) {%>,
|
|
5
5
|
standalone: true<%}%>
|
|
6
6
|
})
|
|
7
|
-
export class <%=
|
|
7
|
+
export class <%= symbolName %> implements PipeTransform {
|
|
8
8
|
|
|
9
9
|
transform(value: unknown, ...args: unknown[]): unknown {
|
|
10
10
|
return null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
2
|
import type { NormalizedSchema, Schema } from '../schema';
|
|
3
|
-
export declare function normalizeOptions(tree: Tree, options: Schema): NormalizedSchema
|
|
3
|
+
export declare function normalizeOptions(tree: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
async function normalizeOptions(tree, options) {
|
|
7
|
+
const { artifactName: name, directory, fileName, filePath, project, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
8
|
+
artifactType: 'pipe',
|
|
9
|
+
callingGenerator: '@nx/angular:pipe',
|
|
10
|
+
name: options.name,
|
|
11
|
+
directory: options.directory ?? options.path,
|
|
12
|
+
flat: options.flat,
|
|
13
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
14
|
+
project: options.project,
|
|
15
|
+
suffix: 'pipe',
|
|
9
16
|
});
|
|
17
|
+
const { className } = (0, devkit_1.names)(name);
|
|
18
|
+
const { className: suffixClassName } = (0, devkit_1.names)('pipe');
|
|
19
|
+
const symbolName = `${className}${suffixClassName}`;
|
|
10
20
|
return {
|
|
11
21
|
...options,
|
|
12
|
-
|
|
22
|
+
project,
|
|
13
23
|
name,
|
|
14
|
-
|
|
24
|
+
directory,
|
|
25
|
+
fileName,
|
|
26
|
+
filePath,
|
|
27
|
+
symbolName,
|
|
15
28
|
};
|
|
16
29
|
}
|
|
17
30
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.validateOptions = void 0;
|
|
4
4
|
const validations_1 = require("../../utils/validations");
|
|
5
5
|
function validateOptions(tree, options) {
|
|
6
|
-
(0, validations_1.validateProject)(tree, options.project);
|
|
7
|
-
(0, validations_1.validatePathIsUnderProjectRoot)(tree, options.project, options.path);
|
|
8
6
|
(0, validations_1.validateStandaloneOption)(tree, options.standalone);
|
|
9
7
|
}
|
|
10
8
|
exports.validateOptions = validateOptions;
|
|
@@ -6,22 +6,22 @@ const utils_1 = require("../utils");
|
|
|
6
6
|
const lib_1 = require("./lib");
|
|
7
7
|
async function pipeGenerator(tree, rawOptions) {
|
|
8
8
|
(0, lib_1.validateOptions)(tree, rawOptions);
|
|
9
|
-
const options = (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
9
|
+
const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
10
10
|
const pipeNames = (0, devkit_1.names)(options.name);
|
|
11
11
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), options.directory, {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
symbolName: options.symbolName,
|
|
13
|
+
fileName: options.fileName,
|
|
14
|
+
selector: pipeNames.propertyName,
|
|
15
15
|
standalone: options.standalone,
|
|
16
16
|
tpl: '',
|
|
17
17
|
});
|
|
18
18
|
if (options.skipTests) {
|
|
19
|
-
const pathToSpecFile = (0, devkit_1.joinPathFragments)(options.directory, `${
|
|
19
|
+
const pathToSpecFile = (0, devkit_1.joinPathFragments)(options.directory, `${options.fileName}.spec.ts`);
|
|
20
20
|
tree.delete(pathToSpecFile);
|
|
21
21
|
}
|
|
22
22
|
if (!options.skipImport && !options.standalone) {
|
|
23
|
-
const modulePath = (0, utils_1.findModule)(tree, options.
|
|
24
|
-
(0, utils_1.addToNgModule)(tree, options.
|
|
23
|
+
const modulePath = (0, utils_1.findModule)(tree, options.directory, options.module);
|
|
24
|
+
(0, utils_1.addToNgModule)(tree, options.directory, modulePath, '', options.symbolName, options.fileName, 'declarations', options.flat, options.export);
|
|
25
25
|
}
|
|
26
26
|
if (!options.skipFormat) {
|
|
27
27
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -1,17 +1,33 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
|
|
1
3
|
export interface Schema {
|
|
2
4
|
name: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
flat?: boolean;
|
|
5
|
+
directory?: string;
|
|
6
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
6
7
|
skipTests?: boolean;
|
|
7
8
|
skipImport?: boolean;
|
|
8
9
|
standalone?: boolean;
|
|
9
10
|
module?: string;
|
|
10
11
|
export?: boolean;
|
|
11
12
|
skipFormat?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.
|
|
15
|
+
*/
|
|
16
|
+
flat?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v18.
|
|
19
|
+
*/
|
|
20
|
+
path?: string;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v18.
|
|
23
|
+
*/
|
|
24
|
+
project?: string;
|
|
12
25
|
}
|
|
13
26
|
|
|
14
27
|
export interface NormalizedSchema extends Schema {
|
|
15
28
|
directory: string;
|
|
16
|
-
|
|
29
|
+
filePath: string;
|
|
30
|
+
project: string;
|
|
31
|
+
fileName: string;
|
|
32
|
+
symbolName: string;
|
|
17
33
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"type": "object",
|
|
6
6
|
"cli": "nx",
|
|
7
7
|
"additionalProperties": false,
|
|
8
|
-
"description": "Creates
|
|
8
|
+
"description": "Creates an Angular pipe.",
|
|
9
9
|
"properties": {
|
|
10
10
|
"name": {
|
|
11
11
|
"type": "string",
|
|
@@ -16,14 +16,16 @@
|
|
|
16
16
|
},
|
|
17
17
|
"x-prompt": "What name would you like to use for the pipe?"
|
|
18
18
|
},
|
|
19
|
-
"
|
|
19
|
+
"directory": {
|
|
20
20
|
"type": "string",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
21
|
+
"description": "The directory at which to create the pipe file. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
|
|
22
|
+
"aliases": ["dir", "path"],
|
|
23
|
+
"x-priority": "important"
|
|
24
|
+
},
|
|
25
|
+
"nameAndDirectoryFormat": {
|
|
26
|
+
"description": "Whether to generate the pipe 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`).",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": ["as-provided", "derived"]
|
|
27
29
|
},
|
|
28
30
|
"project": {
|
|
29
31
|
"type": "string",
|
|
@@ -31,12 +33,14 @@
|
|
|
31
33
|
"$default": {
|
|
32
34
|
"$source": "projectName"
|
|
33
35
|
},
|
|
34
|
-
"x-dropdown": "projects"
|
|
36
|
+
"x-dropdown": "projects",
|
|
37
|
+
"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 v18."
|
|
35
38
|
},
|
|
36
39
|
"flat": {
|
|
37
40
|
"type": "boolean",
|
|
38
41
|
"default": true,
|
|
39
|
-
"description": "When true (the default) creates files at the top level of the project."
|
|
42
|
+
"description": "When true (the default) creates files at the top level of the project.",
|
|
43
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18."
|
|
40
44
|
},
|
|
41
45
|
"skipTests": {
|
|
42
46
|
"type": "boolean",
|
|
@@ -69,5 +73,5 @@
|
|
|
69
73
|
"description": "Skip formatting of files."
|
|
70
74
|
}
|
|
71
75
|
},
|
|
72
|
-
"required": ["name"
|
|
76
|
+
"required": ["name"]
|
|
73
77
|
}
|
|
@@ -9,9 +9,6 @@ function convertComponentToScam(tree, options) {
|
|
|
9
9
|
if (!tree.exists(options.filePath)) {
|
|
10
10
|
throw new Error(`Couldn't find component at path ${options.filePath} to add SCAM setup.`);
|
|
11
11
|
}
|
|
12
|
-
const componentNames = (0, devkit_1.names)(options.name);
|
|
13
|
-
const typeNames = (0, devkit_1.names)(options.type ?? 'component');
|
|
14
|
-
const componentClassName = `${componentNames.className}${typeNames.className}`;
|
|
15
12
|
if (!tsModule) {
|
|
16
13
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
17
14
|
}
|
|
@@ -21,12 +18,12 @@ function convertComponentToScam(tree, options) {
|
|
|
21
18
|
source = (0, js_1.insertImport)(tree, source, options.filePath, 'NgModule', '@angular/core');
|
|
22
19
|
source = (0, js_1.insertImport)(tree, source, options.filePath, 'CommonModule', '@angular/common');
|
|
23
20
|
let updatedComponentSource = source.getText();
|
|
24
|
-
updatedComponentSource = `${updatedComponentSource}${getNgModuleDeclaration(
|
|
21
|
+
updatedComponentSource = `${updatedComponentSource}${getNgModuleDeclaration(options.symbolName)}`;
|
|
25
22
|
tree.write(options.filePath, updatedComponentSource);
|
|
26
23
|
return;
|
|
27
24
|
}
|
|
28
|
-
const moduleFilePath = (0, devkit_1.joinPathFragments)(options.directory, `${
|
|
29
|
-
tree.write(moduleFilePath, getModuleFileContent(
|
|
25
|
+
const moduleFilePath = (0, devkit_1.joinPathFragments)(options.directory, `${options.name}.module.ts`);
|
|
26
|
+
tree.write(moduleFilePath, getModuleFileContent(options.symbolName, options.fileName));
|
|
30
27
|
}
|
|
31
28
|
exports.convertComponentToScam = convertComponentToScam;
|
|
32
29
|
function getModuleFileContent(componentClassName, componentFileName) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
2
|
import type { NormalizedSchema, Schema } from '../schema';
|
|
3
|
-
export declare function normalizeOptions(tree: Tree, options: Schema): NormalizedSchema
|
|
3
|
+
export declare function normalizeOptions(tree: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
async function normalizeOptions(tree, options) {
|
|
7
|
+
options.type ??= 'component';
|
|
8
|
+
const { artifactName: name, directory, fileName, filePath, project, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
9
|
+
artifactType: options.type,
|
|
10
|
+
callingGenerator: '@nx/angular:scam',
|
|
11
|
+
name: options.name,
|
|
12
|
+
directory: options.directory ?? options.path,
|
|
13
|
+
flat: options.flat,
|
|
14
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
15
|
+
project: options.project,
|
|
16
|
+
suffix: options.type ?? 'component',
|
|
9
17
|
});
|
|
18
|
+
const { className } = (0, devkit_1.names)(name);
|
|
19
|
+
const { className: suffixClassName } = (0, devkit_1.names)(options.type);
|
|
20
|
+
const symbolName = `${className}${suffixClassName}`;
|
|
10
21
|
return {
|
|
11
22
|
...options,
|
|
12
23
|
export: options.export ?? true,
|
|
@@ -15,6 +26,8 @@ function normalizeOptions(tree, options) {
|
|
|
15
26
|
fileName,
|
|
16
27
|
filePath,
|
|
17
28
|
name,
|
|
29
|
+
symbolName,
|
|
30
|
+
project,
|
|
18
31
|
};
|
|
19
32
|
}
|
|
20
33
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -15,7 +15,7 @@ async function scamGenerator(tree, rawOptions) {
|
|
|
15
15
|
standalone: false,
|
|
16
16
|
skipFormat: true,
|
|
17
17
|
});
|
|
18
|
-
const options = (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
18
|
+
const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
19
19
|
(0, lib_1.convertComponentToScam)(tree, options);
|
|
20
20
|
(0, export_scam_1.exportScam)(tree, options);
|
|
21
21
|
if (!options.skipFormat) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
|
|
1
3
|
export interface Schema {
|
|
2
4
|
name: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
directory?: string;
|
|
6
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
5
7
|
displayBlock?: boolean;
|
|
6
8
|
inlineStyle?: boolean;
|
|
7
9
|
inlineTemplate?: boolean;
|
|
@@ -11,18 +13,31 @@ export interface Schema {
|
|
|
11
13
|
skipTests?: boolean;
|
|
12
14
|
inlineScam?: boolean;
|
|
13
15
|
type?: string;
|
|
14
|
-
flat?: boolean;
|
|
15
16
|
prefix?: string;
|
|
16
17
|
selector?: string;
|
|
17
18
|
skipSelector?: boolean;
|
|
18
19
|
export?: boolean;
|
|
19
20
|
skipFormat?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.
|
|
23
|
+
*/
|
|
24
|
+
flat?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v18.
|
|
27
|
+
*/
|
|
28
|
+
path?: string;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v18.
|
|
31
|
+
*/
|
|
32
|
+
project?: string;
|
|
20
33
|
}
|
|
21
34
|
|
|
22
35
|
export interface NormalizedSchema extends Schema {
|
|
23
36
|
directory: string;
|
|
37
|
+
project: string;
|
|
24
38
|
fileName: string;
|
|
25
39
|
filePath: string;
|
|
40
|
+
symbolName: string;
|
|
26
41
|
export: boolean;
|
|
27
42
|
inlineScam: boolean;
|
|
28
43
|
}
|
|
@@ -6,27 +6,13 @@
|
|
|
6
6
|
"type": "object",
|
|
7
7
|
"examples": [
|
|
8
8
|
{
|
|
9
|
-
"command": "nx g @nx/angular:scam --
|
|
9
|
+
"command": "nx g @nx/angular:scam my-sample --directory=my-lib/src/lib/my-sample",
|
|
10
10
|
"description": "Generate a `MySampleComponent` component in the `my-lib` library."
|
|
11
11
|
}
|
|
12
12
|
],
|
|
13
|
-
"description": "Creates a new
|
|
13
|
+
"description": "Creates a new Angular SCAM.",
|
|
14
14
|
"additionalProperties": false,
|
|
15
15
|
"properties": {
|
|
16
|
-
"path": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"format": "path",
|
|
19
|
-
"description": "The path at which to create the component file, relative to the current workspace. Default is a folder with the same name as the component in the project root.",
|
|
20
|
-
"visible": false
|
|
21
|
-
},
|
|
22
|
-
"project": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"description": "The name of the project.",
|
|
25
|
-
"$default": {
|
|
26
|
-
"$source": "projectName"
|
|
27
|
-
},
|
|
28
|
-
"x-dropdown": "projects"
|
|
29
|
-
},
|
|
30
16
|
"name": {
|
|
31
17
|
"type": "string",
|
|
32
18
|
"description": "The name of the component.",
|
|
@@ -36,6 +22,26 @@
|
|
|
36
22
|
},
|
|
37
23
|
"x-prompt": "What name would you like to use for the component?"
|
|
38
24
|
},
|
|
25
|
+
"directory": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "The directory at which to create the SCAM files. When `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. Otherwise, it will be relative to the workspace root.",
|
|
28
|
+
"aliases": ["dir", "path"],
|
|
29
|
+
"x-priority": "important"
|
|
30
|
+
},
|
|
31
|
+
"nameAndDirectoryFormat": {
|
|
32
|
+
"description": "Whether to generate the SCAM 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`).",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"enum": ["as-provided", "derived"]
|
|
35
|
+
},
|
|
36
|
+
"project": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "The name of the project.",
|
|
39
|
+
"$default": {
|
|
40
|
+
"$source": "projectName"
|
|
41
|
+
},
|
|
42
|
+
"x-dropdown": "projects",
|
|
43
|
+
"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 v18."
|
|
44
|
+
},
|
|
39
45
|
"displayBlock": {
|
|
40
46
|
"description": "Specifies if the style will contain `:host { display: block; }`.",
|
|
41
47
|
"type": "boolean",
|
|
@@ -87,7 +93,8 @@
|
|
|
87
93
|
"flat": {
|
|
88
94
|
"type": "boolean",
|
|
89
95
|
"description": "Create the new files at the top level of the current project.",
|
|
90
|
-
"default": false
|
|
96
|
+
"default": false,
|
|
97
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18."
|
|
91
98
|
},
|
|
92
99
|
"selector": {
|
|
93
100
|
"type": "string",
|
|
@@ -131,5 +138,5 @@
|
|
|
131
138
|
"x-priority": "internal"
|
|
132
139
|
}
|
|
133
140
|
},
|
|
134
|
-
"required": ["name"
|
|
141
|
+
"required": ["name"]
|
|
135
142
|
}
|
|
@@ -12,21 +12,18 @@ function convertDirectiveToScam(tree, options) {
|
|
|
12
12
|
if (!tsModule) {
|
|
13
13
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
14
14
|
}
|
|
15
|
-
const directiveNames = (0, devkit_1.names)(options.name);
|
|
16
|
-
const typeNames = (0, devkit_1.names)('directive');
|
|
17
|
-
const directiveClassName = `${directiveNames.className}${typeNames.className}`;
|
|
18
15
|
if (options.inlineScam) {
|
|
19
16
|
const currentDirectiveContents = tree.read(options.filePath, 'utf-8');
|
|
20
17
|
let source = tsModule.createSourceFile(options.filePath, currentDirectiveContents, tsModule.ScriptTarget.Latest, true);
|
|
21
18
|
source = (0, js_1.insertImport)(tree, source, options.filePath, 'NgModule', '@angular/core');
|
|
22
19
|
source = (0, js_1.insertImport)(tree, source, options.filePath, 'CommonModule', '@angular/common');
|
|
23
20
|
let updatedDirectiveSource = source.getText();
|
|
24
|
-
updatedDirectiveSource = `${updatedDirectiveSource}${getNgModuleDeclaration(
|
|
21
|
+
updatedDirectiveSource = `${updatedDirectiveSource}${getNgModuleDeclaration(options.symbolName)}`;
|
|
25
22
|
tree.write(options.filePath, updatedDirectiveSource);
|
|
26
23
|
return;
|
|
27
24
|
}
|
|
28
|
-
const scamFilePath = (0, devkit_1.joinPathFragments)(options.directory, `${
|
|
29
|
-
tree.write(scamFilePath, getModuleFileContent(
|
|
25
|
+
const scamFilePath = (0, devkit_1.joinPathFragments)(options.directory, `${options.name}.module.ts`);
|
|
26
|
+
tree.write(scamFilePath, getModuleFileContent(options.symbolName, options.fileName));
|
|
30
27
|
}
|
|
31
28
|
exports.convertDirectiveToScam = convertDirectiveToScam;
|
|
32
29
|
function getModuleFileContent(directiveClassName, directiveFileName) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
2
|
import type { NormalizedSchema, Schema } from '../schema';
|
|
3
|
-
export declare function normalizeOptions(tree: Tree, options: Schema): NormalizedSchema
|
|
3
|
+
export declare function normalizeOptions(tree: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
async function normalizeOptions(tree, options) {
|
|
7
|
+
const { artifactName: name, directory, fileName, filePath, project, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
8
|
+
artifactType: 'directive',
|
|
9
|
+
callingGenerator: '@nx/angular:scam-directive',
|
|
10
|
+
name: options.name,
|
|
11
|
+
directory: options.directory ?? options.path,
|
|
12
|
+
flat: options.flat,
|
|
13
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
14
|
+
project: options.project,
|
|
15
|
+
suffix: 'directive',
|
|
9
16
|
});
|
|
17
|
+
const { className } = (0, devkit_1.names)(name);
|
|
18
|
+
const { className: suffixClassName } = (0, devkit_1.names)('directive');
|
|
19
|
+
const symbolName = `${className}${suffixClassName}`;
|
|
10
20
|
return {
|
|
11
21
|
...options,
|
|
12
22
|
export: options.export ?? true,
|
|
13
|
-
flat: options.flat ?? true,
|
|
14
23
|
inlineScam: options.inlineScam ?? true,
|
|
15
24
|
directory,
|
|
16
25
|
fileName,
|
|
17
26
|
filePath,
|
|
18
|
-
path,
|
|
19
27
|
name,
|
|
28
|
+
symbolName,
|
|
29
|
+
project,
|
|
20
30
|
};
|
|
21
31
|
}
|
|
22
32
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -15,7 +15,7 @@ async function scamDirectiveGenerator(tree, rawOptions) {
|
|
|
15
15
|
standalone: false,
|
|
16
16
|
skipFormat: true,
|
|
17
17
|
});
|
|
18
|
-
const options = (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
18
|
+
const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
19
19
|
(0, lib_1.convertDirectiveToScam)(tree, options);
|
|
20
20
|
(0, export_scam_1.exportScam)(tree, options);
|
|
21
21
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
|
|
1
3
|
export interface Schema {
|
|
2
4
|
name: string;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
directory?: string;
|
|
6
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
5
7
|
skipTests?: boolean;
|
|
6
8
|
inlineScam?: boolean;
|
|
7
|
-
flat?: boolean;
|
|
8
9
|
prefix?: string;
|
|
9
10
|
selector?: string;
|
|
10
11
|
export?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.
|
|
14
|
+
*/
|
|
15
|
+
flat?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v18.
|
|
18
|
+
*/
|
|
19
|
+
path?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v18.
|
|
22
|
+
*/
|
|
23
|
+
project?: string;
|
|
11
24
|
}
|
|
12
25
|
|
|
13
26
|
export interface NormalizedSchema extends Schema {
|
|
@@ -15,7 +28,7 @@ export interface NormalizedSchema extends Schema {
|
|
|
15
28
|
export: boolean;
|
|
16
29
|
fileName: string;
|
|
17
30
|
filePath: string;
|
|
18
|
-
flat: boolean;
|
|
19
31
|
inlineScam: boolean;
|
|
20
|
-
|
|
32
|
+
symbolName: string;
|
|
33
|
+
project: string;
|
|
21
34
|
}
|
|
@@ -6,27 +6,13 @@
|
|
|
6
6
|
"type": "object",
|
|
7
7
|
"examples": [
|
|
8
8
|
{
|
|
9
|
-
"command": "nx g @nx/angular:scam-directive
|
|
9
|
+
"command": "nx g @nx/angular:scam-directive my-sample --directory=my-lib/src/lib/my-sample",
|
|
10
10
|
"description": "Generate a `MySampleDirective` directive in a `my-sample` folder in the `my-lib` library"
|
|
11
11
|
}
|
|
12
12
|
],
|
|
13
13
|
"description": "Creates a new, generic Angular directive definition in the given or default project.",
|
|
14
14
|
"additionalProperties": false,
|
|
15
15
|
"properties": {
|
|
16
|
-
"path": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"format": "path",
|
|
19
|
-
"description": "The path at which to create the directive file, relative to the current workspace. Default is a folder with the same name as the directive in the project root.",
|
|
20
|
-
"visible": false
|
|
21
|
-
},
|
|
22
|
-
"project": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"description": "The name of the project.",
|
|
25
|
-
"$default": {
|
|
26
|
-
"$source": "projectName"
|
|
27
|
-
},
|
|
28
|
-
"x-dropdown": "projects"
|
|
29
|
-
},
|
|
30
16
|
"name": {
|
|
31
17
|
"type": "string",
|
|
32
18
|
"description": "The name of the directive.",
|
|
@@ -37,6 +23,26 @@
|
|
|
37
23
|
"x-prompt": "What name would you like to use for the directive?",
|
|
38
24
|
"x-priority": "important"
|
|
39
25
|
},
|
|
26
|
+
"directory": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"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.",
|
|
29
|
+
"aliases": ["dir", "path"],
|
|
30
|
+
"x-priority": "important"
|
|
31
|
+
},
|
|
32
|
+
"nameAndDirectoryFormat": {
|
|
33
|
+
"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`).",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"enum": ["as-provided", "derived"]
|
|
36
|
+
},
|
|
37
|
+
"project": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "The name of the project.",
|
|
40
|
+
"$default": {
|
|
41
|
+
"$source": "projectName"
|
|
42
|
+
},
|
|
43
|
+
"x-dropdown": "projects",
|
|
44
|
+
"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 v18."
|
|
45
|
+
},
|
|
40
46
|
"skipTests": {
|
|
41
47
|
"type": "boolean",
|
|
42
48
|
"description": "Do not create `spec.ts` test files for the new directive.",
|
|
@@ -51,7 +57,8 @@
|
|
|
51
57
|
"flat": {
|
|
52
58
|
"type": "boolean",
|
|
53
59
|
"description": "Create the new files at the top level of the current project.",
|
|
54
|
-
"default": true
|
|
60
|
+
"default": true,
|
|
61
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18."
|
|
55
62
|
},
|
|
56
63
|
"selector": {
|
|
57
64
|
"type": "string",
|
|
@@ -79,5 +86,5 @@
|
|
|
79
86
|
"x-priority": "important"
|
|
80
87
|
}
|
|
81
88
|
},
|
|
82
|
-
"required": ["name"
|
|
89
|
+
"required": ["name"]
|
|
83
90
|
}
|
|
@@ -12,21 +12,18 @@ function convertPipeToScam(tree, options) {
|
|
|
12
12
|
if (!tsModule) {
|
|
13
13
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
14
14
|
}
|
|
15
|
-
const pipeNames = (0, devkit_1.names)(options.name);
|
|
16
|
-
const typeNames = (0, devkit_1.names)('pipe');
|
|
17
|
-
const pipeClassName = `${pipeNames.className}${typeNames.className}`;
|
|
18
15
|
if (options.inlineScam) {
|
|
19
16
|
const currentPipeContents = tree.read(options.filePath, 'utf-8');
|
|
20
17
|
let source = tsModule.createSourceFile(options.filePath, currentPipeContents, tsModule.ScriptTarget.Latest, true);
|
|
21
18
|
source = (0, js_1.insertImport)(tree, source, options.filePath, 'NgModule', '@angular/core');
|
|
22
19
|
source = (0, js_1.insertImport)(tree, source, options.filePath, 'CommonModule', '@angular/common');
|
|
23
20
|
let updatedPipeSource = source.getText();
|
|
24
|
-
updatedPipeSource = `${updatedPipeSource}${getNgModuleDeclaration(
|
|
21
|
+
updatedPipeSource = `${updatedPipeSource}${getNgModuleDeclaration(options.symbolName)}`;
|
|
25
22
|
tree.write(options.filePath, updatedPipeSource);
|
|
26
23
|
return;
|
|
27
24
|
}
|
|
28
|
-
const scamFilePath = (0, devkit_1.joinPathFragments)(options.directory, `${
|
|
29
|
-
tree.write(scamFilePath, getModuleFileContent(
|
|
25
|
+
const scamFilePath = (0, devkit_1.joinPathFragments)(options.directory, `${options.name}.module.ts`);
|
|
26
|
+
tree.write(scamFilePath, getModuleFileContent(options.symbolName, options.fileName));
|
|
30
27
|
}
|
|
31
28
|
exports.convertPipeToScam = convertPipeToScam;
|
|
32
29
|
function getModuleFileContent(pipeClassName, pipeFileName) {
|