@let-value/translate-extract-static 1.1.2 → 1.1.6-beta.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/dist/bin/cli.cjs +3 -8
- package/dist/bin/{cli.js → cli.mjs} +2 -4
- package/dist/{binary-Ceo8ROxg.js → binary-B9VjMzKh.mjs} +4 -6
- package/dist/binary-USvBdAnM.cjs +32 -0
- package/dist/scripts/postinstall.cjs +3 -11
- package/dist/scripts/{postinstall.js → postinstall.mjs} +3 -8
- package/dist/src/index.cjs +27 -19
- package/dist/src/index.d.cts +53 -1096
- package/dist/src/index.d.mts +433 -0
- package/dist/src/{index.js → index.mjs} +26 -17
- package/package.json +44 -39
- package/dist/binary-B-BK0iD4.cjs +0 -37
- package/dist/chunk-CUT6urMc.cjs +0 -30
- package/dist/src/index.d.ts +0 -1476
- /package/dist/bin/{cli.d.ts → cli.d.mts} +0 -0
- /package/dist/scripts/{postinstall.d.ts → postinstall.d.mts} +0 -0
package/dist/bin/cli.cjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
3
|
-
const require_binary = require('../binary-B-BK0iD4.cjs');
|
|
4
|
-
let node_child_process = require("node:child_process");
|
|
5
|
-
node_child_process = require_chunk.__toESM(node_child_process);
|
|
6
|
-
|
|
2
|
+
const require_binary = require("../binary-USvBdAnM.cjs");
|
|
7
3
|
//#region bin/cli.ts
|
|
8
|
-
const child = (0,
|
|
4
|
+
const child = (0, require("node:child_process").spawn)(require_binary.binaryPath, process.argv.slice(2), {
|
|
9
5
|
stdio: "inherit",
|
|
10
6
|
windowsHide: true
|
|
11
7
|
});
|
|
@@ -20,5 +16,4 @@ child.on("exit", (code, signal) => {
|
|
|
20
16
|
}
|
|
21
17
|
process.exit(code ?? 1);
|
|
22
18
|
});
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
19
|
+
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { binaryPath } from "../binary-
|
|
2
|
+
import { n as binaryPath } from "../binary-B9VjMzKh.mjs";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
|
-
|
|
5
4
|
//#region bin/cli.ts
|
|
6
5
|
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
7
6
|
stdio: "inherit",
|
|
@@ -18,6 +17,5 @@ child.on("exit", (code, signal) => {
|
|
|
18
17
|
}
|
|
19
18
|
process.exit(code ?? 1);
|
|
20
19
|
});
|
|
21
|
-
|
|
22
20
|
//#endregion
|
|
23
|
-
export {
|
|
21
|
+
export {};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { resolve } from "node:path";
|
|
2
2
|
import { familySync } from "detect-libc";
|
|
3
|
-
|
|
4
3
|
//#region src/binary.ts
|
|
5
4
|
const root = resolve(import.meta.dirname, "..");
|
|
6
5
|
const platform = process.platform;
|
|
7
6
|
const arch = process.arch;
|
|
8
7
|
const libc = familySync() || null;
|
|
9
|
-
function getBinaryName(platform
|
|
10
|
-
const extension = platform
|
|
11
|
-
return `extract-${platform
|
|
8
|
+
function getBinaryName(platform, arch, libc) {
|
|
9
|
+
const extension = platform === "win32" ? ".exe" : "";
|
|
10
|
+
return `extract-${platform}-${arch}${libc ? `-${libc}` : ""}${extension}`;
|
|
12
11
|
}
|
|
13
12
|
const binaryName = getBinaryName(platform, arch, libc);
|
|
14
13
|
const binaryPath = resolve(root, "prebuilts", binaryName);
|
|
15
|
-
|
|
16
14
|
//#endregion
|
|
17
|
-
export {
|
|
15
|
+
export { binaryPath as n, platform as r, binaryName as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
let node_path = require("node:path");
|
|
2
|
+
let detect_libc = require("detect-libc");
|
|
3
|
+
//#region src/binary.ts
|
|
4
|
+
const root = (0, node_path.resolve)(__dirname, "..");
|
|
5
|
+
const platform = process.platform;
|
|
6
|
+
const arch = process.arch;
|
|
7
|
+
const libc = (0, detect_libc.familySync)() || null;
|
|
8
|
+
function getBinaryName(platform, arch, libc) {
|
|
9
|
+
const extension = platform === "win32" ? ".exe" : "";
|
|
10
|
+
return `extract-${platform}-${arch}${libc ? `-${libc}` : ""}${extension}`;
|
|
11
|
+
}
|
|
12
|
+
const binaryName = getBinaryName(platform, arch, libc);
|
|
13
|
+
const binaryPath = (0, node_path.resolve)(root, "prebuilts", binaryName);
|
|
14
|
+
//#endregion
|
|
15
|
+
Object.defineProperty(exports, "binaryName", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function() {
|
|
18
|
+
return binaryName;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "binaryPath", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return binaryPath;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "platform", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function() {
|
|
30
|
+
return platform;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_binary = require('../binary-B-BK0iD4.cjs');
|
|
1
|
+
const require_binary = require("../binary-USvBdAnM.cjs");
|
|
3
2
|
let node_path = require("node:path");
|
|
4
|
-
node_path = require_chunk.__toESM(node_path);
|
|
5
3
|
let node_fs = require("node:fs");
|
|
6
|
-
node_fs = require_chunk.__toESM(node_fs);
|
|
7
|
-
|
|
8
4
|
//#region scripts/postinstall.ts
|
|
9
5
|
const root = (0, node_path.resolve)(__dirname, "../..");
|
|
10
|
-
const
|
|
11
|
-
const repo = "https://github.com/let-value/translate";
|
|
12
|
-
const tag = `v${pkg.version}`;
|
|
13
|
-
const url = `${repo}/releases/download/${tag}/${require_binary.binaryName}`;
|
|
6
|
+
const url = `https://github.com/let-value/translate/releases/download/${`v${JSON.parse((0, node_fs.readFileSync)((0, node_path.resolve)(root, "package.json"), "utf8")).version}`}/${require_binary.binaryName}`;
|
|
14
7
|
async function downloadBinary() {
|
|
15
8
|
try {
|
|
16
9
|
const response = await fetch(url, {
|
|
@@ -35,5 +28,4 @@ async function main() {
|
|
|
35
28
|
main().catch((error) => {
|
|
36
29
|
console.warn(`Binary download failed: ${String(error)}`);
|
|
37
30
|
});
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
31
|
+
//#endregion
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as binaryPath, r as platform, t as binaryName } from "../binary-B9VjMzKh.mjs";
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
3
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
-
|
|
5
4
|
//#region scripts/postinstall.ts
|
|
6
5
|
const root = resolve(import.meta.dirname, "../..");
|
|
7
|
-
const
|
|
8
|
-
const repo = "https://github.com/let-value/translate";
|
|
9
|
-
const tag = `v${pkg.version}`;
|
|
10
|
-
const url = `${repo}/releases/download/${tag}/${binaryName}`;
|
|
6
|
+
const url = `https://github.com/let-value/translate/releases/download/${`v${JSON.parse(readFileSync(resolve(root, "package.json"), "utf8")).version}`}/${binaryName}`;
|
|
11
7
|
async function downloadBinary() {
|
|
12
8
|
try {
|
|
13
9
|
const response = await fetch(url, {
|
|
@@ -32,6 +28,5 @@ async function main() {
|
|
|
32
28
|
main().catch((error) => {
|
|
33
29
|
console.warn(`Binary download failed: ${String(error)}`);
|
|
34
30
|
});
|
|
35
|
-
|
|
36
31
|
//#endregion
|
|
37
|
-
export {
|
|
32
|
+
export {};
|
package/dist/src/index.cjs
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let node_path = require("node:path");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
//#region ../extract/dist/exclude-CpTGSisK.mjs
|
|
4
|
+
function normalizedPath(path) {
|
|
5
|
+
return path.replace(/\\/g, "/");
|
|
6
|
+
}
|
|
7
|
+
function isInsideDirectory(path, directory) {
|
|
8
|
+
return normalizedPath(path).split("/").some((part) => part === directory);
|
|
9
|
+
}
|
|
10
|
+
const defaultExclude = {
|
|
11
|
+
modules: ({ path }) => isInsideDirectory(path, "node_modules"),
|
|
12
|
+
dist: ({ path }) => isInsideDirectory(path, "dist"),
|
|
13
|
+
build: ({ path }) => isInsideDirectory(path, "build"),
|
|
14
|
+
types: ({ import: imp }) => imp?.typeOnly ?? false
|
|
15
|
+
};
|
|
16
|
+
const defaultExcludes = Object.values(defaultExclude);
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region ../extract/dist/src/static.mjs
|
|
6
19
|
function core(...props) {
|
|
7
20
|
return { static: {
|
|
8
21
|
name: "core",
|
|
@@ -27,24 +40,22 @@ function cleanup(...props) {
|
|
|
27
40
|
props
|
|
28
41
|
} };
|
|
29
42
|
}
|
|
30
|
-
|
|
31
43
|
//#endregion
|
|
32
|
-
//#region ../extract/src/
|
|
44
|
+
//#region ../extract/dist/src/core.mjs
|
|
33
45
|
const defaultPlugins = {
|
|
34
46
|
core,
|
|
35
47
|
po,
|
|
36
48
|
cleanup
|
|
37
49
|
};
|
|
38
50
|
const defaultDestination = ({ entrypoint, locale }) => (0, node_path.join)((0, node_path.dirname)(entrypoint), "translations", `${(0, node_path.basename)(entrypoint, (0, node_path.extname)(entrypoint))}.${locale}.po`);
|
|
39
|
-
const defaultExclude = [
|
|
40
|
-
/(?:^|[\\/])node_modules(?:[\\/]|$)/,
|
|
41
|
-
/(?:^|[\\/])dist(?:[\\/]|$)/,
|
|
42
|
-
/(?:^|[\\/])build(?:[\\/]|$)/
|
|
43
|
-
];
|
|
44
51
|
function normalizeExclude(exclude) {
|
|
45
52
|
if (!exclude) return [];
|
|
46
53
|
return Array.isArray(exclude) ? exclude : [exclude];
|
|
47
54
|
}
|
|
55
|
+
function resolveExcludes(exclude) {
|
|
56
|
+
if (typeof exclude === "function") return exclude(defaultExclude);
|
|
57
|
+
return [...defaultExcludes, ...normalizeExclude(exclude)];
|
|
58
|
+
}
|
|
48
59
|
function resolveEntrypoint(ep) {
|
|
49
60
|
if (typeof ep === "string") return { entrypoint: ep };
|
|
50
61
|
const { entrypoint, destination, obsolete, walk, exclude } = ep;
|
|
@@ -53,7 +64,7 @@ function resolveEntrypoint(ep) {
|
|
|
53
64
|
destination,
|
|
54
65
|
obsolete,
|
|
55
66
|
walk,
|
|
56
|
-
exclude: exclude ?
|
|
67
|
+
exclude: exclude ? resolveExcludes(exclude) : void 0
|
|
57
68
|
};
|
|
58
69
|
}
|
|
59
70
|
function resolvePlugins(user) {
|
|
@@ -67,24 +78,21 @@ function resolvePlugins(user) {
|
|
|
67
78
|
*/
|
|
68
79
|
function defineConfig(config) {
|
|
69
80
|
const defaultLocale = config.defaultLocale ?? "en";
|
|
70
|
-
const plugins = resolvePlugins(config.plugins);
|
|
71
|
-
const entrypoints = (Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints]).map(resolveEntrypoint);
|
|
72
81
|
return {
|
|
73
|
-
plugins,
|
|
74
|
-
entrypoints,
|
|
82
|
+
plugins: resolvePlugins(config.plugins),
|
|
83
|
+
entrypoints: (Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints]).map(resolveEntrypoint),
|
|
75
84
|
defaultLocale,
|
|
76
85
|
locales: config.locales ?? [defaultLocale],
|
|
77
86
|
destination: config.destination ?? defaultDestination,
|
|
78
87
|
obsolete: config.obsolete ?? "mark",
|
|
79
88
|
walk: config.walk ?? true,
|
|
80
89
|
logLevel: config.logLevel ?? "info",
|
|
81
|
-
exclude:
|
|
90
|
+
exclude: resolveExcludes(config.exclude)
|
|
82
91
|
};
|
|
83
92
|
}
|
|
84
|
-
|
|
85
93
|
//#endregion
|
|
86
94
|
exports.cleanup = cleanup;
|
|
87
95
|
exports.core = core;
|
|
88
96
|
exports.defineConfig = defineConfig;
|
|
89
97
|
exports.po = po;
|
|
90
|
-
exports.react = react;
|
|
98
|
+
exports.react = react;
|