@intlayer/chokidar 8.4.10 → 8.5.1
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/assets/initConfig/templates/cjs.txt +9 -1
- package/dist/assets/initConfig/templates/mjs.txt +9 -1
- package/dist/assets/initConfig/templates/ts.txt +9 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/index.cjs +19 -0
- package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/spawnWin32.cjs +1 -1
- package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
- package/dist/cjs/writeConfiguration/generateConfigurationContent.cjs +31 -0
- package/dist/cjs/writeConfiguration/generateConfigurationContent.cjs.map +1 -0
- package/dist/cjs/writeConfiguration/index.cjs +5 -23
- package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs.map +1 -1
- package/dist/esm/utils/runParallel/index.mjs +19 -0
- package/dist/esm/utils/runParallel/index.mjs.map +1 -1
- package/dist/esm/utils/runParallel/spawnWin32.mjs +2 -2
- package/dist/esm/utils/runParallel/spawnWin32.mjs.map +1 -1
- package/dist/esm/writeConfiguration/generateConfigurationContent.mjs +29 -0
- package/dist/esm/writeConfiguration/generateConfigurationContent.mjs.map +1 -0
- package/dist/esm/writeConfiguration/index.mjs +5 -23
- package/dist/esm/writeConfiguration/index.mjs.map +1 -1
- package/dist/types/utils/runParallel/spawnWin32.d.ts.map +1 -1
- package/dist/types/writeConfiguration/generateConfigurationContent.d.ts +7 -0
- package/dist/types/writeConfiguration/generateConfigurationContent.d.ts.map +1 -0
- package/dist/types/writeConfiguration/index.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -53,6 +53,11 @@ const config = {
|
|
|
53
53
|
provider: 'openai',
|
|
54
54
|
model: 'gpt-5-mini',
|
|
55
55
|
apiKey: process.env.OPENAI_API_KEY,
|
|
56
|
+
/**
|
|
57
|
+
* Additional context for the translations
|
|
58
|
+
*
|
|
59
|
+
* Can be use in addition of the dictionary `description` field
|
|
60
|
+
*/
|
|
56
61
|
applicationContext: [''].join('\n'),
|
|
57
62
|
},
|
|
58
63
|
compiler: {
|
|
@@ -85,7 +90,10 @@ const config = {
|
|
|
85
90
|
|
|
86
91
|
/**
|
|
87
92
|
* Indicates if the components should be saved after being transformed.
|
|
88
|
-
*
|
|
93
|
+
*
|
|
94
|
+
* - If `true`, the compiler will rewrite the component file in the disk. So the transformation will be permanent, and the compiler will skip the transformation for the next process. That way, the compiler can transform the app, and then it can be removed.
|
|
95
|
+
*
|
|
96
|
+
* - If `false`, the compiler will inject the `useIntlayer()` function call into the code in the build output only, and keep the base codebase intact. The transformation will be done only in memory.
|
|
89
97
|
*/
|
|
90
98
|
saveComponents: false,
|
|
91
99
|
},
|
|
@@ -53,6 +53,11 @@ const config = {
|
|
|
53
53
|
provider: 'openai',
|
|
54
54
|
model: 'gpt-5-mini',
|
|
55
55
|
apiKey: process.env.OPENAI_API_KEY,
|
|
56
|
+
/**
|
|
57
|
+
* Additional context for the translations
|
|
58
|
+
*
|
|
59
|
+
* Can be use in addition of the dictionary `description` field
|
|
60
|
+
*/
|
|
56
61
|
applicationContext: [''].join('\n'),
|
|
57
62
|
},
|
|
58
63
|
compiler: {
|
|
@@ -85,7 +90,10 @@ const config = {
|
|
|
85
90
|
|
|
86
91
|
/**
|
|
87
92
|
* Indicates if the components should be saved after being transformed.
|
|
88
|
-
*
|
|
93
|
+
*
|
|
94
|
+
* - If `true`, the compiler will rewrite the component file in the disk. So the transformation will be permanent, and the compiler will skip the transformation for the next process. That way, the compiler can transform the app, and then it can be removed.
|
|
95
|
+
*
|
|
96
|
+
* - If `false`, the compiler will inject the `useIntlayer()` function call into the code in the build output only, and keep the base codebase intact. The transformation will be done only in memory.
|
|
89
97
|
*/
|
|
90
98
|
saveComponents: false,
|
|
91
99
|
},
|
|
@@ -52,6 +52,11 @@ const config: IntlayerConfig = {
|
|
|
52
52
|
provider: 'openai',
|
|
53
53
|
model: 'gpt-5-mini',
|
|
54
54
|
apiKey: process.env.OPENAI_API_KEY,
|
|
55
|
+
/**
|
|
56
|
+
* Additional context for the translations
|
|
57
|
+
*
|
|
58
|
+
* Can be use in addition of the dictionary `description` field
|
|
59
|
+
*/
|
|
55
60
|
applicationContext: [''].join('\n'),
|
|
56
61
|
},
|
|
57
62
|
compiler: {
|
|
@@ -84,7 +89,10 @@ const config: IntlayerConfig = {
|
|
|
84
89
|
|
|
85
90
|
/**
|
|
86
91
|
* Indicates if the components should be saved after being transformed.
|
|
87
|
-
*
|
|
92
|
+
*
|
|
93
|
+
* - If `true`, the compiler will rewrite the component file in the disk. So the transformation will be permanent, and the compiler will skip the transformation for the next process. That way, the compiler can transform the app, and then it can be removed.
|
|
94
|
+
*
|
|
95
|
+
* - If `false`, the compiler will inject the `useIntlayer()` function call into the code in the build output only, and keep the base codebase intact. The transformation will be done only in memory.
|
|
88
96
|
*/
|
|
89
97
|
saveComponents: false,
|
|
90
98
|
},
|
|
@@ -46,7 +46,7 @@ const getIntlayerBundle = async (configuration) => {
|
|
|
46
46
|
const rootRequire = (0, _intlayer_config_utils.getProjectRequire)(configuration.system.baseDir);
|
|
47
47
|
const configPackageRequire = _intlayer_config_utils.configESMxCJSRequire;
|
|
48
48
|
const localRequire = _intlayer_config_utils.isESModule ? (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href) : require;
|
|
49
|
-
const configurationPath = (0, node_path.join)(configuration.system.configDir, `configuration.
|
|
49
|
+
const configurationPath = (0, node_path.join)(configuration.system.configDir, `configuration.cjs`);
|
|
50
50
|
const replaceModules = {
|
|
51
51
|
defu: configPackageRequire.resolve("defu"),
|
|
52
52
|
esbuild: configPackageRequire.resolve("esbuild"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayerBundle.cjs","names":["configESMxCJSRequire","isESModule","builtinModules"],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules, createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { bundleFile, type ESBuildPlugin } from '@intlayer/config/file';\nimport {\n configESMxCJSRequire,\n getProjectRequire,\n isESModule,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Rewrites selected bare specifiers (and any of their subpaths) to absolute file paths,\n * using the provided localeRequire (either createRequire(import.meta.url) or require).\n *\n * Example:\n * rewritePathsPlugin([\"@intlayer/config\", \"@intlayer/core\"], localeRequire)\n * …will also rewrite \"@intlayer/core/file\" etc.\n */\nconst rewritePathsPlugin = (\n replaceModules: Record<string, string>,\n excludeModules?: string[]\n): ESBuildPlugin => {\n return {\n name: 'rewrite-paths',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n const exact = replaceModules[args.path];\n\n if (excludeModules?.includes(args.path)) {\n return null;\n }\n\n if (exact) {\n return {\n path: exact,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n\n // Optional: support subpaths like \"@intlayer/core/xyz\"\n for (const key of Object.keys(replaceModules)) {\n if (args.path === key || args.path.startsWith(`${key}/`)) {\n const sub = args.path.slice(key.length); // '' or '/...'\n return {\n path: replaceModules[key] + sub,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n }\n });\n },\n };\n};\n\n/**\n * Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.\n */\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.system.baseDir);\n const configPackageRequire = configESMxCJSRequire;\n const localRequire = isESModule ? createRequire(import.meta.url) : require;\n\n const configurationPath = join(\n configuration.system.configDir,\n `configuration.
|
|
1
|
+
{"version":3,"file":"getIntlayerBundle.cjs","names":["configESMxCJSRequire","isESModule","builtinModules"],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules, createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { bundleFile, type ESBuildPlugin } from '@intlayer/config/file';\nimport {\n configESMxCJSRequire,\n getProjectRequire,\n isESModule,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Rewrites selected bare specifiers (and any of their subpaths) to absolute file paths,\n * using the provided localeRequire (either createRequire(import.meta.url) or require).\n *\n * Example:\n * rewritePathsPlugin([\"@intlayer/config\", \"@intlayer/core\"], localeRequire)\n * …will also rewrite \"@intlayer/core/file\" etc.\n */\nconst rewritePathsPlugin = (\n replaceModules: Record<string, string>,\n excludeModules?: string[]\n): ESBuildPlugin => {\n return {\n name: 'rewrite-paths',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n const exact = replaceModules[args.path];\n\n if (excludeModules?.includes(args.path)) {\n return null;\n }\n\n if (exact) {\n return {\n path: exact,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n\n // Optional: support subpaths like \"@intlayer/core/xyz\"\n for (const key of Object.keys(replaceModules)) {\n if (args.path === key || args.path.startsWith(`${key}/`)) {\n const sub = args.path.slice(key.length); // '' or '/...'\n return {\n path: replaceModules[key] + sub,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n }\n });\n },\n };\n};\n\n/**\n * Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.\n */\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.system.baseDir);\n const configPackageRequire = configESMxCJSRequire;\n const localRequire = isESModule ? createRequire(import.meta.url) : require;\n\n const configurationPath = join(\n configuration.system.configDir,\n `configuration.cjs`\n );\n\n const replaceModules = {\n defu: configPackageRequire.resolve('defu'),\n esbuild: configPackageRequire.resolve('esbuild'),\n '@intlayer/config/built': configurationPath,\n '@intlayer/config/utils': localRequire.resolve('@intlayer/config/utils'),\n '@intlayer/config/client': localRequire.resolve('@intlayer/config/client'),\n '@intlayer/config/logger': localRequire.resolve('@intlayer/config/logger'),\n '@intlayer/core/file': localRequire.resolve('@intlayer/core/file'),\n };\n\n const filePath = rootRequire.resolve('intlayer');\n const code = await readFile(filePath, 'utf-8');\n\n const output = await bundleFile(code, filePath, {\n external: [\n ...builtinModules,\n ...builtinModules.map((mod) => `node:${mod}`),\n ],\n minify: true,\n plugins: [rewritePathsPlugin(replaceModules)],\n });\n\n return output ?? '';\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAM,sBACJ,gBACA,mBACkB;AAClB,QAAO;EACL,MAAM;EACN,MAAM,OAAO;AACX,SAAM,UAAU,EAAE,QAAQ,MAAM,GAAG,SAAS;IAC1C,MAAM,QAAQ,eAAe,KAAK;AAElC,QAAI,gBAAgB,SAAS,KAAK,KAAK,CACrC,QAAO;AAGT,QAAI,MACF,QAAO;KACL,MAAM;KACN,WAAW;KACX,UAAU;KACX;AAIH,SAAK,MAAM,OAAO,OAAO,KAAK,eAAe,CAC3C,KAAI,KAAK,SAAS,OAAO,KAAK,KAAK,WAAW,GAAG,IAAI,GAAG,EAAE;KACxD,MAAM,MAAM,KAAK,KAAK,MAAM,IAAI,OAAO;AACvC,YAAO;MACL,MAAM,eAAe,OAAO;MAC5B,WAAW;MACX,UAAU;MACX;;KAGL;;EAEL;;;;;AAMH,MAAa,oBAAoB,OAAO,kBAAkC;CACxE,MAAM,4DAAgC,cAAc,OAAO,QAAQ;CACnE,MAAM,uBAAuBA;CAC7B,MAAM,eAAeC,iHAA2C,GAAG;CAEnE,MAAM,wCACJ,cAAc,OAAO,WACrB,oBACD;CAED,MAAM,iBAAiB;EACrB,MAAM,qBAAqB,QAAQ,OAAO;EAC1C,SAAS,qBAAqB,QAAQ,UAAU;EAChD,0BAA0B;EAC1B,0BAA0B,aAAa,QAAQ,yBAAyB;EACxE,2BAA2B,aAAa,QAAQ,0BAA0B;EAC1E,2BAA2B,aAAa,QAAQ,0BAA0B;EAC1E,uBAAuB,aAAa,QAAQ,sBAAsB;EACnE;CAED,MAAM,WAAW,YAAY,QAAQ,WAAW;AAYhD,QATe,4CAFF,qCAAe,UAAU,QAAQ,EAER,UAAU;EAC9C,UAAU,CACR,GAAGC,4BACH,GAAGA,2BAAe,KAAK,QAAQ,QAAQ,MAAM,CAC9C;EACD,QAAQ;EACR,SAAS,CAAC,mBAAmB,eAAe,CAAC;EAC9C,CAAC,IAEe"}
|
|
@@ -71,6 +71,25 @@ const runParallel = (proc) => {
|
|
|
71
71
|
child.kill("SIGTERM");
|
|
72
72
|
} catch {}
|
|
73
73
|
};
|
|
74
|
+
const handleExit = () => kill();
|
|
75
|
+
const handleSigInt = () => {
|
|
76
|
+
kill();
|
|
77
|
+
process.off("SIGINT", handleSigInt);
|
|
78
|
+
process.kill(process.pid, "SIGINT");
|
|
79
|
+
};
|
|
80
|
+
const handleSigTerm = () => {
|
|
81
|
+
kill();
|
|
82
|
+
process.off("SIGTERM", handleSigTerm);
|
|
83
|
+
process.kill(process.pid, "SIGTERM");
|
|
84
|
+
};
|
|
85
|
+
process.on("exit", handleExit);
|
|
86
|
+
process.on("SIGINT", handleSigInt);
|
|
87
|
+
process.on("SIGTERM", handleSigTerm);
|
|
88
|
+
child.on("exit", () => {
|
|
89
|
+
process.off("exit", handleExit);
|
|
90
|
+
process.off("SIGINT", handleSigInt);
|
|
91
|
+
process.off("SIGTERM", handleSigTerm);
|
|
92
|
+
});
|
|
74
93
|
return {
|
|
75
94
|
kill,
|
|
76
95
|
result,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["delimiter","spawnWin32","spawnPosix"],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n // Also treat shell-convention exit codes (128 + signal number) as graceful:\n // 129 = SIGHUP, 130 = SIGINT, 131 = SIGQUIT, 143 = SIGTERM\n const gracefulSignalCodes = new Set([129, 130, 131, 143]);\n if (\n code === 0 ||\n gracefulSignalCodes.has(code ?? -1) ||\n (signal && gracefulSignals.includes(signal))\n ) {\n resolve();\n } else {\n reject(\n Object.assign(new Error('Parallel process failed'), { code, signal })\n );\n }\n });\n });\n\n const kill = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n return { kill, result, commandText };\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,eAAe,SAA6C;AACvE,KAAI,CAAC,QAAS,MAAM,QAAQ,KAAK,IAAI,KAAK,WAAW,EACnD,OAAM,IAAI,MAAM,kBAAkB;CAEpC,MAAM,cAAc,MAAM,QAAQ,KAAK,GAAG,KAAK,KAAK,IAAI,GAAG;CAE3D,MAAM,UAAU,MAAM,QAAQ,KAAK;CACnC,MAAM,UAAU,UAAW,KAAkB,KAAK;CAClD,MAAM,OAAO,UAAW,KAAkB,MAAM,EAAE,GAAG,EAAE;CAGvD,MAAM,6BAAc,QAAQ,KAAK,EAAE,gBAAgB,OAAO;CAC1D,MAAM,WACJ,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,QAAQ,IAAI,aAAa,KAAK,OAAO,IACpE;CAEF,MAAM,eAAe,CAAC,QAAQ,QAAQ,IAAI,aAAa,GAAG,CACvD,OAAO,QAAQ,CACf,KAAKA,oBAAU;CAElB,MAAM,WAAW;EACf,GAAG,QAAQ;GACV,WAAW;EACb;CAED,MAAM,QAAQ,QAAQ,aAAa;CACnC,MAAM,YAAY,QAAQC,kDAAaC;CAGvC,MAAM,eAAe;EACnB,KAAK,QAAQ,KAAK;EAClB,OAAO;EACP,KAAK;EACL,OAAO;EACR;CAGD,MAAM,QAAQ,UAEV,KAAK,WAAW,KAAK,KAAK,KAAK,QAAQ,GACrC,QACE,UACE,QAAQ,IAAI,WAAW,WACvB;EAAC;EAAM;EAAM;EAAM;EAAQ,EAC3B,aACD,GACD,UACE,QAAQ,IAAI,SAAS,WACrB,CAAC,MAAM,QAAQ,EACf,aACD,GACH,UAAU,SAAS,MAAM,aAAa,GACxC,QACE,UACE,QAAQ,IAAI,WAAW,WACvB;EAAC;EAAM;EAAM;EAAM;EAAY,EAC/B,aACD,GACD,UACE,QAAQ,IAAI,SAAS,WACrB,CAAC,MAAM,YAAY,EACnB,aACD;CAEP,MAAM,SAAS,IAAI,SAAe,SAAS,WAAW;AACpD,QAAM,GAAG,UAAU,QAAQ;AACzB,OAAI;AACF,YAAQ,MACN,kCAAkC,KAAK,WAAW,OAAO,IAAI,GAC9D;WACK;AACR,UAAO,IAAI;IACX;AAEF,QAAM,GAAG,SAAS,MAAM,WAAW;AAMjC,OACE,SAAS,KAFiB,IAAI,IAAI;IAAC;IAAK;IAAK;IAAK;IAAI,CAAC,CAGnC,IAAI,QAAQ,GAAG,IAClC,UAPqB;IAAC;IAAU;IAAW;IAAW;IAAS,CAOrC,SAAS,OAAO,CAE3C,UAAS;OAET,QACE,OAAO,uBAAO,IAAI,MAAM,0BAA0B,EAAE;IAAE;IAAM;IAAQ,CAAC,CACtE;IAEH;GACF;CAEF,MAAM,aAAa;AACjB,MAAI;AACF,SAAM,KAAK,UAAU;UACf;;
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["delimiter","spawnWin32","spawnPosix"],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n // Also treat shell-convention exit codes (128 + signal number) as graceful:\n // 129 = SIGHUP, 130 = SIGINT, 131 = SIGQUIT, 143 = SIGTERM\n const gracefulSignalCodes = new Set([129, 130, 131, 143]);\n if (\n code === 0 ||\n gracefulSignalCodes.has(code ?? -1) ||\n (signal && gracefulSignals.includes(signal))\n ) {\n resolve();\n } else {\n reject(\n Object.assign(new Error('Parallel process failed'), { code, signal })\n );\n }\n });\n });\n\n const kill = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n const handleExit = () => kill();\n\n const handleSigInt = () => {\n kill();\n process.off('SIGINT', handleSigInt);\n process.kill(process.pid, 'SIGINT'); // Propagate to allow natural shutdown\n };\n\n const handleSigTerm = () => {\n kill();\n process.off('SIGTERM', handleSigTerm);\n process.kill(process.pid, 'SIGTERM'); // Propagate to allow natural shutdown\n };\n\n process.on('exit', handleExit);\n process.on('SIGINT', handleSigInt);\n process.on('SIGTERM', handleSigTerm);\n\n child.on('exit', () => {\n process.off('exit', handleExit);\n process.off('SIGINT', handleSigInt);\n process.off('SIGTERM', handleSigTerm);\n });\n\n return { kill, result, commandText };\n};\n"],"mappings":";;;;;;;;;;;AAcA,MAAa,eAAe,SAA6C;AACvE,KAAI,CAAC,QAAS,MAAM,QAAQ,KAAK,IAAI,KAAK,WAAW,EACnD,OAAM,IAAI,MAAM,kBAAkB;CAEpC,MAAM,cAAc,MAAM,QAAQ,KAAK,GAAG,KAAK,KAAK,IAAI,GAAG;CAE3D,MAAM,UAAU,MAAM,QAAQ,KAAK;CACnC,MAAM,UAAU,UAAW,KAAkB,KAAK;CAClD,MAAM,OAAO,UAAW,KAAkB,MAAM,EAAE,GAAG,EAAE;CAGvD,MAAM,6BAAc,QAAQ,KAAK,EAAE,gBAAgB,OAAO;CAC1D,MAAM,WACJ,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,QAAQ,IAAI,aAAa,KAAK,OAAO,IACpE;CAEF,MAAM,eAAe,CAAC,QAAQ,QAAQ,IAAI,aAAa,GAAG,CACvD,OAAO,QAAQ,CACf,KAAKA,oBAAU;CAElB,MAAM,WAAW;EACf,GAAG,QAAQ;GACV,WAAW;EACb;CAED,MAAM,QAAQ,QAAQ,aAAa;CACnC,MAAM,YAAY,QAAQC,kDAAaC;CAGvC,MAAM,eAAe;EACnB,KAAK,QAAQ,KAAK;EAClB,OAAO;EACP,KAAK;EACL,OAAO;EACR;CAGD,MAAM,QAAQ,UAEV,KAAK,WAAW,KAAK,KAAK,KAAK,QAAQ,GACrC,QACE,UACE,QAAQ,IAAI,WAAW,WACvB;EAAC;EAAM;EAAM;EAAM;EAAQ,EAC3B,aACD,GACD,UACE,QAAQ,IAAI,SAAS,WACrB,CAAC,MAAM,QAAQ,EACf,aACD,GACH,UAAU,SAAS,MAAM,aAAa,GACxC,QACE,UACE,QAAQ,IAAI,WAAW,WACvB;EAAC;EAAM;EAAM;EAAM;EAAY,EAC/B,aACD,GACD,UACE,QAAQ,IAAI,SAAS,WACrB,CAAC,MAAM,YAAY,EACnB,aACD;CAEP,MAAM,SAAS,IAAI,SAAe,SAAS,WAAW;AACpD,QAAM,GAAG,UAAU,QAAQ;AACzB,OAAI;AACF,YAAQ,MACN,kCAAkC,KAAK,WAAW,OAAO,IAAI,GAC9D;WACK;AACR,UAAO,IAAI;IACX;AAEF,QAAM,GAAG,SAAS,MAAM,WAAW;AAMjC,OACE,SAAS,KAFiB,IAAI,IAAI;IAAC;IAAK;IAAK;IAAK;IAAI,CAAC,CAGnC,IAAI,QAAQ,GAAG,IAClC,UAPqB;IAAC;IAAU;IAAW;IAAW;IAAS,CAOrC,SAAS,OAAO,CAE3C,UAAS;OAET,QACE,OAAO,uBAAO,IAAI,MAAM,0BAA0B,EAAE;IAAE;IAAM;IAAQ,CAAC,CACtE;IAEH;GACF;CAEF,MAAM,aAAa;AACjB,MAAI;AACF,SAAM,KAAK,UAAU;UACf;;CAKV,MAAM,mBAAmB,MAAM;CAE/B,MAAM,qBAAqB;AACzB,QAAM;AACN,UAAQ,IAAI,UAAU,aAAa;AACnC,UAAQ,KAAK,QAAQ,KAAK,SAAS;;CAGrC,MAAM,sBAAsB;AAC1B,QAAM;AACN,UAAQ,IAAI,WAAW,cAAc;AACrC,UAAQ,KAAK,QAAQ,KAAK,UAAU;;AAGtC,SAAQ,GAAG,QAAQ,WAAW;AAC9B,SAAQ,GAAG,UAAU,aAAa;AAClC,SAAQ,GAAG,WAAW,cAAc;AAEpC,OAAM,GAAG,cAAc;AACrB,UAAQ,IAAI,QAAQ,WAAW;AAC/B,UAAQ,IAAI,UAAU,aAAa;AACnC,UAAQ,IAAI,WAAW,cAAc;GACrC;AAEF,QAAO;EAAE;EAAM;EAAQ;EAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawnWin32.cjs","names":[],"sources":["../../../../src/utils/runParallel/spawnWin32.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\nimport type { SpawnOptions } from 'node:child_process';\nimport {
|
|
1
|
+
{"version":3,"file":"spawnWin32.cjs","names":[],"sources":["../../../../src/utils/runParallel/spawnWin32.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\nimport type { SpawnOptions } from 'node:child_process';\nimport {\n type ChildProcess,\n spawn as nodeSpawn,\n spawnSync,\n} from 'node:child_process';\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\n/**\n * Kills the new process and its sub processes forcibly.\n */\nconst createKillHandler = (child: ChildProcess) => {\n return (): boolean => {\n if (!child.pid) return false;\n\n try {\n // This MUST be synchronous. Otherwise, it dies with the parent process.\n spawnSync('taskkill', ['/F', '/T', '/PID', String(child.pid)], {\n stdio: 'ignore',\n });\n } catch {\n // ignore\n }\n\n return true;\n };\n};\n\n//------------------------------------------------------------------------------\n// Public Interface\n//------------------------------------------------------------------------------\n\n/**\n * Launches a new process with the given command.\n * This is almost same as `child_process.spawn`.\n *\n * This returns a `ChildProcess` instance.\n * `kill` method of the instance kills the new process and its sub processes forcibly.\n *\n * @param command - The command to run.\n * @param args - List of string arguments.\n * @param options - Options.\n * @returns A ChildProcess instance of new process.\n * @private\n */\nexport const spawnWin32 = (\n command: string,\n args: string[],\n options: SpawnOptions\n): ChildProcess => {\n const child = nodeSpawn(command, args, options);\n child.kill = createKillHandler(child);\n\n return child;\n};\n"],"mappings":";;;;;;;;AAkBA,MAAM,qBAAqB,UAAwB;AACjD,cAAsB;AACpB,MAAI,CAAC,MAAM,IAAK,QAAO;AAEvB,MAAI;AAEF,qCAAU,YAAY;IAAC;IAAM;IAAM;IAAQ,OAAO,MAAM,IAAI;IAAC,EAAE,EAC7D,OAAO,UACR,CAAC;UACI;AAIR,SAAO;;;;;;;;;;;;;;;;AAqBX,MAAa,cACX,SACA,MACA,YACiB;CACjB,MAAM,sCAAkB,SAAS,MAAM,QAAQ;AAC/C,OAAM,OAAO,kBAAkB,MAAM;AAErC,QAAO"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _intlayer_config_node = require("@intlayer/config/node");
|
|
4
|
+
|
|
5
|
+
//#region src/writeConfiguration/generateConfigurationContent.ts
|
|
6
|
+
const generateConfigurationContent = (configuration, format) => {
|
|
7
|
+
const { internationalization, routing, editor, log, metadata } = (0, _intlayer_config_node.buildBrowserConfiguration)(configuration);
|
|
8
|
+
let content = "";
|
|
9
|
+
content += `const internationalization = ${JSON.stringify(internationalization, null, 2)};\n`;
|
|
10
|
+
content += `const routing = ${JSON.stringify(routing, null, 2)};\n`;
|
|
11
|
+
content += `const editor = ${JSON.stringify(editor, null, 2)};\n`;
|
|
12
|
+
content += `const log = ${JSON.stringify(log, null, 2)};\n`;
|
|
13
|
+
content += `const metadata = ${JSON.stringify(metadata, null, 2)};\n`;
|
|
14
|
+
content += `const configuration = { internationalization, routing, editor, log, metadata };\n`;
|
|
15
|
+
if (format === "esm") {
|
|
16
|
+
content += `\nexport { internationalization, routing, editor, log, metadata, configuration };\n`;
|
|
17
|
+
content += `export default configuration;\n`;
|
|
18
|
+
} else {
|
|
19
|
+
content += `\nmodule.exports.internationalization = internationalization;\n`;
|
|
20
|
+
content += `module.exports.routing = routing;\n`;
|
|
21
|
+
content += `module.exports.editor = editor;\n`;
|
|
22
|
+
content += `module.exports.log = log;\n`;
|
|
23
|
+
content += `module.exports.metadata = metadata;\n`;
|
|
24
|
+
content += `module.exports = configuration;\n`;
|
|
25
|
+
}
|
|
26
|
+
return content;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.generateConfigurationContent = generateConfigurationContent;
|
|
31
|
+
//# sourceMappingURL=generateConfigurationContent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateConfigurationContent.cjs","names":[],"sources":["../../../src/writeConfiguration/generateConfigurationContent.ts"],"sourcesContent":["import { buildBrowserConfiguration } from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const generateConfigurationContent = (\n configuration: IntlayerConfig,\n format: 'cjs' | 'esm'\n): string => {\n const { internationalization, routing, editor, log, metadata } =\n buildBrowserConfiguration(configuration);\n\n let content = '';\n\n content += `const internationalization = ${JSON.stringify(internationalization, null, 2)};\\n`;\n content += `const routing = ${JSON.stringify(routing, null, 2)};\\n`;\n content += `const editor = ${JSON.stringify(editor, null, 2)};\\n`;\n content += `const log = ${JSON.stringify(log, null, 2)};\\n`;\n content += `const metadata = ${JSON.stringify(metadata, null, 2)};\\n`;\n content += `const configuration = { internationalization, routing, editor, log, metadata };\\n`;\n\n if (format === 'esm') {\n content += `\\nexport { internationalization, routing, editor, log, metadata, configuration };\\n`;\n content += `export default configuration;\\n`;\n } else {\n content += `\\nmodule.exports.internationalization = internationalization;\\n`;\n content += `module.exports.routing = routing;\\n`;\n content += `module.exports.editor = editor;\\n`;\n content += `module.exports.log = log;\\n`;\n content += `module.exports.metadata = metadata;\\n`;\n content += `module.exports = configuration;\\n`;\n }\n\n return content;\n};\n"],"mappings":";;;;;AAGA,MAAa,gCACX,eACA,WACW;CACX,MAAM,EAAE,sBAAsB,SAAS,QAAQ,KAAK,kEACxB,cAAc;CAE1C,IAAI,UAAU;AAEd,YAAW,gCAAgC,KAAK,UAAU,sBAAsB,MAAM,EAAE,CAAC;AACzF,YAAW,mBAAmB,KAAK,UAAU,SAAS,MAAM,EAAE,CAAC;AAC/D,YAAW,kBAAkB,KAAK,UAAU,QAAQ,MAAM,EAAE,CAAC;AAC7D,YAAW,eAAe,KAAK,UAAU,KAAK,MAAM,EAAE,CAAC;AACvD,YAAW,oBAAoB,KAAK,UAAU,UAAU,MAAM,EAAE,CAAC;AACjE,YAAW;AAEX,KAAI,WAAW,OAAO;AACpB,aAAW;AACX,aAAW;QACN;AACL,aAAW;AACX,aAAW;AACX,aAAW;AACX,aAAW;AACX,aAAW;AACX,aAAW;;AAGb,QAAO"}
|
|
@@ -1,40 +1,22 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_writeFileIfChanged = require('../writeFileIfChanged.cjs');
|
|
4
|
+
const require_writeConfiguration_generateConfigurationContent = require('./generateConfigurationContent.cjs');
|
|
4
5
|
let node_fs_promises = require("node:fs/promises");
|
|
5
6
|
let node_path = require("node:path");
|
|
6
|
-
let node_util = require("node:util");
|
|
7
7
|
|
|
8
8
|
//#region src/writeConfiguration/index.ts
|
|
9
|
-
const getCachedConfiguration = async (configuration) => {
|
|
10
|
-
const configurationContent = await (0, node_fs_promises.readFile)((0, node_path.join)(configuration.system.configDir, "configuration.json"), "utf8");
|
|
11
|
-
return JSON.parse(configurationContent);
|
|
12
|
-
};
|
|
13
9
|
const isCachedConfigurationUpToDate = async (configuration) => {
|
|
14
10
|
try {
|
|
15
|
-
|
|
16
|
-
return (0, node_util.isDeepStrictEqual)(await getCachedConfiguration(configuration), cleanedConfiguration);
|
|
11
|
+
return await (0, node_fs_promises.readFile)((0, node_path.join)(configuration.system.configDir, "configuration.mjs"), "utf8") === require_writeConfiguration_generateConfigurationContent.generateConfigurationContent(configuration, "esm");
|
|
17
12
|
} catch {
|
|
18
13
|
return null;
|
|
19
14
|
}
|
|
20
15
|
};
|
|
21
|
-
const cleanConfiguration = (configuration) => {
|
|
22
|
-
return JSON.parse(JSON.stringify({
|
|
23
|
-
internationalization: {
|
|
24
|
-
locales: configuration.internationalization.locales,
|
|
25
|
-
defaultLocale: configuration.internationalization.defaultLocale
|
|
26
|
-
},
|
|
27
|
-
editor: configuration.editor,
|
|
28
|
-
log: configuration.log,
|
|
29
|
-
routing: configuration.routing,
|
|
30
|
-
metadata: configuration.metadata
|
|
31
|
-
}));
|
|
32
|
-
};
|
|
33
16
|
const writeConfiguration = async (configuration) => {
|
|
34
|
-
const {
|
|
35
|
-
const { configDir } = system;
|
|
17
|
+
const { configDir } = configuration.system;
|
|
36
18
|
await (0, node_fs_promises.mkdir)(configDir, { recursive: true });
|
|
37
|
-
await
|
|
19
|
+
await Promise.all([require_writeFileIfChanged.writeFileIfChanged((0, node_path.join)(configDir, "configuration.mjs"), require_writeConfiguration_generateConfigurationContent.generateConfigurationContent(configuration, "esm")), require_writeFileIfChanged.writeFileIfChanged((0, node_path.join)(configDir, "configuration.cjs"), require_writeConfiguration_generateConfigurationContent.generateConfigurationContent(configuration, "cjs"))]);
|
|
38
20
|
};
|
|
39
21
|
|
|
40
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["generateConfigurationContent","writeFileIfChanged"],"sources":["../../../src/writeConfiguration/index.ts"],"sourcesContent":["import { mkdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { generateConfigurationContent } from './generateConfigurationContent';\n\nexport const isCachedConfigurationUpToDate = async (\n configuration: IntlayerConfig\n): Promise<boolean | null> => {\n try {\n const mjsPath = join(configuration.system.configDir, 'configuration.mjs');\n const existingContent = await readFile(mjsPath, 'utf8');\n const expectedContent = generateConfigurationContent(configuration, 'esm');\n return existingContent === expectedContent;\n } catch {\n return null; // Can crash if file doesn't exist yet or config is not defined\n }\n};\n\nexport const writeConfiguration = async (configuration: IntlayerConfig) => {\n const { configDir } = configuration.system;\n\n await mkdir(configDir, { recursive: true });\n\n await Promise.all([\n writeFileIfChanged(\n join(configDir, 'configuration.mjs'),\n generateConfigurationContent(configuration, 'esm')\n ),\n writeFileIfChanged(\n join(configDir, 'configuration.cjs'),\n generateConfigurationContent(configuration, 'cjs')\n ),\n ]);\n};\n"],"mappings":";;;;;;;;AAMA,MAAa,gCAAgC,OAC3C,kBAC4B;AAC5B,KAAI;AAIF,SAFwB,yDADH,cAAc,OAAO,WAAW,oBAAoB,EACzB,OAAO,KAC/BA,qFAA6B,eAAe,MAAM;SAEpE;AACN,SAAO;;;AAIX,MAAa,qBAAqB,OAAO,kBAAkC;CACzE,MAAM,EAAE,cAAc,cAAc;AAEpC,mCAAY,WAAW,EAAE,WAAW,MAAM,CAAC;AAE3C,OAAM,QAAQ,IAAI,CAChBC,kEACO,WAAW,oBAAoB,EACpCD,qFAA6B,eAAe,MAAM,CACnD,EACDC,kEACO,WAAW,oBAAoB,EACpCD,qFAA6B,eAAe,MAAM,CACnD,CACF,CAAC"}
|
|
@@ -45,7 +45,7 @@ const getIntlayerBundle = async (configuration) => {
|
|
|
45
45
|
const rootRequire = getProjectRequire(configuration.system.baseDir);
|
|
46
46
|
const configPackageRequire = configESMxCJSRequire;
|
|
47
47
|
const localRequire = isESModule ? createRequire(import.meta.url) : __require;
|
|
48
|
-
const configurationPath = join(configuration.system.configDir, `configuration.
|
|
48
|
+
const configurationPath = join(configuration.system.configDir, `configuration.cjs`);
|
|
49
49
|
const replaceModules = {
|
|
50
50
|
defu: configPackageRequire.resolve("defu"),
|
|
51
51
|
esbuild: configPackageRequire.resolve("esbuild"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayerBundle.mjs","names":[],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules, createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { bundleFile, type ESBuildPlugin } from '@intlayer/config/file';\nimport {\n configESMxCJSRequire,\n getProjectRequire,\n isESModule,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Rewrites selected bare specifiers (and any of their subpaths) to absolute file paths,\n * using the provided localeRequire (either createRequire(import.meta.url) or require).\n *\n * Example:\n * rewritePathsPlugin([\"@intlayer/config\", \"@intlayer/core\"], localeRequire)\n * …will also rewrite \"@intlayer/core/file\" etc.\n */\nconst rewritePathsPlugin = (\n replaceModules: Record<string, string>,\n excludeModules?: string[]\n): ESBuildPlugin => {\n return {\n name: 'rewrite-paths',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n const exact = replaceModules[args.path];\n\n if (excludeModules?.includes(args.path)) {\n return null;\n }\n\n if (exact) {\n return {\n path: exact,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n\n // Optional: support subpaths like \"@intlayer/core/xyz\"\n for (const key of Object.keys(replaceModules)) {\n if (args.path === key || args.path.startsWith(`${key}/`)) {\n const sub = args.path.slice(key.length); // '' or '/...'\n return {\n path: replaceModules[key] + sub,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n }\n });\n },\n };\n};\n\n/**\n * Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.\n */\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.system.baseDir);\n const configPackageRequire = configESMxCJSRequire;\n const localRequire = isESModule ? createRequire(import.meta.url) : require;\n\n const configurationPath = join(\n configuration.system.configDir,\n `configuration.
|
|
1
|
+
{"version":3,"file":"getIntlayerBundle.mjs","names":[],"sources":["../../../src/loadDictionaries/getIntlayerBundle.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { builtinModules, createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { bundleFile, type ESBuildPlugin } from '@intlayer/config/file';\nimport {\n configESMxCJSRequire,\n getProjectRequire,\n isESModule,\n} from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Rewrites selected bare specifiers (and any of their subpaths) to absolute file paths,\n * using the provided localeRequire (either createRequire(import.meta.url) or require).\n *\n * Example:\n * rewritePathsPlugin([\"@intlayer/config\", \"@intlayer/core\"], localeRequire)\n * …will also rewrite \"@intlayer/core/file\" etc.\n */\nconst rewritePathsPlugin = (\n replaceModules: Record<string, string>,\n excludeModules?: string[]\n): ESBuildPlugin => {\n return {\n name: 'rewrite-paths',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n const exact = replaceModules[args.path];\n\n if (excludeModules?.includes(args.path)) {\n return null;\n }\n\n if (exact) {\n return {\n path: exact,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n\n // Optional: support subpaths like \"@intlayer/core/xyz\"\n for (const key of Object.keys(replaceModules)) {\n if (args.path === key || args.path.startsWith(`${key}/`)) {\n const sub = args.path.slice(key.length); // '' or '/...'\n return {\n path: replaceModules[key] + sub,\n namespace: 'intlayer-replace-modules',\n external: true, // ← prevents onLoad requirement\n };\n }\n }\n });\n },\n };\n};\n\n/**\n * Get the intlayer bundle to embed @intlayer/core and be able to mock @intlayer/config/built to mock the configuration file.\n */\nexport const getIntlayerBundle = async (configuration: IntlayerConfig) => {\n const rootRequire = getProjectRequire(configuration.system.baseDir);\n const configPackageRequire = configESMxCJSRequire;\n const localRequire = isESModule ? createRequire(import.meta.url) : require;\n\n const configurationPath = join(\n configuration.system.configDir,\n `configuration.cjs`\n );\n\n const replaceModules = {\n defu: configPackageRequire.resolve('defu'),\n esbuild: configPackageRequire.resolve('esbuild'),\n '@intlayer/config/built': configurationPath,\n '@intlayer/config/utils': localRequire.resolve('@intlayer/config/utils'),\n '@intlayer/config/client': localRequire.resolve('@intlayer/config/client'),\n '@intlayer/config/logger': localRequire.resolve('@intlayer/config/logger'),\n '@intlayer/core/file': localRequire.resolve('@intlayer/core/file'),\n };\n\n const filePath = rootRequire.resolve('intlayer');\n const code = await readFile(filePath, 'utf-8');\n\n const output = await bundleFile(code, filePath, {\n external: [\n ...builtinModules,\n ...builtinModules.map((mod) => `node:${mod}`),\n ],\n minify: true,\n plugins: [rewritePathsPlugin(replaceModules)],\n });\n\n return output ?? '';\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,MAAM,sBACJ,gBACA,mBACkB;AAClB,QAAO;EACL,MAAM;EACN,MAAM,OAAO;AACX,SAAM,UAAU,EAAE,QAAQ,MAAM,GAAG,SAAS;IAC1C,MAAM,QAAQ,eAAe,KAAK;AAElC,QAAI,gBAAgB,SAAS,KAAK,KAAK,CACrC,QAAO;AAGT,QAAI,MACF,QAAO;KACL,MAAM;KACN,WAAW;KACX,UAAU;KACX;AAIH,SAAK,MAAM,OAAO,OAAO,KAAK,eAAe,CAC3C,KAAI,KAAK,SAAS,OAAO,KAAK,KAAK,WAAW,GAAG,IAAI,GAAG,EAAE;KACxD,MAAM,MAAM,KAAK,KAAK,MAAM,IAAI,OAAO;AACvC,YAAO;MACL,MAAM,eAAe,OAAO;MAC5B,WAAW;MACX,UAAU;MACX;;KAGL;;EAEL;;;;;AAMH,MAAa,oBAAoB,OAAO,kBAAkC;CACxE,MAAM,cAAc,kBAAkB,cAAc,OAAO,QAAQ;CACnE,MAAM,uBAAuB;CAC7B,MAAM,eAAe,aAAa,cAAc,OAAO,KAAK,IAAI;CAEhE,MAAM,oBAAoB,KACxB,cAAc,OAAO,WACrB,oBACD;CAED,MAAM,iBAAiB;EACrB,MAAM,qBAAqB,QAAQ,OAAO;EAC1C,SAAS,qBAAqB,QAAQ,UAAU;EAChD,0BAA0B;EAC1B,0BAA0B,aAAa,QAAQ,yBAAyB;EACxE,2BAA2B,aAAa,QAAQ,0BAA0B;EAC1E,2BAA2B,aAAa,QAAQ,0BAA0B;EAC1E,uBAAuB,aAAa,QAAQ,sBAAsB;EACnE;CAED,MAAM,WAAW,YAAY,QAAQ,WAAW;AAYhD,QATe,MAAM,WAFR,MAAM,SAAS,UAAU,QAAQ,EAER,UAAU;EAC9C,UAAU,CACR,GAAG,gBACH,GAAG,eAAe,KAAK,QAAQ,QAAQ,MAAM,CAC9C;EACD,QAAQ;EACR,SAAS,CAAC,mBAAmB,eAAe,CAAC;EAC9C,CAAC,IAEe"}
|
|
@@ -69,6 +69,25 @@ const runParallel = (proc) => {
|
|
|
69
69
|
child.kill("SIGTERM");
|
|
70
70
|
} catch {}
|
|
71
71
|
};
|
|
72
|
+
const handleExit = () => kill();
|
|
73
|
+
const handleSigInt = () => {
|
|
74
|
+
kill();
|
|
75
|
+
process.off("SIGINT", handleSigInt);
|
|
76
|
+
process.kill(process.pid, "SIGINT");
|
|
77
|
+
};
|
|
78
|
+
const handleSigTerm = () => {
|
|
79
|
+
kill();
|
|
80
|
+
process.off("SIGTERM", handleSigTerm);
|
|
81
|
+
process.kill(process.pid, "SIGTERM");
|
|
82
|
+
};
|
|
83
|
+
process.on("exit", handleExit);
|
|
84
|
+
process.on("SIGINT", handleSigInt);
|
|
85
|
+
process.on("SIGTERM", handleSigTerm);
|
|
86
|
+
child.on("exit", () => {
|
|
87
|
+
process.off("exit", handleExit);
|
|
88
|
+
process.off("SIGINT", handleSigInt);
|
|
89
|
+
process.off("SIGTERM", handleSigTerm);
|
|
90
|
+
});
|
|
72
91
|
return {
|
|
73
92
|
kill,
|
|
74
93
|
result,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n // Also treat shell-convention exit codes (128 + signal number) as graceful:\n // 129 = SIGHUP, 130 = SIGINT, 131 = SIGQUIT, 143 = SIGTERM\n const gracefulSignalCodes = new Set([129, 130, 131, 143]);\n if (\n code === 0 ||\n gracefulSignalCodes.has(code ?? -1) ||\n (signal && gracefulSignals.includes(signal))\n ) {\n resolve();\n } else {\n reject(\n Object.assign(new Error('Parallel process failed'), { code, signal })\n );\n }\n });\n });\n\n const kill = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n return { kill, result, commandText };\n};\n"],"mappings":";;;;;;;;;AAcA,MAAa,eAAe,SAA6C;AACvE,KAAI,CAAC,QAAS,MAAM,QAAQ,KAAK,IAAI,KAAK,WAAW,EACnD,OAAM,IAAI,MAAM,kBAAkB;CAEpC,MAAM,cAAc,MAAM,QAAQ,KAAK,GAAG,KAAK,KAAK,IAAI,GAAG;CAE3D,MAAM,UAAU,MAAM,QAAQ,KAAK;CACnC,MAAM,UAAU,UAAW,KAAkB,KAAK;CAClD,MAAM,OAAO,UAAW,KAAkB,MAAM,EAAE,GAAG,EAAE;CAGvD,MAAM,SAAS,KAAK,QAAQ,KAAK,EAAE,gBAAgB,OAAO;CAC1D,MAAM,WACJ,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,QAAQ,IAAI,aAAa,KAAK,OAAO,IACpE;CAEF,MAAM,eAAe,CAAC,QAAQ,QAAQ,IAAI,aAAa,GAAG,CACvD,OAAO,QAAQ,CACf,KAAK,UAAU;CAElB,MAAM,WAAW;EACf,GAAG,QAAQ;GACV,WAAW;EACb;CAED,MAAM,QAAQ,QAAQ,aAAa;CACnC,MAAM,YAAY,QAAQ,aAAa;CAGvC,MAAM,eAAe;EACnB,KAAK,QAAQ,KAAK;EAClB,OAAO;EACP,KAAK;EACL,OAAO;EACR;CAGD,MAAM,QAAQ,UAEV,KAAK,WAAW,KAAK,KAAK,KAAK,QAAQ,GACrC,QACE,UACE,QAAQ,IAAI,WAAW,WACvB;EAAC;EAAM;EAAM;EAAM;EAAQ,EAC3B,aACD,GACD,UACE,QAAQ,IAAI,SAAS,WACrB,CAAC,MAAM,QAAQ,EACf,aACD,GACH,UAAU,SAAS,MAAM,aAAa,GACxC,QACE,UACE,QAAQ,IAAI,WAAW,WACvB;EAAC;EAAM;EAAM;EAAM;EAAY,EAC/B,aACD,GACD,UACE,QAAQ,IAAI,SAAS,WACrB,CAAC,MAAM,YAAY,EACnB,aACD;CAEP,MAAM,SAAS,IAAI,SAAe,SAAS,WAAW;AACpD,QAAM,GAAG,UAAU,QAAQ;AACzB,OAAI;AACF,YAAQ,MACN,kCAAkC,KAAK,WAAW,OAAO,IAAI,GAC9D;WACK;AACR,UAAO,IAAI;IACX;AAEF,QAAM,GAAG,SAAS,MAAM,WAAW;AAMjC,OACE,SAAS,KAFiB,IAAI,IAAI;IAAC;IAAK;IAAK;IAAK;IAAI,CAAC,CAGnC,IAAI,QAAQ,GAAG,IAClC,UAPqB;IAAC;IAAU;IAAW;IAAW;IAAS,CAOrC,SAAS,OAAO,CAE3C,UAAS;OAET,QACE,OAAO,uBAAO,IAAI,MAAM,0BAA0B,EAAE;IAAE;IAAM;IAAQ,CAAC,CACtE;IAEH;GACF;CAEF,MAAM,aAAa;AACjB,MAAI;AACF,SAAM,KAAK,UAAU;UACf;;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/utils/runParallel/index.ts"],"sourcesContent":["import { delimiter, join } from 'node:path';\nimport { spawnPosix } from './spawnPosix';\nimport { spawnWin32 } from './spawnWin32';\n\nexport type ParallelHandle = {\n kill: () => void;\n result: Promise<any>;\n commandText: string;\n};\n\n/**\n * Start a cross-platform parallel process using npm-run-all approach.\n * Accepts either a single string (e.g., 'next start') or an array of tokens (e.g., ['next', 'start']).\n */\nexport const runParallel = (proc?: string | string[]): ParallelHandle => {\n if (!proc || (Array.isArray(proc) && proc.length === 0))\n throw new Error('Invalid command');\n\n const commandText = Array.isArray(proc) ? proc.join(' ') : proc;\n\n const isArray = Array.isArray(proc);\n const command = isArray ? (proc as string[])[0] : commandText;\n const args = isArray ? (proc as string[]).slice(1) : [];\n\n // Ensure local binaries (node_modules/.bin) are resolvable\n const cwdBin = join(process.cwd(), 'node_modules', '.bin');\n const PATH_KEY =\n Object.keys(process.env).find((key) => key.toLowerCase() === 'path') ??\n 'PATH';\n\n const extendedPath = [cwdBin, process.env[PATH_KEY] ?? '']\n .filter(Boolean)\n .join(delimiter);\n\n const childEnv = {\n ...process.env,\n [PATH_KEY]: extendedPath,\n } as NodeJS.ProcessEnv;\n\n const isWin = process.platform === 'win32';\n const spawnFunc = isWin ? spawnWin32 : spawnPosix;\n\n // Spawn options\n const spawnOptions = {\n cwd: process.cwd(),\n stdio: 'inherit' as const,\n env: childEnv,\n shell: isWin,\n };\n\n // Spawn the child process\n const child = isArray\n ? // If provided as a single string element that includes spaces, treat it like a shell command\n args.length === 0 && /\\s/.test(command)\n ? isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', command],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', command],\n spawnOptions\n )\n : spawnFunc(command, args, spawnOptions)\n : isWin\n ? spawnFunc(\n process.env.ComSpec ?? 'cmd.exe',\n ['/d', '/s', '/c', commandText],\n spawnOptions\n )\n : spawnFunc(\n process.env.SHELL ?? '/bin/sh',\n ['-c', commandText],\n spawnOptions\n );\n\n const result = new Promise<void>((resolve, reject) => {\n child.on('error', (err) => {\n try {\n console.error(\n `[runParallel] Failed to start: ${err?.message ?? String(err)}`\n );\n } catch {}\n reject(err);\n });\n\n child.on('exit', (code, signal) => {\n // Treat common termination signals as graceful exits, not failures\n const gracefulSignals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP'];\n // Also treat shell-convention exit codes (128 + signal number) as graceful:\n // 129 = SIGHUP, 130 = SIGINT, 131 = SIGQUIT, 143 = SIGTERM\n const gracefulSignalCodes = new Set([129, 130, 131, 143]);\n if (\n code === 0 ||\n gracefulSignalCodes.has(code ?? -1) ||\n (signal && gracefulSignals.includes(signal))\n ) {\n resolve();\n } else {\n reject(\n Object.assign(new Error('Parallel process failed'), { code, signal })\n );\n }\n });\n });\n\n const kill = () => {\n try {\n child.kill('SIGTERM');\n } catch {\n // Best effort\n }\n };\n\n const handleExit = () => kill();\n\n const handleSigInt = () => {\n kill();\n process.off('SIGINT', handleSigInt);\n process.kill(process.pid, 'SIGINT'); // Propagate to allow natural shutdown\n };\n\n const handleSigTerm = () => {\n kill();\n process.off('SIGTERM', handleSigTerm);\n process.kill(process.pid, 'SIGTERM'); // Propagate to allow natural shutdown\n };\n\n process.on('exit', handleExit);\n process.on('SIGINT', handleSigInt);\n process.on('SIGTERM', handleSigTerm);\n\n child.on('exit', () => {\n process.off('exit', handleExit);\n process.off('SIGINT', handleSigInt);\n process.off('SIGTERM', handleSigTerm);\n });\n\n return { kill, result, commandText };\n};\n"],"mappings":";;;;;;;;;AAcA,MAAa,eAAe,SAA6C;AACvE,KAAI,CAAC,QAAS,MAAM,QAAQ,KAAK,IAAI,KAAK,WAAW,EACnD,OAAM,IAAI,MAAM,kBAAkB;CAEpC,MAAM,cAAc,MAAM,QAAQ,KAAK,GAAG,KAAK,KAAK,IAAI,GAAG;CAE3D,MAAM,UAAU,MAAM,QAAQ,KAAK;CACnC,MAAM,UAAU,UAAW,KAAkB,KAAK;CAClD,MAAM,OAAO,UAAW,KAAkB,MAAM,EAAE,GAAG,EAAE;CAGvD,MAAM,SAAS,KAAK,QAAQ,KAAK,EAAE,gBAAgB,OAAO;CAC1D,MAAM,WACJ,OAAO,KAAK,QAAQ,IAAI,CAAC,MAAM,QAAQ,IAAI,aAAa,KAAK,OAAO,IACpE;CAEF,MAAM,eAAe,CAAC,QAAQ,QAAQ,IAAI,aAAa,GAAG,CACvD,OAAO,QAAQ,CACf,KAAK,UAAU;CAElB,MAAM,WAAW;EACf,GAAG,QAAQ;GACV,WAAW;EACb;CAED,MAAM,QAAQ,QAAQ,aAAa;CACnC,MAAM,YAAY,QAAQ,aAAa;CAGvC,MAAM,eAAe;EACnB,KAAK,QAAQ,KAAK;EAClB,OAAO;EACP,KAAK;EACL,OAAO;EACR;CAGD,MAAM,QAAQ,UAEV,KAAK,WAAW,KAAK,KAAK,KAAK,QAAQ,GACrC,QACE,UACE,QAAQ,IAAI,WAAW,WACvB;EAAC;EAAM;EAAM;EAAM;EAAQ,EAC3B,aACD,GACD,UACE,QAAQ,IAAI,SAAS,WACrB,CAAC,MAAM,QAAQ,EACf,aACD,GACH,UAAU,SAAS,MAAM,aAAa,GACxC,QACE,UACE,QAAQ,IAAI,WAAW,WACvB;EAAC;EAAM;EAAM;EAAM;EAAY,EAC/B,aACD,GACD,UACE,QAAQ,IAAI,SAAS,WACrB,CAAC,MAAM,YAAY,EACnB,aACD;CAEP,MAAM,SAAS,IAAI,SAAe,SAAS,WAAW;AACpD,QAAM,GAAG,UAAU,QAAQ;AACzB,OAAI;AACF,YAAQ,MACN,kCAAkC,KAAK,WAAW,OAAO,IAAI,GAC9D;WACK;AACR,UAAO,IAAI;IACX;AAEF,QAAM,GAAG,SAAS,MAAM,WAAW;AAMjC,OACE,SAAS,KAFiB,IAAI,IAAI;IAAC;IAAK;IAAK;IAAK;IAAI,CAAC,CAGnC,IAAI,QAAQ,GAAG,IAClC,UAPqB;IAAC;IAAU;IAAW;IAAW;IAAS,CAOrC,SAAS,OAAO,CAE3C,UAAS;OAET,QACE,OAAO,uBAAO,IAAI,MAAM,0BAA0B,EAAE;IAAE;IAAM;IAAQ,CAAC,CACtE;IAEH;GACF;CAEF,MAAM,aAAa;AACjB,MAAI;AACF,SAAM,KAAK,UAAU;UACf;;CAKV,MAAM,mBAAmB,MAAM;CAE/B,MAAM,qBAAqB;AACzB,QAAM;AACN,UAAQ,IAAI,UAAU,aAAa;AACnC,UAAQ,KAAK,QAAQ,KAAK,SAAS;;CAGrC,MAAM,sBAAsB;AAC1B,QAAM;AACN,UAAQ,IAAI,WAAW,cAAc;AACrC,UAAQ,KAAK,QAAQ,KAAK,UAAU;;AAGtC,SAAQ,GAAG,QAAQ,WAAW;AAC9B,SAAQ,GAAG,UAAU,aAAa;AAClC,SAAQ,GAAG,WAAW,cAAc;AAEpC,OAAM,GAAG,cAAc;AACrB,UAAQ,IAAI,QAAQ,WAAW;AAC/B,UAAQ,IAAI,UAAU,aAAa;AACnC,UAAQ,IAAI,WAAW,cAAc;GACrC;AAEF,QAAO;EAAE;EAAM;EAAQ;EAAa"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/runParallel/spawnWin32.ts
|
|
4
4
|
/**
|
|
@@ -8,7 +8,7 @@ const createKillHandler = (child) => {
|
|
|
8
8
|
return () => {
|
|
9
9
|
if (!child.pid) return false;
|
|
10
10
|
try {
|
|
11
|
-
|
|
11
|
+
spawnSync("taskkill", [
|
|
12
12
|
"/F",
|
|
13
13
|
"/T",
|
|
14
14
|
"/PID",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawnWin32.mjs","names":["nodeSpawn"],"sources":["../../../../src/utils/runParallel/spawnWin32.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\nimport type { SpawnOptions } from 'node:child_process';\nimport {
|
|
1
|
+
{"version":3,"file":"spawnWin32.mjs","names":["nodeSpawn"],"sources":["../../../../src/utils/runParallel/spawnWin32.ts"],"sourcesContent":["//------------------------------------------------------------------------------\n// Requirements\n//------------------------------------------------------------------------------\n\nimport type { SpawnOptions } from 'node:child_process';\nimport {\n type ChildProcess,\n spawn as nodeSpawn,\n spawnSync,\n} from 'node:child_process';\n\n//------------------------------------------------------------------------------\n// Helpers\n//------------------------------------------------------------------------------\n\n/**\n * Kills the new process and its sub processes forcibly.\n */\nconst createKillHandler = (child: ChildProcess) => {\n return (): boolean => {\n if (!child.pid) return false;\n\n try {\n // This MUST be synchronous. Otherwise, it dies with the parent process.\n spawnSync('taskkill', ['/F', '/T', '/PID', String(child.pid)], {\n stdio: 'ignore',\n });\n } catch {\n // ignore\n }\n\n return true;\n };\n};\n\n//------------------------------------------------------------------------------\n// Public Interface\n//------------------------------------------------------------------------------\n\n/**\n * Launches a new process with the given command.\n * This is almost same as `child_process.spawn`.\n *\n * This returns a `ChildProcess` instance.\n * `kill` method of the instance kills the new process and its sub processes forcibly.\n *\n * @param command - The command to run.\n * @param args - List of string arguments.\n * @param options - Options.\n * @returns A ChildProcess instance of new process.\n * @private\n */\nexport const spawnWin32 = (\n command: string,\n args: string[],\n options: SpawnOptions\n): ChildProcess => {\n const child = nodeSpawn(command, args, options);\n child.kill = createKillHandler(child);\n\n return child;\n};\n"],"mappings":";;;;;;AAkBA,MAAM,qBAAqB,UAAwB;AACjD,cAAsB;AACpB,MAAI,CAAC,MAAM,IAAK,QAAO;AAEvB,MAAI;AAEF,aAAU,YAAY;IAAC;IAAM;IAAM;IAAQ,OAAO,MAAM,IAAI;IAAC,EAAE,EAC7D,OAAO,UACR,CAAC;UACI;AAIR,SAAO;;;;;;;;;;;;;;;;AAqBX,MAAa,cACX,SACA,MACA,YACiB;CACjB,MAAM,QAAQA,MAAU,SAAS,MAAM,QAAQ;AAC/C,OAAM,OAAO,kBAAkB,MAAM;AAErC,QAAO"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { buildBrowserConfiguration } from "@intlayer/config/node";
|
|
2
|
+
|
|
3
|
+
//#region src/writeConfiguration/generateConfigurationContent.ts
|
|
4
|
+
const generateConfigurationContent = (configuration, format) => {
|
|
5
|
+
const { internationalization, routing, editor, log, metadata } = buildBrowserConfiguration(configuration);
|
|
6
|
+
let content = "";
|
|
7
|
+
content += `const internationalization = ${JSON.stringify(internationalization, null, 2)};\n`;
|
|
8
|
+
content += `const routing = ${JSON.stringify(routing, null, 2)};\n`;
|
|
9
|
+
content += `const editor = ${JSON.stringify(editor, null, 2)};\n`;
|
|
10
|
+
content += `const log = ${JSON.stringify(log, null, 2)};\n`;
|
|
11
|
+
content += `const metadata = ${JSON.stringify(metadata, null, 2)};\n`;
|
|
12
|
+
content += `const configuration = { internationalization, routing, editor, log, metadata };\n`;
|
|
13
|
+
if (format === "esm") {
|
|
14
|
+
content += `\nexport { internationalization, routing, editor, log, metadata, configuration };\n`;
|
|
15
|
+
content += `export default configuration;\n`;
|
|
16
|
+
} else {
|
|
17
|
+
content += `\nmodule.exports.internationalization = internationalization;\n`;
|
|
18
|
+
content += `module.exports.routing = routing;\n`;
|
|
19
|
+
content += `module.exports.editor = editor;\n`;
|
|
20
|
+
content += `module.exports.log = log;\n`;
|
|
21
|
+
content += `module.exports.metadata = metadata;\n`;
|
|
22
|
+
content += `module.exports = configuration;\n`;
|
|
23
|
+
}
|
|
24
|
+
return content;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { generateConfigurationContent };
|
|
29
|
+
//# sourceMappingURL=generateConfigurationContent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateConfigurationContent.mjs","names":[],"sources":["../../../src/writeConfiguration/generateConfigurationContent.ts"],"sourcesContent":["import { buildBrowserConfiguration } from '@intlayer/config/node';\nimport type { IntlayerConfig } from '@intlayer/types/config';\n\nexport const generateConfigurationContent = (\n configuration: IntlayerConfig,\n format: 'cjs' | 'esm'\n): string => {\n const { internationalization, routing, editor, log, metadata } =\n buildBrowserConfiguration(configuration);\n\n let content = '';\n\n content += `const internationalization = ${JSON.stringify(internationalization, null, 2)};\\n`;\n content += `const routing = ${JSON.stringify(routing, null, 2)};\\n`;\n content += `const editor = ${JSON.stringify(editor, null, 2)};\\n`;\n content += `const log = ${JSON.stringify(log, null, 2)};\\n`;\n content += `const metadata = ${JSON.stringify(metadata, null, 2)};\\n`;\n content += `const configuration = { internationalization, routing, editor, log, metadata };\\n`;\n\n if (format === 'esm') {\n content += `\\nexport { internationalization, routing, editor, log, metadata, configuration };\\n`;\n content += `export default configuration;\\n`;\n } else {\n content += `\\nmodule.exports.internationalization = internationalization;\\n`;\n content += `module.exports.routing = routing;\\n`;\n content += `module.exports.editor = editor;\\n`;\n content += `module.exports.log = log;\\n`;\n content += `module.exports.metadata = metadata;\\n`;\n content += `module.exports = configuration;\\n`;\n }\n\n return content;\n};\n"],"mappings":";;;AAGA,MAAa,gCACX,eACA,WACW;CACX,MAAM,EAAE,sBAAsB,SAAS,QAAQ,KAAK,aAClD,0BAA0B,cAAc;CAE1C,IAAI,UAAU;AAEd,YAAW,gCAAgC,KAAK,UAAU,sBAAsB,MAAM,EAAE,CAAC;AACzF,YAAW,mBAAmB,KAAK,UAAU,SAAS,MAAM,EAAE,CAAC;AAC/D,YAAW,kBAAkB,KAAK,UAAU,QAAQ,MAAM,EAAE,CAAC;AAC7D,YAAW,eAAe,KAAK,UAAU,KAAK,MAAM,EAAE,CAAC;AACvD,YAAW,oBAAoB,KAAK,UAAU,UAAU,MAAM,EAAE,CAAC;AACjE,YAAW;AAEX,KAAI,WAAW,OAAO;AACpB,aAAW;AACX,aAAW;QACN;AACL,aAAW;AACX,aAAW;AACX,aAAW;AACX,aAAW;AACX,aAAW;AACX,aAAW;;AAGb,QAAO"}
|
|
@@ -1,38 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { writeFileIfChanged } from "../writeFileIfChanged.mjs";
|
|
2
|
+
import { generateConfigurationContent } from "./generateConfigurationContent.mjs";
|
|
2
3
|
import { mkdir, readFile } from "node:fs/promises";
|
|
3
4
|
import { join } from "node:path";
|
|
4
|
-
import { isDeepStrictEqual } from "node:util";
|
|
5
5
|
|
|
6
6
|
//#region src/writeConfiguration/index.ts
|
|
7
|
-
const getCachedConfiguration = async (configuration) => {
|
|
8
|
-
const configurationContent = await readFile(join(configuration.system.configDir, "configuration.json"), "utf8");
|
|
9
|
-
return JSON.parse(configurationContent);
|
|
10
|
-
};
|
|
11
7
|
const isCachedConfigurationUpToDate = async (configuration) => {
|
|
12
8
|
try {
|
|
13
|
-
|
|
14
|
-
return isDeepStrictEqual(await getCachedConfiguration(configuration), cleanedConfiguration);
|
|
9
|
+
return await readFile(join(configuration.system.configDir, "configuration.mjs"), "utf8") === generateConfigurationContent(configuration, "esm");
|
|
15
10
|
} catch {
|
|
16
11
|
return null;
|
|
17
12
|
}
|
|
18
13
|
};
|
|
19
|
-
const cleanConfiguration = (configuration) => {
|
|
20
|
-
return JSON.parse(JSON.stringify({
|
|
21
|
-
internationalization: {
|
|
22
|
-
locales: configuration.internationalization.locales,
|
|
23
|
-
defaultLocale: configuration.internationalization.defaultLocale
|
|
24
|
-
},
|
|
25
|
-
editor: configuration.editor,
|
|
26
|
-
log: configuration.log,
|
|
27
|
-
routing: configuration.routing,
|
|
28
|
-
metadata: configuration.metadata
|
|
29
|
-
}));
|
|
30
|
-
};
|
|
31
14
|
const writeConfiguration = async (configuration) => {
|
|
32
|
-
const {
|
|
33
|
-
const { configDir } = system;
|
|
15
|
+
const { configDir } = configuration.system;
|
|
34
16
|
await mkdir(configDir, { recursive: true });
|
|
35
|
-
await
|
|
17
|
+
await Promise.all([writeFileIfChanged(join(configDir, "configuration.mjs"), generateConfigurationContent(configuration, "esm")), writeFileIfChanged(join(configDir, "configuration.cjs"), generateConfigurationContent(configuration, "cjs"))]);
|
|
36
18
|
};
|
|
37
19
|
|
|
38
20
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/writeConfiguration/index.ts"],"sourcesContent":["import { mkdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/writeConfiguration/index.ts"],"sourcesContent":["import { mkdir, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { writeFileIfChanged } from '../writeFileIfChanged';\nimport { generateConfigurationContent } from './generateConfigurationContent';\n\nexport const isCachedConfigurationUpToDate = async (\n configuration: IntlayerConfig\n): Promise<boolean | null> => {\n try {\n const mjsPath = join(configuration.system.configDir, 'configuration.mjs');\n const existingContent = await readFile(mjsPath, 'utf8');\n const expectedContent = generateConfigurationContent(configuration, 'esm');\n return existingContent === expectedContent;\n } catch {\n return null; // Can crash if file doesn't exist yet or config is not defined\n }\n};\n\nexport const writeConfiguration = async (configuration: IntlayerConfig) => {\n const { configDir } = configuration.system;\n\n await mkdir(configDir, { recursive: true });\n\n await Promise.all([\n writeFileIfChanged(\n join(configDir, 'configuration.mjs'),\n generateConfigurationContent(configuration, 'esm')\n ),\n writeFileIfChanged(\n join(configDir, 'configuration.cjs'),\n generateConfigurationContent(configuration, 'cjs')\n ),\n ]);\n};\n"],"mappings":";;;;;;AAMA,MAAa,gCAAgC,OAC3C,kBAC4B;AAC5B,KAAI;AAIF,SAFwB,MAAM,SADd,KAAK,cAAc,OAAO,WAAW,oBAAoB,EACzB,OAAO,KAC/B,6BAA6B,eAAe,MAAM;SAEpE;AACN,SAAO;;;AAIX,MAAa,qBAAqB,OAAO,kBAAkC;CACzE,MAAM,EAAE,cAAc,cAAc;AAEpC,OAAM,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;AAE3C,OAAM,QAAQ,IAAI,CAChB,mBACE,KAAK,WAAW,oBAAoB,EACpC,6BAA6B,eAAe,MAAM,CACnD,EACD,mBACE,KAAK,WAAW,oBAAoB,EACpC,6BAA6B,eAAe,MAAM,CACnD,CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawnWin32.d.ts","names":[],"sources":["../../../../src/utils/runParallel/spawnWin32.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"spawnWin32.d.ts","names":[],"sources":["../../../../src/utils/runParallel/spawnWin32.ts"],"mappings":";;;;AAoDA;;;;;;;;;;;;cAAa,UAAA,GACX,OAAA,UACA,IAAA,YACA,OAAA,EAAS,YAAA,KACR,YAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
+
|
|
3
|
+
//#region src/writeConfiguration/generateConfigurationContent.d.ts
|
|
4
|
+
declare const generateConfigurationContent: (configuration: IntlayerConfig, format: "cjs" | "esm") => string;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { generateConfigurationContent };
|
|
7
|
+
//# sourceMappingURL=generateConfigurationContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateConfigurationContent.d.ts","names":[],"sources":["../../../src/writeConfiguration/generateConfigurationContent.ts"],"mappings":";;;cAGa,4BAAA,GACX,aAAA,EAAe,cAAA,EACf,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/writeConfiguration/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/writeConfiguration/index.ts"],"mappings":";;;cAMa,6BAAA,GACX,aAAA,EAAe,cAAA,KACd,OAAA;AAAA,cAWU,kBAAA,GAA4B,aAAA,EAAe,cAAA,KAAc,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
|
|
6
6
|
"keywords": [
|
|
@@ -110,13 +110,13 @@
|
|
|
110
110
|
},
|
|
111
111
|
"dependencies": {
|
|
112
112
|
"@babel/parser": "7.29.0",
|
|
113
|
-
"@intlayer/api": "8.
|
|
114
|
-
"@intlayer/config": "8.
|
|
115
|
-
"@intlayer/core": "8.
|
|
116
|
-
"@intlayer/dictionaries-entry": "8.
|
|
117
|
-
"@intlayer/remote-dictionaries-entry": "8.
|
|
118
|
-
"@intlayer/types": "8.
|
|
119
|
-
"@intlayer/unmerged-dictionaries-entry": "8.
|
|
113
|
+
"@intlayer/api": "8.5.1",
|
|
114
|
+
"@intlayer/config": "8.5.1",
|
|
115
|
+
"@intlayer/core": "8.5.1",
|
|
116
|
+
"@intlayer/dictionaries-entry": "8.5.1",
|
|
117
|
+
"@intlayer/remote-dictionaries-entry": "8.5.1",
|
|
118
|
+
"@intlayer/types": "8.5.1",
|
|
119
|
+
"@intlayer/unmerged-dictionaries-entry": "8.5.1",
|
|
120
120
|
"chokidar": "3.6.0",
|
|
121
121
|
"defu": "6.1.4",
|
|
122
122
|
"fast-glob": "3.3.3",
|