@nx/vue 20.2.2 → 20.3.0-beta.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/vue",
3
- "version": "20.2.2",
3
+ "version": "20.3.0-beta.1",
4
4
  "private": false,
5
5
  "description": "The Vue plugin for Nx contains executors and generators for managing Vue applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
6
6
  "repository": {
@@ -31,11 +31,11 @@
31
31
  "dependencies": {
32
32
  "minimatch": "9.0.3",
33
33
  "tslib": "^2.3.0",
34
- "@nx/devkit": "20.2.2",
35
- "@nx/js": "20.2.2",
36
- "@nx/eslint": "20.2.2",
37
- "@nx/vite": "20.2.2",
38
- "@nx/web": "20.2.2"
34
+ "@nx/devkit": "20.3.0-beta.1",
35
+ "@nx/js": "20.3.0-beta.1",
36
+ "@nx/eslint": "20.3.0-beta.1",
37
+ "@nx/vite": "20.3.0-beta.1",
38
+ "@nx/web": "20.3.0-beta.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -5,7 +5,6 @@ exports.applicationGeneratorInternal = applicationGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const eslint_1 = require("@nx/eslint");
7
7
  const js_1 = require("@nx/js");
8
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
9
8
  const normalize_options_1 = require("./lib/normalize-options");
10
9
  const init_1 = require("../init/init");
11
10
  const add_linting_1 = require("../../utils/add-linting");
@@ -15,30 +14,49 @@ const add_vite_1 = require("./lib/add-vite");
15
14
  const create_ts_config_1 = require("../../utils/create-ts-config");
16
15
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
17
16
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
17
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
18
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
18
19
  function applicationGenerator(tree, options) {
19
20
  return applicationGeneratorInternal(tree, { addPlugin: false, ...options });
20
21
  }
21
22
  async function applicationGeneratorInternal(tree, _options) {
22
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'vue', 'application');
23
- const options = await (0, normalize_options_1.normalizeOptions)(tree, _options);
24
- const nxJson = (0, devkit_1.readNxJson)(tree);
25
- options.addPlugin ??=
26
- process.env.NX_ADD_PLUGINS !== 'false' &&
27
- nxJson.useInferencePlugins !== false;
28
23
  const tasks = [];
29
- (0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
30
- root: options.appProjectRoot,
31
- projectType: 'application',
32
- sourceRoot: `${options.appProjectRoot}/src`,
33
- targets: {},
34
- });
35
24
  tasks.push(await (0, js_1.initGenerator)(tree, {
36
- ...options,
37
- tsConfigName: options.rootProject
25
+ ..._options,
26
+ tsConfigName: _options.rootProject
38
27
  ? 'tsconfig.json'
39
28
  : 'tsconfig.base.json',
40
29
  skipFormat: true,
30
+ addTsPlugin: _options.useTsSolution,
31
+ formatter: _options.formatter,
41
32
  }));
33
+ const options = await (0, normalize_options_1.normalizeOptions)(tree, _options);
34
+ const nxJson = (0, devkit_1.readNxJson)(tree);
35
+ options.addPlugin ??=
36
+ process.env.NX_ADD_PLUGINS !== 'false' &&
37
+ nxJson.useInferencePlugins !== false;
38
+ if (options.isUsingTsSolutionConfig) {
39
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
40
+ name: (0, get_import_path_1.getImportPath)(tree, options.name),
41
+ version: '0.0.1',
42
+ private: true,
43
+ nx: {
44
+ name: options.name,
45
+ projectType: 'application',
46
+ sourceRoot: `${options.appProjectRoot}/src`,
47
+ tags: options.parsedTags?.length ? options.parsedTags : undefined,
48
+ },
49
+ });
50
+ }
51
+ else {
52
+ (0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
53
+ root: options.appProjectRoot,
54
+ projectType: 'application',
55
+ sourceRoot: `${options.appProjectRoot}/src`,
56
+ tags: options.parsedTags?.length ? options.parsedTags : undefined,
57
+ targets: {},
58
+ });
59
+ }
42
60
  tasks.push(await (0, init_1.vueInitGenerator)(tree, {
43
61
  ...options,
44
62
  skipFormat: true,
@@ -66,6 +84,17 @@ async function applicationGeneratorInternal(tree, _options) {
66
84
  (0, devkit_1.toJS)(tree);
67
85
  if (!options.skipFormat)
68
86
  await (0, devkit_1.formatFiles)(tree);
87
+ if (options.isUsingTsSolutionConfig) {
88
+ (0, ts_solution_setup_1.updateTsconfigFiles)(tree, options.appProjectRoot, 'tsconfig.app.json', {
89
+ jsx: 'preserve',
90
+ jsxImportSource: 'vue',
91
+ module: 'esnext',
92
+ moduleResolution: 'bundler',
93
+ resolveJsonModule: true,
94
+ }, options.linter === 'eslint'
95
+ ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
96
+ : undefined);
97
+ }
69
98
  tasks.push(() => {
70
99
  (0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
71
100
  });
@@ -0,0 +1,5 @@
1
+ declare module '*.vue' {
2
+ import { defineComponent } from 'vue';
3
+ const component: ReturnType<typeof defineComponent>;
4
+ export default component;
5
+ }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = normalizeOptions;
4
4
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
6
  async function normalizeOptions(host, options) {
6
7
  await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
7
8
  const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
@@ -28,5 +29,6 @@ async function normalizeOptions(host, options) {
28
29
  normalized.routing = normalized.routing ?? false;
29
30
  normalized.unitTestRunner ??= 'vitest';
30
31
  normalized.e2eTestRunner = normalized.e2eTestRunner ?? 'playwright';
32
+ normalized.isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
31
33
  return normalized;
32
34
  }
@@ -10,6 +10,7 @@ export interface Schema {
10
10
  inSourceTests?: boolean;
11
11
  e2eTestRunner: 'cypress' | 'playwright' | 'none';
12
12
  linter: Linter | LinterType;
13
+ formatter?: 'none' | 'prettier';
13
14
  routing?: boolean;
14
15
  js?: boolean;
15
16
  strict?: boolean;
@@ -18,6 +19,7 @@ export interface Schema {
18
19
  rootProject?: boolean;
19
20
  addPlugin?: boolean;
20
21
  nxCloudToken?: string;
22
+ useTsSolution?: boolean;
21
23
  }
22
24
 
23
25
  export interface NormalizedSchema extends Schema {
@@ -27,4 +29,5 @@ export interface NormalizedSchema extends Schema {
27
29
  e2eProjectRoot: string;
28
30
  parsedTags: string[];
29
31
  devServerPort?: number;
32
+ isUsingTsSolutionConfig: boolean;
30
33
  }
@@ -60,12 +60,6 @@
60
60
  ]
61
61
  }
62
62
  },
63
- "linter": {
64
- "description": "The tool to use for running lint checks.",
65
- "type": "string",
66
- "enum": ["eslint", "none"],
67
- "default": "eslint"
68
- },
69
63
  "routing": {
70
64
  "type": "boolean",
71
65
  "description": "Generate application with routes.",
@@ -78,12 +72,21 @@
78
72
  "default": false,
79
73
  "x-priority": "internal"
80
74
  },
75
+ "linter": {
76
+ "description": "The tool to use for running lint checks.",
77
+ "type": "string",
78
+ "enum": ["eslint", "none"],
79
+ "default": "none",
80
+ "x-prompt": "Which linter would you like to use?",
81
+ "x-priority": "important"
82
+ },
81
83
  "unitTestRunner": {
82
84
  "type": "string",
83
85
  "enum": ["vitest", "none"],
84
86
  "description": "Test runner to use for unit tests.",
85
87
  "x-prompt": "Which unit test runner would you like to use?",
86
- "default": "vitest"
88
+ "default": "none",
89
+ "x-priority": "important"
87
90
  },
88
91
  "inSourceTests": {
89
92
  "type": "boolean",
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.vueInitGenerator = vueInitGenerator;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
5
  const versions_1 = require("../../utils/versions");
7
6
  function updateDependencies(host, schema) {
8
7
  const tasks = [];
@@ -11,7 +10,6 @@ function updateDependencies(host, schema) {
11
10
  return (0, devkit_1.runTasksInSerial)(...tasks);
12
11
  }
13
12
  async function vueInitGenerator(host, schema) {
14
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'vue', 'init');
15
13
  let installTask = () => { };
16
14
  if (!schema.skipPackageJson) {
17
15
  installTask = updateDependencies(host, schema);
@@ -14,8 +14,21 @@ function createLibraryFiles(host, options) {
14
14
  fileName: options.fileName,
15
15
  };
16
16
  (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, '../files'), options.projectRoot, substitutions);
17
- if (!options.publishable && options.bundler === 'none') {
18
- host.delete(`${options.projectRoot}/package.json`);
17
+ if (!options.isUsingTsSolutionConfig &&
18
+ (options.publishable || options.bundler !== 'none')) {
19
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
20
+ name: options.name,
21
+ version: '0.0.1',
22
+ main: './index.js',
23
+ types: './index.d.ts',
24
+ exports: {
25
+ '.': {
26
+ import: './index.mjs',
27
+ require: './index.js',
28
+ types: './index.d.ts',
29
+ },
30
+ },
31
+ });
19
32
  }
20
33
  if (options.unitTestRunner !== 'vitest') {
21
34
  host.delete(`${options.projectRoot}/tsconfig.spec.json`);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = normalizeOptions;
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 ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
7
  async function normalizeOptions(host, options) {
7
8
  await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
8
9
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
@@ -35,6 +36,7 @@ async function normalizeOptions(host, options) {
35
36
  projectRoot,
36
37
  parsedTags,
37
38
  importPath,
39
+ isUsingTsSolutionConfig: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
38
40
  };
39
41
  // Libraries with a bundler or is publishable must also be buildable.
40
42
  normalized.bundler =
@@ -4,7 +4,6 @@ exports.libraryGenerator = libraryGenerator;
4
4
  exports.libraryGeneratorInternal = libraryGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const js_1 = require("@nx/js");
7
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
7
  const init_1 = require("../init/init");
9
8
  const normalize_options_1 = require("./lib/normalize-options");
10
9
  const add_linting_1 = require("../../utils/add-linting");
@@ -16,24 +15,54 @@ const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
16
15
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
17
16
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
18
17
  const path_1 = require("path");
18
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
19
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
20
+ const plugin_1 = require("@nx/js/src/utils/typescript/plugin");
19
21
  function libraryGenerator(tree, schema) {
20
22
  return libraryGeneratorInternal(tree, { addPlugin: false, ...schema });
21
23
  }
22
24
  async function libraryGeneratorInternal(tree, schema) {
23
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'vue', 'library');
24
25
  const tasks = [];
26
+ tasks.push(await (0, js_1.initGenerator)(tree, { ...schema, skipFormat: true }));
25
27
  const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
26
28
  if (options.publishable === true && !schema.importPath) {
27
29
  throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
28
30
  }
29
- (0, devkit_1.addProjectConfiguration)(tree, options.name, {
30
- root: options.projectRoot,
31
- sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
32
- projectType: 'library',
33
- tags: options.parsedTags,
34
- targets: {},
35
- });
36
- tasks.push(await (0, js_1.initGenerator)(tree, { ...schema, skipFormat: true }));
31
+ if (options.isUsingTsSolutionConfig) {
32
+ const moduleFile = options.bundler === 'none'
33
+ ? options.js
34
+ ? './src/index.js'
35
+ : './src/index.ts'
36
+ : './dist/index.mjs';
37
+ const typesFile = options.bundler === 'none'
38
+ ? options.js
39
+ ? './src/index.js'
40
+ : './src/index.ts'
41
+ : './dist/index.d.ts';
42
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
43
+ name: (0, get_import_path_1.getImportPath)(tree, options.name),
44
+ version: '0.0.1',
45
+ private: true,
46
+ module: moduleFile,
47
+ types: typesFile,
48
+ files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
49
+ nx: {
50
+ name: options.name,
51
+ projectType: 'application',
52
+ sourceRoot: `${options.projectRoot}/src`,
53
+ tags: options.parsedTags?.length ? options.parsedTags : undefined,
54
+ },
55
+ });
56
+ }
57
+ else {
58
+ (0, devkit_1.addProjectConfiguration)(tree, options.name, {
59
+ root: options.projectRoot,
60
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
61
+ projectType: 'library',
62
+ tags: options.parsedTags,
63
+ targets: {},
64
+ });
65
+ }
37
66
  tasks.push(await (0, init_1.vueInitGenerator)(tree, {
38
67
  ...options,
39
68
  skipFormat: true,
@@ -59,13 +88,19 @@ async function libraryGeneratorInternal(tree, schema) {
59
88
  skipFormat: true,
60
89
  });
61
90
  }
62
- if (options.publishable || options.bundler !== 'none') {
91
+ if (!options.isUsingTsSolutionConfig &&
92
+ (options.publishable || options.bundler !== 'none')) {
63
93
  (0, devkit_1.updateJson)(tree, `${options.projectRoot}/package.json`, (json) => {
64
94
  json.name = options.importPath;
65
95
  return json;
66
96
  });
67
97
  }
68
- if (!options.skipTsConfig) {
98
+ if (options.bundler === 'none') {
99
+ const nxJson = (0, devkit_1.readNxJson)(tree);
100
+ (0, plugin_1.ensureProjectIsExcludedFromPluginRegistrations)(nxJson, options.projectRoot);
101
+ (0, devkit_1.updateNxJson)(tree, nxJson);
102
+ }
103
+ if (!options.skipTsConfig && !options.isUsingTsSolutionConfig) {
69
104
  (0, js_1.addTsConfigPath)(tree, options.importPath, [
70
105
  (0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
71
106
  ]);
@@ -74,6 +109,21 @@ async function libraryGeneratorInternal(tree, schema) {
74
109
  (0, devkit_1.toJS)(tree);
75
110
  if (!options.skipFormat)
76
111
  await (0, devkit_1.formatFiles)(tree);
112
+ if (options.isUsingTsSolutionConfig) {
113
+ (0, ts_solution_setup_1.updateTsconfigFiles)(tree, options.projectRoot, 'tsconfig.lib.json', {
114
+ jsx: 'preserve',
115
+ jsxImportSource: 'vue',
116
+ module: 'esnext',
117
+ moduleResolution: 'bundler',
118
+ resolveJsonModule: true,
119
+ }, options.linter === 'eslint'
120
+ ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
121
+ : undefined);
122
+ }
123
+ // Always run install to link packages.
124
+ if (options.isUsingTsSolutionConfig) {
125
+ tasks.push(() => (0, devkit_1.installPackagesTask)(tree, true));
126
+ }
77
127
  tasks.push(() => {
78
128
  (0, log_show_project_command_1.logShowProjectCommand)(options.name);
79
129
  });
@@ -35,4 +35,5 @@ export interface NormalizedSchema extends Schema {
35
35
  appMain?: string;
36
36
  appSourceRoot?: string;
37
37
  unitTestRunner?: 'vitest' | 'none';
38
+ isUsingTsSolutionConfig: boolean;
38
39
  }
@@ -36,13 +36,17 @@
36
36
  "description": "The tool to use for running lint checks.",
37
37
  "type": "string",
38
38
  "enum": ["eslint", "none"],
39
- "default": "eslint"
39
+ "default": "none",
40
+ "x-prompt": "Which linter would you like to use?",
41
+ "x-priority": "important"
40
42
  },
41
43
  "unitTestRunner": {
42
44
  "type": "string",
43
45
  "enum": ["vitest", "none"],
44
46
  "description": "Test runner to use for unit tests.",
45
- "x-prompt": "What unit test runner should be used?"
47
+ "x-prompt": "What unit test runner should be used?",
48
+ "default": "none",
49
+ "x-priority": "important"
46
50
  },
47
51
  "inSourceTests": {
48
52
  "type": "boolean",
@@ -1,5 +1,18 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  export declare function createTsConfig(host: Tree, projectRoot: string, type: 'app' | 'lib', options: {
3
+ strict?: boolean;
4
+ style?: string;
5
+ bundler?: string;
6
+ rootProject?: boolean;
7
+ unitTestRunner?: string;
8
+ }, relativePathToRootTsConfig: string): void;
9
+ export declare function createTsConfigForTsSolution(host: Tree, projectRoot: string, type: 'app' | 'lib', options: {
10
+ strict?: boolean;
11
+ style?: string;
12
+ rootProject?: boolean;
13
+ unitTestRunner?: string;
14
+ }, relativePathToRootTsConfig: string): void;
15
+ export declare function createTsConfigForNonTsSolution(host: Tree, projectRoot: string, type: 'app' | 'lib', options: {
3
16
  strict?: boolean;
4
17
  style?: string;
5
18
  rootProject?: boolean;
@@ -1,10 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTsConfig = createTsConfig;
4
+ exports.createTsConfigForTsSolution = createTsConfigForTsSolution;
5
+ exports.createTsConfigForNonTsSolution = createTsConfigForNonTsSolution;
4
6
  exports.extractTsConfigBase = extractTsConfigBase;
5
7
  const devkit_1 = require("@nx/devkit");
6
8
  const shared = require("@nx/js/src/utils/typescript/create-ts-config");
9
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
10
  function createTsConfig(host, projectRoot, type, options, relativePathToRootTsConfig) {
11
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
12
+ createTsConfigForTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig);
13
+ }
14
+ else {
15
+ createTsConfigForNonTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig);
16
+ }
17
+ }
18
+ function createTsConfigForTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig) {
19
+ const json = {
20
+ extends: relativePathToRootTsConfig,
21
+ files: [],
22
+ include: [],
23
+ references: [
24
+ {
25
+ path: type === 'app' ? './tsconfig.app.json' : './tsconfig.lib.json',
26
+ },
27
+ ],
28
+ };
29
+ (0, devkit_1.writeJson)(host, `${projectRoot}/tsconfig.json`, json);
30
+ const tsconfigProjectPath = `${projectRoot}/tsconfig.${type}.json`;
31
+ if (host.exists(tsconfigProjectPath)) {
32
+ (0, devkit_1.updateJson)(host, tsconfigProjectPath, (json) => {
33
+ json.compilerOptions ??= {};
34
+ const types = new Set(json.compilerOptions.types ?? []);
35
+ types.add('vite/client');
36
+ json.compilerOptions.types = Array.from(types);
37
+ return json;
38
+ });
39
+ }
40
+ }
41
+ function createTsConfigForNonTsSolution(host, projectRoot, type, options, relativePathToRootTsConfig) {
8
42
  const json = {
9
43
  compilerOptions: {
10
44
  allowJs: true,
@@ -1,12 +0,0 @@
1
- {
2
- "name": "<%= name %>",
3
- "version": "0.0.1",
4
- "main": "./index.js",
5
- "types": "./index.d.ts",
6
- "exports": {
7
- ".": {
8
- "import": "./index.mjs",
9
- "require": "./index.js"
10
- }
11
- }
12
- }