@circlesac/oneup 0.0.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/bin/oneup +3 -0
- package/install.js +74 -0
- package/package.json +27 -0
package/bin/oneup
ADDED
package/install.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const https = require("https");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const { execSync } = require("child_process");
|
|
5
|
+
|
|
6
|
+
const { version } = require("./package.json");
|
|
7
|
+
|
|
8
|
+
const REPO = "circlesac/oneup";
|
|
9
|
+
|
|
10
|
+
const PLATFORMS = {
|
|
11
|
+
"darwin-x64": "oneup-x86_64-apple-darwin",
|
|
12
|
+
"darwin-arm64": "oneup-aarch64-apple-darwin",
|
|
13
|
+
"linux-x64": "oneup-x86_64-unknown-linux-gnu",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
async function download(url) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
https.get(url, (res) => {
|
|
19
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
20
|
+
download(res.headers.location).then(resolve).catch(reject);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (res.statusCode !== 200) {
|
|
24
|
+
reject(new Error(`HTTP ${res.statusCode}`));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const chunks = [];
|
|
28
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
29
|
+
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
30
|
+
res.on("error", reject);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function main() {
|
|
36
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
37
|
+
const artifact = PLATFORMS[platform];
|
|
38
|
+
|
|
39
|
+
if (!artifact) {
|
|
40
|
+
console.error(`Unsupported platform: ${platform}`);
|
|
41
|
+
console.error(`Supported: ${Object.keys(PLATFORMS).join(", ")}`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const url = `https://github.com/${REPO}/releases/download/v${version}/${artifact}.tar.gz`;
|
|
46
|
+
console.log(`Downloading ${artifact}...`);
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const data = await download(url);
|
|
50
|
+
const binDir = path.join(__dirname, "bin");
|
|
51
|
+
|
|
52
|
+
if (!fs.existsSync(binDir)) {
|
|
53
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Extract tar.gz
|
|
57
|
+
const tmpFile = path.join(binDir, "tmp.tar.gz");
|
|
58
|
+
fs.writeFileSync(tmpFile, data);
|
|
59
|
+
|
|
60
|
+
execSync(`tar xzf tmp.tar.gz`, { cwd: binDir });
|
|
61
|
+
fs.unlinkSync(tmpFile);
|
|
62
|
+
|
|
63
|
+
// Make executable
|
|
64
|
+
const binPath = path.join(binDir, "oneup");
|
|
65
|
+
fs.chmodSync(binPath, 0o755);
|
|
66
|
+
|
|
67
|
+
console.log(`Installed oneup v${version}`);
|
|
68
|
+
} catch (err) {
|
|
69
|
+
console.error(`Failed to install: ${err.message}`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@circlesac/oneup",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "CalVer-based version management for npm packages",
|
|
5
|
+
"bin": {
|
|
6
|
+
"oneup": "bin/oneup"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node install.js"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/circlesac/oneup.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"calver",
|
|
17
|
+
"version",
|
|
18
|
+
"npm",
|
|
19
|
+
"cli"
|
|
20
|
+
],
|
|
21
|
+
"author": "",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/circlesac/oneup/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/circlesac/oneup#readme"
|
|
27
|
+
}
|