@intlayer/cli 9.4.4 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +0 -2
  2. package/dist/cjs/build.cjs +8 -0
  3. package/dist/cjs/build.cjs.map +1 -1
  4. package/dist/cjs/init.cjs +19 -19
  5. package/dist/cjs/init.cjs.map +1 -1
  6. package/dist/cjs/initBuildOptimization.cjs +15 -16
  7. package/dist/cjs/initBuildOptimization.cjs.map +1 -1
  8. package/dist/cjs/initCompiler.cjs +15 -55
  9. package/dist/cjs/initCompiler.cjs.map +1 -1
  10. package/dist/cjs/initMCP.cjs +12 -12
  11. package/dist/cjs/initMCP.cjs.map +1 -1
  12. package/dist/cjs/initSkills.cjs +12 -12
  13. package/dist/cjs/initSkills.cjs.map +1 -1
  14. package/dist/cjs/loadPrompts.cjs +18 -0
  15. package/dist/cjs/loadPrompts.cjs.map +1 -0
  16. package/dist/cjs/push/push.cjs +2 -1
  17. package/dist/cjs/push/push.cjs.map +1 -1
  18. package/dist/cjs/watch.cjs +6 -0
  19. package/dist/cjs/watch.cjs.map +1 -1
  20. package/dist/esm/build.mjs +9 -1
  21. package/dist/esm/build.mjs.map +1 -1
  22. package/dist/esm/init.mjs +2 -1
  23. package/dist/esm/init.mjs.map +1 -1
  24. package/dist/esm/initBuildOptimization.mjs +2 -1
  25. package/dist/esm/initBuildOptimization.mjs.map +1 -1
  26. package/dist/esm/initCompiler.mjs +10 -48
  27. package/dist/esm/initCompiler.mjs.map +1 -1
  28. package/dist/esm/initMCP.mjs +2 -1
  29. package/dist/esm/initMCP.mjs.map +1 -1
  30. package/dist/esm/initSkills.mjs +2 -1
  31. package/dist/esm/initSkills.mjs.map +1 -1
  32. package/dist/esm/loadPrompts.mjs +17 -0
  33. package/dist/esm/loadPrompts.mjs.map +1 -0
  34. package/dist/esm/push/push.mjs +2 -1
  35. package/dist/esm/push/push.mjs.map +1 -1
  36. package/dist/esm/watch.mjs +7 -1
  37. package/dist/esm/watch.mjs.map +1 -1
  38. package/dist/types/build.d.ts.map +1 -1
  39. package/dist/types/init.d.ts.map +1 -1
  40. package/dist/types/initCompiler.d.ts +5 -2
  41. package/dist/types/initCompiler.d.ts.map +1 -1
  42. package/dist/types/loadPrompts.d.ts +17 -0
  43. package/dist/types/loadPrompts.d.ts.map +1 -0
  44. package/dist/types/push/push.d.ts.map +1 -1
  45. package/dist/types/watch.d.ts.map +1 -1
  46. package/package.json +13 -13
package/README.md CHANGED
@@ -69,8 +69,6 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
69
69
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
70
70
  | <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
71
71
 
72
- ---
73
-
74
72
  ## 📦 Installation
75
73
 
76
74
  Start your journey with Intlayer today and experience a smoother, more powerful approach to internationalization.
@@ -13,6 +13,14 @@ const build = async (options) => {
13
13
  const config = (0, _intlayer_config_node.getConfiguration)(options?.configOptions);
14
14
  (0, _intlayer_engine_cli.logConfigDetails)(options?.configOptions);
15
15
  let parallelProcess = null;
16
+ if (options?.watch) {
17
+ const bundlerAlreadyWatching = await (0, _intlayer_engine_utils.claimCliContentWatcher)(config, "intlayer build --watch");
18
+ if (bundlerAlreadyWatching) (0, _intlayer_engine_utils.reportRedundantContentWatcher)(config, {
19
+ cliLabel: "intlayer build --watch",
20
+ bundlerLabel: bundlerAlreadyWatching.label,
21
+ since: bundlerAlreadyWatching.since
22
+ });
23
+ }
16
24
  if (options?.with) {
17
25
  parallelProcess = (0, _intlayer_engine_utils.runParallel)(options.with);
18
26
  parallelProcess.result.catch(() => {});
@@ -1 +1 @@
1
- {"version":3,"file":"build.cjs","names":["getConfiguration","runParallel","buildAndWatchIntlayer"],"sources":["../../src/build.ts"],"sourcesContent":["import {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { type ParallelHandle, runParallel } from '@intlayer/engine/utils';\nimport { buildAndWatchIntlayer } from '@intlayer/engine/watcher';\n\ntype BuildOptions = {\n watch?: boolean;\n skipPrepare?: boolean;\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\n/**\n * Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.\n * Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}\n */\nexport const build = async (options?: BuildOptions) => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n let parallelProcess: ParallelHandle | null = null;\n\n if (options?.with) {\n parallelProcess = runParallel(options.with);\n // Handle the promise to avoid unhandled rejection\n parallelProcess.result.catch(() => {\n // Parallel process failed or was terminated\n });\n }\n\n await buildAndWatchIntlayer({\n persistent: options?.watch ?? false,\n skipPrepare: options?.skipPrepare ?? false,\n configuration: config,\n });\n\n if (!options?.watch && parallelProcess) {\n parallelProcess.kill();\n }\n};\n"],"mappings":";;;;;;;;;;;AAmBA,MAAa,QAAQ,OAAO,YAA2B;CACrD,MAAM,aAASA,wCAAiB,SAAS,aAAa;CACtD,2CAAiB,SAAS,aAAa;CAEvC,IAAI,kBAAyC;CAE7C,IAAI,SAAS,MAAM;EACjB,sBAAkBC,oCAAY,QAAQ,IAAI;EAE1C,gBAAgB,OAAO,YAAY,CAEnC,CAAC;CACH;CAEA,UAAMC,gDAAsB;EAC1B,YAAY,SAAS,SAAS;EAC9B,aAAa,SAAS,eAAe;EACrC,eAAe;CACjB,CAAC;CAED,IAAI,CAAC,SAAS,SAAS,iBACrB,gBAAgB,KAAK;AAEzB"}
1
+ {"version":3,"file":"build.cjs","names":["getConfiguration","claimCliContentWatcher","runParallel","buildAndWatchIntlayer"],"sources":["../../src/build.ts"],"sourcesContent":["import {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport {\n claimCliContentWatcher,\n type ParallelHandle,\n reportRedundantContentWatcher,\n runParallel,\n} from '@intlayer/engine/utils';\nimport { buildAndWatchIntlayer } from '@intlayer/engine/watcher';\n\ntype BuildOptions = {\n watch?: boolean;\n skipPrepare?: boolean;\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\n/**\n * Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.\n * Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}\n */\nexport const build = async (options?: BuildOptions) => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n let parallelProcess: ParallelHandle | null = null;\n\n // Only watch mode keeps a watcher alive; a one-off build has nothing to\n // deduplicate. Claimed before the child is spawned so the bundler plugin\n // inside it stands down instead of racing this command.\n if (options?.watch) {\n const bundlerAlreadyWatching = await claimCliContentWatcher(\n config,\n 'intlayer build --watch'\n );\n\n if (bundlerAlreadyWatching) {\n reportRedundantContentWatcher(config, {\n cliLabel: 'intlayer build --watch',\n bundlerLabel: bundlerAlreadyWatching.label,\n since: bundlerAlreadyWatching.since,\n });\n }\n }\n\n if (options?.with) {\n parallelProcess = runParallel(options.with);\n // Handle the promise to avoid unhandled rejection\n parallelProcess.result.catch(() => {\n // Parallel process failed or was terminated\n });\n }\n\n await buildAndWatchIntlayer({\n persistent: options?.watch ?? false,\n skipPrepare: options?.skipPrepare ?? false,\n configuration: config,\n });\n\n if (!options?.watch && parallelProcess) {\n parallelProcess.kill();\n }\n};\n"],"mappings":";;;;;;;;;;;AAwBA,MAAa,QAAQ,OAAO,YAA2B;CACrD,MAAM,aAASA,wCAAiB,SAAS,aAAa;CACtD,2CAAiB,SAAS,aAAa;CAEvC,IAAI,kBAAyC;CAK7C,IAAI,SAAS,OAAO;EAClB,MAAM,yBAAyB,UAAMC,+CACnC,QACA,wBACF;EAEA,IAAI,wBACF,0DAA8B,QAAQ;GACpC,UAAU;GACV,cAAc,uBAAuB;GACrC,OAAO,uBAAuB;EAChC,CAAC;CAEL;CAEA,IAAI,SAAS,MAAM;EACjB,sBAAkBC,oCAAY,QAAQ,IAAI;EAE1C,gBAAgB,OAAO,YAAY,CAEnC,CAAC;CACH;CAEA,UAAMC,gDAAsB;EAC1B,YAAY,SAAS,SAAS;EAC9B,aAAa,SAAS,eAAe;EACrC,eAAe;CACjB,CAAC;CAED,IAAI,CAAC,SAAS,SAAS,iBACrB,gBAAgB,KAAK;AAEzB"}
package/dist/cjs/init.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
3
  const require_auth_login = require('./auth/login.cjs');
4
+ const require_loadPrompts = require('./loadPrompts.cjs');
4
5
  const require_initBuildOptimization = require('./initBuildOptimization.cjs');
5
6
  const require_initCompiler = require('./initCompiler.cjs');
6
7
  const require_initSkills = require('./initSkills.cjs');
@@ -10,8 +11,6 @@ let node_path = require("node:path");
10
11
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
11
12
  let enquirer = require("enquirer");
12
13
  enquirer = require_runtime.__toESM(enquirer);
13
- let _clack_prompts = require("@clack/prompts");
14
- _clack_prompts = require_runtime.__toESM(_clack_prompts);
15
14
 
16
15
  //#region src/init.ts
17
16
  const findProjectRoot = (startDir) => {
@@ -146,7 +145,8 @@ const hasUrlRouting = (root) => {
146
145
  * offered as a checkbox — it is always added (unless `--no-gitignore` is set).
147
146
  */
148
147
  const runInteractiveInit = async (root, baseOptions) => {
149
- _clack_prompts.intro("Initialize Intlayer");
148
+ const p = await require_loadPrompts.loadPrompts();
149
+ p.intro("Initialize Intlayer");
150
150
  const stepOptions = [...BASE_INIT_STEP_OPTIONS];
151
151
  const nextJsProject = isNextJsProject(root);
152
152
  if (nextJsProject || isViteProject(root)) stepOptions.push({
@@ -159,42 +159,42 @@ const runInteractiveInit = async (root, baseOptions) => {
159
159
  label: "Bundle optimization",
160
160
  hint: "choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)"
161
161
  });
162
- const selected = await _clack_prompts.multiselect({
162
+ const selected = await p.multiselect({
163
163
  message: "Select what you want to set up:",
164
164
  options: stepOptions,
165
165
  initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),
166
166
  required: false
167
167
  });
168
- if (_clack_prompts.isCancel(selected)) {
169
- _clack_prompts.cancel("Operation cancelled.");
168
+ if (p.isCancel(selected)) {
169
+ p.cancel("Operation cancelled.");
170
170
  return;
171
171
  }
172
172
  const steps = selected;
173
173
  let routingMode;
174
174
  if (hasUrlRouting(root)) {
175
- const selectedRoutingMode = await _clack_prompts.select({
175
+ const selectedRoutingMode = await p.select({
176
176
  message: "Which locale routing strategy do you want?",
177
177
  options: ROUTING_MODE_OPTIONS,
178
178
  initialValue: "prefix-no-default"
179
179
  });
180
- if (_clack_prompts.isCancel(selectedRoutingMode)) {
181
- _clack_prompts.cancel("Operation cancelled.");
180
+ if (p.isCancel(selectedRoutingMode)) {
181
+ p.cancel("Operation cancelled.");
182
182
  return;
183
183
  }
184
184
  routingMode = selectedRoutingMode;
185
185
  }
186
186
  const detectedCompatLibraries = (0, _intlayer_engine_cli.detectCompatI18nLibraries)(getProjectDependencies(root));
187
187
  const hasCompatLib = detectedCompatLibraries.length > 0;
188
- if (hasCompatLib) _clack_prompts.log.info(`Detected existing i18n ${detectedCompatLibraries.length > 1 ? "libraries" : "library"}: ${detectedCompatLibraries.join(", ")} — the matching Intlayer compat adapter and catalog sync will be set up.`);
188
+ if (hasCompatLib) p.log.info(`Detected existing i18n ${detectedCompatLibraries.length > 1 ? "libraries" : "library"}: ${detectedCompatLibraries.join(", ")} — the matching Intlayer compat adapter and catalog sync will be set up.`);
189
189
  let contentStrategy;
190
190
  if (!hasCompatLib) {
191
- const selectedContentStrategy = await _clack_prompts.select({
191
+ const selectedContentStrategy = await p.select({
192
192
  message: "How do you want to organize your translated content?",
193
193
  options: CONTENT_STRATEGY_OPTIONS,
194
194
  initialValue: "per-component"
195
195
  });
196
- if (_clack_prompts.isCancel(selectedContentStrategy)) {
197
- _clack_prompts.cancel("Operation cancelled.");
196
+ if (p.isCancel(selectedContentStrategy)) {
197
+ p.cancel("Operation cancelled.");
198
198
  return;
199
199
  }
200
200
  contentStrategy = selectedContentStrategy;
@@ -230,7 +230,7 @@ const runInteractiveInit = async (root, baseOptions) => {
230
230
  }))
231
231
  })).platforms;
232
232
  } catch {
233
- _clack_prompts.cancel("Operation cancelled.");
233
+ p.cancel("Operation cancelled.");
234
234
  return;
235
235
  }
236
236
  }
@@ -238,22 +238,22 @@ const runInteractiveInit = async (root, baseOptions) => {
238
238
  if (steps.includes("mcp")) await require_initMCP.initMCP(root, sharedPlatform);
239
239
  if (steps.includes("compiler")) await require_initCompiler.initCompiler(root);
240
240
  if (steps.includes("buildOptimization")) await require_initBuildOptimization.initBuildOptimization(root);
241
- const shouldSetUpCms = await _clack_prompts.confirm({
241
+ const shouldSetUpCms = await p.confirm({
242
242
  message: "Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)",
243
243
  initialValue: false
244
244
  });
245
- if (_clack_prompts.isCancel(shouldSetUpCms)) {
246
- _clack_prompts.cancel("Operation cancelled.");
245
+ if (p.isCancel(shouldSetUpCms)) {
246
+ p.cancel("Operation cancelled.");
247
247
  return;
248
248
  }
249
249
  if (shouldSetUpCms) {
250
- _clack_prompts.log.info("Opening your browser to log in to the Intlayer CMS...");
250
+ p.log.info("Opening your browser to log in to the Intlayer CMS...");
251
251
  await require_auth_login.login({
252
252
  exitAfter: false,
253
253
  onCredentials: (credentials) => (0, _intlayer_engine_cli.setupCmsCredentials)(root, credentials)
254
254
  });
255
255
  }
256
- _clack_prompts.outro("Intlayer initialization complete");
256
+ p.outro("Intlayer initialization complete");
257
257
  };
258
258
  const init = async (projectRoot, options, interactive) => {
259
259
  const root = projectRoot ? findProjectRoot((0, node_path.resolve)(projectRoot)) : findProjectRoot(process.cwd());
@@ -1 +1 @@
1
- {"version":3,"file":"init.cjs","names":["resolve","existsSync","join","readFileSync","p","detectCompatI18nLibraries","initIntlayer","getDetectedPlatform","PLATFORMS","PLATFORM_OPTIONS","initSkills","initMCP","initCompiler","initBuildOptimization","login","setupCmsCredentials"],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n type ContentStrategy,\n detectCompatI18nLibraries,\n type InitOptions,\n initIntlayer,\n PLATFORMS,\n type Platform,\n type RoutingMode,\n setupCmsCredentials,\n} from '@intlayer/engine/cli';\nimport enquirer from 'enquirer';\nimport { login } from './auth/login';\nimport { initBuildOptimization } from './initBuildOptimization';\nimport { initCompiler } from './initCompiler';\nimport { initMCP } from './initMCP';\nimport {\n getDetectedPlatform,\n initSkills,\n PLATFORM_OPTIONS,\n} from './initSkills';\n\nexport const findProjectRoot = (startDir: string) => {\n let currentDir = startDir;\n\n while (currentDir !== resolve(currentDir, '..')) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = resolve(currentDir, '..');\n }\n\n // If no package.json is found, return the start directory.\n // The initIntlayer function will handle the missing package.json error.\n return startDir;\n};\n\n/** Individually selectable setup steps exposed by the interactive init flow. */\ntype InitStep =\n | 'packages'\n | 'githubActions'\n | 'frameworkSetup'\n | 'vscodeExtension'\n | 'lsp'\n | 'eslint'\n | 'skills'\n | 'mcp'\n | 'compiler'\n | 'buildOptimization';\n\nconst BASE_INIT_STEP_OPTIONS: Array<{\n value: InitStep;\n label: string;\n hint: string;\n}> = [\n {\n value: 'packages',\n label: 'Install & upgrade packages',\n hint: 'install missing Intlayer dependencies and upgrade outdated ones',\n },\n {\n value: 'githubActions',\n label: 'CI/CD (GitHub Actions)',\n hint: 'scaffold the fill and test workflows that run on every pull request (covers every project in a monorepo)',\n },\n {\n value: 'frameworkSetup',\n label: 'Framework setup',\n hint: 'middleware/proxy and providers in layout/page',\n },\n {\n value: 'vscodeExtension',\n label: 'VS Code extension',\n hint: 'recommend the Intlayer extension',\n },\n {\n value: 'lsp',\n label: 'Editor LSP',\n hint: 'go-to-definition from keys to .content files',\n },\n {\n value: 'eslint',\n label: 'Lint rules (ESLint / oxlint)',\n hint: 'flag hardcoded text and dynamic calls the compiler cannot optimize',\n },\n {\n value: 'skills',\n label: 'AI skills',\n hint: 'install the Intlayer documentation as agent skills',\n },\n {\n value: 'mcp',\n label: 'MCP server',\n hint: 'configure the Intlayer MCP server',\n },\n];\n\n/** Locale routing strategies offered by the interactive init flow. */\nconst ROUTING_MODE_OPTIONS: Array<{\n value: RoutingMode;\n label: string;\n hint: string;\n}> = [\n {\n value: 'prefix-no-default',\n label: 'Prefix all except the default locale',\n hint: '/about, /fr/about (default)',\n },\n {\n value: 'prefix-all',\n label: 'Prefix all locales',\n hint: '/en/about, /fr/about',\n },\n {\n value: 'no-prefix',\n label: 'No locale in the URL',\n hint: '/about',\n },\n {\n value: 'search-params',\n label: 'Use a search parameter',\n hint: '/about?locale=fr',\n },\n];\n\n/**\n * Content organization strategies offered by the interactive init flow.\n * Drives the `compiler.output` template (autogenerated content: compiler /\n * autofill / extract) or the injection of the syncJSON plugin.\n */\nconst CONTENT_STRATEGY_OPTIONS: Array<{\n value: ContentStrategy;\n label: string;\n hint: string;\n}> = [\n {\n value: 'per-component',\n label: 'Per component (default)',\n hint: 'multilingual .content files co-located with the components',\n },\n {\n value: 'centralized',\n label: 'Centralized folder',\n hint: 'per-locale JSON dictionaries under /locales/{locale}/{key}.content.json',\n },\n {\n value: 'json-namespaces',\n label: 'JSON namespaces',\n hint: 'plain /locales/{locale}/{namespace}.json files synced via @intlayer/sync-json-plugin',\n },\n];\n\n/** Reads the merged dependencies of the project at `root`. */\nconst getProjectDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\n/** Returns true when the project at `root` depends on Next.js. */\nconst isNextJsProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).next);\n\n/** Returns true when the project at `root` depends on Vite. */\nconst isViteProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).vite);\n\n/**\n * Returns true when the project uses a URL-based router for which a locale\n * routing strategy is meaningful: Next.js, React Router, or TanStack Router.\n * Apps without URL routing (e.g. React Native / Expo) are excluded, since\n * `routing.mode` has no effect there.\n */\nconst hasUrlRouting = (root: string): boolean => {\n const deps = getProjectDependencies(root);\n\n // React Native / Expo apps have no URL routing — never ask for a strategy.\n if (deps['react-native'] || deps.expo) return false;\n\n return Boolean(\n deps.next ||\n deps['react-router'] ||\n deps['react-router-dom'] ||\n deps['@tanstack/react-router'] ||\n deps['@tanstack/react-start']\n );\n};\n\n/**\n * Runs `init` in interactive mode: prompts the user with a checkbox of setup\n * steps, then forwards the selection to {@link initIntlayer} (packages, GitHub\n * Actions, VS Code extension, LSP) and runs the dedicated skills/MCP installers\n * for the steps that own their own prompts. The `.gitignore` entry is not\n * offered as a checkbox — it is always added (unless `--no-gitignore` is set).\n */\nconst runInteractiveInit = async (\n root: string,\n baseOptions?: InitOptions\n): Promise<void> => {\n p.intro('Initialize Intlayer');\n\n const stepOptions = [...BASE_INIT_STEP_OPTIONS];\n\n const nextJsProject = isNextJsProject(root);\n\n // The compiler is plugged in directly on Vite; on Next.js it needs a Babel\n // config. Only offer the step when one of those frameworks is detected.\n if (nextJsProject || isViteProject(root)) {\n stepOptions.push({\n value: 'compiler',\n label: 'Compiler',\n hint: nextJsProject\n ? 'add the Babel compiler config to extract inline content (Next.js)'\n : 'auto-extract inline content at build time (already plugged in on Vite)',\n });\n }\n\n if (nextJsProject) {\n stepOptions.push({\n value: 'buildOptimization',\n label: 'Bundle optimization',\n hint: 'choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)',\n });\n }\n\n const selected = await p.multiselect<InitStep>({\n message: 'Select what you want to set up:',\n options: stepOptions,\n initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),\n required: false,\n });\n\n if (p.isCancel(selected)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const steps = selected as InitStep[];\n\n // Locale routing strategy → written to `routing.mode` in the config file.\n // Only relevant for URL-based routers (Next.js, React Router, TanStack);\n // skipped for apps without URL routing such as React Native / Expo.\n let routingMode: RoutingMode | undefined;\n\n if (hasUrlRouting(root)) {\n const selectedRoutingMode = await p.select<RoutingMode>({\n message: 'Which locale routing strategy do you want?',\n options: ROUTING_MODE_OPTIONS,\n initialValue: 'prefix-no-default',\n });\n\n if (p.isCancel(selectedRoutingMode)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n routingMode = selectedRoutingMode;\n }\n\n // Compat i18n library detection — never asked, always derived from the\n // installed packages. `detectMissingIntlayerPackages` reads the very same\n // dependency map to schedule the compat adapter, the sync plugin and the\n // catalog template, so a project without any of those packages is simply set\n // up on Intlayer alone.\n const detectedCompatLibraries = detectCompatI18nLibraries(\n getProjectDependencies(root)\n );\n const hasCompatLib = detectedCompatLibraries.length > 0;\n\n if (hasCompatLib) {\n p.log.info(\n `Detected existing i18n ${detectedCompatLibraries.length > 1 ? 'libraries' : 'library'}: ${detectedCompatLibraries.join(', ')} — the matching Intlayer compat adapter and catalog sync will be set up.`\n );\n }\n\n // Content organization strategy → drives `compiler.output` (autogenerated\n // content) or the syncJSON plugin injection. A compat library already\n // dictates the catalog layout (its JSON/PO files are synced as-is), so the\n // question is only asked when none is in play.\n let contentStrategy: ContentStrategy | undefined;\n\n if (!hasCompatLib) {\n const selectedContentStrategy = await p.select<ContentStrategy>({\n message: 'How do you want to organize your translated content?',\n options: CONTENT_STRATEGY_OPTIONS,\n initialValue: 'per-component',\n });\n\n if (p.isCancel(selectedContentStrategy)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n contentStrategy = selectedContentStrategy;\n }\n\n const options: InitOptions = {\n ...baseOptions,\n routingMode,\n contentStrategy,\n noInstallPackages: !steps.includes('packages'),\n // The `.gitignore` entry is never offered as a checkbox: in interactive\n // mode we always add `.intlayer` to `.gitignore`, only honoring an explicit\n // `--no-gitignore` flag from the command line.\n noGitignore: baseOptions?.noGitignore,\n // Respect explicit `--no-*` flags from the command line even when the\n // corresponding step is selected in the checkbox.\n noGithubActions:\n baseOptions?.noGithubActions || !steps.includes('githubActions'),\n noFrameworkSetup:\n baseOptions?.noFrameworkSetup || !steps.includes('frameworkSetup'),\n noVscodeExtension: !steps.includes('vscodeExtension'),\n noLsp: !steps.includes('lsp'),\n noEslint: !steps.includes('eslint'),\n };\n\n await initIntlayer(root, options);\n\n const needsPlatform = steps.includes('skills') || steps.includes('mcp');\n\n let sharedPlatform: Platform | undefined;\n\n if (needsPlatform) {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n sharedPlatform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (steps.includes('skills')) {\n await initSkills(root, sharedPlatform);\n }\n\n if (steps.includes('mcp')) {\n await initMCP(root, sharedPlatform);\n }\n\n if (steps.includes('compiler')) {\n await initCompiler(root);\n }\n\n if (steps.includes('buildOptimization')) {\n await initBuildOptimization(root);\n }\n\n // CMS / visual editor is the last step: an opt-in browser login that\n // persists the access-key credentials to `.env` and enables the editor in the\n // config file. Asked last so the browser flow does not interrupt setup.\n const shouldSetUpCms = await p.confirm({\n message:\n 'Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)',\n initialValue: false,\n });\n\n if (p.isCancel(shouldSetUpCms)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (shouldSetUpCms) {\n p.log.info('Opening your browser to log in to the Intlayer CMS...');\n // `exitAfter: false` keeps the process alive so the flow can finish; the\n // credentials are persisted to `.env` and the editor enabled in the config.\n await login({\n exitAfter: false,\n onCredentials: (credentials) => setupCmsCredentials(root, credentials),\n });\n }\n\n p.outro('Intlayer initialization complete');\n};\n\nexport const init = async (\n projectRoot?: string,\n options?: InitOptions,\n interactive?: boolean\n) => {\n const root = projectRoot\n ? findProjectRoot(resolve(projectRoot))\n : findProjectRoot(process.cwd());\n\n if (interactive) {\n await runInteractiveInit(root, options);\n return;\n }\n\n await initIntlayer(root, options);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAa,mBAAmB,aAAqB;CACnD,IAAI,aAAa;CAEjB,OAAO,mBAAeA,mBAAQ,YAAY,IAAI,GAAG;EAC/C,QAAIC,wBAAWC,gBAAK,YAAY,cAAc,CAAC,GAC7C,OAAO;EAET,iBAAaF,mBAAQ,YAAY,IAAI;CACvC;CAIA,OAAO;AACT;AAeA,MAAM,yBAID;CACH;EACE,OAAO;EACP,OAAO;EACP,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;E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AE,IAAI,KAAK,uDAAuD;EAGlE,MAAMU,yBAAM;GACV,WAAW;GACX,gBAAgB,oBAAgBC,0CAAoB,MAAM,WAAW;EACvE,CAAC;CACH;CAEA,eAAE,MAAM,kCAAkC;AAC5C;AAEA,MAAa,OAAO,OAClB,aACA,SACA,gBACG;CACH,MAAM,OAAO,cACT,oBAAgBf,mBAAQ,WAAW,CAAC,IACpC,gBAAgB,QAAQ,IAAI,CAAC;CAEjC,IAAI,aAAa;EACf,MAAM,mBAAmB,MAAM,OAAO;EACtC;CACF;CAEA,UAAMM,mCAAa,MAAM,OAAO;AAClC"}
1
+ {"version":3,"file":"init.cjs","names":["resolve","existsSync","join","readFileSync","loadPrompts","detectCompatI18nLibraries","initIntlayer","getDetectedPlatform","PLATFORMS","PLATFORM_OPTIONS","initSkills","initMCP","initCompiler","initBuildOptimization","login","setupCmsCredentials"],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n type ContentStrategy,\n detectCompatI18nLibraries,\n type InitOptions,\n initIntlayer,\n PLATFORMS,\n type Platform,\n type RoutingMode,\n setupCmsCredentials,\n} from '@intlayer/engine/cli';\nimport enquirer from 'enquirer';\nimport { login } from './auth/login';\nimport { initBuildOptimization } from './initBuildOptimization';\nimport { initCompiler } from './initCompiler';\nimport { initMCP } from './initMCP';\nimport {\n getDetectedPlatform,\n initSkills,\n PLATFORM_OPTIONS,\n} from './initSkills';\nimport { loadPrompts } from './loadPrompts';\n\nexport const findProjectRoot = (startDir: string) => {\n let currentDir = startDir;\n\n while (currentDir !== resolve(currentDir, '..')) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = resolve(currentDir, '..');\n }\n\n // If no package.json is found, return the start directory.\n // The initIntlayer function will handle the missing package.json error.\n return startDir;\n};\n\n/** Individually selectable setup steps exposed by the interactive init flow. */\ntype InitStep =\n | 'packages'\n | 'githubActions'\n | 'frameworkSetup'\n | 'vscodeExtension'\n | 'lsp'\n | 'eslint'\n | 'skills'\n | 'mcp'\n | 'compiler'\n | 'buildOptimization';\n\nconst BASE_INIT_STEP_OPTIONS: Array<{\n value: InitStep;\n label: string;\n hint: string;\n}> = [\n {\n value: 'packages',\n label: 'Install & upgrade packages',\n hint: 'install missing Intlayer dependencies and upgrade outdated ones',\n },\n {\n value: 'githubActions',\n label: 'CI/CD (GitHub Actions)',\n hint: 'scaffold the fill and test workflows that run on every pull request (covers every project in a monorepo)',\n },\n {\n value: 'frameworkSetup',\n label: 'Framework setup',\n hint: 'middleware/proxy and providers in layout/page',\n },\n {\n value: 'vscodeExtension',\n label: 'VS Code extension',\n hint: 'recommend the Intlayer extension',\n },\n {\n value: 'lsp',\n label: 'Editor LSP',\n hint: 'go-to-definition from keys to .content files',\n },\n {\n value: 'eslint',\n label: 'Lint rules (ESLint / oxlint)',\n hint: 'flag hardcoded text and dynamic calls the compiler cannot optimize',\n },\n {\n value: 'skills',\n label: 'AI skills',\n hint: 'install the Intlayer documentation as agent skills',\n },\n {\n value: 'mcp',\n label: 'MCP server',\n hint: 'configure the Intlayer MCP server',\n },\n];\n\n/** Locale routing strategies offered by the interactive init flow. */\nconst ROUTING_MODE_OPTIONS: Array<{\n value: RoutingMode;\n label: string;\n hint: string;\n}> = [\n {\n value: 'prefix-no-default',\n label: 'Prefix all except the default locale',\n hint: '/about, /fr/about (default)',\n },\n {\n value: 'prefix-all',\n label: 'Prefix all locales',\n hint: '/en/about, /fr/about',\n },\n {\n value: 'no-prefix',\n label: 'No locale in the URL',\n hint: '/about',\n },\n {\n value: 'search-params',\n label: 'Use a search parameter',\n hint: '/about?locale=fr',\n },\n];\n\n/**\n * Content organization strategies offered by the interactive init flow.\n * Drives the `compiler.output` template (autogenerated content: compiler /\n * autofill / extract) or the injection of the syncJSON plugin.\n */\nconst CONTENT_STRATEGY_OPTIONS: Array<{\n value: ContentStrategy;\n label: string;\n hint: string;\n}> = [\n {\n value: 'per-component',\n label: 'Per component (default)',\n hint: 'multilingual .content files co-located with the components',\n },\n {\n value: 'centralized',\n label: 'Centralized folder',\n hint: 'per-locale JSON dictionaries under /locales/{locale}/{key}.content.json',\n },\n {\n value: 'json-namespaces',\n label: 'JSON namespaces',\n hint: 'plain /locales/{locale}/{namespace}.json files synced via @intlayer/sync-json-plugin',\n },\n];\n\n/** Reads the merged dependencies of the project at `root`. */\nconst getProjectDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\n/** Returns true when the project at `root` depends on Next.js. */\nconst isNextJsProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).next);\n\n/** Returns true when the project at `root` depends on Vite. */\nconst isViteProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).vite);\n\n/**\n * Returns true when the project uses a URL-based router for which a locale\n * routing strategy is meaningful: Next.js, React Router, or TanStack Router.\n * Apps without URL routing (e.g. React Native / Expo) are excluded, since\n * `routing.mode` has no effect there.\n */\nconst hasUrlRouting = (root: string): boolean => {\n const deps = getProjectDependencies(root);\n\n // React Native / Expo apps have no URL routing — never ask for a strategy.\n if (deps['react-native'] || deps.expo) return false;\n\n return Boolean(\n deps.next ||\n deps['react-router'] ||\n deps['react-router-dom'] ||\n deps['@tanstack/react-router'] ||\n deps['@tanstack/react-start']\n );\n};\n\n/**\n * Runs `init` in interactive mode: prompts the user with a checkbox of setup\n * steps, then forwards the selection to {@link initIntlayer} (packages, GitHub\n * Actions, VS Code extension, LSP) and runs the dedicated skills/MCP installers\n * for the steps that own their own prompts. The `.gitignore` entry is not\n * offered as a checkbox — it is always added (unless `--no-gitignore` is set).\n */\nconst runInteractiveInit = async (\n root: string,\n baseOptions?: InitOptions\n): Promise<void> => {\n const p = await loadPrompts();\n\n p.intro('Initialize Intlayer');\n\n const stepOptions = [...BASE_INIT_STEP_OPTIONS];\n\n const nextJsProject = isNextJsProject(root);\n\n // The compiler is plugged in directly on Vite; on Next.js it needs a Babel\n // config. Only offer the step when one of those frameworks is detected.\n if (nextJsProject || isViteProject(root)) {\n stepOptions.push({\n value: 'compiler',\n label: 'Compiler',\n hint: nextJsProject\n ? 'add the Babel compiler config to extract inline content (Next.js)'\n : 'auto-extract inline content at build time (already plugged in on Vite)',\n });\n }\n\n if (nextJsProject) {\n stepOptions.push({\n value: 'buildOptimization',\n label: 'Bundle optimization',\n hint: 'choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)',\n });\n }\n\n const selected = await p.multiselect<InitStep>({\n message: 'Select what you want to set up:',\n options: stepOptions,\n initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),\n required: false,\n });\n\n if (p.isCancel(selected)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const steps = selected as InitStep[];\n\n // Locale routing strategy → written to `routing.mode` in the config file.\n // Only relevant for URL-based routers (Next.js, React Router, TanStack);\n // skipped for apps without URL routing such as React Native / Expo.\n let routingMode: RoutingMode | undefined;\n\n if (hasUrlRouting(root)) {\n const selectedRoutingMode = await p.select<RoutingMode>({\n message: 'Which locale routing strategy do you want?',\n options: ROUTING_MODE_OPTIONS,\n initialValue: 'prefix-no-default',\n });\n\n if (p.isCancel(selectedRoutingMode)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n routingMode = selectedRoutingMode;\n }\n\n // Compat i18n library detection — never asked, always derived from the\n // installed packages. `detectMissingIntlayerPackages` reads the very same\n // dependency map to schedule the compat adapter, the sync plugin and the\n // catalog template, so a project without any of those packages is simply set\n // up on Intlayer alone.\n const detectedCompatLibraries = detectCompatI18nLibraries(\n getProjectDependencies(root)\n );\n const hasCompatLib = detectedCompatLibraries.length > 0;\n\n if (hasCompatLib) {\n p.log.info(\n `Detected existing i18n ${detectedCompatLibraries.length > 1 ? 'libraries' : 'library'}: ${detectedCompatLibraries.join(', ')} — the matching Intlayer compat adapter and catalog sync will be set up.`\n );\n }\n\n // Content organization strategy → drives `compiler.output` (autogenerated\n // content) or the syncJSON plugin injection. A compat library already\n // dictates the catalog layout (its JSON/PO files are synced as-is), so the\n // question is only asked when none is in play.\n let contentStrategy: ContentStrategy | undefined;\n\n if (!hasCompatLib) {\n const selectedContentStrategy = await p.select<ContentStrategy>({\n message: 'How do you want to organize your translated content?',\n options: CONTENT_STRATEGY_OPTIONS,\n initialValue: 'per-component',\n });\n\n if (p.isCancel(selectedContentStrategy)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n contentStrategy = selectedContentStrategy;\n }\n\n const options: InitOptions = {\n ...baseOptions,\n routingMode,\n contentStrategy,\n noInstallPackages: !steps.includes('packages'),\n // The `.gitignore` entry is never offered as a checkbox: in interactive\n // mode we always add `.intlayer` to `.gitignore`, only honoring an explicit\n // `--no-gitignore` flag from the command line.\n noGitignore: baseOptions?.noGitignore,\n // Respect explicit `--no-*` flags from the command line even when the\n // corresponding step is selected in the checkbox.\n noGithubActions:\n baseOptions?.noGithubActions || !steps.includes('githubActions'),\n noFrameworkSetup:\n baseOptions?.noFrameworkSetup || !steps.includes('frameworkSetup'),\n noVscodeExtension: !steps.includes('vscodeExtension'),\n noLsp: !steps.includes('lsp'),\n noEslint: !steps.includes('eslint'),\n };\n\n await initIntlayer(root, options);\n\n const needsPlatform = steps.includes('skills') || steps.includes('mcp');\n\n let sharedPlatform: Platform | undefined;\n\n if (needsPlatform) {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n sharedPlatform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (steps.includes('skills')) {\n await initSkills(root, sharedPlatform);\n }\n\n if (steps.includes('mcp')) {\n await initMCP(root, sharedPlatform);\n }\n\n if (steps.includes('compiler')) {\n await initCompiler(root);\n }\n\n if (steps.includes('buildOptimization')) {\n await initBuildOptimization(root);\n }\n\n // CMS / visual editor is the last step: an opt-in browser login that\n // persists the access-key credentials to `.env` and enables the editor in the\n // config file. Asked last so the browser flow does not interrupt setup.\n const shouldSetUpCms = await p.confirm({\n message:\n 'Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)',\n initialValue: false,\n });\n\n if (p.isCancel(shouldSetUpCms)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (shouldSetUpCms) {\n p.log.info('Opening your browser to log in to the Intlayer CMS...');\n // `exitAfter: false` keeps the process alive so the flow can finish; the\n // credentials are persisted to `.env` and the editor enabled in the config.\n await login({\n exitAfter: false,\n onCredentials: (credentials) => setupCmsCredentials(root, credentials),\n });\n }\n\n p.outro('Intlayer initialization complete');\n};\n\nexport const init = async (\n projectRoot?: string,\n options?: InitOptions,\n interactive?: boolean\n) => {\n const root = projectRoot\n ? findProjectRoot(resolve(projectRoot))\n : findProjectRoot(process.cwd());\n\n if (interactive) {\n await runInteractiveInit(root, options);\n return;\n }\n\n await initIntlayer(root, options);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,MAAa,mBAAmB,aAAqB;CACnD,IAAI,aAAa;CAEjB,OAAO,mBAAeA,mBAAQ,YAAY,IAAI,GAAG;EAC/C,QAAIC,wBAAWC,gBAAK,YAAY,cAAc,CAAC,GAC7C,OAAO;EAET,iBAAaF,mBAAQ,YAAY,IAAI;CACvC;CAIA,OAAO;AACT;AAeA,MAAM,yBAID;CACH;EACE,OAAO;EACP,OAAO;EACP,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;CACR;CACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;CACR;CACA;EACE,OAAO;EACP,O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AW;GACX,gBAAgB,oBAAgBC,0CAAoB,MAAM,WAAW;EACvE,CAAC;CACH;CAEA,EAAE,MAAM,kCAAkC;AAC5C;AAEA,MAAa,OAAO,OAClB,aACA,SACA,gBACG;CACH,MAAM,OAAO,cACT,oBAAgBf,mBAAQ,WAAW,CAAC,IACpC,gBAAgB,QAAQ,IAAI,CAAC;CAEjC,IAAI,aAAa;EACf,MAAM,mBAAmB,MAAM,OAAO;EACtC;CACF;CAEA,UAAMM,mCAAa,MAAM,OAAO;AAClC"}
@@ -1,11 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ const require_loadPrompts = require('./loadPrompts.cjs');
3
3
  const require_init = require('./init.cjs');
4
4
  let node_fs = require("node:fs");
5
5
  let node_path = require("node:path");
6
6
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
7
- let _clack_prompts = require("@clack/prompts");
8
- _clack_prompts = require_runtime.__toESM(_clack_prompts);
9
7
 
10
8
  //#region src/initBuildOptimization.ts
11
9
  /** Babel config filenames Next.js picks up, ordered by preference. */
@@ -29,9 +27,10 @@ const BABEL_CONFIG_CANDIDATES = [
29
27
  * @param projectRoot - Optional project root; defaults to the current directory.
30
28
  */
31
29
  const initBuildOptimization = async (projectRoot) => {
30
+ const p = await require_loadPrompts.loadPrompts();
32
31
  const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
33
- _clack_prompts.intro("Configuring Next.js build optimization");
34
- const plugin = await _clack_prompts.select({
32
+ p.intro("Configuring Next.js build optimization");
33
+ const plugin = await p.select({
35
34
  message: "Which build optimization plugin do you want to use?",
36
35
  options: [{
37
36
  value: "babel",
@@ -43,37 +42,37 @@ const initBuildOptimization = async (projectRoot) => {
43
42
  hint: "Lightweight — SWC plugin that rewrites useIntlayer imports; wired automatically by withIntlayer"
44
43
  }]
45
44
  });
46
- if (_clack_prompts.isCancel(plugin) || !plugin) {
47
- _clack_prompts.cancel("Operation cancelled.");
45
+ if (p.isCancel(plugin) || !plugin) {
46
+ p.cancel("Operation cancelled.");
48
47
  return;
49
48
  }
50
49
  const packageManager = (0, _intlayer_engine_cli.detectPackageManager)(root);
51
50
  const packageToInstall = plugin === "babel" ? "@intlayer/babel" : "@intlayer/swc";
52
- const spinner = _clack_prompts.spinner();
51
+ const spinner = p.spinner();
53
52
  spinner.start("Installing packages...");
54
53
  try {
55
54
  (0, _intlayer_engine_cli.installPackages)(root, [packageToInstall], packageManager, true);
56
55
  spinner.stop(`Installed: ${packageToInstall}`);
57
56
  } catch {
58
57
  spinner.stop("Package installation failed");
59
- _clack_prompts.log.warn(`Please install manually: ${packageToInstall} (dev dependency)`);
58
+ p.log.warn(`Please install manually: ${packageToInstall} (dev dependency)`);
60
59
  }
61
60
  if (plugin === "swc") {
62
- _clack_prompts.outro("Build optimization configuration complete");
61
+ p.outro("Build optimization configuration complete");
63
62
  return;
64
63
  }
65
64
  const existingBabelConfig = BABEL_CONFIG_CANDIDATES.find((file) => (0, node_fs.existsSync)((0, node_path.join)(root, file)));
66
65
  if (existingBabelConfig) {
67
- _clack_prompts.log.warn(`${existingBabelConfig} already exists — add the Intlayer plugins manually.`);
68
- _clack_prompts.note(_intlayer_engine_cli.NEXT_INTLAYER_BABEL_CONFIG_CONTENT, "Plugins to add to your babel config");
66
+ p.log.warn(`${existingBabelConfig} already exists — add the Intlayer plugins manually.`);
67
+ p.note(_intlayer_engine_cli.NEXT_INTLAYER_BABEL_CONFIG_CONTENT, "Plugins to add to your babel config");
69
68
  } else try {
70
69
  (0, node_fs.writeFileSync)((0, node_path.join)(root, "babel.config.js"), _intlayer_engine_cli.NEXT_INTLAYER_BABEL_CONFIG_CONTENT, { encoding: "utf-8" });
71
- _clack_prompts.log.success("Created babel.config.js with the Intlayer compiler plugins (extract, purge, minify, optimize)");
70
+ p.log.success("Created babel.config.js with the Intlayer compiler plugins (extract, purge, minify, optimize)");
72
71
  } catch {
73
- _clack_prompts.log.warn("Could not create babel.config.js — please create it manually.");
74
- _clack_prompts.note(_intlayer_engine_cli.NEXT_INTLAYER_BABEL_CONFIG_CONTENT, "babel.config.js");
72
+ p.log.warn("Could not create babel.config.js — please create it manually.");
73
+ p.note(_intlayer_engine_cli.NEXT_INTLAYER_BABEL_CONFIG_CONTENT, "babel.config.js");
75
74
  }
76
- _clack_prompts.outro("Build optimization configuration complete");
75
+ p.outro("Build optimization configuration complete");
77
76
  };
78
77
 
79
78
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"initBuildOptimization.cjs","names":["findProjectRoot","resolve","p","detectPackageManager","existsSync","join","NEXT_INTLAYER_BABEL_CONFIG_CONTENT"],"sources":["../../src/initBuildOptimization.ts"],"sourcesContent":["import { existsSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n detectPackageManager,\n installPackages,\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n} from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\n\n/** Intlayer build optimization plugin choices for Next.js. */\nexport type BuildOptimizationPlugin = 'babel' | 'swc';\n\n/** Babel config filenames Next.js picks up, ordered by preference. */\nconst BABEL_CONFIG_CANDIDATES = [\n 'babel.config.js',\n 'babel.config.cjs',\n 'babel.config.mjs',\n 'babel.config.ts',\n];\n\n/**\n * Interactive prompt to select a build optimization plugin for Next.js and\n * scaffold the required files. The two options are independent — pick one:\n *\n * - `@intlayer/babel` — runs the full compiler pipeline (extract, purge, minify,\n * optimize) through Babel. Installs `@intlayer/babel` and creates a\n * `babel.config.js`.\n * - `@intlayer/swc` — lightweight SWC plugin that rewrites `useIntlayer` imports.\n * Installs only the dependency; `withIntlayer` wires it in automatically, so\n * no config file is required.\n *\n * @param projectRoot - Optional project root; defaults to the current directory.\n */\nexport const initBuildOptimization = async (\n projectRoot?: string\n): Promise<void> => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n p.intro('Configuring Next.js build optimization');\n\n const plugin = (await p.select({\n message: 'Which build optimization plugin do you want to use?',\n options: [\n {\n value: 'babel',\n label: '@intlayer/babel',\n hint: 'Full pipeline — extract, purge, minify and optimize via Babel; creates babel.config.js',\n },\n {\n value: 'swc',\n label: '@intlayer/swc',\n hint: 'Lightweight — SWC plugin that rewrites useIntlayer imports; wired automatically by withIntlayer',\n },\n ],\n })) as BuildOptimizationPlugin;\n\n if (p.isCancel(plugin) || !plugin) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const packageManager = detectPackageManager(root);\n const packageToInstall =\n plugin === 'babel' ? '@intlayer/babel' : '@intlayer/swc';\n\n const spinner = p.spinner();\n spinner.start('Installing packages...');\n\n try {\n installPackages(root, [packageToInstall], packageManager, true);\n spinner.stop(`Installed: ${packageToInstall}`);\n } catch {\n spinner.stop('Package installation failed');\n p.log.warn(`Please install manually: ${packageToInstall} (dev dependency)`);\n }\n\n // SWC needs no extra setup — withIntlayer injects the plugin at build time.\n if (plugin === 'swc') {\n p.outro('Build optimization configuration complete');\n return;\n }\n\n // BABEL — scaffold babel.config.js with the full compiler pipeline.\n const existingBabelConfig = BABEL_CONFIG_CANDIDATES.find((file) =>\n existsSync(join(root, file))\n );\n\n if (existingBabelConfig) {\n p.log.warn(\n `${existingBabelConfig} already exists — add the Intlayer plugins manually.`\n );\n p.note(\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n 'Plugins to add to your babel config'\n );\n } else {\n try {\n writeFileSync(\n join(root, 'babel.config.js'),\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n { encoding: 'utf-8' }\n );\n p.log.success(\n 'Created babel.config.js with the Intlayer compiler plugins (extract, purge, minify, optimize)'\n );\n } catch {\n p.log.warn(\n 'Could not create babel.config.js — please create it manually.'\n );\n p.note(NEXT_INTLAYER_BABEL_CONFIG_CONTENT, 'babel.config.js');\n }\n }\n\n p.outro('Build optimization configuration complete');\n};\n"],"mappings":";;;;;;;;;;;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AE,MAAM,2CAA2C;AACrD"}
1
+ {"version":3,"file":"initBuildOptimization.cjs","names":["loadPrompts","findProjectRoot","resolve","detectPackageManager","existsSync","join","NEXT_INTLAYER_BABEL_CONFIG_CONTENT"],"sources":["../../src/initBuildOptimization.ts"],"sourcesContent":["import { existsSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n detectPackageManager,\n installPackages,\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n} from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\nimport { loadPrompts } from './loadPrompts';\n\n/** Intlayer build optimization plugin choices for Next.js. */\nexport type BuildOptimizationPlugin = 'babel' | 'swc';\n\n/** Babel config filenames Next.js picks up, ordered by preference. */\nconst BABEL_CONFIG_CANDIDATES = [\n 'babel.config.js',\n 'babel.config.cjs',\n 'babel.config.mjs',\n 'babel.config.ts',\n];\n\n/**\n * Interactive prompt to select a build optimization plugin for Next.js and\n * scaffold the required files. The two options are independent — pick one:\n *\n * - `@intlayer/babel` — runs the full compiler pipeline (extract, purge, minify,\n * optimize) through Babel. Installs `@intlayer/babel` and creates a\n * `babel.config.js`.\n * - `@intlayer/swc` — lightweight SWC plugin that rewrites `useIntlayer` imports.\n * Installs only the dependency; `withIntlayer` wires it in automatically, so\n * no config file is required.\n *\n * @param projectRoot - Optional project root; defaults to the current directory.\n */\nexport const initBuildOptimization = async (\n projectRoot?: string\n): Promise<void> => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n p.intro('Configuring Next.js build optimization');\n\n const plugin = (await p.select({\n message: 'Which build optimization plugin do you want to use?',\n options: [\n {\n value: 'babel',\n label: '@intlayer/babel',\n hint: 'Full pipeline — extract, purge, minify and optimize via Babel; creates babel.config.js',\n },\n {\n value: 'swc',\n label: '@intlayer/swc',\n hint: 'Lightweight — SWC plugin that rewrites useIntlayer imports; wired automatically by withIntlayer',\n },\n ],\n })) as BuildOptimizationPlugin;\n\n if (p.isCancel(plugin) || !plugin) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const packageManager = detectPackageManager(root);\n const packageToInstall =\n plugin === 'babel' ? '@intlayer/babel' : '@intlayer/swc';\n\n const spinner = p.spinner();\n spinner.start('Installing packages...');\n\n try {\n installPackages(root, [packageToInstall], packageManager, true);\n spinner.stop(`Installed: ${packageToInstall}`);\n } catch {\n spinner.stop('Package installation failed');\n p.log.warn(`Please install manually: ${packageToInstall} (dev dependency)`);\n }\n\n // SWC needs no extra setup — withIntlayer injects the plugin at build time.\n if (plugin === 'swc') {\n p.outro('Build optimization configuration complete');\n return;\n }\n\n // BABEL — scaffold babel.config.js with the full compiler pipeline.\n const existingBabelConfig = BABEL_CONFIG_CANDIDATES.find((file) =>\n existsSync(join(root, file))\n );\n\n if (existingBabelConfig) {\n p.log.warn(\n `${existingBabelConfig} already exists — add the Intlayer plugins manually.`\n );\n p.note(\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n 'Plugins to add to your babel config'\n );\n } else {\n try {\n writeFileSync(\n join(root, 'babel.config.js'),\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n { encoding: 'utf-8' }\n );\n p.log.success(\n 'Created babel.config.js with the Intlayer compiler plugins (extract, purge, minify, optimize)'\n );\n } catch {\n p.log.warn(\n 'Could not create babel.config.js — please create it manually.'\n );\n p.note(NEXT_INTLAYER_BABEL_CONFIG_CONTENT, 'babel.config.js');\n }\n }\n\n p.outro('Build optimization configuration complete');\n};\n"],"mappings":";;;;;;;;;AAcA,MAAM,0BAA0B;CAC9B;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;AAeA,MAAa,wBAAwB,OACnC,gBACkB;CAClB,MAAM,IAAI,MAAMA,gCAAY;CAE5B,MAAM,OAAOC,6BACX,kBAAcC,mBAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CACA,EAAE,MAAM,wCAAwC;CAEhD,MAAM,SAAU,MAAM,EAAE,OAAO;EAC7B,SAAS;EACT,SAAS,CACP;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,GACA;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,CACF;CACF,CAAC;CAED,IAAI,EAAE,SAAS,MAAM,KAAK,CAAC,QAAQ;EACjC,EAAE,OAAO,sBAAsB;EAC/B;CACF;CAEA,MAAM,qBAAiBC,2CAAqB,IAAI;CAChD,MAAM,mBACJ,WAAW,UAAU,oBAAoB;CAE3C,MAAM,UAAU,EAAE,QAAQ;CAC1B,QAAQ,MAAM,wBAAwB;CAEtC,IAAI;EACF,0CAAgB,MAAM,CAAC,gBAAgB,GAAG,gBAAgB,IAAI;EAC9D,QAAQ,KAAK,cAAc,kBAAkB;CAC/C,QAAQ;EACN,QAAQ,KAAK,6BAA6B;EAC1C,EAAE,IAAI,KAAK,4BAA4B,iBAAiB,kBAAkB;CAC5E;CAGA,IAAI,WAAW,OAAO;EACpB,EAAE,MAAM,2CAA2C;EACnD;CACF;CAGA,MAAM,sBAAsB,wBAAwB,MAAM,aACxDC,wBAAWC,gBAAK,MAAM,IAAI,CAAC,CAC7B;CAEA,IAAI,qBAAqB;EACvB,EAAE,IAAI,KACJ,GAAG,oBAAoB,qDACzB;EACA,EAAE,KACAC,yDACA,qCACF;CACF,OACE,IAAI;EACF,+BACED,gBAAK,MAAM,iBAAiB,GAC5BC,yDACA,EAAE,UAAU,QAAQ,CACtB;EACA,EAAE,IAAI,QACJ,+FACF;CACF,QAAQ;EACN,EAAE,IAAI,KACJ,+DACF;EACA,EAAE,KAAKA,yDAAoC,iBAAiB;CAC9D;CAGF,EAAE,MAAM,2CAA2C;AACrD"}
@@ -1,40 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ const require_loadPrompts = require('./loadPrompts.cjs');
3
3
  const require_init = require('./init.cjs');
4
4
  let node_fs = require("node:fs");
5
5
  let node_path = require("node:path");
6
6
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
7
- let _clack_prompts = require("@clack/prompts");
8
- _clack_prompts = require_runtime.__toESM(_clack_prompts);
9
7
 
10
8
  //#region src/initCompiler.ts
11
9
  /**
12
- * babel.config.js that runs the Intlayer compiler passes for Next.js.
13
- *
14
- * Mirrors the Next.js (Babel) tab of `docs/docs/en/compiler.md`: the extract
15
- * plugin pulls inline content into dictionaries and the optimize plugin
16
- * rewrites `useIntlayer` into direct dictionary imports. On Vite the same work
17
- * is handled by the `intlayer()` plugin (which bundles the compiler in v9), so
18
- * no Babel config is needed.
19
- */
20
- const BABEL_COMPILER_CONFIG_CONTENT = `const {
21
- intlayerExtractBabelPlugin,
22
- intlayerOptimizeBabelPlugin,
23
- getExtractPluginOptions,
24
- getOptimizePluginOptions,
25
- } = require("@intlayer/babel");
26
-
27
- module.exports = {
28
- presets: ["next/babel"],
29
- plugins: [
30
- // Extract content from components into dictionaries
31
- [intlayerExtractBabelPlugin, getExtractPluginOptions()],
32
- // Optimize imports by replacing useIntlayer with direct dictionary imports
33
- [intlayerOptimizeBabelPlugin, getOptimizePluginOptions()],
34
- ],
35
- };
36
- `;
37
- /**
38
10
  * Reads the project dependencies and detects which framework the compiler
39
11
  * should target. Next.js is checked before Vite because a Next.js project may
40
12
  * transitively depend on Vite tooling.
@@ -62,54 +34,42 @@ const detectCompilerFramework = (root) => {
62
34
  * - **Vite** — nothing to do: since v9 the compiler is built into the
63
35
  * `intlayer()` plugin in `vite.config.ts`, so this only confirms the setup
64
36
  * to the user.
65
- * - **Next.js** — installs `@intlayer/babel` and writes a `babel.config.js`
66
- * that runs the extract + optimize compiler passes.
37
+ * - **Next.js** — installs `@intlayer/babel`, which is all that is needed:
38
+ * `withIntlayer` registers `next-intlayer/extractor-loader` on both webpack
39
+ * and Turbopack as soon as the package resolves. No `babel.config.js` is
40
+ * written — Turbopack never reads one, and on webpack its mere presence
41
+ * switches Next.js off SWC, taking the `@intlayer/swc` optimize pass with it.
67
42
  *
68
43
  * In non-interactive init this function is never called, so the compiler setup
69
44
  * is left untouched.
70
45
  */
71
46
  const initCompiler = async (projectRoot) => {
47
+ const p = await require_loadPrompts.loadPrompts();
72
48
  const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
73
49
  const framework = detectCompilerFramework(root);
74
50
  if (framework === "vite") {
75
- _clack_prompts.log.info("Vite detected — the compiler is built into `intlayer()` in your vite.config. Nothing to configure.");
51
+ p.log.info("Vite detected — the compiler is built into `intlayer()` in your vite.config. Nothing to configure.");
76
52
  return;
77
53
  }
78
54
  if (framework !== "nextjs") {
79
- _clack_prompts.log.warn("No supported framework detected for the compiler — skipping. See the compiler docs for manual setup.");
55
+ p.log.warn("No supported framework detected for the compiler — skipping. See the compiler docs for manual setup.");
80
56
  return;
81
57
  }
82
- _clack_prompts.intro("Configuring the Intlayer compiler for Next.js");
58
+ p.intro("Configuring the Intlayer compiler for Next.js");
83
59
  const packageManager = (0, _intlayer_engine_cli.detectPackageManager)(root);
84
60
  const devPackagesToInstall = ["@intlayer/babel"];
85
- const spinner = _clack_prompts.spinner();
61
+ const spinner = p.spinner();
86
62
  spinner.start("Installing packages...");
87
63
  try {
88
64
  (0, _intlayer_engine_cli.installPackages)(root, devPackagesToInstall, packageManager, true);
89
65
  spinner.stop(`Installed: ${devPackagesToInstall.join(", ")}`);
90
66
  } catch {
91
67
  spinner.stop("Package installation failed");
92
- _clack_prompts.log.warn(`Please install manually: ${devPackagesToInstall.join(" ")} (dev dependency)`);
93
- }
94
- const existingBabelConfig = [
95
- "babel.config.js",
96
- "babel.config.cjs",
97
- "babel.config.mjs",
98
- "babel.config.ts",
99
- ".babelrc",
100
- ".babelrc.js"
101
- ].find((file) => (0, node_fs.existsSync)((0, node_path.join)(root, file)));
102
- if (existingBabelConfig) {
103
- _clack_prompts.log.warn(`${existingBabelConfig} already exists — add the Intlayer compiler plugins manually.`);
104
- _clack_prompts.note(BABEL_COMPILER_CONFIG_CONTENT, "Plugins to add to your babel config");
105
- } else try {
106
- (0, node_fs.writeFileSync)((0, node_path.join)(root, "babel.config.js"), BABEL_COMPILER_CONFIG_CONTENT, { encoding: "utf-8" });
107
- _clack_prompts.log.success("Created babel.config.js with the Intlayer compiler extract and optimize plugins");
108
- } catch {
109
- _clack_prompts.log.warn("Could not create babel.config.js — please create it manually.");
110
- _clack_prompts.note(BABEL_COMPILER_CONFIG_CONTENT, "babel.config.js");
68
+ p.log.warn(`Please install manually: ${devPackagesToInstall.join(" ")} (dev dependency)`);
111
69
  }
112
- _clack_prompts.outro("Compiler configuration complete");
70
+ p.log.success("The compiler runs through `withIntlayer` in your next.config — nothing else to wire up.");
71
+ p.log.info("Set `compiler.enabled` in intlayer.config.ts to turn the extraction on.");
72
+ p.outro("Compiler configuration complete");
113
73
  };
114
74
 
115
75
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"initCompiler.cjs","names":["join","existsSync","readFileSync","findProjectRoot","resolve","detectPackageManager","p"],"sources":["../../src/initCompiler.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport { detectPackageManager, installPackages } from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\n\n/** Framework the Intlayer compiler can be wired into during init. */\ntype CompilerFramework = 'vite' | 'nextjs' | 'unknown';\n\n/**\n * babel.config.js that runs the Intlayer compiler passes for Next.js.\n *\n * Mirrors the Next.js (Babel) tab of `docs/docs/en/compiler.md`: the extract\n * plugin pulls inline content into dictionaries and the optimize plugin\n * rewrites `useIntlayer` into direct dictionary imports. On Vite the same work\n * is handled by the `intlayer()` plugin (which bundles the compiler in v9), so\n * no Babel config is needed.\n */\nconst BABEL_COMPILER_CONFIG_CONTENT = `const {\n intlayerExtractBabelPlugin,\n intlayerOptimizeBabelPlugin,\n getExtractPluginOptions,\n getOptimizePluginOptions,\n} = require(\"@intlayer/babel\");\n\nmodule.exports = {\n presets: [\"next/babel\"],\n plugins: [\n // Extract content from components into dictionaries\n [intlayerExtractBabelPlugin, getExtractPluginOptions()],\n // Optimize imports by replacing useIntlayer with direct dictionary imports\n [intlayerOptimizeBabelPlugin, getOptimizePluginOptions()],\n ],\n};\n`;\n\n/**\n * Reads the project dependencies and detects which framework the compiler\n * should target. Next.js is checked before Vite because a Next.js project may\n * transitively depend on Vite tooling.\n */\nconst detectCompilerFramework = (root: string): CompilerFramework => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return 'unknown';\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n const allDependencies = { ...dependencies, ...devDependencies };\n\n if (allDependencies.next) return 'nextjs';\n if (allDependencies.vite) return 'vite';\n\n return 'unknown';\n } catch {\n return 'unknown';\n }\n};\n\n/**\n * Scaffolds the Intlayer compiler for the current project during interactive\n * init.\n *\n * - **Vite** — nothing to do: since v9 the compiler is built into the\n * `intlayer()` plugin in `vite.config.ts`, so this only confirms the setup\n * to the user.\n * - **Next.js** — installs `@intlayer/babel` and writes a `babel.config.js`\n * that runs the extract + optimize compiler passes.\n *\n * In non-interactive init this function is never called, so the compiler setup\n * is left untouched.\n */\nexport const initCompiler = async (projectRoot?: string): Promise<void> => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n const framework = detectCompilerFramework(root);\n\n if (framework === 'vite') {\n // Since v9 the compiler is bundled inside intlayer() — nothing to scaffold.\n p.log.info(\n 'Vite detected — the compiler is built into `intlayer()` in your vite.config. Nothing to configure.'\n );\n return;\n }\n\n if (framework !== 'nextjs') {\n p.log.warn(\n 'No supported framework detected for the compiler — skipping. See the compiler docs for manual setup.'\n );\n return;\n }\n\n p.intro('Configuring the Intlayer compiler for Next.js');\n\n const packageManager = detectPackageManager(root);\n const devPackagesToInstall = ['@intlayer/babel'];\n\n const spinner = p.spinner();\n spinner.start('Installing packages...');\n\n try {\n installPackages(root, devPackagesToInstall, packageManager, true);\n spinner.stop(`Installed: ${devPackagesToInstall.join(', ')}`);\n } catch {\n spinner.stop('Package installation failed');\n p.log.warn(\n `Please install manually: ${devPackagesToInstall.join(' ')} (dev dependency)`\n );\n }\n\n const babelConfigCandidates = [\n 'babel.config.js',\n 'babel.config.cjs',\n 'babel.config.mjs',\n 'babel.config.ts',\n '.babelrc',\n '.babelrc.js',\n ];\n\n const existingBabelConfig = babelConfigCandidates.find((file) =>\n existsSync(join(root, file))\n );\n\n if (existingBabelConfig) {\n p.log.warn(\n `${existingBabelConfig} already exists — add the Intlayer compiler plugins manually.`\n );\n p.note(\n BABEL_COMPILER_CONFIG_CONTENT,\n 'Plugins to add to your babel config'\n );\n } else {\n try {\n writeFileSync(\n join(root, 'babel.config.js'),\n BABEL_COMPILER_CONFIG_CONTENT,\n { encoding: 'utf-8' }\n );\n p.log.success(\n 'Created babel.config.js with the Intlayer compiler extract and optimize plugins'\n );\n } catch {\n p.log.warn(\n 'Could not create babel.config.js — please create it manually.'\n );\n p.note(BABEL_COMPILER_CONFIG_CONTENT, 'babel.config.js');\n }\n }\n\n p.outro('Compiler configuration complete');\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;AAuBtC,MAAM,2BAA2B,SAAoC;CACnE,IAAI;EACF,MAAM,sBAAkBA,gBAAK,MAAM,cAAc;EACjD,IAAI,KAACC,oBAAW,eAAe,GAAG,OAAO;EAEzC,MAAM,EAAE,eAAe,CAAC,GAAG,kBAAkB,CAAC,MAAM,KAAK,UACvDC,sBAAa,iBAAiB,OAAO,CACvC;EACA,MAAM,kBAAkB;GAAE,GAAG;GAAc,GAAG;EAAgB;EAE9D,IAAI,gBAAgB,MAAM,OAAO;EACjC,IAAI,gBAAgB,MAAM,OAAO;EAEjC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;;;;AAeA,MAAa,eAAe,OAAO,gBAAwC;CACzE,MAAM,OAAOC,6BACX,kBAAcC,mBAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,MAAM,YAAY,wBAAwB,IAAI;CAE9C,IAAI,cAAc,QAAQ;EAExB,eAAE,IAAI,KACJ,oGACF;EACA;CACF;CAEA,IAAI,cAAc,UAAU;EAC1B,eAAE,IAAI,KACJ,sGACF;EACA;CACF;CAEA,eAAE,MAAM,+CAA+C;CAEvD,MAAM,qBAAiBC,2CAAqB,IAAI;CAChD,MAAM,uBAAuB,CAAC,iBAAiB;CAE/C,MAAM,UAAUC,eAAE,QAAQ;CAC1B,QAAQ,MAAM,wBAAwB;CAEtC,IAAI;EACF,0CAAgB,MAAM,sBAAsB,gBAAgB,IAAI;EAChE,QAAQ,KAAK,cAAc,qBAAqB,KAAK,IAAI,GAAG;CAC9D,QAAQ;EACN,QAAQ,KAAK,6BAA6B;EAC1C,eAAE,IAAI,KACJ,4BAA4B,qBAAqB,KAAK,GAAG,EAAE,kBAC7D;CACF;CAWA,MAAM,sBAAsB;EAR1B;EACA;EACA;EACA;EACA;EACA;CAG8C,CAAC,CAAC,MAAM,aACtDL,wBAAWD,gBAAK,MAAM,IAAI,CAAC,CAC7B;CAEA,IAAI,qBAAqB;EACvB,eAAE,IAAI,KACJ,GAAG,oBAAoB,8DACzB;EACA,eAAE,KACA,+BACA,qCACF;CACF,OACE,IAAI;EACF,+BACEA,gBAAK,MAAM,iBAAiB,GAC5B,+BACA,EAAE,UAAU,QAAQ,CACtB;EACA,eAAE,IAAI,QACJ,iFACF;CACF,QAAQ;EACN,eAAE,IAAI,KACJ,+DACF;EACA,eAAE,KAAK,+BAA+B,iBAAiB;CACzD;CAGF,eAAE,MAAM,iCAAiC;AAC3C"}
1
+ {"version":3,"file":"initCompiler.cjs","names":["join","existsSync","readFileSync","loadPrompts","findProjectRoot","resolve","detectPackageManager"],"sources":["../../src/initCompiler.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { detectPackageManager, installPackages } from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\nimport { loadPrompts } from './loadPrompts';\n\n/** Framework the Intlayer compiler can be wired into during init. */\ntype CompilerFramework = 'vite' | 'nextjs' | 'unknown';\n\n/**\n * Reads the project dependencies and detects which framework the compiler\n * should target. Next.js is checked before Vite because a Next.js project may\n * transitively depend on Vite tooling.\n */\nconst detectCompilerFramework = (root: string): CompilerFramework => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return 'unknown';\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n const allDependencies = { ...dependencies, ...devDependencies };\n\n if (allDependencies.next) return 'nextjs';\n if (allDependencies.vite) return 'vite';\n\n return 'unknown';\n } catch {\n return 'unknown';\n }\n};\n\n/**\n * Scaffolds the Intlayer compiler for the current project during interactive\n * init.\n *\n * - **Vite** — nothing to do: since v9 the compiler is built into the\n * `intlayer()` plugin in `vite.config.ts`, so this only confirms the setup\n * to the user.\n * - **Next.js** — installs `@intlayer/babel`, which is all that is needed:\n * `withIntlayer` registers `next-intlayer/extractor-loader` on both webpack\n * and Turbopack as soon as the package resolves. No `babel.config.js` is\n * written — Turbopack never reads one, and on webpack its mere presence\n * switches Next.js off SWC, taking the `@intlayer/swc` optimize pass with it.\n *\n * In non-interactive init this function is never called, so the compiler setup\n * is left untouched.\n */\nexport const initCompiler = async (projectRoot?: string): Promise<void> => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n const framework = detectCompilerFramework(root);\n\n if (framework === 'vite') {\n // Since v9 the compiler is bundled inside intlayer() — nothing to scaffold.\n p.log.info(\n 'Vite detected — the compiler is built into `intlayer()` in your vite.config. Nothing to configure.'\n );\n return;\n }\n\n if (framework !== 'nextjs') {\n p.log.warn(\n 'No supported framework detected for the compiler — skipping. See the compiler docs for manual setup.'\n );\n return;\n }\n\n p.intro('Configuring the Intlayer compiler for Next.js');\n\n const packageManager = detectPackageManager(root);\n const devPackagesToInstall = ['@intlayer/babel'];\n\n const spinner = p.spinner();\n spinner.start('Installing packages...');\n\n try {\n installPackages(root, devPackagesToInstall, packageManager, true);\n spinner.stop(`Installed: ${devPackagesToInstall.join(', ')}`);\n } catch {\n spinner.stop('Package installation failed');\n p.log.warn(\n `Please install manually: ${devPackagesToInstall.join(' ')} (dev dependency)`\n );\n }\n\n p.log.success(\n 'The compiler runs through `withIntlayer` in your next.config — nothing else to wire up.'\n );\n p.log.info(\n 'Set `compiler.enabled` in intlayer.config.ts to turn the extraction on.'\n );\n\n p.outro('Compiler configuration complete');\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,2BAA2B,SAAoC;CACnE,IAAI;EACF,MAAM,sBAAkBA,gBAAK,MAAM,cAAc;EACjD,IAAI,KAACC,oBAAW,eAAe,GAAG,OAAO;EAEzC,MAAM,EAAE,eAAe,CAAC,GAAG,kBAAkB,CAAC,MAAM,KAAK,UACvDC,sBAAa,iBAAiB,OAAO,CACvC;EACA,MAAM,kBAAkB;GAAE,GAAG;GAAc,GAAG;EAAgB;EAE9D,IAAI,gBAAgB,MAAM,OAAO;EACjC,IAAI,gBAAgB,MAAM,OAAO;EAEjC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,eAAe,OAAO,gBAAwC;CACzE,MAAM,IAAI,MAAMC,gCAAY;CAE5B,MAAM,OAAOC,6BACX,kBAAcC,mBAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,MAAM,YAAY,wBAAwB,IAAI;CAE9C,IAAI,cAAc,QAAQ;EAExB,EAAE,IAAI,KACJ,oGACF;EACA;CACF;CAEA,IAAI,cAAc,UAAU;EAC1B,EAAE,IAAI,KACJ,sGACF;EACA;CACF;CAEA,EAAE,MAAM,+CAA+C;CAEvD,MAAM,qBAAiBC,2CAAqB,IAAI;CAChD,MAAM,uBAAuB,CAAC,iBAAiB;CAE/C,MAAM,UAAU,EAAE,QAAQ;CAC1B,QAAQ,MAAM,wBAAwB;CAEtC,IAAI;EACF,0CAAgB,MAAM,sBAAsB,gBAAgB,IAAI;EAChE,QAAQ,KAAK,cAAc,qBAAqB,KAAK,IAAI,GAAG;CAC9D,QAAQ;EACN,QAAQ,KAAK,6BAA6B;EAC1C,EAAE,IAAI,KACJ,4BAA4B,qBAAqB,KAAK,GAAG,EAAE,kBAC7D;CACF;CAEA,EAAE,IAAI,QACJ,yFACF;CACA,EAAE,IAAI,KACJ,yEACF;CAEA,EAAE,MAAM,iCAAiC;AAC3C"}
@@ -1,18 +1,18 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_loadPrompts = require('./loadPrompts.cjs');
3
4
  const require_initSkills = require('./initSkills.cjs');
4
5
  const require_init = require('./init.cjs');
5
6
  let node_path = require("node:path");
6
7
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
7
8
  let enquirer = require("enquirer");
8
9
  enquirer = require_runtime.__toESM(enquirer);
9
- let _clack_prompts = require("@clack/prompts");
10
- _clack_prompts = require_runtime.__toESM(_clack_prompts);
11
10
 
12
11
  //#region src/initMCP.ts
13
12
  const initMCP = async (projectRoot, preselectedPlatform) => {
13
+ const p = await require_loadPrompts.loadPrompts();
14
14
  const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
15
- _clack_prompts.intro("Initializing Intlayer MCP Server");
15
+ p.intro("Initializing Intlayer MCP Server");
16
16
  let platform;
17
17
  if (preselectedPlatform) platform = preselectedPlatform;
18
18
  else {
@@ -31,15 +31,15 @@ const initMCP = async (projectRoot, preselectedPlatform) => {
31
31
  }))
32
32
  })).platforms;
33
33
  } catch {
34
- _clack_prompts.cancel("Operation cancelled.");
34
+ p.cancel("Operation cancelled.");
35
35
  return;
36
36
  }
37
37
  }
38
38
  if (!platform) {
39
- _clack_prompts.cancel("Operation cancelled. No platform selected.");
39
+ p.cancel("Operation cancelled. No platform selected.");
40
40
  return;
41
41
  }
42
- const transport = await _clack_prompts.select({
42
+ const transport = await p.select({
43
43
  message: "Which transport method do you want to use?",
44
44
  options: [{
45
45
  value: "stdio",
@@ -51,21 +51,21 @@ const initMCP = async (projectRoot, preselectedPlatform) => {
51
51
  hint: "Hosted by Intlayer. Documentation only."
52
52
  }]
53
53
  });
54
- if (_clack_prompts.isCancel(transport) || !transport) {
55
- _clack_prompts.cancel("Operation cancelled.");
54
+ if (p.isCancel(transport) || !transport) {
55
+ p.cancel("Operation cancelled.");
56
56
  return;
57
57
  }
58
- const s = _clack_prompts.spinner();
58
+ const s = p.spinner();
59
59
  s.start("Configuring MCP Server...");
60
60
  try {
61
61
  const result = await (0, _intlayer_engine_cli.installMCP)(root, platform, transport);
62
62
  s.stop("MCP Server configured successfully");
63
- _clack_prompts.note(result, "Success");
63
+ p.note(result, "Success");
64
64
  } catch (error) {
65
65
  s.stop("Failed to configure MCP Server");
66
- _clack_prompts.log.error(error instanceof Error ? error.message : String(error));
66
+ p.log.error(error instanceof Error ? error.message : String(error));
67
67
  }
68
- _clack_prompts.outro("Intlayer MCP Server initialization complete");
68
+ p.outro("Intlayer MCP Server initialization complete");
69
69
  };
70
70
 
71
71
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"initMCP.cjs","names":["findProjectRoot","resolve","getDetectedPlatform","PLATFORMS","PLATFORM_OPTIONS","p","installMCP"],"sources":["../../src/initMCP.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n installMCP,\n type MCPTransport,\n PLATFORMS,\n type Platform,\n} from '@intlayer/engine/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { getDetectedPlatform, PLATFORM_OPTIONS } from './initSkills';\n\nexport const initMCP = async (\n projectRoot?: string,\n preselectedPlatform?: Platform\n) => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer MCP Server');\n\n let platform: Platform;\n\n if (preselectedPlatform) {\n platform = preselectedPlatform;\n } else {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (!platform) {\n p.cancel('Operation cancelled. No platform selected.');\n return;\n }\n\n const transport = (await p.select({\n message: 'Which transport method do you want to use?',\n options: [\n {\n value: 'stdio',\n label: 'Local server (stdio)',\n hint: 'Recommended. Integrates all features including CLI tools.',\n },\n {\n value: 'sse',\n label: 'Remote server (SSE)',\n hint: 'Hosted by Intlayer. Documentation only.',\n },\n ],\n })) as MCPTransport;\n\n if (p.isCancel(transport) || !transport) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const s = p.spinner();\n s.start('Configuring MCP Server...');\n\n try {\n const result = await installMCP(root, platform, transport);\n\n s.stop('MCP Server configured successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to configure MCP Server');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer MCP Server initialization complete');\n};\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,UAAU,OACrB,aACA,wBACG;CACH,MAAM,OAAOA,6BACX,kBAAcC,mBAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,eAAE,MAAM,kCAAkC;CAE1C,IAAI;CAEJ,IAAI,qBACF,WAAW;MACN;EACL,MAAM,mBAAmBC,uCAAoB;EAE7C,IAAI;GAeF,YAAW,MAdY,iBAAS,OAAgC;IAC9D,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IACV,SAAS,mBACLC,+BAAU,QAAQ,gBAAgB,IAClC;IACJ,SAASC,oCAAiB,KAAK,SAAS;KACtC,MAAM,IAAI;KACV,SAAS,IAAI;KACb,MAAM,IAAI;IACZ,EAAE;GACJ,CAAC,EACkB,CAAC;EACtB,QAAQ;GACN,eAAE,OAAO,sBAAsB;GAC/B;EACF;CACF;CAEA,IAAI,CAAC,UAAU;EACb,eAAE,OAAO,4CAA4C;EACrD;CACF;CAEA,MAAM,YAAa,MAAMC,eAAE,OAAO;EAChC,SAAS;EACT,SAAS,CACP;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,GACA;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,CACF;CACF,CAAC;CAED,IAAIA,eAAE,SAAS,SAAS,KAAK,CAAC,WAAW;EACvC,eAAE,OAAO,sBAAsB;EAC/B;CACF;CAEA,MAAM,IAAIA,eAAE,QAAQ;CACpB,EAAE,MAAM,2BAA2B;CAEnC,IAAI;EACF,MAAM,SAAS,UAAMC,iCAAW,MAAM,UAAU,SAAS;EAEzD,EAAE,KAAK,oCAAoC;EAE3C,eAAE,KAAK,QAAQ,SAAS;CAC1B,SAAS,OAAO;EACd,EAAE,KAAK,gCAAgC;EACvC,eAAE,IAAI,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE;CAEA,eAAE,MAAM,6CAA6C;AACvD"}
1
+ {"version":3,"file":"initMCP.cjs","names":["loadPrompts","findProjectRoot","resolve","getDetectedPlatform","PLATFORMS","PLATFORM_OPTIONS","installMCP"],"sources":["../../src/initMCP.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport {\n installMCP,\n type MCPTransport,\n PLATFORMS,\n type Platform,\n} from '@intlayer/engine/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { getDetectedPlatform, PLATFORM_OPTIONS } from './initSkills';\nimport { loadPrompts } from './loadPrompts';\n\nexport const initMCP = async (\n projectRoot?: string,\n preselectedPlatform?: Platform\n) => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer MCP Server');\n\n let platform: Platform;\n\n if (preselectedPlatform) {\n platform = preselectedPlatform;\n } else {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n platform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (!platform) {\n p.cancel('Operation cancelled. No platform selected.');\n return;\n }\n\n const transport = (await p.select({\n message: 'Which transport method do you want to use?',\n options: [\n {\n value: 'stdio',\n label: 'Local server (stdio)',\n hint: 'Recommended. Integrates all features including CLI tools.',\n },\n {\n value: 'sse',\n label: 'Remote server (SSE)',\n hint: 'Hosted by Intlayer. Documentation only.',\n },\n ],\n })) as MCPTransport;\n\n if (p.isCancel(transport) || !transport) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const s = p.spinner();\n s.start('Configuring MCP Server...');\n\n try {\n const result = await installMCP(root, platform, transport);\n\n s.stop('MCP Server configured successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to configure MCP Server');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer MCP Server initialization complete');\n};\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,UAAU,OACrB,aACA,wBACG;CACH,MAAM,IAAI,MAAMA,gCAAY;CAE5B,MAAM,OAAOC,6BACX,kBAAcC,mBAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,EAAE,MAAM,kCAAkC;CAE1C,IAAI;CAEJ,IAAI,qB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