lingo.dev 0.111.3 → 0.111.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.
Binary file
Binary file
package/build/cli.cjs CHANGED
@@ -926,9 +926,9 @@ function makeGitlabInitializer(spinner) {
926
926
 
927
927
  // src/cli/cmd/init.ts
928
928
 
929
- var openUrl = (path17) => {
929
+ var openUrl = (path18) => {
930
930
  const settings = getSettings(void 0);
931
- _open2.default.call(void 0, `${settings.auth.webUrl}${path17}`, { wait: false });
931
+ _open2.default.call(void 0, `${settings.auth.webUrl}${path18}`, { wait: false });
932
932
  };
933
933
  var throwHelpError = (option, value) => {
934
934
  if (value === "help") {
@@ -1348,8 +1348,8 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
1348
1348
  } else if (type.target) {
1349
1349
  result.push(...targetPaths);
1350
1350
  }
1351
- result.forEach((path17) => {
1352
- console.log(path17);
1351
+ result.forEach((path18) => {
1352
+ console.log(path18);
1353
1353
  });
1354
1354
  }
1355
1355
  }
@@ -1667,8 +1667,8 @@ function extractCommentsFromJsonc(jsoncString) {
1667
1667
  const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
1668
1668
  if (keyMatch) {
1669
1669
  const key = keyMatch[1];
1670
- const path17 = contextStack.map((ctx) => ctx.key).filter(Boolean);
1671
- keyInfo = { key, path: path17 };
1670
+ const path18 = contextStack.map((ctx) => ctx.key).filter(Boolean);
1671
+ keyInfo = { key, path: path18 };
1672
1672
  }
1673
1673
  } else {
1674
1674
  keyInfo = findAssociatedKey(lines, commentData.lineIndex, contextStack);
@@ -1752,8 +1752,8 @@ function findAssociatedKey(lines, commentLineIndex, contextStack) {
1752
1752
  const keyMatch = line.match(/^\s*["']?([^"':,\s]+)["']?\s*:/);
1753
1753
  if (keyMatch) {
1754
1754
  const key = keyMatch[1];
1755
- const path17 = contextStack.map((ctx) => ctx.key).filter(Boolean);
1756
- return { key, path: path17 };
1755
+ const path18 = contextStack.map((ctx) => ctx.key).filter(Boolean);
1756
+ return { key, path: path18 };
1757
1757
  }
1758
1758
  }
1759
1759
  return { key: null, path: [] };
@@ -1772,9 +1772,9 @@ function updateContext(contextStack, line, parsedJson) {
1772
1772
  }
1773
1773
  }
1774
1774
  }
1775
- function setCommentAtPath(comments, path17, key, hint) {
1775
+ function setCommentAtPath(comments, path18, key, hint) {
1776
1776
  let current = comments;
1777
- for (const pathKey of path17) {
1777
+ for (const pathKey of path18) {
1778
1778
  if (!current[pathKey]) {
1779
1779
  current[pathKey] = {};
1780
1780
  }
@@ -2435,9 +2435,9 @@ function createHtmlLoader() {
2435
2435
  const bDepth = b.split("/").length;
2436
2436
  return aDepth - bDepth;
2437
2437
  });
2438
- paths.forEach((path17) => {
2439
- const value = data[path17];
2440
- const [nodePath, attribute] = path17.split("#");
2438
+ paths.forEach((path18) => {
2439
+ const value = data[path18];
2440
+ const [nodePath, attribute] = path18.split("#");
2441
2441
  const [rootTag, ...indices] = nodePath.split("/");
2442
2442
  let parent = rootTag === "head" ? document.head : document.body;
2443
2443
  let current = parent;
@@ -4080,24 +4080,24 @@ function createRawDatoValue(parsedDatoValue, originalRawDatoValue, isClean = fal
4080
4080
  }
4081
4081
  function serializeStructuredText(rawStructuredText) {
4082
4082
  return serializeStructuredTextNode(rawStructuredText);
4083
- function serializeStructuredTextNode(node, path17 = [], acc = {}) {
4083
+ function serializeStructuredTextNode(node, path18 = [], acc = {}) {
4084
4084
  if ("document" in node) {
4085
4085
  return serializeStructuredTextNode(
4086
4086
  node.document,
4087
- [...path17, "document"],
4087
+ [...path18, "document"],
4088
4088
  acc
4089
4089
  );
4090
4090
  }
4091
4091
  if (!_lodash2.default.isNil(node.value)) {
4092
- acc[[...path17, "value"].join(".")] = node.value;
4092
+ acc[[...path18, "value"].join(".")] = node.value;
4093
4093
  } else if (_lodash2.default.get(node, "type") === "block") {
4094
- acc[[...path17, "item"].join(".")] = serializeBlock(node.item);
4094
+ acc[[...path18, "item"].join(".")] = serializeBlock(node.item);
4095
4095
  }
4096
4096
  if (node.children) {
4097
4097
  for (let i = 0; i < node.children.length; i++) {
4098
4098
  serializeStructuredTextNode(
4099
4099
  node.children[i],
4100
- [...path17, i.toString()],
4100
+ [...path18, i.toString()],
4101
4101
  acc
4102
4102
  );
4103
4103
  }
@@ -4164,8 +4164,8 @@ function deserializeBlockList(parsedBlockList, originalRawBlockList, isClean = f
4164
4164
  }
4165
4165
  function deserializeStructuredText(parsedStructuredText, originalRawStructuredText) {
4166
4166
  const result = _lodash2.default.cloneDeep(originalRawStructuredText);
4167
- for (const [path17, value] of _lodash2.default.entries(parsedStructuredText)) {
4168
- const realPath = _lodash2.default.chain(path17.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
4167
+ for (const [path18, value] of _lodash2.default.entries(parsedStructuredText)) {
4168
+ const realPath = _lodash2.default.chain(path18.split(".")).flatMap((s) => !_lodash2.default.isNaN(_lodash2.default.toNumber(s)) ? ["children", s] : s).value();
4169
4169
  const deserializedValue = createRawDatoValue(
4170
4170
  value,
4171
4171
  _lodash2.default.get(originalRawStructuredText, realPath),
@@ -4591,15 +4591,15 @@ function parseTypeScript(input2) {
4591
4591
  function extractStringsFromDefaultExport(ast) {
4592
4592
  let extracted = {};
4593
4593
  traverse(ast, {
4594
- ExportDefaultDeclaration(path17) {
4595
- const { declaration } = path17.node;
4594
+ ExportDefaultDeclaration(path18) {
4595
+ const { declaration } = path18.node;
4596
4596
  const decl = unwrapTSAsExpression(declaration);
4597
4597
  if (t.isObjectExpression(decl)) {
4598
4598
  extracted = objectExpressionToObject(decl);
4599
4599
  } else if (t.isArrayExpression(decl)) {
4600
4600
  extracted = arrayExpressionToArray(decl);
4601
4601
  } else if (t.isIdentifier(decl)) {
4602
- const binding = path17.scope.bindings[decl.name];
4602
+ const binding = path18.scope.bindings[decl.name];
4603
4603
  if (binding && t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
4604
4604
  const initRaw = binding.path.node.init;
4605
4605
  const init = initRaw ? unwrapTSAsExpression(initRaw) : initRaw;
@@ -4664,8 +4664,8 @@ function arrayExpressionToArray(arrayExpression) {
4664
4664
  function updateStringsInDefaultExport(ast, data) {
4665
4665
  let modified = false;
4666
4666
  traverse(ast, {
4667
- ExportDefaultDeclaration(path17) {
4668
- const { declaration } = path17.node;
4667
+ ExportDefaultDeclaration(path18) {
4668
+ const { declaration } = path18.node;
4669
4669
  const decl = unwrapTSAsExpression(declaration);
4670
4670
  if (t.isObjectExpression(decl)) {
4671
4671
  modified = updateStringsInObjectExpression(decl, data) || modified;
@@ -4674,7 +4674,7 @@ function updateStringsInDefaultExport(ast, data) {
4674
4674
  modified = updateStringsInArrayExpression(decl, data) || modified;
4675
4675
  }
4676
4676
  } else if (t.isIdentifier(decl)) {
4677
- modified = updateStringsInExportedIdentifier(path17, data) || modified;
4677
+ modified = updateStringsInExportedIdentifier(path18, data) || modified;
4678
4678
  }
4679
4679
  }
4680
4680
  });
@@ -4745,9 +4745,9 @@ function updateStringsInArrayExpression(arrayExpression, incoming) {
4745
4745
  });
4746
4746
  return modified;
4747
4747
  }
4748
- function updateStringsInExportedIdentifier(path17, data) {
4749
- const exportName = path17.node.declaration.name;
4750
- const binding = path17.scope.bindings[exportName];
4748
+ function updateStringsInExportedIdentifier(path18, data) {
4749
+ const exportName = path18.node.declaration.name;
4750
+ const binding = path18.scope.bindings[exportName];
4751
4751
  if (!binding || !binding.path.node) return false;
4752
4752
  if (t.isVariableDeclarator(binding.path.node) && binding.path.node.init) {
4753
4753
  const initRaw = binding.path.node.init;
@@ -6349,11 +6349,11 @@ function _getAllKeys(obj, prefix = "") {
6349
6349
  let keys = [];
6350
6350
  for (const key in obj) {
6351
6351
  if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
6352
- const path17 = prefix ? `${prefix}.${key}` : key;
6352
+ const path18 = prefix ? `${prefix}.${key}` : key;
6353
6353
  if (typeof obj[key] === "object" && obj[key] !== null && !Array.isArray(obj[key])) {
6354
- keys = keys.concat(_getAllKeys(obj[key], path17));
6354
+ keys = keys.concat(_getAllKeys(obj[key], path18));
6355
6355
  } else {
6356
- keys.push(path17);
6356
+ keys.push(path18);
6357
6357
  }
6358
6358
  }
6359
6359
  return keys;
@@ -6866,19 +6866,19 @@ function createJsonDictionaryLoader() {
6866
6866
  );
6867
6867
  return input2;
6868
6868
  }
6869
- function walk(obj, dataNode, path17 = []) {
6869
+ function walk(obj, dataNode, path18 = []) {
6870
6870
  if (Array.isArray(obj) && Array.isArray(dataNode)) {
6871
6871
  obj.forEach(
6872
- (item, idx) => walk(item, dataNode[idx], [...path17, String(idx)])
6872
+ (item, idx) => walk(item, dataNode[idx], [...path18, String(idx)])
6873
6873
  );
6874
6874
  } else if (obj && typeof obj === "object" && dataNode && typeof dataNode === "object" && !Array.isArray(dataNode)) {
6875
6875
  for (const key of Object.keys(obj)) {
6876
6876
  if (dataNode.hasOwnProperty(key)) {
6877
- walk(obj[key], dataNode[key], [...path17, key]);
6877
+ walk(obj[key], dataNode[key], [...path18, key]);
6878
6878
  }
6879
6879
  }
6880
6880
  } else if (obj && typeof obj === "object" && !Array.isArray(obj) && typeof dataNode === "string") {
6881
- setNestedLocale(input2, path17, locale, dataNode, originalLocale);
6881
+ setNestedLocale(input2, path18, locale, dataNode, originalLocale);
6882
6882
  }
6883
6883
  }
6884
6884
  walk(input2, data);
@@ -6906,14 +6906,14 @@ function extractTranslatables(obj, locale) {
6906
6906
  function isTranslatableObject(obj, locale) {
6907
6907
  return obj && typeof obj === "object" && !Array.isArray(obj) && Object.prototype.hasOwnProperty.call(obj, locale);
6908
6908
  }
6909
- function setNestedLocale(obj, path17, locale, value, originalLocale) {
6909
+ function setNestedLocale(obj, path18, locale, value, originalLocale) {
6910
6910
  let curr = obj;
6911
- for (let i = 0; i < path17.length - 1; i++) {
6912
- const key = path17[i];
6911
+ for (let i = 0; i < path18.length - 1; i++) {
6912
+ const key = path18[i];
6913
6913
  if (!(key in curr)) curr[key] = {};
6914
6914
  curr = curr[key];
6915
6915
  }
6916
- const last = path17[path17.length - 1];
6916
+ const last = path18[path18.length - 1];
6917
6917
  if (curr[last] && typeof curr[last] === "object") {
6918
6918
  curr[last][locale] = value;
6919
6919
  if (originalLocale && curr[last][originalLocale]) {
@@ -7727,7 +7727,7 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
7727
7727
  if (_optionalChain([flags, 'access', _254 => _254.file, 'optionalAccess', _255 => _255.length])) {
7728
7728
  buckets = buckets.map((bucket) => {
7729
7729
  const paths = bucket.paths.filter(
7730
- (path17) => flags.file.find((file) => _optionalChain([path17, 'access', _256 => _256.pathPattern, 'optionalAccess', _257 => _257.includes, 'call', _258 => _258(file)]))
7730
+ (path18) => flags.file.find((file) => _optionalChain([path18, 'access', _256 => _256.pathPattern, 'optionalAccess', _257 => _257.includes, 'call', _258 => _258(file)]))
7731
7731
  );
7732
7732
  return { ...bucket, paths };
7733
7733
  }).filter((bucket) => bucket.paths.length > 0);
@@ -7742,8 +7742,8 @@ var i18n_default = new (0, _interactivecommander.Command)().command("i18n").desc
7742
7742
  ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
7743
7743
  buckets.map((bucket) => {
7744
7744
  ora.info(` ${bucket.type}:`);
7745
- bucket.paths.forEach((path17) => {
7746
- ora.info(` - ${path17.pathPattern}`);
7745
+ bucket.paths.forEach((path18) => {
7746
+ ora.info(` - ${path18.pathPattern}`);
7747
7747
  });
7748
7748
  });
7749
7749
  }
@@ -8554,6 +8554,10 @@ function escapeShellArg(arg) {
8554
8554
  // src/cli/cmd/run/index.ts
8555
8555
 
8556
8556
 
8557
+
8558
+ var _url = require('url');
8559
+
8560
+
8557
8561
  // src/cli/cmd/run/setup.ts
8558
8562
 
8559
8563
  var _listr2 = require('listr2');
@@ -9296,14 +9300,14 @@ async function watch2(ctx) {
9296
9300
  pollInterval: 100
9297
9301
  }
9298
9302
  });
9299
- watcher.on("change", (path17) => {
9300
- handleFileChange(path17, state, ctx);
9303
+ watcher.on("change", (path18) => {
9304
+ handleFileChange(path18, state, ctx);
9301
9305
  });
9302
- watcher.on("add", (path17) => {
9303
- handleFileChange(path17, state, ctx);
9306
+ watcher.on("add", (path18) => {
9307
+ handleFileChange(path18, state, ctx);
9304
9308
  });
9305
- watcher.on("unlink", (path17) => {
9306
- handleFileChange(path17, state, ctx);
9309
+ watcher.on("unlink", (path18) => {
9310
+ handleFileChange(path18, state, ctx);
9307
9311
  });
9308
9312
  watcher.on("error", (error) => {
9309
9313
  console.error(
@@ -9414,8 +9418,9 @@ var flagsSchema2 = _zod.z.object({
9414
9418
  sourceLocale: _zod.z.string().optional(),
9415
9419
  targetLocale: _zod.z.array(_zod.z.string()).optional(),
9416
9420
  watch: _zod.z.boolean().default(false),
9417
- debounce: _zod.z.number().positive().default(5e3)
9421
+ debounce: _zod.z.number().positive().default(5e3),
9418
9422
  // 5 seconds default
9423
+ sound: _zod.z.boolean().optional()
9419
9424
  });
9420
9425
 
9421
9426
  // src/cli/cmd/run/_utils.ts
@@ -9434,6 +9439,32 @@ async function determineAuthId(ctx) {
9434
9439
  }
9435
9440
 
9436
9441
  // src/cli/cmd/run/index.ts
9442
+ var __dirname = path13.default.dirname(_url.fileURLToPath.call(void 0, import.meta.url));
9443
+ function playSound(type) {
9444
+ const platform = _os2.default.platform();
9445
+ return new Promise((resolve) => {
9446
+ const assetDir = path13.default.join(__dirname, "../assets");
9447
+ const soundFiles = [path13.default.join(assetDir, `${type}.mp3`)];
9448
+ let command = "";
9449
+ if (platform === "linux") {
9450
+ command = soundFiles.map(
9451
+ (file) => `mpg123 -q "${file}" 2>/dev/null || aplay "${file}" 2>/dev/null`
9452
+ ).join(" || ");
9453
+ } else if (platform === "darwin") {
9454
+ command = soundFiles.map((file) => `afplay "${file}"`).join(" || ");
9455
+ } else if (platform === "win32") {
9456
+ command = `powershell -c "try { (New-Object Media.SoundPlayer '${soundFiles[1]}').PlaySync() } catch { Start-Process -FilePath '${soundFiles[0]}' -WindowStyle Hidden -Wait }"`;
9457
+ } else {
9458
+ command = soundFiles.map(
9459
+ (file) => `aplay "${file}" 2>/dev/null || afplay "${file}" 2>/dev/null`
9460
+ ).join(" || ");
9461
+ }
9462
+ _child_process.exec.call(void 0, command, () => {
9463
+ resolve();
9464
+ });
9465
+ setTimeout(resolve, 3e3);
9466
+ });
9467
+ }
9437
9468
  var run_default = new (0, _interactivecommander.Command)().command("run").description("Run Lingo.dev localization engine").helpOption("-h, --help", "Show help").option(
9438
9469
  "--source-locale <source-locale>",
9439
9470
  "Locale to use as source locale. Defaults to i18n.json locale.source"
@@ -9473,6 +9504,9 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
9473
9504
  "--debounce <milliseconds>",
9474
9505
  "Debounce delay in milliseconds for watch mode (default: 5000ms)",
9475
9506
  (val) => parseInt(val)
9507
+ ).option(
9508
+ "--sound",
9509
+ "Play sound on completion, partially completion and failed of the task"
9476
9510
  ).action(async (args) => {
9477
9511
  let authId = null;
9478
9512
  try {
@@ -9502,6 +9536,9 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
9502
9536
  await renderSpacer();
9503
9537
  await renderSummary(ctx.results);
9504
9538
  await renderSpacer();
9539
+ if (ctx.flags.sound) {
9540
+ await playSound("success");
9541
+ }
9505
9542
  if (ctx.flags.watch) {
9506
9543
  await watch2(ctx);
9507
9544
  }
@@ -9511,6 +9548,9 @@ var run_default = new (0, _interactivecommander.Command)().command("run").descri
9511
9548
  });
9512
9549
  } catch (error) {
9513
9550
  await trackEvent(authId || "unknown", "cmd.run.error", {});
9551
+ if (args.sound) {
9552
+ await playSound("failure");
9553
+ }
9514
9554
  throw error;
9515
9555
  }
9516
9556
  });
@@ -10340,8 +10380,8 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
10340
10380
  if (_optionalChain([flags, 'access', _320 => _320.file, 'optionalAccess', _321 => _321.length])) {
10341
10381
  buckets = buckets.map((bucket) => {
10342
10382
  const paths = bucket.paths.filter(
10343
- (path17) => flags.file.find(
10344
- (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)
10383
+ (path18) => flags.file.find(
10384
+ (file) => _optionalChain([path18, 'access', _322 => _322.pathPattern, 'optionalAccess', _323 => _323.includes, 'call', _324 => _324(file)]) || _optionalChain([path18, 'access', _325 => _325.pathPattern, 'optionalAccess', _326 => _326.match, 'call', _327 => _327(file)]) || minimatch(path18.pathPattern, file)
10345
10385
  )
10346
10386
  );
10347
10387
  return { ...bucket, paths };
@@ -10355,8 +10395,8 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
10355
10395
  ora.info(`\x1B[36mProcessing only filtered buckets:\x1B[0m`);
10356
10396
  buckets.map((bucket) => {
10357
10397
  ora.info(` ${bucket.type}:`);
10358
- bucket.paths.forEach((path17) => {
10359
- ora.info(` - ${path17.pathPattern}`);
10398
+ bucket.paths.forEach((path18) => {
10399
+ ora.info(` - ${path18.pathPattern}`);
10360
10400
  });
10361
10401
  });
10362
10402
  }
@@ -10640,10 +10680,10 @@ var status_default = new (0, _interactivecommander.Command)().command("status").
10640
10680
  if (flags.confirm && Object.keys(fileStats).length > 0) {
10641
10681
  console.log(_chalk2.default.bold(`
10642
10682
  \u{1F4D1} BREAKDOWN BY FILE:`));
10643
- Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path17, stats]) => {
10683
+ Object.entries(fileStats).sort((a, b) => b[1].wordCount - a[1].wordCount).forEach(([path18, stats]) => {
10644
10684
  if (stats.sourceKeys === 0) return;
10645
10685
  console.log(_chalk2.default.bold(`
10646
- \u2022 ${path17}:`));
10686
+ \u2022 ${path18}:`));
10647
10687
  console.log(
10648
10688
  ` ${stats.sourceKeys} source keys, ~${stats.wordCount.toLocaleString()} source words`
10649
10689
  );
@@ -10863,7 +10903,7 @@ async function renderHero2() {
10863
10903
  // package.json
10864
10904
  var package_default = {
10865
10905
  name: "lingo.dev",
10866
- version: "0.111.3",
10906
+ version: "0.111.4",
10867
10907
  description: "Lingo.dev CLI",
10868
10908
  private: false,
10869
10909
  publishConfig: {
@@ -10961,7 +11001,8 @@ var package_default = {
10961
11001
  },
10962
11002
  files: [
10963
11003
  "bin",
10964
- "build"
11004
+ "build",
11005
+ "assets"
10965
11006
  ],
10966
11007
  scripts: {
10967
11008
  "lingo.dev": "node --inspect=9229 ./bin/cli.mjs",