instabox 0.8.235 → 0.8.237
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/bin/instabox.mjs +8 -0
- 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 +56 -1
- package/package.json +1 -1
package/bin/instabox.mjs
CHANGED
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
real,
|
|
30
30
|
runCli,
|
|
31
31
|
sha256File,
|
|
32
|
+
sharedShim,
|
|
32
33
|
} from '../lib/cli.mjs';
|
|
33
34
|
import { browserCommand, canOpenBrowser, deviceLogin } from '../lib/login.mjs';
|
|
34
35
|
import { makeDirPrivate, sessionArgs } from '../lib/ssh.mjs';
|
|
@@ -283,6 +284,13 @@ async function ensureBundledCli(bundled, found) {
|
|
|
283
284
|
}
|
|
284
285
|
if (version === 'dev' || version?.endsWith('-dirty'))
|
|
285
286
|
return `instabox CLI at ${found} is a development build (${version}), left as is`;
|
|
287
|
+
// A tool manager's shim that already holds instabox (SUP2-1915) is not written again.
|
|
288
|
+
const shim = sharedShim(found, target);
|
|
289
|
+
if (shim)
|
|
290
|
+
return {
|
|
291
|
+
line: `instabox CLI${v} at ${found} is ${shim.whose} shared shim, which also starts ${shim.users}, left as is`,
|
|
292
|
+
more: `\n ${dim('it now holds instabox, so they run instabox instead · to repair it:')} ${shim.repair}`,
|
|
293
|
+
};
|
|
286
294
|
// Only a target that identifies itself as InstaBox can be upgraded through a symlink.
|
|
287
295
|
const dir = dirname(target);
|
|
288
296
|
try {
|
package/cli/SHA256SUMS
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
5d791e35e576a3bb136b90d5d980e2aaf08f4e11f29550bce39df1e39f769172 instabox-darwin-amd64
|
|
2
|
+
e04aa03299968181356268a1cd5b82bb46c8fbf76b11fb7bce1252a36926f66a instabox-darwin-arm64
|
|
3
|
+
99ba24a9ac209d298a19dcf7525608d0e67ec2b0e19a24dabc58730f4151ba9d instabox-linux-amd64
|
|
4
|
+
7eb583a7b080479ae4f76ad9bbe0a61554f8ead121fd7e2fc8527c5a25cd602a instabox-linux-arm64
|
|
5
|
+
e3abf84fb7d6a8654be40050bf23da1d38935c0c9bacd1ed2dd34b97d8f43793 instabox-windows-amd64.exe
|
|
6
|
+
f23128bad6e6c773114ffe8f5df7be6d75578c56ec994d83dd4c7b1e90ec8c1e 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
|
@@ -8,13 +8,14 @@ import {
|
|
|
8
8
|
copyFileSync,
|
|
9
9
|
createReadStream,
|
|
10
10
|
mkdirSync,
|
|
11
|
+
readdirSync,
|
|
11
12
|
realpathSync,
|
|
12
13
|
renameSync,
|
|
13
14
|
rmSync,
|
|
14
15
|
statSync,
|
|
15
16
|
} from 'node:fs';
|
|
16
17
|
import { constants as osConstants, homedir } from 'node:os';
|
|
17
|
-
import { dirname, join, sep } from 'node:path';
|
|
18
|
+
import { basename, dirname, join, sep } from 'node:path';
|
|
18
19
|
import { fileURLToPath } from 'node:url';
|
|
19
20
|
import { buildName, platformFor } from './platforms.mjs';
|
|
20
21
|
|
|
@@ -159,6 +160,60 @@ export function findCli({ env = process.env, self = process.argv[1], platform =
|
|
|
159
160
|
return null;
|
|
160
161
|
}
|
|
161
162
|
|
|
163
|
+
// Tool managers' shims that every tool they manage links to: one binary that starts the tool named
|
|
164
|
+
// by how it was run (as sharedShims in cmd/instabox/update.go).
|
|
165
|
+
const SHARED_SHIMS = new Map([
|
|
166
|
+
['volta-shim', 'Volta'],
|
|
167
|
+
['mise', 'mise'],
|
|
168
|
+
['mise-shim', 'mise'],
|
|
169
|
+
['proto-shim', 'proto'],
|
|
170
|
+
]);
|
|
171
|
+
const commandName = (name) => name.toLowerCase().replace(/\.exe$/, '');
|
|
172
|
+
|
|
173
|
+
// names in a sentence: "a and b", "a, b and c", "a, b, c and 2 more".
|
|
174
|
+
function someNames(names) {
|
|
175
|
+
if (names.length > 3) return `${names.slice(0, 3).join(', ')} and ${names.length - 3} more`;
|
|
176
|
+
if (names.length === 1) return names[0];
|
|
177
|
+
return `${names.slice(0, -1).join(', ')} and ${names.at(-1)}`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// When target, the file the CLI at found resolves to, is a tool manager's shared shim: its name is
|
|
181
|
+
// one of SHARED_SHIMS, or other commands next to found or target link to it. Old installers wrote
|
|
182
|
+
// the CLI over Volta's shim, which node and npm run through too, and it must not be written again
|
|
183
|
+
// (SUP2-1915). {whose, users, repair} for the line that says so, else null.
|
|
184
|
+
export function sharedShim(found, target, { platform = process.platform, arch = process.arch } = {}) {
|
|
185
|
+
const manager = SHARED_SHIMS.get(commandName(basename(target)));
|
|
186
|
+
const others = new Set();
|
|
187
|
+
for (const dir of new Set([dirname(found), dirname(target)])) {
|
|
188
|
+
let entries = [];
|
|
189
|
+
try {
|
|
190
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
191
|
+
} catch {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
for (const e of entries) {
|
|
195
|
+
if (!e.isSymbolicLink() || e.name === basename(found) || commandName(e.name) === 'instabox') continue;
|
|
196
|
+
if (real(join(dir, e.name)) === target) others.add(e.name);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!manager && !others.size) return null;
|
|
200
|
+
// node, npm and npx first, then by name.
|
|
201
|
+
const rank = (n) => {
|
|
202
|
+
const i = ['node', 'npm', 'npx'].indexOf(n);
|
|
203
|
+
return i < 0 ? 3 : i;
|
|
204
|
+
};
|
|
205
|
+
const names = [...others].sort((a, b) => rank(a) - rank(b) || (a < b ? -1 : 1));
|
|
206
|
+
const users = names.length ? someNames(names) : 'other commands';
|
|
207
|
+
const asset =
|
|
208
|
+
platform === 'darwin' ? 'macos' : platform === 'linux' ? (arch === 'arm64' ? 'linux-arm' : 'linux') : null;
|
|
209
|
+
let repair = 'reinstall the tool manager that made those links, then update instabox through it';
|
|
210
|
+
if (manager === 'Volta' && asset)
|
|
211
|
+
repair = `replace <version> with what volta --version prints and run: curl -fsSL https://github.com/volta-cli/volta/releases/download/v<version>/volta-<version>-${asset}.tar.gz | tar -xzf - -C "${dirname(target)}" volta-shim, then update instabox with: volta install instabox@latest`;
|
|
212
|
+
else if (manager === 'Volta') repair = 'reinstall Volta, then update instabox with: volta install instabox@latest';
|
|
213
|
+
else if (manager) repair = `reinstall ${manager}, then update instabox through ${manager}`;
|
|
214
|
+
return { whose: manager ? `${manager}'s` : "a tool manager's", users, repair };
|
|
215
|
+
}
|
|
216
|
+
|
|
162
217
|
// What `instabox --version` prints after "instabox ", or null when it does not run. Async, so a
|
|
163
218
|
// slow or hung binary does not hold up the rest of onboarding.
|
|
164
219
|
export async function cliVersion(path) {
|