lingo.dev 0.111.4 → 0.111.6
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 +335 -129
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +223 -17
- package/build/cli.mjs.map +1 -1
- package/package.json +4 -4
package/build/cli.mjs
CHANGED
|
@@ -216,6 +216,7 @@ var docLinks = {
|
|
|
216
216
|
};
|
|
217
217
|
var CLIError = class extends Error {
|
|
218
218
|
docUrl;
|
|
219
|
+
errorType = "cli_error";
|
|
219
220
|
constructor({ message, docUrl }) {
|
|
220
221
|
super(message);
|
|
221
222
|
this.docUrl = docLinks[docUrl];
|
|
@@ -223,6 +224,137 @@ var CLIError = class extends Error {
|
|
|
223
224
|
visit: ${this.docUrl}`;
|
|
224
225
|
}
|
|
225
226
|
};
|
|
227
|
+
var ConfigError = class extends CLIError {
|
|
228
|
+
errorType = "config_error";
|
|
229
|
+
constructor({ message, docUrl }) {
|
|
230
|
+
super({ message, docUrl });
|
|
231
|
+
this.name = "ConfigError";
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
var AuthenticationError = class extends CLIError {
|
|
235
|
+
errorType = "auth_error";
|
|
236
|
+
constructor({ message, docUrl }) {
|
|
237
|
+
super({ message, docUrl });
|
|
238
|
+
this.name = "AuthenticationError";
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
var ValidationError = class extends CLIError {
|
|
242
|
+
errorType = "validation_error";
|
|
243
|
+
constructor({ message, docUrl }) {
|
|
244
|
+
super({ message, docUrl });
|
|
245
|
+
this.name = "ValidationError";
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
var LocalizationError = class extends Error {
|
|
249
|
+
errorType = "locale_error";
|
|
250
|
+
bucket;
|
|
251
|
+
sourceLocale;
|
|
252
|
+
targetLocale;
|
|
253
|
+
pathPattern;
|
|
254
|
+
constructor(message, context) {
|
|
255
|
+
super(message);
|
|
256
|
+
this.name = "LocalizationError";
|
|
257
|
+
this.bucket = context?.bucket;
|
|
258
|
+
this.sourceLocale = context?.sourceLocale;
|
|
259
|
+
this.targetLocale = context?.targetLocale;
|
|
260
|
+
this.pathPattern = context?.pathPattern;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
var BucketProcessingError = class extends Error {
|
|
264
|
+
errorType = "bucket_error";
|
|
265
|
+
bucket;
|
|
266
|
+
constructor(message, bucket) {
|
|
267
|
+
super(message);
|
|
268
|
+
this.name = "BucketProcessingError";
|
|
269
|
+
this.bucket = bucket;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
function isConfigError(error) {
|
|
273
|
+
return error instanceof ConfigError || error.errorType === "config_error";
|
|
274
|
+
}
|
|
275
|
+
function isAuthenticationError(error) {
|
|
276
|
+
return error instanceof AuthenticationError || error.errorType === "auth_error";
|
|
277
|
+
}
|
|
278
|
+
function isValidationError(error) {
|
|
279
|
+
return error instanceof ValidationError || error.errorType === "validation_error";
|
|
280
|
+
}
|
|
281
|
+
function isLocalizationError(error) {
|
|
282
|
+
return error instanceof LocalizationError || error.errorType === "locale_error";
|
|
283
|
+
}
|
|
284
|
+
function isBucketProcessingError(error) {
|
|
285
|
+
return error instanceof BucketProcessingError || error.errorType === "bucket_error";
|
|
286
|
+
}
|
|
287
|
+
function getCLIErrorType(error) {
|
|
288
|
+
if (isConfigError(error)) return "config_error";
|
|
289
|
+
if (isAuthenticationError(error)) return "auth_error";
|
|
290
|
+
if (isValidationError(error)) return "validation_error";
|
|
291
|
+
if (isLocalizationError(error)) return "locale_error";
|
|
292
|
+
if (isBucketProcessingError(error)) return "bucket_error";
|
|
293
|
+
if (error instanceof CLIError) return "cli_error";
|
|
294
|
+
return "unknown_error";
|
|
295
|
+
}
|
|
296
|
+
function createPreviousErrorContext(errorDetails) {
|
|
297
|
+
if (errorDetails.length === 0) return void 0;
|
|
298
|
+
return {
|
|
299
|
+
count: errorDetails.length,
|
|
300
|
+
types: [...new Set(errorDetails.map((e) => e.type))],
|
|
301
|
+
buckets: [...new Set(errorDetails.map((e) => e.bucket).filter(Boolean))]
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function aggregateErrorAnalytics(errorDetails, buckets, targetLocales, i18nConfig) {
|
|
305
|
+
if (errorDetails.length === 0) {
|
|
306
|
+
return {
|
|
307
|
+
errorCount: 0,
|
|
308
|
+
errorTypes: [],
|
|
309
|
+
errorsByBucket: {},
|
|
310
|
+
errorsByType: {},
|
|
311
|
+
firstError: void 0,
|
|
312
|
+
bucketCount: buckets.length,
|
|
313
|
+
localeCount: targetLocales.length,
|
|
314
|
+
i18nConfig: {
|
|
315
|
+
sourceLocale: i18nConfig.locale.source,
|
|
316
|
+
targetLocales: i18nConfig.locale.targets,
|
|
317
|
+
bucketTypes: Object.keys(i18nConfig.buckets)
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
const errorsByBucket = errorDetails.reduce(
|
|
322
|
+
(acc, error) => {
|
|
323
|
+
if (error.bucket) {
|
|
324
|
+
acc[error.bucket] = (acc[error.bucket] || 0) + 1;
|
|
325
|
+
}
|
|
326
|
+
return acc;
|
|
327
|
+
},
|
|
328
|
+
{}
|
|
329
|
+
);
|
|
330
|
+
const errorsByType = errorDetails.reduce(
|
|
331
|
+
(acc, error) => {
|
|
332
|
+
acc[error.type] = (acc[error.type] || 0) + 1;
|
|
333
|
+
return acc;
|
|
334
|
+
},
|
|
335
|
+
{}
|
|
336
|
+
);
|
|
337
|
+
return {
|
|
338
|
+
errorCount: errorDetails.length,
|
|
339
|
+
errorTypes: [...new Set(errorDetails.map((e) => e.type))],
|
|
340
|
+
errorsByBucket,
|
|
341
|
+
errorsByType,
|
|
342
|
+
firstError: {
|
|
343
|
+
type: errorDetails[0].type,
|
|
344
|
+
bucket: errorDetails[0].bucket,
|
|
345
|
+
locale: errorDetails[0].locale,
|
|
346
|
+
pathPattern: errorDetails[0].pathPattern,
|
|
347
|
+
message: errorDetails[0].message
|
|
348
|
+
},
|
|
349
|
+
bucketCount: buckets.length,
|
|
350
|
+
localeCount: targetLocales.length,
|
|
351
|
+
i18nConfig: {
|
|
352
|
+
sourceLocale: i18nConfig.locale.source,
|
|
353
|
+
targetLocales: i18nConfig.locale.targets,
|
|
354
|
+
bucketTypes: Object.keys(i18nConfig.buckets)
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
226
358
|
|
|
227
359
|
// src/cli/utils/cloudflare-status.ts
|
|
228
360
|
async function checkCloudflareStatus() {
|
|
@@ -7483,7 +7615,11 @@ function trackEvent(distinctId, event, properties) {
|
|
|
7483
7615
|
properties: {
|
|
7484
7616
|
...properties,
|
|
7485
7617
|
$lib: "lingo.dev-cli",
|
|
7486
|
-
$lib_version: process.env.npm_package_version || "unknown"
|
|
7618
|
+
$lib_version: process.env.npm_package_version || "unknown",
|
|
7619
|
+
// Essential debugging context only
|
|
7620
|
+
node_version: process.version,
|
|
7621
|
+
is_ci: !!process.env.CI,
|
|
7622
|
+
debug_enabled: process.env.DEBUG === "true"
|
|
7487
7623
|
},
|
|
7488
7624
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
7489
7625
|
};
|
|
@@ -7683,7 +7819,21 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
|
|
|
7683
7819
|
).action(async function(options) {
|
|
7684
7820
|
updateGitignore();
|
|
7685
7821
|
const ora = Ora7();
|
|
7686
|
-
|
|
7822
|
+
let flags;
|
|
7823
|
+
try {
|
|
7824
|
+
flags = parseFlags(options);
|
|
7825
|
+
} catch (parseError) {
|
|
7826
|
+
await trackEvent("unknown", "cmd.i18n.error", {
|
|
7827
|
+
errorType: "validation_error",
|
|
7828
|
+
errorName: parseError.name || "ValidationError",
|
|
7829
|
+
errorMessage: parseError.message || "Invalid command line options",
|
|
7830
|
+
errorStack: parseError.stack,
|
|
7831
|
+
fatal: true,
|
|
7832
|
+
errorCount: 1,
|
|
7833
|
+
stage: "flag_validation"
|
|
7834
|
+
});
|
|
7835
|
+
throw parseError;
|
|
7836
|
+
}
|
|
7687
7837
|
if (flags.debug) {
|
|
7688
7838
|
const { debug } = await inquirer2.prompt([
|
|
7689
7839
|
{
|
|
@@ -7695,6 +7845,7 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
|
|
|
7695
7845
|
}
|
|
7696
7846
|
let hasErrors = false;
|
|
7697
7847
|
let authId = null;
|
|
7848
|
+
const errorDetails = [];
|
|
7698
7849
|
try {
|
|
7699
7850
|
ora.start("Loading configuration...");
|
|
7700
7851
|
const i18nConfig = getConfig();
|
|
@@ -7996,9 +8147,23 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
|
|
|
7996
8147
|
);
|
|
7997
8148
|
}
|
|
7998
8149
|
} catch (_error) {
|
|
7999
|
-
const error = new
|
|
8000
|
-
`[${sourceLocale} -> ${targetLocale}] Localization failed: ${_error.message}
|
|
8150
|
+
const error = new LocalizationError(
|
|
8151
|
+
`[${sourceLocale} -> ${targetLocale}] Localization failed: ${_error.message}`,
|
|
8152
|
+
{
|
|
8153
|
+
bucket: bucket.type,
|
|
8154
|
+
sourceLocale,
|
|
8155
|
+
targetLocale,
|
|
8156
|
+
pathPattern: bucketPath.pathPattern
|
|
8157
|
+
}
|
|
8001
8158
|
);
|
|
8159
|
+
errorDetails.push({
|
|
8160
|
+
type: "locale_error",
|
|
8161
|
+
bucket: bucket.type,
|
|
8162
|
+
locale: `${sourceLocale} -> ${targetLocale}`,
|
|
8163
|
+
pathPattern: bucketPath.pathPattern,
|
|
8164
|
+
message: _error.message,
|
|
8165
|
+
stack: _error.stack
|
|
8166
|
+
});
|
|
8002
8167
|
if (flags.strict) {
|
|
8003
8168
|
throw error;
|
|
8004
8169
|
} else {
|
|
@@ -8014,9 +8179,16 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
|
|
|
8014
8179
|
}
|
|
8015
8180
|
}
|
|
8016
8181
|
} catch (_error) {
|
|
8017
|
-
const error = new
|
|
8018
|
-
`Failed to process bucket ${bucket.type}: ${_error.message}
|
|
8182
|
+
const error = new BucketProcessingError(
|
|
8183
|
+
`Failed to process bucket ${bucket.type}: ${_error.message}`,
|
|
8184
|
+
bucket.type
|
|
8019
8185
|
);
|
|
8186
|
+
errorDetails.push({
|
|
8187
|
+
type: "bucket_error",
|
|
8188
|
+
bucket: bucket.type,
|
|
8189
|
+
message: _error.message,
|
|
8190
|
+
stack: _error.stack
|
|
8191
|
+
});
|
|
8020
8192
|
if (flags.strict) {
|
|
8021
8193
|
throw error;
|
|
8022
8194
|
} else {
|
|
@@ -8029,20 +8201,54 @@ var i18n_default = new Command12().command("i18n").description("Run Localization
|
|
|
8029
8201
|
if (!hasErrors) {
|
|
8030
8202
|
ora.succeed("Localization completed.");
|
|
8031
8203
|
await trackEvent(authId, "cmd.i18n.success", {
|
|
8032
|
-
i18nConfig
|
|
8033
|
-
|
|
8204
|
+
i18nConfig: {
|
|
8205
|
+
sourceLocale: i18nConfig.locale.source,
|
|
8206
|
+
targetLocales: i18nConfig.locale.targets,
|
|
8207
|
+
bucketTypes: Object.keys(i18nConfig.buckets)
|
|
8208
|
+
},
|
|
8209
|
+
flags,
|
|
8210
|
+
bucketCount: buckets.length,
|
|
8211
|
+
localeCount: targetLocales.length,
|
|
8212
|
+
processedSuccessfully: true
|
|
8034
8213
|
});
|
|
8035
8214
|
} else {
|
|
8036
8215
|
ora.warn("Localization completed with errors.");
|
|
8037
8216
|
await trackEvent(authId || "unknown", "cmd.i18n.error", {
|
|
8038
|
-
flags
|
|
8217
|
+
flags,
|
|
8218
|
+
...aggregateErrorAnalytics(
|
|
8219
|
+
errorDetails,
|
|
8220
|
+
buckets,
|
|
8221
|
+
targetLocales,
|
|
8222
|
+
i18nConfig
|
|
8223
|
+
)
|
|
8039
8224
|
});
|
|
8040
8225
|
}
|
|
8041
8226
|
} catch (error) {
|
|
8042
8227
|
ora.fail(error.message);
|
|
8228
|
+
const errorType = getCLIErrorType(error);
|
|
8229
|
+
let errorContext = {};
|
|
8230
|
+
if (isLocalizationError(error)) {
|
|
8231
|
+
errorContext = {
|
|
8232
|
+
bucket: error.bucket,
|
|
8233
|
+
sourceLocale: error.sourceLocale,
|
|
8234
|
+
targetLocale: error.targetLocale,
|
|
8235
|
+
pathPattern: error.pathPattern
|
|
8236
|
+
};
|
|
8237
|
+
} else if (isBucketProcessingError(error)) {
|
|
8238
|
+
errorContext = {
|
|
8239
|
+
bucket: error.bucket
|
|
8240
|
+
};
|
|
8241
|
+
}
|
|
8043
8242
|
await trackEvent(authId || "unknown", "cmd.i18n.error", {
|
|
8044
8243
|
flags,
|
|
8045
|
-
|
|
8244
|
+
errorType,
|
|
8245
|
+
errorName: error.name || "Error",
|
|
8246
|
+
errorMessage: error.message,
|
|
8247
|
+
errorStack: error.stack,
|
|
8248
|
+
errorContext,
|
|
8249
|
+
fatal: true,
|
|
8250
|
+
errorCount: errorDetails.length + 1,
|
|
8251
|
+
previousErrors: createPreviousErrorContext(errorDetails)
|
|
8046
8252
|
});
|
|
8047
8253
|
}
|
|
8048
8254
|
});
|
|
@@ -8063,7 +8269,7 @@ function parseFlags(options) {
|
|
|
8063
8269
|
}
|
|
8064
8270
|
async function validateAuth(settings) {
|
|
8065
8271
|
if (!settings.auth.apiKey) {
|
|
8066
|
-
throw new
|
|
8272
|
+
throw new AuthenticationError({
|
|
8067
8273
|
message: "Not authenticated. Please run `lingo.dev login` to authenticate.",
|
|
8068
8274
|
docUrl: "authError"
|
|
8069
8275
|
});
|
|
@@ -8074,7 +8280,7 @@ async function validateAuth(settings) {
|
|
|
8074
8280
|
});
|
|
8075
8281
|
const user = await authenticator.whoami();
|
|
8076
8282
|
if (!user) {
|
|
8077
|
-
throw new
|
|
8283
|
+
throw new AuthenticationError({
|
|
8078
8284
|
message: "Invalid API key. Please run `lingo.dev login` to authenticate.",
|
|
8079
8285
|
docUrl: "authError"
|
|
8080
8286
|
});
|
|
@@ -8083,24 +8289,24 @@ async function validateAuth(settings) {
|
|
|
8083
8289
|
}
|
|
8084
8290
|
function validateParams(i18nConfig, flags) {
|
|
8085
8291
|
if (!i18nConfig) {
|
|
8086
|
-
throw new
|
|
8292
|
+
throw new ConfigError({
|
|
8087
8293
|
message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
|
|
8088
8294
|
docUrl: "i18nNotFound"
|
|
8089
8295
|
});
|
|
8090
8296
|
} else if (!i18nConfig.buckets || !Object.keys(i18nConfig.buckets).length) {
|
|
8091
|
-
throw new
|
|
8297
|
+
throw new ConfigError({
|
|
8092
8298
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
8093
8299
|
docUrl: "bucketNotFound"
|
|
8094
8300
|
});
|
|
8095
8301
|
} else if (flags.locale?.some((locale) => !i18nConfig.locale.targets.includes(locale))) {
|
|
8096
|
-
throw new
|
|
8302
|
+
throw new ValidationError({
|
|
8097
8303
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
8098
8304
|
docUrl: "localeTargetNotFound"
|
|
8099
8305
|
});
|
|
8100
8306
|
} else if (flags.bucket?.some(
|
|
8101
8307
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
8102
8308
|
)) {
|
|
8103
|
-
throw new
|
|
8309
|
+
throw new ValidationError({
|
|
8104
8310
|
message: `One or more specified buckets do not exist in i18n.json. Please add them to the list and try again.`,
|
|
8105
8311
|
docUrl: "bucketNotFound"
|
|
8106
8312
|
});
|
|
@@ -10903,7 +11109,7 @@ async function renderHero2() {
|
|
|
10903
11109
|
// package.json
|
|
10904
11110
|
var package_default = {
|
|
10905
11111
|
name: "lingo.dev",
|
|
10906
|
-
version: "0.111.
|
|
11112
|
+
version: "0.111.6",
|
|
10907
11113
|
description: "Lingo.dev CLI",
|
|
10908
11114
|
private: false,
|
|
10909
11115
|
publishConfig: {
|