Skip to content

Commit 1d6421b

Browse files
committed
feat: add bin list command
1 parent 9971329 commit 1d6421b

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ There is an extra subcommand: `cloudflared bin`. You can use it to manage the cl
4747
cloudflared bin : Prints the path to the binary
4848
cloudflared bin remove : Removes the binary
4949
cloudflared bin install [version] : Installs the binary
50+
cloudflared bin list : Lists 30 latest releases
5051
cloudflared bin help : Prints this help message
5152
Examples:
5253
cloudflared bin install : Installs the latest version of cloudflared

src/index.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from "node:fs";
2+
import https from "node:https";
23
import { spawn } from "node:child_process";
34
import { bin, install } from "./lib.js";
45

@@ -25,10 +26,39 @@ export async function main(): Promise<void> {
2526
}
2627
return;
2728
}
29+
if (args[1] === "list") {
30+
https.get(
31+
{
32+
hostname: "api.github.com",
33+
path: "/repos/cloudflare/cloudflared/releases",
34+
headers: {
35+
"user-agent": "node-cloudflared",
36+
},
37+
},
38+
(res) => {
39+
let data = "";
40+
res.on("data", (chunk) => {
41+
data += chunk;
42+
});
43+
res.on("end", () => {
44+
const releases = JSON.parse(data);
45+
for (const release of releases) {
46+
console.log(
47+
`${release.tag_name.padEnd(10)} (${release.published_at}) [${
48+
release.html_url
49+
}]`,
50+
);
51+
}
52+
});
53+
},
54+
);
55+
return;
56+
}
2857
if (args[1] === "help" || args[1] === "--help" || args[1] === "-h") {
2958
console.log(`cloudflared bin : Prints the path to the binary`);
3059
console.log(`cloudflared bin remove : Removes the binary`);
3160
console.log(`cloudflared bin install [version] : Installs the binary`);
61+
console.log(`cloudflared bin list : Lists 30 latest releases`);
3262
console.log(`cloudflared bin help : Prints this help message`);
3363
console.log(`Examples:`);
3464
console.log(

0 commit comments

Comments
 (0)