@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,412 @@
|
|
|
1
|
+
import { TextDecoder, TextEncoder } from "util";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
if (!globalThis.TextEncoder) {
|
|
4
|
+
globalThis.TextEncoder = TextEncoder;
|
|
5
|
+
}
|
|
6
|
+
if (!globalThis.TextDecoder) {
|
|
7
|
+
globalThis.TextDecoder = TextDecoder;
|
|
8
|
+
}
|
|
9
|
+
const ORIGINAL_ARGV = [...process.argv];
|
|
10
|
+
const setProcessArgv = (args) => {
|
|
11
|
+
process.argv = ["node", "intlayer", ...args];
|
|
12
|
+
};
|
|
13
|
+
let buildMock;
|
|
14
|
+
let pushMock;
|
|
15
|
+
let pullMock;
|
|
16
|
+
let fillMock;
|
|
17
|
+
let getConfigMock;
|
|
18
|
+
let pushConfigMock;
|
|
19
|
+
let listContentDeclarationMock;
|
|
20
|
+
let translateDocMock;
|
|
21
|
+
let reviewDocMock;
|
|
22
|
+
vi.mock("./build", () => ({
|
|
23
|
+
build: (...args) => buildMock(...args)
|
|
24
|
+
}));
|
|
25
|
+
vi.mock("./push", () => ({
|
|
26
|
+
push: (...args) => pushMock(...args)
|
|
27
|
+
}));
|
|
28
|
+
vi.mock("./pull", () => ({
|
|
29
|
+
pull: (...args) => pullMock(...args)
|
|
30
|
+
}));
|
|
31
|
+
vi.mock("./fill", () => ({
|
|
32
|
+
fill: (...args) => fillMock(...args)
|
|
33
|
+
}));
|
|
34
|
+
vi.mock("./config", () => ({
|
|
35
|
+
getConfig: (...args) => getConfigMock(...args)
|
|
36
|
+
}));
|
|
37
|
+
vi.mock("./pushConfig", () => ({
|
|
38
|
+
pushConfig: (...args) => pushConfigMock(...args)
|
|
39
|
+
}));
|
|
40
|
+
vi.mock("./listContentDeclaration", () => ({
|
|
41
|
+
listContentDeclaration: (...args) => listContentDeclarationMock(...args)
|
|
42
|
+
}));
|
|
43
|
+
vi.mock("./translateDoc", () => ({
|
|
44
|
+
translateDoc: (...args) => translateDocMock(...args)
|
|
45
|
+
}));
|
|
46
|
+
vi.mock("./reviewDoc", () => ({
|
|
47
|
+
reviewDoc: (...args) => reviewDocMock(...args)
|
|
48
|
+
}));
|
|
49
|
+
vi.mock("./utils/getParentPackageJSON", () => ({
|
|
50
|
+
getParentPackageJSON: vi.fn(() => ({
|
|
51
|
+
name: "@intlayer/cli",
|
|
52
|
+
version: "1.0.0",
|
|
53
|
+
description: "Intlayer CLI"
|
|
54
|
+
}))
|
|
55
|
+
}));
|
|
56
|
+
vi.mock("@intlayer/config/built", () => ({
|
|
57
|
+
__esModule: true,
|
|
58
|
+
default: {}
|
|
59
|
+
}));
|
|
60
|
+
vi.mock("@intlayer/config", () => ({
|
|
61
|
+
__esModule: true,
|
|
62
|
+
isESModule: false
|
|
63
|
+
}));
|
|
64
|
+
describe("Intlayer CLI", () => {
|
|
65
|
+
beforeEach(() => {
|
|
66
|
+
vi.resetModules();
|
|
67
|
+
buildMock = vi.fn();
|
|
68
|
+
pushMock = vi.fn();
|
|
69
|
+
pullMock = vi.fn();
|
|
70
|
+
fillMock = vi.fn();
|
|
71
|
+
getConfigMock = vi.fn();
|
|
72
|
+
pushConfigMock = vi.fn();
|
|
73
|
+
listContentDeclarationMock = vi.fn();
|
|
74
|
+
translateDocMock = vi.fn();
|
|
75
|
+
reviewDocMock = vi.fn();
|
|
76
|
+
});
|
|
77
|
+
afterEach(() => {
|
|
78
|
+
process.argv = [...ORIGINAL_ARGV];
|
|
79
|
+
vi.clearAllMocks();
|
|
80
|
+
});
|
|
81
|
+
describe("build command", () => {
|
|
82
|
+
it("triggers build with the --watch flag", async () => {
|
|
83
|
+
setProcessArgv(["build", "--watch"]);
|
|
84
|
+
const { setAPI } = await import("./cli");
|
|
85
|
+
setAPI();
|
|
86
|
+
expect(buildMock).toHaveBeenCalledTimes(1);
|
|
87
|
+
expect(buildMock).toHaveBeenCalledWith(
|
|
88
|
+
expect.objectContaining({ watch: true })
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
it("triggers build with verbose and custom prefix", async () => {
|
|
92
|
+
setProcessArgv(["build", "--verbose", "--prefix", "TEST"]);
|
|
93
|
+
const { setAPI } = await import("./cli");
|
|
94
|
+
setAPI();
|
|
95
|
+
expect(buildMock).toHaveBeenCalledTimes(1);
|
|
96
|
+
expect(buildMock).toHaveBeenCalledWith(
|
|
97
|
+
expect.objectContaining({
|
|
98
|
+
verbose: true,
|
|
99
|
+
prefix: "TEST",
|
|
100
|
+
configOptions: expect.objectContaining({
|
|
101
|
+
override: expect.objectContaining({
|
|
102
|
+
log: expect.objectContaining({
|
|
103
|
+
verbose: true,
|
|
104
|
+
prefix: "TEST"
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
it("triggers build with environment and base directory options", async () => {
|
|
112
|
+
setProcessArgv([
|
|
113
|
+
"build",
|
|
114
|
+
"--env",
|
|
115
|
+
"production",
|
|
116
|
+
"--base-dir",
|
|
117
|
+
"/custom/path"
|
|
118
|
+
]);
|
|
119
|
+
const { setAPI } = await import("./cli");
|
|
120
|
+
setAPI();
|
|
121
|
+
expect(buildMock).toHaveBeenCalledTimes(1);
|
|
122
|
+
expect(buildMock).toHaveBeenCalledWith(
|
|
123
|
+
expect.objectContaining({
|
|
124
|
+
env: "production",
|
|
125
|
+
baseDir: "/custom/path",
|
|
126
|
+
configOptions: expect.objectContaining({
|
|
127
|
+
env: "production",
|
|
128
|
+
baseDir: "/custom/path"
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
describe("push command", () => {
|
|
135
|
+
it("triggers push with dictionaries and delete flag", async () => {
|
|
136
|
+
setProcessArgv([
|
|
137
|
+
"push",
|
|
138
|
+
"--dictionaries",
|
|
139
|
+
"id1",
|
|
140
|
+
"id2",
|
|
141
|
+
"--deleteLocaleDictionary"
|
|
142
|
+
]);
|
|
143
|
+
const { setAPI } = await import("./cli");
|
|
144
|
+
setAPI();
|
|
145
|
+
expect(pushMock).toHaveBeenCalledTimes(1);
|
|
146
|
+
const pushOptions = pushMock.mock.calls[0][0];
|
|
147
|
+
expect(pushOptions.dictionaries).toEqual(["id1", "id2"]);
|
|
148
|
+
expect(pushOptions.deleteLocaleDictionary).toBe(true);
|
|
149
|
+
});
|
|
150
|
+
it("triggers push with keep flag and git options", async () => {
|
|
151
|
+
setProcessArgv([
|
|
152
|
+
"push",
|
|
153
|
+
"--keepLocaleDictionary",
|
|
154
|
+
"--uncommitted",
|
|
155
|
+
"--git-diff-base",
|
|
156
|
+
"main"
|
|
157
|
+
]);
|
|
158
|
+
const { setAPI } = await import("./cli");
|
|
159
|
+
setAPI();
|
|
160
|
+
expect(pushMock).toHaveBeenCalledTimes(1);
|
|
161
|
+
const pushOptions = pushMock.mock.calls[0][0];
|
|
162
|
+
expect(pushOptions.keepLocaleDictionary).toBe(true);
|
|
163
|
+
expect(pushOptions.gitOptions).toEqual(
|
|
164
|
+
expect.objectContaining({
|
|
165
|
+
mode: ["uncommitted"],
|
|
166
|
+
baseRef: "main",
|
|
167
|
+
absolute: true
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
describe("pull command", () => {
|
|
173
|
+
it("triggers pull with specific dictionaries", async () => {
|
|
174
|
+
setProcessArgv(["pull", "--dictionaries", "dict1", "dict2"]);
|
|
175
|
+
const { setAPI } = await import("./cli");
|
|
176
|
+
setAPI();
|
|
177
|
+
expect(pullMock).toHaveBeenCalledTimes(1);
|
|
178
|
+
expect(pullMock).toHaveBeenCalledWith(
|
|
179
|
+
expect.objectContaining({
|
|
180
|
+
dictionaries: ["dict1", "dict2"]
|
|
181
|
+
})
|
|
182
|
+
);
|
|
183
|
+
});
|
|
184
|
+
it("triggers pull with custom path for new dictionaries", async () => {
|
|
185
|
+
setProcessArgv(["pull", "--newDictionariesPath", "/custom/dict/path"]);
|
|
186
|
+
const { setAPI } = await import("./cli");
|
|
187
|
+
setAPI();
|
|
188
|
+
expect(pullMock).toHaveBeenCalledTimes(1);
|
|
189
|
+
expect(pullMock).toHaveBeenCalledWith(
|
|
190
|
+
expect.objectContaining({
|
|
191
|
+
newDictionariesPath: "/custom/dict/path"
|
|
192
|
+
})
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
describe("config commands", () => {
|
|
197
|
+
it("triggers config get with environment options", async () => {
|
|
198
|
+
setProcessArgv(["config", "get", "--env-file", ".env.local"]);
|
|
199
|
+
const { setAPI } = await import("./cli");
|
|
200
|
+
setAPI();
|
|
201
|
+
expect(getConfigMock).toHaveBeenCalledTimes(1);
|
|
202
|
+
expect(getConfigMock).toHaveBeenCalledWith(
|
|
203
|
+
expect.objectContaining({
|
|
204
|
+
envFile: ".env.local",
|
|
205
|
+
configOptions: expect.objectContaining({
|
|
206
|
+
envFile: ".env.local"
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
it("triggers config push", async () => {
|
|
212
|
+
setProcessArgv(["config", "push"]);
|
|
213
|
+
const { setAPI } = await import("./cli");
|
|
214
|
+
setAPI();
|
|
215
|
+
expect(pushConfigMock).toHaveBeenCalledTimes(1);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
describe("fill command", () => {
|
|
219
|
+
it("triggers fill with complete mode and AI options", async () => {
|
|
220
|
+
setProcessArgv([
|
|
221
|
+
"fill",
|
|
222
|
+
"--mode",
|
|
223
|
+
"complete",
|
|
224
|
+
"--provider",
|
|
225
|
+
"openai",
|
|
226
|
+
"--model",
|
|
227
|
+
"gpt-4",
|
|
228
|
+
"--temperature",
|
|
229
|
+
"0.7"
|
|
230
|
+
]);
|
|
231
|
+
const { setAPI } = await import("./cli");
|
|
232
|
+
setAPI();
|
|
233
|
+
expect(fillMock).toHaveBeenCalledTimes(1);
|
|
234
|
+
expect(fillMock).toHaveBeenCalledWith(
|
|
235
|
+
expect.objectContaining({
|
|
236
|
+
mode: "complete",
|
|
237
|
+
provider: "openai",
|
|
238
|
+
model: "gpt-4",
|
|
239
|
+
temperature: "0.7",
|
|
240
|
+
aiOptions: expect.objectContaining({
|
|
241
|
+
provider: "openai",
|
|
242
|
+
model: "gpt-4",
|
|
243
|
+
temperature: "0.7"
|
|
244
|
+
})
|
|
245
|
+
})
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
it("triggers fill with file filters and locale options", async () => {
|
|
249
|
+
setProcessArgv([
|
|
250
|
+
"fill",
|
|
251
|
+
"--file",
|
|
252
|
+
"dict1.ts",
|
|
253
|
+
"dict2.ts",
|
|
254
|
+
"--source-locale",
|
|
255
|
+
"en",
|
|
256
|
+
"--output-locales",
|
|
257
|
+
"fr",
|
|
258
|
+
"es",
|
|
259
|
+
"--keys",
|
|
260
|
+
"button",
|
|
261
|
+
"title"
|
|
262
|
+
]);
|
|
263
|
+
const { setAPI } = await import("./cli");
|
|
264
|
+
setAPI();
|
|
265
|
+
expect(fillMock).toHaveBeenCalledTimes(1);
|
|
266
|
+
expect(fillMock).toHaveBeenCalledWith(
|
|
267
|
+
expect.objectContaining({
|
|
268
|
+
file: ["dict1.ts", "dict2.ts"],
|
|
269
|
+
sourceLocale: "en",
|
|
270
|
+
outputLocales: ["fr", "es"],
|
|
271
|
+
keys: ["button", "title"]
|
|
272
|
+
})
|
|
273
|
+
);
|
|
274
|
+
});
|
|
275
|
+
it("triggers fill with path filters and excluded keys", async () => {
|
|
276
|
+
setProcessArgv([
|
|
277
|
+
"fill",
|
|
278
|
+
"--path-filter",
|
|
279
|
+
"src/**/*.ts",
|
|
280
|
+
"--excluded-keys",
|
|
281
|
+
"debug",
|
|
282
|
+
"test"
|
|
283
|
+
]);
|
|
284
|
+
const { setAPI } = await import("./cli");
|
|
285
|
+
setAPI();
|
|
286
|
+
expect(fillMock).toHaveBeenCalledTimes(1);
|
|
287
|
+
expect(fillMock).toHaveBeenCalledWith(
|
|
288
|
+
expect.objectContaining({
|
|
289
|
+
pathFilter: ["src/**/*.ts"],
|
|
290
|
+
excludedKeys: ["debug", "test"]
|
|
291
|
+
})
|
|
292
|
+
);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
describe("doc commands", () => {
|
|
296
|
+
it("triggers doc translate with AI and locale options", async () => {
|
|
297
|
+
setProcessArgv([
|
|
298
|
+
"doc",
|
|
299
|
+
"translate",
|
|
300
|
+
"--doc-pattern",
|
|
301
|
+
"docs/**/*.md",
|
|
302
|
+
"--locales",
|
|
303
|
+
"fr",
|
|
304
|
+
"es",
|
|
305
|
+
"--base-locale",
|
|
306
|
+
"en",
|
|
307
|
+
"--api-key",
|
|
308
|
+
"test-key"
|
|
309
|
+
]);
|
|
310
|
+
const { setAPI } = await import("./cli");
|
|
311
|
+
setAPI();
|
|
312
|
+
expect(translateDocMock).toHaveBeenCalledTimes(1);
|
|
313
|
+
expect(translateDocMock).toHaveBeenCalledWith(
|
|
314
|
+
expect.objectContaining({
|
|
315
|
+
docPattern: ["docs/**/*.md"],
|
|
316
|
+
locales: ["fr", "es"],
|
|
317
|
+
baseLocale: "en",
|
|
318
|
+
aiOptions: expect.objectContaining({
|
|
319
|
+
apiKey: "test-key"
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
);
|
|
323
|
+
});
|
|
324
|
+
it("triggers doc review with excluded patterns and processing options", async () => {
|
|
325
|
+
setProcessArgv([
|
|
326
|
+
"doc",
|
|
327
|
+
"review",
|
|
328
|
+
"--excluded-glob-pattern",
|
|
329
|
+
"node_modules/**",
|
|
330
|
+
"--nb-simultaneous-file-processed",
|
|
331
|
+
"5",
|
|
332
|
+
"--custom-prompt",
|
|
333
|
+
"Review for clarity"
|
|
334
|
+
]);
|
|
335
|
+
const { setAPI } = await import("./cli");
|
|
336
|
+
setAPI();
|
|
337
|
+
expect(reviewDocMock).toHaveBeenCalledTimes(1);
|
|
338
|
+
expect(reviewDocMock).toHaveBeenCalledWith(
|
|
339
|
+
expect.objectContaining({
|
|
340
|
+
excludedGlobPattern: ["node_modules/**"],
|
|
341
|
+
nbSimultaneousFileProcessed: "5",
|
|
342
|
+
aiOptions: expect.objectContaining({
|
|
343
|
+
customPrompt: "Review for clarity"
|
|
344
|
+
})
|
|
345
|
+
})
|
|
346
|
+
);
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
describe("content list command", () => {
|
|
350
|
+
it("triggers content list", async () => {
|
|
351
|
+
setProcessArgv(["content", "list"]);
|
|
352
|
+
const { setAPI } = await import("./cli");
|
|
353
|
+
setAPI();
|
|
354
|
+
expect(listContentDeclarationMock).toHaveBeenCalledTimes(1);
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
describe("git options integration", () => {
|
|
358
|
+
it("correctly parses git diff options", async () => {
|
|
359
|
+
setProcessArgv([
|
|
360
|
+
"fill",
|
|
361
|
+
"--git-diff",
|
|
362
|
+
"--git-diff-base",
|
|
363
|
+
"origin/main",
|
|
364
|
+
"--git-diff-current",
|
|
365
|
+
"HEAD",
|
|
366
|
+
"--untracked"
|
|
367
|
+
]);
|
|
368
|
+
const { setAPI } = await import("./cli");
|
|
369
|
+
setAPI();
|
|
370
|
+
expect(fillMock).toHaveBeenCalledTimes(1);
|
|
371
|
+
expect(fillMock).toHaveBeenCalledWith(
|
|
372
|
+
expect.objectContaining({
|
|
373
|
+
gitOptions: expect.objectContaining({
|
|
374
|
+
mode: ["gitDiff", "untracked"],
|
|
375
|
+
baseRef: "origin/main",
|
|
376
|
+
currentRef: "HEAD",
|
|
377
|
+
absolute: true
|
|
378
|
+
})
|
|
379
|
+
})
|
|
380
|
+
);
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
describe("alias commands", () => {
|
|
384
|
+
it("supports dictionary alias for build", async () => {
|
|
385
|
+
setProcessArgv(["dictionary", "build", "--watch"]);
|
|
386
|
+
const { setAPI } = await import("./cli");
|
|
387
|
+
setAPI();
|
|
388
|
+
expect(buildMock).toHaveBeenCalledTimes(1);
|
|
389
|
+
expect(buildMock).toHaveBeenCalledWith(
|
|
390
|
+
expect.objectContaining({ watch: true })
|
|
391
|
+
);
|
|
392
|
+
});
|
|
393
|
+
it("supports dic alias for push", async () => {
|
|
394
|
+
setProcessArgv(["dic", "push", "--dictionaries", "test"]);
|
|
395
|
+
const { setAPI } = await import("./cli");
|
|
396
|
+
setAPI();
|
|
397
|
+
expect(pushMock).toHaveBeenCalledTimes(1);
|
|
398
|
+
expect(pushMock).toHaveBeenCalledWith(
|
|
399
|
+
expect.objectContaining({
|
|
400
|
+
dictionaries: ["test"]
|
|
401
|
+
})
|
|
402
|
+
);
|
|
403
|
+
});
|
|
404
|
+
it("supports conf alias for config get", async () => {
|
|
405
|
+
setProcessArgv(["conf", "get"]);
|
|
406
|
+
const { setAPI } = await import("./cli");
|
|
407
|
+
setAPI();
|
|
408
|
+
expect(getConfigMock).toHaveBeenCalledTimes(1);
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
//# sourceMappingURL=cli.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli.test.ts"],"sourcesContent":["import { TextDecoder, TextEncoder } from 'util';\nimport { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';\n\n// Polyfill TextEncoder/TextDecoder for Node versions < 19\nif (!(globalThis as any).TextEncoder) {\n (globalThis as any).TextEncoder = TextEncoder;\n}\nif (!(globalThis as any).TextDecoder) {\n (globalThis as any).TextDecoder = TextDecoder;\n}\n\n// Keep references to the original argv so we can restore it after each test\nconst ORIGINAL_ARGV = [...process.argv];\n\n// Helper to reset process.argv for each test\nconst setProcessArgv = (args: string[]) => {\n process.argv = ['node', 'intlayer', ...args];\n};\n\n// Dynamic mock placeholders\nlet buildMock: ReturnType<typeof vi.fn>;\nlet pushMock: ReturnType<typeof vi.fn>;\nlet pullMock: ReturnType<typeof vi.fn>;\nlet fillMock: ReturnType<typeof vi.fn>;\nlet getConfigMock: ReturnType<typeof vi.fn>;\nlet pushConfigMock: ReturnType<typeof vi.fn>;\nlet listContentDeclarationMock: ReturnType<typeof vi.fn>;\nlet translateDocMock: ReturnType<typeof vi.fn>;\nlet reviewDocMock: ReturnType<typeof vi.fn>;\n\n// Hoisted mocks – evaluated before the tested module is imported\nvi.mock('./build', () => ({\n build: (...args: any[]) => buildMock(...args),\n}));\n\nvi.mock('./push', () => ({\n push: (...args: any[]) => pushMock(...args),\n}));\n\nvi.mock('./pull', () => ({\n pull: (...args: any[]) => pullMock(...args),\n}));\n\nvi.mock('./fill', () => ({\n fill: (...args: any[]) => fillMock(...args),\n}));\n\nvi.mock('./config', () => ({\n getConfig: (...args: any[]) => getConfigMock(...args),\n}));\n\nvi.mock('./pushConfig', () => ({\n pushConfig: (...args: any[]) => pushConfigMock(...args),\n}));\n\nvi.mock('./listContentDeclaration', () => ({\n listContentDeclaration: (...args: any[]) =>\n listContentDeclarationMock(...args),\n}));\n\nvi.mock('./translateDoc', () => ({\n translateDoc: (...args: any[]) => translateDocMock(...args),\n}));\n\nvi.mock('./reviewDoc', () => ({\n reviewDoc: (...args: any[]) => reviewDocMock(...args),\n}));\n\n// Mock getParentPackageJSON utility\nvi.mock('./utils/getParentPackageJSON', () => ({\n getParentPackageJSON: vi.fn(() => ({\n name: '@intlayer/cli',\n version: '1.0.0',\n description: 'Intlayer CLI',\n })),\n}));\n\n// Mock configuration import that the CLI relies on for defaults\nvi.mock('@intlayer/config/built', () => ({\n __esModule: true,\n default: {},\n}));\n\nvi.mock('@intlayer/config', () => ({\n __esModule: true,\n isESModule: false,\n}));\n\ndescribe('Intlayer CLI', () => {\n beforeEach(() => {\n // Reset module cache to load a fresh CLI instance for each test\n vi.resetModules();\n\n // Re-initialise mocks for each test run\n buildMock = vi.fn();\n pushMock = vi.fn();\n pullMock = vi.fn();\n fillMock = vi.fn();\n getConfigMock = vi.fn();\n pushConfigMock = vi.fn();\n listContentDeclarationMock = vi.fn();\n translateDocMock = vi.fn();\n reviewDocMock = vi.fn();\n });\n\n afterEach(() => {\n // Restore the original process arguments after each test\n process.argv = [...ORIGINAL_ARGV];\n vi.clearAllMocks();\n });\n\n describe('build command', () => {\n it('triggers build with the --watch flag', async () => {\n setProcessArgv(['build', '--watch']);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(buildMock).toHaveBeenCalledTimes(1);\n expect(buildMock).toHaveBeenCalledWith(\n expect.objectContaining({ watch: true })\n );\n });\n\n it('triggers build with verbose and custom prefix', async () => {\n setProcessArgv(['build', '--verbose', '--prefix', 'TEST']);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(buildMock).toHaveBeenCalledTimes(1);\n expect(buildMock).toHaveBeenCalledWith(\n expect.objectContaining({\n verbose: true,\n prefix: 'TEST',\n configOptions: expect.objectContaining({\n override: expect.objectContaining({\n log: expect.objectContaining({\n verbose: true,\n prefix: 'TEST',\n }),\n }),\n }),\n })\n );\n });\n\n it('triggers build with environment and base directory options', async () => {\n setProcessArgv([\n 'build',\n '--env',\n 'production',\n '--base-dir',\n '/custom/path',\n ]);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(buildMock).toHaveBeenCalledTimes(1);\n expect(buildMock).toHaveBeenCalledWith(\n expect.objectContaining({\n env: 'production',\n baseDir: '/custom/path',\n configOptions: expect.objectContaining({\n env: 'production',\n baseDir: '/custom/path',\n }),\n })\n );\n });\n });\n\n describe('push command', () => {\n it('triggers push with dictionaries and delete flag', async () => {\n setProcessArgv([\n 'push',\n '--dictionaries',\n 'id1',\n 'id2',\n '--deleteLocaleDictionary',\n ]);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(pushMock).toHaveBeenCalledTimes(1);\n\n const pushOptions = pushMock.mock.calls[0][0] as Record<string, unknown>;\n expect(pushOptions.dictionaries).toEqual(['id1', 'id2']);\n expect(pushOptions.deleteLocaleDictionary).toBe(true);\n });\n\n it('triggers push with keep flag and git options', async () => {\n setProcessArgv([\n 'push',\n '--keepLocaleDictionary',\n '--uncommitted',\n '--git-diff-base',\n 'main',\n ]);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(pushMock).toHaveBeenCalledTimes(1);\n\n const pushOptions = pushMock.mock.calls[0][0] as Record<string, unknown>;\n expect(pushOptions.keepLocaleDictionary).toBe(true);\n expect(pushOptions.gitOptions).toEqual(\n expect.objectContaining({\n mode: ['uncommitted'],\n baseRef: 'main',\n absolute: true,\n })\n );\n });\n });\n\n describe('pull command', () => {\n it('triggers pull with specific dictionaries', async () => {\n setProcessArgv(['pull', '--dictionaries', 'dict1', 'dict2']);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(pullMock).toHaveBeenCalledTimes(1);\n expect(pullMock).toHaveBeenCalledWith(\n expect.objectContaining({\n dictionaries: ['dict1', 'dict2'],\n })\n );\n });\n\n it('triggers pull with custom path for new dictionaries', async () => {\n setProcessArgv(['pull', '--newDictionariesPath', '/custom/dict/path']);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(pullMock).toHaveBeenCalledTimes(1);\n expect(pullMock).toHaveBeenCalledWith(\n expect.objectContaining({\n newDictionariesPath: '/custom/dict/path',\n })\n );\n });\n });\n\n describe('config commands', () => {\n it('triggers config get with environment options', async () => {\n setProcessArgv(['config', 'get', '--env-file', '.env.local']);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(getConfigMock).toHaveBeenCalledTimes(1);\n expect(getConfigMock).toHaveBeenCalledWith(\n expect.objectContaining({\n envFile: '.env.local',\n configOptions: expect.objectContaining({\n envFile: '.env.local',\n }),\n })\n );\n });\n\n it('triggers config push', async () => {\n setProcessArgv(['config', 'push']);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(pushConfigMock).toHaveBeenCalledTimes(1);\n });\n });\n\n describe('fill command', () => {\n it('triggers fill with complete mode and AI options', async () => {\n setProcessArgv([\n 'fill',\n '--mode',\n 'complete',\n '--provider',\n 'openai',\n '--model',\n 'gpt-4',\n '--temperature',\n '0.7',\n ]);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(fillMock).toHaveBeenCalledTimes(1);\n expect(fillMock).toHaveBeenCalledWith(\n expect.objectContaining({\n mode: 'complete',\n provider: 'openai',\n model: 'gpt-4',\n temperature: '0.7',\n aiOptions: expect.objectContaining({\n provider: 'openai',\n model: 'gpt-4',\n temperature: '0.7',\n }),\n })\n );\n });\n\n it('triggers fill with file filters and locale options', async () => {\n setProcessArgv([\n 'fill',\n '--file',\n 'dict1.ts',\n 'dict2.ts',\n '--source-locale',\n 'en',\n '--output-locales',\n 'fr',\n 'es',\n '--keys',\n 'button',\n 'title',\n ]);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(fillMock).toHaveBeenCalledTimes(1);\n expect(fillMock).toHaveBeenCalledWith(\n expect.objectContaining({\n file: ['dict1.ts', 'dict2.ts'],\n sourceLocale: 'en',\n outputLocales: ['fr', 'es'],\n keys: ['button', 'title'],\n })\n );\n });\n\n it('triggers fill with path filters and excluded keys', async () => {\n setProcessArgv([\n 'fill',\n '--path-filter',\n 'src/**/*.ts',\n '--excluded-keys',\n 'debug',\n 'test',\n ]);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(fillMock).toHaveBeenCalledTimes(1);\n expect(fillMock).toHaveBeenCalledWith(\n expect.objectContaining({\n pathFilter: ['src/**/*.ts'],\n excludedKeys: ['debug', 'test'],\n })\n );\n });\n });\n\n describe('doc commands', () => {\n it('triggers doc translate with AI and locale options', async () => {\n setProcessArgv([\n 'doc',\n 'translate',\n '--doc-pattern',\n 'docs/**/*.md',\n '--locales',\n 'fr',\n 'es',\n '--base-locale',\n 'en',\n '--api-key',\n 'test-key',\n ]);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(translateDocMock).toHaveBeenCalledTimes(1);\n expect(translateDocMock).toHaveBeenCalledWith(\n expect.objectContaining({\n docPattern: ['docs/**/*.md'],\n locales: ['fr', 'es'],\n baseLocale: 'en',\n aiOptions: expect.objectContaining({\n apiKey: 'test-key',\n }),\n })\n );\n });\n\n it('triggers doc review with excluded patterns and processing options', async () => {\n setProcessArgv([\n 'doc',\n 'review',\n '--excluded-glob-pattern',\n 'node_modules/**',\n '--nb-simultaneous-file-processed',\n '5',\n '--custom-prompt',\n 'Review for clarity',\n ]);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(reviewDocMock).toHaveBeenCalledTimes(1);\n expect(reviewDocMock).toHaveBeenCalledWith(\n expect.objectContaining({\n excludedGlobPattern: ['node_modules/**'],\n nbSimultaneousFileProcessed: '5',\n aiOptions: expect.objectContaining({\n customPrompt: 'Review for clarity',\n }),\n })\n );\n });\n });\n\n describe('content list command', () => {\n it('triggers content list', async () => {\n setProcessArgv(['content', 'list']);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(listContentDeclarationMock).toHaveBeenCalledTimes(1);\n });\n });\n\n describe('git options integration', () => {\n it('correctly parses git diff options', async () => {\n setProcessArgv([\n 'fill',\n '--git-diff',\n '--git-diff-base',\n 'origin/main',\n '--git-diff-current',\n 'HEAD',\n '--untracked',\n ]);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(fillMock).toHaveBeenCalledTimes(1);\n expect(fillMock).toHaveBeenCalledWith(\n expect.objectContaining({\n gitOptions: expect.objectContaining({\n mode: ['gitDiff', 'untracked'],\n baseRef: 'origin/main',\n currentRef: 'HEAD',\n absolute: true,\n }),\n })\n );\n });\n });\n\n describe('alias commands', () => {\n it('supports dictionary alias for build', async () => {\n setProcessArgv(['dictionary', 'build', '--watch']);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(buildMock).toHaveBeenCalledTimes(1);\n expect(buildMock).toHaveBeenCalledWith(\n expect.objectContaining({ watch: true })\n );\n });\n\n it('supports dic alias for push', async () => {\n setProcessArgv(['dic', 'push', '--dictionaries', 'test']);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(pushMock).toHaveBeenCalledTimes(1);\n expect(pushMock).toHaveBeenCalledWith(\n expect.objectContaining({\n dictionaries: ['test'],\n })\n );\n });\n\n it('supports conf alias for config get', async () => {\n setProcessArgv(['conf', 'get']);\n\n const { setAPI } = await import('./cli');\n setAPI();\n\n expect(getConfigMock).toHaveBeenCalledTimes(1);\n });\n });\n});\n"],"mappings":"AAAA,SAAS,aAAa,mBAAmB;AACzC,SAAS,WAAW,YAAY,UAAU,QAAQ,IAAI,UAAU;AAGhE,IAAI,CAAE,WAAmB,aAAa;AACpC,EAAC,WAAmB,cAAc;AACpC;AACA,IAAI,CAAE,WAAmB,aAAa;AACpC,EAAC,WAAmB,cAAc;AACpC;AAGA,MAAM,gBAAgB,CAAC,GAAG,QAAQ,IAA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AAA,MACzC;AAAA,IACF,CAAC;AAED,OAAG,+BAA+B,YAAY;AAC5C,qBAAe,CAAC,OAAO,QAAQ,kBAAkB,MAAM,CAAC;AAExD,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,OAAO;AACvC,aAAO;AAEP,aAAO,QAAQ,EAAE,sBAAsB,CAAC;AACxC,aAAO,QAAQ,EAAE;AAAA,QACf,OAAO,iBAAiB;AAAA,UACtB,cAAc,CAAC,MAAM;AAAA,QACvB,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,OAAG,sCAAsC,YAAY;AACnD,qBAAe,CAAC,QAAQ,KAAK,CAAC;AAE9B,YAAM,EAAE,OAAO,IAAI,MAAM,OAAO,OAAO;AACvC,aAAO;AAEP,aAAO,aAAa,EAAE,sBAAsB,CAAC;AAAA,IAC/C,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
|
package/dist/esm/fill.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import dictionariesRecord from "@intlayer/dictionaries-entry";
|
|
18
18
|
import unmergedDictionariesRecord from "@intlayer/unmerged-dictionaries-entry";
|
|
19
19
|
import { dirname, extname, join } from "path";
|
|
20
|
+
import { checkAIAccess } from "./utils/checkAIAccess.mjs";
|
|
20
21
|
const ensureArray = (value) => [value].flat();
|
|
21
22
|
const getTargetDictionary = async (options) => {
|
|
22
23
|
const configuration = getConfiguration(options.configOptions);
|
|
@@ -193,14 +194,7 @@ const fill = async (options) => {
|
|
|
193
194
|
const { defaultLocale, locales } = configuration.internationalization;
|
|
194
195
|
const mode = options.mode ?? "review";
|
|
195
196
|
const baseLocale = options.sourceLocale ?? defaultLocale;
|
|
196
|
-
|
|
197
|
-
appLogger("AI options or API key not provided. Skipping AI translation.", {
|
|
198
|
-
level: "error"
|
|
199
|
-
});
|
|
200
|
-
throw new Error(
|
|
201
|
-
"AI options or API key not provided. Skipping AI translation."
|
|
202
|
-
);
|
|
203
|
-
}
|
|
197
|
+
checkAIAccess(configuration, options.aiOptions);
|
|
204
198
|
let oAuth2AccessToken;
|
|
205
199
|
if (configuration.editor.clientId) {
|
|
206
200
|
const intlayerAuthAPI = getAuthAPI(void 0, configuration);
|
|
@@ -293,11 +287,13 @@ const fill = async (options) => {
|
|
|
293
287
|
mode,
|
|
294
288
|
aiOptions: options.aiOptions
|
|
295
289
|
},
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
290
|
+
{
|
|
291
|
+
...oAuth2AccessToken && {
|
|
292
|
+
headers: {
|
|
293
|
+
Authorization: `Bearer ${oAuth2AccessToken}`
|
|
294
|
+
}
|
|
299
295
|
}
|
|
300
|
-
}
|
|
296
|
+
}
|
|
301
297
|
);
|
|
302
298
|
if (!translationResult.data?.fileContent) {
|
|
303
299
|
appLogger(
|
package/dist/esm/fill.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/fill.ts"],"sourcesContent":["import { AIOptions, getAiAPI, getAuthAPI } from '@intlayer/api'; // Importing only getAiAPI for now\nimport {\n getFilteredLocalesContent,\n listGitFiles,\n ListGitFilesOptions,\n mergeDictionaries,\n processPerLocaleDictionary,\n reduceDictionaryContent,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport {\n getAppLogger,\n getConfiguration,\n GetConfigurationOptions,\n type IntlayerConfig,\n Locales,\n} from '@intlayer/config';\nimport {\n type AutoFill,\n type ContentNode,\n type Dictionary,\n getLocalisedContent,\n} from '@intlayer/core';\nimport dictionariesRecord from '@intlayer/dictionaries-entry';\nimport unmergedDictionariesRecord from '@intlayer/unmerged-dictionaries-entry';\nimport { dirname, extname, join } from 'path';\n\n// Arguments for the fill function\nexport type FillOptions = {\n sourceLocale?: Locales;\n outputLocales?: Locales | Locales[];\n file?: string | string[];\n mode?: 'complete' | 'review';\n keys?: string | string[];\n excludedKeys?: string | string[];\n filter?: (entry: Dictionary) => boolean; // DictionaryEntry needs to be defined\n pathFilter?: string | string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n aiOptions?: AIOptions; // Added aiOptions to be passed to translateJSON\n verbose?: boolean;\n};\n\nconst ensureArray = <T>(value: T | T[]): T[] => [value].flat() as T[];\n\nconst getTargetDictionary = async (options: FillOptions) => {\n const configuration = getConfiguration(options.configOptions);\n\n const { baseDir } = configuration.content;\n\n let result = Object.values(unmergedDictionariesRecord).flat();\n\n // 1. if filePath not defined, list all content declaration files based on unmerged dictionaries list\n if (typeof options.file !== 'undefined') {\n const fileArray = ensureArray(options.file);\n const absoluteFilePaths = fileArray.map((file) => join(baseDir, file));\n\n result = result.filter(\n (dict) =>\n dict.filePath &&\n (absoluteFilePaths.includes(dict.filePath) ||\n absoluteFilePaths.includes(join(baseDir, dict.filePath)))\n );\n }\n\n if (typeof options.keys !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options.keys)?.includes(dict.key)\n );\n }\n\n if (typeof options.excludedKeys !== 'undefined') {\n result = result.filter(\n (dict) => !ensureArray(options.excludedKeys)?.includes(dict.key)\n );\n }\n\n if (typeof options.pathFilter !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options.pathFilter)?.includes(dict.filePath ?? '')\n );\n }\n\n if (typeof options.filter !== 'undefined') {\n result = result.filter(options.filter);\n }\n\n const gitOptions = options.gitOptions;\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n result = result.filter((dict) => {\n if (!dict.filePath) return false;\n\n return gitChangedFiles.some((gitFile) => dict.filePath === gitFile);\n });\n }\n }\n\n return result.filter((dict) => !dict.autoFilled);\n};\n\nconst transformUriToAbsolutePath = (\n uri: string,\n filePath: string,\n baseDir: string\n) => {\n if (uri.startsWith('/')) {\n return join(baseDir, uri);\n }\n\n if (uri.startsWith('./')) {\n return join(dirname(filePath), uri);\n }\n\n return filePath;\n};\n\nexport type AutoFillData = {\n localeList: Locales[];\n filePath: string;\n};\n\nconst formatAutoFillData = (\n autoFillOptions: AutoFill,\n localeList: Locales[],\n filePath: string,\n dictionaryKey: string,\n configuration: IntlayerConfig\n): AutoFillData[] => {\n const outputContentDeclarationFile: AutoFillData[] = [];\n\n if (!Boolean(autoFillOptions)) return outputContentDeclarationFile;\n\n if (autoFillOptions === true) {\n // wanted jsonFilePath: /..../src/components/home/index.content.json\n // replace file extension in json\n let jsonFilePath = filePath.replace(extname(filePath), '.json');\n\n // if both filePath jsonFilePath are same path, change it as : /..../src/components/home/index.fill.content.json\n if (filePath === jsonFilePath) {\n jsonFilePath = jsonFilePath.replace(extname(jsonFilePath), '.fill.json');\n }\n\n outputContentDeclarationFile.push({\n localeList,\n filePath: jsonFilePath,\n });\n }\n\n if (typeof autoFillOptions === 'string') {\n if (autoFillOptions.includes('{{locale}}')) {\n const output = localeList.map((locale) => ({\n localeList: [locale],\n filePath: transformUriToAbsolutePath(\n autoFillOptions\n .replace('{{locale}}', locale)\n .replace('{{key}}', dictionaryKey),\n filePath,\n configuration.content.baseDir\n ),\n }));\n\n outputContentDeclarationFile.push(...output);\n } else {\n outputContentDeclarationFile.push({\n localeList,\n filePath: transformUriToAbsolutePath(\n autoFillOptions,\n filePath,\n configuration.content.baseDir\n ),\n });\n }\n\n return outputContentDeclarationFile;\n }\n\n if (typeof autoFillOptions === 'object') {\n const localeList = Object.keys(autoFillOptions).filter(\n (locale) => typeof autoFillOptions[locale] === 'string'\n ) as Locales[];\n\n const output: AutoFillData[] = localeList.map((locale) => ({\n localeList: [locale],\n filePath: transformUriToAbsolutePath(\n autoFillOptions[locale].replace('{{key}}', dictionaryKey),\n filePath,\n configuration.content.baseDir\n ),\n }));\n\n // Group by filePath and merge localeList\n const groupedByFilePath = output.reduce((acc, curr) => {\n const existing = acc.find((item) => item.filePath === curr.filePath);\n if (existing) {\n existing.localeList.push(...curr.localeList);\n } else {\n acc.push(curr);\n }\n return acc;\n }, [] as AutoFillData[]);\n\n outputContentDeclarationFile.push(...groupedByFilePath);\n }\n\n return outputContentDeclarationFile;\n};\n\nconst autoFill = async (\n fullDictionary: Dictionary,\n contentDeclarationFile: Dictionary,\n autoFillOptions: AutoFill,\n outputLocales: Locales[],\n parentLocales: Locales[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n let localeList: Locales[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n const filePath = contentDeclarationFile.filePath;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const autoFillData: AutoFillData[] = formatAutoFillData(\n autoFillOptions,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n appLogger(`Auto fill data: ${JSON.stringify(autoFillData, null, 2)}`, {\n level: 'info',\n isVerbose: true,\n });\n\n for await (const output of autoFillData) {\n const reducedDictionary = reduceDictionaryContent(\n fullDictionary,\n contentDeclarationFile\n );\n\n const isPerLocaleDeclarationFile = output.localeList.length === 1;\n\n if (isPerLocaleDeclarationFile) {\n const sourceLocale = output.localeList[0];\n\n const sourceLocaleContent = getLocalisedContent(\n reducedDictionary as unknown as ContentNode,\n sourceLocale,\n { dictionaryKey: reducedDictionary.key, keyPath: [] }\n );\n\n await writeContentDeclaration({\n ...fullDictionary,\n locale: sourceLocale,\n autoFilled: true,\n autoFill: undefined,\n content: sourceLocaleContent.content,\n filePath: output.filePath,\n });\n } else {\n const content = getFilteredLocalesContent(\n reducedDictionary.content as unknown as ContentNode,\n output.localeList,\n { dictionaryKey: reducedDictionary.key, keyPath: [] }\n );\n\n // write file\n await writeContentDeclaration({\n ...fullDictionary,\n autoFilled: true,\n autoFill: undefined,\n content,\n filePath: output.filePath,\n });\n }\n }\n};\n\n/**\n * Fill translations based on the provided options.\n */\nexport const fill = async (options: FillOptions): Promise<void> => {\n const configuration = getConfiguration(options.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const { defaultLocale, locales } = configuration.internationalization;\n const mode = options.mode ?? 'review';\n const baseLocale = options.sourceLocale ?? defaultLocale;\n\n if (!configuration.editor.clientId && !options.aiOptions?.apiKey) {\n appLogger('AI options or API key not provided. Skipping AI translation.', {\n level: 'error',\n });\n // Potentially handle this case differently, e.g., by using a different translation method or stopping.\n\n throw new Error(\n 'AI options or API key not provided. Skipping AI translation.'\n );\n }\n\n let oAuth2AccessToken: string | undefined;\n if (configuration.editor.clientId) {\n const intlayerAuthAPI = getAuthAPI(undefined, configuration);\n const oAuth2TokenResult = await intlayerAuthAPI.getOAuth2AccessToken();\n\n oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n }\n\n appLogger('Starting fill function', {\n level: 'info',\n });\n\n const targetUnmergedDictionaries = await getTargetDictionary(options);\n\n // Determine output locales\n const outputLocalesList: Locales[] = (\n options.outputLocales ? ensureArray(options.outputLocales) : locales\n ).filter((locale) =>\n // If mode is review, translate all locales\n // If mode is complete, translate only the locales that are not the source locale\n mode === 'review' ? true : locale !== baseLocale\n );\n\n const affectedDictionaryKeys = new Set<string>();\n targetUnmergedDictionaries.forEach((dict) => {\n affectedDictionaryKeys.add(dict.key);\n });\n\n appLogger(\n [\n 'Affected dictionary keys for processing:',\n Array.from(affectedDictionaryKeys).join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n\n for (const targetUnmergedDictionary of targetUnmergedDictionaries) {\n const dictionaryKey = targetUnmergedDictionary.key;\n const mainDictionaryToProcess = dictionariesRecord[dictionaryKey];\n const sourceLocale: Locales =\n (targetUnmergedDictionary.locale as Locales) ?? baseLocale;\n\n if (!mainDictionaryToProcess) {\n appLogger(\n `Dictionary with key \"${dictionaryKey}\" not found in dictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n appLogger(\n `Processing content declaration: ${targetUnmergedDictionary.filePath}`,\n {\n isVerbose: true,\n }\n );\n\n const sourceLocaleContent = getLocalisedContent(\n mainDictionaryToProcess as unknown as ContentNode,\n sourceLocale,\n { dictionaryKey, keyPath: [] }\n );\n\n if (Object.keys(sourceLocaleContent).length === 0) {\n appLogger(\n `No content found for dictionary ${dictionaryKey} in source locale ${sourceLocale}. Skipping translation for this dictionary.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n const result: Dictionary[] = [];\n\n // 5. for each locale to translate (exclude base locale) generate json translations\n for await (const targetLocale of outputLocalesList) {\n appLogger(\n `Preparing translation for ${dictionaryKey} from ${sourceLocale} to ${targetLocale}`,\n {\n isVerbose: true,\n }\n );\n\n const presetOutputContent = getLocalisedContent(\n mainDictionaryToProcess as unknown as ContentNode,\n targetLocale,\n { dictionaryKey, keyPath: [] }\n );\n\n try {\n const translationResult = await getAiAPI(\n undefined,\n configuration\n ).translateJSON(\n {\n entryFileContent: sourceLocaleContent.content, // Should be JSON, ensure getLocalisedContent provides this.\n presetOutputContent: presetOutputContent.content, // Should be JSON\n dictionaryDescription: mainDictionaryToProcess.description,\n entryLocale: sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiOptions: options.aiOptions,\n },\n oAuth2AccessToken\n ? {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }\n : undefined\n );\n\n if (!translationResult.data?.fileContent) {\n appLogger(\n `No content result found for ${dictionaryKey} to ${targetLocale}`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n const processedPerLocaleDictionary = processPerLocaleDictionary({\n ...mainDictionaryToProcess,\n content: translationResult.data?.fileContent,\n locale: targetLocale,\n });\n\n result.push(processedPerLocaleDictionary);\n } catch (error) {\n appLogger(\n `Error filling ${dictionaryKey} to ${targetLocale}:` + error,\n {\n level: 'error',\n }\n );\n }\n }\n\n const dictionaryToMerge =\n mode === 'review'\n ? [...result, mainDictionaryToProcess] // Mode review: generated content will override the base one\n : [mainDictionaryToProcess, ...result]; // Mode complete: base content will override the generated one\n\n const mergedResults = mergeDictionaries(dictionaryToMerge);\n\n let formattedDict = targetUnmergedDictionary;\n\n if (formattedDict.locale) {\n const presetOutputContent = getLocalisedContent(\n mainDictionaryToProcess as unknown as ContentNode,\n formattedDict.locale,\n { dictionaryKey, keyPath: [] }\n );\n formattedDict = {\n ...formattedDict,\n content: presetOutputContent.content,\n };\n }\n\n const reducedResult = reduceDictionaryContent(mergedResults, formattedDict);\n\n await writeContentDeclaration(\n { ...formattedDict, content: reducedResult.content },\n configuration,\n formattedDict.filePath\n );\n\n await autoFill(\n mergedResults,\n targetUnmergedDictionary,\n formattedDict.autoFill,\n outputLocalesList,\n [sourceLocale],\n configuration\n );\n }\n};\n"],"mappings":"AAAA,SAAoB,UAAU,kBAAkB;AAChD;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EAIE;AAAA,OACK;AACP,OAAO,wBAAwB;AAC/B,OAAO,gCAAgC;AACvC,SAAS,SAAS,SAAS,YAAY;AAkBvC,MAAM,cAAc,CAAI,UAAwB,CAAC,KAAK,EAAE,KAAK;AAE7D,MAAM,sBAAsB,OAAO,YAAyB;AAC1D,QAAM,gBAAgB,iBAAiB,QAAQ,aAAa;AAE5D,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,SAAS,OAAO,OAAO,0BAA0B,EAAE,KAAK;AAG5D,MAAI,OAAO,QAAQ,SAAS,aAAa;AACvC,UAAM,YAAY,YAAY,QAAQ,IAAI;AAC1C,UAAM,oBAAoB,UAAU,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC;AAErE,aAAS,OAAO;AAAA,MACd,CAAC,SACC,KAAK,aACJ,kBAAkB,SAAS,KAAK,QAAQ,KACvC,kBAAkB,SAAS,KAAK,SAAS,KAAK,QAAQ,CAAC;AAAA,IAC7D;AAAA,EACF;AAEA,MAAI,OAAO,QAAQ,SAAS,aAAa;AACvC,aAAS,OAAO;AAAA,MAAO,CAAC,SACtB,YAAY,QAAQ,IAAI,GAAG,SAAS,KAAK,GAAG;AAAA,IAC9C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AY;AAAA,YAC/D;AAAA,cACE,OAAO;AAAA,YACT;AAAA,UACF;AACA;AAAA,QACF;AAEA,cAAM,+BAA+B,2BAA2B;AAAA,UAC9D,GAAG;AAAA,UACH,SAAS,kBAAkB,MAAM;AAAA,UACjC,QAAQ;AAAA,QACV,CAAC;AAED,eAAO,KAAK,4BAA4B;AAAA,MAC1C,SAAS,OAAO;AACd;AAAA,UACE,iBAAiB,aAAa,OAAO,YAAY,MAAM;AAAA,UACvD;AAAA,YACE,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,UAAM,oBACJ,SAAS,WACL,CAAC,GAAG,QAAQ,uBAAuB,IACnC,CAAC,yBAAyB,GAAG,MAAM;AAEzC,UAAM,gBAAgB,kBAAkB,iBAAiB;AAEzD,QAAI,gBAAgB;AAEpB,QAAI,cAAc,QAAQ;AACxB,YAAM,sBAAsB;AAAA,QAC1B;AAAA,QACA,cAAc;AAAA,QACd,EAAE,eAAe,SAAS,CAAC,EAAE;AAAA,MAC/B;AACA,sBAAgB;AAAA,QACd,GAAG;AAAA,QACH,SAAS,oBAAoB;AAAA,MAC/B;AAAA,IACF;AAEA,UAAM,gBAAgB,wBAAwB,eAAe,aAAa;AAE1E,UAAM;AAAA,MACJ,EAAE,GAAG,eAAe,SAAS,cAAc,QAAQ;AAAA,MACnD;AAAA,MACA,cAAc;AAAA,IAChB;AAEA,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA,CAAC,YAAY;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;","names":["localeList"]}
|
|
1
|
+
{"version":3,"sources":["../../src/fill.ts"],"sourcesContent":["import { AIOptions, getAiAPI, getAuthAPI } from '@intlayer/api'; // Importing only getAiAPI for now\nimport {\n getFilteredLocalesContent,\n listGitFiles,\n ListGitFilesOptions,\n mergeDictionaries,\n processPerLocaleDictionary,\n reduceDictionaryContent,\n writeContentDeclaration,\n} from '@intlayer/chokidar';\nimport {\n getAppLogger,\n getConfiguration,\n GetConfigurationOptions,\n type IntlayerConfig,\n Locales,\n} from '@intlayer/config';\nimport {\n type AutoFill,\n type ContentNode,\n type Dictionary,\n getLocalisedContent,\n} from '@intlayer/core';\nimport dictionariesRecord from '@intlayer/dictionaries-entry';\nimport unmergedDictionariesRecord from '@intlayer/unmerged-dictionaries-entry';\nimport { dirname, extname, join } from 'path';\nimport { checkAIAccess } from './utils/checkAIAccess';\n\n// Arguments for the fill function\nexport type FillOptions = {\n sourceLocale?: Locales;\n outputLocales?: Locales | Locales[];\n file?: string | string[];\n mode?: 'complete' | 'review';\n keys?: string | string[];\n excludedKeys?: string | string[];\n filter?: (entry: Dictionary) => boolean; // DictionaryEntry needs to be defined\n pathFilter?: string | string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n aiOptions?: AIOptions; // Added aiOptions to be passed to translateJSON\n verbose?: boolean;\n};\n\nconst ensureArray = <T>(value: T | T[]): T[] => [value].flat() as T[];\n\nconst getTargetDictionary = async (options: FillOptions) => {\n const configuration = getConfiguration(options.configOptions);\n\n const { baseDir } = configuration.content;\n\n let result = Object.values(unmergedDictionariesRecord).flat();\n\n // 1. if filePath not defined, list all content declaration files based on unmerged dictionaries list\n if (typeof options.file !== 'undefined') {\n const fileArray = ensureArray(options.file);\n const absoluteFilePaths = fileArray.map((file) => join(baseDir, file));\n\n result = result.filter(\n (dict) =>\n dict.filePath &&\n (absoluteFilePaths.includes(dict.filePath) ||\n absoluteFilePaths.includes(join(baseDir, dict.filePath)))\n );\n }\n\n if (typeof options.keys !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options.keys)?.includes(dict.key)\n );\n }\n\n if (typeof options.excludedKeys !== 'undefined') {\n result = result.filter(\n (dict) => !ensureArray(options.excludedKeys)?.includes(dict.key)\n );\n }\n\n if (typeof options.pathFilter !== 'undefined') {\n result = result.filter((dict) =>\n ensureArray(options.pathFilter)?.includes(dict.filePath ?? '')\n );\n }\n\n if (typeof options.filter !== 'undefined') {\n result = result.filter(options.filter);\n }\n\n const gitOptions = options.gitOptions;\n if (gitOptions) {\n const gitChangedFiles = await listGitFiles(gitOptions);\n\n if (gitChangedFiles) {\n // Convert dictionary file paths to be relative to git root for comparison\n\n // Filter dictionaries based on git changed files\n result = result.filter((dict) => {\n if (!dict.filePath) return false;\n\n return gitChangedFiles.some((gitFile) => dict.filePath === gitFile);\n });\n }\n }\n\n return result.filter((dict) => !dict.autoFilled);\n};\n\nconst transformUriToAbsolutePath = (\n uri: string,\n filePath: string,\n baseDir: string\n) => {\n if (uri.startsWith('/')) {\n return join(baseDir, uri);\n }\n\n if (uri.startsWith('./')) {\n return join(dirname(filePath), uri);\n }\n\n return filePath;\n};\n\nexport type AutoFillData = {\n localeList: Locales[];\n filePath: string;\n};\n\nconst formatAutoFillData = (\n autoFillOptions: AutoFill,\n localeList: Locales[],\n filePath: string,\n dictionaryKey: string,\n configuration: IntlayerConfig\n): AutoFillData[] => {\n const outputContentDeclarationFile: AutoFillData[] = [];\n\n if (!Boolean(autoFillOptions)) return outputContentDeclarationFile;\n\n if (autoFillOptions === true) {\n // wanted jsonFilePath: /..../src/components/home/index.content.json\n // replace file extension in json\n let jsonFilePath = filePath.replace(extname(filePath), '.json');\n\n // if both filePath jsonFilePath are same path, change it as : /..../src/components/home/index.fill.content.json\n if (filePath === jsonFilePath) {\n jsonFilePath = jsonFilePath.replace(extname(jsonFilePath), '.fill.json');\n }\n\n outputContentDeclarationFile.push({\n localeList,\n filePath: jsonFilePath,\n });\n }\n\n if (typeof autoFillOptions === 'string') {\n if (autoFillOptions.includes('{{locale}}')) {\n const output = localeList.map((locale) => ({\n localeList: [locale],\n filePath: transformUriToAbsolutePath(\n autoFillOptions\n .replace('{{locale}}', locale)\n .replace('{{key}}', dictionaryKey),\n filePath,\n configuration.content.baseDir\n ),\n }));\n\n outputContentDeclarationFile.push(...output);\n } else {\n outputContentDeclarationFile.push({\n localeList,\n filePath: transformUriToAbsolutePath(\n autoFillOptions,\n filePath,\n configuration.content.baseDir\n ),\n });\n }\n\n return outputContentDeclarationFile;\n }\n\n if (typeof autoFillOptions === 'object') {\n const localeList = Object.keys(autoFillOptions).filter(\n (locale) => typeof autoFillOptions[locale] === 'string'\n ) as Locales[];\n\n const output: AutoFillData[] = localeList.map((locale) => ({\n localeList: [locale],\n filePath: transformUriToAbsolutePath(\n autoFillOptions[locale].replace('{{key}}', dictionaryKey),\n filePath,\n configuration.content.baseDir\n ),\n }));\n\n // Group by filePath and merge localeList\n const groupedByFilePath = output.reduce((acc, curr) => {\n const existing = acc.find((item) => item.filePath === curr.filePath);\n if (existing) {\n existing.localeList.push(...curr.localeList);\n } else {\n acc.push(curr);\n }\n return acc;\n }, [] as AutoFillData[]);\n\n outputContentDeclarationFile.push(...groupedByFilePath);\n }\n\n return outputContentDeclarationFile;\n};\n\nconst autoFill = async (\n fullDictionary: Dictionary,\n contentDeclarationFile: Dictionary,\n autoFillOptions: AutoFill,\n outputLocales: Locales[],\n parentLocales: Locales[],\n configuration: IntlayerConfig\n) => {\n const appLogger = getAppLogger(configuration);\n let localeList: Locales[] = (\n outputLocales ?? configuration.internationalization.locales\n ).filter((locale) => !parentLocales?.includes(locale));\n\n const filePath = contentDeclarationFile.filePath;\n\n if (!filePath) {\n appLogger('No file path found for dictionary', {\n level: 'error',\n });\n return;\n }\n\n const autoFillData: AutoFillData[] = formatAutoFillData(\n autoFillOptions,\n localeList,\n filePath,\n fullDictionary.key,\n configuration\n );\n\n appLogger(`Auto fill data: ${JSON.stringify(autoFillData, null, 2)}`, {\n level: 'info',\n isVerbose: true,\n });\n\n for await (const output of autoFillData) {\n const reducedDictionary = reduceDictionaryContent(\n fullDictionary,\n contentDeclarationFile\n );\n\n const isPerLocaleDeclarationFile = output.localeList.length === 1;\n\n if (isPerLocaleDeclarationFile) {\n const sourceLocale = output.localeList[0];\n\n const sourceLocaleContent = getLocalisedContent(\n reducedDictionary as unknown as ContentNode,\n sourceLocale,\n { dictionaryKey: reducedDictionary.key, keyPath: [] }\n );\n\n await writeContentDeclaration({\n ...fullDictionary,\n locale: sourceLocale,\n autoFilled: true,\n autoFill: undefined,\n content: sourceLocaleContent.content,\n filePath: output.filePath,\n });\n } else {\n const content = getFilteredLocalesContent(\n reducedDictionary.content as unknown as ContentNode,\n output.localeList,\n { dictionaryKey: reducedDictionary.key, keyPath: [] }\n );\n\n // write file\n await writeContentDeclaration({\n ...fullDictionary,\n autoFilled: true,\n autoFill: undefined,\n content,\n filePath: output.filePath,\n });\n }\n }\n};\n\n/**\n * Fill translations based on the provided options.\n */\nexport const fill = async (options: FillOptions): Promise<void> => {\n const configuration = getConfiguration(options.configOptions);\n const appLogger = getAppLogger(configuration);\n\n const { defaultLocale, locales } = configuration.internationalization;\n const mode = options.mode ?? 'review';\n const baseLocale = options.sourceLocale ?? defaultLocale;\n\n checkAIAccess(configuration, options.aiOptions);\n\n let oAuth2AccessToken: string | undefined;\n if (configuration.editor.clientId) {\n const intlayerAuthAPI = getAuthAPI(undefined, configuration);\n const oAuth2TokenResult = await intlayerAuthAPI.getOAuth2AccessToken();\n\n oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n }\n\n appLogger('Starting fill function', {\n level: 'info',\n });\n\n const targetUnmergedDictionaries = await getTargetDictionary(options);\n\n // Determine output locales\n const outputLocalesList: Locales[] = (\n options.outputLocales ? ensureArray(options.outputLocales) : locales\n ).filter((locale) =>\n // If mode is review, translate all locales\n // If mode is complete, translate only the locales that are not the source locale\n mode === 'review' ? true : locale !== baseLocale\n );\n\n const affectedDictionaryKeys = new Set<string>();\n targetUnmergedDictionaries.forEach((dict) => {\n affectedDictionaryKeys.add(dict.key);\n });\n\n appLogger(\n [\n 'Affected dictionary keys for processing:',\n Array.from(affectedDictionaryKeys).join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n\n for (const targetUnmergedDictionary of targetUnmergedDictionaries) {\n const dictionaryKey = targetUnmergedDictionary.key;\n const mainDictionaryToProcess = dictionariesRecord[dictionaryKey];\n const sourceLocale: Locales =\n (targetUnmergedDictionary.locale as Locales) ?? baseLocale;\n\n if (!mainDictionaryToProcess) {\n appLogger(\n `Dictionary with key \"${dictionaryKey}\" not found in dictionariesRecord. Skipping.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n appLogger(\n `Processing content declaration: ${targetUnmergedDictionary.filePath}`,\n {\n isVerbose: true,\n }\n );\n\n const sourceLocaleContent = getLocalisedContent(\n mainDictionaryToProcess as unknown as ContentNode,\n sourceLocale,\n { dictionaryKey, keyPath: [] }\n );\n\n if (Object.keys(sourceLocaleContent).length === 0) {\n appLogger(\n `No content found for dictionary ${dictionaryKey} in source locale ${sourceLocale}. Skipping translation for this dictionary.`,\n {\n level: 'warn',\n }\n );\n continue;\n }\n\n const result: Dictionary[] = [];\n\n // 5. for each locale to translate (exclude base locale) generate json translations\n for await (const targetLocale of outputLocalesList) {\n appLogger(\n `Preparing translation for ${dictionaryKey} from ${sourceLocale} to ${targetLocale}`,\n {\n isVerbose: true,\n }\n );\n\n const presetOutputContent = getLocalisedContent(\n mainDictionaryToProcess as unknown as ContentNode,\n targetLocale,\n { dictionaryKey, keyPath: [] }\n );\n\n try {\n const translationResult = await getAiAPI(\n undefined,\n configuration\n ).translateJSON(\n {\n entryFileContent: sourceLocaleContent.content, // Should be JSON, ensure getLocalisedContent provides this.\n presetOutputContent: presetOutputContent.content, // Should be JSON\n dictionaryDescription: mainDictionaryToProcess.description,\n entryLocale: sourceLocale,\n outputLocale: targetLocale,\n mode,\n aiOptions: options.aiOptions,\n },\n {\n ...(oAuth2AccessToken && {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }),\n }\n );\n\n if (!translationResult.data?.fileContent) {\n appLogger(\n `No content result found for ${dictionaryKey} to ${targetLocale}`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n const processedPerLocaleDictionary = processPerLocaleDictionary({\n ...mainDictionaryToProcess,\n content: translationResult.data?.fileContent,\n locale: targetLocale,\n });\n\n result.push(processedPerLocaleDictionary);\n } catch (error) {\n appLogger(\n `Error filling ${dictionaryKey} to ${targetLocale}:` + error,\n {\n level: 'error',\n }\n );\n }\n }\n\n const dictionaryToMerge =\n mode === 'review'\n ? [...result, mainDictionaryToProcess] // Mode review: generated content will override the base one\n : [mainDictionaryToProcess, ...result]; // Mode complete: base content will override the generated one\n\n const mergedResults = mergeDictionaries(dictionaryToMerge);\n\n let formattedDict = targetUnmergedDictionary;\n\n if (formattedDict.locale) {\n const presetOutputContent = getLocalisedContent(\n mainDictionaryToProcess as unknown as ContentNode,\n formattedDict.locale,\n { dictionaryKey, keyPath: [] }\n );\n formattedDict = {\n ...formattedDict,\n content: presetOutputContent.content,\n };\n }\n\n const reducedResult = reduceDictionaryContent(mergedResults, formattedDict);\n\n await writeContentDeclaration(\n { ...formattedDict, content: reducedResult.content },\n configuration,\n formattedDict.filePath\n );\n\n await autoFill(\n mergedResults,\n targetUnmergedDictionary,\n formattedDict.autoFill,\n outputLocalesList,\n [sourceLocale],\n configuration\n );\n }\n};\n"],"mappings":"AAAA,SAAoB,UAAU,kBAAkB;AAChD;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EAIE;AAAA,OACK;AACP,OAAO,wBAAwB;AAC/B,OAAO,gCAAgC;AACvC,SAAS,SAAS,SAAS,YAAY;AACvC,SAAS,qBAAqB;AAkB9B,MAAM,cAAc,CAAI,UAAwB,CAAC,KAAK,EAAE,KAAK;AAE7D,MAAM,sBAAsB,OAAO,YAAyB;AAC1D,QAAM,gBAAgB,iBAAiB,QAAQ,aAAa;AAE5D,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,SAAS,OAAO,OAAO,0BAA0B,EAAE,KAAK;AAG5D,MAAI,OAAO,QAAQ,SAAS,aAAa;AACvC,UAAM,YAAY,YAAY,QAAQ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AA,EACF;AACF;","names":["localeList"]}
|
package/dist/esm/index.mjs
CHANGED
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './build';\nexport * from './cli';\nexport * from './fill';\nexport * from './listContentDeclaration';\nexport * from './pull';\nexport * from './push';\nexport * from './pushConfig';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './build';\nexport * from './cli';\nexport * from './fill';\nexport * from './listContentDeclaration';\nexport * from './pull';\nexport * from './push';\nexport * from './pushConfig';\nexport * from './reviewDoc';\nexport * from './translateDoc';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|