backlog.md 0.1.23 → 0.1.25
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/cli.js +26 -104
- package/package.json +8 -2
- package/getBinaryName.cjs +0 -39
package/cli.js
CHANGED
|
@@ -1,115 +1,37 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { spawn } = require("node:child_process");
|
|
4
|
-
const { join } = require("node:path");
|
|
5
|
-
const fs = require("node:fs");
|
|
6
|
-
const https = require("node:https");
|
|
7
|
-
const { createWriteStream, chmodSync } = require("node:fs");
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
https
|
|
22
|
-
.get(url, (response) => {
|
|
23
|
-
if (response.statusCode === 302 || response.statusCode === 301) {
|
|
24
|
-
// Follow redirect
|
|
25
|
-
https
|
|
26
|
-
.get(response.headers.location, (redirectResponse) => {
|
|
27
|
-
if (redirectResponse.statusCode !== 200) {
|
|
28
|
-
reject(new Error(`Failed to download: ${redirectResponse.statusCode}`));
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const file = createWriteStream(binaryPath);
|
|
33
|
-
redirectResponse.pipe(file);
|
|
34
|
-
|
|
35
|
-
file.on("finish", () => {
|
|
36
|
-
file.close();
|
|
37
|
-
// Make executable on Unix
|
|
38
|
-
if (process.platform !== "win32") {
|
|
39
|
-
chmodSync(binaryPath, 0o755);
|
|
40
|
-
}
|
|
41
|
-
console.log("Download complete!");
|
|
42
|
-
resolve();
|
|
43
|
-
});
|
|
44
|
-
})
|
|
45
|
-
.on("error", reject);
|
|
46
|
-
} else if (response.statusCode !== 200) {
|
|
47
|
-
reject(new Error(`Failed to download: ${response.statusCode}`));
|
|
48
|
-
} else {
|
|
49
|
-
const file = createWriteStream(binaryPath);
|
|
50
|
-
response.pipe(file);
|
|
51
|
-
|
|
52
|
-
file.on("finish", () => {
|
|
53
|
-
file.close();
|
|
54
|
-
// Make executable on Unix
|
|
55
|
-
if (process.platform !== "win32") {
|
|
56
|
-
chmodSync(binaryPath, 0o755);
|
|
57
|
-
}
|
|
58
|
-
console.log("Download complete!");
|
|
59
|
-
resolve();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
.on("error", reject);
|
|
64
|
-
});
|
|
5
|
+
// Resolve binary from platform-specific package
|
|
6
|
+
const platform = process.platform;
|
|
7
|
+
const arch = process.arch;
|
|
8
|
+
const packageName = `backlog.md-${platform}-${arch}`;
|
|
9
|
+
let binaryPath;
|
|
10
|
+
try {
|
|
11
|
+
binaryPath = require.resolve(`${packageName}/backlog${platform === "win32" ? ".exe" : ""}`);
|
|
12
|
+
} catch {
|
|
13
|
+
console.error(`Binary package not installed for ${platform}-${arch}.`);
|
|
14
|
+
process.exit(1);
|
|
65
15
|
}
|
|
66
16
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
17
|
+
// Spawn the binary with all arguments
|
|
18
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
19
|
+
stdio: "inherit",
|
|
20
|
+
windowsHide: true,
|
|
21
|
+
});
|
|
72
22
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
23
|
+
// Handle exit
|
|
24
|
+
child.on("exit", (code) => {
|
|
25
|
+
process.exit(code || 0);
|
|
26
|
+
});
|
|
77
27
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
28
|
+
// Handle errors
|
|
29
|
+
child.on("error", (err) => {
|
|
30
|
+
if (err.code === "ENOENT") {
|
|
31
|
+
console.error(`Binary not found: ${binaryPath}`);
|
|
32
|
+
console.error(`Please ensure you have the correct version for your platform (${process.platform}-${process.arch})`);
|
|
33
|
+
} else {
|
|
34
|
+
console.error("Failed to start backlog:", err);
|
|
87
35
|
}
|
|
88
|
-
|
|
89
|
-
// Spawn the binary with all arguments
|
|
90
|
-
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
91
|
-
stdio: "inherit",
|
|
92
|
-
windowsHide: true,
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// Handle exit
|
|
96
|
-
child.on("exit", (code) => {
|
|
97
|
-
process.exit(code || 0);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Handle errors
|
|
101
|
-
child.on("error", (err) => {
|
|
102
|
-
if (err.code === "ENOENT") {
|
|
103
|
-
console.error(`Binary not found: ${binaryPath}`);
|
|
104
|
-
console.error(`Please delete ${binDir} and try again.`);
|
|
105
|
-
} else {
|
|
106
|
-
console.error("Failed to start backlog:", err);
|
|
107
|
-
}
|
|
108
|
-
process.exit(1);
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
main().catch((err) => {
|
|
113
|
-
console.error(err);
|
|
114
36
|
process.exit(1);
|
|
115
37
|
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "backlog.md",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"bin": {
|
|
5
5
|
"backlog": "cli.js"
|
|
6
6
|
},
|
|
7
|
+
"optionalDependencies": {
|
|
8
|
+
"backlog.md-linux-x64": "*",
|
|
9
|
+
"backlog.md-linux-arm64": "*",
|
|
10
|
+
"backlog.md-darwin-x64": "*",
|
|
11
|
+
"backlog.md-darwin-arm64": "*",
|
|
12
|
+
"backlog.md-windows-x64": "*"
|
|
13
|
+
},
|
|
7
14
|
"scripts": {
|
|
8
15
|
"test": "bun test",
|
|
9
16
|
"format": "biome format --write .",
|
|
@@ -44,7 +51,6 @@
|
|
|
44
51
|
],
|
|
45
52
|
"files": [
|
|
46
53
|
"cli.js",
|
|
47
|
-
"getBinaryName.cjs",
|
|
48
54
|
"package.json",
|
|
49
55
|
"README.md",
|
|
50
56
|
"LICENSE"
|
package/getBinaryName.cjs
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
function getBinaryName(platform = process.platform, arch = process.arch) {
|
|
2
|
-
let binaryName = "backlog-";
|
|
3
|
-
|
|
4
|
-
// Map Node.js platform names to Bun target names
|
|
5
|
-
switch (platform) {
|
|
6
|
-
case "linux":
|
|
7
|
-
binaryName += "bun-linux-";
|
|
8
|
-
break;
|
|
9
|
-
case "darwin":
|
|
10
|
-
binaryName += "bun-darwin-";
|
|
11
|
-
break;
|
|
12
|
-
case "win32":
|
|
13
|
-
binaryName += "bun-windows-";
|
|
14
|
-
break;
|
|
15
|
-
default:
|
|
16
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Map Node.js arch names to Bun target names
|
|
20
|
-
switch (arch) {
|
|
21
|
-
case "x64":
|
|
22
|
-
binaryName += "x64";
|
|
23
|
-
break;
|
|
24
|
-
case "arm64":
|
|
25
|
-
binaryName += "arm64";
|
|
26
|
-
break;
|
|
27
|
-
default:
|
|
28
|
-
throw new Error(`Unsupported architecture: ${arch}`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Windows executables have .exe extension
|
|
32
|
-
if (platform === "win32") {
|
|
33
|
-
binaryName += ".exe";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return binaryName;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = { getBinaryName };
|