@nx/nuxt 0.0.0-pr-31222-862e973 → 0.0.0-pr-31313-387cdca

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2024 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2025 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
11
  [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
- [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nx/workspace)
12
+ [![NPM Version](https://badge.fury.io/js/nx.svg)](https://www.npmjs.com/package/nx)
13
13
  [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
14
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
15
  [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
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/migrations.json CHANGED
@@ -7,24 +7,5 @@
7
7
  "implementation": "./src/migrations/update-19-6-0/add-vue-plugin-to-storybook-config"
8
8
  }
9
9
  },
10
- "packageJsonUpdates": {
11
- "18.2.0": {
12
- "version": "18.2.0-beta.0",
13
- "packages": {
14
- "@nuxt/eslint-config": {
15
- "version": "~0.3.0-alpha.1",
16
- "alwaysAddToPackageJson": false
17
- }
18
- }
19
- },
20
- "18.3.0": {
21
- "version": "18.3.0-beta.2",
22
- "packages": {
23
- "@nuxt/eslint-config": {
24
- "version": "~0.3.6",
25
- "alwaysAddToPackageJson": false
26
- }
27
- }
28
- }
29
- }
10
+ "packageJsonUpdates": {}
30
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/nuxt",
3
- "version": "0.0.0-pr-31222-862e973",
3
+ "version": "0.0.0-pr-31313-387cdca",
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,24 +31,29 @@
31
31
  "dependencies": {
32
32
  "tslib": "^2.3.0",
33
33
  "@nuxt/kit": "^3.10.0",
34
- "@nx/devkit": "0.0.0-pr-31222-862e973",
35
- "@nx/js": "0.0.0-pr-31222-862e973",
36
- "@nx/eslint": "0.0.0-pr-31222-862e973",
37
- "@nx/vue": "0.0.0-pr-31222-862e973",
38
- "@nx/vite": "0.0.0-pr-31222-862e973",
34
+ "@nx/devkit": "0.0.0-pr-31313-387cdca",
35
+ "@nx/js": "0.0.0-pr-31313-387cdca",
36
+ "@nx/eslint": "0.0.0-pr-31313-387cdca",
37
+ "@nx/vue": "0.0.0-pr-31313-387cdca",
38
+ "@nx/vite": "0.0.0-pr-31313-387cdca",
39
39
  "@phenomnomnominal/tsquery": "~5.0.1"
40
40
  },
41
- "peerDependencies": {},
41
+ "peerDependencies": {
42
+ "@nuxt/schema": "^3.10.0"
43
+ },
42
44
  "publishConfig": {
43
45
  "access": "public"
44
46
  },
45
47
  "exports": {
46
48
  "./package.json": "./package.json",
47
- ".": "./index.js",
49
+ ".": {
50
+ "types": "./index.d.ts",
51
+ "default": "./index.js"
52
+ },
48
53
  "./generators.json": "./generators.json",
49
54
  "./migrations.json": "./migrations.json",
50
55
  "./plugin": "./plugin.js"
51
56
  },
52
- "type": "commonjs",
53
- "types": "./index.d.ts"
57
+ "types": "./index.d.ts",
58
+ "type": "commonjs"
54
59
  }
package/plugin.d.ts CHANGED
@@ -1 +1 @@
1
- export { createNodes, NuxtPluginOptions } from './src/plugins/plugin';
1
+ export { createNodes, createNodesV2, NuxtPluginOptions, } from './src/plugins/plugin';
package/plugin.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = void 0;
3
+ exports.createNodesV2 = exports.createNodes = void 0;
4
4
  var plugin_1 = require("./src/plugins/plugin");
5
5
  Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
6
+ Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
@@ -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,13 +1,13 @@
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");
7
8
  const create_ts_config_1 = require("../../utils/create-ts-config");
8
9
  const js_1 = require("@nx/js");
9
10
  const update_gitignore_1 = require("../../utils/update-gitignore");
10
- const eslint_1 = require("@nx/eslint");
11
11
  const add_e2e_1 = require("./lib/add-e2e");
12
12
  const add_linting_1 = require("../../utils/add-linting");
13
13
  const add_vitest_1 = require("./lib/add-vitest");
@@ -16,26 +16,56 @@ const ensure_dependencies_1 = require("./lib/ensure-dependencies");
16
16
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
17
17
  const node_child_process_1 = require("node:child_process");
18
18
  const onboarding_1 = require("nx/src/nx-cloud/utilities/onboarding");
19
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
20
+ const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
19
21
  async function applicationGenerator(tree, schema) {
22
+ return await applicationGeneratorInternal(tree, {
23
+ useProjectJson: true,
24
+ ...schema,
25
+ });
26
+ }
27
+ async function applicationGeneratorInternal(tree, schema) {
20
28
  const tasks = [];
21
- const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
22
- const projectOffsetFromRoot = (0, devkit_1.offsetFromRoot)(options.appProjectRoot);
23
- const onBoardingStatus = await (0, onboarding_1.createNxCloudOnboardingURLForWelcomeApp)(tree, options.nxCloudToken);
24
- const connectCloudUrl = onBoardingStatus === 'unclaimed' &&
25
- (await (0, onboarding_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
26
29
  const jsInitTask = await (0, js_1.initGenerator)(tree, {
27
30
  ...schema,
28
31
  tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
29
32
  skipFormat: true,
33
+ addTsPlugin: schema.useTsSolution,
34
+ platform: 'web',
30
35
  });
31
36
  tasks.push(jsInitTask);
37
+ const options = await (0, normalize_options_1.normalizeOptions)(tree, schema);
38
+ const projectOffsetFromRoot = (0, devkit_1.offsetFromRoot)(options.appProjectRoot);
39
+ const onBoardingStatus = await (0, onboarding_1.createNxCloudOnboardingURLForWelcomeApp)(tree, options.nxCloudToken);
40
+ const connectCloudUrl = onBoardingStatus === 'unclaimed' &&
41
+ (await (0, onboarding_1.getNxCloudAppOnBoardingUrl)(options.nxCloudToken));
32
42
  tasks.push((0, ensure_dependencies_1.ensureDependencies)(tree, options));
33
- (0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
34
- root: options.appProjectRoot,
35
- projectType: 'application',
36
- sourceRoot: `${options.appProjectRoot}/src`,
37
- targets: {},
38
- });
43
+ const packageJson = {
44
+ name: options.importPath,
45
+ version: '0.0.1',
46
+ private: true,
47
+ };
48
+ if (!options.useProjectJson) {
49
+ if (options.projectName !== options.importPath) {
50
+ packageJson.nx = { name: options.projectName };
51
+ }
52
+ if (options.parsedTags?.length) {
53
+ packageJson.nx ??= {};
54
+ packageJson.nx.tags = options.parsedTags;
55
+ }
56
+ }
57
+ else {
58
+ (0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
59
+ root: options.appProjectRoot,
60
+ projectType: 'application',
61
+ sourceRoot: `${options.appProjectRoot}/src`,
62
+ tags: options.parsedTags?.length ? options.parsedTags : undefined,
63
+ targets: {},
64
+ });
65
+ }
66
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
67
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
68
+ }
39
69
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, './files/base'), options.appProjectRoot, {
40
70
  ...options,
41
71
  offsetFromRoot: projectOffsetFromRoot,
@@ -64,12 +94,18 @@ async function applicationGenerator(tree, schema) {
64
94
  projectRoot: options.appProjectRoot,
65
95
  rootProject: options.rootProject,
66
96
  unitTestRunner: options.unitTestRunner,
97
+ isUsingTsSolutionConfig: options.isUsingTsSolutionConfig,
67
98
  }, (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot));
68
99
  (0, update_gitignore_1.updateGitIgnore)(tree);
100
+ // If we are using the new TS solution
101
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
102
+ if (options.isUsingTsSolutionConfig) {
103
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(tree, options.appProjectRoot);
104
+ }
69
105
  tasks.push(await (0, add_linting_1.addLinting)(tree, {
70
106
  projectName: options.projectName,
71
107
  projectRoot: options.appProjectRoot,
72
- linter: options.linter ?? eslint_1.Linter.EsLint,
108
+ linter: options.linter ?? 'eslint',
73
109
  unitTestRunner: options.unitTestRunner,
74
110
  rootProject: options.rootProject,
75
111
  }));
@@ -88,13 +124,25 @@ async function applicationGenerator(tree, schema) {
88
124
  tasks.push(await (0, add_e2e_1.addE2e)(tree, options));
89
125
  if (options.js)
90
126
  (0, devkit_1.toJS)(tree);
127
+ if (options.isUsingTsSolutionConfig) {
128
+ (0, ts_solution_setup_1.updateTsconfigFiles)(tree, options.appProjectRoot, 'tsconfig.app.json', {
129
+ jsx: 'preserve',
130
+ jsxImportSource: 'vue',
131
+ module: 'esnext',
132
+ moduleResolution: 'bundler',
133
+ resolveJsonModule: true,
134
+ }, options.linter === 'eslint'
135
+ ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
136
+ : undefined);
137
+ }
138
+ (0, sort_fields_1.sortPackageJsonFields)(tree, options.appProjectRoot);
91
139
  if (!options.skipFormat)
92
140
  await (0, devkit_1.formatFiles)(tree);
93
141
  tasks.push(() => {
94
142
  try {
95
143
  (0, node_child_process_1.execSync)(`npx -y nuxi prepare`, {
96
144
  cwd: options.appProjectRoot,
97
- windowsHide: true,
145
+ windowsHide: false,
98
146
  });
99
147
  }
100
148
  catch (e) {
@@ -19,9 +19,9 @@ export default defineNuxtConfig({
19
19
  imports: {
20
20
  autoImport: true,
21
21
  },
22
- <% if (style !== 'none') { %>
22
+ <%_ if (style !== 'none') { _%>
23
23
  css: ['~/assets/css/styles.<%= style %>'],
24
- <% } %>
24
+ <%_ } _%>
25
25
  vite: {
26
26
  plugins: [
27
27
  nxViteTsPaths()
@@ -1,3 +1,3 @@
1
1
  {
2
- "extends": "../.nuxt/tsconfig.server.json"
2
+ "extends": "../../.nuxt/tsconfig.server.json"
3
3
  }
@@ -4,20 +4,33 @@ exports.addE2e = addE2e;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const e2e_web_server_info_utils_1 = require("@nx/devkit/src/generators/e2e-web-server-info-utils");
6
6
  const versions_1 = require("../../../utils/versions");
7
- const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
8
- const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
9
7
  async function addE2e(host, options) {
10
8
  const e2eWebServerInfo = await getNuxtE2EWebServerInfo(host, options.projectName, (0, devkit_1.joinPathFragments)(options.appProjectRoot, `nuxt.config.${options.js ? 'js' : 'ts'}`));
11
9
  if (options.e2eTestRunner === 'cypress') {
12
10
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
13
- (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
14
- projectType: 'application',
15
- root: options.e2eProjectRoot,
16
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
17
- targets: {},
18
- tags: [],
19
- implicitDependencies: [options.projectName],
20
- });
11
+ const packageJson = {
12
+ name: options.e2eProjectName,
13
+ version: '0.0.1',
14
+ private: true,
15
+ };
16
+ if (!options.useProjectJson) {
17
+ packageJson.nx = {
18
+ implicitDependencies: [options.projectName],
19
+ };
20
+ }
21
+ else {
22
+ (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
23
+ projectType: 'application',
24
+ root: options.e2eProjectRoot,
25
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
26
+ targets: {},
27
+ tags: [],
28
+ implicitDependencies: [options.projectName],
29
+ });
30
+ }
31
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
32
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
33
+ }
21
34
  const e2eTask = await configurationGenerator(host, {
22
35
  ...options,
23
36
  project: options.e2eProjectName,
@@ -34,22 +47,32 @@ async function addE2e(host, options) {
34
47
  jsx: true,
35
48
  addPlugin: true,
36
49
  });
37
- let buildTarget = '^build-static';
38
- const matchingPlugin = await (0, find_plugin_for_config_file_1.findPluginForConfigFile)(host, '@nx/nuxt/plugin', (0, devkit_1.joinPathFragments)(options.appProjectRoot, `nuxt.config.${options.js ? 'js' : 'ts'}`));
39
- if (matchingPlugin && typeof matchingPlugin !== 'string') {
40
- buildTarget = `^${matchingPlugin.options?.buildStaticTargetName ?? 'build-static'}`;
41
- }
42
- await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(host, '@nx/cypress/plugin', buildTarget, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, `cypress.config.${options.js ? 'js' : 'ts'}`));
43
50
  return e2eTask;
44
51
  }
45
52
  else if (options.e2eTestRunner === 'playwright') {
46
53
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
47
- (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
48
- root: options.e2eProjectRoot,
49
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
50
- targets: {},
51
- implicitDependencies: [options.projectName],
52
- });
54
+ const packageJson = {
55
+ name: options.e2eProjectName,
56
+ version: '0.0.1',
57
+ private: true,
58
+ };
59
+ if (!options.useProjectJson) {
60
+ packageJson.nx = {
61
+ implicitDependencies: [options.projectName],
62
+ };
63
+ }
64
+ else {
65
+ (0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
66
+ projectType: 'application',
67
+ root: options.e2eProjectRoot,
68
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
69
+ targets: {},
70
+ implicitDependencies: [options.projectName],
71
+ });
72
+ }
73
+ if (!options.useProjectJson || options.isUsingTsSolutionConfig) {
74
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
75
+ }
53
76
  const e2eTask = await configurationGenerator(host, {
54
77
  project: options.e2eProjectName,
55
78
  skipFormat: true,
@@ -58,16 +81,10 @@ async function addE2e(host, options) {
58
81
  js: false,
59
82
  linter: options.linter,
60
83
  setParserOptionsProject: options.setParserOptionsProject,
61
- webServerAddress: e2eWebServerInfo.e2eCiWebServerCommand,
62
- webServerCommand: e2eWebServerInfo.e2eCiBaseUrl,
84
+ webServerAddress: e2eWebServerInfo.e2eCiBaseUrl,
85
+ webServerCommand: e2eWebServerInfo.e2eCiWebServerCommand,
63
86
  addPlugin: true,
64
87
  });
65
- let buildTarget = '^build-static';
66
- const matchingPlugin = await (0, find_plugin_for_config_file_1.findPluginForConfigFile)(host, '@nx/nuxt/plugin', (0, devkit_1.joinPathFragments)(options.appProjectRoot, `nuxt.config.${options.js ? 'js' : 'ts'}`));
67
- if (matchingPlugin && typeof matchingPlugin !== 'string') {
68
- buildTarget = `^${matchingPlugin.options?.buildStaticTargetName ?? 'build-static'}`;
69
- }
70
- await (0, target_defaults_utils_1.addE2eCiTargetDefaults)(host, '@nx/playwright/plugin', buildTarget, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, `playwright.config.ts`));
71
88
  return e2eTask;
72
89
  }
73
90
  return () => { };
@@ -1,4 +1,3 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { NormalizedSchema, Schema } from '../schema';
3
- export declare function normalizeDirectory(options: Schema): string;
4
- export declare function normalizeOptions(host: Tree, options: Schema, callingGenerator?: string): Promise<NormalizedSchema>;
3
+ export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -1,28 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeDirectory = normalizeDirectory;
4
3
  exports.normalizeOptions = normalizeOptions;
5
- const devkit_1 = require("@nx/devkit");
6
4
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
7
- function normalizeDirectory(options) {
8
- options.directory = options.directory?.replace(/\\{1,2}/g, '/');
9
- const { projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
10
- return projectDirectory
11
- ? `${(0, devkit_1.names)(projectDirectory).fileName}/${(0, devkit_1.names)(options.name).fileName}`
12
- : (0, devkit_1.names)(options.name).fileName;
13
- }
14
- async function normalizeOptions(host, options, callingGenerator = '@nx/nuxt:application') {
15
- const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
+ async function normalizeOptions(host, options) {
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, {
16
9
  name: options.name,
17
10
  projectType: 'application',
18
11
  directory: options.directory,
19
- projectNameAndRootFormat: options.projectNameAndRootFormat,
20
12
  rootProject: options.rootProject,
21
- callingGenerator,
22
13
  });
23
14
  options.rootProject = appProjectRoot === '.';
24
- options.projectNameAndRootFormat = projectNameAndRootFormat;
25
- const nxJson = (0, devkit_1.readNxJson)(host);
15
+ const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
16
+ const appProjectName = !isUsingTsSolutionConfig || options.name ? projectName : importPath;
26
17
  const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
27
18
  const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
28
19
  const parsedTags = options.tags
@@ -30,13 +21,16 @@ async function normalizeOptions(host, options, callingGenerator = '@nx/nuxt:appl
30
21
  : [];
31
22
  const normalized = {
32
23
  ...options,
33
- name: (0, devkit_1.names)(options.name).fileName,
24
+ name: projectNames.projectFileName,
34
25
  projectName: appProjectName,
35
26
  appProjectRoot,
27
+ importPath,
36
28
  e2eProjectName,
37
29
  e2eProjectRoot,
38
30
  parsedTags,
39
31
  style: options.style ?? 'none',
32
+ isUsingTsSolutionConfig,
33
+ useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
40
34
  };
41
35
  normalized.unitTestRunner ??= 'vitest';
42
36
  normalized.e2eTestRunner = normalized.e2eTestRunner ?? 'playwright';
@@ -1,11 +1,10 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
 
4
3
  export interface Schema {
5
- name: string;
6
- directory?: string;
7
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
4
+ directory: string;
5
+ name?: string;
8
6
  linter?: Linter | LinterType;
7
+ formatter?: 'none' | 'prettier';
9
8
  skipFormat?: boolean;
10
9
  unitTestRunner?: 'vitest' | 'none';
11
10
  e2eTestRunner?: 'cypress' | 'playwright' | 'none';
@@ -16,12 +15,16 @@ export interface Schema {
16
15
  setParserOptionsProject?: boolean;
17
16
  style?: 'css' | 'scss' | 'less' | 'none';
18
17
  nxCloudToken?: string;
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[];
29
+ isUsingTsSolutionConfig: boolean;
27
30
  }
@@ -6,46 +6,43 @@
6
6
  "description": "Create a Nuxt Application for Nx.",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the application.",
9
+ "directory": {
10
+ "description": "The directory of the new application.",
11
11
  "type": "string",
12
+ "alias": "dir",
12
13
  "$default": {
13
14
  "$source": "argv",
14
15
  "index": 0
15
16
  },
16
- "x-prompt": "What name would you like to use for the application?",
17
- "pattern": "^[a-zA-Z][^:]*$",
18
- "x-priority": "important"
17
+ "x-prompt": "Which directory do you want to create the application in?"
19
18
  },
20
- "directory": {
21
- "description": "The directory of the new application.",
19
+ "name": {
20
+ "description": "The name of the application.",
22
21
  "type": "string",
23
- "alias": "dir",
22
+ "pattern": "^[a-zA-Z][^:]*$",
24
23
  "x-priority": "important"
25
24
  },
26
- "projectNameAndRootFormat": {
27
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
28
- "type": "string",
29
- "enum": ["as-provided", "derived"]
30
- },
31
- "linter": {
32
- "description": "The tool to use for running lint checks.",
33
- "type": "string",
34
- "enum": ["eslint"],
35
- "default": "eslint"
36
- },
37
25
  "skipFormat": {
38
26
  "description": "Skip formatting files.",
39
27
  "type": "boolean",
40
28
  "default": false,
41
29
  "x-priority": "internal"
42
30
  },
31
+ "linter": {
32
+ "description": "The tool to use for running lint checks.",
33
+ "type": "string",
34
+ "enum": ["eslint", "none"],
35
+ "default": "none",
36
+ "x-prompt": "Which linter would you like to use?",
37
+ "x-priority": "important"
38
+ },
43
39
  "unitTestRunner": {
44
40
  "type": "string",
45
41
  "enum": ["vitest", "none"],
46
42
  "description": "Test runner to use for unit tests.",
47
43
  "x-prompt": "Which unit test runner would you like to use?",
48
- "default": "none"
44
+ "default": "none",
45
+ "x-priority": "important"
49
46
  },
50
47
  "e2eTestRunner": {
51
48
  "type": "string",
@@ -86,7 +83,10 @@
86
83
  "message": "Which stylesheet format would you like to use?",
87
84
  "type": "list",
88
85
  "items": [
89
- { "value": "css", "label": "CSS" },
86
+ {
87
+ "value": "css",
88
+ "label": "CSS"
89
+ },
90
90
  {
91
91
  "value": "scss",
92
92
  "label": "SASS(.scss) [ https://sass-lang.com ]"
@@ -95,7 +95,10 @@
95
95
  "value": "less",
96
96
  "label": "LESS [ https://lesscss.org ]"
97
97
  },
98
- { "value": "none", "label": "None" }
98
+ {
99
+ "value": "none",
100
+ "label": "None"
101
+ }
99
102
  ]
100
103
  }
101
104
  },
@@ -103,8 +106,12 @@
103
106
  "type": "boolean",
104
107
  "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
105
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."
106
113
  }
107
114
  },
108
- "required": [],
115
+ "required": ["directory"],
109
116
  "examplesFile": "../../../docs/application-examples.md"
110
117
  }
@@ -6,9 +6,11 @@ const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
6
6
  const plugin_1 = require("../../plugins/plugin");
7
7
  const utils_1 = require("./lib/utils");
8
8
  async function nuxtInitGenerator(host, schema) {
9
- await (0, add_plugin_1.addPluginV1)(host, await (0, devkit_1.createProjectGraphAsync)(), '@nx/nuxt/plugin', plugin_1.createNodes, {
9
+ await (0, add_plugin_1.addPlugin)(host, await (0, devkit_1.createProjectGraphAsync)(), '@nx/nuxt/plugin', plugin_1.createNodesV2, {
10
10
  buildTargetName: ['build', 'nuxt:build', 'nuxt-build'],
11
11
  serveTargetName: ['serve', 'nuxt:serve', 'nuxt-serve'],
12
+ buildDepsTargetName: ['build-deps', 'nuxt:build-deps', 'nuxt-build-deps'],
13
+ watchDepsTargetName: ['watch-deps', 'nuxt:watch-deps', 'nuxt-watch-deps'],
12
14
  }, schema.updatePackageScripts);
13
15
  let installTask = () => { };
14
16
  if (!schema.skipPackageJson) {
@@ -1,9 +1,11 @@
1
- import { CreateDependencies, CreateNodes } from '@nx/devkit';
2
- export declare const createDependencies: CreateDependencies;
1
+ import { CreateNodes, CreateNodesV2 } from '@nx/devkit';
3
2
  export interface NuxtPluginOptions {
4
3
  buildTargetName?: string;
5
4
  serveTargetName?: string;
6
5
  serveStaticTargetName?: string;
7
6
  buildStaticTargetName?: string;
7
+ buildDepsTargetName?: string;
8
+ watchDepsTargetName?: string;
8
9
  }
10
+ export declare const createNodesV2: CreateNodesV2<NuxtPluginOptions>;
9
11
  export declare const createNodes: CreateNodes<NuxtPluginOptions>;
@@ -1,16 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = exports.createDependencies = void 0;
3
+ exports.createNodes = exports.createNodesV2 = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- const cache_directory_1 = require("nx/src/utils/cache-directory");
5
+ const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
7
6
  const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
8
- const fs_1 = require("fs");
9
7
  const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
8
+ const cache_directory_1 = require("nx/src/utils/cache-directory");
10
9
  const js_1 = require("@nx/js");
11
- const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
10
+ const path_1 = require("path");
11
+ const fs_1 = require("fs");
12
+ const executor_utils_1 = require("../utils/executor-utils");
13
+ const util_1 = require("@nx/js/src/plugins/typescript/util");
12
14
  const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'nuxt.hash');
13
15
  const targetsCache = readTargetsCache();
16
+ const pmc = (0, devkit_1.getPackageManagerCommand)();
14
17
  function readTargetsCache() {
15
18
  return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
16
19
  }
@@ -21,11 +24,15 @@ function writeTargetsToCache() {
21
24
  ...targetsCache,
22
25
  });
23
26
  }
24
- const createDependencies = () => {
25
- writeTargetsToCache();
26
- return [];
27
- };
28
- exports.createDependencies = createDependencies;
27
+ exports.createNodesV2 = [
28
+ '**/nuxt.config.{js,ts,mjs,mts,cjs,cts}',
29
+ async (files, options, context) => {
30
+ //TODO(@nrwl/nx-vue-reviewers): This should batch hashing like our other plugins.
31
+ const result = await (0, devkit_1.createNodesFromFiles)(exports.createNodes[1], files, options, context);
32
+ writeTargetsToCache();
33
+ return result;
34
+ },
35
+ ];
29
36
  exports.createNodes = [
30
37
  '**/nuxt.config.{js,ts,mjs,mts,cjs,cts}',
31
38
  async (configFilePath, options, context) => {
@@ -58,6 +65,7 @@ async function buildNuxtTargets(configFilePath, projectRoot, options, context) {
58
65
  targets[options.serveTargetName] = serveTarget(projectRoot);
59
66
  targets[options.serveStaticTargetName] = serveStaticTarget(options);
60
67
  targets[options.buildStaticTargetName] = buildStaticTarget(options.buildStaticTargetName, namedInputs, buildOutputs, projectRoot);
68
+ (0, util_1.addBuildAndWatchDepsTargets)(context.workspaceRoot, projectRoot, targets, options, pmc);
61
69
  return targets;
62
70
  }
63
71
  function buildTarget(buildTargetName, namedInputs, buildOutputs, projectRoot) {
@@ -83,11 +91,14 @@ function serveTarget(projectRoot) {
83
91
  options: {
84
92
  cwd: projectRoot,
85
93
  },
94
+ continuous: true,
86
95
  };
87
96
  return targetConfig;
88
97
  }
89
98
  function serveStaticTarget(options) {
90
99
  const targetConfig = {
100
+ dependsOn: [`${options.buildStaticTargetName}`],
101
+ continuous: true,
91
102
  executor: '@nx/web:file-server',
92
103
  options: {
93
104
  buildTarget: `${options.buildStaticTargetName}`,
@@ -118,8 +129,15 @@ function buildStaticTarget(buildStaticTargetName, namedInputs, buildOutputs, pro
118
129
  return targetConfig;
119
130
  }
120
131
  async function getInfoFromNuxtConfig(configFilePath, context, projectRoot) {
121
- // TODO(Colum): Once plugins are isolated we can go back to @nuxt/kit since each plugin will be run in its own worker.
122
- const config = await (0, config_utils_1.loadConfigFile)((0, path_1.join)(context.workspaceRoot, configFilePath));
132
+ let config;
133
+ if (process.env.NX_ISOLATE_PLUGINS !== 'false') {
134
+ config = await (await (0, executor_utils_1.loadNuxtKitDynamicImport)()).loadNuxtConfig({
135
+ configFile: configFilePath,
136
+ });
137
+ }
138
+ else {
139
+ config = await (0, config_utils_1.loadConfigFile)((0, path_1.join)(context.workspaceRoot, configFilePath));
140
+ }
123
141
  return {
124
142
  buildDir: config?.buildDir ??
125
143
  // Match .nuxt default build dir from '@nuxt/schema'
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLinting = addLinting;
4
4
  const eslint_1 = require("@nx/eslint");
5
+ const versions_1 = require("@nx/eslint/src/utils/versions");
5
6
  const path_1 = require("nx/src/utils/path");
6
7
  const devkit_1 = require("@nx/devkit");
7
8
  const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
8
- const versions_1 = require("./versions");
9
+ const versions_2 = require("./versions");
9
10
  const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
10
11
  // TODO(colum): Look into the recommended set up using `withNuxt` inside eslint.config.mjs. https://eslint.nuxt.com/packages/config
11
12
  async function addLinting(host, options) {
@@ -21,6 +22,9 @@ async function addLinting(host, options) {
21
22
  addPlugin: true,
22
23
  });
23
24
  tasks.push(lintTask);
25
+ const devDependencies = {
26
+ '@nuxt/eslint-config': versions_2.nuxtEslintConfigVersion,
27
+ };
24
28
  if ((0, eslint_file_1.isEslintConfigSupported)(host, options.projectRoot)) {
25
29
  editEslintConfigFiles(host, options.projectRoot);
26
30
  const addExtendsTask = (0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, ['@nuxt/eslint-config'], true);
@@ -33,6 +37,7 @@ async function addLinting(host, options) {
33
37
  },
34
38
  } // languageOptions is not in eslintrc format but for flat config
35
39
  );
40
+ devDependencies['@typescript-eslint/parser'] = versions_1.typescriptESLintVersion;
36
41
  }
37
42
  (0, eslint_file_1.addIgnoresToLintConfig)(host, options.projectRoot, [
38
43
  '.nuxt/**',
@@ -40,9 +45,7 @@ async function addLinting(host, options) {
40
45
  'node_modules',
41
46
  ]);
42
47
  }
43
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
44
- '@nuxt/eslint-config': versions_1.nuxtEslintConfigVersion,
45
- });
48
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies);
46
49
  tasks.push(installTask);
47
50
  }
48
51
  return (0, devkit_1.runTasksInSerial)(...tasks);
@@ -3,4 +3,5 @@ export declare function createTsConfig(host: Tree, options: {
3
3
  projectRoot: string;
4
4
  rootProject?: boolean;
5
5
  unitTestRunner?: string;
6
+ isUsingTsSolutionConfig: boolean;
6
7
  }, relativePathToRootTsConfig: string): void;
@@ -6,9 +6,8 @@ const shared = require("@nx/js/src/utils/typescript/create-ts-config");
6
6
  function createTsConfig(host, options, relativePathToRootTsConfig) {
7
7
  createAppTsConfig(host, options);
8
8
  const json = {
9
- compilerOptions: {},
10
9
  files: [],
11
- include: ['.nuxt/nuxt.d.ts'],
10
+ include: options.isUsingTsSolutionConfig ? undefined : ['.nuxt/nuxt.d.ts'],
12
11
  references: [
13
12
  {
14
13
  path: './tsconfig.app.json',