@lingui/cli 4.0.0-next.5 → 4.0.0-next.6
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/dist/api/catalog/extractFromFiles.d.ts +5 -0
- package/dist/api/catalog/extractFromFiles.js +27 -44
- package/dist/api/catalog/getCatalogs.d.ts +14 -0
- package/dist/api/catalog/getCatalogs.js +70 -78
- package/dist/api/catalog/getTranslationsForCatalog.d.ts +14 -0
- package/dist/api/catalog/getTranslationsForCatalog.js +36 -32
- package/dist/api/catalog/mergeCatalog.d.ts +3 -0
- package/dist/api/catalog/mergeCatalog.js +43 -74
- package/dist/api/catalog.d.ts +66 -0
- package/dist/api/catalog.js +144 -169
- package/dist/api/compile.d.ts +19 -0
- package/dist/api/compile.js +60 -87
- package/dist/api/extractors/babel.d.ts +3 -0
- package/dist/api/extractors/babel.js +43 -100
- package/dist/api/extractors/index.d.ts +6 -0
- package/dist/api/extractors/index.js +17 -23
- package/dist/api/extractors/typescript.d.ts +3 -0
- package/dist/api/extractors/typescript.js +7 -11
- package/dist/api/formats/formatterWrapper.d.ts +10 -0
- package/dist/api/formats/formatterWrapper.js +14 -19
- package/dist/api/formats/index.d.ts +5 -0
- package/dist/api/formats/index.js +15 -63
- package/dist/api/help.d.ts +1 -0
- package/dist/api/help.js +12 -13
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.js +24 -30
- package/dist/api/pseudoLocalize.d.ts +1 -0
- package/dist/api/pseudoLocalize.js +23 -27
- package/dist/api/rethrownError.d.ts +4 -0
- package/dist/api/rethrownError.js +4 -9
- package/dist/api/stats.d.ts +6 -0
- package/dist/api/stats.js +23 -55
- package/dist/api/types.d.ts +5 -0
- package/dist/api/types.js +1 -3
- package/dist/api/utils.d.ts +22 -0
- package/dist/api/utils.js +61 -59
- package/dist/extract-experimental/buildExternalizeFilter.d.ts +13 -0
- package/dist/extract-experimental/buildExternalizeFilter.js +19 -64
- package/dist/extract-experimental/bundleSource.d.ts +2 -0
- package/dist/extract-experimental/bundleSource.js +25 -74
- package/dist/extract-experimental/constants.d.ts +2 -0
- package/dist/extract-experimental/constants.js +4 -15
- package/dist/extract-experimental/getEntryPoints.d.ts +1 -0
- package/dist/extract-experimental/getEntryPoints.js +8 -16
- package/dist/extract-experimental/getExperimentalCatalogs.d.ts +3 -0
- package/dist/extract-experimental/getExperimentalCatalogs.js +15 -19
- package/dist/extract-experimental/resolveCatalogPath.d.ts +2 -0
- package/dist/extract-experimental/resolveCatalogPath.js +13 -24
- package/dist/extract-experimental/resolveTemplatePath.d.ts +1 -0
- package/dist/extract-experimental/resolveTemplatePath.js +11 -14
- package/dist/extract-experimental/writeCatalogs.d.ts +21 -0
- package/dist/extract-experimental/writeCatalogs.js +23 -36
- package/dist/lingui-compile.d.ts +9 -0
- package/dist/lingui-compile.js +94 -82
- package/dist/lingui-extract-experimental.d.ts +10 -0
- package/dist/lingui-extract-experimental.js +58 -67
- package/dist/lingui-extract-template.d.ts +6 -0
- package/dist/lingui-extract-template.js +29 -35
- package/dist/lingui-extract.d.ts +11 -0
- package/dist/lingui-extract.js +81 -117
- package/dist/lingui.d.ts +2 -0
- package/dist/lingui.js +11 -6
- package/dist/services/translationIO.d.ts +3 -0
- package/dist/services/translationIO.js +92 -89
- package/package.json +23 -14
- package/dist/tests.js +0 -137
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/cli",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.6",
|
|
4
4
|
"description": "CLI for working wit message catalogs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -27,17 +27,26 @@
|
|
|
27
27
|
"require": "./dist/lingui.js"
|
|
28
28
|
},
|
|
29
29
|
"./api": {
|
|
30
|
-
"require":
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./dist/api/index.d.ts",
|
|
32
|
+
"default": "./dist/api/index.js"
|
|
33
|
+
}
|
|
31
34
|
},
|
|
32
35
|
"./api/extractors/babel": {
|
|
33
|
-
"require":
|
|
36
|
+
"require": {
|
|
37
|
+
"types": "./dist/api/extractors/babel.d.ts",
|
|
38
|
+
"default": "./dist/api/extractors/babel.js"
|
|
39
|
+
}
|
|
34
40
|
},
|
|
35
41
|
"./api/extractors/typescript": {
|
|
36
|
-
"require":
|
|
42
|
+
"require": {
|
|
43
|
+
"types": "./dist/api/extractors/typescript.d.ts",
|
|
44
|
+
"default": "./dist/api/extractors/typescript.js"
|
|
45
|
+
}
|
|
37
46
|
}
|
|
38
47
|
},
|
|
39
48
|
"scripts": {
|
|
40
|
-
"build": "rimraf ./dist &&
|
|
49
|
+
"build": "rimraf ./dist && tsc -p tsconfig.build.json"
|
|
41
50
|
},
|
|
42
51
|
"engines": {
|
|
43
52
|
"node": ">=16.0.0"
|
|
@@ -53,11 +62,11 @@
|
|
|
53
62
|
"@babel/parser": "^7.21.2",
|
|
54
63
|
"@babel/runtime": "^7.21.0",
|
|
55
64
|
"@babel/types": "^7.21.2",
|
|
56
|
-
"@lingui/babel-plugin-extract-messages": "^4.0.0-next.
|
|
57
|
-
"@lingui/conf": "^4.0.0-next.
|
|
58
|
-
"@lingui/core": "^4.0.0-next.
|
|
59
|
-
"@lingui/format-po": "^4.0.0-next.
|
|
60
|
-
"@lingui/message-utils": "^4.0.0-next.
|
|
65
|
+
"@lingui/babel-plugin-extract-messages": "^4.0.0-next.6",
|
|
66
|
+
"@lingui/conf": "^4.0.0-next.6",
|
|
67
|
+
"@lingui/core": "^4.0.0-next.6",
|
|
68
|
+
"@lingui/format-po": "^4.0.0-next.6",
|
|
69
|
+
"@lingui/message-utils": "^4.0.0-next.6",
|
|
61
70
|
"babel-plugin-macros": "^3.0.1",
|
|
62
71
|
"chalk": "^4.1.0",
|
|
63
72
|
"chokidar": "3.5.1",
|
|
@@ -73,19 +82,19 @@
|
|
|
73
82
|
"ora": "^5.1.0",
|
|
74
83
|
"pkg-up": "^3.1.0",
|
|
75
84
|
"pofile": "^1.1.4",
|
|
76
|
-
"pseudolocale": "^
|
|
85
|
+
"pseudolocale": "^2.0.0",
|
|
77
86
|
"ramda": "^0.27.1",
|
|
78
87
|
"source-map": "^0.8.0-beta.0"
|
|
79
88
|
},
|
|
80
89
|
"devDependencies": {
|
|
81
90
|
"@lingui/jest-mocks": "^3.0.3",
|
|
82
|
-
"@
|
|
83
|
-
"@swc/core": "^1.3.42",
|
|
91
|
+
"@lingui/macro": "^4.0.0-next.6",
|
|
84
92
|
"@types/convert-source-map": "^2.0.0",
|
|
93
|
+
"@types/glob": "^8.1.0",
|
|
85
94
|
"@types/micromatch": "^4.0.1",
|
|
86
95
|
"@types/normalize-path": "^3.0.0",
|
|
87
96
|
"mock-fs": "^5.2.0",
|
|
88
97
|
"mockdate": "^3.0.5"
|
|
89
98
|
},
|
|
90
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "d4d9e149b2419d1796e14176d53703a7cff4b82c"
|
|
91
100
|
}
|
package/dist/tests.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
copyFixture: ()=>copyFixture,
|
|
13
|
-
defaultMakeOptions: ()=>defaultMakeOptions,
|
|
14
|
-
defaultMakeTemplateOptions: ()=>defaultMakeTemplateOptions,
|
|
15
|
-
defaultMergeOptions: ()=>defaultMergeOptions,
|
|
16
|
-
normalizeLineEndings: ()=>normalizeLineEndings,
|
|
17
|
-
makeCatalog: ()=>makeCatalog,
|
|
18
|
-
makePrevMessage: ()=>makePrevMessage,
|
|
19
|
-
makeNextMessage: ()=>makeNextMessage,
|
|
20
|
-
listingToHumanReadable: ()=>listingToHumanReadable,
|
|
21
|
-
createFixtures: ()=>createFixtures,
|
|
22
|
-
readFsToJson: ()=>readFsToJson
|
|
23
|
-
});
|
|
24
|
-
const _os = /*#__PURE__*/ _interopRequireDefault(require("os"));
|
|
25
|
-
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
26
|
-
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
27
|
-
const _catalog = require("./api/catalog");
|
|
28
|
-
const _conf = require("@lingui/conf");
|
|
29
|
-
const _api = require("./api");
|
|
30
|
-
function _interopRequireDefault(obj) {
|
|
31
|
-
return obj && obj.__esModule ? obj : {
|
|
32
|
-
default: obj
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
async function copyFixture(fixtureDir) {
|
|
36
|
-
const tmpDir = await _fs.default.promises.mkdtemp(_path.default.join(_os.default.tmpdir(), `lingui-test-${process.pid}`));
|
|
37
|
-
try {
|
|
38
|
-
await _fs.default.promises.cp(fixtureDir, tmpDir, {
|
|
39
|
-
recursive: true
|
|
40
|
-
});
|
|
41
|
-
} catch (err) {
|
|
42
|
-
if (err.code != "ENOENT") {
|
|
43
|
-
throw err;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return tmpDir;
|
|
47
|
-
}
|
|
48
|
-
const defaultMakeOptions = {
|
|
49
|
-
verbose: false,
|
|
50
|
-
clean: false,
|
|
51
|
-
overwrite: false,
|
|
52
|
-
locale: null,
|
|
53
|
-
prevFormat: null,
|
|
54
|
-
orderBy: "messageId"
|
|
55
|
-
};
|
|
56
|
-
const defaultMakeTemplateOptions = {
|
|
57
|
-
verbose: false,
|
|
58
|
-
orderBy: "messageId"
|
|
59
|
-
};
|
|
60
|
-
const defaultMergeOptions = {
|
|
61
|
-
overwrite: false
|
|
62
|
-
};
|
|
63
|
-
const normalizeLineEndings = (str)=>str.replace(/\r?\n/g, "\r\n");
|
|
64
|
-
const makeCatalog = async (_config = {})=>{
|
|
65
|
-
const config = (0, _conf.makeConfig)(_config, {
|
|
66
|
-
skipValidation: true
|
|
67
|
-
});
|
|
68
|
-
return new _catalog.Catalog({
|
|
69
|
-
name: "messages",
|
|
70
|
-
path: "{locale}/messages",
|
|
71
|
-
include: [],
|
|
72
|
-
exclude: [],
|
|
73
|
-
format: await (0, _api.getFormat)(config.format, config.formatOptions, config.sourceLocale)
|
|
74
|
-
}, config);
|
|
75
|
-
};
|
|
76
|
-
function makePrevMessage(message = {}) {
|
|
77
|
-
return {
|
|
78
|
-
translation: "",
|
|
79
|
-
...makeNextMessage(message)
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
function makeNextMessage(message = {}) {
|
|
83
|
-
return {
|
|
84
|
-
origin: [
|
|
85
|
-
[
|
|
86
|
-
"catalog.test.ts",
|
|
87
|
-
1
|
|
88
|
-
]
|
|
89
|
-
],
|
|
90
|
-
obsolete: false,
|
|
91
|
-
...message
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function listingToHumanReadable(listing) {
|
|
95
|
-
const output = [];
|
|
96
|
-
Object.entries(listing).forEach(([filename, value])=>{
|
|
97
|
-
if (typeof value === "string") {
|
|
98
|
-
output.push("#######################");
|
|
99
|
-
output.push(`Filename: ${filename}`);
|
|
100
|
-
output.push("#######################");
|
|
101
|
-
output.push("");
|
|
102
|
-
output.push(normalizeLineEndings(value));
|
|
103
|
-
output.push("");
|
|
104
|
-
} else {
|
|
105
|
-
output.push(...listingToHumanReadable(value));
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
return output.join("\n");
|
|
109
|
-
}
|
|
110
|
-
async function createFixtures(listing) {
|
|
111
|
-
const tmpDir = await _fs.default.promises.mkdtemp(_path.default.join(_os.default.tmpdir(), `lingui-test-${process.pid}`));
|
|
112
|
-
async function create(listing) {
|
|
113
|
-
for (const [filename, value] of Object.entries(listing)){
|
|
114
|
-
if (typeof value === "string") {
|
|
115
|
-
await _fs.default.promises.writeFile(_path.default.join(tmpDir, filename), value);
|
|
116
|
-
} else {
|
|
117
|
-
await create(value);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
await create(listing);
|
|
122
|
-
return tmpDir;
|
|
123
|
-
}
|
|
124
|
-
function readFsToJson(directory, filter) {
|
|
125
|
-
const out = {};
|
|
126
|
-
_fs.default.readdirSync(directory).map((filename)=>{
|
|
127
|
-
const filepath = _path.default.join(directory, filename);
|
|
128
|
-
if (_fs.default.lstatSync(filepath).isDirectory()) {
|
|
129
|
-
out[filename] = readFsToJson(filepath);
|
|
130
|
-
return out;
|
|
131
|
-
}
|
|
132
|
-
if (!filter || filter(filename)) {
|
|
133
|
-
out[filename] = _fs.default.readFileSync(filepath).toString();
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
return out;
|
|
137
|
-
}
|