@nx/angular 17.1.0-beta.0 → 17.1.0-beta.3
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/fesm2022/nx-angular.mjs +1 -1
- package/migrations.json +135 -0
- package/ng-package.json +0 -1
- package/package.json +15 -20
- package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.d.ts +1 -1
- package/src/builders/module-federation-dev-server/module-federation-dev-server.impl.js +112 -60
- package/src/builders/module-federation-dev-server/schema.d.ts +23 -7
- package/src/builders/module-federation-dev-server/schema.json +13 -3
- package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.d.ts +1 -1
- package/src/builders/module-federation-dev-ssr/module-federation-dev-ssr.impl.js +13 -8
- package/src/builders/webpack-browser/schema.json +7 -7
- package/src/builders/webpack-browser/webpack-browser.impl.js +0 -2
- package/src/builders/webpack-dev-server/lib/normalize-options.d.ts +2 -2
- package/src/builders/webpack-dev-server/lib/normalize-options.js +11 -5
- package/src/builders/webpack-dev-server/schema.d.ts +22 -7
- package/src/builders/webpack-dev-server/schema.json +9 -3
- package/src/builders/webpack-dev-server/webpack-dev-server.impl.js +24 -13
- package/src/builders/webpack-server/schema.d.ts +0 -1
- package/src/builders/webpack-server/schema.json +1 -13
- package/src/builders/webpack-server/validate-options.js +0 -7
- package/src/builders/webpack-server/webpack-server.impl.js +0 -8
- package/src/executors/browser-esbuild/browser-esbuild.impl.js +0 -2
- package/src/executors/browser-esbuild/schema.json +5 -4
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.js +20 -12
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ngc/compile-source-files.js +10 -1
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/styles/stylesheet-processor.js +0 -13
- package/src/executors/package/ng-packagr-adjustments/ngc/compile-source-files.js +10 -1
- package/src/executors/package/ng-packagr-adjustments/styles/stylesheet-processor.js +0 -13
- package/src/executors/utilities/ng-compiler-cli.d.ts +15 -0
- package/src/executors/utilities/ng-compiler-cli.js +28 -0
- package/src/generators/application/application.js +7 -17
- package/src/generators/application/files/base/tsconfig.app.json__tpl__ +1 -1
- package/src/generators/application/files/base/tsconfig.json__tpl__ +3 -2
- package/src/generators/application/files/ng-module/src/app/app.module.ts__tpl__ +1 -1
- package/src/generators/application/files/ng-module/src/app/nx-welcome.component.ts__tpl__ +2 -2
- package/src/generators/application/files/ng-module/src/main.ts__tpl__ +2 -8
- package/src/generators/application/files/standalone-components/src/app/app.config.ts__tpl__ +2 -2
- package/src/generators/application/files/standalone-components/src/app/nx-welcome.component.ts__tpl__ +2 -2
- package/src/generators/application/lib/add-e2e.js +7 -1
- package/src/generators/application/lib/add-unit-test-runner.js +11 -1
- package/src/generators/application/lib/create-files.js +10 -5
- package/src/generators/application/lib/create-project.js +46 -38
- package/src/generators/application/lib/normalize-options.d.ts +1 -1
- package/src/generators/application/lib/normalize-options.js +14 -3
- package/src/generators/application/lib/normalized-schema.d.ts +2 -0
- package/src/generators/application/schema.d.ts +1 -0
- package/src/generators/application/schema.json +13 -6
- package/src/generators/component/component.js +0 -1
- package/src/generators/component/lib/index.d.ts +0 -1
- package/src/generators/component/lib/index.js +0 -1
- package/src/generators/component/lib/normalize-options.js +1 -0
- package/src/generators/component/schema.json +2 -2
- package/src/generators/directive/directive.js +0 -1
- package/src/generators/directive/lib/index.d.ts +0 -1
- package/src/generators/directive/lib/index.js +0 -1
- package/src/generators/directive/lib/normalize-options.js +1 -0
- package/src/generators/directive/schema.json +2 -2
- package/src/generators/federate-module/federate-module.js +1 -0
- package/src/generators/federate-module/lib/add-remote.d.ts +1 -1
- package/src/generators/federate-module/lib/add-remote.js +2 -11
- package/src/generators/federate-module/schema.json +9 -9
- package/src/generators/host/files/common/v17+/src/main.server.ts__tmpl__ +67 -0
- package/src/generators/host/host.js +5 -9
- package/src/generators/host/lib/index.d.ts +1 -1
- package/src/generators/host/lib/index.js +1 -1
- package/src/generators/host/lib/update-ssr-setup.d.ts +3 -0
- package/src/generators/host/lib/{add-ssr.js → update-ssr-setup.js} +8 -14
- package/src/generators/host/schema.json +2 -2
- package/src/generators/library/lib/normalize-options.js +1 -0
- package/src/generators/library/library.js +10 -6
- package/src/generators/library/schema.json +12 -12
- package/src/generators/ng-add/migrators/projects/app.migrator.js +50 -7
- package/src/generators/ngrx/lib/generate-files.js +1 -10
- package/src/generators/ngrx/lib/validate-options.js +0 -23
- package/src/generators/ngrx/schema.json +2 -2
- package/src/generators/ngrx-feature-store/lib/generate-files.js +1 -12
- package/src/generators/ngrx-feature-store/lib/validate-options.js +0 -22
- package/src/generators/ngrx-feature-store/schema.json +2 -2
- package/src/generators/ngrx-root-store/lib/normalize-options.js +1 -1
- package/src/generators/ngrx-root-store/lib/validate-options.js +0 -15
- package/src/generators/ngrx-root-store/schema.json +1 -1
- package/src/generators/pipe/lib/index.d.ts +0 -1
- package/src/generators/pipe/lib/index.js +0 -1
- package/src/generators/pipe/lib/normalize-options.js +1 -0
- package/src/generators/pipe/pipe.js +0 -1
- package/src/generators/pipe/schema.json +2 -2
- package/src/generators/remote/files/common/v17+/src/main.server.ts__tmpl__ +74 -0
- package/src/generators/remote/lib/index.d.ts +1 -1
- package/src/generators/remote/lib/index.js +1 -1
- package/src/generators/remote/lib/{add-ssr.d.ts → update-ssr-setup.d.ts} +1 -1
- package/src/generators/remote/lib/{add-ssr.js → update-ssr-setup.js} +9 -13
- package/src/generators/remote/remote.js +4 -9
- package/src/generators/remote/schema.json +2 -2
- package/src/generators/scam-to-standalone/scam-to-standalone.js +0 -7
- package/src/generators/scam-to-standalone/schema.json +1 -1
- package/src/generators/setup-mf/lib/add-remote-entry.js +2 -11
- package/src/generators/setup-mf/lib/fix-bootstrap.js +3 -12
- package/src/generators/setup-mf/lib/index.d.ts +1 -1
- package/src/generators/setup-mf/lib/index.js +1 -1
- package/src/generators/setup-mf/lib/normalize-options.js +1 -0
- package/src/generators/{component/lib/validate-options.d.ts → setup-mf/lib/update-tsconfig.d.ts} +1 -1
- package/src/generators/setup-mf/lib/update-tsconfig.js +19 -0
- package/src/generators/setup-mf/schema.json +2 -2
- package/src/generators/setup-mf/setup-mf.js +1 -7
- package/src/generators/setup-ssr/files/server/application-builder/__serverFileName__ +54 -0
- package/src/generators/setup-ssr/files/{ngmodule/base → server/server-builder/pre-v17}/__serverFileName__ +3 -4
- package/src/generators/setup-ssr/files/{standalone → server/server-builder/v17+}/__serverFileName__ +25 -16
- package/src/generators/setup-ssr/lib/add-dependencies.d.ts +2 -0
- package/src/generators/setup-ssr/lib/add-dependencies.js +32 -0
- package/src/generators/setup-ssr/lib/generate-files.d.ts +1 -1
- package/src/generators/setup-ssr/lib/generate-files.js +10 -13
- package/src/generators/setup-ssr/lib/generate-server-ts-config.d.ts +4 -0
- package/src/generators/setup-ssr/lib/generate-server-ts-config.js +26 -0
- package/src/generators/setup-ssr/lib/index.d.ts +3 -0
- package/src/generators/setup-ssr/lib/index.js +3 -0
- package/src/generators/setup-ssr/lib/normalize-options.js +7 -1
- package/src/generators/setup-ssr/lib/set-router-initial-navigation.d.ts +3 -0
- package/src/generators/setup-ssr/lib/set-router-initial-navigation.js +93 -0
- package/src/generators/setup-ssr/lib/update-project-config.d.ts +2 -1
- package/src/generators/setup-ssr/lib/update-project-config.js +24 -6
- package/src/generators/setup-ssr/lib/validate-options.js +15 -2
- package/src/generators/setup-ssr/schema.json +3 -3
- package/src/generators/setup-ssr/setup-ssr.js +16 -12
- package/src/generators/utils/create-ts-config.d.ts +1 -0
- package/src/generators/utils/create-ts-config.js +2 -3
- package/src/generators/utils/project.js +4 -4
- package/src/generators/utils/testing.js +12 -0
- package/src/generators/utils/validations.d.ts +0 -1
- package/src/generators/utils/validations.js +1 -14
- package/src/generators/utils/version-utils.js +2 -2
- package/src/migrations/update-17-1-0/browser-target-to-build-target.d.ts +3 -0
- package/src/migrations/update-17-1-0/browser-target-to-build-target.js +50 -0
- package/src/migrations/update-17-1-0/replace-nguniversal-builders.d.ts +2 -0
- package/src/migrations/update-17-1-0/replace-nguniversal-builders.js +75 -0
- package/src/migrations/update-17-1-0/replace-nguniversal-engines.d.ts +2 -0
- package/src/migrations/update-17-1-0/replace-nguniversal-engines.js +185 -0
- package/src/migrations/update-17-1-0/stub-performance-mark-in-jest-test-setup.d.ts +2 -0
- package/src/migrations/update-17-1-0/stub-performance-mark-in-jest-test-setup.js +63 -0
- package/src/migrations/update-17-1-0/update-angular-cli.d.ts +3 -0
- package/src/migrations/update-17-1-0/update-angular-cli.js +23 -0
- package/src/utils/backward-compatible-versions.d.ts +1 -1
- package/src/utils/backward-compatible-versions.js +18 -18
- package/src/utils/nx-devkit/ast-utils.js +4 -2
- package/src/utils/versions.d.ts +6 -6
- package/src/utils/versions.js +6 -6
- package/src/builders/webpack-browser/validate-options.d.ts +0 -2
- package/src/builders/webpack-browser/validate-options.js +0 -40
- package/src/executors/browser-esbuild/lib/validate-options.d.ts +0 -2
- package/src/executors/browser-esbuild/lib/validate-options.js +0 -40
- package/src/generators/application/files/tsconfig.editor.json__tpl__ +0 -5
- package/src/generators/application/files/v14/.browserlistrc__tpl__ +0 -16
- package/src/generators/application/files/v14/src/environments/environment.prod.ts__tpl__ +0 -3
- package/src/generators/application/files/v14/src/environments/environment.ts__tpl__ +0 -16
- package/src/generators/application/files/v14/src/polyfills.ts__tpl__ +0 -53
- package/src/generators/component/lib/validate-options.js +0 -8
- package/src/generators/directive/lib/validate-options.d.ts +0 -3
- package/src/generators/directive/lib/validate-options.js +0 -8
- package/src/generators/host/lib/add-ssr.d.ts +0 -3
- package/src/generators/ngrx/files/no-inject/__directory__/__fileName__.effects.ts__tmpl__ +0 -22
- package/src/generators/ngrx/files/no-inject/__directory__/__fileName__.facade.ts__tmpl__ +0 -27
- package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.effects.ts__tmpl__ +0 -22
- package/src/generators/ngrx-feature-store/files/no-inject/__directory__/__fileName__.facade.ts__tmpl__ +0 -27
- package/src/generators/pipe/lib/validate-options.d.ts +0 -3
- package/src/generators/pipe/lib/validate-options.js +0 -8
- package/src/generators/setup-mf/lib/set-tsconfig-target.d.ts +0 -3
- package/src/generators/setup-mf/lib/set-tsconfig-target.js +0 -16
- package/src/generators/setup-ssr/files/ngmodule/v14/src/__main__ +0 -11
- /package/src/generators/host/files/common/{src → pre-v17/src}/main.server.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.actions.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.effects.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.effects.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.facade.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.facade.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.models.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.reducer.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.reducer.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.selectors.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx/files/{base/__directory__ → __directory__}/__fileName__.selectors.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.actions.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.effects.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.effects.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.facade.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.facade.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.models.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.reducer.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.reducer.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.selectors.spec.ts__tmpl__ +0 -0
- /package/src/generators/ngrx-feature-store/files/{base/__directory__ → __directory__}/__fileName__.selectors.ts__tmpl__ +0 -0
- /package/src/generators/remote/files/common/{src → pre-v17/src}/main.server.ts__tmpl__ +0 -0
- /package/src/generators/setup-ssr/files/{base → root}/tsconfig.server.json__tpl__ +0 -0
|
@@ -3,12 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.hostInternal = exports.host = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
|
-
const semver_1 = require("semver");
|
|
7
6
|
const test_runners_1 = require("../../utils/test-runners");
|
|
8
7
|
const application_1 = require("../application/application");
|
|
9
8
|
const remote_1 = require("../remote/remote");
|
|
10
9
|
const setup_mf_1 = require("../setup-mf/setup-mf");
|
|
11
|
-
const version_utils_1 = require("../utils/version-utils");
|
|
12
10
|
const lib_1 = require("./lib");
|
|
13
11
|
async function host(tree, options) {
|
|
14
12
|
return await hostInternal(tree, {
|
|
@@ -18,12 +16,8 @@ async function host(tree, options) {
|
|
|
18
16
|
}
|
|
19
17
|
exports.host = host;
|
|
20
18
|
async function hostInternal(tree, schema) {
|
|
21
|
-
const installedAngularVersionInfo = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
22
|
-
if ((0, semver_1.lt)(installedAngularVersionInfo.version, '14.1.0') && schema.standalone) {
|
|
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
|
-
You can resolve this error by removing the "standalone" option or by migrating to Angular 14.1.0.`);
|
|
25
|
-
}
|
|
26
19
|
const { typescriptConfiguration = true, ...options } = schema;
|
|
20
|
+
options.standalone = options.standalone ?? true;
|
|
27
21
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
28
22
|
const remotesToGenerate = [];
|
|
29
23
|
const remotesToIntegrate = [];
|
|
@@ -47,10 +41,11 @@ async function hostInternal(tree, schema) {
|
|
|
47
41
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
48
42
|
const appInstallTask = await (0, application_1.default)(tree, {
|
|
49
43
|
...options,
|
|
50
|
-
standalone: options.standalone
|
|
44
|
+
standalone: options.standalone,
|
|
51
45
|
routing: true,
|
|
52
46
|
port: 4200,
|
|
53
47
|
skipFormat: true,
|
|
48
|
+
bundler: 'webpack',
|
|
54
49
|
});
|
|
55
50
|
const skipE2E = !options.e2eTestRunner || options.e2eTestRunner === test_runners_1.E2eTestRunner.None;
|
|
56
51
|
await (0, setup_mf_1.setupMf)(tree, {
|
|
@@ -66,10 +61,11 @@ async function hostInternal(tree, schema) {
|
|
|
66
61
|
e2eProjectName: skipE2E ? undefined : `${hostProjectName}-e2e`,
|
|
67
62
|
prefix: options.prefix,
|
|
68
63
|
typescriptConfiguration,
|
|
64
|
+
standalone: options.standalone,
|
|
69
65
|
});
|
|
70
66
|
let installTasks = [appInstallTask];
|
|
71
67
|
if (options.ssr) {
|
|
72
|
-
let ssrInstallTask = await (0, lib_1.
|
|
68
|
+
let ssrInstallTask = await (0, lib_1.updateSsrSetup)(tree, options, hostProjectName, typescriptConfiguration);
|
|
73
69
|
installTasks.push(ssrInstallTask);
|
|
74
70
|
}
|
|
75
71
|
for (const remote of remotesToGenerate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './update-ssr-setup';
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.updateSsrSetup = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const setup_ssr_1 = require("../../setup-ssr/setup-ssr");
|
|
6
|
-
const versions_1 = require("../../../utils/versions");
|
|
7
5
|
const path_1 = require("path");
|
|
8
|
-
|
|
6
|
+
const versions_1 = require("../../../utils/versions");
|
|
7
|
+
const version_utils_1 = require("../../utils/version-utils");
|
|
8
|
+
async function updateSsrSetup(tree, options, appName, typescriptConfiguration) {
|
|
9
9
|
let project = (0, devkit_1.readProjectConfiguration)(tree, appName);
|
|
10
|
-
await (0, setup_ssr_1.default)(tree, {
|
|
11
|
-
project: appName,
|
|
12
|
-
standalone: options.standalone,
|
|
13
|
-
});
|
|
14
10
|
tree.rename((0, devkit_1.joinPathFragments)(project.sourceRoot, 'main.server.ts'), (0, devkit_1.joinPathFragments)(project.sourceRoot, 'bootstrap.server.ts'));
|
|
15
11
|
tree.write((0, devkit_1.joinPathFragments)(project.root, 'server.ts'), "import('./src/main.server');");
|
|
16
|
-
const
|
|
17
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common'), project.root, {
|
|
12
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
13
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, '../files/common', angularMajorVersion >= 17 ? 'v17+' : 'pre-v17'), project.root, {
|
|
18
14
|
appName,
|
|
19
|
-
browserBundleOutput,
|
|
15
|
+
browserBundleOutput: project.targets.build.options.outputPath,
|
|
20
16
|
standalone: options.standalone,
|
|
21
17
|
tmpl: '',
|
|
22
18
|
});
|
|
@@ -35,12 +31,10 @@ async function addSsr(tree, options, appName, typescriptConfiguration) {
|
|
|
35
31
|
(0, devkit_1.updateProjectConfiguration)(tree, appName, project);
|
|
36
32
|
const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
37
33
|
cors: versions_1.corsVersion,
|
|
38
|
-
express: versions_1.expressVersion,
|
|
39
34
|
'@module-federation/node': versions_1.moduleFederationNodeVersion,
|
|
40
35
|
}, {
|
|
41
36
|
'@types/cors': versions_1.typesCorsVersion,
|
|
42
|
-
'@types/express': versions_1.typesExpressVersion,
|
|
43
37
|
});
|
|
44
38
|
return installTask;
|
|
45
39
|
}
|
|
46
|
-
exports.
|
|
40
|
+
exports.updateSsrSetup = updateSsrSetup;
|
|
@@ -165,8 +165,8 @@
|
|
|
165
165
|
},
|
|
166
166
|
"standalone": {
|
|
167
167
|
"type": "boolean",
|
|
168
|
-
"description": "Whether to generate a host application that uses standalone components.
|
|
169
|
-
"default":
|
|
168
|
+
"description": "Whether to generate a host application that uses standalone components.",
|
|
169
|
+
"default": true
|
|
170
170
|
},
|
|
171
171
|
"ssr": {
|
|
172
172
|
"description": "Whether to configure SSR for the host application",
|
|
@@ -8,6 +8,7 @@ const eslint_1 = require("@nx/eslint");
|
|
|
8
8
|
const test_runners_1 = require("../../../utils/test-runners");
|
|
9
9
|
const project_1 = require("../../utils/project");
|
|
10
10
|
async function normalizeOptions(host, schema) {
|
|
11
|
+
schema.standalone = schema.standalone ?? true;
|
|
11
12
|
// Create a schema with populated default values
|
|
12
13
|
const options = {
|
|
13
14
|
buildable: false,
|
|
@@ -5,7 +5,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const jest_1 = require("@nx/jest");
|
|
6
6
|
const eslint_1 = require("@nx/eslint");
|
|
7
7
|
const js_1 = require("@nx/js");
|
|
8
|
-
const semver_1 = require("semver");
|
|
9
8
|
const init_1 = require("../../generators/init/init");
|
|
10
9
|
const test_runners_1 = require("../../utils/test-runners");
|
|
11
10
|
const add_linting_1 = require("../add-linting/add-linting");
|
|
@@ -40,10 +39,6 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
40
39
|
if (schema.addTailwind && !schema.buildable && !schema.publishable) {
|
|
41
40
|
throw new Error(`To use "--addTailwind" option, you have to set either "--buildable" or "--publishable".`);
|
|
42
41
|
}
|
|
43
|
-
const userInstalledAngularVersion = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
44
|
-
if ((0, semver_1.lt)(userInstalledAngularVersion.version, '14.1.0') && schema.standalone) {
|
|
45
|
-
throw new Error(`The "--standalone" option is not supported in Angular versions < 14.1.0.`);
|
|
46
|
-
}
|
|
47
42
|
const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
|
|
48
43
|
const { libraryOptions } = options;
|
|
49
44
|
const pkgVersions = (0, version_utils_1.versions)(tree);
|
|
@@ -99,6 +94,7 @@ async function addUnitTestRunner(host, options) {
|
|
|
99
94
|
skipPackageJson: options.skipPackageJson,
|
|
100
95
|
});
|
|
101
96
|
const setupFile = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src', 'test-setup.ts');
|
|
97
|
+
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(host);
|
|
102
98
|
if (options.strict && host.exists(setupFile)) {
|
|
103
99
|
const contents = host.read(setupFile, 'utf-8');
|
|
104
100
|
host.write(setupFile, `// @ts-expect-error https://thymikee.github.io/jest-preset-angular/docs/getting-started/test-environment
|
|
@@ -108,7 +104,15 @@ globalThis.ngJest = {
|
|
|
108
104
|
errorOnUnknownProperties: true,
|
|
109
105
|
},
|
|
110
106
|
};
|
|
111
|
-
${contents}
|
|
107
|
+
${contents}${angularMajorVersion >= 17
|
|
108
|
+
? `
|
|
109
|
+
/**
|
|
110
|
+
* Angular uses performance.mark() which is not supported by jsdom. Stub it out
|
|
111
|
+
* to avoid errors.
|
|
112
|
+
*/
|
|
113
|
+
global.performance.mark = jest.fn();
|
|
114
|
+
`
|
|
115
|
+
: ''}`);
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
}
|
|
@@ -141,65 +141,65 @@
|
|
|
141
141
|
},
|
|
142
142
|
"standalone": {
|
|
143
143
|
"type": "boolean",
|
|
144
|
-
"description": "Generate a library that uses a standalone component instead of a module as the entry point.
|
|
145
|
-
"default":
|
|
144
|
+
"description": "Generate a library that uses a standalone component instead of a module as the entry point.",
|
|
145
|
+
"default": true
|
|
146
146
|
},
|
|
147
147
|
"displayBlock": {
|
|
148
|
-
"description": "Specifies if the component generated style will contain `:host { display: block; }`. Disclaimer: This option is only valid when `--standalone` is set to `true`.
|
|
148
|
+
"description": "Specifies if the component generated style will contain `:host { display: block; }`. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
|
|
149
149
|
"type": "boolean",
|
|
150
150
|
"default": false,
|
|
151
151
|
"alias": "b"
|
|
152
152
|
},
|
|
153
153
|
"inlineStyle": {
|
|
154
|
-
"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`.
|
|
154
|
+
"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`.",
|
|
155
155
|
"type": "boolean",
|
|
156
156
|
"default": false,
|
|
157
157
|
"alias": "s"
|
|
158
158
|
},
|
|
159
159
|
"inlineTemplate": {
|
|
160
|
-
"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`.
|
|
160
|
+
"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`.",
|
|
161
161
|
"type": "boolean",
|
|
162
162
|
"default": false,
|
|
163
163
|
"alias": "t"
|
|
164
164
|
},
|
|
165
165
|
"viewEncapsulation": {
|
|
166
|
-
"description": "The view encapsulation strategy to use in the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.
|
|
166
|
+
"description": "The view encapsulation strategy to use in the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
|
|
167
167
|
"enum": ["Emulated", "None", "ShadowDom"],
|
|
168
168
|
"type": "string",
|
|
169
169
|
"alias": "v"
|
|
170
170
|
},
|
|
171
171
|
"changeDetection": {
|
|
172
|
-
"description": "The change detection strategy to use in the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.
|
|
172
|
+
"description": "The change detection strategy to use in the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
|
|
173
173
|
"enum": ["Default", "OnPush"],
|
|
174
174
|
"type": "string",
|
|
175
175
|
"default": "Default",
|
|
176
176
|
"alias": "c"
|
|
177
177
|
},
|
|
178
178
|
"style": {
|
|
179
|
-
"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`.
|
|
179
|
+
"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`.",
|
|
180
180
|
"type": "string",
|
|
181
181
|
"default": "css",
|
|
182
182
|
"enum": ["css", "scss", "sass", "less", "none"]
|
|
183
183
|
},
|
|
184
184
|
"skipTests": {
|
|
185
185
|
"type": "boolean",
|
|
186
|
-
"description": "Do not create `spec.ts` test files for the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.
|
|
186
|
+
"description": "Do not create `spec.ts` test files for the new component. Disclaimer: This option is only valid when `--standalone` is set to `true`.",
|
|
187
187
|
"default": false
|
|
188
188
|
},
|
|
189
189
|
"selector": {
|
|
190
190
|
"type": "string",
|
|
191
191
|
"format": "html-selector",
|
|
192
|
-
"description": "The HTML selector to use for this component. Disclaimer: This option is only valid when `--standalone` is set to `true`.
|
|
192
|
+
"description": "The HTML selector to use for this component. Disclaimer: This option is only valid when `--standalone` is set to `true`."
|
|
193
193
|
},
|
|
194
194
|
"skipSelector": {
|
|
195
195
|
"type": "boolean",
|
|
196
196
|
"default": false,
|
|
197
|
-
"description": "Specifies if the component should have a selector or not. Disclaimer: This option is only valid when `--standalone` is set to `true`.
|
|
197
|
+
"description": "Specifies if the component should have a selector or not. Disclaimer: This option is only valid when `--standalone` is set to `true`."
|
|
198
198
|
},
|
|
199
199
|
"flat": {
|
|
200
200
|
"type": "boolean",
|
|
201
201
|
"default": false,
|
|
202
|
-
"description": "Ensure the generated standalone component is not placed in a subdirectory. Disclaimer: This option is only valid when `--standalone` is set to `true`.
|
|
202
|
+
"description": "Ensure the generated standalone component is not placed in a subdirectory. Disclaimer: This option is only valid when `--standalone` is set to `true`."
|
|
203
203
|
}
|
|
204
204
|
},
|
|
205
205
|
"additionalProperties": false,
|
|
@@ -9,7 +9,13 @@ const builders_1 = require("../builders");
|
|
|
9
9
|
const e2e_migrator_1 = require("./e2e.migrator");
|
|
10
10
|
const project_migrator_1 = require("./project.migrator");
|
|
11
11
|
const supportedTargets = {
|
|
12
|
-
build: {
|
|
12
|
+
build: {
|
|
13
|
+
builders: [
|
|
14
|
+
'@angular-devkit/build-angular:application',
|
|
15
|
+
'@angular-devkit/build-angular:browser',
|
|
16
|
+
'@angular-devkit/build-angular:browser-esbuild',
|
|
17
|
+
],
|
|
18
|
+
},
|
|
13
19
|
e2e: {
|
|
14
20
|
acceptMultipleDefinitions: true,
|
|
15
21
|
builders: [
|
|
@@ -18,10 +24,20 @@ const supportedTargets = {
|
|
|
18
24
|
],
|
|
19
25
|
},
|
|
20
26
|
i18n: { builders: ['@angular-devkit/build-angular:extract-i18n'] },
|
|
21
|
-
prerender: {
|
|
27
|
+
prerender: {
|
|
28
|
+
builders: [
|
|
29
|
+
'@nguniversal/builders:prerender',
|
|
30
|
+
'@angular-devkit/build-angular:prerender',
|
|
31
|
+
],
|
|
32
|
+
},
|
|
22
33
|
serve: { builders: ['@angular-devkit/build-angular:dev-server'] },
|
|
23
34
|
server: { builders: ['@angular-devkit/build-angular:server'] },
|
|
24
|
-
serveSsr: {
|
|
35
|
+
serveSsr: {
|
|
36
|
+
builders: [
|
|
37
|
+
'@nguniversal/builders:ssr-dev-server',
|
|
38
|
+
'@angular-devkit/build-angular:ssr-dev-server',
|
|
39
|
+
],
|
|
40
|
+
},
|
|
25
41
|
};
|
|
26
42
|
// TODO(leo): this will replace `supportedTargets` once the full refactor is done.
|
|
27
43
|
const supportedBuilderMigrators = [
|
|
@@ -125,10 +141,22 @@ class AppMigrator extends project_migrator_1.ProjectMigrator {
|
|
|
125
141
|
buildOptions.outputPath =
|
|
126
142
|
buildOptions.outputPath &&
|
|
127
143
|
(0, devkit_1.joinPathFragments)('dist', this.project.newRoot, this.targetNames.server ? 'browser' : '');
|
|
128
|
-
buildOptions.index
|
|
129
|
-
buildOptions.index
|
|
144
|
+
if (buildOptions.index) {
|
|
145
|
+
if (typeof buildOptions.index === 'string') {
|
|
146
|
+
buildOptions.index = this.convertAsset(buildOptions.index);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
buildOptions.index.input =
|
|
150
|
+
buildOptions.index.input &&
|
|
151
|
+
this.convertAsset(buildOptions.index.input);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
130
154
|
buildOptions.main =
|
|
131
155
|
buildOptions.main && this.convertAsset(buildOptions.main);
|
|
156
|
+
buildOptions.browser =
|
|
157
|
+
buildOptions.browser && this.convertAsset(buildOptions.browser);
|
|
158
|
+
buildOptions.server =
|
|
159
|
+
buildOptions.server && this.convertAsset(buildOptions.server);
|
|
132
160
|
buildOptions.polyfills =
|
|
133
161
|
buildOptions.polyfills &&
|
|
134
162
|
(Array.isArray(buildOptions.polyfills)
|
|
@@ -152,6 +180,20 @@ class AppMigrator extends project_migrator_1.ProjectMigrator {
|
|
|
152
180
|
replace: this.convertAsset(replacement.replace),
|
|
153
181
|
with: this.convertAsset(replacement.with),
|
|
154
182
|
}));
|
|
183
|
+
buildOptions.serviceWorker =
|
|
184
|
+
buildOptions.serviceWorker &&
|
|
185
|
+
typeof buildOptions.serviceWorker === 'string' &&
|
|
186
|
+
this.convertAsset(buildOptions.serviceWorker);
|
|
187
|
+
buildOptions.ngswConfigPath =
|
|
188
|
+
buildOptions.ngswConfigPath &&
|
|
189
|
+
this.convertAsset(buildOptions.ngswConfigPath);
|
|
190
|
+
if (buildOptions.prerender?.routesFile) {
|
|
191
|
+
buildOptions.prerender.routesFile = this.convertAsset(buildOptions.prerender.routesFile);
|
|
192
|
+
}
|
|
193
|
+
buildOptions.ssr =
|
|
194
|
+
buildOptions.ssr &&
|
|
195
|
+
typeof buildOptions.ssr === 'string' &&
|
|
196
|
+
this.convertAsset(buildOptions.ssr);
|
|
155
197
|
}
|
|
156
198
|
convertServerOptions(serverOptions) {
|
|
157
199
|
serverOptions.outputPath =
|
|
@@ -243,11 +285,12 @@ class AppMigrator extends project_migrator_1.ProjectMigrator {
|
|
|
243
285
|
this.shouldSkipTargetTypeMigration('serveSsr')) {
|
|
244
286
|
return;
|
|
245
287
|
}
|
|
246
|
-
const
|
|
288
|
+
const ssrTarget = this.targetNames.serveSsr ?? this.targetNames['serve-ssr'];
|
|
289
|
+
const serveSsrTarget = this.projectConfig.targets[ssrTarget];
|
|
247
290
|
if (!serveSsrTarget.options &&
|
|
248
291
|
(!serveSsrTarget.configurations ||
|
|
249
292
|
!Object.keys(serveSsrTarget.configurations).length)) {
|
|
250
|
-
this.logger.warn(`The target "${
|
|
293
|
+
this.logger.warn(`The target "${ssrTarget}" is not specifying any options or configurations. Skipping updating the target configuration.`);
|
|
251
294
|
return;
|
|
252
295
|
}
|
|
253
296
|
['sslKey', 'sslCert', 'proxyConfig'].forEach((option) => {
|
|
@@ -3,27 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateNgrxFilesFromTemplates = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const semver_1 = require("semver");
|
|
6
|
-
const version_utils_1 = require("../../utils/version-utils");
|
|
7
6
|
/**
|
|
8
7
|
* Generate 'feature' scaffolding: actions, reducer, effects, interfaces, selectors, facade
|
|
9
8
|
*/
|
|
10
9
|
function generateNgrxFilesFromTemplates(tree, options) {
|
|
11
10
|
const name = options.name;
|
|
12
11
|
const projectNames = (0, devkit_1.names)(name);
|
|
13
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files'
|
|
12
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files'), options.parentDirectory, {
|
|
14
13
|
...options,
|
|
15
14
|
...projectNames,
|
|
16
15
|
importFromOperators: (0, semver_1.lt)(options.rxjsVersion, '7.2.0'),
|
|
17
16
|
tmpl: '',
|
|
18
17
|
});
|
|
19
|
-
const angularVersion = (0, version_utils_1.getInstalledAngularVersion)(tree);
|
|
20
|
-
if ((0, semver_1.lt)(angularVersion, '14.1.0')) {
|
|
21
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files', 'no-inject'), options.parentDirectory, {
|
|
22
|
-
...options,
|
|
23
|
-
...projectNames,
|
|
24
|
-
tmpl: '',
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
18
|
if (!options.facade) {
|
|
28
19
|
tree.delete((0, devkit_1.joinPathFragments)(options.parentDirectory, options.directory, `${projectNames.fileName}.facade.ts`));
|
|
29
20
|
tree.delete((0, devkit_1.joinPathFragments)(options.parentDirectory, options.directory, `${projectNames.fileName}.facade.spec.ts`));
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateOptions = void 0;
|
|
4
|
-
const semver_1 = require("semver");
|
|
5
|
-
const version_utils_1 = require("../../utils/version-utils");
|
|
6
|
-
const version_utils_2 = require("../../../utils/version-utils");
|
|
7
4
|
function validateOptions(tree, options) {
|
|
8
5
|
if (!options.module && !options.parent) {
|
|
9
6
|
throw new Error('Please provide a value for "--parent"!');
|
|
@@ -14,25 +11,5 @@ function validateOptions(tree, options) {
|
|
|
14
11
|
if (options.parent && !tree.exists(options.parent)) {
|
|
15
12
|
throw new Error(`Parent does not exist: ${options.parent}.`);
|
|
16
13
|
}
|
|
17
|
-
const angularVersionInfo = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
18
|
-
const intendedNgRxVersionForAngularMajor = (0, version_utils_2.getPkgVersionForAngularMajorVersion)('ngrxVersion', angularVersionInfo.major);
|
|
19
|
-
const ngrxMajorVersion = (0, version_utils_1.getInstalledPackageVersionInfo)(tree, '@ngrx/store')?.major ??
|
|
20
|
-
(0, semver_1.major)((0, semver_1.coerce)(intendedNgRxVersionForAngularMajor));
|
|
21
|
-
if ((0, semver_1.lt)(angularVersionInfo.version, '14.1.0') || ngrxMajorVersion < 15) {
|
|
22
|
-
const parentPath = options.parent ?? options.module;
|
|
23
|
-
const parentContent = tree.read(parentPath, 'utf-8');
|
|
24
|
-
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
25
|
-
const ast = tsquery.ast(parentContent);
|
|
26
|
-
const NG_MODULE_DECORATOR_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule])';
|
|
27
|
-
const nodes = tsquery(ast, NG_MODULE_DECORATOR_SELECTOR, {
|
|
28
|
-
visitAllChildren: true,
|
|
29
|
-
});
|
|
30
|
-
if (nodes.length === 0) {
|
|
31
|
-
throw new Error(`The provided parent path "${parentPath}" does not contain an "NgModule". ` +
|
|
32
|
-
'Please make sure to provide a path to an "NgModule" where the state will be registered. ' +
|
|
33
|
-
'If you are trying to use a "Routes" definition file (for Standalone API usage), ' +
|
|
34
|
-
'please note this is not supported in Angular versions lower than 14.1.0.');
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
14
|
}
|
|
38
15
|
exports.validateOptions = validateOptions;
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
},
|
|
43
43
|
"parent": {
|
|
44
44
|
"type": "string",
|
|
45
|
-
"description": "The path to the file where the state will be registered. For NgModule usage, this will be your `app.module.ts` for your root state, or your Feature Module for feature state. For Standalone API usage, this will be your `app.config.ts` file for your root state, or the Routes definition file for your feature state. The host directory will create/use the new state directory.
|
|
45
|
+
"description": "The path to the file where the state will be registered. For NgModule usage, this will be your `app.module.ts` for your root state, or your Feature Module for feature state. For Standalone API usage, this will be your `app.config.ts` file for your root state, or the Routes definition file for your feature state. The host directory will create/use the new state directory.",
|
|
46
46
|
"x-prompt": "What is the path to the module or Routes definition where this NgRx state should be registered?",
|
|
47
47
|
"x-priority": "important"
|
|
48
48
|
},
|
|
49
49
|
"route": {
|
|
50
50
|
"type": "string",
|
|
51
|
-
"description": "The route that the Standalone NgRx Providers should be added to.
|
|
51
|
+
"description": "The route that the Standalone NgRx Providers should be added to.",
|
|
52
52
|
"default": "''"
|
|
53
53
|
},
|
|
54
54
|
"directory": {
|
|
@@ -3,13 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateFilesFromTemplates = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const semver_1 = require("semver");
|
|
6
|
-
const version_utils_1 = require("../../utils/version-utils");
|
|
7
6
|
function generateFilesFromTemplates(tree, options) {
|
|
8
7
|
const projectNames = (0, devkit_1.names)(options.name);
|
|
9
8
|
const fileName = options.subdirectory
|
|
10
9
|
? (0, devkit_1.joinPathFragments)(options.subdirectory, projectNames.fileName)
|
|
11
10
|
: projectNames.fileName;
|
|
12
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files'
|
|
11
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files'), options.parentDirectory, {
|
|
13
12
|
...options,
|
|
14
13
|
...projectNames,
|
|
15
14
|
fileName,
|
|
@@ -17,16 +16,6 @@ function generateFilesFromTemplates(tree, options) {
|
|
|
17
16
|
importFromOperators: (0, semver_1.lt)(options.rxjsVersion, '7.2.0'),
|
|
18
17
|
tmpl: '',
|
|
19
18
|
});
|
|
20
|
-
const angularVersion = (0, version_utils_1.getInstalledAngularVersion)(tree);
|
|
21
|
-
if ((0, semver_1.lt)(angularVersion, '14.1.0')) {
|
|
22
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files', 'no-inject'), options.parentDirectory, {
|
|
23
|
-
...options,
|
|
24
|
-
...projectNames,
|
|
25
|
-
fileName,
|
|
26
|
-
relativeFileName: projectNames.fileName,
|
|
27
|
-
tmpl: '',
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
19
|
if (!options.facade) {
|
|
31
20
|
tree.delete((0, devkit_1.joinPathFragments)(options.parentDirectory, options.directory, `${options.subdirectory ? `${options.subdirectory}/` : ''}${projectNames.fileName}.facade.ts`));
|
|
32
21
|
tree.delete((0, devkit_1.joinPathFragments)(options.parentDirectory, options.directory, `${options.subdirectory ? `${options.subdirectory}/` : ''}${projectNames.fileName}.facade.spec.ts`));
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateOptions = void 0;
|
|
4
|
-
const version_utils_1 = require("../..//utils/version-utils");
|
|
5
|
-
const version_utils_2 = require("../../../utils/version-utils");
|
|
6
|
-
const semver_1 = require("semver");
|
|
7
4
|
function validateOptions(tree, options) {
|
|
8
5
|
if (!options.parent) {
|
|
9
6
|
throw new Error('Please provide a value for "--parent"!');
|
|
@@ -11,24 +8,5 @@ function validateOptions(tree, options) {
|
|
|
11
8
|
if (options.parent && !tree.exists(options.parent)) {
|
|
12
9
|
throw new Error(`Parent does not exist: ${options.parent}.`);
|
|
13
10
|
}
|
|
14
|
-
const angularVersionInfo = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
15
|
-
const intendedNgRxVersionForAngularMajor = (0, version_utils_2.getPkgVersionForAngularMajorVersion)('ngrxVersion', angularVersionInfo.major);
|
|
16
|
-
const ngrxMajorVersion = (0, version_utils_1.getInstalledPackageVersionInfo)(tree, '@ngrx/store')?.major ??
|
|
17
|
-
(0, semver_1.major)((0, semver_1.coerce)(intendedNgRxVersionForAngularMajor));
|
|
18
|
-
if ((0, semver_1.lt)(angularVersionInfo.version, '14.1.0') || ngrxMajorVersion < 15) {
|
|
19
|
-
const parentContent = tree.read(options.parent, 'utf-8');
|
|
20
|
-
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
21
|
-
const ast = tsquery.ast(parentContent);
|
|
22
|
-
const NG_MODULE_DECORATOR_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule])';
|
|
23
|
-
const nodes = tsquery(ast, NG_MODULE_DECORATOR_SELECTOR, {
|
|
24
|
-
visitAllChildren: true,
|
|
25
|
-
});
|
|
26
|
-
if (nodes.length === 0) {
|
|
27
|
-
throw new Error(`The provided parent path "${options.parent}" does not contain an "NgModule". ` +
|
|
28
|
-
'Please make sure to provide a path to an "NgModule" where the state will be registered. ' +
|
|
29
|
-
'If you are trying to use a "Routes" definition file (for Standalone API usage), ' +
|
|
30
|
-
'please note this is not supported in Angular versions lower than 14.1.0.');
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
11
|
}
|
|
34
12
|
exports.validateOptions = validateOptions;
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
},
|
|
19
19
|
"parent": {
|
|
20
20
|
"type": "string",
|
|
21
|
-
"description": "The path to the file where the state will be registered. For NgModule usage, this will be your Feature Module. For Standalone API usage, this will be your Routes definition file for your feature state. The host directory will create/use the new state directory.
|
|
21
|
+
"description": "The path to the file where the state will be registered. For NgModule usage, this will be your Feature Module. For Standalone API usage, this will be your Routes definition file for your feature state. The host directory will create/use the new state directory.",
|
|
22
22
|
"x-prompt": "What is the path to the module or Routes definition where this NgRx state should be registered?",
|
|
23
23
|
"x-priority": "important"
|
|
24
24
|
},
|
|
25
25
|
"route": {
|
|
26
26
|
"type": "string",
|
|
27
|
-
"description": "The route that the Standalone NgRx Providers should be added to.
|
|
27
|
+
"description": "The route that the Standalone NgRx Providers should be added to.",
|
|
28
28
|
"default": "''"
|
|
29
29
|
},
|
|
30
30
|
"minimal": {
|
|
@@ -16,7 +16,7 @@ function normalizeOptions(tree, options) {
|
|
|
16
16
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
17
17
|
const isStandalone = (0, ast_utils_1.isNgStandaloneApp)(tree, options.project);
|
|
18
18
|
const appConfigPath = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'app/app.config.ts');
|
|
19
|
-
const appMainPath = project.targets.build.options.main;
|
|
19
|
+
const appMainPath = project.targets.build.options.main ?? project.targets.build.options.browser;
|
|
20
20
|
/** If NgModule App
|
|
21
21
|
* -> Use App Module
|
|
22
22
|
* If Standalone
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateOptions = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const version_utils_1 = require("../../utils/version-utils");
|
|
6
|
-
const version_utils_2 = require("../../../utils/version-utils");
|
|
7
|
-
const semver_1 = require("semver");
|
|
8
|
-
const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
|
|
9
5
|
function validateOptions(tree, options) {
|
|
10
6
|
if (!(0, devkit_1.getProjects)(tree).has(options.project)) {
|
|
11
7
|
throw new Error(`Could not find project '${options.project}'. Please ensure the project name is correct and exists.`);
|
|
@@ -17,16 +13,5 @@ function validateOptions(tree, options) {
|
|
|
17
13
|
if (!options.minimal && !options.name) {
|
|
18
14
|
throw new Error(`If generating a global feature state with your root store, you must provide a name for it with '--name'.`);
|
|
19
15
|
}
|
|
20
|
-
const angularVersionInfo = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
21
|
-
const intendedNgRxVersionForAngularMajor = (0, version_utils_2.getPkgVersionForAngularMajorVersion)('ngrxVersion', angularVersionInfo.major);
|
|
22
|
-
const ngrxMajorVersion = (0, version_utils_1.getInstalledPackageVersionInfo)(tree, '@ngrx/store')?.major ??
|
|
23
|
-
(0, semver_1.major)((0, semver_1.coerce)(intendedNgRxVersionForAngularMajor));
|
|
24
|
-
const isStandalone = (0, ast_utils_1.isNgStandaloneApp)(tree, options.project);
|
|
25
|
-
if ((0, semver_1.lt)(angularVersionInfo.version, '14.1.0') || ngrxMajorVersion < 15) {
|
|
26
|
-
if (isStandalone) {
|
|
27
|
-
throw new Error(`The provided project '${options.project}' is set up to use Standalone APIs, however your workspace is not configured to support Standalone APIs. ` +
|
|
28
|
-
'Please make sure to provide a path to an "NgModule" where the state will be registered. ');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
16
|
}
|
|
32
17
|
exports.validateOptions = validateOptions;
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"route": {
|
|
31
31
|
"type": "string",
|
|
32
|
-
"description": "The route that the Standalone NgRx Providers should be added to.
|
|
32
|
+
"description": "The route that the Standalone NgRx Providers should be added to.",
|
|
33
33
|
"default": "''"
|
|
34
34
|
},
|
|
35
35
|
"directory": {
|
|
@@ -5,7 +5,6 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const lib_1 = require("./lib");
|
|
7
7
|
async function pipeGenerator(tree, rawOptions) {
|
|
8
|
-
(0, lib_1.validateOptions)(tree, rawOptions);
|
|
9
8
|
const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
|
|
10
9
|
const pipeNames = (0, devkit_1.names)(options.name);
|
|
11
10
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), options.directory, {
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"description": "Do not import this pipe into the owning NgModule."
|
|
54
54
|
},
|
|
55
55
|
"standalone": {
|
|
56
|
-
"description": "Whether the generated pipe is standalone.
|
|
56
|
+
"description": "Whether the generated pipe is standalone.",
|
|
57
57
|
"type": "boolean",
|
|
58
|
-
"default":
|
|
58
|
+
"default": true
|
|
59
59
|
},
|
|
60
60
|
"module": {
|
|
61
61
|
"type": "string",
|