lingo.dev 0.117.23 → 0.117.25

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 CHANGED
@@ -51,20 +51,24 @@
51
51
  Install once:
52
52
 
53
53
  ```bash
54
- npm install lingo.dev
54
+ npm install @lingo.dev/compiler
55
55
  ```
56
56
 
57
57
  Enable in your build config:
58
58
 
59
- ```js
60
- import lingoCompiler from "lingo.dev/compiler";
61
-
62
- const existingNextConfig = {};
63
-
64
- export default lingoCompiler.next({
65
- sourceLocale: "en",
66
- targetLocales: ["es", "fr"],
67
- })(existingNextConfig);
59
+ ```ts
60
+ import type { NextConfig } from "next";
61
+ import { withLingo } from "@lingo.dev/compiler/next";
62
+
63
+ const nextConfig: NextConfig = {};
64
+
65
+ export default async function (): Promise<NextConfig> {
66
+ return await withLingo(nextConfig, {
67
+ sourceLocale: "en",
68
+ targetLocales: ["es", "fr"],
69
+ models: "lingo.dev",
70
+ });
71
+ }
68
72
  ```
69
73
 
70
74
  Run `next build` and watch Spanish and French bundles pop out ✨
@@ -165,7 +169,7 @@ We're community-driven and love contributions!
165
169
 
166
170
  ## ⭐ Star History
167
171
 
168
- If you like what we're doing, give us a ⭐ and help us reach 5,000 stars! 🌟
172
+ If you like what we're doing, give us a ⭐ and help us reach 6,000 stars! 🌟
169
173
 
170
174
  [![Star History Chart](https://api.star-history.com/svg?repos=lingodotdev/lingo.dev&type=Date)](https://www.star-history.com/#lingodotdev/lingo.dev&Date)
171
175
 
package/build/cli.cjs CHANGED
@@ -10860,7 +10860,17 @@ var _https = require('https'); var _https2 = _interopRequireDefault(_https);
10860
10860
 
10861
10861
  // src/cli/utils/repository-id.ts
10862
10862
  var _child_process = require('child_process'); var cp = _interopRequireWildcard(_child_process);
10863
+ var _crypto = require('crypto');
10863
10864
  var cachedGitRepoId = void 0;
10865
+ function hashProjectName(fullPath) {
10866
+ const parts = fullPath.split("/");
10867
+ if (parts.length !== 2) {
10868
+ return _crypto.createHash.call(void 0, "sha256").update(fullPath).digest("hex").slice(0, 8);
10869
+ }
10870
+ const [org, project] = parts;
10871
+ const hashedProject = _crypto.createHash.call(void 0, "sha256").update(project).digest("hex").slice(0, 8);
10872
+ return `${org}/${hashedProject}`;
10873
+ }
10864
10874
  function getRepositoryId() {
10865
10875
  const ciRepoId = getCIRepositoryId();
10866
10876
  if (ciRepoId) return ciRepoId;
@@ -10870,13 +10880,16 @@ function getRepositoryId() {
10870
10880
  }
10871
10881
  function getCIRepositoryId() {
10872
10882
  if (process.env.GITHUB_REPOSITORY) {
10873
- return `github:${process.env.GITHUB_REPOSITORY}`;
10883
+ const hashed = hashProjectName(process.env.GITHUB_REPOSITORY);
10884
+ return `github:${hashed}`;
10874
10885
  }
10875
10886
  if (process.env.CI_PROJECT_PATH) {
10876
- return `gitlab:${process.env.CI_PROJECT_PATH}`;
10887
+ const hashed = hashProjectName(process.env.CI_PROJECT_PATH);
10888
+ return `gitlab:${hashed}`;
10877
10889
  }
10878
10890
  if (process.env.BITBUCKET_REPO_FULL_NAME) {
10879
- return `bitbucket:${process.env.BITBUCKET_REPO_FULL_NAME}`;
10891
+ const hashed = hashProjectName(process.env.BITBUCKET_REPO_FULL_NAME);
10892
+ return `bitbucket:${hashed}`;
10880
10893
  }
10881
10894
  return null;
10882
10895
  }
@@ -10914,10 +10927,11 @@ function parseGitUrl(url) {
10914
10927
  const httpsMatch = cleanUrl.match(/\/([^/]+\/[^/]+)$/);
10915
10928
  const repoPath = _optionalChain([sshMatch, 'optionalAccess', _341 => _341[1]]) || _optionalChain([httpsMatch, 'optionalAccess', _342 => _342[1]]);
10916
10929
  if (!repoPath) return null;
10930
+ const hashedPath = hashProjectName(repoPath);
10917
10931
  if (platform) {
10918
- return `${platform}:${repoPath}`;
10932
+ return `${platform}:${hashedPath}`;
10919
10933
  }
10920
- return `git:${repoPath}`;
10934
+ return `git:${hashedPath}`;
10921
10935
  }
10922
10936
 
10923
10937
  // src/cli/utils/observability.ts
@@ -10927,11 +10941,11 @@ var POSTHOG_HOST = "eu.i.posthog.com";
10927
10941
  var POSTHOG_PATH = "/i/v0/e/";
10928
10942
  var REQUEST_TIMEOUT_MS = 3e3;
10929
10943
  var TRACKING_VERSION = "2.0";
10930
- function determineDistinctId(providedId) {
10931
- if (providedId) {
10944
+ function determineDistinctId(email) {
10945
+ if (email) {
10932
10946
  const projectId = getRepositoryId();
10933
10947
  return {
10934
- distinct_id: providedId,
10948
+ distinct_id: email,
10935
10949
  distinct_id_source: "email",
10936
10950
  project_id: projectId
10937
10951
  };
@@ -10956,13 +10970,13 @@ function determineDistinctId(providedId) {
10956
10970
  project_id: null
10957
10971
  };
10958
10972
  }
10959
- function trackEvent(distinctId, event, properties) {
10973
+ function trackEvent(email, event, properties) {
10960
10974
  if (process.env.DO_NOT_TRACK === "1") {
10961
10975
  return;
10962
10976
  }
10963
10977
  setImmediate(() => {
10964
10978
  try {
10965
- const identityInfo = determineDistinctId(distinctId);
10979
+ const identityInfo = determineDistinctId(email);
10966
10980
  if (process.env.DEBUG === "true") {
10967
10981
  console.log(
10968
10982
  `[Tracking] Event: ${event}, ID: ${identityInfo.distinct_id}, Source: ${identityInfo.distinct_id_source}`
@@ -11210,7 +11224,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
11210
11224
  ]);
11211
11225
  }
11212
11226
  let hasErrors = false;
11213
- let authId = null;
11227
+ let email = null;
11214
11228
  const errorDetails = [];
11215
11229
  try {
11216
11230
  ora.start("Loading configuration...");
@@ -11223,14 +11237,14 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
11223
11237
  ora.start("Connecting to Lingo.dev Localization Engine...");
11224
11238
  const isByokMode = !!_optionalChain([i18nConfig, 'optionalAccess', _343 => _343.provider]);
11225
11239
  if (isByokMode) {
11226
- authId = null;
11240
+ email = null;
11227
11241
  ora.succeed("Using external provider (BYOK mode)");
11228
11242
  } else {
11229
11243
  const auth = await validateAuth(settings);
11230
- authId = auth.id;
11244
+ email = auth.email;
11231
11245
  ora.succeed(`Authenticated as ${auth.email}`);
11232
11246
  }
11233
- await trackEvent(authId, "cmd.i18n.start", {
11247
+ await trackEvent(email, "cmd.i18n.start", {
11234
11248
  i18nConfig,
11235
11249
  flags
11236
11250
  });
@@ -11576,7 +11590,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
11576
11590
  console.log();
11577
11591
  if (!hasErrors) {
11578
11592
  ora.succeed("Localization completed.");
11579
- await trackEvent(authId, "cmd.i18n.success", {
11593
+ await trackEvent(email, "cmd.i18n.success", {
11580
11594
  i18nConfig: {
11581
11595
  sourceLocale: i18nConfig.locale.source,
11582
11596
  targetLocales: i18nConfig.locale.targets,
@@ -11590,7 +11604,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
11590
11604
  await new Promise((resolve) => setTimeout(resolve, 50));
11591
11605
  } else {
11592
11606
  ora.warn("Localization completed with errors.");
11593
- await trackEvent(authId, "cmd.i18n.error", {
11607
+ await trackEvent(email, "cmd.i18n.error", {
11594
11608
  flags,
11595
11609
  ...aggregateErrorAnalytics(
11596
11610
  errorDetails,
@@ -11617,7 +11631,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
11617
11631
  bucket: error.bucket
11618
11632
  };
11619
11633
  }
11620
- await trackEvent(authId, "cmd.i18n.error", {
11634
+ await trackEvent(email, "cmd.i18n.error", {
11621
11635
  flags,
11622
11636
  errorType,
11623
11637
  errorName: error.name || "Error",
@@ -13249,7 +13263,7 @@ async function frozen(input2) {
13249
13263
  }
13250
13264
 
13251
13265
  // src/cli/cmd/run/_utils.ts
13252
- async function determineAuthId(ctx) {
13266
+ async function determineEmail(ctx) {
13253
13267
  const isByokMode = !!_optionalChain([ctx, 'access', _389 => _389.config, 'optionalAccess', _390 => _390.provider]);
13254
13268
  if (isByokMode) {
13255
13269
  return null;
@@ -13333,7 +13347,7 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
13333
13347
  "--sound",
13334
13348
  "Play audio feedback when translations complete (success or failure sounds)"
13335
13349
  ).action(async (args) => {
13336
- let authId = null;
13350
+ let email = null;
13337
13351
  try {
13338
13352
  const ctx = {
13339
13353
  flags: flagsSchema2.parse(args),
@@ -13349,8 +13363,8 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
13349
13363
  await renderHero();
13350
13364
  await renderSpacer();
13351
13365
  await setup(ctx);
13352
- authId = await determineAuthId(ctx);
13353
- await trackEvent(authId, "cmd.run.start", {
13366
+ email = await determineEmail(ctx);
13367
+ await trackEvent(email, "cmd.run.start", {
13354
13368
  config: ctx.config,
13355
13369
  flags: ctx.flags
13356
13370
  });
@@ -13369,13 +13383,17 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
13369
13383
  if (ctx.flags.watch) {
13370
13384
  await watch2(ctx);
13371
13385
  }
13372
- await trackEvent(authId, "cmd.run.success", {
13386
+ await trackEvent(email, "cmd.run.success", {
13373
13387
  config: ctx.config,
13374
13388
  flags: ctx.flags
13375
13389
  });
13376
13390
  await new Promise((resolve) => setTimeout(resolve, 50));
13377
13391
  } catch (error) {
13378
- await trackEvent(authId, "cmd.run.error", {});
13392
+ await trackEvent(email, "cmd.run.error", {
13393
+ flags: args,
13394
+ error: error.message,
13395
+ authenticated: !!email
13396
+ });
13379
13397
  await new Promise((resolve) => setTimeout(resolve, 50));
13380
13398
  if (args.sound) {
13381
13399
  await playSound("failure");
@@ -14208,7 +14226,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
14208
14226
  ).action(async function(options) {
14209
14227
  const ora = _ora2.default.call(void 0, );
14210
14228
  const flags = parseFlags2(options);
14211
- let authId = null;
14229
+ let email = null;
14212
14230
  try {
14213
14231
  ora.start("Loading configuration...");
14214
14232
  const i18nConfig = getConfig();
@@ -14218,7 +14236,7 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
14218
14236
  ora.start("Checking authentication status...");
14219
14237
  const auth = await tryAuthenticate(settings);
14220
14238
  if (auth) {
14221
- authId = auth.id;
14239
+ email = auth.email;
14222
14240
  ora.succeed(`Authenticated as ${auth.email}`);
14223
14241
  } else {
14224
14242
  ora.info(
@@ -14231,10 +14249,11 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
14231
14249
  ora.start("Validating localization configuration...");
14232
14250
  validateParams2(i18nConfig, flags);
14233
14251
  ora.succeed("Localization configuration is valid");
14234
- trackEvent(authId, "cmd.status.start", {
14252
+ trackEvent(email, "cmd.status.start", {
14235
14253
  i18nConfig,
14236
14254
  flags
14237
14255
  });
14256
+ await new Promise((resolve) => setTimeout(resolve, 50));
14238
14257
  let buckets = getBuckets(i18nConfig);
14239
14258
  if (_optionalChain([flags, 'access', _420 => _420.bucket, 'optionalAccess', _421 => _421.length])) {
14240
14259
  buckets = buckets.filter(
@@ -14618,22 +14637,22 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
14618
14637
  `\u2022 Try 'lingo.dev@latest i18n --locale ${targetLocales[0]}' to process just one language`
14619
14638
  );
14620
14639
  }
14621
- trackEvent(authId, "cmd.status.success", {
14640
+ trackEvent(email, "cmd.status.success", {
14622
14641
  i18nConfig,
14623
14642
  flags,
14624
14643
  totalSourceKeyCount,
14625
14644
  languageStats,
14626
14645
  totalWordsToTranslate,
14627
- authenticated: !!authId
14646
+ authenticated: !!email
14628
14647
  });
14629
14648
  await new Promise((resolve) => setTimeout(resolve, 50));
14630
14649
  exitGracefully();
14631
14650
  } catch (error) {
14632
14651
  ora.fail(error.message);
14633
- trackEvent(authId, "cmd.status.error", {
14652
+ trackEvent(email, "cmd.status.error", {
14634
14653
  flags,
14635
14654
  error: error.message,
14636
- authenticated: !!authId
14655
+ authenticated: !!email
14637
14656
  });
14638
14657
  await new Promise((resolve) => setTimeout(resolve, 50));
14639
14658
  process.exit(1);
@@ -14773,7 +14792,7 @@ async function renderHero2() {
14773
14792
  // package.json
14774
14793
  var package_default = {
14775
14794
  name: "lingo.dev",
14776
- version: "0.117.23",
14795
+ version: "0.117.25",
14777
14796
  description: "Lingo.dev CLI",
14778
14797
  private: false,
14779
14798
  repository: {