@intlayer/cli 6.0.2 → 6.1.1
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/README.md +249 -56
- package/dist/cjs/build.cjs +8 -0
- package/dist/cjs/build.cjs.map +1 -1
- package/dist/cjs/cli.cjs +32 -5
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/fill/index.cjs +114 -59
- package/dist/cjs/fill/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/liveSync.cjs +6 -30
- package/dist/cjs/liveSync.cjs.map +1 -1
- package/dist/cjs/pull.cjs +1 -1
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push/pullLog.cjs.map +1 -0
- package/dist/cjs/{push.cjs → push/push.cjs} +2 -2
- package/dist/cjs/push/push.cjs.map +1 -0
- package/dist/cjs/reviewDoc.cjs +148 -96
- package/dist/cjs/reviewDoc.cjs.map +1 -1
- package/dist/cjs/test/index.cjs +2 -0
- package/dist/cjs/test/index.cjs.map +1 -1
- package/dist/cjs/translateDoc.cjs +39 -42
- package/dist/cjs/translateDoc.cjs.map +1 -1
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs +145 -0
- package/dist/cjs/utils/mapChunksBetweenFiles.cjs.map +1 -0
- package/dist/cjs/watch.cjs +42 -0
- package/dist/cjs/watch.cjs.map +1 -0
- package/dist/esm/build.mjs +12 -1
- package/dist/esm/build.mjs.map +1 -1
- package/dist/esm/cli.mjs +32 -5
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/fill/index.mjs +114 -59
- package/dist/esm/fill/index.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/liveSync.mjs +10 -31
- package/dist/esm/liveSync.mjs.map +1 -1
- package/dist/esm/pull.mjs +1 -1
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/push/pullLog.mjs.map +1 -0
- package/dist/esm/{push.mjs → push/push.mjs} +2 -2
- package/dist/esm/push/push.mjs.map +1 -0
- package/dist/esm/reviewDoc.mjs +151 -97
- package/dist/esm/reviewDoc.mjs.map +1 -1
- package/dist/esm/test/index.mjs +2 -0
- package/dist/esm/test/index.mjs.map +1 -1
- package/dist/esm/translateDoc.mjs +41 -43
- package/dist/esm/translateDoc.mjs.map +1 -1
- package/dist/esm/utils/mapChunksBetweenFiles.mjs +121 -0
- package/dist/esm/utils/mapChunksBetweenFiles.mjs.map +1 -0
- package/dist/esm/watch.mjs +21 -0
- package/dist/esm/watch.mjs.map +1 -0
- package/dist/types/build.d.ts +2 -0
- package/dist/types/build.d.ts.map +1 -1
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/fill/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/liveSync.d.ts +1 -1
- package/dist/types/liveSync.d.ts.map +1 -1
- package/dist/types/push/pullLog.d.ts.map +1 -0
- package/dist/types/push/push.d.ts.map +1 -0
- package/dist/types/reviewDoc.d.ts +2 -2
- package/dist/types/reviewDoc.d.ts.map +1 -1
- package/dist/types/test/index.d.ts.map +1 -1
- package/dist/types/translateDoc.d.ts.map +1 -1
- package/dist/types/utils/mapChunksBetweenFiles.d.ts +12 -0
- package/dist/types/utils/mapChunksBetweenFiles.d.ts.map +1 -0
- package/dist/types/watch.d.ts +13 -0
- package/dist/types/watch.d.ts.map +1 -0
- package/package.json +21 -21
- package/dist/cjs/pullLog.cjs.map +0 -1
- package/dist/cjs/push.cjs.map +0 -1
- package/dist/esm/pullLog.mjs.map +0 -1
- package/dist/esm/push.mjs.map +0 -1
- package/dist/types/pullLog.d.ts.map +0 -1
- package/dist/types/push.d.ts.map +0 -1
- /package/dist/cjs/{pullLog.cjs → push/pullLog.cjs} +0 -0
- /package/dist/esm/{pullLog.mjs → push/pullLog.mjs} +0 -0
- /package/dist/types/{pullLog.d.ts → push/pullLog.d.ts} +0 -0
- /package/dist/types/{push.d.ts → push/push.d.ts} +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { chunkText } from "./calculateChunks.mjs";
|
|
2
|
+
import { splitTextByLines } from "./splitTextByLine.mjs";
|
|
3
|
+
const mapChunksBetweenFiles = (baseFileContent, updatedFileContent, maxCharsPerChunk = 800, changedLines) => {
|
|
4
|
+
const baseChunks = chunkText(baseFileContent, maxCharsPerChunk, 0);
|
|
5
|
+
const baseLines = splitTextByLines(baseFileContent);
|
|
6
|
+
const updatedLines = splitTextByLines(updatedFileContent);
|
|
7
|
+
const lineMapping = createLineMapping(baseLines, updatedLines);
|
|
8
|
+
return baseChunks.map((baseChunk) => {
|
|
9
|
+
const mappedRange = mapLineRange(
|
|
10
|
+
baseChunk.lineStart,
|
|
11
|
+
baseChunk.lineLength,
|
|
12
|
+
lineMapping
|
|
13
|
+
);
|
|
14
|
+
if (!mappedRange) {
|
|
15
|
+
return {
|
|
16
|
+
baseChunk,
|
|
17
|
+
updatedChunk: null,
|
|
18
|
+
hasChanges: true
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const updatedChunk = {
|
|
22
|
+
lineStart: mappedRange.start,
|
|
23
|
+
lineLength: mappedRange.length,
|
|
24
|
+
charStart: 0,
|
|
25
|
+
// Will be calculated when needed
|
|
26
|
+
charLength: 0,
|
|
27
|
+
// Will be calculated when needed
|
|
28
|
+
content: extractLinesFromRange(
|
|
29
|
+
updatedLines,
|
|
30
|
+
mappedRange.start,
|
|
31
|
+
mappedRange.length
|
|
32
|
+
)
|
|
33
|
+
};
|
|
34
|
+
updatedChunk.charStart = getCharStartForLine(
|
|
35
|
+
updatedFileContent,
|
|
36
|
+
updatedChunk.lineStart
|
|
37
|
+
);
|
|
38
|
+
updatedChunk.charLength = updatedChunk.content.length;
|
|
39
|
+
const hasChanges = determineIfChunkHasChanges(
|
|
40
|
+
baseChunk,
|
|
41
|
+
updatedChunk,
|
|
42
|
+
changedLines
|
|
43
|
+
);
|
|
44
|
+
return {
|
|
45
|
+
baseChunk,
|
|
46
|
+
updatedChunk,
|
|
47
|
+
hasChanges
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const createLineMapping = (baseLines, updatedLines) => {
|
|
52
|
+
const mapping = /* @__PURE__ */ new Map();
|
|
53
|
+
const dp = Array(baseLines.length + 1).fill(null).map(() => Array(updatedLines.length + 1).fill(0));
|
|
54
|
+
for (let i2 = 1; i2 <= baseLines.length; i2++) {
|
|
55
|
+
for (let j2 = 1; j2 <= updatedLines.length; j2++) {
|
|
56
|
+
if (baseLines[i2 - 1] === updatedLines[j2 - 1]) {
|
|
57
|
+
dp[i2][j2] = dp[i2 - 1][j2 - 1] + 1;
|
|
58
|
+
} else {
|
|
59
|
+
dp[i2][j2] = Math.max(dp[i2 - 1][j2], dp[i2][j2 - 1]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
let i = baseLines.length;
|
|
64
|
+
let j = updatedLines.length;
|
|
65
|
+
while (i > 0 || j > 0) {
|
|
66
|
+
if (i > 0 && j > 0 && baseLines[i - 1] === updatedLines[j - 1]) {
|
|
67
|
+
mapping.set(i - 1, j - 1);
|
|
68
|
+
i--;
|
|
69
|
+
j--;
|
|
70
|
+
} else if (i > 0 && (j === 0 || dp[i - 1][j] >= dp[i][j - 1])) {
|
|
71
|
+
mapping.set(i - 1, null);
|
|
72
|
+
i--;
|
|
73
|
+
} else {
|
|
74
|
+
j--;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return mapping;
|
|
78
|
+
};
|
|
79
|
+
const mapLineRange = (baseStart, baseLength, lineMapping) => {
|
|
80
|
+
const mappedLines = [];
|
|
81
|
+
for (let i = baseStart; i < baseStart + baseLength; i++) {
|
|
82
|
+
const mappedLine = lineMapping.get(i);
|
|
83
|
+
if (mappedLine !== null && mappedLine !== void 0) {
|
|
84
|
+
mappedLines.push(mappedLine);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (mappedLines.length === 0) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
mappedLines.sort((a, b) => a - b);
|
|
91
|
+
const start = mappedLines[0];
|
|
92
|
+
const end = mappedLines[mappedLines.length - 1];
|
|
93
|
+
return {
|
|
94
|
+
start,
|
|
95
|
+
length: end - start + 1
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
const extractLinesFromRange = (lines, start, length) => {
|
|
99
|
+
const endIndex = Math.min(start + length, lines.length);
|
|
100
|
+
return lines.slice(start, endIndex).join("");
|
|
101
|
+
};
|
|
102
|
+
const getCharStartForLine = (text, lineNumber) => {
|
|
103
|
+
const lines = splitTextByLines(text);
|
|
104
|
+
let charStart = 0;
|
|
105
|
+
for (let i = 0; i < Math.min(lineNumber, lines.length); i++) {
|
|
106
|
+
charStart += lines[i].length;
|
|
107
|
+
}
|
|
108
|
+
return charStart;
|
|
109
|
+
};
|
|
110
|
+
const determineIfChunkHasChanges = (baseChunk, updatedChunk, changedLines) => {
|
|
111
|
+
if (changedLines && changedLines.length > 0) {
|
|
112
|
+
return changedLines.some(
|
|
113
|
+
(line) => line >= updatedChunk.lineStart && line < updatedChunk.lineStart + updatedChunk.lineLength
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return baseChunk.content !== updatedChunk.content;
|
|
117
|
+
};
|
|
118
|
+
export {
|
|
119
|
+
mapChunksBetweenFiles
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=mapChunksBetweenFiles.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/mapChunksBetweenFiles.ts"],"sourcesContent":["import { ChunkLineResult, chunkText } from './calculateChunks';\nimport { splitTextByLines } from './splitTextByLine';\n\nexport interface ChunkMapping {\n baseChunk: ChunkLineResult;\n updatedChunk: ChunkLineResult | null; // null if the chunk was deleted\n hasChanges: boolean;\n}\n\n/**\n * Maps chunks from base file to corresponding chunks in updated file,\n * handling insertions, deletions, and modifications properly.\n */\nexport const mapChunksBetweenFiles = (\n baseFileContent: string,\n updatedFileContent: string,\n maxCharsPerChunk: number = 800,\n changedLines?: number[]\n): ChunkMapping[] => {\n const baseChunks = chunkText(baseFileContent, maxCharsPerChunk, 0);\n const baseLines = splitTextByLines(baseFileContent);\n const updatedLines = splitTextByLines(updatedFileContent);\n\n // Create a simple line mapping using LCS (Longest Common Subsequence) approach\n const lineMapping = createLineMapping(baseLines, updatedLines);\n\n return baseChunks.map((baseChunk): ChunkMapping => {\n // Map the base chunk's line range to the updated file\n const mappedRange = mapLineRange(\n baseChunk.lineStart,\n baseChunk.lineLength,\n lineMapping\n );\n\n if (!mappedRange) {\n // This chunk was completely deleted\n return {\n baseChunk,\n updatedChunk: null,\n hasChanges: true,\n };\n }\n\n // Create the corresponding chunk in the updated file\n const updatedChunk: ChunkLineResult = {\n lineStart: mappedRange.start,\n lineLength: mappedRange.length,\n charStart: 0, // Will be calculated when needed\n charLength: 0, // Will be calculated when needed\n content: extractLinesFromRange(\n updatedLines,\n mappedRange.start,\n mappedRange.length\n ),\n };\n\n // Calculate character positions\n updatedChunk.charStart = getCharStartForLine(\n updatedFileContent,\n updatedChunk.lineStart\n );\n updatedChunk.charLength = updatedChunk.content.length;\n\n // Determine if this chunk has changes\n const hasChanges = determineIfChunkHasChanges(\n baseChunk,\n updatedChunk,\n changedLines\n );\n\n return {\n baseChunk,\n updatedChunk,\n hasChanges,\n };\n });\n};\n\n/**\n * Creates a mapping between line numbers in base file and updated file\n * Returns a map where key = base line number, value = updated line number (or null if deleted)\n */\nconst createLineMapping = (\n baseLines: string[],\n updatedLines: string[]\n): Map<number, number | null> => {\n const mapping = new Map<number, number | null>();\n\n // Use a simple diff algorithm (similar to Myers algorithm but simplified)\n const dp: number[][] = Array(baseLines.length + 1)\n .fill(null)\n .map(() => Array(updatedLines.length + 1).fill(0));\n\n // Fill the DP table\n for (let i = 1; i <= baseLines.length; i++) {\n for (let j = 1; j <= updatedLines.length; j++) {\n if (baseLines[i - 1] === updatedLines[j - 1]) {\n dp[i][j] = dp[i - 1][j - 1] + 1;\n } else {\n dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);\n }\n }\n }\n\n // Backtrack to create the mapping\n let i = baseLines.length;\n let j = updatedLines.length;\n\n while (i > 0 || j > 0) {\n if (i > 0 && j > 0 && baseLines[i - 1] === updatedLines[j - 1]) {\n // Lines match\n mapping.set(i - 1, j - 1);\n i--;\n j--;\n } else if (i > 0 && (j === 0 || dp[i - 1][j] >= dp[i][j - 1])) {\n // Line was deleted from base\n mapping.set(i - 1, null);\n i--;\n } else {\n // Line was added to updated (no mapping needed for base)\n j--;\n }\n }\n\n return mapping;\n};\n\n/**\n * Maps a line range from base file to updated file using the line mapping\n */\nconst mapLineRange = (\n baseStart: number,\n baseLength: number,\n lineMapping: Map<number, number | null>\n): { start: number; length: number } | null => {\n const mappedLines: number[] = [];\n\n for (let i = baseStart; i < baseStart + baseLength; i++) {\n const mappedLine = lineMapping.get(i);\n if (mappedLine !== null && mappedLine !== undefined) {\n mappedLines.push(mappedLine);\n }\n }\n\n if (mappedLines.length === 0) {\n return null; // All lines were deleted\n }\n\n // Find the continuous range in the mapped lines\n mappedLines.sort((a, b) => a - b);\n const start = mappedLines[0];\n const end = mappedLines[mappedLines.length - 1];\n\n return {\n start,\n length: end - start + 1,\n };\n};\n\n/**\n * Extracts lines from a range in the lines array\n */\nconst extractLinesFromRange = (\n lines: string[],\n start: number,\n length: number\n): string => {\n const endIndex = Math.min(start + length, lines.length);\n return lines.slice(start, endIndex).join('');\n};\n\n/**\n * Gets the character position where a line starts in the text\n */\nconst getCharStartForLine = (text: string, lineNumber: number): number => {\n const lines = splitTextByLines(text);\n let charStart = 0;\n\n for (let i = 0; i < Math.min(lineNumber, lines.length); i++) {\n charStart += lines[i].length;\n }\n\n return charStart;\n};\n\n/**\n * Determines if a chunk has changes based on git changed lines or content comparison\n */\nconst determineIfChunkHasChanges = (\n baseChunk: ChunkLineResult,\n updatedChunk: ChunkLineResult,\n changedLines?: number[]\n): boolean => {\n // If we have git changed lines, use them for precise detection\n if (changedLines && changedLines.length > 0) {\n return changedLines.some(\n (line) =>\n line >= updatedChunk.lineStart &&\n line < updatedChunk.lineStart + updatedChunk.lineLength\n );\n }\n\n // Fallback to content comparison\n return baseChunk.content !== updatedChunk.content;\n};\n"],"mappings":"AAAA,SAA0B,iBAAiB;AAC3C,SAAS,wBAAwB;AAY1B,MAAM,wBAAwB,CACnC,iBACA,oBACA,mBAA2B,KAC3B,iBACmB;AACnB,QAAM,aAAa,UAAU,iBAAiB,kBAAkB,CAAC;AACjE,QAAM,YAAY,iBAAiB,eAAe;AAClD,QAAM,eAAe,iBAAiB,kBAAkB;AAGxD,QAAM,cAAc,kBAAkB,WAAW,YAAY;AAE7D,SAAO,WAAW,IAAI,CAAC,cAA4B;AAEjD,UAAM,cAAc;AAAA,MAClB,UAAU;AAAA,MACV,UAAU;AAAA,MACV;AAAA,IACF;AAEA,QAAI,CAAC,aAAa;AAEhB,aAAO;AAAA,QACL;AAAA,QACA,cAAc;AAAA,QACd,YAAY;AAAA,MACd;AAAA,IACF;AAGA,UAAM,eAAgC;AAAA,MACpC,WAAW,YAAY;AAAA,MACvB,YAAY,YAAY;AAAA,MACxB,WAAW;AAAA;AAAA,MACX,YAAY;AAAA;AAAA,MACZ,SAAS;AAAA,QACP;AAAA,QACA,YAAY;AAAA,QACZ,YAAY;AAAA,MACd;AAAA,IACF;AAGA,iBAAa,YAAY;AAAA,MACvB;AAAA,MACA,aAAa;AAAA,IACf;AACA,iBAAa,aAAa,aAAa,QAAQ;AAG/C,UAAM,aAAa;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAMA,MAAM,oBAAoB,CACxB,WACA,iBAC+B;AAC/B,QAAM,UAA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U;AAAA,IAC7B;AAAA,EACF;AAEA,MAAI,YAAY,WAAW,GAAG;AAC5B,WAAO;AAAA,EACT;AAGA,cAAY,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AAChC,QAAM,QAAQ,YAAY,CAAC;AAC3B,QAAM,MAAM,YAAY,YAAY,SAAS,CAAC;AAE9C,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,MAAM,QAAQ;AAAA,EACxB;AACF;AAKA,MAAM,wBAAwB,CAC5B,OACA,OACA,WACW;AACX,QAAM,WAAW,KAAK,IAAI,QAAQ,QAAQ,MAAM,MAAM;AACtD,SAAO,MAAM,MAAM,OAAO,QAAQ,EAAE,KAAK,EAAE;AAC7C;AAKA,MAAM,sBAAsB,CAAC,MAAc,eAA+B;AACxE,QAAM,QAAQ,iBAAiB,IAAI;AACnC,MAAI,YAAY;AAEhB,WAAS,IAAI,GAAG,IAAI,KAAK,IAAI,YAAY,MAAM,MAAM,GAAG,KAAK;AAC3D,iBAAa,MAAM,CAAC,EAAE;AAAA,EACxB;AAEA,SAAO;AACT;AAKA,MAAM,6BAA6B,CACjC,WACA,cACA,iBACY;AAEZ,MAAI,gBAAgB,aAAa,SAAS,GAAG;AAC3C,WAAO,aAAa;AAAA,MAClB,CAAC,SACC,QAAQ,aAAa,aACrB,OAAO,aAAa,YAAY,aAAa;AAAA,IACjD;AAAA,EACF;AAGA,SAAO,UAAU,YAAY,aAAa;AAC5C;","names":["i","j"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { runParallel, watch } from "@intlayer/chokidar";
|
|
2
|
+
import {
|
|
3
|
+
getAppLogger,
|
|
4
|
+
getConfiguration
|
|
5
|
+
} from "@intlayer/config";
|
|
6
|
+
const watchContentDeclaration = async (options) => {
|
|
7
|
+
const config = getConfiguration(options?.configOptions);
|
|
8
|
+
const appLogger = getAppLogger(config);
|
|
9
|
+
if (options?.with) {
|
|
10
|
+
runParallel(options.with);
|
|
11
|
+
}
|
|
12
|
+
appLogger("Watching Intlayer content declarations");
|
|
13
|
+
watch({
|
|
14
|
+
persistent: true,
|
|
15
|
+
skipPrepare: options?.skipPrepare ?? false
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
watchContentDeclaration
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=watch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/watch.ts"],"sourcesContent":["import { runParallel, watch } from '@intlayer/chokidar';\nimport {\n getAppLogger,\n getConfiguration,\n type GetConfigurationOptions,\n} from '@intlayer/config';\n\ntype WatchOptions = {\n skipPrepare?: boolean;\n with?: string | string[];\n configOptions?: GetConfigurationOptions;\n};\n\n/**\n * Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.\n * Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}\n */\nexport const watchContentDeclaration = async (options?: WatchOptions) => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\n\n if (options?.with) {\n runParallel(options.with);\n }\n\n appLogger('Watching Intlayer content declarations');\n\n watch({\n persistent: true,\n skipPrepare: options?.skipPrepare ?? false,\n });\n};\n"],"mappings":"AAAA,SAAS,aAAa,aAAa;AACnC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAYA,MAAM,0BAA0B,OAAO,YAA2B;AACvE,QAAM,SAAS,iBAAiB,SAAS,aAAa;AACtD,QAAM,YAAY,aAAa,MAAM;AAErC,MAAI,SAAS,MAAM;AACjB,gBAAY,QAAQ,IAAI;AAAA,EAC1B;AAEA,YAAU,wCAAwC;AAElD,QAAM;AAAA,IACJ,YAAY;AAAA,IACZ,aAAa,SAAS,eAAe;AAAA,EACvC,CAAC;AACH;","names":[]}
|
package/dist/types/build.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,KAAK,YAAY,GAAG;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,KAAK,GAAU,UAAU,YAAY,kBAiBjD,CAAC"}
|
package/dist/types/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6BpC,eAAO,MAAM,OAAO,QAEP,CAAC;AA+Hd,KAAK,UAAU,GAAG;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,UAAU,CAAC;AA2Cf;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,QAAO,OAmazB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fill/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,MAA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EAAE,MAAM,CAAC;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,0BAA0B,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,IAAI,GAAU,SAAS,WAAW,KAAG,OAAO,CAAC,IAAI,CAiV7D,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export * from './cli';
|
|
|
4
4
|
export * from './editor';
|
|
5
5
|
export * from './fill';
|
|
6
6
|
export * from './listContentDeclaration';
|
|
7
|
+
export * from './liveSync';
|
|
7
8
|
export * from './pull';
|
|
8
|
-
export * from './push';
|
|
9
|
+
export * from './push/push';
|
|
9
10
|
export * from './pushConfig';
|
|
10
11
|
export * from './reviewDoc';
|
|
11
12
|
export * from './test';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,oBAAoB,CAAC;AACxC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,0BAA0B,CAAC;AACzC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,oBAAoB,CAAC;AACxC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC"}
|
package/dist/types/liveSync.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveSync.d.ts","sourceRoot":"","sources":["../../src/liveSync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"liveSync.d.ts","sourceRoot":"","sources":["../../src/liveSync.ts"],"names":[],"mappings":"AAgBA,KAAK,eAAe,GAAG;IACrB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC1B,CAAC;AAWF,eAAO,MAAM,QAAQ,GAAU,UAAU,eAAe,kBA0OvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pullLog.d.ts","sourceRoot":"","sources":["../../../src/push/pullLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAQ3D,MAAM,MAAM,UAAU,GAAG;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,gBAAgB,GAAG,SAAS,GAAG,UAAU,CAAC;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,iBAAiB,CAAc;;IAOvC,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE;IAiBhC,MAAM;IAMN,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,MAAM;IA+Cd,OAAO,CAAC,eAAe;CAqCxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../../src/push/push.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAIL,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAS1B,KAAK,WAAW,GAAG;IACjB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AASF;;GAEG;AACH,eAAO,MAAM,IAAI,GAAU,UAAU,WAAW,KAAG,OAAO,CAAC,IAAI,CAuM9D,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AIOptions } from '@intlayer/api';
|
|
2
2
|
import { ListGitFilesOptions } from '@intlayer/chokidar';
|
|
3
|
-
import { GetConfigurationOptions,
|
|
3
|
+
import { GetConfigurationOptions, Locales } from '@intlayer/config';
|
|
4
4
|
/**
|
|
5
5
|
* Translate a single file for a given locale
|
|
6
6
|
*/
|
|
7
|
-
export declare const reviewFile: (baseFilePath: string, outputFilePath: string, locale: Locales, baseLocale: Locales, aiOptions?: AIOptions,
|
|
7
|
+
export declare const reviewFile: (baseFilePath: string, outputFilePath: string, locale: Locales, baseLocale: Locales, aiOptions?: AIOptions, configOptions?: GetConfigurationOptions, customInstructions?: string, changedLines?: number[]) => Promise<void>;
|
|
8
8
|
type ReviewDocOptions = {
|
|
9
9
|
docPattern: string[];
|
|
10
10
|
locales: Locales[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewDoc.d.ts","sourceRoot":"","sources":["../../src/reviewDoc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAIL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"reviewDoc.d.ts","sourceRoot":"","sources":["../../src/reviewDoc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;A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C;AAEF,eAAO,MAAM,uBAAuB,GAClC,UAAU,8BAA8B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/test/index.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC,KAAK,8BAA8B,GAAG;IACpC,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,UAAU,8BAA8B,SAyEzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translateDoc.d.ts","sourceRoot":"","sources":["../../src/translateDoc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAIL,mBAAmB,
|
|
1
|
+
{"version":3,"file":"translateDoc.d.ts","sourceRoot":"","sources":["../../src/translateDoc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAIL,mBAAmB,EAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAOL,uBAAuB,EACvB,cAAc,EACd,OAAO,EAER,MAAM,kBAAkB,CAAC;AAkB1B;;GAEG;AACH,eAAO,MAAM,aAAa,GACxB,cAAc,MAAM,EACpB,gBAAgB,MAAM,EACtB,QAAQ,OAAO,EACf,YAAY,OAAO,EACnB,YAAY,SAAS,EACrB,gBAAe,cAAmC,EAClD,qBAAqB,MAAM,kBA0H5B,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9C,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7C,UAAU,CAAC,EAAE,mBAAmB,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAU,6LAYhC,mBAAmB,kBA8FrB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChunkLineResult } from './calculateChunks';
|
|
2
|
+
export interface ChunkMapping {
|
|
3
|
+
baseChunk: ChunkLineResult;
|
|
4
|
+
updatedChunk: ChunkLineResult | null;
|
|
5
|
+
hasChanges: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Maps chunks from base file to corresponding chunks in updated file,
|
|
9
|
+
* handling insertions, deletions, and modifications properly.
|
|
10
|
+
*/
|
|
11
|
+
export declare const mapChunksBetweenFiles: (baseFileContent: string, updatedFileContent: string, maxCharsPerChunk?: number, changedLines?: number[]) => ChunkMapping[];
|
|
12
|
+
//# sourceMappingURL=mapChunksBetweenFiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapChunksBetweenFiles.d.ts","sourceRoot":"","sources":["../../../src/utils/mapChunksBetweenFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAa,MAAM,mBAAmB,CAAC;AAG/D,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,eAAe,CAAC;IAC3B,YAAY,EAAE,eAAe,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,iBAAiB,MAAM,EACvB,oBAAoB,MAAM,EAC1B,mBAAkB,MAAY,EAC9B,eAAe,MAAM,EAAE,KACtB,YAAY,EA0Dd,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type GetConfigurationOptions } from '@intlayer/config';
|
|
2
|
+
type WatchOptions = {
|
|
3
|
+
skipPrepare?: boolean;
|
|
4
|
+
with?: string | string[];
|
|
5
|
+
configOptions?: GetConfigurationOptions;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.
|
|
9
|
+
* Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}
|
|
10
|
+
*/
|
|
11
|
+
export declare const watchContentDeclaration: (options?: WatchOptions) => Promise<void>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/watch.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,KAAK,YAAY,GAAG;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAAU,UAAU,YAAY,kBAcnE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/cli",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provides uniform command-line interface scripts for Intlayer, used in packages like intlayer-cli and intlayer.",
|
|
6
6
|
"keywords": [
|
|
@@ -49,41 +49,40 @@
|
|
|
49
49
|
"./package.json"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"commander": "^
|
|
52
|
+
"commander": "^14.0.1",
|
|
53
53
|
"eventsource": "^3.0.7",
|
|
54
54
|
"fast-glob": "^3.3.3",
|
|
55
|
-
"
|
|
56
|
-
"@intlayer/
|
|
57
|
-
"@intlayer/config": "6.
|
|
58
|
-
"@intlayer/
|
|
59
|
-
"@intlayer/
|
|
60
|
-
"@intlayer/
|
|
61
|
-
"@intlayer/remote-dictionaries-entry": "6.0.2"
|
|
55
|
+
"@intlayer/api": "6.1.1",
|
|
56
|
+
"@intlayer/dictionaries-entry": "6.1.1",
|
|
57
|
+
"@intlayer/config": "6.1.1",
|
|
58
|
+
"@intlayer/unmerged-dictionaries-entry": "6.1.1",
|
|
59
|
+
"@intlayer/chokidar": "6.1.1",
|
|
60
|
+
"@intlayer/remote-dictionaries-entry": "6.1.1"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
|
-
"@types/node": "^24.2
|
|
65
|
-
"@typescript-eslint/parser": "^8.
|
|
66
|
-
"concurrently": "^9.1
|
|
67
|
-
"eslint": "^9.
|
|
63
|
+
"@types/node": "^24.5.2",
|
|
64
|
+
"@typescript-eslint/parser": "^8.44.1",
|
|
65
|
+
"concurrently": "^9.2.1",
|
|
66
|
+
"eslint": "^9.36.0",
|
|
68
67
|
"prettier": "^3.6.2",
|
|
69
68
|
"rimraf": "^6.0.1",
|
|
70
69
|
"tsc-alias": "^1.8.16",
|
|
71
70
|
"tsup": "^8.5.0",
|
|
72
71
|
"typescript": "^5.9.2",
|
|
73
72
|
"vitest": "^3.2.4",
|
|
73
|
+
"@intlayer/core": "6.1.1",
|
|
74
74
|
"@utils/eslint-config": "1.0.4",
|
|
75
75
|
"@utils/ts-config": "1.0.4",
|
|
76
76
|
"@utils/ts-config-types": "1.0.4",
|
|
77
|
-
"@utils/tsup-config": "1.0.4"
|
|
78
|
-
"@intlayer/core": "6.0.2"
|
|
77
|
+
"@utils/tsup-config": "1.0.4"
|
|
79
78
|
},
|
|
80
79
|
"peerDependencies": {
|
|
81
|
-
"@intlayer/
|
|
82
|
-
"@intlayer/
|
|
83
|
-
"@intlayer/dictionaries-entry": "6.
|
|
84
|
-
"@intlayer/
|
|
85
|
-
"@intlayer/
|
|
86
|
-
"@intlayer/
|
|
80
|
+
"@intlayer/remote-dictionaries-entry": "6.1.1",
|
|
81
|
+
"@intlayer/config": "6.1.1",
|
|
82
|
+
"@intlayer/dictionaries-entry": "6.1.1",
|
|
83
|
+
"@intlayer/chokidar": "6.1.1",
|
|
84
|
+
"@intlayer/unmerged-dictionaries-entry": "6.1.1",
|
|
85
|
+
"@intlayer/api": "6.1.1"
|
|
87
86
|
},
|
|
88
87
|
"bug": {
|
|
89
88
|
"url": "https://github.com/aymericzip/intlayer/issues"
|
|
@@ -99,6 +98,7 @@
|
|
|
99
98
|
"lint:fix": "eslint . --cache --fix",
|
|
100
99
|
"prettier": "prettier . --check",
|
|
101
100
|
"prettier:fix": "prettier . --write",
|
|
101
|
+
"prepublish": "cp -f ../../../README.md ./README.md",
|
|
102
102
|
"test": "vitest run",
|
|
103
103
|
"test:watch": "vitest"
|
|
104
104
|
}
|
package/dist/cjs/pullLog.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pullLog.ts"],"sourcesContent":["import { type DictionaryStatus } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colorize,\n getConfiguration,\n spinnerFrames,\n} from '@intlayer/config';\n\nexport type PullStatus = {\n dictionaryKey: string;\n status: DictionaryStatus | 'pending' | 'fetching';\n errorMessage?: string;\n};\n\nexport class PullLogger {\n private statuses: PullStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n\n constructor() {\n const configuration = getConfiguration();\n this.prefix = configuration.log.prefix;\n }\n\n update(newStatuses: PullStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) => s.dictionaryKey === status.dictionaryKey\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n private render() {\n const { total, done, success, errors } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const lines: string[] = [];\n\n const isDone = done === total;\n const progressLabel = `dictionaries: ${done}/${total}`;\n const details: string[] = [];\n if (success > 0) details.push(`ok: ${success}`);\n if (errors > 0) details.push(colorize(`errors: ${errors}`, ANSIColors.RED));\n\n const suffix = details.length > 0 ? ` (${details.join(', ')})` : '';\n\n if (isDone) {\n lines.push(\n `${this.prefix} ${colorize('✔', ANSIColors.GREEN)} fetched ${progressLabel}${suffix}`\n );\n } else {\n lines.push(\n `${this.prefix} ${colorize(frame, ANSIColors.BLUE)} fetching ${progressLabel}${suffix}`\n );\n }\n\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const keys = new Set(this.statuses.map((s) => s.dictionaryKey));\n\n const doneSet = new Set<DictionaryStatus | 'error'>([\n 'fetched',\n 'imported',\n 'updated',\n 'up-to-date',\n 'reimported in JSON',\n 'new content file',\n 'error',\n ] as const);\n\n const successesSet = new Set<DictionaryStatus>([\n 'fetched',\n 'imported',\n 'updated',\n 'up-to-date',\n 'reimported in JSON',\n 'new content file',\n ] as const);\n\n const done = this.statuses.filter((s) =>\n doneSet.has(s.status as any)\n ).length;\n const success = this.statuses.filter((s) =>\n successesSet.has(s.status as any)\n ).length;\n const errors = this.statuses.filter((s) => s.status === 'error').length;\n\n return {\n total: keys.size,\n done,\n success,\n errors,\n } as const;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAKO;AAQA,MAAM,WAAW;AAAA,EACd,WAAyB,CAAC;AAAA,EAC1B,eAAsC;AAAA,EACtC,eAAe;AAAA,EACf,gBAAgB;AAAA,EACP,gBAAgB;AAAA,EACzB,aAAa;AAAA,EACJ;AAAA,EACT,oBAA4B;AAAA,EAEpC,cAAc;AACZ,UAAM,oBAAgB,gCAAiB;AACvC,SAAK,SAAS,cAAc,IAAI;AAAA,EAClC;AAAA,EAEA,OAAO,aAA2B;AAChC,QAAI,KAAK,WAAY;AACrB,eAAW,UAAU,aAAa;AAChC,YAAM,QAAQ,KAAK,SAAS;AAAA,QAC1B,CAAC,MAAM,EAAE,kBAAkB,OAAO;AAAA,MACpC;AACA,UAAI,SAAS,GAAG;AACd,aAAK,SAAS,KAAK,IAAI;AAAA,MACzB,OAAO;AACL,aAAK,SAAS,KAAK,MAAM;AAAA,MAC3B;AAAA,IACF;AAEA,SAAK,aAAa;AAClB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,SAAS;AACP,SAAK,aAAa;AAClB,SAAK,YAAY;AACjB,SAAK,OAAO;AAAA,EACd;AAAA,EAEQ,eAAe;AACrB,QAAI,KAAK,gBAAgB,KAAK,WAAY;AAC1C,SAAK,eAAe,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AAS,IAAI,GAAG,IAAI,mBAAmB,KAAK;AAC1C,cAAQ,OAAO,MAAM,SAAS;AAC9B,YAAM,OAAO,MAAM,CAAC;AACpB,UAAI,SAAS,QAAW;AACtB,gBAAQ,OAAO,MAAM,IAAI;AAAA,MAC3B;AACA,cAAQ,OAAO,MAAM,IAAI;AAAA,IAC3B;AAEA,SAAK,gBAAgB,MAAM;AAAA,EAC7B;AAAA,EAEQ,kBAAkB;AACxB,UAAM,OAAO,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC;AAE9D,UAAM,UAAU,oBAAI,IAAgC;AAAA,MAClD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAU;AAEV,UAAM,eAAe,oBAAI,IAAsB;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAU;AAEV,UAAM,OAAO,KAAK,SAAS;AAAA,MAAO,CAAC,MACjC,QAAQ,IAAI,EAAE,MAAa;AAAA,IAC7B,EAAE;AACF,UAAM,UAAU,KAAK,SAAS;AAAA,MAAO,CAAC,MACpC,aAAa,IAAI,EAAE,MAAa;AAAA,IAClC,EAAE;AACF,UAAM,SAAS,KAAK,SAAS,OAAO,CAAC,MAAM,EAAE,WAAW,OAAO,EAAE;AAEjE,WAAO;AAAA,MACL,OAAO,KAAK;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/cjs/push.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/push.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n formatPath,\n listGitFiles,\n ListGitFilesOptions,\n parallelize,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n getAppLogger,\n getConfiguration,\n GetConfigurationOptions,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport * as fsPromises from 'fs/promises';\nimport { join } from 'path';\nimport * as readline from 'readline';\nimport { PushLogger, type PushStatus } from './pushLog';\nimport { checkCMSAuth } from './utils/checkAccess';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status: 'pending' | 'pushing' | 'modified' | 'pushed' | 'unknown' | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const dictionariesRecord = getDictionaries(config);\n let dictionaries: Dictionary[] = Object.values(dictionariesRecord);\n const existingDictionariesKeys: string[] = Object.keys(dictionariesRecord);\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries!.includes(dictionary.key)\n );\n }\n\n if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n\n dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.content.baseDir, dictionary.filePath ?? '')\n )\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:', {});\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries || [];\n const newDictionaries = pushResult.data?.newDictionaries || [];\n\n if (updatedDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (newDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n // Print per-dictionary summary similar to loadDictionaries\n const iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'pushed':\n case 'modified':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n };\n\n const colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'pushed':\n case 'modified':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n };\n\n for (const s of dictionariesStatuses) {\n const icon = iconFor(s.status);\n const color = colorFor(s.status);\n appLogger(\n ` - ${s.dictionary.key} ${ANSIColors.GREY}[${color}${icon} ${s.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const answer = await askUser(\n 'Do you want to delete the local dictionaries that were successfully pushed? (yes/no): '\n );\n if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') {\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst askUser = (question: string): Promise<string> => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n return new Promise((resolve) => {\n rl.question(question, (answer: string) => {\n rl.close();\n resolve(answer);\n });\n });\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n appLogger(`Dictionary ${dictionary.key} does not have a file path`, {\n level: 'error',\n });\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n\n// Legacy per-line spinner output removed in favor of aggregated PushLogger\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAoC;AACpC,sBAKO;AACP,oBAKO;AAEP,gCAAgC;AAChC,iBAA4B;AAC5B,kBAAqB;AACrB,eAA0B;AAC1B,qBAA4C;AAC5C,yBAA6B;AAoBtB,MAAM,OAAO,OAAO,YAAyC;AAClE,QAAM,aAAS,gCAAiB,SAAS,aAAa;AACtD,QAAM,gBAAY,4BAAa,QAAQ;AAAA,IACrC,QAAQ;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACF,CAAC;AAED,MAAI;AACF,UAAM,aAAa,UAAM,iCAAa,MAAM;AAE5C,QAAI,CAAC,WAAY;AAEjB,UAAM,kBAAc,gCAAoB,QAAW,MAAM;AAEzD,UAAM,yBAAqB,2CAAgB,MAAM;AACjD,QAAI,eAA6B,OAAO,OAAO,kBAAkB;AACjE,UAAM,2BAAqC,OAAO,KAAK,kBAAkB;AAEzE,QAAI,SAAS,cAAc;AAEzB,YAAM,iCAAiC,QAAQ,aAAa;AAAA,QAC1D,CAAC,iBAAiB,CA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AAA,EACF,CAAC;AAGD,QAAM,eAA4B,oBAAI,IAAI;AAE1C,aAAW,cAAc,sBAAsB;AAC7C,UAAM,EAAE,SAAS,IAAI;AAErB,QAAI,CAAC,UAAU;AACb,gBAAU,cAAc,WAAW,GAAG,8BAA8B;AAAA,QAClE,OAAO;AAAA,MACT,CAAC;AACD;AAAA,IACF;AAEA,iBAAa,IAAI,QAAQ;AAAA,EAC3B;AAEA,aAAW,YAAY,cAAc;AACnC,QAAI;AACF,YAAM,QAAQ,MAAM,WAAW,MAAM,QAAQ;AAE7C,UAAI,MAAM,OAAO,GAAG;AAClB,cAAM,WAAW,OAAO,QAAQ;AAChC,kBAAU,oBAAgB,4BAAW,QAAQ,CAAC,IAAI,CAAC,CAAC;AAAA,MACtD,WAAW,MAAM,YAAY,GAAG;AAC9B,kBAAU,2BAAuB,4BAAW,QAAQ,CAAC,eAAe,CAAC,CAAC;AAAA,MACxE,OAAO;AACL;AAAA,UACE,6BAAyB,4BAAW,QAAQ,CAAC;AAAA,UAC7C,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,gBAAU,sBAAkB,4BAAW,QAAQ,CAAC,KAAK,GAAG,IAAI;AAAA,QAC1D,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
package/dist/esm/pullLog.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pullLog.ts"],"sourcesContent":["import { type DictionaryStatus } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colorize,\n getConfiguration,\n spinnerFrames,\n} from '@intlayer/config';\n\nexport type PullStatus = {\n dictionaryKey: string;\n status: DictionaryStatus | 'pending' | 'fetching';\n errorMessage?: string;\n};\n\nexport class PullLogger {\n private statuses: PullStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private readonly prefix: string;\n private lastRenderedState: string = '';\n\n constructor() {\n const configuration = getConfiguration();\n this.prefix = configuration.log.prefix;\n }\n\n update(newStatuses: PullStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) => s.dictionaryKey === status.dictionaryKey\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n private render() {\n const { total, done, success, errors } = this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const lines: string[] = [];\n\n const isDone = done === total;\n const progressLabel = `dictionaries: ${done}/${total}`;\n const details: string[] = [];\n if (success > 0) details.push(`ok: ${success}`);\n if (errors > 0) details.push(colorize(`errors: ${errors}`, ANSIColors.RED));\n\n const suffix = details.length > 0 ? ` (${details.join(', ')})` : '';\n\n if (isDone) {\n lines.push(\n `${this.prefix} ${colorize('✔', ANSIColors.GREEN)} fetched ${progressLabel}${suffix}`\n );\n } else {\n lines.push(\n `${this.prefix} ${colorize(frame, ANSIColors.BLUE)} fetching ${progressLabel}${suffix}`\n );\n }\n\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const keys = new Set(this.statuses.map((s) => s.dictionaryKey));\n\n const doneSet = new Set<DictionaryStatus | 'error'>([\n 'fetched',\n 'imported',\n 'updated',\n 'up-to-date',\n 'reimported in JSON',\n 'new content file',\n 'error',\n ] as const);\n\n const successesSet = new Set<DictionaryStatus>([\n 'fetched',\n 'imported',\n 'updated',\n 'up-to-date',\n 'reimported in JSON',\n 'new content file',\n ] as const);\n\n const done = this.statuses.filter((s) =>\n doneSet.has(s.status as any)\n ).length;\n const success = this.statuses.filter((s) =>\n successesSet.has(s.status as any)\n ).length;\n const errors = this.statuses.filter((s) => s.status === 'error').length;\n\n return {\n total: keys.size,\n done,\n success,\n errors,\n } as const;\n }\n}\n"],"mappings":"AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQA,MAAM,WAAW;AAAA,EACd,WAAyB,CAAC;AAAA,EAC1B,eAAsC;AAAA,EACtC,eAAe;AAAA,EACf,gBAAgB;AAAA,EACP,gBAAgB;AAAA,EACzB,aAAa;AAAA,EACJ;AAAA,EACT,oBAA4B;AAAA,EAEpC,cAAc;AACZ,UAAM,gBAAgB,iBAAiB;AACvC,SAAK,SAAS,cAAc,IAAI;AAAA,EAClC;AAAA,EAEA,OAAO,aAA2B;AAChC,QAAI,KAAK,WAAY;AACrB,eAAW,UAAU,aAAa;AAChC,YAAM,QAAQ,KAAK,SAAS;AAAA,QAC1B,CAAC,MAAM,EAAE,kBAAkB,OAAO;AAAA,MACpC;AACA,UAAI,SAAS,GAAG;AACd,aAAK,SAAS,KAAK,IAAI;AAAA,MACzB,OAAO;AACL,aAAK,SAAS,KAAK,MAAM;AAAA,MAC3B;AAAA,IACF;AAEA,SAAK,aAAa;AAClB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,SAAS;AACP,SAAK,aAAa;AAClB,SAAK,YAAY;AACjB,SAAK,OAAO;AAAA,EACd;AAAA,E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AEA,UAAM,oBAAoB,KAAK,IAAI,KAAK,eAAe,MAAM,MAAM;AACnE,aAAS,IAAI,GAAG,IAAI,mBAAmB,KAAK;AAC1C,cAAQ,OAAO,MAAM,SAAS;AAC9B,YAAM,OAAO,MAAM,CAAC;AACpB,UAAI,SAAS,QAAW;AACtB,gBAAQ,OAAO,MAAM,IAAI;AAAA,MAC3B;AACA,cAAQ,OAAO,MAAM,IAAI;AAAA,IAC3B;AAEA,SAAK,gBAAgB,MAAM;AAAA,EAC7B;AAAA,EAEQ,kBAAkB;AACxB,UAAM,OAAO,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC;AAE9D,UAAM,UAAU,oBAAI,IAAgC;AAAA,MAClD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAU;AAEV,UAAM,eAAe,oBAAI,IAAsB;AAAA,MAC7C;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAU;AAEV,UAAM,OAAO,KAAK,SAAS;AAAA,MAAO,CAAC,MACjC,QAAQ,IAAI,EAAE,MAAa;AAAA,IAC7B,EAAE;AACF,UAAM,UAAU,KAAK,SAAS;AAAA,MAAO,CAAC,MACpC,aAAa,IAAI,EAAE,MAAa;AAAA,IAClC,EAAE;AACF,UAAM,SAAS,KAAK,SAAS,OAAO,CAAC,MAAM,EAAE,WAAW,OAAO,EAAE;AAEjE,WAAO;AAAA,MACL,OAAO,KAAK;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/esm/push.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/push.ts"],"sourcesContent":["import { getIntlayerAPIProxy } from '@intlayer/api';\nimport {\n formatPath,\n listGitFiles,\n ListGitFilesOptions,\n parallelize,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n getAppLogger,\n getConfiguration,\n GetConfigurationOptions,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport * as fsPromises from 'fs/promises';\nimport { join } from 'path';\nimport * as readline from 'readline';\nimport { PushLogger, type PushStatus } from './pushLog';\nimport { checkCMSAuth } from './utils/checkAccess';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status: 'pending' | 'pushing' | 'modified' | 'pushed' | 'unknown' | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, config);\n\n const dictionariesRecord = getDictionaries(config);\n let dictionaries: Dictionary[] = Object.values(dictionariesRecord);\n const existingDictionariesKeys: string[] = Object.keys(dictionariesRecord);\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries!.includes(dictionary.key)\n );\n }\n\n if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n\n dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.content.baseDir, dictionary.filePath ?? '')\n )\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:', {});\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries || [];\n const newDictionaries = pushResult.data?.newDictionaries || [];\n\n if (updatedDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (newDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n // Print per-dictionary summary similar to loadDictionaries\n const iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'pushed':\n case 'modified':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n };\n\n const colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'pushed':\n case 'modified':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n };\n\n for (const s of dictionariesStatuses) {\n const icon = iconFor(s.status);\n const color = colorFor(s.status);\n appLogger(\n ` - ${s.dictionary.key} ${ANSIColors.GREY}[${color}${icon} ${s.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const answer = await askUser(\n 'Do you want to delete the local dictionaries that were successfully pushed? (yes/no): '\n );\n if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') {\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst askUser = (question: string): Promise<string> => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n return new Promise((resolve) => {\n rl.question(question, (answer: string) => {\n rl.close();\n resolve(answer);\n });\n });\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n appLogger(`Dictionary ${dictionary.key} does not have a file path`, {\n level: 'error',\n });\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n\n// Legacy per-line spinner output removed in favor of aggregated PushLogger\n"],"mappings":"AAAA,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,uBAAuB;AAChC,YAAY,gBAAgB;AAC5B,SAAS,YAAY;AACrB,YAAY,cAAc;AAC1B,SAAS,kBAAmC;AAC5C,SAAS,oBAAoB;AAoBtB,MAAM,OAAO,OAAO,YAAyC;AAClE,QAAM,SAAS,iBAAiB,SAAS,aAAa;AACtD,QAAM,YAAY,aAAa,QAAQ;AAAA,IACrC,QAAQ;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACF,CAAC;AAED,MAAI;AACF,UAAM,aAAa,MAAM,aAAa,MAAM;AAE5C,QAAI,CAAC,WAAY;AAEjB,UAAM,cAAc,oBAAoB,QAAW,MAAM;AAEzD,UAAM,qBAAqB,gBAAgB,MAAM;AACjD,QAAI,eAA6B,OAAO,OAAO,kBAAkB;AACjE,UAAM,2BAAqC,OAA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AC;AAEF,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAoB;IACpC,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,iBAAiB,CAAc;;IAOvC,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE;IAiBhC,MAAM;IAMN,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,MAAM;IA+Cd,OAAO,CAAC,eAAe;CAqCxB"}
|
package/dist/types/push.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/push.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAIL,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAS1B,KAAK,WAAW,GAAG;IACjB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AASF;;GAEG;AACH,eAAO,MAAM,IAAI,GAAU,UAAU,WAAW,KAAG,OAAO,CAAC,IAAI,CAuM9D,CAAC"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|