@nx/angular 16.10.0 → 17.0.0-beta.2
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/generators.d.ts +0 -1
- package/generators.js +0 -1
- package/generators.json +1 -13
- package/package.json +9 -9
- package/src/builders/utilities/module-federation.js +1 -1
- package/src/builders/utilities/webpack.js +5 -3
- 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/host/files/ts/webpack.server.config.ts__tmpl__ +4 -0
- package/src/generators/host/host.d.ts +1 -1
- package/src/generators/host/host.js +6 -3
- package/src/generators/host/lib/add-ssr.d.ts +1 -1
- package/src/generators/host/lib/add-ssr.js +7 -3
- package/src/generators/host/schema.d.ts +1 -0
- package/src/generators/host/schema.json +5 -0
- package/src/generators/move/lib/update-ng-package.js +3 -6
- package/src/generators/ng-add/migrators/migrator.js +5 -7
- package/src/generators/ng-add/utilities/workspace.js +4 -13
- package/src/generators/remote/files/base-ts/webpack.server.config.ts__tmpl__ +4 -0
- package/src/generators/remote/lib/add-ssr.d.ts +2 -1
- package/src/generators/remote/lib/add-ssr.js +7 -3
- package/src/generators/remote/remote.d.ts +1 -1
- package/src/generators/remote/remote.js +5 -2
- package/src/generators/remote/schema.d.ts +1 -0
- package/src/generators/remote/schema.json +5 -0
- package/src/generators/setup-mf/files/ts-webpack/module-federation.config.ts__tmpl__ +12 -0
- package/src/generators/setup-mf/files/ts-webpack/webpack.config.ts__tmpl__ +4 -0
- package/src/generators/setup-mf/files/ts-webpack/webpack.prod.config.ts__tmpl__ +16 -0
- package/src/generators/setup-mf/lib/add-remote-to-host.js +7 -4
- package/src/generators/setup-mf/lib/change-build-target.js +3 -2
- package/src/generators/setup-mf/lib/generate-config.js +8 -2
- package/src/generators/setup-mf/lib/normalize-options.js +1 -0
- package/src/generators/setup-mf/lib/setup-host-if-dynamic.js +1 -1
- package/src/generators/setup-mf/schema.d.ts +1 -0
- package/src/generators/setup-mf/schema.json +5 -0
- package/src/generators/setup-ssr/lib/update-project-config.js +4 -0
- package/src/generators/storybook-configuration/storybook-configuration.js +1 -1
- package/src/generators/utils/find-module.js +4 -1
- 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/convert-tslint-to-eslint/compat.d.ts +0 -4
- package/src/generators/convert-tslint-to-eslint/compat.js +0 -10
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.d.ts +0 -6
- package/src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint.js +0 -171
- package/src/generators/convert-tslint-to-eslint/schema.json +0 -55
- /package/src/generators/component/files/{__fileName__.__type__.__style__ → __fileName__.__style__} +0 -0
- /package/src/generators/host/files/{src → common/src}/main.server.ts__tmpl__ +0 -0
- /package/src/generators/host/files/{webpack.server.config.js__tmpl__ → js/webpack.server.config.js__tmpl__} +0 -0
- /package/src/generators/remote/files/{base → common}/src/main.server.ts__tmpl__ +0 -0
package/generators.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export * from './src/generators/application/application';
|
|
|
3
3
|
export * from './src/generators/component-cypress-spec/component-cypress-spec';
|
|
4
4
|
export * from './src/generators/component-story/component-story';
|
|
5
5
|
export * from './src/generators/component/component';
|
|
6
|
-
export * from './src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint';
|
|
7
6
|
export * from './src/generators/directive/directive';
|
|
8
7
|
export * from './src/generators/host/host';
|
|
9
8
|
export * from './src/generators/init/init';
|
package/generators.js
CHANGED
|
@@ -6,7 +6,6 @@ tslib_1.__exportStar(require("./src/generators/application/application"), export
|
|
|
6
6
|
tslib_1.__exportStar(require("./src/generators/component-cypress-spec/component-cypress-spec"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./src/generators/component-story/component-story"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./src/generators/component/component"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint"), exports);
|
|
10
9
|
tslib_1.__exportStar(require("./src/generators/directive/directive"), exports);
|
|
11
10
|
tslib_1.__exportStar(require("./src/generators/host/host"), exports);
|
|
12
11
|
tslib_1.__exportStar(require("./src/generators/init/init"), exports);
|
package/generators.json
CHANGED
|
@@ -39,12 +39,6 @@
|
|
|
39
39
|
"schema": "./src/generators/component-test/schema.json",
|
|
40
40
|
"description": "Creates a cypress component test file for a component."
|
|
41
41
|
},
|
|
42
|
-
"convert-tslint-to-eslint": {
|
|
43
|
-
"factory": "./src/generators/convert-tslint-to-eslint/compat",
|
|
44
|
-
"schema": "./src/generators/convert-tslint-to-eslint/schema.json",
|
|
45
|
-
"description": "Converts a project from TSLint to ESLint.",
|
|
46
|
-
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint."
|
|
47
|
-
},
|
|
48
42
|
"init": {
|
|
49
43
|
"factory": "./src/generators/init/init.compat#initSchematic",
|
|
50
44
|
"schema": "./src/generators/init/schema.json",
|
|
@@ -171,7 +165,7 @@
|
|
|
171
165
|
"description": "Creates an Angular application."
|
|
172
166
|
},
|
|
173
167
|
"component": {
|
|
174
|
-
"factory": "./src/generators/component/component",
|
|
168
|
+
"factory": "./src/generators/component/component#componentGeneratorInternal",
|
|
175
169
|
"schema": "./src/generators/component/schema.json",
|
|
176
170
|
"aliases": ["c"],
|
|
177
171
|
"description": "Generate an Angular Component."
|
|
@@ -193,12 +187,6 @@
|
|
|
193
187
|
"schema": "./src/generators/component-test/schema.json",
|
|
194
188
|
"description": "Creates a cypress component test file for a component."
|
|
195
189
|
},
|
|
196
|
-
"convert-tslint-to-eslint": {
|
|
197
|
-
"factory": "./src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint#conversionGenerator",
|
|
198
|
-
"schema": "./src/generators/convert-tslint-to-eslint/schema.json",
|
|
199
|
-
"description": "Converts a project from TSLint to ESLint.",
|
|
200
|
-
"x-deprecated": "This generator is deprecated and will be removed in a future version of Nx. Migrate to ESLint."
|
|
201
|
-
},
|
|
202
190
|
"directive": {
|
|
203
191
|
"factory": "./src/generators/directive/directive",
|
|
204
192
|
"schema": "./src/generators/directive/schema.json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
"webpack": "^5.80.0",
|
|
80
80
|
"webpack-merge": "^5.8.0",
|
|
81
81
|
"enquirer": "^2.3.6",
|
|
82
|
-
"@nx/devkit": "
|
|
83
|
-
"@nx/cypress": "
|
|
84
|
-
"@nx/jest": "
|
|
85
|
-
"@nx/js": "
|
|
86
|
-
"@nx/linter": "
|
|
87
|
-
"@nx/webpack": "
|
|
88
|
-
"@nx/workspace": "
|
|
89
|
-
"@nrwl/angular": "
|
|
82
|
+
"@nx/devkit": "17.0.0-beta.2",
|
|
83
|
+
"@nx/cypress": "17.0.0-beta.2",
|
|
84
|
+
"@nx/jest": "17.0.0-beta.2",
|
|
85
|
+
"@nx/js": "17.0.0-beta.2",
|
|
86
|
+
"@nx/linter": "17.0.0-beta.2",
|
|
87
|
+
"@nx/webpack": "17.0.0-beta.2",
|
|
88
|
+
"@nx/workspace": "17.0.0-beta.2",
|
|
89
|
+
"@nrwl/angular": "17.0.0-beta.2"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"@angular-devkit/build-angular": ">= 14.0.0 < 17.0.0",
|
|
@@ -47,7 +47,7 @@ function getModuleFederationConfig(tsconfigPath, workspaceRoot, projectRoot) {
|
|
|
47
47
|
let moduleFederationConfigPath = moduleFederationConfigPathJS;
|
|
48
48
|
let cleanupTranspiler = () => { };
|
|
49
49
|
if ((0, fs_1.existsSync)(moduleFederationConfigPathTS)) {
|
|
50
|
-
cleanupTranspiler = (0, internal_1.registerTsProject)(
|
|
50
|
+
cleanupTranspiler = (0, internal_1.registerTsProject)((0, path_1.join)(workspaceRoot, tsconfigPath));
|
|
51
51
|
moduleFederationConfigPath = moduleFederationConfigPathTS;
|
|
52
52
|
}
|
|
53
53
|
try {
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.resolveIndexHtmlTransformer = exports.resolveCustomWebpackConfig = exports.mergeCustomWebpackConfig = void 0;
|
|
4
4
|
const webpack_merge_1 = require("webpack-merge");
|
|
5
5
|
const internal_1 = require("@nx/js/src/internal");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const path_1 = require("path");
|
|
6
8
|
async function mergeCustomWebpackConfig(baseWebpackConfig, pathToWebpackConfig, options, target) {
|
|
7
|
-
const customWebpackConfiguration = resolveCustomWebpackConfig(pathToWebpackConfig, options.tsConfig);
|
|
9
|
+
const customWebpackConfiguration = resolveCustomWebpackConfig(pathToWebpackConfig, (0, path_1.join)(devkit_1.workspaceRoot, options.tsConfig));
|
|
8
10
|
// The extra Webpack configuration file can also export a Promise, for instance:
|
|
9
11
|
// `module.exports = new Promise(...)`. If it exports a single object, but not a Promise,
|
|
10
12
|
// then await will just resolve that object.
|
|
@@ -20,7 +22,7 @@ async function mergeCustomWebpackConfig(baseWebpackConfig, pathToWebpackConfig,
|
|
|
20
22
|
}
|
|
21
23
|
exports.mergeCustomWebpackConfig = mergeCustomWebpackConfig;
|
|
22
24
|
function resolveCustomWebpackConfig(path, tsConfig) {
|
|
23
|
-
const cleanupTranspiler = (0, internal_1.registerTsProject)(
|
|
25
|
+
const cleanupTranspiler = (0, internal_1.registerTsProject)(tsConfig);
|
|
24
26
|
const customWebpackConfig = require(path);
|
|
25
27
|
cleanupTranspiler();
|
|
26
28
|
// If the user provides a configuration in TS file
|
|
@@ -32,7 +34,7 @@ function resolveCustomWebpackConfig(path, tsConfig) {
|
|
|
32
34
|
}
|
|
33
35
|
exports.resolveCustomWebpackConfig = resolveCustomWebpackConfig;
|
|
34
36
|
function resolveIndexHtmlTransformer(path, tsConfig, target) {
|
|
35
|
-
const cleanupTranspiler = (0, internal_1.registerTsProject)(
|
|
37
|
+
const cleanupTranspiler = (0, internal_1.registerTsProject)(tsConfig);
|
|
36
38
|
const indexTransformer = require(path);
|
|
37
39
|
cleanupTranspiler();
|
|
38
40
|
const transform = indexTransformer.default ?? indexTransformer;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
2
|
import type { Schema } from './schema';
|
|
3
3
|
export declare function componentGenerator(tree: Tree, rawOptions: Schema): Promise<void>;
|
|
4
|
+
export declare function componentGeneratorInternal(tree: Tree, rawOptions: Schema): Promise<void>;
|
|
4
5
|
export default componentGenerator;
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.componentGenerator = void 0;
|
|
3
|
+
exports.componentGeneratorInternal = exports.componentGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const lib_1 = require("./lib");
|
|
7
7
|
async function componentGenerator(tree, rawOptions) {
|
|
8
|
+
await componentGeneratorInternal(tree, {
|
|
9
|
+
nameAndDirectoryFormat: 'derived',
|
|
10
|
+
...rawOptions,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.componentGenerator = componentGenerator;
|
|
14
|
+
async function componentGeneratorInternal(tree, rawOptions) {
|
|
8
15
|
(0, lib_1.validateOptions)(tree, rawOptions);
|
|
9
|
-
const options = (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
10
|
-
const componentNames = (0, devkit_1.names)(options.name);
|
|
11
|
-
const typeNames = (0, devkit_1.names)(options.type);
|
|
16
|
+
const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
12
17
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), options.directory, {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
typeClassName: typeNames.className,
|
|
18
|
+
name: options.name,
|
|
19
|
+
fileName: options.fileName,
|
|
20
|
+
symbolName: options.symbolName,
|
|
17
21
|
style: options.style,
|
|
18
22
|
inlineStyle: options.inlineStyle,
|
|
19
23
|
inlineTemplate: options.inlineTemplate,
|
|
@@ -26,25 +30,25 @@ async function componentGenerator(tree, rawOptions) {
|
|
|
26
30
|
tpl: '',
|
|
27
31
|
});
|
|
28
32
|
if (options.skipTests) {
|
|
29
|
-
const pathToSpecFile = (0, devkit_1.joinPathFragments)(options.directory, `${
|
|
33
|
+
const pathToSpecFile = (0, devkit_1.joinPathFragments)(options.directory, `${options.fileName}.spec.ts`);
|
|
30
34
|
tree.delete(pathToSpecFile);
|
|
31
35
|
}
|
|
32
36
|
if (options.inlineTemplate) {
|
|
33
|
-
const pathToTemplateFile = (0, devkit_1.joinPathFragments)(options.directory, `${
|
|
37
|
+
const pathToTemplateFile = (0, devkit_1.joinPathFragments)(options.directory, `${options.fileName}.html`);
|
|
34
38
|
tree.delete(pathToTemplateFile);
|
|
35
39
|
}
|
|
36
40
|
if (options.style === 'none' || options.inlineStyle) {
|
|
37
|
-
const pathToStyleFile = (0, devkit_1.joinPathFragments)(options.directory, `${
|
|
41
|
+
const pathToStyleFile = (0, devkit_1.joinPathFragments)(options.directory, `${options.fileName}.${options.style}`);
|
|
38
42
|
tree.delete(pathToStyleFile);
|
|
39
43
|
}
|
|
40
44
|
if (!options.skipImport && !options.standalone) {
|
|
41
45
|
const modulePath = (0, lib_1.findModuleFromOptions)(tree, options, options.projectRoot);
|
|
42
|
-
(0, utils_1.addToNgModule)(tree, options.
|
|
46
|
+
(0, utils_1.addToNgModule)(tree, options.directory, modulePath, options.name, options.symbolName, options.fileName, 'declarations', true, options.export);
|
|
43
47
|
}
|
|
44
48
|
(0, lib_1.exportComponentInEntryPoint)(tree, options);
|
|
45
49
|
if (!options.skipFormat) {
|
|
46
50
|
await (0, devkit_1.formatFiles)(tree);
|
|
47
51
|
}
|
|
48
52
|
}
|
|
49
|
-
exports.
|
|
53
|
+
exports.componentGeneratorInternal = componentGeneratorInternal;
|
|
50
54
|
exports.default = componentGenerator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<p><%= name %> works!</p>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { <%= symbolName %> } from './<%= fileName %>';
|
|
3
|
+
|
|
4
|
+
describe('<%= symbolName %>', () => {
|
|
5
|
+
let component: <%= symbolName %>;
|
|
6
|
+
let fixture: ComponentFixture<<%= symbolName %>>;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
await TestBed.configureTestingModule({
|
|
10
|
+
<%= standalone ? 'imports' : 'declarations' %>: [ <%= symbolName %> ]
|
|
11
|
+
})
|
|
12
|
+
.compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(<%= symbolName %>);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
fixture.detectChanges();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
package/src/generators/component/files/{__fileName__.__type__.ts__tpl__ → __fileName__.ts__tpl__}
RENAMED
|
@@ -5,8 +5,8 @@ import { CommonModule } from '@angular/common';<% } %>
|
|
|
5
5
|
selector: '<%= selector %>',<%}%><% if(standalone) {%>
|
|
6
6
|
standalone: true,
|
|
7
7
|
imports: [CommonModule],<%}%><% if(inlineTemplate) { %>
|
|
8
|
-
template: `<p><%=
|
|
9
|
-
templateUrl: './<%= fileName
|
|
8
|
+
template: `<p><%= name %> works!</p>`<% } else { %>
|
|
9
|
+
templateUrl: './<%= fileName %>.html'<% } if(inlineStyle) { %>,
|
|
10
10
|
styles: [<% if(displayBlock){ %>
|
|
11
11
|
`
|
|
12
12
|
:host {
|
|
@@ -14,8 +14,8 @@ import { CommonModule } from '@angular/common';<% } %>
|
|
|
14
14
|
}
|
|
15
15
|
`<% } %>
|
|
16
16
|
]<% } else if (style !== 'none') { %>,
|
|
17
|
-
styleUrls: ['./<%= fileName
|
|
17
|
+
styleUrls: ['./<%= fileName %>.<%= style %>']<% } %><% if(!!viewEncapsulation) { %>,
|
|
18
18
|
encapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } if (changeDetection !== 'Default') { %>,
|
|
19
19
|
changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %>
|
|
20
20
|
})
|
|
21
|
-
export class <%=
|
|
21
|
+
export class <%= symbolName %> {}
|
|
@@ -12,10 +12,10 @@ function findModuleFromOptions(tree, options, projectRoot) {
|
|
|
12
12
|
return (0, devkit_1.normalizePath)(findModule(tree, options.directory, projectRoot));
|
|
13
13
|
}
|
|
14
14
|
else {
|
|
15
|
-
const modulePath = (0, devkit_1.joinPathFragments)(options.
|
|
15
|
+
const modulePath = (0, devkit_1.joinPathFragments)(options.directory, options.module);
|
|
16
16
|
const componentPath = options.directory;
|
|
17
17
|
const moduleBaseName = (0, path_1.basename)(modulePath);
|
|
18
|
-
const candidateSet = new Set([options.
|
|
18
|
+
const candidateSet = new Set([options.directory]);
|
|
19
19
|
const projectRootParent = (0, path_1.dirname)(projectRoot);
|
|
20
20
|
for (let dir = modulePath; dir !== projectRootParent; dir = (0, path_1.dirname)(dir)) {
|
|
21
21
|
candidateSet.add(dir);
|
|
@@ -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>;
|
|
@@ -2,23 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeOptions = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
6
6
|
const selector_1 = require("../../utils/selector");
|
|
7
|
-
function normalizeOptions(tree, options) {
|
|
7
|
+
async function normalizeOptions(tree, options) {
|
|
8
8
|
options.type ??= 'component';
|
|
9
|
-
const {
|
|
10
|
-
|
|
9
|
+
const { artifactName: name, directory, fileName, filePath, project, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
10
|
+
artifactType: 'component',
|
|
11
|
+
callingGenerator: '@nx/angular:component',
|
|
12
|
+
name: options.name,
|
|
13
|
+
directory: options.directory ?? options.path,
|
|
14
|
+
flat: options.flat,
|
|
15
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
16
|
+
project: options.project,
|
|
17
|
+
suffix: options.type ?? 'component',
|
|
18
|
+
});
|
|
19
|
+
const { className } = (0, devkit_1.names)(name);
|
|
20
|
+
const { className: suffixClassName } = (0, devkit_1.names)(options.type);
|
|
21
|
+
const symbolName = `${className}${suffixClassName}`;
|
|
22
|
+
const { prefix, root, sourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
11
23
|
const selector = options.selector ??
|
|
12
24
|
(0, selector_1.buildSelector)(tree, name, options.prefix, prefix, 'fileName');
|
|
13
25
|
return {
|
|
14
26
|
...options,
|
|
15
27
|
name,
|
|
28
|
+
project,
|
|
16
29
|
changeDetection: options.changeDetection ?? 'Default',
|
|
17
30
|
style: options.style ?? 'css',
|
|
18
|
-
flat: options.flat ?? false,
|
|
19
31
|
directory,
|
|
32
|
+
fileName,
|
|
20
33
|
filePath,
|
|
21
|
-
|
|
34
|
+
symbolName,
|
|
22
35
|
projectSourceRoot: sourceRoot,
|
|
23
36
|
projectRoot: root,
|
|
24
37
|
selector,
|
|
@@ -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;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { 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,7 +13,6 @@ export interface Schema {
|
|
|
11
13
|
style?: 'css' | 'scss' | 'sass' | 'less' | 'none';
|
|
12
14
|
skipTests?: boolean;
|
|
13
15
|
type?: string;
|
|
14
|
-
flat?: boolean;
|
|
15
16
|
skipImport?: boolean;
|
|
16
17
|
selector?: string;
|
|
17
18
|
module?: string;
|
|
@@ -19,12 +20,29 @@ export interface Schema {
|
|
|
19
20
|
export?: boolean;
|
|
20
21
|
prefix?: string;
|
|
21
22
|
skipFormat?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.
|
|
26
|
+
*/
|
|
27
|
+
flat?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Provide the `directory` option instead. It will be removed in Nx v18.
|
|
30
|
+
*/
|
|
31
|
+
path?: string;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Provide the `directory` option instead. The project will be determined from the directory provided. It will be removed in Nx v18.
|
|
34
|
+
*/
|
|
35
|
+
project?: string;
|
|
22
36
|
}
|
|
23
37
|
|
|
24
38
|
export interface NormalizedSchema extends Schema {
|
|
25
39
|
directory: string;
|
|
26
40
|
filePath: string;
|
|
41
|
+
project: string;
|
|
27
42
|
projectSourceRoot: string;
|
|
28
43
|
projectRoot: string;
|
|
29
44
|
selector: string;
|
|
45
|
+
|
|
46
|
+
fileName: string;
|
|
47
|
+
symbolName: string;
|
|
30
48
|
}
|
|
@@ -4,23 +4,9 @@
|
|
|
4
4
|
"title": "Angular Component Schema",
|
|
5
5
|
"cli": "nx",
|
|
6
6
|
"type": "object",
|
|
7
|
-
"description": "Creates a new
|
|
7
|
+
"description": "Creates a new Angular component.",
|
|
8
8
|
"additionalProperties": false,
|
|
9
9
|
"properties": {
|
|
10
|
-
"path": {
|
|
11
|
-
"type": "string",
|
|
12
|
-
"format": "path",
|
|
13
|
-
"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.",
|
|
14
|
-
"visible": false
|
|
15
|
-
},
|
|
16
|
-
"project": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"description": "The name of the project.",
|
|
19
|
-
"$default": {
|
|
20
|
-
"$source": "projectName"
|
|
21
|
-
},
|
|
22
|
-
"x-dropdown": "projects"
|
|
23
|
-
},
|
|
24
10
|
"name": {
|
|
25
11
|
"type": "string",
|
|
26
12
|
"description": "The name of the component.",
|
|
@@ -30,6 +16,26 @@
|
|
|
30
16
|
},
|
|
31
17
|
"x-prompt": "What name would you like to use for the component?"
|
|
32
18
|
},
|
|
19
|
+
"directory": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "The directory at which to create the component 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 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`).",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": ["as-provided", "derived"]
|
|
29
|
+
},
|
|
30
|
+
"project": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "The name of the project.",
|
|
33
|
+
"$default": {
|
|
34
|
+
"$source": "projectName"
|
|
35
|
+
},
|
|
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."
|
|
38
|
+
},
|
|
33
39
|
"prefix": {
|
|
34
40
|
"type": "string",
|
|
35
41
|
"description": "The prefix to apply to the generated component selector.",
|
|
@@ -91,7 +97,8 @@
|
|
|
91
97
|
"flat": {
|
|
92
98
|
"type": "boolean",
|
|
93
99
|
"description": "Create the new files at the top level of the current project.",
|
|
94
|
-
"default": false
|
|
100
|
+
"default": false,
|
|
101
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18."
|
|
95
102
|
},
|
|
96
103
|
"skipImport": {
|
|
97
104
|
"type": "boolean",
|
|
@@ -126,6 +133,6 @@
|
|
|
126
133
|
"x-priority": "internal"
|
|
127
134
|
}
|
|
128
135
|
},
|
|
129
|
-
"required": ["name"
|
|
136
|
+
"required": ["name"],
|
|
130
137
|
"examplesFile": "../../../docs/component-examples.md"
|
|
131
138
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import type { Schema } from './schema';
|
|
3
3
|
export declare function host(tree: Tree, options: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
|
-
export declare function hostInternal(tree: Tree,
|
|
4
|
+
export declare function hostInternal(tree: Tree, schema: Schema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
5
5
|
export default host;
|
|
@@ -17,12 +17,13 @@ async function host(tree, options) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
exports.host = host;
|
|
20
|
-
async function hostInternal(tree,
|
|
20
|
+
async function hostInternal(tree, schema) {
|
|
21
21
|
const installedAngularVersionInfo = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
22
|
-
if ((0, semver_1.lt)(installedAngularVersionInfo.version, '14.1.0') &&
|
|
22
|
+
if ((0, semver_1.lt)(installedAngularVersionInfo.version, '14.1.0') && schema.standalone) {
|
|
23
23
|
throw new Error((0, devkit_1.stripIndents) `The "standalone" option is only supported in Angular >= 14.1.0. You are currently using ${installedAngularVersionInfo.version}.
|
|
24
24
|
You can resolve this error by removing the "standalone" option or by migrating to Angular 14.1.0.`);
|
|
25
25
|
}
|
|
26
|
+
const { typescriptConfiguration = true, ...options } = schema;
|
|
26
27
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
27
28
|
const remotesToGenerate = [];
|
|
28
29
|
const remotesToIntegrate = [];
|
|
@@ -64,10 +65,11 @@ async function hostInternal(tree, options) {
|
|
|
64
65
|
skipE2E,
|
|
65
66
|
e2eProjectName: skipE2E ? undefined : `${hostProjectName}-e2e`,
|
|
66
67
|
prefix: options.prefix,
|
|
68
|
+
typescriptConfiguration,
|
|
67
69
|
});
|
|
68
70
|
let installTasks = [appInstallTask];
|
|
69
71
|
if (options.ssr) {
|
|
70
|
-
let ssrInstallTask = await (0, lib_1.addSsr)(tree, options, hostProjectName);
|
|
72
|
+
let ssrInstallTask = await (0, lib_1.addSsr)(tree, options, hostProjectName, typescriptConfiguration);
|
|
71
73
|
installTasks.push(ssrInstallTask);
|
|
72
74
|
}
|
|
73
75
|
for (const remote of remotesToGenerate) {
|
|
@@ -88,6 +90,7 @@ async function hostInternal(tree, options) {
|
|
|
88
90
|
host: hostProjectName,
|
|
89
91
|
skipFormat: true,
|
|
90
92
|
standalone: options.standalone,
|
|
93
|
+
typescriptConfiguration,
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
96
|
if (!options.skipFormat) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Tree } from '@nx/devkit';
|
|
2
2
|
import type { Schema } from '../schema';
|
|
3
|
-
export declare function addSsr(tree: Tree, options: Schema, appName: string): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
3
|
+
export declare function addSsr(tree: Tree, options: Schema, appName: string, typescriptConfiguration: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const setup_ssr_1 = require("../../setup-ssr/setup-ssr");
|
|
6
6
|
const versions_1 = require("../../../utils/versions");
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
-
async function addSsr(tree, options, appName) {
|
|
8
|
+
async function addSsr(tree, options, appName, typescriptConfiguration) {
|
|
9
9
|
let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
10
10
|
await (0, setup_ssr_1.default)(tree, {
|
|
11
11
|
project: appName,
|
|
@@ -14,17 +14,21 @@ async function addSsr(tree, options, appName) {
|
|
|
14
14
|
tree.rename((0, devkit_1.joinPathFragments)(project.sourceRoot, 'main.server.ts'), (0, devkit_1.joinPathFragments)(project.sourceRoot, 'bootstrap.server.ts'));
|
|
15
15
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'server.ts'), "import('./src/main.server');");
|
|
16
16
|
const browserBundleOutput = (0, devkit_1.joinPathFragments)(project.targets.build.options.outputPath, 'browser');
|
|
17
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files'), project.root, {
|
|
17
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common'), project.root, {
|
|
18
18
|
appName,
|
|
19
19
|
browserBundleOutput,
|
|
20
20
|
standalone: options.standalone,
|
|
21
21
|
tmpl: '',
|
|
22
22
|
});
|
|
23
|
+
const pathToTemplateFiles = typescriptConfiguration ? 'ts' : 'js';
|
|
24
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files', pathToTemplateFiles), project.root, {
|
|
25
|
+
tmpl: '',
|
|
26
|
+
});
|
|
23
27
|
// update project.json
|
|
24
28
|
project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
25
29
|
project.targets.server.executor = '@nx/angular:webpack-server';
|
|
26
30
|
project.targets.server.options.customWebpackConfig = {
|
|
27
|
-
path: (0, devkit_1.joinPathFragments)(project.root,
|
|
31
|
+
path: (0, devkit_1.joinPathFragments)(project.root, `webpack.server.config.${pathToTemplateFiles}`),
|
|
28
32
|
};
|
|
29
33
|
project.targets['serve-ssr'].executor =
|
|
30
34
|
'@nx/angular:module-federation-dev-ssr';
|
|
@@ -173,6 +173,11 @@
|
|
|
173
173
|
"type": "boolean",
|
|
174
174
|
"default": false,
|
|
175
175
|
"x-priority": "important"
|
|
176
|
+
},
|
|
177
|
+
"typescriptConfiguration": {
|
|
178
|
+
"type": "boolean",
|
|
179
|
+
"description": "Whether the module federation configuration and webpack configuration files should use TS.",
|
|
180
|
+
"default": true
|
|
176
181
|
}
|
|
177
182
|
},
|
|
178
183
|
"additionalProperties": false,
|
|
@@ -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: {
|
|
@@ -62,13 +62,11 @@ class Migrator {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
const nxJson = (0, devkit_1.readNxJson)(this.tree);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
]));
|
|
71
|
-
});
|
|
65
|
+
nxJson.targetDefaults ??= {};
|
|
66
|
+
for (const target of targetNames) {
|
|
67
|
+
nxJson.targetDefaults[target] ??= {};
|
|
68
|
+
nxJson.targetDefaults[target].cache ??= true;
|
|
69
|
+
}
|
|
72
70
|
(0, devkit_1.updateNxJson)(this.tree, nxJson);
|
|
73
71
|
}
|
|
74
72
|
// TODO(leo): This should be moved to BuilderMigrator once everything is split into builder migrators.
|
|
@@ -31,19 +31,6 @@ function createNxJson(tree, options, defaultProject) {
|
|
|
31
31
|
affected: {
|
|
32
32
|
defaultBase: options.defaultBase ?? (0, default_base_1.deduceDefaultBase)(),
|
|
33
33
|
},
|
|
34
|
-
tasksRunnerOptions: {
|
|
35
|
-
default: {
|
|
36
|
-
runner: 'nx/tasks-runners/default',
|
|
37
|
-
options: {
|
|
38
|
-
cacheableOperations: [
|
|
39
|
-
'build',
|
|
40
|
-
targets.test ? 'test' : undefined,
|
|
41
|
-
targets.lint ? 'lint' : undefined,
|
|
42
|
-
targets.e2e ? 'e2e' : undefined,
|
|
43
|
-
].filter(Boolean),
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
34
|
namedInputs: {
|
|
48
35
|
sharedGlobals: [],
|
|
49
36
|
default: ['{projectRoot}/**/*', 'sharedGlobals'],
|
|
@@ -65,10 +52,12 @@ function createNxJson(tree, options, defaultProject) {
|
|
|
65
52
|
build: {
|
|
66
53
|
dependsOn: ['^build'],
|
|
67
54
|
inputs: ['production', '^production'],
|
|
55
|
+
cache: true,
|
|
68
56
|
},
|
|
69
57
|
test: targets.test
|
|
70
58
|
? {
|
|
71
59
|
inputs: ['default', '^production', '{workspaceRoot}/karma.conf.js'],
|
|
60
|
+
cache: true,
|
|
72
61
|
}
|
|
73
62
|
: undefined,
|
|
74
63
|
lint: targets.lint
|
|
@@ -78,11 +67,13 @@ function createNxJson(tree, options, defaultProject) {
|
|
|
78
67
|
'{workspaceRoot}/.eslintrc.json',
|
|
79
68
|
'{workspaceRoot}/eslint.config.js',
|
|
80
69
|
],
|
|
70
|
+
cache: true,
|
|
81
71
|
}
|
|
82
72
|
: undefined,
|
|
83
73
|
e2e: targets.e2e
|
|
84
74
|
? {
|
|
85
75
|
inputs: ['default', '^production'],
|
|
76
|
+
cache: true,
|
|
86
77
|
}
|
|
87
78
|
: undefined,
|
|
88
79
|
},
|