@nx/nuxt 21.0.0-beta.0 → 21.0.0-beta.2

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/generators.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "hidden": true
12
12
  },
13
13
  "application": {
14
- "factory": "./src/generators/application/application",
14
+ "factory": "./src/generators/application/application#applicationGeneratorInternal",
15
15
  "schema": "./src/generators/application/schema.json",
16
16
  "aliases": ["app"],
17
17
  "description": "Create a Nuxt application."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/nuxt",
3
- "version": "21.0.0-beta.0",
3
+ "version": "21.0.0-beta.2",
4
4
  "private": false,
5
5
  "description": "The Nuxt plugin for Nx contains executors and generators for managing Nuxt 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
  "tslib": "^2.3.0",
33
33
  "@nuxt/kit": "^3.10.0",
34
- "@nx/devkit": "21.0.0-beta.0",
35
- "@nx/js": "21.0.0-beta.0",
36
- "@nx/eslint": "21.0.0-beta.0",
37
- "@nx/vue": "21.0.0-beta.0",
38
- "@nx/vite": "21.0.0-beta.0",
34
+ "@nx/devkit": "21.0.0-beta.2",
35
+ "@nx/js": "21.0.0-beta.2",
36
+ "@nx/eslint": "21.0.0-beta.2",
37
+ "@nx/vue": "21.0.0-beta.2",
38
+ "@nx/vite": "21.0.0-beta.2",
39
39
  "@phenomnomnominal/tsquery": "~5.0.1"
40
40
  },
41
41
  "peerDependencies": {
@@ -1,4 +1,5 @@
1
1
  import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function applicationGenerator(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function applicationGeneratorInternal(tree: Tree, schema: Schema): Promise<GeneratorCallback>;
4
5
  export default applicationGenerator;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applicationGenerator = applicationGenerator;
4
+ exports.applicationGeneratorInternal = applicationGeneratorInternal;
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const init_1 = require("../init/init");
6
7
  const normalize_options_1 = require("./lib/normalize-options");
@@ -16,10 +17,15 @@ const ensure_dependencies_1 = require("./lib/ensure-dependencies");
16
17
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
17
18
  const node_child_process_1 = require("node:child_process");
18
19
  const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
19
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
20
20
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
21
21
  const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
22
22
  async function applicationGenerator(tree, schema) {
23
+ return await applicationGeneratorInternal(tree, {
24
+ useProjectJson: true,
25
+ ...schema,
26
+ });
27
+ }
28
+ async function applicationGeneratorInternal(tree, schema) {
23
29
  const tasks = [];
24
30
  const jsInitTask = await (0, js_1.initGenerator)(tree, {
25
31
  ...schema,
@@ -35,18 +41,19 @@ async function applicationGenerator(tree, schema) {
35
41
  const connectCloudUrl = onBoardingStatus === 'unclaimed' &&
36
42
  (await (0, onboarding_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
37
43
  tasks.push((0, ensure_dependencies_1.ensureDependencies)(tree, options));
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
- });
44
+ const packageJson = {
45
+ name: options.importPath,
46
+ version: '0.0.1',
47
+ private: true,
48
+ };
49
+ if (!options.useProjectJson) {
50
+ if (options.projectName !== options.importPath) {
51
+ packageJson.nx = { name: options.projectName };
52
+ }
53
+ if (options.parsedTags?.length) {
54
+ packageJson.nx ??= {};
55
+ packageJson.nx.tags = options.parsedTags;
56
+ }
50
57
  }
51
58
  else {
52
59
  (0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
@@ -57,6 +64,9 @@ async function applicationGenerator(tree, schema) {
57
64
  targets: {},
58
65
  });
59
66
  }
67
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
68
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
69
+ }
60
70
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, './files/base'), options.appProjectRoot, {
61
71
  ...options,
62
72
  offsetFromRoot: projectOffsetFromRoot,
@@ -88,6 +98,11 @@ async function applicationGenerator(tree, schema) {
88
98
  isUsingTsSolutionConfig: options.isUsingTsSolutionConfig,
89
99
  }, (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot));
90
100
  (0, update_gitignore_1.updateGitIgnore)(tree);
101
+ // If we are using the new TS solution
102
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
103
+ if (options.isUsingTsSolutionConfig) {
104
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
105
+ }
91
106
  tasks.push(await (0, add_linting_1.addLinting)(tree, {
92
107
  projectName: options.projectName,
93
108
  projectRoot: options.appProjectRoot,
@@ -121,11 +136,6 @@ async function applicationGenerator(tree, schema) {
121
136
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
122
137
  : undefined);
123
138
  }
124
- // If we are using the new TS solution
125
- // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
126
- if (options.isUsingTsSolutionConfig) {
127
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
128
- }
129
139
  (0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
130
140
  if (!options.skipFormat)
131
141
  await (0, devkit_1.formatFiles)(tree);
@@ -10,17 +10,15 @@ async function addE2e(host, options) {
10
10
  const e2eWebServerInfo = await getNuxtE2EWebServerInfo(host, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `nuxt.config.${options.js ? 'js' : 'ts'}`));
11
11
  if (options.e2eTestRunner === 'cypress') {
12
12
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
13
- if (options.isUsingTsSolutionConfig) {
14
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
15
- name: options.e2eProjectName,
16
- version: '0.0.1',
17
- private: true,
18
- nx: {
19
- projectType: 'application',
20
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
21
- implicitDependencies: [options.projectName],
22
- },
23
- });
13
+ const packageJson = {
14
+ name: options.e2eProjectName,
15
+ version: '0.0.1',
16
+ private: true,
17
+ };
18
+ if (!options.useProjectJson) {
19
+ packageJson.nx = {
20
+ implicitDependencies: [options.projectName],
21
+ };
24
22
  }
25
23
  else {
26
24
  (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
@@ -32,6 +30,9 @@ async function addE2e(host, options) {
32
30
  implicitDependencies: [options.projectName],
33
31
  });
34
32
  }
33
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
34
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
35
+ }
35
36
  const e2eTask = await configurationGenerator(host, {
36
37
  ...options,
37
38
  project: options.e2eProjectName,
@@ -58,17 +59,15 @@ async function addE2e(host, options) {
58
59
  }
59
60
  else if (options.e2eTestRunner === 'playwright') {
60
61
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
61
- if (options.isUsingTsSolutionConfig) {
62
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
63
- name: options.e2eProjectName,
64
- version: '0.0.1',
65
- private: true,
66
- nx: {
67
- projectType: 'application',
68
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
69
- implicitDependencies: [options.projectName],
70
- },
71
- });
62
+ const packageJson = {
63
+ name: options.e2eProjectName,
64
+ version: '0.0.1',
65
+ private: true,
66
+ };
67
+ if (!options.useProjectJson) {
68
+ packageJson.nx = {
69
+ implicitDependencies: [options.projectName],
70
+ };
72
71
  }
73
72
  else {
74
73
  (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
@@ -79,6 +78,9 @@ async function addE2e(host, options) {
79
78
  implicitDependencies: [options.projectName],
80
79
  });
81
80
  }
81
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
82
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
83
+ }
82
84
  const e2eTask = await configurationGenerator(host, {
83
85
  project: options.e2eProjectName,
84
86
  skipFormat: true,
@@ -1,18 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = normalizeOptions;
4
- const devkit_1 = require("@nx/devkit");
5
4
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
5
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
6
  async function normalizeOptions(host, options) {
8
- await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
9
- const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
7
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
8
+ const { projectName, names: projectNames, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
10
9
  name: options.name,
11
10
  projectType: 'application',
12
11
  directory: options.directory,
13
12
  rootProject: options.rootProject,
14
13
  });
15
14
  options.rootProject = appProjectRoot === '.';
15
+ const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
16
+ const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
16
17
  const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
17
18
  const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
18
19
  const parsedTags = options.tags
@@ -20,14 +21,16 @@ async function normalizeOptions(host, options) {
20
21
  : [];
21
22
  const normalized = {
22
23
  ...options,
23
- name: (0, devkit_1.names)(options.name).fileName,
24
+ name: projectNames.projectFileName,
24
25
  projectName: appProjectName,
25
26
  appProjectRoot,
27
+ importPath,
26
28
  e2eProjectName,
27
29
  e2eProjectRoot,
28
30
  parsedTags,
29
31
  style: options.style ?? 'none',
30
- isUsingTsSolutionConfig: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
32
+ isUsingTsSolutionConfig,
33
+ useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
31
34
  };
32
35
  normalized.unitTestRunner ??= 'vitest';
33
36
  normalized.e2eTestRunner = normalized.e2eTestRunner ?? 'playwright';
@@ -16,11 +16,13 @@ export interface Schema {
16
16
  style?: 'css' | 'scss' | 'less' | 'none';
17
17
  nxCloudToken?: string;
18
18
  useTsSolution?: boolean;
19
+ useProjectJson?: boolean;
19
20
  }
20
21
 
21
- export interface NormalizedSchema extends Schema {
22
+ export interface NormalizedSchema extends Omit<Schema, 'useTsSolution'> {
22
23
  projectName: string;
23
24
  appProjectRoot: string;
25
+ importPath: string;
24
26
  e2eProjectName: string;
25
27
  e2eProjectRoot: string;
26
28
  parsedTags: string[];
@@ -106,6 +106,10 @@
106
106
  "type": "boolean",
107
107
  "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
108
108
  "default": false
109
+ },
110
+ "useProjectJson": {
111
+ "type": "boolean",
112
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
109
113
  }
110
114
  },
111
115
  "required": ["directory"],