@formatjs/cli 6.4.3 → 6.5.0

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.
Files changed (2) hide show
  1. package/bin/formatjs +39 -12
  2. package/package.json +2 -2
package/bin/formatjs CHANGED
@@ -12498,12 +12498,31 @@ var require_manipulator = __commonJS({
12498
12498
  collectVariables(a, aVars);
12499
12499
  collectVariables(b, bVars);
12500
12500
  if (aVars.size !== bVars.size) {
12501
- return false;
12501
+ return {
12502
+ success: false,
12503
+ error: new Error("Different number of variables: [".concat(Array.from(aVars.keys()).join(", "), "] vs [").concat(Array.from(bVars.keys()).join(", "), "]"))
12504
+ };
12502
12505
  }
12503
- return Array.from(aVars.entries()).every(function(_a) {
12506
+ return Array.from(aVars.entries()).reduce(function(result, _a) {
12504
12507
  var key = _a[0], type = _a[1];
12505
- return bVars.has(key) && bVars.get(key) === type;
12506
- });
12508
+ if (!result.success) {
12509
+ return result;
12510
+ }
12511
+ var bType = bVars.get(key);
12512
+ if (bType == null) {
12513
+ return {
12514
+ success: false,
12515
+ error: new Error("Missing variable ".concat(key, " in message"))
12516
+ };
12517
+ }
12518
+ if (bType !== type) {
12519
+ return {
12520
+ success: false,
12521
+ error: new Error("Variable ".concat(key, " has conflicting types: ").concat(types_1.TYPE[type], " vs ").concat(types_1.TYPE[bType]))
12522
+ };
12523
+ }
12524
+ return result;
12525
+ }, { success: true });
12507
12526
  }
12508
12527
  }
12509
12528
  });
@@ -228002,19 +228021,25 @@ async function checkStructuralEquality(translationFilesContents, sourceLocale) {
228002
228021
  }, {});
228003
228022
  return Object.entries(translationFilesContents).filter(([locale]) => locale !== sourceLocale).reduce((result, [locale, content]) => {
228004
228023
  const localeMessages = flatten(content);
228005
- const problematicKeys = Object.keys(enUSMessages).filter((k) => {
228024
+ const problematicKeys = Object.keys(enUSMessages).map((k) => {
228006
228025
  if (!localeMessages[k]) {
228007
- return false;
228026
+ return { key: k, success: true };
228008
228027
  }
228009
228028
  const enUSMessage = enUSMessages[k];
228010
228029
  try {
228011
228030
  const localeMessage = (0, import_icu_messageformat_parser4.parse)(localeMessages[k]);
228012
- return !(0, import_icu_messageformat_parser4.isStructurallySame)(enUSMessage, localeMessage);
228031
+ return {
228032
+ key: k,
228033
+ ...(0, import_icu_messageformat_parser4.isStructurallySame)(enUSMessage, localeMessage)
228034
+ };
228013
228035
  } catch (e) {
228014
- (0, import_console.error)("Error comparing message", k, enUSMessage, localeMessages[k], e);
228015
- return true;
228036
+ return {
228037
+ key: k,
228038
+ success: false,
228039
+ error: e instanceof Error ? e : new Error(String(e))
228040
+ };
228016
228041
  }
228017
- });
228042
+ }).filter((s) => !s.success);
228018
228043
  if (!problematicKeys.length) {
228019
228044
  return result;
228020
228045
  }
@@ -228023,8 +228048,10 @@ async function checkStructuralEquality(translationFilesContents, sourceLocale) {
228023
228048
  `These translation keys for locale ${locale} are structurally different from ${sourceLocale}:
228024
228049
  `
228025
228050
  );
228026
- problematicKeys.forEach((r) => writeStderr(`${r}
228027
- `));
228051
+ problematicKeys.forEach(
228052
+ ({ key, error: error2 }) => writeStderr(`${key}: ${error2 == null ? void 0 : error2.message}
228053
+ `)
228054
+ );
228028
228055
  return false;
228029
228056
  }, true);
228030
228057
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/cli",
3
- "version": "6.4.3",
3
+ "version": "6.5.0",
4
4
  "description": "A CLI for formatjs.",
5
5
  "keywords": [
6
6
  "intl",
@@ -33,7 +33,7 @@
33
33
  "url": "https://github.com/formatjs/formatjs/issues"
34
34
  },
35
35
  "devDependencies": {
36
- "@formatjs/cli-lib": "7.1.3"
36
+ "@formatjs/cli-lib": "7.2.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@glimmer/env": "^0.1.7",