tombi 0.4.13 → 0.4.15
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/bin/tombi +94 -0
- package/package.json +9 -9
package/bin/tombi
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { platform, arch, env, version, release } = process;
|
|
3
|
+
const { execSync } = require("node:child_process");
|
|
4
|
+
|
|
5
|
+
function isMusl() {
|
|
6
|
+
let stderr;
|
|
7
|
+
try {
|
|
8
|
+
stderr = execSync("ldd --version", {
|
|
9
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
10
|
+
});
|
|
11
|
+
} catch (err) {
|
|
12
|
+
stderr = err.stderr;
|
|
13
|
+
}
|
|
14
|
+
if (stderr.indexOf("musl") > -1) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const PLATFORMS = {
|
|
21
|
+
win32: {
|
|
22
|
+
x64: "@tombi-toml/cli-win32-x64/tombi.exe",
|
|
23
|
+
arm64: "@tombi-toml/cli-win32-arm64/tombi.exe",
|
|
24
|
+
},
|
|
25
|
+
darwin: {
|
|
26
|
+
x64: "@tombi-toml/cli-darwin-x64/tombi",
|
|
27
|
+
arm64: "@tombi-toml/cli-darwin-arm64/tombi",
|
|
28
|
+
},
|
|
29
|
+
linux: {
|
|
30
|
+
x64: "@tombi-toml/cli-linux-x64/tombi",
|
|
31
|
+
arm64: "@tombi-toml/cli-linux-arm64/tombi",
|
|
32
|
+
},
|
|
33
|
+
"linux-musl": {
|
|
34
|
+
x64: "@tombi-toml/cli-linux-x64-musl/tombi",
|
|
35
|
+
arm64: "@tombi-toml/cli-linux-arm64-musl/tombi",
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const binPath =
|
|
40
|
+
env.TOMBI_BINARY ||
|
|
41
|
+
(platform === "linux" && isMusl()
|
|
42
|
+
? PLATFORMS?.["linux-musl"]?.[arch]
|
|
43
|
+
: PLATFORMS?.[platform]?.[arch]);
|
|
44
|
+
|
|
45
|
+
if (binPath) {
|
|
46
|
+
const packageManager = detectPackageManager();
|
|
47
|
+
const result = require("node:child_process").spawnSync(
|
|
48
|
+
require.resolve(binPath),
|
|
49
|
+
process.argv.slice(2),
|
|
50
|
+
{
|
|
51
|
+
shell: false,
|
|
52
|
+
stdio: "inherit",
|
|
53
|
+
env: {
|
|
54
|
+
...env,
|
|
55
|
+
JS_RUNTIME_VERSION: version,
|
|
56
|
+
JS_RUNTIME_NAME: release.name,
|
|
57
|
+
...(packageManager != null
|
|
58
|
+
? { NODE_PACKAGE_MANAGER: packageManager }
|
|
59
|
+
: {}),
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
if (result.error) {
|
|
65
|
+
throw result.error;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
process.exitCode = result.status;
|
|
69
|
+
} else {
|
|
70
|
+
console.error(
|
|
71
|
+
"The Tombi CLI package doesn't ship with prebuilt binaries for your platform yet. " +
|
|
72
|
+
"Please read the documentation at https://tombi-toml.github.io/tombi/docs/installation",
|
|
73
|
+
);
|
|
74
|
+
process.exitCode = 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* NPM, Yarn, and other package manager set the `npm_config_user_agent`. It has the following format:
|
|
79
|
+
*
|
|
80
|
+
* ```
|
|
81
|
+
* "npm/8.3.0 node/v16.13.2 win32 x64 workspaces/false
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @returns The package manager string (`npm/8.3.0`) or null if the user agent string isn't set.
|
|
85
|
+
*/
|
|
86
|
+
function detectPackageManager() {
|
|
87
|
+
const userAgent = env.npm_config_user_agent;
|
|
88
|
+
|
|
89
|
+
if (userAgent == null) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return userAgent.split(" ")[0];
|
|
94
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tombi",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"description": "🦅 TOML Toolkit 🦅",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tombi": "bin/tombi"
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"provenance": true
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"@tombi-toml/cli-win32-x64": "0.4.
|
|
44
|
-
"@tombi-toml/cli-win32-arm64": "0.4.
|
|
45
|
-
"@tombi-toml/cli-darwin-x64": "0.4.
|
|
46
|
-
"@tombi-toml/cli-darwin-arm64": "0.4.
|
|
47
|
-
"@tombi-toml/cli-linux-x64": "0.4.
|
|
48
|
-
"@tombi-toml/cli-linux-arm64": "0.4.
|
|
49
|
-
"@tombi-toml/cli-linux-x64-musl": "0.4.
|
|
50
|
-
"@tombi-toml/cli-linux-arm64-musl": "0.4.
|
|
43
|
+
"@tombi-toml/cli-win32-x64": "0.4.15",
|
|
44
|
+
"@tombi-toml/cli-win32-arm64": "0.4.15",
|
|
45
|
+
"@tombi-toml/cli-darwin-x64": "0.4.15",
|
|
46
|
+
"@tombi-toml/cli-darwin-arm64": "0.4.15",
|
|
47
|
+
"@tombi-toml/cli-linux-x64": "0.4.15",
|
|
48
|
+
"@tombi-toml/cli-linux-arm64": "0.4.15",
|
|
49
|
+
"@tombi-toml/cli-linux-x64-musl": "0.4.15",
|
|
50
|
+
"@tombi-toml/cli-linux-arm64-musl": "0.4.15"
|
|
51
51
|
}
|
|
52
52
|
}
|