@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 +1 -1
- package/README.md +1 -1
- package/generators.json +1 -1
- package/migrations.json +1 -20
- package/package.json +15 -10
- package/plugin.d.ts +1 -1
- package/plugin.js +2 -1
- package/src/generators/application/application.d.ts +1 -0
- package/src/generators/application/application.js +62 -14
- package/src/generators/application/files/base/nuxt.config.ts__tmpl__ +2 -2
- package/src/generators/application/files/base/src/server/tsconfig.json__tmpl__ +1 -1
- package/src/generators/application/lib/add-e2e.js +47 -30
- package/src/generators/application/lib/normalize-options.d.ts +1 -2
- package/src/generators/application/lib/normalize-options.js +10 -16
- package/src/generators/application/schema.d.ts +8 -5
- package/src/generators/application/schema.json +30 -23
- package/src/generators/init/init.js +3 -1
- package/src/plugins/plugin.d.ts +4 -2
- package/src/plugins/plugin.js +30 -12
- package/src/utils/add-linting.js +7 -4
- package/src/utils/create-ts-config.d.ts +1 -0
- package/src/utils/create-ts-config.js +1 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
[](https://circleci.com/gh/nrwl/nx)
|
|
11
11
|
[]()
|
|
12
|
-
[](https://www.npmjs.com/package/nx)
|
|
13
13
|
[]()
|
|
14
14
|
[](http://commitizen.github.io/cz-cli/)
|
|
15
15
|
[](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-
|
|
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-
|
|
35
|
-
"@nx/js": "0.0.0-pr-
|
|
36
|
-
"@nx/eslint": "0.0.0-pr-
|
|
37
|
-
"@nx/vue": "0.0.0-pr-
|
|
38
|
-
"@nx/vite": "0.0.0-pr-
|
|
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
|
-
".":
|
|
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
|
-
"
|
|
53
|
-
"
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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 ??
|
|
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:
|
|
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()
|
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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.
|
|
62
|
-
webServerCommand: e2eWebServerInfo.
|
|
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
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
25
|
-
const
|
|
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:
|
|
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
|
-
|
|
6
|
-
|
|
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
|
-
"
|
|
10
|
-
"description": "The
|
|
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": "
|
|
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
|
-
"
|
|
21
|
-
"description": "The
|
|
19
|
+
"name": {
|
|
20
|
+
"description": "The name of the application.",
|
|
22
21
|
"type": "string",
|
|
23
|
-
"
|
|
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
|
-
{
|
|
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
|
-
{
|
|
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.
|
|
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) {
|
package/src/plugins/plugin.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
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>;
|
package/src/plugins/plugin.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNodes = exports.
|
|
3
|
+
exports.createNodes = exports.createNodesV2 = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
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
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
exports.
|
|
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
|
-
|
|
122
|
-
|
|
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'
|
package/src/utils/add-linting.js
CHANGED
|
@@ -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
|
|
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);
|
|
@@ -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',
|