@intlayer/cli 6.1.6-canary.0 → 7.0.0-canary.0
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 +187 -239
- package/dist/cjs/IntlayerEventListener.cjs.map +1 -1
- package/dist/cjs/_virtual/_utils_asset.cjs +104 -0
- package/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/cjs/build.cjs +23 -42
- package/dist/cjs/build.cjs.map +1 -1
- package/dist/cjs/cli.cjs +370 -431
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +10 -35
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/editor.cjs +51 -66
- package/dist/cjs/editor.cjs.map +1 -1
- package/dist/cjs/fill/fill.cjs +73 -301
- package/dist/cjs/fill/fill.cjs.map +1 -1
- package/dist/cjs/fill/formatAutoFillData.cjs +48 -106
- package/dist/cjs/fill/formatAutoFillData.cjs.map +1 -1
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +27 -43
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -1
- package/dist/cjs/fill/formatFillData.cjs +50 -0
- package/dist/cjs/fill/formatFillData.cjs.map +1 -0
- package/dist/cjs/fill/groupLimiter.cjs +42 -0
- package/dist/cjs/fill/groupLimiter.cjs.map +1 -0
- package/dist/cjs/fill/index.cjs +5 -25
- package/dist/cjs/fill/listTranslationsTasks.cjs +77 -0
- package/dist/cjs/fill/listTranslationsTasks.cjs.map +1 -0
- package/dist/cjs/fill/test-original-case.cjs +10 -0
- package/dist/cjs/fill/test-original-case.cjs.map +1 -0
- package/dist/cjs/fill/translateDictionary.cjs +148 -0
- package/dist/cjs/fill/translateDictionary.cjs.map +1 -0
- package/dist/cjs/fill/writeAutoFill.cjs +48 -0
- package/dist/cjs/fill/writeAutoFill.cjs.map +1 -0
- package/dist/cjs/fill/writeFill.cjs +50 -0
- package/dist/cjs/fill/writeFill.cjs.map +1 -0
- package/dist/cjs/getTargetDictionary.cjs +36 -76
- package/dist/cjs/getTargetDictionary.cjs.map +1 -1
- package/dist/cjs/index.cjs +31 -45
- package/dist/cjs/listContentDeclaration.cjs +36 -64
- package/dist/cjs/listContentDeclaration.cjs.map +1 -1
- package/dist/cjs/liveSync.cjs +146 -221
- package/dist/cjs/liveSync.cjs.map +1 -1
- package/dist/cjs/pull.cjs +132 -195
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push/pullLog.cjs +101 -144
- package/dist/cjs/push/pullLog.cjs.map +1 -1
- package/dist/cjs/push/push.cjs +159 -249
- package/dist/cjs/push/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +18 -45
- package/dist/cjs/pushConfig.cjs.map +1 -1
- package/dist/cjs/pushLog.cjs +87 -128
- package/dist/cjs/pushLog.cjs.map +1 -1
- package/dist/cjs/reviewDoc.cjs +183 -291
- package/dist/cjs/reviewDoc.cjs.map +1 -1
- package/dist/cjs/test/index.cjs +52 -91
- package/dist/cjs/test/index.cjs.map +1 -1
- package/dist/cjs/test/listMissingTranslations.cjs +35 -62
- package/dist/cjs/test/listMissingTranslations.cjs.map +1 -1
- package/dist/cjs/translateDoc.cjs +127 -221
- package/dist/cjs/translateDoc.cjs.map +1 -1
- package/dist/cjs/utils/calculateChunks.cjs +85 -115
- package/dist/cjs/utils/calculateChunks.cjs.map +1 -1
- package/dist/cjs/utils/checkAccess.cjs +33 -72
- package/dist/cjs/utils/checkAccess.cjs.map +1 -1
- package/dist/cjs/utils/checkFileModifiedRange.cjs +75 -91
- package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -1
- package/dist/cjs/utils/checkLastUpdateTime.cjs +17 -30
- package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -1
- package/dist/cjs/utils/chunkInference.cjs +28 -47
- package/dist/cjs/utils/chunkInference.cjs.map +1 -1
- package/dist/cjs/utils/fixChunkStartEndChars.cjs +23 -42
- package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -1
- package/dist/cjs/utils/formatTimeDiff.cjs +17 -43
- package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -1
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +13 -32
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -1
- package/dist/cjs/utils/getOutputFilePath.cjs +71 -86
- package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -1
- package/dist/cjs/utils/getParentPackageJSON.cjs +19 -44
- package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -1
- package/dist/cjs/utils/listSpecialChars.cjs +49 -73
- package/dist/cjs/utils/listSpecialChars.cjs.map +1 -1
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs +90 -132
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -1
- package/dist/cjs/utils/reorderParagraphs.cjs +86 -118
- package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -1
- package/dist/cjs/watch.cjs +21 -39
- package/dist/cjs/watch.cjs.map +1 -1
- package/dist/esm/IntlayerEventListener.mjs +178 -201
- package/dist/esm/IntlayerEventListener.mjs.map +1 -1
- package/dist/esm/_virtual/_utils_asset.mjs +100 -0
- package/dist/esm/_virtual/rolldown_runtime.mjs +8 -0
- package/dist/esm/build.mjs +20 -23
- package/dist/esm/build.mjs.map +1 -1
- package/dist/esm/cli.mjs +349 -380
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +8 -14
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/editor.mjs +47 -41
- package/dist/esm/editor.mjs.map +1 -1
- package/dist/esm/fill/fill.mjs +68 -300
- package/dist/esm/fill/fill.mjs.map +1 -1
- package/dist/esm/fill/formatAutoFillData.mjs +47 -81
- package/dist/esm/fill/formatAutoFillData.mjs.map +1 -1
- package/dist/esm/fill/formatAutoFilledFilePath.mjs +25 -19
- package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -1
- package/dist/esm/fill/formatFillData.mjs +50 -0
- package/dist/esm/fill/formatFillData.mjs.map +1 -0
- package/dist/esm/fill/groupLimiter.mjs +40 -0
- package/dist/esm/fill/groupLimiter.mjs.map +1 -0
- package/dist/esm/fill/index.mjs +4 -3
- package/dist/esm/fill/listTranslationsTasks.mjs +70 -0
- package/dist/esm/fill/listTranslationsTasks.mjs.map +1 -0
- package/dist/esm/fill/test-original-case.mjs +10 -0
- package/dist/esm/fill/test-original-case.mjs.map +1 -0
- package/dist/esm/fill/translateDictionary.mjs +141 -0
- package/dist/esm/fill/translateDictionary.mjs.map +1 -0
- package/dist/esm/fill/writeAutoFill.mjs +44 -0
- package/dist/esm/fill/writeAutoFill.mjs.map +1 -0
- package/dist/esm/fill/writeFill.mjs +45 -0
- package/dist/esm/fill/writeFill.mjs.map +1 -0
- package/dist/esm/getTargetDictionary.mjs +27 -48
- package/dist/esm/getTargetDictionary.mjs.map +1 -1
- package/dist/esm/index.mjs +15 -13
- package/dist/esm/listContentDeclaration.mjs +28 -43
- package/dist/esm/listContentDeclaration.mjs.map +1 -1
- package/dist/esm/liveSync.mjs +135 -187
- package/dist/esm/liveSync.mjs.map +1 -1
- package/dist/esm/pull.mjs +125 -178
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/push/pullLog.mjs +99 -125
- package/dist/esm/push/pullLog.mjs.map +1 -1
- package/dist/esm/push/push.mjs +149 -221
- package/dist/esm/push/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +14 -23
- package/dist/esm/pushConfig.mjs.map +1 -1
- package/dist/esm/pushLog.mjs +85 -109
- package/dist/esm/pushLog.mjs.map +1 -1
- package/dist/esm/reviewDoc.mjs +167 -264
- package/dist/esm/reviewDoc.mjs.map +1 -1
- package/dist/esm/test/index.mjs +47 -73
- package/dist/esm/test/index.mjs.map +1 -1
- package/dist/esm/test/listMissingTranslations.mjs +30 -41
- package/dist/esm/test/listMissingTranslations.mjs.map +1 -1
- package/dist/esm/translateDoc.mjs +114 -193
- package/dist/esm/translateDoc.mjs.map +1 -1
- package/dist/esm/utils/calculateChunks.mjs +83 -91
- package/dist/esm/utils/calculateChunks.mjs.map +1 -1
- package/dist/esm/utils/checkAccess.mjs +28 -46
- package/dist/esm/utils/checkAccess.mjs.map +1 -1
- package/dist/esm/utils/checkFileModifiedRange.mjs +73 -65
- package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -1
- package/dist/esm/utils/checkLastUpdateTime.mjs +15 -6
- package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -1
- package/dist/esm/utils/chunkInference.mjs +24 -24
- package/dist/esm/utils/chunkInference.mjs.map +1 -1
- package/dist/esm/utils/fixChunkStartEndChars.mjs +22 -18
- package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -1
- package/dist/esm/utils/formatTimeDiff.mjs +16 -19
- package/dist/esm/utils/formatTimeDiff.mjs.map +1 -1
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs +11 -8
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -1
- package/dist/esm/utils/getOutputFilePath.mjs +70 -62
- package/dist/esm/utils/getOutputFilePath.mjs.map +1 -1
- package/dist/esm/utils/getParentPackageJSON.mjs +16 -20
- package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -1
- package/dist/esm/utils/listSpecialChars.mjs +48 -49
- package/dist/esm/utils/listSpecialChars.mjs.map +1 -1
- package/dist/esm/utils/mapChunksBetweenFiles.mjs +87 -107
- package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -1
- package/dist/esm/utils/reorderParagraphs.mjs +85 -93
- package/dist/esm/utils/reorderParagraphs.mjs.map +1 -1
- package/dist/esm/watch.mjs +17 -17
- package/dist/esm/watch.mjs.map +1 -1
- package/dist/types/IntlayerEventListener.d.ts +63 -59
- package/dist/types/IntlayerEventListener.d.ts.map +1 -1
- package/dist/types/build.d.ts +10 -7
- package/dist/types/build.d.ts.map +1 -1
- package/dist/types/cli.d.ts +13 -10
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts +7 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/editor.d.ts +6 -4
- package/dist/types/editor.d.ts.map +1 -1
- package/dist/types/fill/fill.d.ts +20 -14
- package/dist/types/fill/fill.d.ts.map +1 -1
- package/dist/types/fill/formatAutoFillData.d.ts +10 -7
- package/dist/types/fill/formatAutoFillData.d.ts.map +1 -1
- package/dist/types/fill/formatAutoFilledFilePath.d.ts +6 -2
- package/dist/types/fill/formatAutoFilledFilePath.d.ts.map +1 -1
- package/dist/types/fill/formatFillData.d.ts +12 -0
- package/dist/types/fill/formatFillData.d.ts.map +1 -0
- package/dist/types/fill/groupLimiter.d.ts +15 -0
- package/dist/types/fill/groupLimiter.d.ts.map +1 -0
- package/dist/types/fill/index.d.ts +3 -3
- package/dist/types/fill/listTranslationsTasks.d.ts +15 -0
- package/dist/types/fill/listTranslationsTasks.d.ts.map +1 -0
- package/dist/types/fill/test-original-case.d.ts +1 -0
- package/dist/types/fill/translateDictionary.d.ts +19 -0
- package/dist/types/fill/translateDictionary.d.ts.map +1 -0
- package/dist/types/fill/writeAutoFill.d.ts +7 -0
- package/dist/types/fill/writeAutoFill.d.ts.map +1 -0
- package/dist/types/fill/writeFill.d.ts +7 -0
- package/dist/types/fill/writeFill.d.ts.map +1 -0
- package/dist/types/getTargetDictionary.d.ts +17 -13
- package/dist/types/getTargetDictionary.d.ts.map +1 -1
- package/dist/types/index.d.ts +15 -14
- package/dist/types/listContentDeclaration.d.ts +10 -7
- package/dist/types/listContentDeclaration.d.ts.map +1 -1
- package/dist/types/liveSync.d.ts +8 -3
- package/dist/types/liveSync.d.ts.map +1 -1
- package/dist/types/pull.d.ts +9 -6
- package/dist/types/pull.d.ts.map +1 -1
- package/dist/types/push/pullLog.d.ts +25 -21
- package/dist/types/push/pullLog.d.ts.map +1 -1
- package/dist/types/push/push.d.ts +13 -9
- package/dist/types/push/push.d.ts.map +1 -1
- package/dist/types/pushConfig.d.ts +7 -4
- package/dist/types/pushConfig.d.ts.map +1 -1
- package/dist/types/pushLog.d.ts +23 -20
- package/dist/types/pushLog.d.ts.map +1 -1
- package/dist/types/reviewDoc.d.ts +34 -17
- package/dist/types/reviewDoc.d.ts.map +1 -1
- package/dist/types/test/index.d.ts +9 -5
- package/dist/types/test/index.d.ts.map +1 -1
- package/dist/types/test/listMissingTranslations.d.ts +14 -10
- package/dist/types/test/listMissingTranslations.d.ts.map +1 -1
- package/dist/types/translateDoc.d.ts +34 -17
- package/dist/types/translateDoc.d.ts.map +1 -1
- package/dist/types/utils/calculateChunks.d.ts +10 -7
- package/dist/types/utils/calculateChunks.d.ts.map +1 -1
- package/dist/types/utils/checkAccess.d.ts +8 -4
- package/dist/types/utils/checkAccess.d.ts.map +1 -1
- package/dist/types/utils/checkFileModifiedRange.d.ts +8 -6
- package/dist/types/utils/checkFileModifiedRange.d.ts.map +1 -1
- package/dist/types/utils/checkLastUpdateTime.d.ts +4 -1
- package/dist/types/utils/checkLastUpdateTime.d.ts.map +1 -1
- package/dist/types/utils/chunkInference.d.ts +9 -6
- package/dist/types/utils/chunkInference.d.ts.map +1 -1
- package/dist/types/utils/fixChunkStartEndChars.d.ts +4 -1
- package/dist/types/utils/fixChunkStartEndChars.d.ts.map +1 -1
- package/dist/types/utils/formatTimeDiff.d.ts +4 -1
- package/dist/types/utils/formatTimeDiff.d.ts.map +1 -1
- package/dist/types/utils/getIsFileUpdatedRecently.d.ts +4 -1
- package/dist/types/utils/getIsFileUpdatedRecently.d.ts.map +1 -1
- package/dist/types/utils/getOutputFilePath.d.ts +7 -2
- package/dist/types/utils/getOutputFilePath.d.ts.map +1 -1
- package/dist/types/utils/getParentPackageJSON.d.ts +30 -28
- package/dist/types/utils/getParentPackageJSON.d.ts.map +1 -1
- package/dist/types/utils/listSpecialChars.d.ts +9 -7
- package/dist/types/utils/listSpecialChars.d.ts.map +1 -1
- package/dist/types/utils/mapChunksBetweenFiles.d.ts +10 -6
- package/dist/types/utils/mapChunksBetweenFiles.d.ts.map +1 -1
- package/dist/types/utils/reorderParagraphs.d.ts +4 -1
- package/dist/types/utils/reorderParagraphs.d.ts.map +1 -1
- package/dist/types/watch.d.ts +9 -6
- package/dist/types/watch.d.ts.map +1 -1
- package/package.json +42 -47
- package/LICENSE +0 -202
- package/dist/cjs/fill/autoFill.cjs +0 -105
- package/dist/cjs/fill/autoFill.cjs.map +0 -1
- package/dist/cjs/fill/index.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/utils/getChunk.cjs +0 -77
- package/dist/cjs/utils/getChunk.cjs.map +0 -1
- package/dist/cjs/utils/splitTextByLine.cjs +0 -35
- package/dist/cjs/utils/splitTextByLine.cjs.map +0 -1
- package/dist/esm/fill/autoFill.mjs +0 -92
- package/dist/esm/fill/autoFill.mjs.map +0 -1
- package/dist/esm/fill/index.mjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/prompts/REVIEW_PROMPT.md +0 -37
- package/dist/esm/prompts/TRANSLATE_PROMPT.md +0 -38
- package/dist/esm/utils/calculrateChunkTest.md +0 -9
- package/dist/esm/utils/getChunk.mjs +0 -53
- package/dist/esm/utils/getChunk.mjs.map +0 -1
- package/dist/esm/utils/splitTextByLine.mjs +0 -11
- package/dist/esm/utils/splitTextByLine.mjs.map +0 -1
- package/dist/types/fill/autoFill.d.ts +0 -4
- package/dist/types/fill/autoFill.d.ts.map +0 -1
- package/dist/types/fill/index.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/utils/getChunk.d.ts +0 -9
- package/dist/types/utils/getChunk.d.ts.map +0 -1
- package/dist/types/utils/splitTextByLine.d.ts +0 -2
- package/dist/types/utils/splitTextByLine.d.ts.map +0 -1
- /package/dist/{cjs → assets}/prompts/REVIEW_PROMPT.md +0 -0
- /package/dist/{cjs → assets}/prompts/TRANSLATE_PROMPT.md +0 -0
- /package/dist/{cjs/utils/calculrateChunkTest.md → assets/utils/_calculateChunkTest.md} +0 -0
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import configuration from "@intlayer/config/built";
|
|
2
|
-
import { Command } from "commander";
|
|
3
|
-
import { dirname as pathDirname } from "path";
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
1
|
import { build } from "./build.mjs";
|
|
6
2
|
import { getConfig } from "./config.mjs";
|
|
7
3
|
import { startEditor } from "./editor.mjs";
|
|
@@ -16,405 +12,378 @@ import { testMissingTranslations } from "./test/index.mjs";
|
|
|
16
12
|
import { translateDoc } from "./translateDoc.mjs";
|
|
17
13
|
import { getParentPackageJSON } from "./utils/getParentPackageJSON.mjs";
|
|
18
14
|
import { watchContentDeclaration } from "./watch.mjs";
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
import { getConfiguration } from "@intlayer/config";
|
|
16
|
+
import { dirname as dirname$1 } from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
import { Command } from "commander";
|
|
19
|
+
|
|
20
|
+
//#region src/cli.ts
|
|
21
|
+
const isESModule$1 = typeof import.meta.url === "string";
|
|
22
|
+
const dirname = isESModule$1 ? dirname$1(fileURLToPath(import.meta.url)) : __dirname;
|
|
21
23
|
const packageJson = getParentPackageJSON(dirname);
|
|
22
|
-
const logOptions = [
|
|
23
|
-
["--verbose", "Verbose (default to true using CLI)"],
|
|
24
|
-
["--prefix [prefix]", "Prefix"]
|
|
25
|
-
];
|
|
26
24
|
const configurationOptions = [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
["--env-file [envFile]", "Environment file"],
|
|
26
|
+
["-e, --env [env]", "Environment"],
|
|
27
|
+
["--base-dir [baseDir]", "Base directory"],
|
|
28
|
+
...[["--verbose", "Verbose (default to true using CLI)"], ["--prefix [prefix]", "Prefix"]]
|
|
31
29
|
];
|
|
32
30
|
const aiOptions = [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
["--provider [provider]", "Provider"],
|
|
32
|
+
["--temperature [temperature]", "Temperature"],
|
|
33
|
+
["--model [model]", "Model"],
|
|
34
|
+
["--api-key [apiKey]", "Provider API key"],
|
|
35
|
+
["--custom-prompt [prompt]", "Custom prompt"],
|
|
36
|
+
["--application-context [applicationContext]", "Application context"]
|
|
39
37
|
];
|
|
40
38
|
const gitOptions = [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
["--git-diff [gitDiff]", "Git diff mode - Check git diff between two refs"],
|
|
40
|
+
["--git-diff-base [gitDiffBase]", "Git diff base ref"],
|
|
41
|
+
["--git-diff-current [gitDiffCurrent]", "Git diff current ref"],
|
|
42
|
+
["--uncommitted [uncommitted]", "Uncommitted"],
|
|
43
|
+
["--unpushed [unpushed]", "Unpushed"],
|
|
44
|
+
["--untracked [untracked]", "Untracked"]
|
|
47
45
|
];
|
|
48
46
|
const extractKeysFromOptions = (options, keys) => keys.filter((key) => options[key]);
|
|
47
|
+
/**
|
|
48
|
+
* Helper functions to apply common options to commands
|
|
49
|
+
*/
|
|
49
50
|
const applyOptions = (command, options) => {
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
options.forEach(([flag, description]) => {
|
|
52
|
+
command.option(flag, description);
|
|
53
|
+
});
|
|
54
|
+
return command;
|
|
52
55
|
};
|
|
53
|
-
const removeUndefined = (obj) => Object.fromEntries(
|
|
54
|
-
Object.entries(obj).filter(([_, value]) => value !== void 0)
|
|
55
|
-
);
|
|
56
|
+
const removeUndefined = (obj) => Object.fromEntries(Object.entries(obj).filter(([_, value]) => value !== void 0));
|
|
56
57
|
const applyConfigOptions = (command) => applyOptions(command, configurationOptions);
|
|
57
58
|
const applyAIOptions = (command) => applyOptions(command, aiOptions);
|
|
58
59
|
const applyGitOptions = (command) => applyOptions(command, gitOptions);
|
|
59
60
|
const extractAiOptions = (options) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
provider: provider ?? configuration.ai?.provider,
|
|
71
|
-
model: model ?? configuration.ai?.model,
|
|
72
|
-
temperature: temperature ?? configuration.ai?.temperature,
|
|
73
|
-
applicationContext: applicationContext ?? configuration.ai?.applicationContext,
|
|
74
|
-
customPrompt: customPrompt ?? configuration.ai?.customPrompt
|
|
75
|
-
});
|
|
61
|
+
const { apiKey, provider, model, temperature, applicationContext, customPrompt } = options;
|
|
62
|
+
const configuration = getConfiguration();
|
|
63
|
+
return removeUndefined({
|
|
64
|
+
apiKey: apiKey ?? configuration.ai?.apiKey,
|
|
65
|
+
provider: provider ?? configuration.ai?.provider,
|
|
66
|
+
model: model ?? configuration.ai?.model,
|
|
67
|
+
temperature: temperature ?? configuration.ai?.temperature,
|
|
68
|
+
applicationContext: applicationContext ?? configuration.ai?.applicationContext,
|
|
69
|
+
customPrompt: customPrompt ?? configuration.ai?.customPrompt
|
|
70
|
+
});
|
|
76
71
|
};
|
|
77
72
|
const gitOptionKeys = [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
73
|
+
"gitDiff",
|
|
74
|
+
"gitDiffBase",
|
|
75
|
+
"gitDiffCurrent",
|
|
76
|
+
"uncommitted",
|
|
77
|
+
"unpushed",
|
|
78
|
+
"untracked"
|
|
84
79
|
];
|
|
85
80
|
const extractGitOptions = (options) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
unpushed && "unpushed",
|
|
101
|
-
untracked && "untracked"
|
|
102
|
-
].filter(Boolean);
|
|
103
|
-
return removeUndefined({
|
|
104
|
-
mode,
|
|
105
|
-
baseRef: gitDiffBase,
|
|
106
|
-
currentRef: gitDiffCurrent,
|
|
107
|
-
absolute: true
|
|
108
|
-
});
|
|
81
|
+
const filteredOptions = extractKeysFromOptions(options, gitOptionKeys);
|
|
82
|
+
if (!Object.values(filteredOptions).some(Boolean)) return void 0;
|
|
83
|
+
const { gitDiff, gitDiffBase, gitDiffCurrent, uncommitted, unpushed, untracked } = options;
|
|
84
|
+
return removeUndefined({
|
|
85
|
+
mode: [
|
|
86
|
+
gitDiff && "gitDiff",
|
|
87
|
+
uncommitted && "uncommitted",
|
|
88
|
+
unpushed && "unpushed",
|
|
89
|
+
untracked && "untracked"
|
|
90
|
+
].filter(Boolean),
|
|
91
|
+
baseRef: gitDiffBase,
|
|
92
|
+
currentRef: gitDiffCurrent,
|
|
93
|
+
absolute: true
|
|
94
|
+
});
|
|
109
95
|
};
|
|
110
96
|
const configurationOptionKeys = [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
97
|
+
"baseDir",
|
|
98
|
+
"env",
|
|
99
|
+
"envFile",
|
|
100
|
+
"verbose",
|
|
101
|
+
"prefix"
|
|
116
102
|
];
|
|
117
103
|
const extractConfigOptions = (options) => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const override = {
|
|
133
|
-
log
|
|
134
|
-
};
|
|
135
|
-
return removeUndefined({
|
|
136
|
-
baseDir,
|
|
137
|
-
env,
|
|
138
|
-
envFile,
|
|
139
|
-
override
|
|
140
|
-
});
|
|
104
|
+
const configuration = getConfiguration(options);
|
|
105
|
+
const filteredOptions = extractKeysFromOptions(options, configurationOptionKeys);
|
|
106
|
+
if (!Object.values(filteredOptions).some(Boolean)) return;
|
|
107
|
+
const { baseDir, env, envFile, verbose, prefix } = options;
|
|
108
|
+
const addPrefix = Boolean(options.with);
|
|
109
|
+
return removeUndefined({
|
|
110
|
+
baseDir,
|
|
111
|
+
env,
|
|
112
|
+
envFile,
|
|
113
|
+
override: { log: {
|
|
114
|
+
prefix: prefix ?? addPrefix ? configuration.log.prefix : "",
|
|
115
|
+
verbose: verbose ?? true
|
|
116
|
+
} }
|
|
117
|
+
});
|
|
141
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* Set the API for the CLI
|
|
121
|
+
*
|
|
122
|
+
* Example of commands:
|
|
123
|
+
*
|
|
124
|
+
* npm run intlayer build --watch
|
|
125
|
+
* npm run intlayer push --dictionaries id1 id2 id3 --deleteLocaleDir
|
|
126
|
+
*/
|
|
142
127
|
const setAPI = () => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
"Live sync - Watch for changes made on the CMS and update the application content accordingly"
|
|
401
|
-
);
|
|
402
|
-
applyOptions(liveCmd, liveOptions);
|
|
403
|
-
liveCmd.action((options) => liveSync(options));
|
|
404
|
-
const editorProgram = program.command("editor").description("Visual editor operations");
|
|
405
|
-
const editorStartCmd = editorProgram.command("start").description("Start the Intlayer visual editor");
|
|
406
|
-
applyConfigOptions(editorStartCmd);
|
|
407
|
-
editorStartCmd.action((options) => {
|
|
408
|
-
startEditor({
|
|
409
|
-
env: options.env,
|
|
410
|
-
envFile: options.envFile
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
program.parse(process.argv);
|
|
414
|
-
return program;
|
|
415
|
-
};
|
|
416
|
-
export {
|
|
417
|
-
dirname,
|
|
418
|
-
setAPI
|
|
128
|
+
const program = new Command();
|
|
129
|
+
program.version(packageJson.version).description("Intlayer CLI");
|
|
130
|
+
program.command("version").description("Print the Intlayer CLI version").action(() => {
|
|
131
|
+
console.log(packageJson.version ?? "unknown");
|
|
132
|
+
});
|
|
133
|
+
/**
|
|
134
|
+
* DICTIONARIES
|
|
135
|
+
*/
|
|
136
|
+
const dictionariesProgram = program.command("dictionary").alias("dictionaries").alias("dic").description("Dictionaries operations");
|
|
137
|
+
const buildOptions = {
|
|
138
|
+
description: "Build the dictionaries",
|
|
139
|
+
options: [
|
|
140
|
+
["-w, --watch", "Watch for changes"],
|
|
141
|
+
["--skip-prepare", "Skip the prepare step"],
|
|
142
|
+
["--with [with...]", "Start command in parallel with the build"]
|
|
143
|
+
]
|
|
144
|
+
};
|
|
145
|
+
const dictionariesBuildCmd = dictionariesProgram.command("build").description(buildOptions.description);
|
|
146
|
+
applyOptions(dictionariesBuildCmd, buildOptions.options);
|
|
147
|
+
applyConfigOptions(dictionariesBuildCmd);
|
|
148
|
+
dictionariesBuildCmd.action((options) => {
|
|
149
|
+
build({
|
|
150
|
+
...options,
|
|
151
|
+
configOptions: extractConfigOptions(options)
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
const rootBuildCmd = program.command("build").description(buildOptions.description);
|
|
155
|
+
applyOptions(rootBuildCmd, buildOptions.options);
|
|
156
|
+
applyConfigOptions(rootBuildCmd);
|
|
157
|
+
rootBuildCmd.action((options) => {
|
|
158
|
+
build({
|
|
159
|
+
...options,
|
|
160
|
+
configOptions: extractConfigOptions(options)
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
const watchOptions = {
|
|
164
|
+
description: "Watch the dictionaries changes",
|
|
165
|
+
options: [["--with [with...]", "Start command in parallel with the build"]]
|
|
166
|
+
};
|
|
167
|
+
const dictionariesWatchCmd = dictionariesProgram.command("watch").description(buildOptions.description);
|
|
168
|
+
applyOptions(dictionariesWatchCmd, watchOptions.options);
|
|
169
|
+
applyConfigOptions(dictionariesWatchCmd);
|
|
170
|
+
dictionariesWatchCmd.action((options) => {
|
|
171
|
+
watchContentDeclaration({
|
|
172
|
+
...options,
|
|
173
|
+
configOptions: extractConfigOptions(options)
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
const rootWatchCmd = program.command("watch").description(buildOptions.description);
|
|
177
|
+
applyOptions(rootWatchCmd, watchOptions.options);
|
|
178
|
+
applyConfigOptions(rootWatchCmd);
|
|
179
|
+
rootWatchCmd.action((options) => {
|
|
180
|
+
watchContentDeclaration({
|
|
181
|
+
...options,
|
|
182
|
+
configOptions: extractConfigOptions(options)
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
const pullOptions = {
|
|
186
|
+
description: "Pull dictionaries from the server",
|
|
187
|
+
options: [
|
|
188
|
+
["-d, --dictionaries [ids...]", "List of dictionary IDs to pull"],
|
|
189
|
+
["--dictionary [ids...]", "List of dictionary IDs to pull (alias for --dictionaries)"],
|
|
190
|
+
["--new-dictionaries-path [path]", "Path to save the new dictionaries"],
|
|
191
|
+
["--newDictionariesPath [path]", "[alias] Path to save the new dictionaries"]
|
|
192
|
+
]
|
|
193
|
+
};
|
|
194
|
+
const dictionariesPullCmd = dictionariesProgram.command("pull").description(pullOptions.description);
|
|
195
|
+
applyOptions(dictionariesPullCmd, pullOptions.options);
|
|
196
|
+
applyConfigOptions(dictionariesPullCmd);
|
|
197
|
+
dictionariesPullCmd.action((options) => {
|
|
198
|
+
const dictionaries = [...options.dictionaries ?? [], ...options.dictionary ?? []];
|
|
199
|
+
pull({
|
|
200
|
+
...options,
|
|
201
|
+
dictionaries: dictionaries.length > 0 ? dictionaries : void 0,
|
|
202
|
+
configOptions: {
|
|
203
|
+
...options.configOptions,
|
|
204
|
+
baseDir: options.baseDir
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
const rootPullCmd = program.command("pull").description(pullOptions.description);
|
|
209
|
+
applyOptions(rootPullCmd, pullOptions.options);
|
|
210
|
+
applyConfigOptions(rootPullCmd);
|
|
211
|
+
rootPullCmd.action((options) => {
|
|
212
|
+
const dictionaries = [...options.dictionaries ?? [], ...options.dictionary ?? []];
|
|
213
|
+
pull({
|
|
214
|
+
...options,
|
|
215
|
+
dictionaries: dictionaries.length > 0 ? dictionaries : void 0,
|
|
216
|
+
configOptions: extractConfigOptions(options)
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
const pushOptions = {
|
|
220
|
+
description: "Push all dictionaries. Create or update the pushed dictionaries",
|
|
221
|
+
options: [
|
|
222
|
+
["-d, --dictionaries [ids...]", "List of dictionary IDs to push"],
|
|
223
|
+
["--dictionary [ids...]", "List of dictionary IDs to push (alias for --dictionaries)"],
|
|
224
|
+
["-r, --delete-locale-dictionary", "Delete the local dictionaries after pushing"],
|
|
225
|
+
["-k, --keep-locale-dictionary", "Keep the local dictionaries after pushing"],
|
|
226
|
+
["--deleteLocaleDictionary", "[alias] Delete the local dictionaries after pushing"],
|
|
227
|
+
["--keepLocaleDictionary", "[alias] Keep the local dictionaries after pushing"],
|
|
228
|
+
["--build [build]", "Build the dictionaries before pushing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build"]
|
|
229
|
+
]
|
|
230
|
+
};
|
|
231
|
+
const dictionariesPushCmd = dictionariesProgram.command("push").description(pushOptions.description);
|
|
232
|
+
applyOptions(dictionariesPushCmd, pushOptions.options);
|
|
233
|
+
applyConfigOptions(dictionariesPushCmd);
|
|
234
|
+
applyGitOptions(dictionariesPushCmd);
|
|
235
|
+
dictionariesPushCmd.action((options) => {
|
|
236
|
+
const dictionaries = [...options.dictionaries || [], ...options.dictionary || []];
|
|
237
|
+
return push({
|
|
238
|
+
...options,
|
|
239
|
+
dictionaries: dictionaries.length > 0 ? dictionaries : void 0,
|
|
240
|
+
gitOptions: extractGitOptions(options),
|
|
241
|
+
configOptions: extractConfigOptions(options)
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
const rootPushCmd = program.command("push").description(pushOptions.description);
|
|
245
|
+
applyOptions(rootPushCmd, pushOptions.options);
|
|
246
|
+
applyConfigOptions(rootPushCmd);
|
|
247
|
+
applyGitOptions(rootPushCmd);
|
|
248
|
+
rootPushCmd.action((options) => {
|
|
249
|
+
const dictionaries = [...options.dictionaries || [], ...options.dictionary || []];
|
|
250
|
+
return push({
|
|
251
|
+
...options,
|
|
252
|
+
dictionaries: dictionaries.length > 0 ? dictionaries : void 0,
|
|
253
|
+
gitOptions: extractGitOptions(options),
|
|
254
|
+
configOptions: extractConfigOptions(options)
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
/**
|
|
258
|
+
* CONFIGURATION
|
|
259
|
+
*/
|
|
260
|
+
const configurationProgram = program.command("configuration").alias("config").alias("conf").description("Configuration operations");
|
|
261
|
+
const configGetCmd = configurationProgram.command("get").description("Get the configuration");
|
|
262
|
+
applyConfigOptions(configGetCmd);
|
|
263
|
+
configGetCmd.action((options) => {
|
|
264
|
+
getConfig({
|
|
265
|
+
...options,
|
|
266
|
+
configOptions: extractConfigOptions(options)
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
const configPushCmd = configurationProgram.command("push").description("Push the configuration");
|
|
270
|
+
applyConfigOptions(configPushCmd);
|
|
271
|
+
configPushCmd.action((options) => {
|
|
272
|
+
pushConfig({
|
|
273
|
+
...options,
|
|
274
|
+
configOptions: extractConfigOptions(options)
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
/**
|
|
278
|
+
* CONTENT DECLARATION
|
|
279
|
+
*/
|
|
280
|
+
const contentProgram = program.command("content").description("Content declaration operations");
|
|
281
|
+
contentProgram.command("list").description("List the content declaration files").action(listContentDeclaration);
|
|
282
|
+
program.command("list").description("List the content declaration files").action(listContentDeclaration);
|
|
283
|
+
const testProgram = contentProgram.command("test").description("Test if there are missing translations").option("--build [build]", "Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build");
|
|
284
|
+
applyConfigOptions(testProgram);
|
|
285
|
+
testProgram.action((options) => {
|
|
286
|
+
testMissingTranslations({
|
|
287
|
+
...options,
|
|
288
|
+
configOptions: extractConfigOptions(options)
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
const rootTestCmd = program.command("test").description("Test if there are missing translations").option("--build [build]", "Build the dictionaries before testing to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build");
|
|
292
|
+
applyConfigOptions(rootTestCmd);
|
|
293
|
+
rootTestCmd.action((options) => {
|
|
294
|
+
testMissingTranslations({
|
|
295
|
+
...options,
|
|
296
|
+
configOptions: extractConfigOptions(options)
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
const fillProgram = program.command("fill").description("Fill the dictionaries").option("-f, --file [files...]", "List of Dictionary files to fill").option("--source-locale [sourceLocale]", "Source locale to translate from").option("--output-locales [outputLocales...]", "Target locales to translate to").option("--mode [mode]", "Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys", "complete").option("-k, --keys [keys...]", "Filter dictionaries based on keys").option("--key [keys...]", "Filter dictionaries based on keys (alias for --keys)").option("--excluded-keys [excludedKeys...]", "Filter out dictionaries based on keys").option("--excluded-key [excludedKeys...]", "Filter out dictionaries based on keys (alias for --excluded-keys)").option("--path-filter [pathFilters...]", "Filter dictionaries based on glob pattern").option("--build [build]", "Build the dictionaries before filling to ensure the content is up to date. True will force the build, false will skip the build, undefined will allow using the cache of the build").option("--skip-metadata", "Skip filling missing metadata (description, title, tags) for dictionaries");
|
|
300
|
+
applyConfigOptions(fillProgram);
|
|
301
|
+
applyAIOptions(fillProgram);
|
|
302
|
+
applyGitOptions(fillProgram);
|
|
303
|
+
fillProgram.action((options) => {
|
|
304
|
+
const keys = [...options.keys ?? [], ...options.key ?? []];
|
|
305
|
+
const excludedKeys = [...options.excludedKeys ?? [], ...options.excludedKey ?? []];
|
|
306
|
+
const dictionaries = [...options.dictionaries ?? [], ...options.dictionary ?? []];
|
|
307
|
+
return fill({
|
|
308
|
+
...options,
|
|
309
|
+
keys: keys.length > 0 ? keys : void 0,
|
|
310
|
+
excludedKeys: excludedKeys.length > 0 ? excludedKeys : void 0,
|
|
311
|
+
dictionaries: dictionaries.length > 0 ? dictionaries : void 0,
|
|
312
|
+
aiOptions: extractAiOptions(options),
|
|
313
|
+
gitOptions: extractGitOptions(options),
|
|
314
|
+
configOptions: extractConfigOptions(options)
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
/**
|
|
318
|
+
* DOCS
|
|
319
|
+
*/
|
|
320
|
+
const docParams = [
|
|
321
|
+
["--doc-pattern [docPattern...]", "Documentation pattern"],
|
|
322
|
+
["--excluded-glob-pattern [excludedGlobPattern...]", "Excluded glob pattern"],
|
|
323
|
+
["--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]", "Number of simultaneous file processed"],
|
|
324
|
+
["--locales [locales...]", "Locales"],
|
|
325
|
+
["--base-locale [baseLocale]", "Base locale"],
|
|
326
|
+
["--custom-instructions [customInstructions]", "Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc."],
|
|
327
|
+
["--skip-if-modified-before [skipIfModifiedBefore]", "Skip the file if it has been modified before the given time. Can be an absolute time as \"2025-12-05\" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file."],
|
|
328
|
+
["--skip-if-modified-after [skipIfModifiedAfter]", "Skip the file if it has been modified within the given time. Can be an absolute time as \"2025-12-05\" (string or Date) or a relative time in ms `1 * 60 * 60 * 1000` (1 hour). This option check update time of the file using the `fs.stat` method. So it could be impacted by Git or other tools that modify the file."]
|
|
329
|
+
];
|
|
330
|
+
const docProgram = program.command("doc").description("Documentation operations");
|
|
331
|
+
const translateProgram = docProgram.command("translate").description("Translate the documentation");
|
|
332
|
+
applyConfigOptions(translateProgram);
|
|
333
|
+
applyAIOptions(translateProgram);
|
|
334
|
+
applyGitOptions(translateProgram);
|
|
335
|
+
applyOptions(translateProgram, docParams);
|
|
336
|
+
translateProgram.action((options) => translateDoc({
|
|
337
|
+
docPattern: options.docPattern,
|
|
338
|
+
excludedGlobPattern: options.excludedGlobPattern,
|
|
339
|
+
locales: options.locales,
|
|
340
|
+
baseLocale: options.baseLocale,
|
|
341
|
+
aiOptions: extractAiOptions(options),
|
|
342
|
+
gitOptions: extractGitOptions(options),
|
|
343
|
+
nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,
|
|
344
|
+
configOptions: extractConfigOptions(options),
|
|
345
|
+
customInstructions: options.customInstructions,
|
|
346
|
+
skipIfModifiedBefore: options.skipIfModifiedBefore,
|
|
347
|
+
skipIfModifiedAfter: options.skipIfModifiedAfter
|
|
348
|
+
}));
|
|
349
|
+
const reviewProgram = docProgram.command("review").description("Review the documentation");
|
|
350
|
+
applyConfigOptions(reviewProgram);
|
|
351
|
+
applyAIOptions(reviewProgram);
|
|
352
|
+
applyGitOptions(reviewProgram);
|
|
353
|
+
applyOptions(reviewProgram, docParams);
|
|
354
|
+
reviewProgram.action((options) => reviewDoc({
|
|
355
|
+
docPattern: options.docPattern,
|
|
356
|
+
excludedGlobPattern: options.excludedGlobPattern,
|
|
357
|
+
locales: options.locales,
|
|
358
|
+
baseLocale: options.baseLocale,
|
|
359
|
+
aiOptions: extractAiOptions(options),
|
|
360
|
+
gitOptions: extractGitOptions(options),
|
|
361
|
+
nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,
|
|
362
|
+
configOptions: extractConfigOptions(options),
|
|
363
|
+
customInstructions: options.customInstructions,
|
|
364
|
+
skipIfModifiedBefore: options.skipIfModifiedBefore,
|
|
365
|
+
skipIfModifiedAfter: options.skipIfModifiedAfter
|
|
366
|
+
}));
|
|
367
|
+
/**
|
|
368
|
+
* LIVE SYNC
|
|
369
|
+
*/
|
|
370
|
+
const liveOptions = [["--with [with...]", "Start command in parallel with the live sync"]];
|
|
371
|
+
const liveCmd = program.command("live").description("Live sync - Watch for changes made on the CMS and update the application content accordingly");
|
|
372
|
+
applyOptions(liveCmd, liveOptions);
|
|
373
|
+
applyConfigOptions(liveCmd);
|
|
374
|
+
liveCmd.action((options) => liveSync(options));
|
|
375
|
+
const editorStartCmd = program.command("editor").description("Visual editor operations").command("start").description("Start the Intlayer visual editor");
|
|
376
|
+
applyConfigOptions(editorStartCmd);
|
|
377
|
+
editorStartCmd.action((options) => {
|
|
378
|
+
startEditor({
|
|
379
|
+
env: options.env,
|
|
380
|
+
envFile: options.envFile
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
program.parse(process.argv);
|
|
384
|
+
return program;
|
|
419
385
|
};
|
|
386
|
+
|
|
387
|
+
//#endregion
|
|
388
|
+
export { dirname, setAPI };
|
|
420
389
|
//# sourceMappingURL=cli.mjs.map
|