lingo.dev 0.112.0 → 0.112.1

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 CHANGED
@@ -1539,148 +1539,11 @@ var files_default = new (0, _interactivecommander.Command)().command("files").de
1539
1539
  }
1540
1540
  });
1541
1541
 
1542
- // src/cli/cmd/show/index.ts
1543
- var show_default = new (0, _interactivecommander.Command)().command("show").description("Display configuration, locales, and file paths").helpOption("-h, --help", "Show help").addCommand(config_default).addCommand(locale_default).addCommand(files_default);
1544
-
1545
- // src/cli/cmd/config/index.ts
1546
-
1547
-
1548
- // src/cli/cmd/config/set.ts
1549
-
1550
-
1551
- var _dedent = require('dedent'); var _dedent2 = _interopRequireDefault(_dedent);
1552
-
1553
- var set_default = new (0, _interactivecommander.Command)().name("set").description("Set or update a CLI setting in ~/.lingodotdevrc").addHelpText("afterAll", `
1554
- Available keys:
1555
- ${SETTINGS_KEYS.join("\n ")}`).argument(
1556
- "<key>",
1557
- "Configuration key to set (dot notation, e.g., auth.apiKey)"
1558
- ).argument("<value>", "The configuration value to set").helpOption("-h, --help", "Show help").action(async (key, value) => {
1559
- if (!SETTINGS_KEYS.includes(key)) {
1560
- console.error(
1561
- _dedent2.default`
1562
- ${_chalk2.default.red("\u2716")} Unknown configuration key: ${_chalk2.default.bold(key)}
1563
- Run ${_chalk2.default.dim("lingo.dev config set --help")} to see available keys.
1564
- `
1565
- );
1566
- process.exitCode = 1;
1567
- return;
1568
- }
1569
- const current = loadSystemSettings();
1570
- const updated = _lodash2.default.cloneDeep(current);
1571
- _lodash2.default.set(updated, key, value);
1572
- try {
1573
- saveSettings(updated);
1574
- console.log(`${_chalk2.default.green("\u2714")} Set ${_chalk2.default.bold(key)}`);
1575
- } catch (err) {
1576
- console.error(
1577
- _chalk2.default.red(
1578
- `\u2716 Failed to save configuration: ${_chalk2.default.dim(
1579
- err instanceof Error ? err.message : String(err)
1580
- )}`
1581
- )
1582
- );
1583
- process.exitCode = 1;
1584
- }
1585
- });
1586
-
1587
- // src/cli/cmd/config/unset.ts
1588
-
1589
-
1590
-
1591
-
1592
- var unset_default = new (0, _interactivecommander.Command)().name("unset").description("Remove a CLI setting from ~/.lingodotdevrc").addHelpText("afterAll", `
1593
- Available keys:
1594
- ${SETTINGS_KEYS.join("\n ")}`).argument(
1595
- "<key>",
1596
- "Configuration key to remove (must match one of the available keys listed below)"
1597
- ).helpOption("-h, --help", "Show help").action(async (key) => {
1598
- if (!SETTINGS_KEYS.includes(key)) {
1599
- console.error(
1600
- _dedent2.default`
1601
- ${_chalk2.default.red("\u2716")} Unknown configuration key: ${_chalk2.default.bold(key)}
1602
- Run ${_chalk2.default.dim(
1603
- "lingo.dev config unset --help"
1604
- )} to see available keys.
1605
- `
1606
- );
1607
- process.exitCode = 1;
1608
- return;
1609
- }
1610
- const settings = loadSystemSettings();
1611
- const currentValue = _lodash2.default.get(settings, key);
1612
- if (!_lodash2.default.trim(String(currentValue || ""))) {
1613
- console.log(`${_chalk2.default.cyan("\u2139")} ${_chalk2.default.bold(key)} is not set.`);
1614
- return;
1615
- } else {
1616
- const updated = _lodash2.default.cloneDeep(settings);
1617
- _lodash2.default.unset(updated, key);
1618
- try {
1619
- saveSettings(updated);
1620
- console.log(
1621
- `${_chalk2.default.green("\u2714")} Removed configuration key ${_chalk2.default.bold(key)}`
1622
- );
1623
- } catch (err) {
1624
- console.error(
1625
- _chalk2.default.red(
1626
- `\u2716 Failed to save configuration: ${_chalk2.default.dim(
1627
- err instanceof Error ? err.message : String(err)
1628
- )}`
1629
- )
1630
- );
1631
- process.exitCode = 1;
1632
- }
1633
- }
1634
- });
1635
-
1636
- // src/cli/cmd/config/get.ts
1637
-
1638
-
1639
-
1640
-
1641
- var get_default = new (0, _interactivecommander.Command)().name("get").description("Display the value of a CLI setting from ~/.lingodotdevrc").addHelpText("afterAll", `
1642
- Available keys:
1643
- ${SETTINGS_KEYS.join("\n ")}`).argument(
1644
- "<key>",
1645
- "Configuration key to read (choose from the available keys listed below)"
1646
- ).helpOption("-h, --help", "Show help").action(async (key) => {
1647
- if (!SETTINGS_KEYS.includes(key)) {
1648
- console.error(
1649
- _dedent2.default`
1650
- ${_chalk2.default.red("\u2716")} Unknown configuration key: ${_chalk2.default.bold(key)}
1651
- Run ${_chalk2.default.dim("lingo.dev config get --help")} to see available keys.
1652
- `
1653
- );
1654
- process.exitCode = 1;
1655
- return;
1656
- }
1657
- const settings = loadSystemSettings();
1658
- const value = _lodash2.default.get(settings, key);
1659
- if (!value) {
1660
- console.log(`${_chalk2.default.cyan("\u2139")} ${_chalk2.default.bold(key)} is not set.`);
1661
- return;
1662
- }
1663
- if (typeof value === "object") {
1664
- console.log(JSON.stringify(value, null, 2));
1665
- } else {
1666
- console.log(value);
1667
- }
1668
- });
1669
-
1670
- // src/cli/cmd/config/index.ts
1671
- var config_default2 = new (0, _interactivecommander.Command)().command("config").description(
1672
- "Manage CLI settings (authentication, API keys) stored in ~/.lingodotdevrc"
1673
- ).helpOption("-h, --help", "Show help").addCommand(set_default).addCommand(unset_default).addCommand(get_default);
1674
-
1675
- // src/cli/cmd/i18n.ts
1676
-
1677
-
1678
-
1679
-
1680
-
1542
+ // src/cli/cmd/show/locked-keys.ts
1681
1543
 
1682
1544
 
1683
1545
 
1546
+ // src/cli/cmd/show/_shared-key-command.ts
1684
1547
 
1685
1548
 
1686
1549
  // src/cli/loaders/_utils.ts
@@ -6764,22 +6627,35 @@ function _getAllKeys(obj, prefix = "") {
6764
6627
 
6765
6628
  // src/cli/loaders/locked-keys.ts
6766
6629
 
6630
+
6631
+ // src/cli/utils/key-matching.ts
6632
+ function matchesKeyPattern(key, patterns) {
6633
+ return patterns.some(
6634
+ (pattern) => key.startsWith(pattern) || minimatch(key, pattern)
6635
+ );
6636
+ }
6637
+ function formatDisplayValue(value, maxLength = 50) {
6638
+ if (typeof value === "string") {
6639
+ return value.length > maxLength ? `${value.substring(0, maxLength)}...` : value;
6640
+ }
6641
+ return JSON.stringify(value);
6642
+ }
6643
+
6644
+ // src/cli/loaders/locked-keys.ts
6767
6645
  function createLockedKeysLoader(lockedKeys) {
6768
6646
  return createLoader({
6769
6647
  pull: async (locale, data) => {
6770
- return _lodash2.default.pickBy(data, (value, key) => !_isLockedKey(key, lockedKeys));
6648
+ return _lodash2.default.pickBy(
6649
+ data,
6650
+ (value, key) => !matchesKeyPattern(key, lockedKeys)
6651
+ );
6771
6652
  },
6772
6653
  push: async (locale, data, originalInput) => {
6773
- const lockedSubObject = _lodash2.default.chain(originalInput).pickBy((value, key) => _isLockedKey(key, lockedKeys)).value();
6654
+ const lockedSubObject = _lodash2.default.chain(originalInput).pickBy((value, key) => matchesKeyPattern(key, lockedKeys)).value();
6774
6655
  return _lodash2.default.merge({}, data, lockedSubObject);
6775
6656
  }
6776
6657
  });
6777
6658
  }
6778
- function _isLockedKey(key, lockedKeys) {
6779
- return lockedKeys.some(
6780
- (lockedKey) => key.startsWith(lockedKey) || minimatch(key, lockedKey)
6781
- );
6782
- }
6783
6659
 
6784
6660
  // src/cli/loaders/mdx2/frontmatter-split.ts
6785
6661
 
@@ -7035,25 +6911,20 @@ function createIgnoredKeysLoader(ignoredKeys) {
7035
6911
  pull: async (locale, data) => {
7036
6912
  const result = _lodash2.default.omitBy(
7037
6913
  data,
7038
- (value, key) => _isIgnoredKey(key, ignoredKeys)
6914
+ (value, key) => matchesKeyPattern(key, ignoredKeys)
7039
6915
  );
7040
6916
  return result;
7041
6917
  },
7042
6918
  push: async (locale, data, originalInput, originalLocale, pullInput) => {
7043
6919
  const ignoredSubObject = _lodash2.default.pickBy(
7044
6920
  pullInput,
7045
- (value, key) => _isIgnoredKey(key, ignoredKeys)
6921
+ (value, key) => matchesKeyPattern(key, ignoredKeys)
7046
6922
  );
7047
6923
  const result = _lodash2.default.merge({}, data, ignoredSubObject);
7048
6924
  return result;
7049
6925
  }
7050
6926
  });
7051
6927
  }
7052
- function _isIgnoredKey(key, ignoredKeys) {
7053
- return ignoredKeys.some(
7054
- (ignoredKey) => key.startsWith(ignoredKey) || minimatch(key, ignoredKey)
7055
- );
7056
- }
7057
6928
 
7058
6929
  // src/cli/loaders/ejs.ts
7059
6930
  function parseEjsForTranslation(input2) {
@@ -7613,8 +7484,277 @@ function createBucketLoader(bucketType, bucketPathPattern, options, lockedKeys,
7613
7484
  }
7614
7485
  }
7615
7486
 
7487
+ // src/cli/cmd/show/_shared-key-command.ts
7488
+ async function executeKeyCommand(i18nConfig, buckets, options, config) {
7489
+ let hasAnyKeys = false;
7490
+ for (const bucket of buckets) {
7491
+ if (options.bucket && bucket.type !== options.bucket) {
7492
+ continue;
7493
+ }
7494
+ const keyPatterns = bucket[config.filterType];
7495
+ if (!keyPatterns || keyPatterns.length === 0) {
7496
+ continue;
7497
+ }
7498
+ hasAnyKeys = true;
7499
+ console.log(`
7500
+ Bucket: ${bucket.type}`);
7501
+ console.log(
7502
+ `${capitalize(config.displayName)} key patterns: ${keyPatterns.join(", ")}`
7503
+ );
7504
+ for (const bucketConfig of bucket.paths) {
7505
+ const sourceLocale = __spec.resolveOverriddenLocale.call(void 0,
7506
+ i18nConfig.locale.source,
7507
+ bucketConfig.delimiter
7508
+ );
7509
+ const sourcePath = bucketConfig.pathPattern.replace(
7510
+ /\[locale\]/g,
7511
+ sourceLocale
7512
+ );
7513
+ try {
7514
+ const loader = createBucketLoader(
7515
+ bucket.type,
7516
+ bucketConfig.pathPattern,
7517
+ {
7518
+ defaultLocale: sourceLocale,
7519
+ injectLocale: bucket.injectLocale
7520
+ },
7521
+ [],
7522
+ // Don't apply any filtering when reading
7523
+ [],
7524
+ []
7525
+ );
7526
+ loader.setDefaultLocale(sourceLocale);
7527
+ const data = await loader.pull(sourceLocale);
7528
+ if (!data || Object.keys(data).length === 0) {
7529
+ continue;
7530
+ }
7531
+ const matchedEntries = Object.entries(data).filter(
7532
+ ([key]) => matchesKeyPattern(key, keyPatterns)
7533
+ );
7534
+ if (matchedEntries.length > 0) {
7535
+ console.log(`
7536
+ Matches in ${sourcePath}:`);
7537
+ for (const [key, value] of matchedEntries) {
7538
+ const displayValue = formatDisplayValue(value);
7539
+ console.log(` - ${key}: ${displayValue}`);
7540
+ }
7541
+ console.log(
7542
+ `Total: ${matchedEntries.length} ${config.displayName} key(s)`
7543
+ );
7544
+ }
7545
+ } catch (error) {
7546
+ console.error(` Error reading ${sourcePath}: ${error.message}`);
7547
+ }
7548
+ }
7549
+ }
7550
+ if (!hasAnyKeys) {
7551
+ if (options.bucket) {
7552
+ console.log(
7553
+ `No ${config.displayName} keys configured for bucket: ${options.bucket}`
7554
+ );
7555
+ } else {
7556
+ console.log(`No ${config.displayName} keys configured in any bucket.`);
7557
+ }
7558
+ }
7559
+ }
7560
+ function capitalize(str) {
7561
+ return str.charAt(0).toUpperCase() + str.slice(1);
7562
+ }
7563
+
7564
+ // src/cli/cmd/show/locked-keys.ts
7565
+ var locked_keys_default = new (0, _interactivecommander.Command)().command("locked-keys").description(
7566
+ "Show which key-value pairs in source files match lockedKeys patterns"
7567
+ ).option("--bucket <name>", "Only show locked keys for a specific bucket").helpOption("-h, --help", "Show help").action(async (options) => {
7568
+ const ora = _ora2.default.call(void 0, );
7569
+ try {
7570
+ const i18nConfig = await getConfig();
7571
+ if (!i18nConfig) {
7572
+ throw new CLIError({
7573
+ message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
7574
+ docUrl: "i18nNotFound"
7575
+ });
7576
+ }
7577
+ const buckets = getBuckets(i18nConfig);
7578
+ await executeKeyCommand(i18nConfig, buckets, options, {
7579
+ filterType: "lockedKeys",
7580
+ displayName: "locked"
7581
+ });
7582
+ } catch (error) {
7583
+ ora.fail(error.message);
7584
+ process.exit(1);
7585
+ }
7586
+ });
7587
+
7588
+ // src/cli/cmd/show/ignored-keys.ts
7589
+
7590
+
7591
+ var ignored_keys_default = new (0, _interactivecommander.Command)().command("ignored-keys").description(
7592
+ "Show which key-value pairs in source files match ignoredKeys patterns"
7593
+ ).option("--bucket <name>", "Only show ignored keys for a specific bucket").helpOption("-h, --help", "Show help").action(async (options) => {
7594
+ const ora = _ora2.default.call(void 0, );
7595
+ try {
7596
+ const i18nConfig = await getConfig();
7597
+ if (!i18nConfig) {
7598
+ throw new CLIError({
7599
+ message: "i18n.json not found. Please run `lingo.dev init` to initialize the project.",
7600
+ docUrl: "i18nNotFound"
7601
+ });
7602
+ }
7603
+ const buckets = getBuckets(i18nConfig);
7604
+ await executeKeyCommand(i18nConfig, buckets, options, {
7605
+ filterType: "ignoredKeys",
7606
+ displayName: "ignored"
7607
+ });
7608
+ } catch (error) {
7609
+ ora.fail(error.message);
7610
+ process.exit(1);
7611
+ }
7612
+ });
7613
+
7614
+ // src/cli/cmd/show/index.ts
7615
+ var show_default = new (0, _interactivecommander.Command)().command("show").description("Display configuration, locales, and file paths").helpOption("-h, --help", "Show help").addCommand(config_default).addCommand(locale_default).addCommand(files_default).addCommand(locked_keys_default).addCommand(ignored_keys_default);
7616
+
7617
+ // src/cli/cmd/config/index.ts
7618
+
7619
+
7620
+ // src/cli/cmd/config/set.ts
7621
+
7622
+
7623
+ var _dedent = require('dedent'); var _dedent2 = _interopRequireDefault(_dedent);
7624
+
7625
+ var set_default = new (0, _interactivecommander.Command)().name("set").description("Set or update a CLI setting in ~/.lingodotdevrc").addHelpText("afterAll", `
7626
+ Available keys:
7627
+ ${SETTINGS_KEYS.join("\n ")}`).argument(
7628
+ "<key>",
7629
+ "Configuration key to set (dot notation, e.g., auth.apiKey)"
7630
+ ).argument("<value>", "The configuration value to set").helpOption("-h, --help", "Show help").action(async (key, value) => {
7631
+ if (!SETTINGS_KEYS.includes(key)) {
7632
+ console.error(
7633
+ _dedent2.default`
7634
+ ${_chalk2.default.red("\u2716")} Unknown configuration key: ${_chalk2.default.bold(key)}
7635
+ Run ${_chalk2.default.dim("lingo.dev config set --help")} to see available keys.
7636
+ `
7637
+ );
7638
+ process.exitCode = 1;
7639
+ return;
7640
+ }
7641
+ const current = loadSystemSettings();
7642
+ const updated = _lodash2.default.cloneDeep(current);
7643
+ _lodash2.default.set(updated, key, value);
7644
+ try {
7645
+ saveSettings(updated);
7646
+ console.log(`${_chalk2.default.green("\u2714")} Set ${_chalk2.default.bold(key)}`);
7647
+ } catch (err) {
7648
+ console.error(
7649
+ _chalk2.default.red(
7650
+ `\u2716 Failed to save configuration: ${_chalk2.default.dim(
7651
+ err instanceof Error ? err.message : String(err)
7652
+ )}`
7653
+ )
7654
+ );
7655
+ process.exitCode = 1;
7656
+ }
7657
+ });
7658
+
7659
+ // src/cli/cmd/config/unset.ts
7660
+
7661
+
7662
+
7663
+
7664
+ var unset_default = new (0, _interactivecommander.Command)().name("unset").description("Remove a CLI setting from ~/.lingodotdevrc").addHelpText("afterAll", `
7665
+ Available keys:
7666
+ ${SETTINGS_KEYS.join("\n ")}`).argument(
7667
+ "<key>",
7668
+ "Configuration key to remove (must match one of the available keys listed below)"
7669
+ ).helpOption("-h, --help", "Show help").action(async (key) => {
7670
+ if (!SETTINGS_KEYS.includes(key)) {
7671
+ console.error(
7672
+ _dedent2.default`
7673
+ ${_chalk2.default.red("\u2716")} Unknown configuration key: ${_chalk2.default.bold(key)}
7674
+ Run ${_chalk2.default.dim(
7675
+ "lingo.dev config unset --help"
7676
+ )} to see available keys.
7677
+ `
7678
+ );
7679
+ process.exitCode = 1;
7680
+ return;
7681
+ }
7682
+ const settings = loadSystemSettings();
7683
+ const currentValue = _lodash2.default.get(settings, key);
7684
+ if (!_lodash2.default.trim(String(currentValue || ""))) {
7685
+ console.log(`${_chalk2.default.cyan("\u2139")} ${_chalk2.default.bold(key)} is not set.`);
7686
+ return;
7687
+ } else {
7688
+ const updated = _lodash2.default.cloneDeep(settings);
7689
+ _lodash2.default.unset(updated, key);
7690
+ try {
7691
+ saveSettings(updated);
7692
+ console.log(
7693
+ `${_chalk2.default.green("\u2714")} Removed configuration key ${_chalk2.default.bold(key)}`
7694
+ );
7695
+ } catch (err) {
7696
+ console.error(
7697
+ _chalk2.default.red(
7698
+ `\u2716 Failed to save configuration: ${_chalk2.default.dim(
7699
+ err instanceof Error ? err.message : String(err)
7700
+ )}`
7701
+ )
7702
+ );
7703
+ process.exitCode = 1;
7704
+ }
7705
+ }
7706
+ });
7707
+
7708
+ // src/cli/cmd/config/get.ts
7709
+
7710
+
7711
+
7712
+
7713
+ var get_default = new (0, _interactivecommander.Command)().name("get").description("Display the value of a CLI setting from ~/.lingodotdevrc").addHelpText("afterAll", `
7714
+ Available keys:
7715
+ ${SETTINGS_KEYS.join("\n ")}`).argument(
7716
+ "<key>",
7717
+ "Configuration key to read (choose from the available keys listed below)"
7718
+ ).helpOption("-h, --help", "Show help").action(async (key) => {
7719
+ if (!SETTINGS_KEYS.includes(key)) {
7720
+ console.error(
7721
+ _dedent2.default`
7722
+ ${_chalk2.default.red("\u2716")} Unknown configuration key: ${_chalk2.default.bold(key)}
7723
+ Run ${_chalk2.default.dim("lingo.dev config get --help")} to see available keys.
7724
+ `
7725
+ );
7726
+ process.exitCode = 1;
7727
+ return;
7728
+ }
7729
+ const settings = loadSystemSettings();
7730
+ const value = _lodash2.default.get(settings, key);
7731
+ if (!value) {
7732
+ console.log(`${_chalk2.default.cyan("\u2139")} ${_chalk2.default.bold(key)} is not set.`);
7733
+ return;
7734
+ }
7735
+ if (typeof value === "object") {
7736
+ console.log(JSON.stringify(value, null, 2));
7737
+ } else {
7738
+ console.log(value);
7739
+ }
7740
+ });
7741
+
7742
+ // src/cli/cmd/config/index.ts
7743
+ var config_default2 = new (0, _interactivecommander.Command)().command("config").description(
7744
+ "Manage CLI settings (authentication, API keys) stored in ~/.lingodotdevrc"
7745
+ ).helpOption("-h, --help", "Show help").addCommand(set_default).addCommand(unset_default).addCommand(get_default);
7746
+
7616
7747
  // src/cli/cmd/i18n.ts
7617
7748
 
7749
+
7750
+
7751
+
7752
+
7753
+
7754
+
7755
+
7756
+
7757
+
7618
7758
  var _diff = require('diff');
7619
7759
 
7620
7760
  var _externaleditor = require('external-editor'); var _externaleditor2 = _interopRequireDefault(_externaleditor);
@@ -11484,7 +11624,7 @@ async function renderHero2() {
11484
11624
  // package.json
11485
11625
  var package_default = {
11486
11626
  name: "lingo.dev",
11487
- version: "0.112.0",
11627
+ version: "0.112.1",
11488
11628
  description: "Lingo.dev CLI",
11489
11629
  private: false,
11490
11630
  publishConfig: {