@intlayer/cli 9.5.7 → 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.
- package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
- package/dist/cjs/auth/login.cjs +24 -16
- package/dist/cjs/auth/login.cjs.map +1 -1
- package/dist/cjs/build.cjs +1 -1
- package/dist/cjs/ci.cjs +1 -1
- package/dist/cjs/cli.cjs +18 -7
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +1 -1
- package/dist/cjs/editor.cjs +1 -1
- package/dist/cjs/extract.cjs +5 -5
- package/dist/cjs/fill/fill.cjs +2 -2
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +1 -1
- package/dist/cjs/fill/listTranslationsTasks.cjs +1 -1
- package/dist/cjs/fill/translateDictionary.cjs +1 -1
- package/dist/cjs/fill/writeFill.cjs +1 -1
- package/dist/cjs/getTargetDictionary.cjs +1 -1
- package/dist/cjs/index.cjs +8 -7
- package/dist/cjs/init.cjs +65 -147
- package/dist/cjs/init.cjs.map +1 -1
- package/dist/cjs/initMCP.cjs +1 -25
- package/dist/cjs/initMCP.cjs.map +1 -1
- package/dist/cjs/initSkills.cjs +36 -27
- package/dist/cjs/initSkills.cjs.map +1 -1
- package/dist/cjs/listContentDeclaration.cjs +2 -2
- package/dist/cjs/liveSync.cjs +4 -4
- package/dist/cjs/pull.cjs +4 -4
- package/dist/cjs/push/push.cjs +5 -5
- package/dist/cjs/pushConfig.cjs +1 -1
- package/dist/cjs/reviewDoc/reviewDoc.cjs +3 -3
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +3 -3
- package/dist/cjs/reviewDoc/reviewDocLog.cjs +1 -1
- package/dist/cjs/searchDoc.cjs +1 -1
- package/dist/cjs/test/listMissingTranslations.cjs +1 -1
- package/dist/cjs/test/test.cjs +1 -1
- package/dist/cjs/translateDoc/translateDoc.cjs +2 -2
- package/dist/cjs/translateDoc/translateFile.cjs +2 -2
- package/dist/cjs/upgrade.cjs +18 -0
- package/dist/cjs/upgrade.cjs.map +1 -0
- package/dist/cjs/utils/getOutputFilePath.cjs +1 -1
- package/dist/cjs/utils/getParentPackageJSON.cjs +1 -1
- package/dist/cjs/watch.cjs +1 -1
- package/dist/esm/_virtual/_utils_asset.mjs +1 -1
- package/dist/esm/auth/login.mjs +23 -15
- package/dist/esm/auth/login.mjs.map +1 -1
- package/dist/esm/build.mjs +1 -1
- package/dist/esm/ci.mjs +1 -1
- package/dist/esm/cli.mjs +19 -8
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +1 -1
- package/dist/esm/editor.mjs +1 -1
- package/dist/esm/extract.mjs +6 -6
- package/dist/esm/extract.mjs.map +1 -1
- package/dist/esm/fill/fill.mjs +4 -4
- package/dist/esm/fill/fill.mjs.map +1 -1
- package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -1
- package/dist/esm/fill/listTranslationsTasks.mjs +1 -1
- package/dist/esm/fill/translateDictionary.mjs +1 -1
- package/dist/esm/fill/writeFill.mjs +1 -1
- package/dist/esm/getTargetDictionary.mjs +1 -1
- package/dist/esm/index.mjs +9 -9
- package/dist/esm/init.mjs +67 -147
- package/dist/esm/init.mjs.map +1 -1
- package/dist/esm/initMCP.mjs +3 -25
- package/dist/esm/initMCP.mjs.map +1 -1
- package/dist/esm/initSkills.mjs +36 -28
- package/dist/esm/initSkills.mjs.map +1 -1
- package/dist/esm/listContentDeclaration.mjs +2 -2
- package/dist/esm/liveSync.mjs +3 -3
- package/dist/esm/pull.mjs +4 -4
- package/dist/esm/push/push.mjs +7 -7
- package/dist/esm/push/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +1 -1
- package/dist/esm/reviewDoc/reviewDoc.mjs +3 -3
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +3 -3
- package/dist/esm/reviewDoc/reviewDocLog.mjs +1 -1
- package/dist/esm/searchDoc.mjs +1 -1
- package/dist/esm/test/listMissingTranslations.mjs +1 -1
- package/dist/esm/test/test.mjs +1 -1
- package/dist/esm/translateDoc/translateDoc.mjs +2 -2
- package/dist/esm/translateDoc/translateFile.mjs +2 -2
- package/dist/esm/upgrade.mjs +17 -0
- package/dist/esm/upgrade.mjs.map +1 -0
- package/dist/esm/utils/getOutputFilePath.mjs +1 -1
- package/dist/esm/utils/getParentPackageJSON.mjs +1 -1
- package/dist/esm/watch.mjs +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/initMCP.d.ts.map +1 -1
- package/dist/types/initSkills.d.ts +11 -1
- package/dist/types/initSkills.d.ts.map +1 -1
- package/dist/types/upgrade.d.ts +9 -0
- package/dist/types/upgrade.d.ts.map +1 -0
- package/package.json +10 -10
- package/dist/cjs/initBuildOptimization.cjs +0 -80
- package/dist/cjs/initBuildOptimization.cjs.map +0 -1
- package/dist/cjs/initCompiler.cjs +0 -77
- package/dist/cjs/initCompiler.cjs.map +0 -1
- package/dist/esm/initBuildOptimization.mjs +0 -79
- package/dist/esm/initBuildOptimization.mjs.map +0 -1
- package/dist/esm/initCompiler.mjs +0 -76
- package/dist/esm/initCompiler.mjs.map +0 -1
- package/dist/types/initBuildOptimization.d.ts +0 -19
- package/dist/types/initBuildOptimization.d.ts.map +0 -1
- package/dist/types/initCompiler.d.ts +0 -20
- package/dist/types/initCompiler.d.ts.map +0 -1
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { loadPrompts } from "./loadPrompts.mjs";
|
|
2
|
-
import { findProjectRoot } from "./init.mjs";
|
|
3
|
-
import { join, resolve } from "node:path";
|
|
4
|
-
import { NEXT_INTLAYER_BABEL_CONFIG_CONTENT, detectPackageManager, installPackages } from "@intlayer/engine/cli";
|
|
5
|
-
import { existsSync, writeFileSync } from "node:fs";
|
|
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 { join, resolve } from "node:path";
|
|
4
|
-
import { detectPackageManager, installPackages } from "@intlayer/engine/cli";
|
|
5
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
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"}
|