@nx/nuxt 17.3.0-beta.3
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 +22 -0
- package/README.md +68 -0
- package/generators.json +26 -0
- package/index.d.ts +4 -0
- package/index.js +9 -0
- package/migrations.json +4 -0
- package/package.json +50 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +5 -0
- package/src/generators/application/application.d.ts +4 -0
- package/src/generators/application/application.js +73 -0
- package/src/generators/application/files/__dot__npmrc +2 -0
- package/src/generators/application/files/nuxt.config.ts__tmpl__ +36 -0
- package/src/generators/application/files/src/app.vue__tmpl__ +48 -0
- package/src/generators/application/files/src/assets/css/styles.__style__ +41 -0
- package/src/generators/application/files/src/components/NxWelcome.vue__tmpl__ +824 -0
- package/src/generators/application/files/src/pages/about.vue__tmpl__ +16 -0
- package/src/generators/application/files/src/pages/index.vue__tmpl__ +6 -0
- package/src/generators/application/files/src/public/__dot__gitkeep +0 -0
- package/src/generators/application/files/src/public/favicon.ico__tmpl__ +0 -0
- package/src/generators/application/files/src/server/api/greet.ts__tmpl__ +10 -0
- package/src/generators/application/files/src/server/tsconfig.json__tmpl__ +3 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +50 -0
- package/src/generators/application/lib/add-vitest.d.ts +3 -0
- package/src/generators/application/lib/add-vitest.js +37 -0
- package/src/generators/application/lib/normalize-options.d.ts +4 -0
- package/src/generators/application/lib/normalize-options.js +44 -0
- package/src/generators/application/schema.d.ts +26 -0
- package/src/generators/application/schema.json +110 -0
- package/src/generators/init/init.d.ts +4 -0
- package/src/generators/init/init.js +22 -0
- package/src/generators/init/lib/utils.d.ts +5 -0
- package/src/generators/init/lib/utils.js +76 -0
- package/src/generators/init/schema.d.ts +6 -0
- package/src/generators/init/schema.json +31 -0
- package/src/generators/storybook-configuration/configuration.d.ts +4 -0
- package/src/generators/storybook-configuration/configuration.js +28 -0
- package/src/generators/storybook-configuration/schema.d.ts +12 -0
- package/src/generators/storybook-configuration/schema.json +80 -0
- package/src/plugins/plugin.d.ts +7 -0
- package/src/plugins/plugin.js +140 -0
- package/src/utils/add-linting.d.ts +10 -0
- package/src/utils/add-linting.js +30 -0
- package/src/utils/create-ts-config.d.ts +6 -0
- package/src/utils/create-ts-config.js +47 -0
- package/src/utils/executor-utils.d.ts +1 -0
- package/src/utils/executor-utils.js +7 -0
- package/src/utils/lint.d.ts +7 -0
- package/src/utils/lint.js +19 -0
- package/src/utils/update-gitignore.d.ts +2 -0
- package/src/utils/update-gitignore.js +23 -0
- package/src/utils/versions.d.ts +6 -0
- package/src/utils/versions.js +11 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="about">
|
|
3
|
+
<h1>This is an about page.</h1>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<style>
|
|
8
|
+
@media (min-width: 768px) {
|
|
9
|
+
.about {
|
|
10
|
+
max-width: 768px;
|
|
11
|
+
margin-left: auto;
|
|
12
|
+
margin-right: auto;
|
|
13
|
+
padding: 0 1rem;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addE2e = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../../utils/versions");
|
|
6
|
+
async function addE2e(host, options) {
|
|
7
|
+
if (options.e2eTestRunner === 'cypress') {
|
|
8
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
|
|
9
|
+
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
10
|
+
projectType: 'application',
|
|
11
|
+
root: options.e2eProjectRoot,
|
|
12
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
13
|
+
targets: {},
|
|
14
|
+
tags: [],
|
|
15
|
+
implicitDependencies: [options.projectName],
|
|
16
|
+
});
|
|
17
|
+
return await configurationGenerator(host, {
|
|
18
|
+
...options,
|
|
19
|
+
project: options.e2eProjectName,
|
|
20
|
+
directory: 'src',
|
|
21
|
+
bundler: 'vite',
|
|
22
|
+
skipFormat: true,
|
|
23
|
+
devServerTarget: `${options.projectName}:serve`,
|
|
24
|
+
baseUrl: 'http://localhost:4200',
|
|
25
|
+
jsx: true,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else if (options.e2eTestRunner === 'playwright') {
|
|
29
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
|
|
30
|
+
(0, devkit_1.addProjectConfiguration)(host, options.e2eProjectName, {
|
|
31
|
+
root: options.e2eProjectRoot,
|
|
32
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
|
|
33
|
+
targets: {},
|
|
34
|
+
implicitDependencies: [options.projectName],
|
|
35
|
+
});
|
|
36
|
+
return configurationGenerator(host, {
|
|
37
|
+
project: options.e2eProjectName,
|
|
38
|
+
skipFormat: true,
|
|
39
|
+
skipPackageJson: options.skipPackageJson,
|
|
40
|
+
directory: 'src',
|
|
41
|
+
js: false,
|
|
42
|
+
linter: options.linter,
|
|
43
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
44
|
+
webServerAddress: 'http://localhost:4200',
|
|
45
|
+
webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.projectName}`,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return () => { };
|
|
49
|
+
}
|
|
50
|
+
exports.addE2e = addE2e;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addVitest = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const utils_1 = require("../../init/lib/utils");
|
|
6
|
+
const versions_1 = require("../../../utils/versions");
|
|
7
|
+
async function addVitest(tree, options) {
|
|
8
|
+
(0, utils_1.addVitestTargetDefaults)(tree);
|
|
9
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
10
|
+
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
11
|
+
? p === '@nx/nuxt/plugin'
|
|
12
|
+
: p.plugin === '@nx/nuxt/plugin');
|
|
13
|
+
const { createOrEditViteConfig, vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
14
|
+
const vitestTask = await vitestGenerator(tree, {
|
|
15
|
+
project: options.name,
|
|
16
|
+
uiFramework: 'none',
|
|
17
|
+
coverageProvider: 'v8',
|
|
18
|
+
skipFormat: true,
|
|
19
|
+
testEnvironment: 'jsdom',
|
|
20
|
+
skipViteConfig: true,
|
|
21
|
+
}, hasPlugin);
|
|
22
|
+
createOrEditViteConfig(tree, {
|
|
23
|
+
project: options.name,
|
|
24
|
+
includeLib: false,
|
|
25
|
+
includeVitest: true,
|
|
26
|
+
testEnvironment: 'jsdom',
|
|
27
|
+
imports: [`import vue from '@vitejs/plugin-vue'`],
|
|
28
|
+
plugins: ['vue()'],
|
|
29
|
+
}, true, undefined, true);
|
|
30
|
+
(0, devkit_1.updateJson)(tree, `${options.appProjectRoot}/tsconfig.spec.json`, (json) => {
|
|
31
|
+
json.compilerOptions ??= {};
|
|
32
|
+
json.compilerOptions.composite = true;
|
|
33
|
+
return json;
|
|
34
|
+
});
|
|
35
|
+
return vitestTask;
|
|
36
|
+
}
|
|
37
|
+
exports.addVitest = addVitest;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
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>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeOptions = exports.normalizeDirectory = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
|
+
function normalizeDirectory(options) {
|
|
7
|
+
options.directory = options.directory?.replace(/\\{1,2}/g, '/');
|
|
8
|
+
const { projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
|
|
9
|
+
return projectDirectory
|
|
10
|
+
? `${(0, devkit_1.names)(projectDirectory).fileName}/${(0, devkit_1.names)(options.name).fileName}`
|
|
11
|
+
: (0, devkit_1.names)(options.name).fileName;
|
|
12
|
+
}
|
|
13
|
+
exports.normalizeDirectory = normalizeDirectory;
|
|
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, {
|
|
16
|
+
name: options.name,
|
|
17
|
+
projectType: 'application',
|
|
18
|
+
directory: options.directory,
|
|
19
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
20
|
+
rootProject: options.rootProject,
|
|
21
|
+
callingGenerator,
|
|
22
|
+
});
|
|
23
|
+
options.rootProject = appProjectRoot === '.';
|
|
24
|
+
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
25
|
+
const e2eProjectName = options.rootProject ? 'e2e' : `${appProjectName}-e2e`;
|
|
26
|
+
const e2eProjectRoot = options.rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
27
|
+
const parsedTags = options.tags
|
|
28
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
29
|
+
: [];
|
|
30
|
+
const normalized = {
|
|
31
|
+
...options,
|
|
32
|
+
name: (0, devkit_1.names)(options.name).fileName,
|
|
33
|
+
projectName: appProjectName,
|
|
34
|
+
appProjectRoot,
|
|
35
|
+
e2eProjectName,
|
|
36
|
+
e2eProjectRoot,
|
|
37
|
+
parsedTags,
|
|
38
|
+
style: options.style ?? 'none',
|
|
39
|
+
};
|
|
40
|
+
normalized.unitTestRunner ??= 'vitest';
|
|
41
|
+
normalized.e2eTestRunner = normalized.e2eTestRunner ?? 'cypress';
|
|
42
|
+
return normalized;
|
|
43
|
+
}
|
|
44
|
+
exports.normalizeOptions = normalizeOptions;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { Linter } from '@nx/eslint';
|
|
3
|
+
|
|
4
|
+
export interface Schema {
|
|
5
|
+
name: string;
|
|
6
|
+
directory?: string;
|
|
7
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
8
|
+
linter?: Linter;
|
|
9
|
+
skipFormat?: boolean;
|
|
10
|
+
unitTestRunner?: 'vitest' | 'none';
|
|
11
|
+
e2eTestRunner?: 'cypress' | 'playwright' | 'none';
|
|
12
|
+
tags?: string;
|
|
13
|
+
js?: boolean;
|
|
14
|
+
skipPackageJson?: boolean;
|
|
15
|
+
rootProject?: boolean;
|
|
16
|
+
setParserOptionsProject?: boolean;
|
|
17
|
+
style?: 'css' | 'scss' | 'less' | 'none';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface NormalizedSchema extends Schema {
|
|
21
|
+
projectName: string;
|
|
22
|
+
appProjectRoot: string;
|
|
23
|
+
e2eProjectName: string;
|
|
24
|
+
e2eProjectRoot: string;
|
|
25
|
+
parsedTags: string[];
|
|
26
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxNuxtApp",
|
|
5
|
+
"title": "Create a Nuxt Application for Nx",
|
|
6
|
+
"description": "Create a Nuxt Application for Nx.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"description": "The name of the application.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-prompt": "What name would you like to use for the application?",
|
|
17
|
+
"pattern": "^[a-zA-Z][^:]*$",
|
|
18
|
+
"x-priority": "important"
|
|
19
|
+
},
|
|
20
|
+
"directory": {
|
|
21
|
+
"description": "The directory of the new application.",
|
|
22
|
+
"type": "string",
|
|
23
|
+
"alias": "dir",
|
|
24
|
+
"x-priority": "important"
|
|
25
|
+
},
|
|
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
|
+
"skipFormat": {
|
|
38
|
+
"description": "Skip formatting files.",
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"default": false,
|
|
41
|
+
"x-priority": "internal"
|
|
42
|
+
},
|
|
43
|
+
"unitTestRunner": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"enum": ["vitest", "none"],
|
|
46
|
+
"description": "Test runner to use for unit tests.",
|
|
47
|
+
"x-prompt": "Which unit test runner would you like to use?",
|
|
48
|
+
"default": "none"
|
|
49
|
+
},
|
|
50
|
+
"e2eTestRunner": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"enum": ["cypress", "playwright", "none"],
|
|
53
|
+
"description": "Test runner to use for end to end (E2E) tests.",
|
|
54
|
+
"x-prompt": "Which E2E test runner would you like to use?",
|
|
55
|
+
"default": "cypress"
|
|
56
|
+
},
|
|
57
|
+
"tags": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "Add tags to the application (used for linting).",
|
|
60
|
+
"alias": "t"
|
|
61
|
+
},
|
|
62
|
+
"js": {
|
|
63
|
+
"type": "boolean",
|
|
64
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
65
|
+
"default": false
|
|
66
|
+
},
|
|
67
|
+
"skipPackageJson": {
|
|
68
|
+
"type": "boolean",
|
|
69
|
+
"default": false,
|
|
70
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
71
|
+
"x-priority": "internal"
|
|
72
|
+
},
|
|
73
|
+
"rootProject": {
|
|
74
|
+
"description": "Create an application at the root of the workspace.",
|
|
75
|
+
"type": "boolean",
|
|
76
|
+
"default": false,
|
|
77
|
+
"hidden": true,
|
|
78
|
+
"x-priority": "internal"
|
|
79
|
+
},
|
|
80
|
+
"style": {
|
|
81
|
+
"description": "The file extension to be used for style files.",
|
|
82
|
+
"type": "string",
|
|
83
|
+
"alias": "s",
|
|
84
|
+
"default": "css",
|
|
85
|
+
"x-prompt": {
|
|
86
|
+
"message": "Which stylesheet format would you like to use?",
|
|
87
|
+
"type": "list",
|
|
88
|
+
"items": [
|
|
89
|
+
{ "value": "css", "label": "CSS" },
|
|
90
|
+
{
|
|
91
|
+
"value": "scss",
|
|
92
|
+
"label": "SASS(.scss) [ http://sass-lang.com ]"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"value": "less",
|
|
96
|
+
"label": "LESS [ http://lesscss.org ]"
|
|
97
|
+
},
|
|
98
|
+
{ "value": "none", "label": "None" }
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"setParserOptionsProject": {
|
|
103
|
+
"type": "boolean",
|
|
104
|
+
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
|
|
105
|
+
"default": false
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"required": [],
|
|
109
|
+
"examplesFile": "../../../docs/application-examples.md"
|
|
110
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nuxtInitGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const js_1 = require("@nx/js");
|
|
6
|
+
const utils_1 = require("./lib/utils");
|
|
7
|
+
async function nuxtInitGenerator(host, schema) {
|
|
8
|
+
const tasks = [];
|
|
9
|
+
tasks.push(await (0, js_1.initGenerator)(host, {
|
|
10
|
+
...schema,
|
|
11
|
+
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
12
|
+
skipFormat: true,
|
|
13
|
+
}));
|
|
14
|
+
if (!schema.skipPackageJson) {
|
|
15
|
+
const installTask = (0, utils_1.updateDependencies)(host, schema);
|
|
16
|
+
tasks.push(installTask);
|
|
17
|
+
}
|
|
18
|
+
(0, utils_1.addPlugin)(host);
|
|
19
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
20
|
+
}
|
|
21
|
+
exports.nuxtInitGenerator = nuxtInitGenerator;
|
|
22
|
+
exports.default = nuxtInitGenerator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { InitSchema } from '../schema';
|
|
3
|
+
export declare function updateDependencies(host: Tree, schema: InitSchema): import("@nx/devkit").GeneratorCallback;
|
|
4
|
+
export declare function addVitestTargetDefaults(tree: Tree): void;
|
|
5
|
+
export declare function addPlugin(tree: Tree): void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addPlugin = exports.addVitestTargetDefaults = exports.updateDependencies = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../../utils/versions");
|
|
6
|
+
const vue_1 = require("@nx/vue");
|
|
7
|
+
function updateDependencies(host, schema) {
|
|
8
|
+
let devDependencies = {
|
|
9
|
+
'@nx/nuxt': versions_1.nxVersion,
|
|
10
|
+
'@nx/vite': versions_1.nxVersion,
|
|
11
|
+
'@nuxt/devtools': versions_1.nuxtDevtoolsVersion,
|
|
12
|
+
'@nuxt/kit': versions_1.nuxtVersion,
|
|
13
|
+
'@nuxt/ui-templates': versions_1.nuxtUiTemplatesVersion,
|
|
14
|
+
nuxi: versions_1.nuxtVersion,
|
|
15
|
+
nuxt: versions_1.nuxtVersion,
|
|
16
|
+
h3: versions_1.h3Version,
|
|
17
|
+
vue: vue_1.vueVersion,
|
|
18
|
+
'vue-router': vue_1.vueRouterVersion,
|
|
19
|
+
'vue-tsc': vue_1.vueTscVersion,
|
|
20
|
+
};
|
|
21
|
+
if (schema.style === 'scss') {
|
|
22
|
+
devDependencies['sass'] = vue_1.sassVersion;
|
|
23
|
+
}
|
|
24
|
+
else if (schema.style === 'less') {
|
|
25
|
+
devDependencies['less'] = vue_1.lessVersion;
|
|
26
|
+
}
|
|
27
|
+
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, devDependencies);
|
|
28
|
+
}
|
|
29
|
+
exports.updateDependencies = updateDependencies;
|
|
30
|
+
function addVitestTargetDefaults(tree) {
|
|
31
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
32
|
+
const productionFileSet = nxJson.namedInputs?.production;
|
|
33
|
+
if (productionFileSet) {
|
|
34
|
+
productionFileSet.push('!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)', '!{projectRoot}/tsconfig.spec.json');
|
|
35
|
+
nxJson.namedInputs.production = Array.from(new Set(productionFileSet));
|
|
36
|
+
}
|
|
37
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
38
|
+
}
|
|
39
|
+
exports.addVitestTargetDefaults = addVitestTargetDefaults;
|
|
40
|
+
function addPlugin(tree) {
|
|
41
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
42
|
+
nxJson.plugins ??= [];
|
|
43
|
+
let hasNxNuxtPlugin = false;
|
|
44
|
+
let hasNxVitePlugin = false;
|
|
45
|
+
for (const plugin of nxJson.plugins) {
|
|
46
|
+
if (typeof plugin === 'string'
|
|
47
|
+
? plugin === '@nx/nuxt/plugin'
|
|
48
|
+
: plugin.plugin === '@nx/nuxt/plugin') {
|
|
49
|
+
hasNxNuxtPlugin = true;
|
|
50
|
+
}
|
|
51
|
+
if (typeof plugin === 'string'
|
|
52
|
+
? plugin === '@nx/vite/plugin'
|
|
53
|
+
: plugin.plugin === '@nx/vite/plugin') {
|
|
54
|
+
hasNxVitePlugin = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!hasNxNuxtPlugin) {
|
|
58
|
+
nxJson.plugins.push({
|
|
59
|
+
plugin: '@nx/nuxt/plugin',
|
|
60
|
+
options: {
|
|
61
|
+
buildTargetName: 'build',
|
|
62
|
+
serveTargetName: 'serve',
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (!hasNxVitePlugin) {
|
|
67
|
+
nxJson.plugins.push({
|
|
68
|
+
plugin: '@nx/vite/plugin',
|
|
69
|
+
options: {
|
|
70
|
+
testTargetName: 'test',
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
75
|
+
}
|
|
76
|
+
exports.addPlugin = addPlugin;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "NxNuxtInit",
|
|
4
|
+
"title": "Init Nuxt Plugin",
|
|
5
|
+
"description": "Initialize a Nuxt Plugin.",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"skipFormat": {
|
|
10
|
+
"description": "Skip formatting files.",
|
|
11
|
+
"type": "boolean",
|
|
12
|
+
"default": false
|
|
13
|
+
},
|
|
14
|
+
"rootProject": {
|
|
15
|
+
"description": "Create a project at the root of the workspace",
|
|
16
|
+
"type": "boolean",
|
|
17
|
+
"default": false
|
|
18
|
+
},
|
|
19
|
+
"skipPackageJson": {
|
|
20
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
"default": false
|
|
23
|
+
},
|
|
24
|
+
"style": {
|
|
25
|
+
"description": "The file extension to be used for style files.",
|
|
26
|
+
"type": "string",
|
|
27
|
+
"default": "css"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": []
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.storybookConfigurationGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const vue_1 = require("@nx/vue");
|
|
6
|
+
/*
|
|
7
|
+
* This generator is basically the Vue one, but for Nuxt we
|
|
8
|
+
* are just adding the styles in `.storybook/preview.ts`
|
|
9
|
+
*/
|
|
10
|
+
async function storybookConfigurationGenerator(host, options) {
|
|
11
|
+
const storybookConfigurationGenerator = await (0, vue_1.storybookConfigurationGenerator)(host, {
|
|
12
|
+
...options,
|
|
13
|
+
});
|
|
14
|
+
const projectConfiguration = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
15
|
+
const storybookConfigFolder = projectConfiguration.targets?.storybook?.options?.configDir;
|
|
16
|
+
host.write(`${storybookConfigFolder}/preview.${options.tsConfiguration ? 'ts' : 'js'}`, `import '../src/assets/css/styles.css';`);
|
|
17
|
+
(0, devkit_1.updateJson)(host, `${projectConfiguration.root}/tsconfig.storybook.json`, (json) => {
|
|
18
|
+
json.compilerOptions = {
|
|
19
|
+
...json.compilerOptions,
|
|
20
|
+
composite: true,
|
|
21
|
+
};
|
|
22
|
+
return json;
|
|
23
|
+
});
|
|
24
|
+
await (0, devkit_1.formatFiles)(host);
|
|
25
|
+
return (0, devkit_1.runTasksInSerial)(storybookConfigurationGenerator);
|
|
26
|
+
}
|
|
27
|
+
exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
|
|
28
|
+
exports.default = storybookConfigurationGenerator;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Linter } from '@nx/eslint';
|
|
2
|
+
|
|
3
|
+
export interface Schema {
|
|
4
|
+
project: string;
|
|
5
|
+
interactionTests?: boolean;
|
|
6
|
+
generateStories?: boolean;
|
|
7
|
+
js?: boolean;
|
|
8
|
+
tsConfiguration?: boolean;
|
|
9
|
+
linter?: Linter;
|
|
10
|
+
ignorePaths?: string[];
|
|
11
|
+
configureStaticServe?: boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxNuxtStorybookConfigure",
|
|
5
|
+
"title": "Nuxt Storybook Configure",
|
|
6
|
+
"description": "Set up Storybook for a Nuxt project.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"aliases": ["name", "projectName"],
|
|
12
|
+
"description": "Project for which to generate Storybook configuration.",
|
|
13
|
+
"$default": {
|
|
14
|
+
"$source": "argv",
|
|
15
|
+
"index": 0
|
|
16
|
+
},
|
|
17
|
+
"x-prompt": "For which project do you want to generate Storybook configuration?",
|
|
18
|
+
"x-dropdown": "projects",
|
|
19
|
+
"x-priority": "important"
|
|
20
|
+
},
|
|
21
|
+
"interactionTests": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "Set up Storybook interaction tests.",
|
|
24
|
+
"x-prompt": "Do you want to set up Storybook interaction tests?",
|
|
25
|
+
"x-priority": "important",
|
|
26
|
+
"alias": ["configureTestRunner"],
|
|
27
|
+
"default": true
|
|
28
|
+
},
|
|
29
|
+
"generateStories": {
|
|
30
|
+
"type": "boolean",
|
|
31
|
+
"description": "Automatically generate `*.stories.ts` files for components declared in this project?",
|
|
32
|
+
"x-prompt": "Automatically generate *.stories.ts files for components declared in this project?",
|
|
33
|
+
"default": true,
|
|
34
|
+
"x-priority": "important"
|
|
35
|
+
},
|
|
36
|
+
"configureStaticServe": {
|
|
37
|
+
"type": "boolean",
|
|
38
|
+
"description": "Specifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.",
|
|
39
|
+
"x-prompt": "Configure a static file server for the storybook instance?",
|
|
40
|
+
"default": true,
|
|
41
|
+
"x-priority": "important"
|
|
42
|
+
},
|
|
43
|
+
"js": {
|
|
44
|
+
"type": "boolean",
|
|
45
|
+
"description": "Generate JavaScript story files rather than TypeScript story files.",
|
|
46
|
+
"default": false
|
|
47
|
+
},
|
|
48
|
+
"tsConfiguration": {
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"description": "Configure your project with TypeScript. Generate main.ts and preview.ts files, instead of main.js and preview.js.",
|
|
51
|
+
"default": true
|
|
52
|
+
},
|
|
53
|
+
"linter": {
|
|
54
|
+
"description": "The tool to use for running lint checks.",
|
|
55
|
+
"type": "string",
|
|
56
|
+
"enum": ["eslint"],
|
|
57
|
+
"default": "eslint"
|
|
58
|
+
},
|
|
59
|
+
"ignorePaths": {
|
|
60
|
+
"type": "array",
|
|
61
|
+
"description": "Paths to ignore when looking for components.",
|
|
62
|
+
"items": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"description": "Path to ignore."
|
|
65
|
+
},
|
|
66
|
+
"default": [
|
|
67
|
+
"*.stories.ts,*.stories.tsx,*.stories.js,*.stories.jsx,*.stories.mdx"
|
|
68
|
+
],
|
|
69
|
+
"examples": [
|
|
70
|
+
"apps/my-app/src/not-stories/**",
|
|
71
|
+
"**/**/src/**/not-stories/**",
|
|
72
|
+
"libs/my-lib/**/*.something.ts",
|
|
73
|
+
"**/**/src/**/*.other.*",
|
|
74
|
+
"libs/my-lib/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts"
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"required": ["project"],
|
|
79
|
+
"examplesFile": "../../../docs/storybook-configuration-examples.md"
|
|
80
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CreateDependencies, CreateNodes } from '@nx/devkit';
|
|
2
|
+
export declare const createDependencies: CreateDependencies;
|
|
3
|
+
export interface NuxtPluginOptions {
|
|
4
|
+
buildTargetName?: string;
|
|
5
|
+
serveTargetName?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const createNodes: CreateNodes<NuxtPluginOptions>;
|