@formatjs/cli 5.0.1 → 5.0.5

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 (53) hide show
  1. package/bin/formatjs +38 -37
  2. package/package.json +46 -44
  3. package/index.d.ts +0 -8
  4. package/index.d.ts.map +0 -1
  5. package/index.js +0 -12
  6. package/main.d.ts +0 -2
  7. package/main.d.ts.map +0 -1
  8. package/main.js +0 -3
  9. package/src/cli.d.ts +0 -3
  10. package/src/cli.d.ts.map +0 -1
  11. package/src/cli.js +0 -142
  12. package/src/compile.d.ts +0 -48
  13. package/src/compile.d.ts.map +0 -1
  14. package/src/compile.js +0 -122
  15. package/src/compile_folder.d.ts +0 -3
  16. package/src/compile_folder.d.ts.map +0 -1
  17. package/src/compile_folder.js +0 -22
  18. package/src/console_utils.d.ts +0 -9
  19. package/src/console_utils.d.ts.map +0 -1
  20. package/src/console_utils.js +0 -141
  21. package/src/extract.d.ts +0 -75
  22. package/src/extract.d.ts.map +0 -1
  23. package/src/extract.js +0 -220
  24. package/src/formatters/crowdin.d.ts +0 -8
  25. package/src/formatters/crowdin.d.ts.map +0 -1
  26. package/src/formatters/crowdin.js +0 -29
  27. package/src/formatters/default.d.ts +0 -6
  28. package/src/formatters/default.d.ts.map +0 -1
  29. package/src/formatters/default.js +0 -13
  30. package/src/formatters/index.d.ts +0 -9
  31. package/src/formatters/index.d.ts.map +0 -1
  32. package/src/formatters/index.js +0 -45
  33. package/src/formatters/lokalise.d.ts +0 -10
  34. package/src/formatters/lokalise.d.ts.map +0 -1
  35. package/src/formatters/lokalise.js +0 -26
  36. package/src/formatters/simple.d.ts +0 -5
  37. package/src/formatters/simple.d.ts.map +0 -1
  38. package/src/formatters/simple.js +0 -12
  39. package/src/formatters/smartling.d.ts +0 -24
  40. package/src/formatters/smartling.d.ts.map +0 -1
  41. package/src/formatters/smartling.js +0 -52
  42. package/src/formatters/transifex.d.ts +0 -10
  43. package/src/formatters/transifex.d.ts.map +0 -1
  44. package/src/formatters/transifex.js +0 -26
  45. package/src/parse_script.d.ts +0 -8
  46. package/src/parse_script.d.ts.map +0 -1
  47. package/src/parse_script.js +0 -50
  48. package/src/pseudo_locale.d.ts +0 -7
  49. package/src/pseudo_locale.d.ts.map +0 -1
  50. package/src/pseudo_locale.js +0 -104
  51. package/src/vue_extractor.d.ts +0 -3
  52. package/src/vue_extractor.d.ts.map +0 -1
  53. package/src/vue_extractor.js +0 -62
package/bin/formatjs CHANGED
@@ -3410,7 +3410,7 @@ var require_source = __commonJS({
3410
3410
  }
3411
3411
  });
3412
3412
 
3413
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/console_utils.js
3413
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/console_utils.js
3414
3414
  async function clearLine(terminal) {
3415
3415
  if (!import_chalk.supportsColor) {
3416
3416
  if (terminal.isTTY) {
@@ -3457,7 +3457,7 @@ function getStdinAsString() {
3457
3457
  }
3458
3458
  var import_chalk, import_readline, import_util, CLEAR_WHOLE_LINE, writeStderr, writeStdout, nativeClearLine, nativeCursorTo, LEVEL_COLORS;
3459
3459
  var init_console_utils = __esm({
3460
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/console_utils.js"() {
3460
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/console_utils.js"() {
3461
3461
  import_chalk = __toESM(require_source());
3462
3462
  import_readline = __toESM(require("readline"));
3463
3463
  import_util = require("util");
@@ -148907,7 +148907,7 @@ var require_ts_transformer = __commonJS({
148907
148907
  }
148908
148908
  });
148909
148909
 
148910
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/default.js
148910
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/default.js
148911
148911
  var default_exports = {};
148912
148912
  __export(default_exports, {
148913
148913
  compile: () => compile,
@@ -148915,7 +148915,7 @@ __export(default_exports, {
148915
148915
  });
148916
148916
  var format2, compile;
148917
148917
  var init_default = __esm({
148918
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/default.js"() {
148918
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/default.js"() {
148919
148919
  format2 = (msgs) => msgs;
148920
148920
  compile = (msgs) => {
148921
148921
  const results = {};
@@ -148927,7 +148927,7 @@ var init_default = __esm({
148927
148927
  }
148928
148928
  });
148929
148929
 
148930
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/transifex.js
148930
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/transifex.js
148931
148931
  var transifex_exports = {};
148932
148932
  __export(transifex_exports, {
148933
148933
  compile: () => compile2,
@@ -148935,7 +148935,7 @@ __export(transifex_exports, {
148935
148935
  });
148936
148936
  var format3, compile2;
148937
148937
  var init_transifex = __esm({
148938
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/transifex.js"() {
148938
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/transifex.js"() {
148939
148939
  format3 = (msgs) => {
148940
148940
  const results = {};
148941
148941
  for (const [id, msg] of Object.entries(msgs)) {
@@ -148956,7 +148956,7 @@ var init_transifex = __esm({
148956
148956
  }
148957
148957
  });
148958
148958
 
148959
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/smartling.js
148959
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/smartling.js
148960
148960
  var smartling_exports = {};
148961
148961
  __export(smartling_exports, {
148962
148962
  compareMessages: () => compareMessages,
@@ -148965,7 +148965,7 @@ __export(smartling_exports, {
148965
148965
  });
148966
148966
  var format4, compareMessages, compile3;
148967
148967
  var init_smartling = __esm({
148968
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/smartling.js"() {
148968
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/smartling.js"() {
148969
148969
  format4 = (msgs) => {
148970
148970
  const results = {
148971
148971
  smartling: {
@@ -149010,7 +149010,7 @@ var init_smartling = __esm({
149010
149010
  }
149011
149011
  });
149012
149012
 
149013
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/simple.js
149013
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/simple.js
149014
149014
  var simple_exports = {};
149015
149015
  __export(simple_exports, {
149016
149016
  compile: () => compile4,
@@ -149018,7 +149018,7 @@ __export(simple_exports, {
149018
149018
  });
149019
149019
  var format5, compile4;
149020
149020
  var init_simple = __esm({
149021
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/simple.js"() {
149021
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/simple.js"() {
149022
149022
  format5 = (msgs) => {
149023
149023
  return Object.keys(msgs).reduce((all, k) => {
149024
149024
  all[k] = msgs[k].defaultMessage;
@@ -149029,7 +149029,7 @@ var init_simple = __esm({
149029
149029
  }
149030
149030
  });
149031
149031
 
149032
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/lokalise.js
149032
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/lokalise.js
149033
149033
  var lokalise_exports = {};
149034
149034
  __export(lokalise_exports, {
149035
149035
  compile: () => compile5,
@@ -149037,7 +149037,7 @@ __export(lokalise_exports, {
149037
149037
  });
149038
149038
  var format6, compile5;
149039
149039
  var init_lokalise = __esm({
149040
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/lokalise.js"() {
149040
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/lokalise.js"() {
149041
149041
  format6 = (msgs) => {
149042
149042
  const results = {};
149043
149043
  for (const [id, msg] of Object.entries(msgs)) {
@@ -149058,7 +149058,7 @@ var init_lokalise = __esm({
149058
149058
  }
149059
149059
  });
149060
149060
 
149061
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/crowdin.js
149061
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/crowdin.js
149062
149062
  var crowdin_exports = {};
149063
149063
  __export(crowdin_exports, {
149064
149064
  compile: () => compile6,
@@ -149066,7 +149066,7 @@ __export(crowdin_exports, {
149066
149066
  });
149067
149067
  var format7, compile6;
149068
149068
  var init_crowdin = __esm({
149069
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/crowdin.js"() {
149069
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/crowdin.js"() {
149070
149070
  format7 = (msgs) => {
149071
149071
  const results = {};
149072
149072
  for (const [id, msg] of Object.entries(msgs)) {
@@ -149090,7 +149090,7 @@ var init_crowdin = __esm({
149090
149090
  }
149091
149091
  });
149092
149092
 
149093
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/index.js
149093
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/index.js
149094
149094
  async function resolveBuiltinFormatter(format8) {
149095
149095
  if (!format8) {
149096
149096
  return default_exports;
@@ -149119,7 +149119,7 @@ async function resolveBuiltinFormatter(format8) {
149119
149119
  }
149120
149120
  var import_path;
149121
149121
  var init_formatters = __esm({
149122
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/formatters/index.js"() {
149122
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/formatters/index.js"() {
149123
149123
  init_default();
149124
149124
  init_transifex();
149125
149125
  init_smartling();
@@ -149130,7 +149130,7 @@ var init_formatters = __esm({
149130
149130
  }
149131
149131
  });
149132
149132
 
149133
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/parse_script.js
149133
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/parse_script.js
149134
149134
  function parseScript(opts, fn) {
149135
149135
  return (source) => {
149136
149136
  let output;
@@ -149170,7 +149170,7 @@ ${e.message || ""}`;
149170
149170
  }
149171
149171
  var import_ts_transformer, import_typescript;
149172
149172
  var init_parse_script = __esm({
149173
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/parse_script.js"() {
149173
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/parse_script.js"() {
149174
149174
  import_ts_transformer = __toESM(require_ts_transformer());
149175
149175
  import_typescript = __toESM(require_typescript());
149176
149176
  init_console_utils();
@@ -149326,7 +149326,7 @@ var require_manipulator = __commonJS({
149326
149326
  }
149327
149327
  });
149328
149328
 
149329
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/vue_extractor.js
149329
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/vue_extractor.js
149330
149330
  var vue_extractor_exports = {};
149331
149331
  __export(vue_extractor_exports, {
149332
149332
  parseFile: () => parseFile
@@ -149380,12 +149380,12 @@ function parseFile(source, filename, parseScriptFn) {
149380
149380
  }
149381
149381
  var import_compiler_sfc;
149382
149382
  var init_vue_extractor = __esm({
149383
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/vue_extractor.js"() {
149383
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/vue_extractor.js"() {
149384
149384
  import_compiler_sfc = require("@vue/compiler-sfc");
149385
149385
  }
149386
149386
  });
149387
149387
 
149388
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/extract.js
149388
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/extract.js
149389
149389
  function calculateLineColFromOffset(text, start) {
149390
149390
  if (!start) {
149391
149391
  return { line: 1, col: 1 };
@@ -149520,7 +149520,7 @@ async function extractAndWrite(files, extractOpts) {
149520
149520
  }
149521
149521
  var import_fs_extra, import_ts_transformer2, import_json_stable_stringify, import_printer, import_manipulator, import_icu_messageformat_parser;
149522
149522
  var init_extract = __esm({
149523
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/extract.js"() {
149523
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/extract.js"() {
149524
149524
  init_console_utils();
149525
149525
  import_fs_extra = __toESM(require_lib());
149526
149526
  import_ts_transformer2 = __toESM(require_ts_transformer());
@@ -149533,7 +149533,7 @@ var init_extract = __esm({
149533
149533
  }
149534
149534
  });
149535
149535
 
149536
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/pseudo_locale.js
149536
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/pseudo_locale.js
149537
149537
  function generateXXLS(msg) {
149538
149538
  const ast = typeof msg === "string" ? (0, import_icu_messageformat_parser2.parse)(msg) : msg;
149539
149539
  const lastChunk = ast.pop();
@@ -149613,14 +149613,14 @@ function generateENXB(msg) {
149613
149613
  }
149614
149614
  var import_icu_messageformat_parser2, ASCII, ACCENTED_ASCII;
149615
149615
  var init_pseudo_locale = __esm({
149616
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/pseudo_locale.js"() {
149616
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/pseudo_locale.js"() {
149617
149617
  import_icu_messageformat_parser2 = __toESM(require_icu_messageformat_parser());
149618
149618
  ASCII = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
149619
149619
  ACCENTED_ASCII = "\xE2\u1E03\u0107\u1E0B\xE8\u1E1F\u011D\u1E2B\xED\u0135\u01E9\u013A\u1E41\u0144\u014F\u1E57\u024B\u0155\u015B\u1E6D\u016F\u1E7F\u1E98\u1E8B\u1E8F\u1E93\u1E00\u1E02\u1E08\u1E0A\u1E14\u1E1E\u1E20\u1E22\u1E2C\u0134\u1E34\u013B\u1E3E\u014A\xD5\u1E54\u024A\u0154\u1E60\u1E6E\u0168\u1E7C\u1E84\u1E8C\u0178\u01B5";
149620
149620
  }
149621
149621
  });
149622
149622
 
149623
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/compile.js
149623
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/compile.js
149624
149624
  async function compile7(inputFiles, opts = {}) {
149625
149625
  debug("Compiling files:", inputFiles);
149626
149626
  const { ast, format: format8, pseudoLocale, skipErrors } = opts;
@@ -149691,7 +149691,7 @@ async function compileAndWrite(inputFiles, compileOpts = {}) {
149691
149691
  }
149692
149692
  var import_icu_messageformat_parser3, import_fs_extra2, import_json_stable_stringify2;
149693
149693
  var init_compile = __esm({
149694
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/compile.js"() {
149694
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/compile.js"() {
149695
149695
  import_icu_messageformat_parser3 = __toESM(require_icu_messageformat_parser());
149696
149696
  import_fs_extra2 = __toESM(require_lib());
149697
149697
  import_json_stable_stringify2 = __toESM(require_json_stable_stringify());
@@ -149701,7 +149701,7 @@ var init_compile = __esm({
149701
149701
  }
149702
149702
  });
149703
149703
 
149704
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/compile_folder.js
149704
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/compile_folder.js
149705
149705
  async function compileFolder(files, outFolder, opts = {}) {
149706
149706
  const results = await Promise.all(files.map((f) => compile7([f], opts)));
149707
149707
  const outFiles = files.map((f) => (0, import_path2.join)(outFolder, (0, import_path2.basename)(f)));
@@ -149709,7 +149709,7 @@ async function compileFolder(files, outFolder, opts = {}) {
149709
149709
  }
149710
149710
  var import_path2, import_fs_extra3;
149711
149711
  var init_compile_folder = __esm({
149712
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/compile_folder.js"() {
149712
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/compile_folder.js"() {
149713
149713
  init_compile();
149714
149714
  import_path2 = require("path");
149715
149715
  import_fs_extra3 = __toESM(require_lib());
@@ -151741,7 +151741,8 @@ var require_parse3 = __commonJS({
151741
151741
  output = token.close = `)$))${extglobStar}`;
151742
151742
  }
151743
151743
  if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
151744
- output = token.close = `)${rest})${extglobStar})`;
151744
+ const expression = parse5(rest, __spreadProps(__spreadValues({}, options), { fastpaths: false })).output;
151745
+ output = token.close = `)${expression})${extglobStar})`;
151745
151746
  }
151746
151747
  if (token.prev.type === "bos") {
151747
151748
  state.negatedExtglob = true;
@@ -152559,9 +152560,9 @@ var require_micromatch = __commonJS({
152559
152560
  options.onResult(state);
152560
152561
  items.push(state.output);
152561
152562
  };
152562
- let matches = micromatch(list, patterns, __spreadProps(__spreadValues({}, options), { onResult }));
152563
+ let matches = new Set(micromatch(list, patterns, __spreadProps(__spreadValues({}, options), { onResult })));
152563
152564
  for (let item of items) {
152564
- if (!matches.includes(item)) {
152565
+ if (!matches.has(item)) {
152565
152566
  result.add(item);
152566
152567
  }
152567
152568
  }
@@ -154910,15 +154911,15 @@ var require_out4 = __commonJS({
154910
154911
  }
154911
154912
  });
154912
154913
 
154913
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/package.json
154914
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/package.json
154914
154915
  var version;
154915
154916
  var init_package = __esm({
154916
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/package.json"() {
154917
- version = "5.0.1";
154917
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/package.json"() {
154918
+ version = "5.0.4";
154918
154919
  }
154919
154920
  });
154920
154921
 
154921
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/cli.js
154922
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/cli.js
154922
154923
  var cli_exports = {};
154923
154924
  __export(cli_exports, {
154924
154925
  default: () => cli_default
@@ -155037,7 +155038,7 @@ for more information`).action(async (folder, outFolder, opts) => {
155037
155038
  }
155038
155039
  var import_commander, import_loud_rejection, import_fast_glob, KNOWN_COMMANDS, cli_default;
155039
155040
  var init_cli = __esm({
155040
- "bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/src/cli.js"() {
155041
+ "bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/src/cli.js"() {
155041
155042
  import_commander = __toESM(require_commander());
155042
155043
  import_loud_rejection = __toESM(require_loud_rejection());
155043
155044
  init_extract();
@@ -155051,7 +155052,7 @@ var init_cli = __esm({
155051
155052
  }
155052
155053
  });
155053
155054
 
155054
- // bazel-out/darwin-fastbuild/bin/packages/cli/lib_esnext/main.js
155055
+ // bazel-out/darwin-fastbuild/bin/packages/cli-lib/lib_esnext/main.js
155055
155056
  (init_cli(), __toCommonJS(cli_exports)).default(process.argv);
155056
155057
  /*!
155057
155058
  * fill-range <https://github.com/jonschlinkert/fill-range>
package/package.json CHANGED
@@ -1,47 +1,49 @@
1
1
  {
2
- "name": "@formatjs/cli",
3
- "version": "5.0.1",
4
- "description": "A CLI for formatjs.",
5
- "keywords": [
6
- "intl",
7
- "i18n",
8
- "internationalization",
9
- "locale",
10
- "localization",
11
- "globalization",
12
- "react",
13
- "react-intl",
14
- "reactjs",
15
- "format",
16
- "formatjs",
17
- "formatting",
18
- "translate",
19
- "translation",
20
- "cli"
21
- ],
22
- "author": "Linjie Ding <linjie@airtable.com>",
23
- "homepage": "https://github.com/formatjs/formatjs",
24
- "license": "MIT",
25
- "main": "index.js",
26
- "bin": {
27
- "formatjs": "bin/formatjs"
28
- },
29
- "repository": {
30
- "type": "git",
31
- "url": "git+ssh://git@github.com/formatjs/formatjs.git"
32
- },
33
- "bugs": {
34
- "url": "https://github.com/formatjs/formatjs/issues"
35
- },
36
- "peerDependencies": {
37
- "@vue/compiler-sfc": "^3.2.34"
38
- },
39
- "peerDependenciesMeta": {
40
- "@vue/compiler-sfc": {
41
- "optional": true
42
- }
43
- },
44
- "engines": {
45
- "node": ">= 16.5.0"
2
+ "name": "@formatjs/cli",
3
+ "version": "5.0.5",
4
+ "description": "A CLI for formatjs.",
5
+ "keywords": [
6
+ "intl",
7
+ "i18n",
8
+ "internationalization",
9
+ "locale",
10
+ "localization",
11
+ "globalization",
12
+ "react",
13
+ "react-intl",
14
+ "reactjs",
15
+ "format",
16
+ "formatjs",
17
+ "formatting",
18
+ "translate",
19
+ "translation",
20
+ "cli"
21
+ ],
22
+ "author": "Linjie Ding <linjie@airtable.com>",
23
+ "homepage": "https://github.com/formatjs/formatjs",
24
+ "license": "MIT",
25
+ "bin": {
26
+ "formatjs": "bin/formatjs"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+ssh://git@github.com/formatjs/formatjs.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/formatjs/formatjs/issues"
34
+ },
35
+ "devDependencies": {
36
+ "@formatjs/cli-lib": "5.0.4"
37
+ },
38
+ "peerDependencies": {
39
+ "@vue/compiler-sfc": "^3.2.34"
40
+ },
41
+ "peerDependenciesMeta": {
42
+ "@vue/compiler-sfc": {
43
+ "optional": true
46
44
  }
45
+ },
46
+ "engines": {
47
+ "node": ">= 16.5.0"
48
+ }
47
49
  }
package/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export { default as extractAndWrite, extract } from './src/extract';
2
- export type { ExtractCLIOptions, ExtractOpts } from './src/extract';
3
- export type { MessageDescriptor } from '@formatjs/ts-transformer';
4
- export type { FormatFn, CompileFn } from './src/formatters/default';
5
- export type { Element, Comparator } from 'json-stable-stringify';
6
- export { default as compileAndWrite, compile } from './src/compile';
7
- export type { CompileCLIOpts, Opts as CompileOpts } from './src/compile';
8
- //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,eAAe,EAAE,OAAO,EAAC,MAAM,eAAe,CAAA;AACjE,YAAY,EAAC,iBAAiB,EAAE,WAAW,EAAC,MAAM,eAAe,CAAA;AACjE,YAAY,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAA;AAC/D,YAAY,EAAC,QAAQ,EAAE,SAAS,EAAC,MAAM,0BAA0B,CAAA;AACjE,YAAY,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAE,OAAO,EAAC,MAAM,eAAe,CAAA;AACjE,YAAY,EAAC,cAAc,EAAE,IAAI,IAAI,WAAW,EAAC,MAAM,eAAe,CAAA"}
package/index.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.compile = exports.compileAndWrite = exports.extract = exports.extractAndWrite = void 0;
7
- var extract_1 = require("./src/extract");
8
- Object.defineProperty(exports, "extractAndWrite", { enumerable: true, get: function () { return __importDefault(extract_1).default; } });
9
- Object.defineProperty(exports, "extract", { enumerable: true, get: function () { return extract_1.extract; } });
10
- var compile_1 = require("./src/compile");
11
- Object.defineProperty(exports, "compileAndWrite", { enumerable: true, get: function () { return __importDefault(compile_1).default; } });
12
- Object.defineProperty(exports, "compile", { enumerable: true, get: function () { return compile_1.compile; } });
package/main.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- //# sourceMappingURL=main.d.ts.map
package/main.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../../packages/cli/main.ts"],"names":[],"mappings":""}
package/main.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- require('./src/cli').default(process.argv);
package/src/cli.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare function main(argv: string[]): Promise<void>;
2
- export default main;
3
- //# sourceMappingURL=cli.d.ts.map
package/src/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../../../../packages/cli/src/cli.ts"],"names":[],"mappings":"AAWA,iBAAe,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,iBAmOjC;AACD,eAAe,IAAI,CAAA"}
package/src/cli.js DELETED
@@ -1,142 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var commander_1 = require("commander");
5
- var loud_rejection_1 = (0, tslib_1.__importDefault)(require("loud-rejection"));
6
- var extract_1 = (0, tslib_1.__importDefault)(require("./extract"));
7
- var compile_1 = (0, tslib_1.__importDefault)(require("./compile"));
8
- var compile_folder_1 = (0, tslib_1.__importDefault)(require("./compile_folder"));
9
- var fast_glob_1 = require("fast-glob");
10
- var console_utils_1 = require("./console_utils");
11
- var package_json_1 = require("../package.json");
12
- var KNOWN_COMMANDS = ['extract'];
13
- function main(argv) {
14
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
15
- var _this = this;
16
- return (0, tslib_1.__generator)(this, function (_a) {
17
- (0, loud_rejection_1.default)();
18
- commander_1.program
19
- .version(package_json_1.version, '-v, --version')
20
- .usage('<command> [flags]')
21
- .action(function (command) {
22
- if (!KNOWN_COMMANDS.includes(command)) {
23
- commander_1.program.help();
24
- }
25
- });
26
- commander_1.program
27
- .command('help', { isDefault: true })
28
- .description('Show this help message.')
29
- .action(function () { return commander_1.program.help(); });
30
- // Long text wrapping to available terminal columns: https://github.com/tj/commander.js/pull/956
31
- // NOTE: please keep the help text in sync with babel-plugin-formatjs documentation.
32
- commander_1.program
33
- .command('extract [files...]')
34
- .description("Extract string messages from React components that use react-intl.\nThe input language is expected to be TypeScript or ES2017 with JSX.")
35
- .option('--format <path>', "Path to a formatter file that controls the shape of JSON file from `--out-file`.\nThe formatter file must export a function called `format` with the signature\n```\ntype FormatFn = <T = Record<string, MessageDescriptor>>(\n msgs: Record<string, MessageDescriptor>\n) => T\n``` \nThis is especially useful to convert from our extracted format to a TMS-specific format.\n")
36
- .option('--out-file <path>', "The target file path where the plugin will output an aggregated \n`.json` file of all the translations from the `files` supplied.")
37
- .option('--id-interpolation-pattern <pattern>', "If certain message descriptors don't have id, this `pattern` will be used to automatically\ngenerate IDs for them. Default to `[sha512:contenthash:base64:6]` where `contenthash` is the hash of\n`defaultMessage` and `description`.\nSee https://github.com/webpack/loader-utils#interpolatename for sample patterns", '[sha512:contenthash:base64:6]')
38
- .option('--extract-source-location', "Whether the metadata about the location of the message in the source file should be \nextracted. If `true`, then `file`, `start`, and `end` fields will exist for each \nextracted message descriptors.", false)
39
- .option('--remove-default-message', 'Remove `defaultMessage` field in generated js after extraction', false)
40
- .option('--additional-component-names <comma-separated-names>', "Additional component names to extract messages from, e.g: `'FormattedFooBarMessage'`. \n**NOTE**: By default we check for the fact that `FormattedMessage` \nis imported from `moduleSourceName` to make sure variable alias \nworks. This option does not do that so it's less safe.", function (val) { return val.split(','); })
41
- .option('--additional-function-names <comma-separated-names>', "Additional function names to extract messages from, e.g: `'$t'`.", function (val) { return val.split(','); })
42
- .option('--ignore <files...>', 'List of glob paths to **not** extract translations from.')
43
- .option('--throws', 'Whether to throw an exception when we fail to process any file in the batch.')
44
- .option('--pragma <pragma>', "parse specific additional custom pragma. This allows you to tag certain file with metadata such as `project`. For example with this file:\n\n ```\n // @intl-meta project:my-custom-project\n import {FormattedMessage} from 'react-intl';\n\n <FormattedMessage defaultMessage=\"foo\" id=\"bar\" />;\n ```\n\n and with option `{pragma: \"intl-meta\"}`, we'll parse out `// @intl-meta project:my-custom-project` into `{project: 'my-custom-project'}` in the result file.")
45
- .option('--preserve-whitespace', 'Whether to preserve whitespace and newlines.')
46
- .option('--flatten', "Whether to hoist selectors & flatten sentences as much as possible. E.g:\n\"I have {count, plural, one{a dog} other{many dogs}}\"\nbecomes \"{count, plural, one{I have a dog} other{I have many dogs}}\".\nThe goal is to provide as many full sentences as possible since fragmented\nsentences are not translator-friendly.")
47
- .action(function (filePatterns, cmdObj) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
48
- var files;
49
- return (0, tslib_1.__generator)(this, function (_a) {
50
- switch (_a.label) {
51
- case 0:
52
- (0, console_utils_1.debug)('File pattern:', filePatterns);
53
- (0, console_utils_1.debug)('Options:', cmdObj);
54
- files = (0, fast_glob_1.sync)(filePatterns, {
55
- ignore: cmdObj.ignore,
56
- });
57
- (0, console_utils_1.debug)('Files to extract:', files);
58
- return [4 /*yield*/, (0, extract_1.default)(files, {
59
- outFile: cmdObj.outFile,
60
- idInterpolationPattern: cmdObj.idInterpolationPattern || '[sha1:contenthash:base64:6]',
61
- extractSourceLocation: cmdObj.extractSourceLocation,
62
- removeDefaultMessage: cmdObj.removeDefaultMessage,
63
- additionalComponentNames: cmdObj.additionalComponentNames,
64
- additionalFunctionNames: cmdObj.additionalFunctionNames,
65
- throws: cmdObj.throws,
66
- pragma: cmdObj.pragma,
67
- format: cmdObj.format,
68
- // It is possible that the glob pattern does NOT match anything.
69
- // But so long as the glob pattern is provided, don't read from stdin.
70
- readFromStdin: filePatterns.length === 0,
71
- preserveWhitespace: cmdObj.preserveWhitespace,
72
- flatten: cmdObj.flatten,
73
- })];
74
- case 1:
75
- _a.sent();
76
- process.exit(0);
77
- return [2 /*return*/];
78
- }
79
- });
80
- }); });
81
- commander_1.program
82
- .command('compile [translation_files...]')
83
- .description("Compile extracted translation file into react-intl consumable JSON\nWe also verify that the messages are valid ICU and not malformed. \n<translation_files> can be a glob like \"foo/**/en.json\"")
84
- .option('--format <path>', "Path to a formatter file that converts `<translation_file>` to `Record<string, string>`\nso we can compile. The file must export a function named `compile` with the signature:\n```\ntype CompileFn = <T = Record<string, MessageDescriptor>>(\n msgs: T\n) => Record<string, string>;\n```\nThis is especially useful to convert from a TMS-specific format back to react-intl format\n")
85
- .option('--out-file <path>', "Compiled translation output file.\nIf this is not provided, result will be printed to stdout")
86
- .option('--ast', "Whether to compile to AST. See https://formatjs.io/docs/guides/advanced-usage#pre-parsing-messages\nfor more information")
87
- .option('--skip-errors', "Whether to continue compiling messages after encountering an error. Any keys with errors will not be included in the output file.")
88
- .option('--pseudo-locale <pseudoLocale>', "Whether to generate pseudo-locale files. See https://formatjs.io/docs/tooling/cli#--pseudo-locale-pseudolocale for possible values. \n\"--ast\" is required for this to work.")
89
- .action(function (filePatterns, opts) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
90
- var files;
91
- return (0, tslib_1.__generator)(this, function (_a) {
92
- switch (_a.label) {
93
- case 0:
94
- (0, console_utils_1.debug)('File pattern:', filePatterns);
95
- (0, console_utils_1.debug)('Options:', opts);
96
- files = (0, fast_glob_1.sync)(filePatterns);
97
- if (!files.length) {
98
- throw new Error("No input file found with pattern ".concat(filePatterns));
99
- }
100
- (0, console_utils_1.debug)('Files to compile:', files);
101
- return [4 /*yield*/, (0, compile_1.default)(files, opts)];
102
- case 1:
103
- _a.sent();
104
- return [2 /*return*/];
105
- }
106
- });
107
- }); });
108
- commander_1.program
109
- .command('compile-folder <folder> <outFolder>')
110
- .description("Batch compile all extracted translation JSON files in <folder> to <outFolder> containing\nreact-intl consumable JSON. We also verify that the messages are \nvalid ICU and not malformed.")
111
- .option('--format <path>', "Path to a formatter file that converts JSON files in `<folder>` to `Record<string, string>`\nso we can compile. The file must export a function named `compile` with the signature:\n```\ntype CompileFn = <T = Record<string, MessageDescriptor>>(\n msgs: T\n) => Record<string, string>;\n```\nThis is especially useful to convert from a TMS-specific format back to react-intl format\n")
112
- .option('--ast', "Whether to compile to AST. See https://formatjs.io/docs/guides/advanced-usage#pre-parsing-messages\nfor more information")
113
- .action(function (folder, outFolder, opts) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
114
- var files;
115
- return (0, tslib_1.__generator)(this, function (_a) {
116
- switch (_a.label) {
117
- case 0:
118
- (0, console_utils_1.debug)('Folder:', folder);
119
- (0, console_utils_1.debug)('Options:', opts);
120
- files = (0, fast_glob_1.sync)("".concat(folder, "/*.json"));
121
- if (!files.length) {
122
- throw new Error("No JSON file found in ".concat(folder));
123
- }
124
- (0, console_utils_1.debug)('Files to compile:', files);
125
- return [4 /*yield*/, (0, compile_folder_1.default)(files, outFolder, opts)];
126
- case 1:
127
- _a.sent();
128
- return [2 /*return*/];
129
- }
130
- });
131
- }); });
132
- if (argv.length < 3) {
133
- commander_1.program.help();
134
- }
135
- else {
136
- commander_1.program.parse(argv);
137
- }
138
- return [2 /*return*/];
139
- });
140
- });
141
- }
142
- exports.default = main;
package/src/compile.d.ts DELETED
@@ -1,48 +0,0 @@
1
- import { Formatter } from './formatters';
2
- export declare type CompileFn = (msgs: any) => Record<string, string>;
3
- export declare type PseudoLocale = 'xx-LS' | 'xx-AC' | 'xx-HA' | 'en-XA' | 'en-XB';
4
- export interface CompileCLIOpts extends Opts {
5
- /**
6
- * The target file that contains compiled messages.
7
- */
8
- outFile?: string;
9
- }
10
- export interface Opts {
11
- /**
12
- * Whether to compile message into AST instead of just string
13
- */
14
- ast?: boolean;
15
- /**
16
- * Whether to continue compiling messages after encountering an error.
17
- * Any keys with errors will not be included in the output file.
18
- */
19
- skipErrors?: boolean;
20
- /**
21
- * Path to a formatter file that converts <translation_files> to
22
- * `Record<string, string>` so we can compile.
23
- */
24
- format?: string | Formatter;
25
- /**
26
- * Whether to compile to pseudo locale
27
- */
28
- pseudoLocale?: PseudoLocale;
29
- }
30
- /**
31
- * Aggregate `inputFiles` into a single JSON blob and compile.
32
- * Also checks for conflicting IDs.
33
- * Then returns the serialized result as a `string` since key order
34
- * makes a difference in some vendor.
35
- * @param inputFiles Input files
36
- * @param opts Options
37
- * @returns serialized result in string format
38
- */
39
- export declare function compile(inputFiles: string[], opts?: Opts): Promise<string>;
40
- /**
41
- * Aggregate `inputFiles` into a single JSON blob and compile.
42
- * Also checks for conflicting IDs and write output to `outFile`.
43
- * @param inputFiles Input files
44
- * @param compileOpts options
45
- * @returns A `Promise` that resolves if file was written successfully
46
- */
47
- export default function compileAndWrite(inputFiles: string[], compileOpts?: CompileCLIOpts): Promise<void>;
48
- //# sourceMappingURL=compile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../../../../packages/cli/src/compile.ts"],"names":[],"mappings":"AAIA,OAAO,EAA0B,SAAS,EAAC,MAAM,cAAc,CAAA;AAS/D,oBAAY,SAAS,GAAG,CAAC,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE7D,oBAAY,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAA;AAE1E,MAAM,WAAW,cAAe,SAAQ,IAAI;IAC1C;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AACD,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,GAAG,CAAC,EAAE,OAAO,CAAA;IACb;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,IAAS,mBAkElE;AAED;;;;;;GAMG;AACH,wBAA8B,eAAe,CAC3C,UAAU,EAAE,MAAM,EAAE,EACpB,WAAW,GAAE,cAAmB,iBAUjC"}