lingo.dev 0.117.26 → 0.119.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/agents.md +12 -0
- package/build/cli.cjs +731 -358
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +719 -346
- package/build/cli.mjs.map +1 -1
- package/package.json +7 -6
package/build/cli.cjs
CHANGED
|
@@ -14,9 +14,9 @@ var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
|
|
|
14
14
|
|
|
15
15
|
// src/cli/utils/settings.ts
|
|
16
16
|
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
17
|
-
var _path = require('path'); var
|
|
17
|
+
var _path = require('path'); var path15 = _interopRequireWildcard(_path); var path16 = _interopRequireWildcard(_path);
|
|
18
18
|
var _zod = require('zod'); var _zod2 = _interopRequireDefault(_zod);
|
|
19
|
-
var _fs = require('fs'); var
|
|
19
|
+
var _fs = require('fs'); var fs13 = _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 = fs13.default.existsSync(settingsFilePath) ? fs13.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,12 +129,12 @@ function _loadSystemFile() {
|
|
|
119
129
|
function _saveSystemFile(settings) {
|
|
120
130
|
const settingsFilePath = _getSettingsFilePath();
|
|
121
131
|
const content = _ini2.default.stringify(settings);
|
|
122
|
-
|
|
132
|
+
fs13.default.writeFileSync(settingsFilePath, content);
|
|
123
133
|
}
|
|
124
134
|
function _getSettingsFilePath() {
|
|
125
135
|
const settingsFile = ".lingodotdevrc";
|
|
126
136
|
const homedir = _os2.default.homedir();
|
|
127
|
-
const settingsFilePath =
|
|
137
|
+
const settingsFilePath = path15.default.join(homedir, settingsFile);
|
|
128
138
|
return settingsFilePath;
|
|
129
139
|
}
|
|
130
140
|
function _legacyEnvVarWarning() {
|
|
@@ -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) || fs13.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 = fs13.default.existsSync(configFilePath);
|
|
721
743
|
if (!configFileExists) {
|
|
722
744
|
return null;
|
|
723
745
|
}
|
|
724
|
-
const fileContents =
|
|
746
|
+
const fileContents = fs13.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,11 +755,11 @@ 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
|
+
fs13.default.writeFileSync(configFilePath, serialized);
|
|
737
759
|
return config;
|
|
738
760
|
}
|
|
739
761
|
function _getConfigFilePath() {
|
|
740
|
-
return
|
|
762
|
+
return path15.default.join(process.cwd(), "i18n.json");
|
|
741
763
|
}
|
|
742
764
|
|
|
743
765
|
// src/cli/cmd/init.ts
|
|
@@ -832,7 +854,7 @@ function findLocaleFilesForFilename(fileName) {
|
|
|
832
854
|
});
|
|
833
855
|
const localeFilesAndPatterns = localeFiles.map((file) => ({
|
|
834
856
|
file,
|
|
835
|
-
pattern:
|
|
857
|
+
pattern: path15.default.join(path15.default.dirname(file), pattern)
|
|
836
858
|
}));
|
|
837
859
|
const grouppedFilesAndPatterns = _lodash2.default.groupBy(localeFilesAndPatterns, "pattern");
|
|
838
860
|
const patterns = Object.keys(grouppedFilesAndPatterns);
|
|
@@ -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 (!
|
|
856
|
-
const defaultContent = getDefaultContent(
|
|
857
|
-
|
|
858
|
-
|
|
877
|
+
if (!fs13.default.existsSync(filePath)) {
|
|
878
|
+
const defaultContent = getDefaultContent(path15.default.extname(filePath), source);
|
|
879
|
+
fs13.default.mkdirSync(path15.default.dirname(filePath), { recursive: true });
|
|
880
|
+
fs13.default.writeFileSync(filePath, defaultContent);
|
|
859
881
|
}
|
|
860
882
|
});
|
|
861
883
|
}
|
|
@@ -934,31 +956,31 @@ function updateGitignore() {
|
|
|
934
956
|
if (!projectRoot) {
|
|
935
957
|
return;
|
|
936
958
|
}
|
|
937
|
-
const gitignorePath =
|
|
938
|
-
if (!
|
|
959
|
+
const gitignorePath = path15.default.join(projectRoot, ".gitignore");
|
|
960
|
+
if (!fs13.default.existsSync(gitignorePath)) {
|
|
939
961
|
return;
|
|
940
962
|
}
|
|
941
|
-
const gitignore =
|
|
963
|
+
const gitignore = fs13.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 = fs13.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
|
+
fs13.default.writeFileSync(gitignorePath, content);
|
|
952
974
|
}
|
|
953
975
|
}
|
|
954
976
|
function findCurrentProjectRoot() {
|
|
955
977
|
let currentDir = process.cwd();
|
|
956
|
-
while (currentDir !==
|
|
957
|
-
const gitDirPath =
|
|
958
|
-
if (
|
|
978
|
+
while (currentDir !== path15.default.parse(currentDir).root) {
|
|
979
|
+
const gitDirPath = path15.default.join(currentDir, ".git");
|
|
980
|
+
if (fs13.default.existsSync(gitDirPath) && fs13.default.lstatSync(gitDirPath).isDirectory()) {
|
|
959
981
|
return currentDir;
|
|
960
982
|
}
|
|
961
|
-
currentDir =
|
|
983
|
+
currentDir = path15.default.dirname(currentDir);
|
|
962
984
|
}
|
|
963
985
|
return null;
|
|
964
986
|
}
|
|
@@ -1002,24 +1024,24 @@ function makePlatformInitializer(config, spinner) {
|
|
|
1002
1024
|
return {
|
|
1003
1025
|
name: config.name,
|
|
1004
1026
|
isEnabled: () => {
|
|
1005
|
-
const filePath =
|
|
1006
|
-
return
|
|
1027
|
+
const filePath = path15.default.join(process.cwd(), config.checkPath);
|
|
1028
|
+
return fs13.default.existsSync(filePath);
|
|
1007
1029
|
},
|
|
1008
1030
|
init: async () => {
|
|
1009
|
-
const filePath =
|
|
1010
|
-
const dirPath =
|
|
1011
|
-
if (!
|
|
1012
|
-
|
|
1031
|
+
const filePath = path15.default.join(process.cwd(), config.ciConfigPath);
|
|
1032
|
+
const dirPath = path15.default.dirname(filePath);
|
|
1033
|
+
if (!fs13.default.existsSync(dirPath)) {
|
|
1034
|
+
fs13.default.mkdirSync(dirPath, { recursive: true });
|
|
1013
1035
|
}
|
|
1014
1036
|
let canWrite = true;
|
|
1015
|
-
if (
|
|
1037
|
+
if (fs13.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
|
+
fs13.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}`);
|
|
@@ -1093,9 +1115,56 @@ function makeGitlabInitializer(spinner) {
|
|
|
1093
1115
|
|
|
1094
1116
|
// src/cli/cmd/init.ts
|
|
1095
1117
|
|
|
1096
|
-
|
|
1118
|
+
|
|
1119
|
+
// src/cli/cmd/init/cursor.ts
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
|
|
1124
|
+
var _url = require('url');
|
|
1125
|
+
|
|
1126
|
+
var __filename = _url.fileURLToPath.call(void 0, _chunkEHIR4A2Gcjs.importMetaUrl);
|
|
1127
|
+
var __dirname = path15.default.dirname(__filename);
|
|
1128
|
+
var AGENTS_MD = fs13.default.existsSync(path15.default.resolve(__dirname, "../agents.md")) ? path15.default.resolve(__dirname, "../agents.md") : path15.default.resolve(__dirname, "../../../../agents.md");
|
|
1129
|
+
var CURSORRULES = path15.default.resolve(process.cwd(), ".cursorrules");
|
|
1130
|
+
var cursor_default = new (0, _interactivecommander.InteractiveCommand)().command("cursor").description("Initialize .cursorrules with i18n-specific instructions for Cursor AI.").addOption(
|
|
1131
|
+
new (0, _interactivecommander.InteractiveOption)("-f, --force", "Overwrite .cursorrules without prompt.").default(false)
|
|
1132
|
+
).action(async (options) => {
|
|
1133
|
+
const spinner = _ora2.default.call(void 0, );
|
|
1134
|
+
let template;
|
|
1135
|
+
try {
|
|
1136
|
+
template = fs13.default.readFileSync(AGENTS_MD, "utf-8");
|
|
1137
|
+
} catch (err) {
|
|
1138
|
+
spinner.fail("Template file agents.md not found. Please reinstall the package.");
|
|
1139
|
+
return process.exit(1);
|
|
1140
|
+
}
|
|
1141
|
+
const exists = fs13.default.existsSync(CURSORRULES);
|
|
1142
|
+
let shouldWrite;
|
|
1143
|
+
if (exists && !options.force) {
|
|
1144
|
+
shouldWrite = await _prompts.confirm.call(void 0, {
|
|
1145
|
+
message: ".cursorrules already exists. Overwrite?"
|
|
1146
|
+
});
|
|
1147
|
+
if (!shouldWrite) {
|
|
1148
|
+
spinner.info("Skipped: .cursorrules left unchanged.");
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
try {
|
|
1153
|
+
fs13.default.writeFileSync(CURSORRULES, template);
|
|
1154
|
+
spinner.succeed("Created .cursorrules");
|
|
1155
|
+
spinner.info(
|
|
1156
|
+
".cursorrules has been created with i18n-specific instructions for Cursor AI."
|
|
1157
|
+
);
|
|
1158
|
+
} catch (err) {
|
|
1159
|
+
spinner.fail(`Failed to write .cursorrules: ${err}`);
|
|
1160
|
+
process.exit(1);
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
// src/cli/cmd/init.ts
|
|
1165
|
+
var openUrl = (path20) => {
|
|
1097
1166
|
const settings = getSettings(void 0);
|
|
1098
|
-
_open2.default.call(void 0, `${settings.auth.webUrl}${
|
|
1167
|
+
_open2.default.call(void 0, `${settings.auth.webUrl}${path20}`, { wait: false });
|
|
1099
1168
|
};
|
|
1100
1169
|
var throwHelpError = (option, value) => {
|
|
1101
1170
|
if (value === "help") {
|
|
@@ -1158,8 +1227,8 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
1158
1227
|
const values = value.includes(",") ? value.split(",") : value.split(" ");
|
|
1159
1228
|
for (const p of values) {
|
|
1160
1229
|
try {
|
|
1161
|
-
const dirPath =
|
|
1162
|
-
const stats =
|
|
1230
|
+
const dirPath = path15.default.dirname(p);
|
|
1231
|
+
const stats = fs13.default.statSync(dirPath);
|
|
1163
1232
|
if (!stats.isDirectory()) {
|
|
1164
1233
|
throw new Error(`${dirPath} is not a directory`);
|
|
1165
1234
|
}
|
|
@@ -1267,7 +1336,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
1267
1336
|
});
|
|
1268
1337
|
const auth2 = await newAuthenticator.whoami();
|
|
1269
1338
|
if (auth2) {
|
|
1270
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
1339
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _92 => _92.email])}`);
|
|
1271
1340
|
} else {
|
|
1272
1341
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
1273
1342
|
}
|
|
@@ -1284,7 +1353,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
1284
1353
|
if (!isInteractive) {
|
|
1285
1354
|
_ora2.default.call(void 0, ).info("Please see https://lingo.dev/cli");
|
|
1286
1355
|
}
|
|
1287
|
-
});
|
|
1356
|
+
}).addCommand(cursor_default);
|
|
1288
1357
|
|
|
1289
1358
|
// src/cli/cmd/show/index.ts
|
|
1290
1359
|
|
|
@@ -1301,12 +1370,12 @@ var config_default = new (0, _interactivecommander.Command)().command("config").
|
|
|
1301
1370
|
console.log(JSON.stringify(config, null, 2));
|
|
1302
1371
|
});
|
|
1303
1372
|
function loadReplexicaFileConfig() {
|
|
1304
|
-
const replexicaConfigPath =
|
|
1305
|
-
const fileExists =
|
|
1373
|
+
const replexicaConfigPath = path15.default.resolve(process.cwd(), "i18n.json");
|
|
1374
|
+
const fileExists = fs13.default.existsSync(replexicaConfigPath);
|
|
1306
1375
|
if (!fileExists) {
|
|
1307
1376
|
return void 0;
|
|
1308
1377
|
}
|
|
1309
|
-
const fileContent =
|
|
1378
|
+
const fileContent = fs13.default.readFileSync(replexicaConfigPath, "utf-8");
|
|
1310
1379
|
const replexicaFileConfig = JSON.parse(fileContent);
|
|
1311
1380
|
return replexicaFileConfig;
|
|
1312
1381
|
}
|
|
@@ -1357,7 +1426,7 @@ function getBuckets(i18nConfig) {
|
|
|
1357
1426
|
const includeItems = bucketEntry.include.map(
|
|
1358
1427
|
(item) => resolveBucketItem(item)
|
|
1359
1428
|
);
|
|
1360
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
1429
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _93 => _93.exclude, 'optionalAccess', _94 => _94.map, 'call', _95 => _95(
|
|
1361
1430
|
(item) => resolveBucketItem(item)
|
|
1362
1431
|
)]);
|
|
1363
1432
|
const config = {
|
|
@@ -1395,7 +1464,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
1395
1464
|
delimiter: pattern.delimiter
|
|
1396
1465
|
}))
|
|
1397
1466
|
);
|
|
1398
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
1467
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _96 => _96.flatMap, 'call', _97 => _97(
|
|
1399
1468
|
(pattern) => expandPlaceholderedGlob(
|
|
1400
1469
|
pattern.path,
|
|
1401
1470
|
__spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)
|
|
@@ -1412,13 +1481,13 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
1412
1481
|
return result;
|
|
1413
1482
|
}
|
|
1414
1483
|
function normalizePath(filepath) {
|
|
1415
|
-
const normalized =
|
|
1484
|
+
const normalized = path15.default.normalize(filepath);
|
|
1416
1485
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
1417
1486
|
}
|
|
1418
1487
|
function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
1419
|
-
const absolutePathPattern =
|
|
1488
|
+
const absolutePathPattern = path15.default.resolve(_pathPattern);
|
|
1420
1489
|
const pathPattern = normalizePath(
|
|
1421
|
-
|
|
1490
|
+
path15.default.relative(process.cwd(), absolutePathPattern)
|
|
1422
1491
|
);
|
|
1423
1492
|
if (pathPattern.startsWith("..")) {
|
|
1424
1493
|
throw new CLIError({
|
|
@@ -1432,7 +1501,7 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
1432
1501
|
docUrl: "invalidPathPattern"
|
|
1433
1502
|
});
|
|
1434
1503
|
}
|
|
1435
|
-
const pathPatternChunks = pathPattern.split(
|
|
1504
|
+
const pathPatternChunks = pathPattern.split(path15.default.sep);
|
|
1436
1505
|
const localeSegmentIndexes = pathPatternChunks.reduce(
|
|
1437
1506
|
(indexes, segment, index) => {
|
|
1438
1507
|
if (segment.includes("[locale]")) {
|
|
@@ -1449,12 +1518,12 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
1449
1518
|
withFileTypes: true,
|
|
1450
1519
|
windowsPathsNoEscape: true
|
|
1451
1520
|
// Windows path support
|
|
1452
|
-
}).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => normalizePath(
|
|
1521
|
+
}).filter((file) => file.isFile() || file.isSymbolicLink()).map((file) => file.fullpath()).map((fullpath) => normalizePath(path15.default.relative(process.cwd(), fullpath)));
|
|
1453
1522
|
const placeholderedPaths = sourcePaths.map((sourcePath) => {
|
|
1454
1523
|
const normalizedSourcePath = normalizePath(
|
|
1455
|
-
sourcePath.replace(/\//g,
|
|
1524
|
+
sourcePath.replace(/\//g, path15.default.sep)
|
|
1456
1525
|
);
|
|
1457
|
-
const sourcePathChunks = normalizedSourcePath.split(
|
|
1526
|
+
const sourcePathChunks = normalizedSourcePath.split(path15.default.sep);
|
|
1458
1527
|
localeSegmentIndexes.forEach((localeSegmentIndex) => {
|
|
1459
1528
|
const pathPatternChunk = pathPatternChunks[localeSegmentIndex];
|
|
1460
1529
|
const sourcePathChunk = sourcePathChunks[localeSegmentIndex];
|
|
@@ -1468,7 +1537,7 @@ function expandPlaceholderedGlob(_pathPattern, sourceLocale) {
|
|
|
1468
1537
|
sourcePathChunks[localeSegmentIndex] = placeholderedSegment;
|
|
1469
1538
|
}
|
|
1470
1539
|
});
|
|
1471
|
-
const placeholderedPath = sourcePathChunks.join(
|
|
1540
|
+
const placeholderedPath = sourcePathChunks.join(path15.default.sep);
|
|
1472
1541
|
return placeholderedPath;
|
|
1473
1542
|
});
|
|
1474
1543
|
return placeholderedPaths;
|
|
@@ -1532,8 +1601,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
1532
1601
|
} else if (type.target) {
|
|
1533
1602
|
result.push(...targetPaths);
|
|
1534
1603
|
}
|
|
1535
|
-
result.forEach((
|
|
1536
|
-
console.log(
|
|
1604
|
+
result.forEach((path20) => {
|
|
1605
|
+
console.log(path20);
|
|
1537
1606
|
});
|
|
1538
1607
|
}
|
|
1539
1608
|
}
|
|
@@ -1561,12 +1630,12 @@ function composeLoaders(...loaders) {
|
|
|
1561
1630
|
return {
|
|
1562
1631
|
init: async () => {
|
|
1563
1632
|
for (const loader of loaders) {
|
|
1564
|
-
await _optionalChain([loader, 'access',
|
|
1633
|
+
await _optionalChain([loader, 'access', _98 => _98.init, 'optionalCall', _99 => _99()]);
|
|
1565
1634
|
}
|
|
1566
1635
|
},
|
|
1567
1636
|
setDefaultLocale(locale) {
|
|
1568
1637
|
for (const loader of loaders) {
|
|
1569
|
-
_optionalChain([loader, 'access',
|
|
1638
|
+
_optionalChain([loader, 'access', _100 => _100.setDefaultLocale, 'optionalCall', _101 => _101(locale)]);
|
|
1570
1639
|
}
|
|
1571
1640
|
return this;
|
|
1572
1641
|
},
|
|
@@ -1587,7 +1656,7 @@ function composeLoaders(...loaders) {
|
|
|
1587
1656
|
pullHints: async (originalInput) => {
|
|
1588
1657
|
let result = originalInput;
|
|
1589
1658
|
for (let i = 0; i < loaders.length; i++) {
|
|
1590
|
-
const subResult = await _optionalChain([loaders, 'access',
|
|
1659
|
+
const subResult = await _optionalChain([loaders, 'access', _102 => _102[i], 'access', _103 => _103.pullHints, 'optionalCall', _104 => _104(result)]);
|
|
1591
1660
|
if (subResult) {
|
|
1592
1661
|
result = subResult;
|
|
1593
1662
|
}
|
|
@@ -1611,7 +1680,7 @@ function createLoader(lDefinition) {
|
|
|
1611
1680
|
if (state.initCtx) {
|
|
1612
1681
|
return state.initCtx;
|
|
1613
1682
|
}
|
|
1614
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1683
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _105 => _105.init, 'optionalCall', _106 => _106()]);
|
|
1615
1684
|
return state.initCtx;
|
|
1616
1685
|
},
|
|
1617
1686
|
setDefaultLocale(locale) {
|
|
@@ -1622,7 +1691,7 @@ function createLoader(lDefinition) {
|
|
|
1622
1691
|
return this;
|
|
1623
1692
|
},
|
|
1624
1693
|
async pullHints(originalInput) {
|
|
1625
|
-
return _optionalChain([lDefinition, 'access',
|
|
1694
|
+
return _optionalChain([lDefinition, 'access', _107 => _107.pullHints, 'optionalCall', _108 => _108(originalInput || state.originalInput)]);
|
|
1626
1695
|
},
|
|
1627
1696
|
async pull(locale, input2) {
|
|
1628
1697
|
if (!state.defaultLocale) {
|
|
@@ -1730,8 +1799,8 @@ function extractCommentsFromJsonc(jsoncString) {
|
|
|
1730
1799
|
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1731
1800
|
if (keyMatch) {
|
|
1732
1801
|
const key = keyMatch[1];
|
|
1733
|
-
const
|
|
1734
|
-
keyInfo = { key, path:
|
|
1802
|
+
const path20 = contextStack.map((ctx) => ctx.arrayIndex !== void 0 ? String(ctx.arrayIndex) : ctx.key).filter(Boolean);
|
|
1803
|
+
keyInfo = { key, path: path20 };
|
|
1735
1804
|
}
|
|
1736
1805
|
} else {
|
|
1737
1806
|
keyInfo = findAssociatedKey(lines, commentData.lineIndex, contextStack, arrayObjectCount);
|
|
@@ -1823,9 +1892,9 @@ function findAssociatedKey(lines, commentLineIndex, contextStack, arrayObjectCou
|
|
|
1823
1892
|
const keyMatch2 = innerLine.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1824
1893
|
if (keyMatch2) {
|
|
1825
1894
|
const key = keyMatch2[1];
|
|
1826
|
-
const
|
|
1827
|
-
|
|
1828
|
-
return { key, path:
|
|
1895
|
+
const path20 = contextStack.map((ctx) => ctx.arrayIndex !== void 0 ? String(ctx.arrayIndex) : ctx.key).filter(Boolean);
|
|
1896
|
+
path20.push(String(arrayIndex));
|
|
1897
|
+
return { key, path: path20 };
|
|
1829
1898
|
}
|
|
1830
1899
|
if (innerLine === "}") break;
|
|
1831
1900
|
}
|
|
@@ -1837,8 +1906,8 @@ function findAssociatedKey(lines, commentLineIndex, contextStack, arrayObjectCou
|
|
|
1837
1906
|
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1838
1907
|
if (keyMatch) {
|
|
1839
1908
|
const key = keyMatch[1];
|
|
1840
|
-
const
|
|
1841
|
-
return { key, path:
|
|
1909
|
+
const path20 = contextStack.map((ctx) => ctx.arrayIndex !== void 0 ? String(ctx.arrayIndex) : ctx.key).filter(Boolean);
|
|
1910
|
+
return { key, path: path20 };
|
|
1842
1911
|
}
|
|
1843
1912
|
}
|
|
1844
1913
|
return { key: null, path: [] };
|
|
@@ -1878,16 +1947,16 @@ function updateContext(contextStack, line, parsedJson, arrayObjectCount) {
|
|
|
1878
1947
|
if (closeBrackets > openBrackets) {
|
|
1879
1948
|
for (let i = 0; i < closeBrackets - openBrackets; i++) {
|
|
1880
1949
|
const popped = contextStack.pop();
|
|
1881
|
-
if (_optionalChain([popped, 'optionalAccess',
|
|
1950
|
+
if (_optionalChain([popped, 'optionalAccess', _109 => _109.isArray])) {
|
|
1882
1951
|
const depth = contextStack.length;
|
|
1883
1952
|
delete arrayObjectCount[depth];
|
|
1884
1953
|
}
|
|
1885
1954
|
}
|
|
1886
1955
|
}
|
|
1887
1956
|
}
|
|
1888
|
-
function setCommentAtPath(comments,
|
|
1957
|
+
function setCommentAtPath(comments, path20, key, hint) {
|
|
1889
1958
|
let current = comments;
|
|
1890
|
-
for (const pathKey of
|
|
1959
|
+
for (const pathKey of path20) {
|
|
1891
1960
|
if (!current[pathKey]) {
|
|
1892
1961
|
current[pathKey] = {};
|
|
1893
1962
|
}
|
|
@@ -1961,7 +2030,7 @@ function createDenormalizeLoader(options) {
|
|
|
1961
2030
|
const preservedObjects = {};
|
|
1962
2031
|
const nonPreservedInput = {};
|
|
1963
2032
|
for (const [key, value] of Object.entries(inputDenormalized)) {
|
|
1964
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2033
|
+
if (_optionalChain([options, 'optionalAccess', _110 => _110.shouldPreserveObject, 'optionalCall', _111 => _111(value)])) {
|
|
1965
2034
|
preservedObjects[key] = value;
|
|
1966
2035
|
} else {
|
|
1967
2036
|
nonPreservedInput[key] = value;
|
|
@@ -1994,7 +2063,7 @@ function createNormalizeLoader() {
|
|
|
1994
2063
|
return normalized;
|
|
1995
2064
|
},
|
|
1996
2065
|
push: async (locale, data, originalInput) => {
|
|
1997
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
2066
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _112 => _112.keysMap]), () => ( {}));
|
|
1998
2067
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1999
2068
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
2000
2069
|
delimiter: "/",
|
|
@@ -2097,8 +2166,8 @@ function createTextFileLoader(pathPattern) {
|
|
|
2097
2166
|
},
|
|
2098
2167
|
async push(locale, data, _37, originalLocale) {
|
|
2099
2168
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
2100
|
-
const finalPath =
|
|
2101
|
-
const dirPath =
|
|
2169
|
+
const finalPath = path15.default.resolve(draftPath);
|
|
2170
|
+
const dirPath = path15.default.dirname(finalPath);
|
|
2102
2171
|
await _promises4.default.mkdir(dirPath, { recursive: true });
|
|
2103
2172
|
const trimmedPayload = data.trim();
|
|
2104
2173
|
const trailingNewLine = await getTrailingNewLine(
|
|
@@ -2116,7 +2185,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
2116
2185
|
}
|
|
2117
2186
|
async function readFileForLocale(pathPattern, locale) {
|
|
2118
2187
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
2119
|
-
const finalPath =
|
|
2188
|
+
const finalPath = path15.default.resolve(draftPath);
|
|
2120
2189
|
const exists = await _promises4.default.access(finalPath).then(() => true).catch(() => false);
|
|
2121
2190
|
if (!exists) {
|
|
2122
2191
|
return "";
|
|
@@ -2128,8 +2197,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
2128
2197
|
if (!templateData) {
|
|
2129
2198
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
2130
2199
|
}
|
|
2131
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
2132
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
2200
|
+
if (_optionalChain([templateData, 'optionalAccess', _113 => _113.match, 'call', _114 => _114(/[\r\n]$/)])) {
|
|
2201
|
+
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
2202
|
return ending;
|
|
2134
2203
|
}
|
|
2135
2204
|
return "";
|
|
@@ -2208,10 +2277,10 @@ function extractQuotingMetadata(doc, skipRootKey) {
|
|
|
2208
2277
|
walkAndExtract(startNode, [], metadata);
|
|
2209
2278
|
return metadata;
|
|
2210
2279
|
}
|
|
2211
|
-
function walkAndExtract(node,
|
|
2280
|
+
function walkAndExtract(node, path20, metadata) {
|
|
2212
2281
|
if (isScalar(node)) {
|
|
2213
2282
|
if (node.type && node.type !== "PLAIN") {
|
|
2214
|
-
metadata.values.set(
|
|
2283
|
+
metadata.values.set(path20.join("."), node.type);
|
|
2215
2284
|
}
|
|
2216
2285
|
} else if (isYAMLMap(node)) {
|
|
2217
2286
|
if (node.items && Array.isArray(node.items)) {
|
|
@@ -2219,12 +2288,12 @@ function walkAndExtract(node, path19, metadata) {
|
|
|
2219
2288
|
if (pair && pair.key) {
|
|
2220
2289
|
const key = getKeyValue(pair.key);
|
|
2221
2290
|
if (key !== null && key !== void 0) {
|
|
2222
|
-
const keyPath = [...
|
|
2291
|
+
const keyPath = [...path20, String(key)].join(".");
|
|
2223
2292
|
if (pair.key.type && pair.key.type !== "PLAIN") {
|
|
2224
2293
|
metadata.keys.set(keyPath, pair.key.type);
|
|
2225
2294
|
}
|
|
2226
2295
|
if (pair.value) {
|
|
2227
|
-
walkAndExtract(pair.value, [...
|
|
2296
|
+
walkAndExtract(pair.value, [...path20, String(key)], metadata);
|
|
2228
2297
|
}
|
|
2229
2298
|
}
|
|
2230
2299
|
}
|
|
@@ -2234,7 +2303,7 @@ function walkAndExtract(node, path19, metadata) {
|
|
|
2234
2303
|
if (node.items && Array.isArray(node.items)) {
|
|
2235
2304
|
for (let i = 0; i < node.items.length; i++) {
|
|
2236
2305
|
if (node.items[i]) {
|
|
2237
|
-
walkAndExtract(node.items[i], [...
|
|
2306
|
+
walkAndExtract(node.items[i], [...path20, String(i)], metadata);
|
|
2238
2307
|
}
|
|
2239
2308
|
}
|
|
2240
2309
|
}
|
|
@@ -2252,9 +2321,9 @@ function applyQuotingMetadata(doc, metadata, skipRootKey) {
|
|
|
2252
2321
|
}
|
|
2253
2322
|
walkAndApply(startNode, [], metadata);
|
|
2254
2323
|
}
|
|
2255
|
-
function walkAndApply(node,
|
|
2324
|
+
function walkAndApply(node, path20, metadata) {
|
|
2256
2325
|
if (isScalar(node)) {
|
|
2257
|
-
const pathKey =
|
|
2326
|
+
const pathKey = path20.join(".");
|
|
2258
2327
|
const quoteType = metadata.values.get(pathKey);
|
|
2259
2328
|
if (quoteType) {
|
|
2260
2329
|
node.type = quoteType;
|
|
@@ -2265,13 +2334,13 @@ function walkAndApply(node, path19, metadata) {
|
|
|
2265
2334
|
if (pair && pair.key) {
|
|
2266
2335
|
const key = getKeyValue(pair.key);
|
|
2267
2336
|
if (key !== null && key !== void 0) {
|
|
2268
|
-
const keyPath = [...
|
|
2337
|
+
const keyPath = [...path20, String(key)].join(".");
|
|
2269
2338
|
const keyQuoteType = metadata.keys.get(keyPath);
|
|
2270
2339
|
if (keyQuoteType) {
|
|
2271
2340
|
pair.key.type = keyQuoteType;
|
|
2272
2341
|
}
|
|
2273
2342
|
if (pair.value) {
|
|
2274
|
-
walkAndApply(pair.value, [...
|
|
2343
|
+
walkAndApply(pair.value, [...path20, String(key)], metadata);
|
|
2275
2344
|
}
|
|
2276
2345
|
}
|
|
2277
2346
|
}
|
|
@@ -2281,7 +2350,7 @@ function walkAndApply(node, path19, metadata) {
|
|
|
2281
2350
|
if (node.items && Array.isArray(node.items)) {
|
|
2282
2351
|
for (let i = 0; i < node.items.length; i++) {
|
|
2283
2352
|
if (node.items[i]) {
|
|
2284
|
-
walkAndApply(node.items[i], [...
|
|
2353
|
+
walkAndApply(node.items[i], [...path20, String(i)], metadata);
|
|
2285
2354
|
}
|
|
2286
2355
|
}
|
|
2287
2356
|
}
|
|
@@ -2404,15 +2473,15 @@ function createAilLoader() {
|
|
|
2404
2473
|
}
|
|
2405
2474
|
const entries = dictionary.ENTRY || [];
|
|
2406
2475
|
for (const entry of entries) {
|
|
2407
|
-
const id = _optionalChain([entry, 'access',
|
|
2476
|
+
const id = _optionalChain([entry, 'access', _119 => _119.$, 'optionalAccess', _120 => _120.id]);
|
|
2408
2477
|
if (!id) {
|
|
2409
2478
|
continue;
|
|
2410
2479
|
}
|
|
2411
2480
|
const strings = entry.STRING || [];
|
|
2412
2481
|
const sourceString = strings.find(
|
|
2413
|
-
(s) => _optionalChain([s, 'access',
|
|
2482
|
+
(s) => _optionalChain([s, 'access', _121 => _121.$, 'optionalAccess', _122 => _122.lang]) === locale
|
|
2414
2483
|
);
|
|
2415
|
-
if (_optionalChain([sourceString, 'optionalAccess',
|
|
2484
|
+
if (_optionalChain([sourceString, 'optionalAccess', _123 => _123.$, 'access', _124 => _124.value])) {
|
|
2416
2485
|
result[id] = sourceString.$.value;
|
|
2417
2486
|
}
|
|
2418
2487
|
}
|
|
@@ -2454,7 +2523,7 @@ function createAilLoader() {
|
|
|
2454
2523
|
}
|
|
2455
2524
|
const entries = dictionary.ENTRY || [];
|
|
2456
2525
|
for (const [id, value] of Object.entries(data)) {
|
|
2457
|
-
let entry = entries.find((e) => _optionalChain([e, 'access',
|
|
2526
|
+
let entry = entries.find((e) => _optionalChain([e, 'access', _125 => _125.$, 'optionalAccess', _126 => _126.id]) === id);
|
|
2458
2527
|
if (!entry) {
|
|
2459
2528
|
entry = {
|
|
2460
2529
|
$: { id },
|
|
@@ -2466,7 +2535,7 @@ function createAilLoader() {
|
|
|
2466
2535
|
entry.STRING = [];
|
|
2467
2536
|
}
|
|
2468
2537
|
let targetString = entry.STRING.find(
|
|
2469
|
-
(s) => _optionalChain([s, 'access',
|
|
2538
|
+
(s) => _optionalChain([s, 'access', _127 => _127.$, 'optionalAccess', _128 => _128.lang]) === locale
|
|
2470
2539
|
);
|
|
2471
2540
|
if (targetString) {
|
|
2472
2541
|
targetString.$.value = value;
|
|
@@ -2597,7 +2666,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2597
2666
|
const resourceNodes = [];
|
|
2598
2667
|
let metaIndex = 0;
|
|
2599
2668
|
for (const child of resourcesNode.$$) {
|
|
2600
|
-
const elementName = _optionalChain([child, 'optionalAccess',
|
|
2669
|
+
const elementName = _optionalChain([child, 'optionalAccess', _129 => _129["#name"]]);
|
|
2601
2670
|
if (!isResourceElementName(elementName)) {
|
|
2602
2671
|
continue;
|
|
2603
2672
|
}
|
|
@@ -2605,11 +2674,11 @@ async function parseAndroidDocument(input2) {
|
|
|
2605
2674
|
if (!meta || meta.type !== elementName) {
|
|
2606
2675
|
continue;
|
|
2607
2676
|
}
|
|
2608
|
-
const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2677
|
+
const name = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _130 => _130.$, 'optionalAccess', _131 => _131.name]), () => ( meta.name));
|
|
2609
2678
|
if (!name) {
|
|
2610
2679
|
continue;
|
|
2611
2680
|
}
|
|
2612
|
-
const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2681
|
+
const translatable = (_nullishCoalesce(_optionalChain([child, 'optionalAccess', _132 => _132.$, 'optionalAccess', _133 => _133.translatable]), () => ( ""))).toLowerCase() !== "false";
|
|
2613
2682
|
switch (meta.type) {
|
|
2614
2683
|
case "string": {
|
|
2615
2684
|
resourceNodes.push({
|
|
@@ -2622,7 +2691,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2622
2691
|
break;
|
|
2623
2692
|
}
|
|
2624
2693
|
case "string-array": {
|
|
2625
|
-
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2694
|
+
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _134 => _134.item]), () => ( []));
|
|
2626
2695
|
const items = [];
|
|
2627
2696
|
const templateItems = meta.items;
|
|
2628
2697
|
for (let i = 0; i < Math.max(itemNodes.length, templateItems.length); i++) {
|
|
@@ -2646,7 +2715,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2646
2715
|
break;
|
|
2647
2716
|
}
|
|
2648
2717
|
case "plurals": {
|
|
2649
|
-
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess',
|
|
2718
|
+
const itemNodes = _nullishCoalesce(_optionalChain([child, 'optionalAccess', _135 => _135.item]), () => ( []));
|
|
2650
2719
|
const templateItems = meta.items;
|
|
2651
2720
|
const items = [];
|
|
2652
2721
|
for (const templateItem of templateItems) {
|
|
@@ -2655,7 +2724,7 @@ async function parseAndroidDocument(input2) {
|
|
|
2655
2724
|
continue;
|
|
2656
2725
|
}
|
|
2657
2726
|
const nodeItem = itemNodes.find(
|
|
2658
|
-
(item) => _optionalChain([item, 'optionalAccess',
|
|
2727
|
+
(item) => _optionalChain([item, 'optionalAccess', _136 => _136.$, 'optionalAccess', _137 => _137.quantity]) === quantity
|
|
2659
2728
|
);
|
|
2660
2729
|
if (!nodeItem) {
|
|
2661
2730
|
continue;
|
|
@@ -2929,7 +2998,7 @@ function cloneResourceNode(resource) {
|
|
|
2929
2998
|
const nodeClone = deepClone(resource.node);
|
|
2930
2999
|
const itemNodes = _nullishCoalesce(nodeClone.item, () => ( []));
|
|
2931
3000
|
const items = itemNodes.map((itemNode, index) => {
|
|
2932
|
-
const templateMeta = _nullishCoalesce(_nullishCoalesce(_optionalChain([resource, 'access',
|
|
3001
|
+
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
3002
|
return {
|
|
2934
3003
|
node: itemNode,
|
|
2935
3004
|
meta: cloneTextMeta(templateMeta)
|
|
@@ -2949,7 +3018,7 @@ function cloneResourceNode(resource) {
|
|
|
2949
3018
|
const items = [];
|
|
2950
3019
|
for (const templateItem of resource.items) {
|
|
2951
3020
|
const cloneNode = itemNodes.find(
|
|
2952
|
-
(item) => _optionalChain([item, 'optionalAccess',
|
|
3021
|
+
(item) => _optionalChain([item, 'optionalAccess', _144 => _144.$, 'optionalAccess', _145 => _145.quantity]) === templateItem.quantity
|
|
2953
3022
|
);
|
|
2954
3023
|
if (!cloneNode) {
|
|
2955
3024
|
continue;
|
|
@@ -3205,8 +3274,8 @@ function cloneDocumentStructure(document) {
|
|
|
3205
3274
|
resourceNodes.map((r) => resourceLookupKey(r.type, r.name))
|
|
3206
3275
|
);
|
|
3207
3276
|
let filtered = resourcesClone.$$.filter((child) => {
|
|
3208
|
-
const elementName = _optionalChain([child, 'optionalAccess',
|
|
3209
|
-
const name = _optionalChain([child, 'optionalAccess',
|
|
3277
|
+
const elementName = _optionalChain([child, 'optionalAccess', _146 => _146["#name"]]);
|
|
3278
|
+
const name = _optionalChain([child, 'optionalAccess', _147 => _147.$, 'optionalAccess', _148 => _148.name]);
|
|
3210
3279
|
if (!isResourceElementName(elementName) || !name) {
|
|
3211
3280
|
return true;
|
|
3212
3281
|
}
|
|
@@ -3215,7 +3284,7 @@ function cloneDocumentStructure(document) {
|
|
|
3215
3284
|
const cleaned = [];
|
|
3216
3285
|
let lastWasWhitespace = false;
|
|
3217
3286
|
for (const child of filtered) {
|
|
3218
|
-
const isWhitespace = _optionalChain([child, 'optionalAccess',
|
|
3287
|
+
const isWhitespace = _optionalChain([child, 'optionalAccess', _149 => _149["#name"]]) === "__text__" && (!child._ || child._.trim() === "");
|
|
3219
3288
|
if (isWhitespace) {
|
|
3220
3289
|
if (!lastWasWhitespace) {
|
|
3221
3290
|
cleaned.push(child);
|
|
@@ -3237,8 +3306,8 @@ function buildResourceLookup(resources) {
|
|
|
3237
3306
|
const lookup = /* @__PURE__ */ new Map();
|
|
3238
3307
|
const children = Array.isArray(resources.$$) ? resources.$$ : [];
|
|
3239
3308
|
for (const child of children) {
|
|
3240
|
-
const type = _optionalChain([child, 'optionalAccess',
|
|
3241
|
-
const name = _optionalChain([child, 'optionalAccess',
|
|
3309
|
+
const type = _optionalChain([child, 'optionalAccess', _150 => _150["#name"]]);
|
|
3310
|
+
const name = _optionalChain([child, 'optionalAccess', _151 => _151.$, 'optionalAccess', _152 => _152.name]);
|
|
3242
3311
|
if (!type || !name || !isResourceElementName(type)) {
|
|
3243
3312
|
continue;
|
|
3244
3313
|
}
|
|
@@ -3267,7 +3336,7 @@ function cloneResourceNodeFromLookup(resource, lookup) {
|
|
|
3267
3336
|
}
|
|
3268
3337
|
case "string-array": {
|
|
3269
3338
|
const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
|
|
3270
|
-
(child) => _optionalChain([child, 'optionalAccess',
|
|
3339
|
+
(child) => _optionalChain([child, 'optionalAccess', _153 => _153["#name"]]) === "item"
|
|
3271
3340
|
);
|
|
3272
3341
|
node.item = childItems;
|
|
3273
3342
|
if (childItems.length < resource.items.length) {
|
|
@@ -3296,12 +3365,12 @@ function cloneResourceNodeFromLookup(resource, lookup) {
|
|
|
3296
3365
|
}
|
|
3297
3366
|
case "plurals": {
|
|
3298
3367
|
const childItems = (Array.isArray(node.$$) ? node.$$ : []).filter(
|
|
3299
|
-
(child) => _optionalChain([child, 'optionalAccess',
|
|
3368
|
+
(child) => _optionalChain([child, 'optionalAccess', _154 => _154["#name"]]) === "item"
|
|
3300
3369
|
);
|
|
3301
3370
|
node.item = childItems;
|
|
3302
3371
|
const itemMap = /* @__PURE__ */ new Map();
|
|
3303
3372
|
for (const item of childItems) {
|
|
3304
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
3373
|
+
if (_optionalChain([item, 'optionalAccess', _155 => _155.$, 'optionalAccess', _156 => _156.quantity])) {
|
|
3305
3374
|
itemMap.set(item.$.quantity, item);
|
|
3306
3375
|
}
|
|
3307
3376
|
}
|
|
@@ -3591,7 +3660,7 @@ var _sync3 = require('csv-stringify/sync');
|
|
|
3591
3660
|
|
|
3592
3661
|
function detectKeyColumnName(csvString) {
|
|
3593
3662
|
const row = _sync.parse.call(void 0, csvString)[0];
|
|
3594
|
-
const firstColumn = _optionalChain([row, 'optionalAccess',
|
|
3663
|
+
const firstColumn = _optionalChain([row, 'optionalAccess', _157 => _157[0], 'optionalAccess', _158 => _158.trim, 'call', _159 => _159()]);
|
|
3595
3664
|
return firstColumn || "KEY";
|
|
3596
3665
|
}
|
|
3597
3666
|
function createCsvLoader() {
|
|
@@ -3816,35 +3885,35 @@ function createHtmlLoader() {
|
|
|
3816
3885
|
function getInnerHTML2(element) {
|
|
3817
3886
|
return element.children.map((child) => DomSerializer.default(child, { encodeEntities: false })).join("");
|
|
3818
3887
|
}
|
|
3819
|
-
function extractAttributes(element,
|
|
3888
|
+
function extractAttributes(element, path20) {
|
|
3820
3889
|
const tagName = element.name.toLowerCase();
|
|
3821
3890
|
const attrs = LOCALIZABLE_ATTRIBUTES2[tagName];
|
|
3822
3891
|
if (!attrs) return;
|
|
3823
3892
|
for (const attr of attrs) {
|
|
3824
|
-
const value = _optionalChain([element, 'access',
|
|
3893
|
+
const value = _optionalChain([element, 'access', _160 => _160.attribs, 'optionalAccess', _161 => _161[attr]]);
|
|
3825
3894
|
if (value && value.trim()) {
|
|
3826
|
-
result[`${
|
|
3895
|
+
result[`${path20}#${attr}`] = value.trim();
|
|
3827
3896
|
}
|
|
3828
3897
|
}
|
|
3829
3898
|
}
|
|
3830
3899
|
function extractFromElement(element, pathParts) {
|
|
3831
|
-
const
|
|
3900
|
+
const path20 = pathParts.join("/");
|
|
3832
3901
|
if (isInsideUnlocalizableTag(element)) {
|
|
3833
3902
|
return;
|
|
3834
3903
|
}
|
|
3835
|
-
extractAttributes(element,
|
|
3904
|
+
extractAttributes(element, path20);
|
|
3836
3905
|
const tagName = element.name.toLowerCase();
|
|
3837
3906
|
if (BLOCK_ELEMENTS.has(tagName) && isLeafBlock(element)) {
|
|
3838
3907
|
const content = getInnerHTML2(element).trim();
|
|
3839
3908
|
if (content) {
|
|
3840
|
-
result[
|
|
3909
|
+
result[path20] = content;
|
|
3841
3910
|
}
|
|
3842
3911
|
return;
|
|
3843
3912
|
}
|
|
3844
3913
|
if (PHRASING_ELEMENTS.has(tagName) && hasTranslatableContent(element)) {
|
|
3845
3914
|
const content = getInnerHTML2(element).trim();
|
|
3846
3915
|
if (content) {
|
|
3847
|
-
result[
|
|
3916
|
+
result[path20] = content;
|
|
3848
3917
|
}
|
|
3849
3918
|
return;
|
|
3850
3919
|
}
|
|
@@ -3936,8 +4005,8 @@ function createHtmlLoader() {
|
|
|
3936
4005
|
}
|
|
3937
4006
|
return current;
|
|
3938
4007
|
}
|
|
3939
|
-
function resolvePathToElement(
|
|
3940
|
-
const parts =
|
|
4008
|
+
function resolvePathToElement(path20) {
|
|
4009
|
+
const parts = path20.split("/");
|
|
3941
4010
|
const [rootTag, ...indices] = parts;
|
|
3942
4011
|
let current = null;
|
|
3943
4012
|
if (html) {
|
|
@@ -3968,8 +4037,8 @@ function createHtmlLoader() {
|
|
|
3968
4037
|
return traverseByIndices(current, indices);
|
|
3969
4038
|
}
|
|
3970
4039
|
}
|
|
3971
|
-
for (const [
|
|
3972
|
-
const [nodePath, attribute] =
|
|
4040
|
+
for (const [path20, value] of Object.entries(data)) {
|
|
4041
|
+
const [nodePath, attribute] = path20.split("#");
|
|
3973
4042
|
const element = resolvePathToElement(nodePath);
|
|
3974
4043
|
if (!element) {
|
|
3975
4044
|
console.warn(`Path not found in original HTML: ${nodePath}`);
|
|
@@ -4013,7 +4082,7 @@ function createMarkdownLoader() {
|
|
|
4013
4082
|
yaml: yamlEngine
|
|
4014
4083
|
}
|
|
4015
4084
|
});
|
|
4016
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
4085
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _162 => _162.trim, 'call', _163 => _163()]), () => ( ""))).filter(Boolean);
|
|
4017
4086
|
return {
|
|
4018
4087
|
...Object.fromEntries(
|
|
4019
4088
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -4032,7 +4101,7 @@ function createMarkdownLoader() {
|
|
|
4032
4101
|
);
|
|
4033
4102
|
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(
|
|
4034
4103
|
([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())
|
|
4035
|
-
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
4104
|
+
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _164 => _164.trim, 'call', _165 => _165()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
4036
4105
|
if (Object.keys(frontmatter).length > 0) {
|
|
4037
4106
|
content = `
|
|
4038
4107
|
${content}`;
|
|
@@ -4057,7 +4126,7 @@ function createMarkdocLoader() {
|
|
|
4057
4126
|
const result = {};
|
|
4058
4127
|
const counters = {};
|
|
4059
4128
|
traverseAndExtract(ast, "", result, counters);
|
|
4060
|
-
if (_optionalChain([ast, 'access',
|
|
4129
|
+
if (_optionalChain([ast, 'access', _166 => _166.attributes, 'optionalAccess', _167 => _167.frontmatter])) {
|
|
4061
4130
|
const frontmatter = _yaml2.default.parse(ast.attributes.frontmatter);
|
|
4062
4131
|
Object.entries(frontmatter).forEach(([key, value]) => {
|
|
4063
4132
|
if (typeof value === "string") {
|
|
@@ -4094,7 +4163,7 @@ function getSemanticNodeType(node) {
|
|
|
4094
4163
|
if (node.type === "tag") return node.tag || "tag";
|
|
4095
4164
|
return node.type;
|
|
4096
4165
|
}
|
|
4097
|
-
function traverseAndExtract(node,
|
|
4166
|
+
function traverseAndExtract(node, path20, result, counters, parentType) {
|
|
4098
4167
|
if (!node || typeof node !== "object") {
|
|
4099
4168
|
return;
|
|
4100
4169
|
}
|
|
@@ -4103,7 +4172,7 @@ function traverseAndExtract(node, path19, result, counters, parentType) {
|
|
|
4103
4172
|
if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
|
|
4104
4173
|
semanticType = nodeSemanticType;
|
|
4105
4174
|
}
|
|
4106
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
4175
|
+
if (node.type === "text" && _optionalChain([node, 'access', _168 => _168.attributes, 'optionalAccess', _169 => _169.content])) {
|
|
4107
4176
|
const content = node.attributes.content;
|
|
4108
4177
|
if (typeof content === "string" && content.trim()) {
|
|
4109
4178
|
if (semanticType) {
|
|
@@ -4116,12 +4185,12 @@ function traverseAndExtract(node, path19, result, counters, parentType) {
|
|
|
4116
4185
|
}
|
|
4117
4186
|
if (Array.isArray(node.children)) {
|
|
4118
4187
|
node.children.forEach((child, index) => {
|
|
4119
|
-
const childPath =
|
|
4188
|
+
const childPath = path20 ? `${path20}/children/${index}` : `children/${index}`;
|
|
4120
4189
|
traverseAndExtract(child, childPath, result, counters, semanticType);
|
|
4121
4190
|
});
|
|
4122
4191
|
}
|
|
4123
4192
|
}
|
|
4124
|
-
function buildPathMap(node,
|
|
4193
|
+
function buildPathMap(node, path20, counters, pathMap, parentType) {
|
|
4125
4194
|
if (!node || typeof node !== "object") {
|
|
4126
4195
|
return;
|
|
4127
4196
|
}
|
|
@@ -4130,33 +4199,33 @@ function buildPathMap(node, path19, counters, pathMap, parentType) {
|
|
|
4130
4199
|
if (nodeSemanticType && !["text", "strong", "em", "inline", "link"].includes(nodeSemanticType)) {
|
|
4131
4200
|
semanticType = nodeSemanticType;
|
|
4132
4201
|
}
|
|
4133
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
4202
|
+
if (node.type === "text" && _optionalChain([node, 'access', _170 => _170.attributes, 'optionalAccess', _171 => _171.content])) {
|
|
4134
4203
|
const content = node.attributes.content;
|
|
4135
4204
|
if (typeof content === "string" && content.trim()) {
|
|
4136
4205
|
if (semanticType) {
|
|
4137
4206
|
const index = counters[semanticType] || 0;
|
|
4138
4207
|
counters[semanticType] = index + 1;
|
|
4139
4208
|
const semanticKey = `${semanticType}-${index}`;
|
|
4140
|
-
const contentPath =
|
|
4209
|
+
const contentPath = path20 ? `${path20}/attributes/content` : "attributes/content";
|
|
4141
4210
|
pathMap[semanticKey] = contentPath;
|
|
4142
4211
|
}
|
|
4143
4212
|
}
|
|
4144
4213
|
}
|
|
4145
4214
|
if (Array.isArray(node.children)) {
|
|
4146
4215
|
node.children.forEach((child, index) => {
|
|
4147
|
-
const childPath =
|
|
4216
|
+
const childPath = path20 ? `${path20}/children/${index}` : `children/${index}`;
|
|
4148
4217
|
buildPathMap(child, childPath, counters, pathMap, semanticType);
|
|
4149
4218
|
});
|
|
4150
4219
|
}
|
|
4151
4220
|
}
|
|
4152
|
-
function applyTranslations(node,
|
|
4221
|
+
function applyTranslations(node, path20, data, pathMap) {
|
|
4153
4222
|
if (!node || typeof node !== "object") {
|
|
4154
4223
|
return;
|
|
4155
4224
|
}
|
|
4156
|
-
if (node.type === "text" && _optionalChain([node, 'access',
|
|
4225
|
+
if (node.type === "text" && _optionalChain([node, 'access', _172 => _172.attributes, 'optionalAccess', _173 => _173.content])) {
|
|
4157
4226
|
const content = node.attributes.content;
|
|
4158
4227
|
if (typeof content === "string") {
|
|
4159
|
-
const contentPath =
|
|
4228
|
+
const contentPath = path20 ? `${path20}/attributes/content` : "attributes/content";
|
|
4160
4229
|
const semanticKey = Object.keys(pathMap).find(
|
|
4161
4230
|
(key) => pathMap[key] === contentPath
|
|
4162
4231
|
);
|
|
@@ -4167,7 +4236,7 @@ function applyTranslations(node, path19, data, pathMap) {
|
|
|
4167
4236
|
}
|
|
4168
4237
|
if (Array.isArray(node.children)) {
|
|
4169
4238
|
node.children.forEach((child, index) => {
|
|
4170
|
-
const childPath =
|
|
4239
|
+
const childPath = path20 ? `${path20}/children/${index}` : `children/${index}`;
|
|
4171
4240
|
applyTranslations(child, childPath, data, pathMap);
|
|
4172
4241
|
});
|
|
4173
4242
|
}
|
|
@@ -4228,21 +4297,21 @@ function createMjmlLoader() {
|
|
|
4228
4297
|
const rootKey = Object.keys(parsed).find((key) => !key.startsWith("_") && !key.startsWith("$"));
|
|
4229
4298
|
const rootNode = rootKey ? parsed[rootKey] : parsed;
|
|
4230
4299
|
const rootPath = rootNode["#name"] || rootKey || "";
|
|
4231
|
-
traverse(rootNode, (node,
|
|
4300
|
+
traverse(rootNode, (node, path20, componentName) => {
|
|
4232
4301
|
if (typeof node !== "object") return;
|
|
4233
4302
|
const localizableAttrs = LOCALIZABLE_ATTRIBUTES[componentName];
|
|
4234
4303
|
if (localizableAttrs && node.$) {
|
|
4235
4304
|
localizableAttrs.forEach((attr) => {
|
|
4236
4305
|
const attrValue = node.$[attr];
|
|
4237
4306
|
if (attrValue) {
|
|
4238
|
-
result[`${
|
|
4307
|
+
result[`${path20}#${attr}`] = attrValue;
|
|
4239
4308
|
}
|
|
4240
4309
|
});
|
|
4241
4310
|
}
|
|
4242
4311
|
if (LOCALIZABLE_COMPONENTS.includes(componentName)) {
|
|
4243
4312
|
const innerHTML = getInnerHTML(node);
|
|
4244
4313
|
if (innerHTML) {
|
|
4245
|
-
result[
|
|
4314
|
+
result[path20] = innerHTML;
|
|
4246
4315
|
return "SKIP_CHILDREN";
|
|
4247
4316
|
}
|
|
4248
4317
|
}
|
|
@@ -4277,19 +4346,19 @@ function createMjmlLoader() {
|
|
|
4277
4346
|
const rootKey = Object.keys(parsed).find((key) => !key.startsWith("_") && !key.startsWith("$"));
|
|
4278
4347
|
const rootNode = rootKey ? parsed[rootKey] : parsed;
|
|
4279
4348
|
const rootPath = rootNode["#name"] || rootKey || "";
|
|
4280
|
-
traverse(rootNode, (node,
|
|
4349
|
+
traverse(rootNode, (node, path20, componentName) => {
|
|
4281
4350
|
if (typeof node !== "object") return;
|
|
4282
4351
|
const localizableAttrs = LOCALIZABLE_ATTRIBUTES[componentName];
|
|
4283
4352
|
if (localizableAttrs && node.$) {
|
|
4284
4353
|
localizableAttrs.forEach((attr) => {
|
|
4285
|
-
const attrKey = `${
|
|
4354
|
+
const attrKey = `${path20}#${attr}`;
|
|
4286
4355
|
if (data[attrKey] !== void 0) {
|
|
4287
4356
|
node.$[attr] = data[attrKey];
|
|
4288
4357
|
}
|
|
4289
4358
|
});
|
|
4290
4359
|
}
|
|
4291
|
-
if (LOCALIZABLE_COMPONENTS.includes(componentName) && data[
|
|
4292
|
-
setInnerHTML(node, data[
|
|
4360
|
+
if (LOCALIZABLE_COMPONENTS.includes(componentName) && data[path20]) {
|
|
4361
|
+
setInnerHTML(node, data[path20]);
|
|
4293
4362
|
return "SKIP_CHILDREN";
|
|
4294
4363
|
}
|
|
4295
4364
|
return void 0;
|
|
@@ -4302,7 +4371,7 @@ function createMjmlLoader() {
|
|
|
4302
4371
|
}
|
|
4303
4372
|
});
|
|
4304
4373
|
}
|
|
4305
|
-
function traverse(node, visitor,
|
|
4374
|
+
function traverse(node, visitor, path20 = "") {
|
|
4306
4375
|
if (!node || typeof node !== "object") {
|
|
4307
4376
|
return;
|
|
4308
4377
|
}
|
|
@@ -4318,7 +4387,7 @@ function traverse(node, visitor, path19 = "") {
|
|
|
4318
4387
|
}
|
|
4319
4388
|
const currentIndex = elementCounts.get(elementName) || 0;
|
|
4320
4389
|
elementCounts.set(elementName, currentIndex + 1);
|
|
4321
|
-
const currentPath =
|
|
4390
|
+
const currentPath = path20 ? `${path20}/${elementName}/${currentIndex}` : `${elementName}/${currentIndex}`;
|
|
4322
4391
|
const result = visitor(child, currentPath, elementName);
|
|
4323
4392
|
if (result !== "SKIP_CHILDREN") {
|
|
4324
4393
|
traverse(child, visitor, currentPath);
|
|
@@ -4466,7 +4535,7 @@ function isSkippableLine(line) {
|
|
|
4466
4535
|
function parsePropertyLine(line) {
|
|
4467
4536
|
const [key, ...valueParts] = line.split("=");
|
|
4468
4537
|
return {
|
|
4469
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
4538
|
+
key: _optionalChain([key, 'optionalAccess', _174 => _174.trim, 'call', _175 => _175()]) || "",
|
|
4470
4539
|
value: valueParts.join("=").trim()
|
|
4471
4540
|
};
|
|
4472
4541
|
}
|
|
@@ -4758,7 +4827,7 @@ var Parser3 = class {
|
|
|
4758
4827
|
}
|
|
4759
4828
|
}
|
|
4760
4829
|
expect(type) {
|
|
4761
|
-
if (_optionalChain([this, 'access',
|
|
4830
|
+
if (_optionalChain([this, 'access', _176 => _176.current, 'call', _177 => _177(), 'optionalAccess', _178 => _178.type]) === type) {
|
|
4762
4831
|
this.advance();
|
|
4763
4832
|
return true;
|
|
4764
4833
|
}
|
|
@@ -4835,7 +4904,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4835
4904
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
4836
4905
|
continue;
|
|
4837
4906
|
}
|
|
4838
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
4907
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _179 => _179.localizations, 'optionalAccess', _180 => _180[locale]]);
|
|
4839
4908
|
if (langTranslationEntity) {
|
|
4840
4909
|
if ("stringUnit" in langTranslationEntity) {
|
|
4841
4910
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -4849,7 +4918,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4849
4918
|
resultData[translationKey] = {};
|
|
4850
4919
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
4851
4920
|
for (const form in pluralForms) {
|
|
4852
|
-
if (_optionalChain([pluralForms, 'access',
|
|
4921
|
+
if (_optionalChain([pluralForms, 'access', _181 => _181[form], 'optionalAccess', _182 => _182.stringUnit, 'optionalAccess', _183 => _183.value])) {
|
|
4853
4922
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
4854
4923
|
}
|
|
4855
4924
|
}
|
|
@@ -4875,7 +4944,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4875
4944
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
4876
4945
|
if (typeof value === "string") {
|
|
4877
4946
|
langDataToMerge.strings[key] = {
|
|
4878
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
4947
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _184 => _184.strings, 'optionalAccess', _185 => _185[key], 'optionalAccess', _186 => _186.extractionState]),
|
|
4879
4948
|
localizations: {
|
|
4880
4949
|
[locale]: {
|
|
4881
4950
|
stringUnit: {
|
|
@@ -4890,7 +4959,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4890
4959
|
}
|
|
4891
4960
|
} else if (Array.isArray(value)) {
|
|
4892
4961
|
langDataToMerge.strings[key] = {
|
|
4893
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
4962
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _187 => _187.strings, 'optionalAccess', _188 => _188[key], 'optionalAccess', _189 => _189.extractionState]),
|
|
4894
4963
|
localizations: {
|
|
4895
4964
|
[locale]: {
|
|
4896
4965
|
stringSet: {
|
|
@@ -4948,7 +5017,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
4948
5017
|
for (const [locale, localization] of Object.entries(
|
|
4949
5018
|
entity.localizations
|
|
4950
5019
|
)) {
|
|
4951
|
-
if (_optionalChain([localization, 'access',
|
|
5020
|
+
if (_optionalChain([localization, 'access', _190 => _190.variations, 'optionalAccess', _191 => _191.plural])) {
|
|
4952
5021
|
const pluralForms = localization.variations.plural;
|
|
4953
5022
|
for (const form in pluralForms) {
|
|
4954
5023
|
const pluralKey = `${translationKey}/${form}`;
|
|
@@ -4968,7 +5037,7 @@ function _removeLocale(input2, locale) {
|
|
|
4968
5037
|
const { strings } = input2;
|
|
4969
5038
|
const newStrings = _lodash2.default.cloneDeep(strings);
|
|
4970
5039
|
for (const [key, value] of Object.entries(newStrings)) {
|
|
4971
|
-
if (_optionalChain([value, 'access',
|
|
5040
|
+
if (_optionalChain([value, 'access', _192 => _192.localizations, 'optionalAccess', _193 => _193[locale]])) {
|
|
4972
5041
|
delete value.localizations[locale];
|
|
4973
5042
|
}
|
|
4974
5043
|
}
|
|
@@ -5099,7 +5168,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5099
5168
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
5100
5169
|
continue;
|
|
5101
5170
|
}
|
|
5102
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
5171
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _194 => _194.localizations, 'optionalAccess', _195 => _195[locale]]);
|
|
5103
5172
|
if (langTranslationEntity) {
|
|
5104
5173
|
if (!resultData[translationKey]) {
|
|
5105
5174
|
resultData[translationKey] = {};
|
|
@@ -5111,7 +5180,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5111
5180
|
for (const [subName, subData] of Object.entries(
|
|
5112
5181
|
langTranslationEntity.substitutions
|
|
5113
5182
|
)) {
|
|
5114
|
-
const pluralForms = _optionalChain([subData, 'access',
|
|
5183
|
+
const pluralForms = _optionalChain([subData, 'access', _196 => _196.variations, 'optionalAccess', _197 => _197.plural]);
|
|
5115
5184
|
if (pluralForms) {
|
|
5116
5185
|
const forms = {};
|
|
5117
5186
|
for (const [form, formData] of Object.entries(pluralForms)) {
|
|
@@ -5136,7 +5205,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5136
5205
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
5137
5206
|
const forms = {};
|
|
5138
5207
|
for (const [form, formData] of Object.entries(pluralForms)) {
|
|
5139
|
-
if (_optionalChain([formData, 'optionalAccess',
|
|
5208
|
+
if (_optionalChain([formData, 'optionalAccess', _198 => _198.stringUnit, 'optionalAccess', _199 => _199.value])) {
|
|
5140
5209
|
forms[form] = formData.stringUnit.value;
|
|
5141
5210
|
}
|
|
5142
5211
|
}
|
|
@@ -5179,7 +5248,7 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5179
5248
|
for (const [subName, subData] of Object.entries(
|
|
5180
5249
|
keyData.substitutions
|
|
5181
5250
|
)) {
|
|
5182
|
-
const pluralValue = _optionalChain([subData, 'optionalAccess',
|
|
5251
|
+
const pluralValue = _optionalChain([subData, 'optionalAccess', _200 => _200.variations, 'optionalAccess', _201 => _201.plural]);
|
|
5183
5252
|
if (pluralValue && isIcuPluralString(pluralValue)) {
|
|
5184
5253
|
try {
|
|
5185
5254
|
const pluralForms = parseIcuPluralString(pluralValue, locale);
|
|
@@ -5192,8 +5261,8 @@ function createXcodeXcstringsV2Loader(defaultLocale) {
|
|
|
5192
5261
|
}
|
|
5193
5262
|
};
|
|
5194
5263
|
}
|
|
5195
|
-
const sourceLocale = _optionalChain([originalInput, 'optionalAccess',
|
|
5196
|
-
const origFormatSpec = _optionalChain([originalInput, 'optionalAccess',
|
|
5264
|
+
const sourceLocale = _optionalChain([originalInput, 'optionalAccess', _202 => _202.sourceLanguage]) || "en";
|
|
5265
|
+
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
5266
|
subs[subName] = {
|
|
5198
5267
|
formatSpecifier: origFormatSpec,
|
|
5199
5268
|
variations: {
|
|
@@ -5218,7 +5287,7 @@ ${error instanceof Error ? error.message : String(error)}`
|
|
|
5218
5287
|
values: keyData.stringSet
|
|
5219
5288
|
};
|
|
5220
5289
|
}
|
|
5221
|
-
if ("variations" in keyData && _optionalChain([keyData, 'access',
|
|
5290
|
+
if ("variations" in keyData && _optionalChain([keyData, 'access', _210 => _210.variations, 'optionalAccess', _211 => _211.plural])) {
|
|
5222
5291
|
const pluralValue = keyData.variations.plural;
|
|
5223
5292
|
if (isIcuPluralString(pluralValue)) {
|
|
5224
5293
|
try {
|
|
@@ -5245,7 +5314,7 @@ ${error instanceof Error ? error.message : String(error)}`
|
|
|
5245
5314
|
}
|
|
5246
5315
|
if (Object.keys(localizationData).length > 0) {
|
|
5247
5316
|
langDataToMerge.strings[baseKey] = {
|
|
5248
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
5317
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _212 => _212.strings, 'optionalAccess', _213 => _213[baseKey], 'optionalAccess', _214 => _214.extractionState]),
|
|
5249
5318
|
localizations: {
|
|
5250
5319
|
[locale]: localizationData
|
|
5251
5320
|
}
|
|
@@ -5340,7 +5409,7 @@ function createBaseFormatterLoader(options, formatFn) {
|
|
|
5340
5409
|
const stage = options.stage || "both";
|
|
5341
5410
|
const formatData = async (locale, data) => {
|
|
5342
5411
|
const draftPath = options.bucketPathPattern.replaceAll("[locale]", locale);
|
|
5343
|
-
const finalPath =
|
|
5412
|
+
const finalPath = path15.default.resolve(draftPath);
|
|
5344
5413
|
return await formatFn(data, finalPath);
|
|
5345
5414
|
};
|
|
5346
5415
|
return createLoader({
|
|
@@ -5418,18 +5487,18 @@ function createBiomeLoader(options) {
|
|
|
5418
5487
|
});
|
|
5419
5488
|
}
|
|
5420
5489
|
async function findBiomeConfig(startPath) {
|
|
5421
|
-
let currentDir =
|
|
5422
|
-
const root =
|
|
5490
|
+
let currentDir = path15.default.dirname(startPath);
|
|
5491
|
+
const root = path15.default.parse(currentDir).root;
|
|
5423
5492
|
while (currentDir !== root) {
|
|
5424
5493
|
for (const configName of ["biome.json", "biome.jsonc"]) {
|
|
5425
|
-
const configPath =
|
|
5494
|
+
const configPath = path15.default.join(currentDir, configName);
|
|
5426
5495
|
try {
|
|
5427
5496
|
await _promises4.default.access(configPath);
|
|
5428
5497
|
return configPath;
|
|
5429
5498
|
} catch (e2) {
|
|
5430
5499
|
}
|
|
5431
5500
|
}
|
|
5432
|
-
const parentDir =
|
|
5501
|
+
const parentDir = path15.default.dirname(currentDir);
|
|
5433
5502
|
if (parentDir === currentDir) break;
|
|
5434
5503
|
currentDir = parentDir;
|
|
5435
5504
|
}
|
|
@@ -5447,7 +5516,7 @@ async function formatDataWithBiome(data, filePath, options) {
|
|
|
5447
5516
|
if (!configPath && !options.alwaysFormat) {
|
|
5448
5517
|
console.log();
|
|
5449
5518
|
console.log(
|
|
5450
|
-
`\u26A0\uFE0F Biome config not found for ${
|
|
5519
|
+
`\u26A0\uFE0F Biome config not found for ${path15.default.basename(filePath)} - skipping formatting`
|
|
5451
5520
|
);
|
|
5452
5521
|
return data;
|
|
5453
5522
|
}
|
|
@@ -5468,10 +5537,10 @@ async function formatDataWithBiome(data, filePath, options) {
|
|
|
5468
5537
|
});
|
|
5469
5538
|
return formatted.content;
|
|
5470
5539
|
} catch (error) {
|
|
5471
|
-
const errorMessage = error instanceof Error ? error.message || _optionalChain([error, 'access',
|
|
5472
|
-
if (_optionalChain([errorMessage, 'optionalAccess',
|
|
5540
|
+
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]]) : "";
|
|
5541
|
+
if (_optionalChain([errorMessage, 'optionalAccess', _221 => _221.includes, 'call', _222 => _222("does not exist in the workspace")])) {
|
|
5473
5542
|
} else {
|
|
5474
|
-
console.log(`\u26A0\uFE0F Biome skipped ${
|
|
5543
|
+
console.log(`\u26A0\uFE0F Biome skipped ${path15.default.basename(filePath)}`);
|
|
5475
5544
|
if (errorMessage) {
|
|
5476
5545
|
console.log(` ${errorMessage}`);
|
|
5477
5546
|
}
|
|
@@ -5516,7 +5585,7 @@ function createPoDataLoader(params) {
|
|
|
5516
5585
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
5517
5586
|
if (msgid && entry.msgid) {
|
|
5518
5587
|
const context = entry.msgctxt || "";
|
|
5519
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
5588
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _223 => _223.translations, 'access', _224 => _224[context], 'optionalAccess', _225 => _225[msgid]]);
|
|
5520
5589
|
if (fullEntry) {
|
|
5521
5590
|
result[msgid] = fullEntry;
|
|
5522
5591
|
}
|
|
@@ -5526,8 +5595,8 @@ function createPoDataLoader(params) {
|
|
|
5526
5595
|
return result;
|
|
5527
5596
|
},
|
|
5528
5597
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
5529
|
-
const currentSections = _optionalChain([pullInput, 'optionalAccess',
|
|
5530
|
-
const originalSections = _optionalChain([originalInput, 'optionalAccess',
|
|
5598
|
+
const currentSections = _optionalChain([pullInput, 'optionalAccess', _226 => _226.split, 'call', _227 => _227("\n\n"), 'access', _228 => _228.filter, 'call', _229 => _229(Boolean)]) || [];
|
|
5599
|
+
const originalSections = _optionalChain([originalInput, 'optionalAccess', _230 => _230.split, 'call', _231 => _231("\n\n"), 'access', _232 => _232.filter, 'call', _233 => _233(Boolean)]) || [];
|
|
5531
5600
|
const result = originalSections.map((section) => {
|
|
5532
5601
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
5533
5602
|
if (Object.keys(sectionPo.translations).length === 0) {
|
|
@@ -5598,8 +5667,8 @@ function createPoContentLoader() {
|
|
|
5598
5667
|
{
|
|
5599
5668
|
...entry,
|
|
5600
5669
|
msgstr: [
|
|
5601
|
-
_optionalChain([data, 'access',
|
|
5602
|
-
_optionalChain([data, 'access',
|
|
5670
|
+
_optionalChain([data, 'access', _234 => _234[entry.msgid], 'optionalAccess', _235 => _235.singular]),
|
|
5671
|
+
_optionalChain([data, 'access', _236 => _236[entry.msgid], 'optionalAccess', _237 => _237.plural]) || null
|
|
5603
5672
|
].filter(Boolean)
|
|
5604
5673
|
}
|
|
5605
5674
|
]).fromPairs().value();
|
|
@@ -5721,7 +5790,7 @@ function pullV1(xliffElement, locale, originalLocale) {
|
|
|
5721
5790
|
let key = getTransUnitKey(unit);
|
|
5722
5791
|
if (!key) return;
|
|
5723
5792
|
if (seenKeys.has(key)) {
|
|
5724
|
-
const id = _optionalChain([unit, 'access',
|
|
5793
|
+
const id = _optionalChain([unit, 'access', _238 => _238.getAttribute, 'call', _239 => _239("id"), 'optionalAccess', _240 => _240.trim, 'call', _241 => _241()]);
|
|
5725
5794
|
if (id) {
|
|
5726
5795
|
key = `${key}#${id}`;
|
|
5727
5796
|
} else {
|
|
@@ -5769,7 +5838,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
5769
5838
|
let key = getTransUnitKey(unit);
|
|
5770
5839
|
if (!key) return;
|
|
5771
5840
|
if (seenKeys.has(key)) {
|
|
5772
|
-
const id = _optionalChain([unit, 'access',
|
|
5841
|
+
const id = _optionalChain([unit, 'access', _242 => _242.getAttribute, 'call', _243 => _243("id"), 'optionalAccess', _244 => _244.trim, 'call', _245 => _245()]);
|
|
5773
5842
|
if (id) {
|
|
5774
5843
|
key = `${key}#${id}`;
|
|
5775
5844
|
} else {
|
|
@@ -5811,7 +5880,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
5811
5880
|
const translationKeys = new Set(Object.keys(translations));
|
|
5812
5881
|
existingUnits.forEach((unit, key) => {
|
|
5813
5882
|
if (!translationKeys.has(key)) {
|
|
5814
|
-
_optionalChain([unit, 'access',
|
|
5883
|
+
_optionalChain([unit, 'access', _246 => _246.parentNode, 'optionalAccess', _247 => _247.removeChild, 'call', _248 => _248(unit)]);
|
|
5815
5884
|
}
|
|
5816
5885
|
});
|
|
5817
5886
|
return serializeWithDeclaration(
|
|
@@ -5854,18 +5923,18 @@ function traverseUnitsV2(container, fileId, currentPath, result) {
|
|
|
5854
5923
|
Array.from(container.children).forEach((child) => {
|
|
5855
5924
|
const tagName = child.tagName;
|
|
5856
5925
|
if (tagName === "unit") {
|
|
5857
|
-
const unitId = _optionalChain([child, 'access',
|
|
5926
|
+
const unitId = _optionalChain([child, 'access', _249 => _249.getAttribute, 'call', _250 => _250("id"), 'optionalAccess', _251 => _251.trim, 'call', _252 => _252()]);
|
|
5858
5927
|
if (!unitId) return;
|
|
5859
5928
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
5860
5929
|
const segment = child.querySelector("segment");
|
|
5861
|
-
const source = _optionalChain([segment, 'optionalAccess',
|
|
5930
|
+
const source = _optionalChain([segment, 'optionalAccess', _253 => _253.querySelector, 'call', _254 => _254("source")]);
|
|
5862
5931
|
if (source) {
|
|
5863
5932
|
result[key] = extractTextContent(source);
|
|
5864
5933
|
} else {
|
|
5865
5934
|
result[key] = unitId;
|
|
5866
5935
|
}
|
|
5867
5936
|
} else if (tagName === "group") {
|
|
5868
|
-
const groupId = _optionalChain([child, 'access',
|
|
5937
|
+
const groupId = _optionalChain([child, 'access', _255 => _255.getAttribute, 'call', _256 => _256("id"), 'optionalAccess', _257 => _257.trim, 'call', _258 => _258()]);
|
|
5869
5938
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
5870
5939
|
traverseUnitsV2(child, fileId, newPath, result);
|
|
5871
5940
|
}
|
|
@@ -5901,12 +5970,12 @@ function indexUnitsV2(container, fileId, currentPath, index) {
|
|
|
5901
5970
|
Array.from(container.children).forEach((child) => {
|
|
5902
5971
|
const tagName = child.tagName;
|
|
5903
5972
|
if (tagName === "unit") {
|
|
5904
|
-
const unitId = _optionalChain([child, 'access',
|
|
5973
|
+
const unitId = _optionalChain([child, 'access', _259 => _259.getAttribute, 'call', _260 => _260("id"), 'optionalAccess', _261 => _261.trim, 'call', _262 => _262()]);
|
|
5905
5974
|
if (!unitId) return;
|
|
5906
5975
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
5907
5976
|
index.set(key, child);
|
|
5908
5977
|
} else if (tagName === "group") {
|
|
5909
|
-
const groupId = _optionalChain([child, 'access',
|
|
5978
|
+
const groupId = _optionalChain([child, 'access', _263 => _263.getAttribute, 'call', _264 => _264("id"), 'optionalAccess', _265 => _265.trim, 'call', _266 => _266()]);
|
|
5910
5979
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
5911
5980
|
indexUnitsV2(child, fileId, newPath, index);
|
|
5912
5981
|
}
|
|
@@ -5927,9 +5996,9 @@ function updateUnitV2(unit, value) {
|
|
|
5927
5996
|
setTextContent(source, value);
|
|
5928
5997
|
}
|
|
5929
5998
|
function getTransUnitKey(transUnit) {
|
|
5930
|
-
const resname = _optionalChain([transUnit, 'access',
|
|
5999
|
+
const resname = _optionalChain([transUnit, 'access', _267 => _267.getAttribute, 'call', _268 => _268("resname"), 'optionalAccess', _269 => _269.trim, 'call', _270 => _270()]);
|
|
5931
6000
|
if (resname) return resname;
|
|
5932
|
-
const id = _optionalChain([transUnit, 'access',
|
|
6001
|
+
const id = _optionalChain([transUnit, 'access', _271 => _271.getAttribute, 'call', _272 => _272("id"), 'optionalAccess', _273 => _273.trim, 'call', _274 => _274()]);
|
|
5933
6002
|
if (id) return id;
|
|
5934
6003
|
const sourceElement = transUnit.querySelector("source");
|
|
5935
6004
|
if (sourceElement) {
|
|
@@ -5986,7 +6055,7 @@ function formatXml(xml) {
|
|
|
5986
6055
|
if (cdataNode) {
|
|
5987
6056
|
return `${indent2}${openTag}<![CDATA[${cdataNode.nodeValue}]]></${tagName}>`;
|
|
5988
6057
|
}
|
|
5989
|
-
const textContent3 = _optionalChain([element, 'access',
|
|
6058
|
+
const textContent3 = _optionalChain([element, 'access', _275 => _275.textContent, 'optionalAccess', _276 => _276.trim, 'call', _277 => _277()]) || "";
|
|
5990
6059
|
const hasOnlyText = element.childNodes.length === 1 && element.childNodes[0].nodeType === 3;
|
|
5991
6060
|
if (hasOnlyText && textContent3) {
|
|
5992
6061
|
return `${indent2}${openTag}${textContent3}</${tagName}>`;
|
|
@@ -6279,7 +6348,7 @@ function createDatoClient(params) {
|
|
|
6279
6348
|
ids: !records.length ? void 0 : records.join(",")
|
|
6280
6349
|
}
|
|
6281
6350
|
}).catch(
|
|
6282
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6351
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _278 => _278.response, 'optionalAccess', _279 => _279.body, 'optionalAccess', _280 => _280.data, 'optionalAccess', _281 => _281[0]]) || error)
|
|
6283
6352
|
);
|
|
6284
6353
|
},
|
|
6285
6354
|
findRecordsForModel: async (modelId, records) => {
|
|
@@ -6290,10 +6359,10 @@ function createDatoClient(params) {
|
|
|
6290
6359
|
filter: {
|
|
6291
6360
|
type: modelId,
|
|
6292
6361
|
only_valid: "true",
|
|
6293
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
6362
|
+
ids: !_optionalChain([records, 'optionalAccess', _282 => _282.length]) ? void 0 : records.join(",")
|
|
6294
6363
|
}
|
|
6295
6364
|
}).catch(
|
|
6296
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6365
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _283 => _283.response, 'optionalAccess', _284 => _284.body, 'optionalAccess', _285 => _285.data, 'optionalAccess', _286 => _286[0]]) || error)
|
|
6297
6366
|
);
|
|
6298
6367
|
return result;
|
|
6299
6368
|
} catch (_error) {
|
|
@@ -6309,10 +6378,10 @@ function createDatoClient(params) {
|
|
|
6309
6378
|
updateRecord: async (id, payload) => {
|
|
6310
6379
|
try {
|
|
6311
6380
|
await dato.items.update(id, payload).catch(
|
|
6312
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6381
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _287 => _287.response, 'optionalAccess', _288 => _288.body, 'optionalAccess', _289 => _289.data, 'optionalAccess', _290 => _290[0]]) || error)
|
|
6313
6382
|
);
|
|
6314
6383
|
} catch (_error) {
|
|
6315
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
6384
|
+
if (_optionalChain([_error, 'optionalAccess', _291 => _291.attributes, 'optionalAccess', _292 => _292.details, 'optionalAccess', _293 => _293.message])) {
|
|
6316
6385
|
throw new Error(
|
|
6317
6386
|
[
|
|
6318
6387
|
`${_error.attributes.details.message}`,
|
|
@@ -6334,10 +6403,10 @@ function createDatoClient(params) {
|
|
|
6334
6403
|
enableFieldLocalization: async (args) => {
|
|
6335
6404
|
try {
|
|
6336
6405
|
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch(
|
|
6337
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
6406
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _294 => _294.response, 'optionalAccess', _295 => _295.body, 'optionalAccess', _296 => _296.data, 'optionalAccess', _297 => _297[0]]) || error)
|
|
6338
6407
|
);
|
|
6339
6408
|
} catch (_error) {
|
|
6340
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
6409
|
+
if (_optionalChain([_error, 'optionalAccess', _298 => _298.attributes, 'optionalAccess', _299 => _299.code]) === "NOT_FOUND") {
|
|
6341
6410
|
throw new Error(
|
|
6342
6411
|
[
|
|
6343
6412
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -6345,7 +6414,7 @@ function createDatoClient(params) {
|
|
|
6345
6414
|
].join("\n\n")
|
|
6346
6415
|
);
|
|
6347
6416
|
}
|
|
6348
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
6417
|
+
if (_optionalChain([_error, 'optionalAccess', _300 => _300.attributes, 'optionalAccess', _301 => _301.details, 'optionalAccess', _302 => _302.message])) {
|
|
6349
6418
|
throw new Error(
|
|
6350
6419
|
[
|
|
6351
6420
|
`${_error.attributes.details.message}`,
|
|
@@ -6423,7 +6492,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
6423
6492
|
const records = await dato.findRecordsForModel(modelId);
|
|
6424
6493
|
const recordChoices = createRecordChoices(
|
|
6425
6494
|
records,
|
|
6426
|
-
_optionalChain([config, 'access',
|
|
6495
|
+
_optionalChain([config, 'access', _303 => _303.models, 'access', _304 => _304[modelId], 'optionalAccess', _305 => _305.records]) || [],
|
|
6427
6496
|
project
|
|
6428
6497
|
);
|
|
6429
6498
|
const selectedRecords = await promptRecordSelection(
|
|
@@ -6442,14 +6511,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
6442
6511
|
},
|
|
6443
6512
|
async pull(locale, input2, initCtx) {
|
|
6444
6513
|
const result = {};
|
|
6445
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
6446
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
6514
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _306 => _306.models]) || {})) {
|
|
6515
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _307 => _307.models, 'access', _308 => _308[modelId], 'access', _309 => _309.records]) || [];
|
|
6447
6516
|
const recordIds = records.map((record) => record.id);
|
|
6448
6517
|
records = await dato.findRecords(recordIds);
|
|
6449
6518
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
6450
6519
|
if (records.length > 0) {
|
|
6451
6520
|
result[modelId] = {
|
|
6452
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
6521
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _310 => _310.models, 'optionalAccess', _311 => _311[modelId], 'optionalAccess', _312 => _312.fields]) || [],
|
|
6453
6522
|
records
|
|
6454
6523
|
};
|
|
6455
6524
|
}
|
|
@@ -6512,7 +6581,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
6512
6581
|
return records.map((record) => ({
|
|
6513
6582
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
6514
6583
|
value: record.id,
|
|
6515
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
6584
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _313 => _313.includes, 'call', _314 => _314(record.id)])
|
|
6516
6585
|
}));
|
|
6517
6586
|
}
|
|
6518
6587
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -6679,24 +6748,24 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
|
|
|
6679
6748
|
}
|
|
6680
6749
|
function serializeStructuredText(rawStructuredText) {
|
|
6681
6750
|
return serializeStructuredTextNode(rawStructuredText);
|
|
6682
|
-
function serializeStructuredTextNode(node,
|
|
6751
|
+
function serializeStructuredTextNode(node, path20 = [], acc = {}) {
|
|
6683
6752
|
if ("document" in node) {
|
|
6684
6753
|
return serializeStructuredTextNode(
|
|
6685
6754
|
node.document,
|
|
6686
|
-
[...
|
|
6755
|
+
[...path20, "document"],
|
|
6687
6756
|
acc
|
|
6688
6757
|
);
|
|
6689
6758
|
}
|
|
6690
6759
|
if (!_lodash2.default.isNil(node.value)) {
|
|
6691
|
-
acc[[...
|
|
6760
|
+
acc[[...path20, "value"].join(".")] = node.value;
|
|
6692
6761
|
} else if (_lodash2.default.get(node, "type") === "block") {
|
|
6693
|
-
acc[[...
|
|
6762
|
+
acc[[...path20, "item"].join(".")] = serializeBlock(node.item);
|
|
6694
6763
|
}
|
|
6695
6764
|
if (node.children) {
|
|
6696
6765
|
for (let i = 0; i < node.children.length; i++) {
|
|
6697
6766
|
serializeStructuredTextNode(
|
|
6698
6767
|
node.children[i],
|
|
6699
|
-
[...
|
|
6768
|
+
[...path20, i.toString()],
|
|
6700
6769
|
acc
|
|
6701
6770
|
);
|
|
6702
6771
|
}
|
|
@@ -6763,8 +6832,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
|
|
|
6763
6832
|
}
|
|
6764
6833
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
6765
6834
|
const result = _lodash2.default.cloneDeep(originalRawStructuredText);
|
|
6766
|
-
for (const [
|
|
6767
|
-
const realPath = _lodash2.default.chain(
|
|
6835
|
+
for (const [path20, value] of _lodash2.default.entries(parsedStructuredText)) {
|
|
6836
|
+
const realPath = _lodash2.default.chain(path20.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
|
|
6768
6837
|
const deserializedValue = createRawDatoValue(
|
|
6769
6838
|
value,
|
|
6770
6839
|
_lodash2.default.get(originalRawStructuredText, realPath),
|
|
@@ -6801,12 +6870,12 @@ function _isVideo(rawDatoValue) {
|
|
|
6801
6870
|
// src/cli/loaders/dato/index.ts
|
|
6802
6871
|
function createDatoLoader(configFilePath) {
|
|
6803
6872
|
try {
|
|
6804
|
-
const configContent =
|
|
6873
|
+
const configContent = fs13.default.readFileSync(configFilePath, "utf-8");
|
|
6805
6874
|
const datoConfig = datoConfigSchema.parse(_json52.default.parse(configContent));
|
|
6806
6875
|
return composeLoaders(
|
|
6807
6876
|
createDatoApiLoader(
|
|
6808
6877
|
datoConfig,
|
|
6809
|
-
(updatedConfig) =>
|
|
6878
|
+
(updatedConfig) => fs13.default.writeFileSync(
|
|
6810
6879
|
configFilePath,
|
|
6811
6880
|
_json52.default.stringify(updatedConfig, null, 2)
|
|
6812
6881
|
)
|
|
@@ -6831,7 +6900,7 @@ function createVttLoader() {
|
|
|
6831
6900
|
if (!input2) {
|
|
6832
6901
|
return "";
|
|
6833
6902
|
}
|
|
6834
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
6903
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _315 => _315.parse, 'call', _316 => _316(input2), 'optionalAccess', _317 => _317.cues]);
|
|
6835
6904
|
if (Object.keys(vtt).length === 0) {
|
|
6836
6905
|
return {};
|
|
6837
6906
|
} else {
|
|
@@ -6885,7 +6954,7 @@ function variableExtractLoader(params) {
|
|
|
6885
6954
|
for (let i = 0; i < matches.length; i++) {
|
|
6886
6955
|
const match2 = matches[i];
|
|
6887
6956
|
const currentValue = result[key].value;
|
|
6888
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
6957
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _318 => _318.replace, 'call', _319 => _319(match2, `{variable:${i}}`)]);
|
|
6889
6958
|
result[key].value = newValue;
|
|
6890
6959
|
result[key].variables[i] = match2;
|
|
6891
6960
|
}
|
|
@@ -6900,7 +6969,7 @@ function variableExtractLoader(params) {
|
|
|
6900
6969
|
const variable = valueObj.variables[i];
|
|
6901
6970
|
const currentValue = result[key];
|
|
6902
6971
|
if (typeof currentValue === "string") {
|
|
6903
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
6972
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _320 => _320.replaceAll, 'call', _321 => _321(
|
|
6904
6973
|
`{variable:${i}}`,
|
|
6905
6974
|
variable
|
|
6906
6975
|
)]);
|
|
@@ -7104,7 +7173,7 @@ function createVueJsonLoader() {
|
|
|
7104
7173
|
return createLoader({
|
|
7105
7174
|
pull: async (locale, input2, ctx) => {
|
|
7106
7175
|
const parsed = parseVueFile(input2);
|
|
7107
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
7176
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _322 => _322.i18n, 'optionalAccess', _323 => _323[locale]]), () => ( {}));
|
|
7108
7177
|
},
|
|
7109
7178
|
push: async (locale, data, originalInput) => {
|
|
7110
7179
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -7195,15 +7264,15 @@ function parseTypeScript(input2) {
|
|
|
7195
7264
|
function extractStringsFromDefaultExport(ast) {
|
|
7196
7265
|
let extracted = {};
|
|
7197
7266
|
traverse2(ast, {
|
|
7198
|
-
ExportDefaultDeclaration(
|
|
7199
|
-
const { declaration } =
|
|
7267
|
+
ExportDefaultDeclaration(path20) {
|
|
7268
|
+
const { declaration } = path20.node;
|
|
7200
7269
|
const decl = unwrapTSAsExpression(declaration);
|
|
7201
7270
|
if (t.isObjectExpression(decl)) {
|
|
7202
7271
|
extracted = objectExpressionToObject(decl);
|
|
7203
7272
|
} else if (t.isArrayExpression(decl)) {
|
|
7204
7273
|
extracted = arrayExpressionToArray(decl);
|
|
7205
7274
|
} else if (t.isIdentifier(decl)) {
|
|
7206
|
-
const binding =
|
|
7275
|
+
const binding = path20.scope.bindings[decl.name];
|
|
7207
7276
|
if (binding && t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
7208
7277
|
const initRaw = binding.path.node.init;
|
|
7209
7278
|
const init = initRaw ? unwrapTSAsExpression(initRaw) : initRaw;
|
|
@@ -7268,8 +7337,8 @@ function arrayExpressionToArray(arrayExpression) {
|
|
|
7268
7337
|
function updateStringsInDefaultExport(ast, data) {
|
|
7269
7338
|
let modified = false;
|
|
7270
7339
|
traverse2(ast, {
|
|
7271
|
-
ExportDefaultDeclaration(
|
|
7272
|
-
const { declaration } =
|
|
7340
|
+
ExportDefaultDeclaration(path20) {
|
|
7341
|
+
const { declaration } = path20.node;
|
|
7273
7342
|
const decl = unwrapTSAsExpression(declaration);
|
|
7274
7343
|
if (t.isObjectExpression(decl)) {
|
|
7275
7344
|
modified = updateStringsInObjectExpression(decl, data) || modified;
|
|
@@ -7278,7 +7347,7 @@ function updateStringsInDefaultExport(ast, data) {
|
|
|
7278
7347
|
modified = updateStringsInArrayExpression(decl, data) || modified;
|
|
7279
7348
|
}
|
|
7280
7349
|
} else if (t.isIdentifier(decl)) {
|
|
7281
|
-
modified = updateStringsInExportedIdentifier(
|
|
7350
|
+
modified = updateStringsInExportedIdentifier(path20, data) || modified;
|
|
7282
7351
|
}
|
|
7283
7352
|
}
|
|
7284
7353
|
});
|
|
@@ -7289,7 +7358,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
|
|
|
7289
7358
|
objectExpression.properties.forEach((prop) => {
|
|
7290
7359
|
if (!t.isObjectProperty(prop)) return;
|
|
7291
7360
|
const key = getPropertyKey(prop);
|
|
7292
|
-
const incomingVal = _optionalChain([data, 'optionalAccess',
|
|
7361
|
+
const incomingVal = _optionalChain([data, 'optionalAccess', _324 => _324[key]]);
|
|
7293
7362
|
if (incomingVal === void 0) {
|
|
7294
7363
|
return;
|
|
7295
7364
|
}
|
|
@@ -7325,7 +7394,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
7325
7394
|
let modified = false;
|
|
7326
7395
|
arrayExpression.elements.forEach((element, index) => {
|
|
7327
7396
|
if (!element) return;
|
|
7328
|
-
const incomingVal = _optionalChain([incoming, 'optionalAccess',
|
|
7397
|
+
const incomingVal = _optionalChain([incoming, 'optionalAccess', _325 => _325[index]]);
|
|
7329
7398
|
if (incomingVal === void 0) return;
|
|
7330
7399
|
if (t.isStringLiteral(element) && typeof incomingVal === "string") {
|
|
7331
7400
|
if (element.value !== incomingVal) {
|
|
@@ -7349,9 +7418,9 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
7349
7418
|
});
|
|
7350
7419
|
return modified;
|
|
7351
7420
|
}
|
|
7352
|
-
function updateStringsInExportedIdentifier(
|
|
7353
|
-
const exportName =
|
|
7354
|
-
const binding =
|
|
7421
|
+
function updateStringsInExportedIdentifier(path20, data) {
|
|
7422
|
+
const exportName = path20.node.declaration.name;
|
|
7423
|
+
const binding = path20.scope.bindings[exportName];
|
|
7355
7424
|
if (!binding || !binding.path.node) return false;
|
|
7356
7425
|
if (t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
7357
7426
|
const initRaw = binding.path.node.init;
|
|
@@ -7819,7 +7888,7 @@ var AST = class _AST {
|
|
|
7819
7888
|
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
7889
|
if (this.isStart() && !this.type)
|
|
7821
7890
|
ret.unshift([]);
|
|
7822
|
-
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
7891
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access', _326 => _326.#parent, 'optionalAccess', _327 => _327.type]) === "!")) {
|
|
7823
7892
|
ret.push({});
|
|
7824
7893
|
}
|
|
7825
7894
|
return ret;
|
|
@@ -7827,7 +7896,7 @@ var AST = class _AST {
|
|
|
7827
7896
|
isStart() {
|
|
7828
7897
|
if (this.#root === this)
|
|
7829
7898
|
return true;
|
|
7830
|
-
if (!_optionalChain([this, 'access',
|
|
7899
|
+
if (!_optionalChain([this, 'access', _328 => _328.#parent, 'optionalAccess', _329 => _329.isStart, 'call', _330 => _330()]))
|
|
7831
7900
|
return false;
|
|
7832
7901
|
if (this.#parentIndex === 0)
|
|
7833
7902
|
return true;
|
|
@@ -7843,12 +7912,12 @@ var AST = class _AST {
|
|
|
7843
7912
|
isEnd() {
|
|
7844
7913
|
if (this.#root === this)
|
|
7845
7914
|
return true;
|
|
7846
|
-
if (_optionalChain([this, 'access',
|
|
7915
|
+
if (_optionalChain([this, 'access', _331 => _331.#parent, 'optionalAccess', _332 => _332.type]) === "!")
|
|
7847
7916
|
return true;
|
|
7848
|
-
if (!_optionalChain([this, 'access',
|
|
7917
|
+
if (!_optionalChain([this, 'access', _333 => _333.#parent, 'optionalAccess', _334 => _334.isEnd, 'call', _335 => _335()]))
|
|
7849
7918
|
return false;
|
|
7850
7919
|
if (!this.type)
|
|
7851
|
-
return _optionalChain([this, 'access',
|
|
7920
|
+
return _optionalChain([this, 'access', _336 => _336.#parent, 'optionalAccess', _337 => _337.isEnd, 'call', _338 => _338()]);
|
|
7852
7921
|
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
7853
7922
|
return this.#parentIndex === pl - 1;
|
|
7854
7923
|
}
|
|
@@ -8093,7 +8162,7 @@ var AST = class _AST {
|
|
|
8093
8162
|
}
|
|
8094
8163
|
}
|
|
8095
8164
|
let end = "";
|
|
8096
|
-
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
8165
|
+
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access', _339 => _339.#parent, 'optionalAccess', _340 => _340.type]) === "!") {
|
|
8097
8166
|
end = "(?:$|\\/)";
|
|
8098
8167
|
}
|
|
8099
8168
|
const final2 = start2 + src + end;
|
|
@@ -8260,11 +8329,11 @@ var qmarksTestNoExtDot = ([$0]) => {
|
|
|
8260
8329
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
8261
8330
|
};
|
|
8262
8331
|
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
8263
|
-
var
|
|
8332
|
+
var path14 = {
|
|
8264
8333
|
win32: { sep: "\\" },
|
|
8265
8334
|
posix: { sep: "/" }
|
|
8266
8335
|
};
|
|
8267
|
-
var sep = defaultPlatform === "win32" ?
|
|
8336
|
+
var sep = defaultPlatform === "win32" ? path14.win32.sep : path14.posix.sep;
|
|
8268
8337
|
minimatch.sep = sep;
|
|
8269
8338
|
var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
|
|
8270
8339
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -8967,11 +9036,11 @@ function _getAllKeys(obj, prefix = "") {
|
|
|
8967
9036
|
let keys = [];
|
|
8968
9037
|
for (const key in obj) {
|
|
8969
9038
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
8970
|
-
const
|
|
9039
|
+
const path20 = prefix ? `${prefix}.${key}` : key;
|
|
8971
9040
|
if (typeof obj[key] === "object" && obj[key] !== null && !Array.isArray(obj[key])) {
|
|
8972
|
-
keys = keys.concat(_getAllKeys(obj[key],
|
|
9041
|
+
keys = keys.concat(_getAllKeys(obj[key], path20));
|
|
8973
9042
|
} else {
|
|
8974
|
-
keys.push(
|
|
9043
|
+
keys.push(path20);
|
|
8975
9044
|
}
|
|
8976
9045
|
}
|
|
8977
9046
|
return keys;
|
|
@@ -9194,7 +9263,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
9194
9263
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
9195
9264
|
const result = {
|
|
9196
9265
|
frontmatter: data.frontmatter,
|
|
9197
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
9266
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _341 => _341.codePlaceholders]) || {},
|
|
9198
9267
|
content
|
|
9199
9268
|
};
|
|
9200
9269
|
return result;
|
|
@@ -9584,36 +9653,36 @@ function createTwigLoader() {
|
|
|
9584
9653
|
const html2 = element.children.map((child) => DomSerializer2.default(child, { encodeEntities: false })).join("");
|
|
9585
9654
|
return postprocessTwig(html2, twigBlocks);
|
|
9586
9655
|
}
|
|
9587
|
-
function extractAttributes(element,
|
|
9656
|
+
function extractAttributes(element, path20) {
|
|
9588
9657
|
const tagName = element.name.toLowerCase();
|
|
9589
9658
|
const attrs = LOCALIZABLE_ATTRIBUTES2[tagName];
|
|
9590
9659
|
if (!attrs) return;
|
|
9591
9660
|
for (const attr of attrs) {
|
|
9592
|
-
const value = _optionalChain([element, 'access',
|
|
9661
|
+
const value = _optionalChain([element, 'access', _342 => _342.attribs, 'optionalAccess', _343 => _343[attr]]);
|
|
9593
9662
|
if (value && value.trim()) {
|
|
9594
9663
|
const restoredValue = postprocessTwig(value.trim(), twigBlocks);
|
|
9595
|
-
result[`${
|
|
9664
|
+
result[`${path20}#${attr}`] = restoredValue;
|
|
9596
9665
|
}
|
|
9597
9666
|
}
|
|
9598
9667
|
}
|
|
9599
9668
|
function extractFromElement(element, pathParts) {
|
|
9600
|
-
const
|
|
9669
|
+
const path20 = pathParts.join("/");
|
|
9601
9670
|
if (isInsideUnlocalizableTag(element)) {
|
|
9602
9671
|
return;
|
|
9603
9672
|
}
|
|
9604
|
-
extractAttributes(element,
|
|
9673
|
+
extractAttributes(element, path20);
|
|
9605
9674
|
const tagName = element.name.toLowerCase();
|
|
9606
9675
|
if (BLOCK_ELEMENTS.has(tagName) && isLeafBlock(element)) {
|
|
9607
9676
|
const content = getInnerHTML2(element).trim();
|
|
9608
9677
|
if (content) {
|
|
9609
|
-
result[
|
|
9678
|
+
result[path20] = content;
|
|
9610
9679
|
}
|
|
9611
9680
|
return;
|
|
9612
9681
|
}
|
|
9613
9682
|
if (PHRASING_ELEMENTS.has(tagName) && hasTranslatableContent(element)) {
|
|
9614
9683
|
const content = getInnerHTML2(element).trim();
|
|
9615
9684
|
if (content) {
|
|
9616
|
-
result[
|
|
9685
|
+
result[path20] = content;
|
|
9617
9686
|
}
|
|
9618
9687
|
return;
|
|
9619
9688
|
}
|
|
@@ -9704,8 +9773,8 @@ function createTwigLoader() {
|
|
|
9704
9773
|
}
|
|
9705
9774
|
return current;
|
|
9706
9775
|
}
|
|
9707
|
-
function resolvePathToElement(
|
|
9708
|
-
const parts =
|
|
9776
|
+
function resolvePathToElement(path20) {
|
|
9777
|
+
const parts = path20.split("/");
|
|
9709
9778
|
const [rootTag, ...indices] = parts;
|
|
9710
9779
|
let current = null;
|
|
9711
9780
|
if (html) {
|
|
@@ -9736,8 +9805,8 @@ function createTwigLoader() {
|
|
|
9736
9805
|
return traverseByIndices(current, indices);
|
|
9737
9806
|
}
|
|
9738
9807
|
}
|
|
9739
|
-
for (const [
|
|
9740
|
-
const [nodePath, attribute] =
|
|
9808
|
+
for (const [path20, value] of Object.entries(data)) {
|
|
9809
|
+
const [nodePath, attribute] = path20.split("#");
|
|
9741
9810
|
const element = resolvePathToElement(nodePath);
|
|
9742
9811
|
if (!element) {
|
|
9743
9812
|
console.warn(`Path not found in original template: ${nodePath}`);
|
|
@@ -9853,19 +9922,19 @@ function createJsonDictionaryLoader() {
|
|
|
9853
9922
|
);
|
|
9854
9923
|
return input2;
|
|
9855
9924
|
}
|
|
9856
|
-
function walk(obj, dataNode,
|
|
9925
|
+
function walk(obj, dataNode, path20 = []) {
|
|
9857
9926
|
if (Array.isArray(obj) && Array.isArray(dataNode)) {
|
|
9858
9927
|
obj.forEach(
|
|
9859
|
-
(item, idx) => walk(item, dataNode[idx], [...
|
|
9928
|
+
(item, idx) => walk(item, dataNode[idx], [...path20, String(idx)])
|
|
9860
9929
|
);
|
|
9861
9930
|
} else if (obj && typeof obj === "object" && dataNode && typeof dataNode === "object" && !Array.isArray(dataNode)) {
|
|
9862
9931
|
for (const key of Object.keys(obj)) {
|
|
9863
9932
|
if (dataNode.hasOwnProperty(key)) {
|
|
9864
|
-
walk(obj[key], dataNode[key], [...
|
|
9933
|
+
walk(obj[key], dataNode[key], [...path20, key]);
|
|
9865
9934
|
}
|
|
9866
9935
|
}
|
|
9867
9936
|
} else if (obj && typeof obj === "object" && !Array.isArray(obj) && typeof dataNode === "string") {
|
|
9868
|
-
setNestedLocale(input2,
|
|
9937
|
+
setNestedLocale(input2, path20, locale, dataNode, originalLocale);
|
|
9869
9938
|
}
|
|
9870
9939
|
}
|
|
9871
9940
|
walk(input2, data);
|
|
@@ -9893,14 +9962,14 @@ function extractTranslatables(obj, locale) {
|
|
|
9893
9962
|
function isTranslatableObject(obj, locale) {
|
|
9894
9963
|
return obj && typeof obj === "object" && !Array.isArray(obj) && Object.prototype.hasOwnProperty.call(obj, locale);
|
|
9895
9964
|
}
|
|
9896
|
-
function setNestedLocale(obj,
|
|
9965
|
+
function setNestedLocale(obj, path20, locale, value, originalLocale) {
|
|
9897
9966
|
let curr = obj;
|
|
9898
|
-
for (let i = 0; i <
|
|
9899
|
-
const key =
|
|
9967
|
+
for (let i = 0; i < path20.length - 1; i++) {
|
|
9968
|
+
const key = path20[i];
|
|
9900
9969
|
if (!(key in curr)) curr[key] = {};
|
|
9901
9970
|
curr = curr[key];
|
|
9902
9971
|
}
|
|
9903
|
-
const last =
|
|
9972
|
+
const last = path20[path20.length - 1];
|
|
9904
9973
|
if (curr[last] && typeof curr[last] === "object") {
|
|
9905
9974
|
curr[last][locale] = value;
|
|
9906
9975
|
if (originalLocale && curr[last][originalLocale]) {
|
|
@@ -10692,7 +10761,7 @@ function createBasicTranslator(model, systemPrompt, settings = {}) {
|
|
|
10692
10761
|
]
|
|
10693
10762
|
});
|
|
10694
10763
|
const result = JSON.parse(response.text);
|
|
10695
|
-
return _optionalChain([result, 'optionalAccess',
|
|
10764
|
+
return _optionalChain([result, 'optionalAccess', _344 => _344.data]) || {};
|
|
10696
10765
|
}
|
|
10697
10766
|
}
|
|
10698
10767
|
function extractPayloadChunks(payload) {
|
|
@@ -10775,7 +10844,7 @@ function getPureModelProvider(provider) {
|
|
|
10775
10844
|
|
|
10776
10845
|
${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
10777
10846
|
`;
|
|
10778
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
10847
|
+
switch (_optionalChain([provider, 'optionalAccess', _345 => _345.id])) {
|
|
10779
10848
|
case "openai": {
|
|
10780
10849
|
if (!process.env.OPENAI_API_KEY) {
|
|
10781
10850
|
throw new Error(
|
|
@@ -10833,7 +10902,7 @@ function getPureModelProvider(provider) {
|
|
|
10833
10902
|
})(provider.model);
|
|
10834
10903
|
}
|
|
10835
10904
|
default: {
|
|
10836
|
-
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess',
|
|
10905
|
+
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _346 => _346.id])));
|
|
10837
10906
|
}
|
|
10838
10907
|
}
|
|
10839
10908
|
}
|
|
@@ -10925,7 +10994,7 @@ function parseGitUrl(url) {
|
|
|
10925
10994
|
}
|
|
10926
10995
|
const sshMatch = cleanUrl.match(/[@:]([^:/@]+\/[^:/@]+)$/);
|
|
10927
10996
|
const httpsMatch = cleanUrl.match(/\/([^/]+\/[^/]+)$/);
|
|
10928
|
-
const repoPath = _optionalChain([sshMatch, 'optionalAccess',
|
|
10997
|
+
const repoPath = _optionalChain([sshMatch, 'optionalAccess', _347 => _347[1]]) || _optionalChain([httpsMatch, 'optionalAccess', _348 => _348[1]]);
|
|
10929
10998
|
if (!repoPath) return null;
|
|
10930
10999
|
const hashedPath = hashProjectName(repoPath);
|
|
10931
11000
|
if (platform) {
|
|
@@ -11043,21 +11112,21 @@ function trackEvent(email, event, properties) {
|
|
|
11043
11112
|
|
|
11044
11113
|
function tryReadFile(filePath, defaultValue = null) {
|
|
11045
11114
|
try {
|
|
11046
|
-
const content =
|
|
11115
|
+
const content = fs13.readFileSync(filePath, "utf-8");
|
|
11047
11116
|
return content;
|
|
11048
11117
|
} catch (error) {
|
|
11049
11118
|
return defaultValue;
|
|
11050
11119
|
}
|
|
11051
11120
|
}
|
|
11052
11121
|
function writeFile(filePath, content) {
|
|
11053
|
-
const dir =
|
|
11054
|
-
if (!
|
|
11055
|
-
|
|
11122
|
+
const dir = path15.dirname(filePath);
|
|
11123
|
+
if (!fs13.existsSync(dir)) {
|
|
11124
|
+
fs13.mkdirSync(dir, { recursive: true });
|
|
11056
11125
|
}
|
|
11057
|
-
|
|
11126
|
+
fs13.writeFileSync(filePath, content);
|
|
11058
11127
|
}
|
|
11059
11128
|
function checkIfFileExists(filePath) {
|
|
11060
|
-
return
|
|
11129
|
+
return fs13.existsSync(filePath);
|
|
11061
11130
|
}
|
|
11062
11131
|
|
|
11063
11132
|
// src/cli/utils/delta.ts
|
|
@@ -11078,7 +11147,7 @@ var LockSchema = _zod2.default.object({
|
|
|
11078
11147
|
).default({})
|
|
11079
11148
|
});
|
|
11080
11149
|
function createDeltaProcessor(fileKey) {
|
|
11081
|
-
const lockfilePath =
|
|
11150
|
+
const lockfilePath = path16.join(process.cwd(), "i18n.lock");
|
|
11082
11151
|
return {
|
|
11083
11152
|
async checkIfLockExists() {
|
|
11084
11153
|
return checkIfFileExists(lockfilePath);
|
|
@@ -11235,7 +11304,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11235
11304
|
validateParams(i18nConfig, flags);
|
|
11236
11305
|
ora.succeed("Localization configuration is valid");
|
|
11237
11306
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
11238
|
-
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess',
|
|
11307
|
+
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _349 => _349.provider]);
|
|
11239
11308
|
if (isByokMode) {
|
|
11240
11309
|
email = null;
|
|
11241
11310
|
ora.succeed("Using external provider (BYOK mode)");
|
|
@@ -11249,16 +11318,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11249
11318
|
flags
|
|
11250
11319
|
});
|
|
11251
11320
|
let buckets = getBuckets(i18nConfig);
|
|
11252
|
-
if (_optionalChain([flags, 'access',
|
|
11321
|
+
if (_optionalChain([flags, 'access', _350 => _350.bucket, 'optionalAccess', _351 => _351.length])) {
|
|
11253
11322
|
buckets = buckets.filter(
|
|
11254
11323
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
11255
11324
|
);
|
|
11256
11325
|
}
|
|
11257
11326
|
ora.succeed("Buckets retrieved");
|
|
11258
|
-
if (_optionalChain([flags, 'access',
|
|
11327
|
+
if (_optionalChain([flags, 'access', _352 => _352.file, 'optionalAccess', _353 => _353.length])) {
|
|
11259
11328
|
buckets = buckets.map((bucket) => {
|
|
11260
11329
|
const paths = bucket.paths.filter(
|
|
11261
|
-
(
|
|
11330
|
+
(path20) => flags.file.find((file) => _optionalChain([path20, 'access', _354 => _354.pathPattern, 'optionalAccess', _355 => _355.includes, 'call', _356 => _356(file)]))
|
|
11262
11331
|
);
|
|
11263
11332
|
return { ...bucket, paths };
|
|
11264
11333
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -11273,13 +11342,13 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11273
11342
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
11274
11343
|
buckets.map((bucket) => {
|
|
11275
11344
|
ora.info(` ${bucket.type}:`);
|
|
11276
|
-
bucket.paths.forEach((
|
|
11277
|
-
ora.info(` - ${
|
|
11345
|
+
bucket.paths.forEach((path20) => {
|
|
11346
|
+
ora.info(` - ${path20.pathPattern}`);
|
|
11278
11347
|
});
|
|
11279
11348
|
});
|
|
11280
11349
|
}
|
|
11281
11350
|
}
|
|
11282
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
11351
|
+
const targetLocales = _optionalChain([flags, 'access', _357 => _357.locale, 'optionalAccess', _358 => _358.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
11283
11352
|
ora.start("Setting up localization cache...");
|
|
11284
11353
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
11285
11354
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -11564,7 +11633,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
11564
11633
|
}
|
|
11565
11634
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
11566
11635
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
11567
|
-
if (!_optionalChain([flags, 'access',
|
|
11636
|
+
if (!_optionalChain([flags, 'access', _359 => _359.locale, 'optionalAccess', _360 => _360.length])) {
|
|
11568
11637
|
await deltaProcessor.saveChecksums(checksums);
|
|
11569
11638
|
}
|
|
11570
11639
|
}
|
|
@@ -11691,12 +11760,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
11691
11760
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
11692
11761
|
docUrl: "bucketNotFound"
|
|
11693
11762
|
});
|
|
11694
|
-
} else if (_optionalChain([flags, 'access',
|
|
11763
|
+
} else if (_optionalChain([flags, 'access', _361 => _361.locale, 'optionalAccess', _362 => _362.some, 'call', _363 => _363((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
11695
11764
|
throw new ValidationError({
|
|
11696
11765
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
11697
11766
|
docUrl: "localeTargetNotFound"
|
|
11698
11767
|
});
|
|
11699
|
-
} else if (_optionalChain([flags, 'access',
|
|
11768
|
+
} else if (_optionalChain([flags, 'access', _364 => _364.bucket, 'optionalAccess', _365 => _365.some, 'call', _366 => _366(
|
|
11700
11769
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
11701
11770
|
)])) {
|
|
11702
11771
|
throw new ValidationError({
|
|
@@ -11837,7 +11906,7 @@ function createLockfileHelper() {
|
|
|
11837
11906
|
return {
|
|
11838
11907
|
isLockfileExists: () => {
|
|
11839
11908
|
const lockfilePath = _getLockfilePath();
|
|
11840
|
-
return
|
|
11909
|
+
return fs13.default.existsSync(lockfilePath);
|
|
11841
11910
|
},
|
|
11842
11911
|
registerSourceData: (pathPattern, sourceData) => {
|
|
11843
11912
|
const lockfile = _loadLockfile();
|
|
@@ -11874,20 +11943,20 @@ function createLockfileHelper() {
|
|
|
11874
11943
|
};
|
|
11875
11944
|
function _loadLockfile() {
|
|
11876
11945
|
const lockfilePath = _getLockfilePath();
|
|
11877
|
-
if (!
|
|
11946
|
+
if (!fs13.default.existsSync(lockfilePath)) {
|
|
11878
11947
|
return LockfileSchema.parse({});
|
|
11879
11948
|
}
|
|
11880
|
-
const content =
|
|
11949
|
+
const content = fs13.default.readFileSync(lockfilePath, "utf-8");
|
|
11881
11950
|
const result = LockfileSchema.parse(_yaml2.default.parse(content));
|
|
11882
11951
|
return result;
|
|
11883
11952
|
}
|
|
11884
11953
|
function _saveLockfile(lockfile) {
|
|
11885
11954
|
const lockfilePath = _getLockfilePath();
|
|
11886
11955
|
const content = _yaml2.default.stringify(lockfile);
|
|
11887
|
-
|
|
11956
|
+
fs13.default.writeFileSync(lockfilePath, content);
|
|
11888
11957
|
}
|
|
11889
11958
|
function _getLockfilePath() {
|
|
11890
|
-
return
|
|
11959
|
+
return path15.default.join(process.cwd(), "i18n.lock");
|
|
11891
11960
|
}
|
|
11892
11961
|
}
|
|
11893
11962
|
var LockfileSchema = _zod2.default.object({
|
|
@@ -12180,7 +12249,7 @@ function escapeShellArg(arg) {
|
|
|
12180
12249
|
|
|
12181
12250
|
|
|
12182
12251
|
|
|
12183
|
-
|
|
12252
|
+
|
|
12184
12253
|
|
|
12185
12254
|
|
|
12186
12255
|
// src/cli/cmd/run/setup.ts
|
|
@@ -12230,7 +12299,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
12230
12299
|
const response = await engine.whoami();
|
|
12231
12300
|
return {
|
|
12232
12301
|
authenticated: !!response,
|
|
12233
|
-
username: _optionalChain([response, 'optionalAccess',
|
|
12302
|
+
username: _optionalChain([response, 'optionalAccess', _367 => _367.email])
|
|
12234
12303
|
};
|
|
12235
12304
|
} catch (error) {
|
|
12236
12305
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -12259,6 +12328,175 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
12259
12328
|
};
|
|
12260
12329
|
}
|
|
12261
12330
|
|
|
12331
|
+
// src/cli/localizer/lingodotdev-vnext.ts
|
|
12332
|
+
|
|
12333
|
+
|
|
12334
|
+
var _cuid2 = require('@paralleldrive/cuid2');
|
|
12335
|
+
function createVNextEngine(config) {
|
|
12336
|
+
const endpoint = `${config.apiUrl}/process/${config.processId}/localize`;
|
|
12337
|
+
return {
|
|
12338
|
+
async localizeChunk(sourceLocale, targetLocale, payload, workflowId, fast, signal) {
|
|
12339
|
+
const res = await fetch(endpoint, {
|
|
12340
|
+
method: "POST",
|
|
12341
|
+
headers: {
|
|
12342
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
12343
|
+
"X-API-Key": config.apiKey
|
|
12344
|
+
},
|
|
12345
|
+
body: JSON.stringify(
|
|
12346
|
+
{
|
|
12347
|
+
params: { workflowId, fast },
|
|
12348
|
+
sourceLocale,
|
|
12349
|
+
targetLocale,
|
|
12350
|
+
data: payload.data,
|
|
12351
|
+
reference: payload.reference,
|
|
12352
|
+
hints: payload.hints
|
|
12353
|
+
},
|
|
12354
|
+
null,
|
|
12355
|
+
2
|
|
12356
|
+
),
|
|
12357
|
+
signal
|
|
12358
|
+
});
|
|
12359
|
+
if (!res.ok) {
|
|
12360
|
+
if (res.status >= 500 && res.status < 600) {
|
|
12361
|
+
const errorText = await res.text();
|
|
12362
|
+
throw new Error(
|
|
12363
|
+
`Server error (${res.status}): ${res.statusText}. ${errorText}. This may be due to temporary service issues.`
|
|
12364
|
+
);
|
|
12365
|
+
} else if (res.status === 400) {
|
|
12366
|
+
throw new Error(`Invalid request: ${res.statusText}`);
|
|
12367
|
+
} else {
|
|
12368
|
+
const errorText = await res.text();
|
|
12369
|
+
throw new Error(errorText);
|
|
12370
|
+
}
|
|
12371
|
+
}
|
|
12372
|
+
const jsonResponse = await res.json();
|
|
12373
|
+
if (!jsonResponse.data && jsonResponse.error) {
|
|
12374
|
+
throw new Error(jsonResponse.error);
|
|
12375
|
+
}
|
|
12376
|
+
return jsonResponse.data || {};
|
|
12377
|
+
},
|
|
12378
|
+
async whoami(signal) {
|
|
12379
|
+
return { email: "vnext-user", id: config.processId };
|
|
12380
|
+
},
|
|
12381
|
+
async localizeObject(obj, params, progressCallback, signal) {
|
|
12382
|
+
const chunkedPayload = extractPayloadChunks2(obj);
|
|
12383
|
+
const processedPayloadChunks = [];
|
|
12384
|
+
const workflowId = _cuid2.createId.call(void 0, );
|
|
12385
|
+
for (let i = 0; i < chunkedPayload.length; i++) {
|
|
12386
|
+
const chunk = chunkedPayload[i];
|
|
12387
|
+
const percentageCompleted = Math.round(
|
|
12388
|
+
(i + 1) / chunkedPayload.length * 100
|
|
12389
|
+
);
|
|
12390
|
+
const processedPayloadChunk = await this.localizeChunk(
|
|
12391
|
+
params.sourceLocale,
|
|
12392
|
+
params.targetLocale,
|
|
12393
|
+
{ data: chunk, reference: params.reference, hints: params.hints },
|
|
12394
|
+
workflowId,
|
|
12395
|
+
params.fast || false,
|
|
12396
|
+
signal
|
|
12397
|
+
);
|
|
12398
|
+
if (progressCallback) {
|
|
12399
|
+
progressCallback(percentageCompleted, chunk, processedPayloadChunk);
|
|
12400
|
+
}
|
|
12401
|
+
processedPayloadChunks.push(processedPayloadChunk);
|
|
12402
|
+
}
|
|
12403
|
+
return Object.assign({}, ...processedPayloadChunks);
|
|
12404
|
+
}
|
|
12405
|
+
};
|
|
12406
|
+
}
|
|
12407
|
+
function extractPayloadChunks2(payload, batchSize = 25, idealBatchItemSize = 250) {
|
|
12408
|
+
const result = [];
|
|
12409
|
+
let currentChunk = {};
|
|
12410
|
+
let currentChunkItemCount = 0;
|
|
12411
|
+
const payloadEntries = Object.entries(payload);
|
|
12412
|
+
for (let i = 0; i < payloadEntries.length; i++) {
|
|
12413
|
+
const [key, value] = payloadEntries[i];
|
|
12414
|
+
currentChunk[key] = value;
|
|
12415
|
+
currentChunkItemCount++;
|
|
12416
|
+
const currentChunkSize = countWordsInRecord2(currentChunk);
|
|
12417
|
+
if (currentChunkSize > idealBatchItemSize || currentChunkItemCount >= batchSize || i === payloadEntries.length - 1) {
|
|
12418
|
+
result.push(currentChunk);
|
|
12419
|
+
currentChunk = {};
|
|
12420
|
+
currentChunkItemCount = 0;
|
|
12421
|
+
}
|
|
12422
|
+
}
|
|
12423
|
+
return result;
|
|
12424
|
+
}
|
|
12425
|
+
function countWordsInRecord2(payload) {
|
|
12426
|
+
if (Array.isArray(payload)) {
|
|
12427
|
+
return payload.reduce(
|
|
12428
|
+
(acc, item) => acc + countWordsInRecord2(item),
|
|
12429
|
+
0
|
|
12430
|
+
);
|
|
12431
|
+
} else if (typeof payload === "object" && payload !== null) {
|
|
12432
|
+
return Object.values(payload).reduce(
|
|
12433
|
+
(acc, item) => acc + countWordsInRecord2(item),
|
|
12434
|
+
0
|
|
12435
|
+
);
|
|
12436
|
+
} else if (typeof payload === "string") {
|
|
12437
|
+
return payload.trim().split(/\s+/).filter(Boolean).length;
|
|
12438
|
+
} else {
|
|
12439
|
+
return 0;
|
|
12440
|
+
}
|
|
12441
|
+
}
|
|
12442
|
+
function createLingoDotDevVNextLocalizer(processId) {
|
|
12443
|
+
const settings = getSettings(void 0);
|
|
12444
|
+
const apiKey = process.env.LINGO_API_KEY || _optionalChain([settings, 'access', _368 => _368.auth, 'access', _369 => _369.vnext, 'optionalAccess', _370 => _370.apiKey]);
|
|
12445
|
+
if (!apiKey) {
|
|
12446
|
+
throw new Error(
|
|
12447
|
+
_dedent2.default`
|
|
12448
|
+
You're trying to use ${_chalk2.default.hex(colors.green)(
|
|
12449
|
+
"Lingo.dev vNext"
|
|
12450
|
+
)} provider, however, no API key is configured.
|
|
12451
|
+
|
|
12452
|
+
To fix this issue:
|
|
12453
|
+
1. Set ${_chalk2.default.dim("LINGO_API_KEY")} environment variable, or
|
|
12454
|
+
2. Add the key to your ${_chalk2.default.dim("~/.lingodotdevrc")} file under ${_chalk2.default.dim("[auth.vnext]")} section.
|
|
12455
|
+
`
|
|
12456
|
+
);
|
|
12457
|
+
}
|
|
12458
|
+
const apiUrl = process.env.LINGO_API_URL || "https://api.lingo.dev";
|
|
12459
|
+
const engine = createVNextEngine({
|
|
12460
|
+
apiKey,
|
|
12461
|
+
apiUrl,
|
|
12462
|
+
processId
|
|
12463
|
+
});
|
|
12464
|
+
return {
|
|
12465
|
+
id: "Lingo.dev vNext",
|
|
12466
|
+
checkAuth: async () => {
|
|
12467
|
+
try {
|
|
12468
|
+
const response = await engine.whoami();
|
|
12469
|
+
return {
|
|
12470
|
+
authenticated: !!response,
|
|
12471
|
+
username: _optionalChain([response, 'optionalAccess', _371 => _371.email])
|
|
12472
|
+
};
|
|
12473
|
+
} catch (error) {
|
|
12474
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
12475
|
+
return { authenticated: false, error: errorMessage };
|
|
12476
|
+
}
|
|
12477
|
+
},
|
|
12478
|
+
localize: async (input2, onProgress) => {
|
|
12479
|
+
if (!Object.keys(input2.processableData).length) {
|
|
12480
|
+
return input2.processableData;
|
|
12481
|
+
}
|
|
12482
|
+
const processedData = await engine.localizeObject(
|
|
12483
|
+
input2.processableData,
|
|
12484
|
+
{
|
|
12485
|
+
sourceLocale: input2.sourceLocale,
|
|
12486
|
+
targetLocale: input2.targetLocale,
|
|
12487
|
+
reference: {
|
|
12488
|
+
[input2.sourceLocale]: input2.sourceData,
|
|
12489
|
+
[input2.targetLocale]: input2.targetData
|
|
12490
|
+
},
|
|
12491
|
+
hints: input2.hints
|
|
12492
|
+
},
|
|
12493
|
+
onProgress
|
|
12494
|
+
);
|
|
12495
|
+
return processedData;
|
|
12496
|
+
}
|
|
12497
|
+
};
|
|
12498
|
+
}
|
|
12499
|
+
|
|
12262
12500
|
// src/cli/localizer/explicit.ts
|
|
12263
12501
|
|
|
12264
12502
|
|
|
@@ -12346,7 +12584,7 @@ function createExplicitLocalizer(provider) {
|
|
|
12346
12584
|
}
|
|
12347
12585
|
function createAiSdkLocalizer(params) {
|
|
12348
12586
|
const skipAuth = params.skipAuth === true;
|
|
12349
|
-
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
12587
|
+
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _372 => _372.apiKeyName]), () => ( ""))];
|
|
12350
12588
|
if (!skipAuth && !apiKey || !params.apiKeyName) {
|
|
12351
12589
|
throw new Error(
|
|
12352
12590
|
_dedent2.default`
|
|
@@ -12448,8 +12686,133 @@ function createAiSdkLocalizer(params) {
|
|
|
12448
12686
|
};
|
|
12449
12687
|
}
|
|
12450
12688
|
|
|
12689
|
+
// src/utils/pseudo-localize.ts
|
|
12690
|
+
var PSEUDO_CHAR_MAP = {
|
|
12691
|
+
a: "\xE3",
|
|
12692
|
+
b: "\u0180",
|
|
12693
|
+
c: "\xE7",
|
|
12694
|
+
d: "\xF0",
|
|
12695
|
+
e: "\xE8",
|
|
12696
|
+
f: "\u0192",
|
|
12697
|
+
g: "\u011D",
|
|
12698
|
+
h: "\u0125",
|
|
12699
|
+
i: "\xED",
|
|
12700
|
+
j: "\u0135",
|
|
12701
|
+
k: "\u0137",
|
|
12702
|
+
l: "\u013C",
|
|
12703
|
+
m: "m",
|
|
12704
|
+
n: "\xF1",
|
|
12705
|
+
o: "\xF8",
|
|
12706
|
+
p: "\xFE",
|
|
12707
|
+
q: "q",
|
|
12708
|
+
r: "\u0155",
|
|
12709
|
+
s: "\u0161",
|
|
12710
|
+
t: "\u0163",
|
|
12711
|
+
u: "\xFB",
|
|
12712
|
+
v: "\u1E7D",
|
|
12713
|
+
w: "\u0175",
|
|
12714
|
+
x: "x",
|
|
12715
|
+
y: "\xFD",
|
|
12716
|
+
z: "\u017E",
|
|
12717
|
+
A: "\xC3",
|
|
12718
|
+
B: "\u1E02",
|
|
12719
|
+
C: "\u0108",
|
|
12720
|
+
D: "\xD0",
|
|
12721
|
+
E: "\xC8",
|
|
12722
|
+
F: "\u1E1E",
|
|
12723
|
+
G: "\u011C",
|
|
12724
|
+
H: "\u0124",
|
|
12725
|
+
I: "\xCD",
|
|
12726
|
+
J: "\u0134",
|
|
12727
|
+
K: "\u0136",
|
|
12728
|
+
L: "\u013B",
|
|
12729
|
+
M: "M",
|
|
12730
|
+
N: "\xD1",
|
|
12731
|
+
O: "\xD8",
|
|
12732
|
+
P: "\xDE",
|
|
12733
|
+
Q: "Q",
|
|
12734
|
+
R: "\u0154",
|
|
12735
|
+
S: "\u0160",
|
|
12736
|
+
T: "\u0162",
|
|
12737
|
+
U: "\xDB",
|
|
12738
|
+
V: "\u1E7C",
|
|
12739
|
+
W: "\u0174",
|
|
12740
|
+
X: "X",
|
|
12741
|
+
Y: "\xDD",
|
|
12742
|
+
Z: "\u017D"
|
|
12743
|
+
};
|
|
12744
|
+
function pseudoLocalize(text, options = {}) {
|
|
12745
|
+
const {
|
|
12746
|
+
addMarker = true,
|
|
12747
|
+
addLengthMarker = false,
|
|
12748
|
+
lengthExpansion = 30
|
|
12749
|
+
} = options;
|
|
12750
|
+
if (!text) {
|
|
12751
|
+
return text;
|
|
12752
|
+
}
|
|
12753
|
+
let result = "";
|
|
12754
|
+
for (const char of text) {
|
|
12755
|
+
result += _nullishCoalesce(PSEUDO_CHAR_MAP[char], () => ( char));
|
|
12756
|
+
}
|
|
12757
|
+
if (addLengthMarker) {
|
|
12758
|
+
const extraChars = Math.ceil(text.length * lengthExpansion / 100);
|
|
12759
|
+
result += "\u030C".repeat(extraChars);
|
|
12760
|
+
}
|
|
12761
|
+
if (addMarker) {
|
|
12762
|
+
result += "\u26A1";
|
|
12763
|
+
}
|
|
12764
|
+
return result;
|
|
12765
|
+
}
|
|
12766
|
+
function pseudoLocalizeObject(obj, options) {
|
|
12767
|
+
if (typeof obj === "string") {
|
|
12768
|
+
return pseudoLocalize(obj, options);
|
|
12769
|
+
}
|
|
12770
|
+
if (Array.isArray(obj)) {
|
|
12771
|
+
return obj.map((item) => pseudoLocalizeObject(item, options));
|
|
12772
|
+
}
|
|
12773
|
+
if (obj !== null && typeof obj === "object") {
|
|
12774
|
+
const result = {};
|
|
12775
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
12776
|
+
result[key] = pseudoLocalizeObject(value, options);
|
|
12777
|
+
}
|
|
12778
|
+
return result;
|
|
12779
|
+
}
|
|
12780
|
+
return obj;
|
|
12781
|
+
}
|
|
12782
|
+
|
|
12783
|
+
// src/cli/localizer/pseudo.ts
|
|
12784
|
+
function createPseudoLocalizer() {
|
|
12785
|
+
return {
|
|
12786
|
+
id: "pseudo",
|
|
12787
|
+
checkAuth: async () => {
|
|
12788
|
+
return {
|
|
12789
|
+
authenticated: true
|
|
12790
|
+
};
|
|
12791
|
+
},
|
|
12792
|
+
localize: async (input2, onProgress) => {
|
|
12793
|
+
if (!Object.keys(input2.processableData).length) {
|
|
12794
|
+
return input2;
|
|
12795
|
+
}
|
|
12796
|
+
const processedData = pseudoLocalizeObject(input2.processableData, {
|
|
12797
|
+
addMarker: true,
|
|
12798
|
+
addLengthMarker: false
|
|
12799
|
+
});
|
|
12800
|
+
if (onProgress) {
|
|
12801
|
+
onProgress(100, input2.processableData, processedData);
|
|
12802
|
+
}
|
|
12803
|
+
return processedData;
|
|
12804
|
+
}
|
|
12805
|
+
};
|
|
12806
|
+
}
|
|
12807
|
+
|
|
12451
12808
|
// src/cli/localizer/index.ts
|
|
12452
|
-
function createLocalizer(provider, apiKey) {
|
|
12809
|
+
function createLocalizer(provider, apiKey, vNext) {
|
|
12810
|
+
if (provider === "pseudo") {
|
|
12811
|
+
return createPseudoLocalizer();
|
|
12812
|
+
}
|
|
12813
|
+
if (vNext) {
|
|
12814
|
+
return createLingoDotDevVNextLocalizer(vNext);
|
|
12815
|
+
}
|
|
12453
12816
|
if (!provider) {
|
|
12454
12817
|
return createLingoDotDevLocalizer(apiKey);
|
|
12455
12818
|
} else {
|
|
@@ -12480,8 +12843,8 @@ async function setup(input2) {
|
|
|
12480
12843
|
throw new Error(
|
|
12481
12844
|
"No buckets found in i18n.json. Please add at least one bucket containing i18n content."
|
|
12482
12845
|
);
|
|
12483
|
-
} else if (_optionalChain([ctx, 'access',
|
|
12484
|
-
(bucket) => !_optionalChain([ctx, 'access',
|
|
12846
|
+
} else if (_optionalChain([ctx, 'access', _373 => _373.flags, 'access', _374 => _374.bucket, 'optionalAccess', _375 => _375.some, 'call', _376 => _376(
|
|
12847
|
+
(bucket) => !_optionalChain([ctx, 'access', _377 => _377.config, 'optionalAccess', _378 => _378.buckets, 'access', _379 => _379[bucket]])
|
|
12485
12848
|
)])) {
|
|
12486
12849
|
throw new Error(
|
|
12487
12850
|
`One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
|
|
@@ -12493,21 +12856,20 @@ async function setup(input2) {
|
|
|
12493
12856
|
{
|
|
12494
12857
|
title: "Selecting localization provider",
|
|
12495
12858
|
task: async (ctx, task) => {
|
|
12496
|
-
ctx.
|
|
12497
|
-
|
|
12498
|
-
|
|
12499
|
-
);
|
|
12859
|
+
const provider = ctx.flags.pseudo ? "pseudo" : _optionalChain([ctx, 'access', _380 => _380.config, 'optionalAccess', _381 => _381.provider]);
|
|
12860
|
+
const vNext = _optionalChain([ctx, 'access', _382 => _382.config, 'optionalAccess', _383 => _383.vNext]);
|
|
12861
|
+
ctx.localizer = createLocalizer(provider, ctx.flags.apiKey, vNext);
|
|
12500
12862
|
if (!ctx.localizer) {
|
|
12501
12863
|
throw new Error(
|
|
12502
12864
|
"Could not create localization provider. Please check your i18n.json configuration."
|
|
12503
12865
|
);
|
|
12504
12866
|
}
|
|
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`;
|
|
12867
|
+
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
12868
|
}
|
|
12507
12869
|
},
|
|
12508
12870
|
{
|
|
12509
12871
|
title: "Checking authentication",
|
|
12510
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
12872
|
+
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
12873
|
task: async (ctx, task) => {
|
|
12512
12874
|
const authStatus = await ctx.localizer.checkAuth();
|
|
12513
12875
|
if (!authStatus.authenticated) {
|
|
@@ -12520,7 +12882,7 @@ async function setup(input2) {
|
|
|
12520
12882
|
},
|
|
12521
12883
|
{
|
|
12522
12884
|
title: "Validating configuration",
|
|
12523
|
-
enabled: (ctx) => _optionalChain([ctx, 'access',
|
|
12885
|
+
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
12886
|
task: async (ctx, task) => {
|
|
12525
12887
|
const validationStatus = await ctx.localizer.validateSettings();
|
|
12526
12888
|
if (!validationStatus.valid) {
|
|
@@ -12535,12 +12897,18 @@ async function setup(input2) {
|
|
|
12535
12897
|
title: "Initializing localization provider",
|
|
12536
12898
|
async task(ctx, task) {
|
|
12537
12899
|
const isLingoDotDev = ctx.localizer.id === "Lingo.dev";
|
|
12900
|
+
const isPseudo = ctx.localizer.id === "pseudo";
|
|
12538
12901
|
const subTasks = isLingoDotDev ? [
|
|
12539
12902
|
"Brand voice enabled",
|
|
12540
12903
|
"Translation memory connected",
|
|
12541
12904
|
"Glossary enabled",
|
|
12542
12905
|
"Quality assurance enabled"
|
|
12543
12906
|
].map((title) => ({ title, task: () => {
|
|
12907
|
+
} })) : isPseudo ? [
|
|
12908
|
+
"Pseudo-localization mode active",
|
|
12909
|
+
"Character replacement configured",
|
|
12910
|
+
"No external API calls"
|
|
12911
|
+
].map((title) => ({ title, task: () => {
|
|
12544
12912
|
} })) : [
|
|
12545
12913
|
"Skipping brand voice",
|
|
12546
12914
|
"Skipping glossary",
|
|
@@ -12851,7 +13219,7 @@ function createWorkerTask(args) {
|
|
|
12851
13219
|
const processableData = _lodash2.default.chain(sourceData).entries().filter(
|
|
12852
13220
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
12853
13221
|
).filter(
|
|
12854
|
-
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access',
|
|
13222
|
+
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _392 => _392.onlyKeys, 'optionalAccess', _393 => _393.some, 'call', _394 => _394(
|
|
12855
13223
|
(pattern) => minimatch(key, pattern)
|
|
12856
13224
|
)])
|
|
12857
13225
|
).fromPairs().value();
|
|
@@ -12919,7 +13287,7 @@ function createWorkerTask(args) {
|
|
|
12919
13287
|
finalRenamedTargetData
|
|
12920
13288
|
);
|
|
12921
13289
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
12922
|
-
if (!_optionalChain([args, 'access',
|
|
13290
|
+
if (!_optionalChain([args, 'access', _395 => _395.ctx, 'access', _396 => _396.flags, 'access', _397 => _397.targetLocale, 'optionalAccess', _398 => _398.length])) {
|
|
12923
13291
|
await deltaProcessor.saveChecksums(checksums);
|
|
12924
13292
|
}
|
|
12925
13293
|
});
|
|
@@ -12993,14 +13361,14 @@ async function watch2(ctx) {
|
|
|
12993
13361
|
pollInterval: 100
|
|
12994
13362
|
}
|
|
12995
13363
|
});
|
|
12996
|
-
watcher.on("change", (
|
|
12997
|
-
handleFileChange(
|
|
13364
|
+
watcher.on("change", (path20) => {
|
|
13365
|
+
handleFileChange(path20, state, ctx);
|
|
12998
13366
|
});
|
|
12999
|
-
watcher.on("add", (
|
|
13000
|
-
handleFileChange(
|
|
13367
|
+
watcher.on("add", (path20) => {
|
|
13368
|
+
handleFileChange(path20, state, ctx);
|
|
13001
13369
|
});
|
|
13002
|
-
watcher.on("unlink", (
|
|
13003
|
-
handleFileChange(
|
|
13370
|
+
watcher.on("unlink", (path20) => {
|
|
13371
|
+
handleFileChange(path20, state, ctx);
|
|
13004
13372
|
});
|
|
13005
13373
|
watcher.on("error", (error) => {
|
|
13006
13374
|
console.error(
|
|
@@ -13113,7 +13481,8 @@ var flagsSchema2 = _zod.z.object({
|
|
|
13113
13481
|
watch: _zod.z.boolean().default(false),
|
|
13114
13482
|
debounce: _zod.z.number().positive().default(5e3),
|
|
13115
13483
|
// 5 seconds default
|
|
13116
|
-
sound: _zod.z.boolean().optional()
|
|
13484
|
+
sound: _zod.z.boolean().optional(),
|
|
13485
|
+
pseudo: _zod.z.boolean().optional()
|
|
13117
13486
|
});
|
|
13118
13487
|
|
|
13119
13488
|
// src/cli/cmd/run/frozen.ts
|
|
@@ -13124,10 +13493,10 @@ var flagsSchema2 = _zod.z.object({
|
|
|
13124
13493
|
async function frozen(input2) {
|
|
13125
13494
|
console.log(_chalk2.default.hex(colors.orange)("[Frozen]"));
|
|
13126
13495
|
let buckets = getBuckets(input2.config);
|
|
13127
|
-
if (_optionalChain([input2, 'access',
|
|
13496
|
+
if (_optionalChain([input2, 'access', _399 => _399.flags, 'access', _400 => _400.bucket, 'optionalAccess', _401 => _401.length])) {
|
|
13128
13497
|
buckets = buckets.filter((b) => input2.flags.bucket.includes(b.type));
|
|
13129
13498
|
}
|
|
13130
|
-
if (_optionalChain([input2, 'access',
|
|
13499
|
+
if (_optionalChain([input2, 'access', _402 => _402.flags, 'access', _403 => _403.file, 'optionalAccess', _404 => _404.length])) {
|
|
13131
13500
|
buckets = buckets.map((bucket) => {
|
|
13132
13501
|
const paths = bucket.paths.filter(
|
|
13133
13502
|
(p) => input2.flags.file.some(
|
|
@@ -13264,13 +13633,13 @@ async function frozen(input2) {
|
|
|
13264
13633
|
|
|
13265
13634
|
// src/cli/cmd/run/_utils.ts
|
|
13266
13635
|
async function determineEmail(ctx) {
|
|
13267
|
-
const isByokMode = !!_optionalChain([ctx, 'access',
|
|
13636
|
+
const isByokMode = !!_optionalChain([ctx, 'access', _405 => _405.config, 'optionalAccess', _406 => _406.provider]);
|
|
13268
13637
|
if (isByokMode) {
|
|
13269
13638
|
return null;
|
|
13270
13639
|
} else {
|
|
13271
13640
|
try {
|
|
13272
|
-
const authStatus = await _optionalChain([ctx, 'access',
|
|
13273
|
-
return _optionalChain([authStatus, 'optionalAccess',
|
|
13641
|
+
const authStatus = await _optionalChain([ctx, 'access', _407 => _407.localizer, 'optionalAccess', _408 => _408.checkAuth, 'call', _409 => _409()]);
|
|
13642
|
+
return _optionalChain([authStatus, 'optionalAccess', _410 => _410.username]) || null;
|
|
13274
13643
|
} catch (e4) {
|
|
13275
13644
|
return null;
|
|
13276
13645
|
}
|
|
@@ -13278,12 +13647,12 @@ async function determineEmail(ctx) {
|
|
|
13278
13647
|
}
|
|
13279
13648
|
|
|
13280
13649
|
// src/cli/cmd/run/index.ts
|
|
13281
|
-
var
|
|
13650
|
+
var __dirname2 = path15.default.dirname(_url.fileURLToPath.call(void 0, _chunkEHIR4A2Gcjs.importMetaUrl));
|
|
13282
13651
|
function playSound(type) {
|
|
13283
13652
|
const platform = _os2.default.platform();
|
|
13284
13653
|
return new Promise((resolve) => {
|
|
13285
|
-
const assetDir =
|
|
13286
|
-
const soundFiles = [
|
|
13654
|
+
const assetDir = path15.default.join(__dirname2, "../assets");
|
|
13655
|
+
const soundFiles = [path15.default.join(assetDir, `${type}.mp3`)];
|
|
13287
13656
|
let command = "";
|
|
13288
13657
|
if (platform === "linux") {
|
|
13289
13658
|
command = soundFiles.map(
|
|
@@ -13346,6 +13715,9 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
|
|
|
13346
13715
|
).option(
|
|
13347
13716
|
"--sound",
|
|
13348
13717
|
"Play audio feedback when translations complete (success or failure sounds)"
|
|
13718
|
+
).option(
|
|
13719
|
+
"--pseudo",
|
|
13720
|
+
"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
13721
|
).action(async (args) => {
|
|
13350
13722
|
let email = null;
|
|
13351
13723
|
try {
|
|
@@ -13474,7 +13846,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
13474
13846
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
13475
13847
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
13476
13848
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
13477
|
-
_optionalChain([this, 'access',
|
|
13849
|
+
_optionalChain([this, 'access', _411 => _411.platformKit, 'optionalAccess', _412 => _412.gitConfig, 'call', _413 => _413()]);
|
|
13478
13850
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
13479
13851
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
13480
13852
|
if (!processOwnCommits) {
|
|
@@ -13489,7 +13861,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
13489
13861
|
return false;
|
|
13490
13862
|
}
|
|
13491
13863
|
}
|
|
13492
|
-
const workingDir =
|
|
13864
|
+
const workingDir = path15.default.resolve(
|
|
13493
13865
|
process.cwd(),
|
|
13494
13866
|
this.platformKit.config.workingDir
|
|
13495
13867
|
);
|
|
@@ -13506,7 +13878,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
13506
13878
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
13507
13879
|
var PullRequestFlow = class extends InBranchFlow {
|
|
13508
13880
|
async preRun() {
|
|
13509
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
13881
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _414 => _414()]);
|
|
13510
13882
|
if (!canContinue) {
|
|
13511
13883
|
return false;
|
|
13512
13884
|
}
|
|
@@ -13773,10 +14145,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
13773
14145
|
repo_slug: this.platformConfig.repositoryName,
|
|
13774
14146
|
state: "OPEN"
|
|
13775
14147
|
}).then(({ data: { values } }) => {
|
|
13776
|
-
return _optionalChain([values, 'optionalAccess',
|
|
13777
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
14148
|
+
return _optionalChain([values, 'optionalAccess', _415 => _415.find, 'call', _416 => _416(
|
|
14149
|
+
({ 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
14150
|
)]);
|
|
13779
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
14151
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _421 => _421.id]));
|
|
13780
14152
|
}
|
|
13781
14153
|
async closePullRequest({ pullRequestNumber }) {
|
|
13782
14154
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -13872,7 +14244,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
13872
14244
|
repo: this.platformConfig.repositoryName,
|
|
13873
14245
|
base: this.platformConfig.baseBranchName,
|
|
13874
14246
|
state: "open"
|
|
13875
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
14247
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _422 => _422.number]));
|
|
13876
14248
|
}
|
|
13877
14249
|
async closePullRequest({ pullRequestNumber }) {
|
|
13878
14250
|
await this.octokit.rest.pulls.update({
|
|
@@ -13999,7 +14371,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
13999
14371
|
sourceBranch: branch,
|
|
14000
14372
|
state: "opened"
|
|
14001
14373
|
});
|
|
14002
|
-
return _optionalChain([mergeRequests, 'access',
|
|
14374
|
+
return _optionalChain([mergeRequests, 'access', _423 => _423[0], 'optionalAccess', _424 => _424.iid]);
|
|
14003
14375
|
}
|
|
14004
14376
|
async closePullRequest({
|
|
14005
14377
|
pullRequestNumber
|
|
@@ -14111,7 +14483,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
14111
14483
|
}
|
|
14112
14484
|
const env = {
|
|
14113
14485
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
14114
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
14486
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _425 => _425.pullRequest, 'optionalAccess', _426 => _426.toString, 'call', _427 => _427()]) || "false",
|
|
14115
14487
|
...options.commitMessage && {
|
|
14116
14488
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
14117
14489
|
},
|
|
@@ -14137,7 +14509,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
14137
14509
|
const { isPullRequestMode } = platformKit.config;
|
|
14138
14510
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
14139
14511
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
14140
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
14512
|
+
const canRun = await _optionalChain([flow, 'access', _428 => _428.preRun, 'optionalCall', _429 => _429()]);
|
|
14141
14513
|
if (canRun === false) {
|
|
14142
14514
|
return;
|
|
14143
14515
|
}
|
|
@@ -14147,7 +14519,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
14147
14519
|
if (!hasChanges) {
|
|
14148
14520
|
return;
|
|
14149
14521
|
}
|
|
14150
|
-
await _optionalChain([flow, 'access',
|
|
14522
|
+
await _optionalChain([flow, 'access', _430 => _430.postRun, 'optionalCall', _431 => _431()]);
|
|
14151
14523
|
});
|
|
14152
14524
|
function parseBooleanArg(val) {
|
|
14153
14525
|
if (val === true) return true;
|
|
@@ -14184,8 +14556,8 @@ function exitGracefully(elapsedMs = 0) {
|
|
|
14184
14556
|
}
|
|
14185
14557
|
}
|
|
14186
14558
|
function checkForPendingOperations() {
|
|
14187
|
-
const activeHandles = _optionalChain([process, 'access',
|
|
14188
|
-
const activeRequests = _optionalChain([process, 'access',
|
|
14559
|
+
const activeHandles = _optionalChain([process, 'access', _432 => _432._getActiveHandles, 'optionalCall', _433 => _433()]) || [];
|
|
14560
|
+
const activeRequests = _optionalChain([process, 'access', _434 => _434._getActiveRequests, 'optionalCall', _435 => _435()]) || [];
|
|
14189
14561
|
const nonStandardHandles = activeHandles.filter((handle) => {
|
|
14190
14562
|
if (handle === process.stdin || handle === process.stdout || handle === process.stderr) {
|
|
14191
14563
|
return false;
|
|
@@ -14255,17 +14627,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
14255
14627
|
});
|
|
14256
14628
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
14257
14629
|
let buckets = getBuckets(i18nConfig);
|
|
14258
|
-
if (_optionalChain([flags, 'access',
|
|
14630
|
+
if (_optionalChain([flags, 'access', _436 => _436.bucket, 'optionalAccess', _437 => _437.length])) {
|
|
14259
14631
|
buckets = buckets.filter(
|
|
14260
14632
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
14261
14633
|
);
|
|
14262
14634
|
}
|
|
14263
14635
|
ora.succeed("Buckets retrieved");
|
|
14264
|
-
if (_optionalChain([flags, 'access',
|
|
14636
|
+
if (_optionalChain([flags, 'access', _438 => _438.file, 'optionalAccess', _439 => _439.length])) {
|
|
14265
14637
|
buckets = buckets.map((bucket) => {
|
|
14266
14638
|
const paths = bucket.paths.filter(
|
|
14267
|
-
(
|
|
14268
|
-
(file) => _optionalChain([
|
|
14639
|
+
(path20) => flags.file.find(
|
|
14640
|
+
(file) => _optionalChain([path20, 'access', _440 => _440.pathPattern, 'optionalAccess', _441 => _441.includes, 'call', _442 => _442(file)]) || _optionalChain([path20, 'access', _443 => _443.pathPattern, 'optionalAccess', _444 => _444.match, 'call', _445 => _445(file)]) || minimatch(path20.pathPattern, file)
|
|
14269
14641
|
)
|
|
14270
14642
|
);
|
|
14271
14643
|
return { ...bucket, paths };
|
|
@@ -14279,13 +14651,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
14279
14651
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
14280
14652
|
buckets.map((bucket) => {
|
|
14281
14653
|
ora.info(` ${bucket.type}:`);
|
|
14282
|
-
bucket.paths.forEach((
|
|
14283
|
-
ora.info(` - ${
|
|
14654
|
+
bucket.paths.forEach((path20) => {
|
|
14655
|
+
ora.info(` - ${path20.pathPattern}`);
|
|
14284
14656
|
});
|
|
14285
14657
|
});
|
|
14286
14658
|
}
|
|
14287
14659
|
}
|
|
14288
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
14660
|
+
const targetLocales = _optionalChain([flags, 'access', _446 => _446.locale, 'optionalAccess', _447 => _447.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
14289
14661
|
let totalSourceKeyCount = 0;
|
|
14290
14662
|
let uniqueKeysToTranslate = 0;
|
|
14291
14663
|
let totalExistingTranslations = 0;
|
|
@@ -14567,10 +14939,10 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
14567
14939
|
if (flags.confirm && Object.keys(fileStats).length > 0) {
|
|
14568
14940
|
console.log(_chalk2.default.bold(`
|
|
14569
14941
|
\u{1F4D1} BREAKDOWN BY FILE:`));
|
|
14570
|
-
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([
|
|
14942
|
+
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path20, stats]) => {
|
|
14571
14943
|
if (stats.sourceKeys === 0) return;
|
|
14572
14944
|
console.log(_chalk2.default.bold(`
|
|
14573
|
-
\u2022 ${
|
|
14945
|
+
\u2022 ${path20}:`));
|
|
14574
14946
|
console.log(
|
|
14575
14947
|
` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`
|
|
14576
14948
|
);
|
|
@@ -14695,12 +15067,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
14695
15067
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
14696
15068
|
docUrl: "bucketNotFound"
|
|
14697
15069
|
});
|
|
14698
|
-
} else if (_optionalChain([flags, 'access',
|
|
15070
|
+
} else if (_optionalChain([flags, 'access', _448 => _448.locale, 'optionalAccess', _449 => _449.some, 'call', _450 => _450((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
14699
15071
|
throw new CLIError({
|
|
14700
15072
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
14701
15073
|
docUrl: "localeTargetNotFound"
|
|
14702
15074
|
});
|
|
14703
|
-
} else if (_optionalChain([flags, 'access',
|
|
15075
|
+
} else if (_optionalChain([flags, 'access', _451 => _451.bucket, 'optionalAccess', _452 => _452.some, 'call', _453 => _453(
|
|
14704
15076
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
14705
15077
|
)])) {
|
|
14706
15078
|
throw new CLIError({
|
|
@@ -14792,7 +15164,7 @@ async function renderHero2() {
|
|
|
14792
15164
|
// package.json
|
|
14793
15165
|
var package_default = {
|
|
14794
15166
|
name: "lingo.dev",
|
|
14795
|
-
version: "0.
|
|
15167
|
+
version: "0.119.0",
|
|
14796
15168
|
description: "Lingo.dev CLI",
|
|
14797
15169
|
private: false,
|
|
14798
15170
|
repository: {
|
|
@@ -14905,7 +15277,8 @@ var package_default = {
|
|
|
14905
15277
|
files: [
|
|
14906
15278
|
"bin",
|
|
14907
15279
|
"build",
|
|
14908
|
-
"assets"
|
|
15280
|
+
"assets",
|
|
15281
|
+
"agents.md"
|
|
14909
15282
|
],
|
|
14910
15283
|
scripts: {
|
|
14911
15284
|
"lingo.dev": "node --inspect=9229 ./bin/cli.mjs",
|
|
@@ -15094,7 +15467,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
|
|
|
15094
15467
|
if (options.file && options.file.length) {
|
|
15095
15468
|
buckets = buckets.map((bucket) => {
|
|
15096
15469
|
const paths = bucket.paths.filter(
|
|
15097
|
-
(bucketPath) => _optionalChain([options, 'access',
|
|
15470
|
+
(bucketPath) => _optionalChain([options, 'access', _454 => _454.file, 'optionalAccess', _455 => _455.some, 'call', _456 => _456((f) => bucketPath.pathPattern.includes(f))])
|
|
15098
15471
|
);
|
|
15099
15472
|
return { ...bucket, paths };
|
|
15100
15473
|
}).filter((bucket) => bucket.paths.length > 0);
|