@intlayer/cli 5.8.1 → 6.0.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/IntlayerEventListener.cjs +240 -0
- package/dist/cjs/IntlayerEventListener.cjs.map +1 -0
- package/dist/cjs/cli.cjs +29 -7
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +5 -1
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/fill/autoFill.cjs +105 -0
- package/dist/cjs/fill/autoFill.cjs.map +1 -0
- package/dist/cjs/fill/formatAutoFillData.cjs +108 -0
- package/dist/cjs/fill/formatAutoFillData.cjs.map +1 -0
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs +46 -0
- package/dist/cjs/fill/formatAutoFilledFilePath.cjs.map +1 -0
- package/dist/cjs/fill/getTargetDictionary.cjs +86 -0
- package/dist/cjs/fill/getTargetDictionary.cjs.map +1 -0
- package/dist/cjs/fill/index.cjs +257 -0
- package/dist/cjs/fill/index.cjs.map +1 -0
- package/dist/cjs/index.cjs +4 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/listContentDeclaration.cjs +37 -19
- package/dist/cjs/listContentDeclaration.cjs.map +1 -1
- package/dist/cjs/liveSync.cjs +254 -0
- package/dist/cjs/liveSync.cjs.map +1 -0
- package/dist/cjs/pull.cjs +18 -22
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push.cjs +28 -27
- package/dist/cjs/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +8 -15
- package/dist/cjs/pushConfig.cjs.map +1 -1
- package/dist/cjs/reviewDoc.cjs +43 -26
- package/dist/cjs/reviewDoc.cjs.map +1 -1
- package/dist/cjs/test/index.cjs +91 -0
- package/dist/cjs/test/index.cjs.map +1 -0
- package/dist/cjs/test/listMissingTranslations.cjs +73 -0
- package/dist/cjs/test/listMissingTranslations.cjs.map +1 -0
- package/dist/cjs/translateDoc.cjs +40 -24
- package/dist/cjs/translateDoc.cjs.map +1 -1
- package/dist/cjs/utils/checkAIAccess.cjs +5 -1
- package/dist/cjs/utils/checkAIAccess.cjs.map +1 -1
- package/dist/esm/IntlayerEventListener.mjs +206 -0
- package/dist/esm/IntlayerEventListener.mjs.map +1 -0
- package/dist/esm/cli.mjs +26 -4
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +5 -1
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/fill/autoFill.mjs +92 -0
- package/dist/esm/fill/autoFill.mjs.map +1 -0
- package/dist/esm/fill/formatAutoFillData.mjs +84 -0
- package/dist/esm/fill/formatAutoFillData.mjs.map +1 -0
- package/dist/esm/fill/formatAutoFilledFilePath.mjs +22 -0
- package/dist/esm/fill/formatAutoFilledFilePath.mjs.map +1 -0
- package/dist/esm/fill/getTargetDictionary.mjs +51 -0
- package/dist/esm/fill/getTargetDictionary.mjs.map +1 -0
- package/dist/esm/fill/index.mjs +240 -0
- package/dist/esm/fill/index.mjs.map +1 -0
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/listContentDeclaration.mjs +38 -17
- package/dist/esm/listContentDeclaration.mjs.map +1 -1
- package/dist/esm/liveSync.mjs +220 -0
- package/dist/esm/liveSync.mjs.map +1 -0
- package/dist/esm/pull.mjs +19 -21
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/push.mjs +33 -27
- package/dist/esm/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +8 -15
- package/dist/esm/pushConfig.mjs.map +1 -1
- package/dist/esm/reviewDoc.mjs +53 -28
- package/dist/esm/reviewDoc.mjs.map +1 -1
- package/dist/esm/test/index.mjs +74 -0
- package/dist/esm/test/index.mjs.map +1 -0
- package/dist/esm/test/listMissingTranslations.mjs +41 -0
- package/dist/esm/test/listMissingTranslations.mjs.map +1 -0
- package/dist/esm/translateDoc.mjs +50 -27
- package/dist/esm/translateDoc.mjs.map +1 -1
- package/dist/esm/utils/checkAIAccess.mjs +5 -1
- package/dist/esm/utils/checkAIAccess.mjs.map +1 -1
- package/dist/types/IntlayerEventListener.d.ts +85 -0
- package/dist/types/IntlayerEventListener.d.ts.map +1 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/fill/autoFill.d.ts +4 -0
- package/dist/types/fill/autoFill.d.ts.map +1 -0
- package/dist/types/fill/formatAutoFillData.d.ts +9 -0
- package/dist/types/fill/formatAutoFillData.d.ts.map +1 -0
- package/dist/types/fill/formatAutoFilledFilePath.d.ts +3 -0
- package/dist/types/fill/formatAutoFilledFilePath.d.ts.map +1 -0
- package/dist/types/fill/getTargetDictionary.d.ts +4 -0
- package/dist/types/fill/getTargetDictionary.d.ts.map +1 -0
- package/dist/types/{fill.d.ts → fill/index.d.ts} +2 -5
- package/dist/types/fill/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/listContentDeclaration.d.ts +4 -5
- package/dist/types/listContentDeclaration.d.ts.map +1 -1
- package/dist/types/liveSync.d.ts +6 -0
- package/dist/types/liveSync.d.ts.map +1 -0
- package/dist/types/pull.d.ts.map +1 -1
- package/dist/types/push.d.ts +1 -1
- package/dist/types/push.d.ts.map +1 -1
- package/dist/types/pushConfig.d.ts +0 -1
- package/dist/types/pushConfig.d.ts.map +1 -1
- package/dist/types/reviewDoc.d.ts.map +1 -1
- package/dist/types/test/index.d.ts +8 -0
- package/dist/types/test/index.d.ts.map +1 -0
- package/dist/types/test/listMissingTranslations.d.ts +12 -0
- package/dist/types/test/listMissingTranslations.d.ts.map +1 -0
- package/dist/types/translateDoc.d.ts.map +1 -1
- package/dist/types/utils/checkAIAccess.d.ts.map +1 -1
- package/package.json +17 -15
- package/dist/cjs/fill.cjs +0 -405
- package/dist/cjs/fill.cjs.map +0 -1
- package/dist/esm/fill.mjs +0 -385
- package/dist/esm/fill.mjs.map +0 -1
- package/dist/types/fill.d.ts.map +0 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { formatLocale, formatPath } from "@intlayer/chokidar";
|
|
2
|
+
import {
|
|
3
|
+
ANSIColors,
|
|
4
|
+
colon,
|
|
5
|
+
colorize,
|
|
6
|
+
colorizeKey,
|
|
7
|
+
colorizeNumber,
|
|
8
|
+
getAppLogger,
|
|
9
|
+
getConfiguration
|
|
10
|
+
} from "@intlayer/config";
|
|
11
|
+
import { listMissingTranslations } from "./listMissingTranslations.mjs";
|
|
12
|
+
const testMissingTranslations = (options) => {
|
|
13
|
+
const config = getConfiguration(options?.configOptions);
|
|
14
|
+
const { locales, requiredLocales } = config.internationalization;
|
|
15
|
+
const appLogger = getAppLogger(config, {
|
|
16
|
+
config: {
|
|
17
|
+
prefix: ""
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const result = listMissingTranslations();
|
|
21
|
+
const maxKeyColSize = result.missingTranslations.map((t) => ` - ${t.key}`).reduce((max, t) => Math.max(max, t.length), 0);
|
|
22
|
+
const maxLocalesColSize = result.missingTranslations.map((t) => formatLocale(t.locales, false)).reduce((max, t) => Math.max(max, t.length), 0);
|
|
23
|
+
const formattedMissingTranslations = result.missingTranslations.map(
|
|
24
|
+
(translation) => [
|
|
25
|
+
colon(` - ${colorizeKey(translation.key)}`, {
|
|
26
|
+
colSize: maxKeyColSize,
|
|
27
|
+
maxSize: 40
|
|
28
|
+
}),
|
|
29
|
+
" - ",
|
|
30
|
+
colon(formatLocale(translation.locales, ANSIColors.RED), {
|
|
31
|
+
colSize: maxLocalesColSize,
|
|
32
|
+
maxSize: 40
|
|
33
|
+
}),
|
|
34
|
+
" - ",
|
|
35
|
+
translation.filePath ? formatPath(translation.filePath) : "Remote"
|
|
36
|
+
].join("")
|
|
37
|
+
);
|
|
38
|
+
appLogger(`Missing translations:`, {
|
|
39
|
+
level: "info"
|
|
40
|
+
});
|
|
41
|
+
formattedMissingTranslations.forEach((t) => {
|
|
42
|
+
appLogger(t, {
|
|
43
|
+
level: "info"
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
appLogger(`Locales: ${formatLocale(locales)}`);
|
|
47
|
+
appLogger(`Required locales: ${formatLocale(requiredLocales ?? locales)}`);
|
|
48
|
+
appLogger(
|
|
49
|
+
`Missing locales: ${result.missingLocales.length === 0 ? colorize("-", ANSIColors.GREEN) : formatLocale(result.missingLocales, ANSIColors.RED)}`
|
|
50
|
+
);
|
|
51
|
+
appLogger(
|
|
52
|
+
`Missing required locales: ${result.missingRequiredLocales.length === 0 ? colorize("-", ANSIColors.GREEN) : formatLocale(result.missingRequiredLocales, ANSIColors.RED)}`
|
|
53
|
+
);
|
|
54
|
+
appLogger(
|
|
55
|
+
`Total missing locales: ${colorizeNumber(result.missingLocales.length, {
|
|
56
|
+
other: ANSIColors.RED,
|
|
57
|
+
zero: ANSIColors.GREEN
|
|
58
|
+
})}`
|
|
59
|
+
);
|
|
60
|
+
appLogger(
|
|
61
|
+
`Total missing required locales: ${colorizeNumber(
|
|
62
|
+
result.missingRequiredLocales.length,
|
|
63
|
+
{
|
|
64
|
+
other: ANSIColors.RED,
|
|
65
|
+
zero: ANSIColors.GREEN
|
|
66
|
+
}
|
|
67
|
+
)}`
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
export {
|
|
71
|
+
listMissingTranslations,
|
|
72
|
+
testMissingTranslations
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/test/index.ts"],"sourcesContent":["import { formatLocale, formatPath } from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n colorizeNumber,\n getAppLogger,\n getConfiguration,\n GetConfigurationOptions,\n} from '@intlayer/config';\nimport { listMissingTranslations } from './listMissingTranslations';\n\nexport { listMissingTranslations };\n\ntype ListMissingTranslationsOptions = {\n configOptions?: GetConfigurationOptions;\n};\n\nexport const testMissingTranslations = (\n options?: ListMissingTranslationsOptions\n) => {\n const config = getConfiguration(options?.configOptions);\n const { locales, requiredLocales } = config.internationalization;\n\n const appLogger = getAppLogger(config, {\n config: {\n prefix: '',\n },\n });\n\n const result = listMissingTranslations();\n\n const maxKeyColSize = result.missingTranslations\n .map((t) => ` - ${t.key}`)\n .reduce((max, t) => Math.max(max, t.length), 0);\n const maxLocalesColSize = result.missingTranslations\n .map((t) => formatLocale(t.locales, false))\n .reduce((max, t) => Math.max(max, t.length), 0);\n\n const formattedMissingTranslations = result.missingTranslations.map(\n (translation) =>\n [\n colon(` - ${colorizeKey(translation.key)}`, {\n colSize: maxKeyColSize,\n maxSize: 40,\n }),\n ' - ',\n colon(formatLocale(translation.locales, ANSIColors.RED), {\n colSize: maxLocalesColSize,\n maxSize: 40,\n }),\n ' - ',\n translation.filePath ? formatPath(translation.filePath) : 'Remote',\n ].join('')\n );\n\n appLogger(`Missing translations:`, {\n level: 'info',\n });\n\n formattedMissingTranslations.forEach((t) => {\n appLogger(t, {\n level: 'info',\n });\n });\n\n appLogger(`Locales: ${formatLocale(locales)}`);\n appLogger(`Required locales: ${formatLocale(requiredLocales ?? locales)}`);\n appLogger(\n `Missing locales: ${result.missingLocales.length === 0 ? colorize('-', ANSIColors.GREEN) : formatLocale(result.missingLocales, ANSIColors.RED)}`\n );\n\n appLogger(\n `Missing required locales: ${result.missingRequiredLocales.length === 0 ? colorize('-', ANSIColors.GREEN) : formatLocale(result.missingRequiredLocales, ANSIColors.RED)}`\n );\n appLogger(\n `Total missing locales: ${colorizeNumber(result.missingLocales.length, {\n other: ANSIColors.RED,\n zero: ANSIColors.GREEN,\n })}`\n );\n appLogger(\n `Total missing required locales: ${colorizeNumber(\n result.missingRequiredLocales.length,\n {\n other: ANSIColors.RED,\n zero: ANSIColors.GREEN,\n }\n )}`\n );\n};\n"],"mappings":"AAAA,SAAS,cAAc,kBAAkB;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;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mB,OAAO,CAAC,EAAE;AACzE;AAAA,IACE,oBAAoB,OAAO,eAAe,WAAW,IAAI,SAAS,KAAK,WAAW,KAAK,IAAI,aAAa,OAAO,gBAAgB,WAAW,GAAG,CAAC;AAAA,EAChJ;AAEA;AAAA,IACE,6BAA6B,OAAO,uBAAuB,WAAW,IAAI,SAAS,KAAK,WAAW,KAAK,IAAI,aAAa,OAAO,wBAAwB,WAAW,GAAG,CAAC;AAAA,EACzK;AACA;AAAA,IACE,0BAA0B,eAAe,OAAO,eAAe,QAAQ;AAAA,MACrE,OAAO,WAAW;AAAA,MAClB,MAAM,WAAW;AAAA,IACnB,CAAC,CAAC;AAAA,EACJ;AACA;AAAA,IACE,mCAAmC;AAAA,MACjC,OAAO,uBAAuB;AAAA,MAC9B;AAAA,QACE,OAAO,WAAW;AAAA,QAClB,MAAM,WAAW;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import configuration from "@intlayer/config/built";
|
|
2
|
+
import {
|
|
3
|
+
getMissingLocalesContent
|
|
4
|
+
} from "@intlayer/core";
|
|
5
|
+
import unmergedDictionariesRecord from "@intlayer/unmerged-dictionaries-entry";
|
|
6
|
+
const listMissingTranslations = (dictionariesRecord = unmergedDictionariesRecord) => {
|
|
7
|
+
const missingTranslations = [];
|
|
8
|
+
const { locales, requiredLocales } = configuration.internationalization;
|
|
9
|
+
for (const dictionaries of Object.values(dictionariesRecord)) {
|
|
10
|
+
for (const dictionary of dictionaries) {
|
|
11
|
+
const missingLocales2 = getMissingLocalesContent(
|
|
12
|
+
dictionary,
|
|
13
|
+
configuration.internationalization.locales,
|
|
14
|
+
{
|
|
15
|
+
dictionaryKey: dictionary.key,
|
|
16
|
+
keyPath: [],
|
|
17
|
+
plugins: []
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
if (missingLocales2.length > 0) {
|
|
21
|
+
missingTranslations.push({
|
|
22
|
+
key: dictionary.key,
|
|
23
|
+
filePath: dictionary.filePath,
|
|
24
|
+
locales: missingLocales2
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const missingLocalesSet = new Set(
|
|
30
|
+
missingTranslations.flatMap((t) => t.locales)
|
|
31
|
+
);
|
|
32
|
+
const missingLocales = Array.from(missingLocalesSet);
|
|
33
|
+
const missingRequiredLocales = missingLocales.filter(
|
|
34
|
+
(locale) => (requiredLocales ?? locales).includes(locale)
|
|
35
|
+
);
|
|
36
|
+
return { missingTranslations, missingLocales, missingRequiredLocales };
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
listMissingTranslations
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=listMissingTranslations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/test/listMissingTranslations.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport {\n type ContentNode,\n type Dictionary,\n getMissingLocalesContent,\n} from '@intlayer/core';\nimport unmergedDictionariesRecord from '@intlayer/unmerged-dictionaries-entry';\n\nexport const listMissingTranslations = (\n dictionariesRecord: keyof typeof unmergedDictionariesRecord = unmergedDictionariesRecord\n) => {\n const missingTranslations: {\n key: keyof typeof unmergedDictionariesRecord;\n filePath?: string;\n locales: Locales[];\n }[] = [];\n\n const { locales, requiredLocales } = configuration.internationalization;\n\n for (const dictionaries of Object.values(dictionariesRecord)) {\n for (const dictionary of dictionaries as unknown as Dictionary[]) {\n const missingLocales = getMissingLocalesContent(\n dictionary as unknown as ContentNode,\n configuration.internationalization.locales,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [],\n }\n );\n\n if (missingLocales.length > 0) {\n missingTranslations.push({\n key: dictionary.key,\n filePath: dictionary.filePath,\n locales: missingLocales,\n });\n }\n }\n }\n\n const missingLocalesSet = new Set(\n missingTranslations.flatMap((t) => t.locales)\n );\n const missingLocales = Array.from(missingLocalesSet);\n\n const missingRequiredLocales = missingLocales.filter((locale) =>\n (requiredLocales ?? locales).includes(locale)\n );\n\n return { missingTranslations, missingLocales, missingRequiredLocales };\n};\n"],"mappings":"AACA,OAAO,mBAAmB;AAC1B;AAAA,EAGE;AAAA,OACK;AACP,OAAO,gCAAgC;AAEhC,MAAM,0BAA0B,CACrC,qBAA8D,+BAC3D;AACH,QAAM,sBAIA,CAAC;AAEP,QAAM,EAAE,SAAS,gBAAgB,IAAI,cAAc;AAEnD,aAAW,gBAAgB,OAAO,OAAO,kBAAkB,GAAG;AAC5D,eAAW,cAAc,cAAyC;AAChE,YAAMA,kBAAiB;AAAA,QACrB;AAAA,QACA,cAAc,qBAAqB;AAAA,QACnC;AAAA,UACE,eAAe,WAAW;AAAA,UAC1B,SAAS,CAAC;AAAA,UACV,SAAS,CAAC;AAAA,QACZ;AAAA,MACF;AAEA,UAAIA,gBAAe,SAAS,GAAG;AAC7B,4BAAoB,KAAK;AAAA,UACvB,KAAK,WAAW;AAAA,UAChB,UAAU,WAAW;AAAA,UACrB,SAASA;AAAA,QACX,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,QAAM,oBAAoB,IAAI;AAAA,IAC5B,oBAAoB,QAAQ,CAAC,MAAM,EAAE,OAAO;AAAA,EAC9C;AACA,QAAM,iBAAiB,MAAM,KAAK,iBAAiB;AAEnD,QAAM,yBAAyB,eAAe;AAAA,IAAO,CAAC,YACnD,mBAAmB,SAAS,SAAS,MAAM;AAAA,EAC9C;AAEA,SAAO,EAAE,qBAAqB,gBAAgB,uBAAuB;AACvE;","names":["missingLocales"]}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { getOAuthAPI } from "@intlayer/api";
|
|
2
|
-
import { listGitFiles } from "@intlayer/chokidar";
|
|
3
2
|
import {
|
|
3
|
+
formatLocale,
|
|
4
|
+
formatPath,
|
|
5
|
+
listGitFiles
|
|
6
|
+
} from "@intlayer/chokidar";
|
|
7
|
+
import {
|
|
8
|
+
ANSIColors,
|
|
9
|
+
colon,
|
|
10
|
+
colorize,
|
|
11
|
+
colorizeNumber,
|
|
4
12
|
getAppLogger,
|
|
5
13
|
getConfiguration,
|
|
6
|
-
Locales,
|
|
7
14
|
retryManager
|
|
8
15
|
} from "@intlayer/config";
|
|
9
|
-
import { getLocaleName } from "@intlayer/core";
|
|
10
16
|
import fg from "fast-glob";
|
|
11
17
|
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
12
18
|
import { readFile } from "fs/promises";
|
|
13
19
|
import pLimit from "p-limit";
|
|
14
|
-
import { dirname, join } from "path";
|
|
20
|
+
import { dirname, join, relative } from "path";
|
|
15
21
|
import { fileURLToPath } from "url";
|
|
16
22
|
import { chunkText } from "./utils/calculateChunks.mjs";
|
|
17
23
|
import { checkAIAccess } from "./utils/checkAIAccess.mjs";
|
|
@@ -25,23 +31,33 @@ const dir = isESModule ? dirname(fileURLToPath(import.meta.url)) : __dirname;
|
|
|
25
31
|
const translateFile = async (baseFilePath, outputFilePath, locale, baseLocale, aiOptions, configOptions, oAuth2AccessToken, customInstructions) => {
|
|
26
32
|
try {
|
|
27
33
|
const configuration = getConfiguration(configOptions);
|
|
28
|
-
const appLogger = getAppLogger(configuration
|
|
34
|
+
const appLogger = getAppLogger(configuration, {
|
|
35
|
+
config: {
|
|
36
|
+
prefix: ""
|
|
37
|
+
}
|
|
38
|
+
});
|
|
29
39
|
const fileContent = await readFile(baseFilePath, "utf-8");
|
|
30
40
|
let fileResultContent = fileContent;
|
|
31
|
-
const basePrompt = (await readFile(join(dir, "./prompts/TRANSLATE_PROMPT.md"), "utf-8")).replaceAll(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
const basePrompt = (await readFile(join(dir, "./prompts/TRANSLATE_PROMPT.md"), "utf-8")).replaceAll("{{localeName}}", `${formatLocale(locale, false)}`).replaceAll("{{baseLocaleName}}", `${formatLocale(baseLocale, false)}`).replace("{{applicationContext}}", aiOptions?.applicationContext ?? "-").replace("{{customInstructions}}", customInstructions ?? "-");
|
|
42
|
+
const filePrexixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;
|
|
43
|
+
const filePrefix = [
|
|
44
|
+
colon(filePrexixText, { colSize: 40 }),
|
|
45
|
+
`\u2192 ${ANSIColors.RESET}`
|
|
46
|
+
].join("");
|
|
47
|
+
const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;
|
|
48
|
+
const prefix = [
|
|
49
|
+
colon(prefixText, { colSize: 40 }),
|
|
50
|
+
`\u2192 ${ANSIColors.RESET}`
|
|
51
|
+
].join("");
|
|
38
52
|
const chunks = chunkText(fileContent);
|
|
39
|
-
appLogger(
|
|
53
|
+
appLogger(
|
|
54
|
+
`${filePrefix}Base file splitted into ${colorizeNumber(chunks.length)} chunks`
|
|
55
|
+
);
|
|
40
56
|
for await (const [i, chunk] of chunks.entries()) {
|
|
41
57
|
const isFirstChunk = i === 0;
|
|
42
|
-
const getPrevChunkPrompt = () => `**CHUNK ${i} of ${chunks.length}** that has been translated in ${
|
|
58
|
+
const getPrevChunkPrompt = () => `**CHUNK ${i} of ${chunks.length}** that has been translated in ${formatLocale(locale)}:
|
|
43
59
|
///chunkStart///` + getChunk(fileResultContent, chunks[i - 1]) + `///chunkEnd///`;
|
|
44
|
-
const getBaseChunkContextPrompt = () => `**CHUNK ${i + 1} to ${Math.min(i + 3, chunks.length)} of ${chunks.length}** is the base chunk in ${
|
|
60
|
+
const getBaseChunkContextPrompt = () => `**CHUNK ${i + 1} to ${Math.min(i + 3, chunks.length)} of ${chunks.length}** is the base chunk in ${formatLocale(baseLocale, false)} as reference.
|
|
45
61
|
///chunksStart///` + (chunks[i - 1]?.content ?? "") + chunks[i].content + (chunks[i + 1]?.content ?? "") + `///chunksEnd///`;
|
|
46
62
|
const fileToTranslateCurrentChunk = chunk.content;
|
|
47
63
|
let chunkTranslation = await retryManager(async () => {
|
|
@@ -52,7 +68,7 @@ const translateFile = async (baseFilePath, outputFilePath, locale, baseLocale, a
|
|
|
52
68
|
...isFirstChunk ? [] : [{ role: "system", content: getPrevChunkPrompt() }],
|
|
53
69
|
{
|
|
54
70
|
role: "system",
|
|
55
|
-
content: `The next user message will be the **CHUNK ${i + 1} of ${chunks.length}** in ${
|
|
71
|
+
content: `The next user message will be the **CHUNK ${colorizeNumber(i + 1)} of ${colorizeNumber(chunks.length)}** in ${formatLocale(baseLocale, false)} to translate in ${formatLocale(locale, false)}:`
|
|
56
72
|
},
|
|
57
73
|
{ role: "user", content: fileToTranslateCurrentChunk }
|
|
58
74
|
],
|
|
@@ -60,7 +76,7 @@ const translateFile = async (baseFilePath, outputFilePath, locale, baseLocale, a
|
|
|
60
76
|
oAuth2AccessToken
|
|
61
77
|
);
|
|
62
78
|
appLogger(
|
|
63
|
-
|
|
79
|
+
`${prefix}${colorizeNumber(result.tokenUsed)} tokens used - Chunk ${colorizeNumber(i + 1)} of ${colorizeNumber(chunks.length)}`
|
|
64
80
|
);
|
|
65
81
|
const fixedTranslatedChunkResult = fixChunkStartEndChars(
|
|
66
82
|
result?.fileContent,
|
|
@@ -75,7 +91,13 @@ const translateFile = async (baseFilePath, outputFilePath, locale, baseLocale, a
|
|
|
75
91
|
}
|
|
76
92
|
mkdirSync(dirname(outputFilePath), { recursive: true });
|
|
77
93
|
writeFileSync(outputFilePath, fileResultContent);
|
|
78
|
-
|
|
94
|
+
const relativePath = relative(
|
|
95
|
+
configuration.content.baseDir,
|
|
96
|
+
outputFilePath
|
|
97
|
+
);
|
|
98
|
+
appLogger(
|
|
99
|
+
`${colorize("\u2714", ANSIColors.GREEN)} File ${formatPath(relativePath)} created/updated successfully.`
|
|
100
|
+
);
|
|
79
101
|
} catch (error) {
|
|
80
102
|
console.error(error);
|
|
81
103
|
}
|
|
@@ -94,7 +116,11 @@ const translateDoc = async ({
|
|
|
94
116
|
gitOptions
|
|
95
117
|
}) => {
|
|
96
118
|
const configuration = getConfiguration(configOptions);
|
|
97
|
-
const appLogger = getAppLogger(configuration
|
|
119
|
+
const appLogger = getAppLogger(configuration, {
|
|
120
|
+
config: {
|
|
121
|
+
prefix: ""
|
|
122
|
+
}
|
|
123
|
+
});
|
|
98
124
|
if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {
|
|
99
125
|
appLogger(
|
|
100
126
|
`Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`
|
|
@@ -120,21 +146,18 @@ const translateDoc = async ({
|
|
|
120
146
|
const oAuth2TokenResult = await intlayerAuthAPI.getOAuth2AccessToken();
|
|
121
147
|
oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
|
|
122
148
|
}
|
|
123
|
-
appLogger(`Base locale is ${
|
|
149
|
+
appLogger(`Base locale is ${formatLocale(baseLocale)}`);
|
|
124
150
|
appLogger(
|
|
125
|
-
`Translating ${locales.length} locales: [ ${locales
|
|
151
|
+
`Translating ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`
|
|
126
152
|
);
|
|
127
|
-
appLogger(`Translating ${docList.length} files:`);
|
|
128
|
-
appLogger(docList.map((path) => ` - ${path}
|
|
153
|
+
appLogger(`Translating ${colorizeNumber(docList.length)} files:`);
|
|
154
|
+
appLogger(docList.map((path) => ` - ${formatPath(path)}
|
|
129
155
|
`));
|
|
130
156
|
const tasks = docList.map(
|
|
131
157
|
(docPath) => locales.flatMap(
|
|
132
158
|
(locale) => limit(async () => {
|
|
133
159
|
appLogger(
|
|
134
|
-
`Translating file: ${docPath} to ${
|
|
135
|
-
locale,
|
|
136
|
-
Locales.ENGLISH
|
|
137
|
-
)} (${locale})`
|
|
160
|
+
`Translating file: ${formatPath(docPath)} to ${formatLocale(locale)}`
|
|
138
161
|
);
|
|
139
162
|
const absoluteBaseFilePath = join(
|
|
140
163
|
configuration.content.baseDir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/translateDoc.ts"],"sourcesContent":["import { AIOptions, getOAuthAPI } from '@intlayer/api';\nimport { listGitFiles, ListGitFilesOptions } from '@intlayer/chokidar';\nimport {\n getAppLogger,\n getConfiguration,\n GetConfigurationOptions,\n Locales,\n retryManager,\n} from '@intlayer/config';\nimport { getLocaleName } from '@intlayer/core';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { readFile } from 'fs/promises';\nimport pLimit from 'p-limit';\nimport { dirname, join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { chunkText } from './utils/calculateChunks';\nimport { checkAIAccess } from './utils/checkAIAccess';\nimport { checkFileModifiedRange } from './utils/checkFileModifiedRange';\nimport { chunkInference } from './utils/chunkInference';\nimport { fixChunkStartEndChars } from './utils/fixChunkStartEndChars';\nimport { getChunk } from './utils/getChunk';\nimport { getOutputFilePath } from './utils/getOutputFilePath';\n\nconst isESModule = typeof import.meta.url === 'string';\n\nconst dir = isESModule ? dirname(fileURLToPath(import.meta.url)) : __dirname;\n\n/**\n * Translate a single file for a given locale\n */\nexport const translateFile = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locales,\n baseLocale: Locales,\n aiOptions?: AIOptions,\n configOptions?: GetConfigurationOptions,\n oAuth2AccessToken?: string,\n customInstructions?: string\n) => {\n try {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\n\n // Determine the target locale file path\n const fileContent = await readFile(baseFilePath, 'utf-8');\n let fileResultContent = fileContent;\n\n // Prepare the base prompt for ChatGPT\n const basePrompt = (\n await readFile(join(dir, './prompts/TRANSLATE_PROMPT.md'), 'utf-8')\n )\n .replaceAll(\n '{{localeName}}',\n `${getLocaleName(locale, Locales.ENGLISH)} (${locale})`\n )\n .replaceAll(\n '{{baseLocaleName}}',\n `${getLocaleName(baseLocale, Locales.ENGLISH)} (${baseLocale})`\n )\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n // 1. Chunk the file by number of lines instead of characters\n const chunks = chunkText(fileContent);\n appLogger(`Base file splitted into ${chunks.length} chunks`);\n\n for await (const [i, chunk] of chunks.entries()) {\n const isFirstChunk = i === 0;\n\n // Build the chunk-specific prompt\n const getPrevChunkPrompt = () =>\n `**CHUNK ${i} of ${chunks.length}** that has been translated in ${getLocaleName(locale, Locales.ENGLISH)} (${locale}):\\n` +\n `///chunkStart///` +\n getChunk(fileResultContent, chunks[i - 1]) +\n `///chunkEnd///`;\n\n const getBaseChunkContextPrompt = () =>\n `**CHUNK ${i + 1} to ${Math.min(i + 3, chunks.length)} of ${chunks.length}** is the base chunk in ${getLocaleName(baseLocale, Locales.ENGLISH)} (${baseLocale}) as reference.\\n` +\n `///chunksStart///` +\n (chunks[i - 1]?.content ?? '') +\n chunks[i].content +\n (chunks[i + 1]?.content ?? '') +\n `///chunksEnd///`;\n\n const fileToTranslateCurrentChunk = chunk.content;\n\n // Make the actual translation call\n let chunkTranslation = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n\n { role: 'system', content: getBaseChunkContextPrompt() },\n ...(isFirstChunk\n ? []\n : [{ role: 'system', content: getPrevChunkPrompt() } as const]),\n {\n role: 'system',\n content: `The next user message will be the **CHUNK ${i + 1} of ${chunks.length}** in ${getLocaleName(baseLocale, Locales.ENGLISH)} (${baseLocale}) to translate in ${getLocaleName(locale, Locales.ENGLISH)} (${locale}):`,\n },\n { role: 'user', content: fileToTranslateCurrentChunk },\n ],\n aiOptions,\n oAuth2AccessToken\n );\n\n appLogger(\n ` -> ${result.tokenUsed} tokens used - CHUNK ${i + 1} of ${chunks.length}`\n );\n\n const fixedTranslatedChunkResult = fixChunkStartEndChars(\n result?.fileContent,\n fileToTranslateCurrentChunk\n );\n\n return fixedTranslatedChunkResult;\n })();\n\n // Replace the chunk in the file content\n fileResultContent = fileResultContent.replace(\n fileToTranslateCurrentChunk,\n chunkTranslation\n );\n }\n\n // 4. Write the final translation to the appropriate file path\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, fileResultContent);\n\n appLogger(`File ${outputFilePath} created/updated successfully.`);\n } catch (error) {\n console.error(error);\n }\n};\n\ntype TranslateDocOptions = {\n docPattern: string[];\n locales: Locales[];\n excludedGlobPattern: string[];\n baseLocale: Locales;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n gitOptions?: ListGitFilesOptions;\n};\n\n/**\n * Main translate function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then translates them to each locale in LOCALE_LIST.\n */\nexport const translateDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n gitOptions,\n}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration);\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n const limit = pLimit(nbSimultaneousFileProcessed ?? 3);\n\n let docList: string[] = fg.sync(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n checkAIAccess(configuration, aiOptions);\n\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 docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n let oAuth2AccessToken: string | undefined;\n if (configuration.editor.clientId) {\n const intlayerAuthAPI = getOAuthAPI(configuration);\n const oAuth2TokenResult = await intlayerAuthAPI.getOAuth2AccessToken();\n\n oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n }\n\n appLogger(`Base locale is ${getLocaleName(baseLocale)} (${baseLocale})`);\n appLogger(\n `Translating ${locales.length} locales: [ ${locales\n .map((locale) => `${getLocaleName(locale, baseLocale)} (${locale})`)\n .join(', ')} ]`\n );\n\n appLogger(`Translating ${docList.length} files:`);\n appLogger(docList.map((path) => ` - ${path}\\n`));\n\n const tasks = docList.map((docPath) =>\n locales.flatMap((locale) =>\n limit(async () => {\n appLogger(\n `Translating file: ${docPath} to ${getLocaleName(\n locale,\n Locales.ENGLISH\n )} (${locale})`\n );\n\n const absoluteBaseFilePath = join(\n configuration.content.baseDir,\n docPath\n );\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // check if the file exist, otherwise create it\n if (!existsSync(outputFilePath)) {\n appLogger(`File ${outputFilePath} does not exist, creating it...`);\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n await translateFile(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locales,\n baseLocale,\n aiOptions,\n configOptions,\n oAuth2AccessToken,\n customInstructions\n );\n })\n )\n );\n\n await Promise.all(tasks);\n};\n"],"mappings":"AAAA,SAAoB,mBAAmB;AACvC,SAAS,oBAAyC;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,OAAO,QAAQ;AACf,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,gBAAgB;AACzB,OAAO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ChB;AAAA,UACE,qBAAqB,OAAO,OAAO;AAAA,YACjC;AAAA,YACA,QAAQ;AAAA,UACV,CAAC,KAAK,MAAM;AAAA,QACd;AAEA,cAAM,uBAAuB;AAAA,UAC3B,cAAc,QAAQ;AAAA,UACtB;AAAA,QACF;AACA,cAAM,iBAAiB;AAAA,UACrB;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAGA,YAAI,CAAC,WAAW,cAAc,GAAG;AAC/B,oBAAU,QAAQ,cAAc,iCAAiC;AACjE,oBAAU,QAAQ,cAAc,GAAG,EAAE,WAAW,KAAK,CAAC;AACtD,wBAAc,gBAAgB,EAAE;AAAA,QAClC;AAEA,cAAM,uBAAuB,uBAAuB,gBAAgB;AAAA,UAClE;AAAA,UACA;AAAA,QACF,CAAC;AAED,YAAI,qBAAqB,WAAW;AAClC,oBAAU,qBAAqB,OAAO;AACtC;AAAA,QACF;AAEA,cAAM;AAAA,UACJ;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,QAAM,QAAQ,IAAI,KAAK;AACzB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/translateDoc.ts"],"sourcesContent":["import { AIOptions, getOAuthAPI } from '@intlayer/api';\nimport {\n formatLocale,\n formatPath,\n listGitFiles,\n ListGitFilesOptions,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeNumber,\n getAppLogger,\n getConfiguration,\n GetConfigurationOptions,\n Locales,\n retryManager,\n} from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { readFile } from 'fs/promises';\nimport pLimit from 'p-limit';\nimport { dirname, join, relative } from 'path';\nimport { fileURLToPath } from 'url';\nimport { chunkText } from './utils/calculateChunks';\nimport { checkAIAccess } from './utils/checkAIAccess';\nimport { checkFileModifiedRange } from './utils/checkFileModifiedRange';\nimport { chunkInference } from './utils/chunkInference';\nimport { fixChunkStartEndChars } from './utils/fixChunkStartEndChars';\nimport { getChunk } from './utils/getChunk';\nimport { getOutputFilePath } from './utils/getOutputFilePath';\n\nconst isESModule = typeof import.meta.url === 'string';\n\nconst dir = isESModule ? dirname(fileURLToPath(import.meta.url)) : __dirname;\n\n/**\n * Translate a single file for a given locale\n */\nexport const translateFile = async (\n baseFilePath: string,\n outputFilePath: string,\n locale: Locales,\n baseLocale: Locales,\n aiOptions?: AIOptions,\n configOptions?: GetConfigurationOptions,\n oAuth2AccessToken?: string,\n customInstructions?: string\n) => {\n try {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration, {\n config: {\n prefix: '',\n },\n });\n\n // Determine the target locale file path\n const fileContent = await readFile(baseFilePath, 'utf-8');\n let fileResultContent = fileContent;\n\n // Prepare the base prompt for ChatGPT\n const basePrompt = (\n await readFile(join(dir, './prompts/TRANSLATE_PROMPT.md'), 'utf-8')\n )\n .replaceAll('{{localeName}}', `${formatLocale(locale, false)}`)\n .replaceAll('{{baseLocaleName}}', `${formatLocale(baseLocale, false)}`)\n .replace('{{applicationContext}}', aiOptions?.applicationContext ?? '-')\n .replace('{{customInstructions}}', customInstructions ?? '-');\n\n const filePrexixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}] `;\n const filePrefix = [\n colon(filePrexixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n const prefixText = `${ANSIColors.GREY_DARK}[${formatPath(baseFilePath)}${ANSIColors.GREY_DARK}][${formatLocale(locale)}${ANSIColors.GREY_DARK}] `;\n const prefix = [\n colon(prefixText, { colSize: 40 }),\n `→ ${ANSIColors.RESET}`,\n ].join('');\n\n // 1. Chunk the file by number of lines instead of characters\n const chunks = chunkText(fileContent);\n appLogger(\n `${filePrefix}Base file splitted into ${colorizeNumber(chunks.length)} chunks`\n );\n\n for await (const [i, chunk] of chunks.entries()) {\n const isFirstChunk = i === 0;\n\n // Build the chunk-specific prompt\n const getPrevChunkPrompt = () =>\n `**CHUNK ${i} of ${chunks.length}** that has been translated in ${formatLocale(locale)}:\\n` +\n `///chunkStart///` +\n getChunk(fileResultContent, chunks[i - 1]) +\n `///chunkEnd///`;\n\n const getBaseChunkContextPrompt = () =>\n `**CHUNK ${i + 1} to ${Math.min(i + 3, chunks.length)} of ${chunks.length}** is the base chunk in ${formatLocale(baseLocale, false)} as reference.\\n` +\n `///chunksStart///` +\n (chunks[i - 1]?.content ?? '') +\n chunks[i].content +\n (chunks[i + 1]?.content ?? '') +\n `///chunksEnd///`;\n\n const fileToTranslateCurrentChunk = chunk.content;\n\n // Make the actual translation call\n let chunkTranslation = await retryManager(async () => {\n const result = await chunkInference(\n [\n { role: 'system', content: basePrompt },\n\n { role: 'system', content: getBaseChunkContextPrompt() },\n ...(isFirstChunk\n ? []\n : [{ role: 'system', content: getPrevChunkPrompt() } as const]),\n {\n role: 'system',\n content: `The next user message will be the **CHUNK ${colorizeNumber(i + 1)} of ${colorizeNumber(chunks.length)}** in ${formatLocale(baseLocale, false)} to translate in ${formatLocale(locale, false)}:`,\n },\n { role: 'user', content: fileToTranslateCurrentChunk },\n ],\n aiOptions,\n oAuth2AccessToken\n );\n\n appLogger(\n `${prefix}${colorizeNumber(result.tokenUsed)} tokens used - Chunk ${colorizeNumber(i + 1)} of ${colorizeNumber(chunks.length)}`\n );\n\n const fixedTranslatedChunkResult = fixChunkStartEndChars(\n result?.fileContent,\n fileToTranslateCurrentChunk\n );\n\n return fixedTranslatedChunkResult;\n })();\n\n // Replace the chunk in the file content\n fileResultContent = fileResultContent.replace(\n fileToTranslateCurrentChunk,\n chunkTranslation\n );\n }\n\n // 4. Write the final translation to the appropriate file path\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, fileResultContent);\n\n const relativePath = relative(\n configuration.content.baseDir,\n outputFilePath\n );\n\n appLogger(\n `${colorize('✔', ANSIColors.GREEN)} File ${formatPath(relativePath)} created/updated successfully.`\n );\n } catch (error) {\n console.error(error);\n }\n};\n\ntype TranslateDocOptions = {\n docPattern: string[];\n locales: Locales[];\n excludedGlobPattern: string[];\n baseLocale: Locales;\n aiOptions?: AIOptions;\n nbSimultaneousFileProcessed?: number;\n configOptions?: GetConfigurationOptions;\n customInstructions?: string;\n skipIfModifiedBefore?: number | string | Date;\n skipIfModifiedAfter?: number | string | Date;\n gitOptions?: ListGitFilesOptions;\n};\n\n/**\n * Main translate function: scans all .md files in \"en/\" (unless you specified DOC_LIST),\n * then translates them to each locale in LOCALE_LIST.\n */\nexport const translateDoc = async ({\n docPattern,\n locales,\n excludedGlobPattern,\n baseLocale,\n aiOptions,\n nbSimultaneousFileProcessed,\n configOptions,\n customInstructions,\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n gitOptions,\n}: TranslateDocOptions) => {\n const configuration = getConfiguration(configOptions);\n const appLogger = getAppLogger(configuration, {\n config: {\n prefix: '',\n },\n });\n\n if (nbSimultaneousFileProcessed && nbSimultaneousFileProcessed > 10) {\n appLogger(\n `Warning: nbSimultaneousFileProcessed is set to ${nbSimultaneousFileProcessed}, which is greater than 10. Setting it to 10.`\n );\n nbSimultaneousFileProcessed = 10; // Limit the number of simultaneous file processed to 10\n }\n\n const limit = pLimit(nbSimultaneousFileProcessed ?? 3);\n\n let docList: string[] = fg.sync(docPattern, {\n ignore: excludedGlobPattern,\n });\n\n checkAIAccess(configuration, aiOptions);\n\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 docList = docList.filter((path) =>\n gitChangedFiles.some((gitFile) => join(process.cwd(), path) === gitFile)\n );\n }\n }\n\n let oAuth2AccessToken: string | undefined;\n if (configuration.editor.clientId) {\n const intlayerAuthAPI = getOAuthAPI(configuration);\n const oAuth2TokenResult = await intlayerAuthAPI.getOAuth2AccessToken();\n\n oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n }\n\n appLogger(`Base locale is ${formatLocale(baseLocale)}`);\n appLogger(\n `Translating ${colorizeNumber(locales.length)} locales: [ ${formatLocale(locales)} ]`\n );\n\n appLogger(`Translating ${colorizeNumber(docList.length)} files:`);\n appLogger(docList.map((path) => ` - ${formatPath(path)}\\n`));\n\n const tasks = docList.map((docPath) =>\n locales.flatMap((locale) =>\n limit(async () => {\n appLogger(\n `Translating file: ${formatPath(docPath)} to ${formatLocale(locale)}`\n );\n\n const absoluteBaseFilePath = join(\n configuration.content.baseDir,\n docPath\n );\n const outputFilePath = getOutputFilePath(\n absoluteBaseFilePath,\n locale,\n baseLocale\n );\n\n // check if the file exist, otherwise create it\n if (!existsSync(outputFilePath)) {\n appLogger(`File ${outputFilePath} does not exist, creating it...`);\n mkdirSync(dirname(outputFilePath), { recursive: true });\n writeFileSync(outputFilePath, '');\n }\n\n const fileModificationData = checkFileModifiedRange(outputFilePath, {\n skipIfModifiedBefore,\n skipIfModifiedAfter,\n });\n\n if (fileModificationData.isSkipped) {\n appLogger(fileModificationData.message);\n return;\n }\n\n await translateFile(\n absoluteBaseFilePath,\n outputFilePath,\n locale as Locales,\n baseLocale,\n aiOptions,\n configOptions,\n oAuth2AccessToken,\n customInstructions\n );\n })\n )\n );\n\n await Promise.all(tasks);\n};\n"],"mappings":"AAAA,SAAoB,mBAAmB;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,OACK;AACP,OAAO,QAAQ;AACf,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,gBAAgB;AACzB,OAAO,YAAY;AACnB,SAAS,SAAS,MAAM,gBAAgB;AACxC,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,8BAA8B;A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
|
|
|
1
1
|
import { getAppLogger } from "@intlayer/config";
|
|
2
2
|
const checkAIAccess = (configuration, aiOptions) => {
|
|
3
|
-
const appLogger = getAppLogger(configuration
|
|
3
|
+
const appLogger = getAppLogger(configuration, {
|
|
4
|
+
config: {
|
|
5
|
+
prefix: ""
|
|
6
|
+
}
|
|
7
|
+
});
|
|
4
8
|
if (!configuration.editor.clientId && !configuration.editor.clientSecret && !configuration.ai?.apiKey && !aiOptions?.apiKey) {
|
|
5
9
|
appLogger("AI options or API key not provided. Skipping AI translation.", {
|
|
6
10
|
level: "error"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/checkAIAccess.ts"],"sourcesContent":["import type { AIOptions } from '@intlayer/api';\nimport { getAppLogger, type IntlayerConfig } from '@intlayer/config';\n\nexport const checkAIAccess = (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions\n) => {\n const appLogger = getAppLogger(configuration);\n\n if (\n !configuration.editor.clientId &&\n !configuration.editor.clientSecret &&\n !configuration.ai?.apiKey &&\n !aiOptions?.apiKey\n ) {\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"],"mappings":"AACA,SAAS,oBAAyC;AAE3C,MAAM,gBAAgB,CAC3B,eACA,cACG;AACH,QAAM,YAAY,aAAa,
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/checkAIAccess.ts"],"sourcesContent":["import type { AIOptions } from '@intlayer/api';\nimport { getAppLogger, type IntlayerConfig } from '@intlayer/config';\n\nexport const checkAIAccess = (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions\n) => {\n const appLogger = getAppLogger(configuration, {\n config: {\n prefix: '',\n },\n });\n\n if (\n !configuration.editor.clientId &&\n !configuration.editor.clientSecret &&\n !configuration.ai?.apiKey &&\n !aiOptions?.apiKey\n ) {\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"],"mappings":"AACA,SAAS,oBAAyC;AAE3C,MAAM,gBAAgB,CAC3B,eACA,cACG;AACH,QAAM,YAAY,aAAa,eAAe;AAAA,IAC5C,QAAQ;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACF,CAAC;AAED,MACE,CAAC,cAAc,OAAO,YACtB,CAAC,cAAc,OAAO,gBACtB,CAAC,cAAc,IAAI,UACnB,CAAC,WAAW,QACZ;AACA,cAAU,gEAAgE;AAAA,MACxE,OAAO;AAAA,IACT,CAAC;AAGD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { DictionaryAPI } from '@intlayer/backend';
|
|
2
|
+
import { type IntlayerConfig } from '@intlayer/config/client';
|
|
3
|
+
export type IntlayerMessageEvent = MessageEvent;
|
|
4
|
+
/**
|
|
5
|
+
* IntlayerEventListener class to listen for dictionary changes via SSE (Server-Sent Events).
|
|
6
|
+
*
|
|
7
|
+
* Usage example:
|
|
8
|
+
*
|
|
9
|
+
* import { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary';
|
|
10
|
+
* import { IntlayerEventListener } from '@intlayer/api';
|
|
11
|
+
*
|
|
12
|
+
* export const checkDictionaryChanges = async () => {
|
|
13
|
+
* // Instantiate the listener
|
|
14
|
+
* const eventListener = new IntlayerEventListener();
|
|
15
|
+
*
|
|
16
|
+
* // Set up your callbacks
|
|
17
|
+
* eventListener.onDictionaryChange = async (dictionary) => {
|
|
18
|
+
* await buildIntlayerDictionary(dictionary);
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* // Initialize the listener
|
|
22
|
+
* await eventListener.initialize();
|
|
23
|
+
*
|
|
24
|
+
* // Optionally, clean up later when you’re done
|
|
25
|
+
* // eventListener.cleanup();
|
|
26
|
+
* };
|
|
27
|
+
*/
|
|
28
|
+
export declare class IntlayerEventListener {
|
|
29
|
+
private intlayerConfig;
|
|
30
|
+
private appLogger;
|
|
31
|
+
private eventSource;
|
|
32
|
+
private reconnectAttempts;
|
|
33
|
+
private maxReconnectAttempts;
|
|
34
|
+
private reconnectDelay;
|
|
35
|
+
private isManuallyDisconnected;
|
|
36
|
+
private reconnectTimeout;
|
|
37
|
+
/**
|
|
38
|
+
* Callback triggered when a Dictionary is ADDED.
|
|
39
|
+
*/
|
|
40
|
+
onDictionaryAdded?: (dictionary: DictionaryAPI) => any;
|
|
41
|
+
/**
|
|
42
|
+
* Callback triggered when a Dictionary is UPDATED.
|
|
43
|
+
*/
|
|
44
|
+
onDictionaryChange?: (dictionary: DictionaryAPI) => any;
|
|
45
|
+
/**
|
|
46
|
+
* Callback triggered when a Dictionary is DELETED.
|
|
47
|
+
*/
|
|
48
|
+
onDictionaryDeleted?: (dictionary: DictionaryAPI) => any;
|
|
49
|
+
/**
|
|
50
|
+
* Callback triggered when connection is established or re-established.
|
|
51
|
+
*/
|
|
52
|
+
onConnectionOpen?: () => any;
|
|
53
|
+
/**
|
|
54
|
+
* Callback triggered when connection encounters an error.
|
|
55
|
+
*/
|
|
56
|
+
onConnectionError?: (error: Event) => any;
|
|
57
|
+
constructor(intlayerConfig?: IntlayerConfig);
|
|
58
|
+
/**
|
|
59
|
+
* Initializes the EventSource connection using the given intlayerConfig
|
|
60
|
+
* (or the default config if none was provided).
|
|
61
|
+
*/
|
|
62
|
+
initialize(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Establishes the EventSource connection with automatic reconnection support.
|
|
65
|
+
*/
|
|
66
|
+
private connect;
|
|
67
|
+
/**
|
|
68
|
+
* Cleans up (closes) the EventSource connection.
|
|
69
|
+
*/
|
|
70
|
+
cleanup(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Schedules a reconnection attempt with exponential backoff.
|
|
73
|
+
*/
|
|
74
|
+
private scheduleReconnect;
|
|
75
|
+
/**
|
|
76
|
+
* Handles incoming SSE messages, parses the event data,
|
|
77
|
+
* and invokes the appropriate callback.
|
|
78
|
+
*/
|
|
79
|
+
private handleMessage;
|
|
80
|
+
/**
|
|
81
|
+
* Handles any SSE errors and attempts reconnection if appropriate.
|
|
82
|
+
*/
|
|
83
|
+
private handleError;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=IntlayerEventListener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntlayerEventListener.d.ts","sourceRoot":"","sources":["../../src/IntlayerEventListener.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,yBAAyB,CAAC;AAG5E,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,qBAAqB;IAmCpB,OAAO,CAAC,cAAc;IAlClC,OAAO,CAAC,SAAS,CAA+B;IAEhD,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,oBAAoB,CAAK;IACjC,OAAO,CAAC,cAAc,CAAQ;IAC9B,OAAO,CAAC,sBAAsB,CAAS;IACvC,OAAO,CAAC,gBAAgB,CAA+B;IAEvD;;OAEG;IACI,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,GAAG,CAAC;IAE9D;;OAEG;IACI,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,GAAG,CAAC;IAE/D;;OAEG;IACI,mBAAmB,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,GAAG,CAAC;IAEhE;;OAEG;IACI,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC;IAEpC;;OAEG;IACI,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,GAAG,CAAC;gBAE7B,cAAc,GAAE,cAA8B;IAIlE;;;OAGG;IACU,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKxC;;OAEG;YACW,OAAO;IA+CrB;;OAEG;IACI,OAAO,IAAI,IAAI;IActB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAgCzB;;;OAGG;YACW,aAAa;IA2C3B;;OAEG;IACH,OAAO,CAAC,WAAW;CAwCpB"}
|
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;AA2BpC,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,OA2VzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,KAAK,aAAa,GAAG;IACnB,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,UAAU,aAAa,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,KAAK,aAAa,GAAG;IACnB,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,UAAU,aAAa,SAShD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type IntlayerConfig, Locales } from '@intlayer/config';
|
|
2
|
+
import { type AutoFill, type Dictionary } from '@intlayer/core';
|
|
3
|
+
export declare const autoFill: (fullDictionary: Dictionary, contentDeclarationFile: Dictionary, autoFillOptions: AutoFill, outputLocales: Locales[], parentLocales: Locales[], configuration: IntlayerConfig) => Promise<void>;
|
|
4
|
+
//# sourceMappingURL=autoFill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoFill.d.ts","sourceRoot":"","sources":["../../../src/fill/autoFill.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,cAAc,EACnB,OAAO,EACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,QAAQ,EAEb,KAAK,UAAU,EAGhB,MAAM,gBAAgB,CAAC;AAGxB,eAAO,MAAM,QAAQ,GACnB,gBAAgB,UAAU,EAC1B,wBAAwB,UAAU,EAClC,iBAAiB,QAAQ,EACzB,eAAe,OAAO,EAAE,EACxB,eAAe,OAAO,EAAE,EACxB,eAAe,cAAc,kBAsF9B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type IntlayerConfig, Locales } from '@intlayer/config';
|
|
2
|
+
import { type AutoFill } from '@intlayer/core';
|
|
3
|
+
export type AutoFillData = {
|
|
4
|
+
localeList: Locales[];
|
|
5
|
+
filePath: string;
|
|
6
|
+
isPerLocale: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const formatAutoFillData: (autoFillField: AutoFill, localeList: Locales[], filePath: string, dictionaryKey: string, configuration: IntlayerConfig) => AutoFillData[];
|
|
9
|
+
//# sourceMappingURL=formatAutoFillData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatAutoFillData.d.ts","sourceRoot":"","sources":["../../../src/fill/formatAutoFillData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,eAAe,QAAQ,EACvB,YAAY,OAAO,EAAE,EACrB,UAAU,MAAM,EAChB,eAAe,MAAM,EACrB,eAAe,cAAc,KAC5B,YAAY,EAmGd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatAutoFilledFilePath.d.ts","sourceRoot":"","sources":["../../../src/fill/formatAutoFilledFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAmB3C,eAAO,MAAM,wBAAwB,GACnC,eAAe,MAAM,EACrB,eAAe,MAAM,EACrB,oBAAoB,MAAM,EAC1B,SAAS,MAAM,EACf,SAAS,OAAO,WAkBjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTargetDictionary.d.ts","sourceRoot":"","sources":["../../../src/fill/getTargetDictionary.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,KAAG,CAAC,EAA2B,CAAC;AAE7E,eAAO,MAAM,mBAAmB,GAAU,SAAS,WAAW,6CA2D7D,CAAC"}
|
|
@@ -16,13 +16,10 @@ export type FillOptions = {
|
|
|
16
16
|
aiOptions?: AIOptions;
|
|
17
17
|
verbose?: boolean;
|
|
18
18
|
nbConcurrentTranslations?: number;
|
|
19
|
-
|
|
20
|
-
export type AutoFillData = {
|
|
21
|
-
localeList: Locales[];
|
|
22
|
-
filePath: string;
|
|
19
|
+
build?: boolean;
|
|
23
20
|
};
|
|
24
21
|
/**
|
|
25
22
|
* Fill translations based on the provided options.
|
|
26
23
|
*/
|
|
27
24
|
export declare const fill: (options: FillOptions) => Promise<void>;
|
|
28
|
-
//# sourceMappingURL=
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fill/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyB,MAAM,eAAe,CAAC;AACjE,OAAO,EAGL,mBAAmB,EAMpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAKL,uBAAuB,EACvB,OAAO,EACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAEL,KAAK,UAAU,EAIhB,MAAM,gBAAgB,CAAC;AAWxB,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,aAAa,CAAC,EAAE,uBAAuB,CAAC;IACxC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,IAAI,GAAU,SAAS,WAAW,KAAG,OAAO,CAAC,IAAI,CAkQ7D,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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,QAAQ,CAAC;AACvB,cAAc,0BAA0B,CAAC;AACzC,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,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,QAAQ,CAAC;AACvB,cAAc,0BAA0B,CAAC;AACzC,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type GetConfigurationOptions } from '@intlayer/config';
|
|
2
|
-
type GetContentDeclarationOptions = {
|
|
3
|
-
exclude?: string[];
|
|
4
|
-
configOptions?: GetConfigurationOptions;
|
|
5
|
-
};
|
|
6
|
-
export declare const getContentDeclaration: (options?: GetContentDeclarationOptions) => string[];
|
|
7
2
|
type ListContentDeclarationOptions = {
|
|
8
3
|
configOptions?: GetConfigurationOptions;
|
|
9
4
|
};
|
|
5
|
+
export declare const listContentDeclarationRows: (options?: ListContentDeclarationOptions) => {
|
|
6
|
+
key: string;
|
|
7
|
+
path: string;
|
|
8
|
+
}[];
|
|
10
9
|
export declare const listContentDeclaration: (options?: ListContentDeclarationOptions) => void;
|
|
11
10
|
export {};
|
|
12
11
|
//# sourceMappingURL=listContentDeclaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listContentDeclaration.d.ts","sourceRoot":"","sources":["../../src/listContentDeclaration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listContentDeclaration.d.ts","sourceRoot":"","sources":["../../src/listContentDeclaration.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAI1B,KAAK,6BAA6B,GAAG;IACnC,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACrC,UAAU,6BAA6B;;;GAWxC,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,UAAU,6BAA6B,SA+BxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveSync.d.ts","sourceRoot":"","sources":["../../src/liveSync.ts"],"names":[],"mappings":"AAaA,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAWF,eAAO,MAAM,QAAQ,GAAU,UAAU,eAAe,kBAuQvD,CAAC"}
|
package/dist/types/pull.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/pull.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/pull.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,uBAAuB,EAExB,MAAM,kBAAkB,CAAC;AAK1B,KAAK,WAAW,GAAG;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAYF;;;GAGG;AACH,eAAO,MAAM,IAAI,GAAU,UAAU,WAAW,KAAG,OAAO,CAAC,IAAI,CAqJ9D,CAAC"}
|
package/dist/types/push.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ type PushOptions = {
|
|
|
8
8
|
configOptions?: GetConfigurationOptions;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* Get all
|
|
11
|
+
* Get all local dictionaries and push them simultaneously.
|
|
12
12
|
*/
|
|
13
13
|
export declare const push: (options?: PushOptions) => Promise<void>;
|
|
14
14
|
export {};
|
package/dist/types/push.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/push.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/push.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAIL,uBAAuB,EAExB,MAAM,kBAAkB,CAAC;AAO1B,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;AAYF;;GAEG;AACH,eAAO,MAAM,IAAI,GAAU,UAAU,WAAW,KAAG,OAAO,CAAC,IAAI,CAyK9D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushConfig.d.ts","sourceRoot":"","sources":["../../src/pushConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,KAAK,WAAW,GAAG;IACjB,
|
|
1
|
+
{"version":3,"file":"pushConfig.d.ts","sourceRoot":"","sources":["../../src/pushConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,KAAK,WAAW,GAAG;IACjB,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,UAAU,WAAW,kBA2CrD,CAAC"}
|