@standardbeagle/tman 0.1.0

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 (2) hide show
  1. package/install.js +55 -0
  2. package/package.json +23 -0
package/install.js ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ const { execFileSync } = require('node:child_process');
3
+ const { createWriteStream, chmodSync, mkdirSync, existsSync } = require('node:fs');
4
+ const { pipeline } = require('node:stream/promises');
5
+ const path = require('node:path');
6
+ const os = require('node:os');
7
+
8
+ const pkg = require('./package.json');
9
+
10
+ const ASSETS = {
11
+ 'linux-x64': 'tman-linux-x64.tar.gz',
12
+ 'linux-arm64': 'tman-linux-arm64.tar.gz',
13
+ 'darwin-x64': 'tman-osx-x64.tar.gz',
14
+ 'darwin-arm64': 'tman-osx-arm64.tar.gz',
15
+ 'win32-x64': 'tman-win-x64.zip',
16
+ };
17
+
18
+ const key = `${os.platform()}-${os.arch()}`;
19
+ const asset = ASSETS[key];
20
+ if (!asset) {
21
+ console.error(`tman: unsupported platform ${key}`);
22
+ process.exit(1);
23
+ }
24
+
25
+ const url = `https://github.com/standardbeagle/tman/releases/download/v${pkg.version}/${asset}`;
26
+ const vendor = path.join(__dirname, 'vendor');
27
+ const archive = path.join(os.tmpdir(), asset);
28
+
29
+ async function main() {
30
+ mkdirSync(vendor, { recursive: true });
31
+ console.log(`tman: downloading ${url}`);
32
+ const res = await fetch(url, { redirect: 'follow' });
33
+ if (!res.ok) {
34
+ console.error(`tman: download failed: ${res.status} ${res.statusText}`);
35
+ process.exit(1);
36
+ }
37
+ await pipeline(res.body, createWriteStream(archive));
38
+
39
+ const isZip = asset.endsWith('.zip');
40
+ const args = isZip ? ['-xf', archive, '-C', vendor] : ['-xzf', archive, '-C', vendor];
41
+ execFileSync('tar', args, { stdio: 'inherit' });
42
+
43
+ const bin = path.join(vendor, os.platform() === 'win32' ? 'tman.exe' : 'tman');
44
+ if (!existsSync(bin)) {
45
+ console.error('tman: archive did not contain the binary');
46
+ process.exit(1);
47
+ }
48
+ if (os.platform() !== 'win32') chmodSync(bin, 0o755);
49
+ console.log(`tman: installed to ${bin}`);
50
+ }
51
+
52
+ main().catch((e) => {
53
+ console.error(`tman: install failed: ${e.message}`);
54
+ process.exit(1);
55
+ });
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@standardbeagle/tman",
3
+ "version": "0.1.0",
4
+ "description": "Supervised process/test runner — caps, culls, and reaps runaway processes (native binary)",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/standardbeagle/tman.git"
9
+ },
10
+ "bin": {
11
+ "tman": "bin/tman.js"
12
+ },
13
+ "scripts": {
14
+ "postinstall": "node install.js"
15
+ },
16
+ "files": [
17
+ "bin",
18
+ "install.js"
19
+ ],
20
+ "engines": {
21
+ "node": ">=18"
22
+ }
23
+ }