@intlayer/cli 9.5.6 → 9.5.8

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 (52) hide show
  1. package/dist/cjs/auth/login.cjs +20 -12
  2. package/dist/cjs/auth/login.cjs.map +1 -1
  3. package/dist/cjs/cli.cjs +21 -6
  4. package/dist/cjs/cli.cjs.map +1 -1
  5. package/dist/cjs/index.cjs +9 -2
  6. package/dist/cjs/init.cjs +66 -135
  7. package/dist/cjs/init.cjs.map +1 -1
  8. package/dist/cjs/initInfra.cjs +105 -0
  9. package/dist/cjs/initInfra.cjs.map +1 -0
  10. package/dist/cjs/initMCP.cjs +1 -25
  11. package/dist/cjs/initMCP.cjs.map +1 -1
  12. package/dist/cjs/initSkills.cjs +35 -26
  13. package/dist/cjs/initSkills.cjs.map +1 -1
  14. package/dist/cjs/upgrade.cjs +18 -0
  15. package/dist/cjs/upgrade.cjs.map +1 -0
  16. package/dist/esm/auth/login.mjs +20 -12
  17. package/dist/esm/auth/login.mjs.map +1 -1
  18. package/dist/esm/cli.mjs +22 -7
  19. package/dist/esm/cli.mjs.map +1 -1
  20. package/dist/esm/index.mjs +4 -3
  21. package/dist/esm/init.mjs +68 -135
  22. package/dist/esm/init.mjs.map +1 -1
  23. package/dist/esm/initInfra.mjs +100 -0
  24. package/dist/esm/initInfra.mjs.map +1 -0
  25. package/dist/esm/initMCP.mjs +3 -25
  26. package/dist/esm/initMCP.mjs.map +1 -1
  27. package/dist/esm/initSkills.mjs +35 -27
  28. package/dist/esm/initSkills.mjs.map +1 -1
  29. package/dist/esm/upgrade.mjs +17 -0
  30. package/dist/esm/upgrade.mjs.map +1 -0
  31. package/dist/types/index.d.ts +3 -2
  32. package/dist/types/init.d.ts.map +1 -1
  33. package/dist/types/initInfra.d.ts +32 -0
  34. package/dist/types/initInfra.d.ts.map +1 -0
  35. package/dist/types/initMCP.d.ts.map +1 -1
  36. package/dist/types/initSkills.d.ts +11 -1
  37. package/dist/types/initSkills.d.ts.map +1 -1
  38. package/dist/types/upgrade.d.ts +9 -0
  39. package/dist/types/upgrade.d.ts.map +1 -0
  40. package/package.json +10 -10
  41. package/dist/cjs/initBuildOptimization.cjs +0 -80
  42. package/dist/cjs/initBuildOptimization.cjs.map +0 -1
  43. package/dist/cjs/initCompiler.cjs +0 -77
  44. package/dist/cjs/initCompiler.cjs.map +0 -1
  45. package/dist/esm/initBuildOptimization.mjs +0 -79
  46. package/dist/esm/initBuildOptimization.mjs.map +0 -1
  47. package/dist/esm/initCompiler.mjs +0 -76
  48. package/dist/esm/initCompiler.mjs.map +0 -1
  49. package/dist/types/initBuildOptimization.d.ts +0 -19
  50. package/dist/types/initBuildOptimization.d.ts.map +0 -1
  51. package/dist/types/initCompiler.d.ts +0 -20
  52. package/dist/types/initCompiler.d.ts.map +0 -1
package/dist/cjs/init.cjs CHANGED
@@ -1,16 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  const require_auth_login = require('./auth/login.cjs');
4
3
  const require_loadPrompts = require('./loadPrompts.cjs');
5
- const require_initBuildOptimization = require('./initBuildOptimization.cjs');
4
+ const require_initInfra = require('./initInfra.cjs');
6
5
  const require_initSkills = require('./initSkills.cjs');
7
6
  const require_initMCP = require('./initMCP.cjs');
8
- const require_initCompiler = require('./initCompiler.cjs');
9
7
  let node_fs = require("node:fs");
10
8
  let node_path = require("node:path");
11
9
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
12
- let enquirer = require("enquirer");
13
- enquirer = require_runtime.__toESM(enquirer);
14
10
 
15
11
  //#region src/init.ts
16
12
  const findProjectRoot = (startDir) => {
@@ -21,48 +17,67 @@ const findProjectRoot = (startDir) => {
21
17
  }
22
18
  return startDir;
23
19
  };
24
- const BASE_INIT_STEP_OPTIONS = [
25
- {
26
- value: "packages",
27
- label: "Install & upgrade packages",
28
- hint: "install missing Intlayer dependencies and upgrade outdated ones"
29
- },
30
- {
31
- value: "githubActions",
32
- label: "CI/CD (GitHub Actions)",
33
- hint: "scaffold the fill and test workflows that run on every pull request (covers every project in a monorepo)"
34
- },
35
- {
36
- value: "frameworkSetup",
37
- label: "Framework setup",
38
- hint: "middleware/proxy and providers in layout/page"
39
- },
40
- {
20
+ /**
21
+ * Steps shown but not pre-selected. The infrastructure installer touches the
22
+ * machine (downloads an app, pulls Docker images) rather than the project, so
23
+ * it must be an explicit choice.
24
+ */
25
+ const OPT_IN_INIT_STEPS = ["infra"];
26
+ /** Grouped checkbox entries of the interactive init flow, in display order. */
27
+ const INIT_STEP_GROUPS = {
28
+ Codebase: [
29
+ {
30
+ value: "packages",
31
+ label: "Install & upgrade packages",
32
+ hint: "install missing Intlayer dependencies and upgrade outdated ones"
33
+ },
34
+ {
35
+ value: "projectSetup",
36
+ label: "Project setup",
37
+ hint: "intlayer config, tsconfig, bundler plugin, middleware/proxy and providers in layout/page"
38
+ },
39
+ {
40
+ value: "githubActions",
41
+ label: "CI/CD (GitHub Actions)",
42
+ hint: "scaffold the fill and test workflows that run on every pull request (covers every project in a monorepo)"
43
+ }
44
+ ],
45
+ DevTools: [{
41
46
  value: "vscodeExtension",
42
47
  label: "VS Code extension",
43
48
  hint: "recommend the Intlayer extension"
44
- },
45
- {
46
- value: "lsp",
47
- label: "Editor LSP",
48
- hint: "go-to-definition from keys to .content files"
49
- },
50
- {
49
+ }, {
51
50
  value: "eslint",
52
51
  label: "Lint rules (ESLint / oxlint)",
53
52
  hint: "flag hardcoded text and dynamic calls the compiler cannot optimize"
54
- },
55
- {
56
- value: "skills",
57
- label: "AI skills",
58
- hint: "install the Intlayer documentation as agent skills"
59
- },
60
- {
61
- value: "mcp",
62
- label: "MCP server",
63
- hint: "configure the Intlayer MCP server"
64
- }
65
- ];
53
+ }],
54
+ "Coding assistant": [
55
+ {
56
+ value: "skills",
57
+ label: "AI skills",
58
+ hint: "install the Intlayer documentation as agent skills"
59
+ },
60
+ {
61
+ value: "mcp",
62
+ label: "MCP server",
63
+ hint: "configure the Intlayer MCP server"
64
+ },
65
+ {
66
+ value: "lsp",
67
+ label: "Editor LSP",
68
+ hint: "go-to-definition from keys to .content files"
69
+ }
70
+ ],
71
+ CMS: [{
72
+ value: "cms",
73
+ label: "CMS",
74
+ hint: "log in through your browser, then store the credentials in your .env"
75
+ }, {
76
+ value: "infra",
77
+ label: "Infrastructure (desktop app / self-hosting)",
78
+ hint: "install the desktop app, or self-host with Docker (all-in-one or Compose)"
79
+ }]
80
+ };
66
81
  /** Locale routing strategies offered by the interactive init flow. */
67
82
  const ROUTING_MODE_OPTIONS = [
68
83
  {
@@ -86,28 +101,6 @@ const ROUTING_MODE_OPTIONS = [
86
101
  hint: "/about?locale=fr"
87
102
  }
88
103
  ];
89
- /**
90
- * Content organization strategies offered by the interactive init flow.
91
- * Drives the `compiler.output` template (autogenerated content: compiler /
92
- * autofill / extract) or the injection of the syncJSON plugin.
93
- */
94
- const CONTENT_STRATEGY_OPTIONS = [
95
- {
96
- value: "per-component",
97
- label: "Per component (default)",
98
- hint: "multilingual .content files co-located with the components"
99
- },
100
- {
101
- value: "centralized",
102
- label: "Centralized folder",
103
- hint: "per-locale JSON dictionaries under /locales/{locale}/{key}.content.json"
104
- },
105
- {
106
- value: "json-namespaces",
107
- label: "JSON namespaces",
108
- hint: "plain /locales/{locale}/{namespace}.json files synced via @intlayer/sync-json-plugin"
109
- }
110
- ];
111
104
  /** Reads the merged dependencies of the project at `root`. */
112
105
  const getProjectDependencies = (root) => {
113
106
  try {
@@ -122,10 +115,6 @@ const getProjectDependencies = (root) => {
122
115
  return {};
123
116
  }
124
117
  };
125
- /** Returns true when the project at `root` depends on Next.js. */
126
- const isNextJsProject = (root) => Boolean(getProjectDependencies(root).next);
127
- /** Returns true when the project at `root` depends on Vite. */
128
- const isViteProject = (root) => Boolean(getProjectDependencies(root).vite);
129
118
  /**
130
119
  * Returns true when the project uses a URL-based router for which a locale
131
120
  * routing strategy is meaningful: Next.js, React Router, or TanStack Router.
@@ -147,22 +136,10 @@ const hasUrlRouting = (root) => {
147
136
  const runInteractiveInit = async (root, baseOptions) => {
148
137
  const p = await require_loadPrompts.loadPrompts();
149
138
  p.intro("Initialize Intlayer");
150
- const stepOptions = [...BASE_INIT_STEP_OPTIONS];
151
- const nextJsProject = isNextJsProject(root);
152
- if (nextJsProject || isViteProject(root)) stepOptions.push({
153
- value: "compiler",
154
- label: "Compiler",
155
- hint: nextJsProject ? "add the Babel compiler config to extract inline content (Next.js)" : "auto-extract inline content at build time (already plugged in on Vite)"
156
- });
157
- if (nextJsProject) stepOptions.push({
158
- value: "buildOptimization",
159
- label: "Bundle optimization",
160
- hint: "choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)"
161
- });
162
- const selected = await p.multiselect({
139
+ const selected = await p.groupMultiselect({
163
140
  message: "Select what you want to set up:",
164
- options: stepOptions,
165
- initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),
141
+ options: INIT_STEP_GROUPS,
142
+ initialValues: Object.values(INIT_STEP_GROUPS).flat().map((option) => option.value).filter((step) => !OPT_IN_INIT_STEPS.includes(step)),
166
143
  required: false
167
144
  });
168
145
  if (p.isCancel(selected)) {
@@ -171,7 +148,7 @@ const runInteractiveInit = async (root, baseOptions) => {
171
148
  }
172
149
  const steps = selected;
173
150
  let routingMode;
174
- if (hasUrlRouting(root)) {
151
+ if (steps.includes("projectSetup") && hasUrlRouting(root)) {
175
152
  const selectedRoutingMode = await p.select({
176
153
  message: "Which locale routing strategy do you want?",
177
154
  options: ROUTING_MODE_OPTIONS,
@@ -184,69 +161,23 @@ const runInteractiveInit = async (root, baseOptions) => {
184
161
  routingMode = selectedRoutingMode;
185
162
  }
186
163
  const detectedCompatLibraries = (0, _intlayer_engine_cli.detectCompatI18nLibraries)(getProjectDependencies(root));
187
- const hasCompatLib = detectedCompatLibraries.length > 0;
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
- let contentStrategy;
190
- if (!hasCompatLib) {
191
- const selectedContentStrategy = await p.select({
192
- message: "How do you want to organize your translated content?",
193
- options: CONTENT_STRATEGY_OPTIONS,
194
- initialValue: "per-component"
195
- });
196
- if (p.isCancel(selectedContentStrategy)) {
197
- p.cancel("Operation cancelled.");
198
- return;
199
- }
200
- contentStrategy = selectedContentStrategy;
201
- }
164
+ if (detectedCompatLibraries.length > 0) 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.`);
202
165
  const options = {
203
166
  ...baseOptions,
204
167
  routingMode,
205
- contentStrategy,
206
168
  noInstallPackages: !steps.includes("packages"),
207
169
  noGitignore: baseOptions?.noGitignore,
208
170
  noGithubActions: baseOptions?.noGithubActions || !steps.includes("githubActions"),
209
- noFrameworkSetup: baseOptions?.noFrameworkSetup || !steps.includes("frameworkSetup"),
171
+ noFrameworkSetup: baseOptions?.noFrameworkSetup || !steps.includes("projectSetup"),
210
172
  noVscodeExtension: !steps.includes("vscodeExtension"),
211
173
  noLsp: !steps.includes("lsp"),
212
174
  noEslint: !steps.includes("eslint")
213
175
  };
214
176
  await (0, _intlayer_engine_cli.initIntlayer)(root, options);
215
- const needsPlatform = steps.includes("skills") || steps.includes("mcp");
216
- let sharedPlatform;
217
- if (needsPlatform) {
218
- const detectedPlatform = require_initSkills.getDetectedPlatform();
219
- try {
220
- sharedPlatform = (await enquirer.default.prompt({
221
- type: "autocomplete",
222
- name: "platforms",
223
- message: "Which platform are you using? (Type to search)",
224
- multiple: false,
225
- initial: detectedPlatform ? _intlayer_engine_cli.PLATFORMS.indexOf(detectedPlatform) : void 0,
226
- choices: require_initSkills.PLATFORM_OPTIONS.map((opt) => ({
227
- name: opt.value,
228
- message: opt.label,
229
- hint: opt.hint
230
- }))
231
- })).platforms;
232
- } catch {
233
- p.cancel("Operation cancelled.");
234
- return;
235
- }
236
- }
237
- if (steps.includes("skills")) await require_initSkills.initSkills(root, sharedPlatform);
238
- if (steps.includes("mcp")) await require_initMCP.initMCP(root, sharedPlatform);
239
- if (steps.includes("compiler")) await require_initCompiler.initCompiler(root);
240
- if (steps.includes("buildOptimization")) await require_initBuildOptimization.initBuildOptimization(root);
241
- const shouldSetUpCms = await p.confirm({
242
- message: "Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)",
243
- initialValue: false
244
- });
245
- if (p.isCancel(shouldSetUpCms)) {
246
- p.cancel("Operation cancelled.");
247
- return;
248
- }
249
- if (shouldSetUpCms) {
177
+ const skillsPlatform = steps.includes("skills") ? await require_initSkills.initSkills(root) : void 0;
178
+ if (steps.includes("mcp")) await require_initMCP.initMCP(root, skillsPlatform);
179
+ if (steps.includes("infra")) await require_initInfra.initInfra();
180
+ if (steps.includes("cms")) {
250
181
  p.log.info("Opening your browser to log in to the Intlayer CMS...");
251
182
  await require_auth_login.login({
252
183
  exitAfter: false,
@@ -1 +1 @@
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,mBA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,kCAAa,IAAI;CAGzB,IAAI,MAAM,SAAS,mBAAmB,GACpC,MAAMC,oDAAsB,IAAI;CAMlC,MAAM,iBAAiB,MAAM,EAAE,QAAQ;EACrC,SACE;EACF,cAAc;CAChB,CAAC;CAED,IAAI,EAAE,SAAS,cAAc,GAAG;EAC9B,EAAE,OAAO,sBAAsB;EAC/B;CACF;CAEA,IAAI,gBAAgB;EAClB,EAAE,IAAI,KAAK,uDAAuD;EAGlE,MAAMC,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","initSkills","initMCP","initInfra","login","setupCmsCredentials"],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n detectCompatI18nLibraries,\n type InitOptions,\n initIntlayer,\n type RoutingMode,\n setupCmsCredentials,\n} from '@intlayer/engine/cli';\nimport { login } from './auth/login';\nimport { initInfra } from './initInfra';\nimport { initMCP } from './initMCP';\nimport { initSkills } 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 | 'projectSetup'\n | 'vscodeExtension'\n | 'lsp'\n | 'eslint'\n | 'skills'\n | 'mcp'\n | 'infra'\n | 'cms';\n\n/** A checkbox entry of the interactive init flow. */\ntype InitStepOption = {\n value: InitStep;\n label: string;\n hint: string;\n};\n\n/**\n * Steps shown but not pre-selected. The infrastructure installer touches the\n * machine (downloads an app, pulls Docker images) rather than the project, so\n * it must be an explicit choice.\n */\nconst OPT_IN_INIT_STEPS: InitStep[] = ['infra'];\n\n/** Grouped checkbox entries of the interactive init flow, in display order. */\nconst INIT_STEP_GROUPS: Record<string, InitStepOption[]> = {\n Codebase: [\n {\n value: 'packages',\n label: 'Install & upgrade packages',\n hint: 'install missing Intlayer dependencies and upgrade outdated ones',\n },\n {\n value: 'projectSetup',\n label: 'Project setup',\n hint: 'intlayer config, tsconfig, bundler plugin, middleware/proxy and providers in layout/page',\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 DevTools: [\n {\n value: 'vscodeExtension',\n label: 'VS Code extension',\n hint: 'recommend the Intlayer extension',\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 'Coding assistant': [\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 value: 'lsp',\n label: 'Editor LSP',\n hint: 'go-to-definition from keys to .content files',\n },\n ],\n CMS: [\n {\n value: 'cms',\n label: 'CMS',\n hint: 'log in through your browser, then store the credentials in your .env',\n },\n {\n value: 'infra',\n label: 'Infrastructure (desktop app / self-hosting)',\n hint: 'install the desktop app, or self-host with Docker (all-in-one or Compose)',\n },\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/** 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/**\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 selected = await p.groupMultiselect<InitStep>({\n message: 'Select what you want to set up:',\n options: INIT_STEP_GROUPS,\n initialValues: Object.values(INIT_STEP_GROUPS)\n .flat()\n .map((option) => option.value)\n .filter((step) => !OPT_IN_INIT_STEPS.includes(step)),\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 (steps.includes('projectSetup') && 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 const options: InitOptions = {\n ...baseOptions,\n routingMode,\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('projectSetup'),\n noVscodeExtension: !steps.includes('vscodeExtension'),\n noLsp: !steps.includes('lsp'),\n noEslint: !steps.includes('eslint'),\n };\n\n await initIntlayer(root, options);\n\n // Skills ask for the platform after the skill selection; MCP reuses it.\n const skillsPlatform = steps.includes('skills')\n ? await initSkills(root)\n : undefined;\n\n if (steps.includes('mcp')) {\n await initMCP(root, skillsPlatform);\n }\n\n // Delegated to the hosted install script, which owns its own menu.\n if (steps.includes('infra')) {\n await initInfra();\n }\n\n // CMS / visual editor runs last: the browser login persists the access-key\n // credentials to `.env` and enables the editor in the config file. Kept last\n // so the browser flow does not interrupt setup.\n if (steps.includes('cms')) {\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":";;;;;;;;;;;AAeA,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;;;;;;AA2BA,MAAM,oBAAgC,CAAC,OAAO;;AAG9C,MAAM,mBAAqD;CACzD,UAAU;EACR;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR;CACF;CACA,UAAU,CACR;EACE,OA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AAG;EACzB,EAAE,IAAI,KAAK,uDAAuD;EAGlE,MAAMC,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,oBAAgBX,mBAAQ,WAAW,CAAC,IACpC,gBAAgB,QAAQ,IAAI,CAAC;CAEjC,IAAI,aAAa;EACf,MAAM,mBAAmB,MAAM,OAAO;EACtC;CACF;CAEA,UAAMM,mCAAa,MAAM,OAAO;AAClC"}
@@ -0,0 +1,105 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_loadPrompts = require('./loadPrompts.cjs');
3
+ let node_path = require("node:path");
4
+ let node_child_process = require("node:child_process");
5
+ let node_os = require("node:os");
6
+ let node_fs_promises = require("node:fs/promises");
7
+
8
+ //#region src/initInfra.ts
9
+ /** Setup modes understood by the hosted installer. */
10
+ const INFRA_MODES = [
11
+ "desktop",
12
+ "docker",
13
+ "compose"
14
+ ];
15
+ /**
16
+ * The hosted installers are the single source of truth for the infrastructure
17
+ * setup flow (desktop app, all-in-one container, Compose stack). The CLI runs
18
+ * them rather than re-implementing the same steps in JavaScript.
19
+ */
20
+ const INSTALL_SCRIPT_URL = "https://intlayer.org/install.sh";
21
+ const INSTALL_SCRIPT_URL_WINDOWS = "https://intlayer.org/install.ps1";
22
+ const POSIX_RUNNER = {
23
+ url: INSTALL_SCRIPT_URL,
24
+ fileName: "install.sh",
25
+ command: (scriptPath, mode) => ["sh", [scriptPath, ...mode ? ["--mode", mode] : []]]
26
+ };
27
+ const WINDOWS_RUNNER = {
28
+ url: INSTALL_SCRIPT_URL_WINDOWS,
29
+ fileName: "install.ps1",
30
+ command: (scriptPath, mode) => ["powershell", [
31
+ "-NoProfile",
32
+ "-ExecutionPolicy",
33
+ "Bypass",
34
+ "-File",
35
+ scriptPath,
36
+ ...mode ? ["-Mode", mode] : []
37
+ ]]
38
+ };
39
+ const getInstallerRunner = () => process.platform === "win32" ? WINDOWS_RUNNER : POSIX_RUNNER;
40
+ /**
41
+ * Validates a user-provided mode against {@link INFRA_MODES}.
42
+ *
43
+ * @throws When the value is not a known mode.
44
+ */
45
+ const parseInfraMode = (value) => {
46
+ if (INFRA_MODES.includes(value)) return value;
47
+ throw new Error(`Unknown infra mode "${value}". Expected one of: ${INFRA_MODES.join(", ")}`);
48
+ };
49
+ /**
50
+ * Runs the installer with the terminal attached, so its own prompts and
51
+ * progress bars reach the user unchanged.
52
+ *
53
+ * @returns The script's exit code.
54
+ */
55
+ const runInstaller = (command, args) => new Promise((resolve, reject) => {
56
+ const child = (0, node_child_process.spawn)(command, args, { stdio: "inherit" });
57
+ child.on("error", reject);
58
+ child.on("close", (code) => resolve(code ?? 1));
59
+ });
60
+ /**
61
+ * Downloads the hosted installer and runs it: desktop app, all-in-one Docker
62
+ * container or Docker Compose stack, chosen interactively unless `mode` is set.
63
+ *
64
+ * Exposed as `intlayer init infra` and as a step of `intlayer init --interactive`.
65
+ */
66
+ const initInfra = async (options = {}) => {
67
+ const p = await require_loadPrompts.loadPrompts();
68
+ const runner = getInstallerRunner();
69
+ const scriptUrl = options.scriptUrl ?? runner.url;
70
+ const spinner = p.spinner();
71
+ spinner.start(`Fetching ${scriptUrl}`);
72
+ let script;
73
+ try {
74
+ const response = await fetch(scriptUrl);
75
+ if (!response.ok) throw new Error(`${response.status} ${response.statusText}`);
76
+ script = await response.text();
77
+ } catch (error) {
78
+ spinner.stop("Could not download the installer", 1);
79
+ p.log.error(`${error.message}\nRun it directly: ${process.platform === "win32" ? `irm ${scriptUrl} | iex` : `curl -fsSL ${scriptUrl} | sh`}`);
80
+ process.exitCode = 1;
81
+ return;
82
+ }
83
+ spinner.stop("Installer downloaded");
84
+ const directory = await (0, node_fs_promises.mkdtemp)((0, node_path.join)((0, node_os.tmpdir)(), "intlayer-install-"));
85
+ const scriptPath = (0, node_path.join)(directory, runner.fileName);
86
+ try {
87
+ await (0, node_fs_promises.writeFile)(scriptPath, script, { mode: 448 });
88
+ const [command, args] = runner.command(scriptPath, options.mode);
89
+ const exitCode = await runInstaller(command, args);
90
+ if (exitCode !== 0) process.exitCode = exitCode;
91
+ } finally {
92
+ await (0, node_fs_promises.rm)(directory, {
93
+ recursive: true,
94
+ force: true
95
+ });
96
+ }
97
+ };
98
+
99
+ //#endregion
100
+ exports.INFRA_MODES = INFRA_MODES;
101
+ exports.INSTALL_SCRIPT_URL = INSTALL_SCRIPT_URL;
102
+ exports.INSTALL_SCRIPT_URL_WINDOWS = INSTALL_SCRIPT_URL_WINDOWS;
103
+ exports.initInfra = initInfra;
104
+ exports.parseInfraMode = parseInfraMode;
105
+ //# sourceMappingURL=initInfra.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initInfra.cjs","names":["spawn","loadPrompts","mkdtemp","join","tmpdir","writeFile","rm"],"sources":["../../src/initInfra.ts"],"sourcesContent":["import { spawn } from 'node:child_process';\nimport { mkdtemp, rm, writeFile } from 'node:fs/promises';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport { loadPrompts } from './loadPrompts';\n\n/** Setup modes understood by the hosted installer. */\nexport const INFRA_MODES = ['desktop', 'docker', 'compose'] as const;\n\nexport type InfraMode = (typeof INFRA_MODES)[number];\n\n/**\n * The hosted installers are the single source of truth for the infrastructure\n * setup flow (desktop app, all-in-one container, Compose stack). The CLI runs\n * them rather than re-implementing the same steps in JavaScript.\n */\nexport const INSTALL_SCRIPT_URL = 'https://intlayer.org/install.sh';\nexport const INSTALL_SCRIPT_URL_WINDOWS = 'https://intlayer.org/install.ps1';\n\nexport type InitInfraOptions = {\n /** Skip the interactive menu and run this mode directly. */\n mode?: InfraMode;\n /** Installer URL override (forks, staging). Defaults to the platform's script. */\n scriptUrl?: string;\n};\n\n/** How to fetch and execute the installer on the current platform. */\ntype InstallerRunner = {\n url: string;\n fileName: string;\n /** Builds the command and arguments that execute the downloaded script. */\n command: (scriptPath: string, mode?: InfraMode) => [string, string[]];\n};\n\nconst POSIX_RUNNER: InstallerRunner = {\n url: INSTALL_SCRIPT_URL,\n fileName: 'install.sh',\n command: (scriptPath, mode) => [\n 'sh',\n [scriptPath, ...(mode ? ['--mode', mode] : [])],\n ],\n};\n\nconst WINDOWS_RUNNER: InstallerRunner = {\n url: INSTALL_SCRIPT_URL_WINDOWS,\n fileName: 'install.ps1',\n command: (scriptPath, mode) => [\n 'powershell',\n [\n '-NoProfile',\n '-ExecutionPolicy',\n 'Bypass',\n '-File',\n scriptPath,\n ...(mode ? ['-Mode', mode] : []),\n ],\n ],\n};\n\nconst getInstallerRunner = (): InstallerRunner =>\n process.platform === 'win32' ? WINDOWS_RUNNER : POSIX_RUNNER;\n\n/**\n * Validates a user-provided mode against {@link INFRA_MODES}.\n *\n * @throws When the value is not a known mode.\n */\nexport const parseInfraMode = (value: string): InfraMode => {\n if ((INFRA_MODES as readonly string[]).includes(value)) {\n return value as InfraMode;\n }\n\n throw new Error(\n `Unknown infra mode \"${value}\". Expected one of: ${INFRA_MODES.join(', ')}`\n );\n};\n\n/**\n * Runs the installer with the terminal attached, so its own prompts and\n * progress bars reach the user unchanged.\n *\n * @returns The script's exit code.\n */\nconst runInstaller = (command: string, args: string[]): Promise<number> =>\n new Promise((resolve, reject) => {\n const child = spawn(command, args, { stdio: 'inherit' });\n\n child.on('error', reject);\n child.on('close', (code) => resolve(code ?? 1));\n });\n\n/**\n * Downloads the hosted installer and runs it: desktop app, all-in-one Docker\n * container or Docker Compose stack, chosen interactively unless `mode` is set.\n *\n * Exposed as `intlayer init infra` and as a step of `intlayer init --interactive`.\n */\nexport const initInfra = async (\n options: InitInfraOptions = {}\n): Promise<void> => {\n const p = await loadPrompts();\n const runner = getInstallerRunner();\n const scriptUrl = options.scriptUrl ?? runner.url;\n\n const spinner = p.spinner();\n spinner.start(`Fetching ${scriptUrl}`);\n\n let script: string;\n\n try {\n const response = await fetch(scriptUrl);\n\n if (!response.ok) {\n throw new Error(`${response.status} ${response.statusText}`);\n }\n\n script = await response.text();\n } catch (error) {\n spinner.stop('Could not download the installer', 1);\n p.log.error(\n `${(error as Error).message}\\nRun it directly: ${\n process.platform === 'win32'\n ? `irm ${scriptUrl} | iex`\n : `curl -fsSL ${scriptUrl} | sh`\n }`\n );\n process.exitCode = 1;\n return;\n }\n\n spinner.stop('Installer downloaded');\n\n const directory = await mkdtemp(join(tmpdir(), 'intlayer-install-'));\n const scriptPath = join(directory, runner.fileName);\n\n try {\n await writeFile(scriptPath, script, { mode: 0o700 });\n\n const [command, args] = runner.command(scriptPath, options.mode);\n const exitCode = await runInstaller(command, args);\n\n if (exitCode !== 0) {\n process.exitCode = exitCode;\n }\n } finally {\n await rm(directory, { recursive: true, force: true });\n }\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,cAAc;CAAC;CAAW;CAAU;AAAS;;;;;;AAS1D,MAAa,qBAAqB;AAClC,MAAa,6BAA6B;AAiB1C,MAAM,eAAgC;CACpC,KAAK;CACL,UAAU;CACV,UAAU,YAAY,SAAS,CAC7B,MACA,CAAC,YAAY,GAAI,OAAO,CAAC,UAAU,IAAI,IAAI,CAAC,CAAE,CAChD;AACF;AAEA,MAAM,iBAAkC;CACtC,KAAK;CACL,UAAU;CACV,UAAU,YAAY,SAAS,CAC7B,cACA;EACE;EACA;EACA;EACA;EACA;EACA,GAAI,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;CAChC,CACF;AACF;AAEA,MAAM,2BACJ,QAAQ,aAAa,UAAU,iBAAiB;;;;;;AAOlD,MAAa,kBAAkB,UAA6B;CAC1D,IAAK,YAAkC,SAAS,KAAK,GACnD,OAAO;CAGT,MAAM,IAAI,MACR,uBAAuB,MAAM,sBAAsB,YAAY,KAAK,IAAI,GAC1E;AACF;;;;;;;AAQA,MAAM,gBAAgB,SAAiB,SACrC,IAAI,SAAS,SAAS,WAAW;CAC/B,MAAM,YAAQA,0BAAM,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_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  const require_loadPrompts = require('./loadPrompts.cjs');
4
3
  const require_initSkills = require('./initSkills.cjs');
5
4
  const require_init = require('./init.cjs');
6
5
  let node_path = require("node:path");
7
6
  let _intlayer_engine_cli = require("@intlayer/engine/cli");
8
- let enquirer = require("enquirer");
9
- enquirer = require_runtime.__toESM(enquirer);
10
7
 
11
8
  //#region src/initMCP.ts
12
9
  const initMCP = async (projectRoot, preselectedPlatform) => {
13
10
  const p = await require_loadPrompts.loadPrompts();
14
11
  const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
15
12
  p.intro("Initializing Intlayer MCP Server");
16
- let platform;
17
- if (preselectedPlatform) platform = preselectedPlatform;
18
- else {
19
- const detectedPlatform = require_initSkills.getDetectedPlatform();
20
- try {
21
- platform = (await enquirer.default.prompt({
22
- type: "autocomplete",
23
- name: "platforms",
24
- message: "Which platform are you using? (Type to search)",
25
- multiple: false,
26
- initial: detectedPlatform ? _intlayer_engine_cli.PLATFORMS.indexOf(detectedPlatform) : void 0,
27
- choices: require_initSkills.PLATFORM_OPTIONS.map((opt) => ({
28
- name: opt.value,
29
- message: opt.label,
30
- hint: opt.hint
31
- }))
32
- })).platforms;
33
- } catch {
34
- p.cancel("Operation cancelled.");
35
- return;
36
- }
37
- }
13
+ const platform = preselectedPlatform ?? await require_initSkills.promptPlatform();
38
14
  if (!platform) {
39
15
  p.cancel("Operation cancelled. No platform selected.");
40
16
  return;
@@ -1 +1 @@
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,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,MAAM,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,IAAI,EAAE,SAAS,SAAS,KAAK,CAAC,WAAW;EACvC,EAAE,OAAO,sBAAsB;EAC/B;CACF;CAEA,MAAM,IAAI,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","promptPlatform","installMCP"],"sources":["../../src/initMCP.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport {\n installMCP,\n type MCPTransport,\n type Platform,\n} from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\nimport { promptPlatform } 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 const platform = preselectedPlatform ?? (await promptPlatform());\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":";;;;;;;;AAUA,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,MAAM,WAAW,uBAAwB,MAAMC,kCAAe;CAE9D,IAAI,CAAC,UAAU;EACb,EAAE,OAAO,4CAA4C;EACrD;CACF;CAEA,MAAM,YAAa,MAAM,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,IAAI,EAAE,SAAS,SAAS,KAAK,CAAC,WAAW;EACvC,EAAE,OAAO,sBAAsB;EAC/B;CACF;CAEA,MAAM,IAAI,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"}
@@ -32,36 +32,38 @@ const getDependencies = (root) => {
32
32
  return {};
33
33
  }
34
34
  };
35
+ /**
36
+ * Asks which AI platform the user is using, preselecting the detected one.
37
+ * Resolves to `undefined` when the prompt is cancelled.
38
+ */
39
+ const promptPlatform = async () => {
40
+ const detectedPlatform = getDetectedPlatform();
41
+ try {
42
+ return (await enquirer.default.prompt({
43
+ type: "autocomplete",
44
+ name: "platform",
45
+ message: "Which platform are you using? (Type to search)",
46
+ multiple: false,
47
+ initial: detectedPlatform ? _intlayer_engine_cli.PLATFORMS.indexOf(detectedPlatform) : void 0,
48
+ choices: PLATFORM_OPTIONS.map((option) => ({
49
+ name: option.value,
50
+ message: option.label,
51
+ hint: option.hint
52
+ }))
53
+ })).platform;
54
+ } catch {
55
+ return;
56
+ }
57
+ };
58
+ /**
59
+ * Installs the Intlayer documentation skills. The skills are picked first, then
60
+ * the platform (unless preselected). Resolves to the platform used, so a
61
+ * following step (e.g. MCP) can reuse it without asking again.
62
+ */
35
63
  const initSkills = async (projectRoot, preselectedPlatform) => {
36
64
  const p = await require_loadPrompts.loadPrompts();
37
65
  const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
38
66
  p.intro("Initializing Intlayer skills");
39
- let platform;
40
- if (preselectedPlatform) platform = preselectedPlatform;
41
- else {
42
- const detectedPlatform = getDetectedPlatform();
43
- try {
44
- platform = (await enquirer.default.prompt({
45
- type: "autocomplete",
46
- name: "platforms",
47
- message: "Which platforms are you using? (Type to search)",
48
- multiple: false,
49
- initial: detectedPlatform ? _intlayer_engine_cli.PLATFORMS.indexOf(detectedPlatform) : void 0,
50
- choices: PLATFORM_OPTIONS.map((opt) => ({
51
- name: opt.value,
52
- message: opt.label,
53
- hint: opt.hint
54
- }))
55
- })).platforms;
56
- } catch {
57
- p.cancel("Operation cancelled.");
58
- return;
59
- }
60
- }
61
- if (!platform) {
62
- p.log.warn("No platform selected. Nothing to install.");
63
- return;
64
- }
65
67
  const dependencies = getDependencies(root);
66
68
  const initialValues = (0, _intlayer_engine_cli.getInitialSkills)(dependencies);
67
69
  const selectedSkills = await p.multiselect({
@@ -78,6 +80,11 @@ const initSkills = async (projectRoot, preselectedPlatform) => {
78
80
  p.cancel("Operation cancelled. No skills selected.");
79
81
  return;
80
82
  }
83
+ const platform = preselectedPlatform ?? await promptPlatform();
84
+ if (!platform) {
85
+ p.cancel("Operation cancelled. No platform selected.");
86
+ return;
87
+ }
81
88
  const s = p.spinner();
82
89
  s.start("Installing skills...");
83
90
  try {
@@ -89,10 +96,12 @@ const initSkills = async (projectRoot, preselectedPlatform) => {
89
96
  p.log.error(error instanceof Error ? error.message : String(error));
90
97
  }
91
98
  p.outro("Intlayer skills initialization complete");
99
+ return platform;
92
100
  };
93
101
 
94
102
  //#endregion
95
103
  exports.PLATFORM_OPTIONS = PLATFORM_OPTIONS;
96
104
  exports.getDetectedPlatform = getDetectedPlatform;
97
105
  exports.initSkills = initSkills;
106
+ exports.promptPlatform = promptPlatform;
98
107
  //# sourceMappingURL=initSkills.cjs.map