lingo.dev 0.111.3 → 0.111.5
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/assets/failure.mp3 +0 -0
- package/assets/success.mp3 +0 -0
- package/build/cli.cjs +431 -184
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +323 -76
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -2
package/build/cli.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6;// src/cli/index.ts
|
|
2
2
|
var _dotenv = require('dotenv'); var _dotenv2 = _interopRequireDefault(_dotenv);
|
|
3
3
|
var _interactivecommander = require('interactive-commander');
|
|
4
4
|
var _figlet = require('figlet'); var _figlet2 = _interopRequireDefault(_figlet);
|
|
@@ -214,15 +214,147 @@ var docLinks = {
|
|
|
214
214
|
invalidBucketType: "https://lingo.dev/cli",
|
|
215
215
|
invalidStringDict: "https://lingo.dev/cli"
|
|
216
216
|
};
|
|
217
|
-
var CLIError = class extends Error {
|
|
217
|
+
var CLIError = (_class = class extends Error {
|
|
218
218
|
|
|
219
|
+
__init() {this.errorType = "cli_error"}
|
|
219
220
|
constructor({ message, docUrl }) {
|
|
220
|
-
super(message);
|
|
221
|
+
super(message);_class.prototype.__init.call(this);;
|
|
221
222
|
this.docUrl = docLinks[docUrl];
|
|
222
223
|
this.message = `${this.message}
|
|
223
224
|
visit: ${this.docUrl}`;
|
|
224
225
|
}
|
|
225
|
-
};
|
|
226
|
+
}, _class);
|
|
227
|
+
var ConfigError = (_class2 = class extends CLIError {
|
|
228
|
+
__init2() {this.errorType = "config_error"}
|
|
229
|
+
constructor({ message, docUrl }) {
|
|
230
|
+
super({ message, docUrl });_class2.prototype.__init2.call(this);;
|
|
231
|
+
this.name = "ConfigError";
|
|
232
|
+
}
|
|
233
|
+
}, _class2);
|
|
234
|
+
var AuthenticationError = (_class3 = class extends CLIError {
|
|
235
|
+
__init3() {this.errorType = "auth_error"}
|
|
236
|
+
constructor({ message, docUrl }) {
|
|
237
|
+
super({ message, docUrl });_class3.prototype.__init3.call(this);;
|
|
238
|
+
this.name = "AuthenticationError";
|
|
239
|
+
}
|
|
240
|
+
}, _class3);
|
|
241
|
+
var ValidationError = (_class4 = class extends CLIError {
|
|
242
|
+
__init4() {this.errorType = "validation_error"}
|
|
243
|
+
constructor({ message, docUrl }) {
|
|
244
|
+
super({ message, docUrl });_class4.prototype.__init4.call(this);;
|
|
245
|
+
this.name = "ValidationError";
|
|
246
|
+
}
|
|
247
|
+
}, _class4);
|
|
248
|
+
var LocalizationError = (_class5 = class extends Error {
|
|
249
|
+
__init5() {this.errorType = "locale_error"}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
constructor(message, context) {
|
|
255
|
+
super(message);_class5.prototype.__init5.call(this);;
|
|
256
|
+
this.name = "LocalizationError";
|
|
257
|
+
this.bucket = _optionalChain([context, 'optionalAccess', _68 => _68.bucket]);
|
|
258
|
+
this.sourceLocale = _optionalChain([context, 'optionalAccess', _69 => _69.sourceLocale]);
|
|
259
|
+
this.targetLocale = _optionalChain([context, 'optionalAccess', _70 => _70.targetLocale]);
|
|
260
|
+
this.pathPattern = _optionalChain([context, 'optionalAccess', _71 => _71.pathPattern]);
|
|
261
|
+
}
|
|
262
|
+
}, _class5);
|
|
263
|
+
var BucketProcessingError = (_class6 = class extends Error {
|
|
264
|
+
__init6() {this.errorType = "bucket_error"}
|
|
265
|
+
|
|
266
|
+
constructor(message, bucket) {
|
|
267
|
+
super(message);_class6.prototype.__init6.call(this);;
|
|
268
|
+
this.name = "BucketProcessingError";
|
|
269
|
+
this.bucket = bucket;
|
|
270
|
+
}
|
|
271
|
+
}, _class6);
|
|
272
|
+
function isConfigError(error) {
|
|
273
|
+
return error instanceof ConfigError || error.errorType === "config_error";
|
|
274
|
+
}
|
|
275
|
+
function isAuthenticationError(error) {
|
|
276
|
+
return error instanceof AuthenticationError || error.errorType === "auth_error";
|
|
277
|
+
}
|
|
278
|
+
function isValidationError(error) {
|
|
279
|
+
return error instanceof ValidationError || error.errorType === "validation_error";
|
|
280
|
+
}
|
|
281
|
+
function isLocalizationError(error) {
|
|
282
|
+
return error instanceof LocalizationError || error.errorType === "locale_error";
|
|
283
|
+
}
|
|
284
|
+
function isBucketProcessingError(error) {
|
|
285
|
+
return error instanceof BucketProcessingError || error.errorType === "bucket_error";
|
|
286
|
+
}
|
|
287
|
+
function getCLIErrorType(error) {
|
|
288
|
+
if (isConfigError(error)) return "config_error";
|
|
289
|
+
if (isAuthenticationError(error)) return "auth_error";
|
|
290
|
+
if (isValidationError(error)) return "validation_error";
|
|
291
|
+
if (isLocalizationError(error)) return "locale_error";
|
|
292
|
+
if (isBucketProcessingError(error)) return "bucket_error";
|
|
293
|
+
if (error instanceof CLIError) return "cli_error";
|
|
294
|
+
return "unknown_error";
|
|
295
|
+
}
|
|
296
|
+
function createPreviousErrorContext(errorDetails) {
|
|
297
|
+
if (errorDetails.length === 0) return void 0;
|
|
298
|
+
return {
|
|
299
|
+
count: errorDetails.length,
|
|
300
|
+
types: [...new Set(errorDetails.map((e) => e.type))],
|
|
301
|
+
buckets: [...new Set(errorDetails.map((e) => e.bucket).filter(Boolean))]
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function aggregateErrorAnalytics(errorDetails, buckets, targetLocales, i18nConfig) {
|
|
305
|
+
if (errorDetails.length === 0) {
|
|
306
|
+
return {
|
|
307
|
+
errorCount: 0,
|
|
308
|
+
errorTypes: [],
|
|
309
|
+
errorsByBucket: {},
|
|
310
|
+
errorsByType: {},
|
|
311
|
+
firstError: void 0,
|
|
312
|
+
bucketCount: buckets.length,
|
|
313
|
+
localeCount: targetLocales.length,
|
|
314
|
+
i18nConfig: {
|
|
315
|
+
sourceLocale: i18nConfig.locale.source,
|
|
316
|
+
targetLocales: i18nConfig.locale.targets,
|
|
317
|
+
bucketTypes: Object.keys(i18nConfig.buckets)
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
const errorsByBucket = errorDetails.reduce(
|
|
322
|
+
(acc, error) => {
|
|
323
|
+
if (error.bucket) {
|
|
324
|
+
acc[error.bucket] = (acc[error.bucket] || 0) + 1;
|
|
325
|
+
}
|
|
326
|
+
return acc;
|
|
327
|
+
},
|
|
328
|
+
{}
|
|
329
|
+
);
|
|
330
|
+
const errorsByType = errorDetails.reduce(
|
|
331
|
+
(acc, error) => {
|
|
332
|
+
acc[error.type] = (acc[error.type] || 0) + 1;
|
|
333
|
+
return acc;
|
|
334
|
+
},
|
|
335
|
+
{}
|
|
336
|
+
);
|
|
337
|
+
return {
|
|
338
|
+
errorCount: errorDetails.length,
|
|
339
|
+
errorTypes: [...new Set(errorDetails.map((e) => e.type))],
|
|
340
|
+
errorsByBucket,
|
|
341
|
+
errorsByType,
|
|
342
|
+
firstError: {
|
|
343
|
+
type: errorDetails[0].type,
|
|
344
|
+
bucket: errorDetails[0].bucket,
|
|
345
|
+
locale: errorDetails[0].locale,
|
|
346
|
+
pathPattern: errorDetails[0].pathPattern,
|
|
347
|
+
message: errorDetails[0].message
|
|
348
|
+
},
|
|
349
|
+
bucketCount: buckets.length,
|
|
350
|
+
localeCount: targetLocales.length,
|
|
351
|
+
i18nConfig: {
|
|
352
|
+
sourceLocale: i18nConfig.locale.source,
|
|
353
|
+
targetLocales: i18nConfig.locale.targets,
|
|
354
|
+
bucketTypes: Object.keys(i18nConfig.buckets)
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
226
358
|
|
|
227
359
|
// src/cli/utils/cloudflare-status.ts
|
|
228
360
|
async function checkCloudflareStatus() {
|
|
@@ -261,7 +393,7 @@ function createAuthenticator(params) {
|
|
|
261
393
|
});
|
|
262
394
|
if (res.ok) {
|
|
263
395
|
const payload = await res.json();
|
|
264
|
-
if (!_optionalChain([payload, 'optionalAccess',
|
|
396
|
+
if (!_optionalChain([payload, 'optionalAccess', _72 => _72.email])) {
|
|
265
397
|
return null;
|
|
266
398
|
}
|
|
267
399
|
return {
|
|
@@ -926,9 +1058,9 @@ function makeGitlabInitializer(spinner) {
|
|
|
926
1058
|
|
|
927
1059
|
// src/cli/cmd/init.ts
|
|
928
1060
|
|
|
929
|
-
var openUrl = (
|
|
1061
|
+
var openUrl = (path18) => {
|
|
930
1062
|
const settings = getSettings(void 0);
|
|
931
|
-
_open2.default.call(void 0, `${settings.auth.webUrl}${
|
|
1063
|
+
_open2.default.call(void 0, `${settings.auth.webUrl}${path18}`, { wait: false });
|
|
932
1064
|
};
|
|
933
1065
|
var throwHelpError = (option, value) => {
|
|
934
1066
|
if (value === "help") {
|
|
@@ -1088,7 +1220,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
1088
1220
|
});
|
|
1089
1221
|
const auth2 = await newAuthenticator.whoami();
|
|
1090
1222
|
if (auth2) {
|
|
1091
|
-
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess',
|
|
1223
|
+
_ora2.default.call(void 0, ).succeed(`Authenticated as ${_optionalChain([auth2, 'optionalAccess', _73 => _73.email])}`);
|
|
1092
1224
|
} else {
|
|
1093
1225
|
_ora2.default.call(void 0, ).fail("Authentication failed.");
|
|
1094
1226
|
}
|
|
@@ -1175,7 +1307,7 @@ function getBuckets(i18nConfig) {
|
|
|
1175
1307
|
const includeItems = bucketEntry.include.map(
|
|
1176
1308
|
(item) => resolveBucketItem(item)
|
|
1177
1309
|
);
|
|
1178
|
-
const excludeItems = _optionalChain([bucketEntry, 'access',
|
|
1310
|
+
const excludeItems = _optionalChain([bucketEntry, 'access', _74 => _74.exclude, 'optionalAccess', _75 => _75.map, 'call', _76 => _76(
|
|
1179
1311
|
(item) => resolveBucketItem(item)
|
|
1180
1312
|
)]);
|
|
1181
1313
|
const config = {
|
|
@@ -1213,7 +1345,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
1213
1345
|
delimiter: pattern.delimiter
|
|
1214
1346
|
}))
|
|
1215
1347
|
);
|
|
1216
|
-
const excludedPatterns = _optionalChain([exclude, 'optionalAccess',
|
|
1348
|
+
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _77 => _77.flatMap, 'call', _78 => _78(
|
|
1217
1349
|
(pattern) => expandPlaceholderedGlob(
|
|
1218
1350
|
pattern.path,
|
|
1219
1351
|
__spec.resolveOverriddenLocale.call(void 0, sourceLocale, pattern.delimiter)
|
|
@@ -1348,8 +1480,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
1348
1480
|
} else if (type.target) {
|
|
1349
1481
|
result.push(...targetPaths);
|
|
1350
1482
|
}
|
|
1351
|
-
result.forEach((
|
|
1352
|
-
console.log(
|
|
1483
|
+
result.forEach((path18) => {
|
|
1484
|
+
console.log(path18);
|
|
1353
1485
|
});
|
|
1354
1486
|
}
|
|
1355
1487
|
}
|
|
@@ -1503,12 +1635,12 @@ function composeLoaders(...loaders) {
|
|
|
1503
1635
|
return {
|
|
1504
1636
|
init: async () => {
|
|
1505
1637
|
for (const loader of loaders) {
|
|
1506
|
-
await _optionalChain([loader, 'access',
|
|
1638
|
+
await _optionalChain([loader, 'access', _79 => _79.init, 'optionalCall', _80 => _80()]);
|
|
1507
1639
|
}
|
|
1508
1640
|
},
|
|
1509
1641
|
setDefaultLocale(locale) {
|
|
1510
1642
|
for (const loader of loaders) {
|
|
1511
|
-
_optionalChain([loader, 'access',
|
|
1643
|
+
_optionalChain([loader, 'access', _81 => _81.setDefaultLocale, 'optionalCall', _82 => _82(locale)]);
|
|
1512
1644
|
}
|
|
1513
1645
|
return this;
|
|
1514
1646
|
},
|
|
@@ -1529,7 +1661,7 @@ function composeLoaders(...loaders) {
|
|
|
1529
1661
|
pullHints: async (originalInput) => {
|
|
1530
1662
|
let result = originalInput;
|
|
1531
1663
|
for (let i = 0; i < loaders.length; i++) {
|
|
1532
|
-
const subResult = await _optionalChain([loaders, 'access',
|
|
1664
|
+
const subResult = await _optionalChain([loaders, 'access', _83 => _83[i], 'access', _84 => _84.pullHints, 'optionalCall', _85 => _85(result)]);
|
|
1533
1665
|
if (subResult) {
|
|
1534
1666
|
result = subResult;
|
|
1535
1667
|
}
|
|
@@ -1551,7 +1683,7 @@ function createLoader(lDefinition) {
|
|
|
1551
1683
|
if (state.initCtx) {
|
|
1552
1684
|
return state.initCtx;
|
|
1553
1685
|
}
|
|
1554
|
-
state.initCtx = await _optionalChain([lDefinition, 'access',
|
|
1686
|
+
state.initCtx = await _optionalChain([lDefinition, 'access', _86 => _86.init, 'optionalCall', _87 => _87()]);
|
|
1555
1687
|
return state.initCtx;
|
|
1556
1688
|
},
|
|
1557
1689
|
setDefaultLocale(locale) {
|
|
@@ -1562,7 +1694,7 @@ function createLoader(lDefinition) {
|
|
|
1562
1694
|
return this;
|
|
1563
1695
|
},
|
|
1564
1696
|
async pullHints() {
|
|
1565
|
-
return _optionalChain([lDefinition, 'access',
|
|
1697
|
+
return _optionalChain([lDefinition, 'access', _88 => _88.pullHints, 'optionalCall', _89 => _89(state.originalInput)]);
|
|
1566
1698
|
},
|
|
1567
1699
|
async pull(locale, input2) {
|
|
1568
1700
|
if (!state.defaultLocale) {
|
|
@@ -1667,8 +1799,8 @@ function extractCommentsFromJsonc(jsoncString) {
|
|
|
1667
1799
|
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1668
1800
|
if (keyMatch) {
|
|
1669
1801
|
const key = keyMatch[1];
|
|
1670
|
-
const
|
|
1671
|
-
keyInfo = { key, path:
|
|
1802
|
+
const path18 = contextStack.map((ctx) => ctx.key).filter(Boolean);
|
|
1803
|
+
keyInfo = { key, path: path18 };
|
|
1672
1804
|
}
|
|
1673
1805
|
} else {
|
|
1674
1806
|
keyInfo = findAssociatedKey(lines, commentData.lineIndex, contextStack);
|
|
@@ -1752,8 +1884,8 @@ function findAssociatedKey(lines, commentLineIndex, contextStack) {
|
|
|
1752
1884
|
const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
|
|
1753
1885
|
if (keyMatch) {
|
|
1754
1886
|
const key = keyMatch[1];
|
|
1755
|
-
const
|
|
1756
|
-
return { key, path:
|
|
1887
|
+
const path18 = contextStack.map((ctx) => ctx.key).filter(Boolean);
|
|
1888
|
+
return { key, path: path18 };
|
|
1757
1889
|
}
|
|
1758
1890
|
}
|
|
1759
1891
|
return { key: null, path: [] };
|
|
@@ -1772,9 +1904,9 @@ function updateContext(contextStack, line, parsedJson) {
|
|
|
1772
1904
|
}
|
|
1773
1905
|
}
|
|
1774
1906
|
}
|
|
1775
|
-
function setCommentAtPath(comments,
|
|
1907
|
+
function setCommentAtPath(comments, path18, key, hint) {
|
|
1776
1908
|
let current = comments;
|
|
1777
|
-
for (const pathKey of
|
|
1909
|
+
for (const pathKey of path18) {
|
|
1778
1910
|
if (!current[pathKey]) {
|
|
1779
1911
|
current[pathKey] = {};
|
|
1780
1912
|
}
|
|
@@ -1867,7 +1999,7 @@ function createNormalizeLoader() {
|
|
|
1867
1999
|
return normalized;
|
|
1868
2000
|
},
|
|
1869
2001
|
push: async (locale, data, originalInput) => {
|
|
1870
|
-
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess',
|
|
2002
|
+
const keysMap = _nullishCoalesce(_optionalChain([originalInput, 'optionalAccess', _90 => _90.keysMap]), () => ( {}));
|
|
1871
2003
|
const input2 = mapDenormalizedKeys(data, keysMap);
|
|
1872
2004
|
const denormalized = _flat.unflatten.call(void 0, input2, {
|
|
1873
2005
|
delimiter: "/",
|
|
@@ -2001,8 +2133,8 @@ async function getTrailingNewLine(pathPattern, locale, originalLocale) {
|
|
|
2001
2133
|
if (!templateData) {
|
|
2002
2134
|
templateData = await readFileForLocale(pathPattern, originalLocale);
|
|
2003
2135
|
}
|
|
2004
|
-
if (_optionalChain([templateData, 'optionalAccess',
|
|
2005
|
-
const ending = _optionalChain([templateData, 'optionalAccess',
|
|
2136
|
+
if (_optionalChain([templateData, 'optionalAccess', _91 => _91.match, 'call', _92 => _92(/[\r\n]$/)])) {
|
|
2137
|
+
const ending = _optionalChain([templateData, 'optionalAccess', _93 => _93.includes, 'call', _94 => _94("\r\n")]) ? "\r\n" : _optionalChain([templateData, 'optionalAccess', _95 => _95.includes, 'call', _96 => _96("\r")]) ? "\r" : "\n";
|
|
2006
2138
|
return ending;
|
|
2007
2139
|
}
|
|
2008
2140
|
return "";
|
|
@@ -2273,7 +2405,7 @@ var _sync3 = require('csv-stringify/sync');
|
|
|
2273
2405
|
|
|
2274
2406
|
function detectKeyColumnName(csvString) {
|
|
2275
2407
|
const row = _sync.parse.call(void 0, csvString)[0];
|
|
2276
|
-
const firstColumn = _optionalChain([row, 'optionalAccess',
|
|
2408
|
+
const firstColumn = _optionalChain([row, 'optionalAccess', _97 => _97[0], 'optionalAccess', _98 => _98.trim, 'call', _99 => _99()]);
|
|
2277
2409
|
return firstColumn || "KEY";
|
|
2278
2410
|
}
|
|
2279
2411
|
function createCsvLoader() {
|
|
@@ -2375,7 +2507,7 @@ function createHtmlLoader() {
|
|
|
2375
2507
|
break;
|
|
2376
2508
|
}
|
|
2377
2509
|
const siblings = Array.from(parent.childNodes).filter(
|
|
2378
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
2510
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _100 => _100.textContent, 'optionalAccess', _101 => _101.trim, 'call', _102 => _102()])
|
|
2379
2511
|
);
|
|
2380
2512
|
const index = siblings.indexOf(current);
|
|
2381
2513
|
if (index !== -1) {
|
|
@@ -2411,15 +2543,15 @@ function createHtmlLoader() {
|
|
|
2411
2543
|
}
|
|
2412
2544
|
});
|
|
2413
2545
|
Array.from(element.childNodes).filter(
|
|
2414
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
2546
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _103 => _103.textContent, 'optionalAccess', _104 => _104.trim, 'call', _105 => _105()])
|
|
2415
2547
|
).forEach(processNode);
|
|
2416
2548
|
}
|
|
2417
2549
|
};
|
|
2418
2550
|
Array.from(document.head.childNodes).filter(
|
|
2419
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
2551
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _106 => _106.textContent, 'optionalAccess', _107 => _107.trim, 'call', _108 => _108()])
|
|
2420
2552
|
).forEach(processNode);
|
|
2421
2553
|
Array.from(document.body.childNodes).filter(
|
|
2422
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
2554
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _109 => _109.textContent, 'optionalAccess', _110 => _110.trim, 'call', _111 => _111()])
|
|
2423
2555
|
).forEach(processNode);
|
|
2424
2556
|
return result;
|
|
2425
2557
|
},
|
|
@@ -2435,16 +2567,16 @@ function createHtmlLoader() {
|
|
|
2435
2567
|
const bDepth = b.split("/").length;
|
|
2436
2568
|
return aDepth - bDepth;
|
|
2437
2569
|
});
|
|
2438
|
-
paths.forEach((
|
|
2439
|
-
const value = data[
|
|
2440
|
-
const [nodePath, attribute] =
|
|
2570
|
+
paths.forEach((path18) => {
|
|
2571
|
+
const value = data[path18];
|
|
2572
|
+
const [nodePath, attribute] = path18.split("#");
|
|
2441
2573
|
const [rootTag, ...indices] = nodePath.split("/");
|
|
2442
2574
|
let parent = rootTag === "head" ? document.head : document.body;
|
|
2443
2575
|
let current = parent;
|
|
2444
2576
|
for (let i = 0; i < indices.length; i++) {
|
|
2445
2577
|
const index = parseInt(indices[i]);
|
|
2446
2578
|
const siblings = Array.from(parent.childNodes).filter(
|
|
2447
|
-
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access',
|
|
2579
|
+
(n) => n.nodeType === 1 || n.nodeType === 3 && _optionalChain([n, 'access', _112 => _112.textContent, 'optionalAccess', _113 => _113.trim, 'call', _114 => _114()])
|
|
2448
2580
|
);
|
|
2449
2581
|
if (index >= siblings.length) {
|
|
2450
2582
|
if (i === indices.length - 1) {
|
|
@@ -2495,7 +2627,7 @@ function createMarkdownLoader() {
|
|
|
2495
2627
|
yaml: yamlEngine
|
|
2496
2628
|
}
|
|
2497
2629
|
});
|
|
2498
|
-
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess',
|
|
2630
|
+
const sections = content.split(SECTION_REGEX).map((section) => _nullishCoalesce(_optionalChain([section, 'optionalAccess', _115 => _115.trim, 'call', _116 => _116()]), () => ( ""))).filter(Boolean);
|
|
2499
2631
|
return {
|
|
2500
2632
|
...Object.fromEntries(
|
|
2501
2633
|
sections.map((section, index) => [`${MD_SECTION_PREFIX}${index}`, section]).filter(([, section]) => Boolean(section))
|
|
@@ -2514,7 +2646,7 @@ function createMarkdownLoader() {
|
|
|
2514
2646
|
);
|
|
2515
2647
|
let content = Object.entries(data).filter(([key]) => key.startsWith(MD_SECTION_PREFIX)).sort(
|
|
2516
2648
|
([a], [b]) => Number(a.split("-").pop()) - Number(b.split("-").pop())
|
|
2517
|
-
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
2649
|
+
).map(([, value]) => _nullishCoalesce(_optionalChain([value, 'optionalAccess', _117 => _117.trim, 'call', _118 => _118()]), () => ( ""))).filter(Boolean).join("\n\n");
|
|
2518
2650
|
if (Object.keys(frontmatter).length > 0) {
|
|
2519
2651
|
content = `
|
|
2520
2652
|
${content}`;
|
|
@@ -2558,7 +2690,7 @@ function isSkippableLine(line) {
|
|
|
2558
2690
|
function parsePropertyLine(line) {
|
|
2559
2691
|
const [key, ...valueParts] = line.split("=");
|
|
2560
2692
|
return {
|
|
2561
|
-
key: _optionalChain([key, 'optionalAccess',
|
|
2693
|
+
key: _optionalChain([key, 'optionalAccess', _119 => _119.trim, 'call', _120 => _120()]) || "",
|
|
2562
2694
|
value: valueParts.join("=").trim()
|
|
2563
2695
|
};
|
|
2564
2696
|
}
|
|
@@ -2646,7 +2778,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
2646
2778
|
if (rootTranslationEntity.shouldTranslate === false) {
|
|
2647
2779
|
continue;
|
|
2648
2780
|
}
|
|
2649
|
-
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess',
|
|
2781
|
+
const langTranslationEntity = _optionalChain([rootTranslationEntity, 'optionalAccess', _121 => _121.localizations, 'optionalAccess', _122 => _122[locale]]);
|
|
2650
2782
|
if (langTranslationEntity) {
|
|
2651
2783
|
if ("stringUnit" in langTranslationEntity) {
|
|
2652
2784
|
resultData[translationKey] = langTranslationEntity.stringUnit.value;
|
|
@@ -2655,7 +2787,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
2655
2787
|
resultData[translationKey] = {};
|
|
2656
2788
|
const pluralForms = langTranslationEntity.variations.plural;
|
|
2657
2789
|
for (const form in pluralForms) {
|
|
2658
|
-
if (_optionalChain([pluralForms, 'access',
|
|
2790
|
+
if (_optionalChain([pluralForms, 'access', _123 => _123[form], 'optionalAccess', _124 => _124.stringUnit, 'optionalAccess', _125 => _125.value])) {
|
|
2659
2791
|
resultData[translationKey][form] = pluralForms[form].stringUnit.value;
|
|
2660
2792
|
}
|
|
2661
2793
|
}
|
|
@@ -2681,7 +2813,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
2681
2813
|
const hasDoNotTranslateFlag = originalInput && originalInput.strings && originalInput.strings[key] && originalInput.strings[key].shouldTranslate === false;
|
|
2682
2814
|
if (typeof value === "string") {
|
|
2683
2815
|
langDataToMerge.strings[key] = {
|
|
2684
|
-
extractionState: _optionalChain([originalInput, 'optionalAccess',
|
|
2816
|
+
extractionState: _optionalChain([originalInput, 'optionalAccess', _126 => _126.strings, 'optionalAccess', _127 => _127[key], 'optionalAccess', _128 => _128.extractionState]),
|
|
2685
2817
|
localizations: {
|
|
2686
2818
|
[locale]: {
|
|
2687
2819
|
stringUnit: {
|
|
@@ -2739,7 +2871,7 @@ function createXcodeXcstringsLoader(defaultLocale) {
|
|
|
2739
2871
|
for (const [locale, localization] of Object.entries(
|
|
2740
2872
|
entity.localizations
|
|
2741
2873
|
)) {
|
|
2742
|
-
if (_optionalChain([localization, 'access',
|
|
2874
|
+
if (_optionalChain([localization, 'access', _129 => _129.variations, 'optionalAccess', _130 => _130.plural])) {
|
|
2743
2875
|
const pluralForms = localization.variations.plural;
|
|
2744
2876
|
for (const form in pluralForms) {
|
|
2745
2877
|
const pluralKey = `${translationKey}/${form}`;
|
|
@@ -2759,7 +2891,7 @@ function _removeLocale(input2, locale) {
|
|
|
2759
2891
|
const { strings } = input2;
|
|
2760
2892
|
const newStrings = _lodash2.default.cloneDeep(strings);
|
|
2761
2893
|
for (const [key, value] of Object.entries(newStrings)) {
|
|
2762
|
-
if (_optionalChain([value, 'access',
|
|
2894
|
+
if (_optionalChain([value, 'access', _131 => _131.localizations, 'optionalAccess', _132 => _132[locale]])) {
|
|
2763
2895
|
delete value.localizations[locale];
|
|
2764
2896
|
}
|
|
2765
2897
|
}
|
|
@@ -2919,7 +3051,7 @@ function createPoDataLoader(params) {
|
|
|
2919
3051
|
Object.entries(entries).forEach(([msgid, entry]) => {
|
|
2920
3052
|
if (msgid && entry.msgid) {
|
|
2921
3053
|
const context = entry.msgctxt || "";
|
|
2922
|
-
const fullEntry = _optionalChain([parsedPo, 'access',
|
|
3054
|
+
const fullEntry = _optionalChain([parsedPo, 'access', _133 => _133.translations, 'access', _134 => _134[context], 'optionalAccess', _135 => _135[msgid]]);
|
|
2923
3055
|
if (fullEntry) {
|
|
2924
3056
|
result[msgid] = fullEntry;
|
|
2925
3057
|
}
|
|
@@ -2929,8 +3061,8 @@ function createPoDataLoader(params) {
|
|
|
2929
3061
|
return result;
|
|
2930
3062
|
},
|
|
2931
3063
|
async push(locale, data, originalInput, originalLocale, pullInput) {
|
|
2932
|
-
const currentSections = _optionalChain([pullInput, 'optionalAccess',
|
|
2933
|
-
const originalSections = _optionalChain([originalInput, 'optionalAccess',
|
|
3064
|
+
const currentSections = _optionalChain([pullInput, 'optionalAccess', _136 => _136.split, 'call', _137 => _137("\n\n"), 'access', _138 => _138.filter, 'call', _139 => _139(Boolean)]) || [];
|
|
3065
|
+
const originalSections = _optionalChain([originalInput, 'optionalAccess', _140 => _140.split, 'call', _141 => _141("\n\n"), 'access', _142 => _142.filter, 'call', _143 => _143(Boolean)]) || [];
|
|
2934
3066
|
const result = originalSections.map((section) => {
|
|
2935
3067
|
const sectionPo = _gettextparser2.default.po.parse(section);
|
|
2936
3068
|
if (Object.keys(sectionPo.translations).length === 0) {
|
|
@@ -2999,8 +3131,8 @@ function createPoContentLoader() {
|
|
|
2999
3131
|
{
|
|
3000
3132
|
...entry,
|
|
3001
3133
|
msgstr: [
|
|
3002
|
-
_optionalChain([data, 'access',
|
|
3003
|
-
_optionalChain([data, 'access',
|
|
3134
|
+
_optionalChain([data, 'access', _144 => _144[entry.msgid], 'optionalAccess', _145 => _145.singular]),
|
|
3135
|
+
_optionalChain([data, 'access', _146 => _146[entry.msgid], 'optionalAccess', _147 => _147.plural]) || null
|
|
3004
3136
|
].filter(Boolean)
|
|
3005
3137
|
}
|
|
3006
3138
|
]).fromPairs().value();
|
|
@@ -3122,7 +3254,7 @@ function pullV1(xliffElement, locale, originalLocale) {
|
|
|
3122
3254
|
let key = getTransUnitKey(unit);
|
|
3123
3255
|
if (!key) return;
|
|
3124
3256
|
if (seenKeys.has(key)) {
|
|
3125
|
-
const id = _optionalChain([unit, 'access',
|
|
3257
|
+
const id = _optionalChain([unit, 'access', _148 => _148.getAttribute, 'call', _149 => _149("id"), 'optionalAccess', _150 => _150.trim, 'call', _151 => _151()]);
|
|
3126
3258
|
if (id) {
|
|
3127
3259
|
key = `${key}#${id}`;
|
|
3128
3260
|
} else {
|
|
@@ -3170,7 +3302,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
3170
3302
|
let key = getTransUnitKey(unit);
|
|
3171
3303
|
if (!key) return;
|
|
3172
3304
|
if (seenKeys.has(key)) {
|
|
3173
|
-
const id = _optionalChain([unit, 'access',
|
|
3305
|
+
const id = _optionalChain([unit, 'access', _152 => _152.getAttribute, 'call', _153 => _153("id"), 'optionalAccess', _154 => _154.trim, 'call', _155 => _155()]);
|
|
3174
3306
|
if (id) {
|
|
3175
3307
|
key = `${key}#${id}`;
|
|
3176
3308
|
} else {
|
|
@@ -3212,7 +3344,7 @@ function pushV1(dom, xliffElement, locale, translations, originalLocale, origina
|
|
|
3212
3344
|
const translationKeys = new Set(Object.keys(translations));
|
|
3213
3345
|
existingUnits.forEach((unit, key) => {
|
|
3214
3346
|
if (!translationKeys.has(key)) {
|
|
3215
|
-
_optionalChain([unit, 'access',
|
|
3347
|
+
_optionalChain([unit, 'access', _156 => _156.parentNode, 'optionalAccess', _157 => _157.removeChild, 'call', _158 => _158(unit)]);
|
|
3216
3348
|
}
|
|
3217
3349
|
});
|
|
3218
3350
|
return serializeWithDeclaration(
|
|
@@ -3255,18 +3387,18 @@ function traverseUnitsV2(container, fileId, currentPath, result) {
|
|
|
3255
3387
|
Array.from(container.children).forEach((child) => {
|
|
3256
3388
|
const tagName = child.tagName;
|
|
3257
3389
|
if (tagName === "unit") {
|
|
3258
|
-
const unitId = _optionalChain([child, 'access',
|
|
3390
|
+
const unitId = _optionalChain([child, 'access', _159 => _159.getAttribute, 'call', _160 => _160("id"), 'optionalAccess', _161 => _161.trim, 'call', _162 => _162()]);
|
|
3259
3391
|
if (!unitId) return;
|
|
3260
3392
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
3261
3393
|
const segment = child.querySelector("segment");
|
|
3262
|
-
const source = _optionalChain([segment, 'optionalAccess',
|
|
3394
|
+
const source = _optionalChain([segment, 'optionalAccess', _163 => _163.querySelector, 'call', _164 => _164("source")]);
|
|
3263
3395
|
if (source) {
|
|
3264
3396
|
result[key] = extractTextContent(source);
|
|
3265
3397
|
} else {
|
|
3266
3398
|
result[key] = unitId;
|
|
3267
3399
|
}
|
|
3268
3400
|
} else if (tagName === "group") {
|
|
3269
|
-
const groupId = _optionalChain([child, 'access',
|
|
3401
|
+
const groupId = _optionalChain([child, 'access', _165 => _165.getAttribute, 'call', _166 => _166("id"), 'optionalAccess', _167 => _167.trim, 'call', _168 => _168()]);
|
|
3270
3402
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
3271
3403
|
traverseUnitsV2(child, fileId, newPath, result);
|
|
3272
3404
|
}
|
|
@@ -3302,12 +3434,12 @@ function indexUnitsV2(container, fileId, currentPath, index) {
|
|
|
3302
3434
|
Array.from(container.children).forEach((child) => {
|
|
3303
3435
|
const tagName = child.tagName;
|
|
3304
3436
|
if (tagName === "unit") {
|
|
3305
|
-
const unitId = _optionalChain([child, 'access',
|
|
3437
|
+
const unitId = _optionalChain([child, 'access', _169 => _169.getAttribute, 'call', _170 => _170("id"), 'optionalAccess', _171 => _171.trim, 'call', _172 => _172()]);
|
|
3306
3438
|
if (!unitId) return;
|
|
3307
3439
|
const key = `resources/${fileId}/${currentPath}${unitId}/source`;
|
|
3308
3440
|
index.set(key, child);
|
|
3309
3441
|
} else if (tagName === "group") {
|
|
3310
|
-
const groupId = _optionalChain([child, 'access',
|
|
3442
|
+
const groupId = _optionalChain([child, 'access', _173 => _173.getAttribute, 'call', _174 => _174("id"), 'optionalAccess', _175 => _175.trim, 'call', _176 => _176()]);
|
|
3311
3443
|
const newPath = groupId ? `${currentPath}${groupId}/groupUnits/` : currentPath;
|
|
3312
3444
|
indexUnitsV2(child, fileId, newPath, index);
|
|
3313
3445
|
}
|
|
@@ -3328,9 +3460,9 @@ function updateUnitV2(unit, value) {
|
|
|
3328
3460
|
setTextContent(source, value);
|
|
3329
3461
|
}
|
|
3330
3462
|
function getTransUnitKey(transUnit) {
|
|
3331
|
-
const resname = _optionalChain([transUnit, 'access',
|
|
3463
|
+
const resname = _optionalChain([transUnit, 'access', _177 => _177.getAttribute, 'call', _178 => _178("resname"), 'optionalAccess', _179 => _179.trim, 'call', _180 => _180()]);
|
|
3332
3464
|
if (resname) return resname;
|
|
3333
|
-
const id = _optionalChain([transUnit, 'access',
|
|
3465
|
+
const id = _optionalChain([transUnit, 'access', _181 => _181.getAttribute, 'call', _182 => _182("id"), 'optionalAccess', _183 => _183.trim, 'call', _184 => _184()]);
|
|
3334
3466
|
if (id) return id;
|
|
3335
3467
|
const sourceElement = transUnit.querySelector("source");
|
|
3336
3468
|
if (sourceElement) {
|
|
@@ -3387,7 +3519,7 @@ function formatXml(xml) {
|
|
|
3387
3519
|
if (cdataNode) {
|
|
3388
3520
|
return `${indent2}${openTag}<![CDATA[${cdataNode.nodeValue}]]></${tagName}>`;
|
|
3389
3521
|
}
|
|
3390
|
-
const textContent = _optionalChain([element, 'access',
|
|
3522
|
+
const textContent = _optionalChain([element, 'access', _185 => _185.textContent, 'optionalAccess', _186 => _186.trim, 'call', _187 => _187()]) || "";
|
|
3391
3523
|
const hasOnlyText = element.childNodes.length === 1 && element.childNodes[0].nodeType === 3;
|
|
3392
3524
|
if (hasOnlyText && textContent) {
|
|
3393
3525
|
return `${indent2}${openTag}${textContent}</${tagName}>`;
|
|
@@ -3680,7 +3812,7 @@ function createDatoClient(params) {
|
|
|
3680
3812
|
ids: !records.length ? void 0 : records.join(",")
|
|
3681
3813
|
}
|
|
3682
3814
|
}).catch(
|
|
3683
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
3815
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _188 => _188.response, 'optionalAccess', _189 => _189.body, 'optionalAccess', _190 => _190.data, 'optionalAccess', _191 => _191[0]]) || error)
|
|
3684
3816
|
);
|
|
3685
3817
|
},
|
|
3686
3818
|
findRecordsForModel: async (modelId, records) => {
|
|
@@ -3691,10 +3823,10 @@ function createDatoClient(params) {
|
|
|
3691
3823
|
filter: {
|
|
3692
3824
|
type: modelId,
|
|
3693
3825
|
only_valid: "true",
|
|
3694
|
-
ids: !_optionalChain([records, 'optionalAccess',
|
|
3826
|
+
ids: !_optionalChain([records, 'optionalAccess', _192 => _192.length]) ? void 0 : records.join(",")
|
|
3695
3827
|
}
|
|
3696
3828
|
}).catch(
|
|
3697
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
3829
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _193 => _193.response, 'optionalAccess', _194 => _194.body, 'optionalAccess', _195 => _195.data, 'optionalAccess', _196 => _196[0]]) || error)
|
|
3698
3830
|
);
|
|
3699
3831
|
return result;
|
|
3700
3832
|
} catch (_error) {
|
|
@@ -3710,10 +3842,10 @@ function createDatoClient(params) {
|
|
|
3710
3842
|
updateRecord: async (id, payload) => {
|
|
3711
3843
|
try {
|
|
3712
3844
|
await dato.items.update(id, payload).catch(
|
|
3713
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
3845
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _197 => _197.response, 'optionalAccess', _198 => _198.body, 'optionalAccess', _199 => _199.data, 'optionalAccess', _200 => _200[0]]) || error)
|
|
3714
3846
|
);
|
|
3715
3847
|
} catch (_error) {
|
|
3716
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
3848
|
+
if (_optionalChain([_error, 'optionalAccess', _201 => _201.attributes, 'optionalAccess', _202 => _202.details, 'optionalAccess', _203 => _203.message])) {
|
|
3717
3849
|
throw new Error(
|
|
3718
3850
|
[
|
|
3719
3851
|
`${_error.attributes.details.message}`,
|
|
@@ -3735,10 +3867,10 @@ function createDatoClient(params) {
|
|
|
3735
3867
|
enableFieldLocalization: async (args) => {
|
|
3736
3868
|
try {
|
|
3737
3869
|
await dato.fields.update(`${args.modelId}::${args.fieldId}`, { localized: true }).catch(
|
|
3738
|
-
(error) => Promise.reject(_optionalChain([error, 'optionalAccess',
|
|
3870
|
+
(error) => Promise.reject(_optionalChain([error, 'optionalAccess', _204 => _204.response, 'optionalAccess', _205 => _205.body, 'optionalAccess', _206 => _206.data, 'optionalAccess', _207 => _207[0]]) || error)
|
|
3739
3871
|
);
|
|
3740
3872
|
} catch (_error) {
|
|
3741
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
3873
|
+
if (_optionalChain([_error, 'optionalAccess', _208 => _208.attributes, 'optionalAccess', _209 => _209.code]) === "NOT_FOUND") {
|
|
3742
3874
|
throw new Error(
|
|
3743
3875
|
[
|
|
3744
3876
|
`Field "${args.fieldId}" not found in model "${args.modelId}".`,
|
|
@@ -3746,7 +3878,7 @@ function createDatoClient(params) {
|
|
|
3746
3878
|
].join("\n\n")
|
|
3747
3879
|
);
|
|
3748
3880
|
}
|
|
3749
|
-
if (_optionalChain([_error, 'optionalAccess',
|
|
3881
|
+
if (_optionalChain([_error, 'optionalAccess', _210 => _210.attributes, 'optionalAccess', _211 => _211.details, 'optionalAccess', _212 => _212.message])) {
|
|
3750
3882
|
throw new Error(
|
|
3751
3883
|
[
|
|
3752
3884
|
`${_error.attributes.details.message}`,
|
|
@@ -3824,7 +3956,7 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
3824
3956
|
const records = await dato.findRecordsForModel(modelId);
|
|
3825
3957
|
const recordChoices = createRecordChoices(
|
|
3826
3958
|
records,
|
|
3827
|
-
_optionalChain([config, 'access',
|
|
3959
|
+
_optionalChain([config, 'access', _213 => _213.models, 'access', _214 => _214[modelId], 'optionalAccess', _215 => _215.records]) || [],
|
|
3828
3960
|
project
|
|
3829
3961
|
);
|
|
3830
3962
|
const selectedRecords = await promptRecordSelection(
|
|
@@ -3843,14 +3975,14 @@ function createDatoApiLoader(config, onConfigUpdate) {
|
|
|
3843
3975
|
},
|
|
3844
3976
|
async pull(locale, input2, initCtx) {
|
|
3845
3977
|
const result = {};
|
|
3846
|
-
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess',
|
|
3847
|
-
let records = _optionalChain([initCtx, 'optionalAccess',
|
|
3978
|
+
for (const modelId of _lodash2.default.keys(_optionalChain([initCtx, 'optionalAccess', _216 => _216.models]) || {})) {
|
|
3979
|
+
let records = _optionalChain([initCtx, 'optionalAccess', _217 => _217.models, 'access', _218 => _218[modelId], 'access', _219 => _219.records]) || [];
|
|
3848
3980
|
const recordIds = records.map((record) => record.id);
|
|
3849
3981
|
records = await dato.findRecords(recordIds);
|
|
3850
3982
|
console.log(`Fetched ${records.length} records for model ${modelId}`);
|
|
3851
3983
|
if (records.length > 0) {
|
|
3852
3984
|
result[modelId] = {
|
|
3853
|
-
fields: _optionalChain([initCtx, 'optionalAccess',
|
|
3985
|
+
fields: _optionalChain([initCtx, 'optionalAccess', _220 => _220.models, 'optionalAccess', _221 => _221[modelId], 'optionalAccess', _222 => _222.fields]) || [],
|
|
3854
3986
|
records
|
|
3855
3987
|
};
|
|
3856
3988
|
}
|
|
@@ -3913,7 +4045,7 @@ function createRecordChoices(records, selectedIds = [], project) {
|
|
|
3913
4045
|
return records.map((record) => ({
|
|
3914
4046
|
name: `${record.id} - https://${project.internal_domain}/editor/item_types/${record.item_type.id}/items/${record.id}`,
|
|
3915
4047
|
value: record.id,
|
|
3916
|
-
checked: _optionalChain([selectedIds, 'optionalAccess',
|
|
4048
|
+
checked: _optionalChain([selectedIds, 'optionalAccess', _223 => _223.includes, 'call', _224 => _224(record.id)])
|
|
3917
4049
|
}));
|
|
3918
4050
|
}
|
|
3919
4051
|
async function promptRecordSelection(modelName, choices) {
|
|
@@ -4080,24 +4212,24 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
|
|
|
4080
4212
|
}
|
|
4081
4213
|
function serializeStructuredText(rawStructuredText) {
|
|
4082
4214
|
return serializeStructuredTextNode(rawStructuredText);
|
|
4083
|
-
function serializeStructuredTextNode(node,
|
|
4215
|
+
function serializeStructuredTextNode(node, path18 = [], acc = {}) {
|
|
4084
4216
|
if ("document" in node) {
|
|
4085
4217
|
return serializeStructuredTextNode(
|
|
4086
4218
|
node.document,
|
|
4087
|
-
[...
|
|
4219
|
+
[...path18, "document"],
|
|
4088
4220
|
acc
|
|
4089
4221
|
);
|
|
4090
4222
|
}
|
|
4091
4223
|
if (!_lodash2.default.isNil(node.value)) {
|
|
4092
|
-
acc[[...
|
|
4224
|
+
acc[[...path18, "value"].join(".")] = node.value;
|
|
4093
4225
|
} else if (_lodash2.default.get(node, "type") === "block") {
|
|
4094
|
-
acc[[...
|
|
4226
|
+
acc[[...path18, "item"].join(".")] = serializeBlock(node.item);
|
|
4095
4227
|
}
|
|
4096
4228
|
if (node.children) {
|
|
4097
4229
|
for (let i = 0; i < node.children.length; i++) {
|
|
4098
4230
|
serializeStructuredTextNode(
|
|
4099
4231
|
node.children[i],
|
|
4100
|
-
[...
|
|
4232
|
+
[...path18, i.toString()],
|
|
4101
4233
|
acc
|
|
4102
4234
|
);
|
|
4103
4235
|
}
|
|
@@ -4164,8 +4296,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
|
|
|
4164
4296
|
}
|
|
4165
4297
|
function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
|
|
4166
4298
|
const result = _lodash2.default.cloneDeep(originalRawStructuredText);
|
|
4167
|
-
for (const [
|
|
4168
|
-
const realPath = _lodash2.default.chain(
|
|
4299
|
+
for (const [path18, value] of _lodash2.default.entries(parsedStructuredText)) {
|
|
4300
|
+
const realPath = _lodash2.default.chain(path18.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
|
|
4169
4301
|
const deserializedValue = createRawDatoValue(
|
|
4170
4302
|
value,
|
|
4171
4303
|
_lodash2.default.get(originalRawStructuredText, realPath),
|
|
@@ -4232,7 +4364,7 @@ function createVttLoader() {
|
|
|
4232
4364
|
if (!input2) {
|
|
4233
4365
|
return "";
|
|
4234
4366
|
}
|
|
4235
|
-
const vtt = _optionalChain([_nodewebvtt2.default, 'access',
|
|
4367
|
+
const vtt = _optionalChain([_nodewebvtt2.default, 'access', _225 => _225.parse, 'call', _226 => _226(input2), 'optionalAccess', _227 => _227.cues]);
|
|
4236
4368
|
if (Object.keys(vtt).length === 0) {
|
|
4237
4369
|
return {};
|
|
4238
4370
|
} else {
|
|
@@ -4286,7 +4418,7 @@ function variableExtractLoader(params) {
|
|
|
4286
4418
|
for (let i = 0; i < matches.length; i++) {
|
|
4287
4419
|
const match2 = matches[i];
|
|
4288
4420
|
const currentValue = result[key].value;
|
|
4289
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
4421
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _228 => _228.replace, 'call', _229 => _229(match2, `{variable:${i}}`)]);
|
|
4290
4422
|
result[key].value = newValue;
|
|
4291
4423
|
result[key].variables[i] = match2;
|
|
4292
4424
|
}
|
|
@@ -4300,7 +4432,7 @@ function variableExtractLoader(params) {
|
|
|
4300
4432
|
for (let i = 0; i < valueObj.variables.length; i++) {
|
|
4301
4433
|
const variable = valueObj.variables[i];
|
|
4302
4434
|
const currentValue = result[key];
|
|
4303
|
-
const newValue = _optionalChain([currentValue, 'optionalAccess',
|
|
4435
|
+
const newValue = _optionalChain([currentValue, 'optionalAccess', _230 => _230.replace, 'call', _231 => _231(`{variable:${i}}`, variable)]);
|
|
4304
4436
|
result[key] = newValue;
|
|
4305
4437
|
}
|
|
4306
4438
|
}
|
|
@@ -4500,7 +4632,7 @@ function createVueJsonLoader() {
|
|
|
4500
4632
|
return createLoader({
|
|
4501
4633
|
pull: async (locale, input2, ctx) => {
|
|
4502
4634
|
const parsed = parseVueFile(input2);
|
|
4503
|
-
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess',
|
|
4635
|
+
return _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _232 => _232.i18n, 'optionalAccess', _233 => _233[locale]]), () => ( {}));
|
|
4504
4636
|
},
|
|
4505
4637
|
push: async (locale, data, originalInput) => {
|
|
4506
4638
|
const parsed = parseVueFile(_nullishCoalesce(originalInput, () => ( "")));
|
|
@@ -4591,15 +4723,15 @@ function parseTypeScript(input2) {
|
|
|
4591
4723
|
function extractStringsFromDefaultExport(ast) {
|
|
4592
4724
|
let extracted = {};
|
|
4593
4725
|
traverse(ast, {
|
|
4594
|
-
ExportDefaultDeclaration(
|
|
4595
|
-
const { declaration } =
|
|
4726
|
+
ExportDefaultDeclaration(path18) {
|
|
4727
|
+
const { declaration } = path18.node;
|
|
4596
4728
|
const decl = unwrapTSAsExpression(declaration);
|
|
4597
4729
|
if (t.isObjectExpression(decl)) {
|
|
4598
4730
|
extracted = objectExpressionToObject(decl);
|
|
4599
4731
|
} else if (t.isArrayExpression(decl)) {
|
|
4600
4732
|
extracted = arrayExpressionToArray(decl);
|
|
4601
4733
|
} else if (t.isIdentifier(decl)) {
|
|
4602
|
-
const binding =
|
|
4734
|
+
const binding = path18.scope.bindings[decl.name];
|
|
4603
4735
|
if (binding && t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
4604
4736
|
const initRaw = binding.path.node.init;
|
|
4605
4737
|
const init = initRaw ? unwrapTSAsExpression(initRaw) : initRaw;
|
|
@@ -4664,8 +4796,8 @@ function arrayExpressionToArray(arrayExpression) {
|
|
|
4664
4796
|
function updateStringsInDefaultExport(ast, data) {
|
|
4665
4797
|
let modified = false;
|
|
4666
4798
|
traverse(ast, {
|
|
4667
|
-
ExportDefaultDeclaration(
|
|
4668
|
-
const { declaration } =
|
|
4799
|
+
ExportDefaultDeclaration(path18) {
|
|
4800
|
+
const { declaration } = path18.node;
|
|
4669
4801
|
const decl = unwrapTSAsExpression(declaration);
|
|
4670
4802
|
if (t.isObjectExpression(decl)) {
|
|
4671
4803
|
modified = updateStringsInObjectExpression(decl, data) || modified;
|
|
@@ -4674,7 +4806,7 @@ function updateStringsInDefaultExport(ast, data) {
|
|
|
4674
4806
|
modified = updateStringsInArrayExpression(decl, data) || modified;
|
|
4675
4807
|
}
|
|
4676
4808
|
} else if (t.isIdentifier(decl)) {
|
|
4677
|
-
modified = updateStringsInExportedIdentifier(
|
|
4809
|
+
modified = updateStringsInExportedIdentifier(path18, data) || modified;
|
|
4678
4810
|
}
|
|
4679
4811
|
}
|
|
4680
4812
|
});
|
|
@@ -4685,7 +4817,7 @@ function updateStringsInObjectExpression(objectExpression, data) {
|
|
|
4685
4817
|
objectExpression.properties.forEach((prop) => {
|
|
4686
4818
|
if (!t.isObjectProperty(prop)) return;
|
|
4687
4819
|
const key = getPropertyKey(prop);
|
|
4688
|
-
const incomingVal = _optionalChain([data, 'optionalAccess',
|
|
4820
|
+
const incomingVal = _optionalChain([data, 'optionalAccess', _234 => _234[key]]);
|
|
4689
4821
|
if (incomingVal === void 0) {
|
|
4690
4822
|
return;
|
|
4691
4823
|
}
|
|
@@ -4721,7 +4853,7 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
4721
4853
|
let modified = false;
|
|
4722
4854
|
arrayExpression.elements.forEach((element, index) => {
|
|
4723
4855
|
if (!element) return;
|
|
4724
|
-
const incomingVal = _optionalChain([incoming, 'optionalAccess',
|
|
4856
|
+
const incomingVal = _optionalChain([incoming, 'optionalAccess', _235 => _235[index]]);
|
|
4725
4857
|
if (incomingVal === void 0) return;
|
|
4726
4858
|
if (t.isStringLiteral(element) && typeof incomingVal === "string") {
|
|
4727
4859
|
if (element.value !== incomingVal) {
|
|
@@ -4745,9 +4877,9 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
|
4745
4877
|
});
|
|
4746
4878
|
return modified;
|
|
4747
4879
|
}
|
|
4748
|
-
function updateStringsInExportedIdentifier(
|
|
4749
|
-
const exportName =
|
|
4750
|
-
const binding =
|
|
4880
|
+
function updateStringsInExportedIdentifier(path18, data) {
|
|
4881
|
+
const exportName = path18.node.declaration.name;
|
|
4882
|
+
const binding = path18.scope.bindings[exportName];
|
|
4751
4883
|
if (!binding || !binding.path.node) return false;
|
|
4752
4884
|
if (t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
4753
4885
|
const initRaw = binding.path.node.init;
|
|
@@ -5212,7 +5344,7 @@ var AST = class _AST {
|
|
|
5212
5344
|
const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
|
|
5213
5345
|
if (this.isStart() && !this.type)
|
|
5214
5346
|
ret.unshift([]);
|
|
5215
|
-
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
5347
|
+
if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && _optionalChain([this, 'access', _236 => _236.#parent, 'optionalAccess', _237 => _237.type]) === "!")) {
|
|
5216
5348
|
ret.push({});
|
|
5217
5349
|
}
|
|
5218
5350
|
return ret;
|
|
@@ -5220,7 +5352,7 @@ var AST = class _AST {
|
|
|
5220
5352
|
isStart() {
|
|
5221
5353
|
if (this.#root === this)
|
|
5222
5354
|
return true;
|
|
5223
|
-
if (!_optionalChain([this, 'access',
|
|
5355
|
+
if (!_optionalChain([this, 'access', _238 => _238.#parent, 'optionalAccess', _239 => _239.isStart, 'call', _240 => _240()]))
|
|
5224
5356
|
return false;
|
|
5225
5357
|
if (this.#parentIndex === 0)
|
|
5226
5358
|
return true;
|
|
@@ -5236,12 +5368,12 @@ var AST = class _AST {
|
|
|
5236
5368
|
isEnd() {
|
|
5237
5369
|
if (this.#root === this)
|
|
5238
5370
|
return true;
|
|
5239
|
-
if (_optionalChain([this, 'access',
|
|
5371
|
+
if (_optionalChain([this, 'access', _241 => _241.#parent, 'optionalAccess', _242 => _242.type]) === "!")
|
|
5240
5372
|
return true;
|
|
5241
|
-
if (!_optionalChain([this, 'access',
|
|
5373
|
+
if (!_optionalChain([this, 'access', _243 => _243.#parent, 'optionalAccess', _244 => _244.isEnd, 'call', _245 => _245()]))
|
|
5242
5374
|
return false;
|
|
5243
5375
|
if (!this.type)
|
|
5244
|
-
return _optionalChain([this, 'access',
|
|
5376
|
+
return _optionalChain([this, 'access', _246 => _246.#parent, 'optionalAccess', _247 => _247.isEnd, 'call', _248 => _248()]);
|
|
5245
5377
|
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
5246
5378
|
return this.#parentIndex === pl - 1;
|
|
5247
5379
|
}
|
|
@@ -5486,7 +5618,7 @@ var AST = class _AST {
|
|
|
5486
5618
|
}
|
|
5487
5619
|
}
|
|
5488
5620
|
let end = "";
|
|
5489
|
-
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access',
|
|
5621
|
+
if (this.isEnd() && this.#root.#filledNegs && _optionalChain([this, 'access', _249 => _249.#parent, 'optionalAccess', _250 => _250.type]) === "!") {
|
|
5490
5622
|
end = "(?:$|\\/)";
|
|
5491
5623
|
}
|
|
5492
5624
|
const final2 = start2 + src + end;
|
|
@@ -6349,11 +6481,11 @@ function _getAllKeys(obj, prefix = "") {
|
|
|
6349
6481
|
let keys = [];
|
|
6350
6482
|
for (const key in obj) {
|
|
6351
6483
|
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
6352
|
-
const
|
|
6484
|
+
const path18 = prefix ? `${prefix}.${key}` : key;
|
|
6353
6485
|
if (typeof obj[key] === "object" && obj[key] !== null && !Array.isArray(obj[key])) {
|
|
6354
|
-
keys = keys.concat(_getAllKeys(obj[key],
|
|
6486
|
+
keys = keys.concat(_getAllKeys(obj[key], path18));
|
|
6355
6487
|
} else {
|
|
6356
|
-
keys.push(
|
|
6488
|
+
keys.push(path18);
|
|
6357
6489
|
}
|
|
6358
6490
|
}
|
|
6359
6491
|
return keys;
|
|
@@ -6563,7 +6695,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
6563
6695
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
6564
6696
|
const result = {
|
|
6565
6697
|
frontmatter: data.frontmatter,
|
|
6566
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
6698
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _251 => _251.codePlaceholders]) || {},
|
|
6567
6699
|
content
|
|
6568
6700
|
};
|
|
6569
6701
|
return result;
|
|
@@ -6866,19 +6998,19 @@ function createJsonDictionaryLoader() {
|
|
|
6866
6998
|
);
|
|
6867
6999
|
return input2;
|
|
6868
7000
|
}
|
|
6869
|
-
function walk(obj, dataNode,
|
|
7001
|
+
function walk(obj, dataNode, path18 = []) {
|
|
6870
7002
|
if (Array.isArray(obj) && Array.isArray(dataNode)) {
|
|
6871
7003
|
obj.forEach(
|
|
6872
|
-
(item, idx) => walk(item, dataNode[idx], [...
|
|
7004
|
+
(item, idx) => walk(item, dataNode[idx], [...path18, String(idx)])
|
|
6873
7005
|
);
|
|
6874
7006
|
} else if (obj && typeof obj === "object" && dataNode && typeof dataNode === "object" && !Array.isArray(dataNode)) {
|
|
6875
7007
|
for (const key of Object.keys(obj)) {
|
|
6876
7008
|
if (dataNode.hasOwnProperty(key)) {
|
|
6877
|
-
walk(obj[key], dataNode[key], [...
|
|
7009
|
+
walk(obj[key], dataNode[key], [...path18, key]);
|
|
6878
7010
|
}
|
|
6879
7011
|
}
|
|
6880
7012
|
} else if (obj && typeof obj === "object" && !Array.isArray(obj) && typeof dataNode === "string") {
|
|
6881
|
-
setNestedLocale(input2,
|
|
7013
|
+
setNestedLocale(input2, path18, locale, dataNode, originalLocale);
|
|
6882
7014
|
}
|
|
6883
7015
|
}
|
|
6884
7016
|
walk(input2, data);
|
|
@@ -6906,14 +7038,14 @@ function extractTranslatables(obj, locale) {
|
|
|
6906
7038
|
function isTranslatableObject(obj, locale) {
|
|
6907
7039
|
return obj && typeof obj === "object" && !Array.isArray(obj) && Object.prototype.hasOwnProperty.call(obj, locale);
|
|
6908
7040
|
}
|
|
6909
|
-
function setNestedLocale(obj,
|
|
7041
|
+
function setNestedLocale(obj, path18, locale, value, originalLocale) {
|
|
6910
7042
|
let curr = obj;
|
|
6911
|
-
for (let i = 0; i <
|
|
6912
|
-
const key =
|
|
7043
|
+
for (let i = 0; i < path18.length - 1; i++) {
|
|
7044
|
+
const key = path18[i];
|
|
6913
7045
|
if (!(key in curr)) curr[key] = {};
|
|
6914
7046
|
curr = curr[key];
|
|
6915
7047
|
}
|
|
6916
|
-
const last =
|
|
7048
|
+
const last = path18[path18.length - 1];
|
|
6917
7049
|
if (curr[last] && typeof curr[last] === "object") {
|
|
6918
7050
|
curr[last][locale] = value;
|
|
6919
7051
|
if (originalLocale && curr[last][originalLocale]) {
|
|
@@ -7300,7 +7432,7 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
7300
7432
|
]
|
|
7301
7433
|
});
|
|
7302
7434
|
const result = JSON.parse(response.text);
|
|
7303
|
-
return _optionalChain([result, 'optionalAccess',
|
|
7435
|
+
return _optionalChain([result, 'optionalAccess', _252 => _252.data]) || {};
|
|
7304
7436
|
}
|
|
7305
7437
|
}
|
|
7306
7438
|
function extractPayloadChunks(payload) {
|
|
@@ -7382,7 +7514,7 @@ function getPureModelProvider(provider) {
|
|
|
7382
7514
|
|
|
7383
7515
|
${_chalk2.default.hex(colors.blue)("Docs: https://lingo.dev/go/docs")}
|
|
7384
7516
|
`;
|
|
7385
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
7517
|
+
switch (_optionalChain([provider, 'optionalAccess', _253 => _253.id])) {
|
|
7386
7518
|
case "openai": {
|
|
7387
7519
|
if (!process.env.OPENAI_API_KEY) {
|
|
7388
7520
|
throw new Error(
|
|
@@ -7440,7 +7572,7 @@ function getPureModelProvider(provider) {
|
|
|
7440
7572
|
})(provider.model);
|
|
7441
7573
|
}
|
|
7442
7574
|
default: {
|
|
7443
|
-
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess',
|
|
7575
|
+
throw new Error(createUnsupportedProviderErrorMessage(_optionalChain([provider, 'optionalAccess', _254 => _254.id])));
|
|
7444
7576
|
}
|
|
7445
7577
|
}
|
|
7446
7578
|
}
|
|
@@ -7483,7 +7615,11 @@ function trackEvent(distinctId, event, properties) {
|
|
|
7483
7615
|
properties: {
|
|
7484
7616
|
...properties,
|
|
7485
7617
|
$lib: "lingo.dev-cli",
|
|
7486
|
-
$lib_version: process.env.npm_package_version || "unknown"
|
|
7618
|
+
$lib_version: process.env.npm_package_version || "unknown",
|
|
7619
|
+
// Essential debugging context only
|
|
7620
|
+
node_version: process.version,
|
|
7621
|
+
is_ci: !!process.env.CI,
|
|
7622
|
+
debug_enabled: process.env.DEBUG === "true"
|
|
7487
7623
|
},
|
|
7488
7624
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
7489
7625
|
};
|
|
@@ -7683,7 +7819,21 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7683
7819
|
).action(async function(options) {
|
|
7684
7820
|
updateGitignore();
|
|
7685
7821
|
const ora = _ora2.default.call(void 0, );
|
|
7686
|
-
|
|
7822
|
+
let flags;
|
|
7823
|
+
try {
|
|
7824
|
+
flags = parseFlags(options);
|
|
7825
|
+
} catch (parseError) {
|
|
7826
|
+
await trackEvent("unknown", "cmd.i18n.error", {
|
|
7827
|
+
errorType: "validation_error",
|
|
7828
|
+
errorName: parseError.name || "ValidationError",
|
|
7829
|
+
errorMessage: parseError.message || "Invalid command line options",
|
|
7830
|
+
errorStack: parseError.stack,
|
|
7831
|
+
fatal: true,
|
|
7832
|
+
errorCount: 1,
|
|
7833
|
+
stage: "flag_validation"
|
|
7834
|
+
});
|
|
7835
|
+
throw parseError;
|
|
7836
|
+
}
|
|
7687
7837
|
if (flags.debug) {
|
|
7688
7838
|
const { debug } = await _inquirer2.default.prompt([
|
|
7689
7839
|
{
|
|
@@ -7695,6 +7845,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7695
7845
|
}
|
|
7696
7846
|
let hasErrors = false;
|
|
7697
7847
|
let authId = null;
|
|
7848
|
+
const errorDetails = [];
|
|
7698
7849
|
try {
|
|
7699
7850
|
ora.start("Loading configuration...");
|
|
7700
7851
|
const i18nConfig = getConfig();
|
|
@@ -7704,7 +7855,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7704
7855
|
validateParams(i18nConfig, flags);
|
|
7705
7856
|
ora.succeed("Localization configuration is valid");
|
|
7706
7857
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
7707
|
-
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess',
|
|
7858
|
+
const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _255 => _255.provider]);
|
|
7708
7859
|
if (isByokMode) {
|
|
7709
7860
|
authId = null;
|
|
7710
7861
|
ora.succeed("Using external provider (BYOK mode)");
|
|
@@ -7718,16 +7869,16 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7718
7869
|
flags
|
|
7719
7870
|
});
|
|
7720
7871
|
let buckets = getBuckets(i18nConfig);
|
|
7721
|
-
if (_optionalChain([flags, 'access',
|
|
7872
|
+
if (_optionalChain([flags, 'access', _256 => _256.bucket, 'optionalAccess', _257 => _257.length])) {
|
|
7722
7873
|
buckets = buckets.filter(
|
|
7723
7874
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
7724
7875
|
);
|
|
7725
7876
|
}
|
|
7726
7877
|
ora.succeed("Buckets retrieved");
|
|
7727
|
-
if (_optionalChain([flags, 'access',
|
|
7878
|
+
if (_optionalChain([flags, 'access', _258 => _258.file, 'optionalAccess', _259 => _259.length])) {
|
|
7728
7879
|
buckets = buckets.map((bucket) => {
|
|
7729
7880
|
const paths = bucket.paths.filter(
|
|
7730
|
-
(
|
|
7881
|
+
(path18) => flags.file.find((file) => _optionalChain([path18, 'access', _260 => _260.pathPattern, 'optionalAccess', _261 => _261.includes, 'call', _262 => _262(file)]))
|
|
7731
7882
|
);
|
|
7732
7883
|
return { ...bucket, paths };
|
|
7733
7884
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -7742,13 +7893,13 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7742
7893
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
7743
7894
|
buckets.map((bucket) => {
|
|
7744
7895
|
ora.info(` ${bucket.type}:`);
|
|
7745
|
-
bucket.paths.forEach((
|
|
7746
|
-
ora.info(` - ${
|
|
7896
|
+
bucket.paths.forEach((path18) => {
|
|
7897
|
+
ora.info(` - ${path18.pathPattern}`);
|
|
7747
7898
|
});
|
|
7748
7899
|
});
|
|
7749
7900
|
}
|
|
7750
7901
|
}
|
|
7751
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
7902
|
+
const targetLocales = _optionalChain([flags, 'access', _263 => _263.locale, 'optionalAccess', _264 => _264.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
7752
7903
|
ora.start("Setting up localization cache...");
|
|
7753
7904
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
7754
7905
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -7996,9 +8147,23 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7996
8147
|
);
|
|
7997
8148
|
}
|
|
7998
8149
|
} catch (_error) {
|
|
7999
|
-
const error = new
|
|
8000
|
-
`[${sourceLocale} -> ${targetLocale}] Localization failed: ${_error.message}
|
|
8150
|
+
const error = new LocalizationError(
|
|
8151
|
+
`[${sourceLocale} -> ${targetLocale}] Localization failed: ${_error.message}`,
|
|
8152
|
+
{
|
|
8153
|
+
bucket: bucket.type,
|
|
8154
|
+
sourceLocale,
|
|
8155
|
+
targetLocale,
|
|
8156
|
+
pathPattern: bucketPath.pathPattern
|
|
8157
|
+
}
|
|
8001
8158
|
);
|
|
8159
|
+
errorDetails.push({
|
|
8160
|
+
type: "locale_error",
|
|
8161
|
+
bucket: bucket.type,
|
|
8162
|
+
locale: `${sourceLocale} -> ${targetLocale}`,
|
|
8163
|
+
pathPattern: bucketPath.pathPattern,
|
|
8164
|
+
message: _error.message,
|
|
8165
|
+
stack: _error.stack
|
|
8166
|
+
});
|
|
8002
8167
|
if (flags.strict) {
|
|
8003
8168
|
throw error;
|
|
8004
8169
|
} else {
|
|
@@ -8009,14 +8174,21 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
8009
8174
|
}
|
|
8010
8175
|
const deltaProcessor = createDeltaProcessor(bucketPath.pathPattern);
|
|
8011
8176
|
const checksums = await deltaProcessor.createChecksums(sourceData);
|
|
8012
|
-
if (!_optionalChain([flags, 'access',
|
|
8177
|
+
if (!_optionalChain([flags, 'access', _265 => _265.locale, 'optionalAccess', _266 => _266.length])) {
|
|
8013
8178
|
await deltaProcessor.saveChecksums(checksums);
|
|
8014
8179
|
}
|
|
8015
8180
|
}
|
|
8016
8181
|
} catch (_error) {
|
|
8017
|
-
const error = new
|
|
8018
|
-
`Failed to process bucket ${bucket.type}: ${_error.message}
|
|
8182
|
+
const error = new BucketProcessingError(
|
|
8183
|
+
`Failed to process bucket ${bucket.type}: ${_error.message}`,
|
|
8184
|
+
bucket.type
|
|
8019
8185
|
);
|
|
8186
|
+
errorDetails.push({
|
|
8187
|
+
type: "bucket_error",
|
|
8188
|
+
bucket: bucket.type,
|
|
8189
|
+
message: _error.message,
|
|
8190
|
+
stack: _error.stack
|
|
8191
|
+
});
|
|
8020
8192
|
if (flags.strict) {
|
|
8021
8193
|
throw error;
|
|
8022
8194
|
} else {
|
|
@@ -8029,20 +8201,54 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
8029
8201
|
if (!hasErrors) {
|
|
8030
8202
|
ora.succeed("Localization completed.");
|
|
8031
8203
|
await trackEvent(authId, "cmd.i18n.success", {
|
|
8032
|
-
i18nConfig
|
|
8033
|
-
|
|
8204
|
+
i18nConfig: {
|
|
8205
|
+
sourceLocale: i18nConfig.locale.source,
|
|
8206
|
+
targetLocales: i18nConfig.locale.targets,
|
|
8207
|
+
bucketTypes: Object.keys(i18nConfig.buckets)
|
|
8208
|
+
},
|
|
8209
|
+
flags,
|
|
8210
|
+
bucketCount: buckets.length,
|
|
8211
|
+
localeCount: targetLocales.length,
|
|
8212
|
+
processedSuccessfully: true
|
|
8034
8213
|
});
|
|
8035
8214
|
} else {
|
|
8036
8215
|
ora.warn("Localization completed with errors.");
|
|
8037
8216
|
await trackEvent(authId || "unknown", "cmd.i18n.error", {
|
|
8038
|
-
flags
|
|
8217
|
+
flags,
|
|
8218
|
+
...aggregateErrorAnalytics(
|
|
8219
|
+
errorDetails,
|
|
8220
|
+
buckets,
|
|
8221
|
+
targetLocales,
|
|
8222
|
+
i18nConfig
|
|
8223
|
+
)
|
|
8039
8224
|
});
|
|
8040
8225
|
}
|
|
8041
8226
|
} catch (error) {
|
|
8042
8227
|
ora.fail(error.message);
|
|
8228
|
+
const errorType = getCLIErrorType(error);
|
|
8229
|
+
let errorContext = {};
|
|
8230
|
+
if (isLocalizationError(error)) {
|
|
8231
|
+
errorContext = {
|
|
8232
|
+
bucket: error.bucket,
|
|
8233
|
+
sourceLocale: error.sourceLocale,
|
|
8234
|
+
targetLocale: error.targetLocale,
|
|
8235
|
+
pathPattern: error.pathPattern
|
|
8236
|
+
};
|
|
8237
|
+
} else if (isBucketProcessingError(error)) {
|
|
8238
|
+
errorContext = {
|
|
8239
|
+
bucket: error.bucket
|
|
8240
|
+
};
|
|
8241
|
+
}
|
|
8043
8242
|
await trackEvent(authId || "unknown", "cmd.i18n.error", {
|
|
8044
8243
|
flags,
|
|
8045
|
-
|
|
8244
|
+
errorType,
|
|
8245
|
+
errorName: error.name || "Error",
|
|
8246
|
+
errorMessage: error.message,
|
|
8247
|
+
errorStack: error.stack,
|
|
8248
|
+
errorContext,
|
|
8249
|
+
fatal: true,
|
|
8250
|
+
errorCount: errorDetails.length + 1,
|
|
8251
|
+
previousErrors: createPreviousErrorContext(errorDetails)
|
|
8046
8252
|
});
|
|
8047
8253
|
}
|
|
8048
8254
|
});
|
|
@@ -8063,7 +8269,7 @@ function parseFlags(options) {
|
|
|
8063
8269
|
}
|
|
8064
8270
|
async function validateAuth(settings) {
|
|
8065
8271
|
if (!settings.auth.apiKey) {
|
|
8066
|
-
throw new
|
|
8272
|
+
throw new AuthenticationError({
|
|
8067
8273
|
message: "Not authenticated. Please run `lingo.dev login` to authenticate.",
|
|
8068
8274
|
docUrl: "authError"
|
|
8069
8275
|
});
|
|
@@ -8074,7 +8280,7 @@ async function validateAuth(settings) {
|
|
|
8074
8280
|
});
|
|
8075
8281
|
const user = await authenticator.whoami();
|
|
8076
8282
|
if (!user) {
|
|
8077
|
-
throw new
|
|
8283
|
+
throw new AuthenticationError({
|
|
8078
8284
|
message: "Invalid API key. Please run `lingo.dev login` to authenticate.",
|
|
8079
8285
|
docUrl: "authError"
|
|
8080
8286
|
});
|
|
@@ -8083,24 +8289,24 @@ async function validateAuth(settings) {
|
|
|
8083
8289
|
}
|
|
8084
8290
|
function validateParams(i18nConfig, flags) {
|
|
8085
8291
|
if (!i18nConfig) {
|
|
8086
|
-
throw new
|
|
8292
|
+
throw new ConfigError({
|
|
8087
8293
|
message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
|
|
8088
8294
|
docUrl: "i18nNotFound"
|
|
8089
8295
|
});
|
|
8090
8296
|
} else if (!i18nConfig.buckets || !Object.keys(i18nConfig.buckets).length) {
|
|
8091
|
-
throw new
|
|
8297
|
+
throw new ConfigError({
|
|
8092
8298
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
8093
8299
|
docUrl: "bucketNotFound"
|
|
8094
8300
|
});
|
|
8095
|
-
} else if (_optionalChain([flags, 'access',
|
|
8096
|
-
throw new
|
|
8301
|
+
} else if (_optionalChain([flags, 'access', _267 => _267.locale, 'optionalAccess', _268 => _268.some, 'call', _269 => _269((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
8302
|
+
throw new ValidationError({
|
|
8097
8303
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
8098
8304
|
docUrl: "localeTargetNotFound"
|
|
8099
8305
|
});
|
|
8100
|
-
} else if (_optionalChain([flags, 'access',
|
|
8306
|
+
} else if (_optionalChain([flags, 'access', _270 => _270.bucket, 'optionalAccess', _271 => _271.some, 'call', _272 => _272(
|
|
8101
8307
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
8102
8308
|
)])) {
|
|
8103
|
-
throw new
|
|
8309
|
+
throw new ValidationError({
|
|
8104
8310
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
8105
8311
|
docUrl: "bucketNotFound"
|
|
8106
8312
|
});
|
|
@@ -8554,6 +8760,10 @@ function escapeShellArg(arg) {
|
|
|
8554
8760
|
// src/cli/cmd/run/index.ts
|
|
8555
8761
|
|
|
8556
8762
|
|
|
8763
|
+
|
|
8764
|
+
var _url = require('url');
|
|
8765
|
+
|
|
8766
|
+
|
|
8557
8767
|
// src/cli/cmd/run/setup.ts
|
|
8558
8768
|
|
|
8559
8769
|
var _listr2 = require('listr2');
|
|
@@ -8601,7 +8811,7 @@ function createLingoDotDevLocalizer(explicitApiKey) {
|
|
|
8601
8811
|
const response = await engine.whoami();
|
|
8602
8812
|
return {
|
|
8603
8813
|
authenticated: !!response,
|
|
8604
|
-
username: _optionalChain([response, 'optionalAccess',
|
|
8814
|
+
username: _optionalChain([response, 'optionalAccess', _273 => _273.email])
|
|
8605
8815
|
};
|
|
8606
8816
|
} catch (e2) {
|
|
8607
8817
|
return { authenticated: false };
|
|
@@ -8709,7 +8919,7 @@ function createExplicitLocalizer(provider) {
|
|
|
8709
8919
|
}
|
|
8710
8920
|
function createAiSdkLocalizer(params) {
|
|
8711
8921
|
const skipAuth = params.skipAuth === true;
|
|
8712
|
-
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess',
|
|
8922
|
+
const apiKey = process.env[_nullishCoalesce(_optionalChain([params, 'optionalAccess', _274 => _274.apiKeyName]), () => ( ""))];
|
|
8713
8923
|
if (!skipAuth && !apiKey || !params.apiKeyName) {
|
|
8714
8924
|
throw new Error(
|
|
8715
8925
|
_dedent2.default`
|
|
@@ -8834,8 +9044,8 @@ async function setup(input2) {
|
|
|
8834
9044
|
throw new Error(
|
|
8835
9045
|
"No buckets found in i18n.json. Please add at least one bucket containing i18n content."
|
|
8836
9046
|
);
|
|
8837
|
-
} else if (_optionalChain([ctx, 'access',
|
|
8838
|
-
(bucket) => !_optionalChain([ctx, 'access',
|
|
9047
|
+
} else if (_optionalChain([ctx, 'access', _275 => _275.flags, 'access', _276 => _276.bucket, 'optionalAccess', _277 => _277.some, 'call', _278 => _278(
|
|
9048
|
+
(bucket) => !_optionalChain([ctx, 'access', _279 => _279.config, 'optionalAccess', _280 => _280.buckets, 'access', _281 => _281[bucket]])
|
|
8839
9049
|
)])) {
|
|
8840
9050
|
throw new Error(
|
|
8841
9051
|
`One or more specified buckets do not exist in i18n.json. Please add them to the list first and try again.`
|
|
@@ -8848,7 +9058,7 @@ async function setup(input2) {
|
|
|
8848
9058
|
title: "Selecting localization provider",
|
|
8849
9059
|
task: async (ctx, task) => {
|
|
8850
9060
|
ctx.localizer = createLocalizer(
|
|
8851
|
-
_optionalChain([ctx, 'access',
|
|
9061
|
+
_optionalChain([ctx, 'access', _282 => _282.config, 'optionalAccess', _283 => _283.provider]),
|
|
8852
9062
|
ctx.flags.apiKey
|
|
8853
9063
|
);
|
|
8854
9064
|
if (!ctx.localizer) {
|
|
@@ -9167,7 +9377,7 @@ function createWorkerTask(args) {
|
|
|
9167
9377
|
const processableData = _lodash2.default.chain(sourceData).entries().filter(
|
|
9168
9378
|
([key, value]) => delta.added.includes(key) || delta.updated.includes(key) || !!args.ctx.flags.force
|
|
9169
9379
|
).filter(
|
|
9170
|
-
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access',
|
|
9380
|
+
([key]) => !assignedTask.onlyKeys.length || _optionalChain([assignedTask, 'access', _284 => _284.onlyKeys, 'optionalAccess', _285 => _285.some, 'call', _286 => _286(
|
|
9171
9381
|
(pattern) => minimatch(key, pattern)
|
|
9172
9382
|
)])
|
|
9173
9383
|
).fromPairs().value();
|
|
@@ -9230,7 +9440,7 @@ function createWorkerTask(args) {
|
|
|
9230
9440
|
finalRenamedTargetData
|
|
9231
9441
|
);
|
|
9232
9442
|
const checksums2 = await deltaProcessor.createChecksums(sourceData);
|
|
9233
|
-
if (!_optionalChain([args, 'access',
|
|
9443
|
+
if (!_optionalChain([args, 'access', _287 => _287.ctx, 'access', _288 => _288.flags, 'access', _289 => _289.targetLocale, 'optionalAccess', _290 => _290.length])) {
|
|
9234
9444
|
await deltaProcessor.saveChecksums(checksums2);
|
|
9235
9445
|
}
|
|
9236
9446
|
});
|
|
@@ -9296,14 +9506,14 @@ async function watch2(ctx) {
|
|
|
9296
9506
|
pollInterval: 100
|
|
9297
9507
|
}
|
|
9298
9508
|
});
|
|
9299
|
-
watcher.on("change", (
|
|
9300
|
-
handleFileChange(
|
|
9509
|
+
watcher.on("change", (path18) => {
|
|
9510
|
+
handleFileChange(path18, state, ctx);
|
|
9301
9511
|
});
|
|
9302
|
-
watcher.on("add", (
|
|
9303
|
-
handleFileChange(
|
|
9512
|
+
watcher.on("add", (path18) => {
|
|
9513
|
+
handleFileChange(path18, state, ctx);
|
|
9304
9514
|
});
|
|
9305
|
-
watcher.on("unlink", (
|
|
9306
|
-
handleFileChange(
|
|
9515
|
+
watcher.on("unlink", (path18) => {
|
|
9516
|
+
handleFileChange(path18, state, ctx);
|
|
9307
9517
|
});
|
|
9308
9518
|
watcher.on("error", (error) => {
|
|
9309
9519
|
console.error(
|
|
@@ -9414,19 +9624,20 @@ var flagsSchema2 = _zod.z.object({
|
|
|
9414
9624
|
sourceLocale: _zod.z.string().optional(),
|
|
9415
9625
|
targetLocale: _zod.z.array(_zod.z.string()).optional(),
|
|
9416
9626
|
watch: _zod.z.boolean().default(false),
|
|
9417
|
-
debounce: _zod.z.number().positive().default(5e3)
|
|
9627
|
+
debounce: _zod.z.number().positive().default(5e3),
|
|
9418
9628
|
// 5 seconds default
|
|
9629
|
+
sound: _zod.z.boolean().optional()
|
|
9419
9630
|
});
|
|
9420
9631
|
|
|
9421
9632
|
// src/cli/cmd/run/_utils.ts
|
|
9422
9633
|
async function determineAuthId(ctx) {
|
|
9423
|
-
const isByokMode = !!_optionalChain([ctx, 'access',
|
|
9634
|
+
const isByokMode = !!_optionalChain([ctx, 'access', _291 => _291.config, 'optionalAccess', _292 => _292.provider]);
|
|
9424
9635
|
if (isByokMode) {
|
|
9425
9636
|
return null;
|
|
9426
9637
|
} else {
|
|
9427
9638
|
try {
|
|
9428
|
-
const authStatus = await _optionalChain([ctx, 'access',
|
|
9429
|
-
return _optionalChain([authStatus, 'optionalAccess',
|
|
9639
|
+
const authStatus = await _optionalChain([ctx, 'access', _293 => _293.localizer, 'optionalAccess', _294 => _294.checkAuth, 'call', _295 => _295()]);
|
|
9640
|
+
return _optionalChain([authStatus, 'optionalAccess', _296 => _296.username]) || null;
|
|
9430
9641
|
} catch (e3) {
|
|
9431
9642
|
return null;
|
|
9432
9643
|
}
|
|
@@ -9434,6 +9645,32 @@ async function determineAuthId(ctx) {
|
|
|
9434
9645
|
}
|
|
9435
9646
|
|
|
9436
9647
|
// src/cli/cmd/run/index.ts
|
|
9648
|
+
var __dirname = path13.default.dirname(_url.fileURLToPath.call(void 0, import.meta.url));
|
|
9649
|
+
function playSound(type) {
|
|
9650
|
+
const platform = _os2.default.platform();
|
|
9651
|
+
return new Promise((resolve) => {
|
|
9652
|
+
const assetDir = path13.default.join(__dirname, "../assets");
|
|
9653
|
+
const soundFiles = [path13.default.join(assetDir, `${type}.mp3`)];
|
|
9654
|
+
let command = "";
|
|
9655
|
+
if (platform === "linux") {
|
|
9656
|
+
command = soundFiles.map(
|
|
9657
|
+
(file) => `mpg123 -q "${file}" 2>/dev/null || aplay "${file}" 2>/dev/null`
|
|
9658
|
+
).join(" || ");
|
|
9659
|
+
} else if (platform === "darwin") {
|
|
9660
|
+
command = soundFiles.map((file) => `afplay "${file}"`).join(" || ");
|
|
9661
|
+
} else if (platform === "win32") {
|
|
9662
|
+
command = `powershell -c "try { (New-Object Media.SoundPlayer '${soundFiles[1]}').PlaySync() } catch { Start-Process -FilePath '${soundFiles[0]}' -WindowStyle Hidden -Wait }"`;
|
|
9663
|
+
} else {
|
|
9664
|
+
command = soundFiles.map(
|
|
9665
|
+
(file) => `aplay "${file}" 2>/dev/null || afplay "${file}" 2>/dev/null`
|
|
9666
|
+
).join(" || ");
|
|
9667
|
+
}
|
|
9668
|
+
_child_process.exec.call(void 0, command, () => {
|
|
9669
|
+
resolve();
|
|
9670
|
+
});
|
|
9671
|
+
setTimeout(resolve, 3e3);
|
|
9672
|
+
});
|
|
9673
|
+
}
|
|
9437
9674
|
var run_default = new (0, _interactivecommander.Command)().command("run").description("Run Lingo.dev localization engine").helpOption("-h, --help", "Show help").option(
|
|
9438
9675
|
"--source-locale <source-locale>",
|
|
9439
9676
|
"Locale to use as source locale. Defaults to i18n.json locale.source"
|
|
@@ -9473,6 +9710,9 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
|
|
|
9473
9710
|
"--debounce <milliseconds>",
|
|
9474
9711
|
"Debounce delay in milliseconds for watch mode (default: 5000ms)",
|
|
9475
9712
|
(val) => parseInt(val)
|
|
9713
|
+
).option(
|
|
9714
|
+
"--sound",
|
|
9715
|
+
"Play sound on completion, partially completion and failed of the task"
|
|
9476
9716
|
).action(async (args) => {
|
|
9477
9717
|
let authId = null;
|
|
9478
9718
|
try {
|
|
@@ -9502,6 +9742,9 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
|
|
|
9502
9742
|
await renderSpacer();
|
|
9503
9743
|
await renderSummary(ctx.results);
|
|
9504
9744
|
await renderSpacer();
|
|
9745
|
+
if (ctx.flags.sound) {
|
|
9746
|
+
await playSound("success");
|
|
9747
|
+
}
|
|
9505
9748
|
if (ctx.flags.watch) {
|
|
9506
9749
|
await watch2(ctx);
|
|
9507
9750
|
}
|
|
@@ -9511,6 +9754,9 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
|
|
|
9511
9754
|
});
|
|
9512
9755
|
} catch (error) {
|
|
9513
9756
|
await trackEvent(authId || "unknown", "cmd.run.error", {});
|
|
9757
|
+
if (args.sound) {
|
|
9758
|
+
await playSound("failure");
|
|
9759
|
+
}
|
|
9514
9760
|
throw error;
|
|
9515
9761
|
}
|
|
9516
9762
|
});
|
|
@@ -9586,7 +9832,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
9586
9832
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
9587
9833
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
9588
9834
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
9589
|
-
_optionalChain([this, 'access',
|
|
9835
|
+
_optionalChain([this, 'access', _297 => _297.platformKit, 'optionalAccess', _298 => _298.gitConfig, 'call', _299 => _299()]);
|
|
9590
9836
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
9591
9837
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
9592
9838
|
if (!processOwnCommits) {
|
|
@@ -9618,7 +9864,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
9618
9864
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
9619
9865
|
var PullRequestFlow = class extends InBranchFlow {
|
|
9620
9866
|
async preRun() {
|
|
9621
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
9867
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _300 => _300()]);
|
|
9622
9868
|
if (!canContinue) {
|
|
9623
9869
|
return false;
|
|
9624
9870
|
}
|
|
@@ -9881,10 +10127,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
9881
10127
|
repo_slug: this.platformConfig.repositoryName,
|
|
9882
10128
|
state: "OPEN"
|
|
9883
10129
|
}).then(({ data: { values } }) => {
|
|
9884
|
-
return _optionalChain([values, 'optionalAccess',
|
|
9885
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
10130
|
+
return _optionalChain([values, 'optionalAccess', _301 => _301.find, 'call', _302 => _302(
|
|
10131
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _303 => _303.branch, 'optionalAccess', _304 => _304.name]) === branch && _optionalChain([destination, 'optionalAccess', _305 => _305.branch, 'optionalAccess', _306 => _306.name]) === this.platformConfig.baseBranchName
|
|
9886
10132
|
)]);
|
|
9887
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
10133
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _307 => _307.id]));
|
|
9888
10134
|
}
|
|
9889
10135
|
async closePullRequest({ pullRequestNumber }) {
|
|
9890
10136
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -9980,7 +10226,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
9980
10226
|
repo: this.platformConfig.repositoryName,
|
|
9981
10227
|
base: this.platformConfig.baseBranchName,
|
|
9982
10228
|
state: "open"
|
|
9983
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
10229
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _308 => _308.number]));
|
|
9984
10230
|
}
|
|
9985
10231
|
async closePullRequest({ pullRequestNumber }) {
|
|
9986
10232
|
await this.octokit.rest.pulls.update({
|
|
@@ -10107,7 +10353,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
10107
10353
|
sourceBranch: branch,
|
|
10108
10354
|
state: "opened"
|
|
10109
10355
|
});
|
|
10110
|
-
return _optionalChain([mergeRequests, 'access',
|
|
10356
|
+
return _optionalChain([mergeRequests, 'access', _309 => _309[0], 'optionalAccess', _310 => _310.iid]);
|
|
10111
10357
|
}
|
|
10112
10358
|
async closePullRequest({
|
|
10113
10359
|
pullRequestNumber
|
|
@@ -10197,7 +10443,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
10197
10443
|
}
|
|
10198
10444
|
const env = {
|
|
10199
10445
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
10200
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
10446
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _311 => _311.pullRequest, 'optionalAccess', _312 => _312.toString, 'call', _313 => _313()]) || "false",
|
|
10201
10447
|
...options.commitMessage && {
|
|
10202
10448
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
10203
10449
|
},
|
|
@@ -10217,7 +10463,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
10217
10463
|
const { isPullRequestMode } = platformKit.config;
|
|
10218
10464
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
10219
10465
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
10220
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
10466
|
+
const canRun = await _optionalChain([flow, 'access', _314 => _314.preRun, 'optionalCall', _315 => _315()]);
|
|
10221
10467
|
if (canRun === false) {
|
|
10222
10468
|
return;
|
|
10223
10469
|
}
|
|
@@ -10227,7 +10473,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
10227
10473
|
if (!hasChanges) {
|
|
10228
10474
|
return;
|
|
10229
10475
|
}
|
|
10230
|
-
await _optionalChain([flow, 'access',
|
|
10476
|
+
await _optionalChain([flow, 'access', _316 => _316.postRun, 'optionalCall', _317 => _317()]);
|
|
10231
10477
|
});
|
|
10232
10478
|
function parseBooleanArg(val) {
|
|
10233
10479
|
if (val === true) return true;
|
|
@@ -10264,8 +10510,8 @@ function exitGracefully(elapsedMs = 0) {
|
|
|
10264
10510
|
}
|
|
10265
10511
|
}
|
|
10266
10512
|
function checkForPendingOperations() {
|
|
10267
|
-
const activeHandles = _optionalChain([process, 'access',
|
|
10268
|
-
const activeRequests = _optionalChain([process, 'access',
|
|
10513
|
+
const activeHandles = _optionalChain([process, 'access', _318 => _318._getActiveHandles, 'optionalCall', _319 => _319()]) || [];
|
|
10514
|
+
const activeRequests = _optionalChain([process, 'access', _320 => _320._getActiveRequests, 'optionalCall', _321 => _321()]) || [];
|
|
10269
10515
|
const nonStandardHandles = activeHandles.filter((handle) => {
|
|
10270
10516
|
if (handle === process.stdin || handle === process.stdout || handle === process.stderr) {
|
|
10271
10517
|
return false;
|
|
@@ -10331,17 +10577,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
10331
10577
|
flags
|
|
10332
10578
|
});
|
|
10333
10579
|
let buckets = getBuckets(i18nConfig);
|
|
10334
|
-
if (_optionalChain([flags, 'access',
|
|
10580
|
+
if (_optionalChain([flags, 'access', _322 => _322.bucket, 'optionalAccess', _323 => _323.length])) {
|
|
10335
10581
|
buckets = buckets.filter(
|
|
10336
10582
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
10337
10583
|
);
|
|
10338
10584
|
}
|
|
10339
10585
|
ora.succeed("Buckets retrieved");
|
|
10340
|
-
if (_optionalChain([flags, 'access',
|
|
10586
|
+
if (_optionalChain([flags, 'access', _324 => _324.file, 'optionalAccess', _325 => _325.length])) {
|
|
10341
10587
|
buckets = buckets.map((bucket) => {
|
|
10342
10588
|
const paths = bucket.paths.filter(
|
|
10343
|
-
(
|
|
10344
|
-
(file) => _optionalChain([
|
|
10589
|
+
(path18) => flags.file.find(
|
|
10590
|
+
(file) => _optionalChain([path18, 'access', _326 => _326.pathPattern, 'optionalAccess', _327 => _327.includes, 'call', _328 => _328(file)]) || _optionalChain([path18, 'access', _329 => _329.pathPattern, 'optionalAccess', _330 => _330.match, 'call', _331 => _331(file)]) || minimatch(path18.pathPattern, file)
|
|
10345
10591
|
)
|
|
10346
10592
|
);
|
|
10347
10593
|
return { ...bucket, paths };
|
|
@@ -10355,13 +10601,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
10355
10601
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
10356
10602
|
buckets.map((bucket) => {
|
|
10357
10603
|
ora.info(` ${bucket.type}:`);
|
|
10358
|
-
bucket.paths.forEach((
|
|
10359
|
-
ora.info(` - ${
|
|
10604
|
+
bucket.paths.forEach((path18) => {
|
|
10605
|
+
ora.info(` - ${path18.pathPattern}`);
|
|
10360
10606
|
});
|
|
10361
10607
|
});
|
|
10362
10608
|
}
|
|
10363
10609
|
}
|
|
10364
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
10610
|
+
const targetLocales = _optionalChain([flags, 'access', _332 => _332.locale, 'optionalAccess', _333 => _333.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
10365
10611
|
let totalSourceKeyCount = 0;
|
|
10366
10612
|
let uniqueKeysToTranslate = 0;
|
|
10367
10613
|
let totalExistingTranslations = 0;
|
|
@@ -10640,10 +10886,10 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
10640
10886
|
if (flags.confirm && Object.keys(fileStats).length > 0) {
|
|
10641
10887
|
console.log(_chalk2.default.bold(`
|
|
10642
10888
|
\u{1F4D1} BREAKDOWN BY FILE:`));
|
|
10643
|
-
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([
|
|
10889
|
+
Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path18, stats]) => {
|
|
10644
10890
|
if (stats.sourceKeys === 0) return;
|
|
10645
10891
|
console.log(_chalk2.default.bold(`
|
|
10646
|
-
\u2022 ${
|
|
10892
|
+
\u2022 ${path18}:`));
|
|
10647
10893
|
console.log(
|
|
10648
10894
|
` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`
|
|
10649
10895
|
);
|
|
@@ -10766,12 +11012,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
10766
11012
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
10767
11013
|
docUrl: "bucketNotFound"
|
|
10768
11014
|
});
|
|
10769
|
-
} else if (_optionalChain([flags, 'access',
|
|
11015
|
+
} else if (_optionalChain([flags, 'access', _334 => _334.locale, 'optionalAccess', _335 => _335.some, 'call', _336 => _336((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
10770
11016
|
throw new CLIError({
|
|
10771
11017
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
10772
11018
|
docUrl: "localeTargetNotFound"
|
|
10773
11019
|
});
|
|
10774
|
-
} else if (_optionalChain([flags, 'access',
|
|
11020
|
+
} else if (_optionalChain([flags, 'access', _337 => _337.bucket, 'optionalAccess', _338 => _338.some, 'call', _339 => _339(
|
|
10775
11021
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
10776
11022
|
)])) {
|
|
10777
11023
|
throw new CLIError({
|
|
@@ -10863,7 +11109,7 @@ async function renderHero2() {
|
|
|
10863
11109
|
// package.json
|
|
10864
11110
|
var package_default = {
|
|
10865
11111
|
name: "lingo.dev",
|
|
10866
|
-
version: "0.111.
|
|
11112
|
+
version: "0.111.5",
|
|
10867
11113
|
description: "Lingo.dev CLI",
|
|
10868
11114
|
private: false,
|
|
10869
11115
|
publishConfig: {
|
|
@@ -10961,7 +11207,8 @@ var package_default = {
|
|
|
10961
11207
|
},
|
|
10962
11208
|
files: [
|
|
10963
11209
|
"bin",
|
|
10964
|
-
"build"
|
|
11210
|
+
"build",
|
|
11211
|
+
"assets"
|
|
10965
11212
|
],
|
|
10966
11213
|
scripts: {
|
|
10967
11214
|
"lingo.dev": "node --inspect=9229 ./bin/cli.mjs",
|
|
@@ -11140,7 +11387,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
|
|
|
11140
11387
|
if (options.file && options.file.length) {
|
|
11141
11388
|
buckets = buckets.map((bucket) => {
|
|
11142
11389
|
const paths = bucket.paths.filter(
|
|
11143
|
-
(bucketPath) => _optionalChain([options, 'access',
|
|
11390
|
+
(bucketPath) => _optionalChain([options, 'access', _340 => _340.file, 'optionalAccess', _341 => _341.some, 'call', _342 => _342((f) => bucketPath.pathPattern.includes(f))])
|
|
11144
11391
|
);
|
|
11145
11392
|
return { ...bucket, paths };
|
|
11146
11393
|
}).filter((bucket) => bucket.paths.length > 0);
|