@bluevs/vhcli 0.2.0 → 0.3.0

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/package.json +7 -7
  2. package/scripts/run.js +30 -8
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@bluevs/vhcli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Vision Hub CLI - query projects and resources, designed for AI Agent and developers",
5
5
  "bin": {
6
6
  "vhcli": "scripts/run.js"
7
7
  },
8
8
  "scripts": {},
9
9
  "optionalDependencies": {
10
- "@bluevs/vhcli-darwin-arm64": "0.2.0",
11
- "@bluevs/vhcli-darwin-x64": "0.2.0",
12
- "@bluevs/vhcli-linux-arm64": "0.2.0",
13
- "@bluevs/vhcli-linux-x64": "0.2.0",
14
- "@bluevs/vhcli-win32-arm64": "0.2.0",
15
- "@bluevs/vhcli-win32-x64": "0.2.0"
10
+ "@bluevs/vhcli-darwin-arm64": "0.3.0",
11
+ "@bluevs/vhcli-darwin-x64": "0.3.0",
12
+ "@bluevs/vhcli-linux-arm64": "0.3.0",
13
+ "@bluevs/vhcli-linux-x64": "0.3.0",
14
+ "@bluevs/vhcli-win32-arm64": "0.3.0",
15
+ "@bluevs/vhcli-win32-x64": "0.3.0"
16
16
  },
17
17
  "engines": {
18
18
  "node": ">=16"
package/scripts/run.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const { execFileSync } = require("child_process");
2
+ const { execFileSync, execSync } = require("child_process");
3
3
  const path = require("path");
4
4
 
5
5
  const PLATFORM_MAP = {
@@ -22,14 +22,36 @@ if (!platform || !arch) {
22
22
  }
23
23
 
24
24
  const pkgName = `@bluevs/vhcli-${platform}-${arch}`;
25
- let binPath;
25
+ const binName = `vhcli${process.platform === "win32" ? ".exe" : ""}`;
26
26
 
27
- try {
28
- binPath = require.resolve(`${pkgName}/bin/vhcli${process.platform === "win32" ? ".exe" : ""}`);
29
- } catch {
30
- console.error(`Platform package ${pkgName} is not installed.`);
31
- console.error(`Run: npm install ${pkgName}`);
32
- process.exit(1);
27
+ function findBinary() {
28
+ try {
29
+ return require.resolve(`${pkgName}/bin/${binName}`);
30
+ } catch {
31
+ return null;
32
+ }
33
+ }
34
+
35
+ let binPath = findBinary();
36
+
37
+ if (!binPath) {
38
+ const version = require("../package.json").version;
39
+ const spec = `${pkgName}@${version}`;
40
+ process.stderr.write(`Installing platform package ${spec}...\n`);
41
+ try {
42
+ execSync(`npm install --no-save ${spec}`, {
43
+ stdio: ["ignore", "ignore", "inherit"],
44
+ cwd: path.join(__dirname, ".."),
45
+ });
46
+ } catch {
47
+ console.error(`Failed to install ${spec}. Install manually: npm install ${spec}`);
48
+ process.exit(1);
49
+ }
50
+ binPath = findBinary();
51
+ if (!binPath) {
52
+ console.error(`Platform package ${pkgName} could not be resolved after install.`);
53
+ process.exit(1);
54
+ }
33
55
  }
34
56
 
35
57
  try {