@bob-kit/client 0.0.4 → 0.0.5
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.
- package/dist/cache.js +1 -3
- package/dist/daemon.js +5 -4
- package/dist/get-program.d.ts +1 -0
- package/dist/get-program.js +18 -0
- package/dist/install.js +3 -20
- package/dist/motor.exe +0 -0
- package/package.json +1 -1
package/dist/cache.js
CHANGED
package/dist/daemon.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { getProgram } from "./get-program.js";
|
|
1
2
|
import { spawn } from "node:child_process";
|
|
2
3
|
export class Daemon {
|
|
4
|
+
process;
|
|
5
|
+
buffer = "";
|
|
6
|
+
queue = [];
|
|
3
7
|
constructor(driver) {
|
|
4
|
-
this.
|
|
5
|
-
this.queue = [];
|
|
6
|
-
const cwd = process.cwd();
|
|
7
|
-
this.process = spawn(`./motor`, ["-d", driver, "--json", "--daemon"], {
|
|
8
|
+
this.process = spawn(`./${getProgram()}`, ["-d", driver, "--json", "--daemon"], {
|
|
8
9
|
stdio: ["pipe", "pipe", "pipe"],
|
|
9
10
|
windowsHide: true,
|
|
10
11
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getProgram(): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function getProgram() {
|
|
2
|
+
const platform = process.platform; // 'win32', 'darwin', 'linux'
|
|
3
|
+
const arch = process.arch; // 'x64', 'arm64', etc.
|
|
4
|
+
let file = "";
|
|
5
|
+
if (platform === "win32") {
|
|
6
|
+
file = "bob-windows-amd64.exe";
|
|
7
|
+
}
|
|
8
|
+
else if (platform === "darwin") {
|
|
9
|
+
file = arch === "arm64" ? "bob-darwin-arm64" : "bob-darwin-amd64";
|
|
10
|
+
}
|
|
11
|
+
else if (platform === "linux") {
|
|
12
|
+
file = arch === "arm64" ? "bob-linux-arm64" : "bob-linux-amd64";
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
16
|
+
}
|
|
17
|
+
return file;
|
|
18
|
+
}
|
package/dist/install.js
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
|
+
import { getProgram } from "./get-program.js";
|
|
1
2
|
import * as fs from "fs";
|
|
2
3
|
import * as path from "path";
|
|
3
4
|
import { pipeline } from "stream";
|
|
4
5
|
import { promisify } from "util";
|
|
5
6
|
const streamPipeline = promisify(pipeline);
|
|
6
|
-
function detectBobFile() {
|
|
7
|
-
const platform = process.platform; // 'win32', 'darwin', 'linux'
|
|
8
|
-
const arch = process.arch; // 'x64', 'arm64', etc.
|
|
9
|
-
let file = "";
|
|
10
|
-
if (platform === "win32") {
|
|
11
|
-
file = "bob-windows-amd64.exe";
|
|
12
|
-
}
|
|
13
|
-
else if (platform === "darwin") {
|
|
14
|
-
file = arch === "arm64" ? "bob-darwin-arm64" : "bob-darwin-amd64";
|
|
15
|
-
}
|
|
16
|
-
else if (platform === "linux") {
|
|
17
|
-
file = arch === "arm64" ? "bob-linux-arm64" : "bob-linux-amd64";
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
21
|
-
}
|
|
22
|
-
return file;
|
|
23
|
-
}
|
|
24
7
|
async function downloadFile(url, folder, filename) {
|
|
25
8
|
const res = await fetch(url);
|
|
26
9
|
if (!res.ok)
|
|
@@ -34,10 +17,10 @@ async function downloadFile(url, folder, filename) {
|
|
|
34
17
|
(async () => {
|
|
35
18
|
try {
|
|
36
19
|
const version = "v0.0.1"; // or dynamic
|
|
37
|
-
const fileName =
|
|
20
|
+
const fileName = getProgram();
|
|
38
21
|
const url = `https://github.com/bob-object-builder/bob/releases/download/${version}/${fileName}`;
|
|
39
22
|
const downloadFolder = "dist";
|
|
40
|
-
await downloadFile(url, downloadFolder,
|
|
23
|
+
await downloadFile(url, downloadFolder, fileName);
|
|
41
24
|
}
|
|
42
25
|
catch (err) {
|
|
43
26
|
console.error("Error:", err);
|
package/dist/motor.exe
ADDED
|
Binary file
|