@piperace/cli 1.5.18 → 1.5.20
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/install.js +47 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piperace/cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.20",
|
|
4
4
|
"description": "Piperace — the missing toolkit for localhost: public tunnels, trusted local HTTPS domains and traffic inspection, with an MCP server for AI agents. One binary, one command.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
package/scripts/install.js
CHANGED
|
@@ -347,17 +347,64 @@ function registerWithLaunchServices(dest) {
|
|
|
347
347
|
module.exports = {
|
|
348
348
|
installBinary,
|
|
349
349
|
installMacTrayApp,
|
|
350
|
+
autostart,
|
|
350
351
|
binaryName,
|
|
351
352
|
finalBinaryPath,
|
|
352
353
|
platformKey,
|
|
353
354
|
BINARY_MAP
|
|
354
355
|
};
|
|
355
356
|
|
|
357
|
+
// autostart opens the Control Center once the install is done.
|
|
358
|
+
//
|
|
359
|
+
// The install used to end in silence: you copy one command from the front page,
|
|
360
|
+
// it prints download progress, and then nothing happens. Everything piperace
|
|
361
|
+
// does lives in that dashboard, so a dashboard you have to be separately told
|
|
362
|
+
// to run is one most people never see. The front page already promises "the
|
|
363
|
+
// dashboard opens by itself" — this is the line that makes that true.
|
|
364
|
+
//
|
|
365
|
+
// Only for a global install someone typed themselves. A project dependency
|
|
366
|
+
// must never start a daemon during `npm ci`, and no build server wants a
|
|
367
|
+
// browser window, so both are skipped outright rather than guessed at.
|
|
368
|
+
// PIPERACE_NO_AUTOSTART=1 is the way out for anyone else.
|
|
369
|
+
//
|
|
370
|
+
// `ui` behaves the same for a first install and an upgrade: on macOS it stops
|
|
371
|
+
// the previous instance, hands the stack to the menu-bar app and returns;
|
|
372
|
+
// elsewhere it stays up in the background, which is why the child is detached
|
|
373
|
+
// and unref'd — npm must not wait on it.
|
|
374
|
+
function autostart() {
|
|
375
|
+
const bin = finalBinaryPath('cli');
|
|
376
|
+
if (!fs.existsSync(bin)) return;
|
|
377
|
+
|
|
378
|
+
// Under `sudo npm i -g` the child would inherit root, and piperace keeps its
|
|
379
|
+
// state in $HOME — one root-owned ~/.piperace and the user's own runs cannot
|
|
380
|
+
// read their own config afterwards. Print the command; let them type it.
|
|
381
|
+
const asRoot = typeof process.getuid === 'function' && process.getuid() === 0 && process.env.SUDO_USER;
|
|
382
|
+
|
|
383
|
+
const skip =
|
|
384
|
+
process.env.PIPERACE_NO_AUTOSTART === '1' ? 'PIPERACE_NO_AUTOSTART=1' :
|
|
385
|
+
process.env.CI ? 'CI is set' :
|
|
386
|
+
process.env.npm_config_global !== 'true' ? 'not a global install' :
|
|
387
|
+
asRoot ? 'installed with sudo' : null;
|
|
388
|
+
if (skip) {
|
|
389
|
+
console.log(`[piperace] Installed. Run \`piperace\` to open the dashboard (${skip}).`);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
try {
|
|
394
|
+
const { spawn } = require('child_process');
|
|
395
|
+
spawn(bin, ['ui'], { detached: true, stdio: 'ignore' }).unref();
|
|
396
|
+
console.log('[piperace] Opening the dashboard… (run `piperace` any time to get back to it)');
|
|
397
|
+
} catch (err) {
|
|
398
|
+
console.log(`[piperace] Installed, but could not start it (${err.message}). Run \`piperace\`.`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
356
402
|
// Fetch the CLI binary (and, on macOS, the menu-bar app) at install time.
|
|
357
403
|
if (require.main === module) {
|
|
358
404
|
// Never let a failure here break `npm install`; the launcher retries lazily.
|
|
359
405
|
Promise.resolve()
|
|
360
406
|
.then(() => installBinary('cli'))
|
|
361
407
|
.then(() => installMacTrayApp())
|
|
408
|
+
.then(() => autostart())
|
|
362
409
|
.catch((err) => console.error(`[piperace] install skipped: ${err.message}`));
|
|
363
410
|
}
|