lingo.dev 0.117.26 → 0.118.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/build/cli.cjs +539 -214
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +482 -157
- package/build/cli.mjs.map +1 -1
- package/package.json +5 -5
package/build/cli.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
|
|
|
16
16
|
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
17
17
|
var _path = require('path'); var path14 = _interopRequireWildcard(_path); var path15 = _interopRequireWildcard(_path);
|
|
18
18
|
var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);
|
|
19
|
-
var _fs = require('fs'); var
|
|
19
|
+
var _fs = require('fs'); var fs12 = _interopRequireWildcard(_fs);
|
|
20
20
|
var _ini = require('ini'); var _ini2 = _interopRequireDefault(_ini);
|
|
21
21
|
function getSettings(explicitApiKey) {
|
|
22
22
|
const env = _loadEnv();
|
|
@@ -28,15 +28,18 @@ function getSettings(explicitApiKey) {
|
|
|
28
28
|
auth: {
|
|
29
29
|
apiKey: explicitApiKey || env.LINGODOTDEV_API_KEY || _optionalChain([systemFile, 'access', _38 => _38.auth, 'optionalAccess', _39 => _39.apiKey]) || defaults2.auth.apiKey,
|
|
30
30
|
apiUrl: env.LINGODOTDEV_API_URL || _optionalChain([systemFile, 'access', _40 => _40.auth, 'optionalAccess', _41 => _41.apiUrl]) || defaults2.auth.apiUrl,
|
|
31
|
-
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _42 => _42.auth, 'optionalAccess', _43 => _43.webUrl]) || defaults2.auth.webUrl
|
|
31
|
+
webUrl: env.LINGODOTDEV_WEB_URL || _optionalChain([systemFile, 'access', _42 => _42.auth, 'optionalAccess', _43 => _43.webUrl]) || defaults2.auth.webUrl,
|
|
32
|
+
vnext: {
|
|
33
|
+
apiKey: env.LINGO_API_KEY || _optionalChain([systemFile, 'access', _44 => _44.auth, 'optionalAccess', _45 => _45.vnext, 'optionalAccess', _46 => _46.apiKey])
|
|
34
|
+
}
|
|
32
35
|
},
|
|
33
36
|
llm: {
|
|
34
|
-
openaiApiKey: env.OPENAI_API_KEY || _optionalChain([systemFile, 'access',
|
|
35
|
-
anthropicApiKey: env.ANTHROPIC_API_KEY || _optionalChain([systemFile, 'access',
|
|
36
|
-
groqApiKey: env.GROQ_API_KEY || _optionalChain([systemFile, 'access',
|
|
37
|
-
googleApiKey: env.GOOGLE_API_KEY || _optionalChain([systemFile, 'access',
|
|
38
|
-
openrouterApiKey: env.OPENROUTER_API_KEY || _optionalChain([systemFile, 'access',
|
|
39
|
-
mistralApiKey: env.MISTRAL_API_KEY || _optionalChain([systemFile, 'access',
|
|
37
|
+
openaiApiKey: env.OPENAI_API_KEY || _optionalChain([systemFile, 'access', _47 => _47.llm, 'optionalAccess', _48 => _48.openaiApiKey]),
|
|
38
|
+
anthropicApiKey: env.ANTHROPIC_API_KEY || _optionalChain([systemFile, 'access', _49 => _49.llm, 'optionalAccess', _50 => _50.anthropicApiKey]),
|
|
39
|
+
groqApiKey: env.GROQ_API_KEY || _optionalChain([systemFile, 'access', _51 => _51.llm, 'optionalAccess', _52 => _52.groqApiKey]),
|
|
40
|
+
googleApiKey: env.GOOGLE_API_KEY || _optionalChain([systemFile, 'access', _53 => _53.llm, 'optionalAccess', _54 => _54.googleApiKey]),
|
|
41
|
+
openrouterApiKey: env.OPENROUTER_API_KEY || _optionalChain([systemFile, 'access', _55 => _55.llm, 'optionalAccess', _56 => _56.openrouterApiKey]),
|
|
42
|
+
mistralApiKey: env.MISTRAL_API_KEY || _optionalChain([systemFile, 'access', _57 => _57.llm, 'optionalAccess', _58 => _58.mistralApiKey])
|
|
40
43
|
}
|
|
41
44
|
};
|
|
42
45
|
}
|
|
@@ -59,7 +62,10 @@ var SettingsSchema = _zod2.default.object({
|
|
|
59
62
|
auth: _zod2.default.object({
|
|
60
63
|
apiKey: _zod2.default.string(),
|
|
61
64
|
apiUrl: _zod2.default.string(),
|
|
62
|
-
webUrl: _zod2.default.string()
|
|
65
|
+
webUrl: _zod2.default.string(),
|
|
66
|
+
vnext: _zod2.default.object({
|
|
67
|
+
apiKey: _zod2.default.string().optional()
|
|
68
|
+
}).optional()
|
|
63
69
|
}),
|
|
64
70
|
llm: _zod2.default.object({
|
|
65
71
|
openaiApiKey: _zod2.default.string().optional(),
|
|
@@ -88,6 +94,7 @@ function _loadEnv() {
|
|
|
88
94
|
LINGODOTDEV_API_KEY: _zod2.default.string().optional(),
|
|
89
95
|
LINGODOTDEV_API_URL: _zod2.default.string().optional(),
|
|
90
96
|
LINGODOTDEV_WEB_URL: _zod2.default.string().optional(),
|
|
97
|
+
LINGO_API_KEY: _zod2.default.string().optional(),
|
|
91
98
|
OPENAI_API_KEY: _zod2.default.string().optional(),
|
|
92
99
|
ANTHROPIC_API_KEY: _zod2.default.string().optional(),
|
|
93
100
|
GROQ_API_KEY: _zod2.default.string().optional(),
|
|
@@ -98,13 +105,16 @@ function _loadEnv() {
|
|
|
98
105
|
}
|
|
99
106
|
function _loadSystemFile() {
|
|
100
107
|
const settingsFilePath = _getSettingsFilePath();
|
|
101
|
-
const content =
|
|
108
|
+
const content = fs12.default.existsSync(settingsFilePath) ? fs12.default.readFileSync(settingsFilePath, "utf-8") : "";
|
|
102
109
|
const data = _ini2.default.parse(content);
|
|
103
110
|
return _zod2.default.object({
|
|
104
111
|
auth: _zod2.default.object({
|
|
105
112
|
apiKey: _zod2.default.string().optional(),
|
|
106
113
|
apiUrl: _zod2.default.string().optional(),
|
|
107
|
-
webUrl: _zod2.default.string().optional()
|
|
114
|
+
webUrl: _zod2.default.string().optional(),
|
|
115
|
+
vnext: _zod2.default.object({
|
|
116
|
+
apiKey: _zod2.default.string().optional()
|
|
117
|
+
}).optional()
|
|
108
118
|
}).optional(),
|
|
109
119
|
llm: _zod2.default.object({
|
|
110
120
|
openaiApiKey: _zod2.default.string().optional(),
|
|
@@ -119,7 +129,7 @@ function _loadSystemFile() {
|
|
|
119
129
|
function _saveSystemFile(settings) {
|
|
120
130
|
const settingsFilePath = _getSettingsFilePath();
|
|
121
131
|
const content = _ini2.default.stringify(settings);
|
|
122
|
-
|
|
132
|
+
fs12.default.writeFileSync(settingsFilePath, content);
|
|
123
133
|
}
|
|
124
134
|
function _getSettingsFilePath() {
|
|
125
135
|
const settingsFile = ".lingodotdevrc";
|
|
@@ -145,43 +155,43 @@ Please use LINGODOTDEV_API_KEY instead.
|
|
|
145
155
|
function _envVarsInfo() {
|
|
146
156
|
const env = _loadEnv();
|
|
147
157
|
const systemFile = _loadSystemFile();
|
|
148
|
-
if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access',
|
|
158
|
+
if (env.LINGODOTDEV_API_KEY && _optionalChain([systemFile, 'access', _59 => _59.auth, 'optionalAccess', _60 => _60.apiKey])) {
|
|
149
159
|
console.info(
|
|
150
160
|
"\x1B[36m%s\x1B[0m",
|
|
151
161
|
`\u2139\uFE0F Using LINGODOTDEV_API_KEY env var instead of credentials from user config`
|
|
152
162
|
);
|
|
153
163
|
}
|
|
154
|
-
if (env.OPENAI_API_KEY && _optionalChain([systemFile, 'access',
|
|
164
|
+
if (env.OPENAI_API_KEY && _optionalChain([systemFile, 'access', _61 => _61.llm, 'optionalAccess', _62 => _62.openaiApiKey])) {
|
|
155
165
|
console.info(
|
|
156
166
|
"\x1B[36m%s\x1B[0m",
|
|
157
167
|
`\u2139\uFE0F Using OPENAI_API_KEY env var instead of key from user config.`
|
|
158
168
|
);
|
|
159
169
|
}
|
|
160
|
-
if (env.ANTHROPIC_API_KEY && _optionalChain([systemFile, 'access',
|
|
170
|
+
if (env.ANTHROPIC_API_KEY && _optionalChain([systemFile, 'access', _63 => _63.llm, 'optionalAccess', _64 => _64.anthropicApiKey])) {
|
|
161
171
|
console.info(
|
|
162
172
|
"\x1B[36m%s\x1B[0m",
|
|
163
173
|
`\u2139\uFE0F Using ANTHROPIC_API_KEY env var instead of key from user config`
|
|
164
174
|
);
|
|
165
175
|
}
|
|
166
|
-
if (env.GROQ_API_KEY && _optionalChain([systemFile, 'access',
|
|
176
|
+
if (env.GROQ_API_KEY && _optionalChain([systemFile, 'access', _65 => _65.llm, 'optionalAccess', _66 => _66.groqApiKey])) {
|
|
167
177
|
console.info(
|
|
168
178
|
"\x1B[36m%s\x1B[0m",
|
|
169
179
|
`\u2139\uFE0F Using GROQ_API_KEY env var instead of key from user config`
|
|
170
180
|
);
|
|
171
181
|
}
|
|
172
|
-
if (env.GOOGLE_API_KEY && _optionalChain([systemFile, 'access',
|
|
182
|
+
if (env.GOOGLE_API_KEY && _optionalChain([systemFile, 'access', _67 => _67.llm, 'optionalAccess', _68 => _68.googleApiKey])) {
|
|
173
183
|
console.info(
|
|
174
184
|
"\x1B[36m%s\x1B[0m",
|
|
175
185
|
`\u2139\uFE0F Using GOOGLE_API_KEY env var instead of key from user config`
|
|
176
186
|
);
|
|
177
187
|
}
|
|
178
|
-
if (env.OPENROUTER_API_KEY && _optionalChain([systemFile, 'access',
|
|
188
|
+
if (env.OPENROUTER_API_KEY && _optionalChain([systemFile, 'access', _69 => _69.llm, 'optionalAccess', _70 => _70.openrouterApiKey])) {
|
|
179
189
|
console.info(
|
|
180
190
|
"\x1B[36m%s\x1B[0m",
|
|
181
191
|
`\u2139\uFE0F Using OPENROUTER_API_KEY env var instead of key from user config`
|
|
182
192
|
);
|
|
183
193
|
}
|
|
184
|
-
if (env.MISTRAL_API_KEY && _optionalChain([systemFile, 'access',
|
|
194
|
+
if (env.MISTRAL_API_KEY && _optionalChain([systemFile, 'access', _71 => _71.llm, 'optionalAccess', _72 => _72.mistralApiKey])) {
|
|
185
195
|
console.info(
|
|
186
196
|
"\x1B[36m%s\x1B[0m",
|
|
187
197
|
`\u2139\uFE0F Using MISTRAL_API_KEY env var instead of key from user config`
|
|
@@ -199,6 +209,12 @@ function _envVarsInfo() {
|
|
|
199
209
|
`\u2139\uFE0F Using LINGODOTDEV_WEB_URL: ${env.LINGODOTDEV_WEB_URL}`
|
|
200
210
|
);
|
|
201
211
|
}
|
|
212
|
+
if (env.LINGO_API_KEY && _optionalChain([systemFile, 'access', _73 => _73.auth, 'optionalAccess', _74 => _74.vnext, 'optionalAccess', _75 => _75.apiKey])) {
|
|
213
|
+
console.info(
|
|
214
|
+
"\x1B[36m%s\x1B[0m",
|
|
215
|
+
`\u2139\uFE0F Using LINGO_API_KEY env var instead of key from user config`
|
|
216
|
+
);
|
|
217
|
+
}
|
|
202
218
|
}
|
|
203
219
|
|
|
204
220
|
// src/cli/utils/errors.ts
|
|
@@ -264,10 +280,10 @@ var LocalizationError = (_class5 = class extends Error {
|
|
|
264
280
|
constructor(message, context) {
|
|
265
281
|
super(message);_class5.prototype.__init5.call(this);;
|
|
266
282
|
this.name = "LocalizationError";
|
|
267
|
-
this.bucket = _optionalChain([context, 'optionalAccess',
|
|
268
|
-
this.sourceLocale = _optionalChain([context, 'optionalAccess',
|
|
269
|
-
this.targetLocale = _optionalChain([context, 'optionalAccess',
|
|
270
|
-
this.pathPattern = _optionalChain([context, 'optionalAccess',
|
|
283
|
+
this.bucket = _optionalChain([context, 'optionalAccess', _76 => _76.bucket]);
|
|
284
|
+
this.sourceLocale = _optionalChain([context, 'optionalAccess', _77 => _77.sourceLocale]);
|
|
285
|
+
this.targetLocale = _optionalChain([context, 'optionalAccess', _78 => _78.targetLocale]);
|
|
286
|
+
this.pathPattern = _optionalChain([context, 'optionalAccess', _79 => _79.pathPattern]);
|
|
271
287
|
}
|
|
272
288
|
}, _class5);
|
|
273
289
|
var BucketProcessingError = (_class6 = class extends Error {
|
|
@@ -403,7 +419,7 @@ function createAuthenticator(params) {
|
|
|
403
419
|
});
|
|
404
420
|
if (res.ok) {
|
|
405
421
|
const payload = await res.json();
|
|
406
|
-
if (!_optionalChain([payload, 'optionalAccess',
|
|
422
|
+
if (!_optionalChain([payload, 'optionalAccess', _80 => _80.email])) {
|
|
407
423
|
return null;
|
|
408
424
|
}
|
|
409
425
|
return {
|
|
@@ -515,6 +531,10 @@ var colors = {
|
|
|
515
531
|
};
|
|
516
532
|
|
|
517
533
|
// src/cli/utils/ui.ts
|
|
534
|
+
|
|
535
|
+
function isCI() {
|
|
536
|
+
return Boolean(process.env.CI) || fs12.default.existsSync("/.dockerenv");
|
|
537
|
+
}
|
|
518
538
|
async function renderClear() {
|
|
519
539
|
console.log("\x1Bc");
|
|
520
540
|
}
|
|
@@ -543,10 +563,12 @@ async function renderHero() {
|
|
|
543
563
|
const label2 = "\u2B50 Star the repo:";
|
|
544
564
|
const label3 = "\u{1F3AE} Join Discord:";
|
|
545
565
|
const maxLabelWidth = 17;
|
|
566
|
+
const isCIEnv = isCI();
|
|
567
|
+
const docsUrl = isCIEnv ? "https://lingo.dev/ci" : "https://lingo.dev/cli";
|
|
546
568
|
console.log(
|
|
547
569
|
`${_chalk2.default.hex(colors.blue)(label1.padEnd(maxLabelWidth + 1))} ${_chalk2.default.hex(
|
|
548
570
|
colors.blue
|
|
549
|
-
)(
|
|
571
|
+
)(docsUrl)}`
|
|
550
572
|
);
|
|
551
573
|
console.log(
|
|
552
574
|
`${_chalk2.default.hex(colors.blue)(label2.padEnd(maxLabelWidth))} ${_chalk2.default.hex(
|
|
@@ -598,7 +620,7 @@ async function renderSummary(results) {
|
|
|
598
620
|
if (succeededResults.length > 0) {
|
|
599
621
|
console.log(_chalk2.default.hex(colors.green)("\n[Processed Files]"));
|
|
600
622
|
for (const result of succeededResults) {
|
|
601
|
-
const displayPath = _optionalChain([result, 'access',
|
|
623
|
+
const displayPath = _optionalChain([result, 'access', _81 => _81.pathPattern, 'optionalAccess', _82 => _82.replace, 'call', _83 => _83("[locale]", result.targetLocale)]) || "unknown";
|
|
602
624
|
console.log(
|
|
603
625
|
` \u2713 ${_chalk2.default.dim(displayPath)} ${_chalk2.default.hex(colors.yellow)(`(${result.sourceLocale} \u2192 ${result.targetLocale})`)}`
|
|
604
626
|
);
|
|
@@ -607,7 +629,7 @@ async function renderSummary(results) {
|
|
|
607
629
|
if (skippedResults.length > 0) {
|
|
608
630
|
console.log(_chalk2.default.hex(colors.blue)("\n[Cached Files]"));
|
|
609
631
|
for (const result of skippedResults) {
|
|
610
|
-
const displayPath = _optionalChain([result, 'access',
|
|
632
|
+
const displayPath = _optionalChain([result, 'access', _84 => _84.pathPattern, 'optionalAccess', _85 => _85.replace, 'call', _86 => _86("[locale]", result.targetLocale)]) || "unknown";
|
|
611
633
|
console.log(
|
|
612
634
|
` \u26A1 ${_chalk2.default.dim(displayPath)} ${_chalk2.default.hex(colors.yellow)(`(${result.sourceLocale} \u2192 ${result.targetLocale})`)}`
|
|
613
635
|
);
|
|
@@ -616,12 +638,12 @@ async function renderSummary(results) {
|
|
|
616
638
|
if (failedResults.length > 0) {
|
|
617
639
|
console.log(_chalk2.default.hex(colors.orange)("\n[Failed Files]"));
|
|
618
640
|
for (const result of failedResults) {
|
|
619
|
-
const displayPath = _optionalChain([result, 'access',
|
|
641
|
+
const displayPath = _optionalChain([result, 'access', _87 => _87.pathPattern, 'optionalAccess', _88 => _88.replace, 'call', _89 => _89("[locale]", result.targetLocale)]) || "unknown";
|
|
620
642
|
console.log(
|
|
621
643
|
` \u274C ${_chalk2.default.dim(displayPath)} ${_chalk2.default.hex(colors.yellow)(`(${result.sourceLocale} \u2192 ${result.targetLocale})`)}`
|
|
622
644
|
);
|
|
623
645
|
console.log(
|
|
624
|
-
` ${_chalk2.default.hex(colors.white)(String(_optionalChain([result, 'access',
|
|
646
|
+
` ${_chalk2.default.hex(colors.white)(String(_optionalChain([result, 'access', _90 => _90.error, 'optionalAccess', _91 => _91.message]) || "Unknown error"))}`
|
|
625
647
|
);
|
|
626
648
|
}
|
|
627
649
|
}
|
|
@@ -717,11 +739,11 @@ var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
|
717
739
|
var __spec = require('@lingo.dev/_spec');
|
|
718
740
|
function getConfig(resave = true) {
|
|
719
741
|
const configFilePath = _getConfigFilePath();
|
|
720
|
-
const configFileExists =
|
|
742
|
+
const configFileExists = fs12.default.existsSync(configFilePath);
|
|
721
743
|
if (!configFileExists) {
|
|
722
744
|
return null;
|
|
723
745
|
}
|
|
724
|
-
const fileContents =
|
|
746
|
+
const fileContents = fs12.default.readFileSync(configFilePath, "utf8");
|
|
725
747
|
const rawConfig = JSON.parse(fileContents);
|
|
726
748
|
const result = __spec.parseI18nConfig.call(void 0, rawConfig);
|
|
727
749
|
const didConfigChange = !_lodash2.default.isEqual(rawConfig, result);
|
|
@@ -733,7 +755,7 @@ function getConfig(resave = true) {
|
|
|
733
755
|
function saveConfig(config) {
|
|
734
756
|
const configFilePath = _getConfigFilePath();
|
|
735
757
|
const serialized = JSON.stringify(config, null, 2);
|
|
736
|
-
|
|
758
|
+
fs12.default.writeFileSync(configFilePath, serialized);
|
|
737
759
|
return config;
|
|
738
760
|
}
|
|
739
761
|
function _getConfigFilePath() {
|
|
@@ -852,10 +874,10 @@ function ensurePatterns(patterns, source) {
|
|
|
852
874
|
}
|
|
853
875
|
patterns.forEach((pattern) => {
|
|
854
876
|
const filePath = pattern.replace("[locale]", source);
|
|
855
|
-
if (!
|
|
877
|
+
if (!fs12.default.existsSync(filePath)) {
|
|
856
878
|
const defaultContent = getDefaultContent(path14.default.extname(filePath), source);
|
|
857
|
-
|
|
858
|
-
|
|
879
|
+
fs12.default.mkdirSync(path14.default.dirname(filePath), { recursive: true });
|
|
880
|
+
fs12.default.writeFileSync(filePath, defaultContent);
|
|
859
881
|
}
|
|
860
882
|
});
|
|
861
883
|
}
|
|
@@ -935,27 +957,27 @@ function updateGitignore() {
|
|
|
935
957
|
return;
|
|
936
958
|
}
|
|
937
959
|
const gitignorePath = path14.default.join(projectRoot, ".gitignore");
|
|
938
|
-
if (!
|
|
960
|
+
if (!fs12.default.existsSync(gitignorePath)) {
|
|
939
961
|
return;
|
|
940
962
|
}
|
|
941
|
-
const gitignore =
|
|
963
|
+
const gitignore = fs12.default.readFileSync(gitignorePath, "utf8").split("\n");
|
|
942
964
|
const cacheIsIgnored = gitignore.includes(cacheFile);
|
|
943
965
|
if (!cacheIsIgnored) {
|
|
944
966
|
let content = "";
|
|
945
|
-
content =
|
|
967
|
+
content = fs12.default.readFileSync(gitignorePath, "utf8");
|
|
946
968
|
if (content !== "" && !content.endsWith("\n")) {
|
|
947
969
|
content += "\n";
|
|
948
970
|
}
|
|
949
971
|
content += `${cacheFile}
|
|
950
972
|
`;
|
|
951
|
-
|
|
973
|
+
fs12.default.writeFileSync(gitignorePath, content);
|
|
952
974
|
}
|
|
953
975
|
}
|
|
954
976
|
function findCurrentProjectRoot() {
|
|
955
977
|
let currentDir = process.cwd();
|
|
956
978
|
while (currentDir !== path14.default.parse(currentDir).root) {
|
|
957
979
|
const gitDirPath = path14.default.join(currentDir, ".git");
|
|
958
|
-
if (
|
|
980
|
+
if (fs12.default.existsSync(gitDirPath) && fs12.default.lstatSync(gitDirPath).isDirectory()) {
|
|
959
981
|
return currentDir;
|
|
960
982
|
}
|
|
961
983
|
currentDir = path14.default.dirname(currentDir);
|
|
@@ -1003,23 +1025,23 @@ function makePlatformInitializer(config, spinner) {
|
|
|
1003
1025
|
name: config.name,
|
|
1004
1026
|
isEnabled: () => {
|
|
1005
1027
|
const filePath = path14.default.join(process.cwd(), config.checkPath);
|
|
1006
|
-
return
|
|
1028
|
+
return fs12.default.existsSync(filePath);
|
|
1007
1029
|
},
|
|
1008
1030
|
init: async () => {
|
|
1009
1031
|
const filePath = path14.default.join(process.cwd(), config.ciConfigPath);
|
|
1010
1032
|
const dirPath = path14.default.dirname(filePath);
|
|
1011
|
-
if (!
|
|
1012
|
-
|
|
1033
|
+
if (!fs12.default.existsSync(dirPath)) {
|
|
1034
|
+
fs12.default.mkdirSync(dirPath, { recursive: true });
|
|
1013
1035
|
}
|
|
1014
1036
|
let canWrite = true;
|
|
1015
|
-
if (
|
|
1037
|
+
if (fs12.default.existsSync(filePath)) {
|
|
1016
1038
|
canWrite = await _prompts.confirm.call(void 0, {
|
|
1017
1039
|
message: `File ${filePath} already exists. Do you want to overwrite it?`,
|
|
1018
1040
|
default: false
|
|
1019
1041
|
});
|
|
1020
1042
|
}
|
|
1021
1043
|
if (canWrite) {
|
|
1022
|
-
|
|
1044
|
+
fs12.default.writeFileSync(filePath, config.ciConfigContent);
|
|
1023
1045
|
spinner.succeed(`CI/CD initialized for ${config.name}`);
|
|
1024
1046
|
} else {
|
|
1025
1047
|
spinner.warn(`CI/CD not initialized for ${config.name}`);
|
|
@@ -1159,7 +1181,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
1159
1181
|
for (const p of values) {
|
|
1160
1182
|
try {
|
|
1161
1183
|
const dirPath = path14.default.dirname(p);
|
|
1162
|
-
const stats =
|
|
1184
|
+
const stats = fs12.default.statSync(dirPath);
|
|
1163
1185
|
if (!stats.isDirectory()) {
|
|
1164
1186
|
throw new Error(`${dirPath} is not a directory`);
|
|
1165
1187
|
}
|
|
@@ -1267,7 +1289,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
1267
1289
|
});
|
|
1268
1290
|
const auth2 = await newAuthenticator.whoami();
|
|
1269
1291
|
if (auth2) {
|
|
1270
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
1292
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _92 => _92.email])}`);
|
|
1271
1293
|
} else {
|
|
1272
1294
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
1273
1295
|
}
|
|
@@ -1302,11 +1324,11 @@ var config_default = new (0, _interactivecommander.Command)().command("config").
|
|
|
1302
1324
|
});
|
|
1303
1325
|
function loadReplexicaFileConfig() {
|
|
1304
1326
|
const replexicaConfigPath = path14.default.resolve(process.cwd(), "i18n.json");
|
|
1305
|
-
const fileExists =
|
|
1327
|
+
const fileExists = fs12.default.existsSync(replexicaConfigPath);
|
|
1306
1328
|
if (!fileExists) {
|
|
1307
1329
|
return void 0;
|
|
1308
1330
|
}
|
|
1309
|
-
const fileContent =
|
|
1331
|
+
const fileContent = fs12.default.readFileSync(replexicaConfigPath, "utf-8");
|
|
1310
1332
|
const replexicaFileConfig = JSON.parse(fileContent);
|
|
1311
1333
|
return replexicaFileConfig;
|
|
1312
1334
|
}
|
|
@@ -1357,7 +1379,7 @@ function getBuckets(i18nConfig) {
|
|
|
1357
1379
|
const includeItems = bucketEntry.include.map(
|
|
1358
1380
|
(item) => resolveBucketItem(item)
|
|
1359
1381
|
);
|
|
1360
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
1382
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _93 => _93.exclude, 'optionalAccess', _94 => _94.map, 'call', _95 => _95(
|
|
1361
1383
|
(item) => resolveBucketItem(item)
|
|
1362
1384
|
)]);
|
|
1363
1385
|
const config = {
|
|
@@ -1395,7 +1417,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
1395
1417
|
delimiter: pattern.delimiter
|
|
1396
1418
|
}))
|
|
1397
1419
|
);
|
|
1398
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
1420
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _96 => _96.flatMap, 'call', _97 => _97(
|
|
1399
1421
|
(pattern) => expandPlaceholderedGlob(
|
|
1400
1422
|
pattern.path,
|
|
1401
1423
|
__spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)
|
|
@@ -1561,12 +1583,12 @@ function composeLoaders(...loaders) {
|
|
|
1561
1583
|
return {
|
|
1562
1584
|
init: async () => {
|
|
1563
1585
|
for (const loader of loaders) {
|
|
1564
|
-
await _optionalChain([loader, 'access',
|
|
1586
|
+
await _optionalChain([loader, 'access', _98 => _98.init, 'optionalCall', _99 => _99()]);
|
|
1565
1587
|
}
|
|
1566
1588
|
},
|
|
1567
1589
|
setDefaultLocale(locale) {
|
|
1568
1590
|
for (const loader of loaders) {
|
|
1569
|
-
_optionalChain([loader, 'access',
|
|
1591
|
+
_optionalChain([loader, 'access', _100 => _100.setDefaultLocale, 'optionalCall', _101 => _101(locale)]);
|
|
1570
1592
|
}
|
|
1571
1593
|
return this;
|
|
1572
1594
|
},
|
|
@@ -1587,7 +1609,7 @@ function composeLoaders(...loaders) {
|
|
|
1587
1609
|
pullHints: async (originalInput) => {
|
|
1588
1610
|
let result = originalInput;
|
|
1589
1611
|
for (let i = 0; i < loaders.length; i++) {
|
|
1590
|
-
const subResult = await _optionalChain([loaders, 'access',
|
|
1612
|
+
const subResult = await _optionalChain([loaders, 'access', _102 => _102[i], 'access', _103 => _103.pullHints, 'optionalCall', _104 => _104(result)]);
|
|
1591
1613
|
if (subResult) {
|
|
1592
1614
|
result = subResult;
|
|
1593
1615
|
}
|
|
@@ -1611,7 +1633,7 @@ function createLoader(lDefinition) {
|
|
|
1611
1633
|
if (state.initCtx) {
|
|
1612
1634
|
return state.initCtx;
|
|
1613
1635
|
}
|
|
1614
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1636
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _105 => _105.init, 'optionalCall', _106 => _106()]);
|
|
1615
1637
|
return state.initCtx;
|
|
1616
1638
|
},
|
|
1617
1639
|
setDefaultLocale(locale) {
|
|
@@ -1622,7 +1644,7 @@ function createLoader(lDefinition) {
|
|
|
1622
1644
|
return this;
|
|
1623
1645
|
},
|
|
1624
1646
|
async pullHints(originalInput) {
|
|
1625
|
-
return _optionalChain([lDefinition, 'access',
|
|
1647
|
+
return _optionalChain([lDefinition, 'access', _107 => _107.pullHints, 'optionalCall', _108 => _108(originalInput || state.originalInput)]);
|
|
1626
1648
|
},
|
|
1627
1649
|
async pull(locale, input2) {
|
|
1628
1650
|
if (!state.defaultLocale) {
|
|
@@ -1878,7 +1900,7 @@ function updateContext(contextStack, line, parsedJson, arrayObjectCount) {
|
|
|
1878
1900
|
if (closeBrackets > openBrackets) {
|
|
1879
1901
|
for (let i = 0; i < closeBrackets - openBrackets; i++) {
|
|
1880
1902
|
const popped = contextStack.pop();
|
|
1881
|
-
if (_optionalChain([popped, 'optionalAccess',
|
|
1903
|
+
if (_optionalChain([popped, 'optionalAccess', _109 => _109.isArray])) {
|
|
1882
1904
|
const depth = contextStack.length;
|
|
1883
1905
|
delete arrayObjectCount[depth];
|
|
1884
1906
|
}
|
|
@@ -1961,7 +1983,7 @@ function createDenormalizeLoader(options) {
|
|
|
1961
1983
|
const preservedObjects = {};
|
|
1962
1984
|
const nonPreservedInput = {};
|
|
1963
1985
|
for (const [key, value] of Object.entries(inputDenormalized)) {
|
|
1964
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
1986
|
+
if (_optionalChain([options, 'optionalAccess', _110 => _110.shouldPreserveObject, 'optionalCall', _111 => _111(value)])) {
|
|
1965
1987
|
preservedObjects[key] = value;
|
|
1966
1988
|
} else {
|
|
1967
1989
|
nonPreservedInput[key] = value;
|
|
@@ -1994,7 +2016,7 @@ function createNormalizeLoader() {
|
|
|
1994
2016
|
return normalized;
|
|
1995
2017
|
},
|
|
1996
2018
|
push: async (locale, data, originalInput) => {
|
|
1997
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
2019
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _112 => _112.keysMap]), () => ( {}));
|
|
1998
2020
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1999
2021
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
2000
2022
|
delimiter: "/",
|
|
@@ -2128,8 +2150,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
2128
2150
|
if (!templateData) {
|
|
2129
2151
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
2130
2152
|
}
|
|
2131
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
2132
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
2153
|
+
if (_optionalChain([templateData, 'optionalAccess', _113 => _113.match, 'call', _114 => _114(/[\r\n]$/)])) {
|
|
2154
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _115 => _115.includes, 'call', _116 => _116("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _117 => _117.includes, 'call', _118 => _118("\r")]) ? "\r" : "\n";
|
|
2133
2155
|
return ending;
|
|
2134
2156
|
}
|
|
2135
2157
|
return "";
|
|
@@ -2404,15 +2426,15 @@ function createAilLoader() {
|
|
|
2404
2426
|
}
|
|
2405
2427
|
const entries = dictionary.ENTRY || [];
|
|
2406
2428
|
for (const entry of entries) {
|
|
2407
|
-
const id = _optionalChain([entry, 'access',
|
|
2429
|
+
const id = _optionalChain([entry, 'access', _119 => _119.$, 'optionalAccess', _120 => _120.id]);
|
|
2408
2430
|
if (!id) {
|
|
2409
2431
|
continue;
|
|
2410
2432
|
}
|
|
2411
2433
|
const strings = entry.STRING || [];
|
|
2412
2434
|
const sourceString = strings.find(
|
|
2413
|
-
(s) => _optionalChain([s, 'access',
|
|
2435
|
+
(s) => _optionalChain([s, 'access', _121 => _121.$, 'optionalAccess', _122 => _122.lang]) === locale
|
|
2414
2436
|
);
|
|
2415
|
-
if (_optionalChain([sourceString, 'optionalAccess',
|
|
2437
|
+
if (_optionalChain([sourceString, 'optionalAccess', _123 => _123.$, 'access', _124 => _124.value])) {
|
|
2416
2438
|
result[id] = sourceString.$.value;
|
|
2417
2439
|
}
|
|
2418
2440
|
}
|
|
@@ -2454,7 +2476,7 @@ function createAilLoader() {
|
|
|
2454
2476
|
}
|
|
2455
2477
|
const entries = dictionary.ENTRY || [];
|
|
2456
2478
|
for (const [id, value] of Object.entries(data)) {
|
|
2457
|
-
let entry = entries.find((e) => _optionalChain([e, 'access',
|
|
2479
|
+
let entry = entries.find((e) => _optionalChain([e, 'access', _125 => _125.$, 'optionalAccess', _126 => _126.id]) === id);
|
|
2458
2480
|
if (!entry) {
|
|
2459
2481
|
entry = {
|
|
2460
2482
|
$: { id },
|
|
@@ -2466,7 +2488,7 @@ function createAilLoader() {
|
|
|
2466
2488
|
entry.STRING = [];
|
|
2467
2489
|
}
|
|
2468
2490
|
let targetString = entry.STRING.find(
|
|
2469
|
-
(s) => _optionalChain([s, 'access',
|
|
2491
|
+
(s) => _optionalChain([s, 'access', _127 => _127.$, 'optionalAccess', _128 => _128.lang]) === locale
|
|
2470
2492
|
);
|
|
2471
2493
|
if (targetString) {
|
|
2472
2494
|
targetString.$.value = value;
|
|
@@ -2597,7 +2619,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2597
2619
|
const resourceNodes = [];
|
|
2598
2620
|
let metaIndex = 0;
|
|
2599
2621
|
for (const child of resourcesNode.$$) {
|
|
2600
|
-
const elementName = _optionalChain([child, 'optionalAccess',
|
|
2622
|
+
const elementName = _optionalChain([child, 'optionalAccess', _129 => _129["#name"]]);
|
|
2601
2623
|
if (!isResourceElementName(elementName)) {
|
|
2602
2624
|
continue;
|
|
2603
2625
|
}
|
|
@@ -2605,11 +2627,11 @@ async function parseAndroidDocument(input2) {
|
|
|
2605
2627
|
if (!meta || meta.type !== elementName) {
|
|
2606
2628
|
continue;
|
|
2607
2629
|
}
|
|
2608
|
-
const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2630
|
+
const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _130 => _130.$, 'optionalAccess', _131 => _131.name]), () => ( meta.name));
|
|
2609
2631
|
if (!name) {
|
|
2610
2632
|
continue;
|
|
2611
2633
|
}
|
|
2612
|
-
const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2634
|
+
const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess', _132 => _132.$, 'optionalAccess', _133 => _133.translatable]), () => ( ""))).toLowerCase() !== "false";
|
|
2613
2635
|
switch (meta.type) {
|
|
2614
2636
|
case "string": {
|
|
2615
2637
|
resourceNodes.push({
|
|
@@ -2622,7 +2644,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2622
2644
|
break;
|
|
2623
2645
|
}
|
|
2624
2646
|
case "string-array": {
|
|
2625
|
-
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2647
|
+
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _134 => _134.item]), () => ( []));
|
|
2626
2648
|
const items = [];
|
|
2627
2649
|
const templateItems = meta.items;
|
|
2628
2650
|
for (let i = 0; i < Math.max(itemNodes.length, templateItems.length); i++) {
|
|
@@ -2646,7 +2668,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2646
2668
|
break;
|
|
2647
2669
|
}
|
|
2648
2670
|
case "plurals": {
|
|
2649
|
-
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2671
|
+
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _135 => _135.item]), () => ( []));
|
|
2650
2672
|
const templateItems = meta.items;
|
|
2651
2673
|
const items = [];
|
|
2652
2674
|
for (const templateItem of templateItems) {
|
|
@@ -2655,7 +2677,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2655
2677
|
continue;
|
|
2656
2678
|
}
|
|
2657
2679
|
const nodeItem = itemNodes.find(
|
|
2658
|
-
(item) => _optionalChain([item, 'optionalAccess',
|
|
2680
|
+
(item) => _optionalChain([item, 'optionalAccess', _136 => _136.$, 'optionalAccess', _137 => _137.quantity]) === quantity
|
|
2659
2681
|
);
|
|
2660
2682
|
if (!nodeItem) {
|
|
2661
2683
|
continue;
|
|
@@ -2929,7 +2951,7 @@ function cloneResourceNode(resource) {
|
|
|
2929
2951
|
const nodeClone = deepClone(resource.node);
|
|
2930
2952
|
const itemNodes = _nullishCoalesce(nodeClone.item, () => ( []));
|
|
2931
2953
|
const items = itemNodes.map((itemNode, index) => {
|
|
2932
|
-
const templateMeta = _nullishCoalesce(_nullishCoalesce(_optionalChain([resource, 'access',
|
|
2954
|
+
const templateMeta = _nullishCoalesce(_nullishCoalesce(_optionalChain([resource, 'access', _138 => _138.items, 'access', _139 => _139[index], 'optionalAccess', _140 => _140.meta]), () => ( _optionalChain([resource, 'access', _141 => _141.items, 'access', _142 => _142[resource.items.length - 1], 'optionalAccess', _143 => _143.meta]))), () => ( makeTextMeta([])));
|
|
2933
2955
|
return {
|
|
2934
2956
|
node: itemNode,
|
|
2935
2957
|
meta: cloneTextMeta(templateMeta)
|
|
@@ -2949,7 +2971,7 @@ function cloneResourceNode(resource) {
|
|
|
2949
2971
|
const items = [];
|
|
2950
2972
|
for (const templateItem of resource.items) {
|
|
2951
2973
|
const cloneNode = itemNodes.find(
|
|
2952
|
-
(item) => _optionalChain([item, 'optionalAccess',
|
|
2974
|
+
(item) => _optionalChain([item, 'optionalAccess', _144 => _144.$, 'optionalAccess', _145 => _145.quantity]) === templateItem.quantity
|
|
2953
2975
|
);
|
|
2954
2976
|
if (!cloneNode) {
|
|
2955
2977
|
continue;
|
|
@@ -3205,8 +3227,8 @@ function cloneDocumentStructure(document) {
|
|
|
3205
3227
|
resourceNodes.map((r) => resourceLookupKey(r.type, r.name))
|
|
3206
3228
|
);
|
|
3207
3229
|
let filtered = resourcesClone.$$.filter((child) => {
|
|
3208
|
-
const elementName = _optionalChain([child, 'optionalAccess',
|
|
3209
|
-
const name = _optionalChain([child, 'optionalAccess',
|
|
3230
|
+
const elementName = _optionalChain([child, 'optionalAccess', _146 => _146["#name"]]);
|
|
3231
|
+
const name = _optionalChain([child, 'optionalAccess', _147 => _147.$, 'optionalAccess', _148 => _148.name]);
|
|
3210
3232
|
if (!isResourceElementName(elementName) || !name) {
|
|
3211
3233
|
return true;
|
|
3212
3234
|
}
|
|
@@ -3215,7 +3237,7 @@ function cloneDocumentStructure(document) {
|
|
|
3215
3237
|
const cleaned = [];
|
|
3216
3238
|
let lastWasWhitespace = false;
|
|
3217
3239
|
for (const child of filtered) {
|
|
3218
|
-
const isWhitespace = _optionalChain([child, 'optionalAccess',
|
|
3240
|
+
const isWhitespace = _optionalChain([child, 'optionalAccess', _149 => _149["#name"]]) === "__text__" && (!child._ || child._.trim() === "");
|
|
3219
3241
|
if (isWhitespace) {
|
|
3220
3242
|
if (!lastWasWhitespace) {
|
|
3221
3243
|
cleaned.push(child);
|
|
@@ -3237,8 +3259,8 @@ function buildResourceLookup(resources) {
|
|
|
3237
3259
|
const lookup = /* @__PURE__ */ new Map();
|
|
3238
3260
|
const children = Array.isArray(resources.$$) ? resources.$$ : [];
|
|
3239
3261
|
for (const child of children) {
|
|
3240
|
-
const type = _optionalChain([child, 'optionalAccess',
|
|
3241
|
-
const name = _optionalChain([child, 'optionalAccess',
|
|
3262
|
+
const type = _optionalChain([child, 'optionalAccess', _150 => _150["#name"]]);
|
|
3263
|
+
const name = _optionalChain([child, 'optionalAccess', _151 => _151.$, 'optionalAccess', _152 => _152.name]);
|
|
3242
3264
|
if (!type || !name || !isResourceElementName(type)) {
|
|
3243
3265
|
continue;
|
|
3244
3266
|
}
|
|
@@ -3267,7 +3289,7 @@ function cloneResourceNodeFromLookup(resource, lookup) {
|
|
|
3267
3289
|
}
|
|
3268
3290
|
case "string-array": {
|
|
3269
3291
|
const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
|
|
3270
|
-
(child) => _optionalChain([child, 'optionalAccess',
|
|
3292
|
+
(child) => _optionalChain([child, 'optionalAccess', _153 => _153["#name"]]) === "item"
|
|
3271
3293
|
);
|
|
3272
3294
|
node.item = childItems;
|
|
3273
3295
|
if (childItems.length < resource.items.length) {
|
|
@@ -3296,12 +3318,12 @@ function cloneResourceNodeFromLookup(resource, lookup) {
|
|
|
3296
3318
|
}
|
|
3297
3319
|
case "plurals": {
|
|
3298
3320
|
const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
|
|
3299
|
-
(child) => _optionalChain([child, 'optionalAccess',
|
|
3321
|
+
(child) => _optionalChain([child, 'optionalAccess', _154 => _154["#name"]]) === "item"
|
|
3300
3322
|
);
|
|
3301
3323
|
node.item = childItems;
|
|
3302
3324
|
const itemMap = /* @__PURE__ */ new Map();
|
|
3303
3325
|
for (const item of childItems) {
|
|
3304
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
3326
|
+
if (_optionalChain([item, 'optionalAccess', _155 => _155.$, 'optionalAccess', _156 => _156.quantity])) {
|
|
3305
3327
|
itemMap.set(item.$.quantity, item);
|
|
3306
3328
|
}
|
|
3307
3329
|
}
|
|
@@ -3591,7 +3613,7 @@ var _sync3 = require('csv-stringify/sync');
|
|
|
3591
3613
|
|
|
3592
3614
|
function detectKeyColumnName(csvString) {
|
|
3593
3615
|
const row = _sync.parse.call(void 0, csvString)[0];
|
|
3594
|
-
const firstColumn = _optionalChain([row, 'optionalAccess',
|
|
3616
|
+
const firstColumn = _optionalChain([row, 'optionalAccess', _157 => _157[0], 'optionalAccess', _158 => _158.trim, 'call', _159 => _159()]);
|
|
3595
3617
|
return firstColumn || "KEY";
|
|
3596
3618
|
}
|
|
3597
3619
|
function createCsvLoader() {
|
|
@@ -3821,7 +3843,7 @@ function createHtmlLoader() {
|
|
|
3821
3843
|
const attrs = LOCALIZABLE_ATTRIBUTES2[tagName];
|
|
3822
3844
|
if (!attrs) return;
|
|
3823
3845
|
for (const attr of attrs) {
|
|
3824
|
-
const value = _optionalChain([element, 'access',
|
|
3846
|
+
const value = _optionalChain([element, 'access', _160 => _160.attribs, 'optionalAccess', _161 => _161[attr]]);
|
|
3825
3847
|
if (value && value.trim()) {
|
|
3826
3848
|
result[`${path19}#${attr}`] = value.trim();
|
|
3827
3849
|
}
|
|
@@ -4013,7 +4035,7 @@ function createMarkdownLoader() {
|
|
|
4013
4035
|
yaml: yamlEngine
|
|
4014
4036
|
}
|
|
4015
4037
|
});
|
|
4016
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
4038
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _162 => _162.trim, 'call', _163 => _163()]), () => ( ""))).filter(Boolean);
|
|
4017
4039
|
return {
|
|
4018
4040
|
...Object.fromEntries(
|
|
4019
4041
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -4032,7 +4054,7 @@ function createMarkdownLoader() {
|
|
|
4032
4054
|
);
|
|
4033
4055
|
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(
|
|
4034
4056
|
([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())
|
|
4035
|
-
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
4057
|
+
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _164 => _164.trim, 'call', _165 => _165()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
4036
4058
|
if (Object.keys(frontmatter).length > 0) {
|
|
4037
4059
|
content = `
|
|
4038
4060
|
${content}`;
|
|
@@ -4057,7 +4079,7 @@ function createMarkdocLoader() {
|
|
|
4057
4079
|
const result = {};
|
|
4058
4080
|
const counters = {};
|
|
4059
4081
|
traverseAndExtract(ast, "", result, counters);
|
|
4060
|
-
if (_optionalChain([ast, 'access',
|
|
4082
|
+
if (_optionalChain([ast, 'access', _166 => _166.attributes, 'optionalAccess', _167 => _167.frontmatter])) {
|
|
4061
4083
|
const frontmatter = _yaml2.default.parse(ast.attributes.frontmatter);
|
|
4062
4084
|
Object.entries(frontmatter).forEach(([key, value]) => {
|
|
4063
4085
|
if (typeof value === "string") {
|
|
@@ -4103,7 +4125,7 @@ function traverseAndExtract(node, path19, result, counters, parentType) {
|
|
|
4103
4125
|
if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
|
|
4104
4126
|
semanticType = nodeSemanticType;
|
|
4105
4127
|
}
|
|
4106
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
4128
|
+
if (node.type === "text" && _optionalChain([node, 'access', _168 => _168.attributes, 'optionalAccess', _169 => _169.content])) {
|
|
4107
4129
|
const content = node.attributes.content;
|
|
4108
4130
|
if (typeof content === "string" && content.trim()) {
|
|
4109
4131
|
if (semanticType) {
|
|
@@ -4130,7 +4152,7 @@ function buildPathMap(node, path19, counters, pathMap, parentType) {
|
|
|
4130
4152
|
if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
|
|
4131
4153
|
semanticType = nodeSemanticType;
|
|
4132
4154
|
}
|
|
4133
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
4155
|
+
if (node.type === "text" && _optionalChain([node, 'access', _170 => _170.attributes, 'optionalAccess', _171 => _171.content])) {
|
|
4134
4156
|
const content = node.attributes.content;
|
|
4135
4157
|
if (typeof content === "string" && content.trim()) {
|
|
4136
4158
|
if (semanticType) {
|
|
@@ -4153,7 +4175,7 @@ function applyTranslations(node, path19, data, pathMap) {
|
|
|
4153
4175
|
if (!node || typeof node !== "object") {
|
|
4154
4176
|
return;
|
|
4155
4177
|
}
|
|
4156
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
4178
|
+
if (node.type === "text" && _optionalChain([node, 'access', _172 => _172.attributes, 'optionalAccess', _173 => _173.content])) {
|
|
4157
4179
|
const content = node.attributes.content;
|
|
4158
4180
|
if (typeof content === "string") {
|
|
4159
4181
|
const contentPath = path19 ? `${path19}/attributes/content` : "attributes/content";
|
|
@@ -4466,7 +4488,7 @@ function isSkippableLine(line) {
|
|
|
4466
4488
|
function parsePropertyLine(line) {
|
|
4467
4489
|
const [key, ...valueParts] = line.split("=");
|
|
4468
4490
|
return {
|
|
4469
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
4491
|
+
key: _optionalChain([key, 'optionalAccess', _174 => _174.trim, 'call', _175 => _175()]) || "",
|
|
4470
4492
|
value: valueParts.join("=").trim()
|
|
4471
4493
|
};
|
|
4472
4494
|
}
|
|
@@ -4758,7 +4780,7 @@ var Parser3 = class {
|
|
|
4758
4780
|
}
|
|
4759
4781
|
}
|
|
4760
4782
|
expect(type) {
|
|
4761
|
-
if (_optionalChain([this, 'access',
|
|
4783
|
+
if (_optionalChain([this, 'access', _176 => _176.current, 'call', _177 => _177(), 'optionalAccess', _178 => _178.type]) === type) {
|
|
4762
4784
|
this.advance();
|
|
4763
4785
|
return true;
|
|
4764
4786
|
}
|
|
@@ -4835,7 +4857,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4835
4857
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
4836
4858
|
continue;
|
|
4837
4859
|
}
|
|
4838
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
4860
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _179 => _179.localizations, 'optionalAccess', _180 => _180[locale]]);
|
|
4839
4861
|
if (langTranslationEntity) {
|
|
4840
4862
|
if ("stringUnit" in langTranslationEntity) {
|
|
4841
4863
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -4849,7 +4871,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4849
4871
|
resultData[translationKey] = {};
|
|
4850
4872
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
4851
4873
|
for (const form in pluralForms) {
|
|
4852
|
-
if (_optionalChain([pluralForms, 'access',
|
|
4874
|
+
if (_optionalChain([pluralForms, 'access', _181 => _181[form], 'optionalAccess', _182 => _182.stringUnit, 'optionalAccess', _183 => _183.value])) {
|
|
4853
4875
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
4854
4876
|
}
|
|
4855
4877
|
}
|
|
@@ -4875,7 +4897,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4875
4897
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
4876
4898
|
if (typeof value === "string") {
|
|
4877
4899
|
langDataToMerge.strings[key] = {
|
|
4878
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
4900
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _184 => _184.strings, 'optionalAccess', _185 => _185[key], 'optionalAccess', _186 => _186.extractionState]),
|
|
4879
4901
|
localizations: {
|
|
4880
4902
|
[locale]: {
|
|
4881
4903
|
stringUnit: {
|
|
@@ -4890,7 +4912,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4890
4912
|
}
|
|
4891
4913
|
} else if (Array.isArray(value)) {
|
|
4892
4914
|
langDataToMerge.strings[key] = {
|
|
4893
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
4915
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _187 => _187.strings, 'optionalAccess', _188 => _188[key], 'optionalAccess', _189 => _189.extractionState]),
|
|
4894
4916
|
localizations: {
|
|
4895
4917
|
[locale]: {
|
|
4896
4918
|
stringSet: {
|
|
@@ -4948,7 +4970,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4948
4970
|
for (const [locale, localization] of Object.entries(
|
|
4949
4971
|
entity.localizations
|
|
4950
4972
|
)) {
|
|
4951
|
-
if (_optionalChain([localization, 'access',
|
|
4973
|
+
if (_optionalChain([localization, 'access', _190 => _190.variations, 'optionalAccess', _191 => _191.plural])) {
|
|
4952
4974
|
const pluralForms = localization.variations.plural;
|
|
4953
4975
|
for (const form in pluralForms) {
|
|
4954
4976
|
const pluralKey = `${translationKey}/${form}`;
|
|
@@ -4968,7 +4990,7 @@ function _removeLocale(input2, locale) {
|
|
|
4968
4990
|
const { strings } = input2;
|
|
4969
4991
|
const newStrings = _lodash2.default.cloneDeep(strings);
|
|
4970
4992
|
for (const [key, value] of Object.entries(newStrings)) {
|
|
4971
|
-
if (_optionalChain([value, 'access',
|
|
4993
|
+
if (_optionalChain([value, 'access', _192 => _192.localizations, 'optionalAccess', _193 => _193[locale]])) {
|
|
4972
4994
|
delete value.localizations[locale];
|
|
4973
4995
|
}
|
|
4974
4996
|
}
|
|
@@ -5099,7 +5121,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5099
5121
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
5100
5122
|
continue;
|
|
5101
5123
|
}
|
|
5102
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
5124
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _194 => _194.localizations, 'optionalAccess', _195 => _195[locale]]);
|
|
5103
5125
|
if (langTranslationEntity) {
|
|
5104
5126
|
if (!resultData[translationKey]) {
|
|
5105
5127
|
resultData[translationKey] = {};
|
|
@@ -5111,7 +5133,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5111
5133
|
for (const [subName, subData] of Object.entries(
|
|
5112
5134
|
langTranslationEntity.substitutions
|
|
5113
5135
|
)) {
|
|
5114
|
-
const pluralForms = _optionalChain([subData, 'access',
|
|
5136
|
+
const pluralForms = _optionalChain([subData, 'access', _196 => _196.variations, 'optionalAccess', _197 => _197.plural]);
|
|
5115
5137
|
if (pluralForms) {
|
|
5116
5138
|
const forms = {};
|
|
5117
5139
|
for (const [form, formData] of Object.entries(pluralForms)) {
|
|
@@ -5136,7 +5158,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5136
5158
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
5137
5159
|
const forms = {};
|
|
5138
5160
|
for (const [form, formData] of Object.entries(pluralForms)) {
|
|
5139
|
-
if (_optionalChain([formData, 'optionalAccess',
|
|
5161
|
+
if (_optionalChain([formData, 'optionalAccess', _198 => _198.stringUnit, 'optionalAccess', _199 => _199.value])) {
|
|
5140
5162
|
forms[form] = formData.stringUnit.value;
|
|
5141
5163
|
}
|
|
5142
5164
|
}
|
|
@@ -5179,7 +5201,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5179
5201
|
for (const [subName, subData] of Object.entries(
|
|
5180
5202
|
keyData.substitutions
|
|
5181
5203
|
)) {
|
|
5182
|
-
const pluralValue = _optionalChain([subData, 'optionalAccess',
|
|
5204
|
+
const pluralValue = _optionalChain([subData, 'optionalAccess', _200 => _200.variations, 'optionalAccess', _201 => _201.plural]);
|
|
5183
5205
|
if (pluralValue && isIcuPluralString(pluralValue)) {
|
|
5184
5206
|
try {
|
|
5185
5207
|
const pluralForms = parseIcuPluralString(pluralValue, locale);
|
|
@@ -5192,8 +5214,8 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5192
5214
|
}
|
|
5193
5215
|
};
|
|
5194
5216
|
}
|
|
5195
|
-
const sourceLocale = _optionalChain([originalInput, 'optionalAccess',
|
|
5196
|
-
const origFormatSpec = _optionalChain([originalInput, 'optionalAccess',
|
|
5217
|
+
const sourceLocale = _optionalChain([originalInput, 'optionalAccess', _202 => _202.sourceLanguage]) || "en";
|
|
5218
|
+
const origFormatSpec = _optionalChain([originalInput, 'optionalAccess', _203 => _203.strings, 'optionalAccess', _204 => _204[baseKey], 'optionalAccess', _205 => _205.localizations, 'optionalAccess', _206 => _206[sourceLocale], 'optionalAccess', _207 => _207.substitutions, 'optionalAccess', _208 => _208[subName], 'optionalAccess', _209 => _209.formatSpecifier]) || subName;
|
|
5197
5219
|
subs[subName] = {
|
|
5198
5220
|
formatSpecifier: origFormatSpec,
|
|
5199
5221
|
variations: {
|
|
@@ -5218,7 +5240,7 @@ ${error instanceof Error ? error.message : String(error)}`
|
|
|
5218
5240
|
values: keyData.stringSet
|
|
5219
5241
|
};
|
|
5220
5242
|
}
|
|
5221
|
-
if ("variations" in keyData && _optionalChain([keyData, 'access',
|
|
5243
|
+
if ("variations" in keyData && _optionalChain([keyData, 'access', _210 => _210.variations, 'optionalAccess', _211 => _211.plural])) {
|
|
5222
5244
|
const pluralValue = keyData.variations.plural;
|
|
5223
5245
|
if (isIcuPluralString(pluralValue)) {
|
|
5224
5246
|
try {
|
|
@@ -5245,7 +5267,7 @@ ${error instanceof Error ? error.message : String(error)}`
|
|
|
5245
5267
|
}
|
|
5246
5268
|
if (Object.keys(localizationData).length > 0) {
|
|
5247
5269
|
langDataToMerge.strings[baseKey] = {
|
|
5248
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
5270
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _212 => _212.strings, 'optionalAccess', _213 => _213[baseKey], 'optionalAccess', _214 => _214.extractionState]),
|
|
5249
5271
|
localizations: {
|
|
5250
5272
|
[locale]: localizationData
|
|
5251
5273
|
}
|
|
@@ -5468,8 +5490,8 @@ async function formatDataWithBiome(data, filePath, options) {
|
|
|
5468
5490
|
});
|
|
5469
5491
|
return formatted.content;
|
|
5470
5492
|
} catch (error) {
|
|
5471
|
-
const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access',
|
|
5472
|
-
if (_optionalChain([errorMessage, 'optionalAccess',
|
|
5493
|
+
const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access', _215 => _215.stackTrace, 'optionalAccess', _216 => _216.toString, 'call', _217 => _217(), 'access', _218 => _218.split, 'call', _219 => _219("\n"), 'access', _220 => _220[0]]) : "";
|
|
5494
|
+
if (_optionalChain([errorMessage, 'optionalAccess', _221 => _221.includes, 'call', _222 => _222("does not exist in the workspace")])) {
|
|
5473
5495
|
} else {
|
|
5474
5496
|
console.log(`\u26A0\uFE0F Biome skipped ${path14.default.basename(filePath)}`);
|
|
5475
5497
|
if (errorMessage) {
|
|
@@ -5516,7 +5538,7 @@ function createPoDataLoader(params) {
|
|
|
5516
5538
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
5517
5539
|
if (msgid && entry.msgid) {
|
|
5518
5540
|
const context = entry.msgctxt || "";
|
|
5519
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
5541
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _223 => _223.translations, 'access', _224 => _224[context], 'optionalAccess', _225 => _225[msgid]]);
|
|
5520
5542
|
if (fullEntry) {
|
|
5521
5543
|
result[msgid] = fullEntry;
|
|
5522
5544
|
}
|
|
@@ -5526,8 +5548,8 @@ function createPoDataLoader(params) {
|
|
|
5526
5548
|
return result;
|
|
5527
5549
|
},
|
|
5528
5550
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
5529
|
-
const currentSections = _optionalChain([pullInput, 'optionalAccess',
|
|
5530
|
-
const originalSections = _optionalChain([originalInput, 'optionalAccess',
|
|
5551
|
+
const currentSections = _optionalChain([pullInput, 'optionalAccess', _226 => _226.split, 'call', _227 => _227("\n\n"), 'access', _228 => _228.filter, 'call', _229 => _229(Boolean)]) || [];
|
|
5552
|
+
const originalSections = _optionalChain([originalInput, 'optionalAccess', _230 => _230.split, 'call', _231 => _231("\n\n"), 'access', _232 => _232.filter, 'call', _233 => _233(Boolean)]) || [];
|
|
5531
5553
|
const result = originalSections.map((section) => {
|
|
5532
5554
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
5533
5555
|
if (Object.keys(sectionPo.translations).length === 0) {
|
|
@@ -5598,8 +5620,8 @@ function createPoContentLoader() {
|
|
|
5598
5620
|
{
|
|
5599
5621
|
...entry,
|
|
5600
5622
|
msgstr: [
|
|
5601
|
-
_optionalChain([data, 'access',
|
|
5602
|
-
_optionalChain([data, 'access',
|
|
5623
|
+
_optionalChain([data, 'access', _234 => _234[entry.msgid], 'optionalAccess', _235 => _235.singular]),
|
|
5624
|
+
_optionalChain([data, 'access', _236 => _236[entry.msgid], 'optionalAccess', _237 => _237.plural]) || null
|
|
5603
5625
|
].filter(Boolean)
|
|
5604
5626
|
}
|
|
5605
5627
|
]).fromPairs().value();
|
|
@@ -5721,7 +5743,7 @@ function pullV1(xliffElement, locale, originalLocale) {
|
|
|
5721
5743
|
let key = getTransUnitKey(unit);
|
|
5722
5744
|
if (!key) return;
|
|
5723
5745
|
if (seenKeys.has(key)) {
|
|
5724
|
-
const id = _optionalChain([unit, 'access',
|
|
5746
|
+
const id = _optionalChain([unit, 'access', _238 => _238.getAttribute, 'call', _239 => _239("id"), 'optionalAccess', _240 => _240.trim, 'call', _241 => _241()]);
|
|
5725
5747
|
if (id) {
|
|
5726
5748
|
key = `${key}#${id}`;
|
|
5727
5749
|
} else {
|
|
@@ -5769,7 +5791,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
5769
5791
|
let key = getTransUnitKey(unit);
|
|
5770
5792
|
if (!key) return;
|
|
5771
5793
|
if (seenKeys.has(key)) {
|
|
5772
|
-
const id = _optionalChain([unit, 'access',
|
|
5794
|
+
const id = _optionalChain([unit, 'access', _242 => _242.getAttribute, 'call', _243 => _243("id"), 'optionalAccess', _244 => _244.trim, 'call', _245 => _245()]);
|
|
5773
5795
|
if (id) {
|
|
5774
5796
|
key = `${key}#${id}`;
|
|
5775
5797
|
} else {
|
|
@@ -5811,7 +5833,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
5811
5833
|
const translationKeys = new Set(Object.keys(translations));
|
|
5812
5834
|
existingUnits.forEach((unit, key) => {
|
|
5813
5835
|
if (!translationKeys.has(key)) {
|
|
5814
|
-
_optionalChain([unit, 'access',
|
|
5836
|
+
_optionalChain([unit, 'access', _246 => _246.parentNode, 'optionalAccess', _247 => _247.removeChild, 'call', _248 => _248(unit)]);
|
|
5815
5837
|
}
|
|
5816
5838
|
});
|
|
5817
5839
|
return serializeWithDeclaration(
|
|
@@ -5854,18 +5876,18 @@ function traverseUnitsV2(container, fileId, currentPath, result) {
|
|
|
5854
5876
|
Array.from(container.children).forEach((child) => {
|
|
5855
5877
|
const tagName = child.tagName;
|
|
5856
5878
|
if (tagName === "unit") {
|
|
5857
|
-
const unitId = _optionalChain([child, 'access',
|
|
5879
|
+
const unitId = _optionalChain([child, 'access', _249 => _249.getAttribute, 'call', _250 => _250("id"), 'optionalAccess', _251 => _251.trim, 'call', _252 => _252()]);
|
|
5858
5880
|
if (!unitId) return;
|
|
5859
5881
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
5860
5882
|
const segment = child.querySelector("segment");
|
|
5861
|
-
const source = _optionalChain([segment, 'optionalAccess',
|
|
5883
|
+
const source = _optionalChain([segment, 'optionalAccess', _253 => _253.querySelector, 'call', _254 => _254("source")]);
|
|
5862
5884
|
if (source) {
|
|
5863
5885
|
result[key] = extractTextContent(source);
|
|
5864
5886
|
} else {
|
|
5865
5887
|
result[key] = unitId;
|
|
5866
5888
|
}
|
|
5867
5889
|
} else if (tagName === "group") {
|
|
5868
|
-
const groupId = _optionalChain([child, 'access',
|
|
5890
|
+
const groupId = _optionalChain([child, 'access', _255 => _255.getAttribute, 'call', _256 => _256("id"), 'optionalAccess', _257 => _257.trim, 'call', _258 => _258()]);
|
|
5869
5891
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
5870
5892
|
traverseUnitsV2(child, fileId, newPath, result);
|
|
5871
5893
|
}
|
|
@@ -5901,12 +5923,12 @@ function indexUnitsV2(container, fileId, currentPath, index) {
|
|
|
5901
5923
|
Array.from(container.children).forEach((child) => {
|
|
5902
5924
|
const tagName = child.tagName;
|
|
5903
5925
|
if (tagName === "unit") {
|
|
5904
|
-
const unitId = _optionalChain([child, 'access',
|
|
5926
|
+
const unitId = _optionalChain([child, 'access', _259 => _259.getAttribute, 'call', _260 => _260("id"), 'optionalAccess', _261 => _261.trim, 'call', _262 => _262()]);
|
|
5905
5927
|
if (!unitId) return;
|
|
5906
5928
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
5907
5929
|
index.set(key, child);
|
|
5908
5930
|
} else if (tagName === "group") {
|
|
5909
|
-
const groupId = _optionalChain([child, 'access',
|
|
5931
|
+
const groupId = _optionalChain([child, 'access', _263 => _263.getAttribute, 'call', _264 => _264("id"), 'optionalAccess', _265 => _265.trim, 'call', _266 => _266()]);
|
|
5910
5932
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
5911
5933
|
indexUnitsV2(child, fileId, newPath, index);
|
|
5912
5934
|
}
|
|
@@ -5927,9 +5949,9 @@ function updateUnitV2(unit, value) {
|
|
|
5927
5949
|
setTextContent(source, value);
|
|
5928
5950
|
}
|
|
5929
5951
|
function getTransUnitKey(transUnit) {
|
|
5930
|
-
const resname = _optionalChain([transUnit, 'access',
|
|
5952
|
+
const resname = _optionalChain([transUnit, 'access', _267 => _267.getAttribute, 'call', _268 => _268("resname"), 'optionalAccess', _269 => _269.trim, 'call', _270 => _270()]);
|
|
5931
5953
|
if (resname) return resname;
|
|
5932
|
-
const id = _optionalChain([transUnit, 'access',
|
|
5954
|
+
const id = _optionalChain([transUnit, 'access', _271 => _271.getAttribute, 'call', _272 => _272("id"), 'optionalAccess', _273 => _273.trim, 'call', _274 => _274()]);
|
|
5933
5955
|
if (id) return id;
|
|
5934
5956
|
const sourceElement = transUnit.querySelector("source");
|
|
5935
5957
|
if (sourceElement) {
|
|
@@ -5986,7 +6008,7 @@ function formatXml(xml) {
|
|
|
5986
6008
|
if (cdataNode) {
|
|
5987
6009
|
return `${indent2}${openTag}<![CDATA[${cdataNode.nodeValue}]]></${tagName}>`;
|
|
5988
6010
|
}
|
|
5989
|
-
const textContent3 = _optionalChain([element, 'access',
|
|
6011
|
+
const textContent3 = _optionalChain([element, 'access', _275 => _275.textContent, 'optionalAccess', _276 => _276.trim, 'call', _277 => _277()]) || "";
|
|
5990
6012
|
const hasOnlyText = element.childNodes.length === 1 && element.childNodes[0].nodeType === 3;
|
|
5991
6013
|
if (hasOnlyText && textContent3) {
|
|
5992
6014
|
return `${indent2}${openTag}${textContent3}</${tagName}>`;
|
|
@@ -6279,7 +6301,7 @@ function createDatoClient(params) {
|
|
|
6279
6301
|
ids: !records.length ? void 0 : records.join(",")
|
|
6280
6302
|
}
|
|
6281
6303
|
}).catch(
|
|
6282
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6304
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _278 => _278.response, 'optionalAccess', _279 => _279.body, 'optionalAccess', _280 => _280.data, 'optionalAccess', _281 => _281[0]]) || error)
|
|
6283
6305
|
);
|
|
6284
6306
|
},
|
|
6285
6307
|
findRecordsForModel: async (modelId, records) => {
|
|
@@ -6290,10 +6312,10 @@ function createDatoClient(params) {
|
|
|
6290
6312
|
filter: {
|
|
6291
6313
|
type: modelId,
|
|
6292
6314
|
only_valid: "true",
|
|
6293
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
6315
|
+
ids: !_optionalChain([records, 'optionalAccess', _282 => _282.length]) ? void 0 : records.join(",")
|
|
6294
6316
|
}
|
|
6295
6317
|
}).catch(
|
|
6296
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6318
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _283 => _283.response, 'optionalAccess', _284 => _284.body, 'optionalAccess', _285 => _285.data, 'optionalAccess', _286 => _286[0]]) || error)
|
|
6297
6319
|
);
|
|
6298
6320
|
return result;
|
|
6299
6321
|
} catch (_error) {
|
|
@@ -6309,10 +6331,10 @@ function createDatoClient(params) {
|
|
|
6309
6331
|
updateRecord: async (id, payload) => {
|
|
6310
6332
|
try {
|
|
6311
6333
|
await dato.items.update(id, payload).catch(
|
|
6312
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6334
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _287 => _287.response, 'optionalAccess', _288 => _288.body, 'optionalAccess', _289 => _289.data, 'optionalAccess', _290 => _290[0]]) || error)
|
|
6313
6335
|
);
|
|
6314
6336
|
} catch (_error) {
|
|
6315
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
6337
|
+
if (_optionalChain([_error, 'optionalAccess', _291 => _291.attributes, 'optionalAccess', _292 => _292.details, 'optionalAccess', _293 => _293.message])) {
|
|
6316
6338
|
throw new Error(
|
|
6317
6339
|
[
|
|
6318
6340
|
`${_error.attributes.details.message}`,
|
|
@@ -6334,10 +6356,10 @@ function createDatoClient(params) {
|
|
|
6334
6356
|
enableFieldLocalization: async (args) => {
|
|
6335
6357
|
try {
|
|
6336
6358
|
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch(
|
|
6337
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6359
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _294 => _294.response, 'optionalAccess', _295 => _295.body, 'optionalAccess', _296 => _296.data, 'optionalAccess', _297 => _297[0]]) || error)
|
|
6338
6360
|
);
|
|
6339
6361
|
} catch (_error) {
|
|
6340
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
6362
|
+
if (_optionalChain([_error, 'optionalAccess', _298 => _298.attributes, 'optionalAccess', _299 => _299.code]) === "NOT_FOUND") {
|
|
6341
6363
|
throw new Error(
|
|
6342
6364
|
[
|
|
6343
6365
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -6345,7 +6367,7 @@ function createDatoClient(params) {
|
|
|
6345
6367
|
].join("\n\n")
|
|
6346
6368
|
);
|
|
6347
6369
|
}
|
|
6348
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
6370
|
+
if (_optionalChain([_error, 'optionalAccess', _300 => _300.attributes, 'optionalAccess', _301 => _301.details, 'optionalAccess', _302 => _302.message])) {
|
|
6349
6371
|
throw new Error(
|
|
6350
6372
|
[
|
|
6351
6373
|
`${_error.attributes.details.message}`,
|
|
@@ -6423,7 +6445,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
6423
6445
|
const records = await dato.findRecordsForModel(modelId);
|
|
6424
6446
|
const recordChoices = createRecordChoices(
|
|
6425
6447
|
records,
|
|
6426
|
-
_optionalChain([config, 'access',
|
|
6448
|
+
_optionalChain([config, 'access', _303 => _303.models, 'access', _304 => _304[modelId], 'optionalAccess', _305 => _305.records]) || [],
|
|
6427
6449
|
project
|
|
6428
6450
|
);
|
|
6429
6451
|
const selectedRecords = await promptRecordSelection(
|
|
@@ -6442,14 +6464,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
6442
6464
|
},
|
|
6443
6465
|
async pull(locale, input2, initCtx) {
|
|
6444
6466
|
const result = {};
|
|
6445
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
6446
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
6467
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _306 => _306.models]) || {})) {
|
|
6468
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _307 => _307.models, 'access', _308 => _308[modelId], 'access', _309 => _309.records]) || [];
|
|
6447
6469
|
const recordIds = records.map((record) => record.id);
|
|
6448
6470
|
records = await dato.findRecords(recordIds);
|
|
6449
6471
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
6450
6472
|
if (records.length > 0) {
|
|
6451
6473
|
result[modelId] = {
|
|
6452
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
6474
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _310 => _310.models, 'optionalAccess', _311 => _311[modelId], 'optionalAccess', _312 => _312.fields]) || [],
|
|
6453
6475
|
records
|
|
6454
6476
|
};
|
|
6455
6477
|
}
|
|
@@ -6512,7 +6534,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
6512
6534
|
return records.map((record) => ({
|
|
6513
6535
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
6514
6536
|
value: record.id,
|
|
6515
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
6537
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _313 => _313.includes, 'call', _314 => _314(record.id)])
|
|
6516
6538
|
}));
|
|
6517
6539
|
}
|
|
6518
6540
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -6801,12 +6823,12 @@ function _isVideo(rawDatoValue) {
|
|
|
6801
6823
|
// src/cli/loaders/dato/index.ts
|
|
6802
6824
|
function createDatoLoader(configFilePath) {
|
|
6803
6825
|
try {
|
|
6804
|
-
const configContent =
|
|
6826
|
+
const configContent = fs12.default.readFileSync(configFilePath, "utf-8");
|
|
6805
6827
|
const datoConfig = datoConfigSchema.parse(_json52.default.parse(configContent));
|
|
6806
6828
|
return composeLoaders(
|
|
6807
6829
|
createDatoApiLoader(
|
|
6808
6830
|
datoConfig,
|
|
6809
|
-
(updatedConfig) =>
|
|
6831
|
+
(updatedConfig) => fs12.default.writeFileSync(
|
|
6810
6832
|
configFilePath,
|
|
6811
6833
|
_json52.default.stringify(updatedConfig, null, 2)
|
|
6812
6834
|
)
|
|
@@ -6831,7 +6853,7 @@ function createVttLoader() {
|
|
|
6831
6853
|
if (!input2) {
|
|
6832
6854
|
return "";
|
|
6833
6855
|
}
|
|
6834
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
6856
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _315 => _315.parse, 'call', _316 => _316(input2), 'optionalAccess', _317 => _317.cues]);
|
|
6835
6857
|
if (Object.keys(vtt).length === 0) {
|
|
6836
6858
|
return {};
|
|
6837
6859
|
} else {
|
|
@@ -6885,7 +6907,7 @@ function variableExtractLoader(params) {
|
|
|
6885
6907
|
for (let i = 0; i < matches.length; i++) {
|
|
6886
6908
|
const match2 = matches[i];
|
|
6887
6909
|
const currentValue = result[key].value;
|
|
6888
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
6910
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _318 => _318.replace, 'call', _319 => _319(match2, `{variable:${i}}`)]);
|
|
6889
6911
|
result[key].value = newValue;
|
|
6890
6912
|
result[key].variables[i] = match2;
|
|
6891
6913
|
}
|
|
@@ -6900,7 +6922,7 @@ function variableExtractLoader(params) {
|
|
|
6900
6922
|
const variable = valueObj.variables[i];
|
|
6901
6923
|
const currentValue = result[key];
|
|
6902
6924
|
if (typeof currentValue === "string") {
|
|
6903
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
6925
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _320 => _320.replaceAll, 'call', _321 => _321(
|
|
6904
6926
|
`{variable:${i}}`,
|
|
6905
6927
|
variable
|
|
6906
6928
|
)]);
|
|
@@ -7104,7 +7126,7 @@ function createVueJsonLoader() {
|
|
|
7104
7126
|
return createLoader({
|
|
7105
7127
|
pull: async (locale, input2, ctx) => {
|
|
7106
7128
|
const parsed = parseVueFile(input2);
|
|
7107
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
7129
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _322 => _322.i18n, 'optionalAccess', _323 => _323[locale]]), () => ( {}));
|
|
7108
7130
|
},
|
|
7109
7131
|
push: async (locale, data, originalInput) => {
|
|
7110
7132
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -7289,7 +7311,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
|
|
|
7289
7311
|
objectExpression.properties.forEach((prop) => {
|
|
7290
7312
|
if (!t.isObjectProperty(prop)) return;
|
|
7291
7313
|
const key = getPropertyKey(prop);
|
|
7292
|
-
const incomingVal = _optionalChain([data, 'optionalAccess',
|
|
7314
|
+
const incomingVal = _optionalChain([data, 'optionalAccess', _324 => _324[key]]);
|
|
7293
7315
|
if (incomingVal === void 0) {
|
|
7294
7316
|
return;
|
|
7295
7317
|
}
|
|
@@ -7325,7 +7347,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
7325
7347
|
let modified = false;
|
|
7326
7348
|
arrayExpression.elements.forEach((element, index) => {
|
|
7327
7349
|
if (!element) return;
|
|
7328
|
-
const incomingVal = _optionalChain([incoming, 'optionalAccess',
|
|
7350
|
+
const incomingVal = _optionalChain([incoming, 'optionalAccess', _325 => _325[index]]);
|
|
7329
7351
|
if (incomingVal === void 0) return;
|
|
7330
7352
|
if (t.isStringLiteral(element) && typeof incomingVal === "string") {
|
|
7331
7353
|
if (element.value !== incomingVal) {
|
|
@@ -7819,7 +7841,7 @@ var AST = class _AST {
|
|
|
7819
7841
|
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
7820
7842
|
if (this.isStart() && !this.type)
|
|
7821
7843
|
ret.unshift([]);
|
|
7822
|
-
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
7844
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access', _326 => _326.#parent, 'optionalAccess', _327 => _327.type]) === "!")) {
|
|
7823
7845
|
ret.push({});
|
|
7824
7846
|
}
|
|
7825
7847
|
return ret;
|
|
@@ -7827,7 +7849,7 @@ var AST = class _AST {
|
|
|
7827
7849
|
isStart() {
|
|
7828
7850
|
if (this.#root === this)
|
|
7829
7851
|
return true;
|
|
7830
|
-
if (!_optionalChain([this, 'access',
|
|
7852
|
+
if (!_optionalChain([this, 'access', _328 => _328.#parent, 'optionalAccess', _329 => _329.isStart, 'call', _330 => _330()]))
|
|
7831
7853
|
return false;
|
|
7832
7854
|
if (this.#parentIndex === 0)
|
|
7833
7855
|
return true;
|
|
@@ -7843,12 +7865,12 @@ var AST = class _AST {
|
|
|
7843
7865
|
isEnd() {
|
|
7844
7866
|
if (this.#root === this)
|
|
7845
7867
|
return true;
|
|
7846
|
-
if (_optionalChain([this, 'access',
|
|
7868
|
+
if (_optionalChain([this, 'access', _331 => _331.#parent, 'optionalAccess', _332 => _332.type]) === "!")
|
|
7847
7869
|
return true;
|
|
7848
|
-
if (!_optionalChain([this, 'access',
|
|
7870
|
+
if (!_optionalChain([this, 'access', _333 => _333.#parent, 'optionalAccess', _334 => _334.isEnd, 'call', _335 => _335()]))
|
|
7849
7871
|
return false;
|
|
7850
7872
|
if (!this.type)
|
|
7851
|
-
return _optionalChain([this, 'access',
|
|
7873
|
+
return _optionalChain([this, 'access', _336 => _336.#parent, 'optionalAccess', _337 => _337.isEnd, 'call', _338 => _338()]);
|
|
7852
7874
|
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
7853
7875
|
return this.#parentIndex === pl - 1;
|
|
7854
7876
|
}
|
|
@@ -8093,7 +8115,7 @@ var AST = class _AST {
|
|
|
8093
8115
|
}
|
|
8094
8116
|
}
|
|
8095
8117
|
let end = "";
|
|
8096
|
-
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
8118
|
+
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access', _339 => _339.#parent, 'optionalAccess', _340 => _340.type]) === "!") {
|
|
8097
8119
|
end = "(?:$|\\/)";
|
|
8098
8120
|
}
|
|
8099
8121
|
const final2 = start2 + src + end;
|
|
@@ -9194,7 +9216,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
9194
9216
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
9195
9217
|
const result = {
|
|
9196
9218
|
frontmatter: data.frontmatter,
|
|
9197
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
9219
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _341 => _341.codePlaceholders]) || {},
|
|
9198
9220
|
content
|
|
9199
9221
|
};
|
|
9200
9222
|
return result;
|
|
@@ -9589,7 +9611,7 @@ function createTwigLoader() {
|
|
|
9589
9611
|
const attrs = LOCALIZABLE_ATTRIBUTES2[tagName];
|
|
9590
9612
|
if (!attrs) return;
|
|
9591
9613
|
for (const attr of attrs) {
|
|
9592
|
-
const value = _optionalChain([element, 'access',
|
|
9614
|
+
const value = _optionalChain([element, 'access', _342 => _342.attribs, 'optionalAccess', _343 => _343[attr]]);
|
|
9593
9615
|
if (value && value.trim()) {
|
|
9594
9616
|
const restoredValue = postprocessTwig(value.trim(), twigBlocks);
|
|
9595
9617
|
result[`${path19}#${attr}`] = restoredValue;
|
|
@@ -10692,7 +10714,7 @@ function createBasicTranslator(model, systemPrompt, settings = {}) {
|
|
|
10692
10714
|
]
|
|
10693
10715
|
});
|
|
10694
10716
|
const result = JSON.parse(response.text);
|
|
10695
|
-
return _optionalChain([result, 'optionalAccess',
|
|
10717
|
+
return _optionalChain([result, 'optionalAccess', _344 => _344.data]) || {};
|
|
10696
10718
|
}
|
|
10697
10719
|
}
|
|
10698
10720
|
function extractPayloadChunks(payload) {
|
|
@@ -10775,7 +10797,7 @@ function getPureModelProvider(provider) {
|
|
|
10775
10797
|
|
|
10776
10798
|
${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
10777
10799
|
`;
|
|
10778
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
10800
|
+
switch (_optionalChain([provider, 'optionalAccess', _345 => _345.id])) {
|
|
10779
10801
|
case "openai": {
|
|
10780
10802
|
if (!process.env.OPENAI_API_KEY) {
|
|
10781
10803
|
throw new Error(
|
|
@@ -10833,7 +10855,7 @@ function getPureModelProvider(provider) {
|
|
|
10833
10855
|
})(provider.model);
|
|
10834
10856
|
}
|
|
10835
10857
|
default: {
|
|
10836
|
-
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess',
|
|
10858
|
+
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _346 => _346.id])));
|
|
10837
10859
|
}
|
|
10838
10860
|
}
|
|
10839
10861
|
}
|
|
@@ -10925,7 +10947,7 @@ function parseGitUrl(url) {
|
|
|
10925
10947
|
}
|
|
10926
10948
|
const sshMatch = cleanUrl.match(/[@:]([^:/@]+\/[^:/@]+)$/);
|
|
10927
10949
|
const httpsMatch = cleanUrl.match(/\/([^/]+\/[^/]+)$/);
|
|
10928
|
-
const repoPath = _optionalChain([sshMatch, 'optionalAccess',
|
|
10950
|
+
const repoPath = _optionalChain([sshMatch, 'optionalAccess', _347 => _347[1]]) || _optionalChain([httpsMatch, 'optionalAccess', _348 => _348[1]]);
|
|
10929
10951
|
if (!repoPath) return null;
|
|
10930
10952
|
const hashedPath = hashProjectName(repoPath);
|
|
10931
10953
|
if (platform) {
|
|
@@ -11043,7 +11065,7 @@ function trackEvent(email, event, properties) {
|
|
|
11043
11065
|
|
|
11044
11066
|
function tryReadFile(filePath, defaultValue = null) {
|
|
11045
11067
|
try {
|
|
11046
|
-
const content =
|
|
11068
|
+
const content = fs12.readFileSync(filePath, "utf-8");
|
|
11047
11069
|
return content;
|
|
11048
11070
|
} catch (error) {
|
|
11049
11071
|
return defaultValue;
|
|
@@ -11051,13 +11073,13 @@ function tryReadFile(filePath, defaultValue = null) {
|
|
|
11051
11073
|
}
|
|
11052
11074
|
function writeFile(filePath, content) {
|
|
11053
11075
|
const dir = path14.dirname(filePath);
|
|
11054
|
-
if (!
|
|
11055
|
-
|
|
11076
|
+
if (!fs12.existsSync(dir)) {
|
|
11077
|
+
fs12.mkdirSync(dir, { recursive: true });
|
|
11056
11078
|
}
|
|
11057
|
-
|
|
11079
|
+
fs12.writeFileSync(filePath, content);
|
|
11058
11080
|
}
|
|
11059
11081
|
function checkIfFileExists(filePath) {
|
|
11060
|
-
return
|
|
11082
|
+
return fs12.existsSync(filePath);
|
|
11061
11083
|
}
|
|
11062
11084
|
|
|
11063
11085
|
// src/cli/utils/delta.ts
|
|
@@ -11235,7 +11257,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11235
11257
|
validateParams(i18nConfig, flags);
|
|
11236
11258
|
ora.succeed("Localization configuration is valid");
|
|
11237
11259
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
11238
|
-
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess',
|
|
11260
|
+
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _349 => _349.provider]);
|
|
11239
11261
|
if (isByokMode) {
|
|
11240
11262
|
email = null;
|
|
11241
11263
|
ora.succeed("Using external provider (BYOK mode)");
|
|
@@ -11249,16 +11271,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11249
11271
|
flags
|
|
11250
11272
|
});
|
|
11251
11273
|
let buckets = getBuckets(i18nConfig);
|
|
11252
|
-
if (_optionalChain([flags, 'access',
|
|
11274
|
+
if (_optionalChain([flags, 'access', _350 => _350.bucket, 'optionalAccess', _351 => _351.length])) {
|
|
11253
11275
|
buckets = buckets.filter(
|
|
11254
11276
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
11255
11277
|
);
|
|
11256
11278
|
}
|
|
11257
11279
|
ora.succeed("Buckets retrieved");
|
|
11258
|
-
if (_optionalChain([flags, 'access',
|
|
11280
|
+
if (_optionalChain([flags, 'access', _352 => _352.file, 'optionalAccess', _353 => _353.length])) {
|
|
11259
11281
|
buckets = buckets.map((bucket) => {
|
|
11260
11282
|
const paths = bucket.paths.filter(
|
|
11261
|
-
(path19) => flags.file.find((file) => _optionalChain([path19, 'access',
|
|
11283
|
+
(path19) => flags.file.find((file) => _optionalChain([path19, 'access', _354 => _354.pathPattern, 'optionalAccess', _355 => _355.includes, 'call', _356 => _356(file)]))
|
|
11262
11284
|
);
|
|
11263
11285
|
return { ...bucket, paths };
|
|
11264
11286
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -11279,7 +11301,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11279
11301
|
});
|
|
11280
11302
|
}
|
|
11281
11303
|
}
|
|
11282
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
11304
|
+
const targetLocales = _optionalChain([flags, 'access', _357 => _357.locale, 'optionalAccess', _358 => _358.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
11283
11305
|
ora.start("Setting up localization cache...");
|
|
11284
11306
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
11285
11307
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -11564,7 +11586,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11564
11586
|
}
|
|
11565
11587
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
11566
11588
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
11567
|
-
if (!_optionalChain([flags, 'access',
|
|
11589
|
+
if (!_optionalChain([flags, 'access', _359 => _359.locale, 'optionalAccess', _360 => _360.length])) {
|
|
11568
11590
|
await deltaProcessor.saveChecksums(checksums);
|
|
11569
11591
|
}
|
|
11570
11592
|
}
|
|
@@ -11691,12 +11713,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
11691
11713
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
11692
11714
|
docUrl: "bucketNotFound"
|
|
11693
11715
|
});
|
|
11694
|
-
} else if (_optionalChain([flags, 'access',
|
|
11716
|
+
} else if (_optionalChain([flags, 'access', _361 => _361.locale, 'optionalAccess', _362 => _362.some, 'call', _363 => _363((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
11695
11717
|
throw new ValidationError({
|
|
11696
11718
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
11697
11719
|
docUrl: "localeTargetNotFound"
|
|
11698
11720
|
});
|
|
11699
|
-
} else if (_optionalChain([flags, 'access',
|
|
11721
|
+
} else if (_optionalChain([flags, 'access', _364 => _364.bucket, 'optionalAccess', _365 => _365.some, 'call', _366 => _366(
|
|
11700
11722
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
11701
11723
|
)])) {
|
|
11702
11724
|
throw new ValidationError({
|
|
@@ -11837,7 +11859,7 @@ function createLockfileHelper() {
|
|
|
11837
11859
|
return {
|
|
11838
11860
|
isLockfileExists: () => {
|
|
11839
11861
|
const lockfilePath = _getLockfilePath();
|
|
11840
|
-
return
|
|
11862
|
+
return fs12.default.existsSync(lockfilePath);
|
|
11841
11863
|
},
|
|
11842
11864
|
registerSourceData: (pathPattern, sourceData) => {
|
|
11843
11865
|
const lockfile = _loadLockfile();
|
|
@@ -11874,17 +11896,17 @@ function createLockfileHelper() {
|
|
|
11874
11896
|
};
|
|
11875
11897
|
function _loadLockfile() {
|
|
11876
11898
|
const lockfilePath = _getLockfilePath();
|
|
11877
|
-
if (!
|
|
11899
|
+
if (!fs12.default.existsSync(lockfilePath)) {
|
|
11878
11900
|
return LockfileSchema.parse({});
|
|
11879
11901
|
}
|
|
11880
|
-
const content =
|
|
11902
|
+
const content = fs12.default.readFileSync(lockfilePath, "utf-8");
|
|
11881
11903
|
const result = LockfileSchema.parse(_yaml2.default.parse(content));
|
|
11882
11904
|
return result;
|
|
11883
11905
|
}
|
|
11884
11906
|
function _saveLockfile(lockfile) {
|
|
11885
11907
|
const lockfilePath = _getLockfilePath();
|
|
11886
11908
|
const content = _yaml2.default.stringify(lockfile);
|
|
11887
|
-
|
|
11909
|
+
fs12.default.writeFileSync(lockfilePath, content);
|
|
11888
11910
|
}
|
|
11889
11911
|
function _getLockfilePath() {
|
|
11890
11912
|
return path14.default.join(process.cwd(), "i18n.lock");
|
|
@@ -12230,7 +12252,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
12230
12252
|
const response = await engine.whoami();
|
|
12231
12253
|
return {
|
|
12232
12254
|
authenticated: !!response,
|
|
12233
|
-
username: _optionalChain([response, 'optionalAccess',
|
|
12255
|
+
username: _optionalChain([response, 'optionalAccess', _367 => _367.email])
|
|
12234
12256
|
};
|
|
12235
12257
|
} catch (error) {
|
|
12236
12258
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -12259,6 +12281,175 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
12259
12281
|
};
|
|
12260
12282
|
}
|
|
12261
12283
|
|
|
12284
|
+
// src/cli/localizer/lingodotdev-vnext.ts
|
|
12285
|
+
|
|
12286
|
+
|
|
12287
|
+
var _cuid2 = require('@paralleldrive/cuid2');
|
|
12288
|
+
function createVNextEngine(config) {
|
|
12289
|
+
const endpoint = `${config.apiUrl}/process/${config.processId}/localize`;
|
|
12290
|
+
return {
|
|
12291
|
+
async localizeChunk(sourceLocale, targetLocale, payload, workflowId, fast, signal) {
|
|
12292
|
+
const res = await fetch(endpoint, {
|
|
12293
|
+
method: "POST",
|
|
12294
|
+
headers: {
|
|
12295
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
12296
|
+
"X-API-Key": config.apiKey
|
|
12297
|
+
},
|
|
12298
|
+
body: JSON.stringify(
|
|
12299
|
+
{
|
|
12300
|
+
params: { workflowId, fast },
|
|
12301
|
+
sourceLocale,
|
|
12302
|
+
targetLocale,
|
|
12303
|
+
data: payload.data,
|
|
12304
|
+
reference: payload.reference,
|
|
12305
|
+
hints: payload.hints
|
|
12306
|
+
},
|
|
12307
|
+
null,
|
|
12308
|
+
2
|
|
12309
|
+
),
|
|
12310
|
+
signal
|
|
12311
|
+
});
|
|
12312
|
+
if (!res.ok) {
|
|
12313
|
+
if (res.status >= 500 && res.status < 600) {
|
|
12314
|
+
const errorText = await res.text();
|
|
12315
|
+
throw new Error(
|
|
12316
|
+
`Server error (${res.status}): ${res.statusText}. ${errorText}. This may be due to temporary service issues.`
|
|
12317
|
+
);
|
|
12318
|
+
} else if (res.status === 400) {
|
|
12319
|
+
throw new Error(`Invalid request: ${res.statusText}`);
|
|
12320
|
+
} else {
|
|
12321
|
+
const errorText = await res.text();
|
|
12322
|
+
throw new Error(errorText);
|
|
12323
|
+
}
|
|
12324
|
+
}
|
|
12325
|
+
const jsonResponse = await res.json();
|
|
12326
|
+
if (!jsonResponse.data && jsonResponse.error) {
|
|
12327
|
+
throw new Error(jsonResponse.error);
|
|
12328
|
+
}
|
|
12329
|
+
return jsonResponse.data || {};
|
|
12330
|
+
},
|
|
12331
|
+
async whoami(signal) {
|
|
12332
|
+
return { email: "vnext-user", id: config.processId };
|
|
12333
|
+
},
|
|
12334
|
+
async localizeObject(obj, params, progressCallback, signal) {
|
|
12335
|
+
const chunkedPayload = extractPayloadChunks2(obj);
|
|
12336
|
+
const processedPayloadChunks = [];
|
|
12337
|
+
const workflowId = _cuid2.createId.call(void 0, );
|
|
12338
|
+
for (let i = 0; i < chunkedPayload.length; i++) {
|
|
12339
|
+
const chunk = chunkedPayload[i];
|
|
12340
|
+
const percentageCompleted = Math.round(
|
|
12341
|
+
(i + 1) / chunkedPayload.length * 100
|
|
12342
|
+
);
|
|
12343
|
+
const processedPayloadChunk = await this.localizeChunk(
|
|
12344
|
+
params.sourceLocale,
|
|
12345
|
+
params.targetLocale,
|
|
12346
|
+
{ data: chunk, reference: params.reference, hints: params.hints },
|
|
12347
|
+
workflowId,
|
|
12348
|
+
params.fast || false,
|
|
12349
|
+
signal
|
|
12350
|
+
);
|
|
12351
|
+
if (progressCallback) {
|
|
12352
|
+
progressCallback(percentageCompleted, chunk, processedPayloadChunk);
|
|
12353
|
+
}
|
|
12354
|
+
processedPayloadChunks.push(processedPayloadChunk);
|
|
12355
|
+
}
|
|
12356
|
+
return Object.assign({}, ...processedPayloadChunks);
|
|
12357
|
+
}
|
|
12358
|
+
};
|
|
12359
|
+
}
|
|
12360
|
+
function extractPayloadChunks2(payload, batchSize = 25, idealBatchItemSize = 250) {
|
|
12361
|
+
const result = [];
|
|
12362
|
+
let currentChunk = {};
|
|
12363
|
+
let currentChunkItemCount = 0;
|
|
12364
|
+
const payloadEntries = Object.entries(payload);
|
|
12365
|
+
for (let i = 0; i < payloadEntries.length; i++) {
|
|
12366
|
+
const [key, value] = payloadEntries[i];
|
|
12367
|
+
currentChunk[key] = value;
|
|
12368
|
+
currentChunkItemCount++;
|
|
12369
|
+
const currentChunkSize = countWordsInRecord2(currentChunk);
|
|
12370
|
+
if (currentChunkSize > idealBatchItemSize || currentChunkItemCount >= batchSize || i === payloadEntries.length - 1) {
|
|
12371
|
+
result.push(currentChunk);
|
|
12372
|
+
currentChunk = {};
|
|
12373
|
+
currentChunkItemCount = 0;
|
|
12374
|
+
}
|
|
12375
|
+
}
|
|
12376
|
+
return result;
|
|
12377
|
+
}
|
|
12378
|
+
function countWordsInRecord2(payload) {
|
|
12379
|
+
if (Array.isArray(payload)) {
|
|
12380
|
+
return payload.reduce(
|
|
12381
|
+
(acc, item) => acc + countWordsInRecord2(item),
|
|
12382
|
+
0
|
|
12383
|
+
);
|
|
12384
|
+
} else if (typeof payload === "object" && payload !== null) {
|
|
12385
|
+
return Object.values(payload).reduce(
|
|
12386
|
+
(acc, item) => acc + countWordsInRecord2(item),
|
|
12387
|
+
0
|
|
12388
|
+
);
|
|
12389
|
+
} else if (typeof payload === "string") {
|
|
12390
|
+
return payload.trim().split(/\s+/).filter(Boolean).length;
|
|
12391
|
+
} else {
|
|
12392
|
+
return 0;
|
|
12393
|
+
}
|
|
12394
|
+
}
|
|
12395
|
+
function createLingoDotDevVNextLocalizer(processId) {
|
|
12396
|
+
const settings = getSettings(void 0);
|
|
12397
|
+
const apiKey = process.env.LINGO_API_KEY || _optionalChain([settings, 'access', _368 => _368.auth, 'access', _369 => _369.vnext, 'optionalAccess', _370 => _370.apiKey]);
|
|
12398
|
+
if (!apiKey) {
|
|
12399
|
+
throw new Error(
|
|
12400
|
+
_dedent2.default`
|
|
12401
|
+
You're trying to use ${_chalk2.default.hex(colors.green)(
|
|
12402
|
+
"Lingo.dev vNext"
|
|
12403
|
+
)} provider, however, no API key is configured.
|
|
12404
|
+
|
|
12405
|
+
To fix this issue:
|
|
12406
|
+
1. Set ${_chalk2.default.dim("LINGO_API_KEY")} environment variable, or
|
|
12407
|
+
2. Add the key to your ${_chalk2.default.dim("~/.lingodotdevrc")} file under ${_chalk2.default.dim("[auth.vnext]")} section.
|
|
12408
|
+
`
|
|
12409
|
+
);
|
|
12410
|
+
}
|
|
12411
|
+
const apiUrl = process.env.LINGO_API_URL || "https://api.lingo.dev";
|
|
12412
|
+
const engine = createVNextEngine({
|
|
12413
|
+
apiKey,
|
|
12414
|
+
apiUrl,
|
|
12415
|
+
processId
|
|
12416
|
+
});
|
|
12417
|
+
return {
|
|
12418
|
+
id: "Lingo.dev vNext",
|
|
12419
|
+
checkAuth: async () => {
|
|
12420
|
+
try {
|
|
12421
|
+
const response = await engine.whoami();
|
|
12422
|
+
return {
|
|
12423
|
+
authenticated: !!response,
|
|
12424
|
+
username: _optionalChain([response, 'optionalAccess', _371 => _371.email])
|
|
12425
|
+
};
|
|
12426
|
+
} catch (error) {
|
|
12427
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
12428
|
+
return { authenticated: false, error: errorMessage };
|
|
12429
|
+
}
|
|
12430
|
+
},
|
|
12431
|
+
localize: async (input2, onProgress) => {
|
|
12432
|
+
if (!Object.keys(input2.processableData).length) {
|
|
12433
|
+
return input2.processableData;
|
|
12434
|
+
}
|
|
12435
|
+
const processedData = await engine.localizeObject(
|
|
12436
|
+
input2.processableData,
|
|
12437
|
+
{
|
|
12438
|
+
sourceLocale: input2.sourceLocale,
|
|
12439
|
+
targetLocale: input2.targetLocale,
|
|
12440
|
+
reference: {
|
|
12441
|
+
[input2.sourceLocale]: input2.sourceData,
|
|
12442
|
+
[input2.targetLocale]: input2.targetData
|
|
12443
|
+
},
|
|
12444
|
+
hints: input2.hints
|
|
12445
|
+
},
|
|
12446
|
+
onProgress
|
|
12447
|
+
);
|
|
12448
|
+
return processedData;
|
|
12449
|
+
}
|
|
12450
|
+
};
|
|
12451
|
+
}
|
|
12452
|
+
|
|
12262
12453
|
// src/cli/localizer/explicit.ts
|
|
12263
12454
|
|
|
12264
12455
|
|
|
@@ -12346,7 +12537,7 @@ function createExplicitLocalizer(provider) {
|
|
|
12346
12537
|
}
|
|
12347
12538
|
function createAiSdkLocalizer(params) {
|
|
12348
12539
|
const skipAuth = params.skipAuth === true;
|
|
12349
|
-
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
12540
|
+
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _372 => _372.apiKeyName]), () => ( ""))];
|
|
12350
12541
|
if (!skipAuth && !apiKey || !params.apiKeyName) {
|
|
12351
12542
|
throw new Error(
|
|
12352
12543
|
_dedent2.default`
|
|
@@ -12448,8 +12639,133 @@ function createAiSdkLocalizer(params) {
|
|
|
12448
12639
|
};
|
|
12449
12640
|
}
|
|
12450
12641
|
|
|
12642
|
+
// src/utils/pseudo-localize.ts
|
|
12643
|
+
var PSEUDO_CHAR_MAP = {
|
|
12644
|
+
a: "\xE3",
|
|
12645
|
+
b: "\u0180",
|
|
12646
|
+
c: "\xE7",
|
|
12647
|
+
d: "\xF0",
|
|
12648
|
+
e: "\xE8",
|
|
12649
|
+
f: "\u0192",
|
|
12650
|
+
g: "\u011D",
|
|
12651
|
+
h: "\u0125",
|
|
12652
|
+
i: "\xED",
|
|
12653
|
+
j: "\u0135",
|
|
12654
|
+
k: "\u0137",
|
|
12655
|
+
l: "\u013C",
|
|
12656
|
+
m: "m",
|
|
12657
|
+
n: "\xF1",
|
|
12658
|
+
o: "\xF8",
|
|
12659
|
+
p: "\xFE",
|
|
12660
|
+
q: "q",
|
|
12661
|
+
r: "\u0155",
|
|
12662
|
+
s: "\u0161",
|
|
12663
|
+
t: "\u0163",
|
|
12664
|
+
u: "\xFB",
|
|
12665
|
+
v: "\u1E7D",
|
|
12666
|
+
w: "\u0175",
|
|
12667
|
+
x: "x",
|
|
12668
|
+
y: "\xFD",
|
|
12669
|
+
z: "\u017E",
|
|
12670
|
+
A: "\xC3",
|
|
12671
|
+
B: "\u1E02",
|
|
12672
|
+
C: "\u0108",
|
|
12673
|
+
D: "\xD0",
|
|
12674
|
+
E: "\xC8",
|
|
12675
|
+
F: "\u1E1E",
|
|
12676
|
+
G: "\u011C",
|
|
12677
|
+
H: "\u0124",
|
|
12678
|
+
I: "\xCD",
|
|
12679
|
+
J: "\u0134",
|
|
12680
|
+
K: "\u0136",
|
|
12681
|
+
L: "\u013B",
|
|
12682
|
+
M: "M",
|
|
12683
|
+
N: "\xD1",
|
|
12684
|
+
O: "\xD8",
|
|
12685
|
+
P: "\xDE",
|
|
12686
|
+
Q: "Q",
|
|
12687
|
+
R: "\u0154",
|
|
12688
|
+
S: "\u0160",
|
|
12689
|
+
T: "\u0162",
|
|
12690
|
+
U: "\xDB",
|
|
12691
|
+
V: "\u1E7C",
|
|
12692
|
+
W: "\u0174",
|
|
12693
|
+
X: "X",
|
|
12694
|
+
Y: "\xDD",
|
|
12695
|
+
Z: "\u017D"
|
|
12696
|
+
};
|
|
12697
|
+
function pseudoLocalize(text, options = {}) {
|
|
12698
|
+
const {
|
|
12699
|
+
addMarker = true,
|
|
12700
|
+
addLengthMarker = false,
|
|
12701
|
+
lengthExpansion = 30
|
|
12702
|
+
} = options;
|
|
12703
|
+
if (!text) {
|
|
12704
|
+
return text;
|
|
12705
|
+
}
|
|
12706
|
+
let result = "";
|
|
12707
|
+
for (const char of text) {
|
|
12708
|
+
result += _nullishCoalesce(PSEUDO_CHAR_MAP[char], () => ( char));
|
|
12709
|
+
}
|
|
12710
|
+
if (addLengthMarker) {
|
|
12711
|
+
const extraChars = Math.ceil(text.length * lengthExpansion / 100);
|
|
12712
|
+
result += "\u030C".repeat(extraChars);
|
|
12713
|
+
}
|
|
12714
|
+
if (addMarker) {
|
|
12715
|
+
result += "\u26A1";
|
|
12716
|
+
}
|
|
12717
|
+
return result;
|
|
12718
|
+
}
|
|
12719
|
+
function pseudoLocalizeObject(obj, options) {
|
|
12720
|
+
if (typeof obj === "string") {
|
|
12721
|
+
return pseudoLocalize(obj, options);
|
|
12722
|
+
}
|
|
12723
|
+
if (Array.isArray(obj)) {
|
|
12724
|
+
return obj.map((item) => pseudoLocalizeObject(item, options));
|
|
12725
|
+
}
|
|
12726
|
+
if (obj !== null && typeof obj === "object") {
|
|
12727
|
+
const result = {};
|
|
12728
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
12729
|
+
result[key] = pseudoLocalizeObject(value, options);
|
|
12730
|
+
}
|
|
12731
|
+
return result;
|
|
12732
|
+
}
|
|
12733
|
+
return obj;
|
|
12734
|
+
}
|
|
12735
|
+
|
|
12736
|
+
// src/cli/localizer/pseudo.ts
|
|
12737
|
+
function createPseudoLocalizer() {
|
|
12738
|
+
return {
|
|
12739
|
+
id: "pseudo",
|
|
12740
|
+
checkAuth: async () => {
|
|
12741
|
+
return {
|
|
12742
|
+
authenticated: true
|
|
12743
|
+
};
|
|
12744
|
+
},
|
|
12745
|
+
localize: async (input2, onProgress) => {
|
|
12746
|
+
if (!Object.keys(input2.processableData).length) {
|
|
12747
|
+
return input2;
|
|
12748
|
+
}
|
|
12749
|
+
const processedData = pseudoLocalizeObject(input2.processableData, {
|
|
12750
|
+
addMarker: true,
|
|
12751
|
+
addLengthMarker: false
|
|
12752
|
+
});
|
|
12753
|
+
if (onProgress) {
|
|
12754
|
+
onProgress(100, input2.processableData, processedData);
|
|
12755
|
+
}
|
|
12756
|
+
return processedData;
|
|
12757
|
+
}
|
|
12758
|
+
};
|
|
12759
|
+
}
|
|
12760
|
+
|
|
12451
12761
|
// src/cli/localizer/index.ts
|
|
12452
|
-
function createLocalizer(provider, apiKey) {
|
|
12762
|
+
function createLocalizer(provider, apiKey, vNext) {
|
|
12763
|
+
if (provider === "pseudo") {
|
|
12764
|
+
return createPseudoLocalizer();
|
|
12765
|
+
}
|
|
12766
|
+
if (vNext) {
|
|
12767
|
+
return createLingoDotDevVNextLocalizer(vNext);
|
|
12768
|
+
}
|
|
12453
12769
|
if (!provider) {
|
|
12454
12770
|
return createLingoDotDevLocalizer(apiKey);
|
|
12455
12771
|
} else {
|
|
@@ -12480,8 +12796,8 @@ async function setup(input2) {
|
|
|
12480
12796
|
throw new Error(
|
|
12481
12797
|
"No buckets found in i18n.json. Please add at least one bucket containing i18n content."
|
|
12482
12798
|
);
|
|
12483
|
-
} else if (_optionalChain([ctx, 'access',
|
|
12484
|
-
(bucket) => !_optionalChain([ctx, 'access',
|
|
12799
|
+
} else if (_optionalChain([ctx, 'access', _373 => _373.flags, 'access', _374 => _374.bucket, 'optionalAccess', _375 => _375.some, 'call', _376 => _376(
|
|
12800
|
+
(bucket) => !_optionalChain([ctx, 'access', _377 => _377.config, 'optionalAccess', _378 => _378.buckets, 'access', _379 => _379[bucket]])
|
|
12485
12801
|
)])) {
|
|
12486
12802
|
throw new Error(
|
|
12487
12803
|
`One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
|
|
@@ -12493,21 +12809,20 @@ async function setup(input2) {
|
|
|
12493
12809
|
{
|
|
12494
12810
|
title: "Selecting localization provider",
|
|
12495
12811
|
task: async (ctx, task) => {
|
|
12496
|
-
ctx.
|
|
12497
|
-
|
|
12498
|
-
|
|
12499
|
-
);
|
|
12812
|
+
const provider = ctx.flags.pseudo ? "pseudo" : _optionalChain([ctx, 'access', _380 => _380.config, 'optionalAccess', _381 => _381.provider]);
|
|
12813
|
+
const vNext = _optionalChain([ctx, 'access', _382 => _382.config, 'optionalAccess', _383 => _383.vNext]);
|
|
12814
|
+
ctx.localizer = createLocalizer(provider, ctx.flags.apiKey, vNext);
|
|
12500
12815
|
if (!ctx.localizer) {
|
|
12501
12816
|
throw new Error(
|
|
12502
12817
|
"Could not create localization provider. Please check your i18n.json configuration."
|
|
12503
12818
|
);
|
|
12504
12819
|
}
|
|
12505
|
-
task.title = ctx.localizer.id === "Lingo.dev" ? `Using ${_chalk2.default.hex(colors.green)(ctx.localizer.id)} provider` : `Using raw ${_chalk2.default.hex(colors.yellow)(ctx.localizer.id)} API`;
|
|
12820
|
+
task.title = ctx.localizer.id === "Lingo.dev" || ctx.localizer.id === "Lingo.dev vNext" ? `Using ${_chalk2.default.hex(colors.green)(ctx.localizer.id)} provider` : ctx.localizer.id === "pseudo" ? `Using ${_chalk2.default.hex(colors.blue)("pseudo")} mode for testing` : `Using raw ${_chalk2.default.hex(colors.yellow)(ctx.localizer.id)} API`;
|
|
12506
12821
|
}
|
|
12507
12822
|
},
|
|
12508
12823
|
{
|
|
12509
12824
|
title: "Checking authentication",
|
|
12510
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
12825
|
+
enabled: (ctx) => (_optionalChain([ctx, 'access', _384 => _384.localizer, 'optionalAccess', _385 => _385.id]) === "Lingo.dev" || _optionalChain([ctx, 'access', _386 => _386.localizer, 'optionalAccess', _387 => _387.id]) === "Lingo.dev vNext") && !ctx.flags.pseudo,
|
|
12511
12826
|
task: async (ctx, task) => {
|
|
12512
12827
|
const authStatus = await ctx.localizer.checkAuth();
|
|
12513
12828
|
if (!authStatus.authenticated) {
|
|
@@ -12520,7 +12835,7 @@ async function setup(input2) {
|
|
|
12520
12835
|
},
|
|
12521
12836
|
{
|
|
12522
12837
|
title: "Validating configuration",
|
|
12523
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
12838
|
+
enabled: (ctx) => _optionalChain([ctx, 'access', _388 => _388.localizer, 'optionalAccess', _389 => _389.id]) !== "Lingo.dev" && _optionalChain([ctx, 'access', _390 => _390.localizer, 'optionalAccess', _391 => _391.id]) !== "Lingo.dev vNext",
|
|
12524
12839
|
task: async (ctx, task) => {
|
|
12525
12840
|
const validationStatus = await ctx.localizer.validateSettings();
|
|
12526
12841
|
if (!validationStatus.valid) {
|
|
@@ -12535,12 +12850,18 @@ async function setup(input2) {
|
|
|
12535
12850
|
title: "Initializing localization provider",
|
|
12536
12851
|
async task(ctx, task) {
|
|
12537
12852
|
const isLingoDotDev = ctx.localizer.id === "Lingo.dev";
|
|
12853
|
+
const isPseudo = ctx.localizer.id === "pseudo";
|
|
12538
12854
|
const subTasks = isLingoDotDev ? [
|
|
12539
12855
|
"Brand voice enabled",
|
|
12540
12856
|
"Translation memory connected",
|
|
12541
12857
|
"Glossary enabled",
|
|
12542
12858
|
"Quality assurance enabled"
|
|
12543
12859
|
].map((title) => ({ title, task: () => {
|
|
12860
|
+
} })) : isPseudo ? [
|
|
12861
|
+
"Pseudo-localization mode active",
|
|
12862
|
+
"Character replacement configured",
|
|
12863
|
+
"No external API calls"
|
|
12864
|
+
].map((title) => ({ title, task: () => {
|
|
12544
12865
|
} })) : [
|
|
12545
12866
|
"Skipping brand voice",
|
|
12546
12867
|
"Skipping glossary",
|
|
@@ -12851,7 +13172,7 @@ function createWorkerTask(args) {
|
|
|
12851
13172
|
const processableData = _lodash2.default.chain(sourceData).entries().filter(
|
|
12852
13173
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
12853
13174
|
).filter(
|
|
12854
|
-
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access',
|
|
13175
|
+
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _392 => _392.onlyKeys, 'optionalAccess', _393 => _393.some, 'call', _394 => _394(
|
|
12855
13176
|
(pattern) => minimatch(key, pattern)
|
|
12856
13177
|
)])
|
|
12857
13178
|
).fromPairs().value();
|
|
@@ -12919,7 +13240,7 @@ function createWorkerTask(args) {
|
|
|
12919
13240
|
finalRenamedTargetData
|
|
12920
13241
|
);
|
|
12921
13242
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
12922
|
-
if (!_optionalChain([args, 'access',
|
|
13243
|
+
if (!_optionalChain([args, 'access', _395 => _395.ctx, 'access', _396 => _396.flags, 'access', _397 => _397.targetLocale, 'optionalAccess', _398 => _398.length])) {
|
|
12923
13244
|
await deltaProcessor.saveChecksums(checksums);
|
|
12924
13245
|
}
|
|
12925
13246
|
});
|
|
@@ -13113,7 +13434,8 @@ var flagsSchema2 = _zod.z.object({
|
|
|
13113
13434
|
watch: _zod.z.boolean().default(false),
|
|
13114
13435
|
debounce: _zod.z.number().positive().default(5e3),
|
|
13115
13436
|
// 5 seconds default
|
|
13116
|
-
sound: _zod.z.boolean().optional()
|
|
13437
|
+
sound: _zod.z.boolean().optional(),
|
|
13438
|
+
pseudo: _zod.z.boolean().optional()
|
|
13117
13439
|
});
|
|
13118
13440
|
|
|
13119
13441
|
// src/cli/cmd/run/frozen.ts
|
|
@@ -13124,10 +13446,10 @@ var flagsSchema2 = _zod.z.object({
|
|
|
13124
13446
|
async function frozen(input2) {
|
|
13125
13447
|
console.log(_chalk2.default.hex(colors.orange)("[Frozen]"));
|
|
13126
13448
|
let buckets = getBuckets(input2.config);
|
|
13127
|
-
if (_optionalChain([input2, 'access',
|
|
13449
|
+
if (_optionalChain([input2, 'access', _399 => _399.flags, 'access', _400 => _400.bucket, 'optionalAccess', _401 => _401.length])) {
|
|
13128
13450
|
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
13129
13451
|
}
|
|
13130
|
-
if (_optionalChain([input2, 'access',
|
|
13452
|
+
if (_optionalChain([input2, 'access', _402 => _402.flags, 'access', _403 => _403.file, 'optionalAccess', _404 => _404.length])) {
|
|
13131
13453
|
buckets = buckets.map((bucket) => {
|
|
13132
13454
|
const paths = bucket.paths.filter(
|
|
13133
13455
|
(p) => input2.flags.file.some(
|
|
@@ -13264,13 +13586,13 @@ async function frozen(input2) {
|
|
|
13264
13586
|
|
|
13265
13587
|
// src/cli/cmd/run/_utils.ts
|
|
13266
13588
|
async function determineEmail(ctx) {
|
|
13267
|
-
const isByokMode = !!_optionalChain([ctx, 'access',
|
|
13589
|
+
const isByokMode = !!_optionalChain([ctx, 'access', _405 => _405.config, 'optionalAccess', _406 => _406.provider]);
|
|
13268
13590
|
if (isByokMode) {
|
|
13269
13591
|
return null;
|
|
13270
13592
|
} else {
|
|
13271
13593
|
try {
|
|
13272
|
-
const authStatus = await _optionalChain([ctx, 'access',
|
|
13273
|
-
return _optionalChain([authStatus, 'optionalAccess',
|
|
13594
|
+
const authStatus = await _optionalChain([ctx, 'access', _407 => _407.localizer, 'optionalAccess', _408 => _408.checkAuth, 'call', _409 => _409()]);
|
|
13595
|
+
return _optionalChain([authStatus, 'optionalAccess', _410 => _410.username]) || null;
|
|
13274
13596
|
} catch (e4) {
|
|
13275
13597
|
return null;
|
|
13276
13598
|
}
|
|
@@ -13346,6 +13668,9 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
|
|
|
13346
13668
|
).option(
|
|
13347
13669
|
"--sound",
|
|
13348
13670
|
"Play audio feedback when translations complete (success or failure sounds)"
|
|
13671
|
+
).option(
|
|
13672
|
+
"--pseudo",
|
|
13673
|
+
"Enable pseudo-localization mode: automatically pseudo-translates all extracted strings with accented characters and visual markers without calling any external API. Useful for testing UI internationalization readiness"
|
|
13349
13674
|
).action(async (args) => {
|
|
13350
13675
|
let email = null;
|
|
13351
13676
|
try {
|
|
@@ -13474,7 +13799,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
13474
13799
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
13475
13800
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
13476
13801
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
13477
|
-
_optionalChain([this, 'access',
|
|
13802
|
+
_optionalChain([this, 'access', _411 => _411.platformKit, 'optionalAccess', _412 => _412.gitConfig, 'call', _413 => _413()]);
|
|
13478
13803
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
13479
13804
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
13480
13805
|
if (!processOwnCommits) {
|
|
@@ -13506,7 +13831,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
13506
13831
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
13507
13832
|
var PullRequestFlow = class extends InBranchFlow {
|
|
13508
13833
|
async preRun() {
|
|
13509
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
13834
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _414 => _414()]);
|
|
13510
13835
|
if (!canContinue) {
|
|
13511
13836
|
return false;
|
|
13512
13837
|
}
|
|
@@ -13773,10 +14098,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
13773
14098
|
repo_slug: this.platformConfig.repositoryName,
|
|
13774
14099
|
state: "OPEN"
|
|
13775
14100
|
}).then(({ data: { values } }) => {
|
|
13776
|
-
return _optionalChain([values, 'optionalAccess',
|
|
13777
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
14101
|
+
return _optionalChain([values, 'optionalAccess', _415 => _415.find, 'call', _416 => _416(
|
|
14102
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _417 => _417.branch, 'optionalAccess', _418 => _418.name]) === branch && _optionalChain([destination, 'optionalAccess', _419 => _419.branch, 'optionalAccess', _420 => _420.name]) === this.platformConfig.baseBranchName
|
|
13778
14103
|
)]);
|
|
13779
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
14104
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _421 => _421.id]));
|
|
13780
14105
|
}
|
|
13781
14106
|
async closePullRequest({ pullRequestNumber }) {
|
|
13782
14107
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -13872,7 +14197,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
13872
14197
|
repo: this.platformConfig.repositoryName,
|
|
13873
14198
|
base: this.platformConfig.baseBranchName,
|
|
13874
14199
|
state: "open"
|
|
13875
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
14200
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _422 => _422.number]));
|
|
13876
14201
|
}
|
|
13877
14202
|
async closePullRequest({ pullRequestNumber }) {
|
|
13878
14203
|
await this.octokit.rest.pulls.update({
|
|
@@ -13999,7 +14324,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
13999
14324
|
sourceBranch: branch,
|
|
14000
14325
|
state: "opened"
|
|
14001
14326
|
});
|
|
14002
|
-
return _optionalChain([mergeRequests, 'access',
|
|
14327
|
+
return _optionalChain([mergeRequests, 'access', _423 => _423[0], 'optionalAccess', _424 => _424.iid]);
|
|
14003
14328
|
}
|
|
14004
14329
|
async closePullRequest({
|
|
14005
14330
|
pullRequestNumber
|
|
@@ -14111,7 +14436,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
14111
14436
|
}
|
|
14112
14437
|
const env = {
|
|
14113
14438
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
14114
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
14439
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _425 => _425.pullRequest, 'optionalAccess', _426 => _426.toString, 'call', _427 => _427()]) || "false",
|
|
14115
14440
|
...options.commitMessage && {
|
|
14116
14441
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
14117
14442
|
},
|
|
@@ -14137,7 +14462,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
14137
14462
|
const { isPullRequestMode } = platformKit.config;
|
|
14138
14463
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
14139
14464
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
14140
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
14465
|
+
const canRun = await _optionalChain([flow, 'access', _428 => _428.preRun, 'optionalCall', _429 => _429()]);
|
|
14141
14466
|
if (canRun === false) {
|
|
14142
14467
|
return;
|
|
14143
14468
|
}
|
|
@@ -14147,7 +14472,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
14147
14472
|
if (!hasChanges) {
|
|
14148
14473
|
return;
|
|
14149
14474
|
}
|
|
14150
|
-
await _optionalChain([flow, 'access',
|
|
14475
|
+
await _optionalChain([flow, 'access', _430 => _430.postRun, 'optionalCall', _431 => _431()]);
|
|
14151
14476
|
});
|
|
14152
14477
|
function parseBooleanArg(val) {
|
|
14153
14478
|
if (val === true) return true;
|
|
@@ -14184,8 +14509,8 @@ function exitGracefully(elapsedMs = 0) {
|
|
|
14184
14509
|
}
|
|
14185
14510
|
}
|
|
14186
14511
|
function checkForPendingOperations() {
|
|
14187
|
-
const activeHandles = _optionalChain([process, 'access',
|
|
14188
|
-
const activeRequests = _optionalChain([process, 'access',
|
|
14512
|
+
const activeHandles = _optionalChain([process, 'access', _432 => _432._getActiveHandles, 'optionalCall', _433 => _433()]) || [];
|
|
14513
|
+
const activeRequests = _optionalChain([process, 'access', _434 => _434._getActiveRequests, 'optionalCall', _435 => _435()]) || [];
|
|
14189
14514
|
const nonStandardHandles = activeHandles.filter((handle) => {
|
|
14190
14515
|
if (handle === process.stdin || handle === process.stdout || handle === process.stderr) {
|
|
14191
14516
|
return false;
|
|
@@ -14255,17 +14580,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
14255
14580
|
});
|
|
14256
14581
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
14257
14582
|
let buckets = getBuckets(i18nConfig);
|
|
14258
|
-
if (_optionalChain([flags, 'access',
|
|
14583
|
+
if (_optionalChain([flags, 'access', _436 => _436.bucket, 'optionalAccess', _437 => _437.length])) {
|
|
14259
14584
|
buckets = buckets.filter(
|
|
14260
14585
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
14261
14586
|
);
|
|
14262
14587
|
}
|
|
14263
14588
|
ora.succeed("Buckets retrieved");
|
|
14264
|
-
if (_optionalChain([flags, 'access',
|
|
14589
|
+
if (_optionalChain([flags, 'access', _438 => _438.file, 'optionalAccess', _439 => _439.length])) {
|
|
14265
14590
|
buckets = buckets.map((bucket) => {
|
|
14266
14591
|
const paths = bucket.paths.filter(
|
|
14267
14592
|
(path19) => flags.file.find(
|
|
14268
|
-
(file) => _optionalChain([path19, 'access',
|
|
14593
|
+
(file) => _optionalChain([path19, 'access', _440 => _440.pathPattern, 'optionalAccess', _441 => _441.includes, 'call', _442 => _442(file)]) || _optionalChain([path19, 'access', _443 => _443.pathPattern, 'optionalAccess', _444 => _444.match, 'call', _445 => _445(file)]) || minimatch(path19.pathPattern, file)
|
|
14269
14594
|
)
|
|
14270
14595
|
);
|
|
14271
14596
|
return { ...bucket, paths };
|
|
@@ -14285,7 +14610,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
14285
14610
|
});
|
|
14286
14611
|
}
|
|
14287
14612
|
}
|
|
14288
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
14613
|
+
const targetLocales = _optionalChain([flags, 'access', _446 => _446.locale, 'optionalAccess', _447 => _447.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
14289
14614
|
let totalSourceKeyCount = 0;
|
|
14290
14615
|
let uniqueKeysToTranslate = 0;
|
|
14291
14616
|
let totalExistingTranslations = 0;
|
|
@@ -14695,12 +15020,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
14695
15020
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
14696
15021
|
docUrl: "bucketNotFound"
|
|
14697
15022
|
});
|
|
14698
|
-
} else if (_optionalChain([flags, 'access',
|
|
15023
|
+
} else if (_optionalChain([flags, 'access', _448 => _448.locale, 'optionalAccess', _449 => _449.some, 'call', _450 => _450((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
14699
15024
|
throw new CLIError({
|
|
14700
15025
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
14701
15026
|
docUrl: "localeTargetNotFound"
|
|
14702
15027
|
});
|
|
14703
|
-
} else if (_optionalChain([flags, 'access',
|
|
15028
|
+
} else if (_optionalChain([flags, 'access', _451 => _451.bucket, 'optionalAccess', _452 => _452.some, 'call', _453 => _453(
|
|
14704
15029
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
14705
15030
|
)])) {
|
|
14706
15031
|
throw new CLIError({
|
|
@@ -14792,7 +15117,7 @@ async function renderHero2() {
|
|
|
14792
15117
|
// package.json
|
|
14793
15118
|
var package_default = {
|
|
14794
15119
|
name: "lingo.dev",
|
|
14795
|
-
version: "0.
|
|
15120
|
+
version: "0.118.0",
|
|
14796
15121
|
description: "Lingo.dev CLI",
|
|
14797
15122
|
private: false,
|
|
14798
15123
|
repository: {
|
|
@@ -15094,7 +15419,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
|
|
|
15094
15419
|
if (options.file && options.file.length) {
|
|
15095
15420
|
buckets = buckets.map((bucket) => {
|
|
15096
15421
|
const paths = bucket.paths.filter(
|
|
15097
|
-
(bucketPath) => _optionalChain([options, 'access',
|
|
15422
|
+
(bucketPath) => _optionalChain([options, 'access', _454 => _454.file, 'optionalAccess', _455 => _455.some, 'call', _456 => _456((f) => bucketPath.pathPattern.includes(f))])
|
|
15098
15423
|
);
|
|
15099
15424
|
return { ...bucket, paths };
|
|
15100
15425
|
}).filter((bucket) => bucket.paths.length > 0);
|