@formatjs/cli 6.14.2 → 6.14.3

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/bin/formatjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { fileURLToPath as _furl } from "node:url";
3
3
  import { dirname as _dname } from "node:path";
4
4
  _dname(_furl(import.meta.url));
5
- import { _ as __exportAll, a as warn, c as require_json_stable_stringify, d as isPluralElement, f as isSelectElement, g as __commonJSMin, h as parse, i as getStdinAsString, l as TYPE, m as isTagElement, n as interpolateName, o as writeStderr, p as isStructurallySame, r as debug, s as writeStdout, t as parseScript, u as isLiteralElement, v as __require, y as __toESM } from "./parse_script-BKHitY0X.js";
5
+ import { _ as __exportAll, a as warn, c as require_json_stable_stringify, d as isPluralElement, f as isSelectElement, g as __commonJSMin, h as parse, i as getStdinAsString, l as TYPE, m as isTagElement, n as interpolateName, o as writeStderr, p as isStructurallySame, r as debug, s as writeStdout, t as parseScript, u as isLiteralElement, v as __require, y as __toESM } from "./parse_script-BLH7yZ7h.js";
6
6
  import { basename, join, resolve } from "path";
7
7
  import { readFileSync } from "fs";
8
8
  import { readFile } from "fs/promises";
@@ -11444,7 +11444,7 @@ async function processFile(source, fn, { idInterpolationPattern, ...opts }) {
11444
11444
  parseFile(source, fn, opts);
11445
11445
  } else if (fn.endsWith(".gts") || fn.endsWith(".gjs")) {
11446
11446
  debug("Processing %s as gts/gjs file", fn);
11447
- const { parseFile } = await import("./gts_extractor-DGbXbv7G.js");
11447
+ const { parseFile } = await import("./gts_extractor-DbRF6KL4.js");
11448
11448
  parseFile(source, fn, opts);
11449
11449
  } else {
11450
11450
  debug("Processing %s using typescript extractor", fn);
@@ -1,7 +1,7 @@
1
1
  import { fileURLToPath as _furl } from "node:url";
2
2
  import { dirname as _dname } from "node:path";
3
3
  _dname(_furl(import.meta.url));
4
- import { t as parseScript } from "./parse_script-BKHitY0X.js";
4
+ import { t as parseScript } from "./parse_script-BLH7yZ7h.js";
5
5
  import { parseFile as parseFile$1 } from "./hbs_extractor-BBhVhSg0.js";
6
6
  import { Preprocessor } from "content-tag";
7
7
  //#region packages/cli-lib/gts_extractor.ts
@@ -14,4 +14,4 @@ function parseFile(source, fileName, options) {
14
14
  //#endregion
15
15
  export { parseFile };
16
16
 
17
- //# sourceMappingURL=gts_extractor-DGbXbv7G.js.map
17
+ //# sourceMappingURL=gts_extractor-DbRF6KL4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gts_extractor-DGbXbv7G.js","names":[],"sources":["../gts_extractor.ts"],"sourcesContent":["import {Preprocessor} from 'content-tag'\nimport {parseFile as parseHbsFile} from '#packages/cli-lib/hbs_extractor.js'\nimport {parseScript} from '#packages/cli-lib/parse_script.js'\nlet p = new Preprocessor()\n\nexport function parseFile(\n source: string,\n fileName: string,\n options: any\n): void {\n const scriptParseFn = parseScript(options, fileName)\n const transformedSource = p.process(source, {filename: fileName})\n\n scriptParseFn(transformedSource.code)\n\n // extract template from transformed source to then run through hbs processor\n const parseResult = p.parse(source, {filename: fileName})\n\n for (let parsed of parseResult) {\n parseHbsFile(parsed.contents, fileName, options)\n }\n}\n"],"mappings":";;;;;;;AAGA,IAAI,IAAI,IAAI,cAAc;AAE1B,SAAgB,UACd,QACA,UACA,SACM;AACgB,aAAY,SAAS,SAAS,CAC1B,EAAE,QAAQ,QAAQ,EAAC,UAAU,UAAS,CAAC,CAEjC,KAAK;CAGrC,MAAM,cAAc,EAAE,MAAM,QAAQ,EAAC,UAAU,UAAS,CAAC;AAEzD,MAAK,IAAI,UAAU,YACjB,aAAa,OAAO,UAAU,UAAU,QAAQ"}
1
+ {"version":3,"file":"gts_extractor-DbRF6KL4.js","names":[],"sources":["../gts_extractor.ts"],"sourcesContent":["import {Preprocessor} from 'content-tag'\nimport {parseFile as parseHbsFile} from '#packages/cli-lib/hbs_extractor.js'\nimport {parseScript} from '#packages/cli-lib/parse_script.js'\nlet p = new Preprocessor()\n\nexport function parseFile(\n source: string,\n fileName: string,\n options: any\n): void {\n const scriptParseFn = parseScript(options, fileName)\n const transformedSource = p.process(source, {filename: fileName})\n\n scriptParseFn(transformedSource.code)\n\n // extract template from transformed source to then run through hbs processor\n const parseResult = p.parse(source, {filename: fileName})\n\n for (let parsed of parseResult) {\n parseHbsFile(parsed.contents, fileName, options)\n }\n}\n"],"mappings":";;;;;;;AAGA,IAAI,IAAI,IAAI,cAAc;AAE1B,SAAgB,UACd,QACA,UACA,SACM;AACgB,aAAY,SAAS,SAAS,CAC1B,EAAE,QAAQ,QAAQ,EAAC,UAAU,UAAS,CAAC,CAEjC,KAAK;CAGrC,MAAM,cAAc,EAAE,MAAM,QAAQ,EAAC,UAAU,UAAS,CAAC;AAEzD,MAAK,IAAI,UAAU,YACjB,aAAa,OAAO,UAAU,UAAU,QAAQ"}
@@ -151829,8 +151829,13 @@ function evaluateStringConcat(ts, node) {
151829
151829
  }
151830
151830
  function extractMessageDescriptor(ts, node, { overrideIdFn, extractSourceLocation, preserveWhitespace, flatten, throws = true, onMsgError }, sf) {
151831
151831
  let extractionError = null;
151832
- function handleError(errorMsg) {
151833
- const error = new Error(errorMsg);
151832
+ function handleError(errorMsg, errorNode) {
151833
+ let locationMsg = errorMsg;
151834
+ if (errorNode) {
151835
+ const { line, character } = ts.getLineAndCharacterOfPosition(sf, errorNode.getStart(sf));
151836
+ locationMsg = `${sf.fileName}:${line + 1}:${character + 1} ${errorMsg}`;
151837
+ }
151838
+ const error = new Error(locationMsg);
151834
151839
  if (throws) throw error;
151835
151840
  extractionError = error;
151836
151841
  if (onMsgError) onMsgError(sf.fileName, error);
@@ -151870,7 +151875,7 @@ function extractMessageDescriptor(ts, node, { overrideIdFn, extractSourceLocatio
151870
151875
  if (!(name.text === "id" || name.text === "defaultMessage" || name.text === "description")) return;
151871
151876
  const { template } = initializer;
151872
151877
  if (!ts.isNoSubstitutionTemplateLiteral(template)) {
151873
- handleError("[FormatJS] Tagged template expression must be no substitution");
151878
+ handleError("[FormatJS] Tagged template expression must be no substitution", prop);
151874
151879
  return;
151875
151880
  }
151876
151881
  switch (name.text) {
@@ -151914,7 +151919,7 @@ function extractMessageDescriptor(ts, node, { overrideIdFn, extractSourceLocatio
151914
151919
  if (!(name.text === "id" || name.text === "defaultMessage" || name.text === "description")) return;
151915
151920
  const { expression: { template } } = initializer;
151916
151921
  if (!ts.isNoSubstitutionTemplateLiteral(template)) {
151917
- handleError("[FormatJS] Tagged template expression must be no substitution");
151922
+ handleError("[FormatJS] Tagged template expression must be no substitution", prop);
151918
151923
  return;
151919
151924
  }
151920
151925
  switch (name.text) {
@@ -151943,11 +151948,11 @@ function extractMessageDescriptor(ts, node, { overrideIdFn, extractSourceLocatio
151943
151948
  break;
151944
151949
  }
151945
151950
  else if (MESSAGE_DESC_KEYS.includes(name.text) && name.text !== "description") {
151946
- handleError(`[FormatJS] \`${name.text}\` must be a string literal or statically evaluable expression to be extracted.`);
151951
+ handleError(`[FormatJS] \`${name.text}\` must be a string literal or statically evaluable expression to be extracted.`, prop);
151947
151952
  return;
151948
151953
  }
151949
151954
  } else if (MESSAGE_DESC_KEYS.includes(name.text) && name.text !== "description") {
151950
- handleError(`[FormatJS] \`${name.text}\` must be a string literal to be extracted.`);
151955
+ handleError(`[FormatJS] \`${name.text}\` must be a string literal to be extracted.`, prop);
151951
151956
  return;
151952
151957
  }
151953
151958
  } else if (ts.isBinaryExpression(initializer)) {
@@ -151964,12 +151969,12 @@ function extractMessageDescriptor(ts, node, { overrideIdFn, extractSourceLocatio
151964
151969
  break;
151965
151970
  }
151966
151971
  else if (MESSAGE_DESC_KEYS.includes(name.text) && name.text !== "description") {
151967
- handleError(`[FormatJS] \`${name.text}\` must be a string literal or statically evaluable expression to be extracted.`);
151972
+ handleError(`[FormatJS] \`${name.text}\` must be a string literal or statically evaluable expression to be extracted.`, prop);
151968
151973
  return;
151969
151974
  }
151970
151975
  } else if (ts.isObjectLiteralExpression(initializer) && name.text === "description") msg.description = objectLiteralExpressionToObj(ts, initializer);
151971
151976
  else if (MESSAGE_DESC_KEYS.includes(name.text) && name.text !== "description") {
151972
- handleError(`[FormatJS] \`${name.text}\` must be a string literal to be extracted.`);
151977
+ handleError(`[FormatJS] \`${name.text}\` must be a string literal to be extracted.`, prop);
151973
151978
  return;
151974
151979
  }
151975
151980
  }
@@ -152162,4 +152167,4 @@ ${e.message || ""}`;
152162
152167
  //#endregion
152163
152168
  export { __exportAll as _, warn as a, require_json_stable_stringify as c, isPluralElement$2 as d, isSelectElement$2 as f, __commonJSMin as g, parse as h, getStdinAsString as i, TYPE$2 as l, isTagElement$2 as m, interpolateName as n, writeStderr as o, isStructurallySame as p, debug$1 as r, writeStdout as s, parseScript as t, isLiteralElement$1 as u, __require as v, __toESM as y };
152164
152169
 
152165
- //# sourceMappingURL=parse_script-BKHitY0X.js.map
152170
+ //# sourceMappingURL=parse_script-BLH7yZ7h.js.map