lingo.dev 0.92.2 → 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 +181 -174
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +161 -154
- package/build/cli.mjs.map +1 -1
- package/package.json +1 -1
package/build/cli.cjs
CHANGED
|
@@ -3132,46 +3132,52 @@ function parseVueFile(input2) {
|
|
|
3132
3132
|
return { before, after, i18n };
|
|
3133
3133
|
}
|
|
3134
3134
|
|
|
3135
|
-
// src/cli/loaders/typescript.ts
|
|
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
|
|
|
3142
|
+
// src/cli/loaders/typescript/cjs-interop.ts
|
|
3143
|
+
function resolveCjsExport(mod, name = "module") {
|
|
3144
|
+
if (typeof mod === "function" || typeof mod !== "object" || mod === null) {
|
|
3145
|
+
return mod;
|
|
3146
|
+
}
|
|
3147
|
+
if ("default" in mod && typeof mod.default !== "undefined") {
|
|
3148
|
+
return mod.default;
|
|
3149
|
+
}
|
|
3150
|
+
console.error(
|
|
3151
|
+
`[resolveCjsExport] Unable to determine default export for ${name}.`,
|
|
3152
|
+
"Received value:",
|
|
3153
|
+
mod
|
|
3154
|
+
);
|
|
3155
|
+
throw new Error(`Failed to resolve default export for ${name}.`);
|
|
3156
|
+
}
|
|
3141
3157
|
|
|
3158
|
+
// src/cli/loaders/typescript/index.ts
|
|
3159
|
+
var traverse = resolveCjsExport(_traverse2.default, "@babel/traverse");
|
|
3160
|
+
var generate = resolveCjsExport(_generator2.default, "@babel/generator");
|
|
3142
3161
|
function createTypescriptLoader() {
|
|
3143
3162
|
return createLoader({
|
|
3144
3163
|
pull: async (locale, input2) => {
|
|
3145
3164
|
if (!input2) {
|
|
3146
3165
|
return {};
|
|
3147
3166
|
}
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
return flattenExtractedStrings(extractedStrings);
|
|
3152
|
-
} catch (error) {
|
|
3153
|
-
console.error("Error parsing TypeScript file:", error);
|
|
3154
|
-
return {};
|
|
3155
|
-
}
|
|
3167
|
+
const ast = parseTypeScript(input2);
|
|
3168
|
+
const extractedStrings = extractStringsFromDefaultExport(ast);
|
|
3169
|
+
return extractedStrings;
|
|
3156
3170
|
},
|
|
3157
3171
|
push: async (locale, data, originalInput, defaultLocale, pullInput, pullOutput) => {
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
const
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
const nestedData = unflattenStringData(data);
|
|
3165
|
-
const modified = updateStringsInDefaultExport(ast, nestedData);
|
|
3166
|
-
if (!modified) {
|
|
3167
|
-
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
|
|
3168
3178
|
}
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
} catch (error) {
|
|
3172
|
-
console.error("Error updating TypeScript file:", error);
|
|
3173
|
-
return input2;
|
|
3174
|
-
}
|
|
3179
|
+
});
|
|
3180
|
+
return code;
|
|
3175
3181
|
}
|
|
3176
3182
|
});
|
|
3177
3183
|
}
|
|
@@ -3181,167 +3187,159 @@ function parseTypeScript(input2) {
|
|
|
3181
3187
|
plugins: ["typescript"]
|
|
3182
3188
|
});
|
|
3183
3189
|
}
|
|
3184
|
-
function flattenExtractedStrings(obj) {
|
|
3185
|
-
const flattened = _flat.flatten.call(void 0, obj, { delimiter: "/" });
|
|
3186
|
-
return Object.entries(flattened).reduce((acc, [key, value]) => {
|
|
3187
|
-
if (typeof value === "string") {
|
|
3188
|
-
acc[key] = value;
|
|
3189
|
-
}
|
|
3190
|
-
return acc;
|
|
3191
|
-
}, {});
|
|
3192
|
-
}
|
|
3193
|
-
function unflattenStringData(data) {
|
|
3194
|
-
return _flat.unflatten.call(void 0, data, { delimiter: "/" });
|
|
3195
|
-
}
|
|
3196
3190
|
function extractStringsFromDefaultExport(ast) {
|
|
3197
|
-
|
|
3198
|
-
|
|
3191
|
+
let extracted = {};
|
|
3192
|
+
traverse(ast, {
|
|
3199
3193
|
ExportDefaultDeclaration(path17) {
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
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
|
+
}
|
|
3204
3211
|
}
|
|
3205
3212
|
}
|
|
3206
3213
|
});
|
|
3207
|
-
return
|
|
3214
|
+
return extracted;
|
|
3208
3215
|
}
|
|
3209
|
-
function
|
|
3216
|
+
function unwrapTSAsExpression(node) {
|
|
3217
|
+
let current = node;
|
|
3218
|
+
while (t.isTSAsExpression(current)) {
|
|
3219
|
+
current = current.expression;
|
|
3220
|
+
}
|
|
3221
|
+
return current;
|
|
3222
|
+
}
|
|
3223
|
+
function objectExpressionToObject(objectExpression) {
|
|
3224
|
+
const obj = {};
|
|
3210
3225
|
objectExpression.properties.forEach((prop) => {
|
|
3211
|
-
if (t.isObjectProperty(prop))
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
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;
|
|
3220
3239
|
}
|
|
3221
3240
|
}
|
|
3222
3241
|
});
|
|
3242
|
+
return obj;
|
|
3223
3243
|
}
|
|
3224
|
-
function
|
|
3225
|
-
|
|
3226
|
-
|
|
3244
|
+
function arrayExpressionToArray(arrayExpression) {
|
|
3245
|
+
const arr = [];
|
|
3246
|
+
arrayExpression.elements.forEach((element) => {
|
|
3247
|
+
if (!element) return;
|
|
3227
3248
|
if (t.isStringLiteral(element)) {
|
|
3228
|
-
|
|
3249
|
+
arr.push(element.value);
|
|
3229
3250
|
} else if (t.isObjectExpression(element)) {
|
|
3230
|
-
|
|
3251
|
+
const nestedObj = objectExpressionToObject(element);
|
|
3252
|
+
arr.push(nestedObj);
|
|
3231
3253
|
} else if (t.isArrayExpression(element)) {
|
|
3232
|
-
|
|
3254
|
+
arr.push(arrayExpressionToArray(element));
|
|
3233
3255
|
}
|
|
3234
3256
|
});
|
|
3235
|
-
|
|
3236
|
-
function extractStringsFromExportedIdentifier(path17, result, basePath) {
|
|
3237
|
-
const exportName = path17.node.declaration.name;
|
|
3238
|
-
const binding = path17.scope.bindings[exportName];
|
|
3239
|
-
if (binding && binding.path.node) {
|
|
3240
|
-
const bindingPath = binding.path;
|
|
3241
|
-
if (t.isVariableDeclarator(bindingPath.node) && bindingPath.node.init) {
|
|
3242
|
-
if (t.isObjectExpression(bindingPath.node.init)) {
|
|
3243
|
-
extractStringsFromObjectExpression(bindingPath.node.init, result, basePath);
|
|
3244
|
-
} else if (t.isArrayExpression(bindingPath.node.init)) {
|
|
3245
|
-
extractStringsFromArrayExpression(bindingPath.node.init, result, basePath);
|
|
3246
|
-
}
|
|
3247
|
-
}
|
|
3248
|
-
}
|
|
3257
|
+
return arr;
|
|
3249
3258
|
}
|
|
3250
3259
|
function updateStringsInDefaultExport(ast, data) {
|
|
3251
3260
|
let modified = false;
|
|
3252
|
-
|
|
3261
|
+
traverse(ast, {
|
|
3253
3262
|
ExportDefaultDeclaration(path17) {
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
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;
|
|
3258
3273
|
}
|
|
3259
3274
|
}
|
|
3260
3275
|
});
|
|
3261
3276
|
return modified;
|
|
3262
3277
|
}
|
|
3263
|
-
function updateStringsInObjectExpression(objectExpression, data
|
|
3278
|
+
function updateStringsInObjectExpression(objectExpression, data) {
|
|
3264
3279
|
let modified = false;
|
|
3265
3280
|
objectExpression.properties.forEach((prop) => {
|
|
3266
|
-
if (t.isObjectProperty(prop))
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
}
|
|
3277
|
-
} else if (t.isObjectExpression(prop.value)) {
|
|
3278
|
-
if (data[key] && typeof data[key] === "object") {
|
|
3279
|
-
const subModified = updateStringsInObjectExpression(prop.value, data[key], "");
|
|
3280
|
-
modified = subModified || modified;
|
|
3281
|
-
} else {
|
|
3282
|
-
const subModified = updateStringsInObjectExpression(prop.value, data, currentPath);
|
|
3283
|
-
modified = subModified || modified;
|
|
3284
|
-
}
|
|
3285
|
-
} else if (t.isArrayExpression(prop.value)) {
|
|
3286
|
-
if (data[key] && Array.isArray(data[key])) {
|
|
3287
|
-
const subModified = updateStringsInArrayExpression(prop.value, data[key], "");
|
|
3288
|
-
modified = subModified || modified;
|
|
3289
|
-
} else {
|
|
3290
|
-
const subModified = updateStringsInArrayExpression(prop.value, data, currentPath);
|
|
3291
|
-
modified = subModified || modified;
|
|
3292
|
-
}
|
|
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;
|
|
3293
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;
|
|
3294
3304
|
}
|
|
3295
3305
|
});
|
|
3296
3306
|
return modified;
|
|
3297
3307
|
}
|
|
3298
|
-
function updateStringsInArrayExpression(arrayExpression,
|
|
3308
|
+
function updateStringsInArrayExpression(arrayExpression, incoming) {
|
|
3299
3309
|
let modified = false;
|
|
3300
3310
|
arrayExpression.elements.forEach((element, index) => {
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
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;
|
|
3305
3317
|
modified = true;
|
|
3306
|
-
} else if (!Array.isArray(data) && data[currentPath] !== void 0) {
|
|
3307
|
-
element.value = data[currentPath];
|
|
3308
|
-
modified = true;
|
|
3309
|
-
}
|
|
3310
|
-
} else if (t.isObjectExpression(element)) {
|
|
3311
|
-
if (Array.isArray(data) && data[index] && typeof data[index] === "object") {
|
|
3312
|
-
const subModified = updateStringsInObjectExpression(element, data[index], "");
|
|
3313
|
-
modified = subModified || modified;
|
|
3314
|
-
} else {
|
|
3315
|
-
const subModified = updateStringsInObjectExpression(element, data, currentPath);
|
|
3316
|
-
modified = subModified || modified;
|
|
3317
|
-
}
|
|
3318
|
-
} else if (t.isArrayExpression(element)) {
|
|
3319
|
-
if (Array.isArray(data) && data[index] && Array.isArray(data[index])) {
|
|
3320
|
-
const subModified = updateStringsInArrayExpression(element, data[index], "");
|
|
3321
|
-
modified = subModified || modified;
|
|
3322
|
-
} else {
|
|
3323
|
-
const subModified = updateStringsInArrayExpression(element, data, currentPath);
|
|
3324
|
-
modified = subModified || modified;
|
|
3325
3318
|
}
|
|
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;
|
|
3326
3325
|
}
|
|
3327
3326
|
});
|
|
3328
3327
|
return modified;
|
|
3329
3328
|
}
|
|
3330
|
-
function updateStringsInExportedIdentifier(path17, data
|
|
3331
|
-
let modified = false;
|
|
3329
|
+
function updateStringsInExportedIdentifier(path17, data) {
|
|
3332
3330
|
const exportName = path17.node.declaration.name;
|
|
3333
3331
|
const binding = path17.scope.bindings[exportName];
|
|
3334
|
-
if (binding
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
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);
|
|
3342
3340
|
}
|
|
3343
3341
|
}
|
|
3344
|
-
return
|
|
3342
|
+
return false;
|
|
3345
3343
|
}
|
|
3346
3344
|
function getPropertyKey(prop) {
|
|
3347
3345
|
if (t.isIdentifier(prop.key)) {
|
|
@@ -3578,7 +3576,7 @@ function createMdxSectionsSplit2Loader() {
|
|
|
3578
3576
|
const content = _lodash2.default.chain(data.sections).values().join("\n\n").value();
|
|
3579
3577
|
const result = {
|
|
3580
3578
|
frontmatter: data.frontmatter,
|
|
3581
|
-
codePlaceholders: _optionalChain([pullInput, 'optionalAccess',
|
|
3579
|
+
codePlaceholders: _optionalChain([pullInput, 'optionalAccess', _148 => _148.codePlaceholders]) || {},
|
|
3582
3580
|
content
|
|
3583
3581
|
};
|
|
3584
3582
|
return result;
|
|
@@ -3987,7 +3985,7 @@ function createBasicTranslator(model, systemPrompt) {
|
|
|
3987
3985
|
]
|
|
3988
3986
|
});
|
|
3989
3987
|
const result = JSON.parse(response.text);
|
|
3990
|
-
return _optionalChain([result, 'optionalAccess',
|
|
3988
|
+
return _optionalChain([result, 'optionalAccess', _149 => _149.data]) || {};
|
|
3991
3989
|
};
|
|
3992
3990
|
}
|
|
3993
3991
|
|
|
@@ -4005,7 +4003,7 @@ function createProcessor(provider, params) {
|
|
|
4005
4003
|
}
|
|
4006
4004
|
}
|
|
4007
4005
|
function getPureModelProvider(provider) {
|
|
4008
|
-
switch (_optionalChain([provider, 'optionalAccess',
|
|
4006
|
+
switch (_optionalChain([provider, 'optionalAccess', _150 => _150.id])) {
|
|
4009
4007
|
case "openai":
|
|
4010
4008
|
if (!process.env.OPENAI_API_KEY) {
|
|
4011
4009
|
throw new Error("OPENAI_API_KEY is not set.");
|
|
@@ -4022,7 +4020,7 @@ function getPureModelProvider(provider) {
|
|
|
4022
4020
|
apiKey: process.env.ANTHROPIC_API_KEY
|
|
4023
4021
|
})(provider.model);
|
|
4024
4022
|
default:
|
|
4025
|
-
throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess',
|
|
4023
|
+
throw new Error(`Unsupported provider: ${_optionalChain([provider, 'optionalAccess', _151 => _151.id])}`);
|
|
4026
4024
|
}
|
|
4027
4025
|
}
|
|
4028
4026
|
|
|
@@ -4043,11 +4041,14 @@ function withExponentialBackoff(fn, maxAttempts = 3, baseDelay = 1e3) {
|
|
|
4043
4041
|
}
|
|
4044
4042
|
|
|
4045
4043
|
// src/cli/utils/observability.ts
|
|
4044
|
+
var _nodemachineid = require('node-machine-id'); var _nodemachineid2 = _interopRequireDefault(_nodemachineid);
|
|
4045
|
+
var { machineIdSync } = _nodemachineid2.default;
|
|
4046
4046
|
async function trackEvent(distinctId, event, properties) {
|
|
4047
4047
|
if (process.env.DO_NOT_TRACK) {
|
|
4048
4048
|
return;
|
|
4049
4049
|
}
|
|
4050
4050
|
try {
|
|
4051
|
+
const actualId = distinctId || `device-${machineIdSync()}`;
|
|
4051
4052
|
const { PostHog } = await Promise.resolve().then(() => _interopRequireWildcard(require("posthog-node")));
|
|
4052
4053
|
const safeProperties = properties ? JSON.parse(
|
|
4053
4054
|
JSON.stringify(properties, (key, value) => {
|
|
@@ -4070,7 +4071,7 @@ async function trackEvent(distinctId, event, properties) {
|
|
|
4070
4071
|
}
|
|
4071
4072
|
);
|
|
4072
4073
|
await posthog.capture({
|
|
4073
|
-
distinctId,
|
|
4074
|
+
distinctId: actualId,
|
|
4074
4075
|
event,
|
|
4075
4076
|
properties: {
|
|
4076
4077
|
...safeProperties,
|
|
@@ -4256,24 +4257,30 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4256
4257
|
validateParams(i18nConfig, flags);
|
|
4257
4258
|
ora.succeed("Localization configuration is valid");
|
|
4258
4259
|
ora.start("Connecting to Lingo.dev Localization Engine...");
|
|
4259
|
-
const
|
|
4260
|
-
|
|
4261
|
-
|
|
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
|
+
}
|
|
4262
4269
|
trackEvent(authId, "cmd.i18n.start", {
|
|
4263
4270
|
i18nConfig,
|
|
4264
4271
|
flags
|
|
4265
4272
|
});
|
|
4266
4273
|
let buckets = getBuckets(i18nConfig);
|
|
4267
|
-
if (_optionalChain([flags, 'access',
|
|
4274
|
+
if (_optionalChain([flags, 'access', _153 => _153.bucket, 'optionalAccess', _154 => _154.length])) {
|
|
4268
4275
|
buckets = buckets.filter(
|
|
4269
4276
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
4270
4277
|
);
|
|
4271
4278
|
}
|
|
4272
4279
|
ora.succeed("Buckets retrieved");
|
|
4273
|
-
if (_optionalChain([flags, 'access',
|
|
4280
|
+
if (_optionalChain([flags, 'access', _155 => _155.file, 'optionalAccess', _156 => _156.length])) {
|
|
4274
4281
|
buckets = buckets.map((bucket) => {
|
|
4275
4282
|
const paths = bucket.paths.filter(
|
|
4276
|
-
(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)]))
|
|
4277
4284
|
);
|
|
4278
4285
|
return { ...bucket, paths };
|
|
4279
4286
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
@@ -4292,7 +4299,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4292
4299
|
});
|
|
4293
4300
|
}
|
|
4294
4301
|
}
|
|
4295
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
4302
|
+
const targetLocales = _optionalChain([flags, 'access', _160 => _160.locale, 'optionalAccess', _161 => _161.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
4296
4303
|
ora.start("Setting up localization cache...");
|
|
4297
4304
|
const checkLockfileProcessor = createDeltaProcessor("");
|
|
4298
4305
|
const lockfileExists = await checkLockfileProcessor.checkIfLockExists();
|
|
@@ -4635,7 +4642,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
4635
4642
|
console.log();
|
|
4636
4643
|
if (!hasErrors) {
|
|
4637
4644
|
ora.succeed("Localization completed.");
|
|
4638
|
-
trackEvent(
|
|
4645
|
+
trackEvent(authId, "cmd.i18n.success", {
|
|
4639
4646
|
i18nConfig,
|
|
4640
4647
|
flags
|
|
4641
4648
|
});
|
|
@@ -4697,12 +4704,12 @@ function validateParams(i18nConfig, flags) {
|
|
|
4697
4704
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
4698
4705
|
docUrl: "bucketNotFound"
|
|
4699
4706
|
});
|
|
4700
|
-
} 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))])) {
|
|
4701
4708
|
throw new CLIError({
|
|
4702
4709
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
4703
4710
|
docUrl: "localeTargetNotFound"
|
|
4704
4711
|
});
|
|
4705
|
-
} else if (_optionalChain([flags, 'access',
|
|
4712
|
+
} else if (_optionalChain([flags, 'access', _165 => _165.bucket, 'optionalAccess', _166 => _166.some, 'call', _167 => _167(
|
|
4706
4713
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
4707
4714
|
)])) {
|
|
4708
4715
|
throw new CLIError({
|
|
@@ -5167,7 +5174,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5167
5174
|
_child_process.execSync.call(void 0, `git config --global safe.directory ${process.cwd()}`);
|
|
5168
5175
|
_child_process.execSync.call(void 0, `git config user.name "${gitConfig.userName}"`);
|
|
5169
5176
|
_child_process.execSync.call(void 0, `git config user.email "${gitConfig.userEmail}"`);
|
|
5170
|
-
_optionalChain([this, 'access',
|
|
5177
|
+
_optionalChain([this, 'access', _168 => _168.platformKit, 'optionalAccess', _169 => _169.gitConfig, 'call', _170 => _170()]);
|
|
5171
5178
|
_child_process.execSync.call(void 0, `git fetch origin ${baseBranchName}`, { stdio: "inherit" });
|
|
5172
5179
|
_child_process.execSync.call(void 0, `git checkout ${baseBranchName} --`, { stdio: "inherit" });
|
|
5173
5180
|
if (!processOwnCommits) {
|
|
@@ -5199,7 +5206,7 @@ var InBranchFlow = class extends IntegrationFlow {
|
|
|
5199
5206
|
// src/cli/cmd/ci/flows/pull-request.ts
|
|
5200
5207
|
var PullRequestFlow = class extends InBranchFlow {
|
|
5201
5208
|
async preRun() {
|
|
5202
|
-
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall',
|
|
5209
|
+
const canContinue = await _optionalChain([super.preRun.bind(this), 'optionalCall', _171 => _171()]);
|
|
5203
5210
|
if (!canContinue) {
|
|
5204
5211
|
return false;
|
|
5205
5212
|
}
|
|
@@ -5451,10 +5458,10 @@ var BitbucketPlatformKit = class extends PlatformKit {
|
|
|
5451
5458
|
repo_slug: this.platformConfig.repositoryName,
|
|
5452
5459
|
state: "OPEN"
|
|
5453
5460
|
}).then(({ data: { values } }) => {
|
|
5454
|
-
return _optionalChain([values, 'optionalAccess',
|
|
5455
|
-
({ 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
|
|
5456
5463
|
)]);
|
|
5457
|
-
}).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
5464
|
+
}).then((pr) => _optionalChain([pr, 'optionalAccess', _178 => _178.id]));
|
|
5458
5465
|
}
|
|
5459
5466
|
async closePullRequest({ pullRequestNumber }) {
|
|
5460
5467
|
await this.bb.repositories.declinePullRequest({
|
|
@@ -5550,7 +5557,7 @@ var GitHubPlatformKit = class extends PlatformKit {
|
|
|
5550
5557
|
repo: this.platformConfig.repositoryName,
|
|
5551
5558
|
base: this.platformConfig.baseBranchName,
|
|
5552
5559
|
state: "open"
|
|
5553
|
-
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess',
|
|
5560
|
+
}).then(({ data }) => data[0]).then((pr) => _optionalChain([pr, 'optionalAccess', _179 => _179.number]));
|
|
5554
5561
|
}
|
|
5555
5562
|
async closePullRequest({ pullRequestNumber }) {
|
|
5556
5563
|
await this.octokit.rest.pulls.update({
|
|
@@ -5677,7 +5684,7 @@ var GitlabPlatformKit = class extends PlatformKit {
|
|
|
5677
5684
|
sourceBranch: branch,
|
|
5678
5685
|
state: "opened"
|
|
5679
5686
|
});
|
|
5680
|
-
return _optionalChain([mergeRequests, 'access',
|
|
5687
|
+
return _optionalChain([mergeRequests, 'access', _180 => _180[0], 'optionalAccess', _181 => _181.iid]);
|
|
5681
5688
|
}
|
|
5682
5689
|
async closePullRequest({
|
|
5683
5690
|
pullRequestNumber
|
|
@@ -5761,7 +5768,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5761
5768
|
}
|
|
5762
5769
|
const env = {
|
|
5763
5770
|
LINGODOTDEV_API_KEY: settings.auth.apiKey,
|
|
5764
|
-
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access',
|
|
5771
|
+
LINGODOTDEV_PULL_REQUEST: _optionalChain([options, 'access', _182 => _182.pullRequest, 'optionalAccess', _183 => _183.toString, 'call', _184 => _184()]) || "false",
|
|
5765
5772
|
...options.commitMessage && {
|
|
5766
5773
|
LINGODOTDEV_COMMIT_MESSAGE: options.commitMessage
|
|
5767
5774
|
},
|
|
@@ -5781,7 +5788,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5781
5788
|
const { isPullRequestMode } = platformKit.config;
|
|
5782
5789
|
ora.info(`Pull request mode: ${isPullRequestMode ? "on" : "off"}`);
|
|
5783
5790
|
const flow = isPullRequestMode ? new PullRequestFlow(ora, platformKit) : new InBranchFlow(ora, platformKit);
|
|
5784
|
-
const canRun = await _optionalChain([flow, 'access',
|
|
5791
|
+
const canRun = await _optionalChain([flow, 'access', _185 => _185.preRun, 'optionalCall', _186 => _186()]);
|
|
5785
5792
|
if (canRun === false) {
|
|
5786
5793
|
return;
|
|
5787
5794
|
}
|
|
@@ -5789,7 +5796,7 @@ var ci_default = new (0, _interactivecommander.Command)().command("ci").descript
|
|
|
5789
5796
|
if (!hasChanges) {
|
|
5790
5797
|
return;
|
|
5791
5798
|
}
|
|
5792
|
-
await _optionalChain([flow, 'access',
|
|
5799
|
+
await _optionalChain([flow, 'access', _187 => _187.postRun, 'optionalCall', _188 => _188()]);
|
|
5793
5800
|
});
|
|
5794
5801
|
|
|
5795
5802
|
// src/cli/cmd/status.ts
|
|
@@ -5833,13 +5840,13 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5833
5840
|
flags
|
|
5834
5841
|
});
|
|
5835
5842
|
let buckets = getBuckets(i18nConfig);
|
|
5836
|
-
if (_optionalChain([flags, 'access',
|
|
5843
|
+
if (_optionalChain([flags, 'access', _189 => _189.bucket, 'optionalAccess', _190 => _190.length])) {
|
|
5837
5844
|
buckets = buckets.filter((bucket) => flags.bucket.includes(bucket.type));
|
|
5838
5845
|
}
|
|
5839
5846
|
ora.succeed("Buckets retrieved");
|
|
5840
|
-
if (_optionalChain([flags, 'access',
|
|
5847
|
+
if (_optionalChain([flags, 'access', _191 => _191.file, 'optionalAccess', _192 => _192.length])) {
|
|
5841
5848
|
buckets = buckets.map((bucket) => {
|
|
5842
|
-
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)])));
|
|
5843
5850
|
return { ...bucket, paths };
|
|
5844
5851
|
}).filter((bucket) => bucket.paths.length > 0);
|
|
5845
5852
|
if (buckets.length === 0) {
|
|
@@ -5855,7 +5862,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
5855
5862
|
});
|
|
5856
5863
|
}
|
|
5857
5864
|
}
|
|
5858
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
5865
|
+
const targetLocales = _optionalChain([flags, 'access', _196 => _196.locale, 'optionalAccess', _197 => _197.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
5859
5866
|
let totalSourceKeyCount = 0;
|
|
5860
5867
|
let uniqueKeysToTranslate = 0;
|
|
5861
5868
|
let totalExistingTranslations = 0;
|
|
@@ -6196,12 +6203,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
6196
6203
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
6197
6204
|
docUrl: "bucketNotFound"
|
|
6198
6205
|
});
|
|
6199
|
-
} 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))])) {
|
|
6200
6207
|
throw new CLIError({
|
|
6201
6208
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
6202
6209
|
docUrl: "localeTargetNotFound"
|
|
6203
6210
|
});
|
|
6204
|
-
} 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])])) {
|
|
6205
6212
|
throw new CLIError({
|
|
6206
6213
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
6207
6214
|
docUrl: "bucketNotFound"
|
|
@@ -6284,7 +6291,7 @@ async function renderHero() {
|
|
|
6284
6291
|
// package.json
|
|
6285
6292
|
var package_default = {
|
|
6286
6293
|
name: "lingo.dev",
|
|
6287
|
-
version: "0.92.
|
|
6294
|
+
version: "0.92.4",
|
|
6288
6295
|
description: "Lingo.dev CLI",
|
|
6289
6296
|
private: false,
|
|
6290
6297
|
publishConfig: {
|