shellbook 0.2.2

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.
Files changed (3) hide show
  1. package/README.md +15 -0
  2. package/install.js +65 -0
  3. package/package.json +17 -0
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Shellbook
2
+
3
+ This npm package is only the public installer shim for Shellbook.
4
+
5
+ ```bash
6
+ npx shellbook@latest
7
+ ```
8
+
9
+ It downloads and runs `https://shellbook.co/install.sh`, which installs the prebuilt Shellbook binary and the `tmux` dependency needed for popup mode.
10
+
11
+ Invite links pass through:
12
+
13
+ ```bash
14
+ npx shellbook@latest -- --invite INVITE_ID
15
+ ```
package/install.js ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawn } = require("node:child_process");
5
+ const http = require("node:http");
6
+ const https = require("node:https");
7
+
8
+ const installURL = process.env.SHELLBOOK_INSTALL_URL || "https://shellbook.co/install.sh";
9
+ const args = process.argv.slice(2);
10
+
11
+ function clientFor(url) {
12
+ return url.startsWith("http://") ? http : https;
13
+ }
14
+
15
+ function fetchScript(url, redirects = 0) {
16
+ return new Promise((resolve, reject) => {
17
+ const request = clientFor(url).get(url, response => {
18
+ const status = response.statusCode || 0;
19
+ const location = response.headers.location;
20
+ if (status >= 300 && status < 400 && location) {
21
+ response.resume();
22
+ if (redirects >= 5) {
23
+ reject(new Error("too many redirects while fetching installer"));
24
+ return;
25
+ }
26
+ resolve(fetchScript(new URL(location, url).toString(), redirects + 1));
27
+ return;
28
+ }
29
+ if (status < 200 || status >= 300) {
30
+ response.resume();
31
+ reject(new Error(`installer download failed with HTTP ${status}`));
32
+ return;
33
+ }
34
+ resolve(response);
35
+ });
36
+ request.setTimeout(30000, () => {
37
+ request.destroy(new Error("installer download timed out"));
38
+ });
39
+ request.on("error", reject);
40
+ });
41
+ }
42
+
43
+ async function main() {
44
+ const script = await fetchScript(installURL);
45
+ const child = spawn("sh", ["-s", "--", ...args], {
46
+ stdio: ["pipe", "inherit", "inherit"]
47
+ });
48
+ script.pipe(child.stdin);
49
+ child.on("error", error => {
50
+ console.error(`Shellbook installer failed to start: ${error.message}`);
51
+ process.exit(1);
52
+ });
53
+ child.on("exit", (code, signal) => {
54
+ if (signal) {
55
+ process.kill(process.pid, signal);
56
+ return;
57
+ }
58
+ process.exit(code || 0);
59
+ });
60
+ }
61
+
62
+ main().catch(error => {
63
+ console.error(`Shellbook installer failed: ${error.message}`);
64
+ process.exit(1);
65
+ });
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "shellbook",
3
+ "version": "0.2.2",
4
+ "description": "Installer for the Shellbook terminal social client.",
5
+ "bin": {
6
+ "shellbook": "install.js"
7
+ },
8
+ "files": [
9
+ "install.js",
10
+ "README.md"
11
+ ],
12
+ "license": "UNLICENSED",
13
+ "private": false,
14
+ "engines": {
15
+ "node": ">=18"
16
+ }
17
+ }