instabox 0.8.229 → 0.8.231
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/cli/SHA256SUMS +6 -6
- package/cli/instabox-darwin-amd64 +0 -0
- package/cli/instabox-darwin-arm64 +0 -0
- package/cli/instabox-linux-amd64 +0 -0
- package/cli/instabox-linux-arm64 +0 -0
- package/cli/instabox-windows-amd64.exe +0 -0
- package/cli/instabox-windows-arm64.exe +0 -0
- package/lib/cli.mjs +39 -7
- package/package.json +1 -1
package/cli/SHA256SUMS
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
e69e3dfe58a845896fd46617e05d9bdf1ce2e63581b5f603ba59d1ff4d558509 instabox-darwin-amd64
|
|
2
|
+
87e9e114655c538d03e65590eefb74f7dbd2c5e05a81b56d4181ed0d288c8c95 instabox-darwin-arm64
|
|
3
|
+
6242c0eb1675f033989ff7f3da5e3b3b991322bf63d5c6cf6b2dd13c6369f190 instabox-linux-amd64
|
|
4
|
+
c6536bc800e8b89518aa43751c9980d6534d9a8e071f0ba19a5fc2e5b325e5f1 instabox-linux-arm64
|
|
5
|
+
f3170051f8818c0c83a52de146d5732b83bc024855236d34976d1a17939b4d4f instabox-windows-amd64.exe
|
|
6
|
+
25ac5539135d181f6b2df7dc9389d88812cdaeff31a8a2f0b8f9fd47ea5b64a1 instabox-windows-arm64.exe
|
|
Binary file
|
|
Binary file
|
package/cli/instabox-linux-amd64
CHANGED
|
Binary file
|
package/cli/instabox-linux-arm64
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/cli.mjs
CHANGED
|
@@ -109,7 +109,7 @@ export function pathHint(dir, { env = process.env, platform = process.platform }
|
|
|
109
109
|
// never throws, and never needs the network.
|
|
110
110
|
export async function installBundled(
|
|
111
111
|
src,
|
|
112
|
-
{ dir, path: dest, env = process.env, platform = process.platform, version =
|
|
112
|
+
{ dir, path: dest, env = process.env, platform = process.platform, version = cliVersionCheck } = {},
|
|
113
113
|
) {
|
|
114
114
|
const win = platform === 'win32';
|
|
115
115
|
const to = dest ? dirname(dest) : dir || installDir({ env, platform });
|
|
@@ -118,10 +118,16 @@ export async function installBundled(
|
|
|
118
118
|
mkdirSync(to, { recursive: true });
|
|
119
119
|
copyFileSync(src, tmp);
|
|
120
120
|
chmodSync(tmp, 0o755);
|
|
121
|
-
|
|
121
|
+
// version gives {version} or {why} (cliVersionCheck), or a string or null.
|
|
122
|
+
const r = await version(tmp);
|
|
123
|
+
const v = typeof r === 'string' ? r : r?.version;
|
|
122
124
|
if (!v) {
|
|
123
125
|
tryRm(tmp);
|
|
124
|
-
|
|
126
|
+
if (r?.timedOut)
|
|
127
|
+
return {
|
|
128
|
+
error: `the bundled instabox did not answer instabox --version within ${selfCheckTimeoutMs / 1000}s, which antivirus software checking a new file can cause; run this again`,
|
|
129
|
+
};
|
|
130
|
+
return { error: `the bundled instabox does not run (instabox --version${r?.why ? `: ${r.why}` : ' failed'})` };
|
|
125
131
|
}
|
|
126
132
|
const path = dest || join(to, win ? 'instabox.exe' : 'instabox');
|
|
127
133
|
renameSync(tmp, path);
|
|
@@ -155,18 +161,44 @@ export function findCli({ env = process.env, self = process.argv[1], platform =
|
|
|
155
161
|
|
|
156
162
|
// What `instabox --version` prints after "instabox ", or null when it does not run. Async, so a
|
|
157
163
|
// slow or hung binary does not hold up the rest of onboarding.
|
|
158
|
-
export function cliVersion(path) {
|
|
164
|
+
export async function cliVersion(path) {
|
|
165
|
+
return (await cliVersionCheck(path, { timeout: 10_000 })).version ?? null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// The limit on a new copy's --version check. Antivirus software can hold a new, unsigned file on
|
|
169
|
+
// its first run while it checks it (Windows Defender's cloud check waits up to 60 s).
|
|
170
|
+
export const selfCheckTimeoutMs = 90_000;
|
|
171
|
+
|
|
172
|
+
// `instabox --version` as {version}, or {why} it gave none (SUP2-1833: "does not run" alone left
|
|
173
|
+
// nothing to go on): {timedOut} past the limit, the spawn error's code (EBUSY, EPERM, ...), the
|
|
174
|
+
// exit code and first stderr line, or what it printed.
|
|
175
|
+
export function cliVersionCheck(path, { timeout = selfCheckTimeoutMs } = {}) {
|
|
159
176
|
return new Promise((resolve) => {
|
|
160
|
-
execFile(path, ['--version'], { encoding: 'utf8', timeout
|
|
161
|
-
if (err) return resolve(null);
|
|
177
|
+
execFile(path, ['--version'], { encoding: 'utf8', timeout }, (err, stdout, stderr) => {
|
|
162
178
|
const m = String(stdout)
|
|
163
179
|
.trim()
|
|
164
180
|
.match(/^instabox (\S+)$/);
|
|
165
|
-
|
|
181
|
+
if (!err && m) return resolve({ version: m[1] });
|
|
182
|
+
if (err?.killed) return resolve({ timedOut: true, why: `no answer within ${timeout / 1000}s` });
|
|
183
|
+
if (typeof err?.code === 'string') return resolve({ why: err.code });
|
|
184
|
+
if (err) {
|
|
185
|
+
const line = firstLine(stderr);
|
|
186
|
+
return resolve({ why: `exit code ${err.code ?? err.signal}${line ? `: ${line}` : ''}` });
|
|
187
|
+
}
|
|
188
|
+
resolve({ why: `it printed ${JSON.stringify(firstLine(stdout))}` });
|
|
166
189
|
});
|
|
167
190
|
});
|
|
168
191
|
}
|
|
169
192
|
|
|
193
|
+
// s's first non-blank line, at most 160 characters.
|
|
194
|
+
function firstLine(s) {
|
|
195
|
+
const line = String(s ?? '')
|
|
196
|
+
.split('\n')
|
|
197
|
+
.map((l) => l.trim())
|
|
198
|
+
.find(Boolean);
|
|
199
|
+
return !line ? '' : line.length > 160 ? `${line.slice(0, 157)}...` : line;
|
|
200
|
+
}
|
|
201
|
+
|
|
170
202
|
// The file's sha256, streamed: the CLI is tens of MB and this runs while the box starts.
|
|
171
203
|
export function sha256File(path) {
|
|
172
204
|
return new Promise((resolve, reject) => {
|