@nx/angular 23.0.0-beta.17 → 23.0.0-beta.19
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/package.json +8 -8
- package/plugins/component-testing.js +8 -8
- package/src/generators/application/application.d.ts.map +1 -1
- package/src/generators/application/application.js +3 -2
- package/src/generators/application/lib/add-unit-test-runner.d.ts +2 -2
- package/src/generators/application/lib/add-unit-test-runner.d.ts.map +1 -1
- package/src/generators/application/lib/add-unit-test-runner.js +5 -5
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts.map +1 -1
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +4 -4
- package/src/generators/library/library.d.ts.map +1 -1
- package/src/generators/library/library.js +10 -7
- package/src/generators/setup-mf/lib/add-cypress-workaround.js +1 -1
- package/src/generators/utils/add-vitest.d.ts +3 -3
- package/src/generators/utils/add-vitest.d.ts.map +1 -1
- package/src/generators/utils/add-vitest.js +25 -17
- package/src/plugins/plugin.d.ts.map +1 -1
- package/src/plugins/plugin.js +43 -8
- package/src/utils/versions.d.ts.map +1 -1
- package/src/utils/versions.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular",
|
|
3
|
-
"version": "23.0.0-beta.
|
|
3
|
+
"version": "23.0.0-beta.19",
|
|
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, Playwright 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": {
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"migrations": "./migrations.json"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@nx/devkit": "23.0.0-beta.
|
|
65
|
-
"@nx/eslint": "23.0.0-beta.
|
|
66
|
-
"@nx/js": "23.0.0-beta.
|
|
67
|
-
"@nx/module-federation": "23.0.0-beta.
|
|
68
|
-
"@nx/rspack": "23.0.0-beta.
|
|
69
|
-
"@nx/web": "23.0.0-beta.
|
|
70
|
-
"@nx/webpack": "23.0.0-beta.
|
|
64
|
+
"@nx/devkit": "23.0.0-beta.19",
|
|
65
|
+
"@nx/eslint": "23.0.0-beta.19",
|
|
66
|
+
"@nx/js": "23.0.0-beta.19",
|
|
67
|
+
"@nx/module-federation": "23.0.0-beta.19",
|
|
68
|
+
"@nx/rspack": "23.0.0-beta.19",
|
|
69
|
+
"@nx/web": "23.0.0-beta.19",
|
|
70
|
+
"@nx/webpack": "23.0.0-beta.19",
|
|
71
71
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
72
72
|
"@typescript-eslint/type-utils": "^8.0.0",
|
|
73
73
|
"enquirer": "~2.3.6",
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.nxComponentTestingPreset = nxComponentTestingPreset;
|
|
4
4
|
const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/cypress/internal");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const
|
|
7
|
+
const internal_2 = require("@nx/js/internal");
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
const semver_1 = require("semver");
|
|
@@ -46,9 +46,9 @@ This is likely due to not running via nx. i.e. 'nx component-test my-project'.
|
|
|
46
46
|
Please open an issue if this error persists.
|
|
47
47
|
${e.stack ? e.stack : e}`);
|
|
48
48
|
}
|
|
49
|
-
const ctProjectConfig = (0,
|
|
49
|
+
const ctProjectConfig = (0, internal_1.getProjectConfigByPath)(graph, pathToConfig);
|
|
50
50
|
const ctConfigurationName = process.env.NX_CYPRESS_TARGET_CONFIGURATION;
|
|
51
|
-
const ctContext = (0,
|
|
51
|
+
const ctContext = (0, internal_1.createExecutorContext)(graph, ctProjectConfig.targets, ctProjectConfig.name, options?.ctTargetName || 'component-test', ctConfigurationName);
|
|
52
52
|
const buildTarget = options?.buildTarget
|
|
53
53
|
? (0, devkit_1.parseTargetString)(options.buildTarget, graph)
|
|
54
54
|
: // for backwards compat, if no buildTargetin the preset options, get it from the target options
|
|
@@ -65,7 +65,7 @@ ${e.stack ? e.stack : e}`);
|
|
|
65
65
|
const offset = isOffsetNeeded(ctContext, ctProjectConfig)
|
|
66
66
|
? (0, devkit_1.offsetFromRoot)(normalizedFromWorkspaceRootPath)
|
|
67
67
|
: undefined;
|
|
68
|
-
const buildContext = (0,
|
|
68
|
+
const buildContext = (0, internal_1.createExecutorContext)(graph, graph.nodes[buildTarget.project]?.data.targets, buildTarget.project, buildTarget.target, buildTarget.configuration);
|
|
69
69
|
const buildableProjectConfig = normalizeBuildTargetOptions(buildContext, ctContext, offset);
|
|
70
70
|
return {
|
|
71
71
|
...(0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig, { testingType: 'component' }),
|
|
@@ -116,7 +116,7 @@ function normalizeBuildTargetOptions(buildContext, ctContext, offset) {
|
|
|
116
116
|
configuration: buildContext.configurationName,
|
|
117
117
|
}, buildContext);
|
|
118
118
|
const project = buildContext.projectsConfigurations.projects[buildContext.projectName];
|
|
119
|
-
const sourceRoot = (0,
|
|
119
|
+
const sourceRoot = (0, internal_2.getProjectSourceRoot)(project);
|
|
120
120
|
const buildOptions = withSchemaDefaults(options, sourceRoot, buildContext.root);
|
|
121
121
|
// cypress creates a tsconfig if one isn't preset
|
|
122
122
|
// that contains all the support required for angular and component tests
|
|
@@ -158,7 +158,7 @@ function normalizeBuildTargetOptions(buildContext, ctContext, offset) {
|
|
|
158
158
|
// then we don't want to have the assets/scripts/styles be included to
|
|
159
159
|
// prevent inclusion of unintended stuff like tailwind
|
|
160
160
|
if (buildContext.projectName === ctContext.projectName ||
|
|
161
|
-
(0,
|
|
161
|
+
(0, internal_1.isCtProjectUsingBuildProject)(ctContext.projectGraph, buildContext.projectName, ctContext.projectName)) {
|
|
162
162
|
if (offset) {
|
|
163
163
|
buildOptions.assets = buildOptions.assets.map((asset) => {
|
|
164
164
|
return typeof asset === 'string'
|
|
@@ -248,7 +248,7 @@ function getTempStylesForTailwind(ctExecutorContext) {
|
|
|
248
248
|
const rootTailwindPath = (0, path_1.join)(ctExecutorContext.root, 'tailwind.config');
|
|
249
249
|
const isTailWindInRoot = exts.some((ext) => (0, fs_1.existsSync)(`${rootTailwindPath}.${ext}`));
|
|
250
250
|
if (isTailWindInRoot || isTailWindInCtProject) {
|
|
251
|
-
const pathToStyle = (0,
|
|
251
|
+
const pathToStyle = (0, internal_1.getTempTailwindPath)(ctExecutorContext);
|
|
252
252
|
try {
|
|
253
253
|
(0, fs_1.mkdirSync)((0, path_1.dirname)(pathToStyle), { recursive: true });
|
|
254
254
|
(0, fs_1.writeFileSync)(pathToStyle, `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/application/application.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,iBAAiB,EAKjB,IAAI,EAEL,MAAM,YAAY,CAAC;AA0BpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/application/application.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,iBAAiB,EAKjB,IAAI,EAEL,MAAM,YAAY,CAAC;AA0BpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC,CAgI5B;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -39,7 +39,7 @@ async function applicationGenerator(tree, schema) {
|
|
|
39
39
|
(0, lib_1.createProject)(tree, options);
|
|
40
40
|
await (0, lib_1.createFiles)(tree, options, rootOffset);
|
|
41
41
|
await (0, lib_1.addLinting)(tree, options);
|
|
42
|
-
await (0, lib_1.addUnitTestRunner)(tree, options);
|
|
42
|
+
const unitTestRunnerTask = await (0, lib_1.addUnitTestRunner)(tree, options);
|
|
43
43
|
const e2ePort = await (0, lib_1.addE2e)(tree, options);
|
|
44
44
|
(0, lib_1.addServeStaticTarget)(tree, options, options.e2eTestRunner !== 'none' ? e2ePort : options.port);
|
|
45
45
|
(0, lib_1.updateTsconfigFiles)(tree, options);
|
|
@@ -105,7 +105,8 @@ async function applicationGenerator(tree, schema) {
|
|
|
105
105
|
if (!options.skipFormat) {
|
|
106
106
|
await (0, devkit_1.formatFiles)(tree);
|
|
107
107
|
}
|
|
108
|
-
return () => {
|
|
108
|
+
return async () => {
|
|
109
|
+
await unitTestRunnerTask();
|
|
109
110
|
(0, devkit_1.installPackagesTask)(tree);
|
|
110
111
|
(0, internal_1.logShowProjectCommand)(options.name);
|
|
111
112
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Tree } from '@nx/devkit';
|
|
1
|
+
import type { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import type { NormalizedSchema } from './normalized-schema';
|
|
3
|
-
export declare function addUnitTestRunner(host: Tree, options: NormalizedSchema): Promise<
|
|
3
|
+
export declare function addUnitTestRunner(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
4
4
|
//# sourceMappingURL=add-unit-test-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-unit-test-runner.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/application/lib/add-unit-test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"add-unit-test-runner.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/application/lib/add-unit-test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAI1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAgC5B"}
|
|
@@ -16,16 +16,15 @@ async function addUnitTestRunner(host, options) {
|
|
|
16
16
|
runtimeTsconfigFileName: 'tsconfig.app.json',
|
|
17
17
|
zoneless: options.zoneless,
|
|
18
18
|
});
|
|
19
|
-
|
|
19
|
+
return () => { };
|
|
20
20
|
case test_runners_1.UnitTestRunner.VitestAngular:
|
|
21
|
-
|
|
21
|
+
return (0, add_vitest_1.addVitestAngular)(host, {
|
|
22
22
|
name: options.name,
|
|
23
23
|
projectRoot: options.appProjectRoot,
|
|
24
24
|
skipPackageJson: options.skipPackageJson,
|
|
25
25
|
});
|
|
26
|
-
break;
|
|
27
26
|
case test_runners_1.UnitTestRunner.VitestAnalog:
|
|
28
|
-
|
|
27
|
+
return (0, add_vitest_1.addVitestAnalog)(host, {
|
|
29
28
|
name: options.name,
|
|
30
29
|
projectRoot: options.appProjectRoot,
|
|
31
30
|
skipFormat: options.skipFormat,
|
|
@@ -34,6 +33,7 @@ async function addUnitTestRunner(host, options) {
|
|
|
34
33
|
addPlugin: options.addPlugin,
|
|
35
34
|
zoneless: options.zoneless,
|
|
36
35
|
});
|
|
37
|
-
|
|
36
|
+
default:
|
|
37
|
+
return () => { };
|
|
38
38
|
}
|
|
39
39
|
}
|
package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cypress-component-configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/cypress-component-configuration/cypress-component-configuration.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,iBAAiB,EAMjB,IAAI,EAEL,MAAM,YAAY,CAAC;AAapB,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAiBxD;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"cypress-component-configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/cypress-component-configuration/cypress-component-configuration.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,iBAAiB,EAMjB,IAAI,EAEL,MAAM,YAAY,CAAC;AAapB,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAiBxD;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,iBAAiB,CAAC,CAqD5B;AAkJD,eAAe,6BAA6B,CAAC"}
|
|
@@ -75,7 +75,7 @@ async function cypressComponentConfiguration(tree, options) {
|
|
|
75
75
|
isZoneless = (0, devkit_1.getDependencyVersionFromPackageJson)(tree, 'zone.js') === null;
|
|
76
76
|
}
|
|
77
77
|
if (isZoneless) {
|
|
78
|
-
const { getInstalledCypressVersion } = await Promise.resolve().then(() => __importStar(require('@nx/cypress/
|
|
78
|
+
const { getInstalledCypressVersion } = await Promise.resolve().then(() => __importStar(require('@nx/cypress/internal')));
|
|
79
79
|
const installedCypressVersion = getInstalledCypressVersion(tree);
|
|
80
80
|
// Zoneless support was introduced in Cypress 15.8.0
|
|
81
81
|
// If Cypress is not yet installed, we'll install the latest version, which will have zoneless support
|
|
@@ -105,7 +105,7 @@ async function cypressComponentConfiguration(tree, options) {
|
|
|
105
105
|
}
|
|
106
106
|
async function addFiles(tree, projectConfig, options, isZoneless) {
|
|
107
107
|
const componentFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'support', 'component.ts');
|
|
108
|
-
const { addMountDefinition } = require('@nx/cypress/
|
|
108
|
+
const { addMountDefinition } = (require('@nx/cypress/internal'));
|
|
109
109
|
const updatedCmpContents = await addMountDefinition(tree.read(componentFile, 'utf-8'));
|
|
110
110
|
tree.write(componentFile, `import { mount } from '${isZoneless ? 'cypress/angular-zoneless' : 'cypress/angular'}';\n${updatedCmpContents}`);
|
|
111
111
|
if (!options.generateTests) {
|
|
@@ -143,7 +143,7 @@ async function addFiles(tree, projectConfig, options, isZoneless) {
|
|
|
143
143
|
async function configureCypressCT(tree, options) {
|
|
144
144
|
let found = { target: options.buildTarget, config: undefined };
|
|
145
145
|
if (!options.buildTarget) {
|
|
146
|
-
const { findBuildConfig } = require('@nx/cypress/
|
|
146
|
+
const { findBuildConfig } = (require('@nx/cypress/internal'));
|
|
147
147
|
found = await findBuildConfig(tree, {
|
|
148
148
|
project: options.project,
|
|
149
149
|
buildTarget: options.buildTarget,
|
|
@@ -181,7 +181,7 @@ async function configureCypressCT(tree, options) {
|
|
|
181
181
|
else {
|
|
182
182
|
ctConfigOptions.buildTarget = found.target;
|
|
183
183
|
}
|
|
184
|
-
const { addDefaultCTConfig, getProjectCypressConfigPath } = require('@nx/cypress/
|
|
184
|
+
const { addDefaultCTConfig, getProjectCypressConfigPath } = require('@nx/cypress/internal');
|
|
185
185
|
const cypressConfigPath = getProjectCypressConfigPath(tree, projectConfig.root);
|
|
186
186
|
const updatedCyConfig = await addDefaultCTConfig(tree.read(cypressConfigPath, 'utf-8'), ctConfigOptions, '@nx/angular/plugins/component-testing');
|
|
187
187
|
tree.write(cypressConfigPath, updatedCyConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/library/library.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,iBAAiB,EAIjB,IAAI,EACL,MAAM,YAAY,CAAC;AAuBpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/library/library.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,iBAAiB,EAIjB,IAAI,EACL,MAAM,YAAY,CAAC;AAuBpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC,CAqE5B;AAoED,eAAe,gBAAgB,CAAC"}
|
|
@@ -45,7 +45,7 @@ async function libraryGenerator(tree, schema) {
|
|
|
45
45
|
}
|
|
46
46
|
const project = await (0, add_project_1.addProject)(tree, libraryOptions);
|
|
47
47
|
(0, create_files_1.createFiles)(tree, options, project);
|
|
48
|
-
await addUnitTestRunner(tree, libraryOptions);
|
|
48
|
+
const unitTestRunnerTask = await addUnitTestRunner(tree, libraryOptions);
|
|
49
49
|
(0, update_tsconfig_files_1.updateTsConfigFiles)(tree, libraryOptions);
|
|
50
50
|
updateNpmScopeIfBuildableOrPublishable(tree, libraryOptions);
|
|
51
51
|
(0, set_generator_defaults_1.setGeneratorDefaults)(tree, options);
|
|
@@ -66,7 +66,10 @@ async function libraryGenerator(tree, schema) {
|
|
|
66
66
|
if (!libraryOptions.skipFormat) {
|
|
67
67
|
await (0, devkit_1.formatFiles)(tree);
|
|
68
68
|
}
|
|
69
|
-
const tasks = [
|
|
69
|
+
const tasks = [
|
|
70
|
+
unitTestRunnerTask,
|
|
71
|
+
() => (0, devkit_1.installPackagesTask)(tree),
|
|
72
|
+
];
|
|
70
73
|
if (libraryOptions.publishable) {
|
|
71
74
|
tasks.push(await (0, internal_2.releaseTasks)(tree));
|
|
72
75
|
}
|
|
@@ -85,17 +88,16 @@ async function addUnitTestRunner(host, options) {
|
|
|
85
88
|
runtimeTsconfigFileName: 'tsconfig.lib.json',
|
|
86
89
|
zoneless,
|
|
87
90
|
});
|
|
88
|
-
|
|
91
|
+
return () => { };
|
|
89
92
|
case test_runners_1.UnitTestRunner.VitestAngular:
|
|
90
|
-
|
|
93
|
+
return (0, add_vitest_1.addVitestAngular)(host, {
|
|
91
94
|
name: options.name,
|
|
92
95
|
projectRoot: options.projectRoot,
|
|
93
96
|
skipPackageJson: options.skipPackageJson,
|
|
94
97
|
useNxUnitTestRunnerExecutor: true,
|
|
95
98
|
});
|
|
96
|
-
break;
|
|
97
99
|
case test_runners_1.UnitTestRunner.VitestAnalog:
|
|
98
|
-
|
|
100
|
+
return (0, add_vitest_1.addVitestAnalog)(host, {
|
|
99
101
|
name: options.name,
|
|
100
102
|
projectRoot: options.projectRoot,
|
|
101
103
|
skipFormat: options.skipFormat,
|
|
@@ -103,7 +105,8 @@ async function addUnitTestRunner(host, options) {
|
|
|
103
105
|
strict: options.strict,
|
|
104
106
|
zoneless,
|
|
105
107
|
});
|
|
106
|
-
|
|
108
|
+
default:
|
|
109
|
+
return () => { };
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
112
|
function updateNpmScopeIfBuildableOrPublishable(host, options) {
|
|
@@ -26,7 +26,7 @@ function addCypressOnErrorWorkaround(tree, schema) {
|
|
|
26
26
|
if (e2eProject.targets?.e2e?.executor !== '@nx/cypress:cypress') {
|
|
27
27
|
try {
|
|
28
28
|
// don't ensure package is installed, if it's not installed, we don't need to add the workaround
|
|
29
|
-
const { CYPRESS_CONFIG_FILE_NAME_PATTERN, } = require('@nx/cypress/
|
|
29
|
+
const { CYPRESS_CONFIG_FILE_NAME_PATTERN, } = require('@nx/cypress/internal');
|
|
30
30
|
if (!(0, devkit_1.glob)(tree, [`${e2eProject.root}/${CYPRESS_CONFIG_FILE_NAME_PATTERN}`])
|
|
31
31
|
.length) {
|
|
32
32
|
// Not a cypress e2e project, skip
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Tree } from '@nx/devkit';
|
|
1
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
2
2
|
export type AddVitestAngularOptions = {
|
|
3
3
|
name: string;
|
|
4
4
|
projectRoot: string;
|
|
@@ -14,6 +14,6 @@ export type AddVitestAnalogOptions = {
|
|
|
14
14
|
zoneless: boolean;
|
|
15
15
|
addPlugin?: boolean;
|
|
16
16
|
};
|
|
17
|
-
export declare function addVitestAngular(tree: Tree, options: AddVitestAngularOptions): Promise<
|
|
18
|
-
export declare function addVitestAnalog(tree: Tree, options: AddVitestAnalogOptions): Promise<
|
|
17
|
+
export declare function addVitestAngular(tree: Tree, options: AddVitestAngularOptions): Promise<GeneratorCallback>;
|
|
18
|
+
export declare function addVitestAnalog(tree: Tree, options: AddVitestAnalogOptions): Promise<GeneratorCallback>;
|
|
19
19
|
//# sourceMappingURL=add-vitest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-vitest.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/utils/add-vitest.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"add-vitest.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/utils/add-vitest.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EAQtB,KAAK,IAAI,EAKV,MAAM,YAAY,CAAC;AAcpB,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CAqD5B;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,iBAAiB,CAAC,CAuD5B"}
|
|
@@ -67,29 +67,36 @@ async function addVitestAngular(tree, options) {
|
|
|
67
67
|
}
|
|
68
68
|
configureTypeScriptForVitest(tree, options.projectRoot);
|
|
69
69
|
addVitestScreenshotsToGitIgnore(tree);
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
const angularDevkitVersion = (0, version_utils_1.getInstalledAngularDevkitVersion)(tree) ??
|
|
73
|
-
pkgVersions.angularDevkitVersion;
|
|
74
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
75
|
-
'@angular/build': angularDevkitVersion,
|
|
76
|
-
// @angular/build uses rolldown which injects @oxc-project/runtime
|
|
77
|
-
// helpers at transform time but doesn't declare it as a dependency
|
|
78
|
-
'@oxc-project/runtime': versions_1.oxcProjectRuntimeVersion,
|
|
79
|
-
jsdom: pkgVersions.jsdomVersion,
|
|
80
|
-
vitest: pkgVersions.vitestVersion,
|
|
81
|
-
}, undefined, true);
|
|
70
|
+
if (options.skipPackageJson) {
|
|
71
|
+
return () => { };
|
|
82
72
|
}
|
|
73
|
+
const pkgVersions = (0, version_utils_1.versions)(tree, { minAngularMajorVersion: 21 });
|
|
74
|
+
const angularDevkitVersion = (0, version_utils_1.getInstalledAngularDevkitVersion)(tree) ?? pkgVersions.angularDevkitVersion;
|
|
75
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
76
|
+
'@angular/build': angularDevkitVersion,
|
|
77
|
+
jsdom: pkgVersions.jsdomVersion,
|
|
78
|
+
vitest: pkgVersions.vitestVersion,
|
|
79
|
+
}, undefined, true);
|
|
83
80
|
}
|
|
84
81
|
async function addVitestAnalog(tree, options) {
|
|
85
82
|
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
83
|
+
const tasks = [];
|
|
86
84
|
if (!options.skipPackageJson) {
|
|
87
85
|
const angularDevkitVersion = (0, version_utils_1.getInstalledAngularDevkitVersion)(tree) ??
|
|
88
86
|
(0, version_utils_1.versions)(tree).angularDevkitVersion;
|
|
89
87
|
const devDependencies = {
|
|
90
88
|
'@angular/build': angularDevkitVersion,
|
|
91
|
-
//
|
|
92
|
-
//
|
|
89
|
+
// `@analogjs/vite-plugin-angular` (wired in by `@nx/vitest`'s
|
|
90
|
+
// configurationGenerator for `uiFramework: 'angular'`) registers
|
|
91
|
+
// an `angularVitestPlugin` whose `transform` hook downlevels
|
|
92
|
+
// `@angular/*` fesm2022 modules via
|
|
93
|
+
// `vite.transformWithOxc({ target: 'es2016', … })` so Zone.js
|
|
94
|
+
// `fakeAsync` can intercept async/await. The lowered code emits
|
|
95
|
+
// external `@oxc-project/runtime/helpers/*` imports (oxc default
|
|
96
|
+
// `HelperMode = 'Runtime'`). Nothing in the upstream chain
|
|
97
|
+
// (analogjs, @angular/core, vite, rolldown) declares the runtime
|
|
98
|
+
// in a way that's resolvable from the consumer's workspace, so
|
|
99
|
+
// it must be added here.
|
|
93
100
|
'@oxc-project/runtime': versions_1.oxcProjectRuntimeVersion,
|
|
94
101
|
};
|
|
95
102
|
// Add compatible vitest/jsdom versions BEFORE calling configurationGenerator
|
|
@@ -99,11 +106,11 @@ async function addVitestAnalog(tree, options) {
|
|
|
99
106
|
devDependencies['vitest'] = pkgVersions.vitestVersion;
|
|
100
107
|
devDependencies['jsdom'] = pkgVersions.jsdomVersion;
|
|
101
108
|
}
|
|
102
|
-
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, true);
|
|
109
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, true));
|
|
103
110
|
}
|
|
104
111
|
(0, devkit_1.ensurePackage)('@nx/vitest', versions_1.nxVersion);
|
|
105
112
|
const { configurationGenerator } = await Promise.resolve().then(() => __importStar(require('@nx/vitest/generators')));
|
|
106
|
-
await configurationGenerator(tree, {
|
|
113
|
+
tasks.push(await configurationGenerator(tree, {
|
|
107
114
|
project: options.name,
|
|
108
115
|
uiFramework: 'angular',
|
|
109
116
|
testEnvironment: 'jsdom',
|
|
@@ -112,7 +119,8 @@ async function addVitestAnalog(tree, options) {
|
|
|
112
119
|
skipFormat: options.skipFormat,
|
|
113
120
|
skipPackageJson: options.skipPackageJson,
|
|
114
121
|
zoneless: options.zoneless,
|
|
115
|
-
});
|
|
122
|
+
}));
|
|
123
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
116
124
|
}
|
|
117
125
|
function validateVitestVersion(tree) {
|
|
118
126
|
let installedVitestVersion = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/angular/src/plugins/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/angular/src/plugins/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAML,KAAK,aAAa,EAOnB,MAAM,YAAY,CAAC;AAUpB,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAOD,KAAK,0BAA0B,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AACF,MAAM,MAAM,2BAA2B,GAAG;IACxC,WAAW,EAAE,aAAa,GAAG,SAAS,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;CACtD,CAAC;AAqCF,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,oBAAoB,CA6D7D,CAAC"}
|
package/src/plugins/plugin.js
CHANGED
|
@@ -55,21 +55,35 @@ exports.createNodesV2 = [
|
|
|
55
55
|
const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
56
56
|
const lockFileName = (0, js_1.getLockFileName)(packageManager);
|
|
57
57
|
try {
|
|
58
|
-
|
|
58
|
+
const { entries, preErrors } = await filterAngularConfigs(configFiles, context);
|
|
59
|
+
const projectHashes = await (0, internal_1.calculateHashesForCreateNodes)(entries.map((e) => e.angularWorkspaceRoot), options ?? {}, context, entries.map(() => [lockFileName]));
|
|
60
|
+
let results = [];
|
|
61
|
+
let nodeErrors = [];
|
|
62
|
+
try {
|
|
63
|
+
results = await (0, devkit_1.createNodesFromFiles)((configFile, opts, ctx, idx) => createNodesInternal(configFile, opts, ctx, projectsCache, pmc, projectHashes[idx]), entries.map((e) => e.configFile), options, context);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
if (e instanceof devkit_1.AggregateCreateNodesError) {
|
|
67
|
+
results = e.partialResults ?? [];
|
|
68
|
+
nodeErrors = e.errors;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const allErrors = [...preErrors, ...nodeErrors];
|
|
75
|
+
if (allErrors.length > 0) {
|
|
76
|
+
throw new devkit_1.AggregateCreateNodesError(allErrors, results);
|
|
77
|
+
}
|
|
78
|
+
return results;
|
|
59
79
|
}
|
|
60
80
|
finally {
|
|
61
81
|
projectsCache.writeToDisk();
|
|
62
82
|
}
|
|
63
83
|
},
|
|
64
84
|
];
|
|
65
|
-
async function createNodesInternal(configFilePath, options, context, projectsCache, pmc,
|
|
85
|
+
async function createNodesInternal(configFilePath, options, context, projectsCache, pmc, hash) {
|
|
66
86
|
const angularWorkspaceRoot = (0, node_path_1.dirname)(configFilePath);
|
|
67
|
-
// Do not create a project if package.json isn't there
|
|
68
|
-
const siblingFiles = (0, node_fs_1.readdirSync)((0, node_path_1.join)(context.workspaceRoot, angularWorkspaceRoot));
|
|
69
|
-
if (!siblingFiles.includes('package.json')) {
|
|
70
|
-
return {};
|
|
71
|
-
}
|
|
72
|
-
const hash = await (0, internal_1.calculateHashForCreateNodes)(angularWorkspaceRoot, options, context, [lockFileName]);
|
|
73
87
|
if (!projectsCache.has(hash)) {
|
|
74
88
|
projectsCache.set(hash, await buildAngularProjects(configFilePath, options, angularWorkspaceRoot, context, pmc));
|
|
75
89
|
}
|
|
@@ -522,3 +536,24 @@ function getOutput(path, workspaceRoot, angularWorkspaceRoot, projectRoot) {
|
|
|
522
536
|
function getAngularJsonProjectTargets(project) {
|
|
523
537
|
return project.architect ?? project.targets;
|
|
524
538
|
}
|
|
539
|
+
async function filterAngularConfigs(configFiles, context) {
|
|
540
|
+
const preErrors = [];
|
|
541
|
+
const candidates = await Promise.all(configFiles.map(async (configFile) => {
|
|
542
|
+
try {
|
|
543
|
+
const angularWorkspaceRoot = (0, node_path_1.dirname)(configFile);
|
|
544
|
+
const siblingFiles = (0, node_fs_1.readdirSync)((0, node_path_1.join)(context.workspaceRoot, angularWorkspaceRoot));
|
|
545
|
+
if (!siblingFiles.includes('package.json')) {
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
return { configFile, angularWorkspaceRoot };
|
|
549
|
+
}
|
|
550
|
+
catch (e) {
|
|
551
|
+
preErrors.push([configFile, e]);
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
554
|
+
}));
|
|
555
|
+
return {
|
|
556
|
+
entries: candidates.filter((c) => c !== null),
|
|
557
|
+
preErrors,
|
|
558
|
+
};
|
|
559
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/angular/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAE/D,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,2BAA2B,YAAY,CAAC;AACrD,eAAO,MAAM,+BAA+B,WAAW,CAAC;AACxD,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,uBAAuB,YAAY,CAAC;AACjD,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAClD,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAE9C,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,YAAY,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/angular/src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAE/D,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,2BAA2B,YAAY,CAAC;AACrD,eAAO,MAAM,+BAA+B,WAAW,CAAC;AACxD,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,uBAAuB,YAAY,CAAC;AACjD,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAC7C,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAClD,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAE9C,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,eAAO,MAAM,YAAY,YAAY,CAAC;AAQtC,eAAO,MAAM,wBAAwB,aAAa,CAAC;AAEnD,eAAO,MAAM,wBAAwB,WAAW,CAAC"}
|
package/src/utils/versions.js
CHANGED
|
@@ -29,7 +29,12 @@ exports.typesNodeVersion = '^22.0.0';
|
|
|
29
29
|
exports.jasmineMarblesVersion = '^0.9.2';
|
|
30
30
|
exports.vitestVersion = '^4.0.8';
|
|
31
31
|
exports.jsdomVersion = '^27.1.0';
|
|
32
|
-
//
|
|
33
|
-
//
|
|
32
|
+
// `@analogjs/vite-plugin-angular` (vitest-analog path) registers an
|
|
33
|
+
// `angularVitestPlugin` whose `transform` hook downlevels `@angular/*`
|
|
34
|
+
// fesm2022 modules via `vite.transformWithOxc({ target: 'es2016', … })`
|
|
35
|
+
// so Zone.js `fakeAsync` can intercept async/await. The lowered code
|
|
36
|
+
// emits external `@oxc-project/runtime/helpers/*` imports (oxc default
|
|
37
|
+
// `HelperMode = 'Runtime'`). Nothing upstream declares the runtime, so
|
|
38
|
+
// we add it explicitly to user projects.
|
|
34
39
|
exports.oxcProjectRuntimeVersion = '^0.115.0';
|
|
35
40
|
exports.jsoncEslintParserVersion = '^2.1.0';
|