@nx/angular 18.1.0 → 18.2.0-canary.20240316-b69047e
Sign up to get free protection for your applications and to get access to all the features.
- package/migrations.json +6 -0
- package/package.json +11 -13
- package/src/generators/add-linting/add-linting.d.ts +1 -1
- package/src/generators/add-linting/add-linting.js +6 -11
- package/src/generators/add-linting/lib/add-angular-eslint-dependencies.d.ts +2 -2
- package/src/generators/add-linting/lib/add-angular-eslint-dependencies.js +9 -5
- package/src/generators/add-linting/lib/buildable-project.d.ts +2 -0
- package/src/generators/add-linting/lib/buildable-project.js +9 -0
- package/src/generators/application/lib/add-e2e.js +4 -4
- package/src/generators/component-test/component-test.js +4 -2
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +10 -8
- package/src/generators/ng-add/migrators/projects/e2e.migrator.js +26 -22
- package/src/generators/setup-mf/lib/add-cypress-workaround.js +14 -6
- package/src/generators/storybook-configuration/lib/generate-stories.js +4 -2
- package/src/generators/utils/add-jest.js +2 -2
- package/src/generators/utils/add-mf-env-to-inputs.js +4 -1
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.d.ts +2 -0
- package/src/migrations/update-18-1-1/fix-target-defaults-inputs.js +53 -0
- package/src/utils/mf/with-module-federation-ssr.js +3 -0
- package/src/utils/mf/with-module-federation.js +3 -0
package/migrations.json
CHANGED
@@ -371,6 +371,12 @@
|
|
371
371
|
},
|
372
372
|
"description": "Update the @angular/cli package version to ~17.2.0.",
|
373
373
|
"factory": "./src/migrations/update-18-1-0/update-angular-cli"
|
374
|
+
},
|
375
|
+
"fix-target-defaults-for-webpack-browser": {
|
376
|
+
"cli": "nx",
|
377
|
+
"version": "18.1.1-beta.0",
|
378
|
+
"description": "Ensure targetDefaults inputs for task hashing when '@nx/angular:webpack-browser' is used are correct for Module Federation.",
|
379
|
+
"factory": "./src/migrations/update-18-1-1/fix-target-defaults-inputs"
|
374
380
|
}
|
375
381
|
},
|
376
382
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/angular",
|
3
|
-
"version": "18.
|
3
|
+
"version": "18.2.0-canary.20240316-b69047e",
|
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- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
6
6
|
"repository": {
|
@@ -78,24 +78,22 @@
|
|
78
78
|
"tslib": "^2.3.0",
|
79
79
|
"webpack": "^5.80.0",
|
80
80
|
"webpack-merge": "^5.8.0",
|
81
|
-
"@nx/devkit": "18.
|
82
|
-
"@nx/
|
83
|
-
"@nx/
|
84
|
-
"@nx/
|
85
|
-
"@nx/
|
86
|
-
"@nx/
|
87
|
-
"@nx/web": "18.1.0",
|
88
|
-
"@nx/workspace": "18.1.0",
|
81
|
+
"@nx/devkit": "18.2.0-canary.20240316-b69047e",
|
82
|
+
"@nx/js": "18.2.0-canary.20240316-b69047e",
|
83
|
+
"@nx/eslint": "18.2.0-canary.20240316-b69047e",
|
84
|
+
"@nx/webpack": "18.2.0-canary.20240316-b69047e",
|
85
|
+
"@nx/web": "18.2.0-canary.20240316-b69047e",
|
86
|
+
"@nx/workspace": "18.2.0-canary.20240316-b69047e",
|
89
87
|
"piscina": "^4.2.1",
|
90
|
-
"@nrwl/angular": "18.
|
88
|
+
"@nrwl/angular": "18.2.0-canary.20240316-b69047e"
|
91
89
|
},
|
92
90
|
"peerDependencies": {
|
93
91
|
"@angular-devkit/build-angular": ">= 15.0.0 < 18.0.0",
|
92
|
+
"@angular-devkit/core": ">= 15.0.0 < 18.0.0",
|
94
93
|
"@angular-devkit/schematics": ">= 15.0.0 < 18.0.0",
|
95
94
|
"@schematics/angular": ">= 15.0.0 < 18.0.0",
|
96
|
-
"
|
97
|
-
"rxjs": "^6.5.3 || ^7.5.0"
|
98
|
-
"esbuild": "^0.19.2"
|
95
|
+
"esbuild": "^0.19.2",
|
96
|
+
"rxjs": "^6.5.3 || ^7.5.0"
|
99
97
|
},
|
100
98
|
"peerDependenciesMeta": {
|
101
99
|
"esbuild": {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { GeneratorCallback, Tree } from '@nx/devkit';
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
2
2
|
import type { AddLintingGeneratorSchema } from './schema';
|
3
3
|
export declare function addLintingGenerator(tree: Tree, options: AddLintingGeneratorSchema): Promise<GeneratorCallback>;
|
4
4
|
export default addLintingGenerator;
|
@@ -2,11 +2,12 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.addLintingGenerator = void 0;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const eslint_1 = require("@nx/eslint");
|
6
|
-
const add_angular_eslint_dependencies_1 = require("./lib/add-angular-eslint-dependencies");
|
7
|
-
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
8
5
|
const string_utils_1 = require("@nx/devkit/src/utils/string-utils");
|
6
|
+
const eslint_1 = require("@nx/eslint");
|
9
7
|
const global_eslint_config_1 = require("@nx/eslint/src/generators/init/global-eslint-config");
|
8
|
+
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
9
|
+
const add_angular_eslint_dependencies_1 = require("./lib/add-angular-eslint-dependencies");
|
10
|
+
const buildable_project_1 = require("./lib/buildable-project");
|
10
11
|
async function addLintingGenerator(tree, options) {
|
11
12
|
const tasks = [];
|
12
13
|
const rootProject = options.projectRoot === '.' || options.projectRoot === '';
|
@@ -73,7 +74,7 @@ async function addLintingGenerator(tree, options) {
|
|
73
74
|
*/
|
74
75
|
rules: {},
|
75
76
|
},
|
76
|
-
...(isBuildableLibraryProject(tree, options.projectName)
|
77
|
+
...((0, buildable_project_1.isBuildableLibraryProject)(tree, options.projectName)
|
77
78
|
? [
|
78
79
|
{
|
79
80
|
files: ['*.json'],
|
@@ -87,7 +88,7 @@ async function addLintingGenerator(tree, options) {
|
|
87
88
|
]);
|
88
89
|
}
|
89
90
|
if (!options.skipPackageJson) {
|
90
|
-
const installTask = (0, add_angular_eslint_dependencies_1.addAngularEsLintDependencies)(tree);
|
91
|
+
const installTask = (0, add_angular_eslint_dependencies_1.addAngularEsLintDependencies)(tree, options.projectName);
|
91
92
|
tasks.push(installTask);
|
92
93
|
}
|
93
94
|
if (!options.skipFormat) {
|
@@ -96,10 +97,4 @@ async function addLintingGenerator(tree, options) {
|
|
96
97
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
97
98
|
}
|
98
99
|
exports.addLintingGenerator = addLintingGenerator;
|
99
|
-
function isBuildableLibraryProject(tree, projectName) {
|
100
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
101
|
-
return (projectConfig.projectType === 'library' &&
|
102
|
-
projectConfig.targets?.build &&
|
103
|
-
!!projectConfig.targets.build);
|
104
|
-
}
|
105
100
|
exports.default = addLintingGenerator;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import type
|
2
|
-
export declare function addAngularEsLintDependencies(tree: Tree): GeneratorCallback;
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
2
|
+
export declare function addAngularEsLintDependencies(tree: Tree, projectName: string): GeneratorCallback;
|
@@ -3,14 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addAngularEsLintDependencies = void 0;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
const version_utils_1 = require("../../utils/version-utils");
|
6
|
-
|
6
|
+
const buildable_project_1 = require("./buildable-project");
|
7
|
+
function addAngularEsLintDependencies(tree, projectName) {
|
7
8
|
const angularEslintVersionToInstall = (0, version_utils_1.versions)(tree).angularEslintVersion;
|
8
|
-
const
|
9
|
-
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
9
|
+
const devDependencies = {
|
10
10
|
'@angular-eslint/eslint-plugin': angularEslintVersionToInstall,
|
11
11
|
'@angular-eslint/eslint-plugin-template': angularEslintVersionToInstall,
|
12
12
|
'@angular-eslint/template-parser': angularEslintVersionToInstall,
|
13
|
-
|
14
|
-
|
13
|
+
};
|
14
|
+
if ((0, buildable_project_1.isBuildableLibraryProject)(tree, projectName)) {
|
15
|
+
const jsoncEslintParserVersionToInstall = (0, version_utils_1.versions)(tree).jsoncEslintParserVersion;
|
16
|
+
devDependencies['jsonc-eslint-parser'] = jsoncEslintParserVersionToInstall;
|
17
|
+
}
|
18
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies);
|
15
19
|
}
|
16
20
|
exports.addAngularEsLintDependencies = addAngularEsLintDependencies;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isBuildableLibraryProject = void 0;
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
5
|
+
function isBuildableLibraryProject(tree, projectName) {
|
6
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, projectName);
|
7
|
+
return (projectConfig.projectType === 'library' && !!projectConfig.targets?.build);
|
8
|
+
}
|
9
|
+
exports.isBuildableLibraryProject = isBuildableLibraryProject;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.addE2e = void 0;
|
4
|
-
const cypress_1 = require("@nx/cypress");
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
6
5
|
const versions_1 = require("../../../utils/versions");
|
7
6
|
const version_utils_1 = require("../../utils/version-utils");
|
@@ -11,6 +10,7 @@ async function addE2e(tree, options) {
|
|
11
10
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
12
11
|
nxJson.useInferencePlugins !== false;
|
13
12
|
if (options.e2eTestRunner === 'cypress') {
|
13
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
14
14
|
// TODO: This can call `@nx/web:static-config` generator when ready
|
15
15
|
addFileServerTarget(tree, options, 'serve-static');
|
16
16
|
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
@@ -21,7 +21,7 @@ async function addE2e(tree, options) {
|
|
21
21
|
tags: [],
|
22
22
|
implicitDependencies: [options.name],
|
23
23
|
});
|
24
|
-
await
|
24
|
+
await configurationGenerator(tree, {
|
25
25
|
project: options.e2eProjectName,
|
26
26
|
directory: 'src',
|
27
27
|
linter: options.linter,
|
@@ -34,7 +34,7 @@ async function addE2e(tree, options) {
|
|
34
34
|
});
|
35
35
|
}
|
36
36
|
else if (options.e2eTestRunner === 'playwright') {
|
37
|
-
const { configurationGenerator
|
37
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
38
38
|
(0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
|
39
39
|
projectType: 'application',
|
40
40
|
root: options.e2eProjectRoot,
|
@@ -42,7 +42,7 @@ async function addE2e(tree, options) {
|
|
42
42
|
targets: {},
|
43
43
|
implicitDependencies: [options.name],
|
44
44
|
});
|
45
|
-
await
|
45
|
+
await configurationGenerator(tree, {
|
46
46
|
project: options.e2eProjectName,
|
47
47
|
skipFormat: true,
|
48
48
|
skipPackageJson: options.skipPackageJson,
|
@@ -1,11 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.componentTestGenerator = void 0;
|
4
|
-
const cypress_version_1 = require("@nx/cypress/src/utils/cypress-version");
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
+
const versions_1 = require("../../utils/versions");
|
6
6
|
const storybook_inputs_1 = require("../utils/storybook-ast/storybook-inputs");
|
7
7
|
async function componentTestGenerator(tree, options) {
|
8
|
-
(0,
|
8
|
+
(0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
9
|
+
const { assertMinimumCypressVersion } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/cypress-version'));
|
10
|
+
assertMinimumCypressVersion(10);
|
9
11
|
const { root } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
10
12
|
const componentDirPath = (0, devkit_1.joinPathFragments)(root, options.componentDir);
|
11
13
|
const componentFilePath = (0, devkit_1.joinPathFragments)(componentDirPath, `${options.componentFileName}.ts`);
|
@@ -1,11 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.cypressComponentConfigurationInternal = exports.cypressComponentConfiguration = void 0;
|
4
|
-
const cypress_1 = require("@nx/cypress");
|
5
|
-
const config_1 = require("@nx/cypress/src/utils/config");
|
6
|
-
const find_target_options_1 = require("@nx/cypress/src/utils/find-target-options");
|
7
4
|
const devkit_1 = require("@nx/devkit");
|
8
5
|
const path_1 = require("path");
|
6
|
+
const versions_1 = require("../../utils/versions");
|
9
7
|
const component_test_1 = require("../component-test/component-test");
|
10
8
|
const component_info_1 = require("../utils/storybook-ast/component-info");
|
11
9
|
const entry_point_1 = require("../utils/storybook-ast/entry-point");
|
@@ -23,7 +21,8 @@ exports.cypressComponentConfiguration = cypressComponentConfiguration;
|
|
23
21
|
*/
|
24
22
|
async function cypressComponentConfigurationInternal(tree, options) {
|
25
23
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
26
|
-
const
|
24
|
+
const { componentConfigurationGenerator: baseCyCTConfig } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
25
|
+
const installTask = await baseCyCTConfig(tree, {
|
27
26
|
project: options.project,
|
28
27
|
skipFormat: true,
|
29
28
|
addPlugin: false,
|
@@ -42,7 +41,8 @@ async function cypressComponentConfigurationInternal(tree, options) {
|
|
42
41
|
exports.cypressComponentConfigurationInternal = cypressComponentConfigurationInternal;
|
43
42
|
async function addFiles(tree, projectConfig, options) {
|
44
43
|
const componentFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
|
45
|
-
const
|
44
|
+
const { addMountDefinition } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
|
45
|
+
const updatedCmpContents = await addMountDefinition(tree.read(componentFile, 'utf-8'));
|
46
46
|
tree.write(componentFile, `import { mount } from 'cypress/angular';\n${updatedCmpContents}`);
|
47
47
|
if (options.generateTests) {
|
48
48
|
const entryPoints = (0, entry_point_1.getProjectEntryPoints)(tree, options.project);
|
@@ -69,7 +69,8 @@ async function addFiles(tree, projectConfig, options) {
|
|
69
69
|
async function configureCypressCT(tree, options) {
|
70
70
|
let found = { target: options.buildTarget, config: undefined };
|
71
71
|
if (!options.buildTarget) {
|
72
|
-
|
72
|
+
const { findBuildConfig } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/find-target-options'));
|
73
|
+
found = await findBuildConfig(tree, {
|
73
74
|
project: options.project,
|
74
75
|
buildTarget: options.buildTarget,
|
75
76
|
validExecutorNames: new Set([
|
@@ -94,8 +95,9 @@ async function configureCypressCT(tree, options) {
|
|
94
95
|
else {
|
95
96
|
ctConfigOptions.buildTarget = found.target;
|
96
97
|
}
|
97
|
-
const
|
98
|
-
const
|
98
|
+
const { addDefaultCTConfig, getProjectCypressConfigPath } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/config'));
|
99
|
+
const cypressConfigPath = getProjectCypressConfigPath(tree, projectConfig.root);
|
100
|
+
const updatedCyConfig = await addDefaultCTConfig(tree.read(cypressConfigPath, 'utf-8'), ctConfigOptions);
|
99
101
|
tree.write(cypressConfigPath, `import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';\n${updatedCyConfig}`);
|
100
102
|
}
|
101
103
|
function assertValidConfig(config) {
|
@@ -1,17 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.E2eMigrator = void 0;
|
4
|
-
const cypress_1 = require("@nx/cypress");
|
5
|
-
const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
|
6
|
-
const cypress_version_1 = require("@nx/cypress/src/utils/cypress-version");
|
7
4
|
const devkit_1 = require("@nx/devkit");
|
8
5
|
const eslint_1 = require("@nx/eslint");
|
9
6
|
const js_1 = require("@nx/js");
|
7
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
10
8
|
const path_1 = require("path");
|
11
|
-
const typescript_1 = require("typescript");
|
12
9
|
const file_change_recorder_1 = require("../../../../utils/file-change-recorder");
|
10
|
+
const versions_1 = require("../../../../utils/versions");
|
13
11
|
const project_migrator_1 = require("./project.migrator");
|
14
|
-
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
15
12
|
const supportedTargets = {
|
16
13
|
e2e: {
|
17
14
|
acceptMultipleDefinitions: true,
|
@@ -175,7 +172,9 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
175
172
|
};
|
176
173
|
}
|
177
174
|
else if (this.isCypressE2eProject()) {
|
178
|
-
|
175
|
+
(0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
176
|
+
const { installedCypressVersion, } = require('@nx/cypress/src/utils/cypress-version');
|
177
|
+
this.cypressInstalledVersion = installedCypressVersion();
|
179
178
|
this.project = {
|
180
179
|
...this.project,
|
181
180
|
name,
|
@@ -238,7 +237,8 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
238
237
|
const nxJson = (0, devkit_1.readNxJson)(this.tree) ?? {};
|
239
238
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
240
239
|
nxJson.useInferencePlugins !== false;
|
241
|
-
await (
|
240
|
+
const { configurationGenerator } = await Promise.resolve().then(() => require('@nx/cypress'));
|
241
|
+
await configurationGenerator(this.tree, {
|
242
242
|
project: this.project.name,
|
243
243
|
linter: this.isProjectUsingEsLint ? eslint_1.Linter.EsLint : eslint_1.Linter.None,
|
244
244
|
skipFormat: true,
|
@@ -366,9 +366,10 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
366
366
|
: undefined;
|
367
367
|
}
|
368
368
|
updateCypress10ConfigFile(configFilePath) {
|
369
|
-
(0, ensure_typescript_1.ensureTypescript)();
|
369
|
+
const { isPropertyAssignment } = (0, ensure_typescript_1.ensureTypescript)();
|
370
370
|
const { tsquery } = require('@phenomnomnominal/tsquery');
|
371
|
-
|
371
|
+
const { nxE2EPreset } = require('@nx/cypress/plugins/cypress-preset');
|
372
|
+
this.cypressPreset = nxE2EPreset(configFilePath);
|
372
373
|
const fileContent = this.tree.read(configFilePath, 'utf-8');
|
373
374
|
let sourceFile = tsquery.ast(fileContent);
|
374
375
|
const recorder = new file_change_recorder_1.FileChangeRecorder(this.tree, configFilePath);
|
@@ -381,15 +382,15 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
381
382
|
let componentNode;
|
382
383
|
const globalConfig = {};
|
383
384
|
defineConfigExpression.forEachChild((node) => {
|
384
|
-
if (
|
385
|
+
if (isPropertyAssignment(node) && node.name.getText() === 'component') {
|
385
386
|
componentNode = node;
|
386
387
|
return;
|
387
388
|
}
|
388
|
-
if (
|
389
|
+
if (isPropertyAssignment(node) && node.name.getText() === 'e2e') {
|
389
390
|
e2eNode = node;
|
390
391
|
return;
|
391
392
|
}
|
392
|
-
if (
|
393
|
+
if (isPropertyAssignment(node)) {
|
393
394
|
this.updateCypressConfigNodeValue(recorder, node, globalConfig);
|
394
395
|
}
|
395
396
|
});
|
@@ -401,14 +402,15 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
401
402
|
if (!componentNode) {
|
402
403
|
return;
|
403
404
|
}
|
404
|
-
|
405
|
+
const { isObjectLiteralExpression, isPropertyAssignment } = (0, ensure_typescript_1.ensureTypescript)();
|
406
|
+
if (!isObjectLiteralExpression(componentNode.initializer)) {
|
405
407
|
this.logger.warn('The automatic migration only supports having an object literal in the "component" option of the Cypress configuration. ' +
|
406
408
|
`The configuration won't be updated. Please make sure to update any paths you may have in the "component" option ` +
|
407
409
|
'manually to point to the new location.');
|
408
410
|
return;
|
409
411
|
}
|
410
412
|
componentNode.initializer.properties.forEach((node) => {
|
411
|
-
if (
|
413
|
+
if (isPropertyAssignment(node)) {
|
412
414
|
this.updateCypressConfigNodeValue(recorder, node);
|
413
415
|
}
|
414
416
|
});
|
@@ -431,7 +433,8 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
431
433
|
recorder.insertRight(defineConfigNode.getStart() + 1, e2eAssignment);
|
432
434
|
}
|
433
435
|
else {
|
434
|
-
|
436
|
+
const { isObjectLiteralExpression, isPropertyAssignment } = (0, ensure_typescript_1.ensureTypescript)();
|
437
|
+
if (!isObjectLiteralExpression(e2eNode.initializer)) {
|
435
438
|
this.logger.warn('The automatic migration only supports having an object literal in the "e2e" option of the Cypress configuration. ' +
|
436
439
|
`The configuration won't be updated. Please make sure to update any paths you might have in the "e2e" option ` +
|
437
440
|
'manually to point to the new location.');
|
@@ -439,7 +442,7 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
439
442
|
}
|
440
443
|
recorder.insertRight(e2eNode.initializer.getStart() + 1, presetSpreadAssignment);
|
441
444
|
e2eNode.initializer.properties.forEach((node) => {
|
442
|
-
if (!
|
445
|
+
if (!isPropertyAssignment(node)) {
|
443
446
|
return;
|
444
447
|
}
|
445
448
|
let change = { type: 'ignore' };
|
@@ -518,7 +521,8 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
518
521
|
}
|
519
522
|
}
|
520
523
|
isValidPathLikePropertyWithStringLiteralValue(node, properties) {
|
521
|
-
|
524
|
+
const { isPropertyAssignment, isStringLiteralLike, isTemplateExpression, SyntaxKind, } = (0, ensure_typescript_1.ensureTypescript)();
|
525
|
+
if (!isPropertyAssignment(node)) {
|
522
526
|
// TODO(leo): handle more scenarios (spread assignments, etc)
|
523
527
|
return false;
|
524
528
|
}
|
@@ -526,13 +530,13 @@ class E2eMigrator extends project_migrator_1.ProjectMigrator {
|
|
526
530
|
if (!property) {
|
527
531
|
return false;
|
528
532
|
}
|
529
|
-
if (node.initializer.kind ===
|
530
|
-
node.initializer.kind ===
|
531
|
-
node.initializer.kind ===
|
533
|
+
if (node.initializer.kind === SyntaxKind.UndefinedKeyword ||
|
534
|
+
node.initializer.kind === SyntaxKind.NullKeyword ||
|
535
|
+
node.initializer.kind === SyntaxKind.FalseKeyword) {
|
532
536
|
return false;
|
533
537
|
}
|
534
|
-
if (!
|
535
|
-
if (
|
538
|
+
if (!isStringLiteralLike(node.initializer)) {
|
539
|
+
if (isTemplateExpression(node.initializer)) {
|
536
540
|
this.logger.warn(`The "${node.name.getText()}" in the Cypress configuration file is set to a template expression ("${node.initializer.getText()}"). ` +
|
537
541
|
`This is not supported by the automatic migration and its value won't be automatically migrated. ` +
|
538
542
|
`Please make sure to update its value to match the new location if needed.`);
|
@@ -4,7 +4,6 @@
|
|
4
4
|
// is attached to the index.html with type=module
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.addCypressOnErrorWorkaround = void 0;
|
7
|
-
const config_1 = require("@nx/cypress/src/utils/config");
|
8
7
|
const devkit_1 = require("@nx/devkit");
|
9
8
|
function addCypressOnErrorWorkaround(tree, schema) {
|
10
9
|
if (!schema.e2eProjectName) {
|
@@ -23,11 +22,20 @@ function addCypressOnErrorWorkaround(tree, schema) {
|
|
23
22
|
`);
|
24
23
|
return;
|
25
24
|
}
|
26
|
-
if (e2eProject.targets?.e2e?.executor !== '@nx/cypress:cypress'
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
if (e2eProject.targets?.e2e?.executor !== '@nx/cypress:cypress') {
|
26
|
+
try {
|
27
|
+
// don't ensure package is installed, if it's not installed, we don't need to add the workaround
|
28
|
+
const { CYPRESS_CONFIG_FILE_NAME_PATTERN, } = require('@nx/cypress/src/utils/config');
|
29
|
+
if (!(0, devkit_1.glob)(tree, [`${e2eProject.root}/${CYPRESS_CONFIG_FILE_NAME_PATTERN}`])
|
30
|
+
.length) {
|
31
|
+
// Not a cypress e2e project, skip
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
catch {
|
36
|
+
// assume cypress is not installed
|
37
|
+
return;
|
38
|
+
}
|
31
39
|
}
|
32
40
|
const commandToAdd = `Cypress.on('uncaught:exception', err => {
|
33
41
|
if (err.message.includes(\`Cannot use 'import.meta' outside a module\`)) {
|
@@ -1,12 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.generateStories = void 0;
|
4
|
-
const project_name_1 = require("@nx/cypress/src/utils/project-name");
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
+
const versions_1 = require("../../../utils/versions");
|
6
6
|
const stories_1 = require("../../stories/stories");
|
7
7
|
async function generateStories(tree, options) {
|
8
8
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
9
|
-
|
9
|
+
(0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
10
|
+
const { getE2eProjectName } = await Promise.resolve().then(() => require('@nx/cypress/src/utils/project-name'));
|
11
|
+
const e2eProjectName = getE2eProjectName(options.project, project.root, options.cypressDirectory);
|
10
12
|
await (0, stories_1.angularStoriesGenerator)(tree, {
|
11
13
|
name: options.project,
|
12
14
|
generateCypressSpecs: options.configureCypress && options.generateCypressSpecs,
|
@@ -2,7 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.addJest = void 0;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
|
-
const jest_1 = require("@nx/jest");
|
6
5
|
const versions_1 = require("../../utils/versions");
|
7
6
|
const version_utils_1 = require("./version-utils");
|
8
7
|
async function addJest(tree, options) {
|
@@ -10,7 +9,8 @@ async function addJest(tree, options) {
|
|
10
9
|
process.env.npm_config_legacy_peer_deps ??= 'true';
|
11
10
|
(0, version_utils_1.addDependenciesToPackageJsonIfDontExist)(tree, {}, { 'jest-preset-angular': versions_1.jestPresetAngularVersion });
|
12
11
|
}
|
13
|
-
|
12
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
13
|
+
await configurationGenerator(tree, {
|
14
14
|
project: options.name,
|
15
15
|
setupFile: 'angular',
|
16
16
|
supportTsx: false,
|
@@ -8,7 +8,10 @@ function addMfEnvToTargetDefaultInputs(tree) {
|
|
8
8
|
const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
|
9
9
|
nxJson.targetDefaults ??= {};
|
10
10
|
nxJson.targetDefaults[webpackExecutor] ??= {};
|
11
|
-
nxJson.targetDefaults[webpackExecutor].inputs ??= [
|
11
|
+
nxJson.targetDefaults[webpackExecutor].inputs ??= [
|
12
|
+
'production',
|
13
|
+
'^production',
|
14
|
+
];
|
12
15
|
let mfEnvVarExists = false;
|
13
16
|
for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
|
14
17
|
if (typeof input === 'object' && input['env'] === mfEnvVar) {
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
4
|
+
async function default_1(tree) {
|
5
|
+
if (!isWebpackBrowserUsed(tree)) {
|
6
|
+
return;
|
7
|
+
}
|
8
|
+
ensureTargetDefaultsContainProductionInputs(tree);
|
9
|
+
await (0, devkit_1.formatFiles)(tree);
|
10
|
+
}
|
11
|
+
exports.default = default_1;
|
12
|
+
function ensureTargetDefaultsContainProductionInputs(tree) {
|
13
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
14
|
+
const webpackExecutor = '@nx/angular:webpack-browser';
|
15
|
+
const mfEnvVar = 'NX_MF_DEV_SERVER_STATIC_REMOTES';
|
16
|
+
nxJson.targetDefaults[webpackExecutor] ??= {};
|
17
|
+
nxJson.targetDefaults[webpackExecutor].inputs ??= [
|
18
|
+
'production',
|
19
|
+
'^production',
|
20
|
+
{ env: mfEnvVar },
|
21
|
+
];
|
22
|
+
if (!nxJson.targetDefaults[webpackExecutor].inputs.includes('production')) {
|
23
|
+
nxJson.targetDefaults[webpackExecutor].inputs.push('production');
|
24
|
+
}
|
25
|
+
if (!nxJson.targetDefaults[webpackExecutor].inputs.includes('^production')) {
|
26
|
+
nxJson.targetDefaults[webpackExecutor].inputs.push('^production');
|
27
|
+
}
|
28
|
+
let mfEnvVarExists = false;
|
29
|
+
for (const input of nxJson.targetDefaults[webpackExecutor].inputs) {
|
30
|
+
if (typeof input === 'object' && input['env'] === mfEnvVar) {
|
31
|
+
mfEnvVarExists = true;
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
if (!mfEnvVarExists) {
|
36
|
+
nxJson.targetDefaults[webpackExecutor].inputs.push({ env: mfEnvVar });
|
37
|
+
}
|
38
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
39
|
+
}
|
40
|
+
function isWebpackBrowserUsed(tree) {
|
41
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
42
|
+
for (const project of projects.values()) {
|
43
|
+
const targets = project.targets || {};
|
44
|
+
for (const [_, target] of Object.entries(targets)) {
|
45
|
+
if (target.executor === '@nx/angular:webpack-browser' &&
|
46
|
+
(tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.ts')) ||
|
47
|
+
tree.exists((0, devkit_1.joinPathFragments)(project.root, 'module-federation.config.js')))) {
|
48
|
+
return true;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
return false;
|
53
|
+
}
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withModuleFederationForSSR = void 0;
|
4
4
|
const utils_1 = require("./utils");
|
5
5
|
async function withModuleFederationForSSR(options) {
|
6
|
+
if (global.NX_GRAPH_CREATION) {
|
7
|
+
return (config) => config;
|
8
|
+
}
|
6
9
|
const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options, {
|
7
10
|
isServer: true,
|
8
11
|
});
|
@@ -4,6 +4,9 @@ exports.withModuleFederation = void 0;
|
|
4
4
|
const utils_1 = require("./utils");
|
5
5
|
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
|
6
6
|
async function withModuleFederation(options) {
|
7
|
+
if (global.NX_GRAPH_CREATION) {
|
8
|
+
return (config) => config;
|
9
|
+
}
|
7
10
|
const { sharedLibraries, sharedDependencies, mappedRemotes } = await (0, utils_1.getModuleFederationConfig)(options);
|
8
11
|
return (config) => ({
|
9
12
|
...(config ?? {}),
|