@nx/vite 16.0.0-beta.1

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 (116) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +22 -0
  3. package/README.md +63 -0
  4. package/executors.d.ts +8 -0
  5. package/executors.js +19 -0
  6. package/executors.js.map +1 -0
  7. package/executors.json +46 -0
  8. package/generators.json +46 -0
  9. package/index.d.ts +8 -0
  10. package/index.js +20 -0
  11. package/index.js.map +1 -0
  12. package/migrations.json +80 -0
  13. package/package.json +60 -0
  14. package/plugins/rollup-replace-files.plugin.d.ts +16 -0
  15. package/plugins/rollup-replace-files.plugin.js +49 -0
  16. package/plugins/rollup-replace-files.plugin.js.map +1 -0
  17. package/src/executors/build/build.impl.d.ts +10 -0
  18. package/src/executors/build/build.impl.js +91 -0
  19. package/src/executors/build/build.impl.js.map +1 -0
  20. package/src/executors/build/compat.d.ts +2 -0
  21. package/src/executors/build/compat.js +10 -0
  22. package/src/executors/build/compat.js.map +1 -0
  23. package/src/executors/build/schema.d.js +3 -0
  24. package/src/executors/build/schema.d.js.map +1 -0
  25. package/src/executors/build/schema.d.ts +17 -0
  26. package/src/executors/build/schema.json +143 -0
  27. package/src/executors/dev-server/compat.d.ts +2 -0
  28. package/src/executors/dev-server/compat.js +10 -0
  29. package/src/executors/dev-server/compat.js.map +1 -0
  30. package/src/executors/dev-server/dev-server.impl.d.ts +8 -0
  31. package/src/executors/dev-server/dev-server.impl.js +68 -0
  32. package/src/executors/dev-server/dev-server.impl.js.map +1 -0
  33. package/src/executors/dev-server/schema.d.js +3 -0
  34. package/src/executors/dev-server/schema.d.js.map +1 -0
  35. package/src/executors/dev-server/schema.d.ts +14 -0
  36. package/src/executors/dev-server/schema.json +89 -0
  37. package/src/executors/preview-server/compat.d.ts +2 -0
  38. package/src/executors/preview-server/compat.js +10 -0
  39. package/src/executors/preview-server/compat.js.map +1 -0
  40. package/src/executors/preview-server/preview-server.impl.d.ts +7 -0
  41. package/src/executors/preview-server/preview-server.impl.js +107 -0
  42. package/src/executors/preview-server/preview-server.impl.js.map +1 -0
  43. package/src/executors/preview-server/schema.d.js +3 -0
  44. package/src/executors/preview-server/schema.d.js.map +1 -0
  45. package/src/executors/preview-server/schema.d.ts +12 -0
  46. package/src/executors/preview-server/schema.json +80 -0
  47. package/src/executors/test/compat.d.ts +2 -0
  48. package/src/executors/test/compat.js +10 -0
  49. package/src/executors/test/compat.js.map +1 -0
  50. package/src/executors/test/schema.d.js +3 -0
  51. package/src/executors/test/schema.d.js.map +1 -0
  52. package/src/executors/test/schema.d.ts +11 -0
  53. package/src/executors/test/schema.json +63 -0
  54. package/src/executors/test/vitest.impl.d.ts +6 -0
  55. package/src/executors/test/vitest.impl.js +130 -0
  56. package/src/executors/test/vitest.impl.js.map +1 -0
  57. package/src/generators/configuration/configuration.d.ts +5 -0
  58. package/src/generators/configuration/configuration.js +130 -0
  59. package/src/generators/configuration/configuration.js.map +1 -0
  60. package/src/generators/configuration/schema.d.js +3 -0
  61. package/src/generators/configuration/schema.d.js.map +1 -0
  62. package/src/generators/configuration/schema.d.ts +12 -0
  63. package/src/generators/configuration/schema.json +61 -0
  64. package/src/generators/init/init.d.ts +6 -0
  65. package/src/generators/init/init.js +84 -0
  66. package/src/generators/init/init.js.map +1 -0
  67. package/src/generators/init/schema.d.js +3 -0
  68. package/src/generators/init/schema.d.js.map +1 -0
  69. package/src/generators/init/schema.d.ts +4 -0
  70. package/src/generators/init/schema.json +22 -0
  71. package/src/generators/vitest/files/tsconfig.spec.json__tmpl__ +19 -0
  72. package/src/generators/vitest/schema.d.js +3 -0
  73. package/src/generators/vitest/schema.d.js.map +1 -0
  74. package/src/generators/vitest/schema.d.ts +9 -0
  75. package/src/generators/vitest/schema.json +49 -0
  76. package/src/generators/vitest/vitest-generator.d.ts +5 -0
  77. package/src/generators/vitest/vitest-generator.js +99 -0
  78. package/src/generators/vitest/vitest-generator.js.map +1 -0
  79. package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.d.ts +3 -0
  80. package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.js +63 -0
  81. package/src/migrations/update-15-3-1/update-vite-tsconfig-paths.js.map +1 -0
  82. package/src/migrations/update-15-3-4/set-mode-in-configuration.d.ts +3 -0
  83. package/src/migrations/update-15-3-4/set-mode-in-configuration.js +33 -0
  84. package/src/migrations/update-15-3-4/set-mode-in-configuration.js.map +1 -0
  85. package/src/migrations/update-15-4-3/update-report-directory.d.ts +3 -0
  86. package/src/migrations/update-15-4-3/update-report-directory.js +35 -0
  87. package/src/migrations/update-15-4-3/update-report-directory.js.map +1 -0
  88. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  89. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
  90. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
  91. package/src/utils/generator-utils.d.ts +34 -0
  92. package/src/utils/generator-utils.js +567 -0
  93. package/src/utils/generator-utils.js.map +1 -0
  94. package/src/utils/options-utils.d.ts +32 -0
  95. package/src/utils/options-utils.js +113 -0
  96. package/src/utils/options-utils.js.map +1 -0
  97. package/src/utils/test-files/angular-project.config.json +89 -0
  98. package/src/utils/test-files/react-lib-non-buildable-jest.json +25 -0
  99. package/src/utils/test-files/react-lib-non-buildable-vitest.json +25 -0
  100. package/src/utils/test-files/react-mixed-project.config.json +52 -0
  101. package/src/utils/test-files/react-project.config.json +85 -0
  102. package/src/utils/test-files/react-vite-project.config.json +57 -0
  103. package/src/utils/test-files/test-vite-configs.d.ts +32 -0
  104. package/src/utils/test-files/test-vite-configs.js +285 -0
  105. package/src/utils/test-files/test-vite-configs.js.map +1 -0
  106. package/src/utils/test-files/unknown-project.config.json +72 -0
  107. package/src/utils/test-files/web-project.config.json +72 -0
  108. package/src/utils/test-utils.d.ts +9 -0
  109. package/src/utils/test-utils.js +516 -0
  110. package/src/utils/test-utils.js.map +1 -0
  111. package/src/utils/versions.d.ts +13 -0
  112. package/src/utils/versions.js +37 -0
  113. package/src/utils/versions.js.map +1 -0
  114. package/src/utils/vite-config-edit-utils.d.ts +3 -0
  115. package/src/utils/vite-config-edit-utils.js +286 -0
  116. package/src/utils/vite-config-edit-utils.js.map +1 -0
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "ensureViteConfigIsCorrect", {
3
+ enumerable: true,
4
+ get: ()=>ensureViteConfigIsCorrect
5
+ });
6
+ const _devkit = require("@nx/devkit");
7
+ const _typescript = require("nx/src/utils/typescript");
8
+ function ensureViteConfigIsCorrect(tree, path, buildConfigString, buildConfigObject, dtsPlugin, dtsImportLine, pluginOption, testConfigString, testConfigObject, cacheDir, projectAlreadyHasViteTargets) {
9
+ const fileContent = tree.read(path, 'utf-8');
10
+ let updatedContent = undefined;
11
+ if (!(projectAlreadyHasViteTargets == null ? void 0 : projectAlreadyHasViteTargets.test) && (testConfigString == null ? void 0 : testConfigString.length)) {
12
+ updatedContent = handleBuildOrTestNode(fileContent, testConfigString, testConfigObject, 'test');
13
+ }
14
+ if (!(projectAlreadyHasViteTargets == null ? void 0 : projectAlreadyHasViteTargets.build) && (buildConfigString == null ? void 0 : buildConfigString.length)) {
15
+ updatedContent = handlePluginNode(updatedContent != null ? updatedContent : fileContent, dtsPlugin, dtsImportLine, pluginOption);
16
+ updatedContent = handleBuildOrTestNode(updatedContent != null ? updatedContent : fileContent, buildConfigString, buildConfigObject, 'build');
17
+ }
18
+ if (cacheDir == null ? void 0 : cacheDir.length) {
19
+ updatedContent = handleCacheDirNode(updatedContent != null ? updatedContent : fileContent, cacheDir);
20
+ }
21
+ if (updatedContent) {
22
+ tree.write(path, updatedContent);
23
+ return true;
24
+ } else {
25
+ return false;
26
+ }
27
+ }
28
+ function handleBuildOrTestNode(updatedFileContent, configContentString, configContentObject, name) {
29
+ const { tsquery } = require('@phenomnomnominal/tsquery');
30
+ const buildNode = tsquery.query(updatedFileContent, `PropertyAssignment:has(Identifier[name="${name}"])`);
31
+ if (buildNode.length) {
32
+ return tsquery.replace(updatedFileContent, `PropertyAssignment:has(Identifier[name="${name}"])`, (node)=>{
33
+ const found = tsquery.query(node, 'ObjectLiteralExpression');
34
+ return `${name}: {
35
+ ...${found == null ? void 0 : found[0].getText()},
36
+ ...${JSON.stringify(configContentObject)}
37
+ }`;
38
+ });
39
+ } else {
40
+ const foundDefineConfig = tsquery.query(updatedFileContent, 'CallExpression:has(Identifier[name="defineConfig"])');
41
+ if (foundDefineConfig.length) {
42
+ const conditionalConfig = tsquery.query(foundDefineConfig[0], 'ArrowFunction');
43
+ if (conditionalConfig.length) {
44
+ if (name === 'build') {
45
+ return transformConditionalConfig(conditionalConfig, updatedFileContent, configContentString);
46
+ } else {
47
+ // no test config in conditional config
48
+ return updatedFileContent;
49
+ }
50
+ } else {
51
+ const propertyAssignments = tsquery.query(foundDefineConfig[0], 'PropertyAssignment');
52
+ if (propertyAssignments.length) {
53
+ return (0, _devkit.applyChangesToString)(updatedFileContent, [
54
+ {
55
+ type: _devkit.ChangeType.Insert,
56
+ index: propertyAssignments[0].getStart(),
57
+ text: configContentString
58
+ }
59
+ ]);
60
+ } else {
61
+ return (0, _devkit.applyChangesToString)(updatedFileContent, [
62
+ {
63
+ type: _devkit.ChangeType.Insert,
64
+ index: foundDefineConfig[0].getStart() + 14,
65
+ text: configContentString
66
+ }
67
+ ]);
68
+ }
69
+ }
70
+ } else {
71
+ // build config does not exist and defineConfig is not used
72
+ // could also potentially be invalid syntax, so try-catch
73
+ try {
74
+ const defaultExport = tsquery.query(updatedFileContent, 'ExportAssignment');
75
+ const found = tsquery.query(defaultExport == null ? void 0 : defaultExport[0], 'ObjectLiteralExpression');
76
+ const startOfObject = found == null ? void 0 : found[0].getStart();
77
+ return (0, _devkit.applyChangesToString)(updatedFileContent, [
78
+ {
79
+ type: _devkit.ChangeType.Insert,
80
+ index: startOfObject + 1,
81
+ text: configContentString
82
+ }
83
+ ]);
84
+ } catch (e) {
85
+ return updatedFileContent;
86
+ }
87
+ }
88
+ }
89
+ }
90
+ function transformCurrentBuildObject(index, returnStatements, appFileContent, buildConfigObject) {
91
+ var ref;
92
+ if (!(returnStatements == null ? void 0 : returnStatements[index])) {
93
+ return undefined;
94
+ }
95
+ const { tsquery } = require('@phenomnomnominal/tsquery');
96
+ const currentBuildObject = (ref = tsquery.query(returnStatements[index], 'ObjectLiteralExpression')) == null ? void 0 : ref[0].getText();
97
+ const currentBuildObjectStart = returnStatements[index].getStart();
98
+ const currentBuildObjectEnd = returnStatements[index].getEnd();
99
+ const newReturnObject = tsquery.replace(returnStatements[index].getText(), 'ObjectLiteralExpression', (_node)=>{
100
+ return `{
101
+ ...${currentBuildObject},
102
+ ...${JSON.stringify(buildConfigObject)}
103
+ }`;
104
+ });
105
+ const newContents = (0, _devkit.applyChangesToString)(appFileContent, [
106
+ {
107
+ type: _devkit.ChangeType.Delete,
108
+ start: currentBuildObjectStart,
109
+ length: currentBuildObjectEnd - currentBuildObjectStart
110
+ },
111
+ {
112
+ type: _devkit.ChangeType.Insert,
113
+ index: currentBuildObjectStart,
114
+ text: newReturnObject
115
+ }
116
+ ]);
117
+ return newContents;
118
+ }
119
+ function transformConditionalConfig(conditionalConfig, appFileContent, buildConfigObject) {
120
+ const { tsquery } = require('@phenomnomnominal/tsquery');
121
+ const { SyntaxKind } = require('typescript');
122
+ const functionBlock = tsquery.query(conditionalConfig[0], 'Block');
123
+ const ifStatement = tsquery.query(functionBlock == null ? void 0 : functionBlock[0], 'IfStatement');
124
+ const binaryExpressions = tsquery.query(ifStatement == null ? void 0 : ifStatement[0], 'BinaryExpression');
125
+ const buildExists = binaryExpressions == null ? void 0 : binaryExpressions.find((binaryExpression)=>binaryExpression.getText() === `command === 'build'`);
126
+ const buildExistsExpressionIndex = binaryExpressions == null ? void 0 : binaryExpressions.findIndex((binaryExpression)=>binaryExpression.getText() === `command === 'build'`);
127
+ const serveExists = binaryExpressions == null ? void 0 : binaryExpressions.find((binaryExpression)=>binaryExpression.getText() === `command === 'serve'`);
128
+ const elseKeywordExists = (0, _typescript.findNodes)(ifStatement == null ? void 0 : ifStatement[0], SyntaxKind.ElseKeyword);
129
+ const returnStatements = tsquery.query(ifStatement[0], 'ReturnStatement');
130
+ if (!buildExists) {
131
+ if (serveExists && elseKeywordExists) {
132
+ var ref;
133
+ // build options live inside the else block
134
+ return (ref = transformCurrentBuildObject((returnStatements == null ? void 0 : returnStatements.length) - 1, returnStatements, appFileContent, buildConfigObject)) != null ? ref : appFileContent;
135
+ } else {
136
+ // no build options exist yet
137
+ const functionBlockStart = functionBlock == null ? void 0 : functionBlock[0].getStart();
138
+ const newContents = (0, _devkit.applyChangesToString)(appFileContent, [
139
+ {
140
+ type: _devkit.ChangeType.Insert,
141
+ index: functionBlockStart + 1,
142
+ text: `
143
+ if (command === 'build') {
144
+ return ${JSON.stringify(buildConfigObject)}
145
+ }
146
+ `
147
+ }
148
+ ]);
149
+ return newContents;
150
+ }
151
+ } else {
152
+ var ref1;
153
+ // build already exists
154
+ // it will be the return statement which lives
155
+ // at the buildExistsExpressionIndex
156
+ return (ref1 = transformCurrentBuildObject(buildExistsExpressionIndex, returnStatements, appFileContent, buildConfigObject)) != null ? ref1 : appFileContent;
157
+ }
158
+ }
159
+ function handlePluginNode(appFileContent, dtsPlugin, dtsImportLine, pluginOption) {
160
+ const { tsquery } = require('@phenomnomnominal/tsquery');
161
+ const file = tsquery.ast(appFileContent);
162
+ const pluginsNode = tsquery.query(file, 'PropertyAssignment:has(Identifier[name="plugins"])');
163
+ let writeFile = false;
164
+ if (pluginsNode.length) {
165
+ appFileContent = tsquery.replace(file.getText(), 'PropertyAssignment:has(Identifier[name="plugins"])', (node)=>{
166
+ const found = tsquery.query(node, 'ArrayLiteralExpression');
167
+ return `plugins: [
168
+ ...${found == null ? void 0 : found[0].getText()},
169
+ ${dtsPlugin}
170
+ ]`;
171
+ });
172
+ writeFile = true;
173
+ } else {
174
+ // Plugins node does not exist yet
175
+ // So make one from scratch
176
+ const foundDefineConfig = tsquery.query(file, 'CallExpression:has(Identifier[name="defineConfig"])');
177
+ if (foundDefineConfig.length) {
178
+ const conditionalConfig = tsquery.query(foundDefineConfig[0], 'ArrowFunction');
179
+ if (conditionalConfig.length) {
180
+ // We are NOT transforming the conditional config
181
+ // with plugins
182
+ writeFile = false;
183
+ } else {
184
+ const propertyAssignments = tsquery.query(foundDefineConfig[0], 'PropertyAssignment');
185
+ if (propertyAssignments.length) {
186
+ appFileContent = (0, _devkit.applyChangesToString)(appFileContent, [
187
+ {
188
+ type: _devkit.ChangeType.Insert,
189
+ index: propertyAssignments[0].getStart(),
190
+ text: pluginOption
191
+ }
192
+ ]);
193
+ writeFile = true;
194
+ } else {
195
+ appFileContent = (0, _devkit.applyChangesToString)(appFileContent, [
196
+ {
197
+ type: _devkit.ChangeType.Insert,
198
+ index: foundDefineConfig[0].getStart() + 14,
199
+ text: pluginOption
200
+ }
201
+ ]);
202
+ writeFile = true;
203
+ }
204
+ }
205
+ } else {
206
+ // Plugins option does not exist and defineConfig is not used
207
+ // could also potentially be invalid syntax, so try-catch
208
+ try {
209
+ const defaultExport = tsquery.query(file, 'ExportAssignment');
210
+ const found = tsquery == null ? void 0 : tsquery.query(defaultExport == null ? void 0 : defaultExport[0], 'ObjectLiteralExpression');
211
+ const startOfObject = found == null ? void 0 : found[0].getStart();
212
+ appFileContent = (0, _devkit.applyChangesToString)(appFileContent, [
213
+ {
214
+ type: _devkit.ChangeType.Insert,
215
+ index: startOfObject + 1,
216
+ text: pluginOption
217
+ }
218
+ ]);
219
+ writeFile = true;
220
+ } catch (e) {
221
+ writeFile = false;
222
+ }
223
+ }
224
+ }
225
+ if (writeFile) {
226
+ if (!appFileContent.includes(`import dts from 'vite-plugin-dts'`)) {
227
+ return dtsImportLine + '\n' + appFileContent;
228
+ }
229
+ return appFileContent;
230
+ }
231
+ return appFileContent;
232
+ }
233
+ function handleCacheDirNode(appFileContent, cacheDir) {
234
+ const { tsquery } = require('@phenomnomnominal/tsquery');
235
+ const file = tsquery.ast(appFileContent);
236
+ const cacheDirNode = tsquery.query(file, 'PropertyAssignment:has(Identifier[name="cacheDir"])');
237
+ if (!(cacheDirNode == null ? void 0 : cacheDirNode.length) || (cacheDirNode == null ? void 0 : cacheDirNode.length) === 0) {
238
+ // cacheDir node does not exist yet
239
+ // So make one from scratch
240
+ const foundDefineConfig = tsquery.query(file, 'CallExpression:has(Identifier[name="defineConfig"])');
241
+ if (foundDefineConfig.length) {
242
+ const conditionalConfig = tsquery.query(foundDefineConfig[0], 'ArrowFunction');
243
+ if (conditionalConfig.length) {
244
+ // We are NOT transforming the conditional config
245
+ // with cacheDir
246
+ } else {
247
+ const propertyAssignments = tsquery.query(foundDefineConfig[0], 'PropertyAssignment');
248
+ if (propertyAssignments.length) {
249
+ appFileContent = (0, _devkit.applyChangesToString)(appFileContent, [
250
+ {
251
+ type: _devkit.ChangeType.Insert,
252
+ index: propertyAssignments[0].getStart(),
253
+ text: cacheDir
254
+ }
255
+ ]);
256
+ } else {
257
+ appFileContent = (0, _devkit.applyChangesToString)(appFileContent, [
258
+ {
259
+ type: _devkit.ChangeType.Insert,
260
+ index: foundDefineConfig[0].getStart() + 14,
261
+ text: cacheDir
262
+ }
263
+ ]);
264
+ }
265
+ }
266
+ } else {
267
+ // cacheDir option does not exist and defineConfig is not used
268
+ // could also potentially be invalid syntax, so try-catch
269
+ try {
270
+ const defaultExport = tsquery.query(file, 'ExportAssignment');
271
+ const found = tsquery == null ? void 0 : tsquery.query(defaultExport == null ? void 0 : defaultExport[0], 'ObjectLiteralExpression');
272
+ const startOfObject = found == null ? void 0 : found[0].getStart();
273
+ appFileContent = (0, _devkit.applyChangesToString)(appFileContent, [
274
+ {
275
+ type: _devkit.ChangeType.Insert,
276
+ index: startOfObject + 1,
277
+ text: cacheDir
278
+ }
279
+ ]);
280
+ } catch (e) {}
281
+ }
282
+ }
283
+ return appFileContent;
284
+ }
285
+
286
+ //# sourceMappingURL=vite-config-edit-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../packages/vite/src/utils/vite-config-edit-utils.ts"],"sourcesContent":["import { applyChangesToString, ChangeType, Tree } from '@nx/devkit';\nimport { findNodes } from 'nx/src/utils/typescript';\nimport { TargetFlags } from './generator-utils';\nimport type { Node, ReturnStatement } from 'typescript';\n\nexport function ensureViteConfigIsCorrect(\n tree: Tree,\n path: string,\n buildConfigString: string,\n buildConfigObject: {},\n dtsPlugin: string,\n dtsImportLine: string,\n pluginOption: string,\n testConfigString: string,\n testConfigObject: {},\n cacheDir: string,\n projectAlreadyHasViteTargets?: TargetFlags\n): boolean {\n const fileContent = tree.read(path, 'utf-8');\n\n let updatedContent = undefined;\n\n if (!projectAlreadyHasViteTargets?.test && testConfigString?.length) {\n updatedContent = handleBuildOrTestNode(\n fileContent,\n testConfigString,\n testConfigObject,\n 'test'\n );\n }\n\n if (!projectAlreadyHasViteTargets?.build && buildConfigString?.length) {\n updatedContent = handlePluginNode(\n updatedContent ?? fileContent,\n dtsPlugin,\n dtsImportLine,\n pluginOption\n );\n\n updatedContent = handleBuildOrTestNode(\n updatedContent ?? fileContent,\n buildConfigString,\n buildConfigObject,\n 'build'\n );\n }\n\n if (cacheDir?.length) {\n updatedContent = handleCacheDirNode(\n updatedContent ?? fileContent,\n cacheDir\n );\n }\n if (updatedContent) {\n tree.write(path, updatedContent);\n return true;\n } else {\n return false;\n }\n}\n\nfunction handleBuildOrTestNode(\n updatedFileContent: string,\n configContentString: string,\n configContentObject: {},\n name: 'build' | 'test'\n): string | undefined {\n const { tsquery } = require('@phenomnomnominal/tsquery');\n const buildNode = tsquery.query(\n updatedFileContent,\n `PropertyAssignment:has(Identifier[name=\"${name}\"])`\n );\n\n if (buildNode.length) {\n return tsquery.replace(\n updatedFileContent,\n `PropertyAssignment:has(Identifier[name=\"${name}\"])`,\n (node: Node) => {\n const found = tsquery.query(node, 'ObjectLiteralExpression');\n return `${name}: {\n ...${found?.[0].getText()},\n ...${JSON.stringify(configContentObject)}\n }`;\n }\n );\n } else {\n const foundDefineConfig = tsquery.query(\n updatedFileContent,\n 'CallExpression:has(Identifier[name=\"defineConfig\"])'\n );\n\n if (foundDefineConfig.length) {\n const conditionalConfig = tsquery.query(\n foundDefineConfig[0],\n 'ArrowFunction'\n );\n\n if (conditionalConfig.length) {\n if (name === 'build') {\n return transformConditionalConfig(\n conditionalConfig,\n updatedFileContent,\n configContentString\n );\n } else {\n // no test config in conditional config\n return updatedFileContent;\n }\n } else {\n const propertyAssignments = tsquery.query(\n foundDefineConfig[0],\n 'PropertyAssignment'\n );\n\n if (propertyAssignments.length) {\n return applyChangesToString(updatedFileContent, [\n {\n type: ChangeType.Insert,\n index: propertyAssignments[0].getStart(),\n text: configContentString,\n },\n ]);\n } else {\n return applyChangesToString(updatedFileContent, [\n {\n type: ChangeType.Insert,\n index: foundDefineConfig[0].getStart() + 14,\n text: configContentString,\n },\n ]);\n }\n }\n } else {\n // build config does not exist and defineConfig is not used\n // could also potentially be invalid syntax, so try-catch\n try {\n const defaultExport = tsquery.query(\n updatedFileContent,\n 'ExportAssignment'\n );\n const found = tsquery.query(\n defaultExport?.[0],\n 'ObjectLiteralExpression'\n );\n const startOfObject = found?.[0].getStart();\n return applyChangesToString(updatedFileContent, [\n {\n type: ChangeType.Insert,\n index: startOfObject + 1,\n text: configContentString,\n },\n ]);\n } catch {\n return updatedFileContent;\n }\n }\n }\n}\n\nfunction transformCurrentBuildObject(\n index: number,\n returnStatements: ReturnStatement[],\n appFileContent: string,\n buildConfigObject: {}\n): string | undefined {\n if (!returnStatements?.[index]) {\n return undefined;\n }\n const { tsquery } = require('@phenomnomnominal/tsquery');\n const currentBuildObject = tsquery\n .query(returnStatements[index], 'ObjectLiteralExpression')?.[0]\n .getText();\n\n const currentBuildObjectStart = returnStatements[index].getStart();\n const currentBuildObjectEnd = returnStatements[index].getEnd();\n\n const newReturnObject = tsquery.replace(\n returnStatements[index].getText(),\n 'ObjectLiteralExpression',\n (_node: Node) => {\n return `{\n ...${currentBuildObject},\n ...${JSON.stringify(buildConfigObject)}\n }`;\n }\n );\n\n const newContents = applyChangesToString(appFileContent, [\n {\n type: ChangeType.Delete,\n start: currentBuildObjectStart,\n length: currentBuildObjectEnd - currentBuildObjectStart,\n },\n {\n type: ChangeType.Insert,\n index: currentBuildObjectStart,\n text: newReturnObject,\n },\n ]);\n\n return newContents;\n}\n\nfunction transformConditionalConfig(\n conditionalConfig: Node[],\n appFileContent: string,\n buildConfigObject: {}\n): string | undefined {\n const { tsquery } = require('@phenomnomnominal/tsquery');\n const { SyntaxKind } = require('typescript');\n const functionBlock = tsquery.query(conditionalConfig[0], 'Block');\n\n const ifStatement = tsquery.query(functionBlock?.[0], 'IfStatement');\n\n const binaryExpressions = tsquery.query(ifStatement?.[0], 'BinaryExpression');\n\n const buildExists = binaryExpressions?.find(\n (binaryExpression) => binaryExpression.getText() === `command === 'build'`\n );\n\n const buildExistsExpressionIndex = binaryExpressions?.findIndex(\n (binaryExpression) => binaryExpression.getText() === `command === 'build'`\n );\n\n const serveExists = binaryExpressions?.find(\n (binaryExpression) => binaryExpression.getText() === `command === 'serve'`\n );\n\n const elseKeywordExists = findNodes(ifStatement?.[0], SyntaxKind.ElseKeyword);\n const returnStatements: ReturnStatement[] = tsquery.query(\n ifStatement[0],\n 'ReturnStatement'\n );\n\n if (!buildExists) {\n if (serveExists && elseKeywordExists) {\n // build options live inside the else block\n\n return (\n transformCurrentBuildObject(\n returnStatements?.length - 1,\n returnStatements,\n appFileContent,\n buildConfigObject\n ) ?? appFileContent\n );\n } else {\n // no build options exist yet\n const functionBlockStart = functionBlock?.[0].getStart();\n const newContents = applyChangesToString(appFileContent, [\n {\n type: ChangeType.Insert,\n index: functionBlockStart + 1,\n text: `\n if (command === 'build') {\n return ${JSON.stringify(buildConfigObject)}\n }\n `,\n },\n ]);\n return newContents;\n }\n } else {\n // build already exists\n // it will be the return statement which lives\n // at the buildExistsExpressionIndex\n\n return (\n transformCurrentBuildObject(\n buildExistsExpressionIndex,\n returnStatements,\n appFileContent,\n buildConfigObject\n ) ?? appFileContent\n );\n }\n}\n\nfunction handlePluginNode(\n appFileContent: string,\n dtsPlugin: string,\n dtsImportLine: string,\n pluginOption: string\n): string | undefined {\n const { tsquery } = require('@phenomnomnominal/tsquery');\n\n const file = tsquery.ast(appFileContent);\n const pluginsNode = tsquery.query(\n file,\n 'PropertyAssignment:has(Identifier[name=\"plugins\"])'\n );\n\n let writeFile = false;\n\n if (pluginsNode.length) {\n appFileContent = tsquery.replace(\n file.getText(),\n 'PropertyAssignment:has(Identifier[name=\"plugins\"])',\n (node: Node) => {\n const found = tsquery.query(node, 'ArrayLiteralExpression');\n return `plugins: [\n ...${found?.[0].getText()},\n ${dtsPlugin}\n ]`;\n }\n );\n writeFile = true;\n } else {\n // Plugins node does not exist yet\n // So make one from scratch\n\n const foundDefineConfig = tsquery.query(\n file,\n 'CallExpression:has(Identifier[name=\"defineConfig\"])'\n );\n\n if (foundDefineConfig.length) {\n const conditionalConfig = tsquery.query(\n foundDefineConfig[0],\n 'ArrowFunction'\n );\n\n if (conditionalConfig.length) {\n // We are NOT transforming the conditional config\n // with plugins\n writeFile = false;\n } else {\n const propertyAssignments = tsquery.query(\n foundDefineConfig[0],\n 'PropertyAssignment'\n );\n\n if (propertyAssignments.length) {\n appFileContent = applyChangesToString(appFileContent, [\n {\n type: ChangeType.Insert,\n index: propertyAssignments[0].getStart(),\n text: pluginOption,\n },\n ]);\n writeFile = true;\n } else {\n appFileContent = applyChangesToString(appFileContent, [\n {\n type: ChangeType.Insert,\n index: foundDefineConfig[0].getStart() + 14,\n text: pluginOption,\n },\n ]);\n writeFile = true;\n }\n }\n } else {\n // Plugins option does not exist and defineConfig is not used\n // could also potentially be invalid syntax, so try-catch\n try {\n const defaultExport = tsquery.query(file, 'ExportAssignment');\n const found = tsquery?.query(\n defaultExport?.[0],\n 'ObjectLiteralExpression'\n );\n const startOfObject = found?.[0].getStart();\n appFileContent = applyChangesToString(appFileContent, [\n {\n type: ChangeType.Insert,\n index: startOfObject + 1,\n text: pluginOption,\n },\n ]);\n writeFile = true;\n } catch {\n writeFile = false;\n }\n }\n }\n\n if (writeFile) {\n if (!appFileContent.includes(`import dts from 'vite-plugin-dts'`)) {\n return dtsImportLine + '\\n' + appFileContent;\n }\n return appFileContent;\n }\n return appFileContent;\n}\n\nfunction handleCacheDirNode(appFileContent: string, cacheDir: string): string {\n const { tsquery } = require('@phenomnomnominal/tsquery');\n\n const file = tsquery.ast(appFileContent);\n const cacheDirNode = tsquery.query(\n file,\n 'PropertyAssignment:has(Identifier[name=\"cacheDir\"])'\n );\n\n if (!cacheDirNode?.length || cacheDirNode?.length === 0) {\n // cacheDir node does not exist yet\n // So make one from scratch\n\n const foundDefineConfig = tsquery.query(\n file,\n 'CallExpression:has(Identifier[name=\"defineConfig\"])'\n );\n\n if (foundDefineConfig.length) {\n const conditionalConfig = tsquery.query(\n foundDefineConfig[0],\n 'ArrowFunction'\n );\n\n if (conditionalConfig.length) {\n // We are NOT transforming the conditional config\n // with cacheDir\n } else {\n const propertyAssignments = tsquery.query(\n foundDefineConfig[0],\n 'PropertyAssignment'\n );\n\n if (propertyAssignments.length) {\n appFileContent = applyChangesToString(appFileContent, [\n {\n type: ChangeType.Insert,\n index: propertyAssignments[0].getStart(),\n text: cacheDir,\n },\n ]);\n } else {\n appFileContent = applyChangesToString(appFileContent, [\n {\n type: ChangeType.Insert,\n index: foundDefineConfig[0].getStart() + 14,\n text: cacheDir,\n },\n ]);\n }\n }\n } else {\n // cacheDir option does not exist and defineConfig is not used\n // could also potentially be invalid syntax, so try-catch\n try {\n const defaultExport = tsquery.query(file, 'ExportAssignment');\n const found = tsquery?.query(\n defaultExport?.[0],\n 'ObjectLiteralExpression'\n );\n const startOfObject = found?.[0].getStart();\n appFileContent = applyChangesToString(appFileContent, [\n {\n type: ChangeType.Insert,\n index: startOfObject + 1,\n text: cacheDir,\n },\n ]);\n } catch {}\n }\n }\n\n return appFileContent;\n}\n"],"names":["ensureViteConfigIsCorrect","tree","path","buildConfigString","buildConfigObject","dtsPlugin","dtsImportLine","pluginOption","testConfigString","testConfigObject","cacheDir","projectAlreadyHasViteTargets","fileContent","read","updatedContent","undefined","test","length","handleBuildOrTestNode","build","handlePluginNode","handleCacheDirNode","write","updatedFileContent","configContentString","configContentObject","name","tsquery","require","buildNode","query","replace","node","found","getText","JSON","stringify","foundDefineConfig","conditionalConfig","transformConditionalConfig","propertyAssignments","applyChangesToString","type","ChangeType","Insert","index","getStart","text","defaultExport","startOfObject","transformCurrentBuildObject","returnStatements","appFileContent","currentBuildObject","currentBuildObjectStart","currentBuildObjectEnd","getEnd","newReturnObject","_node","newContents","Delete","start","SyntaxKind","functionBlock","ifStatement","binaryExpressions","buildExists","find","binaryExpression","buildExistsExpressionIndex","findIndex","serveExists","elseKeywordExists","findNodes","ElseKeyword","functionBlockStart","file","ast","pluginsNode","writeFile","includes","cacheDirNode"],"mappings":"AAAA;+BAKgBA;;aAAAA;;wBALuC;4BAC7B;AAInB,SAASA,0BACdC,IAAU,EACVC,IAAY,EACZC,iBAAyB,EACzBC,iBAAqB,EACrBC,SAAiB,EACjBC,aAAqB,EACrBC,YAAoB,EACpBC,gBAAwB,EACxBC,gBAAoB,EACpBC,QAAgB,EAChBC,4BAA0C,EACjC;IACT,MAAMC,cAAcX,KAAKY,IAAI,CAACX,MAAM;IAEpC,IAAIY,iBAAiBC;IAErB,IAAI,CAACJ,CAAAA,uCAAAA,KAAAA,IAAAA,6BAA8BK,IAAI,AAAD,KAAKR,CAAAA,2BAAAA,KAAAA,IAAAA,iBAAkBS,MAAM,AAAD,GAAG;QACnEH,iBAAiBI,sBACfN,aACAJ,kBACAC,kBACA;IAEJ,CAAC;IAED,IAAI,CAACE,CAAAA,uCAAAA,KAAAA,IAAAA,6BAA8BQ,KAAK,AAAD,KAAKhB,CAAAA,4BAAAA,KAAAA,IAAAA,kBAAmBc,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