@rocketsurgery/yaks 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 (2) hide show
  1. package/bin/yaks.js +57 -0
  2. package/package.json +23 -0
package/bin/yaks.js ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ // Thin launcher: pick the prebuilt `yaks` binary for the host platform and
4
+ // exec it. The binaries ship as per-platform packages declared in this
5
+ // package's optionalDependencies (npm installs only the one matching the
6
+ // host's os/cpu). This is the esbuild/Biome distribution pattern.
7
+ const { spawnSync } = require("node:child_process");
8
+
9
+ // host key ("<platform> <arch>") -> platform package name
10
+ const TARGETS = {
11
+ "darwin arm64": "@rocketsurgery/yaks-darwin-arm64",
12
+ "darwin x64": "@rocketsurgery/yaks-darwin-x64",
13
+ "linux x64": "@rocketsurgery/yaks-linux-x64",
14
+ "linux arm64": "@rocketsurgery/yaks-linux-arm64",
15
+ "win32 x64": "@rocketsurgery/yaks-win32-x64",
16
+ };
17
+
18
+ function pkgFor(platform, arch) {
19
+ return TARGETS[`${platform} ${arch}`] || null;
20
+ }
21
+
22
+ function binPath() {
23
+ const pkg = pkgFor(process.platform, process.arch);
24
+ if (!pkg) {
25
+ throw new Error(
26
+ `yaks: unsupported platform ${process.platform}/${process.arch}. ` +
27
+ `Install a prebuilt binary from GitHub Releases instead.`
28
+ );
29
+ }
30
+ const exe = process.platform === "win32" ? "yaks.exe" : "yaks";
31
+ try {
32
+ return require.resolve(`${pkg}/bin/${exe}`);
33
+ } catch (_e) {
34
+ throw new Error(
35
+ `yaks: platform package "${pkg}" is not installed. ` +
36
+ `Reinstall with optionalDependencies enabled (npm install --include=optional).`
37
+ );
38
+ }
39
+ }
40
+
41
+ module.exports = { TARGETS, pkgFor, binPath };
42
+
43
+ if (require.main === module) {
44
+ let bin;
45
+ try {
46
+ bin = binPath();
47
+ } catch (e) {
48
+ console.error(e.message);
49
+ process.exit(1);
50
+ }
51
+ const res = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
52
+ if (res.error) {
53
+ console.error(`yaks: failed to launch binary: ${res.error.message}`);
54
+ process.exit(1);
55
+ }
56
+ process.exit(res.status === null ? 1 : res.status);
57
+ }
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@rocketsurgery/yaks",
3
+ "version": "0.0.1",
4
+ "description": "Filesystem-native task tracker (Rust) — npm launcher for the `yaks` binary",
5
+ "bin": {
6
+ "yaks": "bin/yaks.js"
7
+ },
8
+ "files": [
9
+ "bin/"
10
+ ],
11
+ "license": "Apache-2.0",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/rocketsurgery-games/yaks.git"
15
+ },
16
+ "optionalDependencies": {
17
+ "@rocketsurgery/yaks-darwin-arm64": "0.0.1",
18
+ "@rocketsurgery/yaks-darwin-x64": "0.0.1",
19
+ "@rocketsurgery/yaks-linux-x64": "0.0.1",
20
+ "@rocketsurgery/yaks-linux-arm64": "0.0.1",
21
+ "@rocketsurgery/yaks-win32-x64": "0.0.1"
22
+ }
23
+ }