@intlayer/cli 5.5.10 → 5.5.11
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/cli.cjs +78 -6
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/cli.test.cjs +435 -0
- package/dist/cjs/cli.test.cjs.map +1 -0
- package/dist/cjs/fill.cjs +8 -12
- package/dist/cjs/fill.cjs.map +1 -1
- package/dist/cjs/index.cjs +5 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/prompts/REVIEW_PROMPT.md +37 -0
- package/dist/cjs/prompts/TRANSLATE_PROMPT.md +38 -0
- package/dist/cjs/pull.cjs +10 -2
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +5 -1
- package/dist/cjs/pushConfig.cjs.map +1 -1
- package/dist/cjs/reviewDoc.cjs +203 -0
- package/dist/cjs/reviewDoc.cjs.map +1 -0
- package/dist/cjs/translateDoc.cjs +201 -0
- package/dist/cjs/translateDoc.cjs.map +1 -0
- package/dist/cjs/utils/calculateChunks.cjs +120 -0
- package/dist/cjs/utils/calculateChunks.cjs.map +1 -0
- package/dist/cjs/utils/calculateChunks.test.cjs +104 -0
- package/dist/cjs/utils/calculateChunks.test.cjs.map +1 -0
- package/dist/cjs/utils/calculrateChunkTest.md +9 -0
- package/dist/cjs/utils/checkAIAccess.cjs +40 -0
- package/dist/cjs/utils/checkAIAccess.cjs.map +1 -0
- package/dist/cjs/utils/checkFileModifiedRange.cjs +97 -0
- package/dist/cjs/utils/checkFileModifiedRange.cjs.map +1 -0
- package/dist/cjs/utils/checkFileModifiedRange.test.cjs +175 -0
- package/dist/cjs/utils/checkFileModifiedRange.test.cjs.map +1 -0
- package/dist/cjs/utils/checkLastUpdateTime.cjs +33 -0
- package/dist/cjs/utils/checkLastUpdateTime.cjs.map +1 -0
- package/dist/cjs/utils/chunkInference.cjs +58 -0
- package/dist/cjs/utils/chunkInference.cjs.map +1 -0
- package/dist/cjs/utils/fixChunkStartEndChars.cjs +47 -0
- package/dist/cjs/utils/fixChunkStartEndChars.cjs.map +1 -0
- package/dist/cjs/utils/fixChunkStartEndChars.test.cjs +81 -0
- package/dist/cjs/utils/fixChunkStartEndChars.test.cjs.map +1 -0
- package/dist/cjs/utils/formatTimeDiff.cjs +46 -0
- package/dist/cjs/utils/formatTimeDiff.cjs.map +1 -0
- package/dist/cjs/utils/formatTimeDiff.test.cjs +32 -0
- package/dist/cjs/utils/formatTimeDiff.test.cjs.map +1 -0
- package/dist/cjs/utils/getChunk.cjs +77 -0
- package/dist/cjs/utils/getChunk.cjs.map +1 -0
- package/dist/cjs/utils/getChunk.test.cjs +46 -0
- package/dist/cjs/utils/getChunk.test.cjs.map +1 -0
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs +36 -0
- package/dist/cjs/utils/getIsFileUpdatedRecently.cjs.map +1 -0
- package/dist/cjs/utils/getOutputFilePath.cjs +89 -0
- package/dist/cjs/utils/getOutputFilePath.cjs.map +1 -0
- package/dist/cjs/utils/getOutputFilePath.test.cjs +73 -0
- package/dist/cjs/utils/getOutputFilePath.test.cjs.map +1 -0
- package/dist/cjs/utils/getParentPackageJSON.cjs +47 -0
- package/dist/cjs/utils/getParentPackageJSON.cjs.map +1 -0
- package/dist/cjs/utils/listSpecialChars.cjs +78 -0
- package/dist/cjs/utils/listSpecialChars.cjs.map +1 -0
- package/dist/cjs/utils/listSpecialChars.test.cjs +58 -0
- package/dist/cjs/utils/listSpecialChars.test.cjs.map +1 -0
- package/dist/cjs/utils/reorderParagraphs.cjs +125 -0
- package/dist/cjs/utils/reorderParagraphs.cjs.map +1 -0
- package/dist/cjs/utils/reorderParagraphs.test.cjs +71 -0
- package/dist/cjs/utils/reorderParagraphs.test.cjs.map +1 -0
- package/dist/cjs/utils/splitTextByLine.cjs +35 -0
- package/dist/cjs/utils/splitTextByLine.cjs.map +1 -0
- package/dist/cjs/utils/splitTextByLine.test.cjs +14 -0
- package/dist/cjs/utils/splitTextByLine.test.cjs.map +1 -0
- package/dist/esm/cli.mjs +79 -7
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/cli.test.mjs +412 -0
- package/dist/esm/cli.test.mjs.map +1 -0
- package/dist/esm/fill.mjs +8 -12
- package/dist/esm/fill.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/prompts/REVIEW_PROMPT.md +37 -0
- package/dist/esm/prompts/TRANSLATE_PROMPT.md +38 -0
- package/dist/esm/pull.mjs +10 -2
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +5 -1
- package/dist/esm/pushConfig.mjs.map +1 -1
- package/dist/esm/reviewDoc.mjs +172 -0
- package/dist/esm/reviewDoc.mjs.map +1 -0
- package/dist/esm/translateDoc.mjs +170 -0
- package/dist/esm/translateDoc.mjs.map +1 -0
- package/dist/esm/utils/calculateChunks.mjs +96 -0
- package/dist/esm/utils/calculateChunks.mjs.map +1 -0
- package/dist/esm/utils/calculateChunks.test.mjs +103 -0
- package/dist/esm/utils/calculateChunks.test.mjs.map +1 -0
- package/dist/esm/utils/calculrateChunkTest.md +9 -0
- package/dist/esm/utils/checkAIAccess.mjs +16 -0
- package/dist/esm/utils/checkAIAccess.mjs.map +1 -0
- package/dist/esm/utils/checkFileModifiedRange.mjs +73 -0
- package/dist/esm/utils/checkFileModifiedRange.mjs.map +1 -0
- package/dist/esm/utils/checkFileModifiedRange.test.mjs +181 -0
- package/dist/esm/utils/checkFileModifiedRange.test.mjs.map +1 -0
- package/dist/esm/utils/checkLastUpdateTime.mjs +9 -0
- package/dist/esm/utils/checkLastUpdateTime.mjs.map +1 -0
- package/dist/esm/utils/chunkInference.mjs +34 -0
- package/dist/esm/utils/chunkInference.mjs.map +1 -0
- package/dist/esm/utils/fixChunkStartEndChars.mjs +23 -0
- package/dist/esm/utils/fixChunkStartEndChars.mjs.map +1 -0
- package/dist/esm/utils/fixChunkStartEndChars.test.mjs +80 -0
- package/dist/esm/utils/fixChunkStartEndChars.test.mjs.map +1 -0
- package/dist/esm/utils/formatTimeDiff.mjs +22 -0
- package/dist/esm/utils/formatTimeDiff.mjs.map +1 -0
- package/dist/esm/utils/formatTimeDiff.test.mjs +31 -0
- package/dist/esm/utils/formatTimeDiff.test.mjs.map +1 -0
- package/dist/esm/utils/getChunk.mjs +53 -0
- package/dist/esm/utils/getChunk.mjs.map +1 -0
- package/dist/esm/utils/getChunk.test.mjs +45 -0
- package/dist/esm/utils/getChunk.test.mjs.map +1 -0
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs +12 -0
- package/dist/esm/utils/getIsFileUpdatedRecently.mjs.map +1 -0
- package/dist/esm/utils/getOutputFilePath.mjs +65 -0
- package/dist/esm/utils/getOutputFilePath.mjs.map +1 -0
- package/dist/esm/utils/getOutputFilePath.test.mjs +72 -0
- package/dist/esm/utils/getOutputFilePath.test.mjs.map +1 -0
- package/dist/esm/utils/getParentPackageJSON.mjs +23 -0
- package/dist/esm/utils/getParentPackageJSON.mjs.map +1 -0
- package/dist/esm/utils/listSpecialChars.mjs +54 -0
- package/dist/esm/utils/listSpecialChars.mjs.map +1 -0
- package/dist/esm/utils/listSpecialChars.test.mjs +57 -0
- package/dist/esm/utils/listSpecialChars.test.mjs.map +1 -0
- package/dist/esm/utils/reorderParagraphs.mjs +101 -0
- package/dist/esm/utils/reorderParagraphs.mjs.map +1 -0
- package/dist/esm/utils/reorderParagraphs.test.mjs +70 -0
- package/dist/esm/utils/reorderParagraphs.test.mjs.map +1 -0
- package/dist/esm/utils/splitTextByLine.mjs +11 -0
- package/dist/esm/utils/splitTextByLine.mjs.map +1 -0
- package/dist/esm/utils/splitTextByLine.test.mjs +13 -0
- package/dist/esm/utils/splitTextByLine.test.mjs.map +1 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/cli.test.d.ts +2 -0
- package/dist/types/cli.test.d.ts.map +1 -0
- package/dist/types/fill.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/pull.d.ts.map +1 -1
- package/dist/types/pushConfig.d.ts.map +1 -1
- package/dist/types/reviewDoc.d.ts +25 -0
- package/dist/types/reviewDoc.d.ts.map +1 -0
- package/dist/types/translateDoc.d.ts +25 -0
- package/dist/types/translateDoc.d.ts.map +1 -0
- package/dist/types/utils/calculateChunks.d.ts +9 -0
- package/dist/types/utils/calculateChunks.d.ts.map +1 -0
- package/dist/types/utils/calculateChunks.test.d.ts +2 -0
- package/dist/types/utils/calculateChunks.test.d.ts.map +1 -0
- package/dist/types/utils/checkAIAccess.d.ts +4 -0
- package/dist/types/utils/checkAIAccess.d.ts.map +1 -0
- package/dist/types/utils/checkFileModifiedRange.d.ts +11 -0
- package/dist/types/utils/checkFileModifiedRange.d.ts.map +1 -0
- package/dist/types/utils/checkFileModifiedRange.test.d.ts +2 -0
- package/dist/types/utils/checkFileModifiedRange.test.d.ts.map +1 -0
- package/dist/types/utils/checkLastUpdateTime.d.ts +9 -0
- package/dist/types/utils/checkLastUpdateTime.d.ts.map +1 -0
- package/dist/types/utils/chunkInference.d.ts +12 -0
- package/dist/types/utils/chunkInference.d.ts.map +1 -0
- package/dist/types/utils/fixChunkStartEndChars.d.ts +2 -0
- package/dist/types/utils/fixChunkStartEndChars.d.ts.map +1 -0
- package/dist/types/utils/fixChunkStartEndChars.test.d.ts +2 -0
- package/dist/types/utils/fixChunkStartEndChars.test.d.ts.map +1 -0
- package/dist/types/utils/formatTimeDiff.d.ts +2 -0
- package/dist/types/utils/formatTimeDiff.d.ts.map +1 -0
- package/dist/types/utils/formatTimeDiff.test.d.ts +2 -0
- package/dist/types/utils/formatTimeDiff.test.d.ts.map +1 -0
- package/dist/types/utils/getChunk.d.ts +9 -0
- package/dist/types/utils/getChunk.d.ts.map +1 -0
- package/dist/types/utils/getChunk.test.d.ts +2 -0
- package/dist/types/utils/getChunk.test.d.ts.map +1 -0
- package/dist/types/utils/getIsFileUpdatedRecently.d.ts +5 -0
- package/dist/types/utils/getIsFileUpdatedRecently.d.ts.map +1 -0
- package/dist/types/utils/getOutputFilePath.d.ts +26 -0
- package/dist/types/utils/getOutputFilePath.d.ts.map +1 -0
- package/dist/types/utils/getOutputFilePath.test.d.ts +2 -0
- package/dist/types/utils/getOutputFilePath.test.d.ts.map +1 -0
- package/dist/types/utils/getParentPackageJSON.d.ts +32 -0
- package/dist/types/utils/getParentPackageJSON.d.ts.map +1 -0
- package/dist/types/utils/listSpecialChars.d.ts +10 -0
- package/dist/types/utils/listSpecialChars.d.ts.map +1 -0
- package/dist/types/utils/listSpecialChars.test.d.ts +2 -0
- package/dist/types/utils/listSpecialChars.test.d.ts.map +1 -0
- package/dist/types/utils/reorderParagraphs.d.ts +8 -0
- package/dist/types/utils/reorderParagraphs.d.ts.map +1 -0
- package/dist/types/utils/reorderParagraphs.test.d.ts +2 -0
- package/dist/types/utils/reorderParagraphs.test.d.ts.map +1 -0
- package/dist/types/utils/splitTextByLine.d.ts +2 -0
- package/dist/types/utils/splitTextByLine.d.ts.map +1 -0
- package/dist/types/utils/splitTextByLine.test.d.ts +2 -0
- package/dist/types/utils/splitTextByLine.test.d.ts.map +1 -0
- package/package.json +16 -14
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var reorderParagraphs_exports = {};
|
|
20
|
+
__export(reorderParagraphs_exports, {
|
|
21
|
+
reorderParagraphs: () => reorderParagraphs
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(reorderParagraphs_exports);
|
|
24
|
+
var import_listSpecialChars = require('./listSpecialChars.cjs');
|
|
25
|
+
const splitByParagraph = (text) => {
|
|
26
|
+
const paragraphs = [];
|
|
27
|
+
const tokens = text.split(/(\n{2,})/);
|
|
28
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
29
|
+
const token = tokens[i];
|
|
30
|
+
if (i % 2 === 0) {
|
|
31
|
+
if (token) paragraphs.push(token);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const pairsOfNewlines = Math.floor(token.length / 2);
|
|
35
|
+
const blankParagraphs = Math.max(0, pairsOfNewlines - 2);
|
|
36
|
+
for (let j = 0; j < blankParagraphs; j++) {
|
|
37
|
+
paragraphs.push("\n\n");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return paragraphs;
|
|
41
|
+
};
|
|
42
|
+
const paragraphMatches = (paragraph, baseParagraph, paragraphSignature, baseSignature) => {
|
|
43
|
+
if (paragraph === baseParagraph) return true;
|
|
44
|
+
if (paragraphSignature.length !== baseSignature.length) return false;
|
|
45
|
+
for (let i = 0; i < paragraphSignature.length; i++) {
|
|
46
|
+
if (paragraphSignature[i].char !== baseSignature[i].char) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
};
|
|
52
|
+
const reorderParagraphs = (textToReorder, baseFileContent) => {
|
|
53
|
+
const baseFileParagraphs = splitByParagraph(baseFileContent);
|
|
54
|
+
const textToReorderParagraphs = splitByParagraph(textToReorder);
|
|
55
|
+
const baseSignatures = baseFileParagraphs.map((p) => (0, import_listSpecialChars.listSpecialChars)(p));
|
|
56
|
+
const textSignatures = textToReorderParagraphs.map(
|
|
57
|
+
(p) => (0, import_listSpecialChars.listSpecialChars)(p)
|
|
58
|
+
);
|
|
59
|
+
const firstMatchIndexForBase = Array(
|
|
60
|
+
baseFileParagraphs.length
|
|
61
|
+
).fill(-1);
|
|
62
|
+
const paragraphMatchedBaseIdx = Array(
|
|
63
|
+
textToReorderParagraphs.length
|
|
64
|
+
).fill(null);
|
|
65
|
+
for (let i = 0; i < textToReorderParagraphs.length; i++) {
|
|
66
|
+
const paragraph = textToReorderParagraphs[i];
|
|
67
|
+
const sig = textSignatures[i];
|
|
68
|
+
let foundIdx = baseFileParagraphs.findIndex(
|
|
69
|
+
(baseParagraph, idx) => firstMatchIndexForBase[idx] === -1 && paragraph === baseParagraph
|
|
70
|
+
);
|
|
71
|
+
if (foundIdx === -1) {
|
|
72
|
+
foundIdx = baseFileParagraphs.findIndex(
|
|
73
|
+
(baseParagraph, idx) => firstMatchIndexForBase[idx] === -1 && paragraphMatches(paragraph, baseParagraph, sig, baseSignatures[idx])
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (foundIdx !== -1) {
|
|
77
|
+
firstMatchIndexForBase[foundIdx] = i;
|
|
78
|
+
paragraphMatchedBaseIdx[i] = foundIdx;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const insertAfterBaseIdx = Array(
|
|
82
|
+
textToReorderParagraphs.length
|
|
83
|
+
).fill(-1);
|
|
84
|
+
let maxBaseIdxEncountered = -1;
|
|
85
|
+
for (let i = 0; i < textToReorderParagraphs.length; i++) {
|
|
86
|
+
const matchedBase = paragraphMatchedBaseIdx[i];
|
|
87
|
+
if (matchedBase !== null) {
|
|
88
|
+
if (matchedBase > maxBaseIdxEncountered) {
|
|
89
|
+
maxBaseIdxEncountered = matchedBase;
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
insertAfterBaseIdx[i] = maxBaseIdxEncountered;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const result = [];
|
|
96
|
+
const extraParagraphsBuckets = {};
|
|
97
|
+
insertAfterBaseIdx.forEach((afterIdx, paragraphIdx) => {
|
|
98
|
+
if (afterIdx === -1) return;
|
|
99
|
+
extraParagraphsBuckets[afterIdx] = extraParagraphsBuckets[afterIdx] || [];
|
|
100
|
+
extraParagraphsBuckets[afterIdx].push(paragraphIdx);
|
|
101
|
+
});
|
|
102
|
+
for (let bIdx = 0; bIdx < baseFileParagraphs.length; bIdx++) {
|
|
103
|
+
const matchedParagraphIdx = firstMatchIndexForBase[bIdx];
|
|
104
|
+
if (matchedParagraphIdx !== -1) {
|
|
105
|
+
result.push(textToReorderParagraphs[matchedParagraphIdx]);
|
|
106
|
+
}
|
|
107
|
+
if (extraParagraphsBuckets[bIdx]) {
|
|
108
|
+
extraParagraphsBuckets[bIdx].forEach((pIdx) => {
|
|
109
|
+
result.push(textToReorderParagraphs[pIdx]);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const leadingExtras = [];
|
|
114
|
+
insertAfterBaseIdx.forEach((afterIdx, pIdx) => {
|
|
115
|
+
if (afterIdx === -1 && paragraphMatchedBaseIdx[pIdx] === null) {
|
|
116
|
+
leadingExtras.push(textToReorderParagraphs[pIdx]);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return [...leadingExtras, ...result].join("\n\n");
|
|
120
|
+
};
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
reorderParagraphs
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=reorderParagraphs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/reorderParagraphs.ts"],"sourcesContent":["import { listSpecialChars } from './listSpecialChars';\n\n/**\n * Split a text into paragraphs.\n *\n * We consider a paragraph boundary to be a block of at least two consecutive\n * new-lines that is immediately followed by a non-white-space character. This\n * way, internal blank lines that are part of the same paragraph (e.g. a list\n * item that purposely contains a visual break) are preserved while true\n * paragraph breaks – the ones generated when calling `arr.join(\"\\n\\n\")` in\n * the tests – are still detected.\n */\nconst splitByParagraph = (text: string): string[] => {\n const paragraphs: string[] = [];\n\n // Capture the delimiter so that we can inspect how many new-lines it\n // contains. We know that the test strings only use LF, so we keep the\n // regex simple here.\n const tokens = text.split(/(\\n{2,})/);\n\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n\n // Even-indexed tokens are the actual paragraph contents.\n if (i % 2 === 0) {\n if (token) paragraphs.push(token);\n continue;\n }\n\n // Odd-indexed tokens are the delimiters (>= two consecutive new-lines).\n // The first and last pairs represent the natural separators that are\n // added when paragraphs are later joined with \"\\n\\n\". Any additional\n // pairs in between correspond to *explicit* blank paragraphs that were\n // present in the original text and must therefore be preserved.\n const pairsOfNewlines = Math.floor(token.length / 2);\n const blankParagraphs = Math.max(0, pairsOfNewlines - 2);\n\n for (let j = 0; j < blankParagraphs; j++) {\n paragraphs.push('\\n\\n');\n }\n }\n\n return paragraphs;\n};\n\n/**\n * Determine whether two paragraphs match – either exactly, or by sharing the\n * same \"special-character signature\".\n */\nconst paragraphMatches = (\n paragraph: string,\n baseParagraph: string,\n paragraphSignature: ReturnType<typeof listSpecialChars>,\n baseSignature: ReturnType<typeof listSpecialChars>\n): boolean => {\n if (paragraph === baseParagraph) return true;\n // fallback to special-character signature comparison\n if (paragraphSignature.length !== baseSignature.length) return false;\n\n for (let i = 0; i < paragraphSignature.length; i++) {\n if (paragraphSignature[i].char !== baseSignature[i].char) {\n return false;\n }\n }\n return true;\n};\n\n/**\n * Re-order `textToReorder` so that its paragraphs follow the ordering found in\n * `baseFileContent`, while preserving any extra paragraphs (those not present\n * in the base file) in a position that is intuitive for a human reader: right\n * after the closest preceding paragraph coming from the base file.\n */\nexport const reorderParagraphs = (\n textToReorder: string,\n baseFileContent: string\n): string => {\n // 1. Split both texts into paragraphs and pre-compute their signatures.\n const baseFileParagraphs = splitByParagraph(baseFileContent);\n const textToReorderParagraphs = splitByParagraph(textToReorder);\n\n const baseSignatures = baseFileParagraphs.map((p) => listSpecialChars(p));\n const textSignatures = textToReorderParagraphs.map((p) =>\n listSpecialChars(p)\n );\n\n // 2. For every paragraph in the text to reorder, find the *first* base\n // paragraph it matches. We only allow each base paragraph to be matched\n // once. Any further identical paragraphs will be treated as \"extra\" and\n // will be positioned later on, next to their closest neighbour.\n const firstMatchIndexForBase: number[] = Array(\n baseFileParagraphs.length\n ).fill(-1);\n const paragraphMatchedBaseIdx: (number | null)[] = Array(\n textToReorderParagraphs.length\n ).fill(null);\n\n for (let i = 0; i < textToReorderParagraphs.length; i++) {\n const paragraph = textToReorderParagraphs[i];\n const sig = textSignatures[i];\n\n // exact match pass first for performance\n let foundIdx = baseFileParagraphs.findIndex(\n (baseParagraph, idx) =>\n firstMatchIndexForBase[idx] === -1 && paragraph === baseParagraph\n );\n\n if (foundIdx === -1) {\n // fallback to the signature comparison\n foundIdx = baseFileParagraphs.findIndex(\n (baseParagraph, idx) =>\n firstMatchIndexForBase[idx] === -1 &&\n paragraphMatches(paragraph, baseParagraph, sig, baseSignatures[idx])\n );\n }\n\n if (foundIdx !== -1) {\n firstMatchIndexForBase[foundIdx] = i;\n paragraphMatchedBaseIdx[i] = foundIdx;\n }\n }\n\n // 3. For the paragraphs that *didn't* get matched to a base paragraph, we\n // record the highest-numbered base paragraph that was matched *before* it\n // in the original text. The extra paragraph will later be placed right\n // after that paragraph in the final ordering.\n const insertAfterBaseIdx: number[] = Array(\n textToReorderParagraphs.length\n ).fill(-1);\n let maxBaseIdxEncountered = -1;\n\n for (let i = 0; i < textToReorderParagraphs.length; i++) {\n const matchedBase = paragraphMatchedBaseIdx[i];\n\n if (matchedBase !== null) {\n if (matchedBase > maxBaseIdxEncountered) {\n maxBaseIdxEncountered = matchedBase;\n }\n } else {\n insertAfterBaseIdx[i] = maxBaseIdxEncountered;\n }\n }\n\n // 4. Build the final, reordered list of paragraphs.\n const result: string[] = [];\n\n // Helper: quickly retrieve all indices of paragraphs that should be inserted\n // after a given base index, while keeping their original order.\n const extraParagraphsBuckets: Record<number, number[]> = {};\n insertAfterBaseIdx.forEach((afterIdx, paragraphIdx) => {\n if (afterIdx === -1) return; // will be handled later (if any)\n extraParagraphsBuckets[afterIdx] = extraParagraphsBuckets[afterIdx] || [];\n extraParagraphsBuckets[afterIdx].push(paragraphIdx);\n });\n\n for (let bIdx = 0; bIdx < baseFileParagraphs.length; bIdx++) {\n const matchedParagraphIdx = firstMatchIndexForBase[bIdx];\n\n if (matchedParagraphIdx !== -1) {\n result.push(textToReorderParagraphs[matchedParagraphIdx]);\n }\n\n if (extraParagraphsBuckets[bIdx]) {\n extraParagraphsBuckets[bIdx].forEach((pIdx) => {\n result.push(textToReorderParagraphs[pIdx]);\n });\n }\n }\n\n // Finally, if there were extra paragraphs appearing *before* any matched\n // base paragraph (insertAfterBaseIdx === -1), we prepend them to the output\n // in their original order.\n const leadingExtras: string[] = [];\n insertAfterBaseIdx.forEach((afterIdx, pIdx) => {\n if (afterIdx === -1 && paragraphMatchedBaseIdx[pIdx] === null) {\n leadingExtras.push(textToReorderParagraphs[pIdx]);\n }\n });\n\n return [...leadingExtras, ...result].join('\\n\\n');\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAAiC;AAYjC,MAAM,mBAAmB,CAAC,SAA2B;AACnD,QAAM,aAAuB,CAAC;AAK9B,QAAM,SAAS,KAAK,MAAM,UAAU;AAEpC,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,UAAM,QAAQ,OAAO,CAAC;AAGtB,QAAI,IAAI,MAAM,GAAG;AACf,UAAI,MAAO,YAAW,KAAK,KAAK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AClD;AAAA,EACF,CAAC;AAED,SAAO,CAAC,GAAG,eAAe,GAAG,MAAM,EAAE,KAAK,MAAM;AAClD;","names":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_reorderParagraphs = require('./reorderParagraphs.cjs');
|
|
4
|
+
const baseText = [
|
|
5
|
+
"! Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
6
|
+
// '> Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Additional content
|
|
7
|
+
"+ Lorem dolor sit amet consectetur adipiscing elit.",
|
|
8
|
+
// Similar n1
|
|
9
|
+
"- Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
10
|
+
"\n\n",
|
|
11
|
+
// Empty line
|
|
12
|
+
"* Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
13
|
+
"Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
14
|
+
// No special char
|
|
15
|
+
"+ Lorem dolor sit amet consectetur adipiscing elit.",
|
|
16
|
+
// Similar n2
|
|
17
|
+
"+ Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
18
|
+
// Similar n3 but different content
|
|
19
|
+
"= Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
20
|
+
// Missing content
|
|
21
|
+
"& Lorem ipsum dolor sit amet consectetur adipiscing elit."
|
|
22
|
+
].join("\n\n");
|
|
23
|
+
const textToReorder = [
|
|
24
|
+
"! Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
25
|
+
// '> Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Additional content
|
|
26
|
+
"+ Lorem dolor sit amet consectetur adipiscing elit.",
|
|
27
|
+
// Similar n1
|
|
28
|
+
"\n\n",
|
|
29
|
+
// Empty line
|
|
30
|
+
"* Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
31
|
+
"- Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
32
|
+
"+ Lorem dolor sit amet consectetur adipiscing elit.",
|
|
33
|
+
// Similar n2
|
|
34
|
+
"Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
35
|
+
// No special char
|
|
36
|
+
"+ Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
37
|
+
// Similar n3 but different content
|
|
38
|
+
"& Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
39
|
+
"= Lorem ipsum dolor sit amet consectetur adipiscing elit."
|
|
40
|
+
// Missing content
|
|
41
|
+
].join("\n\n");
|
|
42
|
+
const texReordered = [
|
|
43
|
+
"! Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
44
|
+
// '> Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Additional content
|
|
45
|
+
"+ Lorem dolor sit amet consectetur adipiscing elit.",
|
|
46
|
+
// Similar n1
|
|
47
|
+
"- Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
48
|
+
"\n\n",
|
|
49
|
+
// Empty line
|
|
50
|
+
"* Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
51
|
+
"Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
52
|
+
// No special char
|
|
53
|
+
"+ Lorem dolor sit amet consectetur adipiscing elit.",
|
|
54
|
+
// Similar n2
|
|
55
|
+
"+ Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
56
|
+
// Similar n3 but different content
|
|
57
|
+
"= Lorem ipsum dolor sit amet consectetur adipiscing elit.",
|
|
58
|
+
// Missing content
|
|
59
|
+
"& Lorem ipsum dolor sit amet consectetur adipiscing elit."
|
|
60
|
+
].join("\n\n");
|
|
61
|
+
(0, import_vitest.describe)("reorderParagraphs", () => {
|
|
62
|
+
(0, import_vitest.it)("should keep the same order when input matches base text", () => {
|
|
63
|
+
const result = (0, import_reorderParagraphs.reorderParagraphs)(baseText, baseText);
|
|
64
|
+
(0, import_vitest.expect)(result).toEqual(baseText);
|
|
65
|
+
});
|
|
66
|
+
(0, import_vitest.it)("should reorder the paragraphs", () => {
|
|
67
|
+
const result = (0, import_reorderParagraphs.reorderParagraphs)(textToReorder, baseText);
|
|
68
|
+
(0, import_vitest.expect)(result).toEqual(texReordered);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
//# sourceMappingURL=reorderParagraphs.test.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/reorderParagraphs.test.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { reorderParagraphs } from './reorderParagraphs';\n\nconst baseText = [\n '! Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n // '> Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Additional content\n '+ Lorem dolor sit amet consectetur adipiscing elit.', // Similar n1\n '- Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n '\\n\\n', // Empty line\n '* Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n 'Lorem ipsum dolor sit amet consectetur adipiscing elit.', // No special char\n '+ Lorem dolor sit amet consectetur adipiscing elit.', // Similar n2\n '+ Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Similar n3 but different content\n '= Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Missing content\n '& Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n].join('\\n\\n');\n\nconst textToReorder = [\n '! Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n // '> Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Additional content\n '+ Lorem dolor sit amet consectetur adipiscing elit.', // Similar n1\n '\\n\\n', // Empty line\n '* Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n '- Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n '+ Lorem dolor sit amet consectetur adipiscing elit.', // Similar n2\n 'Lorem ipsum dolor sit amet consectetur adipiscing elit.', // No special char\n '+ Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Similar n3 but different content\n '& Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n '= Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Missing content\n].join('\\n\\n');\n\nconst texReordered = [\n '! Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n // '> Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Additional content\n '+ Lorem dolor sit amet consectetur adipiscing elit.', // Similar n1\n '- Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n '\\n\\n', // Empty line\n '* Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n 'Lorem ipsum dolor sit amet consectetur adipiscing elit.', // No special char\n '+ Lorem dolor sit amet consectetur adipiscing elit.', // Similar n2\n '+ Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Similar n3 but different content\n '= Lorem ipsum dolor sit amet consectetur adipiscing elit.', // Missing content\n '& Lorem ipsum dolor sit amet consectetur adipiscing elit.',\n].join('\\n\\n');\n\ndescribe('reorderParagraphs', () => {\n it('should keep the same order when input matches base text', () => {\n const result = reorderParagraphs(baseText, baseText);\n expect(result).toEqual(baseText);\n });\n\n it('should reorder the paragraphs', () => {\n const result = reorderParagraphs(textToReorder, baseText);\n expect(result).toEqual(texReordered);\n });\n});\n"],"mappings":";AAAA,oBAAqC;AACrC,+BAAkC;AAElC,MAAM,WAAW;AAAA,EACf;AAAA;AAAA,EAEA;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AACF,EAAE,KAAK,MAAM;AAEb,MAAM,gBAAgB;AAAA,EACpB;AAAA;AAAA,EAEA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AACF,EAAE,KAAK,MAAM;AAEb,MAAM,eAAe;AAAA,EACnB;AAAA;AAAA,EAEA;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AACF,EAAE,KAAK,MAAM;AAAA,IAEb,wBAAS,qBAAqB,MAAM;AAClC,wBAAG,2DAA2D,MAAM;AAClE,UAAM,aAAS,4CAAkB,UAAU,QAAQ;AACnD,8BAAO,MAAM,EAAE,QAAQ,QAAQ;AAAA,EACjC,CAAC;AAED,wBAAG,iCAAiC,MAAM;AACxC,UAAM,aAAS,4CAAkB,eAAe,QAAQ;AACxD,8BAAO,MAAM,EAAE,QAAQ,YAAY;AAAA,EACrC,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var splitTextByLine_exports = {};
|
|
20
|
+
__export(splitTextByLine_exports, {
|
|
21
|
+
splitTextByLines: () => splitTextByLines
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(splitTextByLine_exports);
|
|
24
|
+
const splitTextByLines = (text) => {
|
|
25
|
+
const splittedText = text.match(/[^\n]*\n|[^\n]*$/g) ?? [];
|
|
26
|
+
if (splittedText.length > 0 && splittedText.at(-1) === "") {
|
|
27
|
+
splittedText.pop();
|
|
28
|
+
}
|
|
29
|
+
return splittedText;
|
|
30
|
+
};
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
splitTextByLines
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=splitTextByLine.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/splitTextByLine.ts"],"sourcesContent":["export const splitTextByLines = (text: string): string[] => {\n const splittedText = text.match(/[^\\n]*\\n|[^\\n]*$/g) ?? [];\n\n if (splittedText.length > 0 && splittedText.at(-1) === '') {\n splittedText.pop();\n }\n\n return splittedText;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,mBAAmB,CAAC,SAA2B;AAC1D,QAAM,eAAe,KAAK,MAAM,mBAAmB,KAAK,CAAC;AAEzD,MAAI,aAAa,SAAS,KAAK,aAAa,GAAG,EAAE,MAAM,IAAI;AACzD,iBAAa,IAAI;AAAA,EACnB;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_splitTextByLine = require('./splitTextByLine.cjs');
|
|
4
|
+
(0, import_vitest.describe)("splitTextByLines", () => {
|
|
5
|
+
(0, import_vitest.it)("splits text by lines", () => {
|
|
6
|
+
const lines = (0, import_splitTextByLine.splitTextByLines)("Here a test. \nAnd another one.");
|
|
7
|
+
(0, import_vitest.expect)(lines).toStrictEqual(["Here a test. \n", "And another one."]);
|
|
8
|
+
});
|
|
9
|
+
(0, import_vitest.it)("splits text by lines with no trailing newline", () => {
|
|
10
|
+
const lines = (0, import_splitTextByLine.splitTextByLines)("Here a test. \n");
|
|
11
|
+
(0, import_vitest.expect)(lines).toStrictEqual(["Here a test. \n"]);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=splitTextByLine.test.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/splitTextByLine.test.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { splitTextByLines } from './splitTextByLine';\n\ndescribe('splitTextByLines', () => {\n it('splits text by lines', () => {\n const lines = splitTextByLines('Here a test. \\nAnd another one.');\n\n expect(lines).toStrictEqual(['Here a test. \\n', 'And another one.']);\n });\n\n it('splits text by lines with no trailing newline', () => {\n const lines = splitTextByLines('Here a test. \\n');\n\n expect(lines).toStrictEqual(['Here a test. \\n']);\n });\n});\n"],"mappings":";AAAA,oBAAqC;AACrC,6BAAiC;AAAA,IAEjC,wBAAS,oBAAoB,MAAM;AACjC,wBAAG,wBAAwB,MAAM;AAC/B,UAAM,YAAQ,yCAAiB,iCAAiC;AAEhE,8BAAO,KAAK,EAAE,cAAc,CAAC,mBAAmB,kBAAkB,CAAC;AAAA,EACrE,CAAC;AAED,wBAAG,iDAAiD,MAAM;AACxD,UAAM,YAAQ,yCAAiB,iBAAiB;AAEhD,8BAAO,KAAK,EAAE,cAAc,CAAC,iBAAiB,CAAC;AAAA,EACjD,CAAC;AACH,CAAC;","names":[]}
|
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { isESModule } from "@intlayer/config";
|
|
2
2
|
import configuration from "@intlayer/config/built";
|
|
3
3
|
import { Command } from "commander";
|
|
4
|
-
import {
|
|
5
|
-
import { dirname as pathDirname, resolve } from "path";
|
|
4
|
+
import { dirname as pathDirname } from "path";
|
|
6
5
|
import { fileURLToPath } from "url";
|
|
7
6
|
import { build } from "./build.mjs";
|
|
8
7
|
import { getConfig } from "./config.mjs";
|
|
@@ -11,10 +10,11 @@ import { listContentDeclaration } from "./listContentDeclaration.mjs";
|
|
|
11
10
|
import { pull } from "./pull.mjs";
|
|
12
11
|
import { push } from "./push.mjs";
|
|
13
12
|
import { pushConfig } from "./pushConfig.mjs";
|
|
13
|
+
import { reviewDoc } from "./reviewDoc.mjs";
|
|
14
|
+
import { translateDoc } from "./translateDoc.mjs";
|
|
15
|
+
import { getParentPackageJSON } from "./utils/getParentPackageJSON.mjs";
|
|
14
16
|
const dirname = isESModule ? pathDirname(fileURLToPath(import.meta.url)) : __dirname;
|
|
15
|
-
const packageJson =
|
|
16
|
-
readFileSync(resolve(dirname, "../../package.json"), "utf8")
|
|
17
|
-
);
|
|
17
|
+
const packageJson = getParentPackageJSON(dirname);
|
|
18
18
|
const logOptions = [
|
|
19
19
|
["--verbose", "Verbose"],
|
|
20
20
|
["--prefix [prefix]", "Prefix"]
|
|
@@ -53,13 +53,21 @@ const applyConfigOptions = (command) => applyOptions(command, configurationOptio
|
|
|
53
53
|
const applyAIOptions = (command) => applyOptions(command, aiOptions);
|
|
54
54
|
const applyGitOptions = (command) => applyOptions(command, gitOptions);
|
|
55
55
|
const extractAiOptions = (options) => {
|
|
56
|
-
const {
|
|
56
|
+
const {
|
|
57
|
+
apiKey,
|
|
58
|
+
provider,
|
|
59
|
+
model,
|
|
60
|
+
temperature,
|
|
61
|
+
applicationContext,
|
|
62
|
+
customPrompt
|
|
63
|
+
} = options;
|
|
57
64
|
return removeUndefined({
|
|
58
65
|
apiKey: apiKey ?? configuration.ai?.apiKey,
|
|
59
66
|
provider: provider ?? configuration.ai?.provider,
|
|
60
67
|
model: model ?? configuration.ai?.model,
|
|
61
68
|
temperature: temperature ?? configuration.ai?.temperature,
|
|
62
|
-
applicationContext: applicationContext ?? configuration.ai?.applicationContext
|
|
69
|
+
applicationContext: applicationContext ?? configuration.ai?.applicationContext,
|
|
70
|
+
customPrompt: customPrompt ?? configuration.ai?.customPrompt
|
|
63
71
|
});
|
|
64
72
|
};
|
|
65
73
|
const gitOptionKeys = [
|
|
@@ -260,6 +268,70 @@ const setAPI = () => {
|
|
|
260
268
|
configOptions: extractConfigOptions(options)
|
|
261
269
|
})
|
|
262
270
|
);
|
|
271
|
+
const docParams = [
|
|
272
|
+
["--doc-pattern [docPattern...]", "Documentation pattern"],
|
|
273
|
+
[
|
|
274
|
+
"--excluded-glob-pattern [excludedGlobPattern...]",
|
|
275
|
+
"Excluded glob pattern"
|
|
276
|
+
],
|
|
277
|
+
[
|
|
278
|
+
"--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]",
|
|
279
|
+
"Number of simultaneous file processed"
|
|
280
|
+
],
|
|
281
|
+
["--locales [locales...]", "Locales"],
|
|
282
|
+
["--base-locale [baseLocale]", "Base locale"],
|
|
283
|
+
[
|
|
284
|
+
"--custom-instructions [customInstructions]",
|
|
285
|
+
"Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc."
|
|
286
|
+
],
|
|
287
|
+
[
|
|
288
|
+
"--skip-if-modified-before [skipIfModifiedBefore]",
|
|
289
|
+
'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.'
|
|
290
|
+
],
|
|
291
|
+
[
|
|
292
|
+
"--skip-if-modified-after [skipIfModifiedAfter]",
|
|
293
|
+
'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.'
|
|
294
|
+
]
|
|
295
|
+
];
|
|
296
|
+
const docProgram = program.command("doc").description("Documentation operations");
|
|
297
|
+
const translateProgram = docProgram.command("translate").description("Translate the documentation");
|
|
298
|
+
applyConfigOptions(translateProgram);
|
|
299
|
+
applyAIOptions(translateProgram);
|
|
300
|
+
applyGitOptions(translateProgram);
|
|
301
|
+
applyOptions(translateProgram, docParams);
|
|
302
|
+
translateProgram.action(
|
|
303
|
+
(options) => translateDoc({
|
|
304
|
+
docPattern: options.docPattern,
|
|
305
|
+
excludedGlobPattern: options.excludedGlobPattern,
|
|
306
|
+
locales: options.locales,
|
|
307
|
+
baseLocale: options.baseLocale,
|
|
308
|
+
aiOptions: extractAiOptions(options),
|
|
309
|
+
nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,
|
|
310
|
+
configOptions: extractConfigOptions(options),
|
|
311
|
+
customInstructions: options.customInstructions,
|
|
312
|
+
skipIfModifiedBefore: options.skipIfModifiedBefore,
|
|
313
|
+
skipIfModifiedAfter: options.skipIfModifiedAfter
|
|
314
|
+
})
|
|
315
|
+
);
|
|
316
|
+
const reviewProgram = docProgram.command("review").description("Review the documentation");
|
|
317
|
+
applyConfigOptions(reviewProgram);
|
|
318
|
+
applyAIOptions(reviewProgram);
|
|
319
|
+
applyGitOptions(reviewProgram);
|
|
320
|
+
applyOptions(reviewProgram, docParams);
|
|
321
|
+
reviewProgram.action(
|
|
322
|
+
(options) => reviewDoc({
|
|
323
|
+
docPattern: options.docPattern,
|
|
324
|
+
excludedGlobPattern: options.excludedGlobPattern,
|
|
325
|
+
locales: options.locales,
|
|
326
|
+
baseLocale: options.baseLocale,
|
|
327
|
+
aiOptions: extractAiOptions(options),
|
|
328
|
+
nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,
|
|
329
|
+
configOptions: extractConfigOptions(options),
|
|
330
|
+
customInstructions: options.customInstructions,
|
|
331
|
+
skipIfModifiedBefore: options.skipIfModifiedBefore,
|
|
332
|
+
skipIfModifiedAfter: options.skipIfModifiedAfter
|
|
333
|
+
})
|
|
334
|
+
);
|
|
263
335
|
program.parse(process.argv);
|
|
264
336
|
return program;
|
|
265
337
|
};
|
package/dist/esm/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import type { AIOptions } from '@intlayer/api';\nimport { GetConfigurationOptions, isESModule } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { Command } from 'commander';\nimport { readFileSync } from 'fs';\nimport { dirname as pathDirname, resolve } from 'path';\nimport { fileURLToPath } from 'url';\nimport {\n DiffMode,\n ListGitFilesOptions,\n} from '../../chokidar/dist/types/listGitFiles';\nimport { build } from './build';\nimport { getConfig } from './config';\nimport { fill, FillOptions } from './fill';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { pull } from './pull';\nimport { push } from './push';\nimport { pushConfig } from './pushConfig';\n\nexport const dirname = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson = JSON.parse(\n readFileSync(resolve(dirname, '../../package.json'), 'utf8')\n);\n\nconst logOptions = [\n ['--verbose', 'Verbose'],\n ['--prefix [prefix]', 'Prefix'],\n];\n\nconst configurationOptions = [\n ['--env-file [envFile]', 'Environment file'],\n ['-e, --env [env]', 'Environment'],\n ['--base-dir [baseDir]', 'Base directory'],\n ...logOptions,\n];\n\nconst aiOptions = [\n ['--provider [provider]', 'Provider'],\n ['--temperature [temperature]', 'Temperature'],\n ['--model [model]', 'Model'],\n ['--api-key [apiKey]', 'Provider API key'],\n ['--custom-prompt [prompt]', 'Custom prompt'],\n ['--application-context [applicationContext]', 'Application context'],\n];\n\nconst gitOptions = [\n ['--git-diff [gitDiff]', 'Git diff mode - Check git diff between two refs'],\n ['--git-diff-base [gitDiffBase]', 'Git diff base ref'],\n ['--git-diff-current [gitDiffCurrent]', 'Git diff current ref'],\n ['--uncommitted [uncommitted]', 'Uncommitted'],\n ['--unpushed [unpushed]', 'Unpushed'],\n ['--untracked [untracked]', 'Untracked'],\n];\n\nconst extractKeysFromOptions = (options: object, keys: string[]) =>\n keys.filter((key) => options[key as keyof typeof options]);\n\n/**\n * Helper functions to apply common options to commands\n */\nconst applyOptions = (command: Command, options: string[][]) => {\n options.forEach(([flag, description]) => command.option(flag, description));\n return command;\n};\n\nconst removeUndefined = <T extends Record<string, any>>(obj: T): T =>\n Object.fromEntries(\n Object.entries(obj).filter(([_, value]) => value !== undefined)\n ) as T;\n\nconst applyConfigOptions = (command: Command) =>\n applyOptions(command, configurationOptions);\nconst applyAIOptions = (command: Command) => applyOptions(command, aiOptions);\nconst applyGitOptions = (command: Command) => applyOptions(command, gitOptions);\n\nconst extractAiOptions = (options: AIOptions) => {\n const { apiKey, provider, model, temperature, applicationContext } = options;\n\n return removeUndefined({\n apiKey: apiKey ?? configuration.ai?.apiKey,\n provider: provider ?? configuration.ai?.provider,\n model: model ?? configuration.ai?.model,\n temperature: temperature ?? configuration.ai?.temperature,\n applicationContext:\n applicationContext ?? configuration.ai?.applicationContext,\n });\n};\n\ntype GitOptions = {\n gitDiff?: boolean;\n gitDiffBase?: string;\n gitDiffCurrent?: string;\n uncommitted?: boolean;\n unpushed?: boolean;\n untracked?: boolean;\n};\n\nconst gitOptionKeys: (keyof GitOptions)[] = [\n 'gitDiff',\n 'gitDiffBase',\n 'gitDiffCurrent',\n 'uncommitted',\n 'unpushed',\n 'untracked',\n];\n\nconst extractGitOptions = (\n options: GitOptions\n): ListGitFilesOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(options, gitOptionKeys);\n\n const isOptionEmpty = !Object.values(filteredOptions).some(Boolean);\n\n if (isOptionEmpty) return undefined;\n\n const {\n gitDiff,\n gitDiffBase,\n gitDiffCurrent,\n uncommitted,\n unpushed,\n untracked,\n } = options;\n\n const mode = [\n gitDiff && 'gitDiff',\n uncommitted && 'uncommitted',\n unpushed && 'unpushed',\n untracked && 'untracked',\n ].filter(Boolean) as DiffMode[];\n\n return removeUndefined({\n mode,\n baseRef: gitDiffBase,\n currentRef: gitDiffCurrent,\n absolute: true,\n });\n};\n\ntype LogOptions = {\n prefix?: string;\n verbose?: boolean;\n};\n\nexport type ConfigurationOptions = {\n baseDir?: string;\n env?: string;\n envFile?: string;\n} & LogOptions;\n\nconst configurationOptionKeys: (keyof ConfigurationOptions)[] = [\n 'baseDir',\n 'env',\n 'envFile',\n 'verbose',\n 'prefix',\n];\n\nconst extractConfigOptions = (\n options: ConfigurationOptions\n): GetConfigurationOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(\n options,\n configurationOptionKeys\n );\n\n const isOptionEmpty = !Object.values(filteredOptions).some(Boolean);\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n const { baseDir, env, envFile, verbose, prefix } = options;\n\n const log = {\n prefix: prefix ?? '', // Should not consider the prefix set in the intlayer configuration file\n verbose,\n };\n\n const override = {\n log,\n };\n\n return removeUndefined({\n baseDir,\n env,\n envFile,\n override,\n });\n};\n\n/**\n * Set the API for the CLI\n *\n * Example of commands:\n *\n * npm run intlayer build --watch\n * npm run intlayer push --dictionaries id1 id2 id3 --deleteLocaleDir\n */\nexport const setAPI = (): Command => {\n const program = new Command();\n\n program.version(packageJson.version).description('Intlayer CLI');\n\n /**\n * DICTIONARIES\n */\n\n const dictionariesProgram = program\n .command('dictionary')\n .alias('dictionaries')\n .alias('dic')\n .description('Dictionaries operations');\n\n // Dictionary build command\n const buildOptions = {\n description: 'Build the dictionaries',\n options: [['-w, --watch', 'Watch for changes']],\n };\n\n // Add build command to dictionaries program\n const dictionariesBuildCmd = dictionariesProgram\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(dictionariesBuildCmd, buildOptions.options);\n applyConfigOptions(dictionariesBuildCmd);\n dictionariesBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootBuildCmd = program\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(rootBuildCmd, buildOptions.options);\n applyConfigOptions(rootBuildCmd);\n rootBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary pull command\n const pullOptions = {\n description: 'Pull dictionaries from the server',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to pull'],\n ['--newDictionariesPath [path]', 'Path to save the new dictionaries'],\n ],\n };\n\n // Add pull command to dictionaries program\n const dictionariesPullCmd = dictionariesProgram\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(dictionariesPullCmd, pullOptions.options);\n applyConfigOptions(dictionariesPullCmd);\n dictionariesPullCmd.action((options) => {\n pull({\n ...options,\n configOptions: {\n ...options.configOptions,\n baseDir: options.baseDir,\n },\n });\n });\n\n // Add pull command to root program as well\n const rootPullCmd = program\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(rootPullCmd, pullOptions.options);\n applyConfigOptions(rootPullCmd);\n rootPullCmd.action((options) => {\n pull({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary push command\n const pushOptions = {\n description:\n 'Push all dictionaries. Create or update the pushed dictionaries',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to push'],\n [\n '-r, --deleteLocaleDictionary',\n 'Delete the local dictionaries after pushing',\n ],\n [\n '-k, --keepLocaleDictionary',\n 'Keep the local dictionaries after pushing',\n ],\n ],\n };\n\n // Add push command to dictionaries program\n const dictionariesPushCmd = dictionariesProgram\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(dictionariesPushCmd, pushOptions.options);\n applyConfigOptions(dictionariesPushCmd);\n applyGitOptions(dictionariesPushCmd);\n\n dictionariesPushCmd.action((options) =>\n push({\n ...options,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions)\n );\n\n // Add push command to root program as well\n const rootPushCmd = program\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(rootPushCmd, pushOptions.options);\n applyConfigOptions(rootPushCmd);\n applyGitOptions(rootPushCmd);\n\n rootPushCmd.action((options) =>\n push({\n ...options,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions)\n );\n\n /**\n * CONFIGURATION\n */\n\n // Define the parent command\n const configurationProgram = program\n .command('configuration')\n .alias('config')\n .alias('conf')\n .description('Configuration operations');\n\n const configGetCmd = configurationProgram\n .command('get')\n .description('Get the configuration');\n\n applyConfigOptions(configGetCmd);\n configGetCmd.action((options) => {\n getConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Define the `push config` subcommand and add it to the `push` command\n const configPushCmd = configurationProgram\n .command('push')\n .description('Push the configuration');\n\n applyConfigOptions(configPushCmd);\n configPushCmd.action((options) => {\n pushConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n /**\n * CONTENT DECLARATION\n */\n\n program\n .command('content list')\n .description('List the content declaration files')\n .action(listContentDeclaration);\n\n const fillProgram = program\n .command('fill')\n .description('Fill the dictionaries')\n .option('-f, --file [files...]', 'List of Dictionary files to fill')\n .option('--source-locale [sourceLocale]', 'Source locale to translate from')\n .option(\n '--output-locales [outputLocales...]',\n 'Target locales to translate to'\n )\n .option(\n '--mode [mode]',\n 'Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys',\n 'review'\n )\n .option('-k, --keys [keys...]', 'Filter dictionaries based on keys')\n .option(\n '--excluded-keys [excludedKeys...]',\n 'Filter out dictionaries based on keys'\n )\n .option(\n '--path-filter [pathFilters...]',\n 'Filter dictionaries based on glob pattern'\n );\n\n applyConfigOptions(fillProgram);\n applyAIOptions(fillProgram);\n applyGitOptions(fillProgram);\n\n fillProgram.action((options) =>\n fill({\n ...options,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions)\n );\n\n program.parse(process.argv);\n\n return program;\n};\n"],"mappings":"AACA,SAAkC,kBAAkB;AACpD,OAAO,mBAAmB;AAC1B,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAC7B,SAAS,WAAW,aAAa,eAAe;AAChD,SAAS,qBAAqB;AAK9B,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,YAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAEpB,MAAM,UAAU,aACnB,YAAY,cAAc,YAAY,GAAG,CAAC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I;AAE1B,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import type { AIOptions as BaseAIOptions } from '@intlayer/api';\nimport { GetConfigurationOptions, isESModule } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { Command } from 'commander';\nimport { dirname as pathDirname } from 'path';\nimport { fileURLToPath } from 'url';\nimport {\n DiffMode,\n ListGitFilesOptions,\n} from '../../chokidar/dist/types/listGitFiles';\nimport { build } from './build';\nimport { getConfig } from './config';\nimport { fill, FillOptions } from './fill';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { pull } from './pull';\nimport { push } from './push';\nimport { pushConfig } from './pushConfig';\nimport { reviewDoc } from './reviewDoc';\nimport { translateDoc } from './translateDoc';\nimport { getParentPackageJSON } from './utils/getParentPackageJSON';\n\n// Extended AI options to include customPrompt\ntype AIOptions = BaseAIOptions & {\n customPrompt?: string;\n};\n\nexport const dirname = isESModule\n ? pathDirname(fileURLToPath(import.meta.url))\n : __dirname;\n\nconst packageJson = getParentPackageJSON(dirname);\n\nconst logOptions = [\n ['--verbose', 'Verbose'],\n ['--prefix [prefix]', 'Prefix'],\n];\n\nconst configurationOptions = [\n ['--env-file [envFile]', 'Environment file'],\n ['-e, --env [env]', 'Environment'],\n ['--base-dir [baseDir]', 'Base directory'],\n ...logOptions,\n];\n\nconst aiOptions = [\n ['--provider [provider]', 'Provider'],\n ['--temperature [temperature]', 'Temperature'],\n ['--model [model]', 'Model'],\n ['--api-key [apiKey]', 'Provider API key'],\n ['--custom-prompt [prompt]', 'Custom prompt'],\n ['--application-context [applicationContext]', 'Application context'],\n];\n\nconst gitOptions = [\n ['--git-diff [gitDiff]', 'Git diff mode - Check git diff between two refs'],\n ['--git-diff-base [gitDiffBase]', 'Git diff base ref'],\n ['--git-diff-current [gitDiffCurrent]', 'Git diff current ref'],\n ['--uncommitted [uncommitted]', 'Uncommitted'],\n ['--unpushed [unpushed]', 'Unpushed'],\n ['--untracked [untracked]', 'Untracked'],\n];\n\nconst extractKeysFromOptions = (options: object, keys: string[]) =>\n keys.filter((key) => options[key as keyof typeof options]);\n\n/**\n * Helper functions to apply common options to commands\n */\nconst applyOptions = (command: Command, options: string[][]) => {\n options.forEach(([flag, description]) => command.option(flag, description));\n return command;\n};\n\nconst removeUndefined = <T extends Record<string, any>>(obj: T): T =>\n Object.fromEntries(\n Object.entries(obj).filter(([_, value]) => value !== undefined)\n ) as T;\n\nconst applyConfigOptions = (command: Command) =>\n applyOptions(command, configurationOptions);\nconst applyAIOptions = (command: Command) => applyOptions(command, aiOptions);\nconst applyGitOptions = (command: Command) => applyOptions(command, gitOptions);\n\nconst extractAiOptions = (options: AIOptions): AIOptions | undefined => {\n const {\n apiKey,\n provider,\n model,\n temperature,\n applicationContext,\n customPrompt,\n } = options;\n\n return removeUndefined({\n apiKey: apiKey ?? configuration.ai?.apiKey,\n provider: provider ?? (configuration.ai?.provider as AIOptions['provider']),\n model: model ?? configuration.ai?.model,\n temperature: temperature ?? configuration.ai?.temperature,\n applicationContext:\n applicationContext ?? configuration.ai?.applicationContext,\n customPrompt: customPrompt ?? (configuration.ai as any)?.customPrompt,\n });\n};\n\ntype GitOptions = {\n gitDiff?: boolean;\n gitDiffBase?: string;\n gitDiffCurrent?: string;\n uncommitted?: boolean;\n unpushed?: boolean;\n untracked?: boolean;\n};\n\nconst gitOptionKeys: (keyof GitOptions)[] = [\n 'gitDiff',\n 'gitDiffBase',\n 'gitDiffCurrent',\n 'uncommitted',\n 'unpushed',\n 'untracked',\n];\n\nconst extractGitOptions = (\n options: GitOptions\n): ListGitFilesOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(options, gitOptionKeys);\n\n const isOptionEmpty = !Object.values(filteredOptions).some(Boolean);\n\n if (isOptionEmpty) return undefined;\n\n const {\n gitDiff,\n gitDiffBase,\n gitDiffCurrent,\n uncommitted,\n unpushed,\n untracked,\n } = options;\n\n const mode = [\n gitDiff && 'gitDiff',\n uncommitted && 'uncommitted',\n unpushed && 'unpushed',\n untracked && 'untracked',\n ].filter(Boolean) as DiffMode[];\n\n return removeUndefined({\n mode,\n baseRef: gitDiffBase,\n currentRef: gitDiffCurrent,\n absolute: true,\n });\n};\n\ntype LogOptions = {\n prefix?: string;\n verbose?: boolean;\n};\n\nexport type ConfigurationOptions = {\n baseDir?: string;\n env?: string;\n envFile?: string;\n} & LogOptions;\n\nconst configurationOptionKeys: (keyof ConfigurationOptions)[] = [\n 'baseDir',\n 'env',\n 'envFile',\n 'verbose',\n 'prefix',\n];\n\nconst extractConfigOptions = (\n options: ConfigurationOptions\n): GetConfigurationOptions | undefined => {\n const filteredOptions = extractKeysFromOptions(\n options,\n configurationOptionKeys\n );\n\n const isOptionEmpty = !Object.values(filteredOptions).some(Boolean);\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n const { baseDir, env, envFile, verbose, prefix } = options;\n\n const log = {\n prefix: prefix ?? '', // Should not consider the prefix set in the intlayer configuration file\n verbose,\n };\n\n const override = {\n log,\n };\n\n return removeUndefined({\n baseDir,\n env,\n envFile,\n override,\n });\n};\n\n/**\n * Set the API for the CLI\n *\n * Example of commands:\n *\n * npm run intlayer build --watch\n * npm run intlayer push --dictionaries id1 id2 id3 --deleteLocaleDir\n */\nexport const setAPI = (): Command => {\n const program = new Command();\n\n program.version(packageJson.version!).description('Intlayer CLI');\n\n /**\n * DICTIONARIES\n */\n\n const dictionariesProgram = program\n .command('dictionary')\n .alias('dictionaries')\n .alias('dic')\n .description('Dictionaries operations');\n\n // Dictionary build command\n const buildOptions = {\n description: 'Build the dictionaries',\n options: [['-w, --watch', 'Watch for changes']],\n };\n\n // Add build command to dictionaries program\n const dictionariesBuildCmd = dictionariesProgram\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(dictionariesBuildCmd, buildOptions.options);\n applyConfigOptions(dictionariesBuildCmd);\n dictionariesBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootBuildCmd = program\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(rootBuildCmd, buildOptions.options);\n applyConfigOptions(rootBuildCmd);\n rootBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary pull command\n const pullOptions = {\n description: 'Pull dictionaries from the server',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to pull'],\n ['--newDictionariesPath [path]', 'Path to save the new dictionaries'],\n ],\n };\n\n // Add pull command to dictionaries program\n const dictionariesPullCmd = dictionariesProgram\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(dictionariesPullCmd, pullOptions.options);\n applyConfigOptions(dictionariesPullCmd);\n dictionariesPullCmd.action((options) => {\n pull({\n ...options,\n configOptions: {\n ...options.configOptions,\n baseDir: options.baseDir,\n },\n });\n });\n\n // Add pull command to root program as well\n const rootPullCmd = program\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(rootPullCmd, pullOptions.options);\n applyConfigOptions(rootPullCmd);\n rootPullCmd.action((options) => {\n pull({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary push command\n const pushOptions = {\n description:\n 'Push all dictionaries. Create or update the pushed dictionaries',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to push'],\n [\n '-r, --deleteLocaleDictionary',\n 'Delete the local dictionaries after pushing',\n ],\n [\n '-k, --keepLocaleDictionary',\n 'Keep the local dictionaries after pushing',\n ],\n ],\n };\n\n // Add push command to dictionaries program\n const dictionariesPushCmd = dictionariesProgram\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(dictionariesPushCmd, pushOptions.options);\n applyConfigOptions(dictionariesPushCmd);\n applyGitOptions(dictionariesPushCmd);\n\n dictionariesPushCmd.action((options) =>\n push({\n ...options,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions)\n );\n\n // Add push command to root program as well\n const rootPushCmd = program\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(rootPushCmd, pushOptions.options);\n applyConfigOptions(rootPushCmd);\n applyGitOptions(rootPushCmd);\n\n rootPushCmd.action((options) =>\n push({\n ...options,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions)\n );\n\n /**\n * CONFIGURATION\n */\n\n // Define the parent command\n const configurationProgram = program\n .command('configuration')\n .alias('config')\n .alias('conf')\n .description('Configuration operations');\n\n const configGetCmd = configurationProgram\n .command('get')\n .description('Get the configuration');\n\n applyConfigOptions(configGetCmd);\n configGetCmd.action((options) => {\n getConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Define the `push config` subcommand and add it to the `push` command\n const configPushCmd = configurationProgram\n .command('push')\n .description('Push the configuration');\n\n applyConfigOptions(configPushCmd);\n configPushCmd.action((options) => {\n pushConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n /**\n * CONTENT DECLARATION\n */\n\n program\n .command('content list')\n .description('List the content declaration files')\n .action(listContentDeclaration);\n\n const fillProgram = program\n .command('fill')\n .description('Fill the dictionaries')\n .option('-f, --file [files...]', 'List of Dictionary files to fill')\n .option('--source-locale [sourceLocale]', 'Source locale to translate from')\n .option(\n '--output-locales [outputLocales...]',\n 'Target locales to translate to'\n )\n .option(\n '--mode [mode]',\n 'Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys',\n 'review'\n )\n .option('-k, --keys [keys...]', 'Filter dictionaries based on keys')\n .option(\n '--excluded-keys [excludedKeys...]',\n 'Filter out dictionaries based on keys'\n )\n .option(\n '--path-filter [pathFilters...]',\n 'Filter dictionaries based on glob pattern'\n );\n\n applyConfigOptions(fillProgram);\n applyAIOptions(fillProgram);\n applyGitOptions(fillProgram);\n\n fillProgram.action((options) =>\n fill({\n ...options,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions)\n );\n\n /**\n * DOCS\n */\n\n const docParams = [\n ['--doc-pattern [docPattern...]', 'Documentation pattern'],\n [\n '--excluded-glob-pattern [excludedGlobPattern...]',\n 'Excluded glob pattern',\n ],\n [\n '--nb-simultaneous-file-processed [nbSimultaneousFileProcessed]',\n 'Number of simultaneous file processed',\n ],\n ['--locales [locales...]', 'Locales'],\n ['--base-locale [baseLocale]', 'Base locale'],\n [\n '--custom-instructions [customInstructions]',\n 'Custom instructions added to the prompt. Usefull to apply specific rules regarding formatting, urls translation, etc.',\n ],\n [\n '--skip-if-modified-before [skipIfModifiedBefore]',\n '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.',\n ],\n [\n '--skip-if-modified-after [skipIfModifiedAfter]',\n '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.',\n ],\n ];\n\n const docProgram = program\n .command('doc')\n .description('Documentation operations');\n\n const translateProgram = docProgram\n .command('translate')\n .description('Translate the documentation');\n\n applyConfigOptions(translateProgram);\n applyAIOptions(translateProgram);\n applyGitOptions(translateProgram);\n applyOptions(translateProgram, docParams);\n\n translateProgram.action((options) =>\n translateDoc({\n docPattern: options.docPattern,\n excludedGlobPattern: options.excludedGlobPattern,\n locales: options.locales,\n baseLocale: options.baseLocale,\n aiOptions: extractAiOptions(options),\n nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,\n configOptions: extractConfigOptions(options),\n customInstructions: options.customInstructions,\n skipIfModifiedBefore: options.skipIfModifiedBefore,\n skipIfModifiedAfter: options.skipIfModifiedAfter,\n })\n );\n\n const reviewProgram = docProgram\n .command('review')\n .description('Review the documentation');\n\n applyConfigOptions(reviewProgram);\n applyAIOptions(reviewProgram);\n applyGitOptions(reviewProgram);\n applyOptions(reviewProgram, docParams);\n\n reviewProgram.action((options) =>\n reviewDoc({\n docPattern: options.docPattern,\n excludedGlobPattern: options.excludedGlobPattern,\n locales: options.locales,\n baseLocale: options.baseLocale,\n aiOptions: extractAiOptions(options),\n nbSimultaneousFileProcessed: options.nbSimultaneousFileProcessed,\n configOptions: extractConfigOptions(options),\n customInstructions: options.customInstructions,\n skipIfModifiedBefore: options.skipIfModifiedBefore,\n skipIfModifiedAfter: options.skipIfModifiedAfter,\n })\n );\n\n program.parse(process.argv);\n\n return program;\n};\n"],"mappings":"AACA,SAAkC,kBAAkB;AACpD,OAAO,mBAAmB;AAC1B,SAAS,eAAe;AACxB,SAAS,WAAW,mBAAmB;AACvC,SAAS,qBAAqB;AAK9B,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,YAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,SAAS,4BAA4B;AAO9B,MAAM,UAAU,aACnB,YAAY,cAAc,YAAY,GAAG,CAAC,IAC1C;AAEJ,MAAM,cAAc,qBAAqB,OAAO;AAEhD,MAAM,aAAa;AAAA,EACjB,CAAC,aAAa,SAAS;AAAA,EACvB,CAAC,qBAAqB,QAAQ;AAChC;AAEA,MAAM,uBAAuB;AAAA,EAC3B,CAAC,wBAAwB,kBAAkB;AAAA,EAC3C,CAAC,mBAAmB,aAAa;AAAA,EACjC,CAAC,wBAAwB,gBAAgB;AAAA,EACzC,GAAG;AACL;AAEA,MAAM,YAAY;AAAA,EAChB,CAAC,yBAAyB,UAAU;AAAA,EACpC,CAAC,+BAA+B,aAAa;AAAA,EAC7C,CAAC,mBAAmB,OAAO;AAAA,EAC3B,CAAC,sBAAsB,kBAAkB;AAAA,EACzC,CAAC,4BAA4B,eAAe;AAAA,EAC5C,CAAC,8CAA8C,qBAAqB;AACtE;AAEA,MAAM,aAAa;AAAA,EACjB,CAAC,wBAAwB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