@intlayer/chokidar 8.12.4 → 9.0.0-canary.0

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 (88) hide show
  1. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +21 -4
  2. package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
  3. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +94 -0
  4. package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
  5. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +1 -1
  6. package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
  7. package/dist/cjs/createType/createType.cjs.map +1 -1
  8. package/dist/cjs/init/index.cjs +63 -9
  9. package/dist/cjs/init/index.cjs.map +1 -1
  10. package/dist/cjs/init/utils/configManipulation.cjs +196 -0
  11. package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
  12. package/dist/cjs/init/utils/fileSystem.cjs +84 -0
  13. package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
  14. package/dist/cjs/init/utils/index.cjs +12 -0
  15. package/dist/cjs/init/utils/packageManager.cjs +187 -0
  16. package/dist/cjs/init/utils/packageManager.cjs.map +1 -0
  17. package/dist/cjs/scan/analyzeBundleContent.cjs +182 -0
  18. package/dist/cjs/scan/analyzeBundleContent.cjs.map +1 -0
  19. package/dist/cjs/scan/calculateScore.cjs +65 -0
  20. package/dist/cjs/scan/calculateScore.cjs.map +1 -0
  21. package/dist/cjs/scan/checks.cjs +274 -0
  22. package/dist/cjs/scan/checks.cjs.map +1 -0
  23. package/dist/cjs/scan/index.cjs +31 -0
  24. package/dist/cjs/scan/parseHtml.cjs +127 -0
  25. package/dist/cjs/scan/parseHtml.cjs.map +1 -0
  26. package/dist/cjs/scan/scanWebsite.cjs +205 -0
  27. package/dist/cjs/scan/scanWebsite.cjs.map +1 -0
  28. package/dist/cjs/scan/types.cjs +0 -0
  29. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs +22 -5
  30. package/dist/esm/buildIntlayerDictionary/buildIntlayerDictionary.mjs.map +1 -1
  31. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +93 -1
  32. package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs.map +1 -1
  33. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +2 -2
  34. package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs.map +1 -1
  35. package/dist/esm/createType/createType.mjs.map +1 -1
  36. package/dist/esm/init/index.mjs +65 -11
  37. package/dist/esm/init/index.mjs.map +1 -1
  38. package/dist/esm/init/utils/configManipulation.mjs +190 -1
  39. package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
  40. package/dist/esm/init/utils/fileSystem.mjs +83 -1
  41. package/dist/esm/init/utils/fileSystem.mjs.map +1 -1
  42. package/dist/esm/init/utils/index.mjs +4 -3
  43. package/dist/esm/init/utils/packageManager.mjs +183 -0
  44. package/dist/esm/init/utils/packageManager.mjs.map +1 -0
  45. package/dist/esm/scan/analyzeBundleContent.mjs +180 -0
  46. package/dist/esm/scan/analyzeBundleContent.mjs.map +1 -0
  47. package/dist/esm/scan/calculateScore.mjs +61 -0
  48. package/dist/esm/scan/calculateScore.mjs.map +1 -0
  49. package/dist/esm/scan/checks.mjs +265 -0
  50. package/dist/esm/scan/checks.mjs.map +1 -0
  51. package/dist/esm/scan/index.mjs +7 -0
  52. package/dist/esm/scan/parseHtml.mjs +115 -0
  53. package/dist/esm/scan/parseHtml.mjs.map +1 -0
  54. package/dist/esm/scan/scanWebsite.mjs +203 -0
  55. package/dist/esm/scan/scanWebsite.mjs.map +1 -0
  56. package/dist/esm/scan/types.mjs +0 -0
  57. package/dist/types/buildIntlayerDictionary/buildIntlayerDictionary.d.ts.map +1 -1
  58. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +31 -4
  59. package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
  60. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +13 -3
  61. package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
  62. package/dist/types/createType/createType.d.ts +3 -3
  63. package/dist/types/createType/createType.d.ts.map +1 -1
  64. package/dist/types/formatDictionary.d.ts +9 -2
  65. package/dist/types/formatDictionary.d.ts.map +1 -1
  66. package/dist/types/init/index.d.ts.map +1 -1
  67. package/dist/types/init/utils/configManipulation.d.ts +42 -1
  68. package/dist/types/init/utils/configManipulation.d.ts.map +1 -1
  69. package/dist/types/init/utils/fileSystem.d.ts +31 -1
  70. package/dist/types/init/utils/fileSystem.d.ts.map +1 -1
  71. package/dist/types/init/utils/index.d.ts +4 -3
  72. package/dist/types/init/utils/packageManager.d.ts +59 -0
  73. package/dist/types/init/utils/packageManager.d.ts.map +1 -0
  74. package/dist/types/intlayer/dist/types/index.d.ts +4 -0
  75. package/dist/types/scan/analyzeBundleContent.d.ts +16 -0
  76. package/dist/types/scan/analyzeBundleContent.d.ts.map +1 -0
  77. package/dist/types/scan/calculateScore.d.ts +65 -0
  78. package/dist/types/scan/calculateScore.d.ts.map +1 -0
  79. package/dist/types/scan/checks.d.ts +38 -0
  80. package/dist/types/scan/checks.d.ts.map +1 -0
  81. package/dist/types/scan/index.d.ts +7 -0
  82. package/dist/types/scan/parseHtml.d.ts +54 -0
  83. package/dist/types/scan/parseHtml.d.ts.map +1 -0
  84. package/dist/types/scan/scanWebsite.d.ts +18 -0
  85. package/dist/types/scan/scanWebsite.d.ts.map +1 -0
  86. package/dist/types/scan/types.d.ts +76 -0
  87. package/dist/types/scan/types.d.ts.map +1 -0
  88. package/package.json +17 -9
@@ -114,10 +114,206 @@ const updateNuxtConfig = (content) => {
114
114
  genericRecastVisit(ast, updateConfigObject, ["defineNuxtConfig"]);
115
115
  return recast.print(ast).code;
116
116
  };
117
+ /**
118
+ * Updates a Vite config for vue-i18n compat: injects `vueI18nVitePlugin` from
119
+ * `@intlayer/vue-i18n/plugin` into the plugins array.
120
+ */
121
+ const updateViteConfigForVueI18n = (content, extension) => {
122
+ const ast = recast.parse(content, { parser: require("recast/parsers/typescript") });
123
+ injectImport(ast, extension === "cjs" || content.includes("module.exports") && !content.includes("import "), "vueI18nVitePlugin", "@intlayer/vue-i18n/plugin");
124
+ genericRecastVisit(ast, (obj) => updatePluginArray(obj, "plugins", "vueI18nVitePlugin"));
125
+ return recast.print(ast).code;
126
+ };
127
+ /**
128
+ * Generic vite config updater for any compat plugin that uses alias injection.
129
+ * Injects the named import from `pluginPackageSource` and appends the plugin
130
+ * call to the `plugins` array.
131
+ */
132
+ const updateViteConfigForCompatPlugin = (content, extension, pluginConfig) => {
133
+ const ast = recast.parse(content, { parser: require("recast/parsers/typescript") });
134
+ injectImport(ast, extension === "cjs" || content.includes("module.exports") && !content.includes("import "), pluginConfig.pluginFunctionName, pluginConfig.pluginPackageSource);
135
+ genericRecastVisit(ast, (obj) => updatePluginArray(obj, "plugins", pluginConfig.pluginFunctionName));
136
+ return recast.print(ast).code;
137
+ };
138
+ /**
139
+ * Generic Next.js config wrapper for compat plugins. Injects the import and
140
+ * wraps the default export / `module.exports` with a HOC call.
141
+ */
142
+ const wrapNextConfigWithHoc = (content, extension, hocFunctionName, pluginPackageSource) => {
143
+ const ast = recast.parse(content, { parser: require("recast/parsers/typescript") });
144
+ injectImport(ast, extension === "cjs" || content.includes("module.exports"), hocFunctionName, pluginPackageSource);
145
+ recast.visit(ast, {
146
+ visitExportDefaultDeclaration(path) {
147
+ const declaration = path.node.declaration;
148
+ if (n.Expression.check(declaration) && !(n.CallExpression.check(declaration) && n.Identifier.check(declaration.callee) && declaration.callee.name === hocFunctionName)) path.get("declaration").replace(b.callExpression(b.identifier(hocFunctionName), [declaration]));
149
+ return false;
150
+ },
151
+ visitAssignmentExpression(path) {
152
+ const { left, right } = path.node;
153
+ if (n.MemberExpression.check(left) && recast.print(left).code === "module.exports" && !(n.CallExpression.check(right) && n.Identifier.check(right.callee) && right.callee.name === hocFunctionName)) path.get("right").replace(b.callExpression(b.identifier(hocFunctionName), [right]));
154
+ return false;
155
+ }
156
+ });
157
+ return recast.print(ast).code;
158
+ };
159
+ /**
160
+ * Updates a Next.js config for next-translate compat: wraps the default export
161
+ * with `withNextTranslate` from `@intlayer/next-translate/plugin`.
162
+ */
163
+ const updateNextConfigForNextTranslate = (content, extension) => wrapNextConfigWithHoc(content, extension, "withNextTranslate", "@intlayer/next-translate/plugin");
164
+ /**
165
+ * Updates a Nuxt config for nuxtjs-i18n compat: adds `@intlayer/nuxtjs-i18n`
166
+ * to the `modules` array.
167
+ */
168
+ const updateNuxtConfigForNuxtjsI18n = (content) => {
169
+ const ast = recast.parse(content, { parser: require("recast/parsers/typescript") });
170
+ const updateConfigObject = (objExpr) => {
171
+ if (!objExpr || objExpr.type !== "ObjectExpression" && !n.ObjectExpression.check(objExpr)) return;
172
+ let modulesProp = objExpr.properties.find((p) => {
173
+ if (!p?.key) return false;
174
+ return (p.key.name || p.key.value) === "modules";
175
+ });
176
+ if (!modulesProp) {
177
+ modulesProp = b.property("init", b.identifier("modules"), b.arrayExpression([]));
178
+ objExpr.properties.push(modulesProp);
179
+ }
180
+ const modulesValue = modulesProp.value;
181
+ if (modulesValue && (modulesValue.type === "ArrayExpression" || n.ArrayExpression.check(modulesValue))) {
182
+ if (!modulesValue.elements.some((el) => {
183
+ if (n.StringLiteral.check(el) || el.type === "StringLiteral" || el.type === "Literal") return (el.value ?? el.extra?.rawValue) === "@intlayer/nuxtjs-i18n";
184
+ return false;
185
+ })) modulesValue.elements.push(b.stringLiteral("@intlayer/nuxtjs-i18n"));
186
+ }
187
+ };
188
+ genericRecastVisit(ast, updateConfigObject, ["defineNuxtConfig"]);
189
+ return recast.print(ast).code;
190
+ };
191
+ /**
192
+ * Updates a Next.js config for next-i18next compat: wraps the default export
193
+ * with `withI18next` from `@intlayer/next-i18next/plugin`.
194
+ */
195
+ const updateNextConfigForNextI18next = (content, extension) => wrapNextConfigWithHoc(content, extension, "withI18next", "@intlayer/next-i18next/plugin");
196
+ /**
197
+ * Updates a Next.js config for next-intl compat: replaces any existing
198
+ * `next-intl/plugin` import source with `@intlayer/next-intl/plugin`, or
199
+ * injects `createNextIntlPlugin` with a factory-call wrapper when no such
200
+ * import is present.
201
+ */
202
+ const updateNextConfigForNextIntl = (content, extension) => {
203
+ const ast = recast.parse(content, { parser: require("recast/parsers/typescript") });
204
+ const isCJSFile = extension === "cjs" || content.includes("module.exports");
205
+ let replacedExistingSource = false;
206
+ recast.visit(ast, { visitImportDeclaration(path) {
207
+ if (path.node.source.value === "next-intl/plugin") {
208
+ path.node.source = b.stringLiteral("@intlayer/next-intl/plugin");
209
+ replacedExistingSource = true;
210
+ }
211
+ return false;
212
+ } });
213
+ if (replacedExistingSource) return recast.print(ast).code;
214
+ if (ast.program.body.some((stmt) => {
215
+ if (!n.ImportDeclaration.check(stmt)) return false;
216
+ return (stmt.specifiers ?? []).some((spec) => n.ImportSpecifier.check(spec) && spec.imported.name === "createNextIntlPlugin" || n.ImportDefaultSpecifier.check(spec) && spec.local?.name === "createNextIntlPlugin");
217
+ })) return recast.print(ast).code;
218
+ injectImport(ast, isCJSFile, "createNextIntlPlugin", "@intlayer/next-intl/plugin");
219
+ const lastImportIndex = ast.program.body.reduce((lastIndex, stmt, index) => {
220
+ if (n.ImportDeclaration.check(stmt)) return index;
221
+ return lastIndex;
222
+ }, -1);
223
+ const factoryCallDeclaration = b.variableDeclaration("const", [b.variableDeclarator(b.identifier("_withNextIntlayer"), b.callExpression(b.identifier("createNextIntlPlugin"), []))]);
224
+ ast.program.body.splice(lastImportIndex + 1, 0, factoryCallDeclaration);
225
+ recast.visit(ast, {
226
+ visitExportDefaultDeclaration(path) {
227
+ const declaration = path.node.declaration;
228
+ if (n.Expression.check(declaration) && !(n.CallExpression.check(declaration) && n.Identifier.check(declaration.callee) && declaration.callee.name === "_withNextIntlayer")) path.get("declaration").replace(b.callExpression(b.identifier("_withNextIntlayer"), [declaration]));
229
+ return false;
230
+ },
231
+ visitAssignmentExpression(path) {
232
+ const { left, right } = path.node;
233
+ if (n.MemberExpression.check(left) && recast.print(left).code === "module.exports" && !(n.CallExpression.check(right) && n.Identifier.check(right.callee) && right.callee.name === "_withNextIntlayer")) path.get("right").replace(b.callExpression(b.identifier("_withNextIntlayer"), [right]));
234
+ return false;
235
+ }
236
+ });
237
+ return recast.print(ast).code;
238
+ };
239
+ /**
240
+ * Parses a syncJSON({ ... }) call expression from a source snippet so it can
241
+ * be injected into a config AST without manually constructing template-literal
242
+ * nodes via builders.
243
+ *
244
+ * The destructuring parameters adapt to whether the source template uses the
245
+ * `key` placeholder (nested pattern) or only `locale` (flat pattern).
246
+ */
247
+ const buildSyncJSONCallNode = (syncConfig) => {
248
+ const usesKey = syncConfig.sourceTemplate.includes("${key}");
249
+ const paramDestructuring = syncConfig.format === "icu" ? usesKey ? "{ key, locale }" : "{ locale }" : usesKey ? "{ locale, key }" : "{ locale }";
250
+ const snippet = `syncJSON({ format: '${syncConfig.format}', source: (${paramDestructuring}) => \`${syncConfig.sourceTemplate}\` })`;
251
+ return recast.parse(snippet, { parser: require("recast/parsers/typescript") }).program.body[0].expression;
252
+ };
253
+ /**
254
+ * Injects or ensures `dictionary: { format: '<value>' }` exists in an object
255
+ * expression. Leaves any pre-existing `dictionary` properties untouched —
256
+ * only the `format` sub-property is added when absent.
257
+ */
258
+ const injectDictionaryFormat = (objExpr, format) => {
259
+ if (!objExpr || objExpr.type !== "ObjectExpression" && !n.ObjectExpression.check(objExpr)) return;
260
+ let dictionaryProp = objExpr.properties.find((prop) => {
261
+ if (!prop?.key) return false;
262
+ return (prop.key.name ?? prop.key.value) === "dictionary";
263
+ });
264
+ if (!dictionaryProp) {
265
+ dictionaryProp = b.property("init", b.identifier("dictionary"), b.objectExpression([]));
266
+ objExpr.properties.push(dictionaryProp);
267
+ }
268
+ const dictionaryObj = dictionaryProp.value;
269
+ if (!dictionaryObj || dictionaryObj.type !== "ObjectExpression" && !n.ObjectExpression.check(dictionaryObj)) return;
270
+ if (!dictionaryObj.properties.some((prop) => {
271
+ if (!prop?.key) return false;
272
+ return (prop.key.name ?? prop.key.value) === "format";
273
+ })) dictionaryObj.properties.push(b.property("init", b.identifier("format"), b.stringLiteral(format)));
274
+ };
275
+ /**
276
+ * Injects the syncJSON import and a configured syncJSON(...) call into the
277
+ * plugins array of an intlayer config file. Idempotent: skips when
278
+ * @intlayer/sync-json-plugin is already imported.
279
+ */
280
+ const updateIntlayerConfigWithSyncPlugin = (content, extension, syncConfig) => {
281
+ const ast = recast.parse(content, { parser: require("recast/parsers/typescript") });
282
+ injectImport(ast, extension === "cjs" || content.includes("module.exports"), "syncJSON", "@intlayer/sync-json-plugin");
283
+ const callNode = buildSyncJSONCallNode(syncConfig);
284
+ genericRecastVisit(ast, (objExpr) => {
285
+ if (!objExpr || objExpr.type !== "ObjectExpression" && !n.ObjectExpression.check(objExpr)) return;
286
+ injectDictionaryFormat(objExpr, syncConfig.format);
287
+ let pluginsProp = objExpr.properties.find((prop) => {
288
+ if (!prop?.key) return false;
289
+ return (prop.key.name ?? prop.key.value) === "plugins";
290
+ });
291
+ if (!pluginsProp) {
292
+ pluginsProp = b.property("init", b.identifier("plugins"), b.arrayExpression([]));
293
+ objExpr.properties.push(pluginsProp);
294
+ }
295
+ const arrayValue = pluginsProp.value;
296
+ if (arrayValue && (arrayValue.type === "ArrayExpression" || n.ArrayExpression.check(arrayValue))) {
297
+ if (!arrayValue.elements.some((element) => {
298
+ const callee = element?.callee;
299
+ if (!callee) return false;
300
+ return (callee.name ?? callee.id?.name) === "syncJSON";
301
+ })) arrayValue.elements.push(callNode);
302
+ }
303
+ });
304
+ return recast.print(ast).code;
305
+ };
117
306
 
118
307
  //#endregion
119
308
  exports.updateAstroConfig = updateAstroConfig;
309
+ exports.updateIntlayerConfigWithSyncPlugin = updateIntlayerConfigWithSyncPlugin;
120
310
  exports.updateNextConfig = updateNextConfig;
311
+ exports.updateNextConfigForNextI18next = updateNextConfigForNextI18next;
312
+ exports.updateNextConfigForNextIntl = updateNextConfigForNextIntl;
313
+ exports.updateNextConfigForNextTranslate = updateNextConfigForNextTranslate;
121
314
  exports.updateNuxtConfig = updateNuxtConfig;
315
+ exports.updateNuxtConfigForNuxtjsI18n = updateNuxtConfigForNuxtjsI18n;
122
316
  exports.updateViteConfig = updateViteConfig;
317
+ exports.updateViteConfigForCompatPlugin = updateViteConfigForCompatPlugin;
318
+ exports.updateViteConfigForVueI18n = updateViteConfigForVueI18n;
123
319
  //# sourceMappingURL=configManipulation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"configManipulation.cjs","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"sourcesContent":["import * as recast from 'recast';\n\nconst { builders: b, namedTypes: n } = recast.types;\n\nconst injectImport = (\n ast: any,\n isCJS: boolean,\n importName: string,\n source: string\n) => {\n const body = ast.program.body;\n const hasImport = body.some((stmt: any) => {\n if (isCJS) {\n return (\n n.VariableDeclaration.check(stmt) &&\n stmt.declarations.some(\n (decl: any) =>\n n.VariableDeclarator.check(decl) &&\n n.CallExpression.check(decl.init) &&\n n.Identifier.check(decl.init.callee) &&\n decl.init.callee.name === 'require' &&\n n.StringLiteral.check(decl.init.arguments[0]) &&\n decl.init.arguments[0].value === source\n )\n );\n }\n return (\n n.ImportDeclaration.check(stmt) &&\n (stmt.source.value === source ||\n stmt.specifiers.some(\n (spec: any) =>\n (n.ImportSpecifier.check(spec) &&\n spec.imported.name === importName) ||\n (n.ImportDefaultSpecifier.check(spec) &&\n spec.local?.name === importName)\n ))\n );\n });\n\n if (hasImport) return;\n\n const declaration = isCJS\n ? b.variableDeclaration('const', [\n b.variableDeclarator(\n b.identifier(`{ ${importName} }`),\n b.callExpression(b.identifier('require'), [b.stringLiteral(source)])\n ),\n ])\n : b.importDeclaration(\n [b.importSpecifier(b.identifier(importName))],\n b.stringLiteral(source)\n );\n\n ast.program.body.unshift(declaration);\n};\n\nconst updatePluginArray = (\n objExpr: any,\n propertyName: string,\n pluginName: string\n) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' && !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let prop = objExpr.properties.find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === propertyName;\n }) as any;\n\n if (!prop) {\n prop = b.property(\n 'init',\n b.identifier(propertyName),\n b.arrayExpression([])\n );\n objExpr.properties.push(prop);\n }\n\n const arrayValue = prop.value;\n\n if (\n arrayValue &&\n (arrayValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(arrayValue))\n ) {\n const hasPlugin = arrayValue.elements.some((el: any) => {\n const callee = el?.callee;\n if (!callee) return false;\n const name = callee.name || callee.id?.name;\n return name === pluginName || name === 'il';\n });\n\n if (!hasPlugin) {\n arrayValue.elements.push(b.callExpression(b.identifier(pluginName), []));\n }\n }\n};\n\nconst genericRecastVisit = (\n ast: any,\n updateConfigObject: (obj: any) => void,\n callNames: string[] = ['defineConfig']\n) => {\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const decl = path.node.declaration;\n\n if (n.ObjectExpression.check(decl)) {\n updateConfigObject(decl);\n } else if (\n n.CallExpression.check(decl) &&\n n.Identifier.check(decl.callee) &&\n callNames.includes(decl.callee.name)\n ) {\n if (n.ObjectExpression.check(decl.arguments[0])) {\n updateConfigObject(decl.arguments[0]);\n }\n } else if (n.Identifier.check(decl)) {\n const name = decl.name;\n ast.program.body.forEach((stmt: any) => {\n if (n.VariableDeclaration.check(stmt)) {\n stmt.declarations.forEach((vdecl: any) => {\n if (\n n.VariableDeclarator.check(vdecl) &&\n n.Identifier.check(vdecl.id) &&\n vdecl.id.name === name &&\n n.ObjectExpression.check(vdecl.init)\n ) {\n updateConfigObject(vdecl.init);\n }\n });\n }\n });\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports'\n ) {\n if (n.ObjectExpression.check(right)) {\n updateConfigObject(right);\n } else if (\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n callNames.includes(right.callee.name)\n ) {\n if (n.ObjectExpression.check(right.arguments[0])) {\n updateConfigObject(right.arguments[0]);\n }\n }\n }\n return false;\n },\n });\n};\n\nexport const updateViteConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(ast, isCJSFile, 'intlayer', 'vite-intlayer');\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'plugins', 'intlayer')\n );\n\n return recast.print(ast).code;\n};\n\nexport const updateAstroConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(ast, isCJSFile, 'intlayer', 'astro-intlayer');\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'integrations', 'intlayer')\n );\n\n return recast.print(ast).code;\n};\n\nexport const updateNextConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n injectImport(ast, isCJSFile, 'withIntlayer', 'next-intlayer/server');\n\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (\n n.Expression.check(declaration) &&\n !(\n n.CallExpression.check(declaration) &&\n n.Identifier.check(declaration.callee) &&\n declaration.callee.name === 'withIntlayer'\n )\n ) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier('withIntlayer'), [declaration as any])\n );\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports' &&\n !(\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n right.callee.name === 'withIntlayer'\n )\n ) {\n path\n .get('right')\n .replace(b.callExpression(b.identifier('withIntlayer'), [right]));\n }\n return false;\n },\n });\n\n return recast.print(ast).code;\n};\n\nexport const updateNuxtConfig = (content: string): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const updateConfigObject = (objExpr: any) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let modulesProp = objExpr.properties.find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === 'modules';\n }) as any;\n\n if (!modulesProp) {\n modulesProp = b.property(\n 'init',\n b.identifier('modules'),\n b.arrayExpression([])\n );\n objExpr.properties.push(modulesProp);\n }\n\n const modulesValue = modulesProp.value;\n\n if (\n modulesValue &&\n (modulesValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(modulesValue))\n ) {\n const hasModule = modulesValue.elements.some((el: any) => {\n if (\n n.StringLiteral.check(el) ||\n el.type === 'StringLiteral' ||\n el.type === 'Literal'\n ) {\n return (el.value || el.extra?.rawValue) === 'nuxt-intlayer';\n }\n return false;\n });\n\n if (!hasModule) {\n modulesValue.elements.push(b.stringLiteral('nuxt-intlayer'));\n }\n }\n };\n\n genericRecastVisit(ast, updateConfigObject, ['defineNuxtConfig']);\n\n return recast.print(ast).code;\n};\n"],"mappings":";;;;;;AAEA,MAAM,EAAE,UAAU,GAAG,YAAY,MAAM,OAAO;AAE9C,MAAM,gBACJ,KACA,OACA,YACA,WACG;AA8BH,KA7Ba,IAAI,QAAQ,KACF,MAAM,SAAc;AACzC,MAAI,MACF,QACE,EAAE,oBAAoB,MAAM,KAAK,IACjC,KAAK,aAAa,MACf,SACC,EAAE,mBAAmB,MAAM,KAAK,IAChC,EAAE,eAAe,MA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BAAgB,CAAC;;;AAKlE,oBAAmB,KAAK,oBAAoB,CAAC,mBAAmB,CAAC;AAEjE,QAAO,OAAO,MAAM,IAAI,CAAC"}
1
+ {"version":3,"file":"configManipulation.cjs","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"sourcesContent":["import * as recast from 'recast';\nimport type {\n CompatSyncConfig,\n CompatVitePluginConfig,\n} from './packageManager';\n\nconst { builders: b, namedTypes: n } = recast.types;\n\nconst injectImport = (\n ast: any,\n isCJS: boolean,\n importName: string,\n source: string\n) => {\n const body = ast.program.body;\n const hasImport = body.some((stmt: any) => {\n if (isCJS) {\n return (\n n.VariableDeclaration.check(stmt) &&\n stmt.declarations.some(\n (decl: any) =>\n n.VariableDeclarator.check(decl) &&\n n.CallExpression.check(decl.init) &&\n n.Identifier.check(decl.init.callee) &&\n decl.init.callee.name === 'require' &&\n n.StringLiteral.check(decl.init.arguments[0]) &&\n decl.init.arguments[0].value === source\n )\n );\n }\n return (\n n.ImportDeclaration.check(stmt) &&\n (stmt.source.value === source ||\n stmt.specifiers.some(\n (spec: any) =>\n (n.ImportSpecifier.check(spec) &&\n spec.imported.name === importName) ||\n (n.ImportDefaultSpecifier.check(spec) &&\n spec.local?.name === importName)\n ))\n );\n });\n\n if (hasImport) return;\n\n const declaration = isCJS\n ? b.variableDeclaration('const', [\n b.variableDeclarator(\n b.identifier(`{ ${importName} }`),\n b.callExpression(b.identifier('require'), [b.stringLiteral(source)])\n ),\n ])\n : b.importDeclaration(\n [b.importSpecifier(b.identifier(importName))],\n b.stringLiteral(source)\n );\n\n ast.program.body.unshift(declaration);\n};\n\nconst updatePluginArray = (\n objExpr: any,\n propertyName: string,\n pluginName: string\n) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' && !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let prop = objExpr.properties.find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === propertyName;\n }) as any;\n\n if (!prop) {\n prop = b.property(\n 'init',\n b.identifier(propertyName),\n b.arrayExpression([])\n );\n objExpr.properties.push(prop);\n }\n\n const arrayValue = prop.value;\n\n if (\n arrayValue &&\n (arrayValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(arrayValue))\n ) {\n const hasPlugin = arrayValue.elements.some((el: any) => {\n const callee = el?.callee;\n if (!callee) return false;\n const name = callee.name || callee.id?.name;\n return name === pluginName || name === 'il';\n });\n\n if (!hasPlugin) {\n arrayValue.elements.push(b.callExpression(b.identifier(pluginName), []));\n }\n }\n};\n\nconst genericRecastVisit = (\n ast: any,\n updateConfigObject: (obj: any) => void,\n callNames: string[] = ['defineConfig']\n) => {\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const decl = path.node.declaration;\n\n if (n.ObjectExpression.check(decl)) {\n updateConfigObject(decl);\n } else if (\n n.CallExpression.check(decl) &&\n n.Identifier.check(decl.callee) &&\n callNames.includes(decl.callee.name)\n ) {\n if (n.ObjectExpression.check(decl.arguments[0])) {\n updateConfigObject(decl.arguments[0]);\n }\n } else if (n.Identifier.check(decl)) {\n const name = decl.name;\n ast.program.body.forEach((stmt: any) => {\n if (n.VariableDeclaration.check(stmt)) {\n stmt.declarations.forEach((vdecl: any) => {\n if (\n n.VariableDeclarator.check(vdecl) &&\n n.Identifier.check(vdecl.id) &&\n vdecl.id.name === name &&\n n.ObjectExpression.check(vdecl.init)\n ) {\n updateConfigObject(vdecl.init);\n }\n });\n }\n });\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports'\n ) {\n if (n.ObjectExpression.check(right)) {\n updateConfigObject(right);\n } else if (\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n callNames.includes(right.callee.name)\n ) {\n if (n.ObjectExpression.check(right.arguments[0])) {\n updateConfigObject(right.arguments[0]);\n }\n }\n }\n return false;\n },\n });\n};\n\nexport const updateViteConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(ast, isCJSFile, 'intlayer', 'vite-intlayer');\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'plugins', 'intlayer')\n );\n\n return recast.print(ast).code;\n};\n\nexport const updateAstroConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(ast, isCJSFile, 'intlayer', 'astro-intlayer');\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'integrations', 'intlayer')\n );\n\n return recast.print(ast).code;\n};\n\nexport const updateNextConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n injectImport(ast, isCJSFile, 'withIntlayer', 'next-intlayer/server');\n\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (\n n.Expression.check(declaration) &&\n !(\n n.CallExpression.check(declaration) &&\n n.Identifier.check(declaration.callee) &&\n declaration.callee.name === 'withIntlayer'\n )\n ) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier('withIntlayer'), [declaration as any])\n );\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports' &&\n !(\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n right.callee.name === 'withIntlayer'\n )\n ) {\n path\n .get('right')\n .replace(b.callExpression(b.identifier('withIntlayer'), [right]));\n }\n return false;\n },\n });\n\n return recast.print(ast).code;\n};\n\nexport const updateNuxtConfig = (content: string): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const updateConfigObject = (objExpr: any) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let modulesProp = objExpr.properties.find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === 'modules';\n }) as any;\n\n if (!modulesProp) {\n modulesProp = b.property(\n 'init',\n b.identifier('modules'),\n b.arrayExpression([])\n );\n objExpr.properties.push(modulesProp);\n }\n\n const modulesValue = modulesProp.value;\n\n if (\n modulesValue &&\n (modulesValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(modulesValue))\n ) {\n const hasModule = modulesValue.elements.some((el: any) => {\n if (\n n.StringLiteral.check(el) ||\n el.type === 'StringLiteral' ||\n el.type === 'Literal'\n ) {\n return (el.value || el.extra?.rawValue) === 'nuxt-intlayer';\n }\n return false;\n });\n\n if (!hasModule) {\n modulesValue.elements.push(b.stringLiteral('nuxt-intlayer'));\n }\n }\n };\n\n genericRecastVisit(ast, updateConfigObject, ['defineNuxtConfig']);\n\n return recast.print(ast).code;\n};\n\n/**\n * Updates a Vite config for vue-i18n compat: injects `vueI18nVitePlugin` from\n * `@intlayer/vue-i18n/plugin` into the plugins array.\n */\nexport const updateViteConfigForVueI18n = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(\n ast,\n isCJSFile,\n 'vueI18nVitePlugin',\n '@intlayer/vue-i18n/plugin'\n );\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'plugins', 'vueI18nVitePlugin')\n );\n\n return recast.print(ast).code;\n};\n\n/**\n * Generic vite config updater for any compat plugin that uses alias injection.\n * Injects the named import from `pluginPackageSource` and appends the plugin\n * call to the `plugins` array.\n */\nexport const updateViteConfigForCompatPlugin = (\n content: string,\n extension: string,\n pluginConfig: CompatVitePluginConfig\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(\n ast,\n isCJSFile,\n pluginConfig.pluginFunctionName,\n pluginConfig.pluginPackageSource\n );\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'plugins', pluginConfig.pluginFunctionName)\n );\n\n return recast.print(ast).code;\n};\n\n/**\n * Generic Next.js config wrapper for compat plugins. Injects the import and\n * wraps the default export / `module.exports` with a HOC call.\n */\nconst wrapNextConfigWithHoc = (\n content: string,\n extension: string,\n hocFunctionName: string,\n pluginPackageSource: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n injectImport(ast, isCJSFile, hocFunctionName, pluginPackageSource);\n\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (\n n.Expression.check(declaration) &&\n !(\n n.CallExpression.check(declaration) &&\n n.Identifier.check(declaration.callee) &&\n declaration.callee.name === hocFunctionName\n )\n ) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier(hocFunctionName), [\n declaration as any,\n ])\n );\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports' &&\n !(\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n right.callee.name === hocFunctionName\n )\n ) {\n path\n .get('right')\n .replace(b.callExpression(b.identifier(hocFunctionName), [right]));\n }\n return false;\n },\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * Updates a Next.js config for next-translate compat: wraps the default export\n * with `withNextTranslate` from `@intlayer/next-translate/plugin`.\n */\nexport const updateNextConfigForNextTranslate = (\n content: string,\n extension: string\n): string =>\n wrapNextConfigWithHoc(\n content,\n extension,\n 'withNextTranslate',\n '@intlayer/next-translate/plugin'\n );\n\n/**\n * Updates a Nuxt config for nuxtjs-i18n compat: adds `@intlayer/nuxtjs-i18n`\n * to the `modules` array.\n */\nexport const updateNuxtConfigForNuxtjsI18n = (content: string): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const updateConfigObject = (objExpr: any) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let modulesProp = (objExpr.properties as any[]).find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === 'modules';\n }) as any;\n\n if (!modulesProp) {\n modulesProp = b.property(\n 'init',\n b.identifier('modules'),\n b.arrayExpression([])\n );\n (objExpr.properties as any[]).push(modulesProp);\n }\n\n const modulesValue = modulesProp.value;\n\n if (\n modulesValue &&\n (modulesValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(modulesValue))\n ) {\n const hasModule = (modulesValue.elements as any[]).some((el: any) => {\n if (\n n.StringLiteral.check(el) ||\n el.type === 'StringLiteral' ||\n el.type === 'Literal'\n ) {\n return (el.value ?? el.extra?.rawValue) === '@intlayer/nuxtjs-i18n';\n }\n return false;\n });\n\n if (!hasModule) {\n (modulesValue.elements as any[]).push(\n b.stringLiteral('@intlayer/nuxtjs-i18n')\n );\n }\n }\n };\n\n genericRecastVisit(ast, updateConfigObject, ['defineNuxtConfig']);\n\n return recast.print(ast).code;\n};\n\n/**\n * Updates a Next.js config for next-i18next compat: wraps the default export\n * with `withI18next` from `@intlayer/next-i18next/plugin`.\n */\nexport const updateNextConfigForNextI18next = (\n content: string,\n extension: string\n): string =>\n wrapNextConfigWithHoc(\n content,\n extension,\n 'withI18next',\n '@intlayer/next-i18next/plugin'\n );\n\n/**\n * Updates a Next.js config for next-intl compat: replaces any existing\n * `next-intl/plugin` import source with `@intlayer/next-intl/plugin`, or\n * injects `createNextIntlPlugin` with a factory-call wrapper when no such\n * import is present.\n */\nexport const updateNextConfigForNextIntl = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n let replacedExistingSource = false;\n\n // Replace 'next-intl/plugin' import source with the compat package.\n recast.visit(ast, {\n visitImportDeclaration(path) {\n if (path.node.source.value === 'next-intl/plugin') {\n path.node.source = b.stringLiteral('@intlayer/next-intl/plugin');\n replacedExistingSource = true;\n }\n return false;\n },\n });\n\n if (replacedExistingSource) {\n return recast.print(ast).code;\n }\n\n // No existing next-intl/plugin import: check whether createNextIntlPlugin is\n // already present from any source before injecting the full factory pattern.\n const hasCreatePlugin = (ast.program.body as any[]).some((stmt: any) => {\n if (!n.ImportDeclaration.check(stmt)) return false;\n return (stmt.specifiers ?? []).some(\n (spec: any) =>\n (n.ImportSpecifier.check(spec) &&\n spec.imported.name === 'createNextIntlPlugin') ||\n (n.ImportDefaultSpecifier.check(spec) &&\n spec.local?.name === 'createNextIntlPlugin')\n );\n });\n\n if (hasCreatePlugin) {\n return recast.print(ast).code;\n }\n\n // Inject the import.\n injectImport(\n ast,\n isCJSFile,\n 'createNextIntlPlugin',\n '@intlayer/next-intl/plugin'\n );\n\n // Insert a factory-call variable declaration after the last import.\n const lastImportIndex = (ast.program.body as any[]).reduce(\n (lastIndex: number, stmt: any, index: number) => {\n if (n.ImportDeclaration.check(stmt)) return index;\n return lastIndex;\n },\n -1\n );\n\n const factoryCallDeclaration = b.variableDeclaration('const', [\n b.variableDeclarator(\n b.identifier('_withNextIntlayer'),\n b.callExpression(b.identifier('createNextIntlPlugin'), [])\n ),\n ]);\n\n (ast.program.body as any[]).splice(\n lastImportIndex + 1,\n 0,\n factoryCallDeclaration\n );\n\n // Wrap the default export with _withNextIntlayer(...).\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (\n n.Expression.check(declaration) &&\n !(\n n.CallExpression.check(declaration) &&\n n.Identifier.check(declaration.callee) &&\n declaration.callee.name === '_withNextIntlayer'\n )\n ) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier('_withNextIntlayer'), [\n declaration as any,\n ])\n );\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports' &&\n !(\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n right.callee.name === '_withNextIntlayer'\n )\n ) {\n path\n .get('right')\n .replace(\n b.callExpression(b.identifier('_withNextIntlayer'), [right])\n );\n }\n return false;\n },\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * Parses a syncJSON({ ... }) call expression from a source snippet so it can\n * be injected into a config AST without manually constructing template-literal\n * nodes via builders.\n *\n * The destructuring parameters adapt to whether the source template uses the\n * `key` placeholder (nested pattern) or only `locale` (flat pattern).\n */\nconst buildSyncJSONCallNode = (syncConfig: CompatSyncConfig): any => {\n const usesKey = syncConfig.sourceTemplate.includes('${key}');\n const paramDestructuring =\n syncConfig.format === 'icu'\n ? usesKey\n ? '{ key, locale }'\n : '{ locale }'\n : usesKey\n ? '{ locale, key }'\n : '{ locale }';\n\n // The sourceTemplate contains ${locale} / ${key} as literal characters;\n // they become proper template expressions once the snippet is parsed by recast.\n const snippet = `syncJSON({ format: '${syncConfig.format}', source: (${paramDestructuring}) => \\`${syncConfig.sourceTemplate}\\` })`;\n const snippetAst = recast.parse(snippet, {\n parser: require('recast/parsers/typescript'),\n });\n return (snippetAst.program.body[0] as any).expression;\n};\n\n/**\n * Injects or ensures `dictionary: { format: '<value>' }` exists in an object\n * expression. Leaves any pre-existing `dictionary` properties untouched —\n * only the `format` sub-property is added when absent.\n */\nconst injectDictionaryFormat = (objExpr: any, format: string): void => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' && !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let dictionaryProp = (objExpr.properties as any[]).find((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === 'dictionary';\n });\n\n if (!dictionaryProp) {\n dictionaryProp = b.property(\n 'init',\n b.identifier('dictionary'),\n b.objectExpression([])\n );\n (objExpr.properties as any[]).push(dictionaryProp);\n }\n\n const dictionaryObj = dictionaryProp.value;\n if (\n !dictionaryObj ||\n (dictionaryObj.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(dictionaryObj))\n )\n return;\n\n const hasFormat = (dictionaryObj.properties as any[]).some((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === 'format';\n });\n\n if (!hasFormat) {\n (dictionaryObj.properties as any[]).push(\n b.property('init', b.identifier('format'), b.stringLiteral(format))\n );\n }\n};\n\n/**\n * Injects the syncJSON import and a configured syncJSON(...) call into the\n * plugins array of an intlayer config file. Idempotent: skips when\n * @intlayer/sync-json-plugin is already imported.\n */\nexport const updateIntlayerConfigWithSyncPlugin = (\n content: string,\n extension: string,\n syncConfig: CompatSyncConfig\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n injectImport(ast, isCJSFile, 'syncJSON', '@intlayer/sync-json-plugin');\n\n const callNode = buildSyncJSONCallNode(syncConfig);\n\n genericRecastVisit(ast, (objExpr) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(objExpr))\n )\n return;\n\n // Inject dictionary.format alongside the plugin so intlayer knows how to\n // interpret dictionary content at runtime.\n injectDictionaryFormat(objExpr, syncConfig.format);\n\n let pluginsProp = (objExpr.properties as any[]).find((prop: any) => {\n if (!prop?.key) return false;\n const keyName = prop.key.name ?? prop.key.value;\n return keyName === 'plugins';\n });\n\n if (!pluginsProp) {\n pluginsProp = b.property(\n 'init',\n b.identifier('plugins'),\n b.arrayExpression([])\n );\n (objExpr.properties as any[]).push(pluginsProp);\n }\n\n const arrayValue = pluginsProp.value;\n\n if (\n arrayValue &&\n (arrayValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(arrayValue))\n ) {\n const hasSyncJSON = (arrayValue.elements as any[]).some(\n (element: any) => {\n const callee = element?.callee;\n if (!callee) return false;\n const name: string = callee.name ?? callee.id?.name;\n return name === 'syncJSON';\n }\n );\n\n if (!hasSyncJSON) {\n (arrayValue.elements as any[]).push(callNode);\n }\n }\n });\n\n return recast.print(ast).code;\n};\n"],"mappings":";;;;;;AAMA,MAAM,EAAE,UAAU,GAAG,YAAY,MAAM,OAAO;AAE9C,MAAM,gBACJ,KACA,OACA,YACA,WACG;AA8BH,KA7Ba,IAAI,QAAQ,KACF,MAAM,SAAc;AACzC,MAAI,MACF,QACE,EAAE,oBAAoB,MAAM,KAAK,IACjC,KAAK,aAAa,MACf,SACC,EAAE,mBAAmB,MAAM,KAAK,IAChC,EAAE,eAAe,MAAM,KAAK,KAAK,IACjC,EAAE,WAAW,MAAM,KAAK,KAAK,OAAO,IACpC,KAAK,KAAK,OAAO,SAAS,aAC1B,EAAE,cAAc,MAAM,KAAK,KAAK,UAAU,GAAG,IAC7C,KAAK,KAAK,UAAU,GAAG,UAAU,OACpC;AAGL,SACE,EAAE,kBAAkB,MAAM,KAAK,KAC9B,KAAK,OAAO,UAAU,UACrB,KAAK,WAAW,MACb,SACE,EAAE,gBAAgB,MAAM,KAAK,IAC5B,KAAK,SAAS,SAAS,cACxB,EAAE,uBAAuB,MAAM,KAAK,IACnC,KAAK,OAAO,SAAS,WAC1B;GAIM,CAAE;CAEf,MAAM,cAAc,QAChB,EAAE,oBAAoB,SAAS,CAC7B,EAAE,mBACA,EAAE,WAAW,KAAK,WAAW,IAAI,EACjC,EAAE,eAAe,EAAE,WAAW,UAAU,EAAE,CAAC,EAAE,cAAc,OAAO,CAAC,CAAC,CACrE,CACF,CAAC,GACF,EAAE,kBACA,CAAC,EAAE,gBAAgB,EAAE,WAAW,WAAW,CAAC,CAAC,EAC7C,EAAE,cAAc,OAAO,CACxB;AAEL,KAAI,QAAQ,KAAK,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MAAa,sCACX,SACA,WACA,eACW;CACX,MAAM,MAAM,OAAO,MAAM,SAAS,EAChC,QAAQ,QAAQ,4BAA4B,EAC7C,CAAC;AAIF,cAAa,KAFK,cAAc,SAAS,QAAQ,SAAS,iBAAiB,EAE9C,YAAY,6BAA6B;CAEtE,MAAM,WAAW,sBAAsB,WAAW;AAElD,oBAAmB,MAAM,YAAY;AACnC,MACE,CAAC,WACA,QAAQ,SAAS,sBAChB,CAAC,EAAE,iBAAiB,MAAM,QAAQ,CAEpC;AAIF,yBAAuB,SAAS,WAAW,OAAO;EAElD,IAAI,cAAe,QAAQ,WAAqB,MAAM,SAAc;AAClE,OAAI,CAAC,MAAM,IAAK,QAAO;AAEvB,WADgB,KAAK,IAAI,QAAQ,KAAK,IAAI,WACvB;IACnB;AAEF,MAAI,CAAC,aAAa;AAChB,iBAAc,EAAE,SACd,QACA,EAAE,WAAW,UAAU,EACvB,EAAE,gBAAgB,EAAE,CAAC,CACtB;AACD,GAAC,QAAQ,WAAqB,KAAK,YAAY;;EAGjD,MAAM,aAAa,YAAY;AAE/B,MACE,eACC,WAAW,SAAS,qBACnB,EAAE,gBAAgB,MAAM,WAAW,GAWrC;OAAI,CATiB,WAAW,SAAmB,MAChD,YAAiB;IAChB,MAAM,SAAS,SAAS;AACxB,QAAI,CAAC,OAAQ,QAAO;AAEpB,YADqB,OAAO,QAAQ,OAAO,IAAI,UAC/B;KAIJ,CACd,CAAC,WAAW,SAAmB,KAAK,SAAS;;GAGjD;AAEF,QAAO,OAAO,MAAM,IAAI,CAAC"}
@@ -2,6 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
3
  let node_fs_promises = require("node:fs/promises");
4
4
  let node_path = require("node:path");
5
+ let fast_glob = require("fast-glob");
6
+ fast_glob = require_runtime.__toESM(fast_glob);
7
+ let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
8
+ let _intlayer_types_allLocales = require("@intlayer/types/allLocales");
5
9
 
6
10
  //#region src/init/utils/fileSystem.ts
7
11
  /**
@@ -31,8 +35,88 @@ const ensureDirectory = async (rootDir, dirPath) => {
31
35
  await (0, node_fs_promises.mkdir)((0, node_path.join)(rootDir, dirPath), { recursive: true });
32
36
  } catch {}
33
37
  };
38
+ /**
39
+ * Set of all known locale string values from the intlayer Locales registry
40
+ * (e.g. `'en'`, `'fr'`, `'zh-TW'`). Keyed by the exact locale string so
41
+ * `.has()` lookups are O(1) and common short directory names (`src`, `lib`,
42
+ * `app`, …) are not mistaken for locales.
43
+ */
44
+ const ALL_LOCALE_VALUES = new Set(Object.values(_intlayer_types_allLocales.ALL_LOCALES));
45
+ /**
46
+ * Returns true when `segment` matches a known BCP-47 locale identifier, e.g.
47
+ * `en`, `fr`, `zh-TW`, `pt-BR`, `en-US`.
48
+ */
49
+ const isLocaleSegment = (segment) => ALL_LOCALE_VALUES.has(segment);
50
+ /** JSON filenames that are never locale translation files. */
51
+ const KNOWN_CONFIG_FILENAMES = new Set([
52
+ "package.json",
53
+ "tsconfig.json",
54
+ "jsconfig.json",
55
+ "biome.json",
56
+ "turbo.json",
57
+ "lerna.json",
58
+ "vercel.json",
59
+ "netlify.json",
60
+ "babel.config.json",
61
+ "jest.config.json",
62
+ "vitest.config.json",
63
+ ".eslintrc.json",
64
+ ".prettierrc.json"
65
+ ]);
66
+ /**
67
+ * Scans the project for JSON files and determines whether locale files are
68
+ * organised as `{base}/{locale}/{key}.json` (nested) or `{base}/{locale}.json`
69
+ * (flat). Returns the most likely source template, or `null` when no locale
70
+ * JSON files are found.
71
+ *
72
+ * The returned `template` contains `${locale}` and `${key}` as **literal**
73
+ * placeholder strings so it can be embedded inside a JS template literal.
74
+ */
75
+ const detectJsonLocalePattern = async (rootDir) => {
76
+ const files = await (0, fast_glob.default)("**/*.json", {
77
+ cwd: rootDir,
78
+ ignore: _intlayer_config_defaultValues.EXCLUDED_PATHS,
79
+ absolute: false,
80
+ onlyFiles: true
81
+ });
82
+ const nestedBasePaths = [];
83
+ const flatBasePaths = [];
84
+ for (const file of files) {
85
+ const parts = file.split("/");
86
+ const filename = parts[parts.length - 1] ?? "";
87
+ if (KNOWN_CONFIG_FILENAMES.has(filename)) continue;
88
+ if (parts.length >= 3) {
89
+ if (isLocaleSegment(parts[parts.length - 2] ?? "")) nestedBasePaths.push(parts.slice(0, -2).join("/") || ".");
90
+ }
91
+ if (parts.length >= 2) {
92
+ if (isLocaleSegment(filename.slice(0, -5))) flatBasePaths.push(parts.slice(0, -1).join("/") || ".");
93
+ }
94
+ }
95
+ if (nestedBasePaths.length === 0 && flatBasePaths.length === 0) return null;
96
+ /**
97
+ * Returns the path prefix that appears most frequently among the matches,
98
+ * formatted as a relative path suitable for a source template.
99
+ */
100
+ const mostFrequentPrefix = (paths) => {
101
+ const counts = paths.reduce((accumulator, path) => {
102
+ accumulator[path] = (accumulator[path] ?? 0) + 1;
103
+ return accumulator;
104
+ }, {});
105
+ const basePath = Object.entries(counts).sort(([, a], [, b]) => b - a)[0]?.[0] ?? ".";
106
+ return basePath === "." ? "." : `./${basePath}`;
107
+ };
108
+ if (nestedBasePaths.length >= flatBasePaths.length) return {
109
+ type: "nested",
110
+ template: `${mostFrequentPrefix(nestedBasePaths)}/\${locale}/\${key}.json`
111
+ };
112
+ return {
113
+ type: "flat",
114
+ template: `${mostFrequentPrefix(flatBasePaths)}/\${locale}.json`
115
+ };
116
+ };
34
117
 
35
118
  //#endregion
119
+ exports.detectJsonLocalePattern = detectJsonLocalePattern;
36
120
  exports.ensureDirectory = ensureDirectory;
37
121
  exports.exists = exists;
38
122
  exports.readFileFromRoot = readFileFromRoot;
@@ -1 +1 @@
1
- {"version":3,"file":"fileSystem.cjs","names":[],"sources":["../../../../src/init/utils/fileSystem.ts"],"sourcesContent":["import { access, mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n * Helper to check if a file exists\n */\nexport const exists = async (rootDir: string, filePath: string) => {\n try {\n await access(join(rootDir, filePath));\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Helper to read a file\n */\nexport const readFileFromRoot = async (rootDir: string, filePath: string) =>\n await readFile(join(rootDir, filePath), 'utf8');\n\n/**\n * Helper to write a file\n */\nexport const writeFileToRoot = async (\n rootDir: string,\n filePath: string,\n content: string\n) => await writeFile(join(rootDir, filePath), content, 'utf8');\n\n/**\n * Helper to ensure a directory exists\n */\nexport const ensureDirectory = async (rootDir: string, dirPath: string) => {\n try {\n await mkdir(join(rootDir, dirPath), { recursive: true });\n } catch {\n // Directory already exists or could not be created\n }\n};\n"],"mappings":";;;;;;;;;AAMA,MAAa,SAAS,OAAO,SAAiB,aAAqB;AACjE,KAAI;AACF,yDAAkB,SAAS,SAAS,CAAC;AACrC,SAAO;SACD;AACN,SAAO;;;;;;AAOX,MAAa,mBAAmB,OAAO,SAAiB,aACtD,yDAAoB,SAAS,SAAS,EAAE,OAAO;;;;AAKjD,MAAa,kBAAkB,OAC7B,SACA,UACA,YACG,0DAAqB,SAAS,SAAS,EAAE,SAAS,OAAO;;;;AAK9D,MAAa,kBAAkB,OAAO,SAAiB,YAAoB;AACzE,KAAI;AACF,wDAAiB,SAAS,QAAQ,EAAE,EAAE,WAAW,MAAM,CAAC;SAClD"}
1
+ {"version":3,"file":"fileSystem.cjs","names":["ALL_LOCALES","EXCLUDED_PATHS"],"sources":["../../../../src/init/utils/fileSystem.ts"],"sourcesContent":["import { access, mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { EXCLUDED_PATHS } from '@intlayer/config/defaultValues';\nimport { ALL_LOCALES } from '@intlayer/types/allLocales';\nimport fg from 'fast-glob';\n\n/**\n * Helper to check if a file exists\n */\nexport const exists = async (rootDir: string, filePath: string) => {\n try {\n await access(join(rootDir, filePath));\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Helper to read a file\n */\nexport const readFileFromRoot = async (rootDir: string, filePath: string) =>\n await readFile(join(rootDir, filePath), 'utf8');\n\n/**\n * Helper to write a file\n */\nexport const writeFileToRoot = async (\n rootDir: string,\n filePath: string,\n content: string\n) => await writeFile(join(rootDir, filePath), content, 'utf8');\n\n/**\n * Helper to ensure a directory exists\n */\nexport const ensureDirectory = async (rootDir: string, dirPath: string) => {\n try {\n await mkdir(join(rootDir, dirPath), { recursive: true });\n } catch {\n // Directory already exists or could not be created\n }\n};\n\n/**\n * Pattern type for locale JSON file organisation.\n * - 'nested': files are at `{base}/{locale}/{key}.json`\n * - 'flat': files are at `{base}/{locale}.json`\n */\nexport type JsonLocalePatternType = 'nested' | 'flat';\n\n/**\n * Detected locale JSON file pattern and the corresponding source template.\n * `template` uses `${locale}` and `${key}` as literal placeholders (not JS\n * expressions) so it can be embedded directly in a template-literal string.\n */\nexport type JsonLocalePattern = {\n type: JsonLocalePatternType;\n /**\n * Source path template for syncJSON `source` option.\n * Example nested: `./locales/${locale}/${key}.json`\n * Example flat: `./locales/${locale}.json`\n */\n template: string;\n};\n\n/**\n * Set of all known locale string values from the intlayer Locales registry\n * (e.g. `'en'`, `'fr'`, `'zh-TW'`). Keyed by the exact locale string so\n * `.has()` lookups are O(1) and common short directory names (`src`, `lib`,\n * `app`, …) are not mistaken for locales.\n */\nconst ALL_LOCALE_VALUES = new Set<string>(Object.values(ALL_LOCALES));\n\n/**\n * Returns true when `segment` matches a known BCP-47 locale identifier, e.g.\n * `en`, `fr`, `zh-TW`, `pt-BR`, `en-US`.\n */\nconst isLocaleSegment = (segment: string): boolean =>\n ALL_LOCALE_VALUES.has(segment);\n\n/** JSON filenames that are never locale translation files. */\nconst KNOWN_CONFIG_FILENAMES = new Set([\n 'package.json',\n 'tsconfig.json',\n 'jsconfig.json',\n 'biome.json',\n 'turbo.json',\n 'lerna.json',\n 'vercel.json',\n 'netlify.json',\n 'babel.config.json',\n 'jest.config.json',\n 'vitest.config.json',\n '.eslintrc.json',\n '.prettierrc.json',\n]);\n\n/**\n * Scans the project for JSON files and determines whether locale files are\n * organised as `{base}/{locale}/{key}.json` (nested) or `{base}/{locale}.json`\n * (flat). Returns the most likely source template, or `null` when no locale\n * JSON files are found.\n *\n * The returned `template` contains `${locale}` and `${key}` as **literal**\n * placeholder strings so it can be embedded inside a JS template literal.\n */\nexport const detectJsonLocalePattern = async (\n rootDir: string\n): Promise<JsonLocalePattern | null> => {\n const files = await fg('**/*.json', {\n cwd: rootDir,\n ignore: EXCLUDED_PATHS,\n absolute: false,\n onlyFiles: true,\n });\n\n const nestedBasePaths: string[] = [];\n const flatBasePaths: string[] = [];\n\n for (const file of files) {\n const parts = file.split('/');\n const filename = parts[parts.length - 1] ?? '';\n\n if (KNOWN_CONFIG_FILENAMES.has(filename)) continue;\n\n // Nested: …/{locale}/{key}.json — parent directory is a locale code\n if (parts.length >= 3) {\n const localeDir = parts[parts.length - 2] ?? '';\n if (isLocaleSegment(localeDir)) {\n nestedBasePaths.push(parts.slice(0, -2).join('/') || '.');\n }\n }\n\n // Flat: …/{locale}.json — filename (without extension) is a locale code\n if (parts.length >= 2) {\n const baseName = filename.slice(0, -5); // strip \".json\"\n if (isLocaleSegment(baseName)) {\n flatBasePaths.push(parts.slice(0, -1).join('/') || '.');\n }\n }\n }\n\n if (nestedBasePaths.length === 0 && flatBasePaths.length === 0) {\n return null;\n }\n\n /**\n * Returns the path prefix that appears most frequently among the matches,\n * formatted as a relative path suitable for a source template.\n */\n const mostFrequentPrefix = (paths: string[]): string => {\n const counts = paths.reduce<Record<string, number>>((accumulator, path) => {\n accumulator[path] = (accumulator[path] ?? 0) + 1;\n return accumulator;\n }, {});\n const topEntry = Object.entries(counts).sort(([, a], [, b]) => b - a)[0];\n const basePath = topEntry?.[0] ?? '.';\n return basePath === '.' ? '.' : `./${basePath}`;\n };\n\n if (nestedBasePaths.length >= flatBasePaths.length) {\n const prefix = mostFrequentPrefix(nestedBasePaths);\n return {\n type: 'nested',\n // Literal ${locale} and ${key} — not evaluated here, used in template literals\n template: `${prefix}/\\${locale}/\\${key}.json`,\n };\n }\n\n const prefix = mostFrequentPrefix(flatBasePaths);\n return {\n type: 'flat',\n template: `${prefix}/\\${locale}.json`,\n };\n};\n"],"mappings":";;;;;;;;;;;;;AASA,MAAa,SAAS,OAAO,SAAiB,aAAqB;AACjE,KAAI;AACF,yDAAkB,SAAS,SAAS,CAAC;AACrC,SAAO;SACD;AACN,SAAO;;;;;;AAOX,MAAa,mBAAmB,OAAO,SAAiB,aACtD,yDAAoB,SAAS,SAAS,EAAE,OAAO;;;;AAKjD,MAAa,kBAAkB,OAC7B,SACA,UACA,YACG,0DAAqB,SAAS,SAAS,EAAE,SAAS,OAAO;;;;AAK9D,MAAa,kBAAkB,OAAO,SAAiB,YAAoB;AACzE,KAAI;AACF,wDAAiB,SAAS,QAAQ,EAAE,EAAE,WAAW,MAAM,CAAC;SAClD;;;;;;;;AAiCV,MAAM,oBAAoB,IAAI,IAAY,OAAO,OAAOA,uCAAY,CAAC;;;;;AAMrE,MAAM,mBAAmB,YACvB,kBAAkB,IAAI,QAAQ;;AAGhC,MAAM,yBAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;;;;;;;AAWF,MAAa,0BAA0B,OACrC,YACsC;CACtC,MAAM,QAAQ,6BAAS,aAAa;EAClC,KAAK;EACL,QAAQC;EACR,UAAU;EACV,WAAW;EACZ,CAAC;CAEF,MAAM,kBAA4B,EAAE;CACpC,MAAM,gBAA0B,EAAE;AAElC,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,QAAQ,KAAK,MAAM,IAAI;EAC7B,MAAM,WAAW,MAAM,MAAM,SAAS,MAAM;AAE5C,MAAI,uBAAuB,IAAI,SAAS,CAAE;AAG1C,MAAI,MAAM,UAAU,GAElB;OAAI,gBADc,MAAM,MAAM,SAAS,MAAM,GACf,CAC5B,iBAAgB,KAAK,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,IAAI,IAAI,IAAI;;AAK7D,MAAI,MAAM,UAAU,GAElB;OAAI,gBADa,SAAS,MAAM,GAAG,GACP,CAAC,CAC3B,eAAc,KAAK,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,IAAI,IAAI,IAAI;;;AAK7D,KAAI,gBAAgB,WAAW,KAAK,cAAc,WAAW,EAC3D,QAAO;;;;;CAOT,MAAM,sBAAsB,UAA4B;EACtD,MAAM,SAAS,MAAM,QAAgC,aAAa,SAAS;AACzE,eAAY,SAAS,YAAY,SAAS,KAAK;AAC/C,UAAO;KACN,EAAE,CAAC;EAEN,MAAM,WADW,OAAO,QAAQ,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,OAAO,IAAI,EAAE,CAAC,KAC1C,MAAM;AAClC,SAAO,aAAa,MAAM,MAAM,KAAK;;AAGvC,KAAI,gBAAgB,UAAU,cAAc,OAE1C,QAAO;EACL,MAAM;EAEN,UAAU,GAJG,mBAAmB,gBAIb,CAAC;EACrB;AAIH,QAAO;EACL,MAAM;EACN,UAAU,GAHG,mBAAmB,cAGb,CAAC;EACrB"}
@@ -2,15 +2,27 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_init_utils_configManipulation = require('./configManipulation.cjs');
3
3
  const require_init_utils_fileSystem = require('./fileSystem.cjs');
4
4
  const require_init_utils_jsonParser = require('./jsonParser.cjs');
5
+ const require_init_utils_packageManager = require('./packageManager.cjs');
5
6
  const require_init_utils_tsConfig = require('./tsConfig.cjs');
6
7
 
8
+ exports.detectJsonLocalePattern = require_init_utils_fileSystem.detectJsonLocalePattern;
9
+ exports.detectMissingIntlayerPackages = require_init_utils_packageManager.detectMissingIntlayerPackages;
10
+ exports.detectPackageManager = require_init_utils_packageManager.detectPackageManager;
7
11
  exports.ensureDirectory = require_init_utils_fileSystem.ensureDirectory;
8
12
  exports.exists = require_init_utils_fileSystem.exists;
9
13
  exports.findTsConfigFiles = require_init_utils_tsConfig.findTsConfigFiles;
14
+ exports.installPackages = require_init_utils_packageManager.installPackages;
10
15
  exports.parseJSONWithComments = require_init_utils_jsonParser.parseJSONWithComments;
11
16
  exports.readFileFromRoot = require_init_utils_fileSystem.readFileFromRoot;
12
17
  exports.updateAstroConfig = require_init_utils_configManipulation.updateAstroConfig;
18
+ exports.updateIntlayerConfigWithSyncPlugin = require_init_utils_configManipulation.updateIntlayerConfigWithSyncPlugin;
13
19
  exports.updateNextConfig = require_init_utils_configManipulation.updateNextConfig;
20
+ exports.updateNextConfigForNextI18next = require_init_utils_configManipulation.updateNextConfigForNextI18next;
21
+ exports.updateNextConfigForNextIntl = require_init_utils_configManipulation.updateNextConfigForNextIntl;
22
+ exports.updateNextConfigForNextTranslate = require_init_utils_configManipulation.updateNextConfigForNextTranslate;
14
23
  exports.updateNuxtConfig = require_init_utils_configManipulation.updateNuxtConfig;
24
+ exports.updateNuxtConfigForNuxtjsI18n = require_init_utils_configManipulation.updateNuxtConfigForNuxtjsI18n;
15
25
  exports.updateViteConfig = require_init_utils_configManipulation.updateViteConfig;
26
+ exports.updateViteConfigForCompatPlugin = require_init_utils_configManipulation.updateViteConfigForCompatPlugin;
27
+ exports.updateViteConfigForVueI18n = require_init_utils_configManipulation.updateViteConfigForVueI18n;
16
28
  exports.writeFileToRoot = require_init_utils_fileSystem.writeFileToRoot;