@boxes-dev/cli 1.0.573 → 1.0.579

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boxes-dev/cli",
3
- "version": "1.0.573",
3
+ "version": "1.0.579",
4
4
  "description": "Boxes.dev CLI (standalone, includes bundled Node runtime)",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -5,11 +5,10 @@ const { execFileSync } = require("node:child_process");
5
5
  const path = require("node:path");
6
6
 
7
7
  try {
8
- execFileSync(
9
- process.execPath,
10
- [path.join(__dirname, "postinstall.mjs")],
11
- { stdio: "inherit", env: { ...process.env } },
12
- );
8
+ execFileSync(process.execPath, [path.join(__dirname, "postinstall.mjs")], {
9
+ stdio: "inherit",
10
+ env: { ...process.env },
11
+ });
13
12
  } catch (err) {
14
13
  // Non-zero exit from the ESM script.
15
14
  if (err.status != null) {
@@ -70,7 +70,9 @@ async function fetchJson(url) {
70
70
  async function downloadFile(url, dest) {
71
71
  const res = await fetch(url);
72
72
  if (!res.ok) {
73
- throw new Error(`Failed to download ${url}: ${res.status} ${res.statusText}`);
73
+ throw new Error(
74
+ `Failed to download ${url}: ${res.status} ${res.statusText}`,
75
+ );
74
76
  }
75
77
  const fileStream = fs.createWriteStream(dest);
76
78
  await pipeline(res.body, fileStream);
@@ -81,11 +83,20 @@ async function downloadFile(url, dest) {
81
83
  // ---------------------------------------------------------------------------
82
84
 
83
85
  async function main() {
86
+ // Only run during a real global install. npm sets npm_config_global=true for
87
+ // `npm install -g`. During workspace version bumps, local installs, or other
88
+ // npm lifecycle invocations this env var is absent or false, so we skip.
89
+ if (process.env.npm_config_global !== "true") {
90
+ return;
91
+ }
92
+
84
93
  const platformKey = getPlatformKey();
85
94
  const devboxDir = getDevboxDir();
86
95
  const standaloneDir = path.join(devboxDir, "standalone");
87
96
 
88
- console.log(`@boxes-dev/cli: installing standalone dvb for ${platformKey}...`);
97
+ console.log(
98
+ `@boxes-dev/cli: installing standalone dvb for ${platformKey}...`,
99
+ );
89
100
 
90
101
  // 1. Fetch manifest
91
102
  const manifestUrl = getManifestUrl();
@@ -108,24 +119,28 @@ async function main() {
108
119
  console.error(
109
120
  `@boxes-dev/cli: no archive available for platform ${platformKey}`,
110
121
  );
111
- console.error(`Available platforms: ${Object.keys(manifest.archives || {}).join(", ")}`);
122
+ console.error(
123
+ `Available platforms: ${Object.keys(manifest.archives || {}).join(", ")}`,
124
+ );
112
125
  process.exit(1);
113
126
  }
114
127
 
115
128
  const version = manifest.version;
116
- const versionDir = path.join(
117
- standaloneDir,
118
- `${version}-${platformKey}`,
119
- );
129
+ const versionDir = path.join(standaloneDir, `${version}-${platformKey}`);
120
130
  const currentLink = path.join(standaloneDir, "current");
121
131
 
122
132
  // 2. Check if already installed at this version
123
- if (fs.existsSync(versionDir) && fs.existsSync(path.join(versionDir, "dvb"))) {
133
+ if (
134
+ fs.existsSync(versionDir) &&
135
+ fs.existsSync(path.join(versionDir, "dvb"))
136
+ ) {
124
137
  // Check if current symlink already points here.
125
138
  try {
126
139
  const currentTarget = fs.readlinkSync(currentLink);
127
- if (path.resolve(standaloneDir, currentTarget) === versionDir ||
128
- currentTarget === versionDir) {
140
+ if (
141
+ path.resolve(standaloneDir, currentTarget) === versionDir ||
142
+ currentTarget === versionDir
143
+ ) {
129
144
  console.log(
130
145
  `@boxes-dev/cli: standalone dvb v${version} already installed, skipping.`,
131
146
  );
@@ -193,11 +208,15 @@ async function main() {
193
208
  } catch (err) {
194
209
  console.error(`@boxes-dev/cli: installation failed: ${err.message}`);
195
210
  // Clean up
196
- try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch {}
211
+ try {
212
+ fs.rmSync(tmpDir, { recursive: true, force: true });
213
+ } catch {}
197
214
  process.exit(1);
198
215
  } finally {
199
216
  // Always clean up the tarball
200
- try { fs.unlinkSync(tarballPath); } catch {}
217
+ try {
218
+ fs.unlinkSync(tarballPath);
219
+ } catch {}
201
220
  }
202
221
  }
203
222
 
@@ -211,8 +230,12 @@ function updateCurrentSymlink(standaloneDir, currentLink, versionDir, version) {
211
230
  fs.renameSync(tmpLink, currentLink);
212
231
  } catch {
213
232
  // Fallback: remove and recreate.
214
- try { fs.unlinkSync(tmpLink); } catch {}
215
- try { fs.unlinkSync(currentLink); } catch {}
233
+ try {
234
+ fs.unlinkSync(tmpLink);
235
+ } catch {}
236
+ try {
237
+ fs.unlinkSync(currentLink);
238
+ } catch {}
216
239
  const relTarget = path.relative(standaloneDir, versionDir);
217
240
  fs.symlinkSync(relTarget, currentLink);
218
241
  }