@intlayer/cli 9.7.0 → 9.7.2
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/IntlayerEventListener.cjs +1 -2
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -2
- package/dist/cjs/_virtual/_utils_asset.cjs +1 -2
- package/dist/cjs/auth/login.cjs +8 -9
- package/dist/cjs/auth/sessionToken.cjs +1 -2
- package/dist/cjs/auth/setupRepository.cjs +6 -7
- package/dist/cjs/build.cjs +2 -3
- package/dist/cjs/bundle.cjs +1 -2
- package/dist/cjs/bundle.cjs.map +1 -1
- package/dist/cjs/ci.cjs +2 -3
- package/dist/cjs/cli.cjs +8 -5
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +2 -3
- package/dist/cjs/editor.cjs +3 -4
- package/dist/cjs/extract.cjs +6 -7
- package/dist/cjs/fill/deepMergeContent.cjs +1 -2
- package/dist/cjs/fill/extractTranslatableContent.cjs +1 -2
- package/dist/cjs/fill/fill.cjs +9 -10
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +1 -2
- package/dist/cjs/fill/formatFillData.cjs +2 -3
- package/dist/cjs/fill/getAvailableLocalesInDictionary.cjs +1 -2
- package/dist/cjs/fill/getFilterMissingContentPerLocale.cjs +1 -2
- package/dist/cjs/fill/index.cjs +2 -2
- package/dist/cjs/fill/listTranslationsTasks.cjs +4 -5
- package/dist/cjs/fill/translateDictionary.cjs +7 -8
- package/dist/cjs/fill/writeFill.cjs +4 -5
- package/dist/cjs/getTargetDictionary.cjs +2 -3
- package/dist/cjs/index.cjs +28 -27
- package/dist/cjs/init.cjs +30 -13
- package/dist/cjs/init.cjs.map +1 -1
- package/dist/cjs/initChromeExtension.cjs +5 -6
- package/dist/cjs/initInfra.cjs +4 -5
- package/dist/cjs/initMCP.cjs +6 -7
- package/dist/cjs/initSkills.cjs +6 -7
- package/dist/cjs/listContentDeclaration.cjs +3 -4
- package/dist/cjs/listProjects.cjs +2 -3
- package/dist/cjs/liveSync.cjs +7 -8
- package/dist/cjs/loadPrompts.cjs +1 -2
- package/dist/cjs/pull.cjs +20 -13
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push/pullLog.cjs +2 -3
- package/dist/cjs/push/push.cjs +12 -12
- package/dist/cjs/push/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +4 -5
- package/dist/cjs/pushLog.cjs +2 -3
- package/dist/cjs/reviewDoc/reviewDoc.cjs +14 -14
- package/dist/cjs/reviewDoc/reviewDoc.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs +9 -10
- package/dist/cjs/reviewDoc/reviewDocBlockAware.cjs.map +1 -1
- package/dist/cjs/reviewDoc/reviewDocLog.cjs +2 -3
- package/dist/cjs/reviewDoc/reviewDocProgress.cjs +2 -3
- package/dist/cjs/reviewDoc/reviewDocSynthesis.cjs +2 -3
- package/dist/cjs/scan.cjs +2 -3
- package/dist/cjs/searchDoc.cjs +2 -3
- package/dist/cjs/test/index.cjs +2 -2
- package/dist/cjs/test/listMissingTranslations.cjs +2 -3
- package/dist/cjs/test/test.cjs +4 -5
- package/dist/cjs/translateDoc/index.cjs +3 -3
- package/dist/cjs/translateDoc/translateDoc.cjs +10 -11
- package/dist/cjs/translateDoc/translateDoc.cjs.map +1 -1
- package/dist/cjs/translateDoc/translateFile.cjs +10 -11
- package/dist/cjs/translateDoc/translateFile.cjs.map +1 -1
- package/dist/cjs/translateDoc/validation.cjs +1 -2
- package/dist/cjs/upgrade.cjs +3 -4
- package/dist/cjs/utils/calculateChunks.cjs +1 -2
- package/dist/cjs/utils/checkAccess.cjs +6 -7
- package/dist/cjs/utils/checkConfigConsistency.cjs +1 -2
- package/dist/cjs/utils/checkFileModifiedRange.cjs +3 -4
- package/dist/cjs/utils/checkLastUpdateTime.cjs +1 -2
- package/dist/cjs/utils/chunkInference.cjs +2 -3
- package/dist/cjs/utils/detectGitRepository.cjs +1 -2
- package/dist/cjs/utils/fixChunkStartEndChars.cjs +1 -2
- package/dist/cjs/utils/formatLineRanges.cjs +1 -2
- package/dist/cjs/utils/formatTimeDiff.cjs +1 -2
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +1 -2
- package/dist/cjs/utils/getOutputFilePath.cjs +1 -2
- package/dist/cjs/utils/getParentPackageJSON.cjs +1 -2
- package/dist/cjs/utils/isInteractiveTerminal.cjs +1 -2
- package/dist/cjs/utils/listSpecialChars.cjs +1 -2
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs +2 -3
- package/dist/cjs/utils/openBrowser.cjs +1 -2
- package/dist/cjs/utils/parseChoice.cjs +1 -2
- package/dist/cjs/utils/reorderParagraphs.cjs +2 -3
- package/dist/cjs/utils/selectCmsEnvironment.cjs +2 -3
- package/dist/cjs/utils/setupAI.cjs +3 -4
- package/dist/cjs/watch.cjs +2 -3
- package/dist/esm/IntlayerEventListener.mjs +1 -2
- package/dist/esm/_virtual/_rolldown/runtime.mjs +1 -2
- package/dist/esm/_virtual/_utils_asset.mjs +1 -2
- package/dist/esm/auth/login.mjs +4 -5
- package/dist/esm/auth/sessionToken.mjs +1 -2
- package/dist/esm/auth/setupRepository.mjs +3 -4
- package/dist/esm/build.mjs +2 -3
- package/dist/esm/bundle.mjs +1 -2
- package/dist/esm/bundle.mjs.map +1 -1
- package/dist/esm/ci.mjs +2 -3
- package/dist/esm/cli.mjs +7 -4
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +2 -3
- package/dist/esm/editor.mjs +2 -3
- package/dist/esm/extract.mjs +6 -7
- package/dist/esm/extract.mjs.map +1 -1
- package/dist/esm/fill/deepMergeContent.mjs +1 -2
- package/dist/esm/fill/extractTranslatableContent.mjs +1 -2
- package/dist/esm/fill/fill.mjs +5 -6
- package/dist/esm/fill/fill.mjs.map +1 -1
- package/dist/esm/fill/formatAutoFilledFilePath.mjs +1 -2
- package/dist/esm/fill/formatFillData.mjs +1 -2
- package/dist/esm/fill/getAvailableLocalesInDictionary.mjs +1 -2
- package/dist/esm/fill/getFilterMissingContentPerLocale.mjs +1 -2
- package/dist/esm/fill/index.mjs +1 -1
- package/dist/esm/fill/listTranslationsTasks.mjs +2 -3
- package/dist/esm/fill/translateDictionary.mjs +3 -4
- package/dist/esm/fill/writeFill.mjs +2 -3
- package/dist/esm/getTargetDictionary.mjs +2 -3
- package/dist/esm/index.mjs +14 -14
- package/dist/esm/init.mjs +24 -8
- package/dist/esm/init.mjs.map +1 -1
- package/dist/esm/initChromeExtension.mjs +2 -3
- package/dist/esm/initInfra.mjs +2 -3
- package/dist/esm/initMCP.mjs +3 -4
- package/dist/esm/initSkills.mjs +2 -3
- package/dist/esm/listContentDeclaration.mjs +3 -4
- package/dist/esm/listProjects.mjs +2 -3
- package/dist/esm/liveSync.mjs +4 -5
- package/dist/esm/loadPrompts.mjs +1 -2
- package/dist/esm/pull.mjs +16 -9
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/push/pullLog.mjs +1 -2
- package/dist/esm/push/push.mjs +9 -9
- package/dist/esm/push/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +2 -3
- package/dist/esm/pushLog.mjs +1 -2
- package/dist/esm/reviewDoc/reviewDoc.mjs +6 -6
- package/dist/esm/reviewDoc/reviewDoc.mjs.map +1 -1
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs +4 -5
- package/dist/esm/reviewDoc/reviewDocBlockAware.mjs.map +1 -1
- package/dist/esm/reviewDoc/reviewDocLog.mjs +2 -3
- package/dist/esm/reviewDoc/reviewDocProgress.mjs +1 -2
- package/dist/esm/reviewDoc/reviewDocSynthesis.mjs +1 -2
- package/dist/esm/scan.mjs +1 -2
- package/dist/esm/searchDoc.mjs +2 -3
- package/dist/esm/test/listMissingTranslations.mjs +2 -3
- package/dist/esm/test/test.mjs +2 -3
- package/dist/esm/translateDoc/index.mjs +2 -2
- package/dist/esm/translateDoc/translateDoc.mjs +5 -6
- package/dist/esm/translateDoc/translateDoc.mjs.map +1 -1
- package/dist/esm/translateDoc/translateFile.mjs +6 -7
- package/dist/esm/translateDoc/translateFile.mjs.map +1 -1
- package/dist/esm/translateDoc/validation.mjs +1 -2
- package/dist/esm/upgrade.mjs +2 -3
- package/dist/esm/utils/calculateChunks.mjs +1 -2
- package/dist/esm/utils/checkAccess.mjs +3 -4
- package/dist/esm/utils/checkConfigConsistency.mjs +1 -2
- package/dist/esm/utils/checkFileModifiedRange.mjs +1 -2
- package/dist/esm/utils/checkLastUpdateTime.mjs +1 -2
- package/dist/esm/utils/chunkInference.mjs +1 -2
- package/dist/esm/utils/detectGitRepository.mjs +1 -2
- package/dist/esm/utils/fixChunkStartEndChars.mjs +1 -2
- package/dist/esm/utils/formatLineRanges.mjs +1 -2
- package/dist/esm/utils/formatTimeDiff.mjs +1 -2
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs +1 -2
- package/dist/esm/utils/getOutputFilePath.mjs +1 -2
- package/dist/esm/utils/getParentPackageJSON.mjs +1 -2
- package/dist/esm/utils/isInteractiveTerminal.mjs +1 -2
- package/dist/esm/utils/listSpecialChars.mjs +1 -2
- package/dist/esm/utils/mapChunksBetweenFiles.mjs +1 -2
- package/dist/esm/utils/openBrowser.mjs +1 -2
- package/dist/esm/utils/parseChoice.mjs +1 -2
- package/dist/esm/utils/reorderParagraphs.mjs +1 -2
- package/dist/esm/utils/selectCmsEnvironment.mjs +1 -2
- package/dist/esm/utils/setupAI.mjs +1 -2
- package/dist/esm/watch.mjs +2 -3
- package/dist/types/IntlayerEventListener.d.ts +1 -3
- package/dist/types/IntlayerEventListener.d.ts.map +1 -1
- package/dist/types/auth/login.d.ts +1 -2
- package/dist/types/auth/login.d.ts.map +1 -1
- package/dist/types/auth/sessionToken.d.ts +0 -2
- package/dist/types/auth/sessionToken.d.ts.map +1 -1
- package/dist/types/auth/setupRepository.d.ts +1 -2
- package/dist/types/auth/setupRepository.d.ts.map +1 -1
- package/dist/types/build.d.ts +1 -2
- package/dist/types/build.d.ts.map +1 -1
- package/dist/types/bundle.d.ts +0 -2
- package/dist/types/bundle.d.ts.map +1 -1
- package/dist/types/ci.d.ts +1 -2
- package/dist/types/ci.d.ts.map +1 -1
- package/dist/types/cli.d.ts +1 -2
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/editor.d.ts +1 -2
- package/dist/types/editor.d.ts.map +1 -1
- package/dist/types/extract.d.ts +1 -2
- package/dist/types/extract.d.ts.map +1 -1
- package/dist/types/fill/deepMergeContent.d.ts +0 -2
- package/dist/types/fill/deepMergeContent.d.ts.map +1 -1
- package/dist/types/fill/extractTranslatableContent.d.ts +0 -2
- package/dist/types/fill/extractTranslatableContent.d.ts.map +1 -1
- package/dist/types/fill/fill.d.ts +1 -3
- package/dist/types/fill/fill.d.ts.map +1 -1
- package/dist/types/fill/formatAutoFilledFilePath.d.ts +1 -3
- package/dist/types/fill/formatAutoFilledFilePath.d.ts.map +1 -1
- package/dist/types/fill/formatFillData.d.ts +0 -2
- package/dist/types/fill/formatFillData.d.ts.map +1 -1
- package/dist/types/fill/getAvailableLocalesInDictionary.d.ts +0 -2
- package/dist/types/fill/getAvailableLocalesInDictionary.d.ts.map +1 -1
- package/dist/types/fill/getFilterMissingContentPerLocale.d.ts +0 -2
- package/dist/types/fill/getFilterMissingContentPerLocale.d.ts.map +1 -1
- package/dist/types/fill/listTranslationsTasks.d.ts +0 -2
- package/dist/types/fill/listTranslationsTasks.d.ts.map +1 -1
- package/dist/types/fill/translateDictionary.d.ts +2 -3
- package/dist/types/fill/translateDictionary.d.ts.map +1 -1
- package/dist/types/fill/writeFill.d.ts +0 -2
- package/dist/types/fill/writeFill.d.ts.map +1 -1
- package/dist/types/getTargetDictionary.d.ts +0 -2
- package/dist/types/getTargetDictionary.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/init.d.ts +6 -3
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/initChromeExtension.d.ts +0 -2
- package/dist/types/initChromeExtension.d.ts.map +1 -1
- package/dist/types/initInfra.d.ts +0 -2
- package/dist/types/initInfra.d.ts.map +1 -1
- package/dist/types/initMCP.d.ts +0 -2
- package/dist/types/initMCP.d.ts.map +1 -1
- package/dist/types/initSkills.d.ts +0 -2
- package/dist/types/initSkills.d.ts.map +1 -1
- package/dist/types/listContentDeclaration.d.ts +1 -2
- package/dist/types/listContentDeclaration.d.ts.map +1 -1
- package/dist/types/listProjects.d.ts +0 -2
- package/dist/types/listProjects.d.ts.map +1 -1
- package/dist/types/liveSync.d.ts +1 -2
- package/dist/types/liveSync.d.ts.map +1 -1
- package/dist/types/loadPrompts.d.ts +0 -2
- package/dist/types/loadPrompts.d.ts.map +1 -1
- package/dist/types/pull.d.ts +15 -3
- package/dist/types/pull.d.ts.map +1 -1
- package/dist/types/push/pullLog.d.ts +0 -2
- package/dist/types/push/pullLog.d.ts.map +1 -1
- package/dist/types/push/push.d.ts +1 -2
- package/dist/types/push/push.d.ts.map +1 -1
- package/dist/types/pushConfig.d.ts +1 -2
- package/dist/types/pushConfig.d.ts.map +1 -1
- package/dist/types/pushLog.d.ts +0 -2
- package/dist/types/pushLog.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDoc.d.ts +2 -3
- package/dist/types/reviewDoc/reviewDoc.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts +0 -2
- package/dist/types/reviewDoc/reviewDocBlockAware.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDocLog.d.ts +0 -2
- package/dist/types/reviewDoc/reviewDocLog.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDocProgress.d.ts +0 -2
- package/dist/types/reviewDoc/reviewDocProgress.d.ts.map +1 -1
- package/dist/types/reviewDoc/reviewDocSynthesis.d.ts +0 -2
- package/dist/types/reviewDoc/reviewDocSynthesis.d.ts.map +1 -1
- package/dist/types/scan.d.ts +0 -2
- package/dist/types/scan.d.ts.map +1 -1
- package/dist/types/searchDoc.d.ts +1 -2
- package/dist/types/searchDoc.d.ts.map +1 -1
- package/dist/types/test/listMissingTranslations.d.ts +1 -3
- package/dist/types/test/listMissingTranslations.d.ts.map +1 -1
- package/dist/types/test/test.d.ts +1 -2
- package/dist/types/test/test.d.ts.map +1 -1
- package/dist/types/translateDoc/index.d.ts +1 -1
- package/dist/types/translateDoc/translateDoc.d.ts +0 -2
- package/dist/types/translateDoc/translateDoc.d.ts.map +1 -1
- package/dist/types/translateDoc/translateFile.d.ts +0 -2
- package/dist/types/translateDoc/translateFile.d.ts.map +1 -1
- package/dist/types/translateDoc/types.d.ts +2 -4
- package/dist/types/translateDoc/types.d.ts.map +1 -1
- package/dist/types/translateDoc/validation.d.ts +0 -2
- package/dist/types/translateDoc/validation.d.ts.map +1 -1
- package/dist/types/upgrade.d.ts +0 -2
- package/dist/types/upgrade.d.ts.map +1 -1
- package/dist/types/utils/calculateChunks.d.ts +0 -2
- package/dist/types/utils/calculateChunks.d.ts.map +1 -1
- package/dist/types/utils/checkAccess.d.ts +1 -3
- package/dist/types/utils/checkAccess.d.ts.map +1 -1
- package/dist/types/utils/checkConfigConsistency.d.ts +0 -2
- package/dist/types/utils/checkConfigConsistency.d.ts.map +1 -1
- package/dist/types/utils/checkFileModifiedRange.d.ts +1 -2
- package/dist/types/utils/checkFileModifiedRange.d.ts.map +1 -1
- package/dist/types/utils/checkLastUpdateTime.d.ts +0 -2
- package/dist/types/utils/checkLastUpdateTime.d.ts.map +1 -1
- package/dist/types/utils/chunkInference.d.ts +1 -2
- package/dist/types/utils/chunkInference.d.ts.map +1 -1
- package/dist/types/utils/detectGitRepository.d.ts +0 -2
- package/dist/types/utils/detectGitRepository.d.ts.map +1 -1
- package/dist/types/utils/fixChunkStartEndChars.d.ts +0 -2
- package/dist/types/utils/fixChunkStartEndChars.d.ts.map +1 -1
- package/dist/types/utils/formatLineRanges.d.ts +0 -2
- package/dist/types/utils/formatLineRanges.d.ts.map +1 -1
- package/dist/types/utils/formatTimeDiff.d.ts +0 -2
- package/dist/types/utils/formatTimeDiff.d.ts.map +1 -1
- package/dist/types/utils/getIsFileUpdatedRecently.d.ts +0 -2
- package/dist/types/utils/getIsFileUpdatedRecently.d.ts.map +1 -1
- package/dist/types/utils/getOutputFilePath.d.ts +0 -2
- package/dist/types/utils/getOutputFilePath.d.ts.map +1 -1
- package/dist/types/utils/getParentPackageJSON.d.ts +1 -2
- package/dist/types/utils/getParentPackageJSON.d.ts.map +1 -1
- package/dist/types/utils/isInteractiveTerminal.d.ts +0 -2
- package/dist/types/utils/isInteractiveTerminal.d.ts.map +1 -1
- package/dist/types/utils/listSpecialChars.d.ts +1 -2
- package/dist/types/utils/listSpecialChars.d.ts.map +1 -1
- package/dist/types/utils/mapChunksBetweenFiles.d.ts +0 -2
- package/dist/types/utils/mapChunksBetweenFiles.d.ts.map +1 -1
- package/dist/types/utils/openBrowser.d.ts +0 -2
- package/dist/types/utils/openBrowser.d.ts.map +1 -1
- package/dist/types/utils/parseChoice.d.ts +0 -2
- package/dist/types/utils/parseChoice.d.ts.map +1 -1
- package/dist/types/utils/reorderParagraphs.d.ts +0 -2
- package/dist/types/utils/reorderParagraphs.d.ts.map +1 -1
- package/dist/types/utils/selectCmsEnvironment.d.ts +1 -3
- package/dist/types/utils/selectCmsEnvironment.d.ts.map +1 -1
- package/dist/types/utils/setupAI.d.ts +1 -2
- package/dist/types/utils/setupAI.d.ts.map +1 -1
- package/dist/types/watch.d.ts +1 -2
- package/dist/types/watch.d.ts.map +1 -1
- package/package.json +32 -32
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
3
|
-
const
|
|
4
|
-
const require_utils_getOutputFilePath = require(
|
|
5
|
-
const
|
|
6
|
-
const require_translateDoc_translateFile = require(
|
|
7
|
-
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_utils_checkFileModifiedRange = require("../utils/checkFileModifiedRange.cjs");
|
|
4
|
+
const require_utils_getOutputFilePath = require("../utils/getOutputFilePath.cjs");
|
|
5
|
+
const require_utils_setupAI = require("../utils/setupAI.cjs");
|
|
6
|
+
const require_translateDoc_translateFile = require("./translateFile.cjs");
|
|
8
7
|
let node_fs = require("node:fs");
|
|
9
8
|
let node_path = require("node:path");
|
|
10
9
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
11
10
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
12
11
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
13
12
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
14
|
-
let
|
|
13
|
+
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
14
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
15
15
|
let fast_glob = require("fast-glob");
|
|
16
16
|
fast_glob = require_runtime.__toESM(fast_glob);
|
|
17
17
|
let node_perf_hooks = require("node:perf_hooks");
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// src/translateDoc/translateDoc.ts
|
|
20
20
|
const translateDoc = async ({ docPattern, locales, excludedGlobPattern, baseLocale, aiOptions, nbSimultaneousFileProcessed = 20, configOptions, customInstructions, skipIfModifiedBefore, skipIfModifiedAfter, skipIfExists, gitOptions, flushStrategy = "incremental" }) => {
|
|
21
21
|
const configuration = (0, _intlayer_config_node.getConfiguration)(configOptions);
|
|
22
22
|
(0, _intlayer_engine_cli.logConfigDetails)(configOptions);
|
|
23
23
|
const appLogger = (0, _intlayer_config_logger.getAppLogger)(configuration);
|
|
24
24
|
const maxConcurrentChunks = nbSimultaneousFileProcessed;
|
|
25
|
-
const globalChunkLimiter = (0,
|
|
25
|
+
const globalChunkLimiter = (0, _intlayer_config_utils.pLimit)(maxConcurrentChunks);
|
|
26
26
|
let docList = await (0, fast_glob.default)(docPattern, { ignore: excludedGlobPattern });
|
|
27
27
|
const aiResult = await require_utils_setupAI.setupAI(configuration, aiOptions);
|
|
28
28
|
if (!aiResult?.hasAIAccess) return;
|
|
@@ -77,12 +77,11 @@ const translateDoc = async ({ docPattern, locales, excludedGlobPattern, baseLoca
|
|
|
77
77
|
limit: globalChunkLimiter
|
|
78
78
|
});
|
|
79
79
|
}));
|
|
80
|
-
await (0,
|
|
80
|
+
await (0, _intlayer_config_utils.parallelize)(allTasks, (task) => task(), 50);
|
|
81
81
|
const batchDuration = ((node_perf_hooks.performance.now() - batchStartTime) / 1e3).toFixed(2);
|
|
82
82
|
if (errorState.count > 0) appLogger(`Finished with ${errorState.count} errors in ${batchDuration}s.`);
|
|
83
83
|
else appLogger(`${(0, _intlayer_config_logger.colorize)("✔", _intlayer_config_colors.GREEN)} Batch completed successfully in ${(0, _intlayer_config_logger.colorizeNumber)(batchDuration)}s.`);
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
//#endregion
|
|
87
86
|
exports.translateDoc = translateDoc;
|
|
88
87
|
//# sourceMappingURL=translateDoc.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translateDoc.cjs","names":["getConfiguration","getAppLogger","pLimit","fg","setupAI","x","listGitFiles","join","performance","colorizeNumber","getOutputFilePath","existsSync","dirname","checkFileModifiedRange","translateFile","parallelize","colorize","ANSIColors"],"sources":["../../../src/translateDoc/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeNumber,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport {
|
|
1
|
+
{"version":3,"file":"translateDoc.cjs","names":["getConfiguration","getAppLogger","pLimit","fg","setupAI","x","listGitFiles","join","performance","colorizeNumber","getOutputFilePath","existsSync","dirname","checkFileModifiedRange","translateFile","parallelize","colorize","ANSIColors"],"sources":["../../../src/translateDoc/translateDoc.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeNumber,\n getAppLogger,\n x,\n} from '@intlayer/config/logger';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { parallelize, pLimit } from '@intlayer/config/utils';\nimport { listGitFiles, logConfigDetails } from '@intlayer/engine/cli';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport fg from 'fast-glob';\nimport { checkFileModifiedRange } from '../utils/checkFileModifiedRange';\nimport { getOutputFilePath } from '../utils/getOutputFilePath';\nimport { setupAI } from '../utils/setupAI';\nimport { translateFile } from './translateFile';\nimport type { ErrorState, TranslateDocOptions } from './types';\n\nexport const translateDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed = 20, // Default to a higher concurrency for chunks\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n skipIfExists,\n gitOptions,\n flushStrategy = 'incremental',\n}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n // 1. GLOBAL QUEUE SETUP\n // We use pLimit to create a single bottleneck for AI requests.\n // This queue is shared across all files and locales.\n const maxConcurrentChunks = nbSimultaneousFileProcessed;\n const globalChunkLimiter = pLimit(maxConcurrentChunks);\n\n let docList: string[] = await fg(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n const aiResult = await setupAI(configuration, aiOptions);\n if (!aiResult?.hasAIAccess) return;\n\n const { aiClient, aiConfig, isCustomAI } = aiResult;\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 if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n if (gitChangedFiles) {\n docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n const batchStartTime = performance.now();\n\n appLogger(\n `Translating ${colorizeNumber(docList.length)} files to ${colorizeNumber(locales.length)} locales. \\n` +\n `Global Concurrency: ${colorizeNumber(maxConcurrentChunks)} chunks in parallel.`\n );\n\n const errorState: ErrorState = {\n count: 0,\n maxErrors: 5,\n shouldStop: false,\n };\n\n // FLATTENED TASK LIST\n // We create a task for every File x Locale combination.\n const allTasks = docList.flatMap((docPath) =>\n locales.map((locale) => async () => {\n if (errorState.shouldStop) return;\n\n const absoluteBaseFilePath = join(configuration.system.baseDir, docPath);\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // Skip logic\n if (skipIfExists && existsSync(outputFilePath)) return;\n\n if (flushStrategy === 'incremental' && !existsSync(outputFilePath)) {\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n // Execute translation using the SHARED limiter\n await translateFile({\n baseFilePath: absoluteBaseFilePath,\n outputFilePath,\n locale: locale as Locale,\n baseLocale,\n configuration,\n errorState,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig,\n flushStrategy,\n limit: globalChunkLimiter, // Pass the global queue\n });\n })\n );\n\n // HIGH-THROUGHPUT FILE OPENER\n // We open many files simultaneously (e.g., 50) to ensure the global chunk queue\n // is always saturated with work.\n // If we open too few files, the chunk queue might drain faster than we can read new files.\n const FILE_OPEN_LIMIT = 50;\n\n await parallelize(allTasks, (task) => task(), FILE_OPEN_LIMIT);\n\n const batchEndTime = performance.now();\n const batchDuration = ((batchEndTime - batchStartTime) / 1000).toFixed(2);\n\n if (errorState.count > 0) {\n appLogger(`Finished with ${errorState.count} errors in ${batchDuration}s.`);\n } else {\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} Batch completed successfully in ${colorizeNumber(batchDuration)}s.`\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,MAAa,eAAe,OAAO,EACjC,YACA,SACA,qBACA,YACA,WACA,8BAA8B,IAC9B,eACA,oBACA,sBACA,qBACA,cACA,YACA,gBAAgB,oBACS;CACzB,MAAM,oBAAgBA,wCAAiB,aAAa;CACpD,2CAAiB,aAAa;CAE9B,MAAM,gBAAYC,sCAAa,aAAa;CAK5C,MAAM,sBAAsB;CAC5B,MAAM,yBAAqBC,+BAAO,mBAAmB;CAErD,IAAI,UAAoB,UAAMC,mBAAG,YAAY,EAC3C,QAAQ,oBACV,CAAC;CAED,MAAM,WAAW,MAAMC,8BAAQ,eAAe,SAAS;CACvD,IAAI,CAAC,UAAU,aAAa;CAE5B,MAAM,EAAE,UAAU,UAAU,eAAe;CAC3C,IAAI,cAAc,YAAY,UAAU;EACtC,MAAM,EAAE,aAAa,UAAU,MAAM,SAAS,iBAAiB,QAAQ;EACvE,IAAI,CAAC,aAAa;GAChB,UAAU,GAAGC,0BAAE,GAAG,OAAO;GACzB;EACF;CACF;CAEA,IAAI,YAAY;EACd,MAAM,kBAAkB,UAAMC,mCAAa,UAAU;EACrD,IAAI,iBACF,UAAU,QAAQ,QAAQ,SACxB,gBAAgB,MAAM,gBAAYC,gBAAK,QAAQ,IAAI,GAAG,IAAI,MAAM,OAAO,CACzE;CAEJ;CAEA,MAAM,iBAAiBC,4BAAY,IAAI;CAEvC,UACE,mBAAeC,wCAAe,QAAQ,MAAM,EAAE,gBAAYA,wCAAe,QAAQ,MAAM,EAAE,sCAChEA,wCAAe,mBAAmB,EAAE,qBAC/D;CAEA,MAAM,aAAyB;EAC7B,OAAO;EACP,WAAW;EACX,YAAY;CACd;CAIA,MAAM,WAAW,QAAQ,SAAS,YAChC,QAAQ,KAAK,WAAW,YAAY;EAClC,IAAI,WAAW,YAAY;EAE3B,MAAM,2BAAuBF,gBAAK,cAAc,OAAO,SAAS,OAAO;EACvE,MAAM,iBAAiBG,kDACrB,sBACA,QACA,UACF;EAGA,IAAI,oBAAgBC,oBAAW,cAAc,GAAG;EAEhD,IAAI,kBAAkB,iBAAiB,KAACA,oBAAW,cAAc,GAAG;GAClE,2BAAUC,mBAAQ,cAAc,GAAG,EAAE,WAAW,KAAK,CAAC;GACtD,2BAAc,gBAAgB,EAAE;EAClC;EAEA,MAAM,uBAAuBC,4DAAuB,gBAAgB;GAClE;GACA;EACF,CAAC;EAED,IAAI,qBAAqB,WAAW;GAClC,UAAU,qBAAqB,OAAO;GACtC;EACF;EAGA,MAAMC,iDAAc;GAClB,cAAc;GACd;GACQ;GACR;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,OAAO;EACT,CAAC;CACH,CAAC,CACH;CAQA,UAAMC,oCAAY,WAAW,SAAS,KAAK,GAAG,EAAe;CAG7D,MAAM,kBADeP,4BAAY,IACE,IAAI,kBAAkB,IAAI,CAAE,QAAQ,CAAC;CAExE,IAAI,WAAW,QAAQ,GACrB,UAAU,iBAAiB,WAAW,MAAM,aAAa,cAAc,GAAG;MAE1E,UACE,OAAGQ,kCAAS,KAAKC,wBAAW,KAAK,EAAE,uCAAmCR,wCAAe,aAAa,EAAE,GACtG;AAEJ"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
3
|
-
const require__utils_asset = require(
|
|
4
|
-
const
|
|
5
|
-
const require_utils_chunkInference = require(
|
|
6
|
-
const require_utils_fixChunkStartEndChars = require(
|
|
7
|
-
const
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require__utils_asset = require("../_virtual/_utils_asset.cjs");
|
|
4
|
+
const require_utils_calculateChunks = require("../utils/calculateChunks.cjs");
|
|
5
|
+
const require_utils_chunkInference = require("../utils/chunkInference.cjs");
|
|
6
|
+
const require_utils_fixChunkStartEndChars = require("../utils/fixChunkStartEndChars.cjs");
|
|
7
|
+
const require_translateDoc_validation = require("./validation.cjs");
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
10
10
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
11
11
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
12
|
-
let node_fs_promises = require("node:fs/promises");
|
|
13
12
|
let _intlayer_engine_utils = require("@intlayer/engine/utils");
|
|
13
|
+
let node_fs_promises = require("node:fs/promises");
|
|
14
14
|
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
15
15
|
let node_perf_hooks = require("node:perf_hooks");
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
// src/translateDoc/translateFile.ts
|
|
18
18
|
const translateFile = async ({ baseFilePath, outputFilePath, locale, baseLocale, configuration, errorState, aiOptions, customInstructions, aiClient, aiConfig, flushStrategy = "incremental", onChunkReceive, limit }) => {
|
|
19
19
|
if (errorState.shouldStop) return null;
|
|
20
20
|
const appLogger = (0, _intlayer_config_logger.getAppLogger)(configuration, { config: { prefix: "" } });
|
|
@@ -37,8 +37,8 @@ const translateFile = async ({ baseFilePath, outputFilePath, locale, baseLocale,
|
|
|
37
37
|
const chunkStartTime = node_perf_hooks.performance.now();
|
|
38
38
|
const isFirstChunk = i === 0;
|
|
39
39
|
const fileToTranslateCurrentChunk = chunk.content;
|
|
40
|
-
const getPrevChunkPrompt = () => `>>> CONTEXT: PREVIOUS SOURCE CONTENT <<<\n\`\`\`\n
|
|
41
|
-
const getBaseChunkContextPrompt = () => `>>> CONTEXT: NEXT CONTENT <<<\n\`\`\`\n
|
|
40
|
+
const getPrevChunkPrompt = () => `>>> CONTEXT: PREVIOUS SOURCE CONTENT <<<\n\`\`\`\n${chunks[i - 1]?.content ?? ""}\n\`\`\`\n>>> END PREVIOUS CONTEXT <<<`;
|
|
41
|
+
const getBaseChunkContextPrompt = () => `>>> CONTEXT: NEXT CONTENT <<<\n\`\`\`\n${chunks[i + 1]?.content ?? ""}\n\`\`\`\n>>> END NEXT CONTEXT <<<`;
|
|
42
42
|
chunkLogger("Process started");
|
|
43
43
|
const { content: translatedChunk, tokens } = await (0, _intlayer_config_utils.retryManager)(async () => {
|
|
44
44
|
const result = await require_utils_chunkInference.chunkInference([
|
|
@@ -103,6 +103,5 @@ const translateFile = async ({ baseFilePath, outputFilePath, locale, baseLocale,
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
//#endregion
|
|
107
106
|
exports.translateFile = translateFile;
|
|
108
107
|
//# sourceMappingURL=translateFile.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translateFile.cjs","names":["getAppLogger","performance","readFile","chunkText","ANSIColors","formatPath","colon","formatLocale","colorizeNumber","readAsset","retryManager","chunkInference","sanitizeChunk","fixChunkStartEndChars","validateTranslation","mkdir","dirname","writeFile","relative","colorize"],"sources":["../../../src/translateDoc/translateFile.ts"],"sourcesContent":["import { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { dirname, relative } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport { readAsset } from 'utils:asset';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colon,\n colorize,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { retryManager } from '@intlayer/config/utils';\nimport { formatLocale, formatPath } from '@intlayer/engine/utils';\nimport { chunkText } from '../utils/calculateChunks';\nimport { chunkInference } from '../utils/chunkInference';\nimport { fixChunkStartEndChars } from '../utils/fixChunkStartEndChars';\nimport type { TranslateFileOptions } from './types';\nimport { sanitizeChunk, validateTranslation } from './validation';\n\nexport const translateFile = async ({\n baseFilePath,\n outputFilePath,\n locale,\n baseLocale,\n configuration,\n errorState,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig,\n flushStrategy = 'incremental',\n onChunkReceive,\n limit, // The Global Limiter\n}: TranslateFileOptions): Promise<string | null> => {\n if (errorState.shouldStop) return null;\n\n const appLogger = getAppLogger(configuration, { config: { prefix: '' } });\n const fileStartTime = performance.now();\n\n try {\n const fileContent = await readFile(baseFilePath, 'utf-8');\n const chunks = chunkText(fileContent);\n const totalChunks = chunks.length;\n\n const filePrefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = `${colon(filePrefixText, { colSize: 40 })}${ANSIColors.RESET}`;\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = `${colon(prefixText, { colSize: 40 })}${ANSIColors.RESET}`;\n\n appLogger(\n `${filePrefix}Split into ${colorizeNumber(totalChunks)} chunks. Queuing...`\n );\n\n const basePrompt = readAsset('./prompts/TRANSLATE_PROMPT.md', 'utf-8')\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const translatedParts: string[] = new Array(totalChunks).fill('');\n\n // Fallback if no limiter is provided (runs immediately)\n const runTask = limit ?? ((fn) => fn());\n\n // MAP CHUNKS TO GLOBAL TASKS\n // This pushes ALL chunks for this file into the Global Queue immediately.\n // They will execute whenever the global concurrency slots open up.\n const tasks = chunks.map((chunk, i) =>\n runTask(async () => {\n if (errorState.shouldStop) return null;\n\n const chunkLogger = getAppLogger(configuration, {\n config: {\n prefix: `${prefix} ${ANSIColors.GREY_DARK}[${i + 1}/${totalChunks}] ${ANSIColors.RESET}`,\n },\n });\n\n const chunkStartTime = performance.now();\n const isFirstChunk = i === 0;\n const fileToTranslateCurrentChunk = chunk.content;\n\n // Context Preparation\n const getPrevChunkPrompt = () =>\n `>>> CONTEXT: PREVIOUS SOURCE CONTENT <<<\\n\\`\\`\\`\\n` +\n (chunks[i - 1]?.content ?? '') +\n `\\n\\`\\`\\`\\n>>> END PREVIOUS CONTEXT <<<`;\n\n const getBaseChunkContextPrompt = () =>\n `>>> CONTEXT: NEXT CONTENT <<<\\n\\`\\`\\`\\n` +\n (chunks[i + 1]?.content ?? '') +\n `\\n\\`\\`\\`\\n>>> END NEXT CONTEXT <<<`;\n\n chunkLogger('Process started');\n\n const chunkTranslation = retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n ...(chunks[i + 1]\n ? [\n {\n role: 'system',\n content: getBaseChunkContextPrompt(),\n } as const,\n ]\n : []),\n ...(isFirstChunk\n ? []\n : [{ role: 'system', content: getPrevChunkPrompt() } as const]),\n {\n role: 'system',\n content: [\n `You are translating TARGET CHUNK (${i + 1}/${totalChunks}).`,\n `Translate ONLY the target chunk. Preserve frontmatter/code exactly.`,\n ].join('\\n'),\n },\n ],\n [\n {\n role: 'user',\n content: `>>> TARGET CHUNK START <<<\\n${fileToTranslateCurrentChunk}\\n>>> TARGET CHUNK END <<<`,\n },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n let processedChunk = sanitizeChunk(\n result?.fileContent,\n fileToTranslateCurrentChunk\n );\n processedChunk = fixChunkStartEndChars(\n processedChunk,\n fileToTranslateCurrentChunk\n );\n\n const isValid = validateTranslation(\n fileToTranslateCurrentChunk,\n processedChunk,\n chunkLogger\n );\n\n if (!isValid) {\n // Throwing an error here signals retryManager to try again\n throw new Error(\n `Validation failed for chunk ${i + 1}/${totalChunks}`\n );\n }\n\n return { content: processedChunk, tokens: result.tokenUsed };\n });\n\n const { content: translatedChunk, tokens } = await chunkTranslation();\n const chunkEndTime = performance.now();\n const chunkDuration = (chunkEndTime - chunkStartTime).toFixed(0);\n\n // Store Result\n translatedParts[i] = translatedChunk;\n\n if (onChunkReceive) {\n onChunkReceive(translatedChunk, i, totalChunks);\n }\n\n // Incremental Flush Strategy\n if (flushStrategy === 'incremental') {\n const isContiguous = translatedParts\n .slice(0, i + 1)\n .every((p) => p && p !== '');\n\n if (isContiguous) {\n let endIdx = 0;\n while (\n endIdx < totalChunks &&\n translatedParts[endIdx] &&\n translatedParts[endIdx] !== ''\n ) {\n endIdx++;\n }\n const currentContent = translatedParts.slice(0, endIdx).join('');\n // Write asynchronously/sync is fine here as node handles file locks reasonably well for single process\n await mkdir(dirname(outputFilePath), { recursive: true });\n await writeFile(outputFilePath, currentContent);\n }\n }\n\n chunkLogger(\n [\n `${colorizeNumber(tokens)} tokens used `,\n `${ANSIColors.GREY_DARK}in ${colorizeNumber(chunkDuration)}ms${ANSIColors.RESET}`,\n ].join('')\n );\n })\n );\n\n // Wait for all chunks for this specific file/locale to finish\n await Promise.all(tasks);\n\n // Final Flush\n const fullContent = translatedParts.join('');\n if (flushStrategy === 'end' || flushStrategy === 'incremental') {\n await mkdir(dirname(outputFilePath), { recursive: true });\n await writeFile(outputFilePath, fullContent);\n }\n\n const fileEndTime = performance.now();\n const totalDuration = ((fileEndTime - fileStartTime) / 1000).toFixed(2);\n const relativePath = relative(configuration.system.baseDir, outputFilePath);\n\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(relativePath)} completed in ${colorizeNumber(totalDuration)}s.`\n );\n\n return fullContent;\n } catch (error: any) {\n errorState.count++;\n const errorMessage = error?.message ?? JSON.stringify(error);\n appLogger(`${colorize('✖', ANSIColors.RED)} Error: ${errorMessage}`);\n if (errorState.count >= errorState.maxErrors) errorState.shouldStop = true;\n return null;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAa,gBAAgB,OAAO,EAClC,cACA,gBACA,QACA,YACA,eACA,YACA,WACA,oBACA,UACA,UACA,gBAAgB,eAChB,gBACA,YACkD;CAClD,I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AM,EAEZ,GAAG;KAChB,IAAI,SAAS;KACb,OACE,SAAS,eACT,gBAAgB,WAChB,gBAAgB,YAAY,IAE5B;KAEF,MAAM,iBAAiB,gBAAgB,MAAM,GAAG,MAAM,CAAC,CAAC,KAAK,EAAE;KAE/D,UAAMc,4BAAMC,mBAAQ,cAAc,GAAG,EAAE,WAAW,KAAK,CAAC;KACxD,UAAMC,4BAAU,gBAAgB,cAAc;IAChD;;GAGF,YACE,CACE,OAAGT,wCAAe,MAAM,EAAE,gBAC1B,GAAGJ,wBAAW,UAAU,SAAKI,wCAAe,aAAa,EAAE,IAAIJ,wBAAW,OAC5E,CAAC,CAAC,KAAK,EAAE,CACX;EACF,CAAC,CACH;EAGA,MAAM,QAAQ,IAAI,KAAK;EAGvB,MAAM,cAAc,gBAAgB,KAAK,EAAE;EAC3C,IAAI,kBAAkB,SAAS,kBAAkB,eAAe;GAC9D,UAAMW,4BAAMC,mBAAQ,cAAc,GAAG,EAAE,WAAW,KAAK,CAAC;GACxD,UAAMC,4BAAU,gBAAgB,WAAW;EAC7C;EAGA,MAAM,kBADchB,4BAAY,IACE,IAAI,iBAAiB,IAAI,CAAE,QAAQ,CAAC;EACtE,MAAM,mBAAeiB,oBAAS,cAAc,OAAO,SAAS,cAAc;EAE1E,UACE,OAAGC,kCAAS,KAAKf,wBAAW,KAAK,EAAE,YAAQC,mCAAW,YAAY,EAAE,oBAAgBG,wCAAe,aAAa,EAAE,GACpH;EAEA,OAAO;CACT,SAAS,OAAY;EACnB,WAAW;EACX,MAAM,eAAe,OAAO,WAAW,KAAK,UAAU,KAAK;EAC3D,UAAU,OAAGW,kCAAS,KAAKf,wBAAW,GAAG,EAAE,UAAU,cAAc;EACnE,IAAI,WAAW,SAAS,WAAW,WAAW,WAAW,aAAa;EACtE,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"translateFile.cjs","names":["getAppLogger","performance","readFile","chunkText","ANSIColors","formatPath","colon","formatLocale","colorizeNumber","readAsset","retryManager","chunkInference","sanitizeChunk","fixChunkStartEndChars","validateTranslation","mkdir","dirname","writeFile","relative","colorize"],"sources":["../../../src/translateDoc/translateFile.ts"],"sourcesContent":["import { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { dirname, relative } from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport {\n colon,\n colorize,\n colorizeNumber,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport { retryManager } from '@intlayer/config/utils';\nimport { formatLocale, formatPath } from '@intlayer/engine/utils';\nimport { readAsset } from 'utils:asset';\nimport { chunkText } from '../utils/calculateChunks';\nimport { chunkInference } from '../utils/chunkInference';\nimport { fixChunkStartEndChars } from '../utils/fixChunkStartEndChars';\nimport type { TranslateFileOptions } from './types';\nimport { sanitizeChunk, validateTranslation } from './validation';\n\nexport const translateFile = async ({\n baseFilePath,\n outputFilePath,\n locale,\n baseLocale,\n configuration,\n errorState,\n aiOptions,\n customInstructions,\n aiClient,\n aiConfig,\n flushStrategy = 'incremental',\n onChunkReceive,\n limit, // The Global Limiter\n}: TranslateFileOptions): Promise<string | null> => {\n if (errorState.shouldStop) return null;\n\n const appLogger = getAppLogger(configuration, { config: { prefix: '' } });\n const fileStartTime = performance.now();\n\n try {\n const fileContent = await readFile(baseFilePath, 'utf-8');\n const chunks = chunkText(fileContent);\n const totalChunks = chunks.length;\n\n const filePrefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = `${colon(filePrefixText, { colSize: 40 })}${ANSIColors.RESET}`;\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = `${colon(prefixText, { colSize: 40 })}${ANSIColors.RESET}`;\n\n appLogger(\n `${filePrefix}Split into ${colorizeNumber(totalChunks)} chunks. Queuing...`\n );\n\n const basePrompt = readAsset('./prompts/TRANSLATE_PROMPT.md', 'utf-8')\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const translatedParts: string[] = new Array(totalChunks).fill('');\n\n // Fallback if no limiter is provided (runs immediately)\n const runTask = limit ?? ((fn) => fn());\n\n // MAP CHUNKS TO GLOBAL TASKS\n // This pushes ALL chunks for this file into the Global Queue immediately.\n // They will execute whenever the global concurrency slots open up.\n const tasks = chunks.map((chunk, i) =>\n runTask(async () => {\n if (errorState.shouldStop) return null;\n\n const chunkLogger = getAppLogger(configuration, {\n config: {\n prefix: `${prefix} ${ANSIColors.GREY_DARK}[${i + 1}/${totalChunks}] ${ANSIColors.RESET}`,\n },\n });\n\n const chunkStartTime = performance.now();\n const isFirstChunk = i === 0;\n const fileToTranslateCurrentChunk = chunk.content;\n\n // Context Preparation\n const getPrevChunkPrompt = () =>\n `>>> CONTEXT: PREVIOUS SOURCE CONTENT <<<\\n\\`\\`\\`\\n${ \n chunks[i - 1]?.content ?? '' \n }\\n\\`\\`\\`\\n>>> END PREVIOUS CONTEXT <<<`;\n\n const getBaseChunkContextPrompt = () =>\n `>>> CONTEXT: NEXT CONTENT <<<\\n\\`\\`\\`\\n${ \n chunks[i + 1]?.content ?? '' \n }\\n\\`\\`\\`\\n>>> END NEXT CONTEXT <<<`;\n\n chunkLogger('Process started');\n\n const chunkTranslation = retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n ...(chunks[i + 1]\n ? [\n {\n role: 'system',\n content: getBaseChunkContextPrompt(),\n } as const,\n ]\n : []),\n ...(isFirstChunk\n ? []\n : [{ role: 'system', content: getPrevChunkPrompt() } as const]),\n {\n role: 'system',\n content: [\n `You are translating TARGET CHUNK (${i + 1}/${totalChunks}).`,\n `Translate ONLY the target chunk. Preserve frontmatter/code exactly.`,\n ].join('\\n'),\n },\n ],\n [\n {\n role: 'user',\n content: `>>> TARGET CHUNK START <<<\\n${fileToTranslateCurrentChunk}\\n>>> TARGET CHUNK END <<<`,\n },\n ],\n aiOptions,\n configuration,\n aiClient,\n aiConfig\n );\n\n let processedChunk = sanitizeChunk(\n result?.fileContent,\n fileToTranslateCurrentChunk\n );\n processedChunk = fixChunkStartEndChars(\n processedChunk,\n fileToTranslateCurrentChunk\n );\n\n const isValid = validateTranslation(\n fileToTranslateCurrentChunk,\n processedChunk,\n chunkLogger\n );\n\n if (!isValid) {\n // Throwing an error here signals retryManager to try again\n throw new Error(\n `Validation failed for chunk ${i + 1}/${totalChunks}`\n );\n }\n\n return { content: processedChunk, tokens: result.tokenUsed };\n });\n\n const { content: translatedChunk, tokens } = await chunkTranslation();\n const chunkEndTime = performance.now();\n const chunkDuration = (chunkEndTime - chunkStartTime).toFixed(0);\n\n // Store Result\n translatedParts[i] = translatedChunk;\n\n if (onChunkReceive) {\n onChunkReceive(translatedChunk, i, totalChunks);\n }\n\n // Incremental Flush Strategy\n if (flushStrategy === 'incremental') {\n const isContiguous = translatedParts\n .slice(0, i + 1)\n .every((p) => p && p !== '');\n\n if (isContiguous) {\n let endIdx = 0;\n while (\n endIdx < totalChunks &&\n translatedParts[endIdx] &&\n translatedParts[endIdx] !== ''\n ) {\n endIdx++;\n }\n const currentContent = translatedParts.slice(0, endIdx).join('');\n // Write asynchronously/sync is fine here as node handles file locks reasonably well for single process\n await mkdir(dirname(outputFilePath), { recursive: true });\n await writeFile(outputFilePath, currentContent);\n }\n }\n\n chunkLogger(\n [\n `${colorizeNumber(tokens)} tokens used `,\n `${ANSIColors.GREY_DARK}in ${colorizeNumber(chunkDuration)}ms${ANSIColors.RESET}`,\n ].join('')\n );\n })\n );\n\n // Wait for all chunks for this specific file/locale to finish\n await Promise.all(tasks);\n\n // Final Flush\n const fullContent = translatedParts.join('');\n if (flushStrategy === 'end' || flushStrategy === 'incremental') {\n await mkdir(dirname(outputFilePath), { recursive: true });\n await writeFile(outputFilePath, fullContent);\n }\n\n const fileEndTime = performance.now();\n const totalDuration = ((fileEndTime - fileStartTime) / 1000).toFixed(2);\n const relativePath = relative(configuration.system.baseDir, outputFilePath);\n\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(relativePath)} completed in ${colorizeNumber(totalDuration)}s.`\n );\n\n return fullContent;\n } catch (error: any) {\n errorState.count++;\n const errorMessage = error?.message ?? JSON.stringify(error);\n appLogger(`${colorize('✖', ANSIColors.RED)} Error: ${errorMessage}`);\n if (errorState.count >= errorState.maxErrors) errorState.shouldStop = true;\n return null;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAa,gBAAgB,OAAO,EAClC,cACA,gBACA,QACA,YACA,eACA,YACA,WACA,oBACA,UACA,UACA,gBAAgB,eAChB,gBACA,YACkD;CAClD,IAAI,WAAW,YAAY,OAAO;CAElC,MAAM,gBAAYA,sCAAa,eAAe,EAAE,QAAQ,EAAE,QAAQ,GAAG,EAAE,CAAC;CACxE,MAAM,gBAAgBC,4BAAY,IAAI;CAEtC,IAAI;EACF,MAAM,cAAc,UAAMC,2BAAS,cAAc,OAAO;EACxD,MAAM,SAASC,wCAAU,WAAW;EACpC,MAAM,cAAc,OAAO;EAE3B,MAAM,iBAAiB,GAAGC,wBAAW,UAAU,OAAGC,mCAAW,YAAY,IAAID,wBAAW,UAAU;EAClG,MAAM,aAAa,OAAGE,+BAAM,gBAAgB,EAAE,SAAS,GAAG,CAAC,IAAIF,wBAAW;EAC1E,MAAM,aAAa,GAAGA,wBAAW,UAAU,OAAGC,mCAAW,YAAY,IAAID,wBAAW,UAAU,QAAIG,qCAAa,MAAM,IAAIH,wBAAW,UAAU;EAC9I,MAAM,SAAS,OAAGE,+BAAM,YAAY,EAAE,SAAS,GAAG,CAAC,IAAIF,wBAAW;EAElE,UACE,GAAG,WAAW,iBAAaI,wCAAe,WAAW,EAAE,oBACzD;EAEA,MAAM,aAAaC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,IACE,IAAI,iBAAiB,IAAI,CAAE,QAAQ,CAAC;EACtE,MAAM,mBAAeiB,oBAAS,cAAc,OAAO,SAAS,cAAc;EAE1E,UACE,OAAGC,kCAAS,KAAKf,wBAAW,KAAK,EAAE,YAAQC,mCAAW,YAAY,EAAE,oBAAgBG,wCAAe,aAAa,EAAE,GACpH;EAEA,OAAO;CACT,SAAS,OAAY;EACnB,WAAW;EACX,MAAM,eAAe,OAAO,WAAW,KAAK,UAAU,KAAK;EAC3D,UAAU,OAAGW,kCAAS,KAAKf,wBAAW,GAAG,EAAE,UAAU,cAAc;EACnE,IAAI,WAAW,SAAS,WAAW,WAAW,WAAW,aAAa;EACtE,OAAO;CACT;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/translateDoc/validation.ts
|
|
3
3
|
/**
|
|
4
4
|
* Validates that the translated content matches the structure of the original.
|
|
5
5
|
* Throws an error if a mismatch is found, triggering a retry.
|
|
@@ -43,7 +43,6 @@ const sanitizeChunk = (translated, original) => {
|
|
|
43
43
|
return cleaned;
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
//#endregion
|
|
47
46
|
exports.sanitizeChunk = sanitizeChunk;
|
|
48
47
|
exports.validateTranslation = validateTranslation;
|
|
49
48
|
//# sourceMappingURL=validation.cjs.map
|
package/dist/cjs/upgrade.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_init = require(
|
|
3
|
-
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
2
|
+
const require_init = require("./init.cjs");
|
|
4
3
|
let node_path = require("node:path");
|
|
4
|
+
let _intlayer_engine_cli = require("@intlayer/engine/cli");
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/upgrade.ts
|
|
7
7
|
/**
|
|
8
8
|
* Lists the Intlayer packages of every `package.json` of the project and
|
|
9
9
|
* upgrades them to the version of the given dist-tag.
|
|
@@ -13,6 +13,5 @@ const upgrade = async (projectRoot, options) => {
|
|
|
13
13
|
await (0, _intlayer_engine_cli.upgradeIntlayerPackages)(root, options);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
//#endregion
|
|
17
16
|
exports.upgrade = upgrade;
|
|
18
17
|
//# sourceMappingURL=upgrade.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
let _intlayer_engine_utils = require("@intlayer/engine/utils");
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/utils/calculateChunks.ts
|
|
5
5
|
const DEFAULT_MAX_CHARS_PER_CHUNK = 800;
|
|
6
6
|
const DEFAULT_OVERLAP_CHARS = 0;
|
|
7
7
|
const chunkText = (text, maxCharsPerChunk = DEFAULT_MAX_CHARS_PER_CHUNK, overlapChars = DEFAULT_OVERLAP_CHARS) => {
|
|
@@ -84,6 +84,5 @@ const chunkText = (text, maxCharsPerChunk = DEFAULT_MAX_CHARS_PER_CHUNK, overlap
|
|
|
84
84
|
return overlapChunks;
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
//#endregion
|
|
88
87
|
exports.chunkText = chunkText;
|
|
89
88
|
//# sourceMappingURL=calculateChunks.cjs.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const require_utils_checkConfigConsistency = require(
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_auth_login = require("../auth/login.cjs");
|
|
4
|
+
const require_auth_sessionToken = require("../auth/sessionToken.cjs");
|
|
5
|
+
const require_utils_checkConfigConsistency = require("./checkConfigConsistency.cjs");
|
|
6
6
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
7
7
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
8
8
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
9
|
-
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
10
9
|
let _intlayer_api = require("@intlayer/api");
|
|
10
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// src/utils/checkAccess.ts
|
|
13
13
|
const getAuthenticatedAPI = async (configuration) => {
|
|
14
14
|
let sessionData = null;
|
|
15
15
|
if (configuration) sessionData = await require_auth_sessionToken.readCliSessionToken(configuration);
|
|
@@ -111,7 +111,6 @@ const checkAIAccess = async (configuration, aiOptions, shouldCheckConfigConsiste
|
|
|
111
111
|
return await checkCMSAuth(configuration, shouldCheckConfigConsistency);
|
|
112
112
|
};
|
|
113
113
|
|
|
114
|
-
//#endregion
|
|
115
114
|
exports.checkAIAccess = checkAIAccess;
|
|
116
115
|
exports.checkCMSAuth = checkCMSAuth;
|
|
117
116
|
exports.getAuthenticatedAPI = getAuthenticatedAPI;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/utils/checkConfigConsistency.ts
|
|
3
3
|
const checkConfigConsistency = (subset, superset) => {
|
|
4
4
|
for (const key in subset) {
|
|
5
5
|
const val1 = subset[key];
|
|
@@ -11,6 +11,5 @@ const checkConfigConsistency = (subset, superset) => {
|
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
//#endregion
|
|
15
14
|
exports.checkConfigConsistency = checkConfigConsistency;
|
|
16
15
|
//# sourceMappingURL=checkConfigConsistency.cjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_utils_checkLastUpdateTime = require(
|
|
3
|
-
const require_utils_formatTimeDiff = require(
|
|
2
|
+
const require_utils_checkLastUpdateTime = require("./checkLastUpdateTime.cjs");
|
|
3
|
+
const require_utils_formatTimeDiff = require("./formatTimeDiff.cjs");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/utils/checkFileModifiedRange.ts
|
|
6
6
|
/**
|
|
7
7
|
* Threshold that helps us differentiate between a numeric *timestamp* (ms from epoch)
|
|
8
8
|
* and a numeric *duration* (ms ago).
|
|
@@ -78,6 +78,5 @@ const checkFileModifiedRange = (filePath, options) => {
|
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
//#endregion
|
|
82
81
|
exports.checkFileModifiedRange = checkFileModifiedRange;
|
|
83
82
|
//# sourceMappingURL=checkFileModifiedRange.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/utils/checkLastUpdateTime.ts
|
|
5
5
|
/**
|
|
6
6
|
* Returns the last modification date of a file.
|
|
7
7
|
*
|
|
@@ -14,6 +14,5 @@ const checkLastUpdateTime = (filePath) => {
|
|
|
14
14
|
return new Date(stats.mtime);
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
//#endregion
|
|
18
17
|
exports.checkLastUpdateTime = checkLastUpdateTime;
|
|
19
18
|
//# sourceMappingURL=checkLastUpdateTime.cjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_utils_checkAccess = require(
|
|
2
|
+
const require_utils_checkAccess = require("./checkAccess.cjs");
|
|
3
3
|
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/utils/chunkInference.ts
|
|
6
6
|
/**
|
|
7
7
|
* Translates a single chunk via the OpenAI API.
|
|
8
8
|
* Includes retry logic if the call fails.
|
|
@@ -41,6 +41,5 @@ const processContent = (content) => {
|
|
|
41
41
|
return content.replaceAll("///chunksStart///", "").replaceAll("///chunkStart///", "").replaceAll("///chunksEnd///", "").replaceAll("///chunkEnd///", "").replaceAll("///chunksStart///", "").replaceAll("chunkStart///", "").replaceAll("chunksEnd///", "").replaceAll("chunkEnd///", "").replaceAll("///chunksStart", "").replaceAll("///chunkStart", "").replaceAll("///chunksEnd", "").replaceAll("///chunkEnd", "").replaceAll("chunksStart", "").replaceAll("chunkStart", "").replaceAll("chunksEnd", "").replaceAll("chunkEnd", "");
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
//#endregion
|
|
45
44
|
exports.chunkInference = chunkInference;
|
|
46
45
|
//# sourceMappingURL=chunkInference.cjs.map
|
|
@@ -3,7 +3,7 @@ let node_path = require("node:path");
|
|
|
3
3
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
4
4
|
let node_child_process = require("node:child_process");
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/utils/detectGitRepository.ts
|
|
7
7
|
const HOST_PROVIDERS = {
|
|
8
8
|
"github.com": "github",
|
|
9
9
|
"gitlab.com": "gitlab",
|
|
@@ -81,7 +81,6 @@ const detectGitRepository = (projectRoot) => {
|
|
|
81
81
|
};
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
//#endregion
|
|
85
84
|
exports.detectGitRepository = detectGitRepository;
|
|
86
85
|
exports.parseGitRemoteUrl = parseGitRemoteUrl;
|
|
87
86
|
//# sourceMappingURL=detectGitRepository.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/utils/fixChunkStartEndChars.ts
|
|
3
3
|
const CHAR_TO_CHECK_FORMATTING = [
|
|
4
4
|
"```",
|
|
5
5
|
"\n\n",
|
|
@@ -23,6 +23,5 @@ const fixChunkStartEndChars = (reviewedChunkResult, baseChunkContext) => {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
//#endregion
|
|
27
26
|
exports.fixChunkStartEndChars = fixChunkStartEndChars;
|
|
28
27
|
//# sourceMappingURL=fixChunkStartEndChars.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/utils/formatLineRanges.ts
|
|
3
3
|
/**
|
|
4
4
|
* Formats a list of line numbers into a compact, human-readable string where
|
|
5
5
|
* runs of consecutive lines are collapsed into ranges.
|
|
@@ -38,6 +38,5 @@ const formatLineRanges = (lineNumbers, separator = ", ") => {
|
|
|
38
38
|
return groups.join(separator);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
//#endregion
|
|
42
41
|
exports.formatLineRanges = formatLineRanges;
|
|
43
42
|
//# sourceMappingURL=formatLineRanges.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/utils/formatTimeDiff.ts
|
|
3
3
|
const formatTimeDiff = (realtiveTime) => {
|
|
4
4
|
const diff = realtiveTime.getTime();
|
|
5
5
|
const MS_IN_SECOND = 1e3;
|
|
@@ -15,6 +15,5 @@ const formatTimeDiff = (realtiveTime) => {
|
|
|
15
15
|
return `${minutes}m ${seconds}s`;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
//#endregion
|
|
19
18
|
exports.formatTimeDiff = formatTimeDiff;
|
|
20
19
|
//# sourceMappingURL=formatTimeDiff.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/utils/getIsFileUpdatedRecently.ts
|
|
5
5
|
const SKIP_RANGE_OF_LAST_UPDATE_TIME = 0;
|
|
6
6
|
/**
|
|
7
7
|
* Check if file was updated recently, to skip re-translation
|
|
@@ -11,6 +11,5 @@ const getIsFileUpdatedRecently = (localeFilePath) => {
|
|
|
11
11
|
return new Date(stats.mtime) > /* @__PURE__ */ new Date(Date.now() - SKIP_RANGE_OF_LAST_UPDATE_TIME);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
//#endregion
|
|
15
14
|
exports.getIsFileUpdatedRecently = getIsFileUpdatedRecently;
|
|
16
15
|
//# sourceMappingURL=getIsFileUpdatedRecently.cjs.map
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
let _intlayer_engine_utils = require("@intlayer/engine/utils");
|
|
3
3
|
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/utils/getOutputFilePath.ts
|
|
6
6
|
/**
|
|
7
7
|
* Get the output file path by replacing the base locale with the target locale
|
|
8
8
|
*
|
|
@@ -102,7 +102,6 @@ const resolveOutputPattern = async (output, locale, context, sourceFilePath, bas
|
|
|
102
102
|
return (0, _intlayer_engine_utils.resolveRelativePath)(rawPath, sourceFilePath, baseDir);
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
//#endregion
|
|
106
105
|
exports.getOutputFilePath = getOutputFilePath;
|
|
107
106
|
exports.getPatternForLocale = getPatternForLocale;
|
|
108
107
|
exports.resolveOutputPattern = resolveOutputPattern;
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/utils/getParentPackageJSON.ts
|
|
6
6
|
const getParentPackageJSON = (startDir) => {
|
|
7
7
|
let currentDir = startDir;
|
|
8
8
|
while (currentDir !== (0, node_path.dirname)(currentDir)) {
|
|
@@ -15,6 +15,5 @@ const getParentPackageJSON = (startDir) => {
|
|
|
15
15
|
throw new Error(`No package.json found in any parent directory of ${startDir}`);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
//#endregion
|
|
19
18
|
exports.getParentPackageJSON = getParentPackageJSON;
|
|
20
19
|
//# sourceMappingURL=getParentPackageJSON.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/utils/isInteractiveTerminal.ts
|
|
3
3
|
/**
|
|
4
4
|
* Whether the process can prompt: both stdin and stdout are attached to a
|
|
5
5
|
* terminal. False for AI agents, CI and piped runs, where a prompt would print
|
|
@@ -7,6 +7,5 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
7
7
|
*/
|
|
8
8
|
const isInteractiveTerminal = () => Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
9
9
|
|
|
10
|
-
//#endregion
|
|
11
10
|
exports.isInteractiveTerminal = isInteractiveTerminal;
|
|
12
11
|
//# sourceMappingURL=isInteractiveTerminal.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/utils/listSpecialChars.ts
|
|
3
3
|
const SPECIAL_CHARS = [
|
|
4
4
|
" ",
|
|
5
5
|
"\\",
|
|
@@ -49,6 +49,5 @@ const listSpecialChars = (text) => {
|
|
|
49
49
|
return results;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
//#endregion
|
|
53
52
|
exports.listSpecialChars = listSpecialChars;
|
|
54
53
|
//# sourceMappingURL=listSpecialChars.cjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_utils_calculateChunks = require(
|
|
2
|
+
const require_utils_calculateChunks = require("./calculateChunks.cjs");
|
|
3
3
|
let _intlayer_engine_utils = require("@intlayer/engine/utils");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/utils/mapChunksBetweenFiles.ts
|
|
6
6
|
/**
|
|
7
7
|
* Maps chunks from base file to corresponding chunks in updated file,
|
|
8
8
|
* handling insertions, deletions, and modifications properly.
|
|
@@ -97,6 +97,5 @@ const determineIfChunkHasChanges = (baseChunk, updatedChunk, changedLines) => {
|
|
|
97
97
|
return baseChunk.content !== updatedChunk.content;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
//#endregion
|
|
101
100
|
exports.mapChunksBetweenFiles = mapChunksBetweenFiles;
|
|
102
101
|
//# sourceMappingURL=mapChunksBetweenFiles.cjs.map
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
let node_child_process = require("node:child_process");
|
|
3
3
|
let node_os = require("node:os");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/utils/openBrowser.ts
|
|
6
6
|
const openBrowser = (url) => {
|
|
7
7
|
const osPlatform = (0, node_os.platform)();
|
|
8
8
|
let command = "";
|
|
@@ -14,6 +14,5 @@ const openBrowser = (url) => {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
//#endregion
|
|
18
17
|
exports.openBrowser = openBrowser;
|
|
19
18
|
//# sourceMappingURL=openBrowser.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/utils/parseChoice.ts
|
|
3
3
|
/**
|
|
4
4
|
* Resolves a command-line value against its allowed choices, ignoring case.
|
|
5
5
|
*
|
|
@@ -16,6 +16,5 @@ const parseChoice = (value, choices, optionName) => {
|
|
|
16
16
|
return choice;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
//#endregion
|
|
20
19
|
exports.parseChoice = parseChoice;
|
|
21
20
|
//# sourceMappingURL=parseChoice.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_utils_listSpecialChars = require(
|
|
2
|
+
const require_utils_listSpecialChars = require("./listSpecialChars.cjs");
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/utils/reorderParagraphs.ts
|
|
5
5
|
/**
|
|
6
6
|
* Split a text into paragraphs.
|
|
7
7
|
*
|
|
@@ -89,6 +89,5 @@ const reorderParagraphs = (textToReorder, baseFileContent) => {
|
|
|
89
89
|
return [...leadingExtras, ...result].join("\n\n");
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
//#endregion
|
|
93
92
|
exports.reorderParagraphs = reorderParagraphs;
|
|
94
93
|
//# sourceMappingURL=reorderParagraphs.cjs.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
4
4
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
5
5
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/utils/selectCmsEnvironment.ts
|
|
8
8
|
/**
|
|
9
9
|
* Selects the CMS project environment that matches `environmentName`.
|
|
10
10
|
*
|
|
@@ -42,6 +42,5 @@ const selectCmsEnvironment = async (environmentName, intlayerAPI, config) => {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
//#endregion
|
|
46
45
|
exports.selectCmsEnvironment = selectCmsEnvironment;
|
|
47
46
|
//# sourceMappingURL=selectCmsEnvironment.cjs.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require(
|
|
3
|
-
const require_utils_checkAccess = require(
|
|
2
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_utils_checkAccess = require("./checkAccess.cjs");
|
|
4
4
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
5
5
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
6
6
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/utils/setupAI.ts
|
|
9
9
|
globalThis.AI_SDK_LOG_WARNINGS = false;
|
|
10
10
|
const logAIConfig = (aiOptions, appLogger) => {
|
|
11
11
|
appLogger([
|
|
@@ -63,6 +63,5 @@ const setupAI = async (configuration, aiOptions) => {
|
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
//#endregion
|
|
67
66
|
exports.setupAI = setupAI;
|
|
68
67
|
//# sourceMappingURL=setupAI.cjs.map
|