lingo.dev 0.92.3 → 0.92.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 +161 -225
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +139 -203
- package/build/cli.mjs.map +1 -1
- package/package.json +1 -1
package/build/cli.cjs
CHANGED
|
@@ -3134,18 +3134,17 @@ function parseVueFile(input2) {
|
|
|
3134
3134
|
|
|
3135
3135
|
// src/cli/loaders/typescript/index.ts
|
|
3136
3136
|
var _parser = require('@babel/parser');
|
|
3137
|
+
|
|
3137
3138
|
var _traverse = require('@babel/traverse'); var _traverse2 = _interopRequireDefault(_traverse);
|
|
3138
3139
|
var _types = require('@babel/types'); var t = _interopRequireWildcard(_types);
|
|
3139
3140
|
var _generator = require('@babel/generator'); var _generator2 = _interopRequireDefault(_generator);
|
|
3140
3141
|
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
3142
|
// src/cli/loaders/typescript/cjs-interop.ts
|
|
3144
3143
|
function resolveCjsExport(mod, name = "module") {
|
|
3145
3144
|
if (typeof mod === "function" || typeof mod !== "object" || mod === null) {
|
|
3146
3145
|
return mod;
|
|
3147
3146
|
}
|
|
3148
|
-
if (typeof mod.default !== "undefined") {
|
|
3147
|
+
if ("default" in mod && typeof mod.default !== "undefined") {
|
|
3149
3148
|
return mod.default;
|
|
3150
3149
|
}
|
|
3151
3150
|
console.error(
|
|
@@ -3165,33 +3164,20 @@ function createTypescriptLoader() {
|
|
|
3165
3164
|
if (!input2) {
|
|
3166
3165
|
return {};
|
|
3167
3166
|
}
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
return flattenExtractedStrings(extractedStrings);
|
|
3172
|
-
} catch (error) {
|
|
3173
|
-
console.error("Error parsing TypeScript file:", error);
|
|
3174
|
-
return {};
|
|
3175
|
-
}
|
|
3167
|
+
const ast = parseTypeScript(input2);
|
|
3168
|
+
const extractedStrings = extractStringsFromDefaultExport(ast);
|
|
3169
|
+
return extractedStrings;
|
|
3176
3170
|
},
|
|
3177
3171
|
push: async (locale, data, originalInput, defaultLocale, pullInput, pullOutput) => {
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
const
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
const nestedData = unflattenStringData(data);
|
|
3185
|
-
const modified = updateStringsInDefaultExport(ast, nestedData);
|
|
3186
|
-
if (!modified) {
|
|
3187
|
-
return input2;
|
|
3172
|
+
const ast = parseTypeScript(originalInput || "");
|
|
3173
|
+
const finalData = _lodash2.default.merge({}, pullOutput, data);
|
|
3174
|
+
updateStringsInDefaultExport(ast, finalData);
|
|
3175
|
+
const { code } = generate(ast, {
|
|
3176
|
+
jsescOption: {
|
|
3177
|
+
minimal: true
|
|
3188
3178
|
}
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
} catch (error) {
|
|
3192
|
-
console.error("Error updating TypeScript file:", error);
|
|
3193
|
-
return input2;
|
|
3194
|
-
}
|
|
3179
|
+
});
|
|
3180
|
+
return code;
|
|
3195
3181
|
}
|
|
3196
3182
|
});
|
|
3197
3183
|
}
|
|
@@ -3201,218 +3187,159 @@ function parseTypeScript(input2) {
|
|
|
3201
3187
|
plugins: ["typescript"]
|
|
3202
3188
|
});
|
|
3203
3189
|
}
|
|
3204
|
-
function flattenExtractedStrings(obj) {
|
|
3205
|
-
const flattened = _flat.flatten.call(void 0, obj, { delimiter: "/" });
|
|
3206
|
-
return Object.entries(flattened).reduce(
|
|
3207
|
-
(acc, [key, value]) => {
|
|
3208
|
-
if (typeof value === "string") {
|
|
3209
|
-
acc[key] = value;
|
|
3210
|
-
}
|
|
3211
|
-
return acc;
|
|
3212
|
-
},
|
|
3213
|
-
{}
|
|
3214
|
-
);
|
|
3215
|
-
}
|
|
3216
|
-
function unflattenStringData(data) {
|
|
3217
|
-
return _flat.unflatten.call(void 0, data, { delimiter: "/" });
|
|
3218
|
-
}
|
|
3219
3190
|
function extractStringsFromDefaultExport(ast) {
|
|
3220
|
-
|
|
3191
|
+
let extracted = {};
|
|
3221
3192
|
traverse(ast, {
|
|
3222
3193
|
ExportDefaultDeclaration(path17) {
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3194
|
+
const { declaration } = path17.node;
|
|
3195
|
+
const decl = unwrapTSAsExpression(declaration);
|
|
3196
|
+
if (t.isObjectExpression(decl)) {
|
|
3197
|
+
extracted = objectExpressionToObject(decl);
|
|
3198
|
+
} else if (t.isArrayExpression(decl)) {
|
|
3199
|
+
extracted = arrayExpressionToArray(decl);
|
|
3200
|
+
} else if (t.isIdentifier(decl)) {
|
|
3201
|
+
const binding = path17.scope.bindings[decl.name];
|
|
3202
|
+
if (binding && t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
3203
|
+
const initRaw = binding.path.node.init;
|
|
3204
|
+
const init = initRaw ? unwrapTSAsExpression(initRaw) : initRaw;
|
|
3205
|
+
if (t.isObjectExpression(init)) {
|
|
3206
|
+
extracted = objectExpressionToObject(init);
|
|
3207
|
+
} else if (t.isArrayExpression(init)) {
|
|
3208
|
+
extracted = arrayExpressionToArray(init);
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3227
3211
|
}
|
|
3228
3212
|
}
|
|
3229
3213
|
});
|
|
3230
|
-
return
|
|
3214
|
+
return extracted;
|
|
3215
|
+
}
|
|
3216
|
+
function unwrapTSAsExpression(node) {
|
|
3217
|
+
let current = node;
|
|
3218
|
+
while (t.isTSAsExpression(current)) {
|
|
3219
|
+
current = current.expression;
|
|
3220
|
+
}
|
|
3221
|
+
return current;
|
|
3231
3222
|
}
|
|
3232
|
-
function
|
|
3223
|
+
function objectExpressionToObject(objectExpression) {
|
|
3224
|
+
const obj = {};
|
|
3233
3225
|
objectExpression.properties.forEach((prop) => {
|
|
3234
|
-
if (t.isObjectProperty(prop))
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3226
|
+
if (!t.isObjectProperty(prop)) return;
|
|
3227
|
+
const key = getPropertyKey(prop);
|
|
3228
|
+
if (t.isStringLiteral(prop.value)) {
|
|
3229
|
+
obj[key] = prop.value.value;
|
|
3230
|
+
} else if (t.isObjectExpression(prop.value)) {
|
|
3231
|
+
const nested = objectExpressionToObject(prop.value);
|
|
3232
|
+
if (Object.keys(nested).length > 0) {
|
|
3233
|
+
obj[key] = nested;
|
|
3234
|
+
}
|
|
3235
|
+
} else if (t.isArrayExpression(prop.value)) {
|
|
3236
|
+
const arr = arrayExpressionToArray(prop.value);
|
|
3237
|
+
if (arr.length > 0) {
|
|
3238
|
+
obj[key] = arr;
|
|
3243
3239
|
}
|
|
3244
3240
|
}
|
|
3245
3241
|
});
|
|
3242
|
+
return obj;
|
|
3246
3243
|
}
|
|
3247
|
-
function
|
|
3248
|
-
|
|
3249
|
-
|
|
3244
|
+
function arrayExpressionToArray(arrayExpression) {
|
|
3245
|
+
const arr = [];
|
|
3246
|
+
arrayExpression.elements.forEach((element) => {
|
|
3247
|
+
if (!element) return;
|
|
3250
3248
|
if (t.isStringLiteral(element)) {
|
|
3251
|
-
|
|
3249
|
+
arr.push(element.value);
|
|
3252
3250
|
} else if (t.isObjectExpression(element)) {
|
|
3253
|
-
|
|
3251
|
+
const nestedObj = objectExpressionToObject(element);
|
|
3252
|
+
arr.push(nestedObj);
|
|
3254
3253
|
} else if (t.isArrayExpression(element)) {
|
|
3255
|
-
|
|
3254
|
+
arr.push(arrayExpressionToArray(element));
|
|
3256
3255
|
}
|
|
3257
3256
|
});
|
|
3258
|
-
|
|
3259
|
-
function extractStringsFromExportedIdentifier(path17, result, basePath) {
|
|
3260
|
-
const exportName = path17.node.declaration.name;
|
|
3261
|
-
const binding = path17.scope.bindings[exportName];
|
|
3262
|
-
if (binding && binding.path.node) {
|
|
3263
|
-
const bindingPath = binding.path;
|
|
3264
|
-
if (t.isVariableDeclarator(bindingPath.node) && bindingPath.node.init) {
|
|
3265
|
-
if (t.isObjectExpression(bindingPath.node.init)) {
|
|
3266
|
-
extractStringsFromObjectExpression(
|
|
3267
|
-
bindingPath.node.init,
|
|
3268
|
-
result,
|
|
3269
|
-
basePath
|
|
3270
|
-
);
|
|
3271
|
-
} else if (t.isArrayExpression(bindingPath.node.init)) {
|
|
3272
|
-
extractStringsFromArrayExpression(
|
|
3273
|
-
bindingPath.node.init,
|
|
3274
|
-
result,
|
|
3275
|
-
basePath
|
|
3276
|
-
);
|
|
3277
|
-
}
|
|
3278
|
-
}
|
|
3279
|
-
}
|
|
3257
|
+
return arr;
|
|
3280
3258
|
}
|
|
3281
3259
|
function updateStringsInDefaultExport(ast, data) {
|
|
3282
3260
|
let modified = false;
|
|
3283
3261
|
traverse(ast, {
|
|
3284
3262
|
ExportDefaultDeclaration(path17) {
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
modified =
|
|
3263
|
+
const { declaration } = path17.node;
|
|
3264
|
+
const decl = unwrapTSAsExpression(declaration);
|
|
3265
|
+
if (t.isObjectExpression(decl)) {
|
|
3266
|
+
modified = updateStringsInObjectExpression(decl, data) || modified;
|
|
3267
|
+
} else if (t.isArrayExpression(decl)) {
|
|
3268
|
+
if (Array.isArray(data)) {
|
|
3269
|
+
modified = updateStringsInArrayExpression(decl, data) || modified;
|
|
3270
|
+
}
|
|
3271
|
+
} else if (t.isIdentifier(decl)) {
|
|
3272
|
+
modified = updateStringsInExportedIdentifier(path17, data) || modified;
|
|
3289
3273
|
}
|
|
3290
3274
|
}
|
|
3291
3275
|
});
|
|
3292
3276
|
return modified;
|
|
3293
3277
|
}
|
|
3294
|
-
function updateStringsInObjectExpression(objectExpression, data
|
|
3278
|
+
function updateStringsInObjectExpression(objectExpression, data) {
|
|
3295
3279
|
let modified = false;
|
|
3296
3280
|
objectExpression.properties.forEach((prop) => {
|
|
3297
|
-
if (t.isObjectProperty(prop))
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
}
|
|
3308
|
-
} else if (t.isObjectExpression(prop.value)) {
|
|
3309
|
-
if (data[key] && typeof data[key] === "object") {
|
|
3310
|
-
const subModified = updateStringsInObjectExpression(
|
|
3311
|
-
prop.value,
|
|
3312
|
-
data[key],
|
|
3313
|
-
""
|
|
3314
|
-
);
|
|
3315
|
-
modified = subModified || modified;
|
|
3316
|
-
} else {
|
|
3317
|
-
const subModified = updateStringsInObjectExpression(
|
|
3318
|
-
prop.value,
|
|
3319
|
-
data,
|
|
3320
|
-
currentPath
|
|
3321
|
-
);
|
|
3322
|
-
modified = subModified || modified;
|
|
3323
|
-
}
|
|
3324
|
-
} else if (t.isArrayExpression(prop.value)) {
|
|
3325
|
-
if (data[key] && Array.isArray(data[key])) {
|
|
3326
|
-
const subModified = updateStringsInArrayExpression(
|
|
3327
|
-
prop.value,
|
|
3328
|
-
data[key],
|
|
3329
|
-
""
|
|
3330
|
-
);
|
|
3331
|
-
modified = subModified || modified;
|
|
3332
|
-
} else {
|
|
3333
|
-
const subModified = updateStringsInArrayExpression(
|
|
3334
|
-
prop.value,
|
|
3335
|
-
data,
|
|
3336
|
-
currentPath
|
|
3337
|
-
);
|
|
3338
|
-
modified = subModified || modified;
|
|
3339
|
-
}
|
|
3281
|
+
if (!t.isObjectProperty(prop)) return;
|
|
3282
|
+
const key = getPropertyKey(prop);
|
|
3283
|
+
const incomingVal = _optionalChain([data, 'optionalAccess', _146 => _146[key]]);
|
|
3284
|
+
if (incomingVal === void 0) {
|
|
3285
|
+
return;
|
|
3286
|
+
}
|
|
3287
|
+
if (t.isStringLiteral(prop.value) && typeof incomingVal === "string") {
|
|
3288
|
+
if (prop.value.value !== incomingVal) {
|
|
3289
|
+
prop.value.value = incomingVal;
|
|
3290
|
+
modified = true;
|
|
3340
3291
|
}
|
|
3292
|
+
} else if (t.isObjectExpression(prop.value) && typeof incomingVal === "object" && !Array.isArray(incomingVal)) {
|
|
3293
|
+
const subModified = updateStringsInObjectExpression(
|
|
3294
|
+
prop.value,
|
|
3295
|
+
incomingVal
|
|
3296
|
+
);
|
|
3297
|
+
modified = subModified || modified;
|
|
3298
|
+
} else if (t.isArrayExpression(prop.value) && Array.isArray(incomingVal)) {
|
|
3299
|
+
const subModified = updateStringsInArrayExpression(
|
|
3300
|
+
prop.value,
|
|
3301
|
+
incomingVal
|
|
3302
|
+
);
|
|
3303
|
+
modified = subModified || modified;
|
|
3341
3304
|
}
|
|
3342
3305
|
});
|
|
3343
3306
|
return modified;
|
|
3344
3307
|
}
|
|
3345
|
-
function updateStringsInArrayExpression(arrayExpression,
|
|
3308
|
+
function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
3346
3309
|
let modified = false;
|
|
3347
3310
|
arrayExpression.elements.forEach((element, index) => {
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
element.value = data[currentPath];
|
|
3311
|
+
if (!element) return;
|
|
3312
|
+
const incomingVal = _optionalChain([incoming, 'optionalAccess', _147 => _147[index]]);
|
|
3313
|
+
if (incomingVal === void 0) return;
|
|
3314
|
+
if (t.isStringLiteral(element) && typeof incomingVal === "string") {
|
|
3315
|
+
if (element.value !== incomingVal) {
|
|
3316
|
+
element.value = incomingVal;
|
|
3355
3317
|
modified = true;
|
|
3356
3318
|
}
|
|
3357
|
-
} else if (t.isObjectExpression(element)) {
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
);
|
|
3364
|
-
modified = subModified || modified;
|
|
3365
|
-
} else {
|
|
3366
|
-
const subModified = updateStringsInObjectExpression(
|
|
3367
|
-
element,
|
|
3368
|
-
data,
|
|
3369
|
-
currentPath
|
|
3370
|
-
);
|
|
3371
|
-
modified = subModified || modified;
|
|
3372
|
-
}
|
|
3373
|
-
} else if (t.isArrayExpression(element)) {
|
|
3374
|
-
if (Array.isArray(data) && data[index] && Array.isArray(data[index])) {
|
|
3375
|
-
const subModified = updateStringsInArrayExpression(
|
|
3376
|
-
element,
|
|
3377
|
-
data[index],
|
|
3378
|
-
""
|
|
3379
|
-
);
|
|
3380
|
-
modified = subModified || modified;
|
|
3381
|
-
} else {
|
|
3382
|
-
const subModified = updateStringsInArrayExpression(
|
|
3383
|
-
element,
|
|
3384
|
-
data,
|
|
3385
|
-
currentPath
|
|
3386
|
-
);
|
|
3387
|
-
modified = subModified || modified;
|
|
3388
|
-
}
|
|
3319
|
+
} else if (t.isObjectExpression(element) && typeof incomingVal === "object" && !Array.isArray(incomingVal)) {
|
|
3320
|
+
const subModified = updateStringsInObjectExpression(element, incomingVal);
|
|
3321
|
+
modified = subModified || modified;
|
|
3322
|
+
} else if (t.isArrayExpression(element) && Array.isArray(incomingVal)) {
|
|
3323
|
+
const subModified = updateStringsInArrayExpression(element, incomingVal);
|
|
3324
|
+
modified = subModified || modified;
|
|
3389
3325
|
}
|
|
3390
3326
|
});
|
|
3391
3327
|
return modified;
|
|
3392
3328
|
}
|
|
3393
|
-
function updateStringsInExportedIdentifier(path17, data
|
|
3394
|
-
let modified = false;
|
|
3329
|
+
function updateStringsInExportedIdentifier(path17, data) {
|
|
3395
3330
|
const exportName = path17.node.declaration.name;
|
|
3396
3331
|
const binding = path17.scope.bindings[exportName];
|
|
3397
|
-
if (binding
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
) || modified;
|
|
3406
|
-
} else if (t.isArrayExpression(bindingPath.node.init)) {
|
|
3407
|
-
modified = updateStringsInArrayExpression(
|
|
3408
|
-
bindingPath.node.init,
|
|
3409
|
-
data,
|
|
3410
|
-
basePath
|
|
3411
|
-
) || modified;
|
|
3412
|
-
}
|
|
3332
|
+
if (!binding || !binding.path.node) return false;
|
|
3333
|
+
if (t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
|
|
3334
|
+
const initRaw = binding.path.node.init;
|
|
3335
|
+
const init = initRaw ? unwrapTSAsExpression(initRaw) : initRaw;
|
|
3336
|
+
if (t.isObjectExpression(init)) {
|
|
3337
|
+
return updateStringsInObjectExpression(init, data);
|
|
3338
|
+
} else if (t.isArrayExpression(init)) {
|
|
3339
|
+
return updateStringsInArrayExpression(init, data);
|
|
3413
3340
|
}
|
|
3414
3341
|
}
|
|
3415
|
-
return
|
|
3342
|
+
return false;
|
|
3416
3343
|
}
|
|
3417
3344
|
function getPropertyKey(prop) {
|
|
3418
3345
|
if (t.isIdentifier(prop.key)) {
|
|
@@ -3649,7 +3576,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
3649
3576
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
3650
3577
|
const result = {
|
|
3651
3578
|
frontmatter: data.frontmatter,
|
|
3652
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
3579
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _148 => _148.codePlaceholders]) || {},
|
|
3653
3580
|
content
|
|
3654
3581
|
};
|
|
3655
3582
|
return result;
|
|
@@ -4058,7 +3985,7 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
4058
3985
|
]
|
|
4059
3986
|
});
|
|
4060
3987
|
const result = JSON.parse(response.text);
|
|
4061
|
-
return _optionalChain([result, 'optionalAccess',
|
|
3988
|
+
return _optionalChain([result, 'optionalAccess', _149 => _149.data]) || {};
|
|
4062
3989
|
};
|
|
4063
3990
|
}
|
|
4064
3991
|
|
|
@@ -4076,7 +4003,7 @@ function createProcessor(provider, params) {
|
|
|
4076
4003
|
}
|
|
4077
4004
|
}
|
|
4078
4005
|
function getPureModelProvider(provider) {
|
|
4079
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
4006
|
+
switch (_optionalChain([provider, 'optionalAccess', _150 => _150.id])) {
|
|
4080
4007
|
case "openai":
|
|
4081
4008
|
if (!process.env.OPENAI_API_KEY) {
|
|
4082
4009
|
throw new Error("OPENAI_API_KEY is not set.");
|
|
@@ -4093,7 +4020,7 @@ function getPureModelProvider(provider) {
|
|
|
4093
4020
|
apiKey: process.env.ANTHROPIC_API_KEY
|
|
4094
4021
|
})(provider.model);
|
|
4095
4022
|
default:
|
|
4096
|
-
throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess',
|
|
4023
|
+
throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess', _151 => _151.id])}`);
|
|
4097
4024
|
}
|
|
4098
4025
|
}
|
|
4099
4026
|
|
|
@@ -4114,11 +4041,14 @@ function withExponentialBackoff(fn, maxAttempts = 3, baseDelay = 1e3) {
|
|
|
4114
4041
|
}
|
|
4115
4042
|
|
|
4116
4043
|
// src/cli/utils/observability.ts
|
|
4044
|
+
var _nodemachineid = require('node-machine-id'); var _nodemachineid2 = _interopRequireDefault(_nodemachineid);
|
|
4045
|
+
var { machineIdSync } = _nodemachineid2.default;
|
|
4117
4046
|
async function trackEvent(distinctId, event, properties) {
|
|
4118
4047
|
if (process.env.DO_NOT_TRACK) {
|
|
4119
4048
|
return;
|
|
4120
4049
|
}
|
|
4121
4050
|
try {
|
|
4051
|
+
const actualId = distinctId || `device-${machineIdSync()}`;
|
|
4122
4052
|
const { PostHog } = await Promise.resolve().then(() => _interopRequireWildcard(require("posthog-node")));
|
|
4123
4053
|
const safeProperties = properties ? JSON.parse(
|
|
4124
4054
|
JSON.stringify(properties, (key, value) => {
|
|
@@ -4141,7 +4071,7 @@ async function trackEvent(distinctId, event, properties) {
|
|
|
4141
4071
|
}
|
|
4142
4072
|
);
|
|
4143
4073
|
await posthog.capture({
|
|
4144
|
-
distinctId,
|
|
4074
|
+
distinctId: actualId,
|
|
4145
4075
|
event,
|
|
4146
4076
|
properties: {
|
|
4147
4077
|
...safeProperties,
|
|
@@ -4327,24 +4257,30 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4327
4257
|
validateParams(i18nConfig, flags);
|
|
4328
4258
|
ora.succeed("Localization configuration is valid");
|
|
4329
4259
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
4330
|
-
const
|
|
4331
|
-
|
|
4332
|
-
|
|
4260
|
+
const isByokMode = _optionalChain([i18nConfig, 'optionalAccess', _152 => _152.provider]) && i18nConfig.provider.id !== "lingo";
|
|
4261
|
+
if (isByokMode) {
|
|
4262
|
+
authId = null;
|
|
4263
|
+
ora.succeed("Using external provider (BYOK mode)");
|
|
4264
|
+
} else {
|
|
4265
|
+
const auth = await validateAuth(settings);
|
|
4266
|
+
authId = auth.id;
|
|
4267
|
+
ora.succeed(`Authenticated as ${auth.email}`);
|
|
4268
|
+
}
|
|
4333
4269
|
trackEvent(authId, "cmd.i18n.start", {
|
|
4334
4270
|
i18nConfig,
|
|
4335
4271
|
flags
|
|
4336
4272
|
});
|
|
4337
4273
|
let buckets = getBuckets(i18nConfig);
|
|
4338
|
-
if (_optionalChain([flags, 'access',
|
|
4274
|
+
if (_optionalChain([flags, 'access', _153 => _153.bucket, 'optionalAccess', _154 => _154.length])) {
|
|
4339
4275
|
buckets = buckets.filter(
|
|
4340
4276
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
4341
4277
|
);
|
|
4342
4278
|
}
|
|
4343
4279
|
ora.succeed("Buckets retrieved");
|
|
4344
|
-
if (_optionalChain([flags, 'access',
|
|
4280
|
+
if (_optionalChain([flags, 'access', _155 => _155.file, 'optionalAccess', _156 => _156.length])) {
|
|
4345
4281
|
buckets = buckets.map((bucket) => {
|
|
4346
4282
|
const paths = bucket.paths.filter(
|
|
4347
|
-
(path17) => flags.file.find((file) => _optionalChain([path17, 'access',
|
|
4283
|
+
(path17) => flags.file.find((file) => _optionalChain([path17, 'access', _157 => _157.pathPattern, 'optionalAccess', _158 => _158.includes, 'call', _159 => _159(file)]))
|
|
4348
4284
|
);
|
|
4349
4285
|
return { ...bucket, paths };
|
|
4350
4286
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -4363,7 +4299,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4363
4299
|
});
|
|
4364
4300
|
}
|
|
4365
4301
|
}
|
|
4366
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
4302
|
+
const targetLocales = _optionalChain([flags, 'access', _160 => _160.locale, 'optionalAccess', _161 => _161.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
4367
4303
|
ora.start("Setting up localization cache...");
|
|
4368
4304
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
4369
4305
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -4706,7 +4642,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4706
4642
|
console.log();
|
|
4707
4643
|
if (!hasErrors) {
|
|
4708
4644
|
ora.succeed("Localization completed.");
|
|
4709
|
-
trackEvent(
|
|
4645
|
+
trackEvent(authId, "cmd.i18n.success", {
|
|
4710
4646
|
i18nConfig,
|
|
4711
4647
|
flags
|
|
4712
4648
|
});
|
|
@@ -4768,12 +4704,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
4768
4704
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
4769
4705
|
docUrl: "bucketNotFound"
|
|
4770
4706
|
});
|
|
4771
|
-
} else if (_optionalChain([flags, 'access',
|
|
4707
|
+
} else if (_optionalChain([flags, 'access', _162 => _162.locale, 'optionalAccess', _163 => _163.some, 'call', _164 => _164((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
4772
4708
|
throw new CLIError({
|
|
4773
4709
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
4774
4710
|
docUrl: "localeTargetNotFound"
|
|
4775
4711
|
});
|
|
4776
|
-
} else if (_optionalChain([flags, 'access',
|
|
4712
|
+
} else if (_optionalChain([flags, 'access', _165 => _165.bucket, 'optionalAccess', _166 => _166.some, 'call', _167 => _167(
|
|
4777
4713
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
4778
4714
|
)])) {
|
|
4779
4715
|
throw new CLIError({
|
|
@@ -5238,7 +5174,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5238
5174
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
5239
5175
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
5240
5176
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
5241
|
-
_optionalChain([this, 'access',
|
|
5177
|
+
_optionalChain([this, 'access', _168 => _168.platformKit, 'optionalAccess', _169 => _169.gitConfig, 'call', _170 => _170()]);
|
|
5242
5178
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
5243
5179
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
5244
5180
|
if (!processOwnCommits) {
|
|
@@ -5270,7 +5206,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5270
5206
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
5271
5207
|
var PullRequestFlow = class extends InBranchFlow {
|
|
5272
5208
|
async preRun() {
|
|
5273
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
5209
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _171 => _171()]);
|
|
5274
5210
|
if (!canContinue) {
|
|
5275
5211
|
return false;
|
|
5276
5212
|
}
|
|
@@ -5522,10 +5458,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
5522
5458
|
repo_slug: this.platformConfig.repositoryName,
|
|
5523
5459
|
state: "OPEN"
|
|
5524
5460
|
}).then(({ data: { values } }) => {
|
|
5525
|
-
return _optionalChain([values, 'optionalAccess',
|
|
5526
|
-
({ source, destination }) => _optionalChain([source, 'optionalAccess',
|
|
5461
|
+
return _optionalChain([values, 'optionalAccess', _172 => _172.find, 'call', _173 => _173(
|
|
5462
|
+
({ source, destination }) => _optionalChain([source, 'optionalAccess', _174 => _174.branch, 'optionalAccess', _175 => _175.name]) === branch && _optionalChain([destination, 'optionalAccess', _176 => _176.branch, 'optionalAccess', _177 => _177.name]) === this.platformConfig.baseBranchName
|
|
5527
5463
|
)]);
|
|
5528
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
5464
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _178 => _178.id]));
|
|
5529
5465
|
}
|
|
5530
5466
|
async closePullRequest({ pullRequestNumber }) {
|
|
5531
5467
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -5621,7 +5557,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
5621
5557
|
repo: this.platformConfig.repositoryName,
|
|
5622
5558
|
base: this.platformConfig.baseBranchName,
|
|
5623
5559
|
state: "open"
|
|
5624
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
5560
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _179 => _179.number]));
|
|
5625
5561
|
}
|
|
5626
5562
|
async closePullRequest({ pullRequestNumber }) {
|
|
5627
5563
|
await this.octokit.rest.pulls.update({
|
|
@@ -5748,7 +5684,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
5748
5684
|
sourceBranch: branch,
|
|
5749
5685
|
state: "opened"
|
|
5750
5686
|
});
|
|
5751
|
-
return _optionalChain([mergeRequests, 'access',
|
|
5687
|
+
return _optionalChain([mergeRequests, 'access', _180 => _180[0], 'optionalAccess', _181 => _181.iid]);
|
|
5752
5688
|
}
|
|
5753
5689
|
async closePullRequest({
|
|
5754
5690
|
pullRequestNumber
|
|
@@ -5832,7 +5768,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5832
5768
|
}
|
|
5833
5769
|
const env = {
|
|
5834
5770
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
5835
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
5771
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _182 => _182.pullRequest, 'optionalAccess', _183 => _183.toString, 'call', _184 => _184()]) || "false",
|
|
5836
5772
|
...options.commitMessage && {
|
|
5837
5773
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
5838
5774
|
},
|
|
@@ -5852,7 +5788,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5852
5788
|
const { isPullRequestMode } = platformKit.config;
|
|
5853
5789
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
5854
5790
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
5855
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
5791
|
+
const canRun = await _optionalChain([flow, 'access', _185 => _185.preRun, 'optionalCall', _186 => _186()]);
|
|
5856
5792
|
if (canRun === false) {
|
|
5857
5793
|
return;
|
|
5858
5794
|
}
|
|
@@ -5860,7 +5796,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5860
5796
|
if (!hasChanges) {
|
|
5861
5797
|
return;
|
|
5862
5798
|
}
|
|
5863
|
-
await _optionalChain([flow, 'access',
|
|
5799
|
+
await _optionalChain([flow, 'access', _187 => _187.postRun, 'optionalCall', _188 => _188()]);
|
|
5864
5800
|
});
|
|
5865
5801
|
|
|
5866
5802
|
// src/cli/cmd/status.ts
|
|
@@ -5904,13 +5840,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5904
5840
|
flags
|
|
5905
5841
|
});
|
|
5906
5842
|
let buckets = getBuckets(i18nConfig);
|
|
5907
|
-
if (_optionalChain([flags, 'access',
|
|
5843
|
+
if (_optionalChain([flags, 'access', _189 => _189.bucket, 'optionalAccess', _190 => _190.length])) {
|
|
5908
5844
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
5909
5845
|
}
|
|
5910
5846
|
ora.succeed("Buckets retrieved");
|
|
5911
|
-
if (_optionalChain([flags, 'access',
|
|
5847
|
+
if (_optionalChain([flags, 'access', _191 => _191.file, 'optionalAccess', _192 => _192.length])) {
|
|
5912
5848
|
buckets = buckets.map((bucket) => {
|
|
5913
|
-
const paths = bucket.paths.filter((path17) => flags.file.find((file) => _optionalChain([path17, 'access',
|
|
5849
|
+
const paths = bucket.paths.filter((path17) => flags.file.find((file) => _optionalChain([path17, 'access', _193 => _193.pathPattern, 'optionalAccess', _194 => _194.match, 'call', _195 => _195(file)])));
|
|
5914
5850
|
return { ...bucket, paths };
|
|
5915
5851
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
5916
5852
|
if (buckets.length === 0) {
|
|
@@ -5926,7 +5862,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5926
5862
|
});
|
|
5927
5863
|
}
|
|
5928
5864
|
}
|
|
5929
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
5865
|
+
const targetLocales = _optionalChain([flags, 'access', _196 => _196.locale, 'optionalAccess', _197 => _197.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
5930
5866
|
let totalSourceKeyCount = 0;
|
|
5931
5867
|
let uniqueKeysToTranslate = 0;
|
|
5932
5868
|
let totalExistingTranslations = 0;
|
|
@@ -6267,12 +6203,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
6267
6203
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
6268
6204
|
docUrl: "bucketNotFound"
|
|
6269
6205
|
});
|
|
6270
|
-
} else if (_optionalChain([flags, 'access',
|
|
6206
|
+
} else if (_optionalChain([flags, 'access', _198 => _198.locale, 'optionalAccess', _199 => _199.some, 'call', _200 => _200((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
6271
6207
|
throw new CLIError({
|
|
6272
6208
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
6273
6209
|
docUrl: "localeTargetNotFound"
|
|
6274
6210
|
});
|
|
6275
|
-
} else if (_optionalChain([flags, 'access',
|
|
6211
|
+
} else if (_optionalChain([flags, 'access', _201 => _201.bucket, 'optionalAccess', _202 => _202.some, 'call', _203 => _203((bucket) => !i18nConfig.buckets[bucket])])) {
|
|
6276
6212
|
throw new CLIError({
|
|
6277
6213
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
6278
6214
|
docUrl: "bucketNotFound"
|
|
@@ -6355,7 +6291,7 @@ async function renderHero() {
|
|
|
6355
6291
|
// package.json
|
|
6356
6292
|
var package_default = {
|
|
6357
6293
|
name: "lingo.dev",
|
|
6358
|
-
version: "0.92.
|
|
6294
|
+
version: "0.92.4",
|
|
6359
6295
|
description: "Lingo.dev CLI",
|
|
6360
6296
|
private: false,
|
|
6361
6297
|
publishConfig: {
|