@intlayer/cli 9.5.8 → 9.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
- package/dist/cjs/auth/login.cjs +4 -4
- package/dist/cjs/build.cjs +1 -1
- package/dist/cjs/ci.cjs +1 -1
- package/dist/cjs/cli.cjs +1 -1
- package/dist/cjs/config.cjs +1 -1
- package/dist/cjs/editor.cjs +1 -1
- package/dist/cjs/extract.cjs +5 -5
- package/dist/cjs/fill/fill.cjs +2 -2
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +1 -1
- package/dist/cjs/fill/listTranslationsTasks.cjs +1 -1
- package/dist/cjs/fill/translateDictionary.cjs +1 -1
- package/dist/cjs/fill/writeFill.cjs +1 -1
- package/dist/cjs/getTargetDictionary.cjs +1 -1
- package/dist/cjs/index.cjs +7 -7
- package/dist/cjs/init.cjs +1 -1
- package/dist/cjs/initSkills.cjs +1 -1
- package/dist/cjs/listContentDeclaration.cjs +2 -2
- package/dist/cjs/liveSync.cjs +4 -4
- package/dist/cjs/pull.cjs +4 -4
- package/dist/cjs/push/push.cjs +5 -5
- package/dist/cjs/pushConfig.cjs +1 -1
- package/dist/cjs/reviewDoc/reviewDoc.cjs +3 -3
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +3 -3
- package/dist/cjs/reviewDoc/reviewDocLog.cjs +1 -1
- package/dist/cjs/searchDoc.cjs +1 -1
- package/dist/cjs/test/listMissingTranslations.cjs +1 -1
- package/dist/cjs/test/test.cjs +1 -1
- package/dist/cjs/translateDoc/translateDoc.cjs +2 -2
- package/dist/cjs/translateDoc/translateFile.cjs +2 -2
- package/dist/cjs/utils/getOutputFilePath.cjs +1 -1
- package/dist/cjs/utils/getParentPackageJSON.cjs +1 -1
- package/dist/cjs/watch.cjs +1 -1
- package/dist/esm/_virtual/_utils_asset.mjs +1 -1
- package/dist/esm/auth/login.mjs +3 -3
- package/dist/esm/build.mjs +1 -1
- package/dist/esm/ci.mjs +1 -1
- package/dist/esm/cli.mjs +1 -1
- package/dist/esm/config.mjs +1 -1
- package/dist/esm/editor.mjs +1 -1
- package/dist/esm/extract.mjs +6 -6
- package/dist/esm/extract.mjs.map +1 -1
- package/dist/esm/fill/fill.mjs +4 -4
- package/dist/esm/fill/fill.mjs.map +1 -1
- package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -1
- package/dist/esm/fill/listTranslationsTasks.mjs +1 -1
- package/dist/esm/fill/translateDictionary.mjs +1 -1
- package/dist/esm/fill/writeFill.mjs +1 -1
- package/dist/esm/getTargetDictionary.mjs +1 -1
- package/dist/esm/index.mjs +7 -7
- package/dist/esm/init.mjs +1 -1
- package/dist/esm/initSkills.mjs +1 -1
- package/dist/esm/listContentDeclaration.mjs +2 -2
- package/dist/esm/liveSync.mjs +3 -3
- package/dist/esm/pull.mjs +4 -4
- package/dist/esm/push/push.mjs +7 -7
- package/dist/esm/push/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +1 -1
- package/dist/esm/reviewDoc/reviewDoc.mjs +3 -3
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +3 -3
- package/dist/esm/reviewDoc/reviewDocLog.mjs +1 -1
- package/dist/esm/searchDoc.mjs +1 -1
- package/dist/esm/test/listMissingTranslations.mjs +1 -1
- package/dist/esm/test/test.mjs +1 -1
- package/dist/esm/translateDoc/translateDoc.mjs +2 -2
- package/dist/esm/translateDoc/translateFile.mjs +2 -2
- package/dist/esm/utils/getOutputFilePath.mjs +1 -1
- package/dist/esm/utils/getParentPackageJSON.mjs +1 -1
- package/dist/esm/watch.mjs +1 -1
- package/package.json +10 -10
package/dist/esm/extract.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.mjs","names":[],"sources":["../../src/extract.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport type { PackageName } from '@intlayer/babel';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger, x } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getUnmergedDictionaries } from '@intlayer/dictionaries-entry/unmerged';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { buildComponentFilesList, formatPath } from '@intlayer/engine/utils';\nimport type { FilePathPattern } from '@intlayer/types/filePathPattern';\nimport enquirer from 'enquirer';\n\ntype ExtractOptions = {\n files?: string[];\n output?: FilePathPattern;\n configOptions?: GetConfigurationOptions;\n codeOnly?: boolean;\n declarationOnly?: boolean;\n};\n\nexport const extract = async (options: ExtractOptions) => {\n const configuration = getConfiguration(options.configOptions);\n\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n const { baseDir } = configuration.system;\n const { output } = configuration.compiler;\n\n if (!output) {\n appLogger(\n `${x} No output configuration found. Add a ${colorize('compiler.output', ANSIColors.BLUE)} in your configuration.`,\n {\n level: 'error',\n }\n );\n return;\n }\n\n const { detectPackageName, extractContent } = await import('@intlayer/babel');\n\n // Detect package\n const packageName: PackageName = detectPackageName(baseDir);\n\n let filesToExtract = options.files ?? [];\n\n if (filesToExtract.length === 0) {\n // Await all promises simultaneously\n const fileList = buildComponentFilesList(configuration);\n\n // Flatten the nested arrays and remove duplicates\n // Relative paths for selection\n const choices = fileList.map((file) => {\n const relPath = relative(baseDir, file);\n\n return {\n value: file,\n label: relPath,\n };\n });\n\n if (choices.length === 0) {\n appLogger('No extractable files found in the project.');\n return;\n }\n\n const SELECT_ALL = '__select_all__';\n\n type PromptChoice = {\n name: string;\n enabled: boolean;\n disabled?: boolean | string;\n };\n\n type PromptContext = {\n choices: PromptChoice[];\n render(): void | Promise<void>;\n state: { submitted: boolean };\n selected: PromptChoice[];\n input: string;\n options: { multiple?: boolean };\n };\n\n let selectedFiles: string[] | symbol;\n try {\n const maxLen = Math.max((process.stdout.columns || 80) - 15, 20);\n const truncatePath = (path: string) =>\n path.length > maxLen ? `...${path.slice(-(maxLen - 3))}` : path;\n\n const { files: enquirerSelectedFiles } = await enquirer.prompt<{\n files: string[];\n }>({\n type: 'autocomplete',\n name: 'files',\n message: 'Select files to extract (Type to search):',\n multiple: true,\n // @ts-ignore limit exist but is not typed\n limit: 40,\n choices: [\n { name: SELECT_ALL, message: '────── Select all ──────' },\n ...choices.map((choice) => ({\n name: choice.value,\n message: truncatePath(choice.label),\n })),\n ],\n async toggle(\n this: PromptContext,\n choice: PromptChoice,\n enabled?: boolean\n ) {\n if (!choice || choice.disabled) return;\n choice.enabled = enabled == null ? !choice.enabled : enabled;\n\n if (choice.name === SELECT_ALL) {\n this.choices\n .filter((choiceEl) => choiceEl.name !== SELECT_ALL)\n .forEach((choiceEl) => {\n choiceEl.enabled = choice.enabled;\n });\n }\n\n return this.render();\n },\n format(this: PromptContext) {\n if (this.state?.submitted && this.options?.multiple) {\n return `${this.selected.filter((s) => s.name !== SELECT_ALL).length} file(s) selected`;\n }\n return this.input ?? '';\n },\n });\n\n selectedFiles = enquirerSelectedFiles.filter(\n (file) => file !== SELECT_ALL\n );\n } catch {\n selectedFiles = Symbol('cancel');\n }\n\n if (typeof selectedFiles === 'symbol') {\n // User cancelled\n process.exit(0);\n }\n\n filesToExtract = selectedFiles as string[];\n }\n\n if (filesToExtract.length === 0) {\n appLogger('No files selected for extraction.');\n return;\n }\n\n const absoluteFiles = filesToExtract\n .map((file) => resolve(baseDir, file))\n .filter((file) => {\n if (!existsSync(file)) {\n appLogger(`File not found: ${formatPath(file)}`);\n return false;\n }\n return true;\n });\n\n if (absoluteFiles.length === 0) {\n return;\n }\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n for (const filePath of absoluteFiles) {\n try {\n await extractContent(filePath, packageName, {\n unmergedDictionaries,\n configuration,\n codeOnly: options.codeOnly,\n declarationOnly: options.declarationOnly,\n });\n } catch (error) {\n appLogger(`Failed to transform ${filePath}: ${(error as Error).message}`);\n }\n }\n\n await prepareIntlayer(configuration); // Prepare Intlayer to apply the changes\n};\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAa,UAAU,OAAO,YAA4B;CACxD,MAAM,gBAAgB,iBAAiB,QAAQ,aAAa;CAE5D,iBAAiB,SAAS,aAAa;CAEvC,MAAM,YAAY,aAAa,aAAa;CAE5C,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,WAAW,cAAc;CAEjC,IAAI,CAAC,QAAQ;EACX,UACE,GAAG,EAAE,wCAAwC,SAAS,mBAAmB,WAAW,IAAI,EAAE,0BAC1F,EACE,OAAO,QACT,CACF;EACA;CACF;CAEA,MAAM,EAAE,mBAAmB,mBAAmB,MAAM,OAAO;CAG3D,MAAM,cAA2B,kBAAkB,OAAO;CAE1D,IAAI,iBAAiB,QAAQ,SAAS,CAAC;CAEvC,IAAI,eAAe,WAAW,GAAG;EAM/B,MAAM,UAJW,wBAAwB,aAIlB,CAAC,CAAC,KAAK,SAAS;GAGrC,OAAO;IACL,OAAO;IACP,OAJc,SAAS,SAAS,IAInB;GACf;EACF,CAAC;EAED,IAAI,QAAQ,WAAW,GAAG;GACxB,UAAU,4CAA4C;GACtD;EACF;EAEA,MAAM,aAAa;EAiBnB,IAAI;EACJ,IAAI;GACF,MAAM,SAAS,KAAK,KAAK,QAAQ,OAAO,WAAW,MAAM,IAAI,EAAE;GAC/D,MAAM,gBAAgB,SACpB,KAAK,SAAS,SAAS,MAAM,KAAK,MAAM,EAAE,SAAS,EAAE,MAAM;GAE7D,MAAM,EAAE,OAAO,0BAA0B,MAAM,SAAS,OAErD;IACD,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IAEV,OAAO;IACP,SAAS,CACP;KAAE,MAAM;KAAY,SAAS;IAA2B,GACxD,GAAG,QAAQ,KAAK,YAAY;KAC1B,MAAM,OAAO;KACb,SAAS,aAAa,OAAO,KAAK;IACpC,EAAE,CACJ;IACA,MAAM,OAEJ,QACA,SACA;KACA,IAAI,CAAC,UAAU,OAAO,UAAU;KAChC,OAAO,UAAU,WAAW,OAAO,CAAC,OAAO,UAAU;KAErD,IAAI,OAAO,SAAS,YAClB,KAAK,QACF,QAAQ,aAAa,SAAS,SAAS,UAAU,CAAC,CAClD,SAAS,aAAa;MACrB,SAAS,UAAU,OAAO;KAC5B,CAAC;KAGL,OAAO,KAAK,OAAO;IACrB;IACA,SAA4B;KAC1B,IAAI,KAAK,OAAO,aAAa,KAAK,SAAS,UACzC,OAAO,GAAG,KAAK,SAAS,QAAQ,MAAM,EAAE,SAAS,UAAU,CAAC,CAAC,OAAO;KAEtE,OAAO,KAAK,SAAS;IACvB;GACF,CAAC;GAED,gBAAgB,sBAAsB,QACnC,SAAS,SAAS,UACrB;EACF,QAAQ;GACN,gBAAgB,OAAO,QAAQ;EACjC;EAEA,IAAI,OAAO,kBAAkB,UAE3B,QAAQ,KAAK,CAAC;EAGhB,iBAAiB;CACnB;CAEA,IAAI,eAAe,WAAW,GAAG;EAC/B,UAAU,mCAAmC;EAC7C;CACF;CAEA,MAAM,gBAAgB,eACnB,KAAK,SAAS,QAAQ,SAAS,IAAI,CAAC,CAAC,CACrC,QAAQ,SAAS;EAChB,IAAI,CAAC,WAAW,IAAI,GAAG;GACrB,UAAU,mBAAmB,WAAW,IAAI,GAAG;GAC/C,OAAO;EACT;EACA,OAAO;CACT,CAAC;CAEH,IAAI,cAAc,WAAW,GAC3B;CAGF,MAAM,uBAAuB,wBAAwB,aAAa;CAElE,KAAK,MAAM,YAAY,eACrB,IAAI;EACF,MAAM,eAAe,UAAU,aAAa;GAC1C;GACA;GACA,UAAU,QAAQ;GAClB,iBAAiB,QAAQ;EAC3B,CAAC;CACH,SAAS,OAAO;EACd,UAAU,uBAAuB,SAAS,IAAK,MAAgB,SAAS;CAC1E;CAGF,
|
|
1
|
+
{"version":3,"file":"extract.mjs","names":["prepareIntlayer"],"sources":["../../src/extract.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport type { PackageName } from '@intlayer/babel';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger, x } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getUnmergedDictionaries } from '@intlayer/dictionaries-entry/unmerged';\nimport { prepareIntlayer } from '@intlayer/engine/build';\nimport { logConfigDetails } from '@intlayer/engine/cli';\nimport { buildComponentFilesList, formatPath } from '@intlayer/engine/utils';\nimport type { FilePathPattern } from '@intlayer/types/filePathPattern';\nimport enquirer from 'enquirer';\n\ntype ExtractOptions = {\n files?: string[];\n output?: FilePathPattern;\n configOptions?: GetConfigurationOptions;\n codeOnly?: boolean;\n declarationOnly?: boolean;\n};\n\nexport const extract = async (options: ExtractOptions) => {\n const configuration = getConfiguration(options.configOptions);\n\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n const { baseDir } = configuration.system;\n const { output } = configuration.compiler;\n\n if (!output) {\n appLogger(\n `${x} No output configuration found. Add a ${colorize('compiler.output', ANSIColors.BLUE)} in your configuration.`,\n {\n level: 'error',\n }\n );\n return;\n }\n\n const { detectPackageName, extractContent } = await import('@intlayer/babel');\n\n // Detect package\n const packageName: PackageName = detectPackageName(baseDir);\n\n let filesToExtract = options.files ?? [];\n\n if (filesToExtract.length === 0) {\n // Await all promises simultaneously\n const fileList = buildComponentFilesList(configuration);\n\n // Flatten the nested arrays and remove duplicates\n // Relative paths for selection\n const choices = fileList.map((file) => {\n const relPath = relative(baseDir, file);\n\n return {\n value: file,\n label: relPath,\n };\n });\n\n if (choices.length === 0) {\n appLogger('No extractable files found in the project.');\n return;\n }\n\n const SELECT_ALL = '__select_all__';\n\n type PromptChoice = {\n name: string;\n enabled: boolean;\n disabled?: boolean | string;\n };\n\n type PromptContext = {\n choices: PromptChoice[];\n render(): void | Promise<void>;\n state: { submitted: boolean };\n selected: PromptChoice[];\n input: string;\n options: { multiple?: boolean };\n };\n\n let selectedFiles: string[] | symbol;\n try {\n const maxLen = Math.max((process.stdout.columns || 80) - 15, 20);\n const truncatePath = (path: string) =>\n path.length > maxLen ? `...${path.slice(-(maxLen - 3))}` : path;\n\n const { files: enquirerSelectedFiles } = await enquirer.prompt<{\n files: string[];\n }>({\n type: 'autocomplete',\n name: 'files',\n message: 'Select files to extract (Type to search):',\n multiple: true,\n // @ts-ignore limit exist but is not typed\n limit: 40,\n choices: [\n { name: SELECT_ALL, message: '────── Select all ──────' },\n ...choices.map((choice) => ({\n name: choice.value,\n message: truncatePath(choice.label),\n })),\n ],\n async toggle(\n this: PromptContext,\n choice: PromptChoice,\n enabled?: boolean\n ) {\n if (!choice || choice.disabled) return;\n choice.enabled = enabled == null ? !choice.enabled : enabled;\n\n if (choice.name === SELECT_ALL) {\n this.choices\n .filter((choiceEl) => choiceEl.name !== SELECT_ALL)\n .forEach((choiceEl) => {\n choiceEl.enabled = choice.enabled;\n });\n }\n\n return this.render();\n },\n format(this: PromptContext) {\n if (this.state?.submitted && this.options?.multiple) {\n return `${this.selected.filter((s) => s.name !== SELECT_ALL).length} file(s) selected`;\n }\n return this.input ?? '';\n },\n });\n\n selectedFiles = enquirerSelectedFiles.filter(\n (file) => file !== SELECT_ALL\n );\n } catch {\n selectedFiles = Symbol('cancel');\n }\n\n if (typeof selectedFiles === 'symbol') {\n // User cancelled\n process.exit(0);\n }\n\n filesToExtract = selectedFiles as string[];\n }\n\n if (filesToExtract.length === 0) {\n appLogger('No files selected for extraction.');\n return;\n }\n\n const absoluteFiles = filesToExtract\n .map((file) => resolve(baseDir, file))\n .filter((file) => {\n if (!existsSync(file)) {\n appLogger(`File not found: ${formatPath(file)}`);\n return false;\n }\n return true;\n });\n\n if (absoluteFiles.length === 0) {\n return;\n }\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n for (const filePath of absoluteFiles) {\n try {\n await extractContent(filePath, packageName, {\n unmergedDictionaries,\n configuration,\n codeOnly: options.codeOnly,\n declarationOnly: options.declarationOnly,\n });\n } catch (error) {\n appLogger(`Failed to transform ${filePath}: ${(error as Error).message}`);\n }\n }\n\n await prepareIntlayer(configuration); // Prepare Intlayer to apply the changes\n};\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAa,UAAU,OAAO,YAA4B;CACxD,MAAM,gBAAgB,iBAAiB,QAAQ,aAAa;CAE5D,iBAAiB,SAAS,aAAa;CAEvC,MAAM,YAAY,aAAa,aAAa;CAE5C,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,WAAW,cAAc;CAEjC,IAAI,CAAC,QAAQ;EACX,UACE,GAAG,EAAE,wCAAwC,SAAS,mBAAmB,WAAW,IAAI,EAAE,0BAC1F,EACE,OAAO,QACT,CACF;EACA;CACF;CAEA,MAAM,EAAE,mBAAmB,mBAAmB,MAAM,OAAO;CAG3D,MAAM,cAA2B,kBAAkB,OAAO;CAE1D,IAAI,iBAAiB,QAAQ,SAAS,CAAC;CAEvC,IAAI,eAAe,WAAW,GAAG;EAM/B,MAAM,UAJW,wBAAwB,aAIlB,CAAC,CAAC,KAAK,SAAS;GAGrC,OAAO;IACL,OAAO;IACP,OAJc,SAAS,SAAS,IAInB;GACf;EACF,CAAC;EAED,IAAI,QAAQ,WAAW,GAAG;GACxB,UAAU,4CAA4C;GACtD;EACF;EAEA,MAAM,aAAa;EAiBnB,IAAI;EACJ,IAAI;GACF,MAAM,SAAS,KAAK,KAAK,QAAQ,OAAO,WAAW,MAAM,IAAI,EAAE;GAC/D,MAAM,gBAAgB,SACpB,KAAK,SAAS,SAAS,MAAM,KAAK,MAAM,EAAE,SAAS,EAAE,MAAM;GAE7D,MAAM,EAAE,OAAO,0BAA0B,MAAM,SAAS,OAErD;IACD,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IAEV,OAAO;IACP,SAAS,CACP;KAAE,MAAM;KAAY,SAAS;IAA2B,GACxD,GAAG,QAAQ,KAAK,YAAY;KAC1B,MAAM,OAAO;K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package/dist/esm/fill/fill.mjs
CHANGED
|
@@ -4,12 +4,12 @@ import { listTranslationsTasks } from "./listTranslationsTasks.mjs";
|
|
|
4
4
|
import { translateDictionary } from "./translateDictionary.mjs";
|
|
5
5
|
import { writeFill } from "./writeFill.mjs";
|
|
6
6
|
import { basename, join, relative } from "node:path";
|
|
7
|
+
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
7
8
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
8
9
|
import { colorize, colorizeKey, colorizePath, getAppLogger, x } from "@intlayer/config/logger";
|
|
9
10
|
import { getConfiguration } from "@intlayer/config/node";
|
|
10
|
-
import { loadContentDeclarations, prepareIntlayer, writeContentDeclaration } from "@intlayer/engine/build";
|
|
11
|
-
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
12
11
|
import { formatPath, getGlobalLimiter, getTaskLimiter } from "@intlayer/engine/utils";
|
|
12
|
+
import { loadContentDeclarations, prepareIntlayer as prepareIntlayer$1, writeContentDeclaration } from "@intlayer/engine/build";
|
|
13
13
|
|
|
14
14
|
//#region src/fill/fill.ts
|
|
15
15
|
const NB_CONCURRENT_TRANSLATIONS = 7;
|
|
@@ -20,8 +20,8 @@ const fill = async (options) => {
|
|
|
20
20
|
const configuration = getConfiguration(options?.configOptions);
|
|
21
21
|
logConfigDetails(options?.configOptions);
|
|
22
22
|
const appLogger = getAppLogger(configuration);
|
|
23
|
-
if (options?.build === true) await prepareIntlayer(configuration, { forceRun: true });
|
|
24
|
-
else if (typeof options?.build === "undefined") await prepareIntlayer(configuration);
|
|
23
|
+
if (options?.build === true) await prepareIntlayer$1(configuration, { forceRun: true });
|
|
24
|
+
else if (typeof options?.build === "undefined") await prepareIntlayer$1(configuration);
|
|
25
25
|
const { defaultLocale, locales } = configuration.internationalization;
|
|
26
26
|
const mode = options?.mode ?? "complete";
|
|
27
27
|
const baseLocale = options?.sourceLocale ?? defaultLocale;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill.mjs","names":[],"sources":["../../../src/fill/fill.ts"],"sourcesContent":["import { basename, join, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n loadContentDeclarations,\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/engine/build';\nimport {\n type ListGitFilesOptions,\n logConfigDetails,\n} from '@intlayer/engine/cli';\nimport {\n formatPath,\n getGlobalLimiter,\n getTaskLimiter,\n} from '@intlayer/engine/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { Fill } from '@intlayer/types/dictionary';\nimport {\n ensureArray,\n type GetTargetDictionaryOptions,\n getTargetUnmergedDictionaries,\n} from '../getTargetDictionary';\nimport { setupAI } from '../utils/setupAI';\nimport {\n listTranslationsTasks,\n type TranslationTask,\n} from './listTranslationsTasks';\nimport { translateDictionary } from './translateDictionary';\nimport { writeFill } from './writeFill';\n\nconst NB_CONCURRENT_TRANSLATIONS = 7;\n\n// Arguments for the fill function\nexport type FillOptions = {\n sourceLocale?: Locale;\n outputLocales?: Locale | Locale[];\n mode?: 'complete' | 'review';\n gitOptions?: ListGitFilesOptions;\n aiOptions?: AIOptions; // Added aiOptions to be passed to translateJSON\n verbose?: boolean;\n nbConcurrentTranslations?: number;\n nbConcurrentTasks?: number; // NEW: number of tasks that may run at once\n build?: boolean;\n skipMetadata?: boolean;\n} & GetTargetDictionaryOptions;\n\n/**\n * Fill translations based on the provided options.\n */\nexport const fill = async (options?: FillOptions): Promise<void> => {\n const configuration = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n if (options?.build === true) {\n await prepareIntlayer(configuration, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(configuration);\n }\n\n const { defaultLocale, locales } = configuration.internationalization;\n const mode = options?.mode ?? 'complete';\n const baseLocale = options?.sourceLocale ?? defaultLocale;\n\n const outputLocales = options?.outputLocales\n ? ensureArray(options.outputLocales)\n : locales;\n\n const aiResult = await setupAI(configuration, options?.aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig, isCustomAI } = aiResult;\n\n if (isCustomAI && aiClient && aiConfig) {\n const { hasAIAccess, error } = await aiClient.checkAISDKAccess(aiConfig);\n if (!hasAIAccess) {\n appLogger(`${x} ${error}`);\n return;\n }\n }\n\n const targetUnmergedDictionaries =\n await getTargetUnmergedDictionaries(options);\n\n // Load the original source content declaration files to recover function-type\n // `fill` values that are lost when dictionaries are JSON-serialised into\n // unmerged_dictionaries.cjs. Dictionary-level fill takes priority over the\n // config-level fill, but we can only know that by reading the source files.\n const uniqueSourcePaths = [\n ...new Set(\n targetUnmergedDictionaries\n .filter((unmergedDictionary) =>\n ['local', 'hybrid'].includes(unmergedDictionary.location!)\n )\n .map((unmergedDictionary) => unmergedDictionary.filePath)\n .filter(Boolean) as string[]\n ),\n ];\n const sourceDictionaries = await loadContentDeclarations(\n uniqueSourcePaths.map((sourcePath) =>\n join(configuration.system.baseDir, sourcePath)\n ),\n configuration,\n undefined,\n {\n logError: false,\n }\n );\n // Map relative filePath → original fill value from the source file\n const originalFillByPath = new Map<string, Fill | undefined>();\n\n for (const dictionary of sourceDictionaries) {\n if (dictionary.filePath) {\n originalFillByPath.set(\n dictionary.filePath,\n dictionary.fill as Fill | undefined\n );\n }\n }\n\n const affectedDictionaryKeys = new Set<string>();\n\n targetUnmergedDictionaries.forEach((dict) => {\n affectedDictionaryKeys.add(dict.key);\n });\n\n const keysToProcess = Array.from(affectedDictionaryKeys);\n\n appLogger([\n 'Affected dictionary keys for processing:',\n keysToProcess.length > 0\n ? keysToProcess.map((key) => colorizeKey(key)).join(', ')\n : colorize('No keys found', ANSIColors.YELLOW),\n ]);\n\n if (keysToProcess.length === 0) return;\n\n /**\n * List the translations tasks\n *\n * Create a list of per-locale dictionaries to translate\n *\n * In 'complete' mode, filter only the missing locales to translate\n */\n const translationTasks: TranslationTask[] = listTranslationsTasks(\n targetUnmergedDictionaries.map((dictionary) => dictionary.localId!),\n outputLocales,\n mode,\n baseLocale,\n configuration\n );\n\n // AI calls in flight at once (translateJSON + metadata audit)\n const nbConcurrentTranslations =\n options?.nbConcurrentTranslations ?? NB_CONCURRENT_TRANSLATIONS;\n const globalLimiter = getGlobalLimiter(nbConcurrentTranslations);\n\n // NEW: number of *tasks* that may run at once (start/prepare/log/write)\n const nbConcurrentTasks = Math.max(\n 1,\n Math.min(\n options?.nbConcurrentTasks ?? nbConcurrentTranslations,\n translationTasks.length\n )\n );\n\n const taskLimiter = getTaskLimiter(nbConcurrentTasks);\n\n const runners = translationTasks.map((task) =>\n taskLimiter(async () => {\n const relativePath = relative(\n configuration?.system?.baseDir ?? process.cwd(),\n task?.dictionaryFilePath ?? ''\n );\n\n // log AFTER acquiring a task slot\n appLogger(\n `${task.dictionaryPreset} Processing ${colorizePath(basename(relativePath))}`,\n { level: 'info' }\n );\n\n const translationTaskResult = await translateDictionary(\n task,\n configuration,\n {\n mode,\n aiOptions: options?.aiOptions,\n fillMetadata: !options?.skipMetadata,\n onHandle: globalLimiter,\n aiClient,\n aiConfig,\n }\n );\n\n if (!translationTaskResult?.dictionaryOutput) return;\n\n const { dictionaryOutput, sourceLocale } = translationTaskResult;\n\n // Determine if we should write to separate files\n // - If dictionary has explicit fill setting (string, function, or object), use it\n // - If dictionary is per-locale AND has no explicit fill=false, use global fill config\n // - If dictionary is multilingual (no locale property), always write to same file\n //\n // NOTE: function-type fill values are lost during JSON serialisation of\n // unmerged_dictionaries.cjs. We recover them by checking the original\n // source file that was loaded above (originalFillByPath). Dictionary-level\n // fill always takes priority over config-level fill.\n const originalFill = originalFillByPath.get(\n dictionaryOutput.filePath ?? ''\n );\n\n // originalFill is undefined when the source file had no fill property; use\n // the (possibly JSON-preserved) dictionaryOutput.fill as a fallback so that\n // string/boolean fill values set directly on the dict still work.\n const dictFill: Fill | undefined =\n originalFill !== undefined ? originalFill : dictionaryOutput.fill;\n\n const hasDictionaryLevelFill =\n typeof dictFill === 'string' ||\n typeof dictFill === 'function' ||\n (typeof dictFill === 'object' && dictFill !== null);\n\n const isPerLocale = typeof dictionaryOutput.locale === 'string';\n\n const effectiveFill = hasDictionaryLevelFill\n ? dictFill\n : isPerLocale\n ? (configuration.dictionary?.fill ?? true)\n : false; // Multilingual dictionaries (no locale property) always write to same file unless explicitly set on the dictionary\n\n const isFillOtherFile =\n typeof effectiveFill === 'string' ||\n typeof effectiveFill === 'function' ||\n (typeof effectiveFill === 'object' && effectiveFill !== null);\n\n if (isFillOtherFile) {\n await writeFill(\n {\n ...dictionaryOutput,\n // Ensure fill is set on the dictionary for writeFill to use\n fill: effectiveFill,\n },\n outputLocales,\n [sourceLocale],\n configuration\n );\n } else {\n await writeContentDeclaration(dictionaryOutput, configuration);\n\n if (dictionaryOutput.filePath) {\n appLogger(\n `${task.dictionaryPreset} Content declaration written to ${formatPath(basename(dictionaryOutput.filePath))}`,\n { level: 'info' }\n );\n }\n }\n })\n );\n\n await Promise.all(runners);\n await (globalLimiter as any).onIdle();\n};\n"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAM,6BAA6B;;;;AAmBnC,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,gBAAgB,iBAAiB,SAAS,aAAa;CAC7D,iBAAiB,SAAS,aAAa;CAEvC,MAAM,YAAY,aAAa,aAAa;CAE5C,IAAI,SAAS,UAAU,MACrB,MAAM,gBAAgB,eAAe,EAAE,UAAU,KAAK,CAAC;MAClD,IAAI,OAAO,SAAS,UAAU,aACnC,MAAM,gBAAgB,aAAa;CAGrC,MAAM,EAAE,eAAe,YAAY,cAAc;CACjD,MAAM,OAAO,SAAS,QAAQ;CAC9B,MAAM,aAAa,SAAS,gBAAgB;CAE5C,MAAM,gBAAgB,SAAS,gBAC3B,YAAY,QAAQ,aAAa,IACjC;CAEJ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CACzB,MAAO,cAAsB,OAAO;AACtC"}
|
|
1
|
+
{"version":3,"file":"fill.mjs","names":["prepareIntlayer"],"sources":["../../../src/fill/fill.ts"],"sourcesContent":["import { basename, join, relative } from 'node:path';\nimport type { AIOptions } from '@intlayer/api';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeKey,\n colorizePath,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {\n loadContentDeclarations,\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/engine/build';\nimport {\n type ListGitFilesOptions,\n logConfigDetails,\n} from '@intlayer/engine/cli';\nimport {\n formatPath,\n getGlobalLimiter,\n getTaskLimiter,\n} from '@intlayer/engine/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { Fill } from '@intlayer/types/dictionary';\nimport {\n ensureArray,\n type GetTargetDictionaryOptions,\n getTargetUnmergedDictionaries,\n} from '../getTargetDictionary';\nimport { setupAI } from '../utils/setupAI';\nimport {\n listTranslationsTasks,\n type TranslationTask,\n} from './listTranslationsTasks';\nimport { translateDictionary } from './translateDictionary';\nimport { writeFill } from './writeFill';\n\nconst NB_CONCURRENT_TRANSLATIONS = 7;\n\n// Arguments for the fill function\nexport type FillOptions = {\n sourceLocale?: Locale;\n outputLocales?: Locale | Locale[];\n mode?: 'complete' | 'review';\n gitOptions?: ListGitFilesOptions;\n aiOptions?: AIOptions; // Added aiOptions to be passed to translateJSON\n verbose?: boolean;\n nbConcurrentTranslations?: number;\n nbConcurrentTasks?: number; // NEW: number of tasks that may run at once\n build?: boolean;\n skipMetadata?: boolean;\n} & GetTargetDictionaryOptions;\n\n/**\n * Fill translations based on the provided options.\n */\nexport const fill = async (options?: FillOptions): Promise<void> => {\n const configuration = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n if (options?.build === true) {\n await prepareIntlayer(configuration, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(configuration);\n }\n\n const { defaultLocale, locales } = configuration.internationalization;\n const mode = options?.mode ?? 'complete';\n const baseLocale = options?.sourceLocale ?? defaultLocale;\n\n const outputLocales = options?.outputLocales\n ? ensureArray(options.outputLocales)\n : locales;\n\n const aiResult = await setupAI(configuration, options?.aiOptions);\n\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig, isCustomAI } = aiResult;\n\n if (isCustomAI && aiClient && aiConfig) {\n const { hasAIAccess, error } = await aiClient.checkAISDKAccess(aiConfig);\n if (!hasAIAccess) {\n appLogger(`${x} ${error}`);\n return;\n }\n }\n\n const targetUnmergedDictionaries =\n await getTargetUnmergedDictionaries(options);\n\n // Load the original source content declaration files to recover function-type\n // `fill` values that are lost when dictionaries are JSON-serialised into\n // unmerged_dictionaries.cjs. Dictionary-level fill takes priority over the\n // config-level fill, but we can only know that by reading the source files.\n const uniqueSourcePaths = [\n ...new Set(\n targetUnmergedDictionaries\n .filter((unmergedDictionary) =>\n ['local', 'hybrid'].includes(unmergedDictionary.location!)\n )\n .map((unmergedDictionary) => unmergedDictionary.filePath)\n .filter(Boolean) as string[]\n ),\n ];\n const sourceDictionaries = await loadContentDeclarations(\n uniqueSourcePaths.map((sourcePath) =>\n join(configuration.system.baseDir, sourcePath)\n ),\n configuration,\n undefined,\n {\n logError: false,\n }\n );\n // Map relative filePath → original fill value from the source file\n const originalFillByPath = new Map<string, Fill | undefined>();\n\n for (const dictionary of sourceDictionaries) {\n if (dictionary.filePath) {\n originalFillByPath.set(\n dictionary.filePath,\n dictionary.fill as Fill | undefined\n );\n }\n }\n\n const affectedDictionaryKeys = new Set<string>();\n\n targetUnmergedDictionaries.forEach((dict) => {\n affectedDictionaryKeys.add(dict.key);\n });\n\n const keysToProcess = Array.from(affectedDictionaryKeys);\n\n appLogger([\n 'Affected dictionary keys for processing:',\n keysToProcess.length > 0\n ? keysToProcess.map((key) => colorizeKey(key)).join(', ')\n : colorize('No keys found', ANSIColors.YELLOW),\n ]);\n\n if (keysToProcess.length === 0) return;\n\n /**\n * List the translations tasks\n *\n * Create a list of per-locale dictionaries to translate\n *\n * In 'complete' mode, filter only the missing locales to translate\n */\n const translationTasks: TranslationTask[] = listTranslationsTasks(\n targetUnmergedDictionaries.map((dictionary) => dictionary.localId!),\n outputLocales,\n mode,\n baseLocale,\n configuration\n );\n\n // AI calls in flight at once (translateJSON + metadata audit)\n const nbConcurrentTranslations =\n options?.nbConcurrentTranslations ?? NB_CONCURRENT_TRANSLATIONS;\n const globalLimiter = getGlobalLimiter(nbConcurrentTranslations);\n\n // NEW: number of *tasks* that may run at once (start/prepare/log/write)\n const nbConcurrentTasks = Math.max(\n 1,\n Math.min(\n options?.nbConcurrentTasks ?? nbConcurrentTranslations,\n translationTasks.length\n )\n );\n\n const taskLimiter = getTaskLimiter(nbConcurrentTasks);\n\n const runners = translationTasks.map((task) =>\n taskLimiter(async () => {\n const relativePath = relative(\n configuration?.system?.baseDir ?? process.cwd(),\n task?.dictionaryFilePath ?? ''\n );\n\n // log AFTER acquiring a task slot\n appLogger(\n `${task.dictionaryPreset} Processing ${colorizePath(basename(relativePath))}`,\n { level: 'info' }\n );\n\n const translationTaskResult = await translateDictionary(\n task,\n configuration,\n {\n mode,\n aiOptions: options?.aiOptions,\n fillMetadata: !options?.skipMetadata,\n onHandle: globalLimiter,\n aiClient,\n aiConfig,\n }\n );\n\n if (!translationTaskResult?.dictionaryOutput) return;\n\n const { dictionaryOutput, sourceLocale } = translationTaskResult;\n\n // Determine if we should write to separate files\n // - If dictionary has explicit fill setting (string, function, or object), use it\n // - If dictionary is per-locale AND has no explicit fill=false, use global fill config\n // - If dictionary is multilingual (no locale property), always write to same file\n //\n // NOTE: function-type fill values are lost during JSON serialisation of\n // unmerged_dictionaries.cjs. We recover them by checking the original\n // source file that was loaded above (originalFillByPath). Dictionary-level\n // fill always takes priority over config-level fill.\n const originalFill = originalFillByPath.get(\n dictionaryOutput.filePath ?? ''\n );\n\n // originalFill is undefined when the source file had no fill property; use\n // the (possibly JSON-preserved) dictionaryOutput.fill as a fallback so that\n // string/boolean fill values set directly on the dict still work.\n const dictFill: Fill | undefined =\n originalFill !== undefined ? originalFill : dictionaryOutput.fill;\n\n const hasDictionaryLevelFill =\n typeof dictFill === 'string' ||\n typeof dictFill === 'function' ||\n (typeof dictFill === 'object' && dictFill !== null);\n\n const isPerLocale = typeof dictionaryOutput.locale === 'string';\n\n const effectiveFill = hasDictionaryLevelFill\n ? dictFill\n : isPerLocale\n ? (configuration.dictionary?.fill ?? true)\n : false; // Multilingual dictionaries (no locale property) always write to same file unless explicitly set on the dictionary\n\n const isFillOtherFile =\n typeof effectiveFill === 'string' ||\n typeof effectiveFill === 'function' ||\n (typeof effectiveFill === 'object' && effectiveFill !== null);\n\n if (isFillOtherFile) {\n await writeFill(\n {\n ...dictionaryOutput,\n // Ensure fill is set on the dictionary for writeFill to use\n fill: effectiveFill,\n },\n outputLocales,\n [sourceLocale],\n configuration\n );\n } else {\n await writeContentDeclaration(dictionaryOutput, configuration);\n\n if (dictionaryOutput.filePath) {\n appLogger(\n `${task.dictionaryPreset} Content declaration written to ${formatPath(basename(dictionaryOutput.filePath))}`,\n { level: 'info' }\n );\n }\n }\n })\n );\n\n await Promise.all(runners);\n await (globalLimiter as any).onIdle();\n};\n"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAM,6BAA6B;;;;AAmBnC,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,gBAAgB,iBAAiB,SAAS,aAAa;CAC7D,iBAAiB,SAAS,aAAa;CAEvC,MAAM,YAAY,aAAa,aAAa;CAE5C,IAAI,SAAS,UAAU,MACrB,MAAMA,kBAAgB,eAAe,EAAE,UAAU,KAAK,CAAC;MAClD,IAAI,OAAO,SAAS,UAAU,aACnC,MAAMA,kBAAgB,aAAa;CAGrC,MAAM,EAAE,eAAe,YAAY,cAAc;CACjD,MAAM,OAAO,SAAS,QAAQ;CAC9B,MAAM,aAAa,SA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EAAE,OAAO,OAAO,CAClB;EAEJ;CACF,CAAC,CACH;CAEA,MAAM,QAAQ,IAAI,OAAO;CACzB,MAAO,cAAsB,OAAO;AACtC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { basename, dirname, isAbsolute, normalize, resolve } from "node:path";
|
|
2
2
|
import { GREY_DARK } from "@intlayer/config/colors";
|
|
3
3
|
import { colorize, colorizePath } from "@intlayer/config/logger";
|
|
4
|
-
import { parseFilePathPattern } from "@intlayer/config/utils";
|
|
5
4
|
import { getFormatFromExtension } from "@intlayer/engine/utils";
|
|
5
|
+
import { parseFilePathPattern } from "@intlayer/config/utils";
|
|
6
6
|
|
|
7
7
|
//#region src/fill/formatAutoFilledFilePath.ts
|
|
8
8
|
const formatAutoFilledFilePath = async (autoFillField, dictionaryKey, dictionaryFilePath, baseDir, configuration, locale) => {
|
|
@@ -2,8 +2,8 @@ import { listMissingTranslationsWithConfig } from "../test/listMissingTranslatio
|
|
|
2
2
|
import { basename } from "node:path";
|
|
3
3
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
4
4
|
import { colon, colorize, colorizeKey, colorizePath, getAppLogger } from "@intlayer/config/logger";
|
|
5
|
-
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
6
5
|
import { formatLocale } from "@intlayer/engine/utils";
|
|
6
|
+
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
7
7
|
import { getFilterTranslationsOnlyDictionary } from "@intlayer/core/plugins";
|
|
8
8
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
9
9
|
|
|
@@ -4,9 +4,9 @@ import { extractTranslatableContent, reinsertTranslatedContent } from "./extract
|
|
|
4
4
|
import { basename } from "node:path";
|
|
5
5
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
6
6
|
import { colon, colorize, colorizeNumber, colorizePath, getAppLogger } from "@intlayer/config/logger";
|
|
7
|
+
import { chunkJSON, excludeObjectFormat, formatLocale, mergeChunks, reconstructFromSingleChunk, verifyIdenticObjectFormat } from "@intlayer/engine/utils";
|
|
7
8
|
import { retryManager } from "@intlayer/config/utils";
|
|
8
9
|
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
9
|
-
import { chunkJSON, excludeObjectFormat, formatLocale, mergeChunks, reconstructFromSingleChunk, verifyIdenticObjectFormat } from "@intlayer/engine/utils";
|
|
10
10
|
import { getFilterMissingTranslationsDictionary, getMultilingualDictionary, getPerLocaleDictionary, insertContentInDictionary } from "@intlayer/core/plugins";
|
|
11
11
|
|
|
12
12
|
//#region src/fill/translateDictionary.ts
|
|
@@ -2,8 +2,8 @@ import { formatFillData } from "./formatFillData.mjs";
|
|
|
2
2
|
import { getAvailableLocalesInDictionary } from "./getAvailableLocalesInDictionary.mjs";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import { colorizeKey, getAppLogger } from "@intlayer/config/logger";
|
|
5
|
-
import { writeContentDeclaration } from "@intlayer/engine/build";
|
|
6
5
|
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
6
|
+
import { writeContentDeclaration } from "@intlayer/engine/build";
|
|
7
7
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
8
8
|
|
|
9
9
|
//#region src/fill/writeFill.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join, relative } from "node:path";
|
|
2
|
+
import { listGitFiles } from "@intlayer/engine/cli";
|
|
2
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
3
4
|
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
4
|
-
import { listGitFiles } from "@intlayer/engine/cli";
|
|
5
5
|
|
|
6
6
|
//#region src/getTargetDictionary.ts
|
|
7
7
|
const ensureArray = (value) => [value].flat();
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { pull } from "./pull.mjs";
|
|
2
|
-
import { extract } from "./extract.mjs";
|
|
3
|
-
import { startEditor } from "./editor.mjs";
|
|
4
|
-
import { liveSync } from "./liveSync.mjs";
|
|
5
1
|
import { INFRA_MODES, INSTALL_SCRIPT_URL, INSTALL_SCRIPT_URL_WINDOWS, initInfra, parseInfraMode } from "./initInfra.mjs";
|
|
6
2
|
import { PLATFORM_OPTIONS, getDetectedPlatform, initSkills, promptPlatform } from "./initSkills.mjs";
|
|
7
3
|
import { findProjectRoot, init } from "./init.mjs";
|
|
8
4
|
import { build } from "./build.mjs";
|
|
9
|
-
import {
|
|
5
|
+
import { listProjectsCommand } from "./listProjects.mjs";
|
|
6
|
+
import { startEditor } from "./editor.mjs";
|
|
7
|
+
import { scan } from "./scan.mjs";
|
|
10
8
|
import { dirname, setAPI } from "./cli.mjs";
|
|
9
|
+
import { extract } from "./extract.mjs";
|
|
10
|
+
import { bundle } from "./bundle.mjs";
|
|
11
11
|
import { listMissingTranslations, listMissingTranslationsWithConfig } from "./test/listMissingTranslations.mjs";
|
|
12
12
|
import { testMissingTranslations } from "./test/test.mjs";
|
|
13
13
|
import { fill } from "./fill/fill.mjs";
|
|
14
14
|
import { listContentDeclaration, listContentDeclarationRows } from "./listContentDeclaration.mjs";
|
|
15
|
-
import {
|
|
15
|
+
import { liveSync } from "./liveSync.mjs";
|
|
16
|
+
import { pull } from "./pull.mjs";
|
|
16
17
|
import { push } from "./push/push.mjs";
|
|
17
18
|
import { pushConfig } from "./pushConfig.mjs";
|
|
18
19
|
import { reviewDoc } from "./reviewDoc/reviewDoc.mjs";
|
|
19
|
-
import { scan } from "./scan.mjs";
|
|
20
20
|
import { searchDoc } from "./searchDoc.mjs";
|
|
21
21
|
import { translateDoc } from "./translateDoc/translateDoc.mjs";
|
|
22
22
|
|
package/dist/esm/init.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import { loadPrompts } from "./loadPrompts.mjs";
|
|
|
3
3
|
import { initInfra } from "./initInfra.mjs";
|
|
4
4
|
import { initSkills } from "./initSkills.mjs";
|
|
5
5
|
import { initMCP } from "./initMCP.mjs";
|
|
6
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
7
6
|
import { join, resolve } from "node:path";
|
|
8
7
|
import { detectCompatI18nLibraries, initIntlayer, setupCmsCredentials } from "@intlayer/engine/cli";
|
|
8
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
9
|
|
|
10
10
|
//#region src/init.ts
|
|
11
11
|
const findProjectRoot = (startDir) => {
|
package/dist/esm/initSkills.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { loadPrompts } from "./loadPrompts.mjs";
|
|
2
2
|
import { findProjectRoot } from "./init.mjs";
|
|
3
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
4
3
|
import { join, resolve } from "node:path";
|
|
5
4
|
import { PLATFORMS, PLATFORMS_METADATA, SKILLS, SKILLS_METADATA, getInitialSkills, installSkills } from "@intlayer/engine/cli";
|
|
5
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
6
6
|
import enquirer from "enquirer";
|
|
7
7
|
|
|
8
8
|
//#region src/initSkills.ts
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { relative } from "node:path";
|
|
2
|
+
import { prepareIntlayer } from "@intlayer/engine/cli";
|
|
2
3
|
import { colon, colorizeKey, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
3
4
|
import { getConfiguration } from "@intlayer/config/node";
|
|
4
|
-
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
5
|
-
import { prepareIntlayer } from "@intlayer/engine/cli";
|
|
6
5
|
import { formatPath } from "@intlayer/engine/utils";
|
|
6
|
+
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
7
7
|
|
|
8
8
|
//#region src/listContentDeclaration.ts
|
|
9
9
|
const listContentDeclarationRows = async (options) => {
|
package/dist/esm/liveSync.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { IntlayerEventListener } from "./IntlayerEventListener.mjs";
|
|
2
|
+
import { createServer } from "node:http";
|
|
2
3
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
3
4
|
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
4
5
|
import { getConfiguration } from "@intlayer/config/node";
|
|
6
|
+
import { runParallel } from "@intlayer/engine/utils";
|
|
5
7
|
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
6
8
|
import { buildDictionary } from "@intlayer/engine/build";
|
|
7
|
-
import { runParallel } from "@intlayer/engine/utils";
|
|
8
|
-
import { createServer } from "node:http";
|
|
9
|
-
import packageJson from "@intlayer/config/package.json" with { type: "json" };
|
|
10
9
|
import { getLocalizedContent } from "@intlayer/core/plugins";
|
|
11
10
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
11
|
+
import packageJson from "@intlayer/config/package.json" with { type: "json" };
|
|
12
12
|
|
|
13
13
|
//#region src/liveSync.ts
|
|
14
14
|
const writeDictionary = async (dictionary, configuration) => {
|
package/dist/esm/pull.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { PullLogger } from "./push/pullLog.mjs";
|
|
2
1
|
import { checkCMSAuth, getAuthenticatedAPI } from "./utils/checkAccess.mjs";
|
|
2
|
+
import { PullLogger } from "./push/pullLog.mjs";
|
|
3
3
|
import { selectCmsEnvironment } from "./utils/selectCmsEnvironment.mjs";
|
|
4
|
-
import { existsSync } from "node:fs";
|
|
5
4
|
import { join } from "node:path";
|
|
5
|
+
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
6
7
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
7
8
|
import { getAppLogger } from "@intlayer/config/logger";
|
|
8
9
|
import { getConfiguration } from "@intlayer/config/node";
|
|
10
|
+
import { parallelize } from "@intlayer/engine/utils";
|
|
9
11
|
import { getProjectRequire } from "@intlayer/config/utils";
|
|
10
12
|
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
11
13
|
import { writeContentDeclaration } from "@intlayer/engine/build";
|
|
12
|
-
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
13
|
-
import { parallelize } from "@intlayer/engine/utils";
|
|
14
14
|
|
|
15
15
|
//#region src/pull.ts
|
|
16
16
|
/**
|
package/dist/esm/push/push.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { loadPrompts } from "../loadPrompts.mjs";
|
|
1
2
|
import { checkCMSAuth, getAuthenticatedAPI } from "../utils/checkAccess.mjs";
|
|
2
3
|
import { selectCmsEnvironment } from "../utils/selectCmsEnvironment.mjs";
|
|
3
4
|
import { PushLogger } from "../pushLog.mjs";
|
|
4
|
-
import { loadPrompts } from "../loadPrompts.mjs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
+
import { listGitFiles, logConfigDetails } from "@intlayer/engine/cli";
|
|
6
7
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
7
8
|
import { colorize, colorizeKey, getAppLogger } from "@intlayer/config/logger";
|
|
8
9
|
import { getConfiguration } from "@intlayer/config/node";
|
|
9
|
-
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
10
|
-
import { prepareIntlayer, writeContentDeclaration } from "@intlayer/engine/build";
|
|
11
|
-
import { listGitFiles, logConfigDetails } from "@intlayer/engine/cli";
|
|
12
|
-
import { formatPath, parallelize } from "@intlayer/engine/utils";
|
|
13
10
|
import * as fsPromises from "node:fs/promises";
|
|
11
|
+
import { formatPath, parallelize } from "@intlayer/engine/utils";
|
|
12
|
+
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
13
|
+
import { prepareIntlayer as prepareIntlayer$1, writeContentDeclaration } from "@intlayer/engine/build";
|
|
14
14
|
|
|
15
15
|
//#region src/push/push.ts
|
|
16
16
|
const statusIconsAndColors = {
|
|
@@ -45,8 +45,8 @@ const push = async (options) => {
|
|
|
45
45
|
const config = getConfiguration(options?.configOptions);
|
|
46
46
|
logConfigDetails(options?.configOptions);
|
|
47
47
|
const appLogger = getAppLogger(config);
|
|
48
|
-
if (options?.build === true) await prepareIntlayer(config, { forceRun: true });
|
|
49
|
-
else if (typeof options?.build === "undefined") await prepareIntlayer(config);
|
|
48
|
+
if (options?.build === true) await prepareIntlayer$1(config, { forceRun: true });
|
|
49
|
+
else if (typeof options?.build === "undefined") await prepareIntlayer$1(config);
|
|
50
50
|
try {
|
|
51
51
|
if (!await checkCMSAuth(config)) return;
|
|
52
52
|
const intlayerAPI = await getAuthenticatedAPI(config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.mjs","names":[],"sources":["../../../src/push/push.ts"],"sourcesContent":["import * as fsPromises from 'node:fs/promises';\nimport { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getUnmergedDictionaries } from '@intlayer/dictionaries-entry/unmerged';\nimport {\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/engine/build';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n logConfigDetails,\n} from '@intlayer/engine/cli';\nimport { formatPath, parallelize } from '@intlayer/engine/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { loadPrompts } from '../loadPrompts';\nimport { PushLogger, type PushStatus } from '../pushLog';\nimport { checkCMSAuth, getAuthenticatedAPI } from '../utils/checkAccess';\nimport { selectCmsEnvironment } from '../utils/selectCmsEnvironment';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status:\n | 'pending'\n | 'pushing'\n | 'modified'\n | 'pushed'\n | 'up-to-date'\n | 'unknown'\n | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n// Print per-dictionary summary similar to loadDictionaries\nconst statusIconsAndColors = {\n pushed: { icon: '✔', color: ANSIColors.GREEN },\n modified: { icon: '✔', color: ANSIColors.GREEN },\n 'up-to-date': { icon: '=', color: ANSIColors.GREY },\n error: { icon: '✖', color: ANSIColors.RED },\n default: { icon: '⏲', color: ANSIColors.BLUE },\n};\n\nconst getIconAndColor = (status: DictionariesStatus['status']) => {\n return (\n statusIconsAndColors[status as keyof typeof statusIconsAndColors] ??\n statusIconsAndColors.default\n );\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n await selectCmsEnvironment(\n options?.configOptions?.env,\n intlayerAPI,\n config\n );\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n const allDictionaries = Object.values(unmergedDictionariesRecord).flat();\n\n const customLocations = Array.from(\n new Set(\n allDictionaries\n .map((dictionary) => dictionary.location)\n .filter(\n (location) =>\n location && !['remote', 'local', 'hybrid'].includes(location)\n )\n )\n ) as string[];\n\n // Include all custom locations automatically — no interactive prompt needed.\n const selectedCustomLocations: string[] = customLocations;\n\n let dictionaries: Dictionary[] = allDictionaries.filter((dictionary) => {\n const location =\n dictionary.location ?? config.dictionary?.location ?? 'local';\n\n return (\n location === 'remote' ||\n location === 'hybrid' ||\n selectedCustomLocations.includes(location)\n );\n });\n\n // Check if the dictionaries list is empty after filtering by location\n if (dictionaries.length === 0) {\n appLogger(\n `No dictionaries found to push. Only dictionaries with location ${colorize('remote', ANSIColors.BLUE, ANSIColors.RESET)}, ${colorize('hybrid', ANSIColors.BLUE, ANSIColors.RESET)} or selected custom locations are pushed.`,\n { level: 'warn' }\n );\n appLogger(\n `You can set the location in your dictionary file (e.g. ${colorize(\"{ key: 'my-key', location: 'hybrid', ... }\", ANSIColors.BLUE, ANSIColors.RESET)} or globally in your intlayer.config.ts file (e.g. ${colorize(\"{ dictionary: { location: 'hybrid' } }\", ANSIColors.BLUE, ANSIColors.RESET)}).`,\n { level: 'info' }\n );\n return;\n }\n\n const existingDictionariesKeys: string[] = Object.keys(\n unmergedDictionariesRecord\n );\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries?.includes(dictionary.key)\n );\n }\n\n if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n\n dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.system.baseDir, dictionary.filePath ?? '')\n )\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];\n const newDictionaries = pushResult.data?.newDictionaries ?? [];\n const upToDateDictionaries =\n pushResult.data?.upToDateDictionaries ?? [];\n\n const allDictionaries = [\n ...updatedDictionaries,\n ...newDictionaries,\n ...upToDateDictionaries,\n ];\n\n for (const remoteDictionaryData of allDictionaries) {\n const localDictionary = unmergedDictionariesRecord[\n remoteDictionaryData.key\n ]?.find(\n (dictionary) => dictionary.localId === remoteDictionaryData.localId\n );\n\n if (!localDictionary) continue;\n\n await writeContentDeclaration(\n { ...localDictionary, id: remoteDictionaryData.id },\n config\n );\n }\n\n if (\n updatedDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (\n newDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else if (\n upToDateDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'up-to-date';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'up-to-date' },\n ]);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n for (const dictionaryStatus of dictionariesStatuses) {\n const { icon, color } = getIconAndColor(dictionaryStatus.status);\n appLogger(\n ` - ${colorizeKey(dictionaryStatus.dictionary.key)} ${ANSIColors.GREY}[${color}${icon} ${dictionaryStatus.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const remoteDictionaries = successfullyPushedDictionaries.filter(\n (dictionary) => dictionary.location === 'remote'\n );\n const remoteDictionariesKeys = remoteDictionaries.map(\n (dictionary) => dictionary.key\n );\n\n if (remoteDictionaries.length > 0) {\n const { confirm, isCancel } = await loadPrompts();\n\n const shouldDelete = await confirm({\n message: `Do you want to delete the local dictionaries that were successfully pushed? ${colorize('(Dictionaries:', ANSIColors.GREY, ANSIColors.RESET)} ${colorizeKey(remoteDictionariesKeys)}${colorize(')', ANSIColors.GREY, ANSIColors.RESET)}`,\n initialValue: false,\n });\n\n if (isCancel(shouldDelete)) {\n return;\n }\n\n if (shouldDelete) {\n await deleteLocalDictionaries(remoteDictionaries, options);\n }\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n appLogger(\n `Dictionary ${colorizeKey(dictionary.key)} does not have a file path`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC7C,UAAU;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC/C,cAAc;EAAE,MAAM;EAAK,OAAO,WAAW;CAAK;CAClD,OAAO;EAAE,MAAM;EAAK,OAAO,WAAW;CAAI;CAC1C,SAAS;EAAE,MAAM;EAAK,OAAO,WAAW;CAAK;AAC/C;AAEA,MAAM,mBAAmB,WAAyC;CAChE,OACE,qBAAqB,WACrB,qBAAqB;AAEzB;;;;AAKA,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,SAAS,iBAAiB,SAAS,aAAa;CACtD,iBAAiB,SAAS,aAAa;CAEvC,MAAM,YAAY,aAAa,MAAM;CAErC,IAAI,SAAS,UAAU,MACrB,MAAM,gBAAgB,QAAQ,EAAE,UAAU,KAAK,CAAC;MAC3C,IAAI,OAAO,SAAS,UAAU,aACnC,MAAM,gBAAgB,MAAM;CAG9B,IAAI;EAGF,IAAI,CAAC,MAFoB,aAAa,MAAM,GAE3B;EAEjB,MAAM,cAAc,MAAM,oBAAoB,MAAM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
{"version":3,"file":"push.mjs","names":["prepareIntlayer"],"sources":["../../../src/push/push.ts"],"sourcesContent":["import * as fsPromises from 'node:fs/promises';\nimport { join } from 'node:path';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getUnmergedDictionaries } from '@intlayer/dictionaries-entry/unmerged';\nimport {\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/engine/build';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n logConfigDetails,\n} from '@intlayer/engine/cli';\nimport { formatPath, parallelize } from '@intlayer/engine/utils';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { loadPrompts } from '../loadPrompts';\nimport { PushLogger, type PushStatus } from '../pushLog';\nimport { checkCMSAuth, getAuthenticatedAPI } from '../utils/checkAccess';\nimport { selectCmsEnvironment } from '../utils/selectCmsEnvironment';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status:\n | 'pending'\n | 'pushing'\n | 'modified'\n | 'pushed'\n | 'up-to-date'\n | 'unknown'\n | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n// Print per-dictionary summary similar to loadDictionaries\nconst statusIconsAndColors = {\n pushed: { icon: '✔', color: ANSIColors.GREEN },\n modified: { icon: '✔', color: ANSIColors.GREEN },\n 'up-to-date': { icon: '=', color: ANSIColors.GREY },\n error: { icon: '✖', color: ANSIColors.RED },\n default: { icon: '⏲', color: ANSIColors.BLUE },\n};\n\nconst getIconAndColor = (status: DictionariesStatus['status']) => {\n return (\n statusIconsAndColors[status as keyof typeof statusIconsAndColors] ??\n statusIconsAndColors.default\n );\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n await selectCmsEnvironment(\n options?.configOptions?.env,\n intlayerAPI,\n config\n );\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n const allDictionaries = Object.values(unmergedDictionariesRecord).flat();\n\n const customLocations = Array.from(\n new Set(\n allDictionaries\n .map((dictionary) => dictionary.location)\n .filter(\n (location) =>\n location && !['remote', 'local', 'hybrid'].includes(location)\n )\n )\n ) as string[];\n\n // Include all custom locations automatically — no interactive prompt needed.\n const selectedCustomLocations: string[] = customLocations;\n\n let dictionaries: Dictionary[] = allDictionaries.filter((dictionary) => {\n const location =\n dictionary.location ?? config.dictionary?.location ?? 'local';\n\n return (\n location === 'remote' ||\n location === 'hybrid' ||\n selectedCustomLocations.includes(location)\n );\n });\n\n // Check if the dictionaries list is empty after filtering by location\n if (dictionaries.length === 0) {\n appLogger(\n `No dictionaries found to push. Only dictionaries with location ${colorize('remote', ANSIColors.BLUE, ANSIColors.RESET)}, ${colorize('hybrid', ANSIColors.BLUE, ANSIColors.RESET)} or selected custom locations are pushed.`,\n { level: 'warn' }\n );\n appLogger(\n `You can set the location in your dictionary file (e.g. ${colorize(\"{ key: 'my-key', location: 'hybrid', ... }\", ANSIColors.BLUE, ANSIColors.RESET)} or globally in your intlayer.config.ts file (e.g. ${colorize(\"{ dictionary: { location: 'hybrid' } }\", ANSIColors.BLUE, ANSIColors.RESET)}).`,\n { level: 'info' }\n );\n return;\n }\n\n const existingDictionariesKeys: string[] = Object.keys(\n unmergedDictionariesRecord\n );\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries?.includes(dictionary.key)\n );\n }\n\n if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n\n dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.system.baseDir, dictionary.filePath ?? '')\n )\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:');\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];\n const newDictionaries = pushResult.data?.newDictionaries ?? [];\n const upToDateDictionaries =\n pushResult.data?.upToDateDictionaries ?? [];\n\n const allDictionaries = [\n ...updatedDictionaries,\n ...newDictionaries,\n ...upToDateDictionaries,\n ];\n\n for (const remoteDictionaryData of allDictionaries) {\n const localDictionary = unmergedDictionariesRecord[\n remoteDictionaryData.key\n ]?.find(\n (dictionary) => dictionary.localId === remoteDictionaryData.localId\n );\n\n if (!localDictionary) continue;\n\n await writeContentDeclaration(\n { ...localDictionary, id: remoteDictionaryData.id },\n config\n );\n }\n\n if (\n updatedDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (\n newDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else if (\n upToDateDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'up-to-date';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'up-to-date' },\n ]);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n for (const dictionaryStatus of dictionariesStatuses) {\n const { icon, color } = getIconAndColor(dictionaryStatus.status);\n appLogger(\n ` - ${colorizeKey(dictionaryStatus.dictionary.key)} ${ANSIColors.GREY}[${color}${icon} ${dictionaryStatus.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const remoteDictionaries = successfullyPushedDictionaries.filter(\n (dictionary) => dictionary.location === 'remote'\n );\n const remoteDictionariesKeys = remoteDictionaries.map(\n (dictionary) => dictionary.key\n );\n\n if (remoteDictionaries.length > 0) {\n const { confirm, isCancel } = await loadPrompts();\n\n const shouldDelete = await confirm({\n message: `Do you want to delete the local dictionaries that were successfully pushed? ${colorize('(Dictionaries:', ANSIColors.GREY, ANSIColors.RESET)} ${colorizeKey(remoteDictionariesKeys)}${colorize(')', ANSIColors.GREY, ANSIColors.RESET)}`,\n initialValue: false,\n });\n\n if (isCancel(shouldDelete)) {\n return;\n }\n\n if (shouldDelete) {\n await deleteLocalDictionaries(remoteDictionaries, options);\n }\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n appLogger(\n `Dictionary ${colorizeKey(dictionary.key)} does not have a file path`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC7C,UAAU;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC/C,cAAc;EAAE,MAAM;EAAK,OAAO,WAAW;CAAK;CAClD,OAAO;EAAE,MAAM;EAAK,OAAO,WAAW;CAAI;CAC1C,SAAS;EAAE,MAAM;EAAK,OAAO,WAAW;CAAK;AAC/C;AAEA,MAAM,mBAAmB,WAAyC;CAChE,OACE,qBAAqB,WACrB,qBAAqB;AAEzB;;;;AAKA,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,SAAS,iBAAiB,SAAS,aAAa;CACtD,iBAAiB,SAAS,aAAa;CAEvC,MAAM,YAAY,aAAa,MAAM;CAErC,IAAI,SAAS,UAAU,MACrB,MAAMA,kBAAgB,QAAQ,EAAE,UAAU,KAAK,CAAC;MAC3C,IAAI,OAAO,SAAS,UAAU,aACnC,MAAMA,kBAAgB,MAAM;CAG9B,IAAI;EAGF,IAAI,CAAC,MAFoB,aAAa,MAAM,GAE3B;EAEjB,MAAM,cAAc,MAAM,oBAAoB,MAAM;EAEpD,MAAM,qBACJ,SAAS,eAAe,KACxB,aACA,MACF;EAEA,MAAM,6BAA6B,wBAAwB,MAAM;EACjE,MAAM,kBAAkB,OAAO,OAAO,0BAA0B,CAAC,CAAC,KAAK;EAcvE,MAAM,0BAZkB,MAAM,KAC5B,IAAI,IACF,gBACG,KAAK,eAAe,WAAW,QAAQ,CAAC,CACxC,QACE,aACC,YAAY,CAAC;GAAC;GAAU;GAAS;EAAQ,CAAC,CAAC,SAAS,QAAQ,CAChE,CACJ,CAIsD;EAExD,IAAI,eAA6B,gBAAgB,QA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AAO;GAE7D;EACF;CACF,SAAS,OAAO;EACd,UAAU,OAAO,EACf,OAAO,QACT,CAAC;CACH;AACF;AAEA,MAAM,0BAA0B,OAC9B,sBACA,YACkB;CAClB,MAAM,SAAS,iBAAiB,SAAS,aAAa;CACtD,MAAM,YAAY,aAAa,MAAM;CAGrC,MAAM,+BAA4B,IAAI,IAAI;CAE1C,KAAK,MAAM,cAAc,sBAAsB;EAC7C,MAAM,EAAE,aAAa;EAErB,IAAI,CAAC,UAAU;GACb,UACE,cAAc,YAAY,WAAW,GAAG,EAAE,6BAC1C,EACE,OAAO,QACT,CACF;GACA;EACF;EAEA,aAAa,IAAI,QAAQ;CAC3B;CAEA,KAAK,MAAM,YAAY,cACrB,IAAI;EACF,MAAM,QAAQ,MAAM,WAAW,MAAM,QAAQ;EAE7C,IAAI,MAAM,OAAO,GAAG;GAClB,MAAM,WAAW,OAAO,QAAQ;GAChC,UAAU,gBAAgB,WAAW,QAAQ,KAAK,CAAC,CAAC;EACtD,OAAO,IAAI,MAAM,YAAY,GAC3B,UAAU,uBAAuB,WAAW,QAAQ,EAAE,cAAc,CAAC,CAAC;OAEtE,UACE,yBAAyB,WAAW,QAAQ,EAAE,cAC9C,CAAC,CACH;CAEJ,SAAS,KAAK;EACZ,UAAU,kBAAkB,WAAW,QAAQ,EAAE,IAAI,OAAO,EAC1D,OAAO,QACT,CAAC;CACH;AAEJ"}
|
package/dist/esm/pushConfig.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { checkCMSAuth, getAuthenticatedAPI } from "./utils/checkAccess.mjs";
|
|
2
2
|
import { selectCmsEnvironment } from "./utils/selectCmsEnvironment.mjs";
|
|
3
|
+
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
3
4
|
import { CYAN, GREY_DARK } from "@intlayer/config/colors";
|
|
4
5
|
import { colorize, colorizeObject, getAppLogger } from "@intlayer/config/logger";
|
|
5
6
|
import { getConfiguration } from "@intlayer/config/node";
|
|
6
|
-
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
7
7
|
|
|
8
8
|
//#region src/pushConfig.ts
|
|
9
9
|
const pushConfig = async (options) => {
|
|
@@ -6,14 +6,14 @@ import { reviewFileBlockAware } from "./reviewDocBlockAware.mjs";
|
|
|
6
6
|
import { buildFileReviewReport, logReviewFileBlocks } from "./reviewDocLog.mjs";
|
|
7
7
|
import { createReviewProgressLogger } from "./reviewDocProgress.mjs";
|
|
8
8
|
import { formatReviewSynthesis } from "./reviewDocSynthesis.mjs";
|
|
9
|
-
import { existsSync } from "node:fs";
|
|
10
9
|
import { join, relative } from "node:path";
|
|
10
|
+
import { listGitFiles, listGitLines, logConfigDetails } from "@intlayer/engine/cli";
|
|
11
|
+
import { existsSync } from "node:fs";
|
|
11
12
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
12
13
|
import { colorize, colorizeNumber, getAppLogger, x } from "@intlayer/config/logger";
|
|
13
14
|
import { getConfiguration } from "@intlayer/config/node";
|
|
14
|
-
import { listGitFiles, listGitLines, logConfigDetails } from "@intlayer/engine/cli";
|
|
15
|
-
import { formatLocale, formatPath, parallelize } from "@intlayer/engine/utils";
|
|
16
15
|
import { readFile } from "node:fs/promises";
|
|
16
|
+
import { formatLocale, formatPath, parallelize } from "@intlayer/engine/utils";
|
|
17
17
|
import { buildReviewReport } from "@intlayer/engine/docReview";
|
|
18
18
|
import fg from "fast-glob";
|
|
19
19
|
|
|
@@ -2,14 +2,14 @@ import { readAsset } from "../_virtual/_utils_asset.mjs";
|
|
|
2
2
|
import { sanitizeChunk, validateTranslation } from "../translateDoc/validation.mjs";
|
|
3
3
|
import { chunkInference } from "../utils/chunkInference.mjs";
|
|
4
4
|
import { fixChunkStartEndChars } from "../utils/fixChunkStartEndChars.mjs";
|
|
5
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
6
5
|
import { dirname } from "node:path";
|
|
6
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
7
7
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
8
8
|
import { colon, colorize, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
9
9
|
import { getConfiguration } from "@intlayer/config/node";
|
|
10
|
-
import { retryManager } from "@intlayer/config/utils";
|
|
11
|
-
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
12
10
|
import { readFile } from "node:fs/promises";
|
|
11
|
+
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
12
|
+
import { retryManager } from "@intlayer/config/utils";
|
|
13
13
|
import { buildAlignmentPlan, mergeReviewedSegments } from "@intlayer/engine/docReview";
|
|
14
14
|
import { getLocaleName } from "@intlayer/core/localization";
|
|
15
15
|
import { ENGLISH } from "@intlayer/types/locales";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { getAppLogger } from "@intlayer/config/logger";
|
|
3
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
4
|
-
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
5
4
|
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
6
6
|
import { buildReviewReport, formatReviewReport } from "@intlayer/engine/docReview";
|
|
7
7
|
|
|
8
8
|
//#region src/reviewDoc/reviewDocLog.ts
|
package/dist/esm/searchDoc.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
1
2
|
import { colorizeKey, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
2
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
3
|
-
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
4
4
|
import { getSearchAPI } from "@intlayer/api";
|
|
5
5
|
|
|
6
6
|
//#region src/searchDoc.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
1
2
|
import { getConfiguration } from "@intlayer/config/node";
|
|
2
3
|
import { getUnmergedDictionaries } from "@intlayer/dictionaries-entry/unmerged";
|
|
3
|
-
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
4
4
|
import { getMissingLocalesContentFromDictionary } from "@intlayer/core/plugins";
|
|
5
5
|
import { getDictionaries } from "@intlayer/dictionaries-entry";
|
|
6
6
|
|
package/dist/esm/test/test.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { listMissingTranslations } from "./listMissingTranslations.mjs";
|
|
|
2
2
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
3
3
|
import { colon, colorize, colorizeKey, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
4
4
|
import { getConfiguration } from "@intlayer/config/node";
|
|
5
|
-
import { prepareIntlayer } from "@intlayer/engine/build";
|
|
6
5
|
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
6
|
+
import { prepareIntlayer } from "@intlayer/engine/build";
|
|
7
7
|
|
|
8
8
|
//#region src/test/test.ts
|
|
9
9
|
const testMissingTranslations = async (options) => {
|
|
@@ -2,12 +2,12 @@ import { setupAI } from "../utils/setupAI.mjs";
|
|
|
2
2
|
import { getOutputFilePath } from "../utils/getOutputFilePath.mjs";
|
|
3
3
|
import { checkFileModifiedRange } from "../utils/checkFileModifiedRange.mjs";
|
|
4
4
|
import { translateFile } from "./translateFile.mjs";
|
|
5
|
-
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
6
5
|
import { dirname, join } from "node:path";
|
|
6
|
+
import { listGitFiles, logConfigDetails } from "@intlayer/engine/cli";
|
|
7
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
7
8
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
8
9
|
import { colorize, colorizeNumber, getAppLogger, x } from "@intlayer/config/logger";
|
|
9
10
|
import { getConfiguration } from "@intlayer/config/node";
|
|
10
|
-
import { listGitFiles, logConfigDetails } from "@intlayer/engine/cli";
|
|
11
11
|
import { pLimit, parallelize } from "@intlayer/engine/utils";
|
|
12
12
|
import fg from "fast-glob";
|
|
13
13
|
import { performance } from "node:perf_hooks";
|
|
@@ -6,9 +6,9 @@ import { chunkText } from "../utils/calculateChunks.mjs";
|
|
|
6
6
|
import { dirname, relative } from "node:path";
|
|
7
7
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
8
8
|
import { colon, colorize, colorizeNumber, getAppLogger } from "@intlayer/config/logger";
|
|
9
|
-
import { retryManager } from "@intlayer/config/utils";
|
|
10
|
-
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
11
9
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
10
|
+
import { formatLocale, formatPath } from "@intlayer/engine/utils";
|
|
11
|
+
import { retryManager } from "@intlayer/config/utils";
|
|
12
12
|
import { performance } from "node:perf_hooks";
|
|
13
13
|
|
|
14
14
|
//#region src/translateDoc/translateFile.ts
|
package/dist/esm/watch.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
1
2
|
import { getAppLogger } from "@intlayer/config/logger";
|
|
2
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
3
|
-
import { logConfigDetails } from "@intlayer/engine/cli";
|
|
4
4
|
import { claimCliContentWatcher, reportRedundantContentWatcher, runParallel } from "@intlayer/engine/utils";
|
|
5
5
|
import { watch } from "@intlayer/engine/watcher";
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/cli",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provides uniform command-line interface scripts for Intlayer, used in packages like intlayer-cli and intlayer.",
|
|
6
6
|
"keywords": [
|
|
@@ -68,20 +68,20 @@
|
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@clack/prompts": "1.7.0",
|
|
71
|
-
"@intlayer/api": "9.5.
|
|
72
|
-
"@intlayer/babel": "9.5.
|
|
73
|
-
"@intlayer/config": "9.5.
|
|
74
|
-
"@intlayer/core": "9.5.
|
|
75
|
-
"@intlayer/dictionaries-entry": "9.5.
|
|
76
|
-
"@intlayer/engine": "9.5.
|
|
77
|
-
"@intlayer/types": "9.5.
|
|
71
|
+
"@intlayer/api": "9.5.9",
|
|
72
|
+
"@intlayer/babel": "9.5.9",
|
|
73
|
+
"@intlayer/config": "9.5.9",
|
|
74
|
+
"@intlayer/core": "9.5.9",
|
|
75
|
+
"@intlayer/dictionaries-entry": "9.5.9",
|
|
76
|
+
"@intlayer/engine": "9.5.9",
|
|
77
|
+
"@intlayer/types": "9.5.9",
|
|
78
78
|
"commander": "15.0.0",
|
|
79
79
|
"enquirer": "2.4.1",
|
|
80
80
|
"eventsource": "5.1.1",
|
|
81
81
|
"fast-glob": "3.3.3"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@intlayer/ai": "9.5.
|
|
84
|
+
"@intlayer/ai": "9.5.9",
|
|
85
85
|
"@types/node": "^22",
|
|
86
86
|
"@utils/ts-config": "1.0.4",
|
|
87
87
|
"@utils/ts-config-types": "1.0.4",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"vitest": "5.0.1"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@intlayer/ai": "9.5.
|
|
95
|
+
"@intlayer/ai": "9.5.9"
|
|
96
96
|
},
|
|
97
97
|
"peerDependenciesMeta": {
|
|
98
98
|
"@intlayer/ai": {
|