@intlayer/engine 9.5.11 → 9.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/installSkills/skills/bundle-optimization.md +123 -0
- package/dist/assets/installSkills/skills/compat.md +0 -4
- package/dist/assets/installSkills/skills/content.md +8 -2
- package/dist/assets/installSkills/skills/next-js.md +2 -2
- package/dist/assets/installSkills/skills/usage.md +1 -1
- package/dist/cjs/build.cjs +5 -0
- package/dist/cjs/cli.cjs +1 -0
- package/dist/cjs/init/index.cjs +2 -12
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/init/utils/backendPackages.cjs +15 -0
- package/dist/cjs/init/utils/backendPackages.cjs.map +1 -0
- package/dist/cjs/init/utils/index.cjs +2 -3
- package/dist/cjs/installSkills/index.cjs +2 -0
- package/dist/cjs/installSkills/index.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +9 -8
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +3 -5
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/remoteDictionaryClient.cjs +18 -0
- package/dist/cjs/loadDictionaries/remoteDictionaryClient.cjs.map +1 -0
- package/dist/cjs/prepareIntlayerServer.cjs +132 -0
- package/dist/cjs/prepareIntlayerServer.cjs.map +1 -0
- package/dist/cjs/utils/getProcessChainCommands.cjs +117 -0
- package/dist/cjs/utils/getProcessChainCommands.cjs.map +1 -0
- package/dist/cjs/utils/index.cjs +2 -0
- package/dist/cjs/utils/startContentWatcher.cjs +99 -0
- package/dist/cjs/utils/startContentWatcher.cjs.map +1 -0
- package/dist/cjs/watcher.cjs +2 -2
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
- package/dist/esm/build.mjs +2 -1
- package/dist/esm/cli.mjs +2 -2
- package/dist/esm/init/index.mjs +1 -11
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/init/utils/backendPackages.mjs +14 -0
- package/dist/esm/init/utils/backendPackages.mjs.map +1 -0
- package/dist/esm/init/utils/index.mjs +2 -2
- package/dist/esm/installSkills/index.mjs +2 -0
- package/dist/esm/installSkills/index.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadDictionaries.mjs +9 -8
- package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs +2 -4
- package/dist/esm/loadDictionaries/loadRemoteDictionaries.mjs.map +1 -1
- package/dist/esm/loadDictionaries/remoteDictionaryClient.mjs +16 -0
- package/dist/esm/loadDictionaries/remoteDictionaryClient.mjs.map +1 -0
- package/dist/esm/prepareIntlayerServer.mjs +128 -0
- package/dist/esm/prepareIntlayerServer.mjs.map +1 -0
- package/dist/esm/utils/getProcessChainCommands.mjs +115 -0
- package/dist/esm/utils/getProcessChainCommands.mjs.map +1 -0
- package/dist/esm/utils/index.mjs +2 -1
- package/dist/esm/utils/startContentWatcher.mjs +98 -0
- package/dist/esm/utils/startContentWatcher.mjs.map +1 -0
- package/dist/esm/watcher.mjs +1 -1
- package/dist/esm/watcher.mjs.map +1 -1
- package/dist/esm/writeJsonIfChanged.mjs +1 -1
- package/dist/esm/writeJsonIfChanged.mjs.map +1 -1
- package/dist/types/build.d.ts +2 -1
- package/dist/types/cli.d.ts +2 -2
- package/dist/types/init/index.d.ts +1 -1
- package/dist/types/init/index.d.ts.map +1 -1
- package/dist/types/init/utils/backendPackages.d.ts +5 -0
- package/dist/types/init/utils/backendPackages.d.ts.map +1 -0
- package/dist/types/init/utils/index.d.ts +2 -2
- package/dist/types/installSkills/index.d.ts +1 -0
- package/dist/types/installSkills/index.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
- package/dist/types/loadDictionaries/remoteDictionaryClient.d.ts +14 -0
- package/dist/types/loadDictionaries/remoteDictionaryClient.d.ts.map +1 -0
- package/dist/types/prepareIntlayerServer.d.ts +67 -0
- package/dist/types/prepareIntlayerServer.d.ts.map +1 -0
- package/dist/types/utils/getProcessChainCommands.d.ts +35 -0
- package/dist/types/utils/getProcessChainCommands.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +2 -1
- package/dist/types/utils/startContentWatcher.d.ts +40 -0
- package/dist/types/utils/startContentWatcher.d.ts.map +1 -0
- package/dist/types/watcher.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/cjs/init/utils/devScript.cjs +0 -57
- package/dist/cjs/init/utils/devScript.cjs.map +0 -1
- package/dist/esm/init/utils/devScript.mjs +0 -55
- package/dist/esm/init/utils/devScript.mjs.map +0 -1
- package/dist/types/init/utils/devScript.d.ts +0 -48
- package/dist/types/init/utils/devScript.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/init/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { ROUTING_MODE } from '@intlayer/config/defaultValues';\nimport { colorize, colorizePath, logger, v, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { initConfig } from '../initConfig';\nimport {\n setCompilerOutputInConfig,\n setEnableProxyInConfig,\n setRoutingModeInConfig,\n setRoutingStorageOnlyInConfig,\n} from './cms';\nimport {\n DocumentationRouter,\n type DocumentationRouterType,\n getDocumentationUrl,\n} from './documentationRouter';\nimport { setupFramework } from './frameworkSetup';\nimport { upgradeIntlayerPackages } from './upgradeIntlayerPackages';\nimport type { CompatSyncConfig, RoutingMode } from './utils';\nimport {\n addIntlayerRulesToOxlintConfig,\n BACKEND_INTLAYER_PACKAGES,\n detectCompatI18nLibraries,\n detectJsonLocalePattern,\n detectLinguiCatalogPattern,\n detectMissingIntlayerPackages,\n detectNextIntlMessagesPattern,\n detectPackageManager,\n ensureDirectory,\n exists,\n findTsConfigFiles,\n getGithubWorkflows,\n getMetroConfigTemplate,\n hasIntlayerVitePlugin,\n hasLegacyEslint,\n hasLintTooling,\n hasUrlRoutingFramework,\n installPackages,\n isIntlayerPackageName,\n LINT_PLUGIN_PACKAGE_NAME,\n MINIMUM_ESLINT_MAJOR,\n moveCompatPackagesToDevDependencies,\n type OxlintConfig,\n parseJSONWithComments,\n readFileFromRoot,\n replaceViteConfigPluginImportSource,\n resolveDevScript,\n resolveGithubWorkflowsContext,\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 writeFileToRoot,\n} from './utils';\n\nexport {\n DocumentationRouter,\n type DocumentationRouterType,\n getDocumentationUrl,\n};\n\n/**\n * Resolves the default dev-server URL of the detected framework, used as the\n * `editor.applicationURL` of the generated configuration file. Frameworks that\n * embed Vite (Astro, SvelteKit, …) are checked before the bare Vite fallback so\n * their own dev port wins.\n */\nexport const getDefaultApplicationURL = (\n dependencies: Record<string, string>\n): string => {\n if (dependencies.next) return 'http://localhost:3000';\n if (dependencies.astro) return 'http://localhost:4321';\n if (dependencies['@angular/core']) return 'http://localhost:4200';\n if (dependencies.nuxt) return 'http://localhost:3000';\n if (dependencies['@sveltejs/kit']) return 'http://localhost:5173';\n if (dependencies['react-scripts']) return 'http://localhost:3000';\n if (dependencies.vite) return 'http://localhost:5173';\n\n return 'http://localhost:3000';\n};\n\n/**\n * How the interactive init organizes autogenerated content (compiler output /\n * autofill):\n * - `per-component` — multilingual `.content` files co-located with components\n * (the configuration template default).\n * - `centralized` — per-locale JSON dictionaries under `/locales/{locale}/`.\n * - `json-namespaces` — plain per-locale JSON namespace files kept in sync\n * through `@intlayer/sync-json-plugin`.\n */\nexport type ContentStrategy =\n | 'per-component'\n | 'centralized'\n | 'json-namespaces';\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 the Intlayer\n * packages of every `package.json` to their latest version.\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 /** Skip enabling the Intlayer lint rules (ESLint / oxlint). */\n noEslint?: boolean;\n /**\n * Skip the project setup: tsconfig types/aliases, the Intlayer config file,\n * bundler/framework configs, the dev script and framework-specific\n * scaffolding (middleware/proxy, providers in layout/page). Defaults to\n * enabled.\n */\n noFrameworkSetup?: boolean;\n /** Skip logging the final success message and documentation link. */\n skipFinalMessage?: boolean;\n /**\n * Version to install the missing Intlayer packages at (typically the running\n * CLI version). Already declared Intlayer packages are upgraded to the latest\n * published version instead.\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 * Whether the app routes by locale through the Intlayer proxy (middleware).\n * Written to `routing.enableProxy` in the configuration file and drives the\n * framework scaffolding: `false` skips the proxy file and any locale route\n * segment. When omitted, the configured value is kept (unset means enabled).\n */\n enableProxy?: boolean;\n /**\n * Content organization strategy chosen by the interactive init prompt. Drives\n * the `compiler.output` template (`centralized`) or the injection of the\n * syncJSON plugin (`json-namespaces`). When omitted (or `per-component`), the\n * configuration template default is kept.\n */\n contentStrategy?: ContentStrategy;\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 // MOVE COMPAT PACKAGES (e.g. next-intl) REPLACED BY @INTLAYER/* TO DEVDEPENDENCIES\n const movedPackages = moveCompatPackagesToDevDependencies(packageJson);\n if (movedPackages.length > 0) {\n const indentation = packageJsonContent.match(/^[ \\t]+(?=\")/m)?.[0] ?? 2;\n const trailingNewline = packageJsonContent.endsWith('\\n') ? '\\n' : '';\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n `${JSON.stringify(packageJson, null, indentation)}${trailingNewline}`\n );\n for (const pkg of movedPackages) {\n logger(\n `${v} Moved ${colorize(pkg, ANSIColors.MAGENTA)} from dependencies to devDependencies`\n );\n }\n }\n\n // INSTALL MISSING INTLAYER DEPENDENCIES\n const packageManager = detectPackageManager(rootDir);\n\n // lingui keeps its catalogs as `.po` (default) or `.json`. Detect which so the\n // matching sync plugin (`syncPO` / `syncJSON`) + dev dependency are chosen.\n const linguiPresent = Boolean(\n allDeps['@lingui/core'] ||\n allDeps['@lingui/react'] ||\n allDeps['@intlayer/lingui']\n );\n\n const linguiCatalog = linguiPresent\n ? await detectLinguiCatalogPattern(rootDir)\n : null;\n\n // `linguiCatalogFormat` resolution:\n // 1. Filesystem scan result (authoritative when catalogs already exist)\n // 2. Fallback: 'po' (lingui's default) when lingui is installed but no\n // catalogs have been generated yet.\n const linguiCatalogFormat: 'po' | 'json' | null =\n linguiCatalog?.format ?? (linguiPresent ? 'po' : null);\n\n const {\n packagesToInstall,\n devPackagesToInstall,\n compatSyncConfig,\n compatVitePluginConfig,\n pendingCompatAdapters,\n } = detectMissingIntlayerPackages(allDeps, {\n linguiCatalogFormat,\n dependencies: packageJson.dependencies,\n devDependencies: packageJson.devDependencies,\n });\n\n /** Whether the compat adapter for a library is not released yet. */\n const isCompatAdapterPending = (adapterPackage: string): boolean =>\n pendingCompatAdapters.includes(adapterPackage);\n\n if (pendingCompatAdapters.length > 0) {\n logger(\n `${x} No released Intlayer adapter yet for ${pendingCompatAdapters\n .map((adapterPackage) => colorize(adapterPackage, ANSIColors.MAGENTA))\n .join(\n ', '\n )} — keeping your current i18n library and only syncing its catalogs with Intlayer.`,\n { level: 'warn' }\n );\n }\n\n // The `json-namespaces` content strategy uses the same syncJSON pipeline as\n // the compat libraries: plain per-locale JSON namespace files synced through\n // `@intlayer/sync-json-plugin`. A detected compat library keeps precedence —\n // its own catalog format/template is authoritative.\n const wantsJsonNamespaces =\n options?.contentStrategy === 'json-namespaces' && !compatSyncConfig;\n\n if (\n wantsJsonNamespaces &&\n !allDeps['@intlayer/sync-json-plugin'] &&\n !devPackagesToInstall.includes('@intlayer/sync-json-plugin')\n ) {\n devPackagesToInstall.push('@intlayer/sync-json-plugin');\n }\n\n if (!options?.noInstallPackages) {\n const withVersion = (packages: string[]): string[] =>\n options?.upgradeToVersion\n ? packages.map((pkg) =>\n isIntlayerPackageName(pkg)\n ? `${pkg}@${options.upgradeToVersion}`\n : pkg\n )\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 INTLAYER DEPENDENCIES TO LATEST\n await upgradeIntlayerPackages(rootDir);\n }\n\n // CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (\n !options?.noGitignore &&\n !options?.noFrameworkSetup &&\n (await exists(rootDir, gitignorePath))\n ) {\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 // Every command runs with `--ci`, which iterates over the Intlayer\n // project(s) of the repository. GitHub only triggers workflows stored at the\n // repository root, so in a monorepo the files are written to the git root\n // (see resolveGithubWorkflowsContext).\n if (!options?.noGithubActions) {\n const workflowsContext = await resolveGithubWorkflowsContext(\n rootDir,\n packageManager\n );\n const workflows = getGithubWorkflows(\n workflowsContext.packageManager,\n workflowsContext.options\n );\n\n for (const workflow of workflows) {\n if (await exists(workflowsContext.workflowsRootDir, workflow.filePath)) {\n logger(`${v} ${colorizePath(workflow.filePath)} already exists`);\n continue;\n }\n\n try {\n await ensureDirectory(\n workflowsContext.workflowsRootDir,\n join('.github', 'workflows')\n );\n await writeFileToRoot(\n workflowsContext.workflowsRootDir,\n workflow.filePath,\n workflow.content\n );\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 LINT RULES (eslint-plugin-intlayer)\n //\n // Gated on the project already having a linter installed: with no ESLint or\n // oxlint there is nothing to plug the rules into, and the guidance below\n // would just be noise. The same check gates the install in\n // `detectMissingIntlayerPackages`, so the two never disagree.\n //\n // Only the oxlint config is patched here: `.oxlintrc.json` is plain JSON and\n // safe to edit, whereas an ESLint flat config is arbitrary JavaScript that\n // cannot be rewritten reliably — that one is left to the user, with the\n // snippet printed below.\n if (!options?.noEslint && hasLegacyEslint(allDeps)) {\n logger(\n `${x} ${colorize(LINT_PLUGIN_PACKAGE_NAME, ANSIColors.MAGENTA)} needs ESLint ${MINIMUM_ESLINT_MAJOR}+ (flat config) — skipped the Intlayer lint rules. Upgrade ESLint to enable them: ${colorizePath(DocumentationRouter.ESLint)}`,\n { level: 'warn' }\n );\n }\n\n if (!options?.noEslint && hasLintTooling(allDeps)) {\n const oxlintConfigPath = '.oxlintrc.json';\n const hasOxlintConfig = await exists(rootDir, oxlintConfigPath);\n // An oxlint-only project without a config gets one; with ESLint around,\n // the rules go into the ESLint config instead.\n const shouldCreateOxlintConfig =\n !hasOxlintConfig && Boolean(allDeps.oxlint) && !allDeps.eslint;\n\n if (hasOxlintConfig || shouldCreateOxlintConfig) {\n try {\n const oxlintConfig: OxlintConfig = hasOxlintConfig\n ? parseJSONWithComments(\n await readFileFromRoot(rootDir, oxlintConfigPath)\n )\n : {};\n\n if (addIntlayerRulesToOxlintConfig(oxlintConfig)) {\n await writeFileToRoot(\n rootDir,\n oxlintConfigPath,\n JSON.stringify(oxlintConfig, null, 2)\n );\n logger(\n `${v} ${hasOxlintConfig ? 'Added the Intlayer lint rules to' : 'Created'} ${colorizePath(oxlintConfigPath)}`\n );\n } else {\n logger(\n `${v} ${colorizePath(oxlintConfigPath)} already includes the Intlayer lint rules`\n );\n }\n } catch {\n logger(\n `${x} Could not update ${colorizePath(oxlintConfigPath)}. You may need to add ${colorize(LINT_PLUGIN_PACKAGE_NAME, ANSIColors.MAGENTA)} manually.`,\n { level: 'warn' }\n );\n }\n } else {\n // ESLint flat config — print the snippet instead of rewriting the file.\n logger([\n colorize('Intlayer lint rules →', ANSIColors.MAGENTA),\n colorize(\n `Add the ${LINT_PLUGIN_PACKAGE_NAME} preset to the array your ESLint flat config exports, to catch hardcoded text and dynamic calls the compiler cannot optimize:`,\n ANSIColors.GREY_LIGHT\n ),\n colorize(\n ` import intlayer from '${LINT_PLUGIN_PACKAGE_NAME}';\\n\\n export default [\\n // ...your existing config\\n ...intlayer.configs.recommended,\\n ];`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(DocumentationRouter.ESLint),\n ]);\n }\n }\n\n // PROJECT SETUP\n // Everything below edits the project itself: tsconfig types and aliases, the\n // Intlayer config file, bundler/framework configs, the dev script and the\n // framework scaffolding. It only runs with the framework setup step, so\n // picking e.g. only the CI or editor steps never creates project files.\n if (!options?.noFrameworkSetup) {\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 const isConfigCreated = await initConfig(format, rootDir, {\n locales: detectedPattern?.locales,\n applicationURL: getDefaultApplicationURL(allDeps),\n });\n\n // APPLY CONTENT STRATEGY — CENTRALIZED\n // Point `compiler.output` at per-locale JSON dictionaries under `/locales/`\n // instead of the per-component template default.\n if (options?.contentStrategy === 'centralized') {\n await setCompilerOutputInConfig(\n rootDir,\n '/locales/{{locale}}/{{key}}.content.json'\n );\n }\n\n // INJECT SYNC-JSON PLUGIN FOR COMPAT LIBRARIES / JSON-NAMESPACES STRATEGY\n const syncConfigToInject: CompatSyncConfig | undefined =\n compatSyncConfig ??\n (wantsJsonNamespaces\n ? {\n format: 'i18next',\n sourceTemplate:\n detectedPattern?.template ?? './locales/${locale}/${key}.json',\n }\n : undefined);\n\n if (syncConfigToInject) {\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 // lingui authoritatively resolves to `…/{locale}/messages.{po,json}`, where\n // the `messages` filename becomes the dictionary key. Prefer it so a `.po`\n // project gets `syncPO` (the generic JSON glob only sees `.json`).\n const sourceTemplate =\n linguiCatalog?.template ??\n nextIntlMessagesPattern?.template ??\n detectedPattern?.template;\n\n const resolvedSyncConfig = {\n ...syncConfigToInject,\n ...(sourceTemplate ? { sourceTemplate } : {}),\n };\n\n const syncPluginPackage =\n resolvedSyncConfig.plugin === 'po'\n ? '@intlayer/sync-po-plugin'\n : '@intlayer/sync-json-plugin';\n const syncPluginName =\n resolvedSyncConfig.plugin === 'po' ? 'syncPO' : 'syncJSON';\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(syncPluginPackage)) {\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 ${syncPluginName} compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(configFile)} already includes ${syncPluginName} plugin`\n );\n }\n break;\n }\n }\n }\n\n // APPLY ROUTING\n // An explicit choice (interactive prompt / `--routing`) is written to\n // `routing.mode` + `routing.enableProxy`. Without one, a freshly created\n // config is adapted to the project: frontends get prefix routing through\n // the proxy (the template ships it disabled), projects without URL routing\n // (backend, React Native…) keep only `routing.storage`. An existing config\n // is never rewritten without an explicit choice. A compat i18n library\n // owns the app routing, so its config keeps the template's disabled proxy:\n // compat bundler plugins wrap `intlayer()`, which would register it.\n const hasUrlRouting = hasUrlRoutingFramework(allDeps);\n const hasCompatI18nLibrary = detectCompatI18nLibraries(allDeps).length > 0;\n const shouldApplyDefaultRouting =\n isConfigCreated &&\n options?.routingMode === undefined &&\n !hasCompatI18nLibrary;\n\n if (shouldApplyDefaultRouting && !hasUrlRouting) {\n await setRoutingStorageOnlyInConfig(rootDir);\n }\n\n const routingMode =\n options?.routingMode ??\n (shouldApplyDefaultRouting && hasUrlRouting ? ROUTING_MODE : undefined);\n const enableProxy =\n options?.enableProxy ??\n (shouldApplyDefaultRouting && hasUrlRouting ? true : undefined);\n\n if (routingMode) {\n await setRoutingModeInConfig(rootDir, routingMode);\n }\n\n if (enableProxy !== undefined) {\n await setEnableProxyInConfig(rootDir, enableProxy);\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 const { replacesVitePlugin } = compatVitePluginConfig;\n\n if (content.includes(compatVitePluginConfig.pluginPackageSource)) {\n logger(\n `${v} ${colorizePath(file)} already includes ${compatVitePluginConfig.pluginPackageSource}`\n );\n } else if (\n replacesVitePlugin &&\n content.includes(replacesVitePlugin.fromPackageSource)\n ) {\n // Drop-in replacement: rewrite the original i18n vite plugin's import\n // source, keeping its binding and call site (e.g. lingui).\n const updatedContent = replaceViteConfigPluginImportSource(\n content,\n replacesVitePlugin.importName,\n replacesVitePlugin.fromPackageSource,\n compatVitePluginConfig.pluginPackageSource\n );\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to import ${replacesVitePlugin.importName} from ${compatVitePluginConfig.pluginPackageSource}`\n );\n } else {\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 }\n } else if (hasIntlayerVitePlugin(content)) {\n // A compat adapter plugin (e.g. `reactI18nextVitePlugin`) already wraps\n // `intlayer()` internally, so skip adding a redundant standalone plugin.\n logger(\n `${v} ${colorizePath(file)} already includes an Intlayer plugin`\n );\n } else {\n const updatedContent = updateViteConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include Intlayer plugin`\n );\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'] || allDeps['@intlayer/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'] || allDeps['@intlayer/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 (isCompatAdapterPending('@intlayer/next-translate')) {\n logger(\n `${v} Kept ${colorizePath(file)} untouched (next-translate stays in charge)`\n );\n } else if (\n allDeps['next-translate'] ||\n allDeps['@intlayer/next-translate']\n ) {\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(\n `${v} Updated ${colorizePath(file)} to include Intlayer plugin`\n );\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 (isCompatAdapterPending('@intlayer/nuxtjs-i18n')) {\n logger(\n `${v} Kept ${colorizePath(file)} untouched (@nuxtjs/i18n stays in charge)`\n );\n } else 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(\n `${v} Updated ${colorizePath(file)} to include Intlayer module`\n );\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(\n allDeps['react-native'] || allDeps.expo\n );\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 // Only frameworks with no bundler plugin to host the content watcher get\n // their dev server wrapped; a Next.js app is always left alone. See\n // `resolveDevScript`.\n const newDevScript = resolveDevScript({\n devScript: packageJson.scripts?.dev,\n allDeps,\n isNextJsProject,\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 // The server frameworks themselves, alongside their Intlayer packages: a\n // project may be mid-setup and carry only one of the two.\n const backendConfigPackages = [\n 'express',\n 'fastify',\n '@adonisjs/core',\n 'hono',\n 'elysia',\n ...BACKEND_INTLAYER_PACKAGES,\n ];\n\n if (backendConfigPackages.some((pkg) => allDeps[pkg])) {\n hasAliasConfiguration = true;\n }\n\n if (!hasAliasConfiguration) {\n const configuration = getConfiguration({ baseDir: rootDir });\n // `tsconfig`/`jsconfig` `paths` and `package.json` `imports` both expect\n // explicitly relative specifiers, so bare relative paths get a `./` prefix.\n const aliases = getAlias({\n configuration,\n formatter: (value) =>\n value.startsWith('./') || value.startsWith('../')\n ? value\n : `./${value}`,\n });\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\n if (!packageJson.imports[importAlias]) {\n packageJson.imports[importAlias] = path;\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 //\n // Skipped entirely when a compat i18n library drives the app (i18next,\n // next-intl, vue-i18n, …): the app already owns its routing, providers and\n // layouts, and Intlayer only syncs its catalogs — restructuring routes or\n // injecting providers would break the existing setup.\n const hasCompatLibrary = Boolean(\n compatSyncConfig || compatVitePluginConfig\n );\n\n if (hasCompatLibrary) {\n logger(\n `${v} Compat i18n library detected — keeping the app structure untouched (no route restructure, no provider injection)`\n );\n }\n\n if (!hasCompatLibrary) {\n try {\n // Prefer the user's choices, else the configured routing (mode defaults\n // to `prefix-no-default`, an unset `enableProxy` means enabled). Drives\n // the proxy file and the locale route segment the adapters scaffold.\n const { routing } = getConfiguration({ baseDir: rootDir });\n\n await setupFramework({\n rootDir,\n allDeps,\n packageManager,\n useTypeScript: hasTsConfig,\n routingMode: routingMode ?? routing.mode,\n enableProxy: enableProxy ?? routing.enableProxy !== false,\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\n // FINAL SUCCESS MESSAGE\n if (!options?.skipFinalMessage) {\n logInitSuccessMessage(guideUrl);\n }\n\n return { guideUrl };\n};\n\nexport const logInitSuccessMessage = (guideUrl: string): void => {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,MAAa,4BACX,iBACW;CACX,IAAI,aAAa,MAAM,OAAO;CAC9B,IAAI,aAAa,OAAO,OAAO;CAC/B,IAAI,aAAa,kBAAkB,OAAO;CAC1C,IAAI,aAAa,MAAM,OAAO;CAC9B,IAAI,aAAa,kBAAkB,OAAO;CAC1C,IAAI,aAAa,kBAAkB,OAAO;CAC1C,IAAI,aAAa,MAAM,OAAO;CAE9B,OAAO;AACT;;;;AA0EA,MAAa,eAAe,OAAO,SAAiB,YAA0B;CAC5E,OAAO,SAAS,sCAAsC,WAAW,IAAI,CAAC;CAGtE,MAAM,kBAAkB;CACxB,IAAI,CAAE,MAAM,OAAO,SAAS,eAAe,GAAI;EAC7C,OACE,GAAG,EAAE,MAAM,aAAa,cAAc,EAAE,wDACxC,EAAE,OAAO,QAAQ,CACnB;EACA,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,qBAAqB,MAAM,iBAAiB,SAAS,eAAe;CAC1E,IAAI;CACJ,IAAI;EACF,cAAc,KAAK,MAAM,kBAAkB;CAC7C,QAAQ;EACN,OAAO,GAAG,EAAE,mBAAmB,aAAa,cAAc,EAAE,IAAI,EAC9D,OAAO,QACT,CAAC;EACD,QAAQ,KAAK,CAAC;CAChB;CAGA,MAAM,WAAW,oBAAoB,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AAC,YAAY,QAAQ,cAAc;OACrC,YAAY,QAAQ,eAAe;OACnC,UAAU;MACZ;KACF,CAAC;KAED,IAAI,SAAS;MACX,MAAM,gBACJ,SACA,iBACA,KAAK,UAAU,aAAa,MAAM,CAAC,CACrC;MACA,OACE,GAAG,EAAE,WAAW,aACd,eACF,EAAE,6BACJ;KACF;IACF;GACF;EACF;EAYA,MAAM,mBAAmB,QACvB,oBAAoB,sBACtB;EAEA,IAAI,kBACF,OACE,GAAG,EAAE,kHACP;EAGF,IAAI,CAAC,kBACH,IAAI;GAIF,MAAM,EAAE,YAAY,iBAAiB,EAAE,SAAS,QAAQ,CAAC;GAEzD,MAAM,eAAe;IACnB;IACA;IACA;IACA,eAAe;IACf,aAAa,eAAe,QAAQ;IACpC,aAAa,eAAe,QAAQ,gBAAgB;GACtD,CAAC;EACH,QAAQ;GACN,OACE,GAAG,EAAE,iIACL,EAAE,OAAO,OAAO,CAClB;EACF;CAEJ;CAGA,IAAI,CAAC,SAAS,kBACZ,sBAAsB,QAAQ;CAGhC,OAAO,EAAE,SAAS;AACpB;AAEA,MAAa,yBAAyB,aAA2B;CAC/D,OAAO,GAAG,EAAE,GAAG,SAAS,iCAAiC,WAAW,KAAK,GAAG;CAC5E,OAAO;EACL,SAAS,UAAU,WAAW,OAAO;EACrC,SACE,uEACA,WAAW,UACb;EACA,aAAa,QAAQ;CACvB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/init/index.ts"],"sourcesContent":["import { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { ROUTING_MODE } from '@intlayer/config/defaultValues';\nimport { colorize, colorizePath, logger, v, x } from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { initConfig } from '../initConfig';\nimport {\n setCompilerOutputInConfig,\n setEnableProxyInConfig,\n setRoutingModeInConfig,\n setRoutingStorageOnlyInConfig,\n} from './cms';\nimport {\n DocumentationRouter,\n type DocumentationRouterType,\n getDocumentationUrl,\n} from './documentationRouter';\nimport { setupFramework } from './frameworkSetup';\nimport { upgradeIntlayerPackages } from './upgradeIntlayerPackages';\nimport type { CompatSyncConfig, RoutingMode } from './utils';\nimport {\n addIntlayerRulesToOxlintConfig,\n BACKEND_INTLAYER_PACKAGES,\n detectCompatI18nLibraries,\n detectJsonLocalePattern,\n detectLinguiCatalogPattern,\n detectMissingIntlayerPackages,\n detectNextIntlMessagesPattern,\n detectPackageManager,\n ensureDirectory,\n exists,\n findTsConfigFiles,\n getGithubWorkflows,\n getMetroConfigTemplate,\n hasIntlayerVitePlugin,\n hasLegacyEslint,\n hasLintTooling,\n hasUrlRoutingFramework,\n installPackages,\n isIntlayerPackageName,\n LINT_PLUGIN_PACKAGE_NAME,\n MINIMUM_ESLINT_MAJOR,\n moveCompatPackagesToDevDependencies,\n type OxlintConfig,\n parseJSONWithComments,\n readFileFromRoot,\n replaceViteConfigPluginImportSource,\n resolveGithubWorkflowsContext,\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 writeFileToRoot,\n} from './utils';\n\nexport {\n DocumentationRouter,\n type DocumentationRouterType,\n getDocumentationUrl,\n};\n\n/**\n * Resolves the default dev-server URL of the detected framework, used as the\n * `editor.applicationURL` of the generated configuration file. Frameworks that\n * embed Vite (Astro, SvelteKit, …) are checked before the bare Vite fallback so\n * their own dev port wins.\n */\nexport const getDefaultApplicationURL = (\n dependencies: Record<string, string>\n): string => {\n if (dependencies.next) return 'http://localhost:3000';\n if (dependencies.astro) return 'http://localhost:4321';\n if (dependencies['@angular/core']) return 'http://localhost:4200';\n if (dependencies.nuxt) return 'http://localhost:3000';\n if (dependencies['@sveltejs/kit']) return 'http://localhost:5173';\n if (dependencies['react-scripts']) return 'http://localhost:3000';\n if (dependencies.vite) return 'http://localhost:5173';\n\n return 'http://localhost:3000';\n};\n\n/**\n * How the interactive init organizes autogenerated content (compiler output /\n * autofill):\n * - `per-component` — multilingual `.content` files co-located with components\n * (the configuration template default).\n * - `centralized` — per-locale JSON dictionaries under `/locales/{locale}/`.\n * - `json-namespaces` — plain per-locale JSON namespace files kept in sync\n * through `@intlayer/sync-json-plugin`.\n */\nexport type ContentStrategy =\n | 'per-component'\n | 'centralized'\n | 'json-namespaces';\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 the Intlayer\n * packages of every `package.json` to their latest version.\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 /** Skip enabling the Intlayer lint rules (ESLint / oxlint). */\n noEslint?: boolean;\n /**\n * Skip the project setup: tsconfig types/aliases, the Intlayer config file,\n * bundler/framework configs and framework-specific\n * scaffolding (middleware/proxy, providers in layout/page). Defaults to\n * enabled.\n */\n noFrameworkSetup?: boolean;\n /** Skip logging the final success message and documentation link. */\n skipFinalMessage?: boolean;\n /**\n * Version to install the missing Intlayer packages at (typically the running\n * CLI version). Already declared Intlayer packages are upgraded to the latest\n * published version instead.\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 * Whether the app routes by locale through the Intlayer proxy (middleware).\n * Written to `routing.enableProxy` in the configuration file and drives the\n * framework scaffolding: `false` skips the proxy file and any locale route\n * segment. When omitted, the configured value is kept (unset means enabled).\n */\n enableProxy?: boolean;\n /**\n * Content organization strategy chosen by the interactive init prompt. Drives\n * the `compiler.output` template (`centralized`) or the injection of the\n * syncJSON plugin (`json-namespaces`). When omitted (or `per-component`), the\n * configuration template default is kept.\n */\n contentStrategy?: ContentStrategy;\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 // MOVE COMPAT PACKAGES (e.g. next-intl) REPLACED BY @INTLAYER/* TO DEVDEPENDENCIES\n const movedPackages = moveCompatPackagesToDevDependencies(packageJson);\n if (movedPackages.length > 0) {\n const indentation = packageJsonContent.match(/^[ \\t]+(?=\")/m)?.[0] ?? 2;\n const trailingNewline = packageJsonContent.endsWith('\\n') ? '\\n' : '';\n await writeFileToRoot(\n rootDir,\n packageJsonPath,\n `${JSON.stringify(packageJson, null, indentation)}${trailingNewline}`\n );\n for (const pkg of movedPackages) {\n logger(\n `${v} Moved ${colorize(pkg, ANSIColors.MAGENTA)} from dependencies to devDependencies`\n );\n }\n }\n\n // INSTALL MISSING INTLAYER DEPENDENCIES\n const packageManager = detectPackageManager(rootDir);\n\n // lingui keeps its catalogs as `.po` (default) or `.json`. Detect which so the\n // matching sync plugin (`syncPO` / `syncJSON`) + dev dependency are chosen.\n const linguiPresent = Boolean(\n allDeps['@lingui/core'] ||\n allDeps['@lingui/react'] ||\n allDeps['@intlayer/lingui']\n );\n\n const linguiCatalog = linguiPresent\n ? await detectLinguiCatalogPattern(rootDir)\n : null;\n\n // `linguiCatalogFormat` resolution:\n // 1. Filesystem scan result (authoritative when catalogs already exist)\n // 2. Fallback: 'po' (lingui's default) when lingui is installed but no\n // catalogs have been generated yet.\n const linguiCatalogFormat: 'po' | 'json' | null =\n linguiCatalog?.format ?? (linguiPresent ? 'po' : null);\n\n const {\n packagesToInstall,\n devPackagesToInstall,\n compatSyncConfig,\n compatVitePluginConfig,\n pendingCompatAdapters,\n } = detectMissingIntlayerPackages(allDeps, {\n linguiCatalogFormat,\n dependencies: packageJson.dependencies,\n devDependencies: packageJson.devDependencies,\n });\n\n /** Whether the compat adapter for a library is not released yet. */\n const isCompatAdapterPending = (adapterPackage: string): boolean =>\n pendingCompatAdapters.includes(adapterPackage);\n\n if (pendingCompatAdapters.length > 0) {\n logger(\n `${x} No released Intlayer adapter yet for ${pendingCompatAdapters\n .map((adapterPackage) => colorize(adapterPackage, ANSIColors.MAGENTA))\n .join(\n ', '\n )} — keeping your current i18n library and only syncing its catalogs with Intlayer.`,\n { level: 'warn' }\n );\n }\n\n // The `json-namespaces` content strategy uses the same syncJSON pipeline as\n // the compat libraries: plain per-locale JSON namespace files synced through\n // `@intlayer/sync-json-plugin`. A detected compat library keeps precedence —\n // its own catalog format/template is authoritative.\n const wantsJsonNamespaces =\n options?.contentStrategy === 'json-namespaces' && !compatSyncConfig;\n\n if (\n wantsJsonNamespaces &&\n !allDeps['@intlayer/sync-json-plugin'] &&\n !devPackagesToInstall.includes('@intlayer/sync-json-plugin')\n ) {\n devPackagesToInstall.push('@intlayer/sync-json-plugin');\n }\n\n if (!options?.noInstallPackages) {\n const withVersion = (packages: string[]): string[] =>\n options?.upgradeToVersion\n ? packages.map((pkg) =>\n isIntlayerPackageName(pkg)\n ? `${pkg}@${options.upgradeToVersion}`\n : pkg\n )\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 INTLAYER DEPENDENCIES TO LATEST\n await upgradeIntlayerPackages(rootDir);\n }\n\n // CHECK .GITIGNORE\n const gitignorePath = '.gitignore';\n if (\n !options?.noGitignore &&\n !options?.noFrameworkSetup &&\n (await exists(rootDir, gitignorePath))\n ) {\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 // Every command runs with `--ci`, which iterates over the Intlayer\n // project(s) of the repository. GitHub only triggers workflows stored at the\n // repository root, so in a monorepo the files are written to the git root\n // (see resolveGithubWorkflowsContext).\n if (!options?.noGithubActions) {\n const workflowsContext = await resolveGithubWorkflowsContext(\n rootDir,\n packageManager\n );\n const workflows = getGithubWorkflows(\n workflowsContext.packageManager,\n workflowsContext.options\n );\n\n for (const workflow of workflows) {\n if (await exists(workflowsContext.workflowsRootDir, workflow.filePath)) {\n logger(`${v} ${colorizePath(workflow.filePath)} already exists`);\n continue;\n }\n\n try {\n await ensureDirectory(\n workflowsContext.workflowsRootDir,\n join('.github', 'workflows')\n );\n await writeFileToRoot(\n workflowsContext.workflowsRootDir,\n workflow.filePath,\n workflow.content\n );\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 LINT RULES (eslint-plugin-intlayer)\n //\n // Gated on the project already having a linter installed: with no ESLint or\n // oxlint there is nothing to plug the rules into, and the guidance below\n // would just be noise. The same check gates the install in\n // `detectMissingIntlayerPackages`, so the two never disagree.\n //\n // Only the oxlint config is patched here: `.oxlintrc.json` is plain JSON and\n // safe to edit, whereas an ESLint flat config is arbitrary JavaScript that\n // cannot be rewritten reliably — that one is left to the user, with the\n // snippet printed below.\n if (!options?.noEslint && hasLegacyEslint(allDeps)) {\n logger(\n `${x} ${colorize(LINT_PLUGIN_PACKAGE_NAME, ANSIColors.MAGENTA)} needs ESLint ${MINIMUM_ESLINT_MAJOR}+ (flat config) — skipped the Intlayer lint rules. Upgrade ESLint to enable them: ${colorizePath(DocumentationRouter.ESLint)}`,\n { level: 'warn' }\n );\n }\n\n if (!options?.noEslint && hasLintTooling(allDeps)) {\n const oxlintConfigPath = '.oxlintrc.json';\n const hasOxlintConfig = await exists(rootDir, oxlintConfigPath);\n // An oxlint-only project without a config gets one; with ESLint around,\n // the rules go into the ESLint config instead.\n const shouldCreateOxlintConfig =\n !hasOxlintConfig && Boolean(allDeps.oxlint) && !allDeps.eslint;\n\n if (hasOxlintConfig || shouldCreateOxlintConfig) {\n try {\n const oxlintConfig: OxlintConfig = hasOxlintConfig\n ? parseJSONWithComments(\n await readFileFromRoot(rootDir, oxlintConfigPath)\n )\n : {};\n\n if (addIntlayerRulesToOxlintConfig(oxlintConfig)) {\n await writeFileToRoot(\n rootDir,\n oxlintConfigPath,\n JSON.stringify(oxlintConfig, null, 2)\n );\n logger(\n `${v} ${hasOxlintConfig ? 'Added the Intlayer lint rules to' : 'Created'} ${colorizePath(oxlintConfigPath)}`\n );\n } else {\n logger(\n `${v} ${colorizePath(oxlintConfigPath)} already includes the Intlayer lint rules`\n );\n }\n } catch {\n logger(\n `${x} Could not update ${colorizePath(oxlintConfigPath)}. You may need to add ${colorize(LINT_PLUGIN_PACKAGE_NAME, ANSIColors.MAGENTA)} manually.`,\n { level: 'warn' }\n );\n }\n } else {\n // ESLint flat config — print the snippet instead of rewriting the file.\n logger([\n colorize('Intlayer lint rules →', ANSIColors.MAGENTA),\n colorize(\n `Add the ${LINT_PLUGIN_PACKAGE_NAME} preset to the array your ESLint flat config exports, to catch hardcoded text and dynamic calls the compiler cannot optimize:`,\n ANSIColors.GREY_LIGHT\n ),\n colorize(\n ` import intlayer from '${LINT_PLUGIN_PACKAGE_NAME}';\\n\\n export default [\\n // ...your existing config\\n ...intlayer.configs.recommended,\\n ];`,\n ANSIColors.GREY_LIGHT\n ),\n colorizePath(DocumentationRouter.ESLint),\n ]);\n }\n }\n\n // PROJECT SETUP\n // Everything below edits the project itself: tsconfig types and aliases, the\n // Intlayer config file, bundler/framework configs and the\n // framework scaffolding. It only runs with the framework setup step, so\n // picking e.g. only the CI or editor steps never creates project files.\n if (!options?.noFrameworkSetup) {\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 const isConfigCreated = await initConfig(format, rootDir, {\n locales: detectedPattern?.locales,\n applicationURL: getDefaultApplicationURL(allDeps),\n });\n\n // APPLY CONTENT STRATEGY — CENTRALIZED\n // Point `compiler.output` at per-locale JSON dictionaries under `/locales/`\n // instead of the per-component template default.\n if (options?.contentStrategy === 'centralized') {\n await setCompilerOutputInConfig(\n rootDir,\n '/locales/{{locale}}/{{key}}.content.json'\n );\n }\n\n // INJECT SYNC-JSON PLUGIN FOR COMPAT LIBRARIES / JSON-NAMESPACES STRATEGY\n const syncConfigToInject: CompatSyncConfig | undefined =\n compatSyncConfig ??\n (wantsJsonNamespaces\n ? {\n format: 'i18next',\n sourceTemplate:\n detectedPattern?.template ?? './locales/${locale}/${key}.json',\n }\n : undefined);\n\n if (syncConfigToInject) {\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 // lingui authoritatively resolves to `…/{locale}/messages.{po,json}`, where\n // the `messages` filename becomes the dictionary key. Prefer it so a `.po`\n // project gets `syncPO` (the generic JSON glob only sees `.json`).\n const sourceTemplate =\n linguiCatalog?.template ??\n nextIntlMessagesPattern?.template ??\n detectedPattern?.template;\n\n const resolvedSyncConfig = {\n ...syncConfigToInject,\n ...(sourceTemplate ? { sourceTemplate } : {}),\n };\n\n const syncPluginPackage =\n resolvedSyncConfig.plugin === 'po'\n ? '@intlayer/sync-po-plugin'\n : '@intlayer/sync-json-plugin';\n const syncPluginName =\n resolvedSyncConfig.plugin === 'po' ? 'syncPO' : 'syncJSON';\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(syncPluginPackage)) {\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 ${syncPluginName} compat plugin`\n );\n } else {\n logger(\n `${v} ${colorizePath(configFile)} already includes ${syncPluginName} plugin`\n );\n }\n break;\n }\n }\n }\n\n // APPLY ROUTING\n // An explicit choice (interactive prompt / `--routing`) is written to\n // `routing.mode` + `routing.enableProxy`. Without one, a freshly created\n // config is adapted to the project: frontends get prefix routing through\n // the proxy (the template ships it disabled), projects without URL routing\n // (backend, React Native…) keep only `routing.storage`. An existing config\n // is never rewritten without an explicit choice. A compat i18n library\n // owns the app routing, so its config keeps the template's disabled proxy:\n // compat bundler plugins wrap `intlayer()`, which would register it.\n const hasUrlRouting = hasUrlRoutingFramework(allDeps);\n const hasCompatI18nLibrary = detectCompatI18nLibraries(allDeps).length > 0;\n const shouldApplyDefaultRouting =\n isConfigCreated &&\n options?.routingMode === undefined &&\n !hasCompatI18nLibrary;\n\n if (shouldApplyDefaultRouting && !hasUrlRouting) {\n await setRoutingStorageOnlyInConfig(rootDir);\n }\n\n const routingMode =\n options?.routingMode ??\n (shouldApplyDefaultRouting && hasUrlRouting ? ROUTING_MODE : undefined);\n const enableProxy =\n options?.enableProxy ??\n (shouldApplyDefaultRouting && hasUrlRouting ? true : undefined);\n\n if (routingMode) {\n await setRoutingModeInConfig(rootDir, routingMode);\n }\n\n if (enableProxy !== undefined) {\n await setEnableProxyInConfig(rootDir, enableProxy);\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 const { replacesVitePlugin } = compatVitePluginConfig;\n\n if (content.includes(compatVitePluginConfig.pluginPackageSource)) {\n logger(\n `${v} ${colorizePath(file)} already includes ${compatVitePluginConfig.pluginPackageSource}`\n );\n } else if (\n replacesVitePlugin &&\n content.includes(replacesVitePlugin.fromPackageSource)\n ) {\n // Drop-in replacement: rewrite the original i18n vite plugin's import\n // source, keeping its binding and call site (e.g. lingui).\n const updatedContent = replaceViteConfigPluginImportSource(\n content,\n replacesVitePlugin.importName,\n replacesVitePlugin.fromPackageSource,\n compatVitePluginConfig.pluginPackageSource\n );\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to import ${replacesVitePlugin.importName} from ${compatVitePluginConfig.pluginPackageSource}`\n );\n } else {\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 }\n } else if (hasIntlayerVitePlugin(content)) {\n // A compat adapter plugin (e.g. `reactI18nextVitePlugin`) already wraps\n // `intlayer()` internally, so skip adding a redundant standalone plugin.\n logger(\n `${v} ${colorizePath(file)} already includes an Intlayer plugin`\n );\n } else {\n const updatedContent = updateViteConfig(content, extension);\n await writeFileToRoot(rootDir, file, updatedContent);\n logger(\n `${v} Updated ${colorizePath(file)} to include Intlayer plugin`\n );\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'] || allDeps['@intlayer/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'] || allDeps['@intlayer/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 (isCompatAdapterPending('@intlayer/next-translate')) {\n logger(\n `${v} Kept ${colorizePath(file)} untouched (next-translate stays in charge)`\n );\n } else if (\n allDeps['next-translate'] ||\n allDeps['@intlayer/next-translate']\n ) {\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(\n `${v} Updated ${colorizePath(file)} to include Intlayer plugin`\n );\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 (isCompatAdapterPending('@intlayer/nuxtjs-i18n')) {\n logger(\n `${v} Kept ${colorizePath(file)} untouched (@nuxtjs/i18n stays in charge)`\n );\n } else 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(\n `${v} Updated ${colorizePath(file)} to include Intlayer module`\n );\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(\n allDeps['react-native'] || allDeps.expo\n );\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 // 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 // The server frameworks themselves, alongside their Intlayer packages: a\n // project may be mid-setup and carry only one of the two.\n const backendConfigPackages = [\n 'express',\n 'fastify',\n '@adonisjs/core',\n 'hono',\n 'elysia',\n ...BACKEND_INTLAYER_PACKAGES,\n ];\n\n if (backendConfigPackages.some((pkg) => allDeps[pkg])) {\n hasAliasConfiguration = true;\n }\n\n if (!hasAliasConfiguration) {\n const configuration = getConfiguration({ baseDir: rootDir });\n // `tsconfig`/`jsconfig` `paths` and `package.json` `imports` both expect\n // explicitly relative specifiers, so bare relative paths get a `./` prefix.\n const aliases = getAlias({\n configuration,\n formatter: (value) =>\n value.startsWith('./') || value.startsWith('../')\n ? value\n : `./${value}`,\n });\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\n if (!packageJson.imports[importAlias]) {\n packageJson.imports[importAlias] = path;\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 //\n // Skipped entirely when a compat i18n library drives the app (i18next,\n // next-intl, vue-i18n, …): the app already owns its routing, providers and\n // layouts, and Intlayer only syncs its catalogs — restructuring routes or\n // injecting providers would break the existing setup.\n const hasCompatLibrary = Boolean(\n compatSyncConfig || compatVitePluginConfig\n );\n\n if (hasCompatLibrary) {\n logger(\n `${v} Compat i18n library detected — keeping the app structure untouched (no route restructure, no provider injection)`\n );\n }\n\n if (!hasCompatLibrary) {\n try {\n // Prefer the user's choices, else the configured routing (mode defaults\n // to `prefix-no-default`, an unset `enableProxy` means enabled). Drives\n // the proxy file and the locale route segment the adapters scaffold.\n const { routing } = getConfiguration({ baseDir: rootDir });\n\n await setupFramework({\n rootDir,\n allDeps,\n packageManager,\n useTypeScript: hasTsConfig,\n routingMode: routingMode ?? routing.mode,\n enableProxy: enableProxy ?? routing.enableProxy !== false,\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\n // FINAL SUCCESS MESSAGE\n if (!options?.skipFinalMessage) {\n logInitSuccessMessage(guideUrl);\n }\n\n return { guideUrl };\n};\n\nexport const logInitSuccessMessage = (guideUrl: string): void => {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,MAAa,4BACX,iBACW;CACX,IAAI,aAAa,MAAM,OAAO;CAC9B,IAAI,aAAa,OAAO,OAAO;CAC/B,IAAI,aAAa,kBAAkB,OAAO;CAC1C,IAAI,aAAa,MAAM,OAAO;CAC9B,IAAI,aAAa,kBAAkB,OAAO;CAC1C,IAAI,aAAa,kBAAkB,OAAO;CAC1C,IAAI,aAAa,MAAM,OAAO;CAE9B,OAAO;AACT;;;;AA0EA,MAAa,eAAe,OAAO,SAAiB,YAA0B;CAC5E,OAAO,SAAS,sCAAsC,WAAW,IAAI,CAAC;CAGtE,MAAM,kBAAkB;CACxB,IAAI,CAAE,MAAM,OAAO,SAAS,eAAe,GAAI;EAC7C,OACE,GAAG,EAAE,MAAM,aAAa,cAAc,EAAE,wDACxC,EAAE,OAAO,QAAQ,CACnB;EACA,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,qBAAqB,MAAM,iBAAiB,SAAS,eAAe;CAC1E,IAAI;CACJ,IAAI;EACF,cAAc,KAAK,MAAM,kBAAkB;CAC7C,QAAQ;EACN,OAAO,GAAG,EAAE,mBAAmB,aAAa,cAAc,EAAE,IAAI,EAC9D,OAAO,QACT,CAAC;EACD,QAAQ,KAAK,CAAC;CAChB;CAGA,MAAM,WAAW,oBAAoB,WAAW;CAEhD,MAAM,UAAkC;EACtC,GAAI,YAAY,gBAAgB,CAAC;EAC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AE,kHACP;EAGF,IAAI,CAAC,kBACH,IAAI;GAIF,MAAM,EAAE,YAAY,iBAAiB,EAAE,SAAS,QAAQ,CAAC;GAEzD,MAAM,eAAe;IACnB;IACA;IACA;IACA,eAAe;IACf,aAAa,eAAe,QAAQ;IACpC,aAAa,eAAe,QAAQ,gBAAgB;GACtD,CAAC;EACH,QAAQ;GACN,OACE,GAAG,EAAE,iIACL,EAAE,OAAO,OAAO,CAClB;EACF;CAEJ;CAGA,IAAI,CAAC,SAAS,kBACZ,sBAAsB,QAAQ;CAGhC,OAAO,EAAE,SAAS;AACpB;AAEA,MAAa,yBAAyB,aAA2B;CAC/D,OAAO,GAAG,EAAE,GAAG,SAAS,iCAAiC,WAAW,KAAK,GAAG;CAC5E,OAAO;EACL,SAAS,UAAU,WAAW,OAAO;EACrC,SACE,uEACA,WAAW,UACb;EACA,aAAa,QAAQ;CACvB,CAAC;AACH"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/init/utils/backendPackages.ts
|
|
2
|
+
/** Intlayer integrations for server frameworks (no bundler plugin). */
|
|
3
|
+
const BACKEND_INTLAYER_PACKAGES = [
|
|
4
|
+
"express-intlayer",
|
|
5
|
+
"fastify-intlayer",
|
|
6
|
+
"adonis-intlayer",
|
|
7
|
+
"hono-intlayer",
|
|
8
|
+
"elysia-intlayer",
|
|
9
|
+
"remix-intlayer"
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { BACKEND_INTLAYER_PACKAGES };
|
|
14
|
+
//# sourceMappingURL=backendPackages.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backendPackages.mjs","names":[],"sources":["../../../../src/init/utils/backendPackages.ts"],"sourcesContent":["/** Intlayer integrations for server frameworks (no bundler plugin). */\nexport const BACKEND_INTLAYER_PACKAGES = [\n 'express-intlayer',\n 'fastify-intlayer',\n 'adonis-intlayer',\n 'hono-intlayer',\n 'elysia-intlayer',\n 'remix-intlayer',\n];\n"],"mappings":";;AACA,MAAa,4BAA4B;CACvC;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -2,7 +2,7 @@ import { ensureNamedImport, firstInsertIndex, isModuleScopeBinding } from "./ast
|
|
|
2
2
|
import { enableIntlayerEditorConfig, getMetroConfigTemplate, hasIntlayerVitePlugin, replaceViteConfigPluginImportSource, setIntlayerConfigCompilerOutput, setIntlayerConfigEnableProxy, setIntlayerConfigRoutingMode, setIntlayerConfigRoutingStorageOnly, updateAstroConfig, updateIntlayerConfigWithSyncPlugin, updateMetroConfig, updateNextConfig, updateNextConfigForNextI18next, updateNextConfigForNextIntl, updateNextConfigForNextTranslate, updateNuxtConfig, updateNuxtConfigForNuxtjsI18n, updateViteConfig, updateViteConfigForCompatPlugin, updateViteConfigForVueI18n } from "./configManipulation.mjs";
|
|
3
3
|
import { detectJsonLocalePattern, detectLinguiCatalogPattern, detectNextIntlMessagesPattern, ensureDirectory, exists, readFileFromRoot, writeFileToRoot } from "./fileSystem.mjs";
|
|
4
4
|
import { isVersionAtLeast } from "./version.mjs";
|
|
5
|
-
import { BACKEND_INTLAYER_PACKAGES
|
|
5
|
+
import { BACKEND_INTLAYER_PACKAGES } from "./backendPackages.mjs";
|
|
6
6
|
import { COMPAT_I18N_LIBRARIES, COMPAT_PACKAGE_REPLACEMENTS, MINIMUM_ESLINT_MAJOR, PENDING_COMPAT_ADAPTERS, detectCompatI18nLibraries, detectMissingIntlayerPackages, detectPackageManager, findLockFileDir, hasLegacyEslint, hasLintTooling, installPackages, isIntlayerPackageName, moveCompatPackagesToDevDependencies, normalizeVersion, runPackageInstall } from "./packageManager.mjs";
|
|
7
7
|
import { GITHUB_FILL_WORKFLOW_PATH, GITHUB_TEST_WORKFLOW_PATH, getGithubWorkflows, resolveGithubWorkflowsContext } from "./githubActions.mjs";
|
|
8
8
|
import { fetchLatestPackageVersion, findPackageJsonFiles, getIntlayerDependencies, getIntlayerDependencyUpgrades, listIntlayerDependencies, toRange, writeIntlayerDependencyUpgrades } from "./intlayerDependencies.mjs";
|
|
@@ -12,4 +12,4 @@ import { NEXT_INTLAYER_BABEL_CONFIG_CONTENT, setupNextCompilerBabelConfig } from
|
|
|
12
12
|
import { findTsConfigFiles } from "./tsConfig.mjs";
|
|
13
13
|
import { hasUrlRoutingFramework } from "./urlRoutingFramework.mjs";
|
|
14
14
|
|
|
15
|
-
export { BACKEND_INTLAYER_PACKAGES, COMPAT_I18N_LIBRARIES, COMPAT_PACKAGE_REPLACEMENTS, GITHUB_FILL_WORKFLOW_PATH, GITHUB_TEST_WORKFLOW_PATH, LINT_PLUGIN_PACKAGE_NAME, MINIMUM_ESLINT_MAJOR, NEXT_INTLAYER_BABEL_CONFIG_CONTENT, PENDING_COMPAT_ADAPTERS, addIntlayerRulesToOxlintConfig, detectCompatI18nLibraries, detectJsonLocalePattern, detectLinguiCatalogPattern, detectMissingIntlayerPackages, detectNextIntlMessagesPattern, detectPackageManager, enableIntlayerEditorConfig, ensureDirectory, ensureNamedImport, exists, fetchLatestPackageVersion, findLockFileDir, findPackageJsonFiles, findTsConfigFiles, firstInsertIndex, getGithubWorkflows, getIntlayerDependencies, getIntlayerDependencyUpgrades, getMetroConfigTemplate, hasIntlayerVitePlugin, hasLegacyEslint, hasLintTooling, hasUrlRoutingFramework, installPackages, isIntlayerPackageName, isModuleScopeBinding, isVersionAtLeast, listIntlayerDependencies, moveCompatPackagesToDevDependencies, normalizeVersion, parseJSONWithComments, readFileFromRoot, replaceViteConfigPluginImportSource,
|
|
15
|
+
export { BACKEND_INTLAYER_PACKAGES, COMPAT_I18N_LIBRARIES, COMPAT_PACKAGE_REPLACEMENTS, GITHUB_FILL_WORKFLOW_PATH, GITHUB_TEST_WORKFLOW_PATH, LINT_PLUGIN_PACKAGE_NAME, MINIMUM_ESLINT_MAJOR, NEXT_INTLAYER_BABEL_CONFIG_CONTENT, PENDING_COMPAT_ADAPTERS, addIntlayerRulesToOxlintConfig, detectCompatI18nLibraries, detectJsonLocalePattern, detectLinguiCatalogPattern, detectMissingIntlayerPackages, detectNextIntlMessagesPattern, detectPackageManager, enableIntlayerEditorConfig, ensureDirectory, ensureNamedImport, exists, fetchLatestPackageVersion, findLockFileDir, findPackageJsonFiles, findTsConfigFiles, firstInsertIndex, getGithubWorkflows, getIntlayerDependencies, getIntlayerDependencyUpgrades, getMetroConfigTemplate, hasIntlayerVitePlugin, hasLegacyEslint, hasLintTooling, hasUrlRoutingFramework, installPackages, isIntlayerPackageName, isModuleScopeBinding, isVersionAtLeast, listIntlayerDependencies, moveCompatPackagesToDevDependencies, normalizeVersion, parseJSONWithComments, readFileFromRoot, replaceViteConfigPluginImportSource, resolveGithubWorkflowsContext, runPackageInstall, setIntlayerConfigCompilerOutput, setIntlayerConfigEnableProxy, setIntlayerConfigRoutingMode, setIntlayerConfigRoutingStorageOnly, setupNextCompilerBabelConfig, toRange, updateAstroConfig, updateIntlayerConfigWithSyncPlugin, updateMetroConfig, updateNextConfig, updateNextConfigForNextI18next, updateNextConfigForNextIntl, updateNextConfigForNextTranslate, updateNuxtConfig, updateNuxtConfigForNuxtjsI18n, updateViteConfig, updateViteConfigForCompatPlugin, updateViteConfigForVueI18n, writeFileToRoot, writeIntlayerDependencyUpgrades };
|
|
@@ -15,6 +15,7 @@ const SKILLS_METADATA = {
|
|
|
15
15
|
Usage: "How to use Intlayer in your project",
|
|
16
16
|
CLI: "Intlayer CLI commands and usage",
|
|
17
17
|
Compiler: "Intlayer Compiler setup and usage for automatic content extraction without .content files",
|
|
18
|
+
BundleOptimization: "Purge, minify and import modes; writing code the bundle optimizer can follow",
|
|
18
19
|
RemoteContent: "How to use Intlayer with Remote/CMS/Server-side content",
|
|
19
20
|
DevTools: "ESLint, LSP, VS Code & Chrome extensions, MCP server and CI/CD",
|
|
20
21
|
Compat: "Migrate from i18next, next-intl, react-intl, vue-i18n, Lingui… keeping their API",
|
|
@@ -39,6 +40,7 @@ const BASE_SKILLS = [
|
|
|
39
40
|
"Config",
|
|
40
41
|
"CLI",
|
|
41
42
|
"Compiler",
|
|
43
|
+
"BundleOptimization",
|
|
42
44
|
"DevTools"
|
|
43
45
|
];
|
|
44
46
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["fs"],"sources":["../../../src/installSkills/index.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { v } from '@intlayer/config/logger';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\n\n/**\n * Metadata for each available documentation skill.\n */\nexport const SKILLS_METADATA = {\n Config: 'Intlayer configuration documentation',\n Content: 'Reference for all Intlayer content node types (t, enu, etc.)',\n Markdown:\n 'Markdown / rich text content: md(), MDX components, MarkdownProvider, SSR',\n Usage: 'How to use Intlayer in your project',\n CLI: 'Intlayer CLI commands and usage',\n Compiler:\n 'Intlayer Compiler setup and usage for automatic content extraction without .content files',\n RemoteContent: 'How to use Intlayer with Remote/CMS/Server-side content',\n DevTools: 'ESLint, LSP, VS Code & Chrome extensions, MCP server and CI/CD',\n Compat:\n 'Migrate from i18next, next-intl, react-intl, vue-i18n, Lingui… keeping their API',\n NextJS: 'Next.js-specific usage (Server & Client components)',\n React: 'React-specific syntax and hooks usage',\n Vue: 'Vue-specific composables and syntax',\n Svelte: 'Svelte-specific stores and syntax',\n Angular: 'Angular-specific syntax and Injectable Function usage',\n Preact: 'Preact-specific syntax and hooks usage',\n Solid: 'Solid-specific syntax and hooks usage',\n Astro: 'Astro-specific usage, middleware and islands',\n Lit: 'Lit-specific ReactiveController usage (useIntlayer, useLocale)',\n Vanilla: 'Framework-less JavaScript usage (vanilla-intlayer)',\n Remix: 'Remix 3 router middleware and request-scoped hooks',\n Backend:\n 'Server-side usage for Express, Fastify, Hono, NestJS, AdonisJS and Elysia',\n} as const;\n\nexport type Skill = keyof typeof SKILLS_METADATA;\n\nexport const SKILLS = Object.keys(SKILLS_METADATA) as Skill[];\n\n/** Skills preselected for every project, whatever its stack. */\nconst BASE_SKILLS: Skill[] = [\n 'Usage',\n 'Content',\n 'Config',\n 'CLI',\n 'Compiler',\n 'DevTools',\n];\n\n/**\n * Packages whose presence in `package.json` preselects a framework skill.\n * Both the framework itself and its Intlayer adapter are listed, so a skill is\n * suggested before and after the adapter is installed.\n */\nconst SKILL_TRIGGER_PACKAGES: Partial<Record<Skill, string[]>> = {\n NextJS: ['next', 'next-intlayer'],\n React: [\n 'react',\n 'react-intlayer',\n 'react-native-intlayer',\n 'react-scripts-intlayer',\n 'lynx-intlayer',\n ],\n Preact: ['preact', 'preact-intlayer'],\n Solid: ['solid-js', '@solidjs/start', 'solid-intlayer'],\n Vue: ['vue', 'nuxt', 'vue-intlayer', 'nuxt-intlayer'],\n Svelte: ['svelte', '@sveltejs/kit', 'svelte-intlayer'],\n Angular: ['@angular/core', '@analogjs/platform', 'angular-intlayer'],\n Astro: ['astro', 'astro-intlayer'],\n Lit: ['lit', 'lit-intlayer'],\n Vanilla: ['vanilla-intlayer'],\n Remix: ['remix', 'remix-intlayer'],\n Compat: [\n 'i18next',\n 'react-i18next',\n 'next-i18next',\n 'next-intl',\n 'use-intl',\n 'react-intl',\n 'vue-i18n',\n '@lingui/core',\n '@lingui/react',\n '@nuxtjs/i18n',\n '@ngx-translate/core',\n '@jsverse/transloco',\n 'svelte-i18n',\n 'next-translate',\n 'node-polyglot',\n 'i18n-js',\n '@intlayer/i18next',\n '@intlayer/react-i18next',\n '@intlayer/next-i18next',\n '@intlayer/next-intl',\n '@intlayer/use-intl',\n '@intlayer/react-intl',\n '@intlayer/vue-i18n',\n '@intlayer/lingui',\n '@intlayer/sync-json-plugin',\n '@intlayer/sync-po-plugin',\n ],\n Backend: [\n 'express',\n 'fastify',\n 'hono',\n 'elysia',\n '@nestjs/core',\n '@adonisjs/core',\n 'express-intlayer',\n 'fastify-intlayer',\n 'hono-intlayer',\n 'elysia-intlayer',\n 'adonis-intlayer',\n ],\n};\n\n/**\n * Resolves the skills to preselect from the project's installed packages.\n *\n * @param dependencies - Merged `dependencies` and `devDependencies` of `package.json`.\n * @returns The base skills plus every framework skill whose packages are installed.\n */\nexport const getInitialSkills = (\n dependencies: Record<string, string>\n): Skill[] => {\n const detectedSkills = SKILLS.filter((skill) =>\n SKILL_TRIGGER_PACKAGES[skill]?.some(\n (packageName) => packageName in dependencies\n )\n );\n\n return [...BASE_SKILLS, ...detectedSkills];\n};\n\nexport interface PlatformMetadata {\n label: string;\n dir: string;\n check?: () => boolean;\n}\n\n/**\n * Metadata and configuration for each supported platform.\n */\nexport const PLATFORMS_METADATA: Record<string, PlatformMetadata> = {\n Cursor: {\n label: 'Cursor',\n dir: '.cursor/skills',\n check: () =>\n process.env.CURSOR === 'true' || process.env.TERM_PROGRAM === 'cursor',\n },\n Windsurf: {\n label: 'Windsurf',\n dir: '.windsurf/skills',\n check: () =>\n process.env.WINDSURF === 'true' ||\n process.env.TERM_PROGRAM === 'windsurf',\n },\n Trae: {\n label: 'Trae',\n dir: '.trae/skills',\n check: () =>\n process.env.TRAE === 'true' || process.env.TERM_PROGRAM === 'trae',\n },\n TraeCN: {\n label: 'Trae CN',\n dir: '.trae/skills',\n check: () => process.env.TRAE_CN === 'true',\n },\n VSCode: {\n label: 'VS Code',\n dir: '.vscode/skills',\n check: () =>\n process.env.VSCODE === 'true' || process.env.TERM_PROGRAM === 'vscode',\n },\n OpenCode: {\n label: 'OpenCode',\n dir: '.opencode/skills',\n check: () => process.env.OPENCODE === 'true',\n },\n Claude: {\n label: 'Claude Code',\n dir: '.claude/skills',\n check: () => process.env.CLAUDE === 'true',\n },\n GitHub: {\n label: 'GitHub Copilot Workspace',\n dir: '.github/skills',\n check: () =>\n process.env.GITHUB_ACTIONS === 'true' || !!process.env.GITHUB_WORKSPACE,\n },\n Antigravity: {\n label: 'Antigravity',\n dir: '.agent/skills',\n },\n Augment: {\n label: 'Augment',\n dir: '.augment/skills',\n },\n OpenClaw: {\n label: 'OpenClaw',\n dir: 'skills',\n },\n Cline: {\n label: 'Cline',\n dir: '.cline/skills',\n },\n CodeBuddy: {\n label: 'CodeBuddy',\n dir: '.codebuddy/skills',\n },\n CommandCode: {\n label: 'Command Code',\n dir: '.commandcode/skills',\n },\n Continue: {\n label: 'Continue',\n dir: '.continue/skills',\n },\n Crush: {\n label: 'Crush',\n dir: '.crush/skills',\n },\n Droid: {\n label: 'Droid',\n dir: '.factory/skills',\n },\n Goose: {\n label: 'Goose',\n dir: '.goose/skills',\n },\n IFlow: {\n label: 'iFlow CLI',\n dir: '.iflow/skills',\n },\n Junie: {\n label: 'Junie',\n dir: '.junie/skills',\n },\n KiloCode: {\n label: 'Kilo Code',\n dir: '.kilocode/skills',\n },\n Kiro: {\n label: 'Kiro CLI',\n dir: '.kiro/skills',\n },\n Kode: {\n label: 'Kode',\n dir: '.kode/skills',\n },\n MCPJam: {\n label: 'MCPJam',\n dir: '.mcpjam/skills',\n },\n MistralVibe: {\n label: 'Mistral Vibe',\n dir: '.vibe/skills',\n },\n Mux: {\n label: 'Mux',\n dir: '.mux/skills',\n },\n OpenHands: {\n label: 'OpenHands',\n dir: '.openhands/skills',\n },\n Pi: {\n label: 'Pi',\n dir: '.pi/skills',\n },\n Qoder: {\n label: 'Qoder',\n dir: '.qoder/skills',\n },\n Qwen: {\n label: 'Qwen Code',\n dir: '.qwen/skills',\n },\n RooCode: {\n label: 'Roo Code',\n dir: '.roo/skills',\n },\n Zencoder: {\n label: 'Zencoder',\n dir: '.zencoder/skills',\n },\n Neovate: {\n label: 'Neovate',\n dir: '.neovate/skills',\n },\n Pochi: {\n label: 'Pochi',\n dir: '.pochi/skills',\n },\n Other: {\n label: 'Other',\n dir: 'skills',\n },\n} as const;\n\nexport type Platform = keyof typeof PLATFORMS_METADATA;\n\nexport const PLATFORMS = Object.keys(PLATFORMS_METADATA) as Platform[];\n\n/**\n * Maps specific skill keys to special filenames if they differ from standard snake_case.\n */\nconst SKILL_FILENAME_MAP: Partial<Record<Skill, string>> = {};\n\n/**\n * Helper to convert CamelCase to kebab-case for directory naming\n */\nconst camelToKebabCase = (str: string) =>\n str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Reads the raw markdown content for a specific skill from the assets folder.\n */\nconst getSkillContent = (skill: Skill): string => {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const fileName = `./skills/${baseName}.md`;\n\n try {\n return readAsset(fileName);\n } catch {\n console.warn(\n `Warning: Could not read asset for skill: ${skill} at ${fileName}`\n );\n return '';\n }\n};\n\n/**\n * Reads the licence content from the assets folder.\n */\nconst getLicenceContent = (): string => {\n try {\n return readAsset('./LICENCE.md');\n } catch {\n console.warn('Warning: Could not read LICENCE.md asset');\n return '';\n }\n};\n\nconst ALLOWED_FETCH_HOSTS = new Set(['intlayer.org']);\n\n/** Upper bound on the redirect chain a reference URL may take. */\nconst MAX_FETCH_REDIRECTS = 5;\n\n/**\n * Parses a URL and rejects it unless it is an HTTPS address on an allowed host.\n *\n * @param url - Absolute URL to validate.\n * @returns The parsed URL.\n * @throws When the protocol or host is not allowed.\n */\nconst parseAllowedUrl = (url: string | URL): URL => {\n const parsed = new URL(url);\n\n if (\n parsed.protocol !== 'https:' ||\n !ALLOWED_FETCH_HOSTS.has(parsed.hostname)\n ) {\n throw new Error(`Blocked fetch to disallowed host: ${parsed.hostname}`);\n }\n\n return parsed;\n};\n\n/**\n * Fetches the content of a URL using native fetch.\n *\n * Redirects are followed manually so every hop is re-checked against the host\n * allowlist — a redirect off `intlayer.org` is refused rather than silently\n * followed. Letting `fetch` refuse them outright (`redirect: 'error'`) instead\n * reported an unhelpful `TypeError: fetch failed` for a documentation URL that\n * merely moved.\n *\n * @param url - Absolute URL to read.\n * @returns The response body as text.\n */\nconst fetchUrlContent = async (url: string): Promise<string> => {\n let target = parseAllowedUrl(url);\n\n for (let hop = 0; hop <= MAX_FETCH_REDIRECTS; hop++) {\n const response = await fetch(target, { redirect: 'manual' });\n\n if (response.status >= 300 && response.status < 400) {\n const location = response.headers.get('location');\n\n if (!location) {\n throw new Error(`Failed to fetch ${url}: redirect without a location`);\n }\n\n target = parseAllowedUrl(new URL(location, target));\n continue;\n }\n\n if (!response.ok) {\n throw new Error(`Failed to fetch ${url}: ${response.statusText}`);\n }\n\n return response.text();\n }\n\n throw new Error(`Failed to fetch ${url}: too many redirects`);\n};\n\n/**\n * Installs skills using the \"Agent Skills\" directory standard.\n * Standard: <PROJECT_ROOT>/<CONFIG_DIR>/skills/<SKILL_NAME>/SKILL.md\n */\nexport const installSkills = async (\n projectRoot: string,\n platform: Platform,\n skills: Skill[]\n): Promise<string> => {\n // Determine destination directory\n const relativeDir = PLATFORMS_METADATA[platform]?.dir ?? 'skills';\n const skillsBaseDir = path.join(projectRoot, relativeDir);\n\n // Ensure the base directory exists\n await fs.mkdir(skillsBaseDir, { recursive: true });\n\n const createdSkills: string[] = [];\n const licenceContent = getLicenceContent();\n\n for (const skill of skills) {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const skillName = `intlayer-${baseName}`;\n const skillContent = getSkillContent(skill);\n\n if (!skillContent) continue;\n\n // Extract unique URLs\n const urls = Array.from(\n new Set(skillContent.match(/https:\\/\\/intlayer\\.org\\/[^\\s)]+\\.md/g) || [])\n );\n\n // Agent Standard: .../skills/<skill-name>/SKILL.md\n const skillDir = path.join(skillsBaseDir, skillName);\n const referenceDir = path.join(skillDir, 'references');\n\n // Ensure directories exist\n await fs.mkdir(referenceDir, { recursive: true });\n\n // Write License\n if (licenceContent) {\n await fs.writeFile(\n path.join(skillDir, 'LICENCE.md'),\n licenceContent,\n 'utf-8'\n );\n }\n\n let updatedSkillContent = skillContent;\n\n // Parallel download of references\n const downloadPromises = urls.map(async (url) => {\n try {\n const content = await fetchUrlContent(url);\n const metadata = getMarkdownMetadata<{ slugs?: string[] }>(content);\n\n let fileName = '';\n\n // Determine filename from slugs or URL path\n if (Array.isArray(metadata.slugs)) {\n fileName = metadata.slugs\n .filter((slug) => slug !== 'doc')\n .join('_')\n // Scoped package slugs (`@intlayer/babel`) must not create subfolders\n .replaceAll('/', '_');\n } else {\n const urlPath = new URL(url).pathname;\n fileName = urlPath\n .split('/')\n .filter((part) => part && part !== 'doc')\n .map((part) => part.replace('.md', '')) // Clean extension for joining\n .join('_');\n }\n\n // Ensure it ends with .md\n fileName = fileName ? `${fileName}.md` : 'index.md';\n const localRefPath = `references/${fileName}`;\n\n return {\n url,\n localRefPath,\n fileName,\n content,\n success: true,\n };\n } catch (error) {\n console.warn(\n `Warning: Failed to download ref ${url} for skill ${skill}`,\n error\n );\n return { url, success: false };\n }\n });\n\n const results = await Promise.all(downloadPromises);\n\n // Process results: Write files and update content string\n for (const res of results) {\n if (res.success && res.fileName && res.content && res.localRefPath) {\n // Write the reference file\n await fs.writeFile(\n path.join(referenceDir, res.fileName),\n res.content,\n 'utf-8'\n );\n\n // Update the main content to point to local file\n updatedSkillContent = updatedSkillContent.replaceAll(\n res.url,\n res.localRefPath\n );\n }\n }\n\n // Write the main SKILL.md\n const filePath = path.join(skillDir, 'SKILL.md');\n await fs.writeFile(filePath, updatedSkillContent, 'utf-8');\n createdSkills.push(`${skillName}/SKILL.md`);\n }\n\n if (createdSkills.length === 0) {\n return `No skill files were created. Check your asset paths.`;\n }\n\n return `${v} Created ${createdSkills.length} skills in ${skillsBaseDir}`;\n};\n"],"mappings":";;;;;;;;;;AASA,MAAa,kBAAkB;CAC7B,QAAQ;CACR,SAAS;CACT,UACE;CACF,OAAO;CACP,KAAK;CACL,UACE;CACF,eAAe;CACf,UAAU;CACV,QACE;CACF,QAAQ;CACR,OAAO;CACP,KAAK;CACL,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,OAAO;CACP,OAAO;CACP,KAAK;CACL,SAAS;CACT,OAAO;CACP,SACE;AACJ;AAIA,MAAa,SAAS,OAAO,KAAK,eAAe;;AAGjD,MAAM,cAAuB;CAC3B;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,MAAM,y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AW,UAAU,QAAQ,IAAI,iBAAiB;CAClE;CACA,UAAU;EACR,OAAO;EACP,KAAK;EACL,aAAa,QAAQ,IAAI,aAAa;CACxC;CACA,QAAQ;EACN,OAAO;EACP,KAAK;EACL,aAAa,QAAQ,IAAI,WAAW;CACtC;CACA,QAAQ;EACN,OAAO;EACP,KAAK;EACL,aACE,QAAQ,IAAI,mBAAmB,UAAU,CAAC,CAAC,QAAQ,IAAI;CAC3D;CACA,aAAa;EACX,OAAO;EACP,KAAK;CACP;CACA,SAAS;EACP,OAAO;EACP,KAAK;CACP;CACA,UAAU;EACR,OAAO;EACP,KAAK;CACP;CACA,OAAO;EACL,OAAO;EACP,KAAK;CACP;CACA,WAAW;EACT,OAAO;EACP,KAAK;CACP;CACA,aAAa;EACX,OAAO;EACP,KAAK;CACP;CACA,UAAU;EACR,OAAO;EACP,KAAK;CACP;CACA,OAAO;EACL,OAAO;EACP,KAAK;CACP;CACA,OAAO;EACL,OAAO;EACP,KAAK;CACP;CACA,OAAO;EACL,OAAO;EACP,KAAK;CACP;CACA,OAAO;EACL,OAAO;EACP,KAAK;CACP;CACA,OAAO;EACL,OAAO;EACP,KAAK;CACP;CACA,UAAU;EACR,OAAO;EACP,KAAK;CACP;CACA,MAAM;EACJ,OAAO;EACP,KAAK;CACP;CACA,MAAM;EACJ,OAAO;EACP,KAAK;CACP;CACA,QAAQ;EACN,OAAO;EACP,KAAK;CACP;CACA,aAAa;EACX,OAAO;EACP,KAAK;CACP;CACA,KAAK;EACH,OAAO;EACP,KAAK;CACP;CACA,WAAW;EACT,OAAO;EACP,KAAK;CACP;CACA,IAAI;EACF,OAAO;EACP,KAAK;CACP;CACA,OAAO;EACL,OAAO;EACP,KAAK;CACP;CACA,MAAM;EACJ,OAAO;EACP,KAAK;CACP;CACA,SAAS;EACP,OAAO;EACP,KAAK;CACP;CACA,UAAU;EACR,OAAO;EACP,KAAK;CACP;CACA,SAAS;EACP,OAAO;EACP,KAAK;CACP;CACA,OAAO;EACL,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GAAG,CAAC,CACV,QAAQ,SAAS,QAAQ,SAAS,KAAK,CAAC,CACxC,KAAK,SAAS,KAAK,QAAQ,OAAO,EAAE,CAAC,CAAC,CACtC,KAAK,GAAG;IAIb,WAAW,WAAW,GAAG,SAAS,OAAO;IAGzC,OAAO;KACL;KACA,4BAJiC;KAKjC;KACA;KACA,SAAS;IACX;GACF,SAAS,OAAO;IACd,QAAQ,KACN,mCAAmC,IAAI,aAAa,SACpD,KACF;IACA,OAAO;KAAE;KAAK,SAAS;IAAM;GAC/B;EACF,CAAC;EAED,MAAM,UAAU,MAAM,QAAQ,IAAI,gBAAgB;EAGlD,KAAK,MAAM,OAAO,SAChB,IAAI,IAAI,WAAW,IAAI,YAAY,IAAI,WAAW,IAAI,cAAc;GAElE,MAAMA,SAAG,UACP,KAAK,KAAK,cAAc,IAAI,QAAQ,GACpC,IAAI,SACJ,OACF;GAGA,sBAAsB,oBAAoB,WACxC,IAAI,KACJ,IAAI,YACN;EACF;EAIF,MAAM,WAAW,KAAK,KAAK,UAAU,UAAU;EAC/C,MAAMA,SAAG,UAAU,UAAU,qBAAqB,OAAO;EACzD,cAAc,KAAK,GAAG,UAAU,UAAU;CAC5C;CAEA,IAAI,cAAc,WAAW,GAC3B,OAAO;CAGT,OAAO,GAAG,EAAE,WAAW,cAAc,OAAO,aAAa;AAC3D"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["fs"],"sources":["../../../src/installSkills/index.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { readAsset } from 'utils:asset';\nimport { v } from '@intlayer/config/logger';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\n\n/**\n * Metadata for each available documentation skill.\n */\nexport const SKILLS_METADATA = {\n Config: 'Intlayer configuration documentation',\n Content: 'Reference for all Intlayer content node types (t, enu, etc.)',\n Markdown:\n 'Markdown / rich text content: md(), MDX components, MarkdownProvider, SSR',\n Usage: 'How to use Intlayer in your project',\n CLI: 'Intlayer CLI commands and usage',\n Compiler:\n 'Intlayer Compiler setup and usage for automatic content extraction without .content files',\n BundleOptimization:\n 'Purge, minify and import modes; writing code the bundle optimizer can follow',\n RemoteContent: 'How to use Intlayer with Remote/CMS/Server-side content',\n DevTools: 'ESLint, LSP, VS Code & Chrome extensions, MCP server and CI/CD',\n Compat:\n 'Migrate from i18next, next-intl, react-intl, vue-i18n, Lingui… keeping their API',\n NextJS: 'Next.js-specific usage (Server & Client components)',\n React: 'React-specific syntax and hooks usage',\n Vue: 'Vue-specific composables and syntax',\n Svelte: 'Svelte-specific stores and syntax',\n Angular: 'Angular-specific syntax and Injectable Function usage',\n Preact: 'Preact-specific syntax and hooks usage',\n Solid: 'Solid-specific syntax and hooks usage',\n Astro: 'Astro-specific usage, middleware and islands',\n Lit: 'Lit-specific ReactiveController usage (useIntlayer, useLocale)',\n Vanilla: 'Framework-less JavaScript usage (vanilla-intlayer)',\n Remix: 'Remix 3 router middleware and request-scoped hooks',\n Backend:\n 'Server-side usage for Express, Fastify, Hono, NestJS, AdonisJS and Elysia',\n} as const;\n\nexport type Skill = keyof typeof SKILLS_METADATA;\n\nexport const SKILLS = Object.keys(SKILLS_METADATA) as Skill[];\n\n/** Skills preselected for every project, whatever its stack. */\nconst BASE_SKILLS: Skill[] = [\n 'Usage',\n 'Content',\n 'Config',\n 'CLI',\n 'Compiler',\n 'BundleOptimization',\n 'DevTools',\n];\n\n/**\n * Packages whose presence in `package.json` preselects a framework skill.\n * Both the framework itself and its Intlayer adapter are listed, so a skill is\n * suggested before and after the adapter is installed.\n */\nconst SKILL_TRIGGER_PACKAGES: Partial<Record<Skill, string[]>> = {\n NextJS: ['next', 'next-intlayer'],\n React: [\n 'react',\n 'react-intlayer',\n 'react-native-intlayer',\n 'react-scripts-intlayer',\n 'lynx-intlayer',\n ],\n Preact: ['preact', 'preact-intlayer'],\n Solid: ['solid-js', '@solidjs/start', 'solid-intlayer'],\n Vue: ['vue', 'nuxt', 'vue-intlayer', 'nuxt-intlayer'],\n Svelte: ['svelte', '@sveltejs/kit', 'svelte-intlayer'],\n Angular: ['@angular/core', '@analogjs/platform', 'angular-intlayer'],\n Astro: ['astro', 'astro-intlayer'],\n Lit: ['lit', 'lit-intlayer'],\n Vanilla: ['vanilla-intlayer'],\n Remix: ['remix', 'remix-intlayer'],\n Compat: [\n 'i18next',\n 'react-i18next',\n 'next-i18next',\n 'next-intl',\n 'use-intl',\n 'react-intl',\n 'vue-i18n',\n '@lingui/core',\n '@lingui/react',\n '@nuxtjs/i18n',\n '@ngx-translate/core',\n '@jsverse/transloco',\n 'svelte-i18n',\n 'next-translate',\n 'node-polyglot',\n 'i18n-js',\n '@intlayer/i18next',\n '@intlayer/react-i18next',\n '@intlayer/next-i18next',\n '@intlayer/next-intl',\n '@intlayer/use-intl',\n '@intlayer/react-intl',\n '@intlayer/vue-i18n',\n '@intlayer/lingui',\n '@intlayer/sync-json-plugin',\n '@intlayer/sync-po-plugin',\n ],\n Backend: [\n 'express',\n 'fastify',\n 'hono',\n 'elysia',\n '@nestjs/core',\n '@adonisjs/core',\n 'express-intlayer',\n 'fastify-intlayer',\n 'hono-intlayer',\n 'elysia-intlayer',\n 'adonis-intlayer',\n ],\n};\n\n/**\n * Resolves the skills to preselect from the project's installed packages.\n *\n * @param dependencies - Merged `dependencies` and `devDependencies` of `package.json`.\n * @returns The base skills plus every framework skill whose packages are installed.\n */\nexport const getInitialSkills = (\n dependencies: Record<string, string>\n): Skill[] => {\n const detectedSkills = SKILLS.filter((skill) =>\n SKILL_TRIGGER_PACKAGES[skill]?.some(\n (packageName) => packageName in dependencies\n )\n );\n\n return [...BASE_SKILLS, ...detectedSkills];\n};\n\nexport interface PlatformMetadata {\n label: string;\n dir: string;\n check?: () => boolean;\n}\n\n/**\n * Metadata and configuration for each supported platform.\n */\nexport const PLATFORMS_METADATA: Record<string, PlatformMetadata> = {\n Cursor: {\n label: 'Cursor',\n dir: '.cursor/skills',\n check: () =>\n process.env.CURSOR === 'true' || process.env.TERM_PROGRAM === 'cursor',\n },\n Windsurf: {\n label: 'Windsurf',\n dir: '.windsurf/skills',\n check: () =>\n process.env.WINDSURF === 'true' ||\n process.env.TERM_PROGRAM === 'windsurf',\n },\n Trae: {\n label: 'Trae',\n dir: '.trae/skills',\n check: () =>\n process.env.TRAE === 'true' || process.env.TERM_PROGRAM === 'trae',\n },\n TraeCN: {\n label: 'Trae CN',\n dir: '.trae/skills',\n check: () => process.env.TRAE_CN === 'true',\n },\n VSCode: {\n label: 'VS Code',\n dir: '.vscode/skills',\n check: () =>\n process.env.VSCODE === 'true' || process.env.TERM_PROGRAM === 'vscode',\n },\n OpenCode: {\n label: 'OpenCode',\n dir: '.opencode/skills',\n check: () => process.env.OPENCODE === 'true',\n },\n Claude: {\n label: 'Claude Code',\n dir: '.claude/skills',\n check: () => process.env.CLAUDE === 'true',\n },\n GitHub: {\n label: 'GitHub Copilot Workspace',\n dir: '.github/skills',\n check: () =>\n process.env.GITHUB_ACTIONS === 'true' || !!process.env.GITHUB_WORKSPACE,\n },\n Antigravity: {\n label: 'Antigravity',\n dir: '.agent/skills',\n },\n Augment: {\n label: 'Augment',\n dir: '.augment/skills',\n },\n OpenClaw: {\n label: 'OpenClaw',\n dir: 'skills',\n },\n Cline: {\n label: 'Cline',\n dir: '.cline/skills',\n },\n CodeBuddy: {\n label: 'CodeBuddy',\n dir: '.codebuddy/skills',\n },\n CommandCode: {\n label: 'Command Code',\n dir: '.commandcode/skills',\n },\n Continue: {\n label: 'Continue',\n dir: '.continue/skills',\n },\n Crush: {\n label: 'Crush',\n dir: '.crush/skills',\n },\n Droid: {\n label: 'Droid',\n dir: '.factory/skills',\n },\n Goose: {\n label: 'Goose',\n dir: '.goose/skills',\n },\n IFlow: {\n label: 'iFlow CLI',\n dir: '.iflow/skills',\n },\n Junie: {\n label: 'Junie',\n dir: '.junie/skills',\n },\n KiloCode: {\n label: 'Kilo Code',\n dir: '.kilocode/skills',\n },\n Kiro: {\n label: 'Kiro CLI',\n dir: '.kiro/skills',\n },\n Kode: {\n label: 'Kode',\n dir: '.kode/skills',\n },\n MCPJam: {\n label: 'MCPJam',\n dir: '.mcpjam/skills',\n },\n MistralVibe: {\n label: 'Mistral Vibe',\n dir: '.vibe/skills',\n },\n Mux: {\n label: 'Mux',\n dir: '.mux/skills',\n },\n OpenHands: {\n label: 'OpenHands',\n dir: '.openhands/skills',\n },\n Pi: {\n label: 'Pi',\n dir: '.pi/skills',\n },\n Qoder: {\n label: 'Qoder',\n dir: '.qoder/skills',\n },\n Qwen: {\n label: 'Qwen Code',\n dir: '.qwen/skills',\n },\n RooCode: {\n label: 'Roo Code',\n dir: '.roo/skills',\n },\n Zencoder: {\n label: 'Zencoder',\n dir: '.zencoder/skills',\n },\n Neovate: {\n label: 'Neovate',\n dir: '.neovate/skills',\n },\n Pochi: {\n label: 'Pochi',\n dir: '.pochi/skills',\n },\n Other: {\n label: 'Other',\n dir: 'skills',\n },\n} as const;\n\nexport type Platform = keyof typeof PLATFORMS_METADATA;\n\nexport const PLATFORMS = Object.keys(PLATFORMS_METADATA) as Platform[];\n\n/**\n * Maps specific skill keys to special filenames if they differ from standard snake_case.\n */\nconst SKILL_FILENAME_MAP: Partial<Record<Skill, string>> = {};\n\n/**\n * Helper to convert CamelCase to kebab-case for directory naming\n */\nconst camelToKebabCase = (str: string) =>\n str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Reads the raw markdown content for a specific skill from the assets folder.\n */\nconst getSkillContent = (skill: Skill): string => {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const fileName = `./skills/${baseName}.md`;\n\n try {\n return readAsset(fileName);\n } catch {\n console.warn(\n `Warning: Could not read asset for skill: ${skill} at ${fileName}`\n );\n return '';\n }\n};\n\n/**\n * Reads the licence content from the assets folder.\n */\nconst getLicenceContent = (): string => {\n try {\n return readAsset('./LICENCE.md');\n } catch {\n console.warn('Warning: Could not read LICENCE.md asset');\n return '';\n }\n};\n\nconst ALLOWED_FETCH_HOSTS = new Set(['intlayer.org']);\n\n/** Upper bound on the redirect chain a reference URL may take. */\nconst MAX_FETCH_REDIRECTS = 5;\n\n/**\n * Parses a URL and rejects it unless it is an HTTPS address on an allowed host.\n *\n * @param url - Absolute URL to validate.\n * @returns The parsed URL.\n * @throws When the protocol or host is not allowed.\n */\nconst parseAllowedUrl = (url: string | URL): URL => {\n const parsed = new URL(url);\n\n if (\n parsed.protocol !== 'https:' ||\n !ALLOWED_FETCH_HOSTS.has(parsed.hostname)\n ) {\n throw new Error(`Blocked fetch to disallowed host: ${parsed.hostname}`);\n }\n\n return parsed;\n};\n\n/**\n * Fetches the content of a URL using native fetch.\n *\n * Redirects are followed manually so every hop is re-checked against the host\n * allowlist — a redirect off `intlayer.org` is refused rather than silently\n * followed. Letting `fetch` refuse them outright (`redirect: 'error'`) instead\n * reported an unhelpful `TypeError: fetch failed` for a documentation URL that\n * merely moved.\n *\n * @param url - Absolute URL to read.\n * @returns The response body as text.\n */\nconst fetchUrlContent = async (url: string): Promise<string> => {\n let target = parseAllowedUrl(url);\n\n for (let hop = 0; hop <= MAX_FETCH_REDIRECTS; hop++) {\n const response = await fetch(target, { redirect: 'manual' });\n\n if (response.status >= 300 && response.status < 400) {\n const location = response.headers.get('location');\n\n if (!location) {\n throw new Error(`Failed to fetch ${url}: redirect without a location`);\n }\n\n target = parseAllowedUrl(new URL(location, target));\n continue;\n }\n\n if (!response.ok) {\n throw new Error(`Failed to fetch ${url}: ${response.statusText}`);\n }\n\n return response.text();\n }\n\n throw new Error(`Failed to fetch ${url}: too many redirects`);\n};\n\n/**\n * Installs skills using the \"Agent Skills\" directory standard.\n * Standard: <PROJECT_ROOT>/<CONFIG_DIR>/skills/<SKILL_NAME>/SKILL.md\n */\nexport const installSkills = async (\n projectRoot: string,\n platform: Platform,\n skills: Skill[]\n): Promise<string> => {\n // Determine destination directory\n const relativeDir = PLATFORMS_METADATA[platform]?.dir ?? 'skills';\n const skillsBaseDir = path.join(projectRoot, relativeDir);\n\n // Ensure the base directory exists\n await fs.mkdir(skillsBaseDir, { recursive: true });\n\n const createdSkills: string[] = [];\n const licenceContent = getLicenceContent();\n\n for (const skill of skills) {\n const baseName = SKILL_FILENAME_MAP[skill] ?? camelToKebabCase(skill);\n const skillName = `intlayer-${baseName}`;\n const skillContent = getSkillContent(skill);\n\n if (!skillContent) continue;\n\n // Extract unique URLs\n const urls = Array.from(\n new Set(skillContent.match(/https:\\/\\/intlayer\\.org\\/[^\\s)]+\\.md/g) || [])\n );\n\n // Agent Standard: .../skills/<skill-name>/SKILL.md\n const skillDir = path.join(skillsBaseDir, skillName);\n const referenceDir = path.join(skillDir, 'references');\n\n // Ensure directories exist\n await fs.mkdir(referenceDir, { recursive: true });\n\n // Write License\n if (licenceContent) {\n await fs.writeFile(\n path.join(skillDir, 'LICENCE.md'),\n licenceContent,\n 'utf-8'\n );\n }\n\n let updatedSkillContent = skillContent;\n\n // Parallel download of references\n const downloadPromises = urls.map(async (url) => {\n try {\n const content = await fetchUrlContent(url);\n const metadata = getMarkdownMetadata<{ slugs?: string[] }>(content);\n\n let fileName = '';\n\n // Determine filename from slugs or URL path\n if (Array.isArray(metadata.slugs)) {\n fileName = metadata.slugs\n .filter((slug) => slug !== 'doc')\n .join('_')\n // Scoped package slugs (`@intlayer/babel`) must not create subfolders\n .replaceAll('/', '_');\n } else {\n const urlPath = new URL(url).pathname;\n fileName = urlPath\n .split('/')\n .filter((part) => part && part !== 'doc')\n .map((part) => part.replace('.md', '')) // Clean extension for joining\n .join('_');\n }\n\n // Ensure it ends with .md\n fileName = fileName ? `${fileName}.md` : 'index.md';\n const localRefPath = `references/${fileName}`;\n\n return {\n url,\n localRefPath,\n fileName,\n content,\n success: true,\n };\n } catch (error) {\n console.warn(\n `Warning: Failed to download ref ${url} for skill ${skill}`,\n error\n );\n return { url, success: false };\n }\n });\n\n const results = await Promise.all(downloadPromises);\n\n // Process results: Write files and update content string\n for (const res of results) {\n if (res.success && res.fileName && res.content && res.localRefPath) {\n // Write the reference file\n await fs.writeFile(\n path.join(referenceDir, res.fileName),\n res.content,\n 'utf-8'\n );\n\n // Update the main content to point to local file\n updatedSkillContent = updatedSkillContent.replaceAll(\n res.url,\n res.localRefPath\n );\n }\n }\n\n // Write the main SKILL.md\n const filePath = path.join(skillDir, 'SKILL.md');\n await fs.writeFile(filePath, updatedSkillContent, 'utf-8');\n createdSkills.push(`${skillName}/SKILL.md`);\n }\n\n if (createdSkills.length === 0) {\n return `No skill files were created. Check your asset paths.`;\n }\n\n return `${v} Created ${createdSkills.length} skills in ${skillsBaseDir}`;\n};\n"],"mappings":";;;;;;;;;;AASA,MAAa,kBAAkB;CAC7B,QAAQ;CACR,SAAS;CACT,UACE;CACF,OAAO;CACP,KAAK;CACL,UACE;CACF,oBACE;CACF,eAAe;CACf,UAAU;CACV,QACE;CACF,QAAQ;CACR,OAAO;CACP,KAAK;CACL,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,OAAO;CACP,OAAO;CACP,KAAK;CACL,SAAS;CACT,OAAO;CACP,SACE;AACJ;AAIA,MAAa,SAAS,OAAO,KAAK,eAAe;;AAGjD,MAAM,cAAuB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,MAAM,yBAA2D;CAC/D,QAAQ,CAAC,QAAQ,eAAe;CAChC,OAAO;EACL;EACA;EACA;EACA;EACA;CACF;CACA,QAAQ,CAAC,UAAU,iBAAiB;CACpC,OAAO;EAAC;EAAY;EAAkB;CAAgB;CACtD,KAAK;EAAC;EAAO;EAAQ;EAAgB;CAAe;CACpD,QAAQ;EAAC;EAAU;EAAiB;CAAiB;CACrD,SAAS;EAAC;EAAiB;EAAsB;CAAkB;CACnE,OAAO,CAAC,SAAS,gBAAgB;CACjC,KAAK,CAAC,OAAO,cAAc;CAC3B,SAAS,CAAC,kBAAkB;CAC5B,OAAO,CAAC,SAAS,gBAAgB;CACjC,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;E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WAAW,IAAI,cAAc;GAElE,MAAMA,SAAG,UACP,KAAK,KAAK,cAAc,IAAI,QAAQ,GACpC,IAAI,SACJ,OACF;GAGA,sBAAsB,oBAAoB,WACxC,IAAI,KACJ,IAAI,YACN;EACF;EAIF,MAAM,WAAW,KAAK,KAAK,UAAU,UAAU;EAC/C,MAAMA,SAAG,UAAU,UAAU,qBAAqB,OAAO;EACzD,cAAc,KAAK,GAAG,UAAU,UAAU;CAC5C;CAEA,IAAI,cAAc,WAAW,GAC3B,OAAO;CAGT,OAAO,GAAG,EAAE,WAAW,cAAc,OAAO,aAAa;AAC3D"}
|
|
@@ -78,6 +78,14 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
|
78
78
|
const { plugins } = configuration;
|
|
79
79
|
const loadDictionariesStartTime = Date.now();
|
|
80
80
|
getAppLogger(configuration)("Dictionaries:", { isVerbose: true });
|
|
81
|
+
const hasRemoteDictionaries = Boolean(configuration.editor.clientId && configuration.editor.clientSecret);
|
|
82
|
+
if (hasRemoteDictionaries) logger$1.setExpectRemote(true);
|
|
83
|
+
const remoteDictionariesPromise = hasRemoteDictionaries ? loadRemoteDictionaries(configuration, setLoadDictionariesStatus, {
|
|
84
|
+
onStartRemoteCheck: () => logger$1.startRemoteCheck(),
|
|
85
|
+
onStopRemoteCheck: () => logger$1.stopRemoteCheck(),
|
|
86
|
+
onError: (error) => logger$1.setRemoteError(error)
|
|
87
|
+
}).then((dictionaries) => filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => formatDictionaries(dictionaries)) : Promise.resolve([]);
|
|
88
|
+
remoteDictionariesPromise.catch(() => void 0);
|
|
81
89
|
const pluginsWithLoadDictionaries = (await Promise.all(plugins ?? [])).filter((plugin) => plugin.loadDictionaries);
|
|
82
90
|
logger$1.setPluginNames(pluginsWithLoadDictionaries.map(({ name }) => name));
|
|
83
91
|
const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(async (plugin) => {
|
|
@@ -100,14 +108,7 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
|
100
108
|
status: "built"
|
|
101
109
|
}));
|
|
102
110
|
setLoadDictionariesStatus(localDictionariesStatus);
|
|
103
|
-
const
|
|
104
|
-
if (hasRemoteDictionaries) logger$1.setExpectRemote(true);
|
|
105
|
-
let remoteDictionaries = [];
|
|
106
|
-
if (hasRemoteDictionaries) remoteDictionaries = await loadRemoteDictionaries(configuration, setLoadDictionariesStatus, {
|
|
107
|
-
onStartRemoteCheck: () => logger$1.startRemoteCheck(),
|
|
108
|
-
onStopRemoteCheck: () => logger$1.stopRemoteCheck(),
|
|
109
|
-
onError: (e) => logger$1.setRemoteError(e)
|
|
110
|
-
}).then((dictionaries) => filterInvalidDictionaries(dictionaries, configuration)).then((dictionaries) => formatDictionaries(dictionaries));
|
|
111
|
+
const remoteDictionaries = await remoteDictionariesPromise;
|
|
111
112
|
const remoteDictionariesTime = Date.now();
|
|
112
113
|
logger$1.finish();
|
|
113
114
|
printSummary(configuration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadDictionaries.mjs","names":["logger"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport {\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const resolvedPlugins = await Promise.all(plugins ?? []);\n\n const pluginsWithLoadDictionaries = resolvedPlugins.filter(\n (plugin) => plugin.loadDictionaries\n );\n\n logger.setPluginNames(pluginsWithLoadDictionaries.map(({ name }) => name));\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error, plugin.name);\n\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n logger.setPluginTotal(pluginDictionaries.length);\n logger.setPluginDone(pluginDictionaries.length);\n\n const pluginDictionariesTime = Date.now();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n let remoteDictionaries: Dictionary[] = [];\n\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus,\n {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (e) => logger.setRemoteError(e),\n }\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n }\n\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - pluginDictionariesTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;AA8BA,IAAI,yBAA+C,CAAC;AACpD,MAAMA,WAAS,IAAI,mBAAmB;AAEtC,MAAM,6BAA6B,aAAmC;CACpE,MAAM,UAAgC,CAAC,GAAG,sBAAsB;CAEhE,KAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,IACtE;EACA,IAAI,SAAS,GACX,QAAQ,SAAS;OAEjB,QAAQ,KAAK,QAAQ;CAEzB;CAEA,yBAAyB;CACzB,SAAO,OAAO,QAAQ;CAEtB,OAAO;AACT;AAOA,MAAM,WAAW,WAAyC;CACxD,QAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,WACH,OAAO;EACT,KAAK,SACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,MAAM,YAAY,WAAyC;CACzD,QAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,WACH,OAAO,WAAW;EACpB,KAAK,SACH,OAAO,WAAW;EACpB,SACE,OAAO,WAAW;CACtB;AACF;AAEA,MAAM,gBAAgB,kBAAkC;CACtD,IAAI,cAAc,IAAI,SAAS,WAAW;CAE1C,MAAM,YAAY,aAAa,aAAa;CAG5C,MAAM,wBAAQ,IAAI,IAA0B;CAC5C,KAAK,MAAM,UAAU,wBAAwB;EAC3C,MAAM,MAAM,MAAM,IAAI,OAAO,aAAa,KAAK,CAAC;EAChD,IAAI,OAAO,SAAS,SAAS,IAAI,QAAQ,OAAO;EAChD,IAAI,OAAO,SAAS,UAAU,IAAI,SAAS,OAAO;EAClD,M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AwB,QAC5B,cAAc,OAAO,YAAY,cAAc,OAAO,YACxD;CAEA,IAAI,uBAEF,SAAO,gBAAgB,IAAI;CAG7B,IAAI,qBAAmC,CAAC;CAExC,IAAI,uBACF,qBAAqB,MAAM,uBACzB,eACA,2BACA;EACE,0BAA0BA,SAAO,iBAAiB;EAClD,yBAAyBA,SAAO,gBAAgB;EAChD,UAAU,MAAMA,SAAO,eAAe,CAAC;CACzC,CACF,CAAC,CACE,MAAM,iBACL,0BAA0B,cAAc,aAAa,CACvD,CAAC,CACA,MAAM,iBAAiB,mBAAmB,YAAY,CAAC;CAG5D,MAAM,yBAAyB,KAAK,IAAI;CAGxC,SAAO,OAAO;CAEd,aAAa,aAAa;CAE1B,OAAO;EACL;EACA;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC7C,oBAAoB,yBAAyB;EAC/C;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"loadDictionaries.mjs","names":["logger"],"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport {\n colon,\n colorize,\n colorizeKey,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { filterInvalidDictionaries } from '../filterInvalidDictionaries';\nimport { formatDictionaries } from '../formatDictionary';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n const updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const index = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (index >= 0) {\n updated[index] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const status of loadDictionariesStatus) {\n const rec = byKey.get(status.dictionaryKey) ?? {};\n if (status.type === 'local') rec.local = status.status;\n if (status.type === 'remote') rec.remote = status.status;\n byKey.set(status.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n pluginDictionaries: Dictionary[];\n time: {\n localDictionaries: number;\n remoteDictionaries: number;\n pluginDictionaries: number;\n };\n}> => {\n const { plugins } = configuration;\n const loadDictionariesStartTime = Date.now();\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n if (hasRemoteDictionaries) {\n // We expect to fetch remote dictionaries soon; suppress a transient local-only render\n logger.setExpectRemote(true);\n }\n\n // Started first so the CMS round trips (OAuth2 token, update timestamps)\n // overlap plugin and local loading instead of running after them.\n const remoteDictionariesPromise: Promise<Dictionary[]> = hasRemoteDictionaries\n ? loadRemoteDictionaries(configuration, setLoadDictionariesStatus, {\n onStartRemoteCheck: () => logger.startRemoteCheck(),\n onStopRemoteCheck: () => logger.stopRemoteCheck(),\n onError: (error) => logger.setRemoteError(error),\n })\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries))\n : Promise.resolve([]);\n\n // Awaited later; this keeps an early rejection from being reported as unhandled\n remoteDictionariesPromise.catch(() => undefined);\n\n // Load additional dictionaries via plugins (e.g., ICU JSON ingestion)\n const resolvedPlugins = await Promise.all(plugins ?? []);\n\n const pluginsWithLoadDictionaries = resolvedPlugins.filter(\n (plugin) => plugin.loadDictionaries\n );\n\n logger.setPluginNames(pluginsWithLoadDictionaries.map(({ name }) => name));\n\n const loadPluginDictionariesPromise = pluginsWithLoadDictionaries.map(\n async (plugin) => {\n try {\n const res = await plugin.loadDictionaries?.({\n configuration,\n });\n\n return (res as Dictionary[] | undefined) ?? [];\n } catch (error) {\n logger.setPluginError(error as Error, plugin.name);\n\n return [];\n }\n }\n );\n\n const pluginDictionaries: Dictionary[] = await Promise.all(\n loadPluginDictionariesPromise as Promise<Dictionary[]>[]\n )\n .then((dictionaries) => dictionaries.flat())\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n logger.setPluginTotal(pluginDictionaries.length);\n logger.setPluginDone(pluginDictionaries.length);\n\n const pluginDictionariesTime = Date.now();\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n setLoadDictionariesStatus\n )\n .then((dictionaries) =>\n filterInvalidDictionaries(dictionaries, configuration)\n )\n .then((dictionaries) => formatDictionaries(dictionaries));\n\n const localDictionariesTime = Date.now();\n\n const localDictionariesStatus = localDictionaries.map(\n (dictionary) =>\n ({\n dictionaryKey: dictionary.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const remoteDictionaries: Dictionary[] = await remoteDictionariesPromise;\n\n const remoteDictionariesTime = Date.now();\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries,\n remoteDictionaries,\n pluginDictionaries,\n time: {\n localDictionaries: localDictionariesTime - pluginDictionariesTime,\n remoteDictionaries: remoteDictionariesTime - localDictionariesTime,\n pluginDictionaries: pluginDictionariesTime - loadDictionariesStartTime,\n },\n };\n};\n"],"mappings":";;;;;;;;;AA8BA,IAAI,yBAA+C,CAAC;AACpD,MAAMA,WAAS,IAAI,mBAAmB;AAEtC,MAAM,6BAA6B,aAAmC;CACpE,MAAM,UAAgC,CAAC,GAAG,sBAAsB;CAEhE,KAAK,MAAM,YAAY,UAAU;EAC/B,MAAM,QAAQ,QAAQ,WACnB,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS,IACtE;EACA,IAAI,SAAS,GACX,QAAQ,SAAS;OAEjB,QAAQ,KAAK,QAAQ;CAEzB;CAEA,yBAAyB;CACzB,SAAO,OAAO,QAAQ;CAEtB,OAAO;AACT;AAOA,MAAM,WAAW,WAAyC;CACxD,QAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,WACH,OAAO;EACT,KAAK,SACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,MAAM,YAAY,WAAyC;CACzD,QAAQ,QAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK,WACH,OAAO,WAAW;EACpB,KAAK,SACH,OAAO,WAAW;EACpB,SACE,OAAO,WAAW;CACtB;AACF;AAEA,MAAM,gBAAgB,kBAAkC;CACtD,IAAI,cAAc,IAAI,SAAS,WAAW;CAE1C,MAAM,YAAY,aAAa,aAAa;CAG5C,MAAM,wBAAQ,IAAI,IAA0B;CAC5C,KAAK,MAAM,UAAU,wBAAwB;EAC3C,MAAM,MAAM,MAAM,IAAI,OAAO,aAAa,KAAK,CAAC;EAChD,IAAI,OAAO,SAAS,SA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AAM,iBAAiB,mBAAmB,YAAY,CAAC;CAE1D,SAAO,eAAe,mBAAmB,MAAM;CAC/C,SAAO,cAAc,mBAAmB,MAAM;CAE9C,MAAM,yBAAyB,KAAK,IAAI;CAMxC,MAAM,oBAAkC,MAAM,wBAJhC,MAAM,QAAQ,wBAAwB,IAChD,2BACA,CAAC,wBAAwB,GAI3B,eACA,yBACF,CAAC,CACE,MAAM,iBACL,0BAA0B,cAAc,aAAa,CACvD,CAAC,CACA,MAAM,iBAAiB,mBAAmB,YAAY,CAAC;CAE1D,MAAM,wBAAwB,KAAK,IAAI;CAEvC,MAAM,0BAA0B,kBAAkB,KAC/C,gBACE;EACC,eAAe,WAAW;EAC1B,MAAM;EACN,QAAQ;CACV,EACJ;CAEA,0BAA0B,uBAAuB;CAEjD,MAAM,qBAAmC,MAAM;CAE/C,MAAM,yBAAyB,KAAK,IAAI;CAGxC,SAAO,OAAO;CAEd,aAAa,aAAa;CAE1B,OAAO;EACL;EACA;EACA;EACA,MAAM;GACJ,mBAAmB,wBAAwB;GAC3C,oBAAoB,yBAAyB;GAC7C,oBAAoB,yBAAyB;EAC/C;CACF;AACF"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { sortAlphabetically } from "../utils/sortAlphabetically.mjs";
|
|
2
|
-
import { fetchDistantDictionaries } from "../fetchDistantDictionaries.mjs";
|
|
3
2
|
import { getConfiguration } from "@intlayer/config/node";
|
|
4
|
-
import { createIntlayerCMS } from "@intlayer/api";
|
|
5
|
-
import { dictionaryEndpoint } from "@intlayer/api/dictionary";
|
|
6
3
|
import { getRemoteDictionaries } from "@intlayer/dictionaries-entry/remote";
|
|
7
4
|
|
|
8
5
|
//#region src/loadDictionaries/loadRemoteDictionaries.ts
|
|
@@ -17,7 +14,8 @@ const loadRemoteDictionaries = async (configuration = getConfiguration(), onStat
|
|
|
17
14
|
if (!Boolean(editor.clientId && editor.clientSecret)) return [];
|
|
18
15
|
try {
|
|
19
16
|
options?.onStartRemoteCheck?.();
|
|
20
|
-
const
|
|
17
|
+
const { createRemoteDictionaryClient, fetchDistantDictionaries } = await import("./remoteDictionaryClient.mjs");
|
|
18
|
+
const distantDictionaryUpdateTimeStamp = (await createRemoteDictionaryClient(configuration).getDictionariesUpdateTimestamp()).data;
|
|
21
19
|
if (!distantDictionaryUpdateTimeStamp) throw new Error("No distant dictionaries found");
|
|
22
20
|
const dictionariesIdToFetch = Object.entries(distantDictionaryUpdateTimeStamp).filter(([dictionaryId, data]) => {
|
|
23
21
|
if (!data.updatedAt) return true;
|