@boxes-dev/cli 1.0.578 → 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 +1 -1
- package/scripts/postinstall.cjs +4 -5
- package/scripts/postinstall.mjs +30 -14
package/package.json
CHANGED
package/scripts/postinstall.cjs
CHANGED
|
@@ -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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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) {
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -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(
|
|
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);
|
|
@@ -92,7 +94,9 @@ async function main() {
|
|
|
92
94
|
const devboxDir = getDevboxDir();
|
|
93
95
|
const standaloneDir = path.join(devboxDir, "standalone");
|
|
94
96
|
|
|
95
|
-
console.log(
|
|
97
|
+
console.log(
|
|
98
|
+
`@boxes-dev/cli: installing standalone dvb for ${platformKey}...`,
|
|
99
|
+
);
|
|
96
100
|
|
|
97
101
|
// 1. Fetch manifest
|
|
98
102
|
const manifestUrl = getManifestUrl();
|
|
@@ -115,24 +119,28 @@ async function main() {
|
|
|
115
119
|
console.error(
|
|
116
120
|
`@boxes-dev/cli: no archive available for platform ${platformKey}`,
|
|
117
121
|
);
|
|
118
|
-
console.error(
|
|
122
|
+
console.error(
|
|
123
|
+
`Available platforms: ${Object.keys(manifest.archives || {}).join(", ")}`,
|
|
124
|
+
);
|
|
119
125
|
process.exit(1);
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
const version = manifest.version;
|
|
123
|
-
const versionDir = path.join(
|
|
124
|
-
standaloneDir,
|
|
125
|
-
`${version}-${platformKey}`,
|
|
126
|
-
);
|
|
129
|
+
const versionDir = path.join(standaloneDir, `${version}-${platformKey}`);
|
|
127
130
|
const currentLink = path.join(standaloneDir, "current");
|
|
128
131
|
|
|
129
132
|
// 2. Check if already installed at this version
|
|
130
|
-
if (
|
|
133
|
+
if (
|
|
134
|
+
fs.existsSync(versionDir) &&
|
|
135
|
+
fs.existsSync(path.join(versionDir, "dvb"))
|
|
136
|
+
) {
|
|
131
137
|
// Check if current symlink already points here.
|
|
132
138
|
try {
|
|
133
139
|
const currentTarget = fs.readlinkSync(currentLink);
|
|
134
|
-
if (
|
|
135
|
-
|
|
140
|
+
if (
|
|
141
|
+
path.resolve(standaloneDir, currentTarget) === versionDir ||
|
|
142
|
+
currentTarget === versionDir
|
|
143
|
+
) {
|
|
136
144
|
console.log(
|
|
137
145
|
`@boxes-dev/cli: standalone dvb v${version} already installed, skipping.`,
|
|
138
146
|
);
|
|
@@ -200,11 +208,15 @@ async function main() {
|
|
|
200
208
|
} catch (err) {
|
|
201
209
|
console.error(`@boxes-dev/cli: installation failed: ${err.message}`);
|
|
202
210
|
// Clean up
|
|
203
|
-
try {
|
|
211
|
+
try {
|
|
212
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
213
|
+
} catch {}
|
|
204
214
|
process.exit(1);
|
|
205
215
|
} finally {
|
|
206
216
|
// Always clean up the tarball
|
|
207
|
-
try {
|
|
217
|
+
try {
|
|
218
|
+
fs.unlinkSync(tarballPath);
|
|
219
|
+
} catch {}
|
|
208
220
|
}
|
|
209
221
|
}
|
|
210
222
|
|
|
@@ -218,8 +230,12 @@ function updateCurrentSymlink(standaloneDir, currentLink, versionDir, version) {
|
|
|
218
230
|
fs.renameSync(tmpLink, currentLink);
|
|
219
231
|
} catch {
|
|
220
232
|
// Fallback: remove and recreate.
|
|
221
|
-
try {
|
|
222
|
-
|
|
233
|
+
try {
|
|
234
|
+
fs.unlinkSync(tmpLink);
|
|
235
|
+
} catch {}
|
|
236
|
+
try {
|
|
237
|
+
fs.unlinkSync(currentLink);
|
|
238
|
+
} catch {}
|
|
223
239
|
const relTarget = path.relative(standaloneDir, versionDir);
|
|
224
240
|
fs.symlinkSync(relTarget, currentLink);
|
|
225
241
|
}
|