@stagepass/cli 2.2.7 → 2.3.0

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.
Files changed (46) hide show
  1. package/README.md +37 -18
  2. package/TESTING-macos.md +28 -10
  3. package/bin/index.js +4 -1
  4. package/package.json +9 -8
  5. package/src/cli.js +62 -7
  6. package/src/commands/certs.js +375 -19
  7. package/src/commands/daemon.js +75 -7
  8. package/src/commands/dev.js +419 -0
  9. package/src/commands/link.js +64 -23
  10. package/src/commands/new.js +397 -41
  11. package/src/commands/npm-run.js +8 -0
  12. package/src/commands/start.js +220 -127
  13. package/src/commands/stop.js +10 -19
  14. package/src/commands/unlink.js +6 -4
  15. package/src/commands/upgrade.js +51 -12
  16. package/src/lib/apply-site-block.js +48 -0
  17. package/src/lib/caddyfile.js +72 -13
  18. package/src/lib/cdn-snippets.js +145 -3
  19. package/src/lib/certs.js +334 -47
  20. package/src/lib/dev-port.js +45 -0
  21. package/src/lib/doctor-site.js +61 -5
  22. package/src/lib/doctor.js +48 -4
  23. package/src/lib/ensure-running.js +89 -0
  24. package/src/lib/exec.js +72 -24
  25. package/src/lib/live-server.js +484 -0
  26. package/src/lib/node-engine.js +55 -0
  27. package/src/lib/notify.js +62 -0
  28. package/src/lib/origins.js +27 -5
  29. package/src/lib/package-versions.js +9 -0
  30. package/src/lib/paths.js +18 -0
  31. package/src/lib/php-fpm.js +33 -0
  32. package/src/lib/project-sync.js +165 -20
  33. package/src/lib/projects.js +137 -7
  34. package/src/lib/prompts.js +47 -0
  35. package/src/lib/registry.js +27 -6
  36. package/src/lib/scaffold.js +288 -11
  37. package/src/lib/site-detect.js +78 -25
  38. package/src/lib/snippets.js +14 -11
  39. package/src/lib/versions.js +20 -8
  40. package/templates/project/AGENTS.md.tmpl +4 -3
  41. package/templates/project/README.md.tmpl +35 -6
  42. package/templates/project/api/README.md.tmpl +7 -0
  43. package/templates/project/examples/php/README.md.tmpl +18 -0
  44. package/templates/project/examples/php/form.php +105 -0
  45. package/templates/project/examples/php/proxy.php +171 -0
  46. package/templates/project/scripts/build.mjs +200 -37
@@ -1,9 +1,57 @@
1
1
  import chalk from 'chalk';
2
- import inquirer from 'inquirer';
2
+ import { confirm as defaultConfirmPrompt } from '../lib/prompts.js';
3
3
  import { defaultExec } from '../lib/exec.js';
4
4
  import { loadProjects } from '../lib/projects.js';
5
- import { getProjectsPath } from '../lib/paths.js';
6
- import { runCertsCheck, assertNoDestructiveCertOps } from '../lib/certs.js';
5
+ import { getProjectsPath, getCaddyfilePath } from '../lib/paths.js';
6
+ import {
7
+ runCertsCheck,
8
+ assertReadOnlyCertOps,
9
+ assertDestructiveCertOpAllowed,
10
+ domainsNeedingSiteCertRenewal,
11
+ renewSiteCertificates,
12
+ moveLocalCaAuthorityToBackup,
13
+ deleteKeychainCertificateBySha1,
14
+ normalizeSha1Fingerprint,
15
+ } from '../lib/certs.js';
16
+
17
+ /**
18
+ * @param {object} [options]
19
+ * @returns {(message: string, opts?: { default?: boolean }) => Promise<boolean>}
20
+ */
21
+ function resolveConfirm(options = {}) {
22
+ if (typeof options.confirm === 'function') return options.confirm;
23
+ // Legacy injectable: options.prompt([{ type: 'confirm', name, message, default }])
24
+ if (typeof options.prompt === 'function') {
25
+ return async (message, opts = {}) => {
26
+ const answers = await options.prompt([
27
+ {
28
+ type: 'confirm',
29
+ name: 'ok',
30
+ message,
31
+ default: opts.default === true,
32
+ },
33
+ ]);
34
+ return answers?.ok === true;
35
+ };
36
+ }
37
+ return (message, opts = {}) =>
38
+ defaultConfirmPrompt(message, { default: opts.default === true });
39
+ }
40
+
41
+ /**
42
+ * Resolve Homebrew prefix the same way doctor does (`brew --prefix`, failure tolerated).
43
+ * @param {import('../lib/exec.js').ExecFn} exec
44
+ * @returns {Promise<string|null>}
45
+ */
46
+ export async function resolveBrewPrefix(exec) {
47
+ try {
48
+ const { stdout } = await exec('brew', ['--prefix']);
49
+ const prefix = String(stdout || '').trim();
50
+ return prefix || null;
51
+ } catch {
52
+ return null;
53
+ }
54
+ }
7
55
 
8
56
  /**
9
57
  * Read-only certificate report.
@@ -14,15 +62,22 @@ import { runCertsCheck, assertNoDestructiveCertOps } from '../lib/certs.js';
14
62
  * @returns {Promise<number>}
15
63
  */
16
64
  export async function certsCheck(options = {}) {
17
- assertNoDestructiveCertOps();
65
+ assertReadOnlyCertOps();
18
66
 
67
+ const exec = options.exec || defaultExec;
19
68
  const projectsPath = getProjectsPath();
20
69
  const doc = await loadProjects(projectsPath);
21
70
  const domains = Object.keys(doc.projects || {});
71
+ const brewPrefix =
72
+ options.brewPrefix !== undefined
73
+ ? options.brewPrefix
74
+ : await resolveBrewPrefix(exec);
22
75
 
23
76
  const report = await runCertsCheck({
77
+ exec,
24
78
  domains: options.skipHandshake ? [] : domains,
25
79
  skipHandshake: options.skipHandshake === true,
80
+ brewPrefix,
26
81
  });
27
82
 
28
83
  let exitCode = 0;
@@ -87,7 +142,7 @@ export async function certsCheck(options = {}) {
87
142
 
88
143
  if (report.orphans?.length) {
89
144
  console.log(
90
- `[${chalk.yellow('warn')}] Orphaned Caddy roots in keychain (report only; never deleted):`
145
+ `[${chalk.yellow('warn')}] Orphaned Caddy roots in keychain (list only; remove via certs renew --remove-orphans):`
91
146
  );
92
147
  for (const orphan of report.orphans) {
93
148
  console.log(
@@ -114,7 +169,9 @@ export async function certsCheck(options = {}) {
114
169
  ? chalk.green('ok')
115
170
  : hs.status === 'warn'
116
171
  ? chalk.yellow('warn')
117
- : chalk.red('fail');
172
+ : hs.status === 'skip'
173
+ ? chalk.dim('not checkable')
174
+ : chalk.red('fail');
118
175
  console.log(`[${tag}] TLS ${hs.servername}: ${hs.reason}`);
119
176
  }
120
177
  }
@@ -130,16 +187,20 @@ export async function certsCheck(options = {}) {
130
187
  * @param {boolean} [options.verbose]
131
188
  * @param {import('../lib/exec.js').ExecFn} [options.exec]
132
189
  * @param {(q: object[]) => Promise<object>} [options.prompt]
190
+ * @param {(message: string, opts?: object) => Promise<boolean>} [options.confirm]
133
191
  * @returns {Promise<number>}
134
192
  */
135
193
  export async function certsTrust(options = {}) {
136
- assertNoDestructiveCertOps();
194
+ assertReadOnlyCertOps();
137
195
  const exec = options.exec || defaultExec;
138
- const prompt = options.prompt || ((questions) => inquirer.prompt(questions));
196
+ const confirm = resolveConfirm(options);
139
197
 
140
198
  let confirmed = options.yes === true;
141
199
  if (!confirmed) {
142
- const canPrompt = typeof options.prompt === 'function' || process.stdin.isTTY;
200
+ const canPrompt =
201
+ typeof options.confirm === 'function' ||
202
+ typeof options.prompt === 'function' ||
203
+ process.stdin.isTTY;
143
204
  if (!canPrompt) {
144
205
  console.log(
145
206
  chalk.red(
@@ -148,16 +209,10 @@ export async function certsTrust(options = {}) {
148
209
  );
149
210
  return 1;
150
211
  }
151
- const answers = await prompt([
152
- {
153
- type: 'confirm',
154
- name: 'ok',
155
- message:
156
- 'Install/trust the Caddy local root CA in the System keychain via `caddy trust`?',
157
- default: false,
158
- },
159
- ]);
160
- confirmed = answers.ok === true;
212
+ confirmed = await confirm(
213
+ 'Install/trust the Caddy local root CA in the System keychain via `caddy trust`?',
214
+ { default: false }
215
+ );
161
216
  }
162
217
 
163
218
  if (!confirmed) {
@@ -183,3 +238,304 @@ export async function certsTrust(options = {}) {
183
238
  return 1;
184
239
  }
185
240
  }
241
+
242
+ /**
243
+ * Repair certificates: site dirs, optional root move, optional orphan SHA-1 deletes.
244
+ *
245
+ * @param {object} [options]
246
+ * @param {boolean} [options.root]
247
+ * @param {boolean} [options.removeOrphans]
248
+ * @param {boolean} [options.yes]
249
+ * @param {boolean} [options.iUnderstandRootRenewal]
250
+ * @param {boolean} [options.verbose]
251
+ * @param {import('../lib/exec.js').ExecFn} [options.exec]
252
+ * @param {(message: string, opts?: object) => Promise<boolean>} [options.confirm]
253
+ * @param {(q: object[]) => Promise<object>} [options.prompt]
254
+ * @param {typeof runCertsCheck} [options.runCheck]
255
+ * @returns {Promise<number>}
256
+ */
257
+ export async function certsRenew(options = {}) {
258
+ const exec = options.exec || defaultExec;
259
+ const confirm = resolveConfirm(options);
260
+ const runCheck = options.runCheck || runCertsCheck;
261
+ const projectsPath = options.projectsPath || getProjectsPath();
262
+ const doc = await (options.loadProjects || loadProjects)(projectsPath);
263
+ const linkedDomains = Object.keys(doc.projects || {});
264
+
265
+ const canPrompt =
266
+ typeof options.confirm === 'function' ||
267
+ typeof options.prompt === 'function' ||
268
+ process.stdin.isTTY;
269
+
270
+ // --- root renewal (move CA folder) ---
271
+ if (options.root === true) {
272
+ if (options.removeOrphans === true) {
273
+ console.log(
274
+ chalk.red(
275
+ 'certs renew --root cannot be combined with --remove-orphans. Run them as separate commands.'
276
+ )
277
+ );
278
+ return 1;
279
+ }
280
+
281
+ assertDestructiveCertOpAllowed('renewRootMoveBackup');
282
+
283
+ let confirmed = false;
284
+ if (
285
+ options.yes === true &&
286
+ options.iUnderstandRootRenewal === true
287
+ ) {
288
+ confirmed = true;
289
+ } else if (options.yes === true) {
290
+ // AC-15: --yes alone always aborts (TTY or not); need the explicit flag too.
291
+ console.log(
292
+ chalk.red(
293
+ 'certs renew --root with --yes also requires --i-understand-root-renewal. Or omit --yes for two interactive confirmations.'
294
+ )
295
+ );
296
+ return 1;
297
+ } else if (!canPrompt) {
298
+ console.log(
299
+ chalk.red(
300
+ 'certs renew --root requires two interactive confirmations, or --yes --i-understand-root-renewal.'
301
+ )
302
+ );
303
+ return 1;
304
+ } else {
305
+ const first = await confirm(
306
+ 'Move the Caddy local CA folder to a timestamped backup? Browsers will need `stagepass certs trust` afterwards.',
307
+ { default: false }
308
+ );
309
+ if (!first) {
310
+ console.log(chalk.dim('Cancelled.'));
311
+ return 1;
312
+ }
313
+ const second = await confirm(
314
+ 'Confirm again: Stagepass will MOVE (not delete) pki/authorities/local. Continue?',
315
+ { default: false }
316
+ );
317
+ confirmed = second === true;
318
+ }
319
+
320
+ if (!confirmed) {
321
+ console.log(chalk.dim('Cancelled.'));
322
+ return 1;
323
+ }
324
+
325
+ const moved = await (options.moveLocalCaAuthorityToBackup ||
326
+ moveLocalCaAuthorityToBackup)({
327
+ authorityDir: options.authorityDir,
328
+ now: options.now,
329
+ move: options.move,
330
+ pathExists: options.pathExists,
331
+ lstat: options.lstat,
332
+ });
333
+
334
+ if (!moved.ok) {
335
+ console.log(chalk.red(`Root renew failed: ${moved.error}`));
336
+ return 1;
337
+ }
338
+
339
+ console.log(chalk.green('Local CA folder moved to backup.'));
340
+ console.log(chalk.dim(` From: ${moved.authorityDir}`));
341
+ console.log(chalk.dim(` To: ${moved.backupDir}`));
342
+ console.log(
343
+ chalk.yellow(
344
+ 'Next: start or reload Caddy so it regenerates a CA, then run `stagepass certs trust`.'
345
+ )
346
+ );
347
+ return 0;
348
+ }
349
+
350
+ // --- orphan keychain removal by SHA-1 ---
351
+ if (options.removeOrphans === true) {
352
+ assertDestructiveCertOpAllowed('deleteKeychainItemBySha1');
353
+
354
+ const brewPrefix =
355
+ options.brewPrefix !== undefined
356
+ ? options.brewPrefix
357
+ : await resolveBrewPrefix(exec);
358
+
359
+ const report = await runCheck({
360
+ exec,
361
+ domains: [],
362
+ skipHandshake: true,
363
+ rootPath: options.rootPath,
364
+ keychainPath: options.keychainPath,
365
+ pathExists: options.pathExists,
366
+ readFile: options.readFile,
367
+ brewPrefix,
368
+ });
369
+ const orphans = report.orphans || [];
370
+ if (orphans.length === 0) {
371
+ console.log(chalk.green('No orphaned Caddy roots to remove.'));
372
+ return 0;
373
+ }
374
+
375
+ console.log(
376
+ chalk.bold(
377
+ `\nRemoving ${orphans.length} orphaned Caddy root(s) by SHA-1 (never by CN):\n`
378
+ )
379
+ );
380
+
381
+ let removed = 0;
382
+ for (const orphan of orphans) {
383
+ const normalized = normalizeSha1Fingerprint(orphan.sha1 || '');
384
+ if (!normalized.ok) {
385
+ console.log(
386
+ chalk.yellow(
387
+ `Skipping orphan without valid SHA-1 (SHA-256 ${orphan.sha256 || '?'}).`
388
+ )
389
+ );
390
+ continue;
391
+ }
392
+
393
+ let ok = options.yes === true;
394
+ if (!ok) {
395
+ if (!canPrompt) {
396
+ console.log(
397
+ chalk.red(
398
+ 'certs renew --remove-orphans requires interactive confirmation per certificate or --yes.'
399
+ )
400
+ );
401
+ return 1;
402
+ }
403
+ ok = await confirm(
404
+ `Delete keychain certificate SHA-1 ${normalized.sha1}?`,
405
+ { default: false }
406
+ );
407
+ }
408
+ if (!ok) {
409
+ console.log(chalk.dim(`Skipped ${normalized.sha1}`));
410
+ continue;
411
+ }
412
+
413
+ // System keychain deletes typically need sudo; warm only when acting.
414
+ if (options.skipSudo !== true) {
415
+ try {
416
+ await exec('sudo', ['-v'], { stdio: 'inherit' });
417
+ } catch {
418
+ console.log(chalk.red('sudo required to delete System keychain items.'));
419
+ return 1;
420
+ }
421
+ }
422
+
423
+ const result = await (options.deleteKeychainCertificateBySha1 ||
424
+ deleteKeychainCertificateBySha1)({
425
+ sha1: normalized.sha1,
426
+ exec,
427
+ keychainPath: options.keychainPath,
428
+ });
429
+ if (!result.ok) {
430
+ console.log(
431
+ chalk.red(`Failed to delete ${normalized.sha1}: ${result.error}`)
432
+ );
433
+ return 1;
434
+ }
435
+ console.log(chalk.green(`Deleted SHA-1 ${normalized.sha1}`));
436
+ console.log(chalk.dim(` security ${result.args.join(' ')}`));
437
+ removed += 1;
438
+ }
439
+
440
+ console.log(chalk.bold(`\nRemoved ${removed} orphan(s).`));
441
+ return 0;
442
+ }
443
+
444
+ // --- default: site certificate repair for failing linked domains ---
445
+ assertDestructiveCertOpAllowed('renewSiteCertDir');
446
+
447
+ if (linkedDomains.length === 0) {
448
+ console.log(chalk.yellow('No linked .sp domains; nothing to renew.'));
449
+ return 0;
450
+ }
451
+
452
+ const report = await runCheck({
453
+ exec,
454
+ domains: linkedDomains,
455
+ skipHandshake: false,
456
+ rootPath: options.rootPath,
457
+ keychainPath: options.keychainPath,
458
+ pathExists: options.pathExists,
459
+ readFile: options.readFile,
460
+ connect: options.connect,
461
+ handshakeHost: options.handshakeHost,
462
+ handshakePort: options.handshakePort,
463
+ handshakeTimeoutMs: options.handshakeTimeoutMs,
464
+ });
465
+
466
+ const needing = domainsNeedingSiteCertRenewal(report.handshakes || []);
467
+ if (needing.length === 0) {
468
+ console.log(
469
+ chalk.green(
470
+ 'No failing site/intermediate certificates detected for linked domains.'
471
+ )
472
+ );
473
+ if (report.root.status === 'fail') {
474
+ console.log(
475
+ chalk.dim(
476
+ 'Root CA looks broken; use `stagepass certs renew --root` (double confirmation).'
477
+ )
478
+ );
479
+ }
480
+ return 0;
481
+ }
482
+
483
+ console.log(
484
+ chalk.yellow(
485
+ `\nFailing TLS for: ${needing.join(', ')}\nScoped delete of certificates/local/<domain> then caddy reload.\n`
486
+ )
487
+ );
488
+
489
+ let confirmed = options.yes === true;
490
+ if (!confirmed) {
491
+ if (!canPrompt) {
492
+ console.log(
493
+ chalk.red(
494
+ 'certs renew requires interactive confirmation or --yes (refusing non-TTY without --yes).'
495
+ )
496
+ );
497
+ return 1;
498
+ }
499
+ confirmed = await confirm(
500
+ `Delete on-disk site cert dirs for ${needing.join(', ')} and reload Caddy?`,
501
+ { default: false }
502
+ );
503
+ }
504
+ if (!confirmed) {
505
+ console.log(chalk.dim('Cancelled.'));
506
+ return 1;
507
+ }
508
+
509
+ const result = await (options.renewSiteCertificates || renewSiteCertificates)({
510
+ domains: needing,
511
+ linkedDomains,
512
+ exec,
513
+ certificatesLocalDir: options.certificatesLocalDir,
514
+ caddyfilePath: options.caddyfilePath || getCaddyfilePath(),
515
+ remove: options.remove,
516
+ lstat: options.lstat,
517
+ pathExists: options.pathExists,
518
+ });
519
+
520
+ for (const d of result.deleted) {
521
+ console.log(chalk.green(`Removed ${d.dir}`));
522
+ }
523
+ for (const err of result.errors) {
524
+ console.log(chalk.red(`${err.domain}: ${err.error}`));
525
+ }
526
+ if (result.deleted.length > 0) {
527
+ if (result.reloaded) {
528
+ console.log(chalk.green('caddy reload completed.'));
529
+ } else if (result.reloadDeferred) {
530
+ console.log(
531
+ chalk.yellow('Caddy is not running; certs issue on next `stagepass start`.')
532
+ );
533
+ } else {
534
+ console.log(
535
+ chalk.red(`caddy reload failed: ${result.reloadError || 'unknown error'}`)
536
+ );
537
+ return 1;
538
+ }
539
+ }
540
+ return result.errors.length > 0 && result.deleted.length === 0 ? 1 : 0;
541
+ }
@@ -5,6 +5,8 @@ import { getCaddyfilePath, getLogsDir } from '../lib/paths.js';
5
5
  import { runCertsCheck } from '../lib/certs.js';
6
6
  import { loadProjects } from '../lib/projects.js';
7
7
  import { getProjectsPath } from '../lib/paths.js';
8
+ import { ensurePhpFpm } from '../lib/php-fpm.js';
9
+ import { notifyMac } from '../lib/notify.js';
8
10
 
9
11
  /**
10
12
  * Detect bind / permission failures that will not self-heal on immediate restart.
@@ -18,15 +20,26 @@ export function isPermanentDaemonFailure(detail) {
18
20
  );
19
21
  }
20
22
 
23
+ /**
24
+ * Best-effort notification; never throws.
25
+ * @param {object} opts
26
+ */
27
+ async function safeNotify(opts) {
28
+ try {
29
+ await (opts.notify || notifyMac)({
30
+ title: opts.title || 'Stagepass',
31
+ body: opts.body,
32
+ exec: opts.exec,
33
+ });
34
+ } catch {
35
+ // ignore
36
+ }
37
+ }
38
+
21
39
  /**
22
40
  * Non-interactive foreground daemon for LaunchAgent use.
23
- * Never uses sudo. Runs certs check (log only, no TLS handshake), then `caddy run`.
24
- *
25
- * Existing `stagepass start` also launches Caddy as the user (sudo is only for
26
- * port conflict helpers). Binding TCP 443 as a user LaunchAgent is therefore
27
- * expected to work on macOS the same way. Permanent startup failures (missing
28
- * Caddyfile, port 443 bind) exit 0 after logging so launchd KeepAlive does not
29
- * restart-loop; unexpected mid-run failures exit 1 so KeepAlive can retry.
41
+ * Never uses sudo. Ensures PHP-FPM, runs certs check (log only, no TLS handshake),
42
+ * then `caddy run`. Problems are reported via macOS notifications (best effort).
30
43
  *
31
44
  * @param {object} [options]
32
45
  * @param {import('../lib/exec.js').ExecFn} [options.exec]
@@ -51,10 +64,41 @@ export async function daemon(options = {}) {
51
64
  if (!(await pathExists(caddyfilePath))) {
52
65
  log(`Caddyfile missing: ${caddyfilePath}`);
53
66
  log('Refusing to start. Run: stagepass setup && stagepass link');
67
+ await safeNotify({
68
+ exec,
69
+ notify: options.notify,
70
+ body: 'Caddyfile missing. Run stagepass setup && stagepass link.',
71
+ });
54
72
  // Exit 0: permanent until the user fixes config; avoid KeepAlive restart loop.
55
73
  return 0;
56
74
  }
57
75
 
76
+ // PHP-FPM (non-interactive, never sudo)
77
+ try {
78
+ const php = await (options.ensurePhpFpm || ensurePhpFpm)({
79
+ exec,
80
+ stdio: 'ignore',
81
+ });
82
+ if (php.ok) {
83
+ log(`php-fpm: ${php.action}`);
84
+ } else {
85
+ log(`php-fpm failed: ${php.detail || 'unknown error'}`);
86
+ await safeNotify({
87
+ exec,
88
+ notify: options.notify,
89
+ body: `PHP-FPM failed: ${php.detail || 'unknown error'}`,
90
+ });
91
+ }
92
+ } catch (error) {
93
+ const detail = error instanceof Error ? error.message : String(error);
94
+ log(`php-fpm error: ${detail}`);
95
+ await safeNotify({
96
+ exec,
97
+ notify: options.notify,
98
+ body: `PHP-FPM error: ${detail}`,
99
+ });
100
+ }
101
+
58
102
  // Non-interactive cert check (log only; never prompts; never repairs).
59
103
  // Skip TLS handshakes: Caddy is not running yet during cold start.
60
104
  try {
@@ -80,6 +124,20 @@ export async function daemon(options = {}) {
80
124
  .join(', ')})`
81
125
  );
82
126
  }
127
+ if (report.trust && !report.trust.trusted) {
128
+ await safeNotify({
129
+ exec,
130
+ notify: options.notify,
131
+ body: 'Caddy local CA is not trusted. Run: stagepass certs trust',
132
+ });
133
+ }
134
+ if (report.root.status === 'fail') {
135
+ await safeNotify({
136
+ exec,
137
+ notify: options.notify,
138
+ body: `Certificate root problem: ${report.root.reason}`,
139
+ });
140
+ }
83
141
  } catch (error) {
84
142
  log(
85
143
  `certs check failed (continuing): ${
@@ -112,12 +170,22 @@ export async function daemon(options = {}) {
112
170
  log(
113
171
  'Port 443 bind/listen failed for the user LaunchAgent. Exiting without KeepAlive retry. Use interactive `stagepass start` (which can resolve conflicts with confirmation), or free port 443, then retry.'
114
172
  );
173
+ await safeNotify({
174
+ exec,
175
+ notify: options.notify,
176
+ body: `Caddy could not bind port 443: ${detail}`,
177
+ });
115
178
  if (process.stderr.isTTY) {
116
179
  console.error(chalk.red(detail));
117
180
  }
118
181
  // Exit 0 so SuccessfulExit=false KeepAlive does not restart-loop.
119
182
  return 0;
120
183
  }
184
+ await safeNotify({
185
+ exec,
186
+ notify: options.notify,
187
+ body: `Caddy failed: ${detail}`,
188
+ });
121
189
  if (process.stderr.isTTY) {
122
190
  console.error(chalk.red(detail));
123
191
  }