@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,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.storiesGenerator = exports.createAllStories = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ const versions_1 = require("../../utils/versions");
7
+ const component_story_1 = require("./lib/component-story");
8
+ const minimatch = require("minimatch");
9
+ async function createAllStories(tree, projectName, interactionTests, js, projectConfiguration, ignorePaths) {
10
+ const { sourceRoot, root } = projectConfiguration;
11
+ let componentPaths = [];
12
+ const pathsToCheck = [
13
+ (0, devkit_1.joinPathFragments)(sourceRoot, 'app'),
14
+ (0, devkit_1.joinPathFragments)(sourceRoot, 'components'), // Additional component folder
15
+ ];
16
+ for (const p of pathsToCheck) {
17
+ (0, devkit_1.visitNotIgnoredFiles)(tree, p, (path) => {
18
+ // Ignore private files starting with "_".
19
+ if ((0, path_1.basename)(path).startsWith('_'))
20
+ return;
21
+ if (ignorePaths?.some((pattern) => minimatch(path, pattern)))
22
+ return;
23
+ if (path.endsWith('.vue')) {
24
+ // Let's see if the .stories.* file exists
25
+ const ext = path.slice(path.lastIndexOf('.'));
26
+ const storyPathJs = `${path.split(ext)[0]}.stories.js`;
27
+ const storyPathTs = `${path.split(ext)[0]}.stories.ts`;
28
+ if (!tree.exists(storyPathJs) && !tree.exists(storyPathTs)) {
29
+ componentPaths.push(path);
30
+ }
31
+ }
32
+ });
33
+ }
34
+ await Promise.all(componentPaths.map(async (componentPath) => {
35
+ const relativeCmpDir = componentPath.replace((0, path_1.join)(sourceRoot, '/'), '');
36
+ (0, component_story_1.createComponentStories)(tree, {
37
+ project: projectName,
38
+ interactionTests,
39
+ js,
40
+ }, relativeCmpDir);
41
+ }));
42
+ }
43
+ exports.createAllStories = createAllStories;
44
+ async function storiesGenerator(host, schema) {
45
+ const projects = (0, devkit_1.getProjects)(host);
46
+ const projectConfiguration = projects.get(schema.project);
47
+ schema.interactionTests = schema.interactionTests ?? true;
48
+ await createAllStories(host, schema.project, schema.interactionTests, schema.js, projectConfiguration, schema.ignorePaths);
49
+ const tasks = [];
50
+ if (schema.interactionTests) {
51
+ const { interactionTestsDependencies, addInteractionsInAddons } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
52
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, interactionTestsDependencies()));
53
+ addInteractionsInAddons(host, projectConfiguration);
54
+ }
55
+ if (!schema.skipFormat) {
56
+ await (0, devkit_1.formatFiles)(host);
57
+ }
58
+ return (0, devkit_1.runTasksInSerial)(...tasks);
59
+ }
60
+ exports.storiesGenerator = storiesGenerator;
61
+ exports.default = storiesGenerator;
@@ -0,0 +1,4 @@
1
+ import { StorybookConfigureSchema } from './schema';
2
+ import { Tree } from '@nx/devkit';
3
+ export declare function storybookConfigurationGenerator(host: Tree, schema: StorybookConfigureSchema): Promise<import("@nx/devkit").GeneratorCallback>;
4
+ export default storybookConfigurationGenerator;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.storybookConfigurationGenerator = void 0;
4
+ const stories_1 = require("../stories/stories");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const versions_1 = require("../../utils/versions");
7
+ async function generateStories(host, schema) {
8
+ await (0, stories_1.default)(host, {
9
+ project: schema.name,
10
+ js: schema.js,
11
+ ignorePaths: schema.ignorePaths,
12
+ skipFormat: true,
13
+ interactionTests: schema.interactionTests ?? true,
14
+ });
15
+ }
16
+ async function storybookConfigurationGenerator(host, schema) {
17
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
18
+ const installTask = await configurationGenerator(host, {
19
+ name: schema.name,
20
+ js: schema.js,
21
+ linter: schema.linter,
22
+ tsConfiguration: schema.tsConfiguration ?? true,
23
+ interactionTests: schema.interactionTests ?? true,
24
+ configureStaticServe: schema.configureStaticServe,
25
+ uiFramework: '@storybook/vue3-vite',
26
+ skipFormat: true,
27
+ });
28
+ if (schema.generateStories) {
29
+ await generateStories(host, schema);
30
+ }
31
+ await (0, devkit_1.formatFiles)(host);
32
+ return installTask;
33
+ }
34
+ exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
35
+ exports.default = storybookConfigurationGenerator;
@@ -0,0 +1,12 @@
1
+ import { Linter } from '@nx/linter';
2
+
3
+ export interface StorybookConfigureSchema {
4
+ name: 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,77 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "NxVueStorybookConfigure",
5
+ "title": "Vue Storybook Configure",
6
+ "description": "Set up Storybook for a Vue project.",
7
+ "type": "object",
8
+ "properties": {
9
+ "name": {
10
+ "type": "string",
11
+ "aliases": ["project", "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
+ "examples": [
67
+ "apps/my-app/src/not-stories/**",
68
+ "**/**/src/**/not-stories/**",
69
+ "libs/my-lib/**/*.something.ts",
70
+ "**/**/src/**/*.other.*",
71
+ "libs/my-lib/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts"
72
+ ]
73
+ }
74
+ },
75
+ "required": ["name"],
76
+ "examplesFile": "../../../docs/storybook-configuration-examples.md"
77
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates a set of glob patterns based off the source root of the app and its dependencies
3
+ * @param dirPath workspace relative directory path that will be used to infer the parent project and dependencies
4
+ * @param fileGlobPattern pass a custom glob pattern to be used
5
+ */
6
+ export declare function createGlobPatternsForDependencies(dirPath: string, fileGlobPattern?: string): string[];
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createGlobPatternsForDependencies = void 0;
4
+ const generate_globs_1 = require("@nx/js/src/utils/generate-globs");
5
+ /**
6
+ * Generates a set of glob patterns based off the source root of the app and its dependencies
7
+ * @param dirPath workspace relative directory path that will be used to infer the parent project and dependencies
8
+ * @param fileGlobPattern pass a custom glob pattern to be used
9
+ */
10
+ function createGlobPatternsForDependencies(dirPath, fileGlobPattern = '/**/*!(*.stories|*.spec).{vue,tsx,ts,jsx,js}') {
11
+ try {
12
+ return (0, generate_globs_1.createGlobPatternsForDependencies)(dirPath, fileGlobPattern);
13
+ }
14
+ catch (e) {
15
+ /**
16
+ * It should not be possible to reach this point when the utility is invoked as part of the normal
17
+ * lifecycle of Nx executors. However, other tooling, such as the VSCode Tailwind IntelliSense plugin
18
+ * or JetBrains editors such as WebStorm, may execute the tailwind.config.js file in order to provide
19
+ * autocomplete features, for example.
20
+ *
21
+ * In order to best support that use-case, we therefore do not hard error when the ProjectGraph is
22
+ * fundamentally unavailable in this tailwind-specific context.
23
+ */
24
+ console.warn('\nWARNING: There was an error creating glob patterns, returning an empty array\n' +
25
+ `${e.message}\n`);
26
+ return [];
27
+ }
28
+ }
29
+ exports.createGlobPatternsForDependencies = createGlobPatternsForDependencies;
@@ -0,0 +1,12 @@
1
+ import { Tree } from 'nx/src/generators/tree';
2
+ import { Linter } from '@nx/linter';
3
+ export declare function addLinting(host: Tree, options: {
4
+ linter: Linter;
5
+ name: string;
6
+ projectRoot: string;
7
+ unitTestRunner?: 'jest' | 'vitest' | 'none';
8
+ setParserOptionsProject?: boolean;
9
+ skipPackageJson?: boolean;
10
+ rootProject?: boolean;
11
+ }, projectType: 'lib' | 'app'): Promise<import("@nx/devkit").GeneratorCallback>;
12
+ export declare function editEslintConfigFiles(tree: Tree, projectRoot: string, rootProject?: boolean): void;
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.editEslintConfigFiles = exports.addLinting = void 0;
4
+ const linter_1 = require("@nx/linter");
5
+ const path_1 = require("nx/src/utils/path");
6
+ const devkit_1 = require("@nx/devkit");
7
+ const lint_1 = require("./lint");
8
+ const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
9
+ const lint_project_1 = require("@nx/linter/src/generators/lint-project/lint-project");
10
+ async function addLinting(host, options, projectType) {
11
+ if (options.linter === linter_1.Linter.EsLint) {
12
+ const lintTask = await (0, linter_1.lintProjectGenerator)(host, {
13
+ linter: options.linter,
14
+ project: options.name,
15
+ tsConfigPaths: [
16
+ (0, path_1.joinPathFragments)(options.projectRoot, `tsconfig.${projectType}.json`),
17
+ ],
18
+ unitTestRunner: options.unitTestRunner,
19
+ eslintFilePatterns: [
20
+ (0, lint_project_1.mapLintPattern)(options.projectRoot, '{ts,tsx,js,jsx,vue}', options.rootProject),
21
+ ],
22
+ skipFormat: true,
23
+ setParserOptionsProject: options.setParserOptionsProject,
24
+ rootProject: options.rootProject,
25
+ });
26
+ if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
27
+ (0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, [
28
+ 'plugin:vue/vue3-essential',
29
+ 'eslint:recommended',
30
+ '@vue/eslint-config-typescript',
31
+ '@vue/eslint-config-prettier/skip-formatting',
32
+ ]);
33
+ }
34
+ editEslintConfigFiles(host, options.projectRoot, options.rootProject);
35
+ let installTask = () => { };
36
+ if (!options.skipPackageJson) {
37
+ installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
38
+ }
39
+ return (0, devkit_1.runTasksInSerial)(lintTask, installTask);
40
+ }
41
+ else {
42
+ return () => { };
43
+ }
44
+ }
45
+ exports.addLinting = addLinting;
46
+ function editEslintConfigFiles(tree, projectRoot, rootProject) {
47
+ if (tree.exists((0, path_1.joinPathFragments)(projectRoot, 'eslint.config.js'))) {
48
+ const fileName = (0, path_1.joinPathFragments)(projectRoot, 'eslint.config.js');
49
+ (0, devkit_1.updateJson)(tree, fileName, (json) => {
50
+ let updated = false;
51
+ for (let override of json.overrides) {
52
+ if (override.parserOptions) {
53
+ if (!override.files.includes('*.vue')) {
54
+ override.files.push('*.vue');
55
+ }
56
+ updated = true;
57
+ }
58
+ }
59
+ if (!updated) {
60
+ json.overrides = [
61
+ {
62
+ files: ['*.ts', '*.tsx', '*.js', '*.jsx', '*.vue'],
63
+ rules: {},
64
+ },
65
+ ];
66
+ }
67
+ return json;
68
+ });
69
+ }
70
+ else {
71
+ const fileName = (0, path_1.joinPathFragments)(projectRoot, '.eslintrc.json');
72
+ (0, devkit_1.updateJson)(tree, fileName, (json) => {
73
+ let updated = false;
74
+ for (let override of json.overrides) {
75
+ if (override.parserOptions) {
76
+ if (!override.files.includes('*.vue')) {
77
+ override.files.push('*.vue');
78
+ }
79
+ updated = true;
80
+ }
81
+ }
82
+ if (!updated) {
83
+ json.overrides = [
84
+ {
85
+ files: ['*.ts', '*.tsx', '*.js', '*.jsx', '*.vue'],
86
+ rules: {},
87
+ },
88
+ ];
89
+ }
90
+ return json;
91
+ });
92
+ }
93
+ // Edit root config too
94
+ if (tree.exists('.eslintrc.base.json')) {
95
+ (0, devkit_1.updateJson)(tree, '.eslintrc.base.json', (json) => {
96
+ for (let override of json.overrides) {
97
+ if (override.rules &&
98
+ '@nx/enforce-module-boundaries' in override.rules) {
99
+ if (!override.files.includes('*.vue')) {
100
+ override.files.push('*.vue');
101
+ }
102
+ }
103
+ }
104
+ return json;
105
+ });
106
+ }
107
+ else if (tree.exists('.eslintrc.json') && !rootProject) {
108
+ (0, devkit_1.updateJson)(tree, '.eslintrc.json', (json) => {
109
+ for (let override of json.overrides) {
110
+ if (override.rules &&
111
+ '@nx/enforce-module-boundaries' in override.rules) {
112
+ if (!override.files.includes('*.vue')) {
113
+ override.files.push('*.vue');
114
+ }
115
+ }
116
+ }
117
+ return json;
118
+ });
119
+ }
120
+ }
121
+ exports.editEslintConfigFiles = editEslintConfigFiles;
@@ -0,0 +1,3 @@
1
+ import type * as ts from 'typescript';
2
+ import { StringChange } from '@nx/devkit';
3
+ export declare function addImport(source: ts.SourceFile, statement: string): StringChange[];
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addImport = void 0;
4
+ const js_1 = require("@nx/js");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
7
+ let tsModule;
8
+ function addImport(source, statement) {
9
+ if (!tsModule) {
10
+ tsModule = (0, ensure_typescript_1.ensureTypescript)();
11
+ }
12
+ const allImports = (0, js_1.findNodes)(source, tsModule.SyntaxKind.ImportDeclaration);
13
+ if (allImports.length > 0) {
14
+ const lastImport = allImports[allImports.length - 1];
15
+ return [
16
+ {
17
+ type: devkit_1.ChangeType.Insert,
18
+ index: lastImport.end + 1,
19
+ text: `\n${statement}\n`,
20
+ },
21
+ ];
22
+ }
23
+ else {
24
+ return [
25
+ {
26
+ type: devkit_1.ChangeType.Insert,
27
+ index: 0,
28
+ text: `\n${statement}\n`,
29
+ },
30
+ ];
31
+ }
32
+ }
33
+ exports.addImport = addImport;
@@ -0,0 +1,9 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function createTsConfig(host: Tree, projectRoot: string, type: 'app' | 'lib', options: {
3
+ strict?: boolean;
4
+ style?: string;
5
+ bundler?: string;
6
+ rootProject?: boolean;
7
+ unitTestRunner?: string;
8
+ }, relativePathToRootTsConfig: string): void;
9
+ export declare function extractTsConfigBase(host: Tree): void;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractTsConfigBase = exports.createTsConfig = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const shared = require("@nx/js/src/utils/typescript/create-ts-config");
6
+ function createTsConfig(host, projectRoot, type, options, relativePathToRootTsConfig) {
7
+ const json = {
8
+ compilerOptions: {
9
+ allowJs: true,
10
+ esModuleInterop: false,
11
+ allowSyntheticDefaultImports: true,
12
+ strict: options.strict,
13
+ jsx: 'preserve',
14
+ jsxImportSource: 'vue',
15
+ moduleResolution: 'bundler',
16
+ resolveJsonModule: true,
17
+ verbatimModuleSyntax: options.unitTestRunner !== 'jest',
18
+ },
19
+ files: [],
20
+ include: [],
21
+ references: [
22
+ {
23
+ path: type === 'app' ? './tsconfig.app.json' : './tsconfig.lib.json',
24
+ },
25
+ ],
26
+ };
27
+ if (options.unitTestRunner === 'vitest') {
28
+ json.references.push({
29
+ path: './tsconfig.spec.json',
30
+ });
31
+ }
32
+ // inline tsconfig.base.json into the project
33
+ if (options.rootProject) {
34
+ json.compileOnSave = false;
35
+ json.compilerOptions = {
36
+ ...shared.tsConfigBaseOptions,
37
+ ...json.compilerOptions,
38
+ };
39
+ json.exclude = ['node_modules', 'tmp'];
40
+ }
41
+ else {
42
+ json.extends = relativePathToRootTsConfig;
43
+ }
44
+ (0, devkit_1.writeJson)(host, `${projectRoot}/tsconfig.json`, json);
45
+ const tsconfigProjectPath = `${projectRoot}/tsconfig.${type}.json`;
46
+ if (options.bundler === 'vite' && host.exists(tsconfigProjectPath)) {
47
+ (0, devkit_1.updateJson)(host, tsconfigProjectPath, (json) => {
48
+ json.compilerOptions ??= {};
49
+ const types = new Set(json.compilerOptions.types ?? []);
50
+ types.add('vite/client');
51
+ json.compilerOptions.types = Array.from(types);
52
+ return json;
53
+ });
54
+ }
55
+ else {
56
+ }
57
+ }
58
+ exports.createTsConfig = createTsConfig;
59
+ function extractTsConfigBase(host) {
60
+ shared.extractTsConfigBase(host);
61
+ if (host.exists('vite.config.ts')) {
62
+ const vite = host.read('vite.config.ts').toString();
63
+ host.write('vite.config.ts', vite.replace(`projects: []`, `projects: ['tsconfig.base.json']`));
64
+ }
65
+ }
66
+ exports.extractTsConfigBase = extractTsConfigBase;
@@ -0,0 +1,9 @@
1
+ export declare const extraEslintDependencies: {
2
+ dependencies: {};
3
+ devDependencies: {
4
+ '@vue/eslint-config-prettier': string;
5
+ '@vue/eslint-config-typescript': string;
6
+ 'eslint-plugin-vue': string;
7
+ };
8
+ };
9
+ export declare const extendVueEslintJson: (json: any) => any;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extendVueEslintJson = exports.extraEslintDependencies = void 0;
4
+ const versions_1 = require("./versions");
5
+ exports.extraEslintDependencies = {
6
+ dependencies: {},
7
+ devDependencies: {
8
+ '@vue/eslint-config-prettier': versions_1.vueEslintConfigPrettierVersion,
9
+ '@vue/eslint-config-typescript': versions_1.vueEslintConfigTypescriptVersion,
10
+ 'eslint-plugin-vue': versions_1.eslintPluginVueVersion,
11
+ },
12
+ };
13
+ const extendVueEslintJson = (json) => {
14
+ const { extends: pluginExtends, ...config } = json;
15
+ return {
16
+ extends: [
17
+ 'plugin:vue/vue3-essential',
18
+ 'eslint:recommended',
19
+ '@vue/eslint-config-typescript',
20
+ '@vue/eslint-config-prettier/skip-formatting',
21
+ ...(pluginExtends || []),
22
+ ],
23
+ ...config,
24
+ };
25
+ };
26
+ exports.extendVueEslintJson = extendVueEslintJson;
@@ -0,0 +1,4 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function setupJestProject(tree: Tree, projectRoot: string): void;
3
+ export declare function writeBabelRcFile(tree: Tree, projectRoot: string): void;
4
+ export declare function updateJestConfigTsFile(tree: Tree, projectRoot: string): void;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateJestConfigTsFile = exports.writeBabelRcFile = exports.setupJestProject = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ function setupJestProject(tree, projectRoot) {
6
+ updateJestConfigTsFile(tree, projectRoot);
7
+ writeBabelRcFile(tree, projectRoot);
8
+ }
9
+ exports.setupJestProject = setupJestProject;
10
+ function writeBabelRcFile(tree, projectRoot) {
11
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(projectRoot, '.babelrc'), {
12
+ presets: ['@nx/js/babel'],
13
+ });
14
+ }
15
+ exports.writeBabelRcFile = writeBabelRcFile;
16
+ function updateJestConfigTsFile(tree, projectRoot) {
17
+ const jestConfigTs = (0, devkit_1.joinPathFragments)(projectRoot, 'jest.config.ts');
18
+ if (tree.exists(jestConfigTs)) {
19
+ const { tsquery } = require('@phenomnomnominal/tsquery');
20
+ let fileContent = tree.read(jestConfigTs, 'utf-8');
21
+ const sourceFile = tsquery.ast(fileContent);
22
+ const settingsObject = tsquery.query(sourceFile, 'ObjectLiteralExpression')?.[0];
23
+ if (settingsObject) {
24
+ const moduleFileExtensions = tsquery.query(sourceFile, `PropertyAssignment:has(Identifier:has([name="moduleFileExtensions"]))`)?.[0];
25
+ if (moduleFileExtensions) {
26
+ fileContent = (0, devkit_1.applyChangesToString)(fileContent, [
27
+ {
28
+ type: devkit_1.ChangeType.Delete,
29
+ start: moduleFileExtensions.getStart(),
30
+ length: moduleFileExtensions.getEnd() -
31
+ moduleFileExtensions.getStart() +
32
+ 1,
33
+ },
34
+ ]);
35
+ }
36
+ const transformProperty = tsquery.query(sourceFile, `PropertyAssignment:has(Identifier:has([name="transform"]))`)?.[0];
37
+ if (transformProperty) {
38
+ fileContent = (0, devkit_1.applyChangesToString)(fileContent, [
39
+ {
40
+ type: devkit_1.ChangeType.Delete,
41
+ start: transformProperty.getStart(),
42
+ length: transformProperty.getEnd() - transformProperty.getStart() + 1,
43
+ },
44
+ ]);
45
+ }
46
+ const settingsObjectUpdated = tsquery.query(fileContent, 'ObjectLiteralExpression')?.[0];
47
+ fileContent = (0, devkit_1.applyChangesToString)(fileContent, [
48
+ {
49
+ type: devkit_1.ChangeType.Insert,
50
+ index: settingsObjectUpdated.getEnd() - 1,
51
+ text: `,
52
+ moduleFileExtensions: ['js', 'ts', 'json', 'vue'],
53
+ transform: {
54
+ '^.+\\.[tj]sx?$': ['babel-jest'],
55
+ '^.+\\.vue$': [
56
+ '@vue/vue3-jest',
57
+ {
58
+ tsConfig: './tsconfig.spec.json',
59
+ },
60
+ ],
61
+ },
62
+ testEnvironment: 'jsdom',
63
+ testMatch: ['**/*.spec.ts?(x)', '**/__tests__/*.ts?(x)'],
64
+ `,
65
+ },
66
+ ]);
67
+ tree.write(jestConfigTs, fileContent);
68
+ }
69
+ else {
70
+ writeNewJestConfig(tree, projectRoot);
71
+ }
72
+ }
73
+ else {
74
+ writeNewJestConfig(tree, projectRoot);
75
+ }
76
+ }
77
+ exports.updateJestConfigTsFile = updateJestConfigTsFile;
78
+ function writeNewJestConfig(tree, projectRoot) {
79
+ tree.write((0, devkit_1.joinPathFragments)(projectRoot, 'jest.config.js'), `
80
+ module.exports = {
81
+ preset: '${devkit_1.offsetFromRoot}/jest.preset.js',
82
+ moduleFileExtensions: ['js', 'ts', 'json', 'vue'],
83
+ transform: {
84
+ '^.+\\.[tj]sx?$': ['babel-jest'],
85
+ '^.+\\.vue$': [
86
+ '@vue/vue3-jest',
87
+ {
88
+ tsConfig: './tsconfig.spec.json',
89
+ },
90
+ ],
91
+ },
92
+ testEnvironment: 'jsdom',
93
+ testMatch: ['**/*.spec.ts?(x)', '**/__tests__/*.ts?(x)'],
94
+ };
95
+ `);
96
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function createApp(tree: Tree, appName: string): Promise<any>;
3
+ export declare function createLib(tree: Tree, libName: string): Promise<any>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createLib = exports.createApp = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const linter_1 = require("@nx/linter");
6
+ const application_1 = require("../generators/application/application");
7
+ async function createApp(tree, appName) {
8
+ await (0, application_1.default)(tree, {
9
+ e2eTestRunner: 'none',
10
+ linter: linter_1.Linter.EsLint,
11
+ skipFormat: true,
12
+ style: 'css',
13
+ unitTestRunner: 'none',
14
+ name: appName,
15
+ projectNameAndRootFormat: 'as-provided',
16
+ });
17
+ }
18
+ exports.createApp = createApp;
19
+ async function createLib(tree, libName) {
20
+ const { fileName } = (0, devkit_1.names)(libName);
21
+ tree.write(`/${fileName}/src/index.ts`, ``);
22
+ (0, devkit_1.addProjectConfiguration)(tree, fileName, {
23
+ tags: [],
24
+ root: `${fileName}`,
25
+ projectType: 'library',
26
+ sourceRoot: `${fileName}/src`,
27
+ targets: {},
28
+ });
29
+ }
30
+ exports.createLib = createLib;