super-release 0.2.1 → 0.3.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/npm/bin/super-release.js +88 -6
- package/package.json +2 -3
- package/npm/install.js +0 -69
package/npm/bin/super-release.js
CHANGED
|
@@ -1,20 +1,102 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { execFileSync } from "node:child_process";
|
|
4
|
+
import {
|
|
5
|
+
existsSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
createWriteStream,
|
|
8
|
+
unlinkSync,
|
|
9
|
+
chmodSync,
|
|
10
|
+
} from "node:fs";
|
|
4
11
|
import { dirname, join } from "node:path";
|
|
5
|
-
import { platform } from "node:os";
|
|
12
|
+
import { platform, arch, tmpdir } from "node:os";
|
|
13
|
+
import { get } from "node:https";
|
|
14
|
+
import { pipeline } from "node:stream/promises";
|
|
6
15
|
import { fileURLToPath } from "node:url";
|
|
16
|
+
import pkg from "../../package.json" with { type: "json" };
|
|
7
17
|
|
|
8
18
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
const
|
|
19
|
+
const binPath = join(
|
|
10
20
|
__dirname,
|
|
11
21
|
platform() === "win32" ? "super-release.exe" : "super-release"
|
|
12
22
|
);
|
|
13
23
|
|
|
24
|
+
if (!existsSync(binPath)) {
|
|
25
|
+
await install();
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
try {
|
|
15
|
-
execFileSync(
|
|
29
|
+
execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
30
|
+
process.exit(0);
|
|
16
31
|
} catch (err) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
process.exit(err.status ?? 1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function install() {
|
|
36
|
+
const REPO = "bowlingx/super-release";
|
|
37
|
+
const PLATFORM_MAP = {
|
|
38
|
+
"linux-x64": "super-release-linux-x86_64",
|
|
39
|
+
"linux-arm64": "super-release-linux-aarch64",
|
|
40
|
+
"darwin-x64": "super-release-darwin-x86_64",
|
|
41
|
+
"darwin-arm64": "super-release-darwin-aarch64",
|
|
42
|
+
"win32-x64": "super-release-windows-x86_64",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const { version } = pkg;
|
|
46
|
+
const key = `${platform()}-${arch()}`;
|
|
47
|
+
const artifact = PLATFORM_MAP[key];
|
|
48
|
+
|
|
49
|
+
if (!artifact) {
|
|
50
|
+
console.error(
|
|
51
|
+
`Unsupported platform: ${key}. Supported: ${Object.keys(PLATFORM_MAP).join(", ")}`
|
|
52
|
+
);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const isWindows = platform() === "win32";
|
|
57
|
+
const ext = isWindows ? "zip" : "tar.gz";
|
|
58
|
+
const url = `https://github.com/${REPO}/releases/download/v${version}/${artifact}.${ext}`;
|
|
59
|
+
console.error(`Downloading super-release v${version} for ${key}...`);
|
|
60
|
+
|
|
61
|
+
mkdirSync(__dirname, { recursive: true });
|
|
62
|
+
|
|
63
|
+
const tmpFile = join(tmpdir(), `super-release-${Date.now()}.${ext}`);
|
|
64
|
+
try {
|
|
65
|
+
const response = await download(url);
|
|
66
|
+
await pipeline(response, createWriteStream(tmpFile));
|
|
67
|
+
|
|
68
|
+
if (isWindows) {
|
|
69
|
+
execFileSync("powershell", ["-Command", `Expand-Archive -Path '${tmpFile}' -DestinationPath '${__dirname}' -Force`], { stdio: "ignore" });
|
|
70
|
+
} else {
|
|
71
|
+
execFileSync("tar", ["xzf", tmpFile, "-C", __dirname], { stdio: "ignore" });
|
|
72
|
+
chmodSync(binPath, 0o755);
|
|
73
|
+
}
|
|
74
|
+
unlinkSync(tmpFile);
|
|
75
|
+
console.error(`Installed super-release v${version}`);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
console.error(`Failed to install super-release: ${err.message}`);
|
|
78
|
+
console.error(
|
|
79
|
+
`Install manually from: https://github.com/${REPO}/releases/tag/v${version}`
|
|
80
|
+
);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function download(url) {
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
get(url, (res) => {
|
|
88
|
+
if (
|
|
89
|
+
res.statusCode >= 300 &&
|
|
90
|
+
res.statusCode < 400 &&
|
|
91
|
+
res.headers.location
|
|
92
|
+
) {
|
|
93
|
+
return download(res.headers.location).then(resolve, reject);
|
|
94
|
+
}
|
|
95
|
+
if (res.statusCode !== 200) {
|
|
96
|
+
reject(new Error(`Download failed: HTTP ${res.statusCode}`));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
resolve(res);
|
|
100
|
+
}).on("error", reject);
|
|
101
|
+
});
|
|
20
102
|
}
|
package/package.json
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"npm/bin",
|
|
11
|
-
"npm/install.js",
|
|
12
11
|
"README.md"
|
|
13
12
|
],
|
|
14
13
|
"keywords": [
|
|
@@ -29,8 +28,8 @@
|
|
|
29
28
|
"url": "git+https://github.com/BowlingX/super-release.git"
|
|
30
29
|
},
|
|
31
30
|
"type": "module",
|
|
32
|
-
"version": "0.
|
|
31
|
+
"version": "0.3.1",
|
|
33
32
|
"scripts": {
|
|
34
|
-
"
|
|
33
|
+
"super-release": "node npm/bin/super-release.js"
|
|
35
34
|
}
|
|
36
35
|
}
|
package/npm/install.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { execSync } from "node:child_process";
|
|
2
|
-
import { createWriteStream, existsSync, mkdirSync, unlinkSync, chmodSync, readFileSync } from "node:fs";
|
|
3
|
-
import { join, dirname } from "node:path";
|
|
4
|
-
import { tmpdir, platform, arch } from "node:os";
|
|
5
|
-
import { get } from "node:https";
|
|
6
|
-
import { pipeline } from "node:stream/promises";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
|
|
9
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
const { version } = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf8"));
|
|
11
|
-
const REPO = "bowlingx/super-release";
|
|
12
|
-
|
|
13
|
-
const PLATFORM_MAP = {
|
|
14
|
-
"linux-x64": "super-release-linux-x86_64",
|
|
15
|
-
"linux-arm64": "super-release-linux-aarch64",
|
|
16
|
-
"darwin-x64": "super-release-darwin-x86_64",
|
|
17
|
-
"darwin-arm64": "super-release-darwin-aarch64",
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
function download(url) {
|
|
21
|
-
return new Promise((resolve, reject) => {
|
|
22
|
-
get(url, (res) => {
|
|
23
|
-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
24
|
-
return download(res.headers.location).then(resolve, reject);
|
|
25
|
-
}
|
|
26
|
-
if (res.statusCode !== 200) {
|
|
27
|
-
reject(new Error(`Download failed: HTTP ${res.statusCode}`));
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
resolve(res);
|
|
31
|
-
}).on("error", reject);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const key = `${platform()}-${arch()}`;
|
|
36
|
-
const artifact = PLATFORM_MAP[key];
|
|
37
|
-
|
|
38
|
-
if (!artifact) {
|
|
39
|
-
console.error(
|
|
40
|
-
`Unsupported platform: ${key}. Supported: ${Object.keys(PLATFORM_MAP).join(", ")}`
|
|
41
|
-
);
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const binDir = join(__dirname, "bin");
|
|
46
|
-
const binPath = join(binDir, "super-release");
|
|
47
|
-
|
|
48
|
-
if (existsSync(binPath)) {
|
|
49
|
-
process.exit(0);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
mkdirSync(binDir, { recursive: true });
|
|
53
|
-
|
|
54
|
-
const url = `https://github.com/${REPO}/releases/download/v${version}/${artifact}.tar.gz`;
|
|
55
|
-
console.log(`Downloading super-release v${version} for ${key}...`);
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
const response = await download(url);
|
|
59
|
-
const tmpFile = join(tmpdir(), `super-release-${Date.now()}.tar.gz`);
|
|
60
|
-
await pipeline(response, createWriteStream(tmpFile));
|
|
61
|
-
execSync(`tar xzf ${tmpFile} -C ${binDir}`, { stdio: "ignore" });
|
|
62
|
-
unlinkSync(tmpFile);
|
|
63
|
-
chmodSync(binPath, 0o755);
|
|
64
|
-
console.log(`Installed super-release v${version}`);
|
|
65
|
-
} catch (err) {
|
|
66
|
-
console.error(`Failed to install super-release: ${err.message}`);
|
|
67
|
-
console.error(`You can install manually from: https://github.com/${REPO}/releases/tag/v${version}`);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|