@intlayer/engine 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 (63) hide show
  1. package/dist/assets/installSkills/skills/angular.md +19 -68
  2. package/dist/assets/installSkills/skills/astro.md +38 -4
  3. package/dist/assets/installSkills/skills/backend.md +113 -0
  4. package/dist/assets/installSkills/skills/cli.md +29 -25
  5. package/dist/assets/installSkills/skills/compat.md +87 -0
  6. package/dist/assets/installSkills/skills/compiler.md +14 -4
  7. package/dist/assets/installSkills/skills/config.md +15 -5
  8. package/dist/assets/installSkills/skills/content.md +80 -6
  9. package/dist/assets/installSkills/skills/dev-tools.md +82 -0
  10. package/dist/assets/installSkills/skills/lit.md +115 -0
  11. package/dist/assets/installSkills/skills/markdown.md +96 -0
  12. package/dist/assets/installSkills/skills/next-js.md +21 -38
  13. package/dist/assets/installSkills/skills/preact.md +18 -0
  14. package/dist/assets/installSkills/skills/react.md +21 -4
  15. package/dist/assets/installSkills/skills/remix.md +95 -0
  16. package/dist/assets/installSkills/skills/remote-content.md +1 -1
  17. package/dist/assets/installSkills/skills/solid.md +21 -1
  18. package/dist/assets/installSkills/skills/svelte.md +22 -1
  19. package/dist/assets/installSkills/skills/usage.md +28 -0
  20. package/dist/assets/installSkills/skills/vanilla.md +108 -0
  21. package/dist/assets/installSkills/skills/vue.md +22 -0
  22. package/dist/cjs/cli.cjs +2 -0
  23. package/dist/cjs/init/index.cjs +305 -300
  24. package/dist/cjs/init/index.cjs.map +1 -1
  25. package/dist/cjs/init/upgradeIntlayerPackages.cjs +60 -0
  26. package/dist/cjs/init/upgradeIntlayerPackages.cjs.map +1 -0
  27. package/dist/cjs/init/utils/index.cjs +13 -4
  28. package/dist/cjs/init/utils/intlayerDependencies.cjs +119 -0
  29. package/dist/cjs/init/utils/intlayerDependencies.cjs.map +1 -0
  30. package/dist/cjs/init/utils/packageManager.cjs +145 -94
  31. package/dist/cjs/init/utils/packageManager.cjs.map +1 -1
  32. package/dist/cjs/installSkills/index.cjs +110 -19
  33. package/dist/cjs/installSkills/index.cjs.map +1 -1
  34. package/dist/cjs/utils/runOnce.cjs +66 -15
  35. package/dist/cjs/utils/runOnce.cjs.map +1 -1
  36. package/dist/esm/cli.mjs +2 -1
  37. package/dist/esm/init/index.mjs +306 -301
  38. package/dist/esm/init/index.mjs.map +1 -1
  39. package/dist/esm/init/upgradeIntlayerPackages.mjs +57 -0
  40. package/dist/esm/init/upgradeIntlayerPackages.mjs.map +1 -0
  41. package/dist/esm/init/utils/index.mjs +3 -2
  42. package/dist/esm/init/utils/intlayerDependencies.mjs +110 -0
  43. package/dist/esm/init/utils/intlayerDependencies.mjs.map +1 -0
  44. package/dist/esm/init/utils/packageManager.mjs +143 -93
  45. package/dist/esm/init/utils/packageManager.mjs.map +1 -1
  46. package/dist/esm/installSkills/index.mjs +110 -19
  47. package/dist/esm/installSkills/index.mjs.map +1 -1
  48. package/dist/esm/utils/runOnce.mjs +67 -16
  49. package/dist/esm/utils/runOnce.mjs.map +1 -1
  50. package/dist/types/cli.d.ts +2 -1
  51. package/dist/types/init/index.d.ts +9 -6
  52. package/dist/types/init/index.d.ts.map +1 -1
  53. package/dist/types/init/upgradeIntlayerPackages.d.ts +26 -0
  54. package/dist/types/init/upgradeIntlayerPackages.d.ts.map +1 -0
  55. package/dist/types/init/utils/index.d.ts +3 -2
  56. package/dist/types/init/utils/intlayerDependencies.d.ts +66 -0
  57. package/dist/types/init/utils/intlayerDependencies.d.ts.map +1 -0
  58. package/dist/types/init/utils/packageManager.d.ts +44 -19
  59. package/dist/types/init/utils/packageManager.d.ts.map +1 -1
  60. package/dist/types/installSkills/index.d.ts +16 -3
  61. package/dist/types/installSkills/index.d.ts.map +1 -1
  62. package/dist/types/utils/runOnce.d.ts.map +1 -1
  63. package/package.json +7 -7
@@ -1,18 +1,57 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { compareVersions } from "@intlayer/config/utils";
2
+ import { dirname, join, resolve } from "node:path";
4
3
  import { execSync } from "node:child_process";
5
4
 
6
5
  //#region src/init/utils/packageManager.ts
6
+ /** Lock files revealing the package manager, in detection priority order. */
7
+ const LOCK_FILE_PACKAGE_MANAGERS = [
8
+ ["bun.lock", "bun"],
9
+ ["bun.lockb", "bun"],
10
+ ["pnpm-lock.yaml", "pnpm"],
11
+ ["yarn.lock", "yarn"],
12
+ ["package-lock.json", "npm"]
13
+ ];
14
+ /** Package managers accepted in the `packageManager` field of `package.json`. */
15
+ const PACKAGE_MANAGERS = [
16
+ "bun",
17
+ "pnpm",
18
+ "yarn",
19
+ "npm"
20
+ ];
21
+ /**
22
+ * Reads the package manager pinned by the `packageManager` field of the
23
+ * `package.json` in `directory` (e.g. `"pnpm@9.0.0"`), if any.
24
+ */
25
+ const readPackageManagerField = (directory) => {
26
+ try {
27
+ const { packageManager } = JSON.parse(readFileSync(join(directory, "package.json"), "utf8"));
28
+ if (typeof packageManager !== "string") return null;
29
+ const name = packageManager.split("@")[0];
30
+ return PACKAGE_MANAGERS.includes(name) ? name : null;
31
+ } catch {
32
+ return null;
33
+ }
34
+ };
7
35
  /**
8
36
  * Detects the package manager in use by checking for lock files in the
9
- * project root. Falls back to npm when no lock file is found.
37
+ * project root, then the `packageManager` field of its `package.json`. Falls
38
+ * back to npm when neither is found.
39
+ */
40
+ const detectPackageManager = (rootDir) => LOCK_FILE_PACKAGE_MANAGERS.find(([lockFile]) => existsSync(join(rootDir, lockFile)))?.[1] ?? readPackageManagerField(rootDir) ?? "npm";
41
+ /**
42
+ * Walks up from `startDir` to the nearest directory holding a lock file — the
43
+ * workspace root an install must run from. Stops at the repository root
44
+ * (`.git`) and returns `null` when no lock file is found.
10
45
  */
11
- const detectPackageManager = (rootDir) => {
12
- if (existsSync(join(rootDir, "bun.lock")) || existsSync(join(rootDir, "bun.lockb"))) return "bun";
13
- if (existsSync(join(rootDir, "pnpm-lock.yaml"))) return "pnpm";
14
- if (existsSync(join(rootDir, "yarn.lock"))) return "yarn";
15
- return "npm";
46
+ const findLockFileDir = (startDir) => {
47
+ let currentDir = resolve(startDir);
48
+ while (true) {
49
+ if (LOCK_FILE_PACKAGE_MANAGERS.some(([lockFile]) => existsSync(join(currentDir, lockFile)))) return currentDir;
50
+ if (existsSync(join(currentDir, ".git"))) return null;
51
+ const parentDir = dirname(currentDir);
52
+ if (parentDir === currentDir) return null;
53
+ currentDir = parentDir;
54
+ }
16
55
  };
17
56
  /**
18
57
  * Returns the install command for the given package manager and package list.
@@ -40,7 +79,11 @@ const COMPAT_I18N_LIBRARIES = [
40
79
  "react-i18next",
41
80
  "@intlayer/i18next",
42
81
  "@intlayer/react-i18next"
43
- ]
82
+ ],
83
+ replacements: {
84
+ i18next: "@intlayer/i18next",
85
+ "react-i18next": "@intlayer/react-i18next"
86
+ }
44
87
  },
45
88
  {
46
89
  label: "next-intl / use-intl",
@@ -49,27 +92,36 @@ const COMPAT_I18N_LIBRARIES = [
49
92
  "use-intl",
50
93
  "@intlayer/next-intl",
51
94
  "@intlayer/use-intl"
52
- ]
95
+ ],
96
+ replacements: {
97
+ "next-intl": "@intlayer/next-intl",
98
+ "use-intl": "@intlayer/use-intl"
99
+ }
53
100
  },
54
101
  {
55
102
  label: "vue-i18n",
56
- packages: ["vue-i18n", "@intlayer/vue-i18n"]
103
+ packages: ["vue-i18n", "@intlayer/vue-i18n"],
104
+ replacements: { "vue-i18n": "@intlayer/vue-i18n" }
57
105
  },
58
106
  {
59
107
  label: "@nuxtjs/i18n",
60
- packages: ["@nuxtjs/i18n", "@intlayer/nuxtjs-i18n"]
108
+ packages: ["@nuxtjs/i18n", "@intlayer/nuxtjs-i18n"],
109
+ replacements: { "@nuxtjs/i18n": "@intlayer/nuxtjs-i18n" }
61
110
  },
62
111
  {
63
112
  label: "next-i18next",
64
- packages: ["next-i18next", "@intlayer/next-i18next"]
113
+ packages: ["next-i18next", "@intlayer/next-i18next"],
114
+ replacements: { "next-i18next": "@intlayer/next-i18next" }
65
115
  },
66
116
  {
67
117
  label: "next-translate",
68
- packages: ["next-translate", "@intlayer/next-translate"]
118
+ packages: ["next-translate", "@intlayer/next-translate"],
119
+ replacements: { "next-translate": "@intlayer/next-translate" }
69
120
  },
70
121
  {
71
122
  label: "react-intl",
72
- packages: ["react-intl", "@intlayer/react-intl"]
123
+ packages: ["react-intl", "@intlayer/react-intl"],
124
+ replacements: { "react-intl": "@intlayer/react-intl" }
73
125
  },
74
126
  {
75
127
  label: "Lingui",
@@ -77,30 +129,63 @@ const COMPAT_I18N_LIBRARIES = [
77
129
  "@lingui/core",
78
130
  "@lingui/react",
79
131
  "@intlayer/lingui"
80
- ]
132
+ ],
133
+ replacements: {
134
+ "@lingui/core": "@intlayer/lingui",
135
+ "@lingui/react": "@intlayer/lingui"
136
+ }
81
137
  },
82
138
  {
83
139
  label: "svelte-i18n",
84
- packages: ["svelte-i18n", "@intlayer/svelte-i18n"]
140
+ packages: ["svelte-i18n", "@intlayer/svelte-i18n"],
141
+ replacements: { "svelte-i18n": "@intlayer/svelte-i18n" }
85
142
  },
86
143
  {
87
144
  label: "@ngneat/transloco",
88
- packages: ["@ngneat/transloco", "@intlayer/transloco"]
145
+ packages: ["@ngneat/transloco", "@intlayer/transloco"],
146
+ replacements: { "@ngneat/transloco": "@intlayer/transloco" }
89
147
  },
90
148
  {
91
149
  label: "@ngx-translate/core",
92
- packages: ["@ngx-translate/core", "@intlayer/ngx-translate"]
150
+ packages: ["@ngx-translate/core", "@intlayer/ngx-translate"],
151
+ replacements: { "@ngx-translate/core": "@intlayer/ngx-translate" }
93
152
  },
94
153
  {
95
154
  label: "node-polyglot",
96
- packages: ["node-polyglot", "@intlayer/polyglot"]
155
+ packages: ["node-polyglot", "@intlayer/polyglot"],
156
+ replacements: { "node-polyglot": "@intlayer/polyglot" }
97
157
  },
98
158
  {
99
159
  label: "i18n-js",
100
- packages: ["i18n-js", "@intlayer/i18n-js"]
160
+ packages: ["i18n-js", "@intlayer/i18n-js"],
161
+ replacements: { "i18n-js": "@intlayer/i18n-js" }
101
162
  }
102
163
  ];
103
164
  /**
165
+ * Maps third-party i18n libraries to the Intlayer compat adapter that replaces
166
+ * them at runtime, derived from {@link COMPAT_I18N_LIBRARIES}.
167
+ */
168
+ const COMPAT_PACKAGE_REPLACEMENTS = Object.fromEntries(COMPAT_I18N_LIBRARIES.flatMap((library) => Object.entries(library.replacements)));
169
+ /**
170
+ * When a project uses a compat i18n package (such as `next-intl`) that gets
171
+ * replaced by an `@intlayer/*` adapter (e.g. `@intlayer/next-intl`), moves the
172
+ * original package from `dependencies` to `devDependencies` in `package.json`.
173
+ *
174
+ * Returns the list of package names that were moved.
175
+ */
176
+ const moveCompatPackagesToDevDependencies = (packageJson) => {
177
+ const movedPackages = [];
178
+ if (!packageJson.dependencies) return movedPackages;
179
+ for (const compatPackage of Object.keys(COMPAT_PACKAGE_REPLACEMENTS)) if (packageJson.dependencies[compatPackage]) {
180
+ const version = packageJson.dependencies[compatPackage];
181
+ delete packageJson.dependencies[compatPackage];
182
+ packageJson.devDependencies = packageJson.devDependencies ?? {};
183
+ if (!packageJson.devDependencies[compatPackage]) packageJson.devDependencies[compatPackage] = version;
184
+ movedPackages.push(compatPackage);
185
+ }
186
+ return movedPackages;
187
+ };
188
+ /**
104
189
  * Returns the labels of the compat i18n libraries present in `dependencies`.
105
190
  *
106
191
  * Lets the init flow report (and branch on) the libraries it found without
@@ -125,6 +210,7 @@ const hasLintTooling = (dependencies) => Boolean(dependencies.eslint) || Boolean
125
210
  const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
126
211
  const packagesToInstall = [];
127
212
  const devPackagesToInstall = [];
213
+ const packagesToMoveToDev = [];
128
214
  let compatSyncConfig;
129
215
  let compatVitePluginConfig;
130
216
  const isInstalled = (packageName) => Boolean(allDependencies[packageName]);
@@ -134,6 +220,16 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
134
220
  const addDevIfMissing = (packageName) => {
135
221
  if (!isInstalled(packageName)) devPackagesToInstall.push(packageName);
136
222
  };
223
+ const markCompatReplacement = (originalPackage, adapterPackage) => {
224
+ addIfMissing(adapterPackage);
225
+ addDevIfMissing(originalPackage);
226
+ const isExplicitDev = Boolean(options.devDependencies?.[originalPackage]);
227
+ const isExplicitProd = Boolean(options.dependencies?.[originalPackage]);
228
+ const isImplicitProd = !options.dependencies && !options.devDependencies && Boolean(allDependencies[originalPackage]);
229
+ if ((isExplicitProd || isImplicitProd) && !isExplicitDev) {
230
+ if (!packagesToMoveToDev.includes(originalPackage)) packagesToMoveToDev.push(originalPackage);
231
+ }
232
+ };
137
233
  addIfMissing("intlayer");
138
234
  const isReactNativeProject = isInstalled("react-native") || isInstalled("expo");
139
235
  if (isInstalled("next")) addIfMissing("next-intlayer");
@@ -146,8 +242,7 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
146
242
  if (isInstalled("vite")) addIfMissing("vite-intlayer");
147
243
  if (hasLintTooling(allDependencies)) addDevIfMissing("eslint-plugin-intlayer");
148
244
  if (isInstalled("next-intl") || isInstalled("@intlayer/next-intl")) {
149
- addIfMissing("@intlayer/next-intl");
150
- addIfMissing("next-intl");
245
+ markCompatReplacement("next-intl", "@intlayer/next-intl");
151
246
  compatSyncConfig ??= {
152
247
  format: "icu",
153
248
  sourceTemplate: "./messages/${locale}.json",
@@ -155,24 +250,21 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
155
250
  };
156
251
  }
157
252
  if (isInstalled("next-i18next") || isInstalled("@intlayer/next-i18next")) {
158
- addIfMissing("@intlayer/next-i18next");
159
- addIfMissing("next-i18next");
253
+ markCompatReplacement("next-i18next", "@intlayer/next-i18next");
160
254
  compatSyncConfig ??= {
161
255
  format: "i18next",
162
256
  sourceTemplate: "./src/locales/${locale}/${key}.json"
163
257
  };
164
258
  }
165
259
  if (isInstalled("next-translate") || isInstalled("@intlayer/next-translate")) {
166
- addIfMissing("@intlayer/next-translate");
167
- addIfMissing("next-translate");
260
+ markCompatReplacement("next-translate", "@intlayer/next-translate");
168
261
  compatSyncConfig ??= {
169
262
  format: "i18next",
170
263
  sourceTemplate: "./locales/${locale}/${key}.json"
171
264
  };
172
265
  }
173
266
  if (isInstalled("i18next") || isInstalled("@intlayer/i18next")) {
174
- addIfMissing("@intlayer/i18next");
175
- addIfMissing("i18next");
267
+ markCompatReplacement("i18next", "@intlayer/i18next");
176
268
  compatSyncConfig ??= {
177
269
  format: "i18next",
178
270
  sourceTemplate: "./src/locales/${locale}/${key}.json"
@@ -183,8 +275,7 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
183
275
  };
184
276
  }
185
277
  if (isInstalled("react-i18next") || isInstalled("@intlayer/react-i18next")) {
186
- addIfMissing("@intlayer/react-i18next");
187
- addIfMissing("react-i18next");
278
+ markCompatReplacement("react-i18next", "@intlayer/react-i18next");
188
279
  compatSyncConfig ??= {
189
280
  format: "i18next",
190
281
  sourceTemplate: "./src/locales/${locale}/${key}.json"
@@ -195,8 +286,7 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
195
286
  };
196
287
  }
197
288
  if (isInstalled("vue-i18n") || isInstalled("@intlayer/vue-i18n")) {
198
- addIfMissing("@intlayer/vue-i18n");
199
- addIfMissing("vue-i18n");
289
+ markCompatReplacement("vue-i18n", "@intlayer/vue-i18n");
200
290
  compatSyncConfig ??= {
201
291
  format: "vue-i18n",
202
292
  sourceTemplate: "./locales/${locale}/${key}.json"
@@ -207,8 +297,7 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
207
297
  };
208
298
  }
209
299
  if (isInstalled("use-intl") || isInstalled("@intlayer/use-intl")) {
210
- addIfMissing("@intlayer/use-intl");
211
- addIfMissing("use-intl");
300
+ markCompatReplacement("use-intl", "@intlayer/use-intl");
212
301
  compatSyncConfig ??= {
213
302
  format: "icu",
214
303
  sourceTemplate: "./messages/${locale}.json",
@@ -220,8 +309,7 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
220
309
  };
221
310
  }
222
311
  if (isInstalled("react-intl") || isInstalled("@intlayer/react-intl")) {
223
- addIfMissing("@intlayer/react-intl");
224
- addIfMissing("react-intl");
312
+ markCompatReplacement("react-intl", "@intlayer/react-intl");
225
313
  compatSyncConfig ??= {
226
314
  format: "icu",
227
315
  sourceTemplate: "./src/i18n/${locale}.json"
@@ -232,16 +320,14 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
232
320
  };
233
321
  }
234
322
  if (isInstalled("@ngneat/transloco") || isInstalled("@intlayer/transloco")) {
235
- addIfMissing("@intlayer/transloco");
236
- addIfMissing("@ngneat/transloco");
323
+ markCompatReplacement("@ngneat/transloco", "@intlayer/transloco");
237
324
  compatVitePluginConfig ??= {
238
325
  pluginFunctionName: "translocoVitePlugin",
239
326
  pluginPackageSource: "@intlayer/transloco/plugin"
240
327
  };
241
328
  }
242
329
  if (isInstalled("svelte-i18n") || isInstalled("@intlayer/svelte-i18n")) {
243
- addIfMissing("@intlayer/svelte-i18n");
244
- addIfMissing("svelte-i18n");
330
+ markCompatReplacement("svelte-i18n", "@intlayer/svelte-i18n");
245
331
  compatSyncConfig ??= {
246
332
  format: "i18next",
247
333
  sourceTemplate: "./src/locales/${locale}.json"
@@ -252,24 +338,21 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
252
338
  };
253
339
  }
254
340
  if (isInstalled("node-polyglot") || isInstalled("@intlayer/polyglot")) {
255
- addIfMissing("@intlayer/polyglot");
256
- addIfMissing("node-polyglot");
341
+ markCompatReplacement("node-polyglot", "@intlayer/polyglot");
257
342
  compatVitePluginConfig ??= {
258
343
  pluginFunctionName: "polyglotVitePlugin",
259
344
  pluginPackageSource: "@intlayer/polyglot/plugin"
260
345
  };
261
346
  }
262
347
  if (isInstalled("@nuxtjs/i18n") || isInstalled("@intlayer/nuxtjs-i18n")) {
263
- addIfMissing("@intlayer/nuxtjs-i18n");
264
- addIfMissing("@nuxtjs/i18n");
348
+ markCompatReplacement("@nuxtjs/i18n", "@intlayer/nuxtjs-i18n");
265
349
  compatSyncConfig ??= {
266
350
  format: "vue-i18n",
267
351
  sourceTemplate: "./locales/${locale}/${key}.json"
268
352
  };
269
353
  }
270
354
  if (isInstalled("@ngx-translate/core") || isInstalled("@intlayer/ngx-translate")) {
271
- addIfMissing("@intlayer/ngx-translate");
272
- addIfMissing("@ngx-translate/core");
355
+ markCompatReplacement("@ngx-translate/core", "@intlayer/ngx-translate");
273
356
  compatSyncConfig ??= {
274
357
  format: "i18next",
275
358
  sourceTemplate: "./assets/i18n/${locale}.json"
@@ -280,8 +363,8 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
280
363
  };
281
364
  }
282
365
  if (isInstalled("@lingui/core") || isInstalled("@lingui/react") || isInstalled("@intlayer/lingui")) {
283
- addIfMissing("@intlayer/lingui");
284
- addIfMissing("@lingui/core");
366
+ markCompatReplacement("@lingui/core", "@intlayer/lingui");
367
+ if (isInstalled("@lingui/react")) markCompatReplacement("@lingui/react", "@intlayer/lingui");
285
368
  const linguiUsesPo = options.linguiCatalogFormat === "po";
286
369
  compatSyncConfig ??= linguiUsesPo ? {
287
370
  plugin: "po",
@@ -302,8 +385,7 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
302
385
  };
303
386
  }
304
387
  if (isInstalled("i18n-js") || isInstalled("@intlayer/i18n-js")) {
305
- addIfMissing("@intlayer/i18n-js");
306
- addIfMissing("i18n-js");
388
+ markCompatReplacement("i18n-js", "@intlayer/i18n-js");
307
389
  compatVitePluginConfig ??= {
308
390
  pluginFunctionName: "i18nJsVitePlugin",
309
391
  pluginPackageSource: "@intlayer/i18n-js/plugin"
@@ -313,6 +395,7 @@ const detectMissingIntlayerPackages = (allDependencies, options = {}) => {
313
395
  return {
314
396
  packagesToInstall,
315
397
  devPackagesToInstall,
398
+ packagesToMoveToDev,
316
399
  compatSyncConfig,
317
400
  compatVitePluginConfig
318
401
  };
@@ -334,9 +417,10 @@ const installPackages = (rootDir, packages, packageManager, isDev = false) => {
334
417
  * Matches the core `intlayer` package, every scoped `@intlayer/*` package
335
418
  * (including compat adapters such as `@intlayer/next-intl`) and the framework
336
419
  * runtime integrations that follow the `<framework>-intlayer` convention
337
- * (e.g. `next-intlayer`, `react-intlayer`, `express-intlayer`).
420
+ * (e.g. `next-intlayer`, `react-intlayer`, `express-intlayer`), as well as the
421
+ * `intlayer-*` packages (e.g. `intlayer-editor`).
338
422
  */
339
- const isIntlayerPackageName = (packageName) => packageName === "intlayer" || packageName.startsWith("@intlayer/") || /-intlayer$/.test(packageName);
423
+ const isIntlayerPackageName = (packageName) => packageName === "intlayer" || packageName.startsWith("@intlayer/") || packageName.startsWith("intlayer-") || packageName.endsWith("-intlayer");
340
424
  /**
341
425
  * Reduces a semver range or full version to its `major.minor.patch` core,
342
426
  * stripping range prefixes (`^`, `~`), pre-release identifiers and build
@@ -350,51 +434,17 @@ const normalizeVersion = (version) => {
350
434
  return match ? `${match[1]}.${match[2]}.${match[3]}` : null;
351
435
  };
352
436
  /**
353
- * Reads the installed version of a package from its `package.json` inside the
354
- * project's `node_modules`. Returns `null` when the package is not installed or
355
- * its manifest cannot be read.
356
- */
357
- const getInstalledPackageVersion = (rootDir, packageName) => {
358
- try {
359
- const manifestPath = join(rootDir, "node_modules", packageName, "package.json");
360
- if (!existsSync(manifestPath)) return null;
361
- const { version } = JSON.parse(readFileSync(manifestPath, "utf-8"));
362
- return typeof version === "string" ? version : null;
363
- } catch {
364
- return null;
365
- }
366
- };
367
- /**
368
- * Returns the Intlayer packages from `dependencies` whose installed version is
369
- * behind `targetVersion` (compared on `major.minor.patch`). Packages that are
370
- * not installed yet are ignored — those are handled by
371
- * {@link detectMissingIntlayerPackages}.
372
- */
373
- const detectOutdatedIntlayerPackages = (rootDir, dependencies, targetVersion) => {
374
- const normalizedTarget = normalizeVersion(targetVersion);
375
- if (!normalizedTarget) return [];
376
- return Object.keys(dependencies).filter(isIntlayerPackageName).filter((packageName) => {
377
- const installedVersion = getInstalledPackageVersion(rootDir, packageName);
378
- const normalizedInstalled = normalizeVersion(installedVersion ?? void 0);
379
- if (!normalizedInstalled) return false;
380
- return compareVersions(normalizedInstalled, "<", normalizedTarget);
381
- });
382
- };
383
- /**
384
- * Upgrades the given packages to `targetVersion` synchronously, preserving the
385
- * dependency type via the `isDev` flag. Throws if the install process exits
386
- * with a non-zero code.
437
+ * Runs the package manager install command synchronously, so edited
438
+ * `package.json` ranges are resolved and the lock file updated. Throws if the
439
+ * install process exits with a non-zero code.
387
440
  */
388
- const upgradePackages = (rootDir, packages, packageManager, targetVersion, isDev = false) => {
389
- if (packages.length === 0) return;
390
- const versionedPackages = packages.map((packageName) => `${packageName}@${targetVersion}`);
391
- const command = buildInstallCommand(packageManager, versionedPackages, isDev);
392
- execSync(command, {
441
+ const runPackageInstall = (rootDir, packageManager) => {
442
+ execSync(`${packageManager} install`, {
393
443
  cwd: rootDir,
394
444
  stdio: "inherit"
395
445
  });
396
446
  };
397
447
 
398
448
  //#endregion
399
- export { COMPAT_I18N_LIBRARIES, detectCompatI18nLibraries, detectMissingIntlayerPackages, detectOutdatedIntlayerPackages, detectPackageManager, getInstalledPackageVersion, hasLintTooling, installPackages, isIntlayerPackageName, normalizeVersion, upgradePackages };
449
+ export { COMPAT_I18N_LIBRARIES, COMPAT_PACKAGE_REPLACEMENTS, detectCompatI18nLibraries, detectMissingIntlayerPackages, detectPackageManager, findLockFileDir, hasLintTooling, installPackages, isIntlayerPackageName, moveCompatPackagesToDevDependencies, normalizeVersion, runPackageInstall };
400
450
  //# sourceMappingURL=packageManager.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageManager.mjs","names":[],"sources":["../../../../src/init/utils/packageManager.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { compareVersions } from '@intlayer/config/utils';\n\n/** Package managers supported for dependency installation. */\nexport type PackageManager = 'bun' | 'pnpm' | 'yarn' | 'npm';\n\n/**\n * Configuration for the syncJSON plugin injected into intlayer.config\n * when a compat i18n library is detected.\n */\nexport type CompatSyncConfig = {\n /**\n * Which sync plugin ingests the catalogs:\n * - `'json'` → `syncJSON` from `@intlayer/sync-json-plugin` (default).\n * - `'po'` → `syncPO` from `@intlayer/sync-po-plugin` (lingui's default\n * format).\n */\n plugin?: 'json' | 'po';\n /**\n * JSON format matching the compat library's conventions. Ignored when\n * `plugin` is `'po'` (PO catalogs are always serialized as gettext).\n */\n format: 'icu' | 'i18next' | 'vue-i18n';\n /**\n * Source path template using ${locale} and ${key} placeholders.\n * Rendered as a template literal in the generated config.\n */\n sourceTemplate: string;\n /**\n * Force `splitKeys: true` in the generated `syncJSON(...)` call so each\n * top-level key of a single per-locale file becomes its own dictionary.\n *\n * Set for libraries whose single `messages/${locale}.json` file groups\n * namespaces by its first-level keys (`next-intl` / `use-intl`, where\n * `useTranslations('Hero')` resolves to the `Hero` dictionary). Left\n * undefined for libraries whose top-level keys are plain message keys\n * (e.g. `i18next`, `react-intl`); for those, syncJSON's auto-detection\n * (split only when the source has no `${key}` segment) stays in control.\n *\n * Only meaningful for flat templates (no `${key}` segment); it is dropped\n * automatically when the resolved template addresses one namespace per file.\n */\n splitKeys?: boolean;\n};\n\n/**\n * Configuration for injecting a compat vite plugin into vite.config.\n * The plugin replaces the generic `intlayer` plugin for libraries that\n * require alias injection (e.g. `vue-i18n` → `@intlayer/vue-i18n`).\n */\nexport type CompatVitePluginConfig = {\n /** Exported function name from the plugin package, e.g. `'vueI18nVitePlugin'`. */\n pluginFunctionName: string;\n /** Import path for the plugin package, e.g. `'@intlayer/vue-i18n/plugin'`. */\n pluginPackageSource: string;\n /**\n * Set when the compat plugin is a drop-in replacement for an i18n library's\n * own Vite plugin (e.g. lingui ships `@lingui/vite-plugin`). When the original\n * import is present, init rewrites only that import's module source to\n * `pluginPackageSource` — keeping the binding and its call site — instead of\n * injecting a second import and appending another plugin to the array.\n */\n replacesVitePlugin?: {\n /** Imported binding to keep, e.g. `'lingui'`. */\n importName: string;\n /** Original package source to rewrite, e.g. `'@lingui/vite-plugin'`. */\n fromPackageSource: string;\n };\n};\n\n/** Result of analyzing project dependencies for intlayer package gaps. */\nexport type IntlayerPackageAnalysis = {\n /** Intlayer packages that are referenced but not yet installed. */\n packagesToInstall: string[];\n /** Intlayer dev packages that are referenced but not yet installed. */\n devPackagesToInstall: string[];\n /**\n * syncJSON plugin configuration to inject when a compat i18n library is\n * detected. Undefined when no compat library is present or format is not\n * yet implemented.\n */\n compatSyncConfig: CompatSyncConfig | undefined;\n /**\n * Vite config plugin to inject when a vite-based compat library is\n * detected. Undefined for Next.js/Nuxt-only compat libs or when no compat\n * library requires alias injection.\n */\n compatVitePluginConfig: CompatVitePluginConfig | undefined;\n};\n\n/**\n * Detects the package manager in use by checking for lock files in the\n * project root. Falls back to npm when no lock file is found.\n */\nexport const detectPackageManager = (rootDir: string): PackageManager => {\n if (\n existsSync(join(rootDir, 'bun.lock')) ||\n existsSync(join(rootDir, 'bun.lockb'))\n ) {\n return 'bun';\n }\n if (existsSync(join(rootDir, 'pnpm-lock.yaml'))) {\n return 'pnpm';\n }\n if (existsSync(join(rootDir, 'yarn.lock'))) {\n return 'yarn';\n }\n return 'npm';\n};\n\n/**\n * Returns the install command for the given package manager and package list.\n */\nconst buildInstallCommand = (\n packageManager: PackageManager,\n packages: string[],\n isDev: boolean = false\n): string => {\n const packageList = packages.join(' ');\n switch (packageManager) {\n case 'bun':\n return `bun add ${isDev ? '-d ' : ''}${packageList}`;\n case 'pnpm':\n return `pnpm add ${isDev ? '-D ' : ''}${packageList}`;\n case 'yarn':\n return `yarn add ${isDev ? '-D ' : ''}${packageList}`;\n case 'npm':\n return `npm install ${isDev ? '-D ' : ''}${packageList}`;\n }\n};\n\n/**\n * Analyzes existing project dependencies to determine which intlayer packages\n * are missing and what syncJSON configuration to inject when compat i18n\n * libraries are present.\n */\n/** Extra signals (from a filesystem scan) that refine compat detection. */\nexport type DetectMissingPackagesOptions = {\n /**\n * Catalog format detected for a lingui project (`'po'` or `'json'`), or\n * `null`/undefined when none was found. Decides which sync plugin + dev\n * dependency the lingui compat setup uses.\n */\n linguiCatalogFormat?: 'po' | 'json' | null;\n};\n\n/** An existing i18n library Intlayer ships a compat adapter for. */\nexport type CompatI18nLibrary = {\n /** Human-readable name, used to report the detection back to the user. */\n label: string;\n /**\n * Dependency names that reveal the library — both the upstream packages and\n * the Intlayer adapters, so a project that already ran `init` is still\n * recognized.\n */\n packages: readonly string[];\n};\n\n/**\n * Existing i18n libraries Intlayer can adapt, keyed by the dependencies that\n * reveal them. Mirrors the compat branches of\n * {@link detectMissingIntlayerPackages}: a library listed here is one that\n * detection will wire up on its own once its package is in `package.json`.\n */\nexport const COMPAT_I18N_LIBRARIES: readonly CompatI18nLibrary[] = [\n {\n label: 'i18next / react-i18next',\n packages: [\n 'i18next',\n 'react-i18next',\n '@intlayer/i18next',\n '@intlayer/react-i18next',\n ],\n },\n {\n label: 'next-intl / use-intl',\n packages: [\n 'next-intl',\n 'use-intl',\n '@intlayer/next-intl',\n '@intlayer/use-intl',\n ],\n },\n {\n label: 'vue-i18n',\n packages: ['vue-i18n', '@intlayer/vue-i18n'],\n },\n {\n label: '@nuxtjs/i18n',\n packages: ['@nuxtjs/i18n', '@intlayer/nuxtjs-i18n'],\n },\n {\n label: 'next-i18next',\n packages: ['next-i18next', '@intlayer/next-i18next'],\n },\n {\n label: 'next-translate',\n packages: ['next-translate', '@intlayer/next-translate'],\n },\n {\n label: 'react-intl',\n packages: ['react-intl', '@intlayer/react-intl'],\n },\n {\n label: 'Lingui',\n packages: ['@lingui/core', '@lingui/react', '@intlayer/lingui'],\n },\n {\n label: 'svelte-i18n',\n packages: ['svelte-i18n', '@intlayer/svelte-i18n'],\n },\n {\n label: '@ngneat/transloco',\n packages: ['@ngneat/transloco', '@intlayer/transloco'],\n },\n {\n label: '@ngx-translate/core',\n packages: ['@ngx-translate/core', '@intlayer/ngx-translate'],\n },\n {\n label: 'node-polyglot',\n packages: ['node-polyglot', '@intlayer/polyglot'],\n },\n {\n label: 'i18n-js',\n packages: ['i18n-js', '@intlayer/i18n-js'],\n },\n];\n\n/**\n * Returns the labels of the compat i18n libraries present in `dependencies`.\n *\n * Lets the init flow report (and branch on) the libraries it found without\n * asking the user, since {@link detectMissingIntlayerPackages} already derives\n * the adapters, sync plugin and config from the very same dependency map.\n *\n * @param dependencies - Merged dependencies of the target project.\n */\nexport const detectCompatI18nLibraries = (\n dependencies: Record<string, string>\n): string[] =>\n COMPAT_I18N_LIBRARIES.filter((library) =>\n library.packages.some((packageName) => Boolean(dependencies[packageName]))\n ).map((library) => library.label);\n\n/**\n * True when the project already lints, and so has something to plug the\n * Intlayer lint rules into.\n *\n * `eslint-plugin-intlayer` loads in both ESLint and oxlint, so either linter is\n * enough. Shared with the init flow so that installing the plugin and wiring up\n * its configuration are gated on exactly the same condition — a project that\n * does not lint is left alone entirely.\n *\n * @param dependencies - Merged dependencies of the target project.\n */\nexport const hasLintTooling = (dependencies: Record<string, string>): boolean =>\n Boolean(dependencies.eslint) || Boolean(dependencies.oxlint);\n\nexport const detectMissingIntlayerPackages = (\n allDependencies: Record<string, string>,\n options: DetectMissingPackagesOptions = {}\n): IntlayerPackageAnalysis => {\n const packagesToInstall: string[] = [];\n const devPackagesToInstall: string[] = [];\n let compatSyncConfig: CompatSyncConfig | undefined;\n let compatVitePluginConfig: CompatVitePluginConfig | undefined;\n\n const isInstalled = (packageName: string): boolean =>\n Boolean(allDependencies[packageName]);\n\n const addIfMissing = (packageName: string): void => {\n if (!isInstalled(packageName)) {\n packagesToInstall.push(packageName);\n }\n };\n\n const addDevIfMissing = (packageName: string): void => {\n if (!isInstalled(packageName)) {\n devPackagesToInstall.push(packageName);\n }\n };\n\n // Core package — always required\n addIfMissing('intlayer');\n\n const isReactNativeProject =\n isInstalled('react-native') || isInstalled('expo');\n\n // Framework-specific runtime integrations\n if (isInstalled('next')) {\n addIfMissing('next-intlayer');\n } else if (isReactNativeProject) {\n addIfMissing('react-native-intlayer');\n } else if (isInstalled('react')) {\n addIfMissing('react-intlayer');\n }\n\n if (isInstalled('svelte')) {\n addIfMissing('svelte-intlayer');\n }\n\n if (isInstalled('solid-js')) {\n addIfMissing('solid-intlayer');\n }\n\n if (isInstalled('@angular/core')) {\n addIfMissing('angular-intlayer');\n }\n\n if (isInstalled('vue')) {\n addIfMissing('vue-intlayer');\n }\n\n if (isInstalled('vite')) {\n addIfMissing('vite-intlayer');\n }\n\n // Lint rules — only when the project already lints.\n if (hasLintTooling(allDependencies)) {\n addDevIfMissing('eslint-plugin-intlayer');\n }\n\n // -------------------------------------------------------------------------\n // Compat adapters for existing i18n libraries.\n //\n // Detection order matters: more specific libraries are checked first so that\n // `compatSyncConfig ??=` and `compatVitePluginConfig ??=` capture the most\n // relevant match. Libraries that only affect the Next.js or Nuxt config do\n // not set `compatVitePluginConfig` (handled separately in init/index.ts).\n // Libraries whose JSON format is not yet supported leave `compatSyncConfig`\n // undefined so no syncJSON plugin is injected.\n // -------------------------------------------------------------------------\n\n // next-intl — next.js only, ICU format. Default layout is a single file per\n // locale (`messages/${locale}.json`) whose top-level keys are namespaces;\n // syncJSON `splitKeys` auto-detection (no `${key}` segment) turns each\n // top-level key into its own dictionary. The exact path is refined from\n // `i18n/request.ts` in init/index.ts when present.\n if (isInstalled('next-intl') || isInstalled('@intlayer/next-intl')) {\n addIfMissing('@intlayer/next-intl');\n addIfMissing('next-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './messages/${locale}.json',\n // next-intl groups namespaces by the first-level keys of one file.\n splitKeys: true,\n };\n // next config handled via updateNextConfigForNextIntl in init/index.ts\n }\n\n // next-i18next — next.js only, i18next JSON format\n if (isInstalled('next-i18next') || isInstalled('@intlayer/next-i18next')) {\n addIfMissing('@intlayer/next-i18next');\n addIfMissing('next-i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n // next config handled via updateNextConfigForNextI18next in init/index.ts\n }\n\n // next-translate — next.js only, i18next-style flat-namespace JSON\n if (\n isInstalled('next-translate') ||\n isInstalled('@intlayer/next-translate')\n ) {\n addIfMissing('@intlayer/next-translate');\n addIfMissing('next-translate');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n // next config handled via updateNextConfigForNextTranslate in init/index.ts\n }\n\n // i18next — vite alias injection (`i18next` → `@intlayer/i18next`) so existing\n // `import … from 'i18next'` is served by Intlayer without touching call sites.\n if (isInstalled('i18next') || isInstalled('@intlayer/i18next')) {\n addIfMissing('@intlayer/i18next');\n // Ensure the required peer dependency is installed\n addIfMissing('i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n // When react-i18next is also present, its wrapper plugin aliases both\n // `react-i18next` and `i18next`, so it must win — only inject the bare\n // i18next plugin when no React wrapper is installed.\n if (\n !isInstalled('react-i18next') &&\n !isInstalled('@intlayer/react-i18next')\n ) {\n compatVitePluginConfig ??= {\n pluginFunctionName: 'i18nextVitePlugin',\n pluginPackageSource: '@intlayer/i18next/plugin',\n };\n }\n }\n\n // react-i18next — vite alias injection (`react-i18next` → `@intlayer/react-i18next`\n // and `i18next` → `@intlayer/i18next`) so components keep importing from\n // `react-i18next` unchanged.\n if (isInstalled('react-i18next') || isInstalled('@intlayer/react-i18next')) {\n addIfMissing('@intlayer/react-i18next');\n // Ensure the required peer dependency is installed\n addIfMissing('react-i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'reactI18nextVitePlugin',\n pluginPackageSource: '@intlayer/react-i18next/plugin',\n };\n }\n\n // vue-i18n — vite alias injection required\n if (isInstalled('vue-i18n') || isInstalled('@intlayer/vue-i18n')) {\n addIfMissing('@intlayer/vue-i18n');\n addIfMissing('vue-i18n');\n compatSyncConfig ??= {\n format: 'vue-i18n',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'vueI18nVitePlugin',\n pluginPackageSource: '@intlayer/vue-i18n/plugin',\n };\n }\n\n // use-intl — framework-agnostic React core of next-intl; vite alias\n // injection required, ICU format. Commonly a single `messages/${locale}.json`\n // file whose top-level keys are namespaces, handled by syncJSON `splitKeys`\n // auto-detection (no `${key}` segment in the source template).\n if (isInstalled('use-intl') || isInstalled('@intlayer/use-intl')) {\n addIfMissing('@intlayer/use-intl');\n addIfMissing('use-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './messages/${locale}.json',\n // use-intl (the core of next-intl) uses the same single-file namespace model.\n splitKeys: true,\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'useIntlVitePlugin',\n pluginPackageSource: '@intlayer/use-intl/plugin',\n };\n }\n\n // react-intl — vite alias injection required, ICU format\n if (isInstalled('react-intl') || isInstalled('@intlayer/react-intl')) {\n addIfMissing('@intlayer/react-intl');\n addIfMissing('react-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './src/i18n/${locale}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'reactIntlVitePlugin',\n pluginPackageSource: '@intlayer/react-intl/plugin',\n };\n }\n\n // @ngneat/transloco — vite alias injection required\n // @todo syncJSON format not yet implemented for transloco\n if (isInstalled('@ngneat/transloco') || isInstalled('@intlayer/transloco')) {\n addIfMissing('@intlayer/transloco');\n addIfMissing('@ngneat/transloco');\n compatVitePluginConfig ??= {\n pluginFunctionName: 'translocoVitePlugin',\n pluginPackageSource: '@intlayer/transloco/plugin',\n };\n }\n\n // svelte-i18n — vite alias injection required, flat JSON (i18next-compatible)\n if (isInstalled('svelte-i18n') || isInstalled('@intlayer/svelte-i18n')) {\n addIfMissing('@intlayer/svelte-i18n');\n addIfMissing('svelte-i18n');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'svelteI18nVitePlugin',\n pluginPackageSource: '@intlayer/svelte-i18n/plugin',\n };\n }\n\n // node-polyglot — vite alias injection required\n // @todo syncJSON format not yet implemented for polyglot\n if (isInstalled('node-polyglot') || isInstalled('@intlayer/polyglot')) {\n addIfMissing('@intlayer/polyglot');\n addIfMissing('node-polyglot');\n compatVitePluginConfig ??= {\n pluginFunctionName: 'polyglotVitePlugin',\n pluginPackageSource: '@intlayer/polyglot/plugin',\n };\n }\n\n // @nuxtjs/i18n — nuxt module (no vite plugin), vue-i18n JSON format\n if (isInstalled('@nuxtjs/i18n') || isInstalled('@intlayer/nuxtjs-i18n')) {\n addIfMissing('@intlayer/nuxtjs-i18n');\n addIfMissing('@nuxtjs/i18n');\n compatSyncConfig ??= {\n format: 'vue-i18n',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n // nuxt config handled via updateNuxtConfigForNuxtjsI18n in init/index.ts\n }\n\n // @ngx-translate/core — vite alias injection required, flat JSON (i18next)\n if (\n isInstalled('@ngx-translate/core') ||\n isInstalled('@intlayer/ngx-translate')\n ) {\n addIfMissing('@intlayer/ngx-translate');\n addIfMissing('@ngx-translate/core');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './assets/i18n/${locale}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'ngxTranslateVitePlugin',\n pluginPackageSource: '@intlayer/ngx-translate/plugin',\n };\n }\n\n // @lingui/core — vite alias injection required.\n // lingui keeps one catalog file per locale (default name `messages`), as\n // `.po` (its default) or `.json`. The catalog filename is captured by the\n // `${key}` segment so the produced dictionary key is `messages`, matching the\n // fixed `messages` namespace the lingui compat runtime reads from.\n if (\n isInstalled('@lingui/core') ||\n isInstalled('@lingui/react') ||\n isInstalled('@intlayer/lingui')\n ) {\n addIfMissing('@intlayer/lingui');\n addIfMissing('@lingui/core');\n\n const linguiUsesPo = options.linguiCatalogFormat === 'po';\n compatSyncConfig ??= linguiUsesPo\n ? {\n plugin: 'po',\n format: 'icu',\n sourceTemplate: './src/locales/${locale}/${key}.po',\n }\n : {\n plugin: 'json',\n format: 'icu',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n\n compatVitePluginConfig ??= {\n // `@intlayer/lingui/plugin` exports `lingui` as a drop-in replacement for\n // `@lingui/vite-plugin`, so a fresh project gets `lingui()` injected and a\n // project already using `@lingui/vite-plugin` only has its import source\n // rewritten (see `replacesVitePlugin`).\n pluginFunctionName: 'lingui',\n pluginPackageSource: '@intlayer/lingui/plugin',\n replacesVitePlugin: {\n importName: 'lingui',\n fromPackageSource: '@lingui/vite-plugin',\n },\n };\n }\n\n // i18n-js — vite alias injection required\n // @todo syncJSON format not yet implemented for i18n-js\n if (isInstalled('i18n-js') || isInstalled('@intlayer/i18n-js')) {\n addIfMissing('@intlayer/i18n-js');\n addIfMissing('i18n-js');\n compatVitePluginConfig ??= {\n pluginFunctionName: 'i18nJsVitePlugin',\n pluginPackageSource: '@intlayer/i18n-js/plugin',\n };\n }\n\n if (compatSyncConfig) {\n addDevIfMissing(\n compatSyncConfig.plugin === 'po'\n ? '@intlayer/sync-po-plugin'\n : '@intlayer/sync-json-plugin'\n );\n }\n\n return {\n packagesToInstall,\n devPackagesToInstall,\n compatSyncConfig,\n compatVitePluginConfig,\n };\n};\n\n/**\n * Runs the package install command synchronously.\n * Throws if the install process exits with a non-zero code.\n */\nexport const installPackages = (\n rootDir: string,\n packages: string[],\n packageManager: PackageManager,\n isDev: boolean = false\n): void => {\n const command = buildInstallCommand(packageManager, packages, isDev);\n execSync(command, { cwd: rootDir, stdio: 'inherit' });\n};\n\n/**\n * Determines whether a dependency name belongs to the Intlayer ecosystem.\n *\n * Matches the core `intlayer` package, every scoped `@intlayer/*` package\n * (including compat adapters such as `@intlayer/next-intl`) and the framework\n * runtime integrations that follow the `<framework>-intlayer` convention\n * (e.g. `next-intlayer`, `react-intlayer`, `express-intlayer`).\n */\nexport const isIntlayerPackageName = (packageName: string): boolean =>\n packageName === 'intlayer' ||\n packageName.startsWith('@intlayer/') ||\n /-intlayer$/.test(packageName);\n\n/**\n * Reduces a semver range or full version to its `major.minor.patch` core,\n * stripping range prefixes (`^`, `~`), pre-release identifiers and build\n * metadata. Returns `null` when no `major.minor.patch` can be extracted.\n *\n * @example normalizeVersion('^9.0.0-canary.3') // '9.0.0'\n */\nexport const normalizeVersion = (version?: string): string | null => {\n if (!version || typeof version !== 'string') return null;\n const match = version.match(/(\\d+)\\.(\\d+)\\.(\\d+)/);\n return match ? `${match[1]}.${match[2]}.${match[3]}` : null;\n};\n\n/**\n * Reads the installed version of a package from its `package.json` inside the\n * project's `node_modules`. Returns `null` when the package is not installed or\n * its manifest cannot be read.\n */\nexport const getInstalledPackageVersion = (\n rootDir: string,\n packageName: string\n): string | null => {\n try {\n const manifestPath = join(\n rootDir,\n 'node_modules',\n packageName,\n 'package.json'\n );\n if (!existsSync(manifestPath)) return null;\n const { version } = JSON.parse(readFileSync(manifestPath, 'utf-8'));\n return typeof version === 'string' ? version : null;\n } catch {\n return null;\n }\n};\n\n/**\n * Returns the Intlayer packages from `dependencies` whose installed version is\n * behind `targetVersion` (compared on `major.minor.patch`). Packages that are\n * not installed yet are ignored — those are handled by\n * {@link detectMissingIntlayerPackages}.\n */\nexport const detectOutdatedIntlayerPackages = (\n rootDir: string,\n dependencies: Record<string, string>,\n targetVersion: string\n): string[] => {\n const normalizedTarget = normalizeVersion(targetVersion);\n if (!normalizedTarget) return [];\n\n return Object.keys(dependencies)\n .filter(isIntlayerPackageName)\n .filter((packageName) => {\n const installedVersion = getInstalledPackageVersion(rootDir, packageName);\n const normalizedInstalled = normalizeVersion(\n installedVersion ?? undefined\n );\n if (!normalizedInstalled) return false;\n return compareVersions(normalizedInstalled, '<', normalizedTarget);\n });\n};\n\n/**\n * Upgrades the given packages to `targetVersion` synchronously, preserving the\n * dependency type via the `isDev` flag. Throws if the install process exits\n * with a non-zero code.\n */\nexport const upgradePackages = (\n rootDir: string,\n packages: string[],\n packageManager: PackageManager,\n targetVersion: string,\n isDev: boolean = false\n): void => {\n if (packages.length === 0) return;\n const versionedPackages = packages.map(\n (packageName) => `${packageName}@${targetVersion}`\n );\n const command = buildInstallCommand(packageManager, versionedPackages, isDev);\n execSync(command, { cwd: rootDir, stdio: 'inherit' });\n};\n"],"mappings":";;;;;;;;;;AAgGA,MAAa,wBAAwB,YAAoC;CACvE,IACE,WAAW,KAAK,SAAS,UAAU,CAAC,KACpC,WAAW,KAAK,SAAS,WAAW,CAAC,GAErC,OAAO;CAET,IAAI,WAAW,KAAK,SAAS,gBAAgB,CAAC,GAC5C,OAAO;CAET,IAAI,WAAW,KAAK,SAAS,WAAW,CAAC,GACvC,OAAO;CAET,OAAO;AACT;;;;AAKA,MAAM,uBACJ,gBACA,UACA,QAAiB,UACN;CACX,MAAM,cAAc,SAAS,KAAK,GAAG;CACrC,QAAQ,gBAAR;EACE,KAAK,OACH,OAAO,WAAW,QAAQ,QAAQ,KAAK;EACzC,KAAK,QACH,OAAO,YAAY,QAAQ,QAAQ,KAAK;EAC1C,KAAK,QACH,OAAO,YAAY,QAAQ,QAAQ,KAAK;EAC1C,KAAK,OACH,OAAO,eAAe,QAAQ,QAAQ,KAAK;CAC/C;AACF;;;;;;;AAmCA,MAAa,wBAAsD;CACjE;EACE,OAAO;EACP,UAAU;GACR;GACA;GACA;GACA;EACF;CACF;CACA;EACE,OAAO;EACP,UAAU;GACR;GACA;GACA;GACA;EACF;CACF;CACA;EACE,OAAO;EACP,UAAU,CAAC,YAAY,oBAAoB;CAC7C;CACA;EACE,OAAO;EACP,UAAU,CAAC,gBAAgB,uBAAuB;CACpD;CACA;EACE,OAAO;EACP,UAAU,CAAC,gBAAgB,wBAAwB;CACrD;CACA;EACE,OAAO;EACP,UAAU,CAAC,kBAAkB,0BAA0B;CACzD;CACA;EACE,OAAO;EACP,UAAU,CAAC,cAAc,sBAAsB;CACjD;CACA;EACE,OAAO;EACP,UAAU;GAAC;GAAgB;GAAiB;EAAkB;CAChE;CACA;E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ACN,OAAO;CACT;AACF;;;;;;;AAQA,MAAa,kCACX,SACA,cACA,kBACa;CACb,MAAM,mBAAmB,iBAAiB,aAAa;CACvD,IAAI,CAAC,kBAAkB,OAAO,CAAC;CAE/B,OAAO,OAAO,KAAK,YAAY,CAAC,CAC7B,OAAO,qBAAqB,CAAC,CAC7B,QAAQ,gBAAgB;EACvB,MAAM,mBAAmB,2BAA2B,SAAS,WAAW;EACxE,MAAM,sBAAsB,iBAC1B,oBAAoB,MACtB;EACA,IAAI,CAAC,qBAAqB,OAAO;EACjC,OAAO,gBAAgB,qBAAqB,KAAK,gBAAgB;CACnE,CAAC;AACL;;;;;;AAOA,MAAa,mBACX,SACA,UACA,gBACA,eACA,QAAiB,UACR;CACT,IAAI,SAAS,WAAW,GAAG;CAC3B,MAAM,oBAAoB,SAAS,KAChC,gBAAgB,GAAG,YAAY,GAAG,eACrC;CACA,MAAM,UAAU,oBAAoB,gBAAgB,mBAAmB,KAAK;CAC5E,SAAS,SAAS;EAAE,KAAK;EAAS,OAAO;CAAU,CAAC;AACtD"}
1
+ {"version":3,"file":"packageManager.mjs","names":[],"sources":["../../../../src/init/utils/packageManager.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\n\n/** Package managers supported for dependency installation. */\nexport type PackageManager = 'bun' | 'pnpm' | 'yarn' | 'npm';\n\n/**\n * Configuration for the syncJSON plugin injected into intlayer.config\n * when a compat i18n library is detected.\n */\nexport type CompatSyncConfig = {\n /**\n * Which sync plugin ingests the catalogs:\n * - `'json'` → `syncJSON` from `@intlayer/sync-json-plugin` (default).\n * - `'po'` → `syncPO` from `@intlayer/sync-po-plugin` (lingui's default\n * format).\n */\n plugin?: 'json' | 'po';\n /**\n * JSON format matching the compat library's conventions. Ignored when\n * `plugin` is `'po'` (PO catalogs are always serialized as gettext).\n */\n format: 'icu' | 'i18next' | 'vue-i18n';\n /**\n * Source path template using ${locale} and ${key} placeholders.\n * Rendered as a template literal in the generated config.\n */\n sourceTemplate: string;\n /**\n * Force `splitKeys: true` in the generated `syncJSON(...)` call so each\n * top-level key of a single per-locale file becomes its own dictionary.\n *\n * Set for libraries whose single `messages/${locale}.json` file groups\n * namespaces by its first-level keys (`next-intl` / `use-intl`, where\n * `useTranslations('Hero')` resolves to the `Hero` dictionary). Left\n * undefined for libraries whose top-level keys are plain message keys\n * (e.g. `i18next`, `react-intl`); for those, syncJSON's auto-detection\n * (split only when the source has no `${key}` segment) stays in control.\n *\n * Only meaningful for flat templates (no `${key}` segment); it is dropped\n * automatically when the resolved template addresses one namespace per file.\n */\n splitKeys?: boolean;\n};\n\n/**\n * Configuration for injecting a compat vite plugin into vite.config.\n * The plugin replaces the generic `intlayer` plugin for libraries that\n * require alias injection (e.g. `vue-i18n` → `@intlayer/vue-i18n`).\n */\nexport type CompatVitePluginConfig = {\n /** Exported function name from the plugin package, e.g. `'vueI18nVitePlugin'`. */\n pluginFunctionName: string;\n /** Import path for the plugin package, e.g. `'@intlayer/vue-i18n/plugin'`. */\n pluginPackageSource: string;\n /**\n * Set when the compat plugin is a drop-in replacement for an i18n library's\n * own Vite plugin (e.g. lingui ships `@lingui/vite-plugin`). When the original\n * import is present, init rewrites only that import's module source to\n * `pluginPackageSource` — keeping the binding and its call site — instead of\n * injecting a second import and appending another plugin to the array.\n */\n replacesVitePlugin?: {\n /** Imported binding to keep, e.g. `'lingui'`. */\n importName: string;\n /** Original package source to rewrite, e.g. `'@lingui/vite-plugin'`. */\n fromPackageSource: string;\n };\n};\n\n/** Result of analyzing project dependencies for intlayer package gaps. */\nexport type IntlayerPackageAnalysis = {\n /** Intlayer packages that are referenced but not yet installed. */\n packagesToInstall: string[];\n /** Intlayer dev packages that are referenced but not yet installed. */\n devPackagesToInstall: string[];\n /** Compat packages in dependencies that got replaced and should be moved to devDependencies. */\n packagesToMoveToDev: string[];\n /**\n * syncJSON plugin configuration to inject when a compat i18n library is\n * detected. Undefined when no compat library is present or format is not\n * yet implemented.\n */\n compatSyncConfig: CompatSyncConfig | undefined;\n /**\n * Vite config plugin to inject when a vite-based compat library is\n * detected. Undefined for Next.js/Nuxt-only compat libs or when no compat\n * library requires alias injection.\n */\n compatVitePluginConfig: CompatVitePluginConfig | undefined;\n};\n\n/** Lock files revealing the package manager, in detection priority order. */\nconst LOCK_FILE_PACKAGE_MANAGERS: ReadonlyArray<\n readonly [lockFile: string, packageManager: PackageManager]\n> = [\n ['bun.lock', 'bun'],\n ['bun.lockb', 'bun'],\n ['pnpm-lock.yaml', 'pnpm'],\n ['yarn.lock', 'yarn'],\n ['package-lock.json', 'npm'],\n];\n\n/** Package managers accepted in the `packageManager` field of `package.json`. */\nconst PACKAGE_MANAGERS: readonly PackageManager[] = [\n 'bun',\n 'pnpm',\n 'yarn',\n 'npm',\n];\n\n/**\n * Reads the package manager pinned by the `packageManager` field of the\n * `package.json` in `directory` (e.g. `\"pnpm@9.0.0\"`), if any.\n */\nconst readPackageManagerField = (directory: string): PackageManager | null => {\n try {\n const { packageManager } = JSON.parse(\n readFileSync(join(directory, 'package.json'), 'utf8')\n ) as { packageManager?: unknown };\n\n if (typeof packageManager !== 'string') return null;\n\n const name = packageManager.split('@')[0] as PackageManager;\n return PACKAGE_MANAGERS.includes(name) ? name : null;\n } catch {\n return null;\n }\n};\n\n/**\n * Detects the package manager in use by checking for lock files in the\n * project root, then the `packageManager` field of its `package.json`. Falls\n * back to npm when neither is found.\n */\nexport const detectPackageManager = (rootDir: string): PackageManager =>\n LOCK_FILE_PACKAGE_MANAGERS.find(([lockFile]) =>\n existsSync(join(rootDir, lockFile))\n )?.[1] ??\n readPackageManagerField(rootDir) ??\n 'npm';\n\n/**\n * Walks up from `startDir` to the nearest directory holding a lock file — the\n * workspace root an install must run from. Stops at the repository root\n * (`.git`) and returns `null` when no lock file is found.\n */\nexport const findLockFileDir = (startDir: string): string | null => {\n let currentDir = resolve(startDir);\n\n while (true) {\n const hasLockFile = LOCK_FILE_PACKAGE_MANAGERS.some(([lockFile]) =>\n existsSync(join(currentDir, lockFile))\n );\n if (hasLockFile) return currentDir;\n if (existsSync(join(currentDir, '.git'))) return null;\n\n const parentDir = dirname(currentDir);\n if (parentDir === currentDir) return null;\n currentDir = parentDir;\n }\n};\n\n/**\n * Returns the install command for the given package manager and package list.\n */\nconst buildInstallCommand = (\n packageManager: PackageManager,\n packages: string[],\n isDev: boolean = false\n): string => {\n const packageList = packages.join(' ');\n switch (packageManager) {\n case 'bun':\n return `bun add ${isDev ? '-d ' : ''}${packageList}`;\n case 'pnpm':\n return `pnpm add ${isDev ? '-D ' : ''}${packageList}`;\n case 'yarn':\n return `yarn add ${isDev ? '-D ' : ''}${packageList}`;\n case 'npm':\n return `npm install ${isDev ? '-D ' : ''}${packageList}`;\n }\n};\n\n/**\n * Analyzes existing project dependencies to determine which intlayer packages\n * are missing and what syncJSON configuration to inject when compat i18n\n * libraries are present.\n */\n/** Extra signals (from a filesystem scan) that refine compat detection. */\nexport type DetectMissingPackagesOptions = {\n /**\n * Catalog format detected for a lingui project (`'po'` or `'json'`), or\n * `null`/undefined when none was found. Decides which sync plugin + dev\n * dependency the lingui compat setup uses.\n */\n linguiCatalogFormat?: 'po' | 'json' | null;\n /**\n * The project's runtime dependencies (from `package.json` `dependencies`).\n * When provided, compat packages found here that are replaced by `@intlayer/*`\n * are reported in `packagesToMoveToDev`.\n */\n dependencies?: Record<string, string>;\n /**\n * The project's development dependencies (from `package.json` `devDependencies`).\n */\n devDependencies?: Record<string, string>;\n};\n\n/** An existing i18n library Intlayer ships a compat adapter for. */\nexport type CompatI18nLibrary = {\n /** Human-readable name, used to report the detection back to the user. */\n label: string;\n /**\n * Dependency names that reveal the library — both the upstream packages and\n * the Intlayer adapters, so a project that already ran `init` is still\n * recognized.\n */\n packages: readonly string[];\n /**\n * Upstream third-party packages replaced by Intlayer compat adapters at runtime,\n * mapped to their adapter package name.\n */\n replacements: Record<string, string>;\n};\n\n/**\n * Existing i18n libraries Intlayer can adapt, keyed by the dependencies that\n * reveal them. Mirrors the compat branches of\n * {@link detectMissingIntlayerPackages}: a library listed here is one that\n * detection will wire up on its own once its package is in `package.json`.\n */\nexport const COMPAT_I18N_LIBRARIES: readonly CompatI18nLibrary[] = [\n {\n label: 'i18next / react-i18next',\n packages: [\n 'i18next',\n 'react-i18next',\n '@intlayer/i18next',\n '@intlayer/react-i18next',\n ],\n replacements: {\n i18next: '@intlayer/i18next',\n 'react-i18next': '@intlayer/react-i18next',\n },\n },\n {\n label: 'next-intl / use-intl',\n packages: [\n 'next-intl',\n 'use-intl',\n '@intlayer/next-intl',\n '@intlayer/use-intl',\n ],\n replacements: {\n 'next-intl': '@intlayer/next-intl',\n 'use-intl': '@intlayer/use-intl',\n },\n },\n {\n label: 'vue-i18n',\n packages: ['vue-i18n', '@intlayer/vue-i18n'],\n replacements: {\n 'vue-i18n': '@intlayer/vue-i18n',\n },\n },\n {\n label: '@nuxtjs/i18n',\n packages: ['@nuxtjs/i18n', '@intlayer/nuxtjs-i18n'],\n replacements: {\n '@nuxtjs/i18n': '@intlayer/nuxtjs-i18n',\n },\n },\n {\n label: 'next-i18next',\n packages: ['next-i18next', '@intlayer/next-i18next'],\n replacements: {\n 'next-i18next': '@intlayer/next-i18next',\n },\n },\n {\n label: 'next-translate',\n packages: ['next-translate', '@intlayer/next-translate'],\n replacements: {\n 'next-translate': '@intlayer/next-translate',\n },\n },\n {\n label: 'react-intl',\n packages: ['react-intl', '@intlayer/react-intl'],\n replacements: {\n 'react-intl': '@intlayer/react-intl',\n },\n },\n {\n label: 'Lingui',\n packages: ['@lingui/core', '@lingui/react', '@intlayer/lingui'],\n replacements: {\n '@lingui/core': '@intlayer/lingui',\n '@lingui/react': '@intlayer/lingui',\n },\n },\n {\n label: 'svelte-i18n',\n packages: ['svelte-i18n', '@intlayer/svelte-i18n'],\n replacements: {\n 'svelte-i18n': '@intlayer/svelte-i18n',\n },\n },\n {\n label: '@ngneat/transloco',\n packages: ['@ngneat/transloco', '@intlayer/transloco'],\n replacements: {\n '@ngneat/transloco': '@intlayer/transloco',\n },\n },\n {\n label: '@ngx-translate/core',\n packages: ['@ngx-translate/core', '@intlayer/ngx-translate'],\n replacements: {\n '@ngx-translate/core': '@intlayer/ngx-translate',\n },\n },\n {\n label: 'node-polyglot',\n packages: ['node-polyglot', '@intlayer/polyglot'],\n replacements: {\n 'node-polyglot': '@intlayer/polyglot',\n },\n },\n {\n label: 'i18n-js',\n packages: ['i18n-js', '@intlayer/i18n-js'],\n replacements: {\n 'i18n-js': '@intlayer/i18n-js',\n },\n },\n];\n\n/**\n * Maps third-party i18n libraries to the Intlayer compat adapter that replaces\n * them at runtime, derived from {@link COMPAT_I18N_LIBRARIES}.\n */\nexport const COMPAT_PACKAGE_REPLACEMENTS: Record<string, string> =\n Object.fromEntries(\n COMPAT_I18N_LIBRARIES.flatMap((library) =>\n Object.entries(library.replacements)\n )\n );\n\n/**\n * When a project uses a compat i18n package (such as `next-intl`) that gets\n * replaced by an `@intlayer/*` adapter (e.g. `@intlayer/next-intl`), moves the\n * original package from `dependencies` to `devDependencies` in `package.json`.\n *\n * Returns the list of package names that were moved.\n */\nexport const moveCompatPackagesToDevDependencies = (\n packageJson: Record<string, any>\n): string[] => {\n const movedPackages: string[] = [];\n if (!packageJson.dependencies) return movedPackages;\n\n for (const compatPackage of Object.keys(COMPAT_PACKAGE_REPLACEMENTS)) {\n if (packageJson.dependencies[compatPackage]) {\n const version = packageJson.dependencies[compatPackage];\n delete packageJson.dependencies[compatPackage];\n\n packageJson.devDependencies = packageJson.devDependencies ?? {};\n if (!packageJson.devDependencies[compatPackage]) {\n packageJson.devDependencies[compatPackage] = version;\n }\n movedPackages.push(compatPackage);\n }\n }\n\n return movedPackages;\n};\n\n/**\n * Returns the labels of the compat i18n libraries present in `dependencies`.\n *\n * Lets the init flow report (and branch on) the libraries it found without\n * asking the user, since {@link detectMissingIntlayerPackages} already derives\n * the adapters, sync plugin and config from the very same dependency map.\n *\n * @param dependencies - Merged dependencies of the target project.\n */\nexport const detectCompatI18nLibraries = (\n dependencies: Record<string, string>\n): string[] =>\n COMPAT_I18N_LIBRARIES.filter((library) =>\n library.packages.some((packageName) => Boolean(dependencies[packageName]))\n ).map((library) => library.label);\n\n/**\n * True when the project already lints, and so has something to plug the\n * Intlayer lint rules into.\n *\n * `eslint-plugin-intlayer` loads in both ESLint and oxlint, so either linter is\n * enough. Shared with the init flow so that installing the plugin and wiring up\n * its configuration are gated on exactly the same condition — a project that\n * does not lint is left alone entirely.\n *\n * @param dependencies - Merged dependencies of the target project.\n */\nexport const hasLintTooling = (dependencies: Record<string, string>): boolean =>\n Boolean(dependencies.eslint) || Boolean(dependencies.oxlint);\n\nexport const detectMissingIntlayerPackages = (\n allDependencies: Record<string, string>,\n options: DetectMissingPackagesOptions = {}\n): IntlayerPackageAnalysis => {\n const packagesToInstall: string[] = [];\n const devPackagesToInstall: string[] = [];\n const packagesToMoveToDev: string[] = [];\n\n let compatSyncConfig: CompatSyncConfig | undefined;\n let compatVitePluginConfig: CompatVitePluginConfig | undefined;\n\n const isInstalled = (packageName: string): boolean =>\n Boolean(allDependencies[packageName]);\n\n const addIfMissing = (packageName: string): void => {\n if (!isInstalled(packageName)) {\n packagesToInstall.push(packageName);\n }\n };\n\n const addDevIfMissing = (packageName: string): void => {\n if (!isInstalled(packageName)) {\n devPackagesToInstall.push(packageName);\n }\n };\n\n const markCompatReplacement = (\n originalPackage: string,\n adapterPackage: string\n ): void => {\n addIfMissing(adapterPackage);\n addDevIfMissing(originalPackage);\n\n const isExplicitDev = Boolean(options.devDependencies?.[originalPackage]);\n const isExplicitProd = Boolean(options.dependencies?.[originalPackage]);\n const isImplicitProd =\n !options.dependencies &&\n !options.devDependencies &&\n Boolean(allDependencies[originalPackage]);\n\n if ((isExplicitProd || isImplicitProd) && !isExplicitDev) {\n if (!packagesToMoveToDev.includes(originalPackage)) {\n packagesToMoveToDev.push(originalPackage);\n }\n }\n };\n\n // Core package — always required\n addIfMissing('intlayer');\n\n const isReactNativeProject =\n isInstalled('react-native') || isInstalled('expo');\n\n // Framework-specific runtime integrations\n if (isInstalled('next')) {\n addIfMissing('next-intlayer');\n } else if (isReactNativeProject) {\n addIfMissing('react-native-intlayer');\n } else if (isInstalled('react')) {\n addIfMissing('react-intlayer');\n }\n\n if (isInstalled('svelte')) {\n addIfMissing('svelte-intlayer');\n }\n\n if (isInstalled('solid-js')) {\n addIfMissing('solid-intlayer');\n }\n\n if (isInstalled('@angular/core')) {\n addIfMissing('angular-intlayer');\n }\n\n if (isInstalled('vue')) {\n addIfMissing('vue-intlayer');\n }\n\n if (isInstalled('vite')) {\n addIfMissing('vite-intlayer');\n }\n\n // Lint rules — only when the project already lints.\n if (hasLintTooling(allDependencies)) {\n addDevIfMissing('eslint-plugin-intlayer');\n }\n\n // -------------------------------------------------------------------------\n // Compat adapters for existing i18n libraries.\n //\n // Detection order matters: more specific libraries are checked first so that\n // `compatSyncConfig ??=` and `compatVitePluginConfig ??=` capture the most\n // relevant match. Libraries that only affect the Next.js or Nuxt config do\n // not set `compatVitePluginConfig` (handled separately in init/index.ts).\n // Libraries whose JSON format is not yet supported leave `compatSyncConfig`\n // undefined so no syncJSON plugin is injected.\n // -------------------------------------------------------------------------\n\n // next-intl — next.js only, ICU format. Default layout is a single file per\n // locale (`messages/${locale}.json`) whose top-level keys are namespaces;\n // syncJSON `splitKeys` auto-detection (no `${key}` segment) turns each\n // top-level key into its own dictionary. The exact path is refined from\n // `i18n/request.ts` in init/index.ts when present.\n if (isInstalled('next-intl') || isInstalled('@intlayer/next-intl')) {\n markCompatReplacement('next-intl', '@intlayer/next-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './messages/${locale}.json',\n // next-intl groups namespaces by the first-level keys of one file.\n splitKeys: true,\n };\n // next config handled via updateNextConfigForNextIntl in init/index.ts\n }\n\n // next-i18next — next.js only, i18next JSON format\n if (isInstalled('next-i18next') || isInstalled('@intlayer/next-i18next')) {\n markCompatReplacement('next-i18next', '@intlayer/next-i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n // next config handled via updateNextConfigForNextI18next in init/index.ts\n }\n\n // next-translate — next.js only, i18next-style flat-namespace JSON\n if (\n isInstalled('next-translate') ||\n isInstalled('@intlayer/next-translate')\n ) {\n markCompatReplacement('next-translate', '@intlayer/next-translate');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n // next config handled via updateNextConfigForNextTranslate in init/index.ts\n }\n\n // i18next — vite alias injection (`i18next` → `@intlayer/i18next`) so existing\n // `import … from 'i18next'` is served by Intlayer without touching call sites.\n if (isInstalled('i18next') || isInstalled('@intlayer/i18next')) {\n markCompatReplacement('i18next', '@intlayer/i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n // When react-i18next is also present, its wrapper plugin aliases both\n // `react-i18next` and `i18next`, so it must win — only inject the bare\n // i18next plugin when no React wrapper is installed.\n if (\n !isInstalled('react-i18next') &&\n !isInstalled('@intlayer/react-i18next')\n ) {\n compatVitePluginConfig ??= {\n pluginFunctionName: 'i18nextVitePlugin',\n pluginPackageSource: '@intlayer/i18next/plugin',\n };\n }\n }\n\n // react-i18next — vite alias injection (`react-i18next` → `@intlayer/react-i18next`\n // and `i18next` → `@intlayer/i18next`) so components keep importing from\n // `react-i18next` unchanged.\n if (isInstalled('react-i18next') || isInstalled('@intlayer/react-i18next')) {\n markCompatReplacement('react-i18next', '@intlayer/react-i18next');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'reactI18nextVitePlugin',\n pluginPackageSource: '@intlayer/react-i18next/plugin',\n };\n }\n\n // vue-i18n — vite alias injection required\n if (isInstalled('vue-i18n') || isInstalled('@intlayer/vue-i18n')) {\n markCompatReplacement('vue-i18n', '@intlayer/vue-i18n');\n compatSyncConfig ??= {\n format: 'vue-i18n',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'vueI18nVitePlugin',\n pluginPackageSource: '@intlayer/vue-i18n/plugin',\n };\n }\n\n // use-intl — framework-agnostic React core of next-intl; vite alias\n // injection required, ICU format. Commonly a single `messages/${locale}.json`\n // file whose top-level keys are namespaces, handled by syncJSON `splitKeys`\n // auto-detection (no `${key}` segment in the source template).\n if (isInstalled('use-intl') || isInstalled('@intlayer/use-intl')) {\n markCompatReplacement('use-intl', '@intlayer/use-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './messages/${locale}.json',\n // use-intl (the core of next-intl) uses the same single-file namespace model.\n splitKeys: true,\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'useIntlVitePlugin',\n pluginPackageSource: '@intlayer/use-intl/plugin',\n };\n }\n\n // react-intl — vite alias injection required, ICU format\n if (isInstalled('react-intl') || isInstalled('@intlayer/react-intl')) {\n markCompatReplacement('react-intl', '@intlayer/react-intl');\n compatSyncConfig ??= {\n format: 'icu',\n sourceTemplate: './src/i18n/${locale}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'reactIntlVitePlugin',\n pluginPackageSource: '@intlayer/react-intl/plugin',\n };\n }\n\n // @ngneat/transloco — vite alias injection required\n // @todo syncJSON format not yet implemented for transloco\n if (isInstalled('@ngneat/transloco') || isInstalled('@intlayer/transloco')) {\n markCompatReplacement('@ngneat/transloco', '@intlayer/transloco');\n compatVitePluginConfig ??= {\n pluginFunctionName: 'translocoVitePlugin',\n pluginPackageSource: '@intlayer/transloco/plugin',\n };\n }\n\n // svelte-i18n — vite alias injection required, flat JSON (i18next-compatible)\n if (isInstalled('svelte-i18n') || isInstalled('@intlayer/svelte-i18n')) {\n markCompatReplacement('svelte-i18n', '@intlayer/svelte-i18n');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './src/locales/${locale}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'svelteI18nVitePlugin',\n pluginPackageSource: '@intlayer/svelte-i18n/plugin',\n };\n }\n\n // node-polyglot — vite alias injection required\n // @todo syncJSON format not yet implemented for polyglot\n if (isInstalled('node-polyglot') || isInstalled('@intlayer/polyglot')) {\n markCompatReplacement('node-polyglot', '@intlayer/polyglot');\n compatVitePluginConfig ??= {\n pluginFunctionName: 'polyglotVitePlugin',\n pluginPackageSource: '@intlayer/polyglot/plugin',\n };\n }\n\n // @nuxtjs/i18n — nuxt module (no vite plugin), vue-i18n JSON format\n if (isInstalled('@nuxtjs/i18n') || isInstalled('@intlayer/nuxtjs-i18n')) {\n markCompatReplacement('@nuxtjs/i18n', '@intlayer/nuxtjs-i18n');\n compatSyncConfig ??= {\n format: 'vue-i18n',\n sourceTemplate: './locales/${locale}/${key}.json',\n };\n // nuxt config handled via updateNuxtConfigForNuxtjsI18n in init/index.ts\n }\n\n // @ngx-translate/core — vite alias injection required, flat JSON (i18next)\n if (\n isInstalled('@ngx-translate/core') ||\n isInstalled('@intlayer/ngx-translate')\n ) {\n markCompatReplacement('@ngx-translate/core', '@intlayer/ngx-translate');\n compatSyncConfig ??= {\n format: 'i18next',\n sourceTemplate: './assets/i18n/${locale}.json',\n };\n compatVitePluginConfig ??= {\n pluginFunctionName: 'ngxTranslateVitePlugin',\n pluginPackageSource: '@intlayer/ngx-translate/plugin',\n };\n }\n\n // @lingui/core — vite alias injection required.\n // lingui keeps one catalog file per locale (default name `messages`), as\n // `.po` (its default) or `.json`. The catalog filename is captured by the\n // `${key}` segment so the produced dictionary key is `messages`, matching the\n // fixed `messages` namespace the lingui compat runtime reads from.\n if (\n isInstalled('@lingui/core') ||\n isInstalled('@lingui/react') ||\n isInstalled('@intlayer/lingui')\n ) {\n markCompatReplacement('@lingui/core', '@intlayer/lingui');\n\n if (isInstalled('@lingui/react')) {\n markCompatReplacement('@lingui/react', '@intlayer/lingui');\n }\n\n const linguiUsesPo = options.linguiCatalogFormat === 'po';\n compatSyncConfig ??= linguiUsesPo\n ? {\n plugin: 'po',\n format: 'icu',\n sourceTemplate: './src/locales/${locale}/${key}.po',\n }\n : {\n plugin: 'json',\n format: 'icu',\n sourceTemplate: './src/locales/${locale}/${key}.json',\n };\n\n compatVitePluginConfig ??= {\n // `@intlayer/lingui/plugin` exports `lingui` as a drop-in replacement for\n // `@lingui/vite-plugin`, so a fresh project gets `lingui()` injected and a\n // project already using `@lingui/vite-plugin` only has its import source\n // rewritten (see `replacesVitePlugin`).\n pluginFunctionName: 'lingui',\n pluginPackageSource: '@intlayer/lingui/plugin',\n replacesVitePlugin: {\n importName: 'lingui',\n fromPackageSource: '@lingui/vite-plugin',\n },\n };\n }\n\n // i18n-js — vite alias injection required\n // @todo syncJSON format not yet implemented for i18n-js\n if (isInstalled('i18n-js') || isInstalled('@intlayer/i18n-js')) {\n markCompatReplacement('i18n-js', '@intlayer/i18n-js');\n compatVitePluginConfig ??= {\n pluginFunctionName: 'i18nJsVitePlugin',\n pluginPackageSource: '@intlayer/i18n-js/plugin',\n };\n }\n\n if (compatSyncConfig) {\n addDevIfMissing(\n compatSyncConfig.plugin === 'po'\n ? '@intlayer/sync-po-plugin'\n : '@intlayer/sync-json-plugin'\n );\n }\n\n return {\n packagesToInstall,\n devPackagesToInstall,\n packagesToMoveToDev,\n compatSyncConfig,\n compatVitePluginConfig,\n };\n};\n\n/**\n * Runs the package install command synchronously.\n * Throws if the install process exits with a non-zero code.\n */\nexport const installPackages = (\n rootDir: string,\n packages: string[],\n packageManager: PackageManager,\n isDev: boolean = false\n): void => {\n const command = buildInstallCommand(packageManager, packages, isDev);\n execSync(command, { cwd: rootDir, stdio: 'inherit' });\n};\n\n/**\n * Determines whether a dependency name belongs to the Intlayer ecosystem.\n *\n * Matches the core `intlayer` package, every scoped `@intlayer/*` package\n * (including compat adapters such as `@intlayer/next-intl`) and the framework\n * runtime integrations that follow the `<framework>-intlayer` convention\n * (e.g. `next-intlayer`, `react-intlayer`, `express-intlayer`), as well as the\n * `intlayer-*` packages (e.g. `intlayer-editor`).\n */\nexport const isIntlayerPackageName = (packageName: string): boolean =>\n packageName === 'intlayer' ||\n packageName.startsWith('@intlayer/') ||\n packageName.startsWith('intlayer-') ||\n packageName.endsWith('-intlayer');\n\n/**\n * Reduces a semver range or full version to its `major.minor.patch` core,\n * stripping range prefixes (`^`, `~`), pre-release identifiers and build\n * metadata. Returns `null` when no `major.minor.patch` can be extracted.\n *\n * @example normalizeVersion('^9.0.0-canary.3') // '9.0.0'\n */\nexport const normalizeVersion = (version?: string): string | null => {\n if (!version || typeof version !== 'string') return null;\n\n const match = version.match(/(\\d+)\\.(\\d+)\\.(\\d+)/);\n\n return match ? `${match[1]}.${match[2]}.${match[3]}` : null;\n};\n\n/**\n * Runs the package manager install command synchronously, so edited\n * `package.json` ranges are resolved and the lock file updated. Throws if the\n * install process exits with a non-zero code.\n */\nexport const runPackageInstall = (\n rootDir: string,\n packageManager: PackageManager\n): void => {\n execSync(`${packageManager} install`, { cwd: rootDir, stdio: 'inherit' });\n};\n"],"mappings":";;;;;;AA8FA,MAAM,6BAEF;CACF,CAAC,YAAY,KAAK;CAClB,CAAC,aAAa,KAAK;CACnB,CAAC,kBAAkB,MAAM;CACzB,CAAC,aAAa,MAAM;CACpB,CAAC,qBAAqB,KAAK;AAC7B;;AAGA,MAAM,mBAA8C;CAClD;CACA;CACA;CACA;AACF;;;;;AAMA,MAAM,2BAA2B,cAA6C;CAC5E,IAAI;EACF,MAAM,EAAE,mBAAmB,KAAK,MAC9B,aAAa,KAAK,WAAW,cAAc,GAAG,MAAM,CACtD;EAEA,IAAI,OAAO,mBAAmB,UAAU,OAAO;EAE/C,MAAM,OAAO,eAAe,MAAM,GAAG,CAAC,CAAC;EACvC,OAAO,iBAAiB,SAAS,IAAI,IAAI,OAAO;CAClD,QAAQ;EACN,OAAO;CACT;AACF;;;;;;AAOA,MAAa,wBAAwB,YACnC,2BAA2B,MAAM,CAAC,cAChC,WAAW,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