@tombi-toml/cli 0.0.0-dev → 1.5.10
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/LICENSE +21 -0
- package/bin/tombi +118 -0
- package/package.json +41 -4
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 tombi-toml
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/tombi
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { platform, arch, env, version, release } = process;
|
|
3
|
+
const { execSync } = require("node:child_process");
|
|
4
|
+
// Published as `@tombi-toml/cli`, `tombi`, and the former `@tombi-toml/tombi`
|
|
5
|
+
// (the release workflow only rewrites `name`), so read it rather than
|
|
6
|
+
// hard-coding one.
|
|
7
|
+
const { name: packageName } = require("../package.json");
|
|
8
|
+
|
|
9
|
+
function isMusl() {
|
|
10
|
+
let stderr;
|
|
11
|
+
try {
|
|
12
|
+
stderr = execSync("ldd --version", {
|
|
13
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
14
|
+
});
|
|
15
|
+
} catch (err) {
|
|
16
|
+
stderr = err.stderr;
|
|
17
|
+
}
|
|
18
|
+
if (stderr.indexOf("musl") > -1) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const PLATFORMS = {
|
|
25
|
+
win32: {
|
|
26
|
+
x64: "@tombi-toml/cli-win32-x64/tombi.exe",
|
|
27
|
+
arm64: "@tombi-toml/cli-win32-arm64/tombi.exe",
|
|
28
|
+
},
|
|
29
|
+
darwin: {
|
|
30
|
+
x64: "@tombi-toml/cli-darwin-x64/tombi",
|
|
31
|
+
arm64: "@tombi-toml/cli-darwin-arm64/tombi",
|
|
32
|
+
},
|
|
33
|
+
linux: {
|
|
34
|
+
x64: "@tombi-toml/cli-linux-x64/tombi",
|
|
35
|
+
arm64: "@tombi-toml/cli-linux-arm64/tombi",
|
|
36
|
+
},
|
|
37
|
+
"linux-musl": {
|
|
38
|
+
x64: "@tombi-toml/cli-linux-x64-musl/tombi",
|
|
39
|
+
arm64: "@tombi-toml/cli-linux-arm64-musl/tombi",
|
|
40
|
+
},
|
|
41
|
+
// "sunos" matches both Oracle Solaris and illumos, but we only publish
|
|
42
|
+
// binaries on illumos, not on Solaris. There doesn't appear to be a way to
|
|
43
|
+
// distinguish between the two over here.
|
|
44
|
+
sunos: {
|
|
45
|
+
x64: "@tombi-toml/cli-sunos-x64/tombi",
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const binPath =
|
|
50
|
+
env.TOMBI_BINARY ||
|
|
51
|
+
(platform === "linux" && isMusl()
|
|
52
|
+
? PLATFORMS?.["linux-musl"]?.[arch]
|
|
53
|
+
: PLATFORMS?.[platform]?.[arch]);
|
|
54
|
+
|
|
55
|
+
if (binPath) {
|
|
56
|
+
let resolvedBinPath;
|
|
57
|
+
try {
|
|
58
|
+
resolvedBinPath = require.resolve(binPath);
|
|
59
|
+
} catch {
|
|
60
|
+
console.error(
|
|
61
|
+
`The Tombi CLI binary "${binPath}" could not be found. ` +
|
|
62
|
+
"The platform-specific optional package may not be installed. " +
|
|
63
|
+
`Please reinstall ${packageName} with optional dependencies enabled.`,
|
|
64
|
+
);
|
|
65
|
+
process.exitCode = 1;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (resolvedBinPath) {
|
|
69
|
+
const packageManager = detectPackageManager();
|
|
70
|
+
const result = require("node:child_process").spawnSync(
|
|
71
|
+
resolvedBinPath,
|
|
72
|
+
process.argv.slice(2),
|
|
73
|
+
{
|
|
74
|
+
shell: false,
|
|
75
|
+
stdio: "inherit",
|
|
76
|
+
env: {
|
|
77
|
+
...env,
|
|
78
|
+
JS_RUNTIME_VERSION: version,
|
|
79
|
+
JS_RUNTIME_NAME: release.name,
|
|
80
|
+
...(packageManager != null
|
|
81
|
+
? { NODE_PACKAGE_MANAGER: packageManager }
|
|
82
|
+
: {}),
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
if (result.error) {
|
|
88
|
+
throw result.error;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
process.exitCode = result.status;
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
console.error(
|
|
95
|
+
"The Tombi CLI package doesn't ship with prebuilt binaries for your platform yet. " +
|
|
96
|
+
"Please read the documentation at https://tombi-toml.github.io/tombi/docs/installation",
|
|
97
|
+
);
|
|
98
|
+
process.exitCode = 1;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* NPM, Yarn, and other package manager set the `npm_config_user_agent`. It has the following format:
|
|
103
|
+
*
|
|
104
|
+
* ```
|
|
105
|
+
* "npm/8.3.0 node/v16.13.2 win32 x64 workspaces/false
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @returns The package manager string (`npm/8.3.0`) or null if the user agent string isn't set.
|
|
109
|
+
*/
|
|
110
|
+
function detectPackageManager() {
|
|
111
|
+
const userAgent = env.npm_config_user_agent;
|
|
112
|
+
|
|
113
|
+
if (userAgent == null) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return userAgent.split(" ")[0];
|
|
118
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tombi-toml/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.5.10",
|
|
4
|
+
"description": "🦅 TOML Toolkit 🦅",
|
|
5
|
+
"bin": {
|
|
6
|
+
"tombi": "bin/tombi"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/tombi",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"toml",
|
|
15
|
+
"cli",
|
|
16
|
+
"formatter",
|
|
17
|
+
"linter"
|
|
18
|
+
],
|
|
19
|
+
"author": "tombi-toml",
|
|
4
20
|
"license": "MIT",
|
|
21
|
+
"private": false,
|
|
22
|
+
"homepage": "https://tombi-toml.github.io/tombi/",
|
|
5
23
|
"repository": {
|
|
6
24
|
"type": "git",
|
|
7
25
|
"url": "git+https://github.com/tombi-toml/tombi.git",
|
|
8
26
|
"directory": "typescript/@tombi-toml/cli"
|
|
9
27
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
}
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/tombi-toml/tombi/issues"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=14.0.0"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"provenance": true
|
|
37
|
+
},
|
|
38
|
+
"optionalDependencies": {
|
|
39
|
+
"@tombi-toml/cli-win32-x64": "1.5.10",
|
|
40
|
+
"@tombi-toml/cli-win32-arm64": "1.5.10",
|
|
41
|
+
"@tombi-toml/cli-darwin-x64": "1.5.10",
|
|
42
|
+
"@tombi-toml/cli-darwin-arm64": "1.5.10",
|
|
43
|
+
"@tombi-toml/cli-linux-x64": "1.5.10",
|
|
44
|
+
"@tombi-toml/cli-linux-arm64": "1.5.10",
|
|
45
|
+
"@tombi-toml/cli-linux-x64-musl": "1.5.10",
|
|
46
|
+
"@tombi-toml/cli-linux-arm64-musl": "1.5.10",
|
|
47
|
+
"@tombi-toml/cli-sunos-x64": "1.5.10"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/README.md
DELETED