@formatjs/cli 4.6.1 → 4.8.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/package.json +3 -3
- package/src/cli.d.ts.map +1 -1
- package/src/cli.js +13 -17
- package/src/formatters/crowdin.d.ts.map +1 -1
- package/src/formatters/crowdin.js +3 -1
- package/src/formatters/lokalise.d.ts.map +1 -1
- package/src/formatters/lokalise.js +3 -1
- package/src/formatters/smartling.d.ts.map +1 -1
- package/src/formatters/smartling.js +3 -1
- package/src/formatters/transifex.d.ts.map +1 -1
- package/src/formatters/transifex.js +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.1",
|
|
4
4
|
"description": "A CLI for formatjs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"url": "git+ssh://git@github.com/formatjs/formatjs.git"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@formatjs/icu-messageformat-parser": "2.0.
|
|
35
|
-
"@formatjs/ts-transformer": "3.
|
|
34
|
+
"@formatjs/icu-messageformat-parser": "2.0.17",
|
|
35
|
+
"@formatjs/ts-transformer": "3.9.1",
|
|
36
36
|
"@types/estree": "^0.0.50",
|
|
37
37
|
"@types/fs-extra": "^9.0.1",
|
|
38
38
|
"@types/json-stable-stringify": "^1.0.32",
|
package/src/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../../../../packages/cli/src/cli.ts"],"names":[],"mappings":"AAUA,iBAAe,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../../../../packages/cli/src/cli.ts"],"names":[],"mappings":"AAUA,iBAAe,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,iBAqOjC;AACD,eAAe,IAAI,CAAA"}
|
package/src/cli.js
CHANGED
|
@@ -45,22 +45,18 @@ function main(argv) {
|
|
|
45
45
|
.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.")
|
|
46
46
|
.option('--preserve-whitespace', 'Whether to preserve whitespace and newlines.')
|
|
47
47
|
.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.")
|
|
48
|
-
.action(function (
|
|
49
|
-
var
|
|
48
|
+
.action(function (filePatterns, cmdObj) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
|
|
49
|
+
var files;
|
|
50
50
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
51
51
|
switch (_a.label) {
|
|
52
52
|
case 0:
|
|
53
|
-
(0, console_utils_1.debug)('File pattern:',
|
|
53
|
+
(0, console_utils_1.debug)('File pattern:', filePatterns);
|
|
54
54
|
(0, console_utils_1.debug)('Options:', cmdObj);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
processedFiles.push.apply(processedFiles, (0, fast_glob_1.sync)(f, {
|
|
59
|
-
ignore: cmdObj.ignore,
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
55
|
+
files = (0, fast_glob_1.sync)(filePatterns, {
|
|
56
|
+
ignore: cmdObj.ignore,
|
|
57
|
+
});
|
|
62
58
|
(0, console_utils_1.debug)('Files to extract:', files);
|
|
63
|
-
return [4 /*yield*/, (0, extract_1.default)(
|
|
59
|
+
return [4 /*yield*/, (0, extract_1.default)(files, {
|
|
64
60
|
outFile: cmdObj.outFile,
|
|
65
61
|
idInterpolationPattern: cmdObj.idInterpolationPattern || '[sha1:contenthash:base64:6]',
|
|
66
62
|
extractSourceLocation: cmdObj.extractSourceLocation,
|
|
@@ -72,7 +68,7 @@ function main(argv) {
|
|
|
72
68
|
format: cmdObj.format,
|
|
73
69
|
// It is possible that the glob pattern does NOT match anything.
|
|
74
70
|
// But so long as the glob pattern is provided, don't read from stdin.
|
|
75
|
-
readFromStdin:
|
|
71
|
+
readFromStdin: filePatterns.length === 0,
|
|
76
72
|
preserveWhitespace: cmdObj.preserveWhitespace,
|
|
77
73
|
flatten: cmdObj.flatten,
|
|
78
74
|
})];
|
|
@@ -84,23 +80,23 @@ function main(argv) {
|
|
|
84
80
|
});
|
|
85
81
|
}); });
|
|
86
82
|
commander_1.program
|
|
87
|
-
.command('compile
|
|
83
|
+
.command('compile [translation_files...]')
|
|
88
84
|
.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\"")
|
|
89
85
|
.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")
|
|
90
86
|
.option('--out-file <path>', "Compiled translation output file.\nIf this is not provided, result will be printed to stdout")
|
|
91
87
|
.option('--ast', "Whether to compile to AST. See https://formatjs.io/docs/guides/advanced-usage#pre-parsing-messages\nfor more information")
|
|
92
88
|
.option('--skip-errors', "Whether to continue compiling messages after encountering an error. Any keys with errors will not be included in the output file.")
|
|
93
89
|
.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.")
|
|
94
|
-
.action(function (
|
|
90
|
+
.action(function (filePatterns, opts) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () {
|
|
95
91
|
var files;
|
|
96
92
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
97
93
|
switch (_a.label) {
|
|
98
94
|
case 0:
|
|
99
|
-
(0, console_utils_1.debug)('File pattern:',
|
|
95
|
+
(0, console_utils_1.debug)('File pattern:', filePatterns);
|
|
100
96
|
(0, console_utils_1.debug)('Options:', opts);
|
|
101
|
-
files = (0, fast_glob_1.sync)(
|
|
97
|
+
files = (0, fast_glob_1.sync)(filePatterns);
|
|
102
98
|
if (!files.length) {
|
|
103
|
-
throw new Error("No input file found with pattern ".concat(
|
|
99
|
+
throw new Error("No input file found with pattern ".concat(filePatterns));
|
|
104
100
|
}
|
|
105
101
|
(0, console_utils_1.debug)('Files to compile:', files);
|
|
106
102
|
return [4 /*yield*/, (0, compile_1.default)(files, opts)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crowdin.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli/src/formatters/crowdin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,oBAAY,aAAa,GAAG,MAAM,CAChC,MAAM,EACN;IACE,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"crowdin.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli/src/formatters/crowdin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,oBAAY,aAAa,GAAG,MAAM,CAChC,MAAM,EACN;IACE,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,aAAa,CAY1C,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAS5C,CAAA"}
|
|
@@ -7,7 +7,9 @@ var format = function (msgs) {
|
|
|
7
7
|
var _b = _a[_i], id = _b[0], msg = _b[1];
|
|
8
8
|
results[id] = {
|
|
9
9
|
message: msg.defaultMessage,
|
|
10
|
-
description: msg.description
|
|
10
|
+
description: typeof msg.description === 'string'
|
|
11
|
+
? msg.description
|
|
12
|
+
: JSON.stringify(msg.description),
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
15
|
return results;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lokalise.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli/src/formatters/lokalise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,oBAAY,cAAc,GAAG,MAAM,CACjC,MAAM,EACN;IACE,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"lokalise.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli/src/formatters/lokalise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,oBAAY,cAAc,GAAG,MAAM,CACjC,MAAM,EACN;IACE,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,cAAc,CAY3C,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,cAAc,CAM7C,CAAA"}
|
|
@@ -7,7 +7,9 @@ var format = function (msgs) {
|
|
|
7
7
|
var _b = _a[_i], id = _b[0], msg = _b[1];
|
|
8
8
|
results[id] = {
|
|
9
9
|
translation: msg.defaultMessage,
|
|
10
|
-
notes: msg.description
|
|
10
|
+
notes: typeof msg.description === 'string'
|
|
11
|
+
? msg.description
|
|
12
|
+
: JSON.stringify(msg.description),
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
15
|
return results;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartling.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli/src/formatters/smartling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE;QACf;YACE,IAAI,EAAE,MAAM,CAAA;YACZ,GAAG,EAAE,MAAM,CAAA;YACX,WAAW,EAAE,MAAM,CAAA;SACpB;KACF,CAAA;IACD,gBAAgB,EAAE,OAAO,CAAA;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED,oBAAY,aAAa,GAAG;IAC1B,SAAS,EAAE,mBAAmB,CAAA;CAC/B,GAAG,MAAM,CACR,MAAM,EACN;IACE,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"smartling.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli/src/formatters/smartling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE;QACf;YACE,IAAI,EAAE,MAAM,CAAA;YACZ,GAAG,EAAE,MAAM,CAAA;YACX,WAAW,EAAE,MAAM,CAAA;SACpB;KACF,CAAA;IACD,gBAAgB,EAAE,OAAO,CAAA;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED,oBAAY,aAAa,GAAG;IAC1B,SAAS,EAAE,mBAAmB,CAAA;CAC/B,GAAG,MAAM,CACR,MAAM,EACN;IACE,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,aAAa,CAwB1C,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,UAS7B,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAS5C,CAAA"}
|
|
@@ -19,7 +19,9 @@ var format = function (msgs) {
|
|
|
19
19
|
var _b = _a[_i], id = _b[0], msg = _b[1];
|
|
20
20
|
results[id] = {
|
|
21
21
|
message: msg.defaultMessage,
|
|
22
|
-
description: msg.description
|
|
22
|
+
description: typeof msg.description === 'string'
|
|
23
|
+
? msg.description
|
|
24
|
+
: JSON.stringify(msg.description),
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
return results;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transifex.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli/src/formatters/transifex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,oBAAY,cAAc,GAAG,MAAM,CACjC,MAAM,EACN;IACE,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"transifex.d.ts","sourceRoot":"","sources":["../../../../../../../packages/cli/src/formatters/transifex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAE7C,oBAAY,cAAc,GAAG,MAAM,CACjC,MAAM,EACN;IACE,MAAM,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB,CACF,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,cAAc,CAY3C,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,cAAc,CAM7C,CAAA"}
|
|
@@ -7,7 +7,9 @@ var format = function (msgs) {
|
|
|
7
7
|
var _b = _a[_i], id = _b[0], msg = _b[1];
|
|
8
8
|
results[id] = {
|
|
9
9
|
string: msg.defaultMessage,
|
|
10
|
-
developer_comment: msg.description
|
|
10
|
+
developer_comment: typeof msg.description === 'string'
|
|
11
|
+
? msg.description
|
|
12
|
+
: JSON.stringify(msg.description),
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
15
|
return results;
|