@nx/angular 20.1.0-canary.20241026-f84b6e5 → 20.1.0-canary.20241030-62f58eb

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/angular",
3
- "version": "20.1.0-canary.20241026-f84b6e5",
3
+ "version": "20.1.0-canary.20241030-62f58eb",
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, 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": {
@@ -80,12 +80,12 @@
80
80
  "webpack-merge": "^5.8.0",
81
81
  "webpack": "^5.88.0",
82
82
  "@module-federation/enhanced": "0.6.9",
83
- "@nx/devkit": "20.1.0-canary.20241026-f84b6e5",
84
- "@nx/js": "20.1.0-canary.20241026-f84b6e5",
85
- "@nx/eslint": "20.1.0-canary.20241026-f84b6e5",
86
- "@nx/webpack": "20.1.0-canary.20241026-f84b6e5",
87
- "@nx/web": "20.1.0-canary.20241026-f84b6e5",
88
- "@nx/workspace": "20.1.0-canary.20241026-f84b6e5",
83
+ "@nx/devkit": "20.1.0-canary.20241030-62f58eb",
84
+ "@nx/js": "20.1.0-canary.20241030-62f58eb",
85
+ "@nx/eslint": "20.1.0-canary.20241030-62f58eb",
86
+ "@nx/webpack": "20.1.0-canary.20241030-62f58eb",
87
+ "@nx/web": "20.1.0-canary.20241030-62f58eb",
88
+ "@nx/workspace": "20.1.0-canary.20241030-62f58eb",
89
89
  "piscina": "^4.4.0"
90
90
  },
91
91
  "peerDependencies": {
@@ -3,13 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addUnitTestRunner = addUnitTestRunner;
4
4
  const test_runners_1 = require("../../../utils/test-runners");
5
5
  const add_jest_1 = require("../../utils/add-jest");
6
+ const add_vitest_1 = require("../../utils/add-vitest");
6
7
  async function addUnitTestRunner(host, options) {
7
- if (options.unitTestRunner === test_runners_1.UnitTestRunner.Jest) {
8
- await (0, add_jest_1.addJest)(host, {
9
- name: options.name,
10
- projectRoot: options.appProjectRoot,
11
- skipPackageJson: options.skipPackageJson,
12
- strict: options.strict,
13
- });
8
+ switch (options.unitTestRunner) {
9
+ case test_runners_1.UnitTestRunner.Jest:
10
+ await (0, add_jest_1.addJest)(host, {
11
+ name: options.name,
12
+ projectRoot: options.appProjectRoot,
13
+ skipPackageJson: options.skipPackageJson,
14
+ strict: options.strict,
15
+ });
16
+ break;
17
+ case test_runners_1.UnitTestRunner.Vitest:
18
+ await (0, add_vitest_1.addVitest)(host, {
19
+ name: options.name,
20
+ projectRoot: options.appProjectRoot,
21
+ skipPackageJson: options.skipPackageJson,
22
+ strict: options.strict,
23
+ });
24
+ break;
14
25
  }
15
26
  }
@@ -99,8 +99,9 @@
99
99
  },
100
100
  "unitTestRunner": {
101
101
  "type": "string",
102
- "enum": ["jest", "none"],
102
+ "enum": ["jest", "vitest", "none"],
103
103
  "description": "Test runner to use for unit tests.",
104
+ "x-prompt": "Which unit test runner would you like to use?",
104
105
  "default": "jest"
105
106
  },
106
107
  "e2eTestRunner": {
@@ -51,8 +51,9 @@
51
51
  },
52
52
  "unitTestRunner": {
53
53
  "type": "string",
54
- "enum": ["jest", "none"],
54
+ "enum": ["jest", "vitest", "none"],
55
55
  "description": "Test runner to use for unit tests of the remote if it needs to be created.",
56
+ "x-prompt": "Which unit test runner would you like to use?",
56
57
  "default": "jest"
57
58
  },
58
59
  "e2eTestRunner": {
@@ -108,8 +108,9 @@
108
108
  },
109
109
  "unitTestRunner": {
110
110
  "type": "string",
111
- "enum": ["jest", "none"],
111
+ "enum": ["jest", "vitest", "none"],
112
112
  "description": "Test runner to use for unit tests.",
113
+ "x-prompt": "Which unit test runner would you like to use?",
113
114
  "default": "jest"
114
115
  },
115
116
  "e2eTestRunner": {
@@ -22,6 +22,8 @@ const add_jest_1 = require("../utils/add-jest");
22
22
  const set_generator_defaults_1 = require("./lib/set-generator-defaults");
23
23
  const ensure_angular_dependencies_1 = require("../utils/ensure-angular-dependencies");
24
24
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
25
+ const test_runners_1 = require("../../utils/test-runners");
26
+ const add_vitest_1 = require("../utils/add-vitest");
25
27
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
26
28
  async function libraryGenerator(tree, schema) {
27
29
  (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'angular', 'library');
@@ -87,13 +89,23 @@ async function libraryGenerator(tree, schema) {
87
89
  };
88
90
  }
89
91
  async function addUnitTestRunner(host, options) {
90
- if (options.unitTestRunner === 'jest') {
91
- await (0, add_jest_1.addJest)(host, {
92
- name: options.name,
93
- projectRoot: options.projectRoot,
94
- skipPackageJson: options.skipPackageJson,
95
- strict: options.strict,
96
- });
92
+ switch (options.unitTestRunner) {
93
+ case test_runners_1.UnitTestRunner.Jest:
94
+ await (0, add_jest_1.addJest)(host, {
95
+ name: options.name,
96
+ projectRoot: options.projectRoot,
97
+ skipPackageJson: options.skipPackageJson,
98
+ strict: options.strict,
99
+ });
100
+ break;
101
+ case test_runners_1.UnitTestRunner.Vitest:
102
+ await (0, add_vitest_1.addVitest)(host, {
103
+ name: options.name,
104
+ projectRoot: options.projectRoot,
105
+ skipPackageJson: options.skipPackageJson,
106
+ strict: options.strict,
107
+ });
108
+ break;
97
109
  }
98
110
  }
99
111
  function updateNpmScopeIfBuildableOrPublishable(host, options) {
@@ -88,8 +88,9 @@
88
88
  },
89
89
  "unitTestRunner": {
90
90
  "type": "string",
91
- "enum": ["jest", "none"],
91
+ "enum": ["jest", "vitest", "none"],
92
92
  "description": "Test runner to use for unit tests.",
93
+ "x-prompt": "Which unit test runner would you like to use?",
93
94
  "default": "jest"
94
95
  },
95
96
  "importPath": {
@@ -102,8 +102,9 @@
102
102
  },
103
103
  "unitTestRunner": {
104
104
  "type": "string",
105
- "enum": ["jest", "none"],
105
+ "enum": ["jest", "vitest", "none"],
106
106
  "description": "Test runner to use for unit tests.",
107
+ "x-prompt": "Which unit test runner would you like to use?",
107
108
  "default": "jest"
108
109
  },
109
110
  "e2eTestRunner": {
@@ -21,4 +21,7 @@ const config: ModuleFederationConfig = {
21
21
  },<% } %>
22
22
  };
23
23
 
24
+ /**
25
+ * Nx requires a default export of the config to allow correct resolution of the module federation graph.
26
+ **/
24
27
  export default config;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Nx requires a default export of the config to allow correct resolution of the module federation graph.
3
+ **/
1
4
  module.exports = {
2
5
  name: '<%= name %>',<% if(type === 'host') { %>
3
6
  /**
@@ -0,0 +1,8 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export type AddVitestOptions = {
3
+ name: string;
4
+ projectRoot: string;
5
+ skipPackageJson: boolean;
6
+ strict: boolean;
7
+ };
8
+ export declare function addVitest(tree: Tree, options: AddVitestOptions): Promise<void>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addVitest = addVitest;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../utils/versions");
6
+ async function addVitest(tree, options) {
7
+ if (!options.skipPackageJson) {
8
+ (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
9
+ '@analogjs/vitest-angular': versions_1.analogVitestAngular,
10
+ '@analogjs/vite-plugin-angular': versions_1.analogVitestAngular,
11
+ }, undefined, true);
12
+ }
13
+ const { createOrEditViteConfig, viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
14
+ const relativeTestSetupPath = (0, devkit_1.joinPathFragments)('src', 'test-setup.ts');
15
+ const setupFile = (0, devkit_1.joinPathFragments)(options.projectRoot, relativeTestSetupPath);
16
+ if (!tree.exists(setupFile)) {
17
+ tree.write(setupFile, `import '@analogjs/vitest-angular/setup-zone';
18
+
19
+ import {
20
+ BrowserDynamicTestingModule,
21
+ platformBrowserDynamicTesting,
22
+ } from '@angular/platform-browser-dynamic/testing';
23
+ import { getTestBed } from '@angular/core/testing';
24
+
25
+ getTestBed().initTestEnvironment(
26
+ BrowserDynamicTestingModule,
27
+ platformBrowserDynamicTesting()
28
+ );
29
+ `);
30
+ await viteConfigurationGenerator(tree, {
31
+ project: options.name,
32
+ newProject: true,
33
+ uiFramework: 'none',
34
+ includeVitest: true,
35
+ testEnvironment: 'jsdom',
36
+ });
37
+ createOrEditViteConfig(tree, {
38
+ project: options.name,
39
+ includeLib: false,
40
+ includeVitest: true,
41
+ inSourceTests: false,
42
+ imports: [`import angular from '@analogjs/vite-plugin-angular'`],
43
+ plugins: ['angular()'],
44
+ setupFile: relativeTestSetupPath,
45
+ useEsmExtension: true,
46
+ }, true);
47
+ }
48
+ }
@@ -4,8 +4,8 @@ type LatestPackageVersionNames = Exclude<keyof typeof latestVersions, 'nxVersion
4
4
  type CompatPackageVersionNames = LatestPackageVersionNames | 'ngUniversalVersion';
5
5
  export type PackageVersionNames = LatestPackageVersionNames | CompatPackageVersionNames;
6
6
  export type VersionMap = {
7
- angularV16: Record<Exclude<CompatPackageVersionNames, 'typescriptEslintVersion'>, string>;
8
- angularV17: Record<Exclude<CompatPackageVersionNames, 'ngUniversalVersion' | 'typescriptEslintVersion'>, string>;
7
+ angularV16: Record<Exclude<CompatPackageVersionNames, 'analogVitestAngular' | 'typescriptEslintVersion'>, string>;
8
+ angularV17: Record<Exclude<CompatPackageVersionNames, 'analogVitestAngular' | 'ngUniversalVersion' | 'typescriptEslintVersion'>, string>;
9
9
  };
10
10
  export type PackageLatestVersions = Record<LatestPackageVersionNames, string>;
11
11
  export type PackageCompatVersions = VersionMap[SupportedVersions];
@@ -1,6 +1,7 @@
1
1
  export declare enum UnitTestRunner {
2
2
  Jest = "jest",
3
- None = "none"
3
+ None = "none",
4
+ Vitest = "vitest"
4
5
  }
5
6
  export declare enum E2eTestRunner {
6
7
  Cypress = "cypress",
@@ -5,6 +5,7 @@ var UnitTestRunner;
5
5
  (function (UnitTestRunner) {
6
6
  UnitTestRunner["Jest"] = "jest";
7
7
  UnitTestRunner["None"] = "none";
8
+ UnitTestRunner["Vitest"] = "vitest";
8
9
  })(UnitTestRunner || (exports.UnitTestRunner = UnitTestRunner = {}));
9
10
  var E2eTestRunner;
10
11
  (function (E2eTestRunner) {
@@ -24,4 +24,5 @@ export declare const tsNodeVersion = "10.9.1";
24
24
  export declare const jestPresetAngularVersion = "~14.1.0";
25
25
  export declare const typesNodeVersion = "18.16.9";
26
26
  export declare const jasmineMarblesVersion = "^0.9.2";
27
+ export declare const analogVitestAngular = "~1.9.1";
27
28
  export declare const jsoncEslintParserVersion = "^2.1.0";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsoncEslintParserVersion = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptEslintVersion = exports.angularEslintVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.angularJsVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
3
+ exports.jsoncEslintParserVersion = exports.analogVitestAngular = exports.jasmineMarblesVersion = exports.typesNodeVersion = exports.jestPresetAngularVersion = exports.tsNodeVersion = exports.autoprefixerVersion = exports.postcssUrlVersion = exports.postcssVersion = exports.tailwindVersion = exports.typescriptEslintVersion = exports.angularEslintVersion = exports.moduleFederationEnhancedVersion = exports.moduleFederationNodeVersion = exports.browserSyncVersion = exports.typesExpressVersion = exports.expressVersion = exports.typesCorsVersion = exports.corsVersion = exports.tsLibVersion = exports.angularJsVersion = exports.zoneJsVersion = exports.rxjsVersion = exports.ngrxVersion = exports.ngPackagrVersion = exports.angularDevkitVersion = exports.angularVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.angularVersion = '~18.2.0';
6
6
  exports.angularDevkitVersion = '~18.2.0';
@@ -27,4 +27,5 @@ exports.tsNodeVersion = '10.9.1';
27
27
  exports.jestPresetAngularVersion = '~14.1.0';
28
28
  exports.typesNodeVersion = '18.16.9';
29
29
  exports.jasmineMarblesVersion = '^0.9.2';
30
+ exports.analogVitestAngular = '~1.9.1';
30
31
  exports.jsoncEslintParserVersion = '^2.1.0';