weside-cli 0.5.2 → 0.5.4

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/bin/weside ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // Thin launcher: execs the platform binary that postinstall.js downloads
5
+ // next to this file as `weside-bin`. This file is committed (and thus packed
6
+ // into the npm tarball) so that npm creates the `weside` bin shim at install
7
+ // time — the native binary itself only exists after postinstall runs.
8
+ const { spawnSync } = require("child_process");
9
+ const path = require("path");
10
+
11
+ const bin = path.join(
12
+ __dirname,
13
+ process.platform === "win32" ? "weside-bin.exe" : "weside-bin"
14
+ );
15
+
16
+ const res = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
17
+
18
+ if (res.error) {
19
+ if (res.error.code === "ENOENT") {
20
+ console.error(
21
+ "weside: native binary missing — the postinstall step may have failed.\n" +
22
+ "Try reinstalling: npm rebuild weside-cli"
23
+ );
24
+ } else {
25
+ console.error(`weside: failed to launch (${res.error.message})`);
26
+ }
27
+ process.exit(1);
28
+ }
29
+
30
+ process.exit(res.status === null ? 1 : res.status);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weside-cli",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "CLI for the weside.ai AI Companion Platform",
5
5
  "homepage": "https://github.com/weside-ai/weside-cli",
6
6
  "repository": {
package/postinstall.js CHANGED
@@ -8,7 +8,10 @@ const os = require("os");
8
8
 
9
9
  const REPO = "weside-ai/weside-cli";
10
10
  const BIN_DIR = path.join(__dirname, "bin");
11
- const BIN_NAME = process.platform === "win32" ? "weside.exe" : "weside";
11
+ // Member name inside the release archive (goreleaser builds.binary = weside).
12
+ const ARCHIVE_BIN = process.platform === "win32" ? "weside.exe" : "weside";
13
+ // Where we store it: next to the committed `weside` launcher, which execs this.
14
+ const REAL_BIN = process.platform === "win32" ? "weside-bin.exe" : "weside-bin";
12
15
 
13
16
  const PLATFORM_MAP = {
14
17
  darwin: "darwin",
@@ -44,22 +47,29 @@ async function main() {
44
47
  fs.mkdirSync(BIN_DIR, { recursive: true });
45
48
 
46
49
  const tmpFile = path.join(os.tmpdir(), archiveName);
50
+ // Extract into a temp dir, never into BIN_DIR directly: the archive member is
51
+ // also named `weside`, which would clobber the committed launcher of the same
52
+ // name. We only move the native binary out, to `bin/weside-bin`.
53
+ const tmpExtract = fs.mkdtempSync(path.join(os.tmpdir(), "weside-cli-"));
47
54
 
48
55
  try {
49
56
  await download(url, tmpFile);
50
57
 
51
58
  if (ext === "tar.gz") {
52
- execSync(`tar -xzf "${tmpFile}" -C "${BIN_DIR}" weside`, {
59
+ execSync(`tar -xzf "${tmpFile}" -C "${tmpExtract}" ${ARCHIVE_BIN}`, {
53
60
  stdio: "pipe",
54
61
  });
55
62
  } else {
56
63
  execSync(
57
- `powershell -Command "Expand-Archive -Path '${tmpFile}' -DestinationPath '${BIN_DIR}' -Force"`,
64
+ `powershell -Command "Expand-Archive -Path '${tmpFile}' -DestinationPath '${tmpExtract}' -Force"`,
58
65
  { stdio: "pipe" }
59
66
  );
60
67
  }
61
68
 
62
- const binPath = path.join(BIN_DIR, BIN_NAME);
69
+ // Move the native binary next to the launcher as `weside-bin` (what the
70
+ // committed `weside` launcher execs). The launcher itself stays in place.
71
+ const binPath = path.join(BIN_DIR, REAL_BIN);
72
+ fs.copyFileSync(path.join(tmpExtract, ARCHIVE_BIN), binPath);
63
73
  if (process.platform !== "win32") {
64
74
  fs.chmodSync(binPath, 0o755);
65
75
  }
@@ -75,6 +85,9 @@ async function main() {
75
85
  try {
76
86
  fs.unlinkSync(tmpFile);
77
87
  } catch {}
88
+ try {
89
+ fs.rmSync(tmpExtract, { recursive: true, force: true });
90
+ } catch {}
78
91
  }
79
92
  }
80
93
 
package/bin/.gitkeep DELETED
File without changes