@intlayer/chokidar 9.0.0-canary.5 → 9.0.0-canary.6

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.
@@ -353,6 +353,35 @@ const initIntlayer = async (rootDir, options) => {
353
353
  }
354
354
  break;
355
355
  }
356
+ if (Boolean(allDeps["react-native"] || allDeps.expo)) {
357
+ hasAliasConfiguration = true;
358
+ const metroConfigs = [
359
+ "metro.config.js",
360
+ "metro.config.cjs",
361
+ "metro.config.mjs",
362
+ "metro.config.ts"
363
+ ];
364
+ let metroConfigFile;
365
+ for (const file of metroConfigs) if (await require_init_utils_fileSystem.exists(rootDir, file)) {
366
+ metroConfigFile = file;
367
+ break;
368
+ }
369
+ if (metroConfigFile) {
370
+ const content = await require_init_utils_fileSystem.readFileFromRoot(rootDir, metroConfigFile);
371
+ if (content.includes("react-native-intlayer")) (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} ${(0, _intlayer_config_logger.colorizePath)(metroConfigFile)} already includes the Intlayer Metro plugin`);
372
+ else {
373
+ const updatedContent = require_init_utils_configManipulation.updateMetroConfig(content, metroConfigFile.split(".").pop());
374
+ if (updatedContent !== content) {
375
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, metroConfigFile, updatedContent);
376
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Updated ${(0, _intlayer_config_logger.colorizePath)(metroConfigFile)} to include the Intlayer Metro plugin`);
377
+ } else (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.x} Could not automatically update ${(0, _intlayer_config_logger.colorizePath)(metroConfigFile)}. Wrap your exported config with ${(0, _intlayer_config_logger.colorize)("configMetroIntlayer", _intlayer_config_colors.MAGENTA)}: ${(0, _intlayer_config_logger.colorizePath)(DocumentationRouter.ReactNativeAndExpo)}`, { level: "warn" });
378
+ }
379
+ } else {
380
+ const newMetroConfigFile = "metro.config.js";
381
+ await require_init_utils_fileSystem.writeFileToRoot(rootDir, newMetroConfigFile, require_init_utils_configManipulation.getMetroConfigTemplate(Boolean(allDeps.expo)));
382
+ (0, _intlayer_config_logger.logger)(`${_intlayer_config_logger.v} Created ${(0, _intlayer_config_logger.colorizePath)(newMetroConfigFile)} with the Intlayer Metro plugin`);
383
+ }
384
+ }
356
385
  const isVersionGreaterOrEqual = (versionString, major) => {
357
386
  if (!versionString || typeof versionString !== "string") return false;
358
387
  const match = versionString.match(/^[^\d]*(\d+)/);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["ANSIColors","exists","x","readFileFromRoot","detectPackageManager","detectMissingIntlayerPackages","v","detectOutdatedIntlayerPackages","writeFileToRoot","getGithubWorkflows","ensureDirectory","parseJSONWithComments","findTsConfigFiles","detectJsonLocalePattern","initConfig","detectNextIntlMessagesPattern","updateIntlayerConfigWithSyncPlugin","setRoutingModeInConfig","updateViteConfigForCompatPlugin","updateViteConfig","updateNextConfigForNextI18next","updateNextConfigForNextIntl","updateNextConfigForNextTranslate","updateNextConfig","setupNextCompilerBabelConfig","updateAstroConfig","updateNuxtConfigForNuxtjsI18n","updateNuxtConfig","setupFramework"],"sources":["../../../src/init/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizePath, logger, v, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\n\nimport { getAlias } from '@intlayer/config/utils';\nimport { initConfig } from '../initConfig';\nimport { setRoutingModeInConfig } from './cms';\nimport { setupFramework } from './frameworkSetup';\nimport type { RoutingMode } from './utils';\nimport {\n detectJsonLocalePattern,\n detectMissingIntlayerPackages,\n detectNextIntlMessagesPattern,\n detectOutdatedIntlayerPackages,\n detectPackageManager,\n ensureDirectory,\n exists,\n findTsConfigFiles,\n getGithubWorkflows,\n installPackages,\n parseJSONWithComments,\n readFileFromRoot,\n setupNextCompilerBabelConfig,\n updateAstroConfig,\n updateIntlayerConfigWithSyncPlugin,\n updateNextConfig,\n updateNextConfigForNextI18next,\n updateNextConfigForNextIntl,\n updateNextConfigForNextTranslate,\n updateNuxtConfig,\n updateNuxtConfigForNuxtjsI18n,\n updateViteConfig,\n updateViteConfigForCompatPlugin,\n upgradePackages,\n writeFileToRoot,\n} from './utils';\n\n/**\n * Documentation URL Constants\n */\nconst DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs.md',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15.md',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14.md',\n CRA: 'https://intlayer.org/doc/environment/create-react-app.md',\n Astro: 'https://intlayer.org/doc/environment/astro.md',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react.md',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md',\n ViteAndReact_ReactRouterV7_FSRoutes:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue.md',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid.md',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte.md',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact.md',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack.md',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue.md',\n Angular: 'https://intlayer.org/doc/environment/angular.md',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit.md',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo.md',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react.md',\n Express: 'https://intlayer.org/doc/environment/express.md',\n NestJS: 'https://intlayer.org/doc/environment/nestjs.md',\n Fastify: 'https://intlayer.org/doc/environment/fastify.md',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Intlayer Language Server (Go-to-Definition from getter keys to .content files)\n LSP: 'https://intlayer.org/doc/lsp.md',\n\n // Check for competitors libs\n NextIntl: 'https://intlayer.org/blog/intlayer-with-next-intl.md',\n ReactI18Next: 'https://intlayer.org/blog/intlayer-with-react-i18next.md',\n ReactIntl: 'https://intlayer.org/blog/intlayer-with-react-intl.md',\n NextI18Next: 'https://intlayer.org/blog/intlayer-with-next-i18next.md',\n VueI18n: 'https://intlayer.org/blog/intlayer-with-vue-i18n.md',\n};\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nconst getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps.expo) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps.next) {\n const version = deps.next;\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps.nuxt) return DocumentationRouter.NuxtAndVue;\n if (deps.astro) return DocumentationRouter.Astro;\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7\n const reactRouterVersion = deps['react-router'];\n if (reactRouterVersion && typeof reactRouterVersion === 'string') {\n // Distinguish between standard v7 and v7 with FS routes\n if (deps['@react-router/fs-routes']) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;\n }\n\n // Use Regex to ensure it is v7\n if (isVersion(reactRouterVersion, 7)) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n }\n\n // Vite Ecosystem (General)\n if (deps.vite) {\n if (deps.vue) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps.svelte) return DocumentationRouter.ViteAndSvelte;\n if (deps.preact) return DocumentationRouter.ViteAndPreact;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) return DocumentationRouter.Angular;\n\n // Backend\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps.express) return DocumentationRouter.Express;\n if (deps.fastify) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps.i18next)\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n\n/**\n * OPTIONS\n */\nexport type InitOptions = {\n noGitignore?: boolean;\n /** Skip scaffolding the `fill` and `test` GitHub Actions workflows. */\n noGithubActions?: boolean;\n /**\n * Skip installing missing Intlayer dependencies and upgrading outdated ones.\n */\n noInstallPackages?: boolean;\n /** Skip adding the Intlayer extension to `.vscode/extensions.json`. */\n noVscodeExtension?: boolean;\n /** Skip writing the Intlayer LSP configuration to `.vscode/settings.json`. */\n noLsp?: boolean;\n /**\n * Skip framework-specific scaffolding (middleware/proxy, providers in\n * layout/page, example content). Defaults to enabled.\n */\n noFrameworkSetup?: boolean;\n /**\n * Version that outdated Intlayer packages should be upgraded to (typically the\n * running CLI version). When omitted, installed packages are left untouched and\n * only missing ones are installed.\n */\n upgradeToVersion?: string;\n /**\n * Locale routing strategy to write to `routing.mode` in the generated/existing\n * Intlayer configuration file. When omitted, the configuration default\n * (`prefix-no-default`) is kept.\n */\n routingMode?: RoutingMode;\n};\n\n/**\n * MAIN LOGIC\n */\nexport const initIntlayer = async (rootDir: string, options?: InitOptions) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // READ PACKAGE.JSON\n const packageJsonPath = 'package.json';\n if (!(await exists(rootDir, packageJsonPath))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);\n let packageJson: Record<string, any>;\n try {\n packageJson = JSON.parse(packageJsonContent);\n } catch {\n logger(`${x} Could not parse ${colorizePath('package.json')}.`, {\n level: 'error',\n });\n process.exit(1);\n }\n\n // Determine the correct documentation URL based on dependencies\n const guideUrl = getDocumentationUrl(packageJson);\n\n const allDeps: Record<string, string> = {\n ...(packageJson.dependencies ?? {}),\n ...(packageJson.devDependencies ?? {}),\n };\n\n // INSTALL MISSING INTLAYER DEPENDENCIES\n const packageManager = detectPackageManager(rootDir);\n const {\n packagesToInstall,\n devPackagesToInstall,\n compatSyncConfig,\n compatVitePluginConfig,\n } = detectMissingIntlayerPackages(allDeps);\n\n if (!options?.noInstallPackages) {\n const withVersion = (packages: string[]): string[] =>\n options?.upgradeToVersion\n ? packages.map((pkg) => `${pkg}@${options.upgradeToVersion}`)\n : packages;\n\n if (packagesToInstall.length > 0) {\n logger(\n colorize('Installing missing Intlayer dependencies...', ANSIColors.CYAN)\n );\n try {\n installPackages(\n rootDir,\n withVersion(packagesToInstall),\n packageManager\n );\n logger(\n `${v} Installed: ${packagesToInstall.map((pkg) => colorize(pkg, ANSIColors.MAGENTA)).join(', ')}`\n );\n } catch {\n logger(\n `${x} Failed to install packages. Please install manually: ${packagesToInstall.join(' ')}`,\n { level: 'warn' }\n );\n }\n }\n\n if (devPackagesToInstall.length > 0) {\n logger(\n colorize(\n 'Installing missing Intlayer dev dependencies...',\n ANSIColors.CYAN\n )\n );\n try {\n installPackages(\n rootDir,\n withVersion(devPackagesToInstall),\n packageManager,\n true\n );\n logger(\n `${v} Installed: ${devPackagesToInstall.map((pkg) => colorize(pkg, ANSIColors.MAGENTA)).join(', ')}`\n );\n } catch {\n logger(\n `${x} Failed to install dev packages. Please install manually: ${devPackagesToInstall.join(' ')}`,\n { level: 'warn' }\n );\n }\n }\n\n // UPGRADE OUTDATED INTLAYER DEPENDENCIES\n // Only runs when a target version is provided (typically the running CLI\n // version). Already up-to-date packages are skipped. Prod and dev\n // dependencies are upgraded separately so their dependency type is kept.\n if (options?.upgradeToVersion) {\n const outdatedDependencies = detectOutdatedIntlayerPackages(\n rootDir,\n packageJson.dependencies ?? {},\n options.upgradeToVersion\n );\n const outdatedDevDependencies = detectOutdatedIntlayerPackages(\n rootDir,\n packageJson.devDependencies ?? {},\n options.upgradeToVersion\n );\n\n const allOutdated = [...outdatedDependencies, ...outdatedDevDependencies];\n\n if (allOutdated.length > 0) {\n logger(\n colorize(\n `Upgrading outdated Intlayer dependencies to ${options.upgradeToVersion}...`,\n ANSIColors.CYAN\n )\n );\n try {\n upgradePackages(\n rootDir,\n outdatedDependencies,\n packageManager,\n options.upgradeToVersion\n );\n upgradePackages(\n rootDir,\n outdatedDevDependencies,\n packageManager,\n options.upgradeToVersion,\n true\n );\n logger(\n `${v} Upgraded: ${allOutdated.map((pkg) => colorize(pkg, ANSIColors.MAGENTA)).join(', ')}`\n );\n } catch {\n logger(\n `${x} Failed to upgrade packages. Please upgrade manually: ${allOutdated.join(' ')}`,\n { level: 'warn' }\n );\n }\n } else {\n logger(`${v} Intlayer dependencies are up to date`);\n }\n }\n }\n\n // CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (!options?.noGitignore && (await exists(rootDir, gitignorePath))) {\n const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(rootDir, gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // SCAFFOLD GITHUB ACTIONS WORKFLOWS (fill + test)\n // Generate two workflows whose commands match the detected package manager:\n // - intlayer-fill.yml: auto-fills missing translations on pull requests\n // - intlayer-test.yml: fails the PR when required locales are missing\n if (!options?.noGithubActions) {\n const workflows = getGithubWorkflows(packageManager);\n\n for (const workflow of workflows) {\n if (await exists(rootDir, workflow.filePath)) {\n logger(`${v} ${colorizePath(workflow.filePath)} already exists`);\n continue;\n }\n\n try {\n await ensureDirectory(rootDir, join('.github', 'workflows'));\n await writeFileToRoot(rootDir, workflow.filePath, workflow.content);\n logger(\n `${v} Added GitHub Actions workflow ${colorizePath(workflow.filePath)}`\n );\n } catch {\n logger(\n `${x} Could not create ${colorizePath(workflow.filePath)}. You may need to add it manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // CHECK VS CODE EXTENSION RECOMMENDATIONS\n const vscodeDir = '.vscode';\n const extensionsJsonPath = join(vscodeDir, 'extensions.json');\n const extensionId = 'intlayer.intlayer-vs-code-extension';\n\n if (!options?.noVscodeExtension) {\n try {\n let extensionsConfig: { recommendations: string[] } = {\n recommendations: [],\n };\n\n if (await exists(rootDir, extensionsJsonPath)) {\n const content = await readFileFromRoot(rootDir, extensionsJsonPath);\n extensionsConfig = parseJSONWithComments(content);\n } else {\n await ensureDirectory(rootDir, vscodeDir);\n }\n\n if (!extensionsConfig.recommendations) {\n extensionsConfig.recommendations = [];\n }\n\n if (!extensionsConfig.recommendations.includes(extensionId)) {\n extensionsConfig.recommendations.push(extensionId);\n await writeFileToRoot(\n rootDir,\n extensionsJsonPath,\n JSON.stringify(extensionsConfig, null, 2)\n );\n logger(\n `${v} Added ${colorize(extensionId, ANSIColors.MAGENTA)} to ${colorizePath(extensionsJsonPath)}`\n );\n } else {\n logger(\n `${v} ${colorizePath(extensionsJsonPath)} already includes ${colorize(extensionId, ANSIColors.MAGENTA)}`\n );\n }\n } catch {\n logger(\n `${x} Could not update ${colorizePath(extensionsJsonPath)}. You may need to add ${colorize(extensionId, ANSIColors.MAGENTA)} manually.`,\n { level: 'warn' }\n );\n }\n }\n\n // CHECK VS CODE LSP SETTINGS\n const settingsJsonPath = join(vscodeDir, 'settings.json');\n\n if (!options?.noLsp) {\n try {\n let settingsConfig: Record<string, unknown> = {};\n\n if (await exists(rootDir, settingsJsonPath)) {\n const content = await readFileFromRoot(rootDir, settingsJsonPath);\n settingsConfig = parseJSONWithComments(content);\n } else {\n await ensureDirectory(rootDir, vscodeDir);\n }\n\n let settingsUpdated = false;\n\n if (!settingsConfig['intlayer.languageServer.command']) {\n settingsConfig['intlayer.languageServer.command'] = 'npx';\n settingsUpdated = true;\n }\n\n if (!settingsConfig['intlayer.languageServer.args']) {\n settingsConfig['intlayer.languageServer.args'] = ['@intlayer/lsp'];\n settingsUpdated = true;\n }\n\n if (settingsUpdated) {\n await writeFileToRoot(\n rootDir,\n settingsJsonPath,\n JSON.stringify(settingsConfig, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(settingsJsonPath)} with LSP configuration`\n );\n } else {\n logger(\n `${v} ${colorizePath(settingsJsonPath)} already includes LSP configuration`\n );\n }\n } catch {\n logger(\n `${x} Could not update ${colorizePath(settingsJsonPath)}. You may need to add the LSP settings manually.`,\n { level: 'warn' }\n );\n }\n }\n\n // CHECK TSCONFIGS\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(rootDir, fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(rootDir, fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n let updated = false;\n\n if (!config.include) {\n // Skip if no include array (solution-style)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((pattern: string) =>\n pattern.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n fileName,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // INITIALIZE CONFIG FILE\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n\n // Detect the locale JSON file pattern already in the project so we can\n // insert the matching locales into the config and produce the most\n // accurate source template for compat libraries.\n const detectedPattern = await detectJsonLocalePattern(rootDir);\n\n await initConfig(format, rootDir, detectedPattern?.locales);\n\n // INJECT SYNC-JSON PLUGIN FOR COMPAT LIBRARIES\n if (compatSyncConfig) {\n // For next-intl / use-intl, the messages path is authoritatively declared\n // in `i18n/request.ts` (e.g. `import(`../messages/${locale}.json`)`), so we\n // read it directly. It usually resolves to a single file per locale (no\n // `${key}` segment), whose first-level keys are namespaces — so the compat\n // config carries `splitKeys: true` to emit one dictionary per namespace.\n // Falls back to file-system globbing otherwise.\n const nextIntlMessagesPattern =\n allDeps['next-intl'] ||\n allDeps['@intlayer/next-intl'] ||\n allDeps['use-intl'] ||\n allDeps['@intlayer/use-intl']\n ? await detectNextIntlMessagesPattern(rootDir)\n : null;\n\n const sourceTemplate =\n nextIntlMessagesPattern?.template ?? detectedPattern?.template;\n\n const resolvedSyncConfig = {\n ...compatSyncConfig,\n ...(sourceTemplate ? { sourceTemplate } : {}),\n };\n\n // `splitKeys` only makes sense for a single file holding several namespaces.\n // If the resolved template addresses one namespace per file (`${key}`\n // segment), each file is already a single namespace — drop the flag so\n // syncJSON keeps one dictionary per file.\n if (\n resolvedSyncConfig.splitKeys &&\n resolvedSyncConfig.sourceTemplate.includes('${key}')\n ) {\n resolvedSyncConfig.splitKeys = false;\n }\n\n const intlayerConfigCandidates = [\n 'intlayer.config.ts',\n 'intlayer.config.mjs',\n 'intlayer.config.js',\n 'intlayer.config.cjs',\n ];\n\n for (const configFile of intlayerConfigCandidates) {\n if (await exists(rootDir, configFile)) {\n const configContent = await readFileFromRoot(rootDir, configFile);\n\n if (!configContent.includes('@intlayer/sync-json-plugin')) {\n const extension = configFile.split('.').pop()!;\n const updatedConfigContent = updateIntlayerConfigWithSyncPlugin(\n configContent,\n extension,\n resolvedSyncConfig\n );\n await writeFileToRoot(rootDir, configFile, updatedConfigContent);\n logger(\n `${v} Updated ${colorizePath(configFile)} with syncJSON compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(configFile)} already includes syncJSON plugin`\n );\n }\n break;\n }\n }\n }\n\n // APPLY ROUTING MODE\n // When a routing strategy was chosen (interactive init), write it to\n // `routing.mode` in the configuration file. Idempotent and comment-preserving.\n if (options?.routingMode) {\n await setRoutingModeInConfig(rootDir, options.routingMode);\n }\n\n let hasAliasConfiguration = false;\n\n // CHECK VITE CONFIG\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n\n for (const file of viteConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n const extension = file.split('.').pop()!;\n\n if (compatVitePluginConfig) {\n if (!content.includes(compatVitePluginConfig.pluginPackageSource)) {\n const updatedContent = updateViteConfigForCompatPlugin(\n content,\n extension,\n compatVitePluginConfig\n );\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include ${compatVitePluginConfig.pluginFunctionName} compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(file)} already includes ${compatVitePluginConfig.pluginPackageSource}`\n );\n }\n } else if (!content.includes('vite-intlayer')) {\n const updatedContent = updateViteConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK NEXT CONFIG\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n let isNextJsProject = false;\n\n for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\n isNextJsProject = true;\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n const extension = file.split('.').pop()!;\n\n if (allDeps['next-i18next']) {\n if (!content.includes('@intlayer/next-i18next')) {\n const updatedContent = updateNextConfigForNextI18next(\n content,\n extension\n );\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include Intlayer next-i18next compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(file)} already includes @intlayer/next-i18next`\n );\n }\n } else if (allDeps['next-intl']) {\n if (!content.includes('@intlayer/next-intl/plugin')) {\n const updatedContent = updateNextConfigForNextIntl(\n content,\n extension\n );\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include Intlayer next-intl compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(file)} already includes @intlayer/next-intl/plugin`\n );\n }\n } else if (allDeps['next-translate']) {\n if (!content.includes('@intlayer/next-translate')) {\n const updatedContent = updateNextConfigForNextTranslate(\n content,\n extension\n );\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include Intlayer next-translate compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(file)} already includes @intlayer/next-translate`\n );\n }\n } else if (!content.includes('next-intlayer')) {\n const updatedContent = updateNextConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK NEXT.JS COMPILER (BABEL)\n // When a Next.js project already uses Babel, install @intlayer/babel and print\n // the compiler + build-optimization plugins (extract, purge, minify, optimize)\n // to add. SWC projects need no setup: withIntlayer injects @intlayer/swc.\n if (isNextJsProject) {\n await setupNextCompilerBabelConfig({\n rootDir,\n packageManager,\n allDeps,\n skipInstall: Boolean(options?.noInstallPackages),\n });\n }\n\n // CHECK OTHER FRAMEWORKS CONFIG\n const astroConfigs = [\n 'astro.config.mjs',\n 'astro.config.js',\n 'astro.config.ts',\n 'astro.config.cjs',\n ];\n\n for (const file of astroConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n\n if (file.startsWith('astro.config.')) {\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('astro-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateAstroConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include Intlayer integration`\n );\n }\n }\n break;\n }\n }\n\n const nuxtConfigs = ['nuxt.config.js', 'nuxt.config.ts'];\n for (const file of nuxtConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n\n const content = await readFileFromRoot(rootDir, file);\n\n if (allDeps['@nuxtjs/i18n']) {\n if (!content.includes('@intlayer/nuxtjs-i18n')) {\n const updatedContent = updateNuxtConfigForNuxtjsI18n(content);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include @intlayer/nuxtjs-i18n module`\n );\n } else {\n logger(\n `${v} ${colorizePath(file)} already includes @intlayer/nuxtjs-i18n`\n );\n }\n } else if (!content.includes('nuxt-intlayer')) {\n const updatedContent = updateNuxtConfig(content);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer module`);\n }\n break;\n }\n }\n\n // UPDATE PACKAGE.JSON DEV SCRIPT\n // Next.js >= 16 uses a bun-specific wrapper; backend frameworks wrap whatever\n // the existing dev script is. Both use `intlayer watch --with`.\n const isVersionGreaterOrEqual = (\n versionString: string,\n major: number\n ): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const match = versionString.match(/^[^\\d]*(\\d+)/);\n\n if (!match?.[1]) return false;\n\n return parseInt(match[1], 10) >= major;\n };\n\n const backendIntlayerPackages = [\n 'express-intlayer',\n 'fastify-intlayer',\n 'adonis-intlayer',\n 'hono-intlayer',\n ];\n\n const devScript = packageJson.scripts?.dev;\n\n let newDevScript: string | undefined;\n\n if (\n ((isNextJsProject &&\n allDeps.next &&\n isVersionGreaterOrEqual(allDeps.next, 16)) ||\n backendIntlayerPackages.some((pkg) => allDeps[pkg])) &&\n !devScript.includes('intlayer watch')\n ) {\n newDevScript = `intlayer watch --with '${devScript}'`;\n }\n\n if (newDevScript) {\n packageJson.scripts.dev = newDevScript;\n\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n\n logger(\n `${v} Updated ${colorizePath('package.json')} dev script to run intlayer watch`\n );\n }\n\n // CHECK WEBPACK CONFIG\n const webpackConfigs = [\n 'webpack.config.js',\n 'webpack.config.ts',\n 'webpack.config.mjs',\n 'webpack.config.cjs',\n ];\n\n for (const file of webpackConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n logger(\n `${v} Found ${colorizePath(\n file\n )}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`\n );\n break;\n }\n }\n\n const backendConfigPackages = [\n 'express',\n 'fastify',\n '@adonisjs/core',\n 'hono',\n ...backendIntlayerPackages,\n ];\n\n if (backendConfigPackages.some((pkg) => allDeps[pkg])) {\n hasAliasConfiguration = true;\n }\n\n if (!hasAliasConfiguration) {\n const configuration = getConfiguration({ baseDir: rootDir });\n const aliases = getAlias({ configuration });\n\n if (hasTsConfig && tsConfigFiles.length > 0) {\n const tsConfigPath =\n tsConfigFiles.find((file) => file === 'tsconfig.json') ||\n tsConfigFiles[0];\n\n if (tsConfigPath) {\n const tsConfigContent = await readFileFromRoot(rootDir, tsConfigPath);\n const config = parseJSONWithComments(tsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n tsConfigPath,\n JSON.stringify(config, null, 2)\n );\n\n logger(\n `${v} Updated ${colorizePath(\n tsConfigPath\n )} to include Intlayer aliases`\n );\n }\n }\n } else {\n const jsConfigPath = 'jsconfig.json';\n\n if (await exists(rootDir, jsConfigPath)) {\n const jsConfigContent = await readFileFromRoot(rootDir, jsConfigPath);\n const config = parseJSONWithComments(jsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n jsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n jsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n packageJson.imports ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n const importAlias = alias.replace('@', '#');\n const importPath = path.startsWith('.') ? path : `./${path}`;\n\n if (!packageJson.imports[importAlias]) {\n packageJson.imports[importAlias] = importPath;\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n packageJsonPath\n )} to include Intlayer imports`\n );\n }\n }\n }\n }\n\n // FRAMEWORK-SPECIFIC SCAFFOLDING\n // Sets up middleware/proxy and wraps the layout/page with the Intlayer\n // providers for the detected framework (Next.js App Router today). Idempotent\n // and non-destructive: it never overwrites user code it cannot safely\n // transform, skipping with guidance instead.\n if (!options?.noFrameworkSetup) {\n try {\n await setupFramework({\n rootDir,\n allDeps,\n packageManager,\n useTypeScript: hasTsConfig,\n });\n } catch {\n logger(\n `${x} Framework-specific scaffolding failed. Your existing files were left untouched; follow the documentation to finish the setup.`,\n { level: 'warn' }\n );\n }\n }\n\n // FINAL SUCCESS MESSAGE\n logger(`${v} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n logger([\n colorize('Next →', ANSIColors.MAGENTA),\n colorize(\n `Follow the instructions in the documentation to complete the setup:`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(guideUrl),\n ]);\n\n // INTLAYER LSP — instruction for the AI agent running `intlayer init`.\n // The Intlayer Language Server (`@intlayer/lsp`) provides Go-to-Definition\n // from `useIntlayer` / `getIntlayer` keys to their `.content` files, for both\n // IDEs and AI agents. Setup is editor-specific (VS Code, Cursor, Windsurf,\n // Zed, Neovim, Claude Code, …), so we don't scaffold anything here — instead\n // we point to the doc and ask the agent to confirm the target platform.\n logger([\n colorize('Intlayer LSP →', ANSIColors.MAGENTA),\n colorize(\n 'The Intlayer Language Server is available via the `@intlayer/lsp` package. It lets IDEs and AI agents jump from `useIntlayer`/`getIntlayer` keys to their `.content` files.',\n ANSIColors.GREY_LIGHT\n ),\n colorize(\n 'Ask the user which platform/editor they want to enable it on (VS Code, Cursor, Windsurf, Zed, Neovim, Claude Code, …), then follow the matching setup instructions:',\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(DocumentationRouter.LSP),\n ]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyCA,MAAM,sBAAsB;CAC1B,QAAQ;CACR,WAAW;CACX,WAAW;CACX,KAAK;CACL,OAAO;CACP,cAAc;CACd,4BACE;CACF,qCACE;CACF,YAAY;CACZ,cAAc;CACd,eAAe;CACf,eAAe;CACf,gBAAgB;CAChB,YAAY;CACZ,SAAS;CACT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AI;EACtC,CAAC"}
1
+ {"version":3,"file":"index.cjs","names":["ANSIColors","exists","x","readFileFromRoot","detectPackageManager","detectMissingIntlayerPackages","v","detectOutdatedIntlayerPackages","writeFileToRoot","getGithubWorkflows","ensureDirectory","parseJSONWithComments","findTsConfigFiles","detectJsonLocalePattern","initConfig","detectNextIntlMessagesPattern","updateIntlayerConfigWithSyncPlugin","setRoutingModeInConfig","updateViteConfigForCompatPlugin","updateViteConfig","updateNextConfigForNextI18next","updateNextConfigForNextIntl","updateNextConfigForNextTranslate","updateNextConfig","setupNextCompilerBabelConfig","updateAstroConfig","updateNuxtConfigForNuxtjsI18n","updateNuxtConfig","updateMetroConfig","getMetroConfigTemplate","setupFramework"],"sources":["../../../src/init/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizePath, logger, v, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\n\nimport { getAlias } from '@intlayer/config/utils';\nimport { initConfig } from '../initConfig';\nimport { setRoutingModeInConfig } from './cms';\nimport { setupFramework } from './frameworkSetup';\nimport type { RoutingMode } from './utils';\nimport {\n detectJsonLocalePattern,\n detectMissingIntlayerPackages,\n detectNextIntlMessagesPattern,\n detectOutdatedIntlayerPackages,\n detectPackageManager,\n ensureDirectory,\n exists,\n findTsConfigFiles,\n getGithubWorkflows,\n getMetroConfigTemplate,\n installPackages,\n parseJSONWithComments,\n readFileFromRoot,\n setupNextCompilerBabelConfig,\n updateAstroConfig,\n updateIntlayerConfigWithSyncPlugin,\n updateMetroConfig,\n updateNextConfig,\n updateNextConfigForNextI18next,\n updateNextConfigForNextIntl,\n updateNextConfigForNextTranslate,\n updateNuxtConfig,\n updateNuxtConfigForNuxtjsI18n,\n updateViteConfig,\n updateViteConfigForCompatPlugin,\n upgradePackages,\n writeFileToRoot,\n} from './utils';\n\n/**\n * Documentation URL Constants\n */\nconst DocumentationRouter = {\n NextJS: 'https://intlayer.org/doc/environment/nextjs.md',\n NextJS_15: 'https://intlayer.org/doc/environment/nextjs/15.md',\n NextJS_14: 'https://intlayer.org/doc/environment/nextjs/14.md',\n CRA: 'https://intlayer.org/doc/environment/create-react-app.md',\n Astro: 'https://intlayer.org/doc/environment/astro.md',\n ViteAndReact: 'https://intlayer.org/doc/environment/vite-and-react.md',\n ViteAndReact_ReactRouterV7:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7.md',\n ViteAndReact_ReactRouterV7_FSRoutes:\n 'https://intlayer.org/doc/environment/vite-and-react/react-router-v7-fs-routes.md',\n ViteAndVue: 'https://intlayer.org/doc/environment/vite-and-vue.md',\n ViteAndSolid: 'https://intlayer.org/doc/environment/vite-and-solid.md',\n ViteAndSvelte: 'https://intlayer.org/doc/environment/vite-and-svelte.md',\n ViteAndPreact: 'https://intlayer.org/doc/environment/vite-and-preact.md',\n TanStackRouter: 'https://intlayer.org/doc/environment/tanstack.md',\n NuxtAndVue: 'https://intlayer.org/doc/environment/nuxt-and-vue.md',\n Angular: 'https://intlayer.org/doc/environment/angular.md',\n SvelteKit: 'https://intlayer.org/doc/environment/sveltekit.md',\n ReactNativeAndExpo:\n 'https://intlayer.org/doc/environment/react-native-and-expo.md',\n Lynx: 'https://intlayer.org/doc/environment/lynx-and-react.md',\n Express: 'https://intlayer.org/doc/environment/express.md',\n NestJS: 'https://intlayer.org/doc/environment/nestjs.md',\n Fastify: 'https://intlayer.org/doc/environment/fastify.md',\n Default: 'https://intlayer.org/doc/get-started',\n\n // Intlayer Language Server (Go-to-Definition from getter keys to .content files)\n LSP: 'https://intlayer.org/doc/lsp.md',\n\n // Check for competitors libs\n NextIntl: 'https://intlayer.org/blog/intlayer-with-next-intl.md',\n ReactI18Next: 'https://intlayer.org/blog/intlayer-with-react-i18next.md',\n ReactIntl: 'https://intlayer.org/blog/intlayer-with-react-intl.md',\n NextI18Next: 'https://intlayer.org/blog/intlayer-with-next-i18next.md',\n VueI18n: 'https://intlayer.org/blog/intlayer-with-vue-i18n.md',\n};\n\n/**\n * Helper: Detects the environment and returns the doc URL\n */\nconst getDocumentationUrl = (packageJson: any): string => {\n const deps = {\n ...packageJson.dependencies,\n ...packageJson.devDependencies,\n };\n\n /**\n * Helper to check if a version string matches a specific major version\n * Matches: \"15\", \"^15.0.0\", \"~15.2\", \"15.0.0-beta\"\n */\n const isVersion = (versionString: string, major: number): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const regex = new RegExp(`^[\\\\^~]?${major}(?:\\\\.|$)`);\n return regex.test(versionString);\n };\n\n // Mobile / Cross-platform\n if (deps['@lynx-js/react'] || deps['@lynx-js/core']) {\n return DocumentationRouter.Lynx;\n }\n if (deps['react-native'] || deps.expo) {\n return DocumentationRouter.ReactNativeAndExpo;\n }\n\n // Meta-frameworks (Next, Nuxt, Astro, SvelteKit)\n if (deps.next) {\n const version = deps.next;\n\n if (isVersion(version, 14)) {\n return DocumentationRouter.NextJS_14;\n }\n\n if (isVersion(version, 15)) {\n return DocumentationRouter.NextJS_15;\n }\n\n return DocumentationRouter.NextJS;\n }\n\n if (deps.nuxt) return DocumentationRouter.NuxtAndVue;\n if (deps.astro) return DocumentationRouter.Astro;\n if (deps['@sveltejs/kit']) return DocumentationRouter.SvelteKit;\n\n // Routers (TanStack & React Router v7)\n if (deps['@tanstack/react-router']) {\n return DocumentationRouter.TanStackRouter;\n }\n\n // Check for React Router v7\n const reactRouterVersion = deps['react-router'];\n if (reactRouterVersion && typeof reactRouterVersion === 'string') {\n // Distinguish between standard v7 and v7 with FS routes\n if (deps['@react-router/fs-routes']) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7_FSRoutes;\n }\n\n // Use Regex to ensure it is v7\n if (isVersion(reactRouterVersion, 7)) {\n return DocumentationRouter.ViteAndReact_ReactRouterV7;\n }\n }\n\n // Vite Ecosystem (General)\n if (deps.vite) {\n if (deps.vue) return DocumentationRouter.ViteAndVue;\n if (deps['solid-js']) return DocumentationRouter.ViteAndSolid;\n if (deps.svelte) return DocumentationRouter.ViteAndSvelte;\n if (deps.preact) return DocumentationRouter.ViteAndPreact;\n\n // Default to React if Vite is present but specific other frameworks aren't found\n return DocumentationRouter.ViteAndReact;\n }\n\n // Other Web Frameworks\n if (deps['react-scripts']) return DocumentationRouter.CRA;\n if (deps['@angular/core']) return DocumentationRouter.Angular;\n\n // Backend\n if (deps['@nestjs/core']) return DocumentationRouter.NestJS;\n if (deps.express) return DocumentationRouter.Express;\n if (deps.fastify) return DocumentationRouter.Fastify;\n\n // Competitor Libs (Migration Guides)\n // We check these last as specific environment setup is usually higher priority,\n // but if no specific framework logic matched (or as a fallback), we guide to migration.\n if (deps['next-intl']) return DocumentationRouter.NextIntl;\n if (deps['react-i18next'] || deps.i18next)\n return DocumentationRouter.ReactI18Next;\n if (deps['react-intl']) return DocumentationRouter.ReactIntl;\n if (deps['next-i18next']) return DocumentationRouter.NextI18Next;\n if (deps['vue-i18n']) return DocumentationRouter.VueI18n;\n\n return DocumentationRouter.Default;\n};\n\n/**\n * OPTIONS\n */\nexport type InitOptions = {\n noGitignore?: boolean;\n /** Skip scaffolding the `fill` and `test` GitHub Actions workflows. */\n noGithubActions?: boolean;\n /**\n * Skip installing missing Intlayer dependencies and upgrading outdated ones.\n */\n noInstallPackages?: boolean;\n /** Skip adding the Intlayer extension to `.vscode/extensions.json`. */\n noVscodeExtension?: boolean;\n /** Skip writing the Intlayer LSP configuration to `.vscode/settings.json`. */\n noLsp?: boolean;\n /**\n * Skip framework-specific scaffolding (middleware/proxy, providers in\n * layout/page, example content). Defaults to enabled.\n */\n noFrameworkSetup?: boolean;\n /**\n * Version that outdated Intlayer packages should be upgraded to (typically the\n * running CLI version). When omitted, installed packages are left untouched and\n * only missing ones are installed.\n */\n upgradeToVersion?: string;\n /**\n * Locale routing strategy to write to `routing.mode` in the generated/existing\n * Intlayer configuration file. When omitted, the configuration default\n * (`prefix-no-default`) is kept.\n */\n routingMode?: RoutingMode;\n};\n\n/**\n * MAIN LOGIC\n */\nexport const initIntlayer = async (rootDir: string, options?: InitOptions) => {\n logger(colorize('Checking Intlayer configuration...', ANSIColors.CYAN));\n\n // READ PACKAGE.JSON\n const packageJsonPath = 'package.json';\n if (!(await exists(rootDir, packageJsonPath))) {\n logger(\n `${x} No ${colorizePath('package.json')} found. Please run this script from the project root.`,\n { level: 'error' }\n );\n process.exit(1);\n }\n\n const packageJsonContent = await readFileFromRoot(rootDir, packageJsonPath);\n let packageJson: Record<string, any>;\n try {\n packageJson = JSON.parse(packageJsonContent);\n } catch {\n logger(`${x} Could not parse ${colorizePath('package.json')}.`, {\n level: 'error',\n });\n process.exit(1);\n }\n\n // Determine the correct documentation URL based on dependencies\n const guideUrl = getDocumentationUrl(packageJson);\n\n const allDeps: Record<string, string> = {\n ...(packageJson.dependencies ?? {}),\n ...(packageJson.devDependencies ?? {}),\n };\n\n // INSTALL MISSING INTLAYER DEPENDENCIES\n const packageManager = detectPackageManager(rootDir);\n const {\n packagesToInstall,\n devPackagesToInstall,\n compatSyncConfig,\n compatVitePluginConfig,\n } = detectMissingIntlayerPackages(allDeps);\n\n if (!options?.noInstallPackages) {\n const withVersion = (packages: string[]): string[] =>\n options?.upgradeToVersion\n ? packages.map((pkg) => `${pkg}@${options.upgradeToVersion}`)\n : packages;\n\n if (packagesToInstall.length > 0) {\n logger(\n colorize('Installing missing Intlayer dependencies...', ANSIColors.CYAN)\n );\n try {\n installPackages(\n rootDir,\n withVersion(packagesToInstall),\n packageManager\n );\n logger(\n `${v} Installed: ${packagesToInstall.map((pkg) => colorize(pkg, ANSIColors.MAGENTA)).join(', ')}`\n );\n } catch {\n logger(\n `${x} Failed to install packages. Please install manually: ${packagesToInstall.join(' ')}`,\n { level: 'warn' }\n );\n }\n }\n\n if (devPackagesToInstall.length > 0) {\n logger(\n colorize(\n 'Installing missing Intlayer dev dependencies...',\n ANSIColors.CYAN\n )\n );\n try {\n installPackages(\n rootDir,\n withVersion(devPackagesToInstall),\n packageManager,\n true\n );\n logger(\n `${v} Installed: ${devPackagesToInstall.map((pkg) => colorize(pkg, ANSIColors.MAGENTA)).join(', ')}`\n );\n } catch {\n logger(\n `${x} Failed to install dev packages. Please install manually: ${devPackagesToInstall.join(' ')}`,\n { level: 'warn' }\n );\n }\n }\n\n // UPGRADE OUTDATED INTLAYER DEPENDENCIES\n // Only runs when a target version is provided (typically the running CLI\n // version). Already up-to-date packages are skipped. Prod and dev\n // dependencies are upgraded separately so their dependency type is kept.\n if (options?.upgradeToVersion) {\n const outdatedDependencies = detectOutdatedIntlayerPackages(\n rootDir,\n packageJson.dependencies ?? {},\n options.upgradeToVersion\n );\n const outdatedDevDependencies = detectOutdatedIntlayerPackages(\n rootDir,\n packageJson.devDependencies ?? {},\n options.upgradeToVersion\n );\n\n const allOutdated = [...outdatedDependencies, ...outdatedDevDependencies];\n\n if (allOutdated.length > 0) {\n logger(\n colorize(\n `Upgrading outdated Intlayer dependencies to ${options.upgradeToVersion}...`,\n ANSIColors.CYAN\n )\n );\n try {\n upgradePackages(\n rootDir,\n outdatedDependencies,\n packageManager,\n options.upgradeToVersion\n );\n upgradePackages(\n rootDir,\n outdatedDevDependencies,\n packageManager,\n options.upgradeToVersion,\n true\n );\n logger(\n `${v} Upgraded: ${allOutdated.map((pkg) => colorize(pkg, ANSIColors.MAGENTA)).join(', ')}`\n );\n } catch {\n logger(\n `${x} Failed to upgrade packages. Please upgrade manually: ${allOutdated.join(' ')}`,\n { level: 'warn' }\n );\n }\n } else {\n logger(`${v} Intlayer dependencies are up to date`);\n }\n }\n }\n\n // CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (!options?.noGitignore && (await exists(rootDir, gitignorePath))) {\n const gitignoreContent = await readFileFromRoot(rootDir, gitignorePath);\n\n if (!gitignoreContent.includes('intlayer')) {\n const newContent = `${gitignoreContent}\\n# Intlayer\\n.intlayer\\n`;\n await writeFileToRoot(rootDir, gitignorePath, newContent);\n logger(\n `${v} Added ${colorizePath('.intlayer')} to ${colorizePath(gitignorePath)}`\n );\n } else {\n logger(`${v} ${colorizePath(gitignorePath)} already includes .intlayer`);\n }\n }\n\n // SCAFFOLD GITHUB ACTIONS WORKFLOWS (fill + test)\n // Generate two workflows whose commands match the detected package manager:\n // - intlayer-fill.yml: auto-fills missing translations on pull requests\n // - intlayer-test.yml: fails the PR when required locales are missing\n if (!options?.noGithubActions) {\n const workflows = getGithubWorkflows(packageManager);\n\n for (const workflow of workflows) {\n if (await exists(rootDir, workflow.filePath)) {\n logger(`${v} ${colorizePath(workflow.filePath)} already exists`);\n continue;\n }\n\n try {\n await ensureDirectory(rootDir, join('.github', 'workflows'));\n await writeFileToRoot(rootDir, workflow.filePath, workflow.content);\n logger(\n `${v} Added GitHub Actions workflow ${colorizePath(workflow.filePath)}`\n );\n } catch {\n logger(\n `${x} Could not create ${colorizePath(workflow.filePath)}. You may need to add it manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // CHECK VS CODE EXTENSION RECOMMENDATIONS\n const vscodeDir = '.vscode';\n const extensionsJsonPath = join(vscodeDir, 'extensions.json');\n const extensionId = 'intlayer.intlayer-vs-code-extension';\n\n if (!options?.noVscodeExtension) {\n try {\n let extensionsConfig: { recommendations: string[] } = {\n recommendations: [],\n };\n\n if (await exists(rootDir, extensionsJsonPath)) {\n const content = await readFileFromRoot(rootDir, extensionsJsonPath);\n extensionsConfig = parseJSONWithComments(content);\n } else {\n await ensureDirectory(rootDir, vscodeDir);\n }\n\n if (!extensionsConfig.recommendations) {\n extensionsConfig.recommendations = [];\n }\n\n if (!extensionsConfig.recommendations.includes(extensionId)) {\n extensionsConfig.recommendations.push(extensionId);\n await writeFileToRoot(\n rootDir,\n extensionsJsonPath,\n JSON.stringify(extensionsConfig, null, 2)\n );\n logger(\n `${v} Added ${colorize(extensionId, ANSIColors.MAGENTA)} to ${colorizePath(extensionsJsonPath)}`\n );\n } else {\n logger(\n `${v} ${colorizePath(extensionsJsonPath)} already includes ${colorize(extensionId, ANSIColors.MAGENTA)}`\n );\n }\n } catch {\n logger(\n `${x} Could not update ${colorizePath(extensionsJsonPath)}. You may need to add ${colorize(extensionId, ANSIColors.MAGENTA)} manually.`,\n { level: 'warn' }\n );\n }\n }\n\n // CHECK VS CODE LSP SETTINGS\n const settingsJsonPath = join(vscodeDir, 'settings.json');\n\n if (!options?.noLsp) {\n try {\n let settingsConfig: Record<string, unknown> = {};\n\n if (await exists(rootDir, settingsJsonPath)) {\n const content = await readFileFromRoot(rootDir, settingsJsonPath);\n settingsConfig = parseJSONWithComments(content);\n } else {\n await ensureDirectory(rootDir, vscodeDir);\n }\n\n let settingsUpdated = false;\n\n if (!settingsConfig['intlayer.languageServer.command']) {\n settingsConfig['intlayer.languageServer.command'] = 'npx';\n settingsUpdated = true;\n }\n\n if (!settingsConfig['intlayer.languageServer.args']) {\n settingsConfig['intlayer.languageServer.args'] = ['@intlayer/lsp'];\n settingsUpdated = true;\n }\n\n if (settingsUpdated) {\n await writeFileToRoot(\n rootDir,\n settingsJsonPath,\n JSON.stringify(settingsConfig, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(settingsJsonPath)} with LSP configuration`\n );\n } else {\n logger(\n `${v} ${colorizePath(settingsJsonPath)} already includes LSP configuration`\n );\n }\n } catch {\n logger(\n `${x} Could not update ${colorizePath(settingsJsonPath)}. You may need to add the LSP settings manually.`,\n { level: 'warn' }\n );\n }\n }\n\n // CHECK TSCONFIGS\n const tsConfigFiles = await findTsConfigFiles(rootDir);\n let hasTsConfig = false;\n\n for (const fileName of tsConfigFiles) {\n if (await exists(rootDir, fileName)) {\n hasTsConfig = true;\n try {\n const fileContent = await readFileFromRoot(rootDir, fileName);\n const config = parseJSONWithComments(fileContent);\n const typeDefinition = '.intlayer/**/*.ts';\n\n let updated = false;\n\n if (!config.include) {\n // Skip if no include array (solution-style)\n } else if (\n Array.isArray(config.include) &&\n !(config.include as string[]).some((pattern: string) =>\n pattern.includes('.intlayer')\n )\n ) {\n config.include.push(typeDefinition);\n updated = true;\n } else if (config.include.includes(typeDefinition)) {\n logger(\n `${v} ${colorizePath(fileName)} already includes intlayer types`\n );\n }\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n fileName,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(fileName)} to include intlayer types`\n );\n }\n } catch {\n logger(\n `${x} Could not parse or update ${colorizePath(fileName)}. You may need to add ${colorizePath('.intlayer/types/**/*.ts')} manually.`,\n { level: 'warn' }\n );\n }\n }\n }\n\n // INITIALIZE CONFIG FILE\n const format = hasTsConfig ? 'intlayer.config.ts' : 'intlayer.config.mjs';\n\n // Detect the locale JSON file pattern already in the project so we can\n // insert the matching locales into the config and produce the most\n // accurate source template for compat libraries.\n const detectedPattern = await detectJsonLocalePattern(rootDir);\n\n await initConfig(format, rootDir, detectedPattern?.locales);\n\n // INJECT SYNC-JSON PLUGIN FOR COMPAT LIBRARIES\n if (compatSyncConfig) {\n // For next-intl / use-intl, the messages path is authoritatively declared\n // in `i18n/request.ts` (e.g. `import(`../messages/${locale}.json`)`), so we\n // read it directly. It usually resolves to a single file per locale (no\n // `${key}` segment), whose first-level keys are namespaces — so the compat\n // config carries `splitKeys: true` to emit one dictionary per namespace.\n // Falls back to file-system globbing otherwise.\n const nextIntlMessagesPattern =\n allDeps['next-intl'] ||\n allDeps['@intlayer/next-intl'] ||\n allDeps['use-intl'] ||\n allDeps['@intlayer/use-intl']\n ? await detectNextIntlMessagesPattern(rootDir)\n : null;\n\n const sourceTemplate =\n nextIntlMessagesPattern?.template ?? detectedPattern?.template;\n\n const resolvedSyncConfig = {\n ...compatSyncConfig,\n ...(sourceTemplate ? { sourceTemplate } : {}),\n };\n\n // `splitKeys` only makes sense for a single file holding several namespaces.\n // If the resolved template addresses one namespace per file (`${key}`\n // segment), each file is already a single namespace — drop the flag so\n // syncJSON keeps one dictionary per file.\n if (\n resolvedSyncConfig.splitKeys &&\n resolvedSyncConfig.sourceTemplate.includes('${key}')\n ) {\n resolvedSyncConfig.splitKeys = false;\n }\n\n const intlayerConfigCandidates = [\n 'intlayer.config.ts',\n 'intlayer.config.mjs',\n 'intlayer.config.js',\n 'intlayer.config.cjs',\n ];\n\n for (const configFile of intlayerConfigCandidates) {\n if (await exists(rootDir, configFile)) {\n const configContent = await readFileFromRoot(rootDir, configFile);\n\n if (!configContent.includes('@intlayer/sync-json-plugin')) {\n const extension = configFile.split('.').pop()!;\n const updatedConfigContent = updateIntlayerConfigWithSyncPlugin(\n configContent,\n extension,\n resolvedSyncConfig\n );\n await writeFileToRoot(rootDir, configFile, updatedConfigContent);\n logger(\n `${v} Updated ${colorizePath(configFile)} with syncJSON compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(configFile)} already includes syncJSON plugin`\n );\n }\n break;\n }\n }\n }\n\n // APPLY ROUTING MODE\n // When a routing strategy was chosen (interactive init), write it to\n // `routing.mode` in the configuration file. Idempotent and comment-preserving.\n if (options?.routingMode) {\n await setRoutingModeInConfig(rootDir, options.routingMode);\n }\n\n let hasAliasConfiguration = false;\n\n // CHECK VITE CONFIG\n const viteConfigs = ['vite.config.ts', 'vite.config.js', 'vite.config.mjs'];\n\n for (const file of viteConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n const extension = file.split('.').pop()!;\n\n if (compatVitePluginConfig) {\n if (!content.includes(compatVitePluginConfig.pluginPackageSource)) {\n const updatedContent = updateViteConfigForCompatPlugin(\n content,\n extension,\n compatVitePluginConfig\n );\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include ${compatVitePluginConfig.pluginFunctionName} compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(file)} already includes ${compatVitePluginConfig.pluginPackageSource}`\n );\n }\n } else if (!content.includes('vite-intlayer')) {\n const updatedContent = updateViteConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK NEXT CONFIG\n const nextConfigs = ['next.config.js', 'next.config.mjs', 'next.config.ts'];\n let isNextJsProject = false;\n\n for (const file of nextConfigs) {\n if (await exists(rootDir, file)) {\n isNextJsProject = true;\n hasAliasConfiguration = true;\n const content = await readFileFromRoot(rootDir, file);\n const extension = file.split('.').pop()!;\n\n if (allDeps['next-i18next']) {\n if (!content.includes('@intlayer/next-i18next')) {\n const updatedContent = updateNextConfigForNextI18next(\n content,\n extension\n );\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include Intlayer next-i18next compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(file)} already includes @intlayer/next-i18next`\n );\n }\n } else if (allDeps['next-intl']) {\n if (!content.includes('@intlayer/next-intl/plugin')) {\n const updatedContent = updateNextConfigForNextIntl(\n content,\n extension\n );\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include Intlayer next-intl compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(file)} already includes @intlayer/next-intl/plugin`\n );\n }\n } else if (allDeps['next-translate']) {\n if (!content.includes('@intlayer/next-translate')) {\n const updatedContent = updateNextConfigForNextTranslate(\n content,\n extension\n );\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include Intlayer next-translate compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(file)} already includes @intlayer/next-translate`\n );\n }\n } else if (!content.includes('next-intlayer')) {\n const updatedContent = updateNextConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer plugin`);\n }\n break;\n }\n }\n\n // CHECK NEXT.JS COMPILER (BABEL)\n // When a Next.js project already uses Babel, install @intlayer/babel and print\n // the compiler + build-optimization plugins (extract, purge, minify, optimize)\n // to add. SWC projects need no setup: withIntlayer injects @intlayer/swc.\n if (isNextJsProject) {\n await setupNextCompilerBabelConfig({\n rootDir,\n packageManager,\n allDeps,\n skipInstall: Boolean(options?.noInstallPackages),\n });\n }\n\n // CHECK OTHER FRAMEWORKS CONFIG\n const astroConfigs = [\n 'astro.config.mjs',\n 'astro.config.js',\n 'astro.config.ts',\n 'astro.config.cjs',\n ];\n\n for (const file of astroConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n\n if (file.startsWith('astro.config.')) {\n const content = await readFileFromRoot(rootDir, file);\n\n if (!content.includes('astro-intlayer')) {\n const extension = file.split('.').pop()!;\n const updatedContent = updateAstroConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include Intlayer integration`\n );\n }\n }\n break;\n }\n }\n\n const nuxtConfigs = ['nuxt.config.js', 'nuxt.config.ts'];\n for (const file of nuxtConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n\n const content = await readFileFromRoot(rootDir, file);\n\n if (allDeps['@nuxtjs/i18n']) {\n if (!content.includes('@intlayer/nuxtjs-i18n')) {\n const updatedContent = updateNuxtConfigForNuxtjsI18n(content);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include @intlayer/nuxtjs-i18n module`\n );\n } else {\n logger(\n `${v} ${colorizePath(file)} already includes @intlayer/nuxtjs-i18n`\n );\n }\n } else if (!content.includes('nuxt-intlayer')) {\n const updatedContent = updateNuxtConfig(content);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(`${v} Updated ${colorizePath(file)} to include Intlayer module`);\n }\n break;\n }\n }\n\n // CHECK METRO CONFIG (React Native / Expo)\n // Metro is the React Native bundler. The Intlayer Metro plugin\n // (`react-native-intlayer/metro`) handles dictionary aliasing and building.\n // When no config exists we scaffold one; when one exists we safely wrap its\n // exported config with `configMetroIntlayerSync`, leaving custom async\n // (IIFE) configs untouched so existing setups are never broken.\n const isReactNativeProject = Boolean(allDeps['react-native'] || allDeps.expo);\n\n if (isReactNativeProject) {\n // Metro resolves Intlayer aliases itself, so skip the alias fallback below.\n hasAliasConfiguration = true;\n\n const metroConfigs = [\n 'metro.config.js',\n 'metro.config.cjs',\n 'metro.config.mjs',\n 'metro.config.ts',\n ];\n\n let metroConfigFile: string | undefined;\n\n for (const file of metroConfigs) {\n if (await exists(rootDir, file)) {\n metroConfigFile = file;\n break;\n }\n }\n\n if (metroConfigFile) {\n const content = await readFileFromRoot(rootDir, metroConfigFile);\n\n if (content.includes('react-native-intlayer')) {\n logger(\n `${v} ${colorizePath(metroConfigFile)} already includes the Intlayer Metro plugin`\n );\n } else {\n const extension = metroConfigFile.split('.').pop()!;\n const updatedContent = updateMetroConfig(content, extension);\n\n if (updatedContent !== content) {\n await writeFileToRoot(rootDir, metroConfigFile, updatedContent);\n logger(\n `${v} Updated ${colorizePath(metroConfigFile)} to include the Intlayer Metro plugin`\n );\n } else {\n logger(\n `${x} Could not automatically update ${colorizePath(metroConfigFile)}. Wrap your exported config with ${colorize('configMetroIntlayer', ANSIColors.MAGENTA)}: ${colorizePath(DocumentationRouter.ReactNativeAndExpo)}`,\n { level: 'warn' }\n );\n }\n }\n } else {\n const newMetroConfigFile = 'metro.config.js';\n await writeFileToRoot(\n rootDir,\n newMetroConfigFile,\n getMetroConfigTemplate(Boolean(allDeps.expo))\n );\n logger(\n `${v} Created ${colorizePath(newMetroConfigFile)} with the Intlayer Metro plugin`\n );\n }\n }\n\n // UPDATE PACKAGE.JSON DEV SCRIPT\n // Next.js >= 16 uses a bun-specific wrapper; backend frameworks wrap whatever\n // the existing dev script is. Both use `intlayer watch --with`.\n const isVersionGreaterOrEqual = (\n versionString: string,\n major: number\n ): boolean => {\n if (!versionString || typeof versionString !== 'string') return false;\n const match = versionString.match(/^[^\\d]*(\\d+)/);\n\n if (!match?.[1]) return false;\n\n return parseInt(match[1], 10) >= major;\n };\n\n const backendIntlayerPackages = [\n 'express-intlayer',\n 'fastify-intlayer',\n 'adonis-intlayer',\n 'hono-intlayer',\n ];\n\n const devScript = packageJson.scripts?.dev;\n\n let newDevScript: string | undefined;\n\n if (\n ((isNextJsProject &&\n allDeps.next &&\n isVersionGreaterOrEqual(allDeps.next, 16)) ||\n backendIntlayerPackages.some((pkg) => allDeps[pkg])) &&\n !devScript.includes('intlayer watch')\n ) {\n newDevScript = `intlayer watch --with '${devScript}'`;\n }\n\n if (newDevScript) {\n packageJson.scripts.dev = newDevScript;\n\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n\n logger(\n `${v} Updated ${colorizePath('package.json')} dev script to run intlayer watch`\n );\n }\n\n // CHECK WEBPACK CONFIG\n const webpackConfigs = [\n 'webpack.config.js',\n 'webpack.config.ts',\n 'webpack.config.mjs',\n 'webpack.config.cjs',\n ];\n\n for (const file of webpackConfigs) {\n if (await exists(rootDir, file)) {\n hasAliasConfiguration = true;\n logger(\n `${v} Found ${colorizePath(\n file\n )}. Make sure to configure aliases manually or use the Intlayer Webpack plugin.`\n );\n break;\n }\n }\n\n const backendConfigPackages = [\n 'express',\n 'fastify',\n '@adonisjs/core',\n 'hono',\n ...backendIntlayerPackages,\n ];\n\n if (backendConfigPackages.some((pkg) => allDeps[pkg])) {\n hasAliasConfiguration = true;\n }\n\n if (!hasAliasConfiguration) {\n const configuration = getConfiguration({ baseDir: rootDir });\n const aliases = getAlias({ configuration });\n\n if (hasTsConfig && tsConfigFiles.length > 0) {\n const tsConfigPath =\n tsConfigFiles.find((file) => file === 'tsconfig.json') ||\n tsConfigFiles[0];\n\n if (tsConfigPath) {\n const tsConfigContent = await readFileFromRoot(rootDir, tsConfigPath);\n const config = parseJSONWithComments(tsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n tsConfigPath,\n JSON.stringify(config, null, 2)\n );\n\n logger(\n `${v} Updated ${colorizePath(\n tsConfigPath\n )} to include Intlayer aliases`\n );\n }\n }\n } else {\n const jsConfigPath = 'jsconfig.json';\n\n if (await exists(rootDir, jsConfigPath)) {\n const jsConfigContent = await readFileFromRoot(rootDir, jsConfigPath);\n const config = parseJSONWithComments(jsConfigContent);\n\n config.compilerOptions ??= {};\n config.compilerOptions.paths ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n if (!config.compilerOptions.paths[alias]) {\n config.compilerOptions.paths[alias] = [path];\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n jsConfigPath,\n JSON.stringify(config, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n jsConfigPath\n )} to include Intlayer aliases`\n );\n }\n } else {\n packageJson.imports ??= {};\n\n let updated = false;\n\n Object.entries(aliases).forEach(([alias, path]) => {\n const importAlias = alias.replace('@', '#');\n const importPath = path.startsWith('.') ? path : `./${path}`;\n\n if (!packageJson.imports[importAlias]) {\n packageJson.imports[importAlias] = importPath;\n updated = true;\n }\n });\n\n if (updated) {\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n JSON.stringify(packageJson, null, 2)\n );\n logger(\n `${v} Updated ${colorizePath(\n packageJsonPath\n )} to include Intlayer imports`\n );\n }\n }\n }\n }\n\n // FRAMEWORK-SPECIFIC SCAFFOLDING\n // Sets up middleware/proxy and wraps the layout/page with the Intlayer\n // providers for the detected framework (Next.js App Router today). Idempotent\n // and non-destructive: it never overwrites user code it cannot safely\n // transform, skipping with guidance instead.\n if (!options?.noFrameworkSetup) {\n try {\n await setupFramework({\n rootDir,\n allDeps,\n packageManager,\n useTypeScript: hasTsConfig,\n });\n } catch {\n logger(\n `${x} Framework-specific scaffolding failed. Your existing files were left untouched; follow the documentation to finish the setup.`,\n { level: 'warn' }\n );\n }\n }\n\n // FINAL SUCCESS MESSAGE\n logger(`${v} ${colorize('Intlayer init setup complete.', ANSIColors.GREEN)}`);\n logger([\n colorize('Next →', ANSIColors.MAGENTA),\n colorize(\n `Follow the instructions in the documentation to complete the setup:`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(guideUrl),\n ]);\n\n // INTLAYER LSP — instruction for the AI agent running `intlayer init`.\n // The Intlayer Language Server (`@intlayer/lsp`) provides Go-to-Definition\n // from `useIntlayer` / `getIntlayer` keys to their `.content` files, for both\n // IDEs and AI agents. Setup is editor-specific (VS Code, Cursor, Windsurf,\n // Zed, Neovim, Claude Code, …), so we don't scaffold anything here — instead\n // we point to the doc and ask the agent to confirm the target platform.\n logger([\n colorize('Intlayer LSP →', ANSIColors.MAGENTA),\n colorize(\n 'The Intlayer Language Server is available via the `@intlayer/lsp` package. It lets IDEs and AI agents jump from `useIntlayer`/`getIntlayer` keys to their `.content` files.',\n ANSIColors.GREY_LIGHT\n ),\n colorize(\n 'Ask the user which platform/editor they want to enable it on (VS Code, Cursor, Windsurf, Zed, Neovim, Claude Code, …), then follow the matching setup instructions:',\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(DocumentationRouter.LSP),\n ]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2CA,MAAM,sBAAsB;CAC1B,QAAQ;CACR,WAAW;CACX,WAAW;CACX,KAAK;CACL,OAAO;CACP,cAAc;CACd,4BACE;CACF,qCACE;CACF,YAAY;CACZ,cAAc;CACd,eAAe;CACf,eAAe;CACf,gBAAgB;CAChB,YAAY;CACZ,SAAS;CACT,WAAW;CACX,oBACE;CACF,MAAM;CACN,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CAGT,KAAK;CAGL,UAAU;CACV,cAAc;CACd,WAAW;CACX,aAAa;CACb,SAAS;CACV;;;;AAKD,MAAM,uBAAuB,gBAA6B;CACxD,MAAM,OAAO;EACX,GAAG,YAAY;EACf,GAAG,YAAY;EAChB;;;;;CAMD,MAAM,aAAa,eAAuB,UAA2B;AACnE,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,SAAU,QAAO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AAEF,QAAI,SAAS;AACX,WAAME,8CACJ,SACA,iBACA,KAAK,UAAU,aAAa,MAAM,EAAE,CACrC;AACD,yCACE,GAAGF,0BAAE,qDACH,gBACD,CAAC,8BACH;;;;;AAWT,KAAI,CAAC,SAAS,iBACZ,KAAI;AACF,QAAMwB,iDAAe;GACnB;GACA;GACA;GACA,eAAe;GAChB,CAAC;SACI;AACN,sCACE,GAAG5B,0BAAE,iIACL,EAAE,OAAO,QAAQ,CAClB;;AAKL,qCAAO,GAAGI,0BAAE,yCAAY,iCAAiCN,wBAAW,MAAM,GAAG;AAC7E,qCAAO;wCACI,UAAUA,wBAAW,QAAQ;wCAEpC,uEACAA,wBAAW,WACZ;4CACY,SAAS;EACvB,CAAC;AAQF,qCAAO;wCACI,kBAAkBA,wBAAW,QAAQ;wCAE5C,+KACAA,wBAAW,WACZ;wCAEC,uKACAA,wBAAW,WACZ;4CACY,oBAAoB,IAAI;EACtC,CAAC"}
@@ -180,6 +180,70 @@ const updateNextConfig = (content, extension) => {
180
180
  });
181
181
  return recast.print(ast).code;
182
182
  };
183
+ /**
184
+ * Returns true when the expression looks like an Immediately Invoked Function
185
+ * Expression (e.g. `(async () => { ... })()`). Such custom async exports cannot
186
+ * be safely wrapped with the synchronous Metro helper, so they are skipped.
187
+ */
188
+ const isImmediatelyInvokedFunction = (node) => n.CallExpression.check(node) && (n.ArrowFunctionExpression.check(node.callee) || n.FunctionExpression.check(node.callee));
189
+ /**
190
+ * Wraps a React Native Metro config's exported value with
191
+ * `configMetroIntlayerSync` from `react-native-intlayer/metro`, injecting the
192
+ * import. The synchronous helper is used because it wraps a plain config object
193
+ * and needs no IIFE, making it safe to inject into existing configs without
194
+ * restructuring them.
195
+ *
196
+ * Non-destructive: returns the content unchanged when the export is already
197
+ * wrapped, when the Intlayer Metro plugin is already present, or when the export
198
+ * is a custom async IIFE that cannot be wrapped synchronously. Callers should
199
+ * compare the result with the input to detect the skipped case.
200
+ */
201
+ const updateMetroConfig = (content, extension) => {
202
+ if (content.includes("react-native-intlayer")) return content;
203
+ const ast = recast.parse(content, { parser: require("recast/parsers/typescript") });
204
+ const isCJSFile = extension === "cjs" || content.includes("module.exports") && !content.includes("import ");
205
+ const wrapperName = "configMetroIntlayerSync";
206
+ const isWrappable = (node) => n.Expression.check(node) && !isImmediatelyInvokedFunction(node) && !(n.CallExpression.check(node) && n.Identifier.check(node.callee) && node.callee.name === wrapperName);
207
+ let wrapped = false;
208
+ recast.visit(ast, {
209
+ visitExportDefaultDeclaration(path) {
210
+ const declaration = path.node.declaration;
211
+ if (isWrappable(declaration)) {
212
+ path.get("declaration").replace(b.callExpression(b.identifier(wrapperName), [declaration]));
213
+ wrapped = true;
214
+ }
215
+ return false;
216
+ },
217
+ visitAssignmentExpression(path) {
218
+ const { left, right } = path.node;
219
+ if (n.MemberExpression.check(left) && recast.print(left).code === "module.exports" && isWrappable(right)) {
220
+ path.get("right").replace(b.callExpression(b.identifier(wrapperName), [right]));
221
+ wrapped = true;
222
+ }
223
+ return false;
224
+ }
225
+ });
226
+ if (!wrapped) return content;
227
+ injectImport(ast, isCJSFile, wrapperName, "react-native-intlayer/metro");
228
+ return recast.print(ast).code;
229
+ };
230
+ /**
231
+ * Builds the contents of a fresh `metro.config.js` wired with the Intlayer
232
+ * Metro plugin. Uses the async `configMetroIntlayer` helper (which can build
233
+ * dictionaries on server start) and picks the default-config source based on
234
+ * whether the project is an Expo app.
235
+ */
236
+ const getMetroConfigTemplate = (isExpo) => {
237
+ return `const { getDefaultConfig } = require("${isExpo ? "expo/metro-config" : "@react-native/metro-config"}");
238
+ const { configMetroIntlayer } = require("react-native-intlayer/metro");
239
+
240
+ module.exports = (async () => {
241
+ const defaultConfig = getDefaultConfig(__dirname);
242
+
243
+ return await configMetroIntlayer(defaultConfig);
244
+ })();
245
+ `;
246
+ };
183
247
  const updateNuxtConfig = (content) => {
184
248
  const ast = recast.parse(content, { parser: require("recast/parsers/typescript") });
185
249
  const updateConfigObject = (objExpr) => {
@@ -396,9 +460,11 @@ const updateIntlayerConfigWithSyncPlugin = (content, extension, syncConfig) => {
396
460
 
397
461
  //#endregion
398
462
  exports.enableIntlayerEditorConfig = enableIntlayerEditorConfig;
463
+ exports.getMetroConfigTemplate = getMetroConfigTemplate;
399
464
  exports.setIntlayerConfigRoutingMode = setIntlayerConfigRoutingMode;
400
465
  exports.updateAstroConfig = updateAstroConfig;
401
466
  exports.updateIntlayerConfigWithSyncPlugin = updateIntlayerConfigWithSyncPlugin;
467
+ exports.updateMetroConfig = updateMetroConfig;
402
468
  exports.updateNextConfig = updateNextConfig;
403
469
  exports.updateNextConfigForNextI18next = updateNextConfigForNextI18next;
404
470
  exports.updateNextConfigForNextIntl = updateNextConfigForNextIntl;
@@ -1 +1 @@
1
- {"version":3,"file":"configManipulation.cjs","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types/config';\nimport * as recast from 'recast';\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: require('recast/parsers/typescript'),\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 * 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: require('recast/parsers/typescript'),\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\nconst injectImport = (\n ast: any,\n isCJS: boolean,\n importName: string,\n source: string\n) => {\n const body = ast.program.body;\n const hasImport = body.some((stmt: any) => {\n if (isCJS) {\n return (\n n.VariableDeclaration.check(stmt) &&\n stmt.declarations.some(\n (decl: any) =>\n n.VariableDeclarator.check(decl) &&\n n.CallExpression.check(decl.init) &&\n n.Identifier.check(decl.init.callee) &&\n decl.init.callee.name === 'require' &&\n n.StringLiteral.check(decl.init.arguments[0]) &&\n decl.init.arguments[0].value === source\n )\n );\n }\n return (\n n.ImportDeclaration.check(stmt) &&\n (stmt.source.value === source ||\n stmt.specifiers?.some(\n (spec: any) =>\n (n.ImportSpecifier.check(spec) &&\n spec.imported.name === importName) ||\n (n.ImportDefaultSpecifier.check(spec) &&\n spec.local?.name === importName)\n ))\n );\n });\n\n if (hasImport) return;\n\n const declaration = isCJS\n ? b.variableDeclaration('const', [\n b.variableDeclarator(\n b.identifier(`{ ${importName} }`),\n b.callExpression(b.identifier('require'), [b.stringLiteral(source)])\n ),\n ])\n : b.importDeclaration(\n [b.importSpecifier(b.identifier(importName))],\n b.stringLiteral(source)\n );\n\n ast.program.body.unshift(declaration);\n};\n\nconst updatePluginArray = (\n objExpr: any,\n propertyName: string,\n pluginName: string\n) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' && !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let prop = objExpr.properties.find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === propertyName;\n }) as any;\n\n if (!prop) {\n prop = b.property(\n 'init',\n b.identifier(propertyName),\n b.arrayExpression([])\n );\n objExpr.properties.push(prop);\n }\n\n const arrayValue = prop.value;\n\n if (\n arrayValue &&\n (arrayValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(arrayValue))\n ) {\n const hasPlugin = arrayValue.elements.some((el: any) => {\n const callee = el?.callee;\n if (!callee) return false;\n const name = callee.name || callee.id?.name;\n return name === pluginName || name === 'il';\n });\n\n if (!hasPlugin) {\n arrayValue.elements.push(b.callExpression(b.identifier(pluginName), []));\n }\n }\n};\n\nconst genericRecastVisit = (\n ast: any,\n updateConfigObject: (obj: any) => void,\n callNames: string[] = ['defineConfig']\n) => {\n /**\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\nexport const updateViteConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(ast, isCJSFile, 'intlayer', 'vite-intlayer');\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'plugins', 'intlayer')\n );\n\n return recast.print(ast).code;\n};\n\nexport const updateAstroConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(ast, isCJSFile, 'intlayer', 'astro-intlayer');\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'integrations', 'intlayer')\n );\n\n return recast.print(ast).code;\n};\n\nexport const updateNextConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n injectImport(ast, isCJSFile, 'withIntlayer', 'next-intlayer/server');\n\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (\n n.Expression.check(declaration) &&\n !(\n n.CallExpression.check(declaration) &&\n n.Identifier.check(declaration.callee) &&\n declaration.callee.name === 'withIntlayer'\n )\n ) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier('withIntlayer'), [declaration as any])\n );\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports' &&\n !(\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n right.callee.name === 'withIntlayer'\n )\n ) {\n path\n .get('right')\n .replace(b.callExpression(b.identifier('withIntlayer'), [right]));\n }\n return false;\n },\n });\n\n return recast.print(ast).code;\n};\n\nexport const updateNuxtConfig = (content: string): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const updateConfigObject = (objExpr: any) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let modulesProp = objExpr.properties.find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === 'modules';\n }) as any;\n\n if (!modulesProp) {\n modulesProp = b.property(\n 'init',\n b.identifier('modules'),\n b.arrayExpression([])\n );\n objExpr.properties.push(modulesProp);\n }\n\n const modulesValue = modulesProp.value;\n\n if (\n modulesValue &&\n (modulesValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(modulesValue))\n ) {\n const hasModule = modulesValue.elements.some((el: any) => {\n if (\n n.StringLiteral.check(el) ||\n el.type === 'StringLiteral' ||\n el.type === 'Literal'\n ) {\n return (el.value || el.extra?.rawValue) === 'nuxt-intlayer';\n }\n return false;\n });\n\n if (!hasModule) {\n modulesValue.elements.push(b.stringLiteral('nuxt-intlayer'));\n }\n }\n };\n\n genericRecastVisit(ast, updateConfigObject, ['defineNuxtConfig']);\n\n return recast.print(ast).code;\n};\n\n/**\n * Updates a Vite config for vue-i18n compat: injects `vueI18nVitePlugin` from\n * `@intlayer/vue-i18n/plugin` into the plugins array.\n */\nexport const updateViteConfigForVueI18n = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(\n ast,\n isCJSFile,\n 'vueI18nVitePlugin',\n '@intlayer/vue-i18n/plugin'\n );\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'plugins', 'vueI18nVitePlugin')\n );\n\n return recast.print(ast).code;\n};\n\n/**\n * Generic vite config updater for any compat plugin that uses alias injection.\n * Injects the named import from `pluginPackageSource` and appends the plugin\n * call to the `plugins` array.\n */\nexport const updateViteConfigForCompatPlugin = (\n content: string,\n extension: string,\n pluginConfig: CompatVitePluginConfig\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(\n ast,\n isCJSFile,\n pluginConfig.pluginFunctionName,\n pluginConfig.pluginPackageSource\n );\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'plugins', pluginConfig.pluginFunctionName)\n );\n\n return recast.print(ast).code;\n};\n\n/**\n * Generic Next.js config wrapper for compat plugins. Injects the import and\n * wraps the default export / `module.exports` with a HOC call.\n */\nconst wrapNextConfigWithHoc = (\n content: string,\n extension: string,\n hocFunctionName: string,\n pluginPackageSource: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n injectImport(ast, isCJSFile, hocFunctionName, pluginPackageSource);\n\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (\n n.Expression.check(declaration) &&\n !(\n n.CallExpression.check(declaration) &&\n n.Identifier.check(declaration.callee) &&\n declaration.callee.name === hocFunctionName\n )\n ) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier(hocFunctionName), [\n declaration as any,\n ])\n );\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports' &&\n !(\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n right.callee.name === hocFunctionName\n )\n ) {\n path\n .get('right')\n .replace(b.callExpression(b.identifier(hocFunctionName), [right]));\n }\n return false;\n },\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * Updates a Next.js config for next-translate compat: wraps the default export\n * with `withNextTranslate` from `@intlayer/next-translate/plugin`.\n */\nexport const updateNextConfigForNextTranslate = (\n content: string,\n extension: string\n): string =>\n wrapNextConfigWithHoc(\n content,\n extension,\n 'withNextTranslate',\n '@intlayer/next-translate/plugin'\n );\n\n/**\n * Updates a Nuxt config for nuxtjs-i18n compat: adds `@intlayer/nuxtjs-i18n`\n * to the `modules` array.\n */\nexport const updateNuxtConfigForNuxtjsI18n = (content: string): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const updateConfigObject = (objExpr: any) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let modulesProp = (objExpr.properties as any[]).find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === 'modules';\n }) as any;\n\n if (!modulesProp) {\n modulesProp = b.property(\n 'init',\n b.identifier('modules'),\n b.arrayExpression([])\n );\n (objExpr.properties as any[]).push(modulesProp);\n }\n\n const modulesValue = modulesProp.value;\n\n if (\n modulesValue &&\n (modulesValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(modulesValue))\n ) {\n const hasModule = (modulesValue.elements as any[]).some((el: any) => {\n if (\n n.StringLiteral.check(el) ||\n el.type === 'StringLiteral' ||\n el.type === 'Literal'\n ) {\n return (el.value ?? el.extra?.rawValue) === '@intlayer/nuxtjs-i18n';\n }\n return false;\n });\n\n if (!hasModule) {\n (modulesValue.elements as any[]).push(\n b.stringLiteral('@intlayer/nuxtjs-i18n')\n );\n }\n }\n };\n\n genericRecastVisit(ast, updateConfigObject, ['defineNuxtConfig']);\n\n return recast.print(ast).code;\n};\n\n/**\n * Updates a Next.js config for next-i18next compat: wraps the default export\n * with `withI18next` from `@intlayer/next-i18next/plugin`.\n */\nexport const updateNextConfigForNextI18next = (\n content: string,\n extension: string\n): string =>\n wrapNextConfigWithHoc(\n content,\n extension,\n 'withI18next',\n '@intlayer/next-i18next/plugin'\n );\n\n/**\n * Updates a Next.js config for next-intl compat: replaces any existing\n * `next-intl/plugin` import source with `@intlayer/next-intl/plugin`, or\n * injects `createNextIntlPlugin` with a factory-call wrapper when no such\n * import is present.\n */\nexport const updateNextConfigForNextIntl = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n let replacedExistingSource = false;\n\n // Replace 'next-intl/plugin' import source with the compat package.\n recast.visit(ast, {\n visitImportDeclaration(path) {\n if (path.node.source.value === 'next-intl/plugin') {\n path.node.source = b.stringLiteral('@intlayer/next-intl/plugin');\n replacedExistingSource = true;\n }\n return false;\n },\n });\n\n if (replacedExistingSource) {\n return recast.print(ast).code;\n }\n\n // No existing next-intl/plugin import: check whether createNextIntlPlugin is\n // already present from any source before injecting the full factory pattern.\n const hasCreatePlugin = (ast.program.body as any[]).some((stmt: any) => {\n if (!n.ImportDeclaration.check(stmt)) return false;\n return (stmt.specifiers ?? []).some(\n (spec: any) =>\n (n.ImportSpecifier.check(spec) &&\n spec.imported.name === 'createNextIntlPlugin') ||\n (n.ImportDefaultSpecifier.check(spec) &&\n spec.local?.name === 'createNextIntlPlugin')\n );\n });\n\n if (hasCreatePlugin) {\n return recast.print(ast).code;\n }\n\n // Inject the import.\n injectImport(\n ast,\n isCJSFile,\n 'createNextIntlPlugin',\n '@intlayer/next-intl/plugin'\n );\n\n // Insert a factory-call variable declaration after the last import.\n const lastImportIndex = (ast.program.body as any[]).reduce(\n (lastIndex: number, stmt: any, index: number) => {\n if (n.ImportDeclaration.check(stmt)) return index;\n return lastIndex;\n },\n -1\n );\n\n const factoryCallDeclaration = b.variableDeclaration('const', [\n b.variableDeclarator(\n b.identifier('_withNextIntlayer'),\n b.callExpression(b.identifier('createNextIntlPlugin'), [])\n ),\n ]);\n\n (ast.program.body as any[]).splice(\n lastImportIndex + 1,\n 0,\n factoryCallDeclaration\n );\n\n // Wrap the default export with _withNextIntlayer(...).\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (\n n.Expression.check(declaration) &&\n !(\n n.CallExpression.check(declaration) &&\n n.Identifier.check(declaration.callee) &&\n declaration.callee.name === '_withNextIntlayer'\n )\n ) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier('_withNextIntlayer'), [\n declaration as any,\n ])\n );\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports' &&\n !(\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n right.callee.name === '_withNextIntlayer'\n )\n ) {\n path\n .get('right')\n .replace(\n b.callExpression(b.identifier('_withNextIntlayer'), [right])\n );\n }\n return false;\n },\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * Parses a syncJSON({ ... }) call expression from a source snippet so it can\n * be injected into a config AST without manually constructing template-literal\n * nodes via builders.\n *\n * The destructuring parameters adapt to whether the source template uses the\n * `key` placeholder (nested pattern) or only `locale` (flat pattern).\n */\nconst buildSyncJSONCallNode = (syncConfig: CompatSyncConfig): any => {\n const usesKey = syncConfig.sourceTemplate.includes('${key}');\n const paramDestructuring =\n syncConfig.format === 'icu'\n ? usesKey\n ? '{ key, locale }'\n : '{ locale }'\n : usesKey\n ? '{ locale, key }'\n : '{ locale }';\n\n // `splitKeys` is written explicitly only when forced on (next-intl / use-intl\n // single-file namespace model). When omitted, syncJSON auto-detects it from\n // the presence of a `${key}` segment in the source.\n const splitKeysProperty = syncConfig.splitKeys ? ', splitKeys: true' : '';\n\n // The sourceTemplate contains ${locale} / ${key} as literal characters;\n // they become proper template expressions once the snippet is parsed by recast.\n const snippet = `syncJSON({ format: '${syncConfig.format}', source: (${paramDestructuring}) => \\`${syncConfig.sourceTemplate}\\`${splitKeysProperty} })`;\n const snippetAst = recast.parse(snippet, {\n parser: require('recast/parsers/typescript'),\n });\n return (snippetAst.program.body[0] as any).expression;\n};\n\n/**\n * Injects or ensures `dictionary: { format: '<value>' }` exists in an object\n * expression. Leaves any pre-existing `dictionary` properties untouched —\n * only the `format` sub-property is added when absent.\n */\nconst injectDictionaryFormat = (objExpr: any, format: string): void => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' && !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let dictionaryProp = (objExpr.properties as any[]).find((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === 'dictionary';\n });\n\n if (!dictionaryProp) {\n dictionaryProp = b.property(\n 'init',\n b.identifier('dictionary'),\n b.objectExpression([])\n );\n (objExpr.properties as any[]).push(dictionaryProp);\n }\n\n const dictionaryObj = dictionaryProp.value;\n if (\n !dictionaryObj ||\n (dictionaryObj.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(dictionaryObj))\n )\n return;\n\n const hasFormat = (dictionaryObj.properties as any[]).some((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === 'format';\n });\n\n if (!hasFormat) {\n (dictionaryObj.properties as any[]).push(\n b.property('init', b.identifier('format'), b.stringLiteral(format))\n );\n }\n};\n\n/**\n * Injects the syncJSON import and a configured syncJSON(...) call into the\n * plugins array of an intlayer config file. Idempotent: skips when\n * @intlayer/sync-json-plugin is already imported.\n */\nexport const updateIntlayerConfigWithSyncPlugin = (\n content: string,\n extension: string,\n syncConfig: CompatSyncConfig\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n injectImport(ast, isCJSFile, 'syncJSON', '@intlayer/sync-json-plugin');\n\n const callNode = buildSyncJSONCallNode(syncConfig);\n\n genericRecastVisit(ast, (objExpr) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(objExpr))\n )\n return;\n\n // Inject dictionary.format alongside the plugin so intlayer knows how to\n // interpret dictionary content at runtime.\n injectDictionaryFormat(objExpr, syncConfig.format);\n\n let pluginsProp = (objExpr.properties as any[]).find((prop: any) => {\n if (!prop?.key) return false;\n const keyName = prop.key.name ?? prop.key.value;\n return keyName === 'plugins';\n });\n\n if (!pluginsProp) {\n pluginsProp = b.property(\n 'init',\n b.identifier('plugins'),\n b.arrayExpression([])\n );\n (objExpr.properties as any[]).push(pluginsProp);\n }\n\n const arrayValue = pluginsProp.value;\n\n if (\n arrayValue &&\n (arrayValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(arrayValue))\n ) {\n const hasSyncJSON = (arrayValue.elements as any[]).some(\n (element: any) => {\n const callee = element?.callee;\n if (!callee) return false;\n const name: string = callee.name ?? callee.id?.name;\n return name === 'syncJSON';\n }\n );\n\n if (!hasSyncJSON) {\n (arrayValue.elements as any[]).push(callNode);\n }\n }\n });\n\n return recast.print(ast).code;\n};\n"],"mappings":";;;;;;AAOA,MAAM,EAAE,UAAU,GAAG,YAAY,MAAM,OAAO;;AAM9C,MAAM,sBAAsB,SAC1B,QAAQ,KAAK,KACZ,KAAK,SAAS,sBAAsB,EAAE,iBAAiB,MAAM,KAAK;;;;;;AAOrE,MAAM,wBACJ,SACA,KACA,qBACQ;CACR,IAAI,WAAY,QAAQ,WAAqB,MAAM,SAAc;AAC/D,MAAI,CAAC,MAAM,IAAK,QAAO;AACvB,UAAQ,KAAK,IAA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YADqB,OAAO,QAAQ,OAAO,IAAI,UAC/B;KAIJ,CACd,CAAC,WAAW,SAAmB,KAAK,SAAS;;GAGjD;AAEF,QAAO,OAAO,MAAM,IAAI,CAAC"}
1
+ {"version":3,"file":"configManipulation.cjs","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types/config';\nimport * as recast from 'recast';\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: require('recast/parsers/typescript'),\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 * 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: require('recast/parsers/typescript'),\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\nconst injectImport = (\n ast: any,\n isCJS: boolean,\n importName: string,\n source: string\n) => {\n const body = ast.program.body;\n const hasImport = body.some((stmt: any) => {\n if (isCJS) {\n return (\n n.VariableDeclaration.check(stmt) &&\n stmt.declarations.some(\n (decl: any) =>\n n.VariableDeclarator.check(decl) &&\n n.CallExpression.check(decl.init) &&\n n.Identifier.check(decl.init.callee) &&\n decl.init.callee.name === 'require' &&\n n.StringLiteral.check(decl.init.arguments[0]) &&\n decl.init.arguments[0].value === source\n )\n );\n }\n return (\n n.ImportDeclaration.check(stmt) &&\n (stmt.source.value === source ||\n stmt.specifiers?.some(\n (spec: any) =>\n (n.ImportSpecifier.check(spec) &&\n spec.imported.name === importName) ||\n (n.ImportDefaultSpecifier.check(spec) &&\n spec.local?.name === importName)\n ))\n );\n });\n\n if (hasImport) return;\n\n const declaration = isCJS\n ? b.variableDeclaration('const', [\n b.variableDeclarator(\n b.identifier(`{ ${importName} }`),\n b.callExpression(b.identifier('require'), [b.stringLiteral(source)])\n ),\n ])\n : b.importDeclaration(\n [b.importSpecifier(b.identifier(importName))],\n b.stringLiteral(source)\n );\n\n ast.program.body.unshift(declaration);\n};\n\nconst updatePluginArray = (\n objExpr: any,\n propertyName: string,\n pluginName: string\n) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' && !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let prop = objExpr.properties.find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === propertyName;\n }) as any;\n\n if (!prop) {\n prop = b.property(\n 'init',\n b.identifier(propertyName),\n b.arrayExpression([])\n );\n objExpr.properties.push(prop);\n }\n\n const arrayValue = prop.value;\n\n if (\n arrayValue &&\n (arrayValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(arrayValue))\n ) {\n const hasPlugin = arrayValue.elements.some((el: any) => {\n const callee = el?.callee;\n if (!callee) return false;\n const name = callee.name || callee.id?.name;\n return name === pluginName || name === 'il';\n });\n\n if (!hasPlugin) {\n arrayValue.elements.push(b.callExpression(b.identifier(pluginName), []));\n }\n }\n};\n\nconst genericRecastVisit = (\n ast: any,\n updateConfigObject: (obj: any) => void,\n callNames: string[] = ['defineConfig']\n) => {\n /**\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\nexport const updateViteConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(ast, isCJSFile, 'intlayer', 'vite-intlayer');\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'plugins', 'intlayer')\n );\n\n return recast.print(ast).code;\n};\n\nexport const updateAstroConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(ast, isCJSFile, 'intlayer', 'astro-intlayer');\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'integrations', 'intlayer')\n );\n\n return recast.print(ast).code;\n};\n\nexport const updateNextConfig = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n injectImport(ast, isCJSFile, 'withIntlayer', 'next-intlayer/server');\n\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (\n n.Expression.check(declaration) &&\n !(\n n.CallExpression.check(declaration) &&\n n.Identifier.check(declaration.callee) &&\n declaration.callee.name === 'withIntlayer'\n )\n ) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier('withIntlayer'), [declaration as any])\n );\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports' &&\n !(\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n right.callee.name === 'withIntlayer'\n )\n ) {\n path\n .get('right')\n .replace(b.callExpression(b.identifier('withIntlayer'), [right]));\n }\n return false;\n },\n });\n\n return recast.print(ast).code;\n};\n\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: require('recast/parsers/typescript'),\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: require('recast/parsers/typescript'),\n });\n\n const updateConfigObject = (objExpr: any) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let modulesProp = objExpr.properties.find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === 'modules';\n }) as any;\n\n if (!modulesProp) {\n modulesProp = b.property(\n 'init',\n b.identifier('modules'),\n b.arrayExpression([])\n );\n objExpr.properties.push(modulesProp);\n }\n\n const modulesValue = modulesProp.value;\n\n if (\n modulesValue &&\n (modulesValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(modulesValue))\n ) {\n const hasModule = modulesValue.elements.some((el: any) => {\n if (\n n.StringLiteral.check(el) ||\n el.type === 'StringLiteral' ||\n el.type === 'Literal'\n ) {\n return (el.value || el.extra?.rawValue) === 'nuxt-intlayer';\n }\n return false;\n });\n\n if (!hasModule) {\n modulesValue.elements.push(b.stringLiteral('nuxt-intlayer'));\n }\n }\n };\n\n genericRecastVisit(ast, updateConfigObject, ['defineNuxtConfig']);\n\n return recast.print(ast).code;\n};\n\n/**\n * Updates a Vite config for vue-i18n compat: injects `vueI18nVitePlugin` from\n * `@intlayer/vue-i18n/plugin` into the plugins array.\n */\nexport const updateViteConfigForVueI18n = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(\n ast,\n isCJSFile,\n 'vueI18nVitePlugin',\n '@intlayer/vue-i18n/plugin'\n );\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'plugins', 'vueI18nVitePlugin')\n );\n\n return recast.print(ast).code;\n};\n\n/**\n * Generic vite config updater for any compat plugin that uses alias injection.\n * Injects the named import from `pluginPackageSource` and appends the plugin\n * call to the `plugins` array.\n */\nexport const updateViteConfigForCompatPlugin = (\n content: string,\n extension: string,\n pluginConfig: CompatVitePluginConfig\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile =\n extension === 'cjs' ||\n (content.includes('module.exports') && !content.includes('import '));\n\n injectImport(\n ast,\n isCJSFile,\n pluginConfig.pluginFunctionName,\n pluginConfig.pluginPackageSource\n );\n\n genericRecastVisit(ast, (obj) =>\n updatePluginArray(obj, 'plugins', pluginConfig.pluginFunctionName)\n );\n\n return recast.print(ast).code;\n};\n\n/**\n * Generic Next.js config wrapper for compat plugins. Injects the import and\n * wraps the default export / `module.exports` with a HOC call.\n */\nconst wrapNextConfigWithHoc = (\n content: string,\n extension: string,\n hocFunctionName: string,\n pluginPackageSource: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n injectImport(ast, isCJSFile, hocFunctionName, pluginPackageSource);\n\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (\n n.Expression.check(declaration) &&\n !(\n n.CallExpression.check(declaration) &&\n n.Identifier.check(declaration.callee) &&\n declaration.callee.name === hocFunctionName\n )\n ) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier(hocFunctionName), [\n declaration as any,\n ])\n );\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports' &&\n !(\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n right.callee.name === hocFunctionName\n )\n ) {\n path\n .get('right')\n .replace(b.callExpression(b.identifier(hocFunctionName), [right]));\n }\n return false;\n },\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * Updates a Next.js config for next-translate compat: wraps the default export\n * with `withNextTranslate` from `@intlayer/next-translate/plugin`.\n */\nexport const updateNextConfigForNextTranslate = (\n content: string,\n extension: string\n): string =>\n wrapNextConfigWithHoc(\n content,\n extension,\n 'withNextTranslate',\n '@intlayer/next-translate/plugin'\n );\n\n/**\n * Updates a Nuxt config for nuxtjs-i18n compat: adds `@intlayer/nuxtjs-i18n`\n * to the `modules` array.\n */\nexport const updateNuxtConfigForNuxtjsI18n = (content: string): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const updateConfigObject = (objExpr: any) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let modulesProp = (objExpr.properties as any[]).find((p: any) => {\n if (!p?.key) return false;\n const keyName = p.key.name || p.key.value;\n return keyName === 'modules';\n }) as any;\n\n if (!modulesProp) {\n modulesProp = b.property(\n 'init',\n b.identifier('modules'),\n b.arrayExpression([])\n );\n (objExpr.properties as any[]).push(modulesProp);\n }\n\n const modulesValue = modulesProp.value;\n\n if (\n modulesValue &&\n (modulesValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(modulesValue))\n ) {\n const hasModule = (modulesValue.elements as any[]).some((el: any) => {\n if (\n n.StringLiteral.check(el) ||\n el.type === 'StringLiteral' ||\n el.type === 'Literal'\n ) {\n return (el.value ?? el.extra?.rawValue) === '@intlayer/nuxtjs-i18n';\n }\n return false;\n });\n\n if (!hasModule) {\n (modulesValue.elements as any[]).push(\n b.stringLiteral('@intlayer/nuxtjs-i18n')\n );\n }\n }\n };\n\n genericRecastVisit(ast, updateConfigObject, ['defineNuxtConfig']);\n\n return recast.print(ast).code;\n};\n\n/**\n * Updates a Next.js config for next-i18next compat: wraps the default export\n * with `withI18next` from `@intlayer/next-i18next/plugin`.\n */\nexport const updateNextConfigForNextI18next = (\n content: string,\n extension: string\n): string =>\n wrapNextConfigWithHoc(\n content,\n extension,\n 'withI18next',\n '@intlayer/next-i18next/plugin'\n );\n\n/**\n * Updates a Next.js config for next-intl compat: replaces any existing\n * `next-intl/plugin` import source with `@intlayer/next-intl/plugin`, or\n * injects `createNextIntlPlugin` with a factory-call wrapper when no such\n * import is present.\n */\nexport const updateNextConfigForNextIntl = (\n content: string,\n extension: string\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n let replacedExistingSource = false;\n\n // Replace 'next-intl/plugin' import source with the compat package.\n recast.visit(ast, {\n visitImportDeclaration(path) {\n if (path.node.source.value === 'next-intl/plugin') {\n path.node.source = b.stringLiteral('@intlayer/next-intl/plugin');\n replacedExistingSource = true;\n }\n return false;\n },\n });\n\n if (replacedExistingSource) {\n return recast.print(ast).code;\n }\n\n // No existing next-intl/plugin import: check whether createNextIntlPlugin is\n // already present from any source before injecting the full factory pattern.\n const hasCreatePlugin = (ast.program.body as any[]).some((stmt: any) => {\n if (!n.ImportDeclaration.check(stmt)) return false;\n return (stmt.specifiers ?? []).some(\n (spec: any) =>\n (n.ImportSpecifier.check(spec) &&\n spec.imported.name === 'createNextIntlPlugin') ||\n (n.ImportDefaultSpecifier.check(spec) &&\n spec.local?.name === 'createNextIntlPlugin')\n );\n });\n\n if (hasCreatePlugin) {\n return recast.print(ast).code;\n }\n\n // Inject the import.\n injectImport(\n ast,\n isCJSFile,\n 'createNextIntlPlugin',\n '@intlayer/next-intl/plugin'\n );\n\n // Insert a factory-call variable declaration after the last import.\n const lastImportIndex = (ast.program.body as any[]).reduce(\n (lastIndex: number, stmt: any, index: number) => {\n if (n.ImportDeclaration.check(stmt)) return index;\n return lastIndex;\n },\n -1\n );\n\n const factoryCallDeclaration = b.variableDeclaration('const', [\n b.variableDeclarator(\n b.identifier('_withNextIntlayer'),\n b.callExpression(b.identifier('createNextIntlPlugin'), [])\n ),\n ]);\n\n (ast.program.body as any[]).splice(\n lastImportIndex + 1,\n 0,\n factoryCallDeclaration\n );\n\n // Wrap the default export with _withNextIntlayer(...).\n recast.visit(ast, {\n visitExportDefaultDeclaration(path) {\n const declaration = path.node.declaration;\n if (\n n.Expression.check(declaration) &&\n !(\n n.CallExpression.check(declaration) &&\n n.Identifier.check(declaration.callee) &&\n declaration.callee.name === '_withNextIntlayer'\n )\n ) {\n path\n .get('declaration')\n .replace(\n b.callExpression(b.identifier('_withNextIntlayer'), [\n declaration as any,\n ])\n );\n }\n return false;\n },\n visitAssignmentExpression(path) {\n const { left, right } = path.node;\n\n if (\n n.MemberExpression.check(left) &&\n recast.print(left).code === 'module.exports' &&\n !(\n n.CallExpression.check(right) &&\n n.Identifier.check(right.callee) &&\n right.callee.name === '_withNextIntlayer'\n )\n ) {\n path\n .get('right')\n .replace(\n b.callExpression(b.identifier('_withNextIntlayer'), [right])\n );\n }\n return false;\n },\n });\n\n return recast.print(ast).code;\n};\n\n/**\n * Parses a syncJSON({ ... }) call expression from a source snippet so it can\n * be injected into a config AST without manually constructing template-literal\n * nodes via builders.\n *\n * The destructuring parameters adapt to whether the source template uses the\n * `key` placeholder (nested pattern) or only `locale` (flat pattern).\n */\nconst buildSyncJSONCallNode = (syncConfig: CompatSyncConfig): any => {\n const usesKey = syncConfig.sourceTemplate.includes('${key}');\n const paramDestructuring =\n syncConfig.format === 'icu'\n ? usesKey\n ? '{ key, locale }'\n : '{ locale }'\n : usesKey\n ? '{ locale, key }'\n : '{ locale }';\n\n // `splitKeys` is written explicitly only when forced on (next-intl / use-intl\n // single-file namespace model). When omitted, syncJSON auto-detects it from\n // the presence of a `${key}` segment in the source.\n const splitKeysProperty = syncConfig.splitKeys ? ', splitKeys: true' : '';\n\n // The sourceTemplate contains ${locale} / ${key} as literal characters;\n // they become proper template expressions once the snippet is parsed by recast.\n const snippet = `syncJSON({ format: '${syncConfig.format}', source: (${paramDestructuring}) => \\`${syncConfig.sourceTemplate}\\`${splitKeysProperty} })`;\n const snippetAst = recast.parse(snippet, {\n parser: require('recast/parsers/typescript'),\n });\n return (snippetAst.program.body[0] as any).expression;\n};\n\n/**\n * Injects or ensures `dictionary: { format: '<value>' }` exists in an object\n * expression. Leaves any pre-existing `dictionary` properties untouched —\n * only the `format` sub-property is added when absent.\n */\nconst injectDictionaryFormat = (objExpr: any, format: string): void => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' && !n.ObjectExpression.check(objExpr))\n )\n return;\n\n let dictionaryProp = (objExpr.properties as any[]).find((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === 'dictionary';\n });\n\n if (!dictionaryProp) {\n dictionaryProp = b.property(\n 'init',\n b.identifier('dictionary'),\n b.objectExpression([])\n );\n (objExpr.properties as any[]).push(dictionaryProp);\n }\n\n const dictionaryObj = dictionaryProp.value;\n if (\n !dictionaryObj ||\n (dictionaryObj.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(dictionaryObj))\n )\n return;\n\n const hasFormat = (dictionaryObj.properties as any[]).some((prop: any) => {\n if (!prop?.key) return false;\n return (prop.key.name ?? prop.key.value) === 'format';\n });\n\n if (!hasFormat) {\n (dictionaryObj.properties as any[]).push(\n b.property('init', b.identifier('format'), b.stringLiteral(format))\n );\n }\n};\n\n/**\n * Injects the syncJSON import and a configured syncJSON(...) call into the\n * plugins array of an intlayer config file. Idempotent: skips when\n * @intlayer/sync-json-plugin is already imported.\n */\nexport const updateIntlayerConfigWithSyncPlugin = (\n content: string,\n extension: string,\n syncConfig: CompatSyncConfig\n): string => {\n const ast = recast.parse(content, {\n parser: require('recast/parsers/typescript'),\n });\n\n const isCJSFile = extension === 'cjs' || content.includes('module.exports');\n\n injectImport(ast, isCJSFile, 'syncJSON', '@intlayer/sync-json-plugin');\n\n const callNode = buildSyncJSONCallNode(syncConfig);\n\n genericRecastVisit(ast, (objExpr) => {\n if (\n !objExpr ||\n (objExpr.type !== 'ObjectExpression' &&\n !n.ObjectExpression.check(objExpr))\n )\n return;\n\n // Inject dictionary.format alongside the plugin so intlayer knows how to\n // interpret dictionary content at runtime.\n injectDictionaryFormat(objExpr, syncConfig.format);\n\n let pluginsProp = (objExpr.properties as any[]).find((prop: any) => {\n if (!prop?.key) return false;\n const keyName = prop.key.name ?? prop.key.value;\n return keyName === 'plugins';\n });\n\n if (!pluginsProp) {\n pluginsProp = b.property(\n 'init',\n b.identifier('plugins'),\n b.arrayExpression([])\n );\n (objExpr.properties as any[]).push(pluginsProp);\n }\n\n const arrayValue = pluginsProp.value;\n\n if (\n arrayValue &&\n (arrayValue.type === 'ArrayExpression' ||\n n.ArrayExpression.check(arrayValue))\n ) {\n const hasSyncJSON = (arrayValue.elements as any[]).some(\n (element: any) => {\n const callee = element?.callee;\n if (!callee) return false;\n const name: string = callee.name ?? callee.id?.name;\n return name === 'syncJSON';\n }\n );\n\n if (!hasSyncJSON) {\n (arrayValue.elements as any[]).push(callNode);\n }\n }\n });\n\n return recast.print(ast).code;\n};\n"],"mappings":";;;;;;AAOA,MAAM,EAAE,UAAU,GAAG,YAAY,MAAM,OAAO;;AAM9C,MAAM,sBAAsB,SAC1B,QAAQ,KAAK,KACZ,KAAK,SAAS,sBAAsB,EAAE,iBAAiB,MAAM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B;AACD,GAAC,QAAQ,WAAqB,KAAK,YAAY;;EAGjD,MAAM,aAAa,YAAY;AAE/B,MACE,eACC,WAAW,SAAS,qBACnB,EAAE,gBAAgB,MAAM,WAAW,GAWrC;OAAI,CATiB,WAAW,SAAmB,MAChD,YAAiB;IAChB,MAAM,SAAS,SAAS;AACxB,QAAI,CAAC,OAAQ,QAAO;AAEpB,YADqB,OAAO,QAAQ,OAAO,IAAI,UAC/B;KAIJ,CACd,CAAC,WAAW,SAAmB,KAAK,SAAS;;GAGjD;AAEF,QAAO,OAAO,MAAM,IAAI,CAAC"}
@@ -21,6 +21,7 @@ exports.exists = require_init_utils_fileSystem.exists;
21
21
  exports.findTsConfigFiles = require_init_utils_tsConfig.findTsConfigFiles;
22
22
  exports.getGithubWorkflows = require_init_utils_githubActions.getGithubWorkflows;
23
23
  exports.getInstalledPackageVersion = require_init_utils_packageManager.getInstalledPackageVersion;
24
+ exports.getMetroConfigTemplate = require_init_utils_configManipulation.getMetroConfigTemplate;
24
25
  exports.installPackages = require_init_utils_packageManager.installPackages;
25
26
  exports.isIntlayerPackageName = require_init_utils_packageManager.isIntlayerPackageName;
26
27
  exports.normalizeVersion = require_init_utils_packageManager.normalizeVersion;
@@ -30,6 +31,7 @@ exports.setIntlayerConfigRoutingMode = require_init_utils_configManipulation.set
30
31
  exports.setupNextCompilerBabelConfig = require_init_utils_nextCompilerBabel.setupNextCompilerBabelConfig;
31
32
  exports.updateAstroConfig = require_init_utils_configManipulation.updateAstroConfig;
32
33
  exports.updateIntlayerConfigWithSyncPlugin = require_init_utils_configManipulation.updateIntlayerConfigWithSyncPlugin;
34
+ exports.updateMetroConfig = require_init_utils_configManipulation.updateMetroConfig;
33
35
  exports.updateNextConfig = require_init_utils_configManipulation.updateNextConfig;
34
36
  exports.updateNextConfigForNextI18next = require_init_utils_configManipulation.updateNextConfigForNextI18next;
35
37
  exports.updateNextConfigForNextIntl = require_init_utils_configManipulation.updateNextConfigForNextIntl;