@bob-kit/client 0.0.4 → 0.0.6

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 CHANGED
@@ -1,7 +1,5 @@
1
1
  export class MemoryCache {
2
- constructor() {
3
- this.cache = new Map();
4
- }
2
+ cache = new Map();
5
3
  get(id) {
6
4
  return this.cache.get(id);
7
5
  }
package/dist/daemon.js CHANGED
@@ -1,10 +1,16 @@
1
+ import { getProgram } from "./get-program.js";
1
2
  import { spawn } from "node:child_process";
3
+ import path from "node:path";
4
+ import { fileURLToPath } from "node:url";
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+ const programPath = path.join(__dirname, getProgram());
2
8
  export class Daemon {
9
+ process;
10
+ buffer = "";
11
+ queue = [];
3
12
  constructor(driver) {
4
- this.buffer = "";
5
- this.queue = [];
6
- const cwd = process.cwd();
7
- this.process = spawn(`./motor`, ["-d", driver, "--json", "--daemon"], {
13
+ this.process = spawn(programPath, ["-d", driver, "--json", "--daemon"], {
8
14
  stdio: ["pipe", "pipe", "pipe"],
9
15
  windowsHide: true,
10
16
  });
@@ -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 = detectBobFile();
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, "motor");
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bob-kit/client",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "",