@intlayer/cli 9.5.6 → 9.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/cjs/auth/login.cjs +20 -12
  2. package/dist/cjs/auth/login.cjs.map +1 -1
  3. package/dist/cjs/cli.cjs +21 -6
  4. package/dist/cjs/cli.cjs.map +1 -1
  5. package/dist/cjs/index.cjs +9 -2
  6. package/dist/cjs/init.cjs +66 -135
  7. package/dist/cjs/init.cjs.map +1 -1
  8. package/dist/cjs/initInfra.cjs +105 -0
  9. package/dist/cjs/initInfra.cjs.map +1 -0
  10. package/dist/cjs/initMCP.cjs +1 -25
  11. package/dist/cjs/initMCP.cjs.map +1 -1
  12. package/dist/cjs/initSkills.cjs +35 -26
  13. package/dist/cjs/initSkills.cjs.map +1 -1
  14. package/dist/cjs/upgrade.cjs +18 -0
  15. package/dist/cjs/upgrade.cjs.map +1 -0
  16. package/dist/esm/auth/login.mjs +20 -12
  17. package/dist/esm/auth/login.mjs.map +1 -1
  18. package/dist/esm/cli.mjs +22 -7
  19. package/dist/esm/cli.mjs.map +1 -1
  20. package/dist/esm/index.mjs +4 -3
  21. package/dist/esm/init.mjs +68 -135
  22. package/dist/esm/init.mjs.map +1 -1
  23. package/dist/esm/initInfra.mjs +100 -0
  24. package/dist/esm/initInfra.mjs.map +1 -0
  25. package/dist/esm/initMCP.mjs +3 -25
  26. package/dist/esm/initMCP.mjs.map +1 -1
  27. package/dist/esm/initSkills.mjs +35 -27
  28. package/dist/esm/initSkills.mjs.map +1 -1
  29. package/dist/esm/upgrade.mjs +17 -0
  30. package/dist/esm/upgrade.mjs.map +1 -0
  31. package/dist/types/index.d.ts +3 -2
  32. package/dist/types/init.d.ts.map +1 -1
  33. package/dist/types/initInfra.d.ts +32 -0
  34. package/dist/types/initInfra.d.ts.map +1 -0
  35. package/dist/types/initMCP.d.ts.map +1 -1
  36. package/dist/types/initSkills.d.ts +11 -1
  37. package/dist/types/initSkills.d.ts.map +1 -1
  38. package/dist/types/upgrade.d.ts +9 -0
  39. package/dist/types/upgrade.d.ts.map +1 -0
  40. package/package.json +10 -10
  41. package/dist/cjs/initBuildOptimization.cjs +0 -80
  42. package/dist/cjs/initBuildOptimization.cjs.map +0 -1
  43. package/dist/cjs/initCompiler.cjs +0 -77
  44. package/dist/cjs/initCompiler.cjs.map +0 -1
  45. package/dist/esm/initBuildOptimization.mjs +0 -79
  46. package/dist/esm/initBuildOptimization.mjs.map +0 -1
  47. package/dist/esm/initCompiler.mjs +0 -76
  48. package/dist/esm/initCompiler.mjs.map +0 -1
  49. package/dist/types/initBuildOptimization.d.ts +0 -19
  50. package/dist/types/initBuildOptimization.d.ts.map +0 -1
  51. package/dist/types/initCompiler.d.ts +0 -20
  52. package/dist/types/initCompiler.d.ts.map +0 -1
@@ -0,0 +1,17 @@
1
+ import { findProjectRoot } from "./init.mjs";
2
+ import { resolve } from "node:path";
3
+ import { upgradeIntlayerPackages } from "@intlayer/engine/cli";
4
+
5
+ //#region src/upgrade.ts
6
+ /**
7
+ * Lists the Intlayer packages of every `package.json` of the project and
8
+ * upgrades them to the version of the given dist-tag.
9
+ */
10
+ const upgrade = async (projectRoot, options) => {
11
+ const root = findProjectRoot(projectRoot ? resolve(projectRoot) : process.cwd());
12
+ await upgradeIntlayerPackages(root, options);
13
+ };
14
+
15
+ //#endregion
16
+ export { upgrade };
17
+ //# sourceMappingURL=upgrade.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade.mjs","names":[],"sources":["../../src/upgrade.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport {\n type UpgradeIntlayerPackagesOptions,\n upgradeIntlayerPackages,\n} from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\n\n/**\n * Lists the Intlayer packages of every `package.json` of the project and\n * upgrades them to the version of the given dist-tag.\n */\nexport const upgrade = async (\n projectRoot?: string,\n options?: UpgradeIntlayerPackagesOptions\n) => {\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n await upgradeIntlayerPackages(root, options);\n};\n"],"mappings":";;;;;;;;;AAWA,MAAa,UAAU,OACrB,aACA,YACG;CACH,MAAM,OAAO,gBACX,cAAc,QAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,MAAM,wBAAwB,MAAM,OAAO;AAC7C"}
@@ -5,7 +5,8 @@ import { startEditor } from "./editor.js";
5
5
  import { extract } from "./extract.js";
6
6
  import { FillOptions, fill } from "./fill/fill.js";
7
7
  import { findProjectRoot, init } from "./init.js";
8
- import { PLATFORM_OPTIONS, getDetectedPlatform, initSkills } from "./initSkills.js";
8
+ import { INFRA_MODES, INSTALL_SCRIPT_URL, INSTALL_SCRIPT_URL_WINDOWS, InfraMode, InitInfraOptions, initInfra, parseInfraMode } from "./initInfra.js";
9
+ import { PLATFORM_OPTIONS, getDetectedPlatform, initSkills, promptPlatform } from "./initSkills.js";
9
10
  import { listContentDeclaration, listContentDeclarationRows } from "./listContentDeclaration.js";
10
11
  import { ListProjectsCommandOptions, listProjectsCommand } from "./listProjects.js";
11
12
  import { liveSync } from "./liveSync.js";
@@ -23,4 +24,4 @@ export type * from "@intlayer/engine/cli";
23
24
  export type * from "@intlayer/engine/build";
24
25
  export type * from "@intlayer/engine/utils";
25
26
  export type * from "@intlayer/engine/watcher";
26
- export { ConfigurationOptions, FillOptions, ListProjectsCommandOptions, PLATFORM_OPTIONS, ReviewDocMode, ScanCommandOptions, build, bundle, dirname, extract, fill, findProjectRoot, getDetectedPlatform, init, initSkills, listContentDeclaration, listContentDeclarationRows, listMissingTranslations, listMissingTranslationsWithConfig, listProjectsCommand, liveSync, pull, push, pushConfig, reviewDoc, scan, searchDoc, setAPI, startEditor, testMissingTranslations, translateDoc };
27
+ export { ConfigurationOptions, FillOptions, INFRA_MODES, INSTALL_SCRIPT_URL, INSTALL_SCRIPT_URL_WINDOWS, InfraMode, InitInfraOptions, ListProjectsCommandOptions, PLATFORM_OPTIONS, ReviewDocMode, ScanCommandOptions, build, bundle, dirname, extract, fill, findProjectRoot, getDetectedPlatform, init, initInfra, initSkills, listContentDeclaration, listContentDeclarationRows, listMissingTranslations, listMissingTranslationsWithConfig, listProjectsCommand, liveSync, parseInfraMode, promptPlatform, pull, push, pushConfig, reviewDoc, scan, searchDoc, setAPI, startEditor, testMissingTranslations, translateDoc };
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","names":[],"sources":["../../src/init.ts"],"mappings":";;qBAwBa,kBAAe;qBAyXf,OAAI,sBACK,UACV,aAAW,0BACA"}
1
+ {"version":3,"file":"init.d.ts","names":[],"sources":["../../src/init.ts"],"mappings":";;qBAea,kBAAe;qBA8Rf,OAAI,sBACK,UACV,aAAW,0BACA"}
@@ -0,0 +1,32 @@
1
+ //#region src/initInfra.d.ts
2
+ /** Setup modes understood by the hosted installer. */
3
+ export declare const INFRA_MODES: readonly ['desktop', 'docker', 'compose'];
4
+ export type InfraMode = (typeof INFRA_MODES)[number];
5
+ /**
6
+ * The hosted installers are the single source of truth for the infrastructure
7
+ * setup flow (desktop app, all-in-one container, Compose stack). The CLI runs
8
+ * them rather than re-implementing the same steps in JavaScript.
9
+ */
10
+ export declare const INSTALL_SCRIPT_URL = "https://intlayer.org/install.sh";
11
+ export declare const INSTALL_SCRIPT_URL_WINDOWS = "https://intlayer.org/install.ps1";
12
+ export type InitInfraOptions = {
13
+ /** Skip the interactive menu and run this mode directly. */
14
+ mode?: InfraMode;
15
+ /** Installer URL override (forks, staging). Defaults to the platform's script. */
16
+ scriptUrl?: string;
17
+ };
18
+ /**
19
+ * Validates a user-provided mode against {@link INFRA_MODES}.
20
+ *
21
+ * @throws When the value is not a known mode.
22
+ */
23
+ export declare const parseInfraMode: (value: string) => InfraMode;
24
+ /**
25
+ * Downloads the hosted installer and runs it: desktop app, all-in-one Docker
26
+ * container or Docker Compose stack, chosen interactively unless `mode` is set.
27
+ *
28
+ * Exposed as `intlayer init infra` and as a step of `intlayer init --interactive`.
29
+ */
30
+ export declare const initInfra: (options?: InitInfraOptions) => Promise<void>;
31
+ //#endregion
32
+ //# sourceMappingURL=initInfra.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initInfra.d.ts","names":[],"sources":["../../src/initInfra.ts"],"mappings":";;qBAOa;YAED,oBAAoB;;;;;;qBAOnB;qBACA;YAED;;EAEV,OAAO;;EAEP;;;;;;;qBA4CW,iBAAc,kBAAoB;;;;;;;qBA8BlC,YAAS,UACX,qBACR"}
@@ -1 +1 @@
1
- {"version":3,"file":"initMCP.d.ts","names":[],"sources":["../../src/initMCP.ts"],"mappings":";;qBAYa,UAAO,sBACE,sBACE,aAAQ"}
1
+ {"version":3,"file":"initMCP.d.ts","names":[],"sources":["../../src/initMCP.ts"],"mappings":";;qBAUa,UAAO,sBACE,sBACE,aAAQ"}
@@ -6,6 +6,16 @@ export declare const PLATFORM_OPTIONS: Array<{
6
6
  hint: string;
7
7
  }>;
8
8
  export declare const getDetectedPlatform: () => Platform | undefined;
9
- export declare const initSkills: (projectRoot?: string, preselectedPlatform?: Platform) => Promise<void>;
9
+ /**
10
+ * Asks which AI platform the user is using, preselecting the detected one.
11
+ * Resolves to `undefined` when the prompt is cancelled.
12
+ */
13
+ export declare const promptPlatform: () => Promise<Platform | undefined>;
14
+ /**
15
+ * Installs the Intlayer documentation skills. The skills are picked first, then
16
+ * the platform (unless preselected). Resolves to the platform used, so a
17
+ * following step (e.g. MCP) can reuse it without asking again.
18
+ */
19
+ export declare const initSkills: (projectRoot?: string, preselectedPlatform?: Platform) => Promise<Platform | undefined>;
10
20
  //#endregion
11
21
  //# sourceMappingURL=initSkills.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initSkills.d.ts","names":[],"sources":["../../src/initSkills.ts"],"mappings":";;qBAuBa,kBAAkB;EAC7B,OAAO;EACP;EACA;;qBAOW,2BAA0B;qBAiB1B,aAAU,sBACD,sBACE,aAAQ"}
1
+ {"version":3,"file":"initSkills.d.ts","names":[],"sources":["../../src/initSkills.ts"],"mappings":";;qBAuBa,kBAAkB;EAC7B,OAAO;EACP;EACA;;qBAOW,2BAA0B;;;;;qBAqB1B,sBAA2B,QAAQ;;;;;;qBA8BnC,aAAU,sBACD,sBACE,aACrB,QAAQ"}
@@ -0,0 +1,9 @@
1
+ import { UpgradeIntlayerPackagesOptions } from "@intlayer/engine/cli";
2
+ //#region src/upgrade.d.ts
3
+ /**
4
+ * Lists the Intlayer packages of every `package.json` of the project and
5
+ * upgrades them to the version of the given dist-tag.
6
+ */
7
+ export declare const upgrade: (projectRoot?: string, options?: UpgradeIntlayerPackagesOptions) => Promise<void>;
8
+ //#endregion
9
+ //# sourceMappingURL=upgrade.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upgrade.d.ts","names":[],"sources":["../../src/upgrade.ts"],"mappings":";;;;;;qBAWa,UAAO,sBACE,UACV,mCAA8B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/cli",
3
- "version": "9.5.6",
3
+ "version": "9.5.8",
4
4
  "private": false,
5
5
  "description": "Provides uniform command-line interface scripts for Intlayer, used in packages like intlayer-cli and intlayer.",
6
6
  "keywords": [
@@ -68,20 +68,20 @@
68
68
  },
69
69
  "dependencies": {
70
70
  "@clack/prompts": "1.7.0",
71
- "@intlayer/api": "9.5.6",
72
- "@intlayer/babel": "9.5.6",
73
- "@intlayer/config": "9.5.6",
74
- "@intlayer/core": "9.5.6",
75
- "@intlayer/dictionaries-entry": "9.5.6",
76
- "@intlayer/engine": "9.5.6",
77
- "@intlayer/types": "9.5.6",
71
+ "@intlayer/api": "9.5.8",
72
+ "@intlayer/babel": "9.5.8",
73
+ "@intlayer/config": "9.5.8",
74
+ "@intlayer/core": "9.5.8",
75
+ "@intlayer/dictionaries-entry": "9.5.8",
76
+ "@intlayer/engine": "9.5.8",
77
+ "@intlayer/types": "9.5.8",
78
78
  "commander": "15.0.0",
79
79
  "enquirer": "2.4.1",
80
80
  "eventsource": "5.1.1",
81
81
  "fast-glob": "3.3.3"
82
82
  },
83
83
  "devDependencies": {
84
- "@intlayer/ai": "9.5.6",
84
+ "@intlayer/ai": "9.5.8",
85
85
  "@types/node": "^22",
86
86
  "@utils/ts-config": "1.0.4",
87
87
  "@utils/ts-config-types": "1.0.4",
@@ -92,7 +92,7 @@
92
92
  "vitest": "5.0.1"
93
93
  },
94
94
  "peerDependencies": {
95
- "@intlayer/ai": "9.5.6"
95
+ "@intlayer/ai": "9.5.8"
96
96
  },
97
97
  "peerDependenciesMeta": {
98
98
  "@intlayer/ai": {
@@ -1,80 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_loadPrompts = require('./loadPrompts.cjs');
3
- const require_init = require('./init.cjs');
4
- let node_fs = require("node:fs");
5
- let node_path = require("node:path");
6
- let _intlayer_engine_cli = require("@intlayer/engine/cli");
7
-
8
- //#region src/initBuildOptimization.ts
9
- /** Babel config filenames Next.js picks up, ordered by preference. */
10
- const BABEL_CONFIG_CANDIDATES = [
11
- "babel.config.js",
12
- "babel.config.cjs",
13
- "babel.config.mjs",
14
- "babel.config.ts"
15
- ];
16
- /**
17
- * Interactive prompt to select a build optimization plugin for Next.js and
18
- * scaffold the required files. The two options are independent — pick one:
19
- *
20
- * - `@intlayer/babel` — runs the full compiler pipeline (extract, purge, minify,
21
- * optimize) through Babel. Installs `@intlayer/babel` and creates a
22
- * `babel.config.js`.
23
- * - `@intlayer/swc` — lightweight SWC plugin that rewrites `useIntlayer` imports.
24
- * Installs only the dependency; `withIntlayer` wires it in automatically, so
25
- * no config file is required.
26
- *
27
- * @param projectRoot - Optional project root; defaults to the current directory.
28
- */
29
- const initBuildOptimization = async (projectRoot) => {
30
- const p = await require_loadPrompts.loadPrompts();
31
- const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
32
- p.intro("Configuring Next.js build optimization");
33
- const plugin = await p.select({
34
- message: "Which build optimization plugin do you want to use?",
35
- options: [{
36
- value: "babel",
37
- label: "@intlayer/babel",
38
- hint: "Full pipeline — extract, purge, minify and optimize via Babel; creates babel.config.js"
39
- }, {
40
- value: "swc",
41
- label: "@intlayer/swc",
42
- hint: "Lightweight — SWC plugin that rewrites useIntlayer imports; wired automatically by withIntlayer"
43
- }]
44
- });
45
- if (p.isCancel(plugin) || !plugin) {
46
- p.cancel("Operation cancelled.");
47
- return;
48
- }
49
- const packageManager = (0, _intlayer_engine_cli.detectPackageManager)(root);
50
- const packageToInstall = plugin === "babel" ? "@intlayer/babel" : "@intlayer/swc";
51
- const spinner = p.spinner();
52
- spinner.start("Installing packages...");
53
- try {
54
- (0, _intlayer_engine_cli.installPackages)(root, [packageToInstall], packageManager, true);
55
- spinner.stop(`Installed: ${packageToInstall}`);
56
- } catch {
57
- spinner.stop("Package installation failed");
58
- p.log.warn(`Please install manually: ${packageToInstall} (dev dependency)`);
59
- }
60
- if (plugin === "swc") {
61
- p.outro("Build optimization configuration complete");
62
- return;
63
- }
64
- const existingBabelConfig = BABEL_CONFIG_CANDIDATES.find((file) => (0, node_fs.existsSync)((0, node_path.join)(root, file)));
65
- if (existingBabelConfig) {
66
- p.log.warn(`${existingBabelConfig} already exists — add the Intlayer plugins manually.`);
67
- p.note(_intlayer_engine_cli.NEXT_INTLAYER_BABEL_CONFIG_CONTENT, "Plugins to add to your babel config");
68
- } else try {
69
- (0, node_fs.writeFileSync)((0, node_path.join)(root, "babel.config.js"), _intlayer_engine_cli.NEXT_INTLAYER_BABEL_CONFIG_CONTENT, { encoding: "utf-8" });
70
- p.log.success("Created babel.config.js with the Intlayer compiler plugins (extract, purge, minify, optimize)");
71
- } catch {
72
- p.log.warn("Could not create babel.config.js — please create it manually.");
73
- p.note(_intlayer_engine_cli.NEXT_INTLAYER_BABEL_CONFIG_CONTENT, "babel.config.js");
74
- }
75
- p.outro("Build optimization configuration complete");
76
- };
77
-
78
- //#endregion
79
- exports.initBuildOptimization = initBuildOptimization;
80
- //# sourceMappingURL=initBuildOptimization.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initBuildOptimization.cjs","names":["loadPrompts","findProjectRoot","resolve","detectPackageManager","existsSync","join","NEXT_INTLAYER_BABEL_CONFIG_CONTENT"],"sources":["../../src/initBuildOptimization.ts"],"sourcesContent":["import { existsSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n detectPackageManager,\n installPackages,\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n} from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\nimport { loadPrompts } from './loadPrompts';\n\n/** Intlayer build optimization plugin choices for Next.js. */\nexport type BuildOptimizationPlugin = 'babel' | 'swc';\n\n/** Babel config filenames Next.js picks up, ordered by preference. */\nconst BABEL_CONFIG_CANDIDATES = [\n 'babel.config.js',\n 'babel.config.cjs',\n 'babel.config.mjs',\n 'babel.config.ts',\n];\n\n/**\n * Interactive prompt to select a build optimization plugin for Next.js and\n * scaffold the required files. The two options are independent — pick one:\n *\n * - `@intlayer/babel` — runs the full compiler pipeline (extract, purge, minify,\n * optimize) through Babel. Installs `@intlayer/babel` and creates a\n * `babel.config.js`.\n * - `@intlayer/swc` — lightweight SWC plugin that rewrites `useIntlayer` imports.\n * Installs only the dependency; `withIntlayer` wires it in automatically, so\n * no config file is required.\n *\n * @param projectRoot - Optional project root; defaults to the current directory.\n */\nexport const initBuildOptimization = async (\n projectRoot?: string\n): Promise<void> => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n p.intro('Configuring Next.js build optimization');\n\n const plugin = (await p.select({\n message: 'Which build optimization plugin do you want to use?',\n options: [\n {\n value: 'babel',\n label: '@intlayer/babel',\n hint: 'Full pipeline — extract, purge, minify and optimize via Babel; creates babel.config.js',\n },\n {\n value: 'swc',\n label: '@intlayer/swc',\n hint: 'Lightweight — SWC plugin that rewrites useIntlayer imports; wired automatically by withIntlayer',\n },\n ],\n })) as BuildOptimizationPlugin;\n\n if (p.isCancel(plugin) || !plugin) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const packageManager = detectPackageManager(root);\n const packageToInstall =\n plugin === 'babel' ? '@intlayer/babel' : '@intlayer/swc';\n\n const spinner = p.spinner();\n spinner.start('Installing packages...');\n\n try {\n installPackages(root, [packageToInstall], packageManager, true);\n spinner.stop(`Installed: ${packageToInstall}`);\n } catch {\n spinner.stop('Package installation failed');\n p.log.warn(`Please install manually: ${packageToInstall} (dev dependency)`);\n }\n\n // SWC needs no extra setup — withIntlayer injects the plugin at build time.\n if (plugin === 'swc') {\n p.outro('Build optimization configuration complete');\n return;\n }\n\n // BABEL — scaffold babel.config.js with the full compiler pipeline.\n const existingBabelConfig = BABEL_CONFIG_CANDIDATES.find((file) =>\n existsSync(join(root, file))\n );\n\n if (existingBabelConfig) {\n p.log.warn(\n `${existingBabelConfig} already exists — add the Intlayer plugins manually.`\n );\n p.note(\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n 'Plugins to add to your babel config'\n );\n } else {\n try {\n writeFileSync(\n join(root, 'babel.config.js'),\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n { encoding: 'utf-8' }\n );\n p.log.success(\n 'Created babel.config.js with the Intlayer compiler plugins (extract, purge, minify, optimize)'\n );\n } catch {\n p.log.warn(\n 'Could not create babel.config.js — please create it manually.'\n );\n p.note(NEXT_INTLAYER_BABEL_CONFIG_CONTENT, 'babel.config.js');\n }\n }\n\n p.outro('Build optimization configuration complete');\n};\n"],"mappings":";;;;;;;;;AAcA,MAAM,0BAA0B;CAC9B;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;AAeA,MAAa,wBAAwB,OACnC,gBACkB;CAClB,MAAM,IAAI,MAAMA,gCAAY;CAE5B,MAAM,OAAOC,6BACX,kBAAcC,mBAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CACA,EAAE,MAAM,wCAAwC;CAEhD,MAAM,SAAU,MAAM,EAAE,OAAO;EAC7B,SAAS;EACT,SAAS,CACP;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,GACA;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,CACF;CACF,CAAC;CAED,IAAI,EAAE,SAAS,MAAM,KAAK,CAAC,QAAQ;EACjC,EAAE,OAAO,sBAAsB;EAC/B;CACF;CAEA,MAAM,qBAAiBC,2CAAqB,IAAI;CAChD,MAAM,mBACJ,WAAW,UAAU,oBAAoB;CAE3C,MAAM,UAAU,EAAE,QAAQ;CAC1B,QAAQ,MAAM,wBAAwB;CAEtC,IAAI;EACF,0CAAgB,MAAM,CAAC,gBAAgB,GAAG,gBAAgB,IAAI;EAC9D,QAAQ,KAAK,cAAc,kBAAkB;CAC/C,QAAQ;EACN,QAAQ,KAAK,6BAA6B;EAC1C,EAAE,IAAI,KAAK,4BAA4B,iBAAiB,kBAAkB;CAC5E;CAGA,IAAI,WAAW,OAAO;EACpB,EAAE,MAAM,2CAA2C;EACnD;CACF;CAGA,MAAM,sBAAsB,wBAAwB,MAAM,aACxDC,wBAAWC,gBAAK,MAAM,IAAI,CAAC,CAC7B;CAEA,IAAI,qBAAqB;EACvB,EAAE,IAAI,KACJ,GAAG,oBAAoB,qDACzB;EACA,EAAE,KACAC,yDACA,qCACF;CACF,OACE,IAAI;EACF,+BACED,gBAAK,MAAM,iBAAiB,GAC5BC,yDACA,EAAE,UAAU,QAAQ,CACtB;EACA,EAAE,IAAI,QACJ,+FACF;CACF,QAAQ;EACN,EAAE,IAAI,KACJ,+DACF;EACA,EAAE,KAAKA,yDAAoC,iBAAiB;CAC9D;CAGF,EAAE,MAAM,2CAA2C;AACrD"}
@@ -1,77 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_loadPrompts = require('./loadPrompts.cjs');
3
- const require_init = require('./init.cjs');
4
- let node_fs = require("node:fs");
5
- let node_path = require("node:path");
6
- let _intlayer_engine_cli = require("@intlayer/engine/cli");
7
-
8
- //#region src/initCompiler.ts
9
- /**
10
- * Reads the project dependencies and detects which framework the compiler
11
- * should target. Next.js is checked before Vite because a Next.js project may
12
- * transitively depend on Vite tooling.
13
- */
14
- const detectCompilerFramework = (root) => {
15
- try {
16
- const packageJsonPath = (0, node_path.join)(root, "package.json");
17
- if (!(0, node_fs.existsSync)(packageJsonPath)) return "unknown";
18
- const { dependencies = {}, devDependencies = {} } = JSON.parse((0, node_fs.readFileSync)(packageJsonPath, "utf-8"));
19
- const allDependencies = {
20
- ...dependencies,
21
- ...devDependencies
22
- };
23
- if (allDependencies.next) return "nextjs";
24
- if (allDependencies.vite) return "vite";
25
- return "unknown";
26
- } catch {
27
- return "unknown";
28
- }
29
- };
30
- /**
31
- * Scaffolds the Intlayer compiler for the current project during interactive
32
- * init.
33
- *
34
- * - **Vite** — nothing to do: since v9 the compiler is built into the
35
- * `intlayer()` plugin in `vite.config.ts`, so this only confirms the setup
36
- * to the user.
37
- * - **Next.js** — installs `@intlayer/babel`, which is all that is needed:
38
- * `withIntlayer` registers `next-intlayer/extractor-loader` on both webpack
39
- * and Turbopack as soon as the package resolves. No `babel.config.js` is
40
- * written — Turbopack never reads one, and on webpack its mere presence
41
- * switches Next.js off SWC, taking the `@intlayer/swc` optimize pass with it.
42
- *
43
- * In non-interactive init this function is never called, so the compiler setup
44
- * is left untouched.
45
- */
46
- const initCompiler = async (projectRoot) => {
47
- const p = await require_loadPrompts.loadPrompts();
48
- const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
49
- const framework = detectCompilerFramework(root);
50
- if (framework === "vite") {
51
- p.log.info("Vite detected — the compiler is built into `intlayer()` in your vite.config. Nothing to configure.");
52
- return;
53
- }
54
- if (framework !== "nextjs") {
55
- p.log.warn("No supported framework detected for the compiler — skipping. See the compiler docs for manual setup.");
56
- return;
57
- }
58
- p.intro("Configuring the Intlayer compiler for Next.js");
59
- const packageManager = (0, _intlayer_engine_cli.detectPackageManager)(root);
60
- const devPackagesToInstall = ["@intlayer/babel"];
61
- const spinner = p.spinner();
62
- spinner.start("Installing packages...");
63
- try {
64
- (0, _intlayer_engine_cli.installPackages)(root, devPackagesToInstall, packageManager, true);
65
- spinner.stop(`Installed: ${devPackagesToInstall.join(", ")}`);
66
- } catch {
67
- spinner.stop("Package installation failed");
68
- p.log.warn(`Please install manually: ${devPackagesToInstall.join(" ")} (dev dependency)`);
69
- }
70
- p.log.success("The compiler runs through `withIntlayer` in your next.config — nothing else to wire up.");
71
- p.log.info("Set `compiler.enabled` in intlayer.config.ts to turn the extraction on.");
72
- p.outro("Compiler configuration complete");
73
- };
74
-
75
- //#endregion
76
- exports.initCompiler = initCompiler;
77
- //# sourceMappingURL=initCompiler.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initCompiler.cjs","names":["join","existsSync","readFileSync","loadPrompts","findProjectRoot","resolve","detectPackageManager"],"sources":["../../src/initCompiler.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { detectPackageManager, installPackages } from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\nimport { loadPrompts } from './loadPrompts';\n\n/** Framework the Intlayer compiler can be wired into during init. */\ntype CompilerFramework = 'vite' | 'nextjs' | 'unknown';\n\n/**\n * Reads the project dependencies and detects which framework the compiler\n * should target. Next.js is checked before Vite because a Next.js project may\n * transitively depend on Vite tooling.\n */\nconst detectCompilerFramework = (root: string): CompilerFramework => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return 'unknown';\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n const allDependencies = { ...dependencies, ...devDependencies };\n\n if (allDependencies.next) return 'nextjs';\n if (allDependencies.vite) return 'vite';\n\n return 'unknown';\n } catch {\n return 'unknown';\n }\n};\n\n/**\n * Scaffolds the Intlayer compiler for the current project during interactive\n * init.\n *\n * - **Vite** — nothing to do: since v9 the compiler is built into the\n * `intlayer()` plugin in `vite.config.ts`, so this only confirms the setup\n * to the user.\n * - **Next.js** — installs `@intlayer/babel`, which is all that is needed:\n * `withIntlayer` registers `next-intlayer/extractor-loader` on both webpack\n * and Turbopack as soon as the package resolves. No `babel.config.js` is\n * written — Turbopack never reads one, and on webpack its mere presence\n * switches Next.js off SWC, taking the `@intlayer/swc` optimize pass with it.\n *\n * In non-interactive init this function is never called, so the compiler setup\n * is left untouched.\n */\nexport const initCompiler = async (projectRoot?: string): Promise<void> => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n const framework = detectCompilerFramework(root);\n\n if (framework === 'vite') {\n // Since v9 the compiler is bundled inside intlayer() — nothing to scaffold.\n p.log.info(\n 'Vite detected — the compiler is built into `intlayer()` in your vite.config. Nothing to configure.'\n );\n return;\n }\n\n if (framework !== 'nextjs') {\n p.log.warn(\n 'No supported framework detected for the compiler — skipping. See the compiler docs for manual setup.'\n );\n return;\n }\n\n p.intro('Configuring the Intlayer compiler for Next.js');\n\n const packageManager = detectPackageManager(root);\n const devPackagesToInstall = ['@intlayer/babel'];\n\n const spinner = p.spinner();\n spinner.start('Installing packages...');\n\n try {\n installPackages(root, devPackagesToInstall, packageManager, true);\n spinner.stop(`Installed: ${devPackagesToInstall.join(', ')}`);\n } catch {\n spinner.stop('Package installation failed');\n p.log.warn(\n `Please install manually: ${devPackagesToInstall.join(' ')} (dev dependency)`\n );\n }\n\n p.log.success(\n 'The compiler runs through `withIntlayer` in your next.config — nothing else to wire up.'\n );\n p.log.info(\n 'Set `compiler.enabled` in intlayer.config.ts to turn the extraction on.'\n );\n\n p.outro('Compiler configuration complete');\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,2BAA2B,SAAoC;CACnE,IAAI;EACF,MAAM,sBAAkBA,gBAAK,MAAM,cAAc;EACjD,IAAI,KAACC,oBAAW,eAAe,GAAG,OAAO;EAEzC,MAAM,EAAE,eAAe,CAAC,GAAG,kBAAkB,CAAC,MAAM,KAAK,UACvDC,sBAAa,iBAAiB,OAAO,CACvC;EACA,MAAM,kBAAkB;GAAE,GAAG;GAAc,GAAG;EAAgB;EAE9D,IAAI,gBAAgB,MAAM,OAAO;EACjC,IAAI,gBAAgB,MAAM,OAAO;EAEjC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,eAAe,OAAO,gBAAwC;CACzE,MAAM,IAAI,MAAMC,gCAAY;CAE5B,MAAM,OAAOC,6BACX,kBAAcC,mBAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,MAAM,YAAY,wBAAwB,IAAI;CAE9C,IAAI,cAAc,QAAQ;EAExB,EAAE,IAAI,KACJ,oGACF;EACA;CACF;CAEA,IAAI,cAAc,UAAU;EAC1B,EAAE,IAAI,KACJ,sGACF;EACA;CACF;CAEA,EAAE,MAAM,+CAA+C;CAEvD,MAAM,qBAAiBC,2CAAqB,IAAI;CAChD,MAAM,uBAAuB,CAAC,iBAAiB;CAE/C,MAAM,UAAU,EAAE,QAAQ;CAC1B,QAAQ,MAAM,wBAAwB;CAEtC,IAAI;EACF,0CAAgB,MAAM,sBAAsB,gBAAgB,IAAI;EAChE,QAAQ,KAAK,cAAc,qBAAqB,KAAK,IAAI,GAAG;CAC9D,QAAQ;EACN,QAAQ,KAAK,6BAA6B;EAC1C,EAAE,IAAI,KACJ,4BAA4B,qBAAqB,KAAK,GAAG,EAAE,kBAC7D;CACF;CAEA,EAAE,IAAI,QACJ,yFACF;CACA,EAAE,IAAI,KACJ,yEACF;CAEA,EAAE,MAAM,iCAAiC;AAC3C"}
@@ -1,79 +0,0 @@
1
- import { loadPrompts } from "./loadPrompts.mjs";
2
- import { findProjectRoot } from "./init.mjs";
3
- import { existsSync, writeFileSync } from "node:fs";
4
- import { join, resolve } from "node:path";
5
- import { NEXT_INTLAYER_BABEL_CONFIG_CONTENT, detectPackageManager, installPackages } from "@intlayer/engine/cli";
6
-
7
- //#region src/initBuildOptimization.ts
8
- /** Babel config filenames Next.js picks up, ordered by preference. */
9
- const BABEL_CONFIG_CANDIDATES = [
10
- "babel.config.js",
11
- "babel.config.cjs",
12
- "babel.config.mjs",
13
- "babel.config.ts"
14
- ];
15
- /**
16
- * Interactive prompt to select a build optimization plugin for Next.js and
17
- * scaffold the required files. The two options are independent — pick one:
18
- *
19
- * - `@intlayer/babel` — runs the full compiler pipeline (extract, purge, minify,
20
- * optimize) through Babel. Installs `@intlayer/babel` and creates a
21
- * `babel.config.js`.
22
- * - `@intlayer/swc` — lightweight SWC plugin that rewrites `useIntlayer` imports.
23
- * Installs only the dependency; `withIntlayer` wires it in automatically, so
24
- * no config file is required.
25
- *
26
- * @param projectRoot - Optional project root; defaults to the current directory.
27
- */
28
- const initBuildOptimization = async (projectRoot) => {
29
- const p = await loadPrompts();
30
- const root = findProjectRoot(projectRoot ? resolve(projectRoot) : process.cwd());
31
- p.intro("Configuring Next.js build optimization");
32
- const plugin = await p.select({
33
- message: "Which build optimization plugin do you want to use?",
34
- options: [{
35
- value: "babel",
36
- label: "@intlayer/babel",
37
- hint: "Full pipeline — extract, purge, minify and optimize via Babel; creates babel.config.js"
38
- }, {
39
- value: "swc",
40
- label: "@intlayer/swc",
41
- hint: "Lightweight — SWC plugin that rewrites useIntlayer imports; wired automatically by withIntlayer"
42
- }]
43
- });
44
- if (p.isCancel(plugin) || !plugin) {
45
- p.cancel("Operation cancelled.");
46
- return;
47
- }
48
- const packageManager = detectPackageManager(root);
49
- const packageToInstall = plugin === "babel" ? "@intlayer/babel" : "@intlayer/swc";
50
- const spinner = p.spinner();
51
- spinner.start("Installing packages...");
52
- try {
53
- installPackages(root, [packageToInstall], packageManager, true);
54
- spinner.stop(`Installed: ${packageToInstall}`);
55
- } catch {
56
- spinner.stop("Package installation failed");
57
- p.log.warn(`Please install manually: ${packageToInstall} (dev dependency)`);
58
- }
59
- if (plugin === "swc") {
60
- p.outro("Build optimization configuration complete");
61
- return;
62
- }
63
- const existingBabelConfig = BABEL_CONFIG_CANDIDATES.find((file) => existsSync(join(root, file)));
64
- if (existingBabelConfig) {
65
- p.log.warn(`${existingBabelConfig} already exists — add the Intlayer plugins manually.`);
66
- p.note(NEXT_INTLAYER_BABEL_CONFIG_CONTENT, "Plugins to add to your babel config");
67
- } else try {
68
- writeFileSync(join(root, "babel.config.js"), NEXT_INTLAYER_BABEL_CONFIG_CONTENT, { encoding: "utf-8" });
69
- p.log.success("Created babel.config.js with the Intlayer compiler plugins (extract, purge, minify, optimize)");
70
- } catch {
71
- p.log.warn("Could not create babel.config.js — please create it manually.");
72
- p.note(NEXT_INTLAYER_BABEL_CONFIG_CONTENT, "babel.config.js");
73
- }
74
- p.outro("Build optimization configuration complete");
75
- };
76
-
77
- //#endregion
78
- export { initBuildOptimization };
79
- //# sourceMappingURL=initBuildOptimization.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initBuildOptimization.mjs","names":[],"sources":["../../src/initBuildOptimization.ts"],"sourcesContent":["import { existsSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport {\n detectPackageManager,\n installPackages,\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n} from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\nimport { loadPrompts } from './loadPrompts';\n\n/** Intlayer build optimization plugin choices for Next.js. */\nexport type BuildOptimizationPlugin = 'babel' | 'swc';\n\n/** Babel config filenames Next.js picks up, ordered by preference. */\nconst BABEL_CONFIG_CANDIDATES = [\n 'babel.config.js',\n 'babel.config.cjs',\n 'babel.config.mjs',\n 'babel.config.ts',\n];\n\n/**\n * Interactive prompt to select a build optimization plugin for Next.js and\n * scaffold the required files. The two options are independent — pick one:\n *\n * - `@intlayer/babel` — runs the full compiler pipeline (extract, purge, minify,\n * optimize) through Babel. Installs `@intlayer/babel` and creates a\n * `babel.config.js`.\n * - `@intlayer/swc` — lightweight SWC plugin that rewrites `useIntlayer` imports.\n * Installs only the dependency; `withIntlayer` wires it in automatically, so\n * no config file is required.\n *\n * @param projectRoot - Optional project root; defaults to the current directory.\n */\nexport const initBuildOptimization = async (\n projectRoot?: string\n): Promise<void> => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n p.intro('Configuring Next.js build optimization');\n\n const plugin = (await p.select({\n message: 'Which build optimization plugin do you want to use?',\n options: [\n {\n value: 'babel',\n label: '@intlayer/babel',\n hint: 'Full pipeline — extract, purge, minify and optimize via Babel; creates babel.config.js',\n },\n {\n value: 'swc',\n label: '@intlayer/swc',\n hint: 'Lightweight — SWC plugin that rewrites useIntlayer imports; wired automatically by withIntlayer',\n },\n ],\n })) as BuildOptimizationPlugin;\n\n if (p.isCancel(plugin) || !plugin) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const packageManager = detectPackageManager(root);\n const packageToInstall =\n plugin === 'babel' ? '@intlayer/babel' : '@intlayer/swc';\n\n const spinner = p.spinner();\n spinner.start('Installing packages...');\n\n try {\n installPackages(root, [packageToInstall], packageManager, true);\n spinner.stop(`Installed: ${packageToInstall}`);\n } catch {\n spinner.stop('Package installation failed');\n p.log.warn(`Please install manually: ${packageToInstall} (dev dependency)`);\n }\n\n // SWC needs no extra setup — withIntlayer injects the plugin at build time.\n if (plugin === 'swc') {\n p.outro('Build optimization configuration complete');\n return;\n }\n\n // BABEL — scaffold babel.config.js with the full compiler pipeline.\n const existingBabelConfig = BABEL_CONFIG_CANDIDATES.find((file) =>\n existsSync(join(root, file))\n );\n\n if (existingBabelConfig) {\n p.log.warn(\n `${existingBabelConfig} already exists — add the Intlayer plugins manually.`\n );\n p.note(\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n 'Plugins to add to your babel config'\n );\n } else {\n try {\n writeFileSync(\n join(root, 'babel.config.js'),\n NEXT_INTLAYER_BABEL_CONFIG_CONTENT,\n { encoding: 'utf-8' }\n );\n p.log.success(\n 'Created babel.config.js with the Intlayer compiler plugins (extract, purge, minify, optimize)'\n );\n } catch {\n p.log.warn(\n 'Could not create babel.config.js — please create it manually.'\n );\n p.note(NEXT_INTLAYER_BABEL_CONFIG_CONTENT, 'babel.config.js');\n }\n }\n\n p.outro('Build optimization configuration complete');\n};\n"],"mappings":";;;;;;;;AAcA,MAAM,0BAA0B;CAC9B;CACA;CACA;CACA;AACF;;;;;;;;;;;;;;AAeA,MAAa,wBAAwB,OACnC,gBACkB;CAClB,MAAM,IAAI,MAAM,YAAY;CAE5B,MAAM,OAAO,gBACX,cAAc,QAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CACA,EAAE,MAAM,wCAAwC;CAEhD,MAAM,SAAU,MAAM,EAAE,OAAO;EAC7B,SAAS;EACT,SAAS,CACP;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,GACA;GACE,OAAO;GACP,OAAO;GACP,MAAM;EACR,CACF;CACF,CAAC;CAED,IAAI,EAAE,SAAS,MAAM,KAAK,CAAC,QAAQ;EACjC,EAAE,OAAO,sBAAsB;EAC/B;CACF;CAEA,MAAM,iBAAiB,qBAAqB,IAAI;CAChD,MAAM,mBACJ,WAAW,UAAU,oBAAoB;CAE3C,MAAM,UAAU,EAAE,QAAQ;CAC1B,QAAQ,MAAM,wBAAwB;CAEtC,IAAI;EACF,gBAAgB,MAAM,CAAC,gBAAgB,GAAG,gBAAgB,IAAI;EAC9D,QAAQ,KAAK,cAAc,kBAAkB;CAC/C,QAAQ;EACN,QAAQ,KAAK,6BAA6B;EAC1C,EAAE,IAAI,KAAK,4BAA4B,iBAAiB,kBAAkB;CAC5E;CAGA,IAAI,WAAW,OAAO;EACpB,EAAE,MAAM,2CAA2C;EACnD;CACF;CAGA,MAAM,sBAAsB,wBAAwB,MAAM,SACxD,WAAW,KAAK,MAAM,IAAI,CAAC,CAC7B;CAEA,IAAI,qBAAqB;EACvB,EAAE,IAAI,KACJ,GAAG,oBAAoB,qDACzB;EACA,EAAE,KACA,oCACA,qCACF;CACF,OACE,IAAI;EACF,cACE,KAAK,MAAM,iBAAiB,GAC5B,oCACA,EAAE,UAAU,QAAQ,CACtB;EACA,EAAE,IAAI,QACJ,+FACF;CACF,QAAQ;EACN,EAAE,IAAI,KACJ,+DACF;EACA,EAAE,KAAK,oCAAoC,iBAAiB;CAC9D;CAGF,EAAE,MAAM,2CAA2C;AACrD"}
@@ -1,76 +0,0 @@
1
- import { loadPrompts } from "./loadPrompts.mjs";
2
- import { findProjectRoot } from "./init.mjs";
3
- import { existsSync, readFileSync } from "node:fs";
4
- import { join, resolve } from "node:path";
5
- import { detectPackageManager, installPackages } from "@intlayer/engine/cli";
6
-
7
- //#region src/initCompiler.ts
8
- /**
9
- * Reads the project dependencies and detects which framework the compiler
10
- * should target. Next.js is checked before Vite because a Next.js project may
11
- * transitively depend on Vite tooling.
12
- */
13
- const detectCompilerFramework = (root) => {
14
- try {
15
- const packageJsonPath = join(root, "package.json");
16
- if (!existsSync(packageJsonPath)) return "unknown";
17
- const { dependencies = {}, devDependencies = {} } = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
18
- const allDependencies = {
19
- ...dependencies,
20
- ...devDependencies
21
- };
22
- if (allDependencies.next) return "nextjs";
23
- if (allDependencies.vite) return "vite";
24
- return "unknown";
25
- } catch {
26
- return "unknown";
27
- }
28
- };
29
- /**
30
- * Scaffolds the Intlayer compiler for the current project during interactive
31
- * init.
32
- *
33
- * - **Vite** — nothing to do: since v9 the compiler is built into the
34
- * `intlayer()` plugin in `vite.config.ts`, so this only confirms the setup
35
- * to the user.
36
- * - **Next.js** — installs `@intlayer/babel`, which is all that is needed:
37
- * `withIntlayer` registers `next-intlayer/extractor-loader` on both webpack
38
- * and Turbopack as soon as the package resolves. No `babel.config.js` is
39
- * written — Turbopack never reads one, and on webpack its mere presence
40
- * switches Next.js off SWC, taking the `@intlayer/swc` optimize pass with it.
41
- *
42
- * In non-interactive init this function is never called, so the compiler setup
43
- * is left untouched.
44
- */
45
- const initCompiler = async (projectRoot) => {
46
- const p = await loadPrompts();
47
- const root = findProjectRoot(projectRoot ? resolve(projectRoot) : process.cwd());
48
- const framework = detectCompilerFramework(root);
49
- if (framework === "vite") {
50
- p.log.info("Vite detected — the compiler is built into `intlayer()` in your vite.config. Nothing to configure.");
51
- return;
52
- }
53
- if (framework !== "nextjs") {
54
- p.log.warn("No supported framework detected for the compiler — skipping. See the compiler docs for manual setup.");
55
- return;
56
- }
57
- p.intro("Configuring the Intlayer compiler for Next.js");
58
- const packageManager = detectPackageManager(root);
59
- const devPackagesToInstall = ["@intlayer/babel"];
60
- const spinner = p.spinner();
61
- spinner.start("Installing packages...");
62
- try {
63
- installPackages(root, devPackagesToInstall, packageManager, true);
64
- spinner.stop(`Installed: ${devPackagesToInstall.join(", ")}`);
65
- } catch {
66
- spinner.stop("Package installation failed");
67
- p.log.warn(`Please install manually: ${devPackagesToInstall.join(" ")} (dev dependency)`);
68
- }
69
- p.log.success("The compiler runs through `withIntlayer` in your next.config — nothing else to wire up.");
70
- p.log.info("Set `compiler.enabled` in intlayer.config.ts to turn the extraction on.");
71
- p.outro("Compiler configuration complete");
72
- };
73
-
74
- //#endregion
75
- export { initCompiler };
76
- //# sourceMappingURL=initCompiler.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initCompiler.mjs","names":[],"sources":["../../src/initCompiler.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport { detectPackageManager, installPackages } from '@intlayer/engine/cli';\nimport { findProjectRoot } from './init';\nimport { loadPrompts } from './loadPrompts';\n\n/** Framework the Intlayer compiler can be wired into during init. */\ntype CompilerFramework = 'vite' | 'nextjs' | 'unknown';\n\n/**\n * Reads the project dependencies and detects which framework the compiler\n * should target. Next.js is checked before Vite because a Next.js project may\n * transitively depend on Vite tooling.\n */\nconst detectCompilerFramework = (root: string): CompilerFramework => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return 'unknown';\n\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n const allDependencies = { ...dependencies, ...devDependencies };\n\n if (allDependencies.next) return 'nextjs';\n if (allDependencies.vite) return 'vite';\n\n return 'unknown';\n } catch {\n return 'unknown';\n }\n};\n\n/**\n * Scaffolds the Intlayer compiler for the current project during interactive\n * init.\n *\n * - **Vite** — nothing to do: since v9 the compiler is built into the\n * `intlayer()` plugin in `vite.config.ts`, so this only confirms the setup\n * to the user.\n * - **Next.js** — installs `@intlayer/babel`, which is all that is needed:\n * `withIntlayer` registers `next-intlayer/extractor-loader` on both webpack\n * and Turbopack as soon as the package resolves. No `babel.config.js` is\n * written — Turbopack never reads one, and on webpack its mere presence\n * switches Next.js off SWC, taking the `@intlayer/swc` optimize pass with it.\n *\n * In non-interactive init this function is never called, so the compiler setup\n * is left untouched.\n */\nexport const initCompiler = async (projectRoot?: string): Promise<void> => {\n const p = await loadPrompts();\n\n const root = findProjectRoot(\n projectRoot ? resolve(projectRoot) : process.cwd()\n );\n\n const framework = detectCompilerFramework(root);\n\n if (framework === 'vite') {\n // Since v9 the compiler is bundled inside intlayer() — nothing to scaffold.\n p.log.info(\n 'Vite detected — the compiler is built into `intlayer()` in your vite.config. Nothing to configure.'\n );\n return;\n }\n\n if (framework !== 'nextjs') {\n p.log.warn(\n 'No supported framework detected for the compiler — skipping. See the compiler docs for manual setup.'\n );\n return;\n }\n\n p.intro('Configuring the Intlayer compiler for Next.js');\n\n const packageManager = detectPackageManager(root);\n const devPackagesToInstall = ['@intlayer/babel'];\n\n const spinner = p.spinner();\n spinner.start('Installing packages...');\n\n try {\n installPackages(root, devPackagesToInstall, packageManager, true);\n spinner.stop(`Installed: ${devPackagesToInstall.join(', ')}`);\n } catch {\n spinner.stop('Package installation failed');\n p.log.warn(\n `Please install manually: ${devPackagesToInstall.join(' ')} (dev dependency)`\n );\n }\n\n p.log.success(\n 'The compiler runs through `withIntlayer` in your next.config — nothing else to wire up.'\n );\n p.log.info(\n 'Set `compiler.enabled` in intlayer.config.ts to turn the extraction on.'\n );\n\n p.outro('Compiler configuration complete');\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAM,2BAA2B,SAAoC;CACnE,IAAI;EACF,MAAM,kBAAkB,KAAK,MAAM,cAAc;EACjD,IAAI,CAAC,WAAW,eAAe,GAAG,OAAO;EAEzC,MAAM,EAAE,eAAe,CAAC,GAAG,kBAAkB,CAAC,MAAM,KAAK,MACvD,aAAa,iBAAiB,OAAO,CACvC;EACA,MAAM,kBAAkB;GAAE,GAAG;GAAc,GAAG;EAAgB;EAE9D,IAAI,gBAAgB,MAAM,OAAO;EACjC,IAAI,gBAAgB,MAAM,OAAO;EAEjC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;;;;;;;AAkBA,MAAa,eAAe,OAAO,gBAAwC;CACzE,MAAM,IAAI,MAAM,YAAY;CAE5B,MAAM,OAAO,gBACX,cAAc,QAAQ,WAAW,IAAI,QAAQ,IAAI,CACnD;CAEA,MAAM,YAAY,wBAAwB,IAAI;CAE9C,IAAI,cAAc,QAAQ;EAExB,EAAE,IAAI,KACJ,oGACF;EACA;CACF;CAEA,IAAI,cAAc,UAAU;EAC1B,EAAE,IAAI,KACJ,sGACF;EACA;CACF;CAEA,EAAE,MAAM,+CAA+C;CAEvD,MAAM,iBAAiB,qBAAqB,IAAI;CAChD,MAAM,uBAAuB,CAAC,iBAAiB;CAE/C,MAAM,UAAU,EAAE,QAAQ;CAC1B,QAAQ,MAAM,wBAAwB;CAEtC,IAAI;EACF,gBAAgB,MAAM,sBAAsB,gBAAgB,IAAI;EAChE,QAAQ,KAAK,cAAc,qBAAqB,KAAK,IAAI,GAAG;CAC9D,QAAQ;EACN,QAAQ,KAAK,6BAA6B;EAC1C,EAAE,IAAI,KACJ,4BAA4B,qBAAqB,KAAK,GAAG,EAAE,kBAC7D;CACF;CAEA,EAAE,IAAI,QACJ,yFACF;CACA,EAAE,IAAI,KACJ,yEACF;CAEA,EAAE,MAAM,iCAAiC;AAC3C"}
@@ -1,19 +0,0 @@
1
- //#region src/initBuildOptimization.d.ts
2
- /** Intlayer build optimization plugin choices for Next.js. */
3
- export type BuildOptimizationPlugin = 'babel' | 'swc';
4
- /**
5
- * Interactive prompt to select a build optimization plugin for Next.js and
6
- * scaffold the required files. The two options are independent — pick one:
7
- *
8
- * - `@intlayer/babel` — runs the full compiler pipeline (extract, purge, minify,
9
- * optimize) through Babel. Installs `@intlayer/babel` and creates a
10
- * `babel.config.js`.
11
- * - `@intlayer/swc` — lightweight SWC plugin that rewrites `useIntlayer` imports.
12
- * Installs only the dependency; `withIntlayer` wires it in automatically, so
13
- * no config file is required.
14
- *
15
- * @param projectRoot - Optional project root; defaults to the current directory.
16
- */
17
- export declare const initBuildOptimization: (projectRoot?: string) => Promise<void>;
18
- //#endregion
19
- //# sourceMappingURL=initBuildOptimization.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initBuildOptimization.d.ts","names":[],"sources":["../../src/initBuildOptimization.ts"],"mappings":";;YAWY;;;;;;;;;;;;;;qBAuBC,wBAAqB,yBAE/B"}
@@ -1,20 +0,0 @@
1
- //#region src/initCompiler.d.ts
2
- /**
3
- * Scaffolds the Intlayer compiler for the current project during interactive
4
- * init.
5
- *
6
- * - **Vite** — nothing to do: since v9 the compiler is built into the
7
- * `intlayer()` plugin in `vite.config.ts`, so this only confirms the setup
8
- * to the user.
9
- * - **Next.js** — installs `@intlayer/babel`, which is all that is needed:
10
- * `withIntlayer` registers `next-intlayer/extractor-loader` on both webpack
11
- * and Turbopack as soon as the package resolves. No `babel.config.js` is
12
- * written — Turbopack never reads one, and on webpack its mere presence
13
- * switches Next.js off SWC, taking the `@intlayer/swc` optimize pass with it.
14
- *
15
- * In non-interactive init this function is never called, so the compiler setup
16
- * is left untouched.
17
- */
18
- export declare const initCompiler: (projectRoot?: string) => Promise<void>;
19
- //#endregion
20
- //# sourceMappingURL=initCompiler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initCompiler.d.ts","names":[],"sources":["../../src/initCompiler.ts"],"mappings":";;;;;;;;;;;;;;;;;qBAiDa,eAAY,yBAAiC"}