@formatjs/cli-lib 8.4.1 → 8.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formatjs/cli-lib",
3
3
  "description": "Lib for CLI for formatjs.",
4
- "version": "8.4.1",
4
+ "version": "8.5.0",
5
5
  "license": "MIT",
6
6
  "author": "Linjie Ding <linjie@airtable.com>",
7
7
  "type": "module",
@@ -22,9 +22,9 @@
22
22
  "json-stable-stringify": "^1.3.0",
23
23
  "loud-rejection": "^2",
24
24
  "typescript": "^5.6.0",
25
- "@formatjs/icu-skeleton-parser": "2.1.3",
25
+ "@formatjs/icu-messageformat-parser": "3.5.3",
26
26
  "@formatjs/ts-transformer": "4.4.2",
27
- "@formatjs/icu-messageformat-parser": "3.5.3"
27
+ "@formatjs/icu-skeleton-parser": "2.1.3"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "@glimmer/syntax": "^0.84.3 || ^0.95.0",
package/src/cli.js CHANGED
@@ -52,12 +52,15 @@ works. This option does not do that so it's less safe.`, (val) => val.split(",")
52
52
  "I have {count, plural, one{a dog} other{many dogs}}"
53
53
  becomes "{count, plural, one{I have a dog} other{I have many dogs}}".
54
54
  The goal is to provide as many full sentences as possible since fragmented
55
- sentences are not translator-friendly.`).action(async (filePatterns, cmdObj) => {
55
+ sentences are not translator-friendly.`).option("--follow-links", `Whether to follow symbolic links when traversing directories. Defaults to true for compatibility with pnpm symlinked node_modules. Use --no-follow-links to disable.`, true).action(async (filePatterns, cmdObj) => {
56
56
  debug("File pattern:", filePatterns);
57
57
  debug("Options:", cmdObj);
58
58
  const files = [];
59
59
  if (filePatterns.length) {
60
- files.push(...globSync(filePatterns, { ignore: cmdObj.ignore }));
60
+ files.push(...globSync(filePatterns, {
61
+ ignore: cmdObj.ignore,
62
+ followSymbolicLinks: cmdObj.followLinks ?? true
63
+ }));
61
64
  }
62
65
  if (cmdObj.inFile) {
63
66
  debug("Reading inFile:", cmdObj.inFile);
@@ -88,10 +91,10 @@ type CompileFn = <T = Record<string, MessageDescriptor>>(
88
91
  ) => Record<string, string>;
89
92
  \`\`\`
90
93
  This is especially useful to convert from a TMS-specific format back to react-intl format
91
- `).option("--out-file <path>", `Compiled translation output file. If this is not provided, result will be printed to stdout`).option("--ast", `Whether to compile to AST. See https://formatjs.github.io/docs/guides/advanced-usage#pre-parsing-messages for more information`).option("--skip-errors", `Whether to continue compiling messages after encountering an error. Any keys with errors will not be included in the output file.`).option("--pseudo-locale <pseudoLocale>", `Whether to generate pseudo-locale files. See https://formatjs.github.io/docs/tooling/cli#--pseudo-locale-pseudolocale for possible values. "--ast" is required for this to work.`).option("--ignore-tag", `Whether the parser to treat HTML/XML tags as string literal instead of parsing them as tag token. When this is false we only allow simple tags without any attributes.`).action(async (filePatterns, opts) => {
94
+ `).option("--out-file <path>", `Compiled translation output file. If this is not provided, result will be printed to stdout`).option("--ast", `Whether to compile to AST. See https://formatjs.github.io/docs/guides/advanced-usage#pre-parsing-messages for more information`).option("--skip-errors", `Whether to continue compiling messages after encountering an error. Any keys with errors will not be included in the output file.`).option("--pseudo-locale <pseudoLocale>", `Whether to generate pseudo-locale files. See https://formatjs.github.io/docs/tooling/cli#--pseudo-locale-pseudolocale for possible values. "--ast" is required for this to work.`).option("--ignore-tag", `Whether the parser to treat HTML/XML tags as string literal instead of parsing them as tag token. When this is false we only allow simple tags without any attributes.`).option("--follow-links", `Whether to follow symbolic links when traversing directories. Defaults to true for compatibility with pnpm symlinked node_modules. Use --no-follow-links to disable.`, true).action(async (filePatterns, opts) => {
92
95
  debug("File pattern:", filePatterns);
93
96
  debug("Options:", opts);
94
- const files = globSync(filePatterns);
97
+ const files = globSync(filePatterns, { followSymbolicLinks: opts.followLinks ?? true });
95
98
  if (!files.length) {
96
99
  throw new Error(`No input file found with pattern ${filePatterns}`);
97
100
  }
@@ -119,11 +122,14 @@ This is especially useful to convert from a TMS-specific format back to react-in
119
122
  program.command("verify [translation_files...]").description(`Run a series of checks on a list of translation files. <translation_files> can be a glob like "foo/**/en.json"`).option("--source-locale <sourceLocale>", `The source locale of the translation files.
120
123
  There must be a file named <sourceLocale>.json in the list of translation files.
121
124
  This is used as source to verify other translations against.`).option("--ignore <files...>", "List of glob paths to ignore").option("--missing-keys", `Whether to check for missing keys in target locale compared to source locale.
122
- This basically guarantees that no messages are untranslated.`).option("--extra-keys", `Whether to check that target locales don't have extra keys not present in the source locale.`).option("--structural-equality", `Whether to check for structural equality of messages between source and target locale.
123
- This makes sure translations are formattable and are not missing any tokens.`).action(async (filePatterns, opts) => {
125
+ This basically guarantees that no messages are untranslated.`).option("--extra-keys", `Whether to check that target locales don't have extra keys not present in the source locale.`).option("--structural-equality", `Whether to check for structural equality of messages between source and target locale.
126
+ This makes sure translations are formattable and are not missing any tokens.`).option("--follow-links", `Whether to follow symbolic links when traversing directories. Defaults to true for compatibility with pnpm symlinked node_modules. Use --no-follow-links to disable.`, true).action(async (filePatterns, opts) => {
124
127
  debug("File pattern:", filePatterns);
125
128
  debug("Options:", opts);
126
- const files = globSync(filePatterns, { ignore: opts.ignore });
129
+ const files = globSync(filePatterns, {
130
+ ignore: opts.ignore,
131
+ followSymbolicLinks: opts.followLinks ?? true
132
+ });
127
133
  if (!files.length) {
128
134
  throw new Error(`No input file found with pattern ${filePatterns}`);
129
135
  }
package/src/compile.d.ts CHANGED
@@ -6,6 +6,11 @@ export interface CompileCLIOpts extends Opts {
6
6
  * The target file that contains compiled messages.
7
7
  */
8
8
  outFile?: string;
9
+ /**
10
+ * Whether to follow symbolic links when traversing directories.
11
+ * Defaults to true for compatibility with pnpm symlinked node_modules.
12
+ */
13
+ followLinks?: boolean;
9
14
  }
10
15
  export interface Opts {
11
16
  /**
package/src/extract.d.ts CHANGED
@@ -37,6 +37,11 @@ export type ExtractCLIOptions = Omit<ExtractOpts, "overrideIdFn" | "onMsgExtract
37
37
  * Ignore file glob pattern
38
38
  */
39
39
  ignore?: string[];
40
+ /**
41
+ * Whether to follow symbolic links when traversing directories.
42
+ * Defaults to true for compatibility with pnpm symlinked node_modules.
43
+ */
44
+ followLinks?: boolean;
40
45
  };
41
46
  export type ExtractOpts = Opts & {
42
47
  /**
@@ -4,5 +4,10 @@ export interface VerifyOpts {
4
4
  extraKeys: boolean;
5
5
  structuralEquality: boolean;
6
6
  ignore?: string[];
7
+ /**
8
+ * Whether to follow symbolic links when traversing directories.
9
+ * Defaults to true for compatibility with pnpm symlinked node_modules.
10
+ */
11
+ followLinks?: boolean;
7
12
  }
8
13
  export declare function verify(files: string[], { sourceLocale, missingKeys, extraKeys, structuralEquality }: VerifyOpts): Promise<void>;