lingo.dev 0.74.3 → 0.74.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cli.cjs +35 -39
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +22 -26
- package/build/cli.mjs.map +1 -1
- package/build/sdk.cjs +2 -7
- package/build/sdk.cjs.map +1 -1
- package/build/sdk.mjs +2 -7
- package/build/sdk.mjs.map +1 -1
- package/build/spec.cjs +2 -46
- package/build/spec.cjs.map +1 -1
- package/build/spec.mjs +2 -46
- package/build/spec.mjs.map +1 -1
- package/package.json +1 -1
- package/build/chunk-B6KMMXCA.mjs +0 -494
- package/build/chunk-B6KMMXCA.mjs.map +0 -1
- package/build/chunk-JZIJPDHI.cjs +0 -331
- package/build/chunk-JZIJPDHI.cjs.map +0 -1
- package/build/chunk-U3YIG2HS.cjs +0 -494
- package/build/chunk-U3YIG2HS.cjs.map +0 -1
- package/build/chunk-XU7ZJKQ2.mjs +0 -331
- package/build/chunk-XU7ZJKQ2.mjs.map +0 -1
package/build/cli.cjs
CHANGED
|
@@ -1,18 +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; }
|
|
2
|
-
|
|
3
|
-
var _chunkJZIJPDHIcjs = require('./chunk-JZIJPDHI.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _chunkU3YIG2HScjs = require('./chunk-U3YIG2HS.cjs');
|
|
14
|
-
|
|
15
|
-
// src/cli/index.ts
|
|
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; }// src/cli/index.ts
|
|
16
2
|
var _dotenv = require('dotenv'); var _dotenv2 = _interopRequireDefault(_dotenv);
|
|
17
3
|
var _interactivecommander = require('interactive-commander');
|
|
18
4
|
var _figlet = require('figlet'); var _figlet2 = _interopRequireDefault(_figlet);
|
|
@@ -250,6 +236,7 @@ async function waitForApiKey(cb) {
|
|
|
250
236
|
var _lodash = require('lodash'); var _lodash2 = _interopRequireDefault(_lodash);
|
|
251
237
|
|
|
252
238
|
|
|
239
|
+
var __spec = require('@lingo.dev/_spec');
|
|
253
240
|
function getConfig(resave = true) {
|
|
254
241
|
const configFilePath = _getConfigFilePath();
|
|
255
242
|
const configFileExists = _fs2.default.existsSync(configFilePath);
|
|
@@ -258,7 +245,7 @@ function getConfig(resave = true) {
|
|
|
258
245
|
}
|
|
259
246
|
const fileContents = _fs2.default.readFileSync(configFilePath, "utf8");
|
|
260
247
|
const rawConfig = JSON.parse(fileContents);
|
|
261
|
-
const result =
|
|
248
|
+
const result = __spec.parseI18nConfig.call(void 0, rawConfig);
|
|
262
249
|
const didConfigChange = !_lodash2.default.isEqual(rawConfig, result);
|
|
263
250
|
if (resave && didConfigChange) {
|
|
264
251
|
saveConfig(result);
|
|
@@ -277,6 +264,7 @@ function _getConfigFilePath() {
|
|
|
277
264
|
|
|
278
265
|
// src/cli/cmd/init.ts
|
|
279
266
|
|
|
267
|
+
|
|
280
268
|
var _child_process = require('child_process');
|
|
281
269
|
|
|
282
270
|
var _prompts = require('@inquirer/prompts');
|
|
@@ -297,7 +285,7 @@ Do you need support for ${value} ${option}? Type "help" and we will.`
|
|
|
297
285
|
var init_default = new (0, _interactivecommander.InteractiveCommand)().command("init").description("Initialize Lingo.dev project").helpOption("-h, --help", "Show help").addOption(new (0, _interactivecommander.InteractiveOption)("-f --force", "Overwrite existing config").prompt(void 0).default(false)).addOption(
|
|
298
286
|
new (0, _interactivecommander.InteractiveOption)("-s --source <locale>", "Source locale").argParser((value) => {
|
|
299
287
|
try {
|
|
300
|
-
|
|
288
|
+
__spec.resolveLocaleCode.call(void 0, value);
|
|
301
289
|
} catch (e) {
|
|
302
290
|
throwHelpError("locale", value);
|
|
303
291
|
}
|
|
@@ -308,7 +296,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
308
296
|
const values = value.includes(",") ? value.split(",") : value.split(" ");
|
|
309
297
|
values.forEach((value2) => {
|
|
310
298
|
try {
|
|
311
|
-
|
|
299
|
+
__spec.resolveLocaleCode.call(void 0, value2);
|
|
312
300
|
} catch (e) {
|
|
313
301
|
throwHelpError("locale", value2);
|
|
314
302
|
}
|
|
@@ -317,7 +305,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
317
305
|
}).default("es")
|
|
318
306
|
).addOption(
|
|
319
307
|
new (0, _interactivecommander.InteractiveOption)("-b, --bucket <type>", "Type of bucket").argParser((value) => {
|
|
320
|
-
if (!
|
|
308
|
+
if (!__spec.bucketTypes.includes(value)) {
|
|
321
309
|
throwHelpError("bucket format", value);
|
|
322
310
|
}
|
|
323
311
|
return value;
|
|
@@ -345,7 +333,7 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
345
333
|
spinner.fail("Lingo.dev project already initialized");
|
|
346
334
|
return process.exit(1);
|
|
347
335
|
}
|
|
348
|
-
const newConfig = _lodash2.default.cloneDeep(
|
|
336
|
+
const newConfig = _lodash2.default.cloneDeep(__spec.defaultConfig);
|
|
349
337
|
newConfig.locale.source = options.source;
|
|
350
338
|
newConfig.locale.targets = options.targets;
|
|
351
339
|
newConfig.buckets = {
|
|
@@ -404,9 +392,10 @@ var init_default = new (0, _interactivecommander.InteractiveCommand)().command("
|
|
|
404
392
|
|
|
405
393
|
|
|
406
394
|
|
|
395
|
+
|
|
407
396
|
var config_default = new (0, _interactivecommander.Command)().command("config").description("Print out the current configuration").helpOption("-h, --help", "Show help").action(async (options) => {
|
|
408
397
|
const fileConfig = loadReplexicaFileConfig();
|
|
409
|
-
const config = _lodash2.default.merge({},
|
|
398
|
+
const config = _lodash2.default.merge({}, __spec.defaultConfig, fileConfig);
|
|
410
399
|
console.log(JSON.stringify(config, null, 2));
|
|
411
400
|
});
|
|
412
401
|
function loadReplexicaFileConfig() {
|
|
@@ -423,6 +412,7 @@ function loadReplexicaFileConfig() {
|
|
|
423
412
|
// src/cli/cmd/show/locale.ts
|
|
424
413
|
|
|
425
414
|
|
|
415
|
+
|
|
426
416
|
var locale_default = new (0, _interactivecommander.Command)().command("locale").description("Print out the list of locales").helpOption("-h, --help", "Show help").argument("<type>", 'Type of locales to show, either "sources" or "targets"').action(async (type) => {
|
|
427
417
|
const ora = _ora2.default.call(void 0, );
|
|
428
418
|
try {
|
|
@@ -433,10 +423,10 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
|
|
|
433
423
|
docUrl: "invalidType"
|
|
434
424
|
});
|
|
435
425
|
case "sources":
|
|
436
|
-
|
|
426
|
+
__spec.localeCodes.forEach((locale) => console.log(locale));
|
|
437
427
|
break;
|
|
438
428
|
case "targets":
|
|
439
|
-
|
|
429
|
+
__spec.localeCodes.forEach((locale) => console.log(locale));
|
|
440
430
|
break;
|
|
441
431
|
}
|
|
442
432
|
} catch (error) {
|
|
@@ -453,6 +443,7 @@ var locale_default = new (0, _interactivecommander.Command)().command("locale").
|
|
|
453
443
|
|
|
454
444
|
|
|
455
445
|
var _glob = require('glob'); var glob = _interopRequireWildcard(_glob);
|
|
446
|
+
|
|
456
447
|
function getBuckets(i18nConfig) {
|
|
457
448
|
const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
|
|
458
449
|
const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
|
|
@@ -466,7 +457,7 @@ function getBuckets(i18nConfig) {
|
|
|
466
457
|
}
|
|
467
458
|
function extractPathPatterns(sourceLocale, include, exclude) {
|
|
468
459
|
const includedPatterns = include.flatMap(
|
|
469
|
-
(pattern) => expandPlaceholderedGlob(pattern.path,
|
|
460
|
+
(pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverridenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
|
|
470
461
|
(pathPattern) => ({
|
|
471
462
|
pathPattern,
|
|
472
463
|
delimiter: pattern.delimiter
|
|
@@ -474,7 +465,7 @@ function extractPathPatterns(sourceLocale, include, exclude) {
|
|
|
474
465
|
)
|
|
475
466
|
);
|
|
476
467
|
const excludedPatterns = _optionalChain([exclude, 'optionalAccess', _31 => _31.flatMap, 'call', _32 => _32(
|
|
477
|
-
(pattern) => expandPlaceholderedGlob(pattern.path,
|
|
468
|
+
(pattern) => expandPlaceholderedGlob(pattern.path, __spec.resolveOverridenLocale.call(void 0, sourceLocale, pattern.delimiter)).map(
|
|
478
469
|
(pathPattern) => ({
|
|
479
470
|
pathPattern,
|
|
480
471
|
delimiter: pattern.delimiter
|
|
@@ -530,6 +521,7 @@ function resolveBucketItem(bucketItem) {
|
|
|
530
521
|
}
|
|
531
522
|
|
|
532
523
|
// src/cli/cmd/show/files.ts
|
|
524
|
+
|
|
533
525
|
var files_default = new (0, _interactivecommander.Command)().command("files").description("Print out the list of files managed by Lingo.dev").option("--source", "Only show source files").option("--target", "Only show target files").helpOption("-h, --help", "Show help").action(async (type) => {
|
|
534
526
|
const ora = _ora2.default.call(void 0, );
|
|
535
527
|
try {
|
|
@@ -544,10 +536,10 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
|
|
|
544
536
|
const buckets = getBuckets(i18nConfig);
|
|
545
537
|
for (const bucket of buckets) {
|
|
546
538
|
for (const bucketConfig of bucket.config) {
|
|
547
|
-
const sourceLocale =
|
|
539
|
+
const sourceLocale = __spec.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
548
540
|
const sourcePath = bucketConfig.pathPattern.replace(/\[locale\]/g, sourceLocale);
|
|
549
541
|
const targetPaths = i18nConfig.locale.targets.map((_targetLocale) => {
|
|
550
|
-
const targetLocale =
|
|
542
|
+
const targetLocale = __spec.resolveOverridenLocale.call(void 0, _targetLocale, bucketConfig.delimiter);
|
|
551
543
|
return bucketConfig.pathPattern.replace(/\[locale\]/g, targetLocale);
|
|
552
544
|
});
|
|
553
545
|
const result = [];
|
|
@@ -580,6 +572,8 @@ var show_default = new (0, _interactivecommander.Command)().command("show").desc
|
|
|
580
572
|
|
|
581
573
|
// src/cli/cmd/i18n.ts
|
|
582
574
|
|
|
575
|
+
var __sdk = require('@lingo.dev/_sdk');
|
|
576
|
+
|
|
583
577
|
|
|
584
578
|
|
|
585
579
|
|
|
@@ -2672,7 +2666,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2672
2666
|
ora.start("Creating i18n.lock...");
|
|
2673
2667
|
for (const bucket of buckets) {
|
|
2674
2668
|
for (const bucketConfig of bucket.config) {
|
|
2675
|
-
const sourceLocale =
|
|
2669
|
+
const sourceLocale = __spec.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
2676
2670
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
|
|
2677
2671
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
2678
2672
|
await bucketLoader.init();
|
|
@@ -2693,7 +2687,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2693
2687
|
cacheOra.info(`Processing bucket: ${bucket.type}`);
|
|
2694
2688
|
for (const bucketConfig of bucket.config) {
|
|
2695
2689
|
const bucketOra = ora.info(`Processing path: ${bucketConfig.pathPattern}`);
|
|
2696
|
-
const sourceLocale =
|
|
2690
|
+
const sourceLocale = __spec.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
2697
2691
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
|
|
2698
2692
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
2699
2693
|
await bucketLoader.init();
|
|
@@ -2728,7 +2722,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2728
2722
|
let requiresUpdate = false;
|
|
2729
2723
|
for (const bucket of buckets) {
|
|
2730
2724
|
for (const bucketConfig of bucket.config) {
|
|
2731
|
-
const sourceLocale =
|
|
2725
|
+
const sourceLocale = __spec.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
2732
2726
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
|
|
2733
2727
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
2734
2728
|
await bucketLoader.init();
|
|
@@ -2754,13 +2748,13 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
2754
2748
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
2755
2749
|
for (const bucketConfig of bucket.config) {
|
|
2756
2750
|
const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${bucketConfig.pathPattern}`);
|
|
2757
|
-
const sourceLocale =
|
|
2751
|
+
const sourceLocale = __spec.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
2758
2752
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
|
|
2759
2753
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
2760
2754
|
await bucketLoader.init();
|
|
2761
2755
|
let sourceData = await bucketLoader.pull(sourceLocale);
|
|
2762
2756
|
for (const _targetLocale of targetLocales) {
|
|
2763
|
-
const targetLocale =
|
|
2757
|
+
const targetLocale = __spec.resolveOverridenLocale.call(void 0, _targetLocale, bucketConfig.delimiter);
|
|
2764
2758
|
try {
|
|
2765
2759
|
bucketOra.start(`[${sourceLocale} -> ${targetLocale}] (0%) Localization in progress...`);
|
|
2766
2760
|
sourceData = await bucketLoader.pull(sourceLocale);
|
|
@@ -2885,7 +2879,7 @@ async function retryWithExponentialBackoff(operation, maxAttempts, baseDelay = 1
|
|
|
2885
2879
|
throw new Error("Unreachable code");
|
|
2886
2880
|
}
|
|
2887
2881
|
function createLocalizationEngineConnection(params) {
|
|
2888
|
-
const replexicaEngine = new (0,
|
|
2882
|
+
const replexicaEngine = new (0, __sdk.ReplexicaEngine)({
|
|
2889
2883
|
apiKey: params.apiKey,
|
|
2890
2884
|
apiUrl: params.apiUrl
|
|
2891
2885
|
});
|
|
@@ -2908,8 +2902,8 @@ function createLocalizationEngineConnection(params) {
|
|
|
2908
2902
|
function parseFlags(options) {
|
|
2909
2903
|
return _zod2.default.object({
|
|
2910
2904
|
apiKey: _zod2.default.string().optional(),
|
|
2911
|
-
locale: _zod2.default.array(
|
|
2912
|
-
bucket: _zod2.default.array(
|
|
2905
|
+
locale: _zod2.default.array(__spec.localeCodeSchema).optional(),
|
|
2906
|
+
bucket: _zod2.default.array(__spec.bucketTypeSchema).optional(),
|
|
2913
2907
|
force: _zod2.default.boolean().optional(),
|
|
2914
2908
|
frozen: _zod2.default.boolean().optional(),
|
|
2915
2909
|
verbose: _zod2.default.boolean().optional(),
|
|
@@ -3062,6 +3056,7 @@ Editing value for: ${_chalk2.default.cyan(key)}`);
|
|
|
3062
3056
|
|
|
3063
3057
|
|
|
3064
3058
|
|
|
3059
|
+
|
|
3065
3060
|
var lockfile_default = new (0, _interactivecommander.Command)().command("lockfile").description("Create a lockfile if it does not exist").helpOption("-h, --help", "Show help").option("-f, --force", "Force create a lockfile").action(async (options) => {
|
|
3066
3061
|
const flags = flagsSchema.parse(options);
|
|
3067
3062
|
const ora = _ora2.default.call(void 0, );
|
|
@@ -3073,7 +3068,7 @@ var lockfile_default = new (0, _interactivecommander.Command)().command("lockfil
|
|
|
3073
3068
|
const buckets = getBuckets(i18nConfig);
|
|
3074
3069
|
for (const bucket of buckets) {
|
|
3075
3070
|
for (const bucketConfig of bucket.config) {
|
|
3076
|
-
const sourceLocale =
|
|
3071
|
+
const sourceLocale = __spec.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
3077
3072
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
|
|
3078
3073
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3079
3074
|
const sourceData = await bucketLoader.pull(sourceLocale);
|
|
@@ -3091,6 +3086,7 @@ var flagsSchema = _zod2.default.object({
|
|
|
3091
3086
|
|
|
3092
3087
|
|
|
3093
3088
|
|
|
3089
|
+
|
|
3094
3090
|
var cleanup_default = new (0, _interactivecommander.Command)().command("cleanup").description("Remove keys from target files that do not exist in the source file").helpOption("-h, --help", "Show help").option("--locale <locale>", "Specific locale to cleanup").option("--bucket <bucket>", "Specific bucket to cleanup").option("--dry-run", "Show what would be removed without making changes").option("--verbose", "Show verbose output").action(async function(options) {
|
|
3095
3091
|
const ora = _ora2.default.call(void 0, );
|
|
3096
3092
|
const results = [];
|
|
@@ -3108,14 +3104,14 @@ var cleanup_default = new (0, _interactivecommander.Command)().command("cleanup"
|
|
|
3108
3104
|
console.log();
|
|
3109
3105
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
3110
3106
|
for (const bucketConfig of bucket.config) {
|
|
3111
|
-
const sourceLocale =
|
|
3107
|
+
const sourceLocale = __spec.resolveOverridenLocale.call(void 0, i18nConfig.locale.source, bucketConfig.delimiter);
|
|
3112
3108
|
const bucketOra = _ora2.default.call(void 0, { indent: 2 }).info(`Processing path: ${bucketConfig.pathPattern}`);
|
|
3113
3109
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern);
|
|
3114
3110
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3115
3111
|
const sourceData = await bucketLoader.pull(sourceLocale);
|
|
3116
3112
|
const sourceKeys = Object.keys(sourceData);
|
|
3117
3113
|
for (const _targetLocale of targetLocales) {
|
|
3118
|
-
const targetLocale =
|
|
3114
|
+
const targetLocale = __spec.resolveOverridenLocale.call(void 0, _targetLocale, bucketConfig.delimiter);
|
|
3119
3115
|
try {
|
|
3120
3116
|
const targetData = await bucketLoader.pull(targetLocale);
|
|
3121
3117
|
const targetKeys = Object.keys(targetData);
|
|
@@ -3180,7 +3176,7 @@ function displaySummary(results) {
|
|
|
3180
3176
|
// package.json
|
|
3181
3177
|
var package_default = {
|
|
3182
3178
|
name: "lingo.dev",
|
|
3183
|
-
version: "0.74.
|
|
3179
|
+
version: "0.74.4",
|
|
3184
3180
|
description: "Lingo.dev CLI",
|
|
3185
3181
|
private: false,
|
|
3186
3182
|
publishConfig: {
|