vibego 0.0.3

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/vibego.js +60 -0
  2. package/package.json +26 -0
package/bin/vibego.js ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { createRequire } from "node:module";
4
+ import path from "node:path";
5
+
6
+ const require = createRequire(import.meta.url);
7
+
8
+ const platformPackageByHost = {
9
+ "linux:x64": "@vibego/vibego-linux-x64",
10
+ "linux:arm64": "@vibego/vibego-linux-arm64",
11
+ "darwin:x64": "@vibego/vibego-darwin-x64",
12
+ "darwin:arm64": "@vibego/vibego-darwin-arm64",
13
+ "win32:x64": "@vibego/vibego-win32-x64",
14
+ "win32:arm64": "@vibego/vibego-win32-arm64"
15
+ };
16
+
17
+ const hostKey = `${process.platform}:${process.arch}`;
18
+ const platformPackage = platformPackageByHost[hostKey];
19
+
20
+ if (!platformPackage) {
21
+ throw new Error(`Unsupported platform: ${process.platform} (${process.arch})`);
22
+ }
23
+
24
+ let packageJsonPath;
25
+
26
+ try {
27
+ packageJsonPath = require.resolve(`${platformPackage}/package.json`);
28
+ } catch {
29
+ throw new Error(`Missing optional dependency ${platformPackage}. Reinstall with: npm i -g vibego@latest`);
30
+ }
31
+
32
+ const vendorRoot = path.join(path.dirname(packageJsonPath), "vendor");
33
+ const binaryName = process.platform === "win32" ? "vibego.exe" : "vibego";
34
+ const binaryPath = path.join(vendorRoot, binaryName);
35
+
36
+ const child = spawn(binaryPath, process.argv.slice(2), {
37
+ stdio: "inherit",
38
+ env: process.env
39
+ });
40
+
41
+ child.on("error", (err) => {
42
+ console.error(err);
43
+ process.exit(1);
44
+ });
45
+
46
+ ["SIGINT", "SIGTERM", "SIGHUP"].forEach((signal) => {
47
+ process.on(signal, () => {
48
+ if (!child.killed) {
49
+ child.kill(signal);
50
+ }
51
+ });
52
+ });
53
+
54
+ child.on("exit", (code, signal) => {
55
+ if (signal) {
56
+ process.kill(process.pid, signal);
57
+ return;
58
+ }
59
+ process.exit(code ?? 1);
60
+ });
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "vibego",
3
+ "version": "0.0.3",
4
+ "type": "module",
5
+ "bin": {
6
+ "vibego": "bin/vibego.js"
7
+ },
8
+ "files": [
9
+ "bin"
10
+ ],
11
+ "engines": {
12
+ "node": ">=16"
13
+ },
14
+ "optionalDependencies": {
15
+ "@vibego/vibego-darwin-arm64": "0.0.3",
16
+ "@vibego/vibego-darwin-x64": "0.0.3",
17
+ "@vibego/vibego-linux-arm64": "0.0.3",
18
+ "@vibego/vibego-linux-x64": "0.0.3",
19
+ "@vibego/vibego-win32-arm64": "0.0.3",
20
+ "@vibego/vibego-win32-x64": "0.0.3"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/xxnuo/VibeGo"
25
+ }
26
+ }