@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.
Files changed (99) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +63 -0
  3. package/executors.json +3 -0
  4. package/generators.json +50 -0
  5. package/index.d.ts +11 -0
  6. package/index.js +21 -0
  7. package/migrations.json +4 -0
  8. package/package.json +54 -0
  9. package/src/generators/application/application.d.ts +4 -0
  10. package/src/generators/application/application.js +52 -0
  11. package/src/generators/application/files/common/index.html.template +13 -0
  12. package/src/generators/application/files/common/src/app/App.spec.ts.template +12 -0
  13. package/src/generators/application/files/common/src/app/App.vue.template +54 -0
  14. package/src/generators/application/files/common/src/app/NxWelcome.vue.template +793 -0
  15. package/src/generators/application/files/common/src/main.ts.template +15 -0
  16. package/src/generators/application/files/common/tsconfig.app.json.template +8 -0
  17. package/src/generators/application/files/routing/src/router/index.ts.template +23 -0
  18. package/src/generators/application/files/routing/src/views/AboutView.vue.template +16 -0
  19. package/src/generators/application/files/routing/src/views/HomeView.vue.template +9 -0
  20. package/src/generators/application/files/stylesheet/src/styles.__style__.template +42 -0
  21. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  22. package/src/generators/application/lib/add-e2e.js +48 -0
  23. package/src/generators/application/lib/add-jest.d.ts +5 -0
  24. package/src/generators/application/lib/add-jest.js +22 -0
  25. package/src/generators/application/lib/add-vite.d.ts +3 -0
  26. package/src/generators/application/lib/add-vite.js +32 -0
  27. package/src/generators/application/lib/create-application-files.d.ts +3 -0
  28. package/src/generators/application/lib/create-application-files.js +30 -0
  29. package/src/generators/application/lib/normalize-options.d.ts +4 -0
  30. package/src/generators/application/lib/normalize-options.js +45 -0
  31. package/src/generators/application/schema.d.ts +30 -0
  32. package/src/generators/application/schema.json +140 -0
  33. package/src/generators/component/component.d.ts +4 -0
  34. package/src/generators/component/component.js +40 -0
  35. package/src/generators/component/files/__fileName__.spec.ts__tmpl__ +13 -0
  36. package/src/generators/component/files/__fileName__.vue__tmpl__ +10 -0
  37. package/src/generators/component/lib/utils.d.ts +7 -0
  38. package/src/generators/component/lib/utils.js +86 -0
  39. package/src/generators/component/schema.d.ts +22 -0
  40. package/src/generators/component/schema.json +107 -0
  41. package/src/generators/init/init.d.ts +4 -0
  42. package/src/generators/init/init.js +41 -0
  43. package/src/generators/init/schema.d.ts +7 -0
  44. package/src/generators/init/schema.json +37 -0
  45. package/src/generators/library/files/README.md +7 -0
  46. package/src/generators/library/files/package.json__tmpl__ +12 -0
  47. package/src/generators/library/files/src/index.ts__tmpl__ +0 -0
  48. package/src/generators/library/files/src/vue-shims.d.ts__tmpl__ +5 -0
  49. package/src/generators/library/files/tsconfig.lib.json__tmpl__ +34 -0
  50. package/src/generators/library/files/tsconfig.spec.json__tmpl__ +27 -0
  51. package/src/generators/library/lib/add-jest.d.ts +3 -0
  52. package/src/generators/library/lib/add-jest.js +23 -0
  53. package/src/generators/library/lib/add-vite.d.ts +3 -0
  54. package/src/generators/library/lib/add-vite.js +56 -0
  55. package/src/generators/library/lib/create-library-files.d.ts +3 -0
  56. package/src/generators/library/lib/create-library-files.js +28 -0
  57. package/src/generators/library/lib/normalize-options.d.ts +3 -0
  58. package/src/generators/library/lib/normalize-options.js +55 -0
  59. package/src/generators/library/library.d.ts +4 -0
  60. package/src/generators/library/library.js +71 -0
  61. package/src/generators/library/schema.d.ts +41 -0
  62. package/src/generators/library/schema.json +139 -0
  63. package/src/generators/setup-tailwind/files/postcss.config.js.template +10 -0
  64. package/src/generators/setup-tailwind/files/tailwind.config.js.template +18 -0
  65. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.d.ts +3 -0
  66. package/src/generators/setup-tailwind/lib/add-tailwind-style-imports.js +25 -0
  67. package/src/generators/setup-tailwind/schema.d.ts +6 -0
  68. package/src/generators/setup-tailwind/schema.json +45 -0
  69. package/src/generators/setup-tailwind/setup-tailwind.d.ts +4 -0
  70. package/src/generators/setup-tailwind/setup-tailwind.js +25 -0
  71. package/src/generators/stories/lib/component-story.d.ts +3 -0
  72. package/src/generators/stories/lib/component-story.js +34 -0
  73. package/src/generators/stories/lib/files/js/__componentFileName__.stories.js__tmpl__ +25 -0
  74. package/src/generators/stories/lib/files/ts/__componentFileName__.stories.ts__tmpl__ +32 -0
  75. package/src/generators/stories/lib/utils.d.ts +10 -0
  76. package/src/generators/stories/lib/utils.js +75 -0
  77. package/src/generators/stories/schema.json +64 -0
  78. package/src/generators/stories/stories.d.ts +13 -0
  79. package/src/generators/stories/stories.js +61 -0
  80. package/src/generators/storybook-configuration/configuration.d.ts +4 -0
  81. package/src/generators/storybook-configuration/configuration.js +35 -0
  82. package/src/generators/storybook-configuration/schema.d.ts +12 -0
  83. package/src/generators/storybook-configuration/schema.json +77 -0
  84. package/src/tailwind.d.ts +6 -0
  85. package/src/tailwind.js +29 -0
  86. package/src/utils/add-linting.d.ts +12 -0
  87. package/src/utils/add-linting.js +121 -0
  88. package/src/utils/ast-utils.d.ts +3 -0
  89. package/src/utils/ast-utils.js +33 -0
  90. package/src/utils/create-ts-config.d.ts +9 -0
  91. package/src/utils/create-ts-config.js +66 -0
  92. package/src/utils/lint.d.ts +9 -0
  93. package/src/utils/lint.js +26 -0
  94. package/src/utils/setup-jest.d.ts +4 -0
  95. package/src/utils/setup-jest.js +96 -0
  96. package/src/utils/test-utils.d.ts +3 -0
  97. package/src/utils/test-utils.js +30 -0
  98. package/src/utils/versions.d.ts +16 -0
  99. package/src/utils/versions.js +25 -0
@@ -0,0 +1,15 @@
1
+ <% if (style !== 'none') { %>
2
+ import './styles.<%= style %>';
3
+ <% } %>
4
+ <% if (routing) { %>
5
+ import router from './router';
6
+ <% } %>
7
+
8
+ import { createApp } from 'vue';
9
+ import App from './app/App.vue';
10
+
11
+ const app = createApp(App);
12
+ <% if (routing) { %>
13
+ app.use(router);
14
+ <% } %>
15
+ app.mount('#root');
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "<%= offsetFromRoot %>dist/out-tsc"
5
+ },
6
+ "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts", "src/**/*.spec.vue", "src/**/*.test.vue"],
7
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.vue"]
8
+ }
@@ -0,0 +1,23 @@
1
+ import { createRouter, createWebHistory } from 'vue-router'
2
+ import HomeView from '../views/HomeView.vue'
3
+
4
+ const router = createRouter({
5
+ history: createWebHistory(import.meta.env.BASE_URL),
6
+ routes: [
7
+ {
8
+ path: '/',
9
+ name: 'home',
10
+ component: HomeView
11
+ },
12
+ {
13
+ path: '/about',
14
+ name: 'about',
15
+ // route level code-splitting
16
+ // this generates a separate chunk (About.[hash].js) for this route
17
+ // which is lazy-loaded when the route is visited.
18
+ component: () => import('../views/AboutView.vue')
19
+ }
20
+ ]
21
+ })
22
+
23
+ export default router
@@ -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>
@@ -0,0 +1,9 @@
1
+ <script setup lang="ts">
2
+ import NxWelcome from '../app/NxWelcome.vue'
3
+ </script>
4
+
5
+ <template>
6
+ <main>
7
+ <NxWelcome />
8
+ </main>
9
+ </template>
@@ -0,0 +1,42 @@
1
+ html {
2
+ -webkit-text-size-adjust: 100%;
3
+ font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
4
+ 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
5
+ 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
6
+ 'Noto Color Emoji';
7
+ line-height: 1.5;
8
+ tab-size: 4;
9
+ scroll-behavior: smooth;
10
+ }
11
+ body {
12
+ font-family: inherit;
13
+ line-height: inherit;
14
+ margin: 0;
15
+ }
16
+ h1,
17
+ h2,
18
+ p,
19
+ pre {
20
+ margin: 0;
21
+ }
22
+ *,
23
+ ::before,
24
+ ::after {
25
+ box-sizing: border-box;
26
+ border-width: 0;
27
+ border-style: solid;
28
+ border-color: currentColor;
29
+ }
30
+ h1,
31
+ h2 {
32
+ font-size: inherit;
33
+ font-weight: inherit;
34
+ }
35
+ a {
36
+ color: inherit;
37
+ text-decoration: inherit;
38
+ }
39
+ pre {
40
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
41
+ 'Liberation Mono', 'Courier New', monospace;
42
+ }
@@ -0,0 +1,3 @@
1
+ import type { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from '../schema';
3
+ export declare function addE2e(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addE2e = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const web_1 = require("@nx/web");
6
+ const versions_1 = require("../../../utils/versions");
7
+ async function addE2e(tree, options) {
8
+ switch (options.e2eTestRunner) {
9
+ case 'cypress':
10
+ (0, web_1.webStaticServeGenerator)(tree, {
11
+ buildTarget: `${options.projectName}:build`,
12
+ targetName: 'serve-static',
13
+ });
14
+ const { cypressProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
15
+ return await cypressProjectGenerator(tree, {
16
+ ...options,
17
+ name: options.e2eProjectName,
18
+ directory: options.e2eProjectRoot,
19
+ projectNameAndRootFormat: 'as-provided',
20
+ project: options.projectName,
21
+ bundler: 'vite',
22
+ skipFormat: true,
23
+ });
24
+ case 'playwright':
25
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
26
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
27
+ root: options.e2eProjectRoot,
28
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
29
+ targets: {},
30
+ implicitDependencies: [options.projectName],
31
+ });
32
+ return configurationGenerator(tree, {
33
+ project: options.e2eProjectName,
34
+ skipFormat: true,
35
+ skipPackageJson: options.skipPackageJson,
36
+ directory: 'src',
37
+ js: false,
38
+ linter: options.linter,
39
+ setParserOptionsProject: options.setParserOptionsProject,
40
+ webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
41
+ webServerAddress: 'http://localhost:4200',
42
+ });
43
+ case 'none':
44
+ default:
45
+ return () => { };
46
+ }
47
+ }
48
+ exports.addE2e = addE2e;
@@ -0,0 +1,5 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ export declare function addJest(tree: Tree, options: {
3
+ name: string;
4
+ projectRoot: string;
5
+ }): Promise<GeneratorCallback>;
@@ -0,0 +1,22 @@
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
+ tasks.push(await configurationGenerator(tree, {
11
+ project: options.name,
12
+ skipFormat: true,
13
+ testEnvironment: 'jsdom',
14
+ compiler: 'babel',
15
+ }));
16
+ (0, setup_jest_1.setupJestProject)(tree, options.projectRoot);
17
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
18
+ '@vue/vue3-jest': versions_1.vueJest3Version,
19
+ }));
20
+ return (0, devkit_1.runTasksInSerial)(...tasks);
21
+ }
22
+ exports.addJest = addJest;
@@ -0,0 +1,3 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from '../schema';
3
+ export declare function addVite(tree: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addVite = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const vite_1 = require("@nx/vite");
6
+ async function addVite(tree, options) {
7
+ // Set up build target (and test target if using vitest)
8
+ const viteTask = await (0, vite_1.viteConfigurationGenerator)(tree, {
9
+ uiFramework: 'none',
10
+ project: options.name,
11
+ newProject: true,
12
+ inSourceTests: options.inSourceTests,
13
+ includeVitest: options.unitTestRunner === 'vitest',
14
+ skipFormat: true,
15
+ testEnvironment: 'jsdom',
16
+ });
17
+ (0, vite_1.createOrEditViteConfig)(tree, {
18
+ project: options.name,
19
+ includeLib: false,
20
+ includeVitest: options.unitTestRunner === 'vitest',
21
+ inSourceTests: options.inSourceTests,
22
+ imports: [`import vue from '@vitejs/plugin-vue'`],
23
+ plugins: ['vue()'],
24
+ }, false);
25
+ // Update build to skip type checking since tsc won't work on .vue files.
26
+ // Need to use vue-tsc instead.
27
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.name);
28
+ projectConfig.targets.build.options.skipTypeCheck = true;
29
+ (0, devkit_1.updateProjectConfiguration)(tree, options.name, projectConfig);
30
+ return viteTask;
31
+ }
32
+ exports.addVite = addVite;
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema } from '../schema';
3
+ export declare function createApplicationFiles(tree: Tree, options: NormalizedSchema): void;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createApplicationFiles = void 0;
4
+ const path = require("path");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const js_1 = require("@nx/js");
7
+ const create_ts_config_1 = require("../../../utils/create-ts-config");
8
+ function createApplicationFiles(tree, options) {
9
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, '../files/common'), options.appProjectRoot, {
10
+ ...options,
11
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
12
+ title: options.projectName,
13
+ });
14
+ if (options.style !== 'none') {
15
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, '../files/stylesheet'), options.appProjectRoot, {
16
+ ...options,
17
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
18
+ title: options.projectName,
19
+ });
20
+ }
21
+ if (options.routing) {
22
+ (0, devkit_1.generateFiles)(tree, path.join(__dirname, '../files/routing'), options.appProjectRoot, {
23
+ ...options,
24
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.appProjectRoot),
25
+ title: options.projectName,
26
+ });
27
+ }
28
+ (0, create_ts_config_1.createTsConfig)(tree, options.appProjectRoot, 'app', options, (0, js_1.getRelativePathToRootTsConfig)(tree, options.appProjectRoot));
29
+ }
30
+ exports.createApplicationFiles = createApplicationFiles;
@@ -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,45 @@
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/vue: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
+ };
39
+ normalized.style = options.style ?? 'css';
40
+ normalized.routing = normalized.routing ?? false;
41
+ normalized.unitTestRunner ??= 'vitest';
42
+ normalized.e2eTestRunner = normalized.e2eTestRunner ?? 'cypress';
43
+ return normalized;
44
+ }
45
+ exports.normalizeOptions = normalizeOptions;
@@ -0,0 +1,30 @@
1
+ import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+ import type { Linter } from '@nx/linter';
3
+
4
+ export interface Schema {
5
+ name: string;
6
+ style: 'none' | 'css' | 'scss' | 'less';
7
+ skipFormat?: boolean;
8
+ directory?: string;
9
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
10
+ tags?: string;
11
+ unitTestRunner?: 'jest' | 'vitest' | 'none';
12
+ inSourceTests?: boolean;
13
+ e2eTestRunner: 'cypress' | 'playwright' | 'none';
14
+ linter: Linter;
15
+ routing?: boolean;
16
+ js?: boolean;
17
+ strict?: boolean;
18
+ setParserOptionsProject?: boolean;
19
+ skipPackageJson?: boolean;
20
+ rootProject?: boolean;
21
+ }
22
+
23
+ export interface NormalizedSchema extends Schema {
24
+ projectName: string;
25
+ appProjectRoot: string;
26
+ e2eProjectName: string;
27
+ e2eProjectRoot: string;
28
+ parsedTags: string[];
29
+ devServerPort?: number;
30
+ }
@@ -0,0 +1,140 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "NxVueApp",
5
+ "title": "Create a Vue Application",
6
+ "description": "Create a Vue application for Nx.",
7
+ "examples": [
8
+ {
9
+ "command": "nx g app myapp --directory=myorg/myapp",
10
+ "description": "Generate `apps/myorg/myapp` and `apps/myorg/myapp-e2e`"
11
+ },
12
+ {
13
+ "command": "nx g app myapp --routing",
14
+ "description": "Set up Vue Router"
15
+ }
16
+ ],
17
+ "type": "object",
18
+ "properties": {
19
+ "name": {
20
+ "description": "The name of the application.",
21
+ "type": "string",
22
+ "$default": {
23
+ "$source": "argv",
24
+ "index": 0
25
+ },
26
+ "x-prompt": "What name would you like to use for the application?",
27
+ "pattern": "^[a-zA-Z][^:]*$"
28
+ },
29
+ "directory": {
30
+ "description": "The directory of the new application.",
31
+ "type": "string",
32
+ "alias": "dir",
33
+ "x-priority": "important"
34
+ },
35
+ "projectNameAndRootFormat": {
36
+ "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`).",
37
+ "type": "string",
38
+ "enum": ["as-provided", "derived"]
39
+ },
40
+ "style": {
41
+ "description": "The file extension to be used for style files.",
42
+ "type": "string",
43
+ "default": "css",
44
+ "alias": "s",
45
+ "x-prompt": {
46
+ "message": "Which stylesheet format would you like to use?",
47
+ "type": "list",
48
+ "items": [
49
+ {
50
+ "value": "css",
51
+ "label": "CSS"
52
+ },
53
+ {
54
+ "value": "scss",
55
+ "label": "SASS(.scss) [ http://sass-lang.com ]"
56
+ },
57
+ {
58
+ "value": "less",
59
+ "label": "LESS [ http://lesscss.org ]"
60
+ },
61
+ {
62
+ "value": "none",
63
+ "label": "None"
64
+ }
65
+ ]
66
+ }
67
+ },
68
+ "linter": {
69
+ "description": "The tool to use for running lint checks.",
70
+ "type": "string",
71
+ "enum": ["eslint", "none"],
72
+ "default": "eslint"
73
+ },
74
+ "routing": {
75
+ "type": "boolean",
76
+ "description": "Generate application with routes.",
77
+ "x-prompt": "Would you like to add Vue Router to this application?",
78
+ "default": false
79
+ },
80
+ "skipFormat": {
81
+ "description": "Skip formatting files.",
82
+ "type": "boolean",
83
+ "default": false,
84
+ "x-priority": "internal"
85
+ },
86
+ "unitTestRunner": {
87
+ "type": "string",
88
+ "enum": ["jest", "vitest", "none"],
89
+ "description": "Test runner to use for unit tests.",
90
+ "x-prompt": "Which unit test runner would you like to use?",
91
+ "default": "none"
92
+ },
93
+ "inSourceTests": {
94
+ "type": "boolean",
95
+ "default": false,
96
+ "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"
97
+ },
98
+ "e2eTestRunner": {
99
+ "type": "string",
100
+ "enum": ["cypress", "playwright", "none"],
101
+ "description": "Test runner to use for end to end (E2E) tests.",
102
+ "x-prompt": "Which E2E test runner would you like to use?",
103
+ "default": "cypress"
104
+ },
105
+ "tags": {
106
+ "type": "string",
107
+ "description": "Add tags to the application (used for linting).",
108
+ "alias": "t"
109
+ },
110
+ "js": {
111
+ "type": "boolean",
112
+ "description": "Generate JavaScript files rather than TypeScript files.",
113
+ "default": false
114
+ },
115
+ "strict": {
116
+ "type": "boolean",
117
+ "description": "Whether to enable tsconfig strict mode or not.",
118
+ "default": true
119
+ },
120
+ "setParserOptionsProject": {
121
+ "type": "boolean",
122
+ "description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
123
+ "default": false
124
+ },
125
+ "skipPackageJson": {
126
+ "description": "Do not add dependencies to `package.json`.",
127
+ "type": "boolean",
128
+ "default": false,
129
+ "x-priority": "internal"
130
+ },
131
+ "rootProject": {
132
+ "description": "Create a application at the root of the workspace",
133
+ "type": "boolean",
134
+ "default": false,
135
+ "hidden": true
136
+ }
137
+ },
138
+ "required": ["name"],
139
+ "examplesFile": "../../../docs/application-examples.md"
140
+ }
@@ -0,0 +1,4 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { Schema } from './schema';
3
+ export declare function componentGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export default componentGenerator;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.componentGenerator = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ const utils_1 = require("./lib/utils");
7
+ async function componentGenerator(host, schema) {
8
+ const workspace = (0, devkit_1.getProjects)(host);
9
+ const isApp = workspace.get(schema.project).projectType === 'application';
10
+ const options = await (0, utils_1.normalizeOptions)(host, schema, isApp);
11
+ createComponentFiles(host, options);
12
+ const tasks = [];
13
+ (0, utils_1.addExportsToBarrel)(host, options, isApp);
14
+ if (!options.skipFormat) {
15
+ await (0, devkit_1.formatFiles)(host);
16
+ }
17
+ return (0, devkit_1.runTasksInSerial)(...tasks);
18
+ }
19
+ exports.componentGenerator = componentGenerator;
20
+ function createComponentFiles(host, options) {
21
+ const componentDir = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.directory);
22
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, './files'), componentDir, {
23
+ ...options,
24
+ tmpl: '',
25
+ unitTestRunner: options.unitTestRunner,
26
+ });
27
+ for (const c of host.listChanges()) {
28
+ let deleteFile = false;
29
+ if ((options.skipTests || options.inSourceTests) &&
30
+ /.*spec.ts/.test(c.path)) {
31
+ deleteFile = true;
32
+ }
33
+ if (deleteFile) {
34
+ host.delete(c.path);
35
+ }
36
+ }
37
+ if (options.js)
38
+ (0, devkit_1.toJS)(host);
39
+ }
40
+ exports.default = componentGenerator;
@@ -0,0 +1,13 @@
1
+ <% if ( unitTestRunner === 'vitest' ) { %>
2
+ import { describe, it, expect } from 'vitest'
3
+ <% } %>
4
+
5
+ import { mount } from '@vue/test-utils'
6
+ import <%= className %> from './<%= fileName %>.vue';
7
+
8
+ describe('<%= className %>', () => {
9
+ it('renders properly', () => {
10
+ const wrapper = mount(<%= className %>, {})
11
+ expect(wrapper.text()).toContain('Welcome to <%= className %>')
12
+ })
13
+ });
@@ -0,0 +1,10 @@
1
+ <script setup lang="ts">
2
+ defineProps<{}>()
3
+ </script>
4
+
5
+ <template>
6
+ <p>Welcome to <%= className %>!</p>
7
+ </template>
8
+
9
+ <style scoped>
10
+ </style>
@@ -0,0 +1,7 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { NormalizedSchema, Schema } from '../schema';
3
+ export declare function normalizeOptions(host: Tree, options: Schema, isApp: boolean): Promise<NormalizedSchema>;
4
+ export declare function getComponentClassName(componentName: string, isApp: boolean, projectName: string, directory?: string): string;
5
+ export declare function addExportsToBarrel(host: Tree, options: NormalizedSchema, isApp: boolean): void;
6
+ export declare function getDirectory(options: Schema): Promise<string>;
7
+ export declare function assertValidOptions(options: Schema): void;