@intlayer/cli 9.5.7 → 9.5.9-canary.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 (105) hide show
  1. package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
  2. package/dist/cjs/auth/login.cjs +24 -16
  3. package/dist/cjs/auth/login.cjs.map +1 -1
  4. package/dist/cjs/build.cjs +1 -1
  5. package/dist/cjs/ci.cjs +1 -1
  6. package/dist/cjs/cli.cjs +18 -7
  7. package/dist/cjs/cli.cjs.map +1 -1
  8. package/dist/cjs/config.cjs +1 -1
  9. package/dist/cjs/editor.cjs +1 -1
  10. package/dist/cjs/extract.cjs +5 -5
  11. package/dist/cjs/fill/fill.cjs +2 -2
  12. package/dist/cjs/fill/formatAutoFilledFilePath.cjs +1 -1
  13. package/dist/cjs/fill/listTranslationsTasks.cjs +1 -1
  14. package/dist/cjs/fill/translateDictionary.cjs +1 -1
  15. package/dist/cjs/fill/writeFill.cjs +1 -1
  16. package/dist/cjs/getTargetDictionary.cjs +1 -1
  17. package/dist/cjs/index.cjs +8 -7
  18. package/dist/cjs/init.cjs +65 -147
  19. package/dist/cjs/init.cjs.map +1 -1
  20. package/dist/cjs/initMCP.cjs +1 -25
  21. package/dist/cjs/initMCP.cjs.map +1 -1
  22. package/dist/cjs/initSkills.cjs +36 -27
  23. package/dist/cjs/initSkills.cjs.map +1 -1
  24. package/dist/cjs/listContentDeclaration.cjs +2 -2
  25. package/dist/cjs/liveSync.cjs +4 -4
  26. package/dist/cjs/pull.cjs +4 -4
  27. package/dist/cjs/push/push.cjs +5 -5
  28. package/dist/cjs/pushConfig.cjs +1 -1
  29. package/dist/cjs/reviewDoc/reviewDoc.cjs +3 -3
  30. package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +3 -3
  31. package/dist/cjs/reviewDoc/reviewDocLog.cjs +1 -1
  32. package/dist/cjs/searchDoc.cjs +1 -1
  33. package/dist/cjs/test/listMissingTranslations.cjs +1 -1
  34. package/dist/cjs/test/test.cjs +1 -1
  35. package/dist/cjs/translateDoc/translateDoc.cjs +2 -2
  36. package/dist/cjs/translateDoc/translateFile.cjs +2 -2
  37. package/dist/cjs/upgrade.cjs +18 -0
  38. package/dist/cjs/upgrade.cjs.map +1 -0
  39. package/dist/cjs/utils/getOutputFilePath.cjs +1 -1
  40. package/dist/cjs/utils/getParentPackageJSON.cjs +1 -1
  41. package/dist/cjs/watch.cjs +1 -1
  42. package/dist/esm/_virtual/_utils_asset.mjs +1 -1
  43. package/dist/esm/auth/login.mjs +23 -15
  44. package/dist/esm/auth/login.mjs.map +1 -1
  45. package/dist/esm/build.mjs +1 -1
  46. package/dist/esm/ci.mjs +1 -1
  47. package/dist/esm/cli.mjs +19 -8
  48. package/dist/esm/cli.mjs.map +1 -1
  49. package/dist/esm/config.mjs +1 -1
  50. package/dist/esm/editor.mjs +1 -1
  51. package/dist/esm/extract.mjs +6 -6
  52. package/dist/esm/extract.mjs.map +1 -1
  53. package/dist/esm/fill/fill.mjs +4 -4
  54. package/dist/esm/fill/fill.mjs.map +1 -1
  55. package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -1
  56. package/dist/esm/fill/listTranslationsTasks.mjs +1 -1
  57. package/dist/esm/fill/translateDictionary.mjs +1 -1
  58. package/dist/esm/fill/writeFill.mjs +1 -1
  59. package/dist/esm/getTargetDictionary.mjs +1 -1
  60. package/dist/esm/index.mjs +9 -9
  61. package/dist/esm/init.mjs +67 -147
  62. package/dist/esm/init.mjs.map +1 -1
  63. package/dist/esm/initMCP.mjs +3 -25
  64. package/dist/esm/initMCP.mjs.map +1 -1
  65. package/dist/esm/initSkills.mjs +36 -28
  66. package/dist/esm/initSkills.mjs.map +1 -1
  67. package/dist/esm/listContentDeclaration.mjs +2 -2
  68. package/dist/esm/liveSync.mjs +3 -3
  69. package/dist/esm/pull.mjs +4 -4
  70. package/dist/esm/push/push.mjs +7 -7
  71. package/dist/esm/push/push.mjs.map +1 -1
  72. package/dist/esm/pushConfig.mjs +1 -1
  73. package/dist/esm/reviewDoc/reviewDoc.mjs +3 -3
  74. package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +3 -3
  75. package/dist/esm/reviewDoc/reviewDocLog.mjs +1 -1
  76. package/dist/esm/searchDoc.mjs +1 -1
  77. package/dist/esm/test/listMissingTranslations.mjs +1 -1
  78. package/dist/esm/test/test.mjs +1 -1
  79. package/dist/esm/translateDoc/translateDoc.mjs +2 -2
  80. package/dist/esm/translateDoc/translateFile.mjs +2 -2
  81. package/dist/esm/upgrade.mjs +17 -0
  82. package/dist/esm/upgrade.mjs.map +1 -0
  83. package/dist/esm/utils/getOutputFilePath.mjs +1 -1
  84. package/dist/esm/utils/getParentPackageJSON.mjs +1 -1
  85. package/dist/esm/watch.mjs +1 -1
  86. package/dist/types/index.d.ts +2 -2
  87. package/dist/types/init.d.ts.map +1 -1
  88. package/dist/types/initMCP.d.ts.map +1 -1
  89. package/dist/types/initSkills.d.ts +11 -1
  90. package/dist/types/initSkills.d.ts.map +1 -1
  91. package/dist/types/upgrade.d.ts +9 -0
  92. package/dist/types/upgrade.d.ts.map +1 -0
  93. package/package.json +10 -10
  94. package/dist/cjs/initBuildOptimization.cjs +0 -80
  95. package/dist/cjs/initBuildOptimization.cjs.map +0 -1
  96. package/dist/cjs/initCompiler.cjs +0 -77
  97. package/dist/cjs/initCompiler.cjs.map +0 -1
  98. package/dist/esm/initBuildOptimization.mjs +0 -79
  99. package/dist/esm/initBuildOptimization.mjs.map +0 -1
  100. package/dist/esm/initCompiler.mjs +0 -76
  101. package/dist/esm/initCompiler.mjs.map +0 -1
  102. package/dist/types/initBuildOptimization.d.ts +0 -19
  103. package/dist/types/initBuildOptimization.d.ts.map +0 -1
  104. package/dist/types/initCompiler.d.ts +0 -20
  105. package/dist/types/initCompiler.d.ts.map +0 -1
package/dist/esm/init.mjs CHANGED
@@ -1,14 +1,11 @@
1
1
  import { login } from "./auth/login.mjs";
2
2
  import { loadPrompts } from "./loadPrompts.mjs";
3
- import { initBuildOptimization } from "./initBuildOptimization.mjs";
4
- import { initCompiler } from "./initCompiler.mjs";
5
3
  import { initInfra } from "./initInfra.mjs";
6
- import { PLATFORM_OPTIONS, getDetectedPlatform, initSkills } from "./initSkills.mjs";
4
+ import { initSkills } from "./initSkills.mjs";
7
5
  import { initMCP } from "./initMCP.mjs";
8
- import { join, resolve } from "node:path";
9
- import { PLATFORMS, detectCompatI18nLibraries, initIntlayer, setupCmsCredentials } from "@intlayer/engine/cli";
10
- import enquirer from "enquirer";
11
6
  import { existsSync, readFileSync } from "node:fs";
7
+ import { join, resolve } from "node:path";
8
+ import { detectCompatI18nLibraries, initIntlayer, setupCmsCredentials } from "@intlayer/engine/cli";
12
9
 
13
10
  //#region src/init.ts
14
11
  const findProjectRoot = (startDir) => {
@@ -19,58 +16,67 @@ const findProjectRoot = (startDir) => {
19
16
  }
20
17
  return startDir;
21
18
  };
22
- const BASE_INIT_STEP_OPTIONS = [
23
- {
24
- value: "packages",
25
- label: "Install & upgrade packages",
26
- hint: "install missing Intlayer dependencies and upgrade outdated ones"
27
- },
28
- {
29
- value: "githubActions",
30
- label: "CI/CD (GitHub Actions)",
31
- hint: "scaffold the fill and test workflows that run on every pull request (covers every project in a monorepo)"
32
- },
33
- {
34
- value: "frameworkSetup",
35
- label: "Framework setup",
36
- hint: "middleware/proxy and providers in layout/page"
37
- },
38
- {
19
+ /**
20
+ * Steps shown but not pre-selected. The infrastructure installer touches the
21
+ * machine (downloads an app, pulls Docker images) rather than the project, so
22
+ * it must be an explicit choice.
23
+ */
24
+ const OPT_IN_INIT_STEPS = ["infra"];
25
+ /** Grouped checkbox entries of the interactive init flow, in display order. */
26
+ const INIT_STEP_GROUPS = {
27
+ Codebase: [
28
+ {
29
+ value: "packages",
30
+ label: "Install & upgrade packages",
31
+ hint: "install missing Intlayer dependencies and upgrade outdated ones"
32
+ },
33
+ {
34
+ value: "projectSetup",
35
+ label: "Project setup",
36
+ hint: "intlayer config, tsconfig, bundler plugin, middleware/proxy and providers in layout/page"
37
+ },
38
+ {
39
+ value: "githubActions",
40
+ label: "CI/CD (GitHub Actions)",
41
+ hint: "scaffold the fill and test workflows that run on every pull request (covers every project in a monorepo)"
42
+ }
43
+ ],
44
+ DevTools: [{
39
45
  value: "vscodeExtension",
40
46
  label: "VS Code extension",
41
47
  hint: "recommend the Intlayer extension"
42
- },
43
- {
44
- value: "lsp",
45
- label: "Editor LSP",
46
- hint: "go-to-definition from keys to .content files"
47
- },
48
- {
48
+ }, {
49
49
  value: "eslint",
50
50
  label: "Lint rules (ESLint / oxlint)",
51
51
  hint: "flag hardcoded text and dynamic calls the compiler cannot optimize"
52
- },
53
- {
54
- value: "skills",
55
- label: "AI skills",
56
- hint: "install the Intlayer documentation as agent skills"
57
- },
58
- {
59
- value: "mcp",
60
- label: "MCP server",
61
- hint: "configure the Intlayer MCP server"
62
- }
63
- ];
64
- /**
65
- * Steps that are opt-in: offered in the checkbox but not pre-selected. The
66
- * infrastructure installer touches the machine (downloads an app, pulls
67
- * Docker images) rather than the project, so it must be an explicit choice.
68
- */
69
- const OPT_IN_INIT_STEP_OPTIONS = [{
70
- value: "infra",
71
- label: "Infrastructure (desktop app / self-hosting)",
72
- hint: "install the desktop app, or self-host with Docker (all-in-one or Compose)"
73
- }];
52
+ }],
53
+ "Coding assistant": [
54
+ {
55
+ value: "skills",
56
+ label: "AI skills",
57
+ hint: "install the Intlayer documentation as agent skills"
58
+ },
59
+ {
60
+ value: "mcp",
61
+ label: "MCP server",
62
+ hint: "configure the Intlayer MCP server"
63
+ },
64
+ {
65
+ value: "lsp",
66
+ label: "Editor LSP",
67
+ hint: "go-to-definition from keys to .content files"
68
+ }
69
+ ],
70
+ CMS: [{
71
+ value: "cms",
72
+ label: "CMS",
73
+ hint: "log in through your browser, then store the credentials in your .env"
74
+ }, {
75
+ value: "infra",
76
+ label: "Infrastructure (desktop app / self-hosting)",
77
+ hint: "install the desktop app, or self-host with Docker (all-in-one or Compose)"
78
+ }]
79
+ };
74
80
  /** Locale routing strategies offered by the interactive init flow. */
75
81
  const ROUTING_MODE_OPTIONS = [
76
82
  {
@@ -94,28 +100,6 @@ const ROUTING_MODE_OPTIONS = [
94
100
  hint: "/about?locale=fr"
95
101
  }
96
102
  ];
97
- /**
98
- * Content organization strategies offered by the interactive init flow.
99
- * Drives the `compiler.output` template (autogenerated content: compiler /
100
- * autofill / extract) or the injection of the syncJSON plugin.
101
- */
102
- const CONTENT_STRATEGY_OPTIONS = [
103
- {
104
- value: "per-component",
105
- label: "Per component (default)",
106
- hint: "multilingual .content files co-located with the components"
107
- },
108
- {
109
- value: "centralized",
110
- label: "Centralized folder",
111
- hint: "per-locale JSON dictionaries under /locales/{locale}/{key}.content.json"
112
- },
113
- {
114
- value: "json-namespaces",
115
- label: "JSON namespaces",
116
- hint: "plain /locales/{locale}/{namespace}.json files synced via @intlayer/sync-json-plugin"
117
- }
118
- ];
119
103
  /** Reads the merged dependencies of the project at `root`. */
120
104
  const getProjectDependencies = (root) => {
121
105
  try {
@@ -130,10 +114,6 @@ const getProjectDependencies = (root) => {
130
114
  return {};
131
115
  }
132
116
  };
133
- /** Returns true when the project at `root` depends on Next.js. */
134
- const isNextJsProject = (root) => Boolean(getProjectDependencies(root).next);
135
- /** Returns true when the project at `root` depends on Vite. */
136
- const isViteProject = (root) => Boolean(getProjectDependencies(root).vite);
137
117
  /**
138
118
  * Returns true when the project uses a URL-based router for which a locale
139
119
  * routing strategy is meaningful: Next.js, React Router, or TanStack Router.
@@ -155,23 +135,10 @@ const hasUrlRouting = (root) => {
155
135
  const runInteractiveInit = async (root, baseOptions) => {
156
136
  const p = await loadPrompts();
157
137
  p.intro("Initialize Intlayer");
158
- const stepOptions = [...BASE_INIT_STEP_OPTIONS];
159
- const nextJsProject = isNextJsProject(root);
160
- if (nextJsProject || isViteProject(root)) stepOptions.push({
161
- value: "compiler",
162
- label: "Compiler",
163
- 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)"
164
- });
165
- if (nextJsProject) stepOptions.push({
166
- value: "buildOptimization",
167
- label: "Bundle optimization",
168
- hint: "choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)"
169
- });
170
- stepOptions.push(...OPT_IN_INIT_STEP_OPTIONS);
171
- const selected = await p.multiselect({
138
+ const selected = await p.groupMultiselect({
172
139
  message: "Select what you want to set up:",
173
- options: stepOptions,
174
- initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),
140
+ options: INIT_STEP_GROUPS,
141
+ initialValues: Object.values(INIT_STEP_GROUPS).flat().map((option) => option.value).filter((step) => !OPT_IN_INIT_STEPS.includes(step)),
175
142
  required: false
176
143
  });
177
144
  if (p.isCancel(selected)) {
@@ -180,7 +147,7 @@ const runInteractiveInit = async (root, baseOptions) => {
180
147
  }
181
148
  const steps = selected;
182
149
  let routingMode;
183
- if (hasUrlRouting(root)) {
150
+ if (steps.includes("projectSetup") && hasUrlRouting(root)) {
184
151
  const selectedRoutingMode = await p.select({
185
152
  message: "Which locale routing strategy do you want?",
186
153
  options: ROUTING_MODE_OPTIONS,
@@ -193,70 +160,23 @@ const runInteractiveInit = async (root, baseOptions) => {
193
160
  routingMode = selectedRoutingMode;
194
161
  }
195
162
  const detectedCompatLibraries = detectCompatI18nLibraries(getProjectDependencies(root));
196
- const hasCompatLib = detectedCompatLibraries.length > 0;
197
- 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.`);
198
- let contentStrategy;
199
- if (!hasCompatLib) {
200
- const selectedContentStrategy = await p.select({
201
- message: "How do you want to organize your translated content?",
202
- options: CONTENT_STRATEGY_OPTIONS,
203
- initialValue: "per-component"
204
- });
205
- if (p.isCancel(selectedContentStrategy)) {
206
- p.cancel("Operation cancelled.");
207
- return;
208
- }
209
- contentStrategy = selectedContentStrategy;
210
- }
163
+ 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.`);
211
164
  const options = {
212
165
  ...baseOptions,
213
166
  routingMode,
214
- contentStrategy,
215
167
  noInstallPackages: !steps.includes("packages"),
216
168
  noGitignore: baseOptions?.noGitignore,
217
169
  noGithubActions: baseOptions?.noGithubActions || !steps.includes("githubActions"),
218
- noFrameworkSetup: baseOptions?.noFrameworkSetup || !steps.includes("frameworkSetup"),
170
+ noFrameworkSetup: baseOptions?.noFrameworkSetup || !steps.includes("projectSetup"),
219
171
  noVscodeExtension: !steps.includes("vscodeExtension"),
220
172
  noLsp: !steps.includes("lsp"),
221
173
  noEslint: !steps.includes("eslint")
222
174
  };
223
175
  await initIntlayer(root, options);
224
- const needsPlatform = steps.includes("skills") || steps.includes("mcp");
225
- let sharedPlatform;
226
- if (needsPlatform) {
227
- const detectedPlatform = getDetectedPlatform();
228
- try {
229
- sharedPlatform = (await enquirer.prompt({
230
- type: "autocomplete",
231
- name: "platforms",
232
- message: "Which platform are you using? (Type to search)",
233
- multiple: false,
234
- initial: detectedPlatform ? PLATFORMS.indexOf(detectedPlatform) : void 0,
235
- choices: PLATFORM_OPTIONS.map((opt) => ({
236
- name: opt.value,
237
- message: opt.label,
238
- hint: opt.hint
239
- }))
240
- })).platforms;
241
- } catch {
242
- p.cancel("Operation cancelled.");
243
- return;
244
- }
245
- }
246
- if (steps.includes("skills")) await initSkills(root, sharedPlatform);
247
- if (steps.includes("mcp")) await initMCP(root, sharedPlatform);
248
- if (steps.includes("compiler")) await initCompiler(root);
249
- if (steps.includes("buildOptimization")) await initBuildOptimization(root);
176
+ const skillsPlatform = steps.includes("skills") ? await initSkills(root) : void 0;
177
+ if (steps.includes("mcp")) await initMCP(root, skillsPlatform);
250
178
  if (steps.includes("infra")) await initInfra();
251
- const shouldSetUpCms = await p.confirm({
252
- message: "Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)",
253
- initialValue: false
254
- });
255
- if (p.isCancel(shouldSetUpCms)) {
256
- p.cancel("Operation cancelled.");
257
- return;
258
- }
259
- if (shouldSetUpCms) {
179
+ if (steps.includes("cms")) {
260
180
  p.log.info("Opening your browser to log in to the Intlayer CMS...");
261
181
  await login({
262
182
  exitAfter: false,
@@ -1 +1 @@
1
- {"version":3,"file":"init.mjs","names":[],"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 { initInfra } from './initInfra';\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 | 'infra';\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/**\n * Steps that are opt-in: offered in the checkbox but not pre-selected. The\n * infrastructure installer touches the machine (downloads an app, pulls\n * Docker images) rather than the project, so it must be an explicit choice.\n */\nconst OPT_IN_INIT_STEP_OPTIONS: Array<{\n value: InitStep;\n label: string;\n hint: string;\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/** 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 stepOptions.push(...OPT_IN_INIT_STEP_OPTIONS);\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 // 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 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":";;;;;;;;;;;;;AAyBA,MAAa,mBAAmB,aAAqB;CACnD,IAAI,aAAa;CAEjB,OAAO,eAAe,QAAQ,YAAY,IAAI,GAAG;EAC/C,IAAI,WAAW,KAAK,YAAY,cAAc,CAAC,GAC7C,OAAO;EAET,aAAa,QAAQ,YAAY,IAAI;CACvC;CAIA,OAAO;AACT;AAgBA,MAAM,yBAID;CACH;EACE,OAAO;E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AAS,OAAO,GACxB,MAAM,UAAU;CAMlB,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,MAAM,MAAM;GACV,WAAW;GACX,gBAAgB,gBAAgB,oBAAoB,MAAM,WAAW;EACvE,CAAC;CACH;CAEA,EAAE,MAAM,kCAAkC;AAC5C;AAEA,MAAa,OAAO,OAClB,aACA,SACA,gBACG;CACH,MAAM,OAAO,cACT,gBAAgB,QAAQ,WAAW,CAAC,IACpC,gBAAgB,QAAQ,IAAI,CAAC;CAEjC,IAAI,aAAa;EACf,MAAM,mBAAmB,MAAM,OAAO;EACtC;CACF;CAEA,MAAM,aAAa,MAAM,OAAO;AAClC"}
1
+ {"version":3,"file":"init.mjs","names":[],"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,eAAe,QAAQ,YAAY,IAAI,GAAG;EAC/C,IAAI,WAAW,KAAK,YAAY,cAAc,CAAC,GAC7C,OAAO;EAET,aAAa,QAAQ,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,OAAO;EACP,OAAO;EACP,MAAM;CACR,GACA;EACE,OAAO;EACP,OAAO;EACP,MAAM;CACR,CACF;CACA,oBAAoB;EAClB;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR;EACA;GACE,OAAO;GACP,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AAO,OAClB,aACA,SACA,gBACG;CACH,MAAM,OAAO,cACT,gBAAgB,QAAQ,WAAW,CAAC,IACpC,gBAAgB,QAAQ,IAAI,CAAC;CAEjC,IAAI,aAAa;EACf,MAAM,mBAAmB,MAAM,OAAO;EACtC;CACF;CAEA,MAAM,aAAa,MAAM,OAAO;AAClC"}
@@ -1,37 +1,15 @@
1
1
  import { loadPrompts } from "./loadPrompts.mjs";
2
- import { PLATFORM_OPTIONS, getDetectedPlatform } from "./initSkills.mjs";
2
+ import { promptPlatform } from "./initSkills.mjs";
3
3
  import { findProjectRoot } from "./init.mjs";
4
4
  import { resolve } from "node:path";
5
- import { PLATFORMS, installMCP } from "@intlayer/engine/cli";
6
- import enquirer from "enquirer";
5
+ import { installMCP } from "@intlayer/engine/cli";
7
6
 
8
7
  //#region src/initMCP.ts
9
8
  const initMCP = async (projectRoot, preselectedPlatform) => {
10
9
  const p = await loadPrompts();
11
10
  const root = findProjectRoot(projectRoot ? resolve(projectRoot) : process.cwd());
12
11
  p.intro("Initializing Intlayer MCP Server");
13
- let platform;
14
- if (preselectedPlatform) platform = preselectedPlatform;
15
- else {
16
- const detectedPlatform = getDetectedPlatform();
17
- try {
18
- platform = (await enquirer.prompt({
19
- type: "autocomplete",
20
- name: "platforms",
21
- message: "Which platform are you using? (Type to search)",
22
- multiple: false,
23
- initial: detectedPlatform ? PLATFORMS.indexOf(detectedPlatform) : void 0,
24
- choices: PLATFORM_OPTIONS.map((opt) => ({
25
- name: opt.value,
26
- message: opt.label,
27
- hint: opt.hint
28
- }))
29
- })).platforms;
30
- } catch {
31
- p.cancel("Operation cancelled.");
32
- return;
33
- }
34
- }
12
+ const platform = preselectedPlatform ?? await promptPlatform();
35
13
  if (!platform) {
36
14
  p.cancel("Operation cancelled. No platform selected.");
37
15
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"initMCP.mjs","names":[],"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,MAAM,YAAY;CAE5B,MAAM,OAAO,gBACX,cAAc,QAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,EAAE,MAAM,kCAAkC;CAE1C,IAAI;CAEJ,IAAI,qBACF,WAAW;MACN;EACL,MAAM,mBAAmB,oBAAoB;EAE7C,IAAI;GAeF,YAAW,MAdY,SAAS,OAAgC;IAC9D,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IACV,SAAS,mBACL,UAAU,QAAQ,gBAAgB,IAClC;IACJ,SAAS,iBAAiB,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,MAAM,WAAW,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.mjs","names":[],"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,MAAM,YAAY;CAE5B,MAAM,OAAO,gBACX,cAAc,QAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,EAAE,MAAM,kCAAkC;CAE1C,MAAM,WAAW,uBAAwB,MAAM,eAAe;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,MAAM,WAAW,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,9 +1,9 @@
1
1
  import { loadPrompts } from "./loadPrompts.mjs";
2
2
  import { findProjectRoot } from "./init.mjs";
3
+ import { existsSync, readFileSync } from "node:fs";
3
4
  import { join, resolve } from "node:path";
4
5
  import { PLATFORMS, PLATFORMS_METADATA, SKILLS, SKILLS_METADATA, getInitialSkills, installSkills } from "@intlayer/engine/cli";
5
6
  import enquirer from "enquirer";
6
- import { existsSync, readFileSync } from "node:fs";
7
7
 
8
8
  //#region src/initSkills.ts
9
9
  const PLATFORM_CHECKS = PLATFORMS.filter((platform) => PLATFORMS_METADATA[platform]?.check).map((platform) => ({
@@ -29,36 +29,38 @@ const getDependencies = (root) => {
29
29
  return {};
30
30
  }
31
31
  };
32
+ /**
33
+ * Asks which AI platform the user is using, preselecting the detected one.
34
+ * Resolves to `undefined` when the prompt is cancelled.
35
+ */
36
+ const promptPlatform = async () => {
37
+ const detectedPlatform = getDetectedPlatform();
38
+ try {
39
+ return (await enquirer.prompt({
40
+ type: "autocomplete",
41
+ name: "platform",
42
+ message: "Which platform are you using? (Type to search)",
43
+ multiple: false,
44
+ initial: detectedPlatform ? PLATFORMS.indexOf(detectedPlatform) : void 0,
45
+ choices: PLATFORM_OPTIONS.map((option) => ({
46
+ name: option.value,
47
+ message: option.label,
48
+ hint: option.hint
49
+ }))
50
+ })).platform;
51
+ } catch {
52
+ return;
53
+ }
54
+ };
55
+ /**
56
+ * Installs the Intlayer documentation skills. The skills are picked first, then
57
+ * the platform (unless preselected). Resolves to the platform used, so a
58
+ * following step (e.g. MCP) can reuse it without asking again.
59
+ */
32
60
  const initSkills = async (projectRoot, preselectedPlatform) => {
33
61
  const p = await loadPrompts();
34
62
  const root = findProjectRoot(projectRoot ? resolve(projectRoot) : process.cwd());
35
63
  p.intro("Initializing Intlayer skills");
36
- let platform;
37
- if (preselectedPlatform) platform = preselectedPlatform;
38
- else {
39
- const detectedPlatform = getDetectedPlatform();
40
- try {
41
- platform = (await enquirer.prompt({
42
- type: "autocomplete",
43
- name: "platforms",
44
- message: "Which platforms are you using? (Type to search)",
45
- multiple: false,
46
- initial: detectedPlatform ? PLATFORMS.indexOf(detectedPlatform) : void 0,
47
- choices: PLATFORM_OPTIONS.map((opt) => ({
48
- name: opt.value,
49
- message: opt.label,
50
- hint: opt.hint
51
- }))
52
- })).platforms;
53
- } catch {
54
- p.cancel("Operation cancelled.");
55
- return;
56
- }
57
- }
58
- if (!platform) {
59
- p.log.warn("No platform selected. Nothing to install.");
60
- return;
61
- }
62
64
  const dependencies = getDependencies(root);
63
65
  const initialValues = getInitialSkills(dependencies);
64
66
  const selectedSkills = await p.multiselect({
@@ -75,6 +77,11 @@ const initSkills = async (projectRoot, preselectedPlatform) => {
75
77
  p.cancel("Operation cancelled. No skills selected.");
76
78
  return;
77
79
  }
80
+ const platform = preselectedPlatform ?? await promptPlatform();
81
+ if (!platform) {
82
+ p.cancel("Operation cancelled. No platform selected.");
83
+ return;
84
+ }
78
85
  const s = p.spinner();
79
86
  s.start("Installing skills...");
80
87
  try {
@@ -86,8 +93,9 @@ const initSkills = async (projectRoot, preselectedPlatform) => {
86
93
  p.log.error(error instanceof Error ? error.message : String(error));
87
94
  }
88
95
  p.outro("Intlayer skills initialization complete");
96
+ return platform;
89
97
  };
90
98
 
91
99
  //#endregion
92
- export { PLATFORM_OPTIONS, getDetectedPlatform, initSkills };
100
+ export { PLATFORM_OPTIONS, getDetectedPlatform, initSkills, promptPlatform };
93
101
  //# sourceMappingURL=initSkills.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"initSkills.mjs","names":[],"sources":["../../src/initSkills.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n getInitialSkills,\n installSkills,\n PLATFORMS,\n PLATFORMS_METADATA,\n type Platform,\n SKILLS,\n SKILLS_METADATA,\n} from '@intlayer/engine/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { loadPrompts } from './loadPrompts';\n\nconst PLATFORM_CHECKS: Array<{ check: () => boolean; platform: Platform }> =\n PLATFORMS.filter((platform) => PLATFORMS_METADATA[platform]?.check).map(\n (platform) => ({\n check: PLATFORMS_METADATA[platform]?.check ?? (() => false),\n platform,\n })\n );\n\nexport const PLATFORM_OPTIONS: Array<{\n value: Platform;\n label: string;\n hint: string;\n}> = PLATFORMS.map((platform) => ({\n value: platform,\n label: PLATFORMS_METADATA[platform]?.label ?? '',\n hint: `(${PLATFORMS_METADATA[platform]?.dir})`,\n}));\n\nexport const getDetectedPlatform = (): Platform | undefined =>\n PLATFORM_CHECKS.find(({ check }) => check())?.platform;\n\nconst getDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\nexport const initSkills = 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 skills');\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 platforms 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.log.warn('No platform selected. Nothing to install.');\n return;\n }\n\n const dependencies = getDependencies(root);\n const initialValues = getInitialSkills(dependencies);\n\n const selectedSkills = await p.multiselect({\n message: 'Select the documentation skills to provide to your AI:',\n initialValues,\n options: SKILLS.map((skill) => ({\n value: skill,\n label: skill,\n hint: SKILLS_METADATA[skill],\n })),\n required: false,\n });\n\n if (\n p.isCancel(selectedSkills) ||\n !selectedSkills ||\n (selectedSkills as string[]).length === 0\n ) {\n p.cancel('Operation cancelled. No skills selected.');\n return;\n }\n\n const s = p.spinner();\n s.start('Installing skills...');\n\n try {\n const result = await installSkills(root, platform, selectedSkills);\n\n s.stop('Skills installed successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to install skills');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer skills initialization complete');\n};\n"],"mappings":";;;;;;;;AAeA,MAAM,kBACJ,UAAU,QAAQ,aAAa,mBAAmB,SAAS,EAAE,KAAK,CAAC,CAAC,KACjE,cAAc;CACb,OAAO,mBAAmB,SAAS,EAAE,gBAAgB;CACrD;AACF,EACF;AAEF,MAAa,mBAIR,UAAU,KAAK,cAAc;CAChC,OAAO;CACP,OAAO,mBAAmB,SAAS,EAAE,SAAS;CAC9C,MAAM,IAAI,mBAAmB,SAAS,EAAE,IAAI;AAC9C,EAAE;AAEF,MAAa,4BACX,gBAAgB,MAAM,EAAE,YAAY,MAAM,CAAC,CAAC,EAAE;AAEh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nD;CACF;CAEA,MAAM,IAAI,EAAE,QAAQ;CACpB,EAAE,MAAM,sBAAsB;CAE9B,IAAI;EACF,MAAM,SAAS,MAAM,cAAc,MAAM,UAAU,cAAc;EAEjE,EAAE,KAAK,+BAA+B;EAEtC,EAAE,KAAK,QAAQ,SAAS;CAC1B,SAAS,OAAO;EACd,EAAE,KAAK,0BAA0B;EACjC,EAAE,IAAI,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE;CAEA,EAAE,MAAM,yCAAyC;AACnD"}
1
+ {"version":3,"file":"initSkills.mjs","names":[],"sources":["../../src/initSkills.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n getInitialSkills,\n installSkills,\n PLATFORMS,\n PLATFORMS_METADATA,\n type Platform,\n SKILLS,\n SKILLS_METADATA,\n} from '@intlayer/engine/cli';\nimport enquirer from 'enquirer';\nimport { findProjectRoot } from './init';\nimport { loadPrompts } from './loadPrompts';\n\nconst PLATFORM_CHECKS: Array<{ check: () => boolean; platform: Platform }> =\n PLATFORMS.filter((platform) => PLATFORMS_METADATA[platform]?.check).map(\n (platform) => ({\n check: PLATFORMS_METADATA[platform]?.check ?? (() => false),\n platform,\n })\n );\n\nexport const PLATFORM_OPTIONS: Array<{\n value: Platform;\n label: string;\n hint: string;\n}> = PLATFORMS.map((platform) => ({\n value: platform,\n label: PLATFORMS_METADATA[platform]?.label ?? '',\n hint: `(${PLATFORMS_METADATA[platform]?.dir})`,\n}));\n\nexport const getDetectedPlatform = (): Platform | undefined =>\n PLATFORM_CHECKS.find(({ check }) => check())?.platform;\n\nconst getDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n\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 * Asks which AI platform the user is using, preselecting the detected one.\n * Resolves to `undefined` when the prompt is cancelled.\n */\nexport const promptPlatform = async (): Promise<Platform | undefined> => {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platform: Platform }>({\n type: 'autocomplete',\n name: 'platform',\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((option) => ({\n name: option.value,\n message: option.label,\n hint: option.hint,\n })),\n });\n\n return response.platform;\n } catch {\n return undefined;\n }\n};\n\n/**\n * Installs the Intlayer documentation skills. The skills are picked first, then\n * the platform (unless preselected). Resolves to the platform used, so a\n * following step (e.g. MCP) can reuse it without asking again.\n */\nexport const initSkills = async (\n projectRoot?: string,\n preselectedPlatform?: Platform\n): Promise<Platform | undefined> => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n p.intro('Initializing Intlayer skills');\n\n const dependencies = getDependencies(root);\n const initialValues = getInitialSkills(dependencies);\n\n const selectedSkills = await p.multiselect({\n message: 'Select the documentation skills to provide to your AI:',\n initialValues,\n options: SKILLS.map((skill) => ({\n value: skill,\n label: skill,\n hint: SKILLS_METADATA[skill],\n })),\n required: false,\n });\n\n if (\n p.isCancel(selectedSkills) ||\n !selectedSkills ||\n (selectedSkills as string[]).length === 0\n ) {\n p.cancel('Operation cancelled. No skills selected.');\n return;\n }\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 s = p.spinner();\n s.start('Installing skills...');\n\n try {\n const result = await installSkills(root, platform, selectedSkills);\n\n s.stop('Skills installed successfully');\n\n p.note(result, 'Success');\n } catch (error) {\n s.stop('Failed to install skills');\n p.log.error(error instanceof Error ? error.message : String(error));\n }\n\n p.outro('Intlayer skills initialization complete');\n\n return platform;\n};\n"],"mappings":";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,gBAAgB,iBAAiB,YAAY;CAEnD,MAAM,iBAAiB,MAAM,EAAE,YAAY;EACzC,SAAS;EACT;EACA,SAAS,OAAO,KAAK,WAAW;GAC9B,OAAO;GACP,OAAO;GACP,MAAM,gBAAgB;EACxB,EAAE;EACF,UAAU;CACZ,CAAC;CAED,IACE,EAAE,SAAS,cAAc,KACzB,CAAC,kBACA,eAA4B,WAAW,GACxC;EACA,EAAE,OAAO,0CAA0C;EACnD;CACF;CAEA,MAAM,WAAW,uBAAwB,MAAM,eAAe;CAE9D,IAAI,CAAC,UAAU;EACb,EAAE,OAAO,4CAA4C;EACrD;CACF;CAEA,MAAM,IAAI,EAAE,QAAQ;CACpB,EAAE,MAAM,sBAAsB;CAE9B,IAAI;EACF,MAAM,SAAS,MAAM,cAAc,MAAM,UAAU,cAAc;EAEjE,EAAE,KAAK,+BAA+B;EAEtC,EAAE,KAAK,QAAQ,SAAS;CAC1B,SAAS,OAAO;EACd,EAAE,KAAK,0BAA0B;EACjC,EAAE,IAAI,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;CACpE;CAEA,EAAE,MAAM,yCAAyC;CAEjD,OAAO;AACT"}
@@ -1,9 +1,9 @@
1
1
  import { relative } from "node:path";
2
- import { prepareIntlayer } from "@intlayer/engine/cli";
3
2
  import { colon, colorizeKey, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
4
3
  import { getConfiguration } from "@intlayer/config/node";
5
- import { formatPath } from "@intlayer/engine/utils";
6
4
  import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
5
+ import { prepareIntlayer } from "@intlayer/engine/cli";
6
+ import { formatPath } from "@intlayer/engine/utils";
7
7
 
8
8
  //#region src/listContentDeclaration.ts
9
9
  const listContentDeclarationRows = async (options) => {
@@ -1,14 +1,14 @@
1
1
  import { IntlayerEventListener } from "./IntlayerEventListener.mjs";
2
- import { createServer } from "node:http";
3
2
  import * as ANSIColors from "@intlayer/config/colors";
4
3
  import { colorize, getAppLogger } from "@intlayer/config/logger";
5
4
  import { getConfiguration } from "@intlayer/config/node";
6
- import { runParallel } from "@intlayer/engine/utils";
7
5
  import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
8
6
  import { buildDictionary } from "@intlayer/engine/build";
7
+ import { runParallel } from "@intlayer/engine/utils";
8
+ import { createServer } from "node:http";
9
+ import packageJson from "@intlayer/config/package.json" with { type: "json" };
9
10
  import { getLocalizedContent } from "@intlayer/core/plugins";
10
11
  import { getDictionaries } from "@intlayer/dictionaries-entry";
11
- import packageJson from "@intlayer/config/package.json" with { type: "json" };
12
12
 
13
13
  //#region src/liveSync.ts
14
14
  const writeDictionary = async (dictionary, configuration) => {
package/dist/esm/pull.mjs CHANGED
@@ -1,16 +1,16 @@
1
- import { checkCMSAuth, getAuthenticatedAPI } from "./utils/checkAccess.mjs";
2
1
  import { PullLogger } from "./push/pullLog.mjs";
2
+ import { checkCMSAuth, getAuthenticatedAPI } from "./utils/checkAccess.mjs";
3
3
  import { selectCmsEnvironment } from "./utils/selectCmsEnvironment.mjs";
4
- import { join } from "node:path";
5
- import { logConfigDetails } from "@intlayer/engine/cli";
6
4
  import { existsSync } from "node:fs";
5
+ import { join } from "node:path";
7
6
  import * as ANSIColors from "@intlayer/config/colors";
8
7
  import { getAppLogger } from "@intlayer/config/logger";
9
8
  import { getConfiguration } from "@intlayer/config/node";
10
- import { parallelize } from "@intlayer/engine/utils";
11
9
  import { getProjectRequire } from "@intlayer/config/utils";
12
10
  import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
13
11
  import { writeContentDeclaration } from "@intlayer/engine/build";
12
+ import { logConfigDetails } from "@intlayer/engine/cli";
13
+ import { parallelize } from "@intlayer/engine/utils";
14
14
 
15
15
  //#region src/pull.ts
16
16
  /**
@@ -1,16 +1,16 @@
1
- import { loadPrompts } from "../loadPrompts.mjs";
2
1
  import { checkCMSAuth, getAuthenticatedAPI } from "../utils/checkAccess.mjs";
3
2
  import { selectCmsEnvironment } from "../utils/selectCmsEnvironment.mjs";
4
3
  import { PushLogger } from "../pushLog.mjs";
4
+ import { loadPrompts } from "../loadPrompts.mjs";
5
5
  import { join } from "node:path";
6
- import { listGitFiles, logConfigDetails } from "@intlayer/engine/cli";
7
6
  import * as ANSIColors from "@intlayer/config/colors";
8
7
  import { colorize, colorizeKey, getAppLogger } from "@intlayer/config/logger";
9
8
  import { getConfiguration } from "@intlayer/config/node";
10
- import * as fsPromises from "node:fs/promises";
11
- import { formatPath, parallelize } from "@intlayer/engine/utils";
12
9
  import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
13
- import { prepareIntlayer as prepareIntlayer$1, writeContentDeclaration } from "@intlayer/engine/build";
10
+ import { prepareIntlayer, writeContentDeclaration } from "@intlayer/engine/build";
11
+ import { listGitFiles, logConfigDetails } from "@intlayer/engine/cli";
12
+ import { formatPath, parallelize } from "@intlayer/engine/utils";
13
+ import * as fsPromises from "node:fs/promises";
14
14
 
15
15
  //#region src/push/push.ts
16
16
  const statusIconsAndColors = {
@@ -45,8 +45,8 @@ const push = async (options) => {
45
45
  const config = getConfiguration(options?.configOptions);
46
46
  logConfigDetails(options?.configOptions);
47
47
  const appLogger = getAppLogger(config);
48
- if (options?.build === true) await prepareIntlayer$1(config, { forceRun: true });
49
- else if (typeof options?.build === "undefined") await prepareIntlayer$1(config);
48
+ if (options?.build === true) await prepareIntlayer(config, { forceRun: true });
49
+ else if (typeof options?.build === "undefined") await prepareIntlayer(config);
50
50
  try {
51
51
  if (!await checkCMSAuth(config)) return;
52
52
  const intlayerAPI = await getAuthenticatedAPI(config);