@skillicinski/bo 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.
Files changed (3) hide show
  1. package/install.js +68 -0
  2. package/package.json +24 -0
  3. package/run.js +23 -0
package/install.js ADDED
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { execSync } = require('child_process');
6
+
7
+ const pkg = require('./package.json');
8
+ const version = pkg.version;
9
+
10
+ const PLATFORM_MAP = {
11
+ 'darwin-x64': 'x86_64-apple-darwin',
12
+ 'darwin-arm64': 'aarch64-apple-darwin',
13
+ 'linux-x64': 'x86_64-unknown-linux-gnu',
14
+ };
15
+
16
+ const key = `${process.platform}-${process.arch}`;
17
+ const target = PLATFORM_MAP[key];
18
+
19
+ if (!target) {
20
+ console.error(
21
+ `bo doesn't provide a pre-built binary for ${process.platform}-${process.arch}. ` +
22
+ `Build from source: cargo install bo`,
23
+ );
24
+ process.exit(0);
25
+ }
26
+
27
+ const binDir = path.join(__dirname, 'bin');
28
+ const binPath = path.join(binDir, 'bo');
29
+ const versionFile = path.join(binDir, '.bo-version');
30
+
31
+ // Re-download guard: skip if correct version is already cached
32
+ if (fs.existsSync(versionFile) && fs.existsSync(binPath)) {
33
+ const cachedVersion = fs.readFileSync(versionFile, 'utf8').trim();
34
+ if (cachedVersion === version) {
35
+ return;
36
+ }
37
+ }
38
+
39
+ fs.mkdirSync(binDir, { recursive: true });
40
+
41
+ const url = `https://github.com/skillicinski/bo/releases/download/v${version}/bo-${target}.tar.gz`;
42
+ const tarball = path.join(binDir, '.bo-tmp.tar.gz');
43
+
44
+ try {
45
+ execSync(`curl -fsSL --retry 2 -o "${tarball}" "${url}"`, { stdio: 'inherit' });
46
+ } catch (err) {
47
+ try { fs.unlinkSync(tarball); } catch (_) {}
48
+ console.error(`failed to download bo binary from ${url}: curl exit ${err.status}`);
49
+ process.exit(1);
50
+ }
51
+
52
+ try {
53
+ execSync(`tar xzf "${tarball}" -C "${binDir}"`, { stdio: 'inherit' });
54
+ fs.unlinkSync(tarball);
55
+ } catch (err) {
56
+ try { fs.unlinkSync(tarball); } catch (_) {}
57
+ console.error('failed to extract bo binary');
58
+ process.exit(1);
59
+ }
60
+
61
+ try {
62
+ fs.chmodSync(binPath, 0o755);
63
+ fs.writeFileSync(versionFile, version);
64
+ console.error(`bo v${version} installed (${target})`);
65
+ } catch (err) {
66
+ console.error(`failed to install bo: ${err.message}`);
67
+ process.exit(1);
68
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@skillicinski/bo",
3
+ "version": "0.0.1",
4
+ "description": "Collect web pages into a local markdown knowledge tree",
5
+ "bin": {
6
+ "bo": "./run.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "files": [
12
+ "install.js",
13
+ "run.js",
14
+ "package.json"
15
+ ],
16
+ "engines": {
17
+ "node": ">=16"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/skillicinski/bo.git"
22
+ },
23
+ "license": "MIT"
24
+ }
package/run.js ADDED
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+ const { spawnSync } = require('child_process');
6
+
7
+ const binPath = path.join(__dirname, 'bin', 'bo');
8
+
9
+ if (!fs.existsSync(binPath)) {
10
+ console.error(
11
+ `bo binary not found at ${binPath}. ` +
12
+ `Try reinstalling: npm install -g @skillicinski/bo`,
13
+ );
14
+ process.exit(1);
15
+ }
16
+
17
+ const result = spawnSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
18
+
19
+ if (result.error) {
20
+ throw result.error;
21
+ }
22
+
23
+ process.exit(result.status != null ? result.status : 1);