@lingui/cli 4.0.0-next.3 → 4.0.0-next.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.
- package/dist/api/catalog/extractFromFiles.js +64 -0
- package/dist/api/catalog/getCatalogs.js +137 -0
- package/dist/api/catalog/getTranslationsForCatalog.js +68 -0
- package/dist/api/catalog/mergeCatalog.js +86 -0
- package/dist/api/catalog.js +286 -0
- package/dist/api/compile.js +115 -0
- package/dist/api/extractors/babel.js +158 -0
- package/dist/api/extractors/index.js +44 -0
- package/dist/api/extractors/typescript.js +15 -0
- package/dist/api/formats/formatterWrapper.js +48 -0
- package/dist/api/formats/index.js +95 -0
- package/dist/api/help.js +41 -0
- package/dist/api/index.js +31 -0
- package/dist/api/pseudoLocalize.js +60 -0
- package/dist/api/rethrownError.js +16 -0
- package/dist/api/stats.js +73 -0
- package/{build → dist}/api/types.js +2 -3
- package/dist/api/utils.js +117 -0
- package/dist/extract-experimental/buildExternalizeFilter.js +83 -0
- package/dist/extract-experimental/bundleSource.js +127 -0
- package/dist/extract-experimental/constants.js +16 -0
- package/dist/extract-experimental/getEntryPoints.js +20 -0
- package/dist/extract-experimental/getExperimentalCatalogs.js +30 -0
- package/dist/extract-experimental/resolveCatalogPath.js +34 -0
- package/dist/extract-experimental/resolveTemplatePath.js +19 -0
- package/dist/extract-experimental/writeCatalogs.js +54 -0
- package/dist/lingui-compile.js +158 -0
- package/dist/lingui-extract-experimental.js +113 -0
- package/dist/lingui-extract-template.js +52 -0
- package/dist/lingui-extract.js +192 -0
- package/dist/lingui.js +8 -0
- package/dist/services/translationIO.js +261 -0
- package/dist/tests.js +137 -0
- package/package.json +21 -14
- package/build/LICENSE +0 -21
- package/build/api/catalog/extractFromFiles.js +0 -45
- package/build/api/catalog/getCatalogs.js +0 -138
- package/build/api/catalog/getTranslationsForCatalog.js +0 -77
- package/build/api/catalog/mergeCatalog.js +0 -44
- package/build/api/catalog.js +0 -245
- package/build/api/compile.js +0 -72
- package/build/api/extractors/babel.js +0 -92
- package/build/api/extractors/index.js +0 -36
- package/build/api/extractors/typescript.js +0 -14
- package/build/api/formats/formatterWrapper.js +0 -45
- package/build/api/formats/index.js +0 -57
- package/build/api/generateMessageId.js +0 -12
- package/build/api/help.js +0 -42
- package/build/api/index.js +0 -58
- package/build/api/pseudoLocalize.js +0 -60
- package/build/api/rethrownError.js +0 -14
- package/build/api/stats.js +0 -40
- package/build/api/utils.js +0 -117
- package/build/extract-experimental/buildExternalizeFilter.js +0 -39
- package/build/extract-experimental/bundleSource.js +0 -69
- package/build/extract-experimental/constants.js +0 -10
- package/build/extract-experimental/getEntryPoints.js +0 -14
- package/build/extract-experimental/getExperimentalCatalogs.js +0 -28
- package/build/extract-experimental/resolveCatalogPath.js +0 -23
- package/build/extract-experimental/resolveTemplatePath.js +0 -17
- package/build/extract-experimental/writeCatalogs.js +0 -59
- package/build/lingui-compile.js +0 -156
- package/build/lingui-extract-experimental.js +0 -103
- package/build/lingui-extract-template.js +0 -46
- package/build/lingui-extract.js +0 -143
- package/build/lingui.js +0 -6
- package/build/services/translationIO.js +0 -266
- package/build/tests.js +0 -133
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
getStats: ()=>getStats,
|
|
13
|
+
printStats: ()=>printStats
|
|
14
|
+
});
|
|
15
|
+
const _cliTable = /*#__PURE__*/ _interopRequireDefault(require("cli-table"));
|
|
16
|
+
const _chalk = /*#__PURE__*/ _interopRequireDefault(require("chalk"));
|
|
17
|
+
function _interopRequireDefault(obj) {
|
|
18
|
+
return obj && obj.__esModule ? obj : {
|
|
19
|
+
default: obj
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function getStats(catalog) {
|
|
23
|
+
return [
|
|
24
|
+
Object.keys(catalog).length,
|
|
25
|
+
Object.keys(catalog).filter((key)=>!catalog[key].translation).length
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
function printStats(config, catalogs) {
|
|
29
|
+
const table = new _cliTable.default({
|
|
30
|
+
head: [
|
|
31
|
+
"Language",
|
|
32
|
+
"Total count",
|
|
33
|
+
"Missing"
|
|
34
|
+
],
|
|
35
|
+
colAligns: [
|
|
36
|
+
"left",
|
|
37
|
+
"middle",
|
|
38
|
+
"middle"
|
|
39
|
+
],
|
|
40
|
+
style: {
|
|
41
|
+
head: [
|
|
42
|
+
"green"
|
|
43
|
+
],
|
|
44
|
+
border: [],
|
|
45
|
+
compact: true
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.keys(catalogs).forEach((locale)=>{
|
|
49
|
+
const catalog = catalogs[locale];
|
|
50
|
+
// catalog is null if no catalog exists on disk and the locale
|
|
51
|
+
// was not extracted due to a `--locale` filter
|
|
52
|
+
const [all, translated] = catalog ? getStats(catalog) : [
|
|
53
|
+
"-",
|
|
54
|
+
"-"
|
|
55
|
+
];
|
|
56
|
+
if (config.sourceLocale === locale) {
|
|
57
|
+
table.push({
|
|
58
|
+
[`${_chalk.default.bold(locale)} (source)`]: [
|
|
59
|
+
all,
|
|
60
|
+
"-"
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
table.push({
|
|
65
|
+
[locale]: [
|
|
66
|
+
all,
|
|
67
|
+
translated
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return table;
|
|
73
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
PATHSEP: ()=>PATHSEP,
|
|
13
|
+
prettyOrigin: ()=>prettyOrigin,
|
|
14
|
+
replacePlaceholders: ()=>replacePlaceholders,
|
|
15
|
+
splitOrigin: ()=>splitOrigin,
|
|
16
|
+
joinOrigin: ()=>joinOrigin,
|
|
17
|
+
readFile: ()=>readFile,
|
|
18
|
+
isDirectory: ()=>isDirectory,
|
|
19
|
+
writeFile: ()=>writeFile,
|
|
20
|
+
writeFileIfChanged: ()=>writeFileIfChanged,
|
|
21
|
+
hasYarn: ()=>hasYarn,
|
|
22
|
+
makeInstall: ()=>makeInstall,
|
|
23
|
+
normalizeSlashes: ()=>normalizeSlashes,
|
|
24
|
+
normalizeRelativePath: ()=>normalizeRelativePath
|
|
25
|
+
});
|
|
26
|
+
const _fs = /*#__PURE__*/ _interopRequireDefault(require("fs"));
|
|
27
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
28
|
+
const _normalizePath = /*#__PURE__*/ _interopRequireDefault(require("normalize-path"));
|
|
29
|
+
function _interopRequireDefault(obj) {
|
|
30
|
+
return obj && obj.__esModule ? obj : {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const PATHSEP = "/" // force posix everywhere
|
|
35
|
+
;
|
|
36
|
+
function prettyOrigin(origins) {
|
|
37
|
+
try {
|
|
38
|
+
return origins.map((origin)=>origin.join(":")).join(", ");
|
|
39
|
+
} catch (e) {
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function replacePlaceholders(input, values) {
|
|
44
|
+
return input.replace(/\{([^}]+)}/g, (m, placeholder)=>{
|
|
45
|
+
return values[placeholder] ?? m;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const splitOrigin = (origin)=>{
|
|
49
|
+
const [file, line] = origin.split(":");
|
|
50
|
+
return [
|
|
51
|
+
file,
|
|
52
|
+
line ? Number(line) : null
|
|
53
|
+
];
|
|
54
|
+
};
|
|
55
|
+
const joinOrigin = (origin)=>origin.join(":");
|
|
56
|
+
async function readFile(fileName) {
|
|
57
|
+
try {
|
|
58
|
+
return (await _fs.default.promises.readFile(fileName)).toString();
|
|
59
|
+
} catch (err) {
|
|
60
|
+
if (err.code != "ENOENT") {
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function mkdirp(dir) {
|
|
66
|
+
try {
|
|
67
|
+
await _fs.default.promises.mkdir(dir, {
|
|
68
|
+
recursive: true
|
|
69
|
+
});
|
|
70
|
+
} catch (err) {
|
|
71
|
+
if (err.code != "EEXIST") {
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function isDirectory(filePath) {
|
|
77
|
+
try {
|
|
78
|
+
return _fs.default.lstatSync(filePath).isDirectory();
|
|
79
|
+
} catch (err) {
|
|
80
|
+
if (err.code != "ENOENT") {
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function writeFile(fileName, content) {
|
|
86
|
+
await mkdirp(_path.default.dirname(fileName));
|
|
87
|
+
await _fs.default.promises.writeFile(fileName, content);
|
|
88
|
+
}
|
|
89
|
+
async function writeFileIfChanged(filename, newContent) {
|
|
90
|
+
const raw = await readFile(filename);
|
|
91
|
+
if (raw) {
|
|
92
|
+
if (newContent !== raw) {
|
|
93
|
+
await writeFile(filename, newContent);
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
await writeFile(filename, newContent);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function hasYarn() {
|
|
100
|
+
return _fs.default.existsSync(_path.default.resolve("yarn.lock"));
|
|
101
|
+
}
|
|
102
|
+
function makeInstall(packageName, dev = false) {
|
|
103
|
+
const withYarn = hasYarn();
|
|
104
|
+
return withYarn ? `yarn add ${dev ? "--dev " : ""}${packageName}` : `npm install ${dev ? "--save-dev" : "--save"} ${packageName}`;
|
|
105
|
+
}
|
|
106
|
+
function normalizeSlashes(path) {
|
|
107
|
+
return path.replace("\\", "/");
|
|
108
|
+
}
|
|
109
|
+
function normalizeRelativePath(sourcePath) {
|
|
110
|
+
if (_path.default.isAbsolute(sourcePath)) {
|
|
111
|
+
// absolute path
|
|
112
|
+
return (0, _normalizePath.default)(sourcePath, false);
|
|
113
|
+
}
|
|
114
|
+
// https://github.com/lingui/js-lingui/issues/809
|
|
115
|
+
const isDir = isDirectory(sourcePath);
|
|
116
|
+
return (0, _normalizePath.default)(_path.default.relative(process.cwd(), sourcePath), false) + (isDir ? "/" : "");
|
|
117
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
buildExternalizeFilter: ()=>buildExternalizeFilter,
|
|
13
|
+
getPackageJson: ()=>getPackageJson
|
|
14
|
+
});
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
16
|
+
if (typeof WeakMap !== "function") return null;
|
|
17
|
+
var cacheBabelInterop = new WeakMap();
|
|
18
|
+
var cacheNodeInterop = new WeakMap();
|
|
19
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
20
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
21
|
+
})(nodeInterop);
|
|
22
|
+
}
|
|
23
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
24
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
28
|
+
return {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
33
|
+
if (cache && cache.has(obj)) {
|
|
34
|
+
return cache.get(obj);
|
|
35
|
+
}
|
|
36
|
+
var newObj = {};
|
|
37
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
38
|
+
for(var key in obj){
|
|
39
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
40
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
41
|
+
if (desc && (desc.get || desc.set)) {
|
|
42
|
+
Object.defineProperty(newObj, key, desc);
|
|
43
|
+
} else {
|
|
44
|
+
newObj[key] = obj[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
newObj.default = obj;
|
|
49
|
+
if (cache) {
|
|
50
|
+
cache.set(obj, newObj);
|
|
51
|
+
}
|
|
52
|
+
return newObj;
|
|
53
|
+
}
|
|
54
|
+
function createPackageRegExp(packageName) {
|
|
55
|
+
return new RegExp("^" + packageName + "(?:\\/.+)?");
|
|
56
|
+
}
|
|
57
|
+
function packages(packages, includeDeps) {
|
|
58
|
+
return Object.keys(packages || {}).filter((packageName)=>{
|
|
59
|
+
return !includeDeps.some((incl)=>packageName.startsWith(incl));
|
|
60
|
+
}).map(createPackageRegExp);
|
|
61
|
+
}
|
|
62
|
+
function buildExternalizeFilter({ includeDeps , excludeDeps , packageJson }) {
|
|
63
|
+
const external = [
|
|
64
|
+
...packages(packageJson.dependencies, includeDeps),
|
|
65
|
+
...packages(packageJson.devDependencies, includeDeps),
|
|
66
|
+
...packages(packageJson.peerDependencies, includeDeps),
|
|
67
|
+
...packages(packageJson.optionalDependencies, includeDeps),
|
|
68
|
+
...excludeDeps.map(createPackageRegExp)
|
|
69
|
+
];
|
|
70
|
+
return (id)=>external.some((regExp)=>{
|
|
71
|
+
return regExp.test(id);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async function getPackageJson(rootDir) {
|
|
75
|
+
const { default: pkgUp } = await Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("pkg-up")));
|
|
76
|
+
const packageJsonPath = await pkgUp({
|
|
77
|
+
cwd: rootDir
|
|
78
|
+
});
|
|
79
|
+
if (!packageJsonPath) {
|
|
80
|
+
throw new Error("We could not able to find your package.json file. " + "Check that `rootDir` is pointing to the folder with package.json");
|
|
81
|
+
}
|
|
82
|
+
return await Promise.resolve(packageJsonPath).then((p)=>/*#__PURE__*/ _interopRequireWildcard(require(p)));
|
|
83
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "bundleSource", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>bundleSource
|
|
8
|
+
});
|
|
9
|
+
const _buildExternalizeFilter = require("./buildExternalizeFilter");
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
11
|
+
if (typeof WeakMap !== "function") return null;
|
|
12
|
+
var cacheBabelInterop = new WeakMap();
|
|
13
|
+
var cacheNodeInterop = new WeakMap();
|
|
14
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
15
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
16
|
+
})(nodeInterop);
|
|
17
|
+
}
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
19
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
23
|
+
return {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
28
|
+
if (cache && cache.has(obj)) {
|
|
29
|
+
return cache.get(obj);
|
|
30
|
+
}
|
|
31
|
+
var newObj = {};
|
|
32
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
33
|
+
for(var key in obj){
|
|
34
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
35
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
36
|
+
if (desc && (desc.get || desc.set)) {
|
|
37
|
+
Object.defineProperty(newObj, key, desc);
|
|
38
|
+
} else {
|
|
39
|
+
newObj[key] = obj[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
newObj.default = obj;
|
|
44
|
+
if (cache) {
|
|
45
|
+
cache.set(obj, newObj);
|
|
46
|
+
}
|
|
47
|
+
return newObj;
|
|
48
|
+
}
|
|
49
|
+
function createExtRegExp(extensions) {
|
|
50
|
+
return new RegExp("\\.(?:" + extensions.join("|") + ")(?:\\?.*)?$");
|
|
51
|
+
}
|
|
52
|
+
async function bundleSource(config, entryPoints, outDir, rootDir) {
|
|
53
|
+
const esbuild = await Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("esbuild")));
|
|
54
|
+
const excludeExtensions = config.excludeExtensions || [
|
|
55
|
+
"ico",
|
|
56
|
+
"pot",
|
|
57
|
+
"xliff",
|
|
58
|
+
"woff2",
|
|
59
|
+
"woff",
|
|
60
|
+
"eot",
|
|
61
|
+
"gif",
|
|
62
|
+
"otf",
|
|
63
|
+
"ttf",
|
|
64
|
+
"mp4",
|
|
65
|
+
"svg",
|
|
66
|
+
"png",
|
|
67
|
+
"css",
|
|
68
|
+
"sass",
|
|
69
|
+
"less",
|
|
70
|
+
"jpg"
|
|
71
|
+
];
|
|
72
|
+
const packageJson = await (0, _buildExternalizeFilter.getPackageJson)(rootDir);
|
|
73
|
+
const esbuildOptions = {
|
|
74
|
+
entryPoints: entryPoints,
|
|
75
|
+
outExtension: {
|
|
76
|
+
".js": ".jsx"
|
|
77
|
+
},
|
|
78
|
+
jsx: "preserve",
|
|
79
|
+
bundle: true,
|
|
80
|
+
platform: "node",
|
|
81
|
+
target: [
|
|
82
|
+
"esnext"
|
|
83
|
+
],
|
|
84
|
+
format: "esm",
|
|
85
|
+
splitting: false,
|
|
86
|
+
treeShaking: true,
|
|
87
|
+
outdir: outDir,
|
|
88
|
+
sourcemap: "inline",
|
|
89
|
+
sourceRoot: outDir,
|
|
90
|
+
sourcesContent: false,
|
|
91
|
+
outbase: rootDir,
|
|
92
|
+
metafile: true,
|
|
93
|
+
plugins: [
|
|
94
|
+
{
|
|
95
|
+
name: "externalize-deps",
|
|
96
|
+
setup (build) {
|
|
97
|
+
const isExternal = (0, _buildExternalizeFilter.buildExternalizeFilter)({
|
|
98
|
+
includeDeps: config.includeDeps || [],
|
|
99
|
+
excludeDeps: config.excludeDeps || [],
|
|
100
|
+
packageJson
|
|
101
|
+
});
|
|
102
|
+
// externalize bare imports
|
|
103
|
+
build.onResolve({
|
|
104
|
+
filter: /^[^.].*/
|
|
105
|
+
}, async ({ path: id })=>{
|
|
106
|
+
if (isExternal(id)) {
|
|
107
|
+
return {
|
|
108
|
+
external: true
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "externalize-files",
|
|
116
|
+
setup (build) {
|
|
117
|
+
build.onResolve({
|
|
118
|
+
filter: createExtRegExp(excludeExtensions)
|
|
119
|
+
}, ()=>({
|
|
120
|
+
external: true
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
return await esbuild.build(config.resolveEsbuildOptions ? config.resolveEsbuildOptions(esbuildOptions) : esbuildOptions);
|
|
127
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
ENTRY_NAME_PH: ()=>ENTRY_NAME_PH,
|
|
13
|
+
DEFAULT_TEMPLATE_NAME: ()=>DEFAULT_TEMPLATE_NAME
|
|
14
|
+
});
|
|
15
|
+
const ENTRY_NAME_PH = "{entryName}";
|
|
16
|
+
const DEFAULT_TEMPLATE_NAME = "messages";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getEntryPoints", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>getEntryPoints
|
|
8
|
+
});
|
|
9
|
+
const _glob = /*#__PURE__*/ _interopRequireDefault(require("glob"));
|
|
10
|
+
function _interopRequireDefault(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function getEntryPoints(entries) {
|
|
16
|
+
const patterns = entries.length > 1 ? `{${entries.join(",")}}` : entries[0];
|
|
17
|
+
return _glob.default.sync(patterns, {
|
|
18
|
+
mark: true
|
|
19
|
+
});
|
|
20
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "getExperimentalCatalogs", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>getExperimentalCatalogs
|
|
8
|
+
});
|
|
9
|
+
const _getEntryPoints = require("./getEntryPoints");
|
|
10
|
+
const _resolveCatalogPath = require("./resolveCatalogPath");
|
|
11
|
+
const _catalog = require("../api/catalog");
|
|
12
|
+
const _resolveTemplatePath = require("./resolveTemplatePath");
|
|
13
|
+
const _api = require("@lingui/cli/api");
|
|
14
|
+
async function getExperimentalCatalogs(linguiConfig) {
|
|
15
|
+
const config = linguiConfig.experimental.extractor;
|
|
16
|
+
const entryPoints = (0, _getEntryPoints.getEntryPoints)(config.entries);
|
|
17
|
+
const format = await (0, _api.getFormat)(linguiConfig.format, linguiConfig.formatOptions, linguiConfig.sourceLocale);
|
|
18
|
+
return entryPoints.map((entryPoint)=>{
|
|
19
|
+
const catalogPath = (0, _resolveCatalogPath.resolveCatalogPath)(config.output, entryPoint, linguiConfig.rootDir, undefined, "");
|
|
20
|
+
const templatePath = (0, _resolveTemplatePath.resolveTemplatePath)(entryPoint, config.output, linguiConfig.rootDir, format.getTemplateExtension());
|
|
21
|
+
return new _catalog.Catalog({
|
|
22
|
+
name: undefined,
|
|
23
|
+
path: catalogPath,
|
|
24
|
+
templatePath,
|
|
25
|
+
include: [],
|
|
26
|
+
exclude: [],
|
|
27
|
+
format
|
|
28
|
+
}, linguiConfig);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
resolveCatalogPath: ()=>resolveCatalogPath,
|
|
13
|
+
getEntryName: ()=>getEntryName
|
|
14
|
+
});
|
|
15
|
+
const _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
|
|
16
|
+
const _utils = require("../api/utils");
|
|
17
|
+
function _interopRequireDefault(obj) {
|
|
18
|
+
return obj && obj.__esModule ? obj : {
|
|
19
|
+
default: obj
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function resolveCatalogPath(configOutput, entryPath, rootDir, locale, extension) {
|
|
23
|
+
const entryName = getEntryName(entryPath);
|
|
24
|
+
const entryDir = _path.default.relative(rootDir, _path.default.dirname(entryPath));
|
|
25
|
+
return _path.default.normalize((0, _utils.replacePlaceholders)(configOutput, {
|
|
26
|
+
entryName,
|
|
27
|
+
entryDir,
|
|
28
|
+
locale
|
|
29
|
+
}) + extension);
|
|
30
|
+
}
|
|
31
|
+
function getEntryName(entryPath) {
|
|
32
|
+
const parsedPath = _path.default.parse(entryPath);
|
|
33
|
+
return parsedPath.name.replace(parsedPath.ext, "");
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "resolveTemplatePath", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>resolveTemplatePath
|
|
8
|
+
});
|
|
9
|
+
const _resolveCatalogPath = require("./resolveCatalogPath");
|
|
10
|
+
const _constants = require("./constants");
|
|
11
|
+
function resolveTemplatePath(entryPoint, output, rootDir, catalogExtension) {
|
|
12
|
+
let templateName;
|
|
13
|
+
if (output.includes(_constants.ENTRY_NAME_PH)) {
|
|
14
|
+
templateName = _constants.DEFAULT_TEMPLATE_NAME;
|
|
15
|
+
} else {
|
|
16
|
+
templateName = (0, _resolveCatalogPath.getEntryName)(entryPoint);
|
|
17
|
+
}
|
|
18
|
+
return (0, _resolveCatalogPath.resolveCatalogPath)(output, entryPoint, rootDir, templateName, catalogExtension);
|
|
19
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
writeCatalogs: ()=>writeCatalogs,
|
|
13
|
+
writeTemplate: ()=>writeTemplate
|
|
14
|
+
});
|
|
15
|
+
const _resolveTemplatePath = require("./resolveTemplatePath");
|
|
16
|
+
const _chalk = /*#__PURE__*/ _interopRequireDefault(require("chalk"));
|
|
17
|
+
const _resolveCatalogPath = require("./resolveCatalogPath");
|
|
18
|
+
const _mergeCatalog = require("../api/catalog/mergeCatalog");
|
|
19
|
+
const _stats = require("../api/stats");
|
|
20
|
+
const _catalog = require("../api/catalog");
|
|
21
|
+
function _interopRequireDefault(obj) {
|
|
22
|
+
return obj && obj.__esModule ? obj : {
|
|
23
|
+
default: obj
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function cleanAndSort(catalog, clean, orderBy) {
|
|
27
|
+
if (clean) {
|
|
28
|
+
catalog = (0, _catalog.cleanObsolete)(catalog);
|
|
29
|
+
}
|
|
30
|
+
return (0, _catalog.order)(orderBy)(catalog);
|
|
31
|
+
}
|
|
32
|
+
async function writeCatalogs(params) {
|
|
33
|
+
const { entryPoint , outputPattern , linguiConfig , locales , overwrite , format , clean , messages } = params;
|
|
34
|
+
const stat = {};
|
|
35
|
+
for (const locale of locales){
|
|
36
|
+
const catalogOutput = (0, _resolveCatalogPath.resolveCatalogPath)(outputPattern, entryPoint, linguiConfig.rootDir, locale, format.getCatalogExtension());
|
|
37
|
+
const catalog = (0, _mergeCatalog.mergeCatalog)(await format.read(catalogOutput, locale), messages, locale === linguiConfig.sourceLocale, {
|
|
38
|
+
overwrite
|
|
39
|
+
});
|
|
40
|
+
await format.write(catalogOutput, cleanAndSort(catalog, clean, linguiConfig.orderBy), locale);
|
|
41
|
+
stat[locale] = catalog;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
statMessage: (0, _stats.printStats)(linguiConfig, stat).toString()
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async function writeTemplate(params) {
|
|
48
|
+
const { entryPoint , outputPattern , linguiConfig , format , clean , messages } = params;
|
|
49
|
+
const catalogOutput = (0, _resolveTemplatePath.resolveTemplatePath)(entryPoint, outputPattern, linguiConfig.rootDir, format.getTemplateExtension());
|
|
50
|
+
await format.write(catalogOutput, cleanAndSort(messages, clean, linguiConfig.orderBy), undefined);
|
|
51
|
+
return {
|
|
52
|
+
statMessage: `${_chalk.default.bold(Object.keys(messages).length)} message(s) extracted`
|
|
53
|
+
};
|
|
54
|
+
}
|