lingo.dev 0.111.0 → 0.111.2
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/README.md +6 -0
- package/build/cli.cjs +72 -30
- package/build/cli.cjs.map +1 -1
- package/build/cli.mjs +65 -23
- package/build/cli.mjs.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
<a href="https://github.com/lingodotdev/lingo.dev/commits/main">
|
|
28
28
|
<img src="https://img.shields.io/github/last-commit/lingodotdev/lingo.dev" alt="Last Commit" />
|
|
29
29
|
</a>
|
|
30
|
+
<a href="https://lingo.dev/en">
|
|
31
|
+
<img src="https://img.shields.io/badge/Product%20Hunt-%231%20Product%20of%20the%20Day-orange?logo=producthunt&style=flat-square" alt="Product Hunt #1 Product of the Day" />
|
|
32
|
+
</a>
|
|
33
|
+
<a href="https://lingo.dev/en">
|
|
34
|
+
<img src="https://img.shields.io/badge/GitHub-Trending-blue?logo=github&style=flat-square" alt="Github trending" />
|
|
35
|
+
</a>
|
|
30
36
|
</p>
|
|
31
37
|
|
|
32
38
|
---
|
package/build/cli.cjs
CHANGED
|
@@ -7464,21 +7464,25 @@ function withExponentialBackoff(fn, maxAttempts = 3, baseDelay = 1e3) {
|
|
|
7464
7464
|
// src/cli/utils/observability.ts
|
|
7465
7465
|
var _nodemachineid = require('node-machine-id'); var _nodemachineid2 = _interopRequireDefault(_nodemachineid);
|
|
7466
7466
|
var { machineIdSync } = _nodemachineid2.default;
|
|
7467
|
+
async function createPosthogClient() {
|
|
7468
|
+
const { PostHog } = await Promise.resolve().then(() => _interopRequireWildcard(require("posthog-node")));
|
|
7469
|
+
const posthog = new PostHog(
|
|
7470
|
+
"phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk",
|
|
7471
|
+
{
|
|
7472
|
+
host: "https://eu.i.posthog.com",
|
|
7473
|
+
flushAt: 1,
|
|
7474
|
+
flushInterval: 0
|
|
7475
|
+
}
|
|
7476
|
+
);
|
|
7477
|
+
return posthog;
|
|
7478
|
+
}
|
|
7467
7479
|
async function trackEvent(distinctId, event, properties) {
|
|
7468
7480
|
if (process.env.DO_NOT_TRACK) {
|
|
7469
7481
|
return;
|
|
7470
7482
|
}
|
|
7471
7483
|
try {
|
|
7472
7484
|
const actualId = distinctId || `device-${machineIdSync()}`;
|
|
7473
|
-
const
|
|
7474
|
-
const posthog = new PostHog(
|
|
7475
|
-
"phc_eR0iSoQufBxNY36k0f0T15UvHJdTfHlh8rJcxsfhfXk",
|
|
7476
|
-
{
|
|
7477
|
-
host: "https://eu.i.posthog.com",
|
|
7478
|
-
flushAt: 1,
|
|
7479
|
-
flushInterval: 0
|
|
7480
|
-
}
|
|
7481
|
-
);
|
|
7485
|
+
const posthog = await createPosthogClient();
|
|
7482
7486
|
await posthog.capture({
|
|
7483
7487
|
distinctId: actualId,
|
|
7484
7488
|
event,
|
|
@@ -7490,7 +7494,6 @@ async function trackEvent(distinctId, event, properties) {
|
|
|
7490
7494
|
}
|
|
7491
7495
|
}
|
|
7492
7496
|
});
|
|
7493
|
-
await posthog.shutdown();
|
|
7494
7497
|
} catch (error) {
|
|
7495
7498
|
if (process.env.DEBUG) {
|
|
7496
7499
|
console.error(error);
|
|
@@ -7689,7 +7692,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7689
7692
|
authId = auth.id;
|
|
7690
7693
|
ora.succeed(`Authenticated as ${auth.email}`);
|
|
7691
7694
|
}
|
|
7692
|
-
trackEvent(authId, "cmd.i18n.start", {
|
|
7695
|
+
await trackEvent(authId, "cmd.i18n.start", {
|
|
7693
7696
|
i18nConfig,
|
|
7694
7697
|
flags
|
|
7695
7698
|
});
|
|
@@ -7711,7 +7714,9 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7711
7714
|
ora.fail(
|
|
7712
7715
|
"No buckets found. All buckets were filtered out by --file option."
|
|
7713
7716
|
);
|
|
7714
|
-
|
|
7717
|
+
throw new Error(
|
|
7718
|
+
"No buckets found. All buckets were filtered out by --file option."
|
|
7719
|
+
);
|
|
7715
7720
|
} else {
|
|
7716
7721
|
ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
|
|
7717
7722
|
buckets.map((bucket) => {
|
|
@@ -7836,7 +7841,9 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
7836
7841
|
`Localization data has changed; please update i18n.lock or run without --frozen.`
|
|
7837
7842
|
);
|
|
7838
7843
|
ora.fail(` Details: ${message}`);
|
|
7839
|
-
|
|
7844
|
+
throw new Error(
|
|
7845
|
+
`Localization data has changed; please update i18n.lock or run without --frozen. Details: ${message}`
|
|
7846
|
+
);
|
|
7840
7847
|
} else {
|
|
7841
7848
|
ora.succeed("No lockfile updates required.");
|
|
7842
7849
|
}
|
|
@@ -8000,23 +8007,22 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
|
|
|
8000
8007
|
console.log();
|
|
8001
8008
|
if (!hasErrors) {
|
|
8002
8009
|
ora.succeed("Localization completed.");
|
|
8003
|
-
trackEvent(authId, "cmd.i18n.success", {
|
|
8010
|
+
await trackEvent(authId, "cmd.i18n.success", {
|
|
8004
8011
|
i18nConfig,
|
|
8005
8012
|
flags
|
|
8006
8013
|
});
|
|
8007
8014
|
} else {
|
|
8008
8015
|
ora.warn("Localization completed with errors.");
|
|
8009
|
-
trackEvent(authId || "unknown", "cmd.i18n.error", {
|
|
8016
|
+
await trackEvent(authId || "unknown", "cmd.i18n.error", {
|
|
8010
8017
|
flags
|
|
8011
8018
|
});
|
|
8012
8019
|
}
|
|
8013
8020
|
} catch (error) {
|
|
8014
8021
|
ora.fail(error.message);
|
|
8015
|
-
trackEvent(authId || "unknown", "cmd.i18n.error", {
|
|
8022
|
+
await trackEvent(authId || "unknown", "cmd.i18n.error", {
|
|
8016
8023
|
flags,
|
|
8017
8024
|
error
|
|
8018
8025
|
});
|
|
8019
|
-
process.exit(1);
|
|
8020
8026
|
}
|
|
8021
8027
|
});
|
|
8022
8028
|
function parseFlags(options) {
|
|
@@ -9464,7 +9470,7 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
|
|
|
9464
9470
|
await renderSpacer();
|
|
9465
9471
|
await setup(ctx);
|
|
9466
9472
|
authId = await determineAuthId(ctx);
|
|
9467
|
-
trackEvent(authId, "cmd.run.start", {
|
|
9473
|
+
await trackEvent(authId, "cmd.run.start", {
|
|
9468
9474
|
config: ctx.config,
|
|
9469
9475
|
flags: ctx.flags
|
|
9470
9476
|
});
|
|
@@ -9478,13 +9484,13 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
|
|
|
9478
9484
|
if (ctx.flags.watch) {
|
|
9479
9485
|
await watch2(ctx);
|
|
9480
9486
|
}
|
|
9481
|
-
trackEvent(authId, "cmd.run.success", {
|
|
9487
|
+
await trackEvent(authId, "cmd.run.success", {
|
|
9482
9488
|
config: ctx.config,
|
|
9483
9489
|
flags: ctx.flags
|
|
9484
9490
|
});
|
|
9485
9491
|
} catch (error) {
|
|
9486
|
-
trackEvent(authId || "unknown", "cmd.run.error", {});
|
|
9487
|
-
|
|
9492
|
+
await trackEvent(authId || "unknown", "cmd.run.error", {});
|
|
9493
|
+
throw error;
|
|
9488
9494
|
}
|
|
9489
9495
|
});
|
|
9490
9496
|
|
|
@@ -10221,6 +10227,41 @@ function parseBooleanArg(val) {
|
|
|
10221
10227
|
|
|
10222
10228
|
|
|
10223
10229
|
var _clitable3 = require('cli-table3'); var _clitable32 = _interopRequireDefault(_clitable3);
|
|
10230
|
+
|
|
10231
|
+
// src/cli/utils/exit-gracefully.ts
|
|
10232
|
+
var STEP_WAIT_INTERVAL = 250;
|
|
10233
|
+
var MAX_WAIT_INTERVAL = 2e3;
|
|
10234
|
+
function exitGracefully(elapsedMs = 0) {
|
|
10235
|
+
const hasPendingOperations = checkForPendingOperations();
|
|
10236
|
+
if (hasPendingOperations && elapsedMs < MAX_WAIT_INTERVAL) {
|
|
10237
|
+
setTimeout(
|
|
10238
|
+
() => exitGracefully(elapsedMs + STEP_WAIT_INTERVAL),
|
|
10239
|
+
STEP_WAIT_INTERVAL
|
|
10240
|
+
);
|
|
10241
|
+
} else {
|
|
10242
|
+
process.exit(0);
|
|
10243
|
+
}
|
|
10244
|
+
}
|
|
10245
|
+
function checkForPendingOperations() {
|
|
10246
|
+
const activeHandles = _optionalChain([process, 'access', _314 => _314._getActiveHandles, 'optionalCall', _315 => _315()]) || [];
|
|
10247
|
+
const activeRequests = _optionalChain([process, 'access', _316 => _316._getActiveRequests, 'optionalCall', _317 => _317()]) || [];
|
|
10248
|
+
const nonStandardHandles = activeHandles.filter((handle) => {
|
|
10249
|
+
if (handle === process.stdin || handle === process.stdout || handle === process.stderr) {
|
|
10250
|
+
return false;
|
|
10251
|
+
}
|
|
10252
|
+
if (handle && typeof handle === "object" && "hasRef" in handle && !handle.hasRef()) {
|
|
10253
|
+
return false;
|
|
10254
|
+
}
|
|
10255
|
+
return true;
|
|
10256
|
+
});
|
|
10257
|
+
const hasFileWatchers = nonStandardHandles.some(
|
|
10258
|
+
(handle) => handle && typeof handle === "object" && "close" in handle
|
|
10259
|
+
);
|
|
10260
|
+
const hasPendingPromises = activeRequests.length > 0;
|
|
10261
|
+
return nonStandardHandles.length > 0 || hasFileWatchers || hasPendingPromises;
|
|
10262
|
+
}
|
|
10263
|
+
|
|
10264
|
+
// src/cli/cmd/status.ts
|
|
10224
10265
|
var status_default = new (0, _interactivecommander.Command)().command("status").description("Show the status of the localization process").helpOption("-h, --help", "Show help").option(
|
|
10225
10266
|
"--locale <locale>",
|
|
10226
10267
|
"Locale to process",
|
|
@@ -10269,17 +10310,17 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
10269
10310
|
flags
|
|
10270
10311
|
});
|
|
10271
10312
|
let buckets = getBuckets(i18nConfig);
|
|
10272
|
-
if (_optionalChain([flags, 'access',
|
|
10313
|
+
if (_optionalChain([flags, 'access', _318 => _318.bucket, 'optionalAccess', _319 => _319.length])) {
|
|
10273
10314
|
buckets = buckets.filter(
|
|
10274
10315
|
(bucket) => flags.bucket.includes(bucket.type)
|
|
10275
10316
|
);
|
|
10276
10317
|
}
|
|
10277
10318
|
ora.succeed("Buckets retrieved");
|
|
10278
|
-
if (_optionalChain([flags, 'access',
|
|
10319
|
+
if (_optionalChain([flags, 'access', _320 => _320.file, 'optionalAccess', _321 => _321.length])) {
|
|
10279
10320
|
buckets = buckets.map((bucket) => {
|
|
10280
10321
|
const paths = bucket.paths.filter(
|
|
10281
10322
|
(path17) => flags.file.find(
|
|
10282
|
-
(file) => _optionalChain([path17, 'access',
|
|
10323
|
+
(file) => _optionalChain([path17, 'access', _322 => _322.pathPattern, 'optionalAccess', _323 => _323.includes, 'call', _324 => _324(file)]) || _optionalChain([path17, 'access', _325 => _325.pathPattern, 'optionalAccess', _326 => _326.match, 'call', _327 => _327(file)]) || minimatch(path17.pathPattern, file)
|
|
10283
10324
|
)
|
|
10284
10325
|
);
|
|
10285
10326
|
return { ...bucket, paths };
|
|
@@ -10299,7 +10340,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
10299
10340
|
});
|
|
10300
10341
|
}
|
|
10301
10342
|
}
|
|
10302
|
-
const targetLocales = _optionalChain([flags, 'access',
|
|
10343
|
+
const targetLocales = _optionalChain([flags, 'access', _328 => _328.locale, 'optionalAccess', _329 => _329.length]) ? flags.locale : i18nConfig.locale.targets;
|
|
10303
10344
|
let totalSourceKeyCount = 0;
|
|
10304
10345
|
let uniqueKeysToTranslate = 0;
|
|
10305
10346
|
let totalExistingTranslations = 0;
|
|
@@ -10656,6 +10697,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
|
|
|
10656
10697
|
totalWordsToTranslate,
|
|
10657
10698
|
authenticated: !!authId
|
|
10658
10699
|
});
|
|
10700
|
+
exitGracefully();
|
|
10659
10701
|
} catch (error) {
|
|
10660
10702
|
ora.fail(error.message);
|
|
10661
10703
|
trackEvent(authId || "status", "cmd.status.error", {
|
|
@@ -10703,12 +10745,12 @@ function validateParams2(i18nConfig, flags) {
|
|
|
10703
10745
|
message: "No buckets found in i18n.json. Please add at least one bucket containing i18n content.",
|
|
10704
10746
|
docUrl: "bucketNotFound"
|
|
10705
10747
|
});
|
|
10706
|
-
} else if (_optionalChain([flags, 'access',
|
|
10748
|
+
} else if (_optionalChain([flags, 'access', _330 => _330.locale, 'optionalAccess', _331 => _331.some, 'call', _332 => _332((locale) => !i18nConfig.locale.targets.includes(locale))])) {
|
|
10707
10749
|
throw new CLIError({
|
|
10708
10750
|
message: `One or more specified locales do not exist in i18n.json locale.targets. Please add them to the list and try again.`,
|
|
10709
10751
|
docUrl: "localeTargetNotFound"
|
|
10710
10752
|
});
|
|
10711
|
-
} else if (_optionalChain([flags, 'access',
|
|
10753
|
+
} else if (_optionalChain([flags, 'access', _333 => _333.bucket, 'optionalAccess', _334 => _334.some, 'call', _335 => _335(
|
|
10712
10754
|
(bucket) => !i18nConfig.buckets[bucket]
|
|
10713
10755
|
)])) {
|
|
10714
10756
|
throw new CLIError({
|
|
@@ -10800,7 +10842,7 @@ async function renderHero2() {
|
|
|
10800
10842
|
// package.json
|
|
10801
10843
|
var package_default = {
|
|
10802
10844
|
name: "lingo.dev",
|
|
10803
|
-
version: "0.111.
|
|
10845
|
+
version: "0.111.2",
|
|
10804
10846
|
description: "Lingo.dev CLI",
|
|
10805
10847
|
private: false,
|
|
10806
10848
|
publishConfig: {
|
|
@@ -10982,7 +11024,7 @@ var package_default = {
|
|
|
10982
11024
|
"p-limit": "^6.2.0",
|
|
10983
11025
|
"php-array-reader": "^2.1.2",
|
|
10984
11026
|
plist: "^3.1.0",
|
|
10985
|
-
"posthog-node": "^5.
|
|
11027
|
+
"posthog-node": "^5.8.1",
|
|
10986
11028
|
prettier: "^3.4.2",
|
|
10987
11029
|
react: "^18.3.1",
|
|
10988
11030
|
"rehype-stringify": "^10.0.1",
|
|
@@ -11077,7 +11119,7 @@ var purge_default = new (0, _interactivecommander.Command)().command("purge").de
|
|
|
11077
11119
|
if (options.file && options.file.length) {
|
|
11078
11120
|
buckets = buckets.map((bucket) => {
|
|
11079
11121
|
const paths = bucket.paths.filter(
|
|
11080
|
-
(bucketPath) => _optionalChain([options, 'access',
|
|
11122
|
+
(bucketPath) => _optionalChain([options, 'access', _336 => _336.file, 'optionalAccess', _337 => _337.some, 'call', _338 => _338((f) => bucketPath.pathPattern.includes(f))])
|
|
11081
11123
|
);
|
|
11082
11124
|
return { ...bucket, paths };
|
|
11083
11125
|
}).filter((bucket) => bucket.paths.length > 0);
|