lingo.dev 0.79.1 → 0.79.3
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 +162 -134
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +120 -92
- package/build/cli.mjs.map +1 -1
- package/package.json +3 -3
package/build/cli.mjs
CHANGED
|
@@ -854,10 +854,14 @@ function getBuckets(i18nConfig) {
|
|
|
854
854
|
const result = Object.entries(i18nConfig.buckets).map(([bucketType, bucketEntry]) => {
|
|
855
855
|
const includeItems = bucketEntry.include.map((item) => resolveBucketItem(item));
|
|
856
856
|
const excludeItems = bucketEntry.exclude?.map((item) => resolveBucketItem(item));
|
|
857
|
-
|
|
857
|
+
const config = {
|
|
858
858
|
type: bucketType,
|
|
859
|
-
|
|
859
|
+
paths: extractPathPatterns(i18nConfig.locale.source, includeItems, excludeItems)
|
|
860
860
|
};
|
|
861
|
+
if (bucketEntry.injectLocale) {
|
|
862
|
+
config.injectLocale = bucketEntry.injectLocale;
|
|
863
|
+
}
|
|
864
|
+
return config;
|
|
861
865
|
});
|
|
862
866
|
return result;
|
|
863
867
|
}
|
|
@@ -947,7 +951,7 @@ var files_default = new Command4().command("files").description("Print out the l
|
|
|
947
951
|
}
|
|
948
952
|
const buckets = getBuckets(i18nConfig);
|
|
949
953
|
for (const bucket of buckets) {
|
|
950
|
-
for (const bucketConfig of bucket.
|
|
954
|
+
for (const bucketConfig of bucket.paths) {
|
|
951
955
|
const sourceLocale = resolveOverriddenLocale2(i18nConfig.locale.source, bucketConfig.delimiter);
|
|
952
956
|
const sourcePath = bucketConfig.pathPattern.replace(/\[locale\]/g, sourceLocale);
|
|
953
957
|
const targetPaths = i18nConfig.locale.targets.map((_targetLocale) => {
|
|
@@ -987,7 +991,7 @@ import { bucketTypeSchema, localeCodeSchema, resolveOverriddenLocale as resolveO
|
|
|
987
991
|
import { LingoDotDevEngine } from "@lingo.dev/_sdk";
|
|
988
992
|
import { Command as Command6 } from "interactive-commander";
|
|
989
993
|
import Z4 from "zod";
|
|
990
|
-
import
|
|
994
|
+
import _20 from "lodash";
|
|
991
995
|
import Ora5 from "ora";
|
|
992
996
|
|
|
993
997
|
// src/cli/loaders/_utils.ts
|
|
@@ -1194,7 +1198,7 @@ function createTextFileLoader(pathPattern) {
|
|
|
1194
1198
|
const trimmedResult = result.trim();
|
|
1195
1199
|
return trimmedResult;
|
|
1196
1200
|
},
|
|
1197
|
-
async push(locale, data,
|
|
1201
|
+
async push(locale, data, _22, originalLocale) {
|
|
1198
1202
|
const draftPath = pathPattern.replaceAll("[locale]", locale);
|
|
1199
1203
|
const finalPath = path10.resolve(draftPath);
|
|
1200
1204
|
const dirPath = path10.dirname(finalPath);
|
|
@@ -1636,7 +1640,7 @@ function createPropertiesLoader() {
|
|
|
1636
1640
|
return result;
|
|
1637
1641
|
},
|
|
1638
1642
|
async push(locale, payload) {
|
|
1639
|
-
const result = Object.entries(payload).filter(([
|
|
1643
|
+
const result = Object.entries(payload).filter(([_22, value]) => value != null).map(([key, value]) => `${key}=${value}`).join("\n");
|
|
1640
1644
|
return result;
|
|
1641
1645
|
}
|
|
1642
1646
|
});
|
|
@@ -1871,13 +1875,17 @@ async function installDependencies() {
|
|
|
1871
1875
|
}
|
|
1872
1876
|
async function getPackageManager() {
|
|
1873
1877
|
const yarnLockfile = path11.resolve(process.cwd(), "yarn.lock");
|
|
1874
|
-
const pnpmLockfile = path11.resolve(process.cwd(), "pnpm-lock.yaml");
|
|
1875
1878
|
if (fs9.existsSync(yarnLockfile)) {
|
|
1876
1879
|
return "yarn";
|
|
1877
1880
|
}
|
|
1881
|
+
const pnpmLockfile = path11.resolve(process.cwd(), "pnpm-lock.yaml");
|
|
1878
1882
|
if (fs9.existsSync(pnpmLockfile)) {
|
|
1879
1883
|
return "pnpm";
|
|
1880
1884
|
}
|
|
1885
|
+
const bunLockfile = path11.resolve(process.cwd(), "bun.lock");
|
|
1886
|
+
if (fs9.existsSync(bunLockfile)) {
|
|
1887
|
+
return "bun";
|
|
1888
|
+
}
|
|
1881
1889
|
return "npm";
|
|
1882
1890
|
}
|
|
1883
1891
|
|
|
@@ -1903,10 +1911,10 @@ function createUnlocalizableLoader(isCacheRestore = false, returnUnlocalizedKeys
|
|
|
1903
1911
|
}
|
|
1904
1912
|
}
|
|
1905
1913
|
return false;
|
|
1906
|
-
}).map(([key,
|
|
1907
|
-
const result = _10.omitBy(input2, (
|
|
1914
|
+
}).map(([key, _22]) => key);
|
|
1915
|
+
const result = _10.omitBy(input2, (_22, key) => passthroughKeys.includes(key));
|
|
1908
1916
|
if (returnUnlocalizedKeys) {
|
|
1909
|
-
result.unlocalizable = _10.omitBy(input2, (
|
|
1917
|
+
result.unlocalizable = _10.omitBy(input2, (_22, key) => !passthroughKeys.includes(key));
|
|
1910
1918
|
}
|
|
1911
1919
|
return result;
|
|
1912
1920
|
},
|
|
@@ -2989,6 +2997,34 @@ function parseVueFile(input2) {
|
|
|
2989
2997
|
return { before, after, i18n };
|
|
2990
2998
|
}
|
|
2991
2999
|
|
|
3000
|
+
// src/cli/loaders/inject-locale.ts
|
|
3001
|
+
import _18 from "lodash";
|
|
3002
|
+
function createInjectLocaleLoader(injectLocaleKeys) {
|
|
3003
|
+
return createLoader({
|
|
3004
|
+
async pull(locale, data) {
|
|
3005
|
+
if (!injectLocaleKeys) {
|
|
3006
|
+
return data;
|
|
3007
|
+
}
|
|
3008
|
+
const omitKeys = injectLocaleKeys.filter((key) => {
|
|
3009
|
+
return _18.get(data, key) === locale;
|
|
3010
|
+
});
|
|
3011
|
+
const result = _18.omit(data, omitKeys);
|
|
3012
|
+
return result;
|
|
3013
|
+
},
|
|
3014
|
+
async push(locale, data, originalInput, originalLocale) {
|
|
3015
|
+
if (!injectLocaleKeys) {
|
|
3016
|
+
return data;
|
|
3017
|
+
}
|
|
3018
|
+
injectLocaleKeys.forEach((key) => {
|
|
3019
|
+
if (_18.get(originalInput, key) === originalLocale) {
|
|
3020
|
+
_18.set(data, key, locale);
|
|
3021
|
+
}
|
|
3022
|
+
});
|
|
3023
|
+
return data;
|
|
3024
|
+
}
|
|
3025
|
+
});
|
|
3026
|
+
}
|
|
3027
|
+
|
|
2992
3028
|
// src/cli/loaders/index.ts
|
|
2993
3029
|
function createBucketLoader(bucketType, bucketPathPattern, options) {
|
|
2994
3030
|
switch (bucketType) {
|
|
@@ -3023,6 +3059,7 @@ function createBucketLoader(bucketType, bucketPathPattern, options) {
|
|
|
3023
3059
|
createTextFileLoader(bucketPathPattern),
|
|
3024
3060
|
createPrettierLoader({ parser: "json", bucketPathPattern }),
|
|
3025
3061
|
createJsonLoader(),
|
|
3062
|
+
createInjectLocaleLoader(options.injectLocale),
|
|
3026
3063
|
createFlatLoader(),
|
|
3027
3064
|
createSyncLoader(),
|
|
3028
3065
|
createUnlocalizableLoader(options.isCacheRestore, options.returnUnlocalizedKeys)
|
|
@@ -3168,7 +3205,7 @@ import path12 from "path";
|
|
|
3168
3205
|
import Z3 from "zod";
|
|
3169
3206
|
import YAML3 from "yaml";
|
|
3170
3207
|
import { MD5 } from "object-hash";
|
|
3171
|
-
import
|
|
3208
|
+
import _19 from "lodash";
|
|
3172
3209
|
function createLockfileHelper() {
|
|
3173
3210
|
return {
|
|
3174
3211
|
isLockfileExists: () => {
|
|
@@ -3178,23 +3215,23 @@ function createLockfileHelper() {
|
|
|
3178
3215
|
registerSourceData: (pathPattern, sourceData) => {
|
|
3179
3216
|
const lockfile = _loadLockfile();
|
|
3180
3217
|
const sectionKey = MD5(pathPattern);
|
|
3181
|
-
const sectionChecksums =
|
|
3218
|
+
const sectionChecksums = _19.mapValues(sourceData, (value) => MD5(value));
|
|
3182
3219
|
lockfile.checksums[sectionKey] = sectionChecksums;
|
|
3183
3220
|
_saveLockfile(lockfile);
|
|
3184
3221
|
},
|
|
3185
3222
|
registerPartialSourceData: (pathPattern, partialSourceData) => {
|
|
3186
3223
|
const lockfile = _loadLockfile();
|
|
3187
3224
|
const sectionKey = MD5(pathPattern);
|
|
3188
|
-
const sectionChecksums =
|
|
3189
|
-
lockfile.checksums[sectionKey] =
|
|
3225
|
+
const sectionChecksums = _19.mapValues(partialSourceData, (value) => MD5(value));
|
|
3226
|
+
lockfile.checksums[sectionKey] = _19.merge({}, lockfile.checksums[sectionKey] ?? {}, sectionChecksums);
|
|
3190
3227
|
_saveLockfile(lockfile);
|
|
3191
3228
|
},
|
|
3192
3229
|
extractUpdatedData: (pathPattern, sourceData) => {
|
|
3193
3230
|
const lockfile = _loadLockfile();
|
|
3194
3231
|
const sectionKey = MD5(pathPattern);
|
|
3195
|
-
const currentChecksums =
|
|
3232
|
+
const currentChecksums = _19.mapValues(sourceData, (value) => MD5(value));
|
|
3196
3233
|
const savedChecksums = lockfile.checksums[sectionKey] || {};
|
|
3197
|
-
const updatedData =
|
|
3234
|
+
const updatedData = _19.pickBy(sourceData, (value, key) => savedChecksums[key] !== currentChecksums[key]);
|
|
3198
3235
|
return updatedData;
|
|
3199
3236
|
}
|
|
3200
3237
|
};
|
|
@@ -3346,11 +3383,9 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3346
3383
|
ora.succeed("Buckets retrieved");
|
|
3347
3384
|
if (flags.file?.length) {
|
|
3348
3385
|
buckets = buckets.map((bucket) => {
|
|
3349
|
-
const
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
return { ...bucket, config };
|
|
3353
|
-
}).filter((bucket) => bucket.config.length > 0);
|
|
3386
|
+
const paths = bucket.paths.filter((path15) => flags.file.find((file) => path15.pathPattern?.match(file)));
|
|
3387
|
+
return { ...bucket, paths };
|
|
3388
|
+
}).filter((bucket) => bucket.paths.length > 0);
|
|
3354
3389
|
if (buckets.length === 0) {
|
|
3355
3390
|
ora.fail("No buckets found. All buckets were filtered out by --file option.");
|
|
3356
3391
|
process.exit(1);
|
|
@@ -3358,8 +3393,8 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3358
3393
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
3359
3394
|
buckets.map((bucket) => {
|
|
3360
3395
|
ora.info(` ${bucket.type}:`);
|
|
3361
|
-
bucket.
|
|
3362
|
-
ora.info(` - ${
|
|
3396
|
+
bucket.paths.forEach((path15) => {
|
|
3397
|
+
ora.info(` - ${path15.pathPattern}`);
|
|
3363
3398
|
});
|
|
3364
3399
|
});
|
|
3365
3400
|
}
|
|
@@ -3370,16 +3405,17 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3370
3405
|
if (!lockfileHelper.isLockfileExists()) {
|
|
3371
3406
|
ora.start("Creating i18n.lock...");
|
|
3372
3407
|
for (const bucket of buckets) {
|
|
3373
|
-
for (const
|
|
3374
|
-
const sourceLocale = resolveOverriddenLocale3(i18nConfig.locale.source,
|
|
3375
|
-
const bucketLoader = createBucketLoader(bucket.type,
|
|
3408
|
+
for (const bucketPath of bucket.paths) {
|
|
3409
|
+
const sourceLocale = resolveOverriddenLocale3(i18nConfig.locale.source, bucketPath.delimiter);
|
|
3410
|
+
const bucketLoader = createBucketLoader(bucket.type, bucketPath.pathPattern, {
|
|
3376
3411
|
isCacheRestore: false,
|
|
3377
|
-
defaultLocale: sourceLocale
|
|
3412
|
+
defaultLocale: sourceLocale,
|
|
3413
|
+
injectLocale: bucket.injectLocale
|
|
3378
3414
|
});
|
|
3379
3415
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3380
3416
|
await bucketLoader.init();
|
|
3381
3417
|
const sourceData = await bucketLoader.pull(i18nConfig.locale.source);
|
|
3382
|
-
lockfileHelper.registerSourceData(
|
|
3418
|
+
lockfileHelper.registerSourceData(bucketPath.pathPattern, sourceData);
|
|
3383
3419
|
}
|
|
3384
3420
|
}
|
|
3385
3421
|
ora.succeed("i18n.lock created");
|
|
@@ -3393,13 +3429,14 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3393
3429
|
const cacheOra = Ora5({ indent: 2 });
|
|
3394
3430
|
for (const bucket of buckets) {
|
|
3395
3431
|
cacheOra.info(`Processing bucket: ${bucket.type}`);
|
|
3396
|
-
for (const
|
|
3432
|
+
for (const bucketPath of bucket.paths) {
|
|
3397
3433
|
const bucketOra = Ora5({ indent: 4 });
|
|
3398
|
-
bucketOra.info(`Processing path: ${
|
|
3399
|
-
const sourceLocale = resolveOverriddenLocale3(i18nConfig.locale.source,
|
|
3400
|
-
const bucketLoader = createBucketLoader(bucket.type,
|
|
3434
|
+
bucketOra.info(`Processing path: ${bucketPath.pathPattern}`);
|
|
3435
|
+
const sourceLocale = resolveOverriddenLocale3(i18nConfig.locale.source, bucketPath.delimiter);
|
|
3436
|
+
const bucketLoader = createBucketLoader(bucket.type, bucketPath.pathPattern, {
|
|
3401
3437
|
isCacheRestore: true,
|
|
3402
|
-
defaultLocale: sourceLocale
|
|
3438
|
+
defaultLocale: sourceLocale,
|
|
3439
|
+
injectLocale: bucket.injectLocale
|
|
3403
3440
|
});
|
|
3404
3441
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3405
3442
|
await bucketLoader.init();
|
|
@@ -3415,7 +3452,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3415
3452
|
}
|
|
3416
3453
|
}
|
|
3417
3454
|
await bucketLoader.push(targetLocale, targetData);
|
|
3418
|
-
lockfileHelper.registerPartialSourceData(
|
|
3455
|
+
lockfileHelper.registerPartialSourceData(bucketPath.pathPattern, cachedSourceData);
|
|
3419
3456
|
bucketOra.succeed(
|
|
3420
3457
|
`[${sourceLocale} -> ${targetLocale}] Recovered ${Object.keys(cachedSourceData).length} entries from cache`
|
|
3421
3458
|
);
|
|
@@ -3433,29 +3470,30 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3433
3470
|
ora.start("Checking for lockfile updates...");
|
|
3434
3471
|
let requiresUpdate = null;
|
|
3435
3472
|
bucketLoop: for (const bucket of buckets) {
|
|
3436
|
-
for (const
|
|
3437
|
-
const sourceLocale = resolveOverriddenLocale3(i18nConfig.locale.source,
|
|
3438
|
-
const bucketLoader = createBucketLoader(bucket.type,
|
|
3473
|
+
for (const bucketPath of bucket.paths) {
|
|
3474
|
+
const sourceLocale = resolveOverriddenLocale3(i18nConfig.locale.source, bucketPath.delimiter);
|
|
3475
|
+
const bucketLoader = createBucketLoader(bucket.type, bucketPath.pathPattern, {
|
|
3439
3476
|
isCacheRestore: false,
|
|
3440
3477
|
defaultLocale: sourceLocale,
|
|
3441
|
-
returnUnlocalizedKeys: true
|
|
3478
|
+
returnUnlocalizedKeys: true,
|
|
3479
|
+
injectLocale: bucket.injectLocale
|
|
3442
3480
|
});
|
|
3443
3481
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3444
3482
|
await bucketLoader.init();
|
|
3445
3483
|
const { unlocalizable: sourceUnlocalizable, ...sourceData } = await bucketLoader.pull(
|
|
3446
3484
|
i18nConfig.locale.source
|
|
3447
3485
|
);
|
|
3448
|
-
const updatedSourceData = lockfileHelper.extractUpdatedData(
|
|
3486
|
+
const updatedSourceData = lockfileHelper.extractUpdatedData(bucketPath.pathPattern, sourceData);
|
|
3449
3487
|
if (Object.keys(updatedSourceData).length > 0) {
|
|
3450
3488
|
requiresUpdate = "updated";
|
|
3451
3489
|
break bucketLoop;
|
|
3452
3490
|
}
|
|
3453
3491
|
for (const _targetLocale of targetLocales) {
|
|
3454
|
-
const targetLocale = resolveOverriddenLocale3(_targetLocale,
|
|
3492
|
+
const targetLocale = resolveOverriddenLocale3(_targetLocale, bucketPath.delimiter);
|
|
3455
3493
|
const { unlocalizable: targetUnlocalizable, ...targetData } = await bucketLoader.pull(targetLocale);
|
|
3456
|
-
const missingKeys =
|
|
3457
|
-
const extraKeys =
|
|
3458
|
-
const unlocalizableDataDiff = !
|
|
3494
|
+
const missingKeys = _20.difference(Object.keys(sourceData), Object.keys(targetData));
|
|
3495
|
+
const extraKeys = _20.difference(Object.keys(targetData), Object.keys(sourceData));
|
|
3496
|
+
const unlocalizableDataDiff = !_20.isEqual(sourceUnlocalizable, targetUnlocalizable);
|
|
3459
3497
|
if (missingKeys.length > 0) {
|
|
3460
3498
|
requiresUpdate = "missing";
|
|
3461
3499
|
break bucketLoop;
|
|
@@ -3489,22 +3527,23 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3489
3527
|
try {
|
|
3490
3528
|
console.log();
|
|
3491
3529
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
3492
|
-
for (const
|
|
3493
|
-
const bucketOra = Ora5({ indent: 2 }).info(`Processing path: ${
|
|
3494
|
-
const sourceLocale = resolveOverriddenLocale3(i18nConfig.locale.source,
|
|
3495
|
-
const bucketLoader = createBucketLoader(bucket.type,
|
|
3530
|
+
for (const bucketPath of bucket.paths) {
|
|
3531
|
+
const bucketOra = Ora5({ indent: 2 }).info(`Processing path: ${bucketPath.pathPattern}`);
|
|
3532
|
+
const sourceLocale = resolveOverriddenLocale3(i18nConfig.locale.source, bucketPath.delimiter);
|
|
3533
|
+
const bucketLoader = createBucketLoader(bucket.type, bucketPath.pathPattern, {
|
|
3496
3534
|
isCacheRestore: false,
|
|
3497
|
-
defaultLocale: sourceLocale
|
|
3535
|
+
defaultLocale: sourceLocale,
|
|
3536
|
+
injectLocale: bucket.injectLocale
|
|
3498
3537
|
});
|
|
3499
3538
|
bucketLoader.setDefaultLocale(sourceLocale);
|
|
3500
3539
|
await bucketLoader.init();
|
|
3501
3540
|
let sourceData = await bucketLoader.pull(sourceLocale);
|
|
3502
3541
|
for (const _targetLocale of targetLocales) {
|
|
3503
|
-
const targetLocale = resolveOverriddenLocale3(_targetLocale,
|
|
3542
|
+
const targetLocale = resolveOverriddenLocale3(_targetLocale, bucketPath.delimiter);
|
|
3504
3543
|
try {
|
|
3505
3544
|
bucketOra.start(`[${sourceLocale} -> ${targetLocale}] (0%) Localization in progress...`);
|
|
3506
3545
|
sourceData = await bucketLoader.pull(sourceLocale);
|
|
3507
|
-
const updatedSourceData = flags.force ? sourceData : lockfileHelper.extractUpdatedData(
|
|
3546
|
+
const updatedSourceData = flags.force ? sourceData : lockfileHelper.extractUpdatedData(bucketPath.pathPattern, sourceData);
|
|
3508
3547
|
const targetData = await bucketLoader.pull(targetLocale);
|
|
3509
3548
|
let processableData = calculateDataDelta({
|
|
3510
3549
|
sourceData,
|
|
@@ -3512,7 +3551,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3512
3551
|
targetData
|
|
3513
3552
|
});
|
|
3514
3553
|
if (flags.key) {
|
|
3515
|
-
processableData =
|
|
3554
|
+
processableData = _20.pickBy(processableData, (_22, key) => key === flags.key);
|
|
3516
3555
|
}
|
|
3517
3556
|
if (flags.verbose) {
|
|
3518
3557
|
bucketOra.info(JSON.stringify(processableData, null, 2));
|
|
@@ -3548,11 +3587,11 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3548
3587
|
if (flags.verbose) {
|
|
3549
3588
|
bucketOra.info(JSON.stringify(processedTargetData, null, 2));
|
|
3550
3589
|
}
|
|
3551
|
-
let finalTargetData =
|
|
3590
|
+
let finalTargetData = _20.merge({}, sourceData, targetData, processedTargetData);
|
|
3552
3591
|
if (flags.interactive) {
|
|
3553
3592
|
bucketOra.stop();
|
|
3554
3593
|
const reviewedData = await reviewChanges({
|
|
3555
|
-
pathPattern:
|
|
3594
|
+
pathPattern: bucketPath.pathPattern,
|
|
3556
3595
|
targetLocale,
|
|
3557
3596
|
currentData: targetData,
|
|
3558
3597
|
proposedData: finalTargetData,
|
|
@@ -3560,9 +3599,9 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3560
3599
|
force: flags.force
|
|
3561
3600
|
});
|
|
3562
3601
|
finalTargetData = reviewedData;
|
|
3563
|
-
bucketOra.start(`Applying changes to ${
|
|
3602
|
+
bucketOra.start(`Applying changes to ${bucketPath} (${targetLocale})`);
|
|
3564
3603
|
}
|
|
3565
|
-
const finalDiffSize =
|
|
3604
|
+
const finalDiffSize = _20.chain(finalTargetData).omitBy((value, key) => value === targetData[key]).size().value();
|
|
3566
3605
|
await bucketLoader.push(targetLocale, finalTargetData);
|
|
3567
3606
|
if (finalDiffSize > 0 || flags.force) {
|
|
3568
3607
|
bucketOra.succeed(`[${sourceLocale} -> ${targetLocale}] Localization completed`);
|
|
@@ -3579,7 +3618,7 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3579
3618
|
}
|
|
3580
3619
|
}
|
|
3581
3620
|
}
|
|
3582
|
-
lockfileHelper.registerSourceData(
|
|
3621
|
+
lockfileHelper.registerSourceData(bucketPath.pathPattern, sourceData);
|
|
3583
3622
|
}
|
|
3584
3623
|
} catch (_error) {
|
|
3585
3624
|
const error = new Error(`Failed to process bucket ${bucket.type}: ${_error.message}`);
|
|
@@ -3607,9 +3646,9 @@ var i18n_default = new Command6().command("i18n").description("Run Localization
|
|
|
3607
3646
|
}
|
|
3608
3647
|
});
|
|
3609
3648
|
function calculateDataDelta(args) {
|
|
3610
|
-
const newKeys =
|
|
3649
|
+
const newKeys = _20.difference(Object.keys(args.sourceData), Object.keys(args.targetData));
|
|
3611
3650
|
const updatedKeys = Object.keys(args.updatedSourceData);
|
|
3612
|
-
const result =
|
|
3651
|
+
const result = _20.chain(args.sourceData).pickBy((value, key) => newKeys.includes(key) || updatedKeys.includes(key)).value();
|
|
3613
3652
|
return result;
|
|
3614
3653
|
}
|
|
3615
3654
|
async function retryWithExponentialBackoff(operation, maxAttempts, baseDelay = 1e3) {
|
|
@@ -3755,7 +3794,7 @@ Reviewing changes for ${chalk.blue(args.pathPattern)} (${chalk.yellow(args.targe
|
|
|
3755
3794
|
return args.currentData;
|
|
3756
3795
|
}
|
|
3757
3796
|
const customData = { ...args.currentData };
|
|
3758
|
-
const changes =
|
|
3797
|
+
const changes = _20.reduce(
|
|
3759
3798
|
args.proposedData,
|
|
3760
3799
|
(result, value, key) => {
|
|
3761
3800
|
if (args.currentData[key] !== value) {
|
|
@@ -3818,7 +3857,7 @@ var lockfile_default = new Command7().command("lockfile").description("Create a
|
|
|
3818
3857
|
const i18nConfig = getConfig();
|
|
3819
3858
|
const buckets = getBuckets(i18nConfig);
|
|
3820
3859
|
for (const bucket of buckets) {
|
|
3821
|
-
for (const bucketConfig of bucket.
|
|
3860
|
+
for (const bucketConfig of bucket.paths) {
|
|
3822
3861
|
const sourceLocale = resolveOverriddenLocale4(i18nConfig.locale.source, bucketConfig.delimiter);
|
|
3823
3862
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern, {
|
|
3824
3863
|
isCacheRestore: false,
|
|
@@ -3839,9 +3878,12 @@ var flagsSchema = Z5.object({
|
|
|
3839
3878
|
// src/cli/cmd/cleanup.ts
|
|
3840
3879
|
import { resolveOverriddenLocale as resolveOverriddenLocale5 } from "@lingo.dev/_spec";
|
|
3841
3880
|
import { Command as Command8 } from "interactive-commander";
|
|
3842
|
-
import
|
|
3881
|
+
import _21 from "lodash";
|
|
3843
3882
|
import Ora7 from "ora";
|
|
3844
|
-
var cleanup_default = new Command8().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(
|
|
3883
|
+
var cleanup_default = new Command8().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(
|
|
3884
|
+
"--verbose",
|
|
3885
|
+
"Show detailed output including:\n - List of keys that would be removed.\n - Processing steps."
|
|
3886
|
+
).action(async function(options) {
|
|
3845
3887
|
const ora = Ora7();
|
|
3846
3888
|
const results = [];
|
|
3847
3889
|
try {
|
|
@@ -3857,7 +3899,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
3857
3899
|
for (const bucket of buckets) {
|
|
3858
3900
|
console.log();
|
|
3859
3901
|
ora.info(`Processing bucket: ${bucket.type}`);
|
|
3860
|
-
for (const bucketConfig of bucket.
|
|
3902
|
+
for (const bucketConfig of bucket.paths) {
|
|
3861
3903
|
const sourceLocale = resolveOverriddenLocale5(i18nConfig.locale.source, bucketConfig.delimiter);
|
|
3862
3904
|
const bucketOra = Ora7({ indent: 2 }).info(`Processing path: ${bucketConfig.pathPattern}`);
|
|
3863
3905
|
const bucketLoader = createBucketLoader(bucket.type, bucketConfig.pathPattern, {
|
|
@@ -3872,7 +3914,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
3872
3914
|
try {
|
|
3873
3915
|
const targetData = await bucketLoader.pull(targetLocale);
|
|
3874
3916
|
const targetKeys = Object.keys(targetData);
|
|
3875
|
-
const keysToRemove =
|
|
3917
|
+
const keysToRemove = _21.difference(targetKeys, sourceKeys);
|
|
3876
3918
|
if (keysToRemove.length === 0) {
|
|
3877
3919
|
bucketOra.succeed(`[${targetLocale}] No keys to remove`);
|
|
3878
3920
|
continue;
|
|
@@ -3881,7 +3923,7 @@ var cleanup_default = new Command8().command("cleanup").description("Remove keys
|
|
|
3881
3923
|
bucketOra.info(`[${targetLocale}] Keys to remove: ${JSON.stringify(keysToRemove, null, 2)}`);
|
|
3882
3924
|
}
|
|
3883
3925
|
if (!options.dryRun) {
|
|
3884
|
-
const cleanedData =
|
|
3926
|
+
const cleanedData = _21.pick(targetData, sourceKeys);
|
|
3885
3927
|
await bucketLoader.push(targetLocale, cleanedData);
|
|
3886
3928
|
bucketOra.succeed(`[${targetLocale}] Removed ${keysToRemove.length} keys`);
|
|
3887
3929
|
} else {
|
|
@@ -3936,7 +3978,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
3936
3978
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3937
3979
|
import Z6 from "zod";
|
|
3938
3980
|
import { ReplexicaEngine } from "@lingo.dev/_sdk";
|
|
3939
|
-
var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (
|
|
3981
|
+
var mcp_default = new Command9().command("mcp").description("Use Lingo.dev model context provider with your AI agent").helpOption("-h, --help", "Show help").action(async (_22, program) => {
|
|
3940
3982
|
const apiKey = program.args[0];
|
|
3941
3983
|
const settings = getSettings(apiKey);
|
|
3942
3984
|
if (!settings.auth.apiKey) {
|
|
@@ -4131,35 +4173,21 @@ var PullRequestFlow = class extends InBranchFlow {
|
|
|
4131
4173
|
this.ora.start(
|
|
4132
4174
|
`Checking for existing PR with head ${i18nBranchName} and base ${this.platformKit.platformConfig.baseBranchName}`
|
|
4133
4175
|
);
|
|
4134
|
-
|
|
4176
|
+
let prNumber = await this.platformKit.getOpenPullRequestNumber({
|
|
4135
4177
|
branch: i18nBranchName
|
|
4136
4178
|
});
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
this.ora.start(`Creating new PR`);
|
|
4146
|
-
const newPrNumber = await this.platformKit.createPullRequest({
|
|
4147
|
-
head: i18nBranchName,
|
|
4148
|
-
title: this.platformKit.config.pullRequestTitle,
|
|
4149
|
-
body: this.getPrBodyContent()
|
|
4150
|
-
});
|
|
4151
|
-
this.ora.succeed(`Created new PR ${newPrNumber}`);
|
|
4152
|
-
if (existingPrNumber) {
|
|
4153
|
-
this.ora.start(`Posting comment about outdated PR ${existingPrNumber}`);
|
|
4154
|
-
await this.platformKit.commentOnPullRequest({
|
|
4155
|
-
pullRequestNumber: existingPrNumber,
|
|
4156
|
-
body: `This PR is now outdated. A new version has been created at ${this.platformKit.buildPullRequestUrl(
|
|
4157
|
-
newPrNumber
|
|
4158
|
-
)}`
|
|
4179
|
+
if (prNumber) {
|
|
4180
|
+
this.ora.succeed(`Existing PR found: #${prNumber}`);
|
|
4181
|
+
} else {
|
|
4182
|
+
this.ora.start(`Creating new PR`);
|
|
4183
|
+
prNumber = await this.platformKit.createPullRequest({
|
|
4184
|
+
head: i18nBranchName,
|
|
4185
|
+
title: this.platformKit.config.pullRequestTitle,
|
|
4186
|
+
body: this.getPrBodyContent()
|
|
4159
4187
|
});
|
|
4160
|
-
this.ora.succeed(`
|
|
4188
|
+
this.ora.succeed(`Created new PR: #${prNumber}`);
|
|
4161
4189
|
}
|
|
4162
|
-
return
|
|
4190
|
+
return prNumber;
|
|
4163
4191
|
}
|
|
4164
4192
|
checkoutI18nBranch(i18nBranchName) {
|
|
4165
4193
|
execSync3(`git fetch origin ${i18nBranchName}`, { stdio: "inherit" });
|
|
@@ -4613,7 +4641,7 @@ var ci_default = new Command10().command("ci").description("Run Lingo.dev CI/CD
|
|
|
4613
4641
|
// package.json
|
|
4614
4642
|
var package_default = {
|
|
4615
4643
|
name: "lingo.dev",
|
|
4616
|
-
version: "0.79.
|
|
4644
|
+
version: "0.79.3",
|
|
4617
4645
|
description: "Lingo.dev CLI",
|
|
4618
4646
|
private: false,
|
|
4619
4647
|
publishConfig: {
|