@nx/vue 17.0.0-beta.4
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 +63 -0
- package/executors.json +3 -0
- package/generators.json +50 -0
- package/index.d.ts +11 -0
- package/index.js +21 -0
- package/migrations.json +4 -0
- package/package.json +54 -0
- package/src/generators/application/application.d.ts +4 -0
- package/src/generators/application/application.js +52 -0
- package/src/generators/application/files/common/index.html.template +13 -0
- package/src/generators/application/files/common/src/app/App.spec.ts.template +12 -0
- package/src/generators/application/files/common/src/app/App.vue.template +54 -0
- package/src/generators/application/files/common/src/app/NxWelcome.vue.template +793 -0
- package/src/generators/application/files/common/src/main.ts.template +15 -0
- package/src/generators/application/files/common/tsconfig.app.json.template +8 -0
- package/src/generators/application/files/routing/src/router/index.ts.template +23 -0
- package/src/generators/application/files/routing/src/views/AboutView.vue.template +16 -0
- package/src/generators/application/files/routing/src/views/HomeView.vue.template +9 -0
- package/src/generators/application/files/stylesheet/src/styles.__style__.template +42 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +48 -0
- package/src/generators/application/lib/add-jest.d.ts +5 -0
- package/src/generators/application/lib/add-jest.js +22 -0
- package/src/generators/application/lib/add-vite.d.ts +3 -0
- package/src/generators/application/lib/add-vite.js +32 -0
- package/src/generators/application/lib/create-application-files.d.ts +3 -0
- package/src/generators/application/lib/create-application-files.js +30 -0
- package/src/generators/application/lib/normalize-options.d.ts +4 -0
- package/src/generators/application/lib/normalize-options.js +45 -0
- package/src/generators/application/schema.d.ts +30 -0
- package/src/generators/application/schema.json +140 -0
- package/src/generators/component/component.d.ts +4 -0
- package/src/generators/component/component.js +40 -0
- package/src/generators/component/files/__fileName__.spec.ts__tmpl__ +13 -0
- package/src/generators/component/files/__fileName__.vue__tmpl__ +10 -0
- package/src/generators/component/lib/utils.d.ts +7 -0
- package/src/generators/component/lib/utils.js +86 -0
- package/src/generators/component/schema.d.ts +22 -0
- package/src/generators/component/schema.json +107 -0
- package/src/generators/init/init.d.ts +4 -0
- package/src/generators/init/init.js +41 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +37 -0
- package/src/generators/library/files/README.md +7 -0
- package/src/generators/library/files/package.json__tmpl__ +12 -0
- package/src/generators/library/files/src/index.ts__tmpl__ +0 -0
- package/src/generators/library/files/src/vue-shims.d.ts__tmpl__ +5 -0
- package/src/generators/library/files/tsconfig.lib.json__tmpl__ +34 -0
- package/src/generators/library/files/tsconfig.spec.json__tmpl__ +27 -0
- package/src/generators/library/lib/add-jest.d.ts +3 -0
- package/src/generators/library/lib/add-jest.js +23 -0
- package/src/generators/library/lib/add-vite.d.ts +3 -0
- package/src/generators/library/lib/add-vite.js +56 -0
- package/src/generators/library/lib/create-library-files.d.ts +3 -0
- package/src/generators/library/lib/create-library-files.js +28 -0
- package/src/generators/library/lib/normalize-options.d.ts +3 -0
- package/src/generators/library/lib/normalize-options.js +55 -0
- package/src/generators/library/library.d.ts +4 -0
- package/src/generators/library/library.js +71 -0
- package/src/generators/library/schema.d.ts +41 -0
- package/src/generators/library/schema.json +139 -0
- package/src/generators/setup-tailwind/files/postcss.config.js.template +10 -0
- package/src/generators/setup-tailwind/files/tailwind.config.js.template +18 -0
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts +3 -0
- package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +25 -0
- package/src/generators/setup-tailwind/schema.d.ts +6 -0
- package/src/generators/setup-tailwind/schema.json +45 -0
- package/src/generators/setup-tailwind/setup-tailwind.d.ts +4 -0
- package/src/generators/setup-tailwind/setup-tailwind.js +25 -0
- package/src/generators/stories/lib/component-story.d.ts +3 -0
- package/src/generators/stories/lib/component-story.js +34 -0
- package/src/generators/stories/lib/files/js/__componentFileName__.stories.js__tmpl__ +25 -0
- package/src/generators/stories/lib/files/ts/__componentFileName__.stories.ts__tmpl__ +32 -0
- package/src/generators/stories/lib/utils.d.ts +10 -0
- package/src/generators/stories/lib/utils.js +75 -0
- package/src/generators/stories/schema.json +64 -0
- package/src/generators/stories/stories.d.ts +13 -0
- package/src/generators/stories/stories.js +61 -0
- package/src/generators/storybook-configuration/configuration.d.ts +4 -0
- package/src/generators/storybook-configuration/configuration.js +35 -0
- package/src/generators/storybook-configuration/schema.d.ts +12 -0
- package/src/generators/storybook-configuration/schema.json +77 -0
- package/src/tailwind.d.ts +6 -0
- package/src/tailwind.js +29 -0
- package/src/utils/add-linting.d.ts +12 -0
- package/src/utils/add-linting.js +121 -0
- package/src/utils/ast-utils.d.ts +3 -0
- package/src/utils/ast-utils.js +33 -0
- package/src/utils/create-ts-config.d.ts +9 -0
- package/src/utils/create-ts-config.js +66 -0
- package/src/utils/lint.d.ts +9 -0
- package/src/utils/lint.js +26 -0
- package/src/utils/setup-jest.d.ts +4 -0
- package/src/utils/setup-jest.js +96 -0
- package/src/utils/test-utils.d.ts +3 -0
- package/src/utils/test-utils.js +30 -0
- package/src/utils/versions.d.ts +16 -0
- package/src/utils/versions.js +25 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertValidOptions = exports.getDirectory = exports.addExportsToBarrel = exports.getComponentClassName = exports.normalizeOptions = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
6
|
+
const ast_utils_1 = require("../../../utils/ast-utils");
|
|
7
|
+
let tsModule;
|
|
8
|
+
async function normalizeOptions(host, options, isApp) {
|
|
9
|
+
assertValidOptions(options);
|
|
10
|
+
let { className, fileName } = (0, devkit_1.names)(options.name);
|
|
11
|
+
const componentFileName = options.fileName ?? (options.pascalCaseFiles ? className : fileName);
|
|
12
|
+
const project = (0, devkit_1.getProjects)(host).get(options.project);
|
|
13
|
+
if (!project) {
|
|
14
|
+
throw new Error(`Cannot find the ${options.project} project. Please double check the project name.`);
|
|
15
|
+
}
|
|
16
|
+
const { sourceRoot: projectSourceRoot, projectType } = project;
|
|
17
|
+
className = getComponentClassName(className, isApp, options.project, options.directory);
|
|
18
|
+
const directory = await getDirectory(options);
|
|
19
|
+
if (options.export && projectType === 'application') {
|
|
20
|
+
devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
|
|
21
|
+
}
|
|
22
|
+
options.routing = options.routing ?? false;
|
|
23
|
+
options.inSourceTests = options.inSourceTests ?? false;
|
|
24
|
+
return {
|
|
25
|
+
...options,
|
|
26
|
+
directory,
|
|
27
|
+
className,
|
|
28
|
+
fileName: componentFileName,
|
|
29
|
+
projectSourceRoot,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.normalizeOptions = normalizeOptions;
|
|
33
|
+
function getComponentClassName(componentName, isApp, projectName, directory) {
|
|
34
|
+
const { className } = (0, devkit_1.names)(projectName);
|
|
35
|
+
let prefix = isApp ? 'App' : className;
|
|
36
|
+
if (directory?.length > 0) {
|
|
37
|
+
prefix = directory
|
|
38
|
+
.split('/')
|
|
39
|
+
.map((segment) => segment
|
|
40
|
+
.split('-')
|
|
41
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
42
|
+
.join(''))
|
|
43
|
+
.join('');
|
|
44
|
+
}
|
|
45
|
+
return `${prefix}${componentName}`;
|
|
46
|
+
}
|
|
47
|
+
exports.getComponentClassName = getComponentClassName;
|
|
48
|
+
function addExportsToBarrel(host, options, isApp) {
|
|
49
|
+
if (!tsModule) {
|
|
50
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
51
|
+
}
|
|
52
|
+
if (options.export && !isApp) {
|
|
53
|
+
const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.js ? 'index.js' : 'index.ts');
|
|
54
|
+
const indexSource = host.read(indexFilePath, 'utf-8');
|
|
55
|
+
if (indexSource !== null) {
|
|
56
|
+
const indexSourceFile = tsModule.createSourceFile(indexFilePath, indexSource, tsModule.ScriptTarget.Latest, true);
|
|
57
|
+
const changes = (0, devkit_1.applyChangesToString)(indexSource, (0, ast_utils_1.addImport)(indexSourceFile, `export { default as ${options.className} } from './${options.directory}/${options.fileName}.vue';`));
|
|
58
|
+
host.write(indexFilePath, changes);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.addExportsToBarrel = addExportsToBarrel;
|
|
63
|
+
async function getDirectory(options) {
|
|
64
|
+
if (options.directory)
|
|
65
|
+
return options.directory;
|
|
66
|
+
if (options.flat)
|
|
67
|
+
return 'components';
|
|
68
|
+
const { className, fileName } = (0, devkit_1.names)(options.name);
|
|
69
|
+
const nestedDir = options.pascalCaseDirectory === true ? className : fileName;
|
|
70
|
+
return (0, devkit_1.joinPathFragments)('components', nestedDir);
|
|
71
|
+
}
|
|
72
|
+
exports.getDirectory = getDirectory;
|
|
73
|
+
function assertValidOptions(options) {
|
|
74
|
+
const slashes = ['/', '\\'];
|
|
75
|
+
slashes.forEach((s) => {
|
|
76
|
+
if (options.name.indexOf(s) !== -1) {
|
|
77
|
+
const [name, ...rest] = options.name.split(s).reverse();
|
|
78
|
+
let suggestion = rest.map((x) => x.toLowerCase()).join(s);
|
|
79
|
+
if (options.directory) {
|
|
80
|
+
suggestion = `${options.directory}${s}${suggestion}`;
|
|
81
|
+
}
|
|
82
|
+
throw new Error(`Found "${s}" in the component name. Did you mean to use the --directory option (e.g. \`nx g c ${name} --directory ${suggestion}\`)?`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.assertValidOptions = assertValidOptions;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Schema {
|
|
2
|
+
name: string;
|
|
3
|
+
project: string;
|
|
4
|
+
skipTests?: boolean;
|
|
5
|
+
directory?: string;
|
|
6
|
+
export?: boolean;
|
|
7
|
+
pascalCaseFiles?: boolean;
|
|
8
|
+
pascalCaseDirectory?: boolean;
|
|
9
|
+
routing?: boolean;
|
|
10
|
+
js?: boolean;
|
|
11
|
+
flat?: boolean;
|
|
12
|
+
fileName?: string;
|
|
13
|
+
inSourceTests?: boolean;
|
|
14
|
+
skipFormat?: boolean;
|
|
15
|
+
unitTestRunner?: 'jest' | 'vitest' | 'none';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface NormalizedSchema extends Schema {
|
|
19
|
+
projectSourceRoot: string;
|
|
20
|
+
fileName: string;
|
|
21
|
+
className: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxVueComponent",
|
|
5
|
+
"title": "Create a Vue Component",
|
|
6
|
+
"description": "Create a Vue Component for Nx.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"examples": [
|
|
9
|
+
{
|
|
10
|
+
"command": "nx g component my-component --project=mylib",
|
|
11
|
+
"description": "Generate a component in the `mylib` library"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"command": "nx g component my-component --project=mylib --classComponent",
|
|
15
|
+
"description": "Generate a class component in the `mylib` library"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"project": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "The name of the project.",
|
|
22
|
+
"alias": "p",
|
|
23
|
+
"$default": {
|
|
24
|
+
"$source": "projectName"
|
|
25
|
+
},
|
|
26
|
+
"x-prompt": "What is the name of the project for this component?",
|
|
27
|
+
"x-priority": "important"
|
|
28
|
+
},
|
|
29
|
+
"name": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "The name of the component.",
|
|
32
|
+
"$default": {
|
|
33
|
+
"$source": "argv",
|
|
34
|
+
"index": 0
|
|
35
|
+
},
|
|
36
|
+
"x-prompt": "What name would you like to use for the component?",
|
|
37
|
+
"x-priority": "important"
|
|
38
|
+
},
|
|
39
|
+
"js": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
42
|
+
"default": false
|
|
43
|
+
},
|
|
44
|
+
"skipTests": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"description": "When true, does not create `spec.ts` test files for the new component.",
|
|
47
|
+
"default": false,
|
|
48
|
+
"x-priority": "internal"
|
|
49
|
+
},
|
|
50
|
+
"directory": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "Create the component under this directory (can be nested).",
|
|
53
|
+
"alias": "dir",
|
|
54
|
+
"x-priority": "important"
|
|
55
|
+
},
|
|
56
|
+
"flat": {
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"description": "Create component at the source root rather than its own directory.",
|
|
59
|
+
"default": false
|
|
60
|
+
},
|
|
61
|
+
"export": {
|
|
62
|
+
"type": "boolean",
|
|
63
|
+
"description": "When true, the component is exported from the project `index.ts` (if it exists).",
|
|
64
|
+
"alias": "e",
|
|
65
|
+
"default": false,
|
|
66
|
+
"x-prompt": "Should this component be exported in the project?"
|
|
67
|
+
},
|
|
68
|
+
"pascalCaseFiles": {
|
|
69
|
+
"type": "boolean",
|
|
70
|
+
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
|
71
|
+
"alias": "P",
|
|
72
|
+
"default": false
|
|
73
|
+
},
|
|
74
|
+
"pascalCaseDirectory": {
|
|
75
|
+
"type": "boolean",
|
|
76
|
+
"description": "Use pascal case directory name (e.g. `App/App.tsx`).",
|
|
77
|
+
"alias": "R",
|
|
78
|
+
"default": false
|
|
79
|
+
},
|
|
80
|
+
"routing": {
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"description": "Generate a library with routes."
|
|
83
|
+
},
|
|
84
|
+
"fileName": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "Create a component with this file name."
|
|
87
|
+
},
|
|
88
|
+
"inSourceTests": {
|
|
89
|
+
"type": "boolean",
|
|
90
|
+
"default": false,
|
|
91
|
+
"description": "When using Vitest, separate spec files will not be generated and instead will be included within the source files. Read more on the Vitest docs site: https://vitest.dev/guide/in-source.html"
|
|
92
|
+
},
|
|
93
|
+
"skipFormat": {
|
|
94
|
+
"description": "Skip formatting files.",
|
|
95
|
+
"type": "boolean",
|
|
96
|
+
"default": false,
|
|
97
|
+
"x-priority": "internal"
|
|
98
|
+
},
|
|
99
|
+
"unitTestRunner": {
|
|
100
|
+
"type": "string",
|
|
101
|
+
"enum": ["vitest", "jest", "none"],
|
|
102
|
+
"description": "Test runner to use for unit tests.",
|
|
103
|
+
"x-prompt": "What unit test runner should be used?"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"required": ["name", "project"]
|
|
107
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vueInitGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const js_1 = require("@nx/js");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
|
+
function updateDependencies(host, schema) {
|
|
8
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nx/vue'], []);
|
|
9
|
+
let dependencies = {
|
|
10
|
+
vue: versions_1.vueVersion,
|
|
11
|
+
'vue-tsc': versions_1.vueTscVersion,
|
|
12
|
+
};
|
|
13
|
+
let devDependencies = {
|
|
14
|
+
'@nx/vue': versions_1.nxVersion,
|
|
15
|
+
'@vue/tsconfig': versions_1.vueTsconfigVersion,
|
|
16
|
+
'@vue/test-utils': versions_1.vueTestUtilsVersion,
|
|
17
|
+
'@vitejs/plugin-vue': versions_1.vitePluginVueVersion,
|
|
18
|
+
};
|
|
19
|
+
if (schema.routing) {
|
|
20
|
+
dependencies['vue-router'] = versions_1.vueRouterVersion;
|
|
21
|
+
}
|
|
22
|
+
if (schema.style === 'scss') {
|
|
23
|
+
devDependencies['sass'] = versions_1.sassVersion;
|
|
24
|
+
}
|
|
25
|
+
else if (schema.style === 'less') {
|
|
26
|
+
devDependencies['less'] = versions_1.lessVersion;
|
|
27
|
+
}
|
|
28
|
+
return (0, devkit_1.addDependenciesToPackageJson)(host, dependencies, devDependencies);
|
|
29
|
+
}
|
|
30
|
+
async function vueInitGenerator(host, schema) {
|
|
31
|
+
const tasks = [];
|
|
32
|
+
tasks.push(await (0, js_1.initGenerator)(host, {
|
|
33
|
+
...schema,
|
|
34
|
+
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
35
|
+
skipFormat: true,
|
|
36
|
+
}));
|
|
37
|
+
tasks.push(updateDependencies(host, schema));
|
|
38
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
39
|
+
}
|
|
40
|
+
exports.vueInitGenerator = vueInitGenerator;
|
|
41
|
+
exports.default = vueInitGenerator;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "NxVueInit",
|
|
4
|
+
"title": "Init Vue Plugin",
|
|
5
|
+
"description": "Initialize a Vue Plugin.",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"skipFormat": {
|
|
10
|
+
"description": "Skip formatting files.",
|
|
11
|
+
"type": "boolean",
|
|
12
|
+
"default": false
|
|
13
|
+
},
|
|
14
|
+
"js": {
|
|
15
|
+
"type": "boolean",
|
|
16
|
+
"description": "Use JavaScript instead of TypeScript",
|
|
17
|
+
"default": false
|
|
18
|
+
},
|
|
19
|
+
"rootProject": {
|
|
20
|
+
"description": "Create a project at the root of the workspace",
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
"default": false
|
|
23
|
+
},
|
|
24
|
+
"routing": {
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"description": "Generate application with routes.",
|
|
27
|
+
"x-prompt": "Would you like to add React Router to this application?",
|
|
28
|
+
"default": false
|
|
29
|
+
},
|
|
30
|
+
"style": {
|
|
31
|
+
"description": "The file extension to be used for style files.",
|
|
32
|
+
"type": "string",
|
|
33
|
+
"default": "css"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"required": []
|
|
37
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
5
|
+
"baseUrl": ".",
|
|
6
|
+
"paths": {
|
|
7
|
+
"@/*": ["./src/*"]
|
|
8
|
+
},
|
|
9
|
+
"types": [],
|
|
10
|
+
"lib": [
|
|
11
|
+
"ES2016",
|
|
12
|
+
"DOM",
|
|
13
|
+
"DOM.Iterable"
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
"exclude": [
|
|
17
|
+
"src/**/__tests__/*",
|
|
18
|
+
"src/**/*.spec.ts",
|
|
19
|
+
"src/**/*.test.ts",
|
|
20
|
+
"src/**/*.spec.tsx",
|
|
21
|
+
"src/**/*.test.tsx",
|
|
22
|
+
"src/**/*.spec.js",
|
|
23
|
+
"src/**/*.test.js",
|
|
24
|
+
"src/**/*.spec.jsx",
|
|
25
|
+
"src/**/*.test.jsx"
|
|
26
|
+
],
|
|
27
|
+
"include": [
|
|
28
|
+
"src/**/*.js",
|
|
29
|
+
"src/**/*.jsx",
|
|
30
|
+
"src/**/*.ts",
|
|
31
|
+
"src/**/*.tsx",
|
|
32
|
+
"src/**/*.vue"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"exclude": [],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"outDir": "../../dist/out-tsc",
|
|
6
|
+
"lib": [],
|
|
7
|
+
"types": [
|
|
8
|
+
"vitest",
|
|
9
|
+
"vitest/globals",
|
|
10
|
+
"vitest/importMeta",
|
|
11
|
+
"vite/client",
|
|
12
|
+
"node"]
|
|
13
|
+
},
|
|
14
|
+
"include": [
|
|
15
|
+
"vite.config.ts",
|
|
16
|
+
"src/**/__tests__/*",
|
|
17
|
+
"src/**/*.test.ts",
|
|
18
|
+
"src/**/*.spec.ts",
|
|
19
|
+
"src/**/*.test.tsx",
|
|
20
|
+
"src/**/*.spec.tsx",
|
|
21
|
+
"src/**/*.test.js",
|
|
22
|
+
"src/**/*.spec.js",
|
|
23
|
+
"src/**/*.test.jsx",
|
|
24
|
+
"src/**/*.spec.jsx",
|
|
25
|
+
"src/**/*.d.ts"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addJest = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../../utils/versions");
|
|
6
|
+
const setup_jest_1 = require("../../../utils/setup-jest");
|
|
7
|
+
async function addJest(tree, options) {
|
|
8
|
+
const tasks = [];
|
|
9
|
+
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
|
|
10
|
+
const jestTask = await configurationGenerator(tree, {
|
|
11
|
+
project: options.name,
|
|
12
|
+
skipFormat: true,
|
|
13
|
+
testEnvironment: 'jsdom',
|
|
14
|
+
compiler: 'babel',
|
|
15
|
+
});
|
|
16
|
+
tasks.push(jestTask);
|
|
17
|
+
(0, setup_jest_1.setupJestProject)(tree, options.projectRoot);
|
|
18
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
19
|
+
'@vue/vue3-jest': versions_1.vueJest3Version,
|
|
20
|
+
}));
|
|
21
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
22
|
+
}
|
|
23
|
+
exports.addJest = addJest;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addVite = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("../../../utils/versions");
|
|
6
|
+
async function addVite(tree, options) {
|
|
7
|
+
const tasks = [];
|
|
8
|
+
// Set up build target
|
|
9
|
+
if (options.bundler === 'vite') {
|
|
10
|
+
const { viteConfigurationGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
11
|
+
const viteTask = await viteConfigurationGenerator(tree, {
|
|
12
|
+
uiFramework: 'none',
|
|
13
|
+
project: options.name,
|
|
14
|
+
newProject: true,
|
|
15
|
+
includeLib: true,
|
|
16
|
+
inSourceTests: options.inSourceTests,
|
|
17
|
+
includeVitest: options.unitTestRunner === 'vitest',
|
|
18
|
+
skipFormat: true,
|
|
19
|
+
testEnvironment: 'jsdom',
|
|
20
|
+
});
|
|
21
|
+
tasks.push(viteTask);
|
|
22
|
+
createOrEditViteConfig(tree, {
|
|
23
|
+
project: options.name,
|
|
24
|
+
includeLib: true,
|
|
25
|
+
includeVitest: options.unitTestRunner === 'vitest',
|
|
26
|
+
inSourceTests: options.inSourceTests,
|
|
27
|
+
imports: [`import vue from '@vitejs/plugin-vue'`],
|
|
28
|
+
plugins: ['vue()'],
|
|
29
|
+
}, false);
|
|
30
|
+
}
|
|
31
|
+
// Set up test target
|
|
32
|
+
if (options.unitTestRunner === 'vitest' &&
|
|
33
|
+
options.bundler !== 'vite' // tests are already configured if bundler is vite
|
|
34
|
+
) {
|
|
35
|
+
const { vitestGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
|
|
36
|
+
const vitestTask = await vitestGenerator(tree, {
|
|
37
|
+
uiFramework: 'none',
|
|
38
|
+
project: options.name,
|
|
39
|
+
coverageProvider: 'c8',
|
|
40
|
+
inSourceTests: options.inSourceTests,
|
|
41
|
+
skipFormat: true,
|
|
42
|
+
testEnvironment: 'jsdom',
|
|
43
|
+
});
|
|
44
|
+
tasks.push(vitestTask);
|
|
45
|
+
createOrEditViteConfig(tree, {
|
|
46
|
+
project: options.name,
|
|
47
|
+
includeLib: true,
|
|
48
|
+
includeVitest: true,
|
|
49
|
+
inSourceTests: options.inSourceTests,
|
|
50
|
+
imports: [`import vue from '@vitejs/plugin-vue'`],
|
|
51
|
+
plugins: ['vue()'],
|
|
52
|
+
}, true);
|
|
53
|
+
}
|
|
54
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
55
|
+
}
|
|
56
|
+
exports.addVite = addVite;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLibraryFiles = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const js_1 = require("@nx/js");
|
|
6
|
+
const create_ts_config_1 = require("../../../utils/create-ts-config");
|
|
7
|
+
function createLibraryFiles(host, options) {
|
|
8
|
+
const relativePathToRootTsConfig = (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot);
|
|
9
|
+
const substitutions = {
|
|
10
|
+
...options,
|
|
11
|
+
...(0, devkit_1.names)(options.name),
|
|
12
|
+
tmpl: '',
|
|
13
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
14
|
+
fileName: options.fileName,
|
|
15
|
+
};
|
|
16
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, '../files'), options.projectRoot, substitutions);
|
|
17
|
+
if (!options.publishable && options.bundler === 'none') {
|
|
18
|
+
host.delete(`${options.projectRoot}/package.json`);
|
|
19
|
+
}
|
|
20
|
+
if (options.unitTestRunner !== 'vitest') {
|
|
21
|
+
host.delete(`${options.projectRoot}/tsconfig.spec.json`);
|
|
22
|
+
}
|
|
23
|
+
if (options.js) {
|
|
24
|
+
(0, devkit_1.toJS)(host);
|
|
25
|
+
}
|
|
26
|
+
(0, create_ts_config_1.createTsConfig)(host, options.projectRoot, 'lib', options, relativePathToRootTsConfig);
|
|
27
|
+
}
|
|
28
|
+
exports.createLibraryFiles = createLibraryFiles;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeOptions = 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
|
+
async function normalizeOptions(host, options) {
|
|
7
|
+
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
|
|
8
|
+
name: options.name,
|
|
9
|
+
projectType: 'library',
|
|
10
|
+
directory: options.directory,
|
|
11
|
+
importPath: options.importPath,
|
|
12
|
+
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
13
|
+
callingGenerator: '@nx/vue:library',
|
|
14
|
+
});
|
|
15
|
+
const fileName = projectNames.projectFileName;
|
|
16
|
+
const parsedTags = options.tags
|
|
17
|
+
? options.tags.split(',').map((s) => s.trim())
|
|
18
|
+
: [];
|
|
19
|
+
let bundler = options.bundler ?? 'none';
|
|
20
|
+
if (bundler === 'none') {
|
|
21
|
+
if (options.publishable) {
|
|
22
|
+
devkit_1.logger.warn(`Publishable libraries cannot be used with bundler: 'none'. Defaulting to 'vite'.`);
|
|
23
|
+
bundler = 'vite';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const normalized = {
|
|
27
|
+
...options,
|
|
28
|
+
bundler,
|
|
29
|
+
fileName,
|
|
30
|
+
routePath: `/${projectNames.projectFileName}`,
|
|
31
|
+
name: projectName,
|
|
32
|
+
projectRoot,
|
|
33
|
+
parsedTags,
|
|
34
|
+
importPath,
|
|
35
|
+
};
|
|
36
|
+
// Libraries with a bundler or is publishable must also be buildable.
|
|
37
|
+
normalized.bundler =
|
|
38
|
+
normalized.bundler !== 'none' || options.publishable ? 'vite' : 'none';
|
|
39
|
+
normalized.inSourceTests === normalized.minimal || normalized.inSourceTests;
|
|
40
|
+
if (options.appProject) {
|
|
41
|
+
const appProjectConfig = (0, devkit_1.getProjects)(host).get(options.appProject);
|
|
42
|
+
if (appProjectConfig.projectType !== 'application') {
|
|
43
|
+
throw new Error(`appProject expected type of "application" but got "${appProjectConfig.projectType}"`);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
normalized.appMain = appProjectConfig.targets.build.options.main;
|
|
47
|
+
normalized.appSourceRoot = (0, devkit_1.normalizePath)(appProjectConfig.sourceRoot);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
throw new Error(`Could not locate project main for ${options.appProject}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return normalized;
|
|
54
|
+
}
|
|
55
|
+
exports.normalizeOptions = normalizeOptions;
|