@dazzle-labs/cli 0.5.5 → 0.5.7

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/run.js +51 -10
  2. package/package.json +7 -7
package/bin/run.js CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { execFileSync } = require("child_process");
3
+ const { execFileSync, execSync } = require("child_process");
4
+ const { chmodSync, realpathSync, statSync } = require("fs");
5
+ const path = require("path");
4
6
 
5
7
  const PLATFORMS = {
6
8
  "darwin-arm64": "@dazzle-labs/cli-darwin-arm64",
@@ -19,17 +21,56 @@ if (!pkg) {
19
21
  }
20
22
 
21
23
  const ext = process.platform === "win32" ? ".exe" : "";
22
- let binPath;
23
- try {
24
- binPath = require.resolve(`${pkg}/bin/dazzle${ext}`);
25
- } catch {
26
- console.error(
27
- `${pkg} is not installed. Make sure optionalDependencies are not disabled.\n` +
28
- `Install with: npm install ${pkg}`
29
- );
30
- process.exit(1);
24
+ const binName = `bin/dazzle${ext}`;
25
+
26
+ // Resolve from the real path of this package so pnpm's strict node_modules
27
+ // layout can find the optional platform dependency via its symlinks.
28
+ const pkgDir = realpathSync(path.resolve(__dirname, ".."));
29
+
30
+ function tryResolve() {
31
+ try {
32
+ return require.resolve(`${pkg}/${binName}`, { paths: [pkgDir] });
33
+ } catch {
34
+ return null;
35
+ }
36
+ }
37
+
38
+ let binPath = tryResolve();
39
+
40
+ if (!binPath) {
41
+ // Platform binary not found — install optionalDependencies into this
42
+ // package's directory. This handles npx/pnpx where optional deps are
43
+ // skipped during ephemeral installs (same pattern as turbo).
44
+ const env = { ...process.env, npm_config_global: undefined };
45
+ try {
46
+ execSync(
47
+ "npm install --loglevel=error --prefer-offline --no-audit --progress=false",
48
+ { cwd: pkgDir, stdio: "pipe", env }
49
+ );
50
+ } catch {
51
+ console.error(
52
+ `${pkg} is not installed and could not be installed automatically.\n` +
53
+ `Install with: npm install ${pkg}`
54
+ );
55
+ process.exit(1);
56
+ }
57
+
58
+ binPath = tryResolve();
59
+ if (!binPath) {
60
+ console.error(
61
+ `${pkg} is not installed. Make sure optionalDependencies are not disabled.\n` +
62
+ `Install with: npm install ${pkg}`
63
+ );
64
+ process.exit(1);
65
+ }
31
66
  }
32
67
 
68
+ // Ensure the binary is executable (pnpm may strip the bit on unpack)
69
+ try {
70
+ const mode = statSync(binPath).mode;
71
+ if (!(mode & 0o111)) chmodSync(binPath, mode | 0o755);
72
+ } catch {}
73
+
33
74
  try {
34
75
  execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
35
76
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazzle-labs/cli",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "Dazzle CLI — cloud stages for AI agents and live streaming",
5
5
  "mcpName": "io.github.dazzle-labs/dazzle",
6
6
  "bin": {
@@ -23,11 +23,11 @@
23
23
  "cli"
24
24
  ],
25
25
  "optionalDependencies": {
26
- "@dazzle-labs/cli-darwin-arm64": "0.5.5",
27
- "@dazzle-labs/cli-darwin-x64": "0.5.5",
28
- "@dazzle-labs/cli-linux-x64": "0.5.5",
29
- "@dazzle-labs/cli-linux-arm64": "0.5.5",
30
- "@dazzle-labs/cli-win32-x64": "0.5.5",
31
- "@dazzle-labs/cli-win32-arm64": "0.5.5"
26
+ "@dazzle-labs/cli-darwin-arm64": "0.5.7",
27
+ "@dazzle-labs/cli-darwin-x64": "0.5.7",
28
+ "@dazzle-labs/cli-linux-x64": "0.5.7",
29
+ "@dazzle-labs/cli-linux-arm64": "0.5.7",
30
+ "@dazzle-labs/cli-win32-x64": "0.5.7",
31
+ "@dazzle-labs/cli-win32-arm64": "0.5.7"
32
32
  }
33
33
  }