@intlayer/cli 9.0.0-canary.5 → 9.0.0-canary.7
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/init.cjs +31 -16
- package/dist/cjs/init.cjs.map +1 -1
- package/dist/cjs/initCompiler.cjs +6 -5
- package/dist/cjs/initCompiler.cjs.map +1 -1
- package/dist/esm/init.mjs +31 -16
- package/dist/esm/init.mjs.map +1 -1
- package/dist/esm/initCompiler.mjs +6 -5
- package/dist/esm/initCompiler.mjs.map +1 -1
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/initCompiler.d.ts +3 -3
- package/dist/types/initCompiler.d.ts.map +1 -1
- package/package.json +12 -12
package/dist/cjs/init.cjs
CHANGED
|
@@ -106,6 +106,17 @@ const isNextJsProject = (root) => Boolean(getProjectDependencies(root).next);
|
|
|
106
106
|
/** Returns true when the project at `root` depends on Vite. */
|
|
107
107
|
const isViteProject = (root) => Boolean(getProjectDependencies(root).vite);
|
|
108
108
|
/**
|
|
109
|
+
* Returns true when the project uses a URL-based router for which a locale
|
|
110
|
+
* routing strategy is meaningful: Next.js, React Router, or TanStack Router.
|
|
111
|
+
* Apps without URL routing (e.g. React Native / Expo) are excluded, since
|
|
112
|
+
* `routing.mode` has no effect there.
|
|
113
|
+
*/
|
|
114
|
+
const hasUrlRouting = (root) => {
|
|
115
|
+
const deps = getProjectDependencies(root);
|
|
116
|
+
if (deps["react-native"] || deps.expo) return false;
|
|
117
|
+
return Boolean(deps.next || deps["react-router"] || deps["react-router-dom"] || deps["@tanstack/react-router"] || deps["@tanstack/react-start"]);
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
109
120
|
* Runs `init` in interactive mode: prompts the user with a checkbox of setup
|
|
110
121
|
* steps, then forwards the selection to {@link initIntlayer} (packages,
|
|
111
122
|
* .gitignore, GitHub Actions, VS Code extension, LSP) and runs the dedicated
|
|
@@ -136,22 +147,18 @@ const runInteractiveInit = async (root, baseOptions) => {
|
|
|
136
147
|
return;
|
|
137
148
|
}
|
|
138
149
|
const steps = selected;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
152
|
-
if (_clack_prompts.isCancel(shouldSetUpCms)) {
|
|
153
|
-
_clack_prompts.cancel("Operation cancelled.");
|
|
154
|
-
return;
|
|
150
|
+
let routingMode;
|
|
151
|
+
if (hasUrlRouting(root)) {
|
|
152
|
+
const selectedRoutingMode = await _clack_prompts.select({
|
|
153
|
+
message: "Which locale routing strategy do you want?",
|
|
154
|
+
options: ROUTING_MODE_OPTIONS,
|
|
155
|
+
initialValue: "prefix-no-default"
|
|
156
|
+
});
|
|
157
|
+
if (_clack_prompts.isCancel(selectedRoutingMode)) {
|
|
158
|
+
_clack_prompts.cancel("Operation cancelled.");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
routingMode = selectedRoutingMode;
|
|
155
162
|
}
|
|
156
163
|
await (0, _intlayer_chokidar_cli.initIntlayer)(root, {
|
|
157
164
|
...baseOptions,
|
|
@@ -189,6 +196,14 @@ const runInteractiveInit = async (root, baseOptions) => {
|
|
|
189
196
|
if (steps.includes("mcp")) await require_initMCP.initMCP(root, sharedPlatform);
|
|
190
197
|
if (steps.includes("compiler")) await require_initCompiler.initCompiler(root);
|
|
191
198
|
if (steps.includes("buildOptimization")) await require_initBuildOptimization.initBuildOptimization(root);
|
|
199
|
+
const shouldSetUpCms = await _clack_prompts.confirm({
|
|
200
|
+
message: "Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)",
|
|
201
|
+
initialValue: false
|
|
202
|
+
});
|
|
203
|
+
if (_clack_prompts.isCancel(shouldSetUpCms)) {
|
|
204
|
+
_clack_prompts.cancel("Operation cancelled.");
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
192
207
|
if (shouldSetUpCms) {
|
|
193
208
|
_clack_prompts.log.info("Opening your browser to log in to the Intlayer CMS...");
|
|
194
209
|
await require_auth_login.login({
|
package/dist/cjs/init.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.cjs","names":["p","getDetectedPlatform","PLATFORMS","PLATFORM_OPTIONS","initSkills","initMCP","initCompiler","initBuildOptimization","login"],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n type InitOptions,\n initIntlayer,\n PLATFORMS,\n type Platform,\n type RoutingMode,\n setupCmsCredentials,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { login } from './auth/login';\nimport { initBuildOptimization } from './initBuildOptimization';\nimport { initCompiler } from './initCompiler';\nimport { initMCP } from './initMCP';\nimport {\n getDetectedPlatform,\n initSkills,\n PLATFORM_OPTIONS,\n} from './initSkills';\n\nexport const findProjectRoot = (startDir: string) => {\n let currentDir = startDir;\n\n while (currentDir !== resolve(currentDir, '..')) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = resolve(currentDir, '..');\n }\n\n // If no package.json is found, return the start directory.\n // The initIntlayer function will handle the missing package.json error.\n return startDir;\n};\n\n/** Individually selectable setup steps exposed by the interactive init flow. */\ntype InitStep =\n | 'packages'\n | 'gitignore'\n | 'githubActions'\n | 'frameworkSetup'\n | 'vscodeExtension'\n | 'lsp'\n | 'skills'\n | 'mcp'\n | 'compiler'\n | 'buildOptimization';\n\nconst BASE_INIT_STEP_OPTIONS: Array<{\n value: InitStep;\n label: string;\n hint: string;\n}> = [\n {\n value: 'packages',\n label: 'Install & upgrade packages',\n hint: 'install missing Intlayer dependencies and upgrade outdated ones',\n },\n {\n value: 'gitignore',\n label: '.gitignore entry',\n hint: 'add .intlayer to .gitignore',\n },\n {\n value: 'githubActions',\n label: 'CI/CD (GitHub Actions)',\n hint: 'scaffold the fill and test workflows that run on every pull request',\n },\n {\n value: 'frameworkSetup',\n label: 'Framework setup',\n hint: 'middleware/proxy and providers in layout/page',\n },\n {\n value: 'vscodeExtension',\n label: 'VS Code extension',\n hint: 'recommend the Intlayer extension',\n },\n {\n value: 'lsp',\n label: 'Editor LSP',\n hint: 'go-to-definition from keys to .content files',\n },\n {\n value: 'skills',\n label: 'AI skills',\n hint: 'install the Intlayer documentation as agent skills',\n },\n {\n value: 'mcp',\n label: 'MCP server',\n hint: 'configure the Intlayer MCP server',\n },\n];\n\n/** Locale routing strategies offered by the interactive init flow. */\nconst ROUTING_MODE_OPTIONS: Array<{\n value: RoutingMode;\n label: string;\n hint: string;\n}> = [\n {\n value: 'prefix-no-default',\n label: 'Prefix all except the default locale',\n hint: '/about, /fr/about (default)',\n },\n {\n value: 'prefix-all',\n label: 'Prefix all locales',\n hint: '/en/about, /fr/about',\n },\n {\n value: 'no-prefix',\n label: 'No locale in the URL',\n hint: '/about',\n },\n {\n value: 'search-params',\n label: 'Use a search parameter',\n hint: '/about?locale=fr',\n },\n];\n\n/** Reads the merged dependencies of the project at `root`. */\nconst getProjectDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\n/** Returns true when the project at `root` depends on Next.js. */\nconst isNextJsProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).next);\n\n/** Returns true when the project at `root` depends on Vite. */\nconst isViteProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).vite);\n\n/**\n * Runs `init` in interactive mode: prompts the user with a checkbox of setup\n * steps, then forwards the selection to {@link initIntlayer} (packages,\n * .gitignore, GitHub Actions, VS Code extension, LSP) and runs the dedicated\n * skills/MCP installers for the steps that own their own prompts.\n */\nconst runInteractiveInit = async (\n root: string,\n baseOptions?: InitOptions\n): Promise<void> => {\n p.intro('Initialize Intlayer');\n\n const stepOptions = [...BASE_INIT_STEP_OPTIONS];\n\n const nextJsProject = isNextJsProject(root);\n\n // The compiler is plugged in directly on Vite; on Next.js it needs a Babel\n // config. Only offer the step when one of those frameworks is detected.\n if (nextJsProject || isViteProject(root)) {\n stepOptions.push({\n value: 'compiler',\n label: 'Compiler',\n hint: nextJsProject\n ? 'add the Babel compiler config to extract inline content (Next.js)'\n : 'auto-extract inline content at build time (already plugged in on Vite)',\n });\n }\n\n if (nextJsProject) {\n stepOptions.push({\n value: 'buildOptimization',\n label: 'Bundle optimization',\n hint: 'choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)',\n });\n }\n\n const selected = await p.multiselect<InitStep>({\n message: 'Select what you want to set up:',\n options: stepOptions,\n initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),\n required: false,\n });\n\n if (p.isCancel(selected)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const steps = selected as InitStep[];\n\n // Locale routing strategy → written to `routing.mode` in the config file.\n const routingMode = await p.select<RoutingMode>({\n message: 'Which locale routing strategy do you want?',\n options: ROUTING_MODE_OPTIONS,\n initialValue: 'prefix-no-default',\n });\n\n if (p.isCancel(routingMode)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n // CMS / visual editor: opt-in browser login that persists the access-key\n // credentials to `.env` and enables the editor in the config file.\n const shouldSetUpCms = await p.confirm({\n message:\n 'Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)',\n initialValue: false,\n });\n\n if (p.isCancel(shouldSetUpCms)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const options: InitOptions = {\n ...baseOptions,\n routingMode,\n noInstallPackages: !steps.includes('packages'),\n // Respect explicit `--no-*` flags from the command line even when the\n // corresponding step is selected in the checkbox.\n noGitignore: baseOptions?.noGitignore || !steps.includes('gitignore'),\n noGithubActions:\n baseOptions?.noGithubActions || !steps.includes('githubActions'),\n noFrameworkSetup:\n baseOptions?.noFrameworkSetup || !steps.includes('frameworkSetup'),\n noVscodeExtension: !steps.includes('vscodeExtension'),\n noLsp: !steps.includes('lsp'),\n };\n\n await initIntlayer(root, options);\n\n const needsPlatform = steps.includes('skills') || steps.includes('mcp');\n\n let sharedPlatform: Platform | undefined;\n\n if (needsPlatform) {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n sharedPlatform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (steps.includes('skills')) {\n await initSkills(root, sharedPlatform);\n }\n\n if (steps.includes('mcp')) {\n await initMCP(root, sharedPlatform);\n }\n\n if (steps.includes('compiler')) {\n await initCompiler(root);\n }\n\n if (steps.includes('buildOptimization')) {\n await initBuildOptimization(root);\n }\n\n if (shouldSetUpCms) {\n p.log.info('Opening your browser to log in to the Intlayer CMS...');\n // `exitAfter: false` keeps the process alive so the flow can finish; the\n // credentials are persisted to `.env` and the editor enabled in the config.\n await login({\n exitAfter: false,\n onCredentials: (credentials) => setupCmsCredentials(root, credentials),\n });\n }\n\n p.outro('Intlayer initialization complete');\n};\n\nexport const init = async (\n projectRoot?: string,\n options?: InitOptions,\n interactive?: boolean\n) => {\n const root = projectRoot\n ? findProjectRoot(resolve(projectRoot))\n : findProjectRoot(process.cwd());\n\n if (interactive) {\n await runInteractiveInit(root, options);\n return;\n }\n\n await initIntlayer(root, options);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,MAAa,mBAAmB,aAAqB;CACnD,IAAI,aAAa;AAEjB,QAAO,sCAAuB,YAAY,KAAK,EAAE;AA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U,QAAQ,iBAAiB,GACnC;IACJ,SAASC,oCAAiB,KAAK,SAAS;KACtC,MAAM,IAAI;KACV,SAAS,IAAI;KACb,MAAM,IAAI;KACX,EAAE;IACJ,CAAC,EACwB;UACpB;AACN,kBAAE,OAAO,uBAAuB;AAChC;;;AAIJ,KAAI,MAAM,SAAS,SAAS,CAC1B,OAAMC,8BAAW,MAAM,eAAe;AAGxC,KAAI,MAAM,SAAS,MAAM,CACvB,OAAMC,wBAAQ,MAAM,eAAe;AAGrC,KAAI,MAAM,SAAS,WAAW,CAC5B,OAAMC,kCAAa,KAAK;AAG1B,KAAI,MAAM,SAAS,oBAAoB,CACrC,OAAMC,oDAAsB,KAAK;AAGnC,KAAI,gBAAgB;AAClB,iBAAE,IAAI,KAAK,wDAAwD;AAGnE,QAAMC,yBAAM;GACV,WAAW;GACX,gBAAgB,gEAAoC,MAAM,YAAY;GACvE,CAAC;;AAGJ,gBAAE,MAAM,mCAAmC;;AAG7C,MAAa,OAAO,OAClB,aACA,SACA,gBACG;CACH,MAAM,OAAO,cACT,uCAAwB,YAAY,CAAC,GACrC,gBAAgB,QAAQ,KAAK,CAAC;AAElC,KAAI,aAAa;AACf,QAAM,mBAAmB,MAAM,QAAQ;AACvC;;AAGF,gDAAmB,MAAM,QAAQ"}
|
|
1
|
+
{"version":3,"file":"init.cjs","names":["p","getDetectedPlatform","PLATFORMS","PLATFORM_OPTIONS","initSkills","initMCP","initCompiler","initBuildOptimization","login"],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n type InitOptions,\n initIntlayer,\n PLATFORMS,\n type Platform,\n type RoutingMode,\n setupCmsCredentials,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { login } from './auth/login';\nimport { initBuildOptimization } from './initBuildOptimization';\nimport { initCompiler } from './initCompiler';\nimport { initMCP } from './initMCP';\nimport {\n getDetectedPlatform,\n initSkills,\n PLATFORM_OPTIONS,\n} from './initSkills';\n\nexport const findProjectRoot = (startDir: string) => {\n let currentDir = startDir;\n\n while (currentDir !== resolve(currentDir, '..')) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = resolve(currentDir, '..');\n }\n\n // If no package.json is found, return the start directory.\n // The initIntlayer function will handle the missing package.json error.\n return startDir;\n};\n\n/** Individually selectable setup steps exposed by the interactive init flow. */\ntype InitStep =\n | 'packages'\n | 'gitignore'\n | 'githubActions'\n | 'frameworkSetup'\n | 'vscodeExtension'\n | 'lsp'\n | 'skills'\n | 'mcp'\n | 'compiler'\n | 'buildOptimization';\n\nconst BASE_INIT_STEP_OPTIONS: Array<{\n value: InitStep;\n label: string;\n hint: string;\n}> = [\n {\n value: 'packages',\n label: 'Install & upgrade packages',\n hint: 'install missing Intlayer dependencies and upgrade outdated ones',\n },\n {\n value: 'gitignore',\n label: '.gitignore entry',\n hint: 'add .intlayer to .gitignore',\n },\n {\n value: 'githubActions',\n label: 'CI/CD (GitHub Actions)',\n hint: 'scaffold the fill and test workflows that run on every pull request',\n },\n {\n value: 'frameworkSetup',\n label: 'Framework setup',\n hint: 'middleware/proxy and providers in layout/page',\n },\n {\n value: 'vscodeExtension',\n label: 'VS Code extension',\n hint: 'recommend the Intlayer extension',\n },\n {\n value: 'lsp',\n label: 'Editor LSP',\n hint: 'go-to-definition from keys to .content files',\n },\n {\n value: 'skills',\n label: 'AI skills',\n hint: 'install the Intlayer documentation as agent skills',\n },\n {\n value: 'mcp',\n label: 'MCP server',\n hint: 'configure the Intlayer MCP server',\n },\n];\n\n/** Locale routing strategies offered by the interactive init flow. */\nconst ROUTING_MODE_OPTIONS: Array<{\n value: RoutingMode;\n label: string;\n hint: string;\n}> = [\n {\n value: 'prefix-no-default',\n label: 'Prefix all except the default locale',\n hint: '/about, /fr/about (default)',\n },\n {\n value: 'prefix-all',\n label: 'Prefix all locales',\n hint: '/en/about, /fr/about',\n },\n {\n value: 'no-prefix',\n label: 'No locale in the URL',\n hint: '/about',\n },\n {\n value: 'search-params',\n label: 'Use a search parameter',\n hint: '/about?locale=fr',\n },\n];\n\n/** Reads the merged dependencies of the project at `root`. */\nconst getProjectDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\n/** Returns true when the project at `root` depends on Next.js. */\nconst isNextJsProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).next);\n\n/** Returns true when the project at `root` depends on Vite. */\nconst isViteProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).vite);\n\n/**\n * Returns true when the project uses a URL-based router for which a locale\n * routing strategy is meaningful: Next.js, React Router, or TanStack Router.\n * Apps without URL routing (e.g. React Native / Expo) are excluded, since\n * `routing.mode` has no effect there.\n */\nconst hasUrlRouting = (root: string): boolean => {\n const deps = getProjectDependencies(root);\n\n // React Native / Expo apps have no URL routing — never ask for a strategy.\n if (deps['react-native'] || deps.expo) return false;\n\n return Boolean(\n deps.next ||\n deps['react-router'] ||\n deps['react-router-dom'] ||\n deps['@tanstack/react-router'] ||\n deps['@tanstack/react-start']\n );\n};\n\n/**\n * Runs `init` in interactive mode: prompts the user with a checkbox of setup\n * steps, then forwards the selection to {@link initIntlayer} (packages,\n * .gitignore, GitHub Actions, VS Code extension, LSP) and runs the dedicated\n * skills/MCP installers for the steps that own their own prompts.\n */\nconst runInteractiveInit = async (\n root: string,\n baseOptions?: InitOptions\n): Promise<void> => {\n p.intro('Initialize Intlayer');\n\n const stepOptions = [...BASE_INIT_STEP_OPTIONS];\n\n const nextJsProject = isNextJsProject(root);\n\n // The compiler is plugged in directly on Vite; on Next.js it needs a Babel\n // config. Only offer the step when one of those frameworks is detected.\n if (nextJsProject || isViteProject(root)) {\n stepOptions.push({\n value: 'compiler',\n label: 'Compiler',\n hint: nextJsProject\n ? 'add the Babel compiler config to extract inline content (Next.js)'\n : 'auto-extract inline content at build time (already plugged in on Vite)',\n });\n }\n\n if (nextJsProject) {\n stepOptions.push({\n value: 'buildOptimization',\n label: 'Bundle optimization',\n hint: 'choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)',\n });\n }\n\n const selected = await p.multiselect<InitStep>({\n message: 'Select what you want to set up:',\n options: stepOptions,\n initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),\n required: false,\n });\n\n if (p.isCancel(selected)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const steps = selected as InitStep[];\n\n // Locale routing strategy → written to `routing.mode` in the config file.\n // Only relevant for URL-based routers (Next.js, React Router, TanStack);\n // skipped for apps without URL routing such as React Native / Expo.\n let routingMode: RoutingMode | undefined;\n\n if (hasUrlRouting(root)) {\n const selectedRoutingMode = await p.select<RoutingMode>({\n message: 'Which locale routing strategy do you want?',\n options: ROUTING_MODE_OPTIONS,\n initialValue: 'prefix-no-default',\n });\n\n if (p.isCancel(selectedRoutingMode)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n routingMode = selectedRoutingMode;\n }\n\n const options: InitOptions = {\n ...baseOptions,\n routingMode,\n noInstallPackages: !steps.includes('packages'),\n // Respect explicit `--no-*` flags from the command line even when the\n // corresponding step is selected in the checkbox.\n noGitignore: baseOptions?.noGitignore || !steps.includes('gitignore'),\n noGithubActions:\n baseOptions?.noGithubActions || !steps.includes('githubActions'),\n noFrameworkSetup:\n baseOptions?.noFrameworkSetup || !steps.includes('frameworkSetup'),\n noVscodeExtension: !steps.includes('vscodeExtension'),\n noLsp: !steps.includes('lsp'),\n };\n\n await initIntlayer(root, options);\n\n const needsPlatform = steps.includes('skills') || steps.includes('mcp');\n\n let sharedPlatform: Platform | undefined;\n\n if (needsPlatform) {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n sharedPlatform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (steps.includes('skills')) {\n await initSkills(root, sharedPlatform);\n }\n\n if (steps.includes('mcp')) {\n await initMCP(root, sharedPlatform);\n }\n\n if (steps.includes('compiler')) {\n await initCompiler(root);\n }\n\n if (steps.includes('buildOptimization')) {\n await initBuildOptimization(root);\n }\n\n // CMS / visual editor is the last step: an opt-in browser login that\n // persists the access-key credentials to `.env` and enables the editor in the\n // config file. Asked last so the browser flow does not interrupt setup.\n const shouldSetUpCms = await p.confirm({\n message:\n 'Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)',\n initialValue: false,\n });\n\n if (p.isCancel(shouldSetUpCms)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (shouldSetUpCms) {\n p.log.info('Opening your browser to log in to the Intlayer CMS...');\n // `exitAfter: false` keeps the process alive so the flow can finish; the\n // credentials are persisted to `.env` and the editor enabled in the config.\n await login({\n exitAfter: false,\n onCredentials: (credentials) => setupCmsCredentials(root, credentials),\n });\n }\n\n p.outro('Intlayer initialization complete');\n};\n\nexport const init = async (\n projectRoot?: string,\n options?: InitOptions,\n interactive?: boolean\n) => {\n const root = projectRoot\n ? findProjectRoot(resolve(projectRoot))\n : findProjectRoot(process.cwd());\n\n if (interactive) {\n await runInteractiveInit(root, options);\n return;\n }\n\n await initIntlayer(root, options);\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,MAAa,mBAAmB,aAAqB;CACnD,IAAI,aAAa;AAEjB,QAAO,sCAAuB,YAAY,KAAK,EAAE;AAC/C,kDAAoB,YAAY,eAAe,CAAC,CAC9C,QAAO;AAET,sCAAqB,Y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M;IACN,SAAS;IACT,UAAU;IACV,SAAS,mBACLC,iCAAU,QAAQ,iBAAiB,GACnC;IACJ,SAASC,oCAAiB,KAAK,SAAS;KACtC,MAAM,IAAI;KACV,SAAS,IAAI;KACb,MAAM,IAAI;KACX,EAAE;IACJ,CAAC,EACwB;UACpB;AACN,kBAAE,OAAO,uBAAuB;AAChC;;;AAIJ,KAAI,MAAM,SAAS,SAAS,CAC1B,OAAMC,8BAAW,MAAM,eAAe;AAGxC,KAAI,MAAM,SAAS,MAAM,CACvB,OAAMC,wBAAQ,MAAM,eAAe;AAGrC,KAAI,MAAM,SAAS,WAAW,CAC5B,OAAMC,kCAAa,KAAK;AAG1B,KAAI,MAAM,SAAS,oBAAoB,CACrC,OAAMC,oDAAsB,KAAK;CAMnC,MAAM,iBAAiB,MAAMP,eAAE,QAAQ;EACrC,SACE;EACF,cAAc;EACf,CAAC;AAEF,KAAIA,eAAE,SAAS,eAAe,EAAE;AAC9B,iBAAE,OAAO,uBAAuB;AAChC;;AAGF,KAAI,gBAAgB;AAClB,iBAAE,IAAI,KAAK,wDAAwD;AAGnE,QAAMQ,yBAAM;GACV,WAAW;GACX,gBAAgB,gEAAoC,MAAM,YAAY;GACvE,CAAC;;AAGJ,gBAAE,MAAM,mCAAmC;;AAG7C,MAAa,OAAO,OAClB,aACA,SACA,gBACG;CACH,MAAM,OAAO,cACT,uCAAwB,YAAY,CAAC,GACrC,gBAAgB,QAAQ,KAAK,CAAC;AAElC,KAAI,aAAa;AACf,QAAM,mBAAmB,MAAM,QAAQ;AACvC;;AAGF,gDAAmB,MAAM,QAAQ"}
|
|
@@ -14,7 +14,8 @@ _clack_prompts = require_runtime.__toESM(_clack_prompts);
|
|
|
14
14
|
* Mirrors the Next.js (Babel) tab of `docs/docs/en/compiler.md`: the extract
|
|
15
15
|
* plugin pulls inline content into dictionaries and the optimize plugin
|
|
16
16
|
* rewrites `useIntlayer` into direct dictionary imports. On Vite the same work
|
|
17
|
-
* is handled by the `
|
|
17
|
+
* is handled by the `intlayer()` plugin (which bundles the compiler in v9), so
|
|
18
|
+
* no Babel config is needed.
|
|
18
19
|
*/
|
|
19
20
|
const BABEL_COMPILER_CONFIG_CONTENT = `const {
|
|
20
21
|
intlayerExtractBabelPlugin,
|
|
@@ -58,9 +59,9 @@ const detectCompilerFramework = (root) => {
|
|
|
58
59
|
* Scaffolds the Intlayer compiler for the current project during interactive
|
|
59
60
|
* init.
|
|
60
61
|
*
|
|
61
|
-
* - **Vite** — nothing to do: the compiler is
|
|
62
|
-
* `
|
|
63
|
-
*
|
|
62
|
+
* - **Vite** — nothing to do: since v9 the compiler is built into the
|
|
63
|
+
* `intlayer()` plugin in `vite.config.ts`, so this only confirms the setup
|
|
64
|
+
* to the user.
|
|
64
65
|
* - **Next.js** — installs `@intlayer/babel` and writes a `babel.config.js`
|
|
65
66
|
* that runs the extract + optimize compiler passes.
|
|
66
67
|
*
|
|
@@ -71,7 +72,7 @@ const initCompiler = async (projectRoot) => {
|
|
|
71
72
|
const root = require_init.findProjectRoot(projectRoot ? (0, node_path.resolve)(projectRoot) : process.cwd());
|
|
72
73
|
const framework = detectCompilerFramework(root);
|
|
73
74
|
if (framework === "vite") {
|
|
74
|
-
_clack_prompts.log.info("Vite detected — the compiler is
|
|
75
|
+
_clack_prompts.log.info("Vite detected — the compiler is built into `intlayer()` in your vite.config. Nothing to configure.");
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
if (framework !== "nextjs") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initCompiler.cjs","names":["findProjectRoot","p"],"sources":["../../src/initCompiler.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport { detectPackageManager, installPackages } from '@intlayer/chokidar/cli';\nimport { findProjectRoot } from './init';\n\n/** Framework the Intlayer compiler can be wired into during init. */\ntype CompilerFramework = 'vite' | 'nextjs' | 'unknown';\n\n/**\n * babel.config.js that runs the Intlayer compiler passes for Next.js.\n *\n * Mirrors the Next.js (Babel) tab of `docs/docs/en/compiler.md`: the extract\n * plugin pulls inline content into dictionaries and the optimize plugin\n * rewrites `useIntlayer` into direct dictionary imports. On Vite the same work\n * is handled by the `
|
|
1
|
+
{"version":3,"file":"initCompiler.cjs","names":["findProjectRoot","p"],"sources":["../../src/initCompiler.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport { detectPackageManager, installPackages } from '@intlayer/chokidar/cli';\nimport { findProjectRoot } from './init';\n\n/** Framework the Intlayer compiler can be wired into during init. */\ntype CompilerFramework = 'vite' | 'nextjs' | 'unknown';\n\n/**\n * babel.config.js that runs the Intlayer compiler passes for Next.js.\n *\n * Mirrors the Next.js (Babel) tab of `docs/docs/en/compiler.md`: the extract\n * plugin pulls inline content into dictionaries and the optimize plugin\n * rewrites `useIntlayer` into direct dictionary imports. On Vite the same work\n * is handled by the `intlayer()` plugin (which bundles the compiler in v9), so\n * no Babel config is needed.\n */\nconst BABEL_COMPILER_CONFIG_CONTENT = `const {\n intlayerExtractBabelPlugin,\n intlayerOptimizeBabelPlugin,\n getExtractPluginOptions,\n getOptimizePluginOptions,\n} = require(\"@intlayer/babel\");\n\nmodule.exports = {\n presets: [\"next/babel\"],\n plugins: [\n // Extract content from components into dictionaries\n [intlayerExtractBabelPlugin, getExtractPluginOptions()],\n // Optimize imports by replacing useIntlayer with direct dictionary imports\n [intlayerOptimizeBabelPlugin, getOptimizePluginOptions()],\n ],\n};\n`;\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` and writes a `babel.config.js`\n * that runs the extract + optimize compiler passes.\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 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 const babelConfigCandidates = [\n 'babel.config.js',\n 'babel.config.cjs',\n 'babel.config.mjs',\n 'babel.config.ts',\n '.babelrc',\n '.babelrc.js',\n ];\n\n const existingBabelConfig = babelConfigCandidates.find((file) =>\n existsSync(join(root, file))\n );\n\n if (existingBabelConfig) {\n p.log.warn(\n `${existingBabelConfig} already exists — add the Intlayer compiler plugins manually.`\n );\n p.note(\n BABEL_COMPILER_CONFIG_CONTENT,\n 'Plugins to add to your babel config'\n );\n } else {\n try {\n writeFileSync(\n join(root, 'babel.config.js'),\n BABEL_COMPILER_CONFIG_CONTENT,\n { encoding: 'utf-8' }\n );\n p.log.success(\n 'Created babel.config.js with the Intlayer compiler extract and optimize plugins'\n );\n } catch {\n p.log.warn(\n 'Could not create babel.config.js — please create it manually.'\n );\n p.note(BABEL_COMPILER_CONFIG_CONTENT, 'babel.config.js');\n }\n }\n\n p.outro('Compiler configuration complete');\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;AAuBtC,MAAM,2BAA2B,SAAoC;AACnE,KAAI;EACF,MAAM,sCAAuB,MAAM,eAAe;AAClD,MAAI,yBAAY,gBAAgB,CAAE,QAAO;EAEzC,MAAM,EAAE,eAAe,EAAE,EAAE,kBAAkB,EAAE,KAAK,KAAK,gCAC1C,iBAAiB,QAAQ,CACvC;EACD,MAAM,kBAAkB;GAAE,GAAG;GAAc,GAAG;GAAiB;AAE/D,MAAI,gBAAgB,KAAM,QAAO;AACjC,MAAI,gBAAgB,KAAM,QAAO;AAEjC,SAAO;SACD;AACN,SAAO;;;;;;;;;;;;;;;;AAiBX,MAAa,eAAe,OAAO,gBAAwC;CACzE,MAAM,OAAOA,6BACX,qCAAsB,YAAY,GAAG,QAAQ,KAAK,CACnD;CAED,MAAM,YAAY,wBAAwB,KAAK;AAE/C,KAAI,cAAc,QAAQ;AAExB,iBAAE,IAAI,KACJ,qGACD;AACD;;AAGF,KAAI,cAAc,UAAU;AAC1B,iBAAE,IAAI,KACJ,uGACD;AACD;;AAGF,gBAAE,MAAM,gDAAgD;CAExD,MAAM,kEAAsC,KAAK;CACjD,MAAM,uBAAuB,CAAC,kBAAkB;CAEhD,MAAM,UAAUC,eAAE,SAAS;AAC3B,SAAQ,MAAM,yBAAyB;AAEvC,KAAI;AACF,8CAAgB,MAAM,sBAAsB,gBAAgB,KAAK;AACjE,UAAQ,KAAK,cAAc,qBAAqB,KAAK,KAAK,GAAG;SACvD;AACN,UAAQ,KAAK,8BAA8B;AAC3C,iBAAE,IAAI,KACJ,4BAA4B,qBAAqB,KAAK,IAAI,CAAC,mBAC5D;;CAYH,MAAM,sBAAsB;EAR1B;EACA;EACA;EACA;EACA;EACA;EAG+C,CAAC,MAAM,qDACtC,MAAM,KAAK,CAAC,CAC7B;AAED,KAAI,qBAAqB;AACvB,iBAAE,IAAI,KACJ,GAAG,oBAAoB,+DACxB;AACD,iBAAE,KACA,+BACA,sCACD;OAED,KAAI;AACF,iDACO,MAAM,kBAAkB,EAC7B,+BACA,EAAE,UAAU,SAAS,CACtB;AACD,iBAAE,IAAI,QACJ,kFACD;SACK;AACN,iBAAE,IAAI,KACJ,gEACD;AACD,iBAAE,KAAK,+BAA+B,kBAAkB;;AAI5D,gBAAE,MAAM,kCAAkC"}
|
package/dist/esm/init.mjs
CHANGED
|
@@ -102,6 +102,17 @@ const isNextJsProject = (root) => Boolean(getProjectDependencies(root).next);
|
|
|
102
102
|
/** Returns true when the project at `root` depends on Vite. */
|
|
103
103
|
const isViteProject = (root) => Boolean(getProjectDependencies(root).vite);
|
|
104
104
|
/**
|
|
105
|
+
* Returns true when the project uses a URL-based router for which a locale
|
|
106
|
+
* routing strategy is meaningful: Next.js, React Router, or TanStack Router.
|
|
107
|
+
* Apps without URL routing (e.g. React Native / Expo) are excluded, since
|
|
108
|
+
* `routing.mode` has no effect there.
|
|
109
|
+
*/
|
|
110
|
+
const hasUrlRouting = (root) => {
|
|
111
|
+
const deps = getProjectDependencies(root);
|
|
112
|
+
if (deps["react-native"] || deps.expo) return false;
|
|
113
|
+
return Boolean(deps.next || deps["react-router"] || deps["react-router-dom"] || deps["@tanstack/react-router"] || deps["@tanstack/react-start"]);
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
105
116
|
* Runs `init` in interactive mode: prompts the user with a checkbox of setup
|
|
106
117
|
* steps, then forwards the selection to {@link initIntlayer} (packages,
|
|
107
118
|
* .gitignore, GitHub Actions, VS Code extension, LSP) and runs the dedicated
|
|
@@ -132,22 +143,18 @@ const runInteractiveInit = async (root, baseOptions) => {
|
|
|
132
143
|
return;
|
|
133
144
|
}
|
|
134
145
|
const steps = selected;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
if (p.isCancel(shouldSetUpCms)) {
|
|
149
|
-
p.cancel("Operation cancelled.");
|
|
150
|
-
return;
|
|
146
|
+
let routingMode;
|
|
147
|
+
if (hasUrlRouting(root)) {
|
|
148
|
+
const selectedRoutingMode = await p.select({
|
|
149
|
+
message: "Which locale routing strategy do you want?",
|
|
150
|
+
options: ROUTING_MODE_OPTIONS,
|
|
151
|
+
initialValue: "prefix-no-default"
|
|
152
|
+
});
|
|
153
|
+
if (p.isCancel(selectedRoutingMode)) {
|
|
154
|
+
p.cancel("Operation cancelled.");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
routingMode = selectedRoutingMode;
|
|
151
158
|
}
|
|
152
159
|
await initIntlayer(root, {
|
|
153
160
|
...baseOptions,
|
|
@@ -185,6 +192,14 @@ const runInteractiveInit = async (root, baseOptions) => {
|
|
|
185
192
|
if (steps.includes("mcp")) await initMCP(root, sharedPlatform);
|
|
186
193
|
if (steps.includes("compiler")) await initCompiler(root);
|
|
187
194
|
if (steps.includes("buildOptimization")) await initBuildOptimization(root);
|
|
195
|
+
const shouldSetUpCms = await p.confirm({
|
|
196
|
+
message: "Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)",
|
|
197
|
+
initialValue: false
|
|
198
|
+
});
|
|
199
|
+
if (p.isCancel(shouldSetUpCms)) {
|
|
200
|
+
p.cancel("Operation cancelled.");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
188
203
|
if (shouldSetUpCms) {
|
|
189
204
|
p.log.info("Opening your browser to log in to the Intlayer CMS...");
|
|
190
205
|
await login({
|
package/dist/esm/init.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.mjs","names":[],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n type InitOptions,\n initIntlayer,\n PLATFORMS,\n type Platform,\n type RoutingMode,\n setupCmsCredentials,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { login } from './auth/login';\nimport { initBuildOptimization } from './initBuildOptimization';\nimport { initCompiler } from './initCompiler';\nimport { initMCP } from './initMCP';\nimport {\n getDetectedPlatform,\n initSkills,\n PLATFORM_OPTIONS,\n} from './initSkills';\n\nexport const findProjectRoot = (startDir: string) => {\n let currentDir = startDir;\n\n while (currentDir !== resolve(currentDir, '..')) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = resolve(currentDir, '..');\n }\n\n // If no package.json is found, return the start directory.\n // The initIntlayer function will handle the missing package.json error.\n return startDir;\n};\n\n/** Individually selectable setup steps exposed by the interactive init flow. */\ntype InitStep =\n | 'packages'\n | 'gitignore'\n | 'githubActions'\n | 'frameworkSetup'\n | 'vscodeExtension'\n | 'lsp'\n | 'skills'\n | 'mcp'\n | 'compiler'\n | 'buildOptimization';\n\nconst BASE_INIT_STEP_OPTIONS: Array<{\n value: InitStep;\n label: string;\n hint: string;\n}> = [\n {\n value: 'packages',\n label: 'Install & upgrade packages',\n hint: 'install missing Intlayer dependencies and upgrade outdated ones',\n },\n {\n value: 'gitignore',\n label: '.gitignore entry',\n hint: 'add .intlayer to .gitignore',\n },\n {\n value: 'githubActions',\n label: 'CI/CD (GitHub Actions)',\n hint: 'scaffold the fill and test workflows that run on every pull request',\n },\n {\n value: 'frameworkSetup',\n label: 'Framework setup',\n hint: 'middleware/proxy and providers in layout/page',\n },\n {\n value: 'vscodeExtension',\n label: 'VS Code extension',\n hint: 'recommend the Intlayer extension',\n },\n {\n value: 'lsp',\n label: 'Editor LSP',\n hint: 'go-to-definition from keys to .content files',\n },\n {\n value: 'skills',\n label: 'AI skills',\n hint: 'install the Intlayer documentation as agent skills',\n },\n {\n value: 'mcp',\n label: 'MCP server',\n hint: 'configure the Intlayer MCP server',\n },\n];\n\n/** Locale routing strategies offered by the interactive init flow. */\nconst ROUTING_MODE_OPTIONS: Array<{\n value: RoutingMode;\n label: string;\n hint: string;\n}> = [\n {\n value: 'prefix-no-default',\n label: 'Prefix all except the default locale',\n hint: '/about, /fr/about (default)',\n },\n {\n value: 'prefix-all',\n label: 'Prefix all locales',\n hint: '/en/about, /fr/about',\n },\n {\n value: 'no-prefix',\n label: 'No locale in the URL',\n hint: '/about',\n },\n {\n value: 'search-params',\n label: 'Use a search parameter',\n hint: '/about?locale=fr',\n },\n];\n\n/** Reads the merged dependencies of the project at `root`. */\nconst getProjectDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\n/** Returns true when the project at `root` depends on Next.js. */\nconst isNextJsProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).next);\n\n/** Returns true when the project at `root` depends on Vite. */\nconst isViteProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).vite);\n\n/**\n * Runs `init` in interactive mode: prompts the user with a checkbox of setup\n * steps, then forwards the selection to {@link initIntlayer} (packages,\n * .gitignore, GitHub Actions, VS Code extension, LSP) and runs the dedicated\n * skills/MCP installers for the steps that own their own prompts.\n */\nconst runInteractiveInit = async (\n root: string,\n baseOptions?: InitOptions\n): Promise<void> => {\n p.intro('Initialize Intlayer');\n\n const stepOptions = [...BASE_INIT_STEP_OPTIONS];\n\n const nextJsProject = isNextJsProject(root);\n\n // The compiler is plugged in directly on Vite; on Next.js it needs a Babel\n // config. Only offer the step when one of those frameworks is detected.\n if (nextJsProject || isViteProject(root)) {\n stepOptions.push({\n value: 'compiler',\n label: 'Compiler',\n hint: nextJsProject\n ? 'add the Babel compiler config to extract inline content (Next.js)'\n : 'auto-extract inline content at build time (already plugged in on Vite)',\n });\n }\n\n if (nextJsProject) {\n stepOptions.push({\n value: 'buildOptimization',\n label: 'Bundle optimization',\n hint: 'choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)',\n });\n }\n\n const selected = await p.multiselect<InitStep>({\n message: 'Select what you want to set up:',\n options: stepOptions,\n initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),\n required: false,\n });\n\n if (p.isCancel(selected)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const steps = selected as InitStep[];\n\n // Locale routing strategy → written to `routing.mode` in the config file.\n const routingMode = await p.select<RoutingMode>({\n message: 'Which locale routing strategy do you want?',\n options: ROUTING_MODE_OPTIONS,\n initialValue: 'prefix-no-default',\n });\n\n if (p.isCancel(routingMode)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n // CMS / visual editor: opt-in browser login that persists the access-key\n // credentials to `.env` and enables the editor in the config file.\n const shouldSetUpCms = await p.confirm({\n message:\n 'Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)',\n initialValue: false,\n });\n\n if (p.isCancel(shouldSetUpCms)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const options: InitOptions = {\n ...baseOptions,\n routingMode,\n noInstallPackages: !steps.includes('packages'),\n // Respect explicit `--no-*` flags from the command line even when the\n // corresponding step is selected in the checkbox.\n noGitignore: baseOptions?.noGitignore || !steps.includes('gitignore'),\n noGithubActions:\n baseOptions?.noGithubActions || !steps.includes('githubActions'),\n noFrameworkSetup:\n baseOptions?.noFrameworkSetup || !steps.includes('frameworkSetup'),\n noVscodeExtension: !steps.includes('vscodeExtension'),\n noLsp: !steps.includes('lsp'),\n };\n\n await initIntlayer(root, options);\n\n const needsPlatform = steps.includes('skills') || steps.includes('mcp');\n\n let sharedPlatform: Platform | undefined;\n\n if (needsPlatform) {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n sharedPlatform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (steps.includes('skills')) {\n await initSkills(root, sharedPlatform);\n }\n\n if (steps.includes('mcp')) {\n await initMCP(root, sharedPlatform);\n }\n\n if (steps.includes('compiler')) {\n await initCompiler(root);\n }\n\n if (steps.includes('buildOptimization')) {\n await initBuildOptimization(root);\n }\n\n if (shouldSetUpCms) {\n p.log.info('Opening your browser to log in to the Intlayer CMS...');\n // `exitAfter: false` keeps the process alive so the flow can finish; the\n // credentials are persisted to `.env` and the editor enabled in the config.\n await login({\n exitAfter: false,\n onCredentials: (credentials) => setupCmsCredentials(root, credentials),\n });\n }\n\n p.outro('Intlayer initialization complete');\n};\n\nexport const init = async (\n projectRoot?: string,\n options?: InitOptions,\n interactive?: boolean\n) => {\n const root = projectRoot\n ? findProjectRoot(resolve(projectRoot))\n : findProjectRoot(process.cwd());\n\n if (interactive) {\n await runInteractiveInit(root, options);\n return;\n }\n\n await initIntlayer(root, options);\n};\n"],"mappings":";;;;;;;;;;;;AAsBA,MAAa,mBAAmB,aAAqB;CACnD,IAAI,aAAa;AAEjB,QAAO,eAAe,QAAQ,YAAY,KAAK,EAAE;AAC/C,MAAI,WAAW,KAAK,YAAY,eAAe,CAAC,CAC9C,QAAO;AAET,eAAa,QAAQ,YAAY,KAA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M,IAAI;KACV,SAAS,IAAI;KACb,MAAM,IAAI;KACX,EAAE;IACJ,CAAC,EACwB;UACpB;AACN,KAAE,OAAO,uBAAuB;AAChC;;;AAIJ,KAAI,MAAM,SAAS,SAAS,CAC1B,OAAM,WAAW,MAAM,eAAe;AAGxC,KAAI,MAAM,SAAS,MAAM,CACvB,OAAM,QAAQ,MAAM,eAAe;AAGrC,KAAI,MAAM,SAAS,WAAW,CAC5B,OAAM,aAAa,KAAK;AAG1B,KAAI,MAAM,SAAS,oBAAoB,CACrC,OAAM,sBAAsB,KAAK;AAGnC,KAAI,gBAAgB;AAClB,IAAE,IAAI,KAAK,wDAAwD;AAGnE,QAAM,MAAM;GACV,WAAW;GACX,gBAAgB,gBAAgB,oBAAoB,MAAM,YAAY;GACvE,CAAC;;AAGJ,GAAE,MAAM,mCAAmC;;AAG7C,MAAa,OAAO,OAClB,aACA,SACA,gBACG;CACH,MAAM,OAAO,cACT,gBAAgB,QAAQ,YAAY,CAAC,GACrC,gBAAgB,QAAQ,KAAK,CAAC;AAElC,KAAI,aAAa;AACf,QAAM,mBAAmB,MAAM,QAAQ;AACvC;;AAGF,OAAM,aAAa,MAAM,QAAQ"}
|
|
1
|
+
{"version":3,"file":"init.mjs","names":[],"sources":["../../src/init.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport {\n type InitOptions,\n initIntlayer,\n PLATFORMS,\n type Platform,\n type RoutingMode,\n setupCmsCredentials,\n} from '@intlayer/chokidar/cli';\nimport enquirer from 'enquirer';\nimport { login } from './auth/login';\nimport { initBuildOptimization } from './initBuildOptimization';\nimport { initCompiler } from './initCompiler';\nimport { initMCP } from './initMCP';\nimport {\n getDetectedPlatform,\n initSkills,\n PLATFORM_OPTIONS,\n} from './initSkills';\n\nexport const findProjectRoot = (startDir: string) => {\n let currentDir = startDir;\n\n while (currentDir !== resolve(currentDir, '..')) {\n if (existsSync(join(currentDir, 'package.json'))) {\n return currentDir;\n }\n currentDir = resolve(currentDir, '..');\n }\n\n // If no package.json is found, return the start directory.\n // The initIntlayer function will handle the missing package.json error.\n return startDir;\n};\n\n/** Individually selectable setup steps exposed by the interactive init flow. */\ntype InitStep =\n | 'packages'\n | 'gitignore'\n | 'githubActions'\n | 'frameworkSetup'\n | 'vscodeExtension'\n | 'lsp'\n | 'skills'\n | 'mcp'\n | 'compiler'\n | 'buildOptimization';\n\nconst BASE_INIT_STEP_OPTIONS: Array<{\n value: InitStep;\n label: string;\n hint: string;\n}> = [\n {\n value: 'packages',\n label: 'Install & upgrade packages',\n hint: 'install missing Intlayer dependencies and upgrade outdated ones',\n },\n {\n value: 'gitignore',\n label: '.gitignore entry',\n hint: 'add .intlayer to .gitignore',\n },\n {\n value: 'githubActions',\n label: 'CI/CD (GitHub Actions)',\n hint: 'scaffold the fill and test workflows that run on every pull request',\n },\n {\n value: 'frameworkSetup',\n label: 'Framework setup',\n hint: 'middleware/proxy and providers in layout/page',\n },\n {\n value: 'vscodeExtension',\n label: 'VS Code extension',\n hint: 'recommend the Intlayer extension',\n },\n {\n value: 'lsp',\n label: 'Editor LSP',\n hint: 'go-to-definition from keys to .content files',\n },\n {\n value: 'skills',\n label: 'AI skills',\n hint: 'install the Intlayer documentation as agent skills',\n },\n {\n value: 'mcp',\n label: 'MCP server',\n hint: 'configure the Intlayer MCP server',\n },\n];\n\n/** Locale routing strategies offered by the interactive init flow. */\nconst ROUTING_MODE_OPTIONS: Array<{\n value: RoutingMode;\n label: string;\n hint: string;\n}> = [\n {\n value: 'prefix-no-default',\n label: 'Prefix all except the default locale',\n hint: '/about, /fr/about (default)',\n },\n {\n value: 'prefix-all',\n label: 'Prefix all locales',\n hint: '/en/about, /fr/about',\n },\n {\n value: 'no-prefix',\n label: 'No locale in the URL',\n hint: '/about',\n },\n {\n value: 'search-params',\n label: 'Use a search parameter',\n hint: '/about?locale=fr',\n },\n];\n\n/** Reads the merged dependencies of the project at `root`. */\nconst getProjectDependencies = (root: string): Record<string, string> => {\n try {\n const packageJsonPath = join(root, 'package.json');\n if (!existsSync(packageJsonPath)) return {};\n const { dependencies = {}, devDependencies = {} } = JSON.parse(\n readFileSync(packageJsonPath, 'utf-8')\n );\n return { ...dependencies, ...devDependencies };\n } catch {\n return {};\n }\n};\n\n/** Returns true when the project at `root` depends on Next.js. */\nconst isNextJsProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).next);\n\n/** Returns true when the project at `root` depends on Vite. */\nconst isViteProject = (root: string): boolean =>\n Boolean(getProjectDependencies(root).vite);\n\n/**\n * Returns true when the project uses a URL-based router for which a locale\n * routing strategy is meaningful: Next.js, React Router, or TanStack Router.\n * Apps without URL routing (e.g. React Native / Expo) are excluded, since\n * `routing.mode` has no effect there.\n */\nconst hasUrlRouting = (root: string): boolean => {\n const deps = getProjectDependencies(root);\n\n // React Native / Expo apps have no URL routing — never ask for a strategy.\n if (deps['react-native'] || deps.expo) return false;\n\n return Boolean(\n deps.next ||\n deps['react-router'] ||\n deps['react-router-dom'] ||\n deps['@tanstack/react-router'] ||\n deps['@tanstack/react-start']\n );\n};\n\n/**\n * Runs `init` in interactive mode: prompts the user with a checkbox of setup\n * steps, then forwards the selection to {@link initIntlayer} (packages,\n * .gitignore, GitHub Actions, VS Code extension, LSP) and runs the dedicated\n * skills/MCP installers for the steps that own their own prompts.\n */\nconst runInteractiveInit = async (\n root: string,\n baseOptions?: InitOptions\n): Promise<void> => {\n p.intro('Initialize Intlayer');\n\n const stepOptions = [...BASE_INIT_STEP_OPTIONS];\n\n const nextJsProject = isNextJsProject(root);\n\n // The compiler is plugged in directly on Vite; on Next.js it needs a Babel\n // config. Only offer the step when one of those frameworks is detected.\n if (nextJsProject || isViteProject(root)) {\n stepOptions.push({\n value: 'compiler',\n label: 'Compiler',\n hint: nextJsProject\n ? 'add the Babel compiler config to extract inline content (Next.js)'\n : 'auto-extract inline content at build time (already plugged in on Vite)',\n });\n }\n\n if (nextJsProject) {\n stepOptions.push({\n value: 'buildOptimization',\n label: 'Bundle optimization',\n hint: 'choose @intlayer/babel or @intlayer/swc for tree-shaking and minification (Next.js only)',\n });\n }\n\n const selected = await p.multiselect<InitStep>({\n message: 'Select what you want to set up:',\n options: stepOptions,\n initialValues: BASE_INIT_STEP_OPTIONS.map((option) => option.value),\n required: false,\n });\n\n if (p.isCancel(selected)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n const steps = selected as InitStep[];\n\n // Locale routing strategy → written to `routing.mode` in the config file.\n // Only relevant for URL-based routers (Next.js, React Router, TanStack);\n // skipped for apps without URL routing such as React Native / Expo.\n let routingMode: RoutingMode | undefined;\n\n if (hasUrlRouting(root)) {\n const selectedRoutingMode = await p.select<RoutingMode>({\n message: 'Which locale routing strategy do you want?',\n options: ROUTING_MODE_OPTIONS,\n initialValue: 'prefix-no-default',\n });\n\n if (p.isCancel(selectedRoutingMode)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n routingMode = selectedRoutingMode;\n }\n\n const options: InitOptions = {\n ...baseOptions,\n routingMode,\n noInstallPackages: !steps.includes('packages'),\n // Respect explicit `--no-*` flags from the command line even when the\n // corresponding step is selected in the checkbox.\n noGitignore: baseOptions?.noGitignore || !steps.includes('gitignore'),\n noGithubActions:\n baseOptions?.noGithubActions || !steps.includes('githubActions'),\n noFrameworkSetup:\n baseOptions?.noFrameworkSetup || !steps.includes('frameworkSetup'),\n noVscodeExtension: !steps.includes('vscodeExtension'),\n noLsp: !steps.includes('lsp'),\n };\n\n await initIntlayer(root, options);\n\n const needsPlatform = steps.includes('skills') || steps.includes('mcp');\n\n let sharedPlatform: Platform | undefined;\n\n if (needsPlatform) {\n const detectedPlatform = getDetectedPlatform();\n\n try {\n const response = await enquirer.prompt<{ platforms: Platform }>({\n type: 'autocomplete',\n name: 'platforms',\n message: 'Which platform are you using? (Type to search)',\n multiple: false,\n initial: detectedPlatform\n ? PLATFORMS.indexOf(detectedPlatform)\n : undefined,\n choices: PLATFORM_OPTIONS.map((opt) => ({\n name: opt.value,\n message: opt.label,\n hint: opt.hint,\n })),\n });\n sharedPlatform = response.platforms;\n } catch {\n p.cancel('Operation cancelled.');\n return;\n }\n }\n\n if (steps.includes('skills')) {\n await initSkills(root, sharedPlatform);\n }\n\n if (steps.includes('mcp')) {\n await initMCP(root, sharedPlatform);\n }\n\n if (steps.includes('compiler')) {\n await initCompiler(root);\n }\n\n if (steps.includes('buildOptimization')) {\n await initBuildOptimization(root);\n }\n\n // CMS / visual editor is the last step: an opt-in browser login that\n // persists the access-key credentials to `.env` and enables the editor in the\n // config file. Asked last so the browser flow does not interrupt setup.\n const shouldSetUpCms = await p.confirm({\n message:\n 'Set up the Intlayer CMS now? (opens your browser to log in, then stores the credentials in your .env)',\n initialValue: false,\n });\n\n if (p.isCancel(shouldSetUpCms)) {\n p.cancel('Operation cancelled.');\n return;\n }\n\n if (shouldSetUpCms) {\n p.log.info('Opening your browser to log in to the Intlayer CMS...');\n // `exitAfter: false` keeps the process alive so the flow can finish; the\n // credentials are persisted to `.env` and the editor enabled in the config.\n await login({\n exitAfter: false,\n onCredentials: (credentials) => setupCmsCredentials(root, credentials),\n });\n }\n\n p.outro('Intlayer initialization complete');\n};\n\nexport const init = async (\n projectRoot?: string,\n options?: InitOptions,\n interactive?: boolean\n) => {\n const root = projectRoot\n ? findProjectRoot(resolve(projectRoot))\n : findProjectRoot(process.cwd());\n\n if (interactive) {\n await runInteractiveInit(root, options);\n return;\n }\n\n await initIntlayer(root, options);\n};\n"],"mappings":";;;;;;;;;;;;AAsBA,MAAa,mBAAmB,aAAqB;CACnD,IAAI,aAAa;AAEjB,QAAO,eAAe,QAAQ,YAAY,KAAK,EAAE;AAC/C,MAAI,WAAW,KAAK,YAAY,eAAe,CAAC,CAC9C,QAAO;AAET,eAAa,QAAQ,YAAY,KAAK;;AAKxC,QAAO;;AAgBT,MAAM,yBAID;CACH;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACP;CACD;EACE,OAAO;EACP,OAAO;EACP,M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IAAI;KACV,SAAS,IAAI;KACb,MAAM,IAAI;KACX,EAAE;IACJ,CAAC,EACwB;UACpB;AACN,KAAE,OAAO,uBAAuB;AAChC;;;AAIJ,KAAI,MAAM,SAAS,SAAS,CAC1B,OAAM,WAAW,MAAM,eAAe;AAGxC,KAAI,MAAM,SAAS,MAAM,CACvB,OAAM,QAAQ,MAAM,eAAe;AAGrC,KAAI,MAAM,SAAS,WAAW,CAC5B,OAAM,aAAa,KAAK;AAG1B,KAAI,MAAM,SAAS,oBAAoB,CACrC,OAAM,sBAAsB,KAAK;CAMnC,MAAM,iBAAiB,MAAM,EAAE,QAAQ;EACrC,SACE;EACF,cAAc;EACf,CAAC;AAEF,KAAI,EAAE,SAAS,eAAe,EAAE;AAC9B,IAAE,OAAO,uBAAuB;AAChC;;AAGF,KAAI,gBAAgB;AAClB,IAAE,IAAI,KAAK,wDAAwD;AAGnE,QAAM,MAAM;GACV,WAAW;GACX,gBAAgB,gBAAgB,oBAAoB,MAAM,YAAY;GACvE,CAAC;;AAGJ,GAAE,MAAM,mCAAmC;;AAG7C,MAAa,OAAO,OAClB,aACA,SACA,gBACG;CACH,MAAM,OAAO,cACT,gBAAgB,QAAQ,YAAY,CAAC,GACrC,gBAAgB,QAAQ,KAAK,CAAC;AAElC,KAAI,aAAa;AACf,QAAM,mBAAmB,MAAM,QAAQ;AACvC;;AAGF,OAAM,aAAa,MAAM,QAAQ"}
|
|
@@ -11,7 +11,8 @@ import * as p from "@clack/prompts";
|
|
|
11
11
|
* Mirrors the Next.js (Babel) tab of `docs/docs/en/compiler.md`: the extract
|
|
12
12
|
* plugin pulls inline content into dictionaries and the optimize plugin
|
|
13
13
|
* rewrites `useIntlayer` into direct dictionary imports. On Vite the same work
|
|
14
|
-
* is handled by the `
|
|
14
|
+
* is handled by the `intlayer()` plugin (which bundles the compiler in v9), so
|
|
15
|
+
* no Babel config is needed.
|
|
15
16
|
*/
|
|
16
17
|
const BABEL_COMPILER_CONFIG_CONTENT = `const {
|
|
17
18
|
intlayerExtractBabelPlugin,
|
|
@@ -55,9 +56,9 @@ const detectCompilerFramework = (root) => {
|
|
|
55
56
|
* Scaffolds the Intlayer compiler for the current project during interactive
|
|
56
57
|
* init.
|
|
57
58
|
*
|
|
58
|
-
* - **Vite** — nothing to do: the compiler is
|
|
59
|
-
* `
|
|
60
|
-
*
|
|
59
|
+
* - **Vite** — nothing to do: since v9 the compiler is built into the
|
|
60
|
+
* `intlayer()` plugin in `vite.config.ts`, so this only confirms the setup
|
|
61
|
+
* to the user.
|
|
61
62
|
* - **Next.js** — installs `@intlayer/babel` and writes a `babel.config.js`
|
|
62
63
|
* that runs the extract + optimize compiler passes.
|
|
63
64
|
*
|
|
@@ -68,7 +69,7 @@ const initCompiler = async (projectRoot) => {
|
|
|
68
69
|
const root = findProjectRoot(projectRoot ? resolve(projectRoot) : process.cwd());
|
|
69
70
|
const framework = detectCompilerFramework(root);
|
|
70
71
|
if (framework === "vite") {
|
|
71
|
-
p.log.info("Vite detected — the compiler is
|
|
72
|
+
p.log.info("Vite detected — the compiler is built into `intlayer()` in your vite.config. Nothing to configure.");
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
if (framework !== "nextjs") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initCompiler.mjs","names":[],"sources":["../../src/initCompiler.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport { detectPackageManager, installPackages } from '@intlayer/chokidar/cli';\nimport { findProjectRoot } from './init';\n\n/** Framework the Intlayer compiler can be wired into during init. */\ntype CompilerFramework = 'vite' | 'nextjs' | 'unknown';\n\n/**\n * babel.config.js that runs the Intlayer compiler passes for Next.js.\n *\n * Mirrors the Next.js (Babel) tab of `docs/docs/en/compiler.md`: the extract\n * plugin pulls inline content into dictionaries and the optimize plugin\n * rewrites `useIntlayer` into direct dictionary imports. On Vite the same work\n * is handled by the `
|
|
1
|
+
{"version":3,"file":"initCompiler.mjs","names":[],"sources":["../../src/initCompiler.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport * as p from '@clack/prompts';\nimport { detectPackageManager, installPackages } from '@intlayer/chokidar/cli';\nimport { findProjectRoot } from './init';\n\n/** Framework the Intlayer compiler can be wired into during init. */\ntype CompilerFramework = 'vite' | 'nextjs' | 'unknown';\n\n/**\n * babel.config.js that runs the Intlayer compiler passes for Next.js.\n *\n * Mirrors the Next.js (Babel) tab of `docs/docs/en/compiler.md`: the extract\n * plugin pulls inline content into dictionaries and the optimize plugin\n * rewrites `useIntlayer` into direct dictionary imports. On Vite the same work\n * is handled by the `intlayer()` plugin (which bundles the compiler in v9), so\n * no Babel config is needed.\n */\nconst BABEL_COMPILER_CONFIG_CONTENT = `const {\n intlayerExtractBabelPlugin,\n intlayerOptimizeBabelPlugin,\n getExtractPluginOptions,\n getOptimizePluginOptions,\n} = require(\"@intlayer/babel\");\n\nmodule.exports = {\n presets: [\"next/babel\"],\n plugins: [\n // Extract content from components into dictionaries\n [intlayerExtractBabelPlugin, getExtractPluginOptions()],\n // Optimize imports by replacing useIntlayer with direct dictionary imports\n [intlayerOptimizeBabelPlugin, getOptimizePluginOptions()],\n ],\n};\n`;\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` and writes a `babel.config.js`\n * that runs the extract + optimize compiler passes.\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 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 const babelConfigCandidates = [\n 'babel.config.js',\n 'babel.config.cjs',\n 'babel.config.mjs',\n 'babel.config.ts',\n '.babelrc',\n '.babelrc.js',\n ];\n\n const existingBabelConfig = babelConfigCandidates.find((file) =>\n existsSync(join(root, file))\n );\n\n if (existingBabelConfig) {\n p.log.warn(\n `${existingBabelConfig} already exists — add the Intlayer compiler plugins manually.`\n );\n p.note(\n BABEL_COMPILER_CONFIG_CONTENT,\n 'Plugins to add to your babel config'\n );\n } else {\n try {\n writeFileSync(\n join(root, 'babel.config.js'),\n BABEL_COMPILER_CONFIG_CONTENT,\n { encoding: 'utf-8' }\n );\n p.log.success(\n 'Created babel.config.js with the Intlayer compiler extract and optimize plugins'\n );\n } catch {\n p.log.warn(\n 'Could not create babel.config.js — please create it manually.'\n );\n p.note(BABEL_COMPILER_CONFIG_CONTENT, 'babel.config.js');\n }\n }\n\n p.outro('Compiler configuration complete');\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;AAuBtC,MAAM,2BAA2B,SAAoC;AACnE,KAAI;EACF,MAAM,kBAAkB,KAAK,MAAM,eAAe;AAClD,MAAI,CAAC,WAAW,gBAAgB,CAAE,QAAO;EAEzC,MAAM,EAAE,eAAe,EAAE,EAAE,kBAAkB,EAAE,KAAK,KAAK,MACvD,aAAa,iBAAiB,QAAQ,CACvC;EACD,MAAM,kBAAkB;GAAE,GAAG;GAAc,GAAG;GAAiB;AAE/D,MAAI,gBAAgB,KAAM,QAAO;AACjC,MAAI,gBAAgB,KAAM,QAAO;AAEjC,SAAO;SACD;AACN,SAAO;;;;;;;;;;;;;;;;AAiBX,MAAa,eAAe,OAAO,gBAAwC;CACzE,MAAM,OAAO,gBACX,cAAc,QAAQ,YAAY,GAAG,QAAQ,KAAK,CACnD;CAED,MAAM,YAAY,wBAAwB,KAAK;AAE/C,KAAI,cAAc,QAAQ;AAExB,IAAE,IAAI,KACJ,qGACD;AACD;;AAGF,KAAI,cAAc,UAAU;AAC1B,IAAE,IAAI,KACJ,uGACD;AACD;;AAGF,GAAE,MAAM,gDAAgD;CAExD,MAAM,iBAAiB,qBAAqB,KAAK;CACjD,MAAM,uBAAuB,CAAC,kBAAkB;CAEhD,MAAM,UAAU,EAAE,SAAS;AAC3B,SAAQ,MAAM,yBAAyB;AAEvC,KAAI;AACF,kBAAgB,MAAM,sBAAsB,gBAAgB,KAAK;AACjE,UAAQ,KAAK,cAAc,qBAAqB,KAAK,KAAK,GAAG;SACvD;AACN,UAAQ,KAAK,8BAA8B;AAC3C,IAAE,IAAI,KACJ,4BAA4B,qBAAqB,KAAK,IAAI,CAAC,mBAC5D;;CAYH,MAAM,sBAAsB;EAR1B;EACA;EACA;EACA;EACA;EACA;EAG+C,CAAC,MAAM,SACtD,WAAW,KAAK,MAAM,KAAK,CAAC,CAC7B;AAED,KAAI,qBAAqB;AACvB,IAAE,IAAI,KACJ,GAAG,oBAAoB,+DACxB;AACD,IAAE,KACA,+BACA,sCACD;OAED,KAAI;AACF,gBACE,KAAK,MAAM,kBAAkB,EAC7B,+BACA,EAAE,UAAU,SAAS,CACtB;AACD,IAAE,IAAI,QACJ,kFACD;SACK;AACN,IAAE,IAAI,KACJ,gEACD;AACD,IAAE,KAAK,+BAA+B,kBAAkB;;AAI5D,GAAE,MAAM,kCAAkC"}
|
package/dist/types/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","names":[],"sources":["../../src/init.ts"],"mappings":";;;cAsBa,eAAA,GAAmB,QAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"init.d.ts","names":[],"sources":["../../src/init.ts"],"mappings":";;;cAsBa,eAAA,GAAmB,QAAA;AAAA,cAiTnB,IAAA,GACX,WAAA,WACA,OAAA,GAAU,WAAA,EACV,WAAA,eAAqB,OAAA"}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* Scaffolds the Intlayer compiler for the current project during interactive
|
|
4
4
|
* init.
|
|
5
5
|
*
|
|
6
|
-
* - **Vite** — nothing to do: the compiler is
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
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
9
|
* - **Next.js** — installs `@intlayer/babel` and writes a `babel.config.js`
|
|
10
10
|
* that runs the extract + optimize compiler passes.
|
|
11
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initCompiler.d.ts","names":[],"sources":["../../src/initCompiler.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"initCompiler.d.ts","names":[],"sources":["../../src/initCompiler.ts"],"mappings":";;AAyEA;;;;;;;;;;;;cAAa,YAAA,GAAsB,WAAA,cAAuB,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/cli",
|
|
3
|
-
"version": "9.0.0-canary.
|
|
3
|
+
"version": "9.0.0-canary.7",
|
|
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": [
|
|
@@ -67,22 +67,22 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@clack/prompts": "0.11.0",
|
|
70
|
-
"@intlayer/api": "9.0.0-canary.
|
|
71
|
-
"@intlayer/babel": "9.0.0-canary.
|
|
72
|
-
"@intlayer/chokidar": "9.0.0-canary.
|
|
73
|
-
"@intlayer/config": "9.0.0-canary.
|
|
74
|
-
"@intlayer/core": "9.0.0-canary.
|
|
75
|
-
"@intlayer/dictionaries-entry": "9.0.0-canary.
|
|
76
|
-
"@intlayer/remote-dictionaries-entry": "9.0.0-canary.
|
|
77
|
-
"@intlayer/types": "9.0.0-canary.
|
|
78
|
-
"@intlayer/unmerged-dictionaries-entry": "9.0.0-canary.
|
|
70
|
+
"@intlayer/api": "9.0.0-canary.7",
|
|
71
|
+
"@intlayer/babel": "9.0.0-canary.7",
|
|
72
|
+
"@intlayer/chokidar": "9.0.0-canary.7",
|
|
73
|
+
"@intlayer/config": "9.0.0-canary.7",
|
|
74
|
+
"@intlayer/core": "9.0.0-canary.7",
|
|
75
|
+
"@intlayer/dictionaries-entry": "9.0.0-canary.7",
|
|
76
|
+
"@intlayer/remote-dictionaries-entry": "9.0.0-canary.7",
|
|
77
|
+
"@intlayer/types": "9.0.0-canary.7",
|
|
78
|
+
"@intlayer/unmerged-dictionaries-entry": "9.0.0-canary.7",
|
|
79
79
|
"commander": "14.0.3",
|
|
80
80
|
"enquirer": "2.4.1",
|
|
81
81
|
"eventsource": "4.1.0",
|
|
82
82
|
"fast-glob": "3.3.3"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@intlayer/ai": "9.0.0-canary.
|
|
85
|
+
"@intlayer/ai": "9.0.0-canary.7",
|
|
86
86
|
"@types/node": "25.9.4",
|
|
87
87
|
"@utils/ts-config": "1.0.4",
|
|
88
88
|
"@utils/ts-config-types": "1.0.4",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"vitest": "4.1.9"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
|
-
"@intlayer/ai": "9.0.0-canary.
|
|
96
|
+
"@intlayer/ai": "9.0.0-canary.7"
|
|
97
97
|
},
|
|
98
98
|
"peerDependenciesMeta": {
|
|
99
99
|
"@intlayer/ai": {
|