@intlayer/engine 9.5.9-canary.0 → 9.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
- package/dist/cjs/build.cjs +4 -4
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +2 -2
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +3 -3
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeNestedDictionary.cjs +3 -3
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +2 -2
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +2 -2
- package/dist/cjs/cleanOutputDir.cjs +1 -1
- package/dist/cjs/cleanRemovedContentDeclaration.cjs +1 -1
- package/dist/cjs/cli.cjs +10 -3
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +2 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +2 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +2 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +2 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +2 -2
- package/dist/cjs/createType/createModuleAugmentation.cjs +3 -3
- package/dist/cjs/createType/createType.cjs +1 -1
- package/dist/cjs/docReview/index.cjs +5 -5
- package/dist/cjs/docReview/pipeline.cjs +4 -4
- package/dist/cjs/docReview/reviewReport.cjs.map +1 -1
- package/dist/cjs/fetchDistantDictionaries.cjs +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs +2 -2
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +1 -1
- package/dist/cjs/init/cms.cjs +35 -0
- package/dist/cjs/init/cms.cjs.map +1 -1
- package/dist/cjs/init/documentationRouter.cjs +141 -0
- package/dist/cjs/init/documentationRouter.cjs.map +1 -0
- package/dist/cjs/init/frameworkSetup/backend/index.cjs +138 -0
- package/dist/cjs/init/frameworkSetup/backend/index.cjs.map +1 -0
- package/dist/cjs/init/frameworkSetup/backend/transforms.cjs +223 -0
- package/dist/cjs/init/frameworkSetup/backend/transforms.cjs.map +1 -0
- package/dist/cjs/init/frameworkSetup/index.cjs +9 -3
- package/dist/cjs/init/frameworkSetup/index.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/localeRouting.cjs +13 -0
- package/dist/cjs/init/frameworkSetup/localeRouting.cjs.map +1 -0
- package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs +34 -7
- package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs +1 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/templates.cjs +56 -0
- package/dist/cjs/init/frameworkSetup/nextAppRouter/templates.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs +2 -2
- package/dist/cjs/init/frameworkSetup/nextAppRouter/transforms.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs +32 -3
- package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/tanstackStart/restructure.cjs +1 -1
- package/dist/cjs/init/frameworkSetup/tanstackStart/templates.cjs +58 -0
- package/dist/cjs/init/frameworkSetup/tanstackStart/templates.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs +94 -14
- package/dist/cjs/init/frameworkSetup/tanstackStart/transforms.cjs.map +1 -1
- package/dist/cjs/init/index.cjs +46 -159
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/init/utils/configManipulation.cjs +39 -0
- package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
- package/dist/cjs/init/utils/fileSystem.cjs +1 -1
- package/dist/cjs/init/utils/githubActions.cjs +1 -1
- package/dist/cjs/init/utils/index.cjs +10 -0
- package/dist/cjs/init/utils/intlayerDependencies.cjs +1 -1
- package/dist/cjs/init/utils/lintConfig.cjs +52 -0
- package/dist/cjs/init/utils/lintConfig.cjs.map +1 -0
- package/dist/cjs/init/utils/packageManager.cjs +63 -14
- package/dist/cjs/init/utils/packageManager.cjs.map +1 -1
- package/dist/cjs/init/utils/urlRoutingFramework.cjs +41 -0
- package/dist/cjs/init/utils/urlRoutingFramework.cjs.map +1 -0
- package/dist/cjs/initConfig/index.cjs +5 -2
- package/dist/cjs/initConfig/index.cjs.map +1 -1
- package/dist/cjs/installLSP.cjs +1 -1
- package/dist/cjs/installMCP/installMCP.cjs +1 -1
- package/dist/cjs/installSkills/index.cjs +1 -1
- package/dist/cjs/listDictionariesPath.cjs +1 -1
- package/dist/cjs/listGitFiles.cjs +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +2 -2
- package/dist/cjs/loadDictionaries/index.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +2 -2
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadMarkdownContentDeclaration.cjs +1 -1
- package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs +104 -43
- package/dist/cjs/loadDictionaries/logTypeScriptErrors.cjs.map +1 -1
- package/dist/cjs/logConfigDetails.cjs +1 -1
- package/dist/cjs/prepareIntlayer.cjs +4 -4
- package/dist/cjs/scan/index.cjs +1 -1
- package/dist/cjs/scan/scanWebsite.cjs +1 -1
- package/dist/cjs/syncPluginKit/createFileAdapter.cjs +1 -1
- package/dist/cjs/syncPluginKit/index.cjs +1 -1
- package/dist/cjs/utils/buildComponentFilesList.cjs +1 -1
- package/dist/cjs/utils/contentWatcherLock.cjs +2 -2
- package/dist/cjs/utils/index.cjs +4 -4
- package/dist/cjs/utils/readDictionariesFromDisk.cjs +1 -1
- package/dist/cjs/utils/runOnce.cjs +1 -1
- package/dist/cjs/utils/runParallel/pidTree.cjs +1 -1
- package/dist/cjs/utils/withFileLock.cjs +1 -1
- package/dist/cjs/watcher.cjs +6 -6
- package/dist/cjs/writeConfiguration/index.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +2 -2
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +4 -4
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +3 -3
- package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs +1 -1
- package/dist/cjs/writeFileIfChanged.cjs +1 -1
- package/dist/esm/_virtual/_utils_asset.mjs +1 -1
- package/dist/esm/build.mjs +4 -4
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +2 -2
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +3 -3
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +1 -1
- package/dist/esm/buildIntlayerDictionary/writeNestedDictionary.mjs +3 -3
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +2 -2
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +2 -2
- package/dist/esm/cleanOutputDir.mjs +1 -1
- package/dist/esm/cleanRemovedContentDeclaration.mjs +1 -1
- package/dist/esm/cli.mjs +8 -6
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +2 -2
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +2 -2
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +2 -2
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +2 -2
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +2 -2
- package/dist/esm/createType/createModuleAugmentation.mjs +3 -3
- package/dist/esm/createType/createType.mjs +1 -1
- package/dist/esm/docReview/index.mjs +5 -5
- package/dist/esm/docReview/pipeline.mjs +4 -4
- package/dist/esm/docReview/reviewReport.mjs.map +1 -1
- package/dist/esm/fetchDistantDictionaries.mjs +1 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs +2 -2
- package/dist/esm/handleUnlinkedContentDeclarationFile.mjs +1 -1
- package/dist/esm/init/cms.mjs +35 -2
- package/dist/esm/init/cms.mjs.map +1 -1
- package/dist/esm/init/documentationRouter.mjs +139 -0
- package/dist/esm/init/documentationRouter.mjs.map +1 -0
- package/dist/esm/init/frameworkSetup/backend/index.mjs +130 -0
- package/dist/esm/init/frameworkSetup/backend/index.mjs.map +1 -0
- package/dist/esm/init/frameworkSetup/backend/transforms.mjs +216 -0
- package/dist/esm/init/frameworkSetup/backend/transforms.mjs.map +1 -0
- package/dist/esm/init/frameworkSetup/index.mjs +9 -3
- package/dist/esm/init/frameworkSetup/index.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/localeRouting.mjs +12 -0
- package/dist/esm/init/frameworkSetup/localeRouting.mjs.map +1 -0
- package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs +36 -9
- package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs +1 -1
- package/dist/esm/init/frameworkSetup/nextAppRouter/templates.mjs +54 -1
- package/dist/esm/init/frameworkSetup/nextAppRouter/templates.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs +2 -2
- package/dist/esm/init/frameworkSetup/nextAppRouter/transforms.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs +35 -6
- package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/tanstackStart/restructure.mjs +1 -1
- package/dist/esm/init/frameworkSetup/tanstackStart/templates.mjs +56 -1
- package/dist/esm/init/frameworkSetup/tanstackStart/templates.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs +94 -15
- package/dist/esm/init/frameworkSetup/tanstackStart/transforms.mjs.map +1 -1
- package/dist/esm/init/index.mjs +42 -158
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/init/utils/configManipulation.mjs +38 -1
- package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
- package/dist/esm/init/utils/fileSystem.mjs +1 -1
- package/dist/esm/init/utils/githubActions.mjs +1 -1
- package/dist/esm/init/utils/index.mjs +5 -3
- package/dist/esm/init/utils/intlayerDependencies.mjs +1 -1
- package/dist/esm/init/utils/lintConfig.mjs +50 -0
- package/dist/esm/init/utils/lintConfig.mjs.map +1 -0
- package/dist/esm/init/utils/packageManager.mjs +61 -15
- package/dist/esm/init/utils/packageManager.mjs.map +1 -1
- package/dist/esm/init/utils/urlRoutingFramework.mjs +40 -0
- package/dist/esm/init/utils/urlRoutingFramework.mjs.map +1 -0
- package/dist/esm/initConfig/index.mjs +5 -2
- package/dist/esm/initConfig/index.mjs.map +1 -1
- package/dist/esm/installLSP.mjs +1 -1
- package/dist/esm/installMCP/installMCP.mjs +1 -1
- package/dist/esm/installSkills/index.mjs +1 -1
- package/dist/esm/listDictionariesPath.mjs +1 -1
- package/dist/esm/listGitFiles.mjs +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +2 -2
- package/dist/esm/loadDictionaries/index.mjs +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +2 -2
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +1 -1
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +1 -1
- package/dist/esm/loadDictionaries/loadMarkdownContentDeclaration.mjs +1 -1
- package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs +105 -44
- package/dist/esm/loadDictionaries/logTypeScriptErrors.mjs.map +1 -1
- package/dist/esm/logConfigDetails.mjs +1 -1
- package/dist/esm/prepareIntlayer.mjs +4 -4
- package/dist/esm/scan/index.mjs +1 -1
- package/dist/esm/scan/scanWebsite.mjs +1 -1
- package/dist/esm/syncPluginKit/createFileAdapter.mjs +1 -1
- package/dist/esm/syncPluginKit/index.mjs +1 -1
- package/dist/esm/utils/buildComponentFilesList.mjs +1 -1
- package/dist/esm/utils/contentWatcherLock.mjs +2 -2
- package/dist/esm/utils/index.mjs +4 -4
- package/dist/esm/utils/readDictionariesFromDisk.mjs +1 -1
- package/dist/esm/utils/runOnce.mjs +1 -1
- package/dist/esm/utils/runParallel/pidTree.mjs +1 -1
- package/dist/esm/utils/withFileLock.mjs +1 -1
- package/dist/esm/watcher.mjs +6 -6
- package/dist/esm/writeConfiguration/index.mjs +1 -1
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +2 -2
- package/dist/esm/writeContentDeclaration/transformJSFile.mjs +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +4 -4
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +3 -3
- package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +1 -1
- package/dist/esm/writeContentDeclaration/writeYamlFile.mjs +1 -1
- package/dist/esm/writeFileIfChanged.mjs +1 -1
- package/dist/types/cli.d.ts +5 -3
- package/dist/types/docReview/reviewReport.d.ts.map +1 -1
- package/dist/types/formatDictionary.d.ts +2 -2
- package/dist/types/init/cms.d.ts +11 -0
- package/dist/types/init/cms.d.ts.map +1 -1
- package/dist/types/init/documentationRouter.d.ts +64 -0
- package/dist/types/init/documentationRouter.d.ts.map +1 -0
- package/dist/types/init/frameworkSetup/backend/index.d.ts +16 -0
- package/dist/types/init/frameworkSetup/backend/index.d.ts.map +1 -0
- package/dist/types/init/frameworkSetup/backend/transforms.d.ts +37 -0
- package/dist/types/init/frameworkSetup/backend/transforms.d.ts.map +1 -0
- package/dist/types/init/frameworkSetup/index.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/localeRouting.d.ts +11 -0
- package/dist/types/init/frameworkSetup/localeRouting.d.ts.map +1 -0
- package/dist/types/init/frameworkSetup/nextAppRouter/index.d.ts +5 -5
- package/dist/types/init/frameworkSetup/nextAppRouter/index.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/nextAppRouter/templates.d.ts +12 -0
- package/dist/types/init/frameworkSetup/nextAppRouter/templates.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/nextAppRouter/transforms.d.ts +10 -1
- package/dist/types/init/frameworkSetup/nextAppRouter/transforms.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/tanstackStart/index.d.ts +3 -2
- package/dist/types/init/frameworkSetup/tanstackStart/index.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/tanstackStart/templates.d.ts +10 -0
- package/dist/types/init/frameworkSetup/tanstackStart/templates.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts +12 -0
- package/dist/types/init/frameworkSetup/tanstackStart/transforms.d.ts.map +1 -1
- package/dist/types/init/frameworkSetup/types.d.ts +6 -0
- package/dist/types/init/frameworkSetup/types.d.ts.map +1 -1
- package/dist/types/init/index.d.ts +15 -1
- package/dist/types/init/index.d.ts.map +1 -1
- package/dist/types/init/utils/configManipulation.d.ts +14 -0
- package/dist/types/init/utils/configManipulation.d.ts.map +1 -1
- package/dist/types/init/utils/index.d.ts +5 -3
- package/dist/types/init/utils/lintConfig.d.ts +28 -0
- package/dist/types/init/utils/lintConfig.d.ts.map +1 -0
- package/dist/types/init/utils/packageManager.d.ts +29 -6
- package/dist/types/init/utils/packageManager.d.ts.map +1 -1
- package/dist/types/init/utils/urlRoutingFramework.d.ts +9 -0
- package/dist/types/init/utils/urlRoutingFramework.d.ts.map +1 -0
- package/dist/types/initConfig/index.d.ts +3 -1
- package/dist/types/initConfig/index.d.ts.map +1 -1
- package/dist/types/loadDictionaries/logTypeScriptErrors.d.ts +4 -0
- package/dist/types/loadDictionaries/logTypeScriptErrors.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configManipulation.cjs","names":["typescriptParser","isModuleScopeBinding"],"sources":["../../../../src/init/utils/configManipulation.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types/config';\nimport * as recast from 'recast';\nimport { typescriptParser } from '../../utils/babelParser';\nimport { isModuleScopeBinding } from './astImports';\nimport type {\n CompatSyncConfig,\n CompatVitePluginConfig,\n} from './packageManager';\n\nconst { builders: b, namedTypes: n } = recast.types;\n\n/** The locale routing strategies supported by the Intlayer configuration. */\nexport type RoutingMode = RoutingConfig['mode'];\n\n/** Narrows an arbitrary recast node to an object expression. */\nconst isObjectExpression = (node: any): boolean =>\n Boolean(node) &&\n (node.type === 'ObjectExpression' || n.ObjectExpression.check(node));\n\n/**\n * Finds a property by key name on an object expression, creating it with the\n * provided default value node when it is absent. Returns the property node so\n * callers can read or mutate its value while preserving any attached comments.\n */\nconst ensureObjectProperty = (\n objExpr: any,\n key: string,\n defaultValueNode: any\n): any => {\n let property = (objExpr.properties as any[]).find((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === key;\n });\n\n if (!property) {\n property = b.property('init', b.identifier(key), defaultValueNode);\n (objExpr.properties as any[]).push(property);\n }\n\n return property;\n};\n\n/**\n * Sets (or replaces) a property's value on an object expression. When the\n * property already exists only its value node is swapped, which keeps the\n * leading documentation comment in place.\n */\nconst setObjectPropertyValue = (\n objExpr: any,\n key: string,\n valueNode: any\n): void => {\n const property = (objExpr.properties as any[]).find((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === key;\n });\n\n if (property) {\n property.value = valueNode;\n return;\n }\n\n (objExpr.properties as any[]).push(\n b.property('init', b.identifier(key), valueNode)\n );\n};\n\n/**\n * Adds a `process.env.<envVar>` reference property to an object expression when\n * the property is not already present. Existing values are left untouched.\n */\nconst addEnvReferenceProperty = (\n objExpr: any,\n key: string,\n envVar: string\n): void => {\n const hasProperty = (objExpr.properties as any[]).some((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === key;\n });\n\n if (hasProperty) return;\n\n (objExpr.properties as any[]).push(\n b.property(\n 'init',\n b.identifier(key),\n b.memberExpression(\n b.memberExpression(b.identifier('process'), b.identifier('env')),\n b.identifier(envVar)\n )\n )\n );\n};\n\n/**\n * Sets `routing.mode` in an Intlayer configuration file to the requested\n * strategy. Idempotent: re-running with the same mode produces identical\n * output. Supports `.ts`, `.mjs`, `.js` and `.cjs` configs; JSON configs are\n * handled with a scoped string replacement since they cannot be parsed by the\n * TypeScript recast parser.\n */\nexport const setIntlayerConfigRoutingMode = (\n content: string,\n extension: string,\n mode: RoutingMode\n): string => {\n if (extension === 'json') {\n return content.replace(\n /(\"mode\"\\s*:\\s*)\"(?:prefix-no-default|prefix-all|no-prefix|search-params)\"/,\n `$1\"${mode}\"`\n );\n }\n\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n genericRecastVisit(ast, (objExpr) => {\n if (!isObjectExpression(objExpr)) return;\n\n const routingProperty = ensureObjectProperty(\n objExpr,\n 'routing',\n b.objectExpression([])\n );\n\n if (!isObjectExpression(routingProperty.value)) return;\n\n setObjectPropertyValue(\n routingProperty.value,\n 'mode',\n b.stringLiteral(mode)\n );\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * Sets `compiler.output` in an Intlayer configuration file to the given path\n * template (the `{{variable}}` string form, e.g.\n * `/locales/{{locale}}/{{key}}.content.json`). Idempotent: re-running with the\n * same template produces identical output. Supports `.ts`, `.mjs`, `.js` and\n * `.cjs` configs; JSON configs are supported too since the template is a plain\n * string.\n */\nexport const setIntlayerConfigCompilerOutput = (\n content: string,\n extension: string,\n outputTemplate: string\n): string => {\n if (extension === 'json') {\n const parsed = JSON.parse(content);\n parsed.compiler = { ...parsed.compiler, output: outputTemplate };\n return JSON.stringify(parsed, null, 2);\n }\n\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n genericRecastVisit(ast, (objExpr) => {\n if (!isObjectExpression(objExpr)) return;\n\n const compilerProperty = ensureObjectProperty(\n objExpr,\n 'compiler',\n b.objectExpression([])\n );\n\n if (!isObjectExpression(compilerProperty.value)) return;\n\n setObjectPropertyValue(\n compilerProperty.value,\n 'output',\n b.stringLiteral(outputTemplate)\n );\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * Enables the Intlayer visual editor in a configuration file: sets\n * `editor.enabled` to `true` and wires `clientId` / `clientSecret` to the\n * `INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET` environment variables.\n * Idempotent and non-destructive — existing `clientId` / `clientSecret` values\n * are preserved. Only `.ts`, `.mjs`, `.js` and `.cjs` configs are supported\n * (JSON cannot reference `process.env`).\n */\nexport const enableIntlayerEditorConfig = (content: string): string => {\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n genericRecastVisit(ast, (objExpr) => {\n if (!isObjectExpression(objExpr)) return;\n\n const editorProperty = ensureObjectProperty(\n objExpr,\n 'editor',\n b.objectExpression([])\n );\n\n if (!isObjectExpression(editorProperty.value)) return;\n\n const editorObject = editorProperty.value;\n\n setObjectPropertyValue(editorObject, 'enabled', b.booleanLiteral(true));\n addEnvReferenceProperty(editorObject, 'clientId', 'INTLAYER_CLIENT_ID');\n addEnvReferenceProperty(\n editorObject,\n 'clientSecret',\n 'INTLAYER_CLIENT_SECRET'\n );\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * True when `statement` is one of the module's own import statements —\n * `import … from '…'` in ESM, `const … = require('…')` in CJS.\n */\nconst isImportStatement = (statement: any, isCJS: boolean): boolean => {\n if (!isCJS) return n.ImportDeclaration.check(statement);\n\n return (\n n.VariableDeclaration.check(statement) &&\n statement.declarations.some(\n (declarator: any) =>\n n.VariableDeclarator.check(declarator) &&\n n.CallExpression.check(declarator.init) &&\n n.Identifier.check(declarator.init.callee) &&\n declarator.init.callee.name === 'require'\n )\n );\n};\n\n/**\n * Adds `declaration` to the top of the module, after the leading import block\n * so the injected import is grouped with the existing ones.\n *\n * Unshifting blindly would push the file's leading comments down one\n * statement, which silently disables directives that only apply on the first\n * line — `// @ts-check`, present in the config Astro and Vite scaffold.\n */\nconst insertImportDeclaration = (\n ast: any,\n isCJS: boolean,\n declaration: any\n): void => {\n const body = ast.program.body;\n\n let insertionIndex = 0;\n while (\n insertionIndex < body.length &&\n isImportStatement(body[insertionIndex], isCJS)\n ) {\n insertionIndex++;\n }\n\n // No import to group with: keep the file's leading comments on the first\n // line by moving them onto the injected statement.\n if (insertionIndex === 0 && body.length > 0) {\n const leadingComments = (body[0].comments ?? []).filter(\n (comment: any) => comment.leading\n );\n\n if (leadingComments.length > 0) {\n body[0].comments = (body[0].comments ?? []).filter(\n (comment: any) => !comment.leading\n );\n declaration.comments = leadingComments;\n }\n }\n\n body.splice(insertionIndex, 0, declaration);\n};\n\nconst injectImport = (\n ast: any,\n isCJS: boolean,\n importName: string,\n source: string\n) => {\n // Never redeclare an identifier already bound at module scope (e.g. imported\n // from another source or declared locally) — that would be a parse error.\n if (!isCJS && isModuleScopeBinding(ast, importName)) return;\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 insertImportDeclaration(ast, isCJS, 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 /**\n * Resolves an identifier reference (e.g. `export default config` /\n * `module.exports = config`) back to the object expression it was declared\n * with, then runs the updater on it.\n */\n const resolveIdentifierConfig = (name: string) => {\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\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 resolveIdentifierConfig(decl.name);\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 } else if (n.Identifier.check(right)) {\n resolveIdentifierConfig(right.name);\n }\n }\n return false;\n },\n });\n};\n\n/**\n * Detects whether a Vite config already wires in an Intlayer plugin — either the\n * base `vite-intlayer` plugin or one of the compat adapters (e.g.\n * `reactI18nextVitePlugin` from `@intlayer/react-i18next/plugin`). The compat\n * plugins internally wrap `intlayer()`, so a standalone `intlayer()` must not be\n * appended when one is already present, otherwise the plugin runs twice.\n */\nexport const hasIntlayerVitePlugin = (content: string): boolean =>\n content.includes('vite-intlayer') ||\n /@intlayer\\/[^'\"]+\\/plugin/.test(content);\n\nexport const updateViteConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: typescriptParser,\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: typescriptParser,\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: typescriptParser,\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\n/**\n * Returns true when the expression looks like an Immediately Invoked Function\n * Expression (e.g. `(async () => { ... })()`). Such custom async exports cannot\n * be safely wrapped with the synchronous Metro helper, so they are skipped.\n */\nconst isImmediatelyInvokedFunction = (node: any): boolean =>\n n.CallExpression.check(node) &&\n (n.ArrowFunctionExpression.check(node.callee) ||\n n.FunctionExpression.check(node.callee));\n\n/**\n * Wraps a React Native Metro config's exported value with\n * `configMetroIntlayerSync` from `react-native-intlayer/metro`, injecting the\n * import. The synchronous helper is used because it wraps a plain config object\n * and needs no IIFE, making it safe to inject into existing configs without\n * restructuring them.\n *\n * Non-destructive: returns the content unchanged when the export is already\n * wrapped, when the Intlayer Metro plugin is already present, or when the export\n * is a custom async IIFE that cannot be wrapped synchronously. Callers should\n * compare the result with the input to detect the skipped case.\n */\nexport const updateMetroConfig = (\n content: string,\n extension: string\n): string => {\n if (content.includes('react-native-intlayer')) {\n return content;\n }\n\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n const wrapperName = 'configMetroIntlayerSync';\n\n const isWrappable = (node: any): boolean =>\n n.Expression.check(node) &&\n !isImmediatelyInvokedFunction(node) &&\n !(\n n.CallExpression.check(node) &&\n n.Identifier.check(node.callee) &&\n node.callee.name === wrapperName\n );\n\n let wrapped = false;\n\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (isWrappable(declaration)) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier(wrapperName), [declaration as any])\n );\n wrapped = true;\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 isWrappable(right)\n ) {\n path\n .get('right')\n .replace(b.callExpression(b.identifier(wrapperName), [right]));\n wrapped = true;\n }\n return false;\n },\n });\n\n // Only inject the import when an export was actually wrapped, so an\n // un-wrappable config is left completely untouched.\n if (!wrapped) {\n return content;\n }\n\n injectImport(ast, isCJSFile, wrapperName, 'react-native-intlayer/metro');\n\n return recast.print(ast).code;\n};\n\n/**\n * Builds the contents of a fresh `metro.config.js` wired with the Intlayer\n * Metro plugin. Uses the async `configMetroIntlayer` helper (which can build\n * dictionaries on server start) and picks the default-config source based on\n * whether the project is an Expo app.\n */\nexport const getMetroConfigTemplate = (isExpo: boolean): string => {\n const defaultConfigSource = isExpo\n ? 'expo/metro-config'\n : '@react-native/metro-config';\n\n return `const { getDefaultConfig } = require(\"${defaultConfigSource}\");\nconst { configMetroIntlayer } = require(\"react-native-intlayer/metro\");\n\nmodule.exports = (async () => {\n const defaultConfig = getDefaultConfig(__dirname);\n\n return await configMetroIntlayer(defaultConfig);\n})();\n`;\n};\n\nexport const updateNuxtConfig = (content: string): string => {\n const ast = recast.parse(content, {\n parser: typescriptParser,\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: typescriptParser,\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: typescriptParser,\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 * Rewrites the module source of an existing named import in a vite config,\n * keeping the imported binding and its call site untouched. Used when a compat\n * plugin is a drop-in replacement for an i18n library's own vite plugin — e.g.\n * lingui: `import { lingui } from \"@lingui/vite-plugin\"` becomes\n * `import { lingui } from \"@intlayer/lingui/plugin\"`, leaving `lingui()` in the\n * `plugins` array as-is. Returns the content unchanged when no matching import\n * is found.\n */\nexport const replaceViteConfigPluginImportSource = (\n content: string,\n importName: string,\n fromPackageSource: string,\n toPackageSource: string\n): string => {\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n let changed = false;\n\n recast.visit(ast, {\n visitImportDeclaration(path) {\n const { source, specifiers } = path.node;\n const importsBinding = (specifiers ?? []).some(\n (specifier) =>\n n.ImportSpecifier.check(specifier) &&\n specifier.imported.name === importName\n );\n\n if (\n n.StringLiteral.check(source) &&\n source.value === fromPackageSource &&\n importsBinding\n ) {\n source.value = toPackageSource;\n changed = true;\n }\n\n return false;\n },\n });\n\n if (!changed) return content;\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: typescriptParser,\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: typescriptParser,\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: typescriptParser,\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/** The sync plugin used to ingest a compat library's catalogs. */\ntype SyncPluginInfo = {\n /** Called function name, e.g. `'syncJSON'`. */\n functionName: string;\n /** Package the function is imported from. */\n packageSource: string;\n};\n\n/** Resolves the sync plugin (function + package) for a compat sync config. */\nconst getSyncPluginInfo = (syncConfig: CompatSyncConfig): SyncPluginInfo =>\n syncConfig.plugin === 'po'\n ? { functionName: 'syncPO', packageSource: '@intlayer/sync-po-plugin' }\n : { functionName: 'syncJSON', packageSource: '@intlayer/sync-json-plugin' };\n\n/**\n * Parses a `syncJSON({ ... })` / `syncPO({ ... })` call expression from a source\n * snippet so it can be injected into a config AST without manually constructing\n * template-literal 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 *\n * For `syncJSON` every option is emitted explicitly — `source`, then `format`\n * and `splitKeys` — each preceded by an explanatory JSDoc block, so the\n * generated config self-documents the two knobs a user is most likely to tweak.\n * `syncPO` takes neither `format` (gettext is always the serialization) nor\n * `splitKeys`, so it keeps a bare `source`-only call.\n */\nconst buildSyncCallNode = (syncConfig: CompatSyncConfig): any => {\n const { functionName } = getSyncPluginInfo(syncConfig);\n const usesKey = syncConfig.sourceTemplate.includes('${key}');\n const paramDestructuring = !usesKey\n ? '{ locale }'\n : // `icu` (and PO, which is ICU-dialect) reads `{ key, locale }`; the\n // i18next/vue-i18n JSON dialects keep their established `{ locale, key }`.\n syncConfig.format === 'icu' || syncConfig.plugin === 'po'\n ? '{ key, locale }'\n : '{ locale, key }';\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 sourceProperty = `source: (${paramDestructuring}) => \\`${syncConfig.sourceTemplate}\\``;\n\n const parseSnippet = (snippet: string): any => {\n const snippetAst = recast.parse(snippet, {\n parser: typescriptParser,\n });\n return (snippetAst.program.body[0] as any).expression;\n };\n\n // `syncPO` always serializes gettext, so it exposes neither `format` nor\n // `splitKeys`: emit a bare `source`-only call.\n if (syncConfig.plugin === 'po') {\n return parseSnippet(`${functionName}({ ${sourceProperty} })`);\n }\n\n // `splitKeys: true` is forced only for the single-file namespace model\n // (next-intl / use-intl); every other library keeps a single dictionary per\n // file. It is now written explicitly (rather than relying on syncJSON's\n // auto-detection) so the generated config documents the choice.\n const splitKeys = Boolean(syncConfig.splitKeys);\n\n // The JSDoc blocks are embedded in the snippet and preserved by recast when\n // the parsed call node is printed back into the config AST.\n const snippet = `${functionName}({\n ${sourceProperty},\n\n /**\n * Parsing of json respecting the syntax\n * Default \\`'intlayer'\\` message format\n */\n format: '${syncConfig.format}',\n\n /**\n * \\`true\\`:\n * \\`en.json\\` -> \\`useTranslation('home')\\` -> \\`t(\"title\")\\`\n *\n * \\`false\\`:\n * \\`en.json\\` -> \\`useTranslation()\\` -> \\`t(\"home.title\")\\`\n */\n splitKeys: ${splitKeys},\n})`;\n\n return parseSnippet(snippet);\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 sync plugin import (`syncJSON` / `syncPO`) and a configured\n * `syncJSON(...)` / `syncPO(...)` call into the plugins array of an intlayer\n * config file. Idempotent: skips when the plugin call is already present.\n */\nexport const updateIntlayerConfigWithSyncPlugin = (\n content: string,\n extension: string,\n syncConfig: CompatSyncConfig\n): string => {\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n const { functionName, packageSource } = getSyncPluginInfo(syncConfig);\n\n injectImport(ast, isCJSFile, functionName, packageSource);\n\n const callNode = buildSyncCallNode(syncConfig);\n\n // PO catalogs are serialized as gettext; JSON catalogs carry the dialect.\n const dictionaryFormat =\n syncConfig.plugin === 'po' ? 'po' : syncConfig.format;\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, dictionaryFormat);\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 hasSyncPlugin = (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 === functionName;\n }\n );\n\n if (!hasSyncPlugin) {\n (arrayValue.elements as any[]).push(callNode);\n }\n }\n });\n\n return recast.print(ast).code;\n};\n"],"mappings":";;;;;;;;AASA,MAAM,EAAE,UAAU,GAAG,YAAY,MAAM,OAAO;;AAM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,UAAU;CAG7C,MAAM,mBACJ,WAAW,WAAW,OAAO,OAAO,WAAW;CAEjD,mBAAmB,MAAM,YAAY;EACnC,IACE,CAAC,WACA,QAAQ,SAAS,sBAChB,CAAC,EAAE,iBAAiB,MAAM,OAAO,GAEnC;EAIF,uBAAuB,SAAS,gBAAgB;EAEhD,IAAI,cAAe,QAAQ,WAAqB,MAAM,SAAc;GAClE,IAAI,CAAC,MAAM,KAAK,OAAO;GAEvB,QADgB,KAAK,IAAI,QAAQ,KAAK,IAAI,WACvB;EACrB,CAAC;EAED,IAAI,CAAC,aAAa;GAChB,cAAc,EAAE,SACd,QACA,EAAE,WAAW,SAAS,GACtB,EAAE,gBAAgB,CAAC,CAAC,CACtB;GACA,AAAC,QAAQ,WAAqB,KAAK,WAAW;EAChD;EAEA,MAAM,aAAa,YAAY;EAE/B,IACE,eACC,WAAW,SAAS,qBACnB,EAAE,gBAAgB,MAAM,UAAU,IAWpC;OAAI,CATmB,WAAW,SAAmB,MAClD,YAAiB;IAChB,MAAM,SAAS,SAAS;IACxB,IAAI,CAAC,QAAQ,OAAO;IAEpB,QADqB,OAAO,QAAQ,OAAO,IAAI,UAC/B;GAClB,CAGe,GACf,AAAC,WAAW,SAAmB,KAAK,QAAQ;EAC9C;CAEJ,CAAC;CAED,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;AAC3B"}
|
|
1
|
+
{"version":3,"file":"configManipulation.cjs","names":["typescriptParser","isModuleScopeBinding"],"sources":["../../../../src/init/utils/configManipulation.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types/config';\nimport * as recast from 'recast';\nimport { typescriptParser } from '../../utils/babelParser';\nimport { isModuleScopeBinding } from './astImports';\nimport type {\n CompatSyncConfig,\n CompatVitePluginConfig,\n} from './packageManager';\n\nconst { builders: b, namedTypes: n } = recast.types;\n\n/** The locale routing strategies supported by the Intlayer configuration. */\nexport type RoutingMode = RoutingConfig['mode'];\n\n/** Narrows an arbitrary recast node to an object expression. */\nconst isObjectExpression = (node: any): boolean =>\n Boolean(node) &&\n (node.type === 'ObjectExpression' || n.ObjectExpression.check(node));\n\n/**\n * Finds a property by key name on an object expression, creating it with the\n * provided default value node when it is absent. Returns the property node so\n * callers can read or mutate its value while preserving any attached comments.\n */\nconst ensureObjectProperty = (\n objExpr: any,\n key: string,\n defaultValueNode: any\n): any => {\n let property = (objExpr.properties as any[]).find((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === key;\n });\n\n if (!property) {\n property = b.property('init', b.identifier(key), defaultValueNode);\n (objExpr.properties as any[]).push(property);\n }\n\n return property;\n};\n\n/**\n * Sets (or replaces) a property's value on an object expression. When the\n * property already exists only its value node is swapped, which keeps the\n * leading documentation comment in place.\n */\nconst setObjectPropertyValue = (\n objExpr: any,\n key: string,\n valueNode: any\n): void => {\n const property = (objExpr.properties as any[]).find((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === key;\n });\n\n if (property) {\n property.value = valueNode;\n return;\n }\n\n (objExpr.properties as any[]).push(\n b.property('init', b.identifier(key), valueNode)\n );\n};\n\n/**\n * Adds a `process.env.<envVar>` reference property to an object expression when\n * the property is not already present. Existing values are left untouched.\n */\nconst addEnvReferenceProperty = (\n objExpr: any,\n key: string,\n envVar: string\n): void => {\n const hasProperty = (objExpr.properties as any[]).some((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === key;\n });\n\n if (hasProperty) return;\n\n (objExpr.properties as any[]).push(\n b.property(\n 'init',\n b.identifier(key),\n b.memberExpression(\n b.memberExpression(b.identifier('process'), b.identifier('env')),\n b.identifier(envVar)\n )\n )\n );\n};\n\n/**\n * Sets `routing.mode` in an Intlayer configuration file to the requested\n * strategy. Idempotent: re-running with the same mode produces identical\n * output. Supports `.ts`, `.mjs`, `.js` and `.cjs` configs; JSON configs are\n * handled with a scoped string replacement since they cannot be parsed by the\n * TypeScript recast parser.\n */\nexport const setIntlayerConfigRoutingMode = (\n content: string,\n extension: string,\n mode: RoutingMode\n): string => {\n if (extension === 'json') {\n return content.replace(\n /(\"mode\"\\s*:\\s*)\"(?:prefix-no-default|prefix-all|no-prefix|search-params)\"/,\n `$1\"${mode}\"`\n );\n }\n\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n genericRecastVisit(ast, (objExpr) => {\n if (!isObjectExpression(objExpr)) return;\n\n const routingProperty = ensureObjectProperty(\n objExpr,\n 'routing',\n b.objectExpression([])\n );\n\n if (!isObjectExpression(routingProperty.value)) return;\n\n setObjectPropertyValue(\n routingProperty.value,\n 'mode',\n b.stringLiteral(mode)\n );\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * Sets `routing.enableProxy` in an Intlayer configuration file. Idempotent and\n * comment-preserving: an existing property only has its value swapped. Supports\n * `.ts`, `.mjs`, `.js`, `.cjs` and `.json` configs.\n */\nexport const setIntlayerConfigEnableProxy = (\n content: string,\n extension: string,\n enableProxy: boolean\n): string => {\n // The JSON template carries comments, so a scoped replacement is used rather\n // than `JSON.parse`.\n if (extension === 'json') {\n return content.replace(\n /(\"enableProxy\"\\s*:\\s*)(?:true|false)/,\n `$1${enableProxy}`\n );\n }\n\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n genericRecastVisit(ast, (objExpr) => {\n if (!isObjectExpression(objExpr)) return;\n\n const routingProperty = ensureObjectProperty(\n objExpr,\n 'routing',\n b.objectExpression([])\n );\n\n if (!isObjectExpression(routingProperty.value)) return;\n\n setObjectPropertyValue(\n routingProperty.value,\n 'enableProxy',\n b.booleanLiteral(enableProxy)\n );\n });\n\n return recast.print(ast).code;\n};\n\n/** Default `routing.storage` written when the routing section is reduced. */\nconst DEFAULT_ROUTING_STORAGE = ['cookie', 'header'] as const;\n\n/**\n * Reduces `routing` in an Intlayer configuration file to its `storage` entry,\n * for projects without URL routing (backend-only, React Native…) where the\n * routing mode and the locale proxy have no effect. An existing `storage`\n * value is kept; otherwise `['cookie', 'header']` is written. JSON configs are\n * returned unchanged.\n */\nexport const setIntlayerConfigRoutingStorageOnly = (\n content: string,\n extension: string\n): string => {\n if (extension === 'json') return content;\n\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n genericRecastVisit(ast, (objExpr) => {\n if (!isObjectExpression(objExpr)) return;\n\n const routingProperty = ensureObjectProperty(\n objExpr,\n 'routing',\n b.objectExpression([])\n );\n\n if (!isObjectExpression(routingProperty.value)) return;\n\n const existingStorageProperty = (\n routingProperty.value.properties as any[]\n ).find((prop: any) => (prop?.key?.name ?? prop?.key?.value) === 'storage');\n\n const storageProperty =\n existingStorageProperty ??\n b.property(\n 'init',\n b.identifier('storage'),\n b.arrayExpression(\n DEFAULT_ROUTING_STORAGE.map((storage) => b.stringLiteral(storage))\n )\n );\n\n routingProperty.value.properties = [storageProperty];\n });\n\n return recast.print(ast, { tabWidth: 2 }).code;\n};\n\n/**\n * Sets `compiler.output` in an Intlayer configuration file to the given path\n * template (the `{{variable}}` string form, e.g.\n * `/locales/{{locale}}/{{key}}.content.json`). Idempotent: re-running with the\n * same template produces identical output. Supports `.ts`, `.mjs`, `.js` and\n * `.cjs` configs; JSON configs are supported too since the template is a plain\n * string.\n */\nexport const setIntlayerConfigCompilerOutput = (\n content: string,\n extension: string,\n outputTemplate: string\n): string => {\n if (extension === 'json') {\n const parsed = JSON.parse(content);\n parsed.compiler = { ...parsed.compiler, output: outputTemplate };\n return JSON.stringify(parsed, null, 2);\n }\n\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n genericRecastVisit(ast, (objExpr) => {\n if (!isObjectExpression(objExpr)) return;\n\n const compilerProperty = ensureObjectProperty(\n objExpr,\n 'compiler',\n b.objectExpression([])\n );\n\n if (!isObjectExpression(compilerProperty.value)) return;\n\n setObjectPropertyValue(\n compilerProperty.value,\n 'output',\n b.stringLiteral(outputTemplate)\n );\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * Enables the Intlayer visual editor in a configuration file: sets\n * `editor.enabled` to `true` and wires `clientId` / `clientSecret` to the\n * `INTLAYER_CLIENT_ID` / `INTLAYER_CLIENT_SECRET` environment variables.\n * Idempotent and non-destructive — existing `clientId` / `clientSecret` values\n * are preserved. Only `.ts`, `.mjs`, `.js` and `.cjs` configs are supported\n * (JSON cannot reference `process.env`).\n */\nexport const enableIntlayerEditorConfig = (content: string): string => {\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n genericRecastVisit(ast, (objExpr) => {\n if (!isObjectExpression(objExpr)) return;\n\n const editorProperty = ensureObjectProperty(\n objExpr,\n 'editor',\n b.objectExpression([])\n );\n\n if (!isObjectExpression(editorProperty.value)) return;\n\n const editorObject = editorProperty.value;\n\n setObjectPropertyValue(editorObject, 'enabled', b.booleanLiteral(true));\n addEnvReferenceProperty(editorObject, 'clientId', 'INTLAYER_CLIENT_ID');\n addEnvReferenceProperty(\n editorObject,\n 'clientSecret',\n 'INTLAYER_CLIENT_SECRET'\n );\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * True when `statement` is one of the module's own import statements —\n * `import … from '…'` in ESM, `const … = require('…')` in CJS.\n */\nconst isImportStatement = (statement: any, isCJS: boolean): boolean => {\n if (!isCJS) return n.ImportDeclaration.check(statement);\n\n return (\n n.VariableDeclaration.check(statement) &&\n statement.declarations.some(\n (declarator: any) =>\n n.VariableDeclarator.check(declarator) &&\n n.CallExpression.check(declarator.init) &&\n n.Identifier.check(declarator.init.callee) &&\n declarator.init.callee.name === 'require'\n )\n );\n};\n\n/**\n * Adds `declaration` to the top of the module, after the leading import block\n * so the injected import is grouped with the existing ones.\n *\n * Unshifting blindly would push the file's leading comments down one\n * statement, which silently disables directives that only apply on the first\n * line — `// @ts-check`, present in the config Astro and Vite scaffold.\n */\nconst insertImportDeclaration = (\n ast: any,\n isCJS: boolean,\n declaration: any\n): void => {\n const body = ast.program.body;\n\n let insertionIndex = 0;\n while (\n insertionIndex < body.length &&\n isImportStatement(body[insertionIndex], isCJS)\n ) {\n insertionIndex++;\n }\n\n // No import to group with: keep the file's leading comments on the first\n // line by moving them onto the injected statement.\n if (insertionIndex === 0 && body.length > 0) {\n const leadingComments = (body[0].comments ?? []).filter(\n (comment: any) => comment.leading\n );\n\n if (leadingComments.length > 0) {\n body[0].comments = (body[0].comments ?? []).filter(\n (comment: any) => !comment.leading\n );\n declaration.comments = leadingComments;\n }\n }\n\n body.splice(insertionIndex, 0, declaration);\n};\n\nconst injectImport = (\n ast: any,\n isCJS: boolean,\n importName: string,\n source: string\n) => {\n // Never redeclare an identifier already bound at module scope (e.g. imported\n // from another source or declared locally) — that would be a parse error.\n if (!isCJS && isModuleScopeBinding(ast, importName)) return;\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 insertImportDeclaration(ast, isCJS, 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 /**\n * Resolves an identifier reference (e.g. `export default config` /\n * `module.exports = config`) back to the object expression it was declared\n * with, then runs the updater on it.\n */\n const resolveIdentifierConfig = (name: string) => {\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\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 resolveIdentifierConfig(decl.name);\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 } else if (n.Identifier.check(right)) {\n resolveIdentifierConfig(right.name);\n }\n }\n return false;\n },\n });\n};\n\n/**\n * Detects whether a Vite config already wires in an Intlayer plugin — either the\n * base `vite-intlayer` plugin or one of the compat adapters (e.g.\n * `reactI18nextVitePlugin` from `@intlayer/react-i18next/plugin`). The compat\n * plugins internally wrap `intlayer()`, so a standalone `intlayer()` must not be\n * appended when one is already present, otherwise the plugin runs twice.\n */\nexport const hasIntlayerVitePlugin = (content: string): boolean =>\n content.includes('vite-intlayer') ||\n /@intlayer\\/[^'\"]+\\/plugin/.test(content);\n\nexport const updateViteConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: typescriptParser,\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: typescriptParser,\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: typescriptParser,\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\n/**\n * Returns true when the expression looks like an Immediately Invoked Function\n * Expression (e.g. `(async () => { ... })()`). Such custom async exports cannot\n * be safely wrapped with the synchronous Metro helper, so they are skipped.\n */\nconst isImmediatelyInvokedFunction = (node: any): boolean =>\n n.CallExpression.check(node) &&\n (n.ArrowFunctionExpression.check(node.callee) ||\n n.FunctionExpression.check(node.callee));\n\n/**\n * Wraps a React Native Metro config's exported value with\n * `configMetroIntlayerSync` from `react-native-intlayer/metro`, injecting the\n * import. The synchronous helper is used because it wraps a plain config object\n * and needs no IIFE, making it safe to inject into existing configs without\n * restructuring them.\n *\n * Non-destructive: returns the content unchanged when the export is already\n * wrapped, when the Intlayer Metro plugin is already present, or when the export\n * is a custom async IIFE that cannot be wrapped synchronously. Callers should\n * compare the result with the input to detect the skipped case.\n */\nexport const updateMetroConfig = (\n content: string,\n extension: string\n): string => {\n if (content.includes('react-native-intlayer')) {\n return content;\n }\n\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n const wrapperName = 'configMetroIntlayerSync';\n\n const isWrappable = (node: any): boolean =>\n n.Expression.check(node) &&\n !isImmediatelyInvokedFunction(node) &&\n !(\n n.CallExpression.check(node) &&\n n.Identifier.check(node.callee) &&\n node.callee.name === wrapperName\n );\n\n let wrapped = false;\n\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (isWrappable(declaration)) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier(wrapperName), [declaration as any])\n );\n wrapped = true;\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 isWrappable(right)\n ) {\n path\n .get('right')\n .replace(b.callExpression(b.identifier(wrapperName), [right]));\n wrapped = true;\n }\n return false;\n },\n });\n\n // Only inject the import when an export was actually wrapped, so an\n // un-wrappable config is left completely untouched.\n if (!wrapped) {\n return content;\n }\n\n injectImport(ast, isCJSFile, wrapperName, 'react-native-intlayer/metro');\n\n return recast.print(ast).code;\n};\n\n/**\n * Builds the contents of a fresh `metro.config.js` wired with the Intlayer\n * Metro plugin. Uses the async `configMetroIntlayer` helper (which can build\n * dictionaries on server start) and picks the default-config source based on\n * whether the project is an Expo app.\n */\nexport const getMetroConfigTemplate = (isExpo: boolean): string => {\n const defaultConfigSource = isExpo\n ? 'expo/metro-config'\n : '@react-native/metro-config';\n\n return `const { getDefaultConfig } = require(\"${defaultConfigSource}\");\nconst { configMetroIntlayer } = require(\"react-native-intlayer/metro\");\n\nmodule.exports = (async () => {\n const defaultConfig = getDefaultConfig(__dirname);\n\n return await configMetroIntlayer(defaultConfig);\n})();\n`;\n};\n\nexport const updateNuxtConfig = (content: string): string => {\n const ast = recast.parse(content, {\n parser: typescriptParser,\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: typescriptParser,\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: typescriptParser,\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 * Rewrites the module source of an existing named import in a vite config,\n * keeping the imported binding and its call site untouched. Used when a compat\n * plugin is a drop-in replacement for an i18n library's own vite plugin — e.g.\n * lingui: `import { lingui } from \"@lingui/vite-plugin\"` becomes\n * `import { lingui } from \"@intlayer/lingui/plugin\"`, leaving `lingui()` in the\n * `plugins` array as-is. Returns the content unchanged when no matching import\n * is found.\n */\nexport const replaceViteConfigPluginImportSource = (\n content: string,\n importName: string,\n fromPackageSource: string,\n toPackageSource: string\n): string => {\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n let changed = false;\n\n recast.visit(ast, {\n visitImportDeclaration(path) {\n const { source, specifiers } = path.node;\n const importsBinding = (specifiers ?? []).some(\n (specifier) =>\n n.ImportSpecifier.check(specifier) &&\n specifier.imported.name === importName\n );\n\n if (\n n.StringLiteral.check(source) &&\n source.value === fromPackageSource &&\n importsBinding\n ) {\n source.value = toPackageSource;\n changed = true;\n }\n\n return false;\n },\n });\n\n if (!changed) return content;\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: typescriptParser,\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: typescriptParser,\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: typescriptParser,\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/** The sync plugin used to ingest a compat library's catalogs. */\ntype SyncPluginInfo = {\n /** Called function name, e.g. `'syncJSON'`. */\n functionName: string;\n /** Package the function is imported from. */\n packageSource: string;\n};\n\n/** Resolves the sync plugin (function + package) for a compat sync config. */\nconst getSyncPluginInfo = (syncConfig: CompatSyncConfig): SyncPluginInfo =>\n syncConfig.plugin === 'po'\n ? { functionName: 'syncPO', packageSource: '@intlayer/sync-po-plugin' }\n : { functionName: 'syncJSON', packageSource: '@intlayer/sync-json-plugin' };\n\n/**\n * Parses a `syncJSON({ ... })` / `syncPO({ ... })` call expression from a source\n * snippet so it can be injected into a config AST without manually constructing\n * template-literal 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 *\n * For `syncJSON` every option is emitted explicitly — `source`, then `format`\n * and `splitKeys` — each preceded by an explanatory JSDoc block, so the\n * generated config self-documents the two knobs a user is most likely to tweak.\n * `syncPO` takes neither `format` (gettext is always the serialization) nor\n * `splitKeys`, so it keeps a bare `source`-only call.\n */\nconst buildSyncCallNode = (syncConfig: CompatSyncConfig): any => {\n const { functionName } = getSyncPluginInfo(syncConfig);\n const usesKey = syncConfig.sourceTemplate.includes('${key}');\n const paramDestructuring = !usesKey\n ? '{ locale }'\n : // `icu` (and PO, which is ICU-dialect) reads `{ key, locale }`; the\n // i18next/vue-i18n JSON dialects keep their established `{ locale, key }`.\n syncConfig.format === 'icu' || syncConfig.plugin === 'po'\n ? '{ key, locale }'\n : '{ locale, key }';\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 sourceProperty = `source: (${paramDestructuring}) => \\`${syncConfig.sourceTemplate}\\``;\n\n const parseSnippet = (snippet: string): any => {\n const snippetAst = recast.parse(snippet, {\n parser: typescriptParser,\n });\n return (snippetAst.program.body[0] as any).expression;\n };\n\n // `syncPO` always serializes gettext, so it exposes neither `format` nor\n // `splitKeys`: emit a bare `source`-only call.\n if (syncConfig.plugin === 'po') {\n return parseSnippet(`${functionName}({ ${sourceProperty} })`);\n }\n\n // `splitKeys: true` is forced only for the single-file namespace model\n // (next-intl / use-intl); every other library keeps a single dictionary per\n // file. It is now written explicitly (rather than relying on syncJSON's\n // auto-detection) so the generated config documents the choice.\n const splitKeys = Boolean(syncConfig.splitKeys);\n\n // The JSDoc blocks are embedded in the snippet and preserved by recast when\n // the parsed call node is printed back into the config AST.\n const snippet = `${functionName}({\n ${sourceProperty},\n\n /**\n * Parsing of json respecting the syntax\n * Default \\`'intlayer'\\` message format\n */\n format: '${syncConfig.format}',\n\n /**\n * \\`true\\`:\n * \\`en.json\\` -> \\`useTranslation('home')\\` -> \\`t(\"title\")\\`\n *\n * \\`false\\`:\n * \\`en.json\\` -> \\`useTranslation()\\` -> \\`t(\"home.title\")\\`\n */\n splitKeys: ${splitKeys},\n})`;\n\n return parseSnippet(snippet);\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 sync plugin import (`syncJSON` / `syncPO`) and a configured\n * `syncJSON(...)` / `syncPO(...)` call into the plugins array of an intlayer\n * config file. Idempotent: skips when the plugin call is already present.\n */\nexport const updateIntlayerConfigWithSyncPlugin = (\n content: string,\n extension: string,\n syncConfig: CompatSyncConfig\n): string => {\n const ast = recast.parse(content, {\n parser: typescriptParser,\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n const { functionName, packageSource } = getSyncPluginInfo(syncConfig);\n\n injectImport(ast, isCJSFile, functionName, packageSource);\n\n const callNode = buildSyncCallNode(syncConfig);\n\n // PO catalogs are serialized as gettext; JSON catalogs carry the dialect.\n const dictionaryFormat =\n syncConfig.plugin === 'po' ? 'po' : syncConfig.format;\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, dictionaryFormat);\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 hasSyncPlugin = (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 === functionName;\n }\n );\n\n if (!hasSyncPlugin) {\n (arrayValue.elements as any[]).push(callNode);\n }\n }\n });\n\n return recast.print(ast).code;\n};\n"],"mappings":";;;;;;;;AASA,MAAM,EAAE,UAAU,GAAG,YAAY,MAAM,OAAO;;AAM9C,MAAM,sBAAsB,SAC1B,QAAQ,IAAI,MACX,KAAK,SAAS,sBAAsB,EAAE,iBAAiB,MAAM,IAAI;;;;;;AAOpE,MAAM,wBACJ,SACA,KACA,qBACQ;CACR,IAAI,WAAY,QAAQ,WAAqB,MAAM,SAAc;EAC/D,IAAI,CAAC,MAAM,KAAK,OAAO;EACvB,QAAQ,KAAK,IAAI,QAAQ,KAAK,IAAI,WAAW;CAC/C,CAAC;CAED,IAAI,CAAC,UAAU;EACb,WAAW,EAAE,SAAS,QAAQ,EAAE,WAAW,GAAG,GAAG,gBAAgB;EACjE,AAAC,QAAQ,WAAqB,KAAK,QAAQ;CAC7C;CAEA,OAAO;AACT;;;;;;AAOA,MAAM,0BAC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AAS,qBACnB,EAAE,gBAAgB,MAAM,UAAU,IAWpC;OAAI,CATmB,WAAW,SAAmB,MAClD,YAAiB;IAChB,MAAM,SAAS,SAAS;IACxB,IAAI,CAAC,QAAQ,OAAO;IAEpB,QADqB,OAAO,QAAQ,OAAO,IAAI,UAC/B;GAClB,CAGe,GACf,AAAC,WAAW,SAAmB,KAAK,QAAQ;EAC9C;CAEJ,CAAC;CAED,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;AAC3B"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let node_fs_promises = require("node:fs/promises");
|
|
4
3
|
let node_path = require("node:path");
|
|
5
4
|
let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
|
|
6
5
|
let fast_glob = require("fast-glob");
|
|
7
6
|
fast_glob = require_runtime.__toESM(fast_glob);
|
|
7
|
+
let node_fs_promises = require("node:fs/promises");
|
|
8
8
|
let _intlayer_types_allLocales = require("@intlayer/types/allLocales");
|
|
9
9
|
|
|
10
10
|
//#region src/init/utils/fileSystem.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_listProjects = require('../../listProjects.cjs');
|
|
3
3
|
const require_init_utils_packageManager = require('./packageManager.cjs');
|
|
4
|
-
let node_fs = require("node:fs");
|
|
5
4
|
let node_path = require("node:path");
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
6
|
|
|
7
7
|
//#region src/init/utils/githubActions.ts
|
|
8
8
|
/**
|
|
@@ -8,15 +8,21 @@ const require_init_utils_packageManager = require('./packageManager.cjs');
|
|
|
8
8
|
const require_init_utils_githubActions = require('./githubActions.cjs');
|
|
9
9
|
const require_init_utils_intlayerDependencies = require('./intlayerDependencies.cjs');
|
|
10
10
|
const require_init_utils_jsonParser = require('./jsonParser.cjs');
|
|
11
|
+
const require_init_utils_lintConfig = require('./lintConfig.cjs');
|
|
11
12
|
const require_init_utils_nextCompilerBabel = require('./nextCompilerBabel.cjs');
|
|
12
13
|
const require_init_utils_tsConfig = require('./tsConfig.cjs');
|
|
14
|
+
const require_init_utils_urlRoutingFramework = require('./urlRoutingFramework.cjs');
|
|
13
15
|
|
|
14
16
|
exports.BACKEND_INTLAYER_PACKAGES = require_init_utils_devScript.BACKEND_INTLAYER_PACKAGES;
|
|
15
17
|
exports.COMPAT_I18N_LIBRARIES = require_init_utils_packageManager.COMPAT_I18N_LIBRARIES;
|
|
16
18
|
exports.COMPAT_PACKAGE_REPLACEMENTS = require_init_utils_packageManager.COMPAT_PACKAGE_REPLACEMENTS;
|
|
17
19
|
exports.GITHUB_FILL_WORKFLOW_PATH = require_init_utils_githubActions.GITHUB_FILL_WORKFLOW_PATH;
|
|
18
20
|
exports.GITHUB_TEST_WORKFLOW_PATH = require_init_utils_githubActions.GITHUB_TEST_WORKFLOW_PATH;
|
|
21
|
+
exports.LINT_PLUGIN_PACKAGE_NAME = require_init_utils_lintConfig.LINT_PLUGIN_PACKAGE_NAME;
|
|
22
|
+
exports.MINIMUM_ESLINT_MAJOR = require_init_utils_packageManager.MINIMUM_ESLINT_MAJOR;
|
|
19
23
|
exports.NEXT_INTLAYER_BABEL_CONFIG_CONTENT = require_init_utils_nextCompilerBabel.NEXT_INTLAYER_BABEL_CONFIG_CONTENT;
|
|
24
|
+
exports.PENDING_COMPAT_ADAPTERS = require_init_utils_packageManager.PENDING_COMPAT_ADAPTERS;
|
|
25
|
+
exports.addIntlayerRulesToOxlintConfig = require_init_utils_lintConfig.addIntlayerRulesToOxlintConfig;
|
|
20
26
|
exports.detectCompatI18nLibraries = require_init_utils_packageManager.detectCompatI18nLibraries;
|
|
21
27
|
exports.detectJsonLocalePattern = require_init_utils_fileSystem.detectJsonLocalePattern;
|
|
22
28
|
exports.detectLinguiCatalogPattern = require_init_utils_fileSystem.detectLinguiCatalogPattern;
|
|
@@ -37,7 +43,9 @@ exports.getIntlayerDependencies = require_init_utils_intlayerDependencies.getInt
|
|
|
37
43
|
exports.getIntlayerDependencyUpgrades = require_init_utils_intlayerDependencies.getIntlayerDependencyUpgrades;
|
|
38
44
|
exports.getMetroConfigTemplate = require_init_utils_configManipulation.getMetroConfigTemplate;
|
|
39
45
|
exports.hasIntlayerVitePlugin = require_init_utils_configManipulation.hasIntlayerVitePlugin;
|
|
46
|
+
exports.hasLegacyEslint = require_init_utils_packageManager.hasLegacyEslint;
|
|
40
47
|
exports.hasLintTooling = require_init_utils_packageManager.hasLintTooling;
|
|
48
|
+
exports.hasUrlRoutingFramework = require_init_utils_urlRoutingFramework.hasUrlRoutingFramework;
|
|
41
49
|
exports.installPackages = require_init_utils_packageManager.installPackages;
|
|
42
50
|
exports.isIntlayerPackageName = require_init_utils_packageManager.isIntlayerPackageName;
|
|
43
51
|
exports.isModuleScopeBinding = require_init_utils_astImports.isModuleScopeBinding;
|
|
@@ -52,7 +60,9 @@ exports.resolveDevScript = require_init_utils_devScript.resolveDevScript;
|
|
|
52
60
|
exports.resolveGithubWorkflowsContext = require_init_utils_githubActions.resolveGithubWorkflowsContext;
|
|
53
61
|
exports.runPackageInstall = require_init_utils_packageManager.runPackageInstall;
|
|
54
62
|
exports.setIntlayerConfigCompilerOutput = require_init_utils_configManipulation.setIntlayerConfigCompilerOutput;
|
|
63
|
+
exports.setIntlayerConfigEnableProxy = require_init_utils_configManipulation.setIntlayerConfigEnableProxy;
|
|
55
64
|
exports.setIntlayerConfigRoutingMode = require_init_utils_configManipulation.setIntlayerConfigRoutingMode;
|
|
65
|
+
exports.setIntlayerConfigRoutingStorageOnly = require_init_utils_configManipulation.setIntlayerConfigRoutingStorageOnly;
|
|
56
66
|
exports.setupNextCompilerBabelConfig = require_init_utils_nextCompilerBabel.setupNextCompilerBabelConfig;
|
|
57
67
|
exports.toRange = require_init_utils_intlayerDependencies.toRange;
|
|
58
68
|
exports.updateAstroConfig = require_init_utils_configManipulation.updateAstroConfig;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_init_utils_packageManager = require('./packageManager.cjs');
|
|
4
|
-
let node_fs_promises = require("node:fs/promises");
|
|
5
4
|
let node_path = require("node:path");
|
|
6
5
|
let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
|
|
7
6
|
let fast_glob = require("fast-glob");
|
|
8
7
|
fast_glob = require_runtime.__toESM(fast_glob);
|
|
8
|
+
let node_fs_promises = require("node:fs/promises");
|
|
9
9
|
|
|
10
10
|
//#region src/init/utils/intlayerDependencies.ts
|
|
11
11
|
/** Dependency fields of a `package.json` scanned for Intlayer packages. */
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region src/init/utils/lintConfig.ts
|
|
3
|
+
/**
|
|
4
|
+
* The Intlayer lint setup, as `intlayer init` writes it into `.oxlintrc.json`.
|
|
5
|
+
*
|
|
6
|
+
* Declared locally on purpose: `@intlayer/engine` is installed by every Intlayer
|
|
7
|
+
* user, so it must not depend on a lint plugin to write a handful of strings
|
|
8
|
+
* into a JSON file. oxlint resolves a plugin's *rules* but not its shipped
|
|
9
|
+
* *configs*, so the preset cannot be referenced by name there either.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors the `recommended` preset of `eslint-plugin-intlayer`; keep in sync
|
|
12
|
+
* when a rule is enabled by default there.
|
|
13
|
+
*/
|
|
14
|
+
const LINT_PLUGIN_PACKAGE_NAME = "eslint-plugin-intlayer";
|
|
15
|
+
/** Intlayer's generated output — never source, never worth linting. */
|
|
16
|
+
const GENERATED_OUTPUT_GLOBS = ["**/.intlayer/**"];
|
|
17
|
+
/** Rules of the `recommended` preset, prefixed by the plugin namespace. */
|
|
18
|
+
const getRecommendedRules = () => ({
|
|
19
|
+
"intlayer/no-raw-text": "warn",
|
|
20
|
+
"intlayer/static-dictionary-key": "error",
|
|
21
|
+
"intlayer/no-dynamic-field-access": "error"
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Adds the Intlayer plugin, the `recommended` rules and the generated-output
|
|
25
|
+
* ignore to an oxlint config, in place. Rules the user already set are kept.
|
|
26
|
+
*
|
|
27
|
+
* @returns Whether anything was added.
|
|
28
|
+
*/
|
|
29
|
+
const addIntlayerRulesToOxlintConfig = (oxlintConfig) => {
|
|
30
|
+
oxlintConfig.jsPlugins ??= [];
|
|
31
|
+
oxlintConfig.rules ??= {};
|
|
32
|
+
oxlintConfig.ignorePatterns ??= [];
|
|
33
|
+
let isUpdated = false;
|
|
34
|
+
for (const glob of GENERATED_OUTPUT_GLOBS) if (!oxlintConfig.ignorePatterns.includes(glob)) {
|
|
35
|
+
oxlintConfig.ignorePatterns.push(glob);
|
|
36
|
+
isUpdated = true;
|
|
37
|
+
}
|
|
38
|
+
if (!oxlintConfig.jsPlugins.includes("eslint-plugin-intlayer")) {
|
|
39
|
+
oxlintConfig.jsPlugins.push(LINT_PLUGIN_PACKAGE_NAME);
|
|
40
|
+
isUpdated = true;
|
|
41
|
+
}
|
|
42
|
+
for (const [ruleName, severity] of Object.entries(getRecommendedRules())) if (!oxlintConfig.rules[ruleName]) {
|
|
43
|
+
oxlintConfig.rules[ruleName] = severity;
|
|
44
|
+
isUpdated = true;
|
|
45
|
+
}
|
|
46
|
+
return isUpdated;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.LINT_PLUGIN_PACKAGE_NAME = LINT_PLUGIN_PACKAGE_NAME;
|
|
51
|
+
exports.addIntlayerRulesToOxlintConfig = addIntlayerRulesToOxlintConfig;
|
|
52
|
+
//# sourceMappingURL=lintConfig.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lintConfig.cjs","names":[],"sources":["../../../../src/init/utils/lintConfig.ts"],"sourcesContent":["/**\n * The Intlayer lint setup, as `intlayer init` writes it into `.oxlintrc.json`.\n *\n * Declared locally on purpose: `@intlayer/engine` is installed by every Intlayer\n * user, so it must not depend on a lint plugin to write a handful of strings\n * into a JSON file. oxlint resolves a plugin's *rules* but not its shipped\n * *configs*, so the preset cannot be referenced by name there either.\n *\n * Mirrors the `recommended` preset of `eslint-plugin-intlayer`; keep in sync\n * when a rule is enabled by default there.\n */\nexport const LINT_PLUGIN_PACKAGE_NAME = 'eslint-plugin-intlayer';\n\n/** Intlayer's generated output — never source, never worth linting. */\nconst GENERATED_OUTPUT_GLOBS = ['**/.intlayer/**'];\n\n/** Rules of the `recommended` preset, prefixed by the plugin namespace. */\nconst getRecommendedRules = (): Record<string, string> => ({\n 'intlayer/no-raw-text': 'warn',\n 'intlayer/static-dictionary-key': 'error',\n 'intlayer/no-dynamic-field-access': 'error',\n});\n\n/** The `.oxlintrc.json` fields init reads and writes. */\nexport type OxlintConfig = {\n jsPlugins?: string[];\n rules?: Record<string, unknown>;\n ignorePatterns?: string[];\n};\n\n/**\n * Adds the Intlayer plugin, the `recommended` rules and the generated-output\n * ignore to an oxlint config, in place. Rules the user already set are kept.\n *\n * @returns Whether anything was added.\n */\nexport const addIntlayerRulesToOxlintConfig = (\n oxlintConfig: OxlintConfig\n): boolean => {\n oxlintConfig.jsPlugins ??= [];\n oxlintConfig.rules ??= {};\n oxlintConfig.ignorePatterns ??= [];\n\n let isUpdated = false;\n\n // Generated dictionaries are not source; linting them is wasted work.\n for (const glob of GENERATED_OUTPUT_GLOBS) {\n if (!oxlintConfig.ignorePatterns.includes(glob)) {\n oxlintConfig.ignorePatterns.push(glob);\n isUpdated = true;\n }\n }\n\n if (!oxlintConfig.jsPlugins.includes(LINT_PLUGIN_PACKAGE_NAME)) {\n oxlintConfig.jsPlugins.push(LINT_PLUGIN_PACKAGE_NAME);\n isUpdated = true;\n }\n\n for (const [ruleName, severity] of Object.entries(getRecommendedRules())) {\n if (!oxlintConfig.rules[ruleName]) {\n oxlintConfig.rules[ruleName] = severity;\n isUpdated = true;\n }\n }\n\n return isUpdated;\n};\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,2BAA2B;;AAGxC,MAAM,yBAAyB,CAAC,iBAAiB;;AAGjD,MAAM,6BAAqD;CACzD,wBAAwB;CACxB,kCAAkC;CAClC,oCAAoC;AACtC;;;;;;;AAeA,MAAa,kCACX,iBACY;CACZ,aAAa,cAAc,CAAC;CAC5B,aAAa,UAAU,CAAC;CACxB,aAAa,mBAAmB,CAAC;CAEjC,IAAI,YAAY;CAGhB,KAAK,MAAM,QAAQ,wBACjB,IAAI,CAAC,aAAa,eAAe,SAAS,IAAI,GAAG;EAC/C,aAAa,eAAe,KAAK,IAAI;EACrC,YAAY;CACd;CAGF,IAAI,CAAC,aAAa,UAAU,iCAAiC,GAAG;EAC9D,aAAa,UAAU,KAAK,wBAAwB;EACpD,YAAY;CACd;CAEA,KAAK,MAAM,CAAC,UAAU,aAAa,OAAO,QAAQ,oBAAoB,CAAC,GACrE,IAAI,CAAC,aAAa,MAAM,WAAW;EACjC,aAAa,MAAM,YAAY;EAC/B,YAAY;CACd;CAGF,OAAO;AACT"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
const require_init_utils_version = require('./version.cjs');
|
|
3
3
|
let node_path = require("node:path");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
4
5
|
let node_child_process = require("node:child_process");
|
|
5
6
|
|
|
6
7
|
//#region src/init/utils/packageManager.ts
|
|
8
|
+
/**
|
|
9
|
+
* Compat adapters that live in `compat-comming/` and are not published to npm
|
|
10
|
+
* yet. Installing one fails the whole install command, so init keeps the
|
|
11
|
+
* original library, skips the adapter and its bundler / framework wiring, and
|
|
12
|
+
* only syncs the catalogs. Remove an entry once its package is released.
|
|
13
|
+
*/
|
|
14
|
+
const PENDING_COMPAT_ADAPTERS = /* @__PURE__ */ new Set([
|
|
15
|
+
"@intlayer/nuxtjs-i18n",
|
|
16
|
+
"@intlayer/svelte-i18n",
|
|
17
|
+
"@intlayer/ngx-translate"
|
|
18
|
+
]);
|
|
7
19
|
/** Lock files revealing the package manager, in detection priority order. */
|
|
8
20
|
const LOCK_FILE_PACKAGE_MANAGERS = [
|
|
9
21
|
["bun.lock", "bun"],
|
|
@@ -196,22 +208,37 @@ const moveCompatPackagesToDevDependencies = (packageJson) => {
|
|
|
196
208
|
* @param dependencies - Merged dependencies of the target project.
|
|
197
209
|
*/
|
|
198
210
|
const detectCompatI18nLibraries = (dependencies) => COMPAT_I18N_LIBRARIES.filter((library) => library.packages.some((packageName) => Boolean(dependencies[packageName]))).map((library) => library.label);
|
|
211
|
+
/** Lowest ESLint major `eslint-plugin-intlayer` supports (flat config). */
|
|
212
|
+
const MINIMUM_ESLINT_MAJOR = 9;
|
|
199
213
|
/**
|
|
200
|
-
* True when the project
|
|
201
|
-
*
|
|
214
|
+
* True when the project pins ESLint below {@link MINIMUM_ESLINT_MAJOR}.
|
|
215
|
+
* Installing the plugin there fails on its `eslint` peer range (and takes the
|
|
216
|
+
* whole install command down with it). Ranges without a version number
|
|
217
|
+
* (`latest`, `*`, `catalog:`) are assumed current.
|
|
202
218
|
*
|
|
203
|
-
*
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
219
|
+
* @param dependencies - Merged dependencies of the target project.
|
|
220
|
+
*/
|
|
221
|
+
const hasLegacyEslint = (dependencies) => {
|
|
222
|
+
const eslintVersion = dependencies.eslint;
|
|
223
|
+
if (!eslintVersion || !/\d/.test(eslintVersion)) return false;
|
|
224
|
+
return !require_init_utils_version.isVersionAtLeast(eslintVersion, 9);
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* True when the project already lints with a linter the Intlayer rules can
|
|
228
|
+
* plug into: oxlint, or ESLint 9+.
|
|
229
|
+
*
|
|
230
|
+
* Shared with the init flow so that installing the plugin and wiring up its
|
|
231
|
+
* configuration are gated on exactly the same condition — a project that does
|
|
232
|
+
* not lint, or lints with ESLint 8, is left alone.
|
|
207
233
|
*
|
|
208
234
|
* @param dependencies - Merged dependencies of the target project.
|
|
209
235
|
*/
|
|
210
|
-
const hasLintTooling = (dependencies) => Boolean(dependencies.eslint) || Boolean(dependencies.oxlint);
|
|
236
|
+
const hasLintTooling = (dependencies) => !hasLegacyEslint(dependencies) && (Boolean(dependencies.eslint) || Boolean(dependencies.oxlint));
|
|
211
237
|
const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
|
|
212
238
|
const packagesToInstall = [];
|
|
213
239
|
const devPackagesToInstall = [];
|
|
214
240
|
const packagesToMoveToDev = [];
|
|
241
|
+
const pendingCompatAdapters = [];
|
|
215
242
|
let compatSyncConfig;
|
|
216
243
|
let compatVitePluginConfig;
|
|
217
244
|
const isInstalled = (packageName) => Boolean(allDependencies[packageName]);
|
|
@@ -221,7 +248,16 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
|
|
|
221
248
|
const addDevIfMissing = (packageName) => {
|
|
222
249
|
if (!isInstalled(packageName)) devPackagesToInstall.push(packageName);
|
|
223
250
|
};
|
|
251
|
+
/**
|
|
252
|
+
* Whether an adapter can be used: published, or already installed by the
|
|
253
|
+
* user (e.g. a local build).
|
|
254
|
+
*/
|
|
255
|
+
const isAdapterAvailable = (adapterPackage) => !PENDING_COMPAT_ADAPTERS.has(adapterPackage) || isInstalled(adapterPackage);
|
|
224
256
|
const markCompatReplacement = (originalPackage, adapterPackage) => {
|
|
257
|
+
if (!isAdapterAvailable(adapterPackage)) {
|
|
258
|
+
if (!pendingCompatAdapters.includes(adapterPackage)) pendingCompatAdapters.push(adapterPackage);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
225
261
|
addIfMissing(adapterPackage);
|
|
226
262
|
addDevIfMissing(originalPackage);
|
|
227
263
|
const isExplicitDev = Boolean(options.devDependencies?.[originalPackage]);
|
|
@@ -241,6 +277,15 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
|
|
|
241
277
|
if (isInstalled("@angular/core")) addIfMissing("angular-intlayer");
|
|
242
278
|
if (isInstalled("vue")) addIfMissing("vue-intlayer");
|
|
243
279
|
if (isInstalled("vite")) addIfMissing("vite-intlayer");
|
|
280
|
+
if (isInstalled("nuxt") && !isInstalled("@nuxtjs/i18n")) addIfMissing("nuxt-intlayer");
|
|
281
|
+
if (isInstalled("astro")) addIfMissing("astro-intlayer");
|
|
282
|
+
const isNestJsProject = isInstalled("@nestjs/core");
|
|
283
|
+
const isNestJsOnFastify = isInstalled("@nestjs/platform-fastify");
|
|
284
|
+
if (isInstalled("express") || isNestJsProject && !isNestJsOnFastify) addIfMissing("express-intlayer");
|
|
285
|
+
if (isInstalled("fastify") || isNestJsOnFastify) addIfMissing("fastify-intlayer");
|
|
286
|
+
if (isInstalled("hono")) addIfMissing("hono-intlayer");
|
|
287
|
+
if (isInstalled("elysia")) addIfMissing("elysia-intlayer");
|
|
288
|
+
if (isInstalled("@adonisjs/core")) addIfMissing("adonis-intlayer");
|
|
244
289
|
if (hasLintTooling(allDependencies)) addDevIfMissing("eslint-plugin-intlayer");
|
|
245
290
|
if (isInstalled("next-intl") || isInstalled("@intlayer/next-intl")) {
|
|
246
291
|
markCompatReplacement("next-intl", "@intlayer/next-intl");
|
|
@@ -322,7 +367,7 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
|
|
|
322
367
|
}
|
|
323
368
|
if (isInstalled("@ngneat/transloco") || isInstalled("@intlayer/transloco")) {
|
|
324
369
|
markCompatReplacement("@ngneat/transloco", "@intlayer/transloco");
|
|
325
|
-
compatVitePluginConfig ??= {
|
|
370
|
+
if (isAdapterAvailable("@intlayer/transloco")) compatVitePluginConfig ??= {
|
|
326
371
|
pluginFunctionName: "translocoVitePlugin",
|
|
327
372
|
pluginPackageSource: "@intlayer/transloco/plugin"
|
|
328
373
|
};
|
|
@@ -333,14 +378,14 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
|
|
|
333
378
|
format: "i18next",
|
|
334
379
|
sourceTemplate: "./src/locales/${locale}.json"
|
|
335
380
|
};
|
|
336
|
-
compatVitePluginConfig ??= {
|
|
381
|
+
if (isAdapterAvailable("@intlayer/svelte-i18n")) compatVitePluginConfig ??= {
|
|
337
382
|
pluginFunctionName: "svelteI18nVitePlugin",
|
|
338
383
|
pluginPackageSource: "@intlayer/svelte-i18n/plugin"
|
|
339
384
|
};
|
|
340
385
|
}
|
|
341
386
|
if (isInstalled("node-polyglot") || isInstalled("@intlayer/polyglot")) {
|
|
342
387
|
markCompatReplacement("node-polyglot", "@intlayer/polyglot");
|
|
343
|
-
compatVitePluginConfig ??= {
|
|
388
|
+
if (isAdapterAvailable("@intlayer/polyglot")) compatVitePluginConfig ??= {
|
|
344
389
|
pluginFunctionName: "polyglotVitePlugin",
|
|
345
390
|
pluginPackageSource: "@intlayer/polyglot/plugin"
|
|
346
391
|
};
|
|
@@ -358,7 +403,7 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
|
|
|
358
403
|
format: "i18next",
|
|
359
404
|
sourceTemplate: "./assets/i18n/${locale}.json"
|
|
360
405
|
};
|
|
361
|
-
compatVitePluginConfig ??= {
|
|
406
|
+
if (isAdapterAvailable("@intlayer/ngx-translate")) compatVitePluginConfig ??= {
|
|
362
407
|
pluginFunctionName: "ngxTranslateVitePlugin",
|
|
363
408
|
pluginPackageSource: "@intlayer/ngx-translate/plugin"
|
|
364
409
|
};
|
|
@@ -387,7 +432,7 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
|
|
|
387
432
|
}
|
|
388
433
|
if (isInstalled("i18n-js") || isInstalled("@intlayer/i18n-js")) {
|
|
389
434
|
markCompatReplacement("i18n-js", "@intlayer/i18n-js");
|
|
390
|
-
compatVitePluginConfig ??= {
|
|
435
|
+
if (isAdapterAvailable("@intlayer/i18n-js")) compatVitePluginConfig ??= {
|
|
391
436
|
pluginFunctionName: "i18nJsVitePlugin",
|
|
392
437
|
pluginPackageSource: "@intlayer/i18n-js/plugin"
|
|
393
438
|
};
|
|
@@ -398,7 +443,8 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
|
|
|
398
443
|
devPackagesToInstall,
|
|
399
444
|
packagesToMoveToDev,
|
|
400
445
|
compatSyncConfig,
|
|
401
|
-
compatVitePluginConfig
|
|
446
|
+
compatVitePluginConfig,
|
|
447
|
+
pendingCompatAdapters
|
|
402
448
|
};
|
|
403
449
|
};
|
|
404
450
|
/**
|
|
@@ -449,10 +495,13 @@ const runPackageInstall = (rootDir, packageManager) => {
|
|
|
449
495
|
//#endregion
|
|
450
496
|
exports.COMPAT_I18N_LIBRARIES = COMPAT_I18N_LIBRARIES;
|
|
451
497
|
exports.COMPAT_PACKAGE_REPLACEMENTS = COMPAT_PACKAGE_REPLACEMENTS;
|
|
498
|
+
exports.MINIMUM_ESLINT_MAJOR = MINIMUM_ESLINT_MAJOR;
|
|
499
|
+
exports.PENDING_COMPAT_ADAPTERS = PENDING_COMPAT_ADAPTERS;
|
|
452
500
|
exports.detectCompatI18nLibraries = detectCompatI18nLibraries;
|
|
453
501
|
exports.detectMissingIntlayerPackages = detectMissingIntlayerPackages;
|
|
454
502
|
exports.detectPackageManager = detectPackageManager;
|
|
455
503
|
exports.findLockFileDir = findLockFileDir;
|
|
504
|
+
exports.hasLegacyEslint = hasLegacyEslint;
|
|
456
505
|
exports.hasLintTooling = hasLintTooling;
|
|
457
506
|
exports.installPackages = installPackages;
|
|
458
507
|
exports.isIntlayerPackageName = isIntlayerPackageName;
|