@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
|
@@ -1,60 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
const _ramda = /*#__PURE__*/ _interopRequireDefault(require("ramda"));
|
|
10
|
-
const _pseudolocale = /*#__PURE__*/ _interopRequireDefault(require("pseudolocale"));
|
|
11
|
-
function _interopRequireDefault(obj) {
|
|
12
|
-
return obj && obj.__esModule ? obj : {
|
|
13
|
-
default: obj
|
|
14
|
-
};
|
|
15
|
-
}
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const ramda_1 = __importDefault(require("ramda"));
|
|
7
|
+
const pseudolocale_1 = __importDefault(require("pseudolocale"));
|
|
16
8
|
const delimiter = "%&&&%";
|
|
17
|
-
_pseudolocale.default.option.delimiter = delimiter;
|
|
18
|
-
// We do not want prepending and appending because of Plurals structure
|
|
19
|
-
_pseudolocale.default.option.prepend = "";
|
|
20
|
-
_pseudolocale.default.option.append = "";
|
|
21
9
|
/**
|
|
22
10
|
* Regex should match HTML tags
|
|
23
11
|
* It was taken from https://haacked.com/archive/2004/10/25/usingregularexpressionstomatchhtml.aspx/
|
|
24
12
|
* Example: https://regex101.com/r/bDHD9z/3
|
|
25
|
-
*/
|
|
13
|
+
*/
|
|
14
|
+
const HTMLRegex = /<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/g;
|
|
26
15
|
/**
|
|
27
16
|
* Regex should match js-lingui Plurals, Select and SelectOrdinal components
|
|
28
17
|
* Example:
|
|
29
18
|
* Plurals https://regex101.com/r/VUJXg0/1
|
|
30
19
|
* SelectOrdinal https://regex101.com/r/T7hSLU/2
|
|
31
20
|
* Select https://regex101.com/r/9JnqB9/1
|
|
32
|
-
*/
|
|
21
|
+
*/
|
|
22
|
+
const MacroRegex = /({\w*,\s*(plural|selectordinal|select),(.|\n)*?{)|(}\s*\w*\s*{)/gi;
|
|
33
23
|
/**
|
|
34
24
|
* Regex should match js-lingui variables
|
|
35
25
|
* Example: https://regex101.com/r/dw1QHb/2
|
|
36
|
-
*/
|
|
26
|
+
*/
|
|
27
|
+
const VariableRegex = /({\s*[a-zA-Z_$][a-zA-Z_$0-9]*\s*})/g;
|
|
37
28
|
function addDelimitersHTMLTags(message) {
|
|
38
|
-
return message.replace(HTMLRegex, (matchedString)=>{
|
|
29
|
+
return message.replace(HTMLRegex, (matchedString) => {
|
|
39
30
|
return `${delimiter}${matchedString}${delimiter}`;
|
|
40
31
|
});
|
|
41
32
|
}
|
|
42
33
|
function addDelimitersMacro(message) {
|
|
43
|
-
return message.replace(MacroRegex, (matchedString)=>{
|
|
34
|
+
return message.replace(MacroRegex, (matchedString) => {
|
|
44
35
|
return `${delimiter}${matchedString}${delimiter}`;
|
|
45
36
|
});
|
|
46
37
|
}
|
|
47
38
|
function addDelimitersVariables(message) {
|
|
48
|
-
return message.replace(VariableRegex, (matchedString)=>{
|
|
39
|
+
return message.replace(VariableRegex, (matchedString) => {
|
|
49
40
|
return `${delimiter}${matchedString}${delimiter}`;
|
|
50
41
|
});
|
|
51
42
|
}
|
|
52
|
-
const addDelimiters =
|
|
43
|
+
const addDelimiters = ramda_1.default.compose(addDelimitersVariables, addDelimitersMacro, addDelimitersHTMLTags);
|
|
53
44
|
function removeDelimiters(message) {
|
|
54
45
|
return message.replace(new RegExp(delimiter, "g"), "");
|
|
55
46
|
}
|
|
56
|
-
function
|
|
47
|
+
function default_1(message) {
|
|
57
48
|
message = addDelimiters(message);
|
|
58
|
-
message =
|
|
49
|
+
message = (0, pseudolocale_1.default)(message, {
|
|
50
|
+
delimiter,
|
|
51
|
+
prepend: "",
|
|
52
|
+
append: "",
|
|
53
|
+
});
|
|
59
54
|
return removeDelimiters(message);
|
|
60
55
|
}
|
|
56
|
+
exports.default = default_1;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "RethrownError", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: ()=>RethrownError
|
|
8
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RethrownError = void 0;
|
|
9
4
|
class RethrownError extends Error {
|
|
10
|
-
message
|
|
11
|
-
constructor(message, originalError){
|
|
5
|
+
constructor(message, originalError) {
|
|
12
6
|
super();
|
|
13
7
|
this.message = message + " " + originalError.message;
|
|
14
8
|
this.stack = `Error: ${message} \nOriginal: ` + originalError.stack;
|
|
15
9
|
}
|
|
16
10
|
}
|
|
11
|
+
exports.RethrownError = RethrownError;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LinguiConfigNormalized } from "@lingui/conf";
|
|
2
|
+
import { AllCatalogsType, CatalogType } from "./types";
|
|
3
|
+
type CatalogStats = [number, number];
|
|
4
|
+
export declare function getStats(catalog: CatalogType): CatalogStats;
|
|
5
|
+
export declare function printStats(config: LinguiConfigNormalized, catalogs: AllCatalogsType): any;
|
|
6
|
+
export {};
|
package/dist/api/stats.js
CHANGED
|
@@ -1,73 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
}
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.printStats = exports.getStats = void 0;
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const cli_table_1 = __importDefault(require("cli-table"));
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
22
10
|
function getStats(catalog) {
|
|
23
11
|
return [
|
|
24
12
|
Object.keys(catalog).length,
|
|
25
|
-
Object.keys(catalog).filter((key)
|
|
13
|
+
Object.keys(catalog).filter((key) => !catalog[key].translation).length,
|
|
26
14
|
];
|
|
27
15
|
}
|
|
16
|
+
exports.getStats = getStats;
|
|
28
17
|
function printStats(config, catalogs) {
|
|
29
|
-
const table = new
|
|
30
|
-
head: [
|
|
31
|
-
|
|
32
|
-
"Total count",
|
|
33
|
-
"Missing"
|
|
34
|
-
],
|
|
35
|
-
colAligns: [
|
|
36
|
-
"left",
|
|
37
|
-
"middle",
|
|
38
|
-
"middle"
|
|
39
|
-
],
|
|
18
|
+
const table = new cli_table_1.default({
|
|
19
|
+
head: ["Language", "Total count", "Missing"],
|
|
20
|
+
colAligns: ["left", "middle", "middle"],
|
|
40
21
|
style: {
|
|
41
|
-
head: [
|
|
42
|
-
"green"
|
|
43
|
-
],
|
|
22
|
+
head: ["green"],
|
|
44
23
|
border: [],
|
|
45
|
-
compact: true
|
|
46
|
-
}
|
|
24
|
+
compact: true,
|
|
25
|
+
},
|
|
47
26
|
});
|
|
48
|
-
Object.keys(catalogs).forEach((locale)=>{
|
|
27
|
+
Object.keys(catalogs).forEach((locale) => {
|
|
49
28
|
const catalog = catalogs[locale];
|
|
50
29
|
// catalog is null if no catalog exists on disk and the locale
|
|
51
30
|
// was not extracted due to a `--locale` filter
|
|
52
|
-
const [all, translated] = catalog ? getStats(catalog) : [
|
|
53
|
-
"-",
|
|
54
|
-
"-"
|
|
55
|
-
];
|
|
31
|
+
const [all, translated] = catalog ? getStats(catalog) : ["-", "-"];
|
|
56
32
|
if (config.sourceLocale === locale) {
|
|
57
|
-
table.push({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
]
|
|
62
|
-
});
|
|
63
|
-
} else {
|
|
64
|
-
table.push({
|
|
65
|
-
[locale]: [
|
|
66
|
-
all,
|
|
67
|
-
translated
|
|
68
|
-
]
|
|
69
|
-
});
|
|
33
|
+
table.push({ [`${chalk_1.default.bold(locale)} (source)`]: [all, "-"] });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
table.push({ [locale]: [all, translated] });
|
|
70
37
|
}
|
|
71
38
|
});
|
|
72
39
|
return table;
|
|
73
40
|
}
|
|
41
|
+
exports.printStats = printStats;
|
package/dist/api/types.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const PATHSEP = "/";
|
|
2
|
+
export declare function prettyOrigin(origins: [filename: string, line?: number][]): string;
|
|
3
|
+
export declare function replacePlaceholders(input: string, values: Record<string, string>): string;
|
|
4
|
+
export declare const splitOrigin: (origin: string) => [file: string, line: number];
|
|
5
|
+
export declare const joinOrigin: (origin: [file: string, line?: number]) => string;
|
|
6
|
+
export declare function readFile(fileName: string): Promise<string | undefined>;
|
|
7
|
+
export declare function isDirectory(filePath: string): boolean;
|
|
8
|
+
export declare function writeFile(fileName: string, content: string): Promise<void>;
|
|
9
|
+
export declare function writeFileIfChanged(filename: string, newContent: string): Promise<void>;
|
|
10
|
+
export declare function hasYarn(): boolean;
|
|
11
|
+
export declare function makeInstall(packageName: string, dev?: boolean): string;
|
|
12
|
+
/**
|
|
13
|
+
* Normalize Windows backslashes in path so they look always as posix
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeSlashes(path: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Remove ./ at the beginning: ./relative => relative
|
|
18
|
+
* relative => relative
|
|
19
|
+
* Preserve directories: ./relative/ => relative/
|
|
20
|
+
* Preserve absolute paths: /absolute/path => /absolute/path
|
|
21
|
+
*/
|
|
22
|
+
export declare function normalizeRelativePath(sourcePath: string): string;
|
package/dist/api/utils.js
CHANGED
|
@@ -1,73 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.normalizeRelativePath = exports.normalizeSlashes = exports.makeInstall = exports.hasYarn = exports.writeFileIfChanged = exports.writeFile = exports.isDirectory = exports.readFile = exports.joinOrigin = exports.splitOrigin = exports.replacePlaceholders = exports.prettyOrigin = exports.PATHSEP = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
10
|
+
exports.PATHSEP = "/"; // force posix everywhere
|
|
36
11
|
function prettyOrigin(origins) {
|
|
37
12
|
try {
|
|
38
|
-
return origins.map((origin)=>origin.join(":")).join(", ");
|
|
39
|
-
}
|
|
13
|
+
return origins.map((origin) => origin.join(":")).join(", ");
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
40
16
|
return "";
|
|
41
17
|
}
|
|
42
18
|
}
|
|
19
|
+
exports.prettyOrigin = prettyOrigin;
|
|
43
20
|
function replacePlaceholders(input, values) {
|
|
44
|
-
return input.replace(/\{([^}]+)}/g, (m, placeholder)=>{
|
|
45
|
-
|
|
21
|
+
return input.replace(/\{([^}]+)}/g, (m, placeholder) => {
|
|
22
|
+
var _a;
|
|
23
|
+
return (_a = values[placeholder]) !== null && _a !== void 0 ? _a : m;
|
|
46
24
|
});
|
|
47
25
|
}
|
|
48
|
-
|
|
26
|
+
exports.replacePlaceholders = replacePlaceholders;
|
|
27
|
+
const splitOrigin = (origin) => {
|
|
49
28
|
const [file, line] = origin.split(":");
|
|
50
|
-
return [
|
|
51
|
-
file,
|
|
52
|
-
line ? Number(line) : null
|
|
53
|
-
];
|
|
29
|
+
return [file, line ? Number(line) : null];
|
|
54
30
|
};
|
|
55
|
-
|
|
31
|
+
exports.splitOrigin = splitOrigin;
|
|
32
|
+
const joinOrigin = (origin) => origin.join(":");
|
|
33
|
+
exports.joinOrigin = joinOrigin;
|
|
56
34
|
async function readFile(fileName) {
|
|
57
35
|
try {
|
|
58
|
-
return (await
|
|
59
|
-
}
|
|
36
|
+
return (await fs_1.default.promises.readFile(fileName)).toString();
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
60
39
|
if (err.code != "ENOENT") {
|
|
61
40
|
throw err;
|
|
62
41
|
}
|
|
63
42
|
}
|
|
64
43
|
}
|
|
44
|
+
exports.readFile = readFile;
|
|
65
45
|
async function mkdirp(dir) {
|
|
66
46
|
try {
|
|
67
|
-
await
|
|
68
|
-
recursive: true
|
|
47
|
+
await fs_1.default.promises.mkdir(dir, {
|
|
48
|
+
recursive: true,
|
|
69
49
|
});
|
|
70
|
-
}
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
71
52
|
if (err.code != "EEXIST") {
|
|
72
53
|
throw err;
|
|
73
54
|
}
|
|
@@ -75,43 +56,64 @@ async function mkdirp(dir) {
|
|
|
75
56
|
}
|
|
76
57
|
function isDirectory(filePath) {
|
|
77
58
|
try {
|
|
78
|
-
return
|
|
79
|
-
}
|
|
59
|
+
return fs_1.default.lstatSync(filePath).isDirectory();
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
80
62
|
if (err.code != "ENOENT") {
|
|
81
63
|
throw err;
|
|
82
64
|
}
|
|
83
65
|
}
|
|
84
66
|
}
|
|
67
|
+
exports.isDirectory = isDirectory;
|
|
85
68
|
async function writeFile(fileName, content) {
|
|
86
|
-
await mkdirp(
|
|
87
|
-
await
|
|
69
|
+
await mkdirp(path_1.default.dirname(fileName));
|
|
70
|
+
await fs_1.default.promises.writeFile(fileName, content);
|
|
88
71
|
}
|
|
72
|
+
exports.writeFile = writeFile;
|
|
89
73
|
async function writeFileIfChanged(filename, newContent) {
|
|
90
74
|
const raw = await readFile(filename);
|
|
91
75
|
if (raw) {
|
|
92
76
|
if (newContent !== raw) {
|
|
93
77
|
await writeFile(filename, newContent);
|
|
94
78
|
}
|
|
95
|
-
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
96
81
|
await writeFile(filename, newContent);
|
|
97
82
|
}
|
|
98
83
|
}
|
|
84
|
+
exports.writeFileIfChanged = writeFileIfChanged;
|
|
99
85
|
function hasYarn() {
|
|
100
|
-
return
|
|
86
|
+
return fs_1.default.existsSync(path_1.default.resolve("yarn.lock"));
|
|
101
87
|
}
|
|
88
|
+
exports.hasYarn = hasYarn;
|
|
102
89
|
function makeInstall(packageName, dev = false) {
|
|
103
90
|
const withYarn = hasYarn();
|
|
104
|
-
return withYarn
|
|
91
|
+
return withYarn
|
|
92
|
+
? `yarn add ${dev ? "--dev " : ""}${packageName}`
|
|
93
|
+
: `npm install ${dev ? "--save-dev" : "--save"} ${packageName}`;
|
|
105
94
|
}
|
|
95
|
+
exports.makeInstall = makeInstall;
|
|
96
|
+
/**
|
|
97
|
+
* Normalize Windows backslashes in path so they look always as posix
|
|
98
|
+
*/
|
|
106
99
|
function normalizeSlashes(path) {
|
|
107
100
|
return path.replace("\\", "/");
|
|
108
101
|
}
|
|
102
|
+
exports.normalizeSlashes = normalizeSlashes;
|
|
103
|
+
/**
|
|
104
|
+
* Remove ./ at the beginning: ./relative => relative
|
|
105
|
+
* relative => relative
|
|
106
|
+
* Preserve directories: ./relative/ => relative/
|
|
107
|
+
* Preserve absolute paths: /absolute/path => /absolute/path
|
|
108
|
+
*/
|
|
109
109
|
function normalizeRelativePath(sourcePath) {
|
|
110
|
-
if (
|
|
110
|
+
if (path_1.default.isAbsolute(sourcePath)) {
|
|
111
111
|
// absolute path
|
|
112
|
-
return (0,
|
|
112
|
+
return (0, normalize_path_1.default)(sourcePath, false);
|
|
113
113
|
}
|
|
114
114
|
// https://github.com/lingui/js-lingui/issues/809
|
|
115
115
|
const isDir = isDirectory(sourcePath);
|
|
116
|
-
return (0,
|
|
116
|
+
return ((0, normalize_path_1.default)(path_1.default.relative(process.cwd(), sourcePath), false) +
|
|
117
|
+
(isDir ? "/" : ""));
|
|
117
118
|
}
|
|
119
|
+
exports.normalizeRelativePath = normalizeRelativePath;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type PackageJson = {
|
|
2
|
+
dependencies?: Record<string, string>;
|
|
3
|
+
devDependencies?: Record<string, string>;
|
|
4
|
+
peerDependencies?: Record<string, string>;
|
|
5
|
+
optionalDependencies?: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
export declare function buildExternalizeFilter({ includeDeps, excludeDeps, packageJson, }: {
|
|
8
|
+
includeDeps: string[];
|
|
9
|
+
excludeDeps: string[];
|
|
10
|
+
packageJson: PackageJson;
|
|
11
|
+
}): (id: string) => boolean;
|
|
12
|
+
export declare function getPackageJson(rootDir: string): Promise<PackageJson>;
|
|
13
|
+
export {};
|
|
@@ -1,83 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
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
|
-
}
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPackageJson = exports.buildExternalizeFilter = void 0;
|
|
54
4
|
function createPackageRegExp(packageName) {
|
|
55
5
|
return new RegExp("^" + packageName + "(?:\\/.+)?");
|
|
56
6
|
}
|
|
57
7
|
function packages(packages, includeDeps) {
|
|
58
|
-
return Object.keys(packages || {})
|
|
59
|
-
|
|
60
|
-
|
|
8
|
+
return Object.keys(packages || {})
|
|
9
|
+
.filter((packageName) => {
|
|
10
|
+
return !includeDeps.some((incl) => packageName.startsWith(incl));
|
|
11
|
+
})
|
|
12
|
+
.map(createPackageRegExp);
|
|
61
13
|
}
|
|
62
|
-
function buildExternalizeFilter({ includeDeps
|
|
14
|
+
function buildExternalizeFilter({ includeDeps, excludeDeps, packageJson, }) {
|
|
63
15
|
const external = [
|
|
64
16
|
...packages(packageJson.dependencies, includeDeps),
|
|
65
17
|
...packages(packageJson.devDependencies, includeDeps),
|
|
66
18
|
...packages(packageJson.peerDependencies, includeDeps),
|
|
67
19
|
...packages(packageJson.optionalDependencies, includeDeps),
|
|
68
|
-
...excludeDeps.map(createPackageRegExp)
|
|
20
|
+
...excludeDeps.map(createPackageRegExp),
|
|
69
21
|
];
|
|
70
|
-
return (id)=>external.some((regExp)=>{
|
|
71
|
-
|
|
72
|
-
|
|
22
|
+
return (id) => external.some((regExp) => {
|
|
23
|
+
return regExp.test(id);
|
|
24
|
+
});
|
|
73
25
|
}
|
|
26
|
+
exports.buildExternalizeFilter = buildExternalizeFilter;
|
|
74
27
|
async function getPackageJson(rootDir) {
|
|
75
|
-
const { default: pkgUp
|
|
28
|
+
const { default: pkgUp } = await import("pkg-up");
|
|
76
29
|
const packageJsonPath = await pkgUp({
|
|
77
|
-
cwd: rootDir
|
|
30
|
+
cwd: rootDir,
|
|
78
31
|
});
|
|
79
32
|
if (!packageJsonPath) {
|
|
80
|
-
throw new Error("We could not able to find your package.json file. " +
|
|
33
|
+
throw new Error("We could not able to find your package.json file. " +
|
|
34
|
+
"Check that `rootDir` is pointing to the folder with package.json");
|
|
81
35
|
}
|
|
82
|
-
return await
|
|
36
|
+
return await import(packageJsonPath);
|
|
83
37
|
}
|
|
38
|
+
exports.getPackageJson = getPackageJson;
|