learnhouse 1.6.0 → 1.7.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.
@@ -44,13 +44,13 @@ var require_picocolors = __commonJS({
44
44
  return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
45
45
  };
46
46
  var replaceClose = (string, close, replace, index) => {
47
- let result = "", cursor3 = 0;
47
+ let result = "", cursor2 = 0;
48
48
  do {
49
- result += string.substring(cursor3, index) + replace;
50
- cursor3 = index + close.length;
51
- index = string.indexOf(close, cursor3);
49
+ result += string.substring(cursor2, index) + replace;
50
+ cursor2 = index + close.length;
51
+ index = string.indexOf(close, cursor2);
52
52
  } while (~index);
53
- return result + string.substring(cursor3);
53
+ return result + string.substring(cursor2);
54
54
  };
55
55
  var createColors = (enabled = isColorSupported) => {
56
56
  let f = enabled ? formatter : () => String;
@@ -104,62 +104,6 @@ var require_picocolors = __commonJS({
104
104
  }
105
105
  });
106
106
 
107
- // node_modules/sisteransi/src/index.js
108
- var require_src = __commonJS({
109
- "node_modules/sisteransi/src/index.js"(exports, module) {
110
- "use strict";
111
- var ESC2 = "\x1B";
112
- var CSI2 = `${ESC2}[`;
113
- var beep = "\x07";
114
- var cursor3 = {
115
- to(x, y2) {
116
- if (!y2) return `${CSI2}${x + 1}G`;
117
- return `${CSI2}${y2 + 1};${x + 1}H`;
118
- },
119
- move(x, y2) {
120
- let ret = "";
121
- if (x < 0) ret += `${CSI2}${-x}D`;
122
- else if (x > 0) ret += `${CSI2}${x}C`;
123
- if (y2 < 0) ret += `${CSI2}${-y2}A`;
124
- else if (y2 > 0) ret += `${CSI2}${y2}B`;
125
- return ret;
126
- },
127
- up: (count = 1) => `${CSI2}${count}A`,
128
- down: (count = 1) => `${CSI2}${count}B`,
129
- forward: (count = 1) => `${CSI2}${count}C`,
130
- backward: (count = 1) => `${CSI2}${count}D`,
131
- nextLine: (count = 1) => `${CSI2}E`.repeat(count),
132
- prevLine: (count = 1) => `${CSI2}F`.repeat(count),
133
- left: `${CSI2}G`,
134
- hide: `${CSI2}?25l`,
135
- show: `${CSI2}?25h`,
136
- save: `${ESC2}7`,
137
- restore: `${ESC2}8`
138
- };
139
- var scroll = {
140
- up: (count = 1) => `${CSI2}S`.repeat(count),
141
- down: (count = 1) => `${CSI2}T`.repeat(count)
142
- };
143
- var erase3 = {
144
- screen: `${CSI2}2J`,
145
- up: (count = 1) => `${CSI2}1J`.repeat(count),
146
- down: (count = 1) => `${CSI2}J`.repeat(count),
147
- line: `${CSI2}2K`,
148
- lineEnd: `${CSI2}K`,
149
- lineStart: `${CSI2}1K`,
150
- lines(count) {
151
- let clear = "";
152
- for (let i2 = 0; i2 < count; i2++)
153
- clear += this.line + (i2 < count - 1 ? cursor3.up() : "");
154
- if (count)
155
- clear += cursor3.left;
156
- return clear;
157
- }
158
- };
159
- module.exports = { cursor: cursor3, scroll, erase: erase3, beep };
160
- }
161
- });
162
-
163
107
  // node_modules/commander/lib/error.js
164
108
  var CommanderError = class extends Error {
165
109
  /**
@@ -387,11 +331,11 @@ var Help = class {
387
331
  visibleOptions.push(helpOption);
388
332
  } else if (helpOption.long && !removeLong) {
389
333
  visibleOptions.push(
390
- cmd.createOption(helpOption.long, helpOption.description)
334
+ cmd.createOption(helpOption.long, helpOption.description).helpGroup(helpOption.helpGroupHeading)
391
335
  );
392
336
  } else if (helpOption.short && !removeShort) {
393
337
  visibleOptions.push(
394
- cmd.createOption(helpOption.short, helpOption.description)
338
+ cmd.createOption(helpOption.short, helpOption.description).helpGroup(helpOption.helpGroupHeading)
395
339
  );
396
340
  }
397
341
  }
@@ -923,7 +867,7 @@ var Option = class {
923
867
  this.description = description || "";
924
868
  this.required = flags.includes("<");
925
869
  this.optional = flags.includes("[");
926
- this.variadic = /\w\.\.\.[>\]]$/.test(flags);
870
+ this.variadic = new RegExp("\\p{ID_Continue}\\.\\.\\.[>\\]]$", "u").test(flags);
927
871
  this.mandatory = false;
928
872
  const optionFlags = splitOptionFlags(flags);
929
873
  this.short = optionFlags.shortFlag;
@@ -2106,7 +2050,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2106
2050
  getOptionValueSourceWithGlobals(key) {
2107
2051
  let source;
2108
2052
  this._getCommandAndAncestors().forEach((cmd) => {
2109
- if (cmd.getOptionValueSource(key) !== void 0) {
2053
+ if (Object.hasOwn(cmd._optionValueSources, key)) {
2110
2054
  source = cmd.getOptionValueSource(key);
2111
2055
  }
2112
2056
  });
@@ -2749,7 +2693,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2749
2693
  return arg.length > 1 && arg[0] === "-";
2750
2694
  }
2751
2695
  const negativeNumberArg = (arg) => {
2752
- if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg)) return false;
2696
+ if (!/^-(\d+|\d*\.\d+)([eE][+-]?\d+)?$/.test(arg)) return false;
2753
2697
  return !this._getCommandAndAncestors().some(
2754
2698
  (cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short))
2755
2699
  );
@@ -3197,7 +3141,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3197
3141
  * (This does not override a group set directly on the subcommand using .helpGroup().)
3198
3142
  *
3199
3143
  * @example
3200
- * program.commandsGroup('Development Commands:);
3144
+ * program.commandsGroup('Development Commands:');
3201
3145
  * program.command('watch')...
3202
3146
  * program.command('lint')...
3203
3147
  * ...
@@ -3368,7 +3312,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3368
3312
  * Pass in false to disable the built-in help option.
3369
3313
  *
3370
3314
  * @example
3371
- * program.helpOption('-?, --help' 'show help'); // customise
3315
+ * program.helpOption('-?, --help', 'show help'); // customise
3372
3316
  * program.helpOption(false); // disable
3373
3317
  *
3374
3318
  * @param {(string | boolean)} flags
@@ -3497,16 +3441,20 @@ function incrementNodeInspectorPort(args) {
3497
3441
  let debugHost = "127.0.0.1";
3498
3442
  let debugPort = "9229";
3499
3443
  let match;
3500
- if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
3444
+ if ((match = arg.match(/^(--inspect(-brk|-wait)?)$/)) !== null) {
3501
3445
  debugOption = match[1];
3502
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
3446
+ } else if ((match = arg.match(
3447
+ /^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+)$/
3448
+ )) !== null) {
3503
3449
  debugOption = match[1];
3504
3450
  if (/^\d+$/.test(match[3])) {
3505
3451
  debugPort = match[3];
3506
3452
  } else {
3507
3453
  debugHost = match[3];
3508
3454
  }
3509
- } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
3455
+ } else if ((match = arg.match(
3456
+ /^(--inspect(-brk|-port|-wait)?)=(\[[^\]]+\]|[^:]+):(\d+)$/
3457
+ )) !== null) {
3510
3458
  debugOption = match[1];
3511
3459
  debugHost = match[3];
3512
3460
  debugPort = match[4];
@@ -3532,7 +3480,7 @@ var program = new Command();
3532
3480
  var import_picocolors26 = __toESM(require_picocolors(), 1);
3533
3481
 
3534
3482
  // src/constants.ts
3535
- var VERSION = "1.6.0";
3483
+ var VERSION = "1.7.0";
3536
3484
  var APP_IMAGE = "ghcr.io/learnhouse/app:latest";
3537
3485
  var DEV_IMAGE = "ghcr.io/learnhouse/app:dev";
3538
3486
  var NGINX_IMAGE = "nginx:1.30-alpine";
@@ -3569,7 +3517,7 @@ var ICON = [
3569
3517
  "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588",
3570
3518
  "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588"
3571
3519
  ];
3572
- var ICON_W = Math.max(...ICON.map((l2) => l2.length));
3520
+ var ICON_W = Math.max(...ICON.map((l) => l.length));
3573
3521
  function center(s, width) {
3574
3522
  const pad = Math.max(0, width - s.length);
3575
3523
  return " ".repeat(Math.floor(pad / 2)) + s;
@@ -3637,7 +3585,7 @@ function validateEmail(value) {
3637
3585
  const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
3638
3586
  if (!re.test(value)) return "Please enter a valid email address";
3639
3587
  const domain = value.slice(value.lastIndexOf("@") + 1).toLowerCase();
3640
- if (!domain.split(".").every((l2) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/.test(l2))) {
3588
+ if (!domain.split(".").every((l) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/.test(l))) {
3641
3589
  return "Please enter a valid email address";
3642
3590
  }
3643
3591
  const tld = domain.includes(".") ? domain.slice(domain.lastIndexOf(".") + 1) : domain;
@@ -3657,9 +3605,12 @@ function validatePassword(value) {
3657
3605
  function validateDomain(value) {
3658
3606
  if (!value) return "Domain is required";
3659
3607
  if (value === "localhost") return void 0;
3608
+ if (/^\d{1,3}(\.\d{1,3}){3}$/.test(value)) {
3609
+ return value.split(".").every((o) => Number(o) <= 255) ? void 0 : "Please enter a valid IP address";
3610
+ }
3660
3611
  const re = /^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/;
3661
3612
  if (!re.test(value)) return "Please enter a valid domain (e.g., learnhouse.example.com)";
3662
- if (value.length > 253 || value.split(".").some((l2) => l2.length > 63)) {
3613
+ if (value.length > 253 || value.split(".").some((l) => l.length > 63)) {
3663
3614
  return "Domain is too long (max 253 characters, 63 per label)";
3664
3615
  }
3665
3616
  return void 0;
@@ -3797,8 +3748,8 @@ import path10 from "path";
3797
3748
  // node_modules/@clack/core/dist/index.mjs
3798
3749
  import { styleText } from "util";
3799
3750
  import { stdout, stdin } from "process";
3800
- import * as l from "readline";
3801
- import l__default from "readline";
3751
+ import * as f$1 from "readline";
3752
+ import f__default from "readline";
3802
3753
 
3803
3754
  // node_modules/fast-string-truncated-width/dist/utils.js
3804
3755
  var getCodePointsLength = /* @__PURE__ */ (() => {
@@ -3886,7 +3837,7 @@ var getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})
3886
3837
  if (index >= length) {
3887
3838
  break outer;
3888
3839
  }
3889
- for (let i2 = 0, l2 = PARSE_BLOCKS.length; i2 < l2; i2++) {
3840
+ for (let i2 = 0, l = PARSE_BLOCKS.length; i2 < l; i2++) {
3890
3841
  const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i2];
3891
3842
  BLOCK_RE.lastIndex = index;
3892
3843
  if (BLOCK_RE.test(input)) {
@@ -4136,14 +4087,66 @@ function wrapAnsi(string, columns, options) {
4136
4087
  return String(string).normalize().split(CRLF_OR_LF).map((line) => exec(line, columns, options)).join("\n");
4137
4088
  }
4138
4089
 
4090
+ // node_modules/sisteransi/dist/index.js
4091
+ var ESC2 = "\x1B";
4092
+ var CSI2 = `${ESC2}[`;
4093
+ var cursor = {
4094
+ to(x, y) {
4095
+ if (!y)
4096
+ return `${CSI2}${x + 1}G`;
4097
+ return `${CSI2}${y + 1};${x + 1}H`;
4098
+ },
4099
+ move(x, y) {
4100
+ let ret = "";
4101
+ if (x < 0)
4102
+ ret += `${CSI2}${-x}D`;
4103
+ else if (x > 0)
4104
+ ret += `${CSI2}${x}C`;
4105
+ if (y < 0)
4106
+ ret += `${CSI2}${-y}A`;
4107
+ else if (y > 0)
4108
+ ret += `${CSI2}${y}B`;
4109
+ return ret;
4110
+ },
4111
+ up: (count = 1) => `${CSI2}${count}A`,
4112
+ down: (count = 1) => `${CSI2}${count}B`,
4113
+ forward: (count = 1) => `${CSI2}${count}C`,
4114
+ backward: (count = 1) => `${CSI2}${count}D`,
4115
+ nextLine: (count = 1) => `${CSI2}E`.repeat(count),
4116
+ prevLine: (count = 1) => `${CSI2}F`.repeat(count),
4117
+ left: `${CSI2}G`,
4118
+ hide: `${CSI2}?25l`,
4119
+ show: `${CSI2}?25h`,
4120
+ save: `${ESC2}7`,
4121
+ restore: `${ESC2}8`
4122
+ };
4123
+ var erase = {
4124
+ screen: `${CSI2}2J`,
4125
+ up: (count = 1) => `${CSI2}1J`.repeat(count),
4126
+ down: (count = 1) => `${CSI2}J`.repeat(count),
4127
+ line: `${CSI2}2K`,
4128
+ lineEnd: `${CSI2}K`,
4129
+ lineStart: `${CSI2}1K`,
4130
+ lines(count) {
4131
+ let clear2 = "";
4132
+ for (let i2 = 0; i2 < count; i2++)
4133
+ clear2 += this.line + (i2 < count - 1 ? cursor.up() : "");
4134
+ if (count)
4135
+ clear2 += cursor.left;
4136
+ return clear2;
4137
+ }
4138
+ };
4139
+ var clear = {
4140
+ screen: `${ESC2}c`
4141
+ };
4142
+
4139
4143
  // node_modules/@clack/core/dist/index.mjs
4140
- var import_sisteransi = __toESM(require_src(), 1);
4141
4144
  import { ReadStream } from "tty";
4142
- function findCursor(s, o, l2) {
4143
- if (!l2.some((r2) => !r2.disabled))
4144
- return s;
4145
- const t2 = s + o, n3 = Math.max(l2.length - 1, 0), e = t2 < 0 ? n3 : t2 > n3 ? 0 : t2;
4146
- return l2[e]?.disabled ? findCursor(e, o < 0 ? -1 : 1, l2) : e;
4145
+ function findCursor(o, s, l) {
4146
+ if (!l.some((r2) => !r2.disabled))
4147
+ return o;
4148
+ const t2 = o + s, n3 = Math.max(l.length - 1, 0), e = t2 < 0 ? n3 : t2 > n3 ? 0 : t2;
4149
+ return l[e]?.disabled ? findCursor(e, s < 0 ? -1 : 1, l) : e;
4147
4150
  }
4148
4151
  var a$1 = ["up", "down", "left", "right", "space", "enter", "cancel"];
4149
4152
  var t = [
@@ -4232,42 +4235,42 @@ function block({
4232
4235
  overwrite: o = true,
4233
4236
  hideCursor: n3 = true
4234
4237
  } = {}) {
4235
- const s = l.createInterface({
4238
+ const s = f$1.createInterface({
4236
4239
  input: e,
4237
4240
  output: r2,
4238
4241
  prompt: "",
4239
4242
  tabSize: 1
4240
4243
  });
4241
- l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
4242
- const t2 = (f, { name: a2, sequence: w }) => {
4243
- const c2 = String(f);
4244
- if (isActionKey([c2, a2, w], "cancel")) {
4245
- n3 && r2.write(import_sisteransi.cursor.show), process.exit(0);
4244
+ f$1.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
4245
+ const t2 = (l, { name: i2, sequence: p }) => {
4246
+ const w = String(l);
4247
+ if (isActionKey([w, i2, p], "cancel")) {
4248
+ n3 && r2.write(cursor.show), process.exit(0);
4246
4249
  return;
4247
4250
  }
4248
4251
  if (!o) return;
4249
- const i2 = a2 === "return" ? 0 : -1, m2 = a2 === "return" ? -1 : 0;
4250
- l.moveCursor(r2, i2, m2, () => {
4251
- l.clearLine(r2, 1, () => {
4252
+ const c3 = i2 === "return" ? 0 : -1, a2 = i2 === "return" ? -1 : 0;
4253
+ f$1.moveCursor(r2, c3, a2, () => {
4254
+ f$1.clearLine(r2, 1, () => {
4252
4255
  e.once("keypress", t2);
4253
4256
  });
4254
4257
  });
4255
4258
  };
4256
- return n3 && r2.write(import_sisteransi.cursor.hide), e.once("keypress", t2), () => {
4257
- e.off("keypress", t2), n3 && r2.write(import_sisteransi.cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
4259
+ return n3 && r2.write(cursor.hide), e.once("keypress", t2), () => {
4260
+ e.off("keypress", t2), n3 && r2.write(cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
4258
4261
  };
4259
4262
  }
4260
4263
  var getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80;
4261
4264
  var getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
4262
4265
  function wrapTextWithPrefix(e, r2, o, n3 = o, s = o, t2) {
4263
- const f = getColumns(e ?? stdout);
4264
- return wrapAnsi(r2, f - o.length, {
4266
+ const l = getColumns(e ?? stdout), i2 = dist_default2(o);
4267
+ return wrapAnsi(r2, l - i2, {
4265
4268
  hard: true,
4266
4269
  trim: false
4267
4270
  }).split(`
4268
- `).map((c2, i2, m2) => {
4269
- const d = t2 ? t2(c2, i2) : c2;
4270
- return i2 === 0 ? `${n3}${d}` : i2 === m2.length - 1 ? `${s}${d}` : `${o}${d}`;
4271
+ `).map((c3, a2, g) => {
4272
+ const m2 = t2 ? t2(c3, a2) : c3;
4273
+ return a2 === 0 ? `${n3}${m2}` : a2 === g.length - 1 ? `${s}${m2}` : `${o}${m2}`;
4271
4274
  }).join(`
4272
4275
  `);
4273
4276
  }
@@ -4278,7 +4281,7 @@ function runValidation(e, a2) {
4278
4281
  }
4279
4282
  return e(a2);
4280
4283
  }
4281
- var y = class {
4284
+ var C$1 = class C {
4282
4285
  input;
4283
4286
  output;
4284
4287
  _abortSignal;
@@ -4360,16 +4363,16 @@ var y = class {
4360
4363
  { once: true }
4361
4364
  );
4362
4365
  }
4363
- this.rl = l__default.createInterface({
4366
+ this.rl = f__default.createInterface({
4364
4367
  input: this.input,
4365
4368
  tabSize: 2,
4366
4369
  prompt: "",
4367
4370
  escapeCodeTimeout: 50,
4368
4371
  terminal: true
4369
4372
  }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
4370
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
4373
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(this.value);
4371
4374
  }), this.once("cancel", () => {
4372
- this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
4375
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t2(CANCEL_SYMBOL);
4373
4376
  });
4374
4377
  });
4375
4378
  }
@@ -4406,18 +4409,18 @@ var y = class {
4406
4409
  `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
4407
4410
  }
4408
4411
  restoreCursor() {
4409
- const t2 = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
4412
+ const t2 = wrapAnsi(this._prevFrame, getColumns(this.output), { hard: true, trim: false }).split(`
4410
4413
  `).length - 1;
4411
- this.output.write(import_sisteransi.cursor.move(-999, t2 * -1));
4414
+ this.output.write(cursor.move(-999, t2 * -1));
4412
4415
  }
4413
4416
  render() {
4414
- const t2 = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
4417
+ const t2 = wrapAnsi(this._render(this) ?? "", getColumns(this.output), {
4415
4418
  hard: true,
4416
4419
  trim: false
4417
4420
  });
4418
4421
  if (t2 !== this._prevFrame) {
4419
4422
  if (this.state === "initial")
4420
- this.output.write(import_sisteransi.cursor.hide);
4423
+ this.output.write(cursor.hide);
4421
4424
  else {
4422
4425
  const e = diffLines(this._prevFrame, t2), i2 = getRows(this.output);
4423
4426
  if (this.restoreCursor(), e) {
@@ -4428,33 +4431,33 @@ var y = class {
4428
4431
  return;
4429
4432
  }
4430
4433
  if (e.lines.length === 1) {
4431
- this.output.write(import_sisteransi.cursor.move(0, n3 - r2)), this.output.write(import_sisteransi.erase.lines(1));
4434
+ this.output.write(cursor.move(0, n3 - r2)), this.output.write(erase.lines(1));
4432
4435
  const o = t2.split(`
4433
4436
  `);
4434
- this.output.write(o[n3]), this._prevFrame = t2, this.output.write(import_sisteransi.cursor.move(0, o.length - n3 - 1));
4437
+ this.output.write(o[n3]), this._prevFrame = t2, this.output.write(cursor.move(0, o.length - n3 - 1));
4435
4438
  return;
4436
4439
  } else if (e.lines.length > 1) {
4437
4440
  if (s < r2)
4438
4441
  n3 = s;
4439
4442
  else {
4440
4443
  const h2 = n3 - r2;
4441
- h2 > 0 && this.output.write(import_sisteransi.cursor.move(0, h2));
4444
+ h2 > 0 && this.output.write(cursor.move(0, h2));
4442
4445
  }
4443
- this.output.write(import_sisteransi.erase.down());
4444
- const f = t2.split(`
4446
+ this.output.write(erase.down());
4447
+ const m2 = t2.split(`
4445
4448
  `).slice(n3);
4446
- this.output.write(f.join(`
4449
+ this.output.write(m2.join(`
4447
4450
  `)), this._prevFrame = t2;
4448
4451
  return;
4449
4452
  }
4450
4453
  }
4451
- this.output.write(import_sisteransi.erase.down());
4454
+ this.output.write(erase.down());
4452
4455
  }
4453
4456
  this.output.write(t2), this.state === "initial" && (this.state = "active"), this._prevFrame = t2;
4454
4457
  }
4455
4458
  }
4456
4459
  };
4457
- var r = class extends y {
4460
+ var r = class extends C$1 {
4458
4461
  get cursor() {
4459
4462
  return this.value ? 0 : 1;
4460
4463
  }
@@ -4465,13 +4468,13 @@ var r = class extends y {
4465
4468
  super(t2, false), this.value = !!t2.initialValue, this.on("userInput", () => {
4466
4469
  this.value = this._value;
4467
4470
  }), this.on("confirm", (i2) => {
4468
- this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
4471
+ this.output.write(cursor.move(0, -1)), this.value = i2, this.state = "submit", this.close();
4469
4472
  }), this.on("cursor", () => {
4470
4473
  this.value = !this.value;
4471
4474
  });
4472
4475
  }
4473
4476
  };
4474
- var a = class extends y {
4477
+ var a = class extends C$1 {
4475
4478
  options;
4476
4479
  cursor = 0;
4477
4480
  get _value() {
@@ -4502,8 +4505,8 @@ var a = class extends y {
4502
4505
  this.options.findIndex(({ value: t2 }) => t2 === e.cursorAt),
4503
4506
  0
4504
4507
  );
4505
- this.cursor = this.options[i2]?.disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2, l2) => {
4506
- l2.name === "a" && this.toggleAll(), l2.name === "i" && this.toggleInvert();
4508
+ this.cursor = this.options[i2]?.disabled ? findCursor(i2, 1, this.options) : i2, this.on("key", (t2, s) => {
4509
+ s.name === "a" && this.toggleAll(), s.name === "i" && this.toggleInvert(), s.name === void 0 && t2 === "\u3000" && this.toggleValue();
4507
4510
  }), this.on("cursor", (t2) => {
4508
4511
  switch (t2) {
4509
4512
  case "left":
@@ -4521,7 +4524,7 @@ var a = class extends y {
4521
4524
  });
4522
4525
  }
4523
4526
  };
4524
- var u$1 = class u extends y {
4527
+ var u = class extends C$1 {
4525
4528
  _mask = "\u2022";
4526
4529
  get cursor() {
4527
4530
  return this._cursor;
@@ -4549,7 +4552,7 @@ var u$1 = class u extends y {
4549
4552
  });
4550
4553
  }
4551
4554
  };
4552
- var n$1 = class n extends y {
4555
+ var n$1 = class n extends C$1 {
4553
4556
  options;
4554
4557
  cursor = 0;
4555
4558
  get _selectedValue() {
@@ -4577,7 +4580,7 @@ var n$1 = class n extends y {
4577
4580
  });
4578
4581
  }
4579
4582
  };
4580
- var n2 = class extends y {
4583
+ var n2 = class extends C$1 {
4581
4584
  get userInputWithCursor() {
4582
4585
  if (this.state === "submit")
4583
4586
  return this.userInput;
@@ -4605,7 +4608,6 @@ var n2 = class extends y {
4605
4608
  // node_modules/@clack/prompts/dist/index.mjs
4606
4609
  import { styleText as styleText2, stripVTControlCharacters as stripVTControlCharacters3 } from "util";
4607
4610
  import process$1 from "process";
4608
- var import_sisteransi2 = __toESM(require_src(), 1);
4609
4611
  import { existsSync, lstatSync, readdirSync } from "fs";
4610
4612
  import { dirname, join } from "path";
4611
4613
  function isUnicodeSupported() {
@@ -4616,7 +4618,7 @@ function isUnicodeSupported() {
4616
4618
  }
4617
4619
  var unicode = isUnicodeSupported();
4618
4620
  var isCI = () => process.env.CI === "true";
4619
- var unicodeOr = (o, e) => unicode ? o : e;
4621
+ var unicodeOr = (e, o) => unicode ? e : o;
4620
4622
  var S_STEP_ACTIVE = unicodeOr("\u25C6", "*");
4621
4623
  var S_STEP_CANCEL = unicodeOr("\u25A0", "x");
4622
4624
  var S_STEP_ERROR = unicodeOr("\u25B2", "x");
@@ -4642,8 +4644,8 @@ var S_INFO = unicodeOr("\u25CF", "\u2022");
4642
4644
  var S_SUCCESS = unicodeOr("\u25C6", "*");
4643
4645
  var S_WARN = unicodeOr("\u25B2", "!");
4644
4646
  var S_ERROR = unicodeOr("\u25A0", "x");
4645
- var symbol = (o) => {
4646
- switch (o) {
4647
+ var symbol = (e) => {
4648
+ switch (e) {
4647
4649
  case "initial":
4648
4650
  case "active":
4649
4651
  return styleText2("cyan", S_STEP_ACTIVE);
@@ -4657,8 +4659,8 @@ var symbol = (o) => {
4657
4659
  return styleText2("dim", S_STEP_ACTIVE);
4658
4660
  }
4659
4661
  };
4660
- var symbolBar = (o) => {
4661
- switch (o) {
4662
+ var symbolBar = (e) => {
4663
+ switch (e) {
4662
4664
  case "initial":
4663
4665
  case "active":
4664
4666
  return styleText2("cyan", S_BAR);
@@ -4670,49 +4672,50 @@ var symbolBar = (o) => {
4670
4672
  return styleText2("green", S_BAR);
4671
4673
  }
4672
4674
  };
4673
- function formatInstructionFooter(o, e) {
4674
- const r2 = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o.join(" \u2022 ")}`];
4675
- return e && r2.push(styleText2("cyan", S_BAR_END)), r2;
4675
+ function formatInstructionFooter(e, o, r2) {
4676
+ const s = r2 ? `${styleText2("cyan", S_BAR)} ` : "", n3 = wrapTextWithPrefix(e, o.join(" \u2022 "), s).split(`
4677
+ `);
4678
+ return r2 && n3.push(styleText2("cyan", S_BAR_END)), n3;
4676
4679
  }
4677
- var I = (l2, e, w, p, b, C = false) => {
4680
+ var E$1 = (l, e, w, p, b, C2 = false) => {
4678
4681
  let r2 = e, O = 0;
4679
- if (C)
4682
+ if (C2)
4680
4683
  for (let i2 = p - 1; i2 >= w; i2--) {
4681
- const m2 = l2[i2];
4684
+ const m2 = l[i2];
4682
4685
  if (m2 && (r2 -= m2.length), O++, r2 <= b) break;
4683
4686
  }
4684
4687
  else
4685
4688
  for (let i2 = w; i2 < p; i2++) {
4686
- const m2 = l2[i2];
4689
+ const m2 = l[i2];
4687
4690
  if (m2 && (r2 -= m2.length), O++, r2 <= b) break;
4688
4691
  }
4689
4692
  return { lineCount: r2, removals: O };
4690
4693
  };
4691
4694
  var limitOptions = ({
4692
- cursor: l2,
4695
+ cursor: l,
4693
4696
  options: e,
4694
4697
  style: w,
4695
4698
  output: p = process.stdout,
4696
4699
  maxItems: b = Number.POSITIVE_INFINITY,
4697
- columnPadding: C = 0,
4700
+ columnPadding: C2 = 0,
4698
4701
  rowPadding: r2 = 4
4699
4702
  }) => {
4700
- const i2 = getColumns(p) - C, m2 = getRows(p), M = styleText2("dim", "..."), v = Math.max(m2 - r2, 0), a2 = Math.max(Math.min(b, v), 5);
4703
+ const i2 = getColumns(p) - C2, m2 = getRows(p), M = styleText2("dim", "..."), v = Math.max(m2 - r2, 0), a2 = Math.max(Math.min(b, v), 5);
4701
4704
  let f = 0;
4702
- l2 >= a2 - 3 && (f = Math.max(
4703
- Math.min(l2 - a2 + 3, e.length - a2),
4705
+ l >= a2 - 3 && (f = Math.max(
4706
+ Math.min(l - a2 + 3, e.length - a2),
4704
4707
  0
4705
4708
  ));
4706
- let d = a2 < e.length && f > 0, c2 = a2 < e.length && f + a2 < e.length;
4707
- const W2 = Math.min(
4709
+ let d = a2 < e.length && f > 0, c3 = a2 < e.length && f + a2 < e.length;
4710
+ const I = Math.min(
4708
4711
  f + a2,
4709
4712
  e.length
4710
4713
  ), s = [];
4711
4714
  let g = 0;
4712
- d && g++, c2 && g++;
4713
- const T = f + (d ? 1 : 0), y2 = W2 - (c2 ? 1 : 0);
4714
- for (let t2 = T; t2 < y2; t2++) {
4715
- const n3 = e[t2], o = n3 ? w(n3, t2 === l2) : "", h2 = wrapAnsi(o, i2, {
4715
+ d && g++, c3 && g++;
4716
+ const T = f + (d ? 1 : 0), W = I - (c3 ? 1 : 0);
4717
+ for (let t2 = T; t2 < W; t2++) {
4718
+ const n3 = e[t2], o = n3 !== void 0 ? w(n3, t2 === l) : "", h2 = wrapAnsi(o, i2, {
4716
4719
  hard: true,
4717
4720
  trim: false
4718
4721
  }).split(`
@@ -4721,24 +4724,24 @@ var limitOptions = ({
4721
4724
  }
4722
4725
  if (g > v) {
4723
4726
  let t2 = 0, n3 = 0, o = g;
4724
- const h2 = l2 - T;
4725
- let u4 = v;
4726
- const L = () => I(s, o, 0, h2, u4), E = () => I(
4727
+ const h2 = l - T;
4728
+ let u3 = v;
4729
+ const L = () => E$1(s, o, 0, h2, u3), y = () => E$1(
4727
4730
  s,
4728
4731
  o,
4729
4732
  h2 + 1,
4730
4733
  s.length,
4731
- u4,
4734
+ u3,
4732
4735
  true
4733
4736
  );
4734
- d ? ({ lineCount: o, removals: t2 } = L(), o > u4 && (c2 || (u4 -= 1), { lineCount: o, removals: n3 } = E())) : (c2 || (u4 -= 1), { lineCount: o, removals: n3 } = E(), o > u4 && (u4 -= 1, { lineCount: o, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n3 > 0 && (c2 = true, s.splice(s.length - n3, n3));
4737
+ d ? ({ lineCount: o, removals: t2 } = L(), o > u3 && (c3 || (u3 -= 1), { lineCount: o, removals: n3 } = y())) : (c3 || (u3 -= 1), { lineCount: o, removals: n3 } = y(), o > u3 && (u3 -= 1, { lineCount: o, removals: t2 } = L())), t2 > 0 && (d = true, s.splice(0, t2)), n3 > 0 && (c3 = true, s.splice(s.length - n3, n3));
4735
4738
  }
4736
4739
  const x = [];
4737
4740
  d && x.push(M);
4738
4741
  for (const t2 of s)
4739
4742
  for (const n3 of t2)
4740
4743
  x.push(n3);
4741
- return c2 && x.push(M), x;
4744
+ return c3 && x.push(M), x;
4742
4745
  };
4743
4746
  var confirm = (e) => {
4744
4747
  const a2 = e.active ?? "Yes", o = e.inactive ?? "No";
@@ -4750,22 +4753,22 @@ var confirm = (e) => {
4750
4753
  output: e.output,
4751
4754
  initialValue: e.initialValue ?? true,
4752
4755
  render() {
4753
- const i2 = e.withGuide ?? settings.withGuide, u4 = `${symbol(this.state)} `, l2 = i2 ? `${styleText2("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
4756
+ const i2 = e.withGuide ?? settings.withGuide, u3 = `${symbol(this.state)} `, l = i2 ? `${styleText2("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(
4754
4757
  e.output,
4755
4758
  e.message,
4756
- l2,
4757
- u4
4759
+ l,
4760
+ u3
4758
4761
  ), s = `${i2 ? `${styleText2("gray", S_BAR)}
4759
4762
  ` : ""}${f}
4760
- `, c2 = this.value ? a2 : o;
4763
+ `, c3 = this.value ? a2 : o;
4761
4764
  switch (this.state) {
4762
4765
  case "submit": {
4763
4766
  const r2 = i2 ? `${styleText2("gray", S_BAR)} ` : "";
4764
- return `${s}${r2}${styleText2("dim", c2)}`;
4767
+ return `${s}${r2}${styleText2("dim", c3)}`;
4765
4768
  }
4766
4769
  case "cancel": {
4767
4770
  const r2 = i2 ? `${styleText2("gray", S_BAR)} ` : "";
4768
- return `${s}${r2}${styleText2(["strikethrough", "dim"], c2)}${i2 ? `
4771
+ return `${s}${r2}${styleText2(["strikethrough", "dim"], c3)}${i2 ? `
4769
4772
  ${styleText2("gray", S_BAR)}` : ""}`;
4770
4773
  }
4771
4774
  default: {
@@ -4785,22 +4788,22 @@ var MULTISELECT_INSTRUCTIONS = [
4785
4788
  `${styleText2("dim", "Space:")} select`,
4786
4789
  `${styleText2("dim", "Enter:")} confirm`
4787
4790
  ];
4788
- var m = (i2, u4) => i2.split(`
4789
- `).map((d) => u4(d)).join(`
4791
+ var m = (n3, u3) => n3.split(`
4792
+ `).map((d) => u3(d)).join(`
4790
4793
  `);
4791
- var multiselect = (i2) => {
4792
- const u4 = (t2, a2) => {
4794
+ var multiselect = (n3) => {
4795
+ const u3 = (t2, a2) => {
4793
4796
  const r2 = t2.label ?? String(t2.value);
4794
4797
  return a2 === "disabled" ? `${styleText2("gray", S_CHECKBOX_INACTIVE)} ${m(r2, (o) => styleText2(["strikethrough", "gray"], o))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint ?? "disabled"})`)}` : ""}` : a2 === "active" ? `${styleText2("cyan", S_CHECKBOX_ACTIVE)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${m(r2, (o) => styleText2("dim", o))}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "cancelled" ? `${m(r2, (o) => styleText2(["strikethrough", "dim"], o))}` : a2 === "active-selected" ? `${styleText2("green", S_CHECKBOX_SELECTED)} ${r2}${t2.hint ? ` ${styleText2("dim", `(${t2.hint})`)}` : ""}` : a2 === "submitted" ? `${m(r2, (o) => styleText2("dim", o))}` : `${styleText2("dim", S_CHECKBOX_INACTIVE)} ${m(r2, (o) => styleText2("dim", o))}`;
4795
- }, d = i2.required ?? true, x = i2.showInstructions ?? true;
4798
+ }, d = n3.required ?? true, x = n3.showInstructions ?? true;
4796
4799
  return new a({
4797
- options: i2.options,
4798
- signal: i2.signal,
4799
- input: i2.input,
4800
- output: i2.output,
4801
- initialValues: i2.initialValues,
4800
+ options: n3.options,
4801
+ signal: n3.signal,
4802
+ input: n3.input,
4803
+ output: n3.output,
4804
+ initialValues: n3.initialValues,
4802
4805
  required: d,
4803
- cursorAt: i2.cursorAt,
4806
+ cursorAt: n3.cursorAt,
4804
4807
  validate(t2) {
4805
4808
  if (d && (t2 === void 0 || t2.length === 0))
4806
4809
  return `Please select at least one option.
@@ -4816,75 +4819,75 @@ ${styleText2(
4816
4819
  )}`;
4817
4820
  },
4818
4821
  render() {
4819
- const t2 = i2.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(
4820
- i2.output,
4821
- i2.message,
4822
+ const t2 = n3.withGuide ?? settings.withGuide, a2 = wrapTextWithPrefix(
4823
+ n3.output,
4824
+ n3.message,
4822
4825
  t2 ? `${symbolBar(this.state)} ` : "",
4823
4826
  `${symbol(this.state)} `
4824
4827
  ), r2 = `${t2 ? `${styleText2("gray", S_BAR)}
4825
4828
  ` : ""}${a2}
4826
- `, o = this.value ?? [], g = (n3, l2) => {
4827
- if (n3.disabled)
4828
- return u4(n3, "disabled");
4829
- const s = o.includes(n3.value);
4830
- return l2 && s ? u4(n3, "active-selected") : s ? u4(n3, "selected") : u4(n3, l2 ? "active" : "inactive");
4829
+ `, o = this.value ?? [], g = (i2, l) => {
4830
+ if (i2.disabled)
4831
+ return u3(i2, "disabled");
4832
+ const s = o.includes(i2.value);
4833
+ return l && s ? u3(i2, "active-selected") : s ? u3(i2, "selected") : u3(i2, l ? "active" : "inactive");
4831
4834
  };
4832
4835
  switch (this.state) {
4833
4836
  case "submit": {
4834
- const n3 = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u4(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l2 = wrapTextWithPrefix(
4835
- i2.output,
4836
- n3,
4837
+ const i2 = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u3(s, "submitted")).join(styleText2("dim", ", ")) || styleText2("dim", "none"), l = wrapTextWithPrefix(
4838
+ n3.output,
4839
+ i2,
4837
4840
  t2 ? `${styleText2("gray", S_BAR)} ` : ""
4838
4841
  );
4839
- return `${r2}${l2}`;
4842
+ return `${r2}${l}`;
4840
4843
  }
4841
4844
  case "cancel": {
4842
- const n3 = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u4(s, "cancelled")).join(styleText2("dim", ", "));
4843
- if (n3.trim() === "")
4845
+ const i2 = this.options.filter(({ value: s }) => o.includes(s)).map((s) => u3(s, "cancelled")).join(styleText2("dim", ", "));
4846
+ if (i2.trim() === "")
4844
4847
  return `${r2}${styleText2("gray", S_BAR)}`;
4845
- const l2 = wrapTextWithPrefix(
4846
- i2.output,
4847
- n3,
4848
+ const l = wrapTextWithPrefix(
4849
+ n3.output,
4850
+ i2,
4848
4851
  t2 ? `${styleText2("gray", S_BAR)} ` : ""
4849
4852
  );
4850
- return `${r2}${l2}${t2 ? `
4853
+ return `${r2}${l}${t2 ? `
4851
4854
  ${styleText2("gray", S_BAR)}` : ""}`;
4852
4855
  }
4853
4856
  case "error": {
4854
- const n3 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l2 = this.error.split(`
4857
+ const i2 = t2 ? `${styleText2("yellow", S_BAR)} ` : "", l = this.error.split(`
4855
4858
  `).map(
4856
4859
  ($, v) => v === 0 ? `${t2 ? `${styleText2("yellow", S_BAR_END)} ` : ""}${styleText2("yellow", $)}` : ` ${$}`
4857
4860
  ).join(`
4858
4861
  `), s = r2.split(`
4859
- `).length, h2 = l2.split(`
4862
+ `).length, h2 = l.split(`
4860
4863
  `).length + 1;
4861
- return `${r2}${n3}${limitOptions({
4862
- output: i2.output,
4864
+ return `${r2}${i2}${limitOptions({
4865
+ output: n3.output,
4863
4866
  options: this.options,
4864
4867
  cursor: this.cursor,
4865
- maxItems: i2.maxItems,
4866
- columnPadding: n3.length,
4868
+ maxItems: n3.maxItems,
4869
+ columnPadding: i2.length,
4867
4870
  rowPadding: s + h2,
4868
4871
  style: g
4869
4872
  }).join(`
4870
- ${n3}`)}
4871
- ${l2}
4873
+ ${i2}`)}
4874
+ ${l}
4872
4875
  `;
4873
4876
  }
4874
4877
  default: {
4875
- const n3 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l2 = r2.split(`
4876
- `).length, s = x ? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
4878
+ const i2 = t2 ? `${styleText2("cyan", S_BAR)} ` : "", l = r2.split(`
4879
+ `).length, s = x ? formatInstructionFooter(n3.output, MULTISELECT_INSTRUCTIONS, t2) : t2 ? [styleText2("cyan", S_BAR_END)] : [], h2 = s.join(`
4877
4880
  `), $ = s.length + 1;
4878
- return `${r2}${n3}${limitOptions({
4879
- output: i2.output,
4881
+ return `${r2}${i2}${limitOptions({
4882
+ output: n3.output,
4880
4883
  options: this.options,
4881
4884
  cursor: this.cursor,
4882
- maxItems: i2.maxItems,
4883
- columnPadding: n3.length,
4884
- rowPadding: l2 + $,
4885
+ maxItems: n3.maxItems,
4886
+ columnPadding: i2.length,
4887
+ rowPadding: l + $,
4885
4888
  style: g
4886
4889
  }).join(`
4887
- ${n3}`)}
4890
+ ${i2}`)}
4888
4891
  ${h2}
4889
4892
  `;
4890
4893
  }
@@ -4897,19 +4900,19 @@ var log = {
4897
4900
  symbol: e = styleText2("gray", S_BAR),
4898
4901
  secondarySymbol: r2 = styleText2("gray", S_BAR),
4899
4902
  output: m2 = process.stdout,
4900
- spacing: l2 = 1,
4901
- withGuide: c2
4903
+ spacing: l = 1,
4904
+ withGuide: c3
4902
4905
  } = {}) => {
4903
- const t2 = [], o = c2 ?? settings.withGuide, f = o ? r2 : "", O = o ? `${e} ` : "", u4 = o ? `${r2} ` : "";
4904
- for (let i2 = 0; i2 < l2; i2++)
4906
+ const t2 = [], o = c3 ?? settings.withGuide, f = o ? r2 : "", O = o ? `${e} ` : "", u3 = o ? `${r2} ` : "";
4907
+ for (let i2 = 0; i2 < l; i2++)
4905
4908
  t2.push(f);
4906
4909
  const g = Array.isArray(s) ? s : s.split(`
4907
4910
  `);
4908
4911
  if (g.length > 0) {
4909
- const [i2, ...y2] = g;
4912
+ const [i2, ...y] = g;
4910
4913
  i2.length > 0 ? t2.push(`${O}${i2}`) : t2.push(o ? e : "");
4911
- for (const p of y2)
4912
- p.length > 0 ? t2.push(`${u4}${p}`) : t2.push(o ? r2 : "");
4914
+ for (const p of y)
4915
+ p.length > 0 ? t2.push(`${u3}${p}`) : t2.push(o ? r2 : "");
4913
4916
  }
4914
4917
  m2.write(`${t2.join(`
4915
4918
  `)}
@@ -4953,7 +4956,7 @@ ${styleText2("gray", S_BAR_END)} ` : "";
4953
4956
 
4954
4957
  `);
4955
4958
  };
4956
- var password = (e) => new u$1({
4959
+ var password = (e) => new u({
4957
4960
  validate: e.validate,
4958
4961
  mask: e.mask ?? S_PASSWORD_MASK,
4959
4962
  signal: e.signal,
@@ -4989,87 +4992,106 @@ ${n3}
4989
4992
  }
4990
4993
  }
4991
4994
  }).prompt();
4992
- var W = (l2) => styleText2("magenta", l2);
4995
+ var Y = 3e4;
4996
+ var Z = (c3) => styleText2("magenta", c3);
4993
4997
  var spinner = ({
4994
- indicator: l2 = "dots",
4995
- onCancel: h2,
4998
+ indicator: c3 = "dots",
4999
+ onCancel: b,
4996
5000
  output: n3 = process.stdout,
4997
- cancelMessage: G,
4998
- errorMessage: O,
4999
- frames: E = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
5000
- delay: F = unicode ? 80 : 120,
5001
- signal: m2,
5002
- ...I2
5001
+ cancelMessage: _,
5002
+ errorMessage: C2,
5003
+ frames: M = unicode ? ["\u25D2", "\u25D0", "\u25D3", "\u25D1"] : ["\u2022", "o", "O", "0"],
5004
+ delay: O = unicode ? 80 : 120,
5005
+ signal: g,
5006
+ ...E
5003
5007
  } = {}) => {
5004
- const u4 = isCI();
5005
- let M, T, d = false, S = false, s = "", p, w = performance.now();
5006
- const x = getColumns(n3), k = I2?.styleFrame ?? W, g = (e) => {
5007
- const r2 = e > 1 ? O ?? settings.messages.error : G ?? settings.messages.cancel;
5008
- S = e === 1, d && (a2(r2, e), S && typeof h2 == "function" && h2());
5009
- }, f = () => g(2), i2 = () => g(1), A = () => {
5010
- process.on("uncaughtExceptionMonitor", f), process.on("unhandledRejection", f), process.on("SIGINT", i2), process.on("SIGTERM", i2), process.on("exit", g), m2 && m2.addEventListener("abort", i2);
5011
- }, H = () => {
5012
- process.removeListener("uncaughtExceptionMonitor", f), process.removeListener("unhandledRejection", f), process.removeListener("SIGINT", i2), process.removeListener("SIGTERM", i2), process.removeListener("exit", g), m2 && m2.removeEventListener("abort", i2);
5013
- }, y2 = () => {
5014
- if (p === void 0) return;
5015
- u4 && n3.write(`
5008
+ const u3 = isCI(), h2 = isAccessible(E.accessible);
5009
+ let x, I, p = false, l = false, r2 = "", v, w = performance.now();
5010
+ const y = getColumns(n3), F = E?.styleFrame ?? Z, S = (e) => {
5011
+ const s = e > 1 ? C2 ?? settings.messages.error : _ ?? settings.messages.cancel;
5012
+ l = e === 1, p && (m2(s, e), l && typeof b == "function" && b());
5013
+ }, $ = () => S(2), a2 = () => S(1), H = () => {
5014
+ process.on("uncaughtExceptionMonitor", $), process.on("unhandledRejection", $), process.on("SIGINT", a2), process.on("SIGTERM", a2), process.on("exit", S), g && g.addEventListener("abort", a2);
5015
+ }, B = () => {
5016
+ process.removeListener("uncaughtExceptionMonitor", $), process.removeListener("unhandledRejection", $), process.removeListener("SIGINT", a2), process.removeListener("SIGTERM", a2), process.removeListener("exit", S), g && g.removeEventListener("abort", a2);
5017
+ }, R2 = () => {
5018
+ if (v === void 0) return;
5019
+ u3 && n3.write(`
5016
5020
  `);
5017
- const r2 = wrapAnsi(p, x, {
5021
+ const s = wrapAnsi(v, y, {
5018
5022
  hard: true,
5019
5023
  trim: false
5020
5024
  }).split(`
5021
5025
  `);
5022
- r2.length > 1 && n3.write(import_sisteransi2.cursor.up(r2.length - 1)), n3.write(import_sisteransi2.cursor.to(0)), n3.write(import_sisteransi2.erase.down());
5023
- }, C = (e) => e.replace(/\.+$/, ""), _ = (e) => {
5024
- const r2 = (performance.now() - e) / 1e3, t2 = Math.floor(r2 / 60), o = Math.floor(r2 % 60);
5025
- return t2 > 0 ? `[${t2}m ${o}s]` : `[${o}s]`;
5026
- }, N = I2.withGuide ?? settings.withGuide, P = (e = "") => {
5027
- d = true, M = block({ output: n3 }), s = C(e), w = performance.now(), N && n3.write(`${styleText2("gray", S_BAR)}
5026
+ s.length > 1 && n3.write(cursor.up(s.length - 1)), n3.write(cursor.to(0)), n3.write(erase.down());
5027
+ }, L = (e) => e.replace(/\.+$/, ""), T = (e) => {
5028
+ const s = (performance.now() - e) / 1e3, i2 = Math.floor(s / 60), t2 = Math.floor(s % 60);
5029
+ return i2 > 0 ? `[${i2}m ${t2}s]` : `[${t2}s]`;
5030
+ }, N = E.withGuide ?? settings.withGuide, P = (e = "") => {
5031
+ if (p = true, l = false, r2 = L(e), w = performance.now(), H(), h2) {
5032
+ r2 !== "" && n3.write(`${r2}
5033
+ `), I = setInterval(() => {
5034
+ n3.write(r2 === "" ? `still working
5035
+ ` : `still working: ${r2}
5036
+ `);
5037
+ }, Y);
5038
+ return;
5039
+ }
5040
+ x = block({ output: n3 }), N && n3.write(`${styleText2("gray", S_BAR)}
5028
5041
  `);
5029
- let r2 = 0, t2 = 0;
5030
- A(), T = setInterval(() => {
5031
- if (u4 && s === p)
5042
+ let s = 0, i2 = 0;
5043
+ I = setInterval(() => {
5044
+ if (u3 && r2 === v)
5032
5045
  return;
5033
- y2(), p = s;
5034
- const o = k(E[r2]);
5035
- let v;
5036
- if (u4)
5037
- v = `${o} ${s}...`;
5038
- else if (l2 === "timer")
5039
- v = `${o} ${s} ${_(w)}`;
5046
+ R2(), v = r2;
5047
+ const t2 = F(M[s]);
5048
+ let o;
5049
+ if (u3)
5050
+ o = `${t2} ${r2}...`;
5051
+ else if (c3 === "timer")
5052
+ o = `${t2} ${r2} ${T(w)}`;
5040
5053
  else {
5041
- const B = ".".repeat(Math.floor(t2)).slice(0, 3);
5042
- v = `${o} ${s}${B}`;
5054
+ const j = ".".repeat(Math.floor(i2)).slice(0, 3);
5055
+ o = `${t2} ${r2}${j}`;
5043
5056
  }
5044
- const j = wrapAnsi(v, x, {
5057
+ const D = wrapAnsi(o, y, {
5045
5058
  hard: true,
5046
5059
  trim: false
5047
5060
  });
5048
- n3.write(j), r2 = r2 + 1 < E.length ? r2 + 1 : 0, t2 = t2 < 4 ? t2 + 0.125 : 0;
5049
- }, F);
5050
- }, a2 = (e = "", r2 = 0, t2 = false) => {
5051
- if (!d) return;
5052
- d = false, clearInterval(T), y2();
5053
- const o = r2 === 0 ? styleText2("green", S_STEP_SUBMIT) : r2 === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
5054
- s = e ?? s, t2 || (l2 === "timer" ? n3.write(`${o} ${s} ${_(w)}
5055
- `) : n3.write(`${o} ${s}
5056
- `)), H(), M();
5061
+ n3.write(D), s = s + 1 < M.length ? s + 1 : 0, i2 = i2 < 4 ? i2 + 0.125 : 0;
5062
+ }, O);
5063
+ }, m2 = (e = "", s = 0, i2 = false) => {
5064
+ if (p) {
5065
+ if (p = false, l = s === 1, clearInterval(I), h2 || R2(), r2 = e ?? r2, !i2)
5066
+ if (h2) {
5067
+ const t2 = s === 1 ? _ ?? settings.messages.cancel : s === 2 ? C2 ?? settings.messages.error : "Done", o = r2 || t2;
5068
+ c3 === "timer" ? n3.write(`${o} ${T(w)}
5069
+ `) : n3.write(`${o}
5070
+ `);
5071
+ } else {
5072
+ const t2 = s === 0 ? styleText2("green", S_STEP_SUBMIT) : s === 1 ? styleText2("red", S_STEP_CANCEL) : styleText2("red", S_STEP_ERROR);
5073
+ c3 === "timer" ? n3.write(`${t2} ${r2} ${T(w)}
5074
+ `) : n3.write(`${t2} ${r2}
5075
+ `);
5076
+ }
5077
+ B(), x?.();
5078
+ }
5057
5079
  };
5058
5080
  return {
5059
5081
  start: P,
5060
- stop: (e = "") => a2(e, 0),
5082
+ stop: (e = "") => m2(e, 0),
5061
5083
  message: (e = "") => {
5062
- s = C(e ?? s);
5084
+ r2 = L(e ?? r2);
5063
5085
  },
5064
- cancel: (e = "") => a2(e, 1),
5065
- error: (e = "") => a2(e, 2),
5066
- clear: () => a2("", 0, true),
5086
+ cancel: (e = "") => m2(e, 1),
5087
+ error: (e = "") => m2(e, 2),
5088
+ clear: () => m2("", 0, true),
5067
5089
  get isCancelled() {
5068
- return S;
5090
+ return l;
5069
5091
  }
5070
5092
  };
5071
5093
  };
5072
- var u3 = {
5094
+ var u2 = {
5073
5095
  light: unicodeOr("\u2500", "-"),
5074
5096
  heavy: unicodeOr("\u2501", "="),
5075
5097
  block: unicodeOr("\u2588", "#")
@@ -5078,7 +5100,7 @@ var SELECT_INSTRUCTIONS = [
5078
5100
  `${styleText2("dim", "\u2191/\u2193")} to navigate`,
5079
5101
  `${styleText2("dim", "Enter:")} confirm`
5080
5102
  ];
5081
- var c = (t2, o) => t2.includes(`
5103
+ var c2 = (t2, o) => t2.includes(`
5082
5104
  `) ? t2.split(`
5083
5105
  `).map((d) => o(d)).join(`
5084
5106
  `) : o(t2);
@@ -5089,15 +5111,15 @@ var select = (t2) => {
5089
5111
  const s = n3.label ?? String(n3.value);
5090
5112
  switch (m2) {
5091
5113
  case "disabled":
5092
- return `${styleText2("gray", S_RADIO_INACTIVE)} ${c(s, (i2) => styleText2("gray", i2))}${n3.hint ? ` ${styleText2("dim", `(${n3.hint ?? "disabled"})`)}` : ""}`;
5114
+ return `${styleText2("gray", S_RADIO_INACTIVE)} ${c2(s, (i2) => styleText2("gray", i2))}${n3.hint ? ` ${styleText2("dim", `(${n3.hint ?? "disabled"})`)}` : ""}`;
5093
5115
  case "selected":
5094
- return `${c(s, (i2) => styleText2("dim", i2))}`;
5116
+ return `${c2(s, (i2) => styleText2("dim", i2))}`;
5095
5117
  case "active":
5096
5118
  return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${n3.hint ? ` ${styleText2("dim", `(${n3.hint})`)}` : ""}`;
5097
5119
  case "cancelled":
5098
- return `${c(s, (i2) => styleText2(["strikethrough", "dim"], i2))}`;
5120
+ return `${c2(s, (i2) => styleText2(["strikethrough", "dim"], i2))}`;
5099
5121
  default:
5100
- return `${styleText2("dim", S_RADIO_INACTIVE)} ${c(s, (i2) => styleText2("dim", i2))}`;
5122
+ return `${styleText2("dim", S_RADIO_INACTIVE)} ${c2(s, (i2) => styleText2("dim", i2))}`;
5101
5123
  }
5102
5124
  }, d = t2.showInstructions ?? true;
5103
5125
  return new n$1({
@@ -5112,7 +5134,7 @@ var select = (t2) => {
5112
5134
  t2.message,
5113
5135
  s,
5114
5136
  m2
5115
- ), u4 = `${n3 ? `${styleText2("gray", S_BAR)}
5137
+ ), u3 = `${n3 ? `${styleText2("gray", S_BAR)}
5116
5138
  ` : ""}${i2}
5117
5139
  `;
5118
5140
  switch (this.state) {
@@ -5122,7 +5144,7 @@ var select = (t2) => {
5122
5144
  o(this.options[this.cursor], "selected"),
5123
5145
  r2
5124
5146
  );
5125
- return `${u4}${a2}`;
5147
+ return `${u3}${a2}`;
5126
5148
  }
5127
5149
  case "cancel": {
5128
5150
  const r2 = n3 ? `${styleText2("gray", S_BAR)} ` : "", a2 = wrapTextWithPrefix(
@@ -5130,14 +5152,14 @@ var select = (t2) => {
5130
5152
  o(this.options[this.cursor], "cancelled"),
5131
5153
  r2
5132
5154
  );
5133
- return `${u4}${a2}${n3 ? `
5155
+ return `${u3}${a2}${n3 ? `
5134
5156
  ${styleText2("gray", S_BAR)}` : ""}`;
5135
5157
  }
5136
5158
  default: {
5137
- const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 = u4.split(`
5138
- `).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], f = p.join(`
5159
+ const r2 = n3 ? `${styleText2("cyan", S_BAR)} ` : "", a2 = u3.split(`
5160
+ `).length, p = d ? formatInstructionFooter(t2.output, SELECT_INSTRUCTIONS, n3) : n3 ? [styleText2("cyan", S_BAR_END)] : [], f = p.join(`
5139
5161
  `), b = p.length + 1;
5140
- return `${u4}${r2}${limitOptions({
5162
+ return `${u3}${r2}${limitOptions({
5141
5163
  output: t2.output,
5142
5164
  cursor: this.cursor,
5143
5165
  options: this.options,
@@ -5641,6 +5663,247 @@ async function checkPrerequisites() {
5641
5663
  // src/prompts/domain.ts
5642
5664
  var import_picocolors5 = __toESM(require_picocolors(), 1);
5643
5665
 
5666
+ // src/templates/env.ts
5667
+ import crypto from "crypto";
5668
+
5669
+ // src/utils/env-quote.ts
5670
+ function quoteEnvValue(value) {
5671
+ if (value === "") return "";
5672
+ if (!/[\s#$'"\\`!]/.test(value)) return value;
5673
+ if (!value.includes("'")) return `'${value}'`;
5674
+ return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
5675
+ }
5676
+
5677
+ // src/services/stack.ts
5678
+ import fs3 from "fs";
5679
+ import path4 from "path";
5680
+ var COMMUNITY = {
5681
+ appService: "learnhouse-app",
5682
+ dbClients: ["learnhouse-app"],
5683
+ contentPath: "/app/api/content",
5684
+ scalableServices: ["learnhouse-app", "db", "redis"]
5685
+ };
5686
+ var ENTERPRISE = {
5687
+ appService: "api",
5688
+ dbClients: ["api", "collab"],
5689
+ contentPath: "/app/content",
5690
+ scalableServices: ["api", "web", "collab", "db", "redis"]
5691
+ };
5692
+ function stackLayout(config) {
5693
+ return config.edition === "enterprise" ? ENTERPRISE : COMMUNITY;
5694
+ }
5695
+ function hasComposeService(installDir, service) {
5696
+ const composePath = path4.join(installDir, "docker-compose.yml");
5697
+ if (!fs3.existsSync(composePath)) return false;
5698
+ const escaped = service.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5699
+ return new RegExp(`^ ${escaped}:\\s*$`, "m").test(fs3.readFileSync(composePath, "utf-8"));
5700
+ }
5701
+ function usesExternalDb(installDir) {
5702
+ const composePath = path4.join(installDir, "docker-compose.yml");
5703
+ return fs3.existsSync(composePath) && !hasComposeService(installDir, "db");
5704
+ }
5705
+ function usesS3Content(installDir) {
5706
+ const envPath = path4.join(installDir, ".env");
5707
+ if (!fs3.existsSync(envPath)) return false;
5708
+ return /^LEARNHOUSE_CONTENT_DELIVERY_TYPE\s*=\s*['"]?s3api['"]?\s*$/m.test(fs3.readFileSync(envPath, "utf-8"));
5709
+ }
5710
+ function publicUrl(config) {
5711
+ if (config.useHttps) {
5712
+ const port = config.autoSsl && config.httpPort !== 443 ? `:${config.httpPort}` : "";
5713
+ return `https://${config.domain}${port}`;
5714
+ }
5715
+ return `http://${config.domain}${config.httpPort === 80 ? "" : `:${config.httpPort}`}`;
5716
+ }
5717
+
5718
+ // src/templates/env.ts
5719
+ function isIpAddress(host) {
5720
+ return /^\d{1,3}(\.\d{1,3}){3}$/.test(host);
5721
+ }
5722
+ function generateSecret() {
5723
+ return crypto.randomBytes(32).toString("base64");
5724
+ }
5725
+ function generateEnvFile(config, existing = {}) {
5726
+ const baseUrl = publicUrl(config);
5727
+ const domainWithPort = baseUrl.replace(/^https?:\/\//, "");
5728
+ const topDomain = config.domain === "localhost" || isIpAddress(config.domain) ? config.domain : config.domain.split(".").slice(-2).join(".");
5729
+ const nextAuthSecret = existing.nextAuthSecret || generateSecret();
5730
+ const jwtSecret = existing.jwtSecret || generateSecret();
5731
+ const collabInternalKey = existing.collabInternalKey || generateSecret();
5732
+ const lines = [
5733
+ "# LearnHouse Environment Variables",
5734
+ "# Generated by LearnHouse CLI",
5735
+ "",
5736
+ "# =============================================================================",
5737
+ "# Domain & Hosting Configuration",
5738
+ "# =============================================================================",
5739
+ "",
5740
+ `LEARNHOUSE_DOMAIN=${domainWithPort}`,
5741
+ `HTTP_PORT=${config.httpPort}`,
5742
+ "",
5743
+ "# =============================================================================",
5744
+ "# Frontend Environment Variables (NEXT_PUBLIC_*)",
5745
+ "# =============================================================================",
5746
+ "",
5747
+ `NEXT_PUBLIC_LEARNHOUSE_API_URL=${baseUrl}/api/v1/`,
5748
+ `NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL=${baseUrl}/`,
5749
+ `NEXT_PUBLIC_LEARNHOUSE_DOMAIN=${domainWithPort}`,
5750
+ `NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN=${topDomain}`,
5751
+ "NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG=False",
5752
+ `NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG=${config.orgSlug || "default"}`,
5753
+ // The web app compares this to lowercase 'true'.
5754
+ `NEXT_PUBLIC_LEARNHOUSE_HTTPS=${config.useHttps ? "true" : "false"}`
5755
+ ];
5756
+ lines.push(
5757
+ "",
5758
+ "# =============================================================================",
5759
+ "# NextAuth Configuration",
5760
+ "# =============================================================================",
5761
+ "",
5762
+ `NEXTAUTH_URL=${baseUrl}`,
5763
+ `NEXTAUTH_SECRET=${nextAuthSecret}`
5764
+ );
5765
+ if (config.googleOAuthEnabled && config.googleClientId && config.googleClientSecret) {
5766
+ lines.push(
5767
+ `LEARNHOUSE_GOOGLE_CLIENT_ID=${quoteEnvValue(config.googleClientId)}`,
5768
+ `LEARNHOUSE_GOOGLE_CLIENT_SECRET=${quoteEnvValue(config.googleClientSecret)}`
5769
+ );
5770
+ }
5771
+ lines.push(
5772
+ "",
5773
+ "# =============================================================================",
5774
+ "# Backend Configuration",
5775
+ "# =============================================================================",
5776
+ "",
5777
+ `LEARNHOUSE_SQL_CONNECTION_STRING=${config.useExternalDb ? quoteEnvValue(config.externalDbConnectionString) : `postgresql://learnhouse:${config.dbPassword}@db:5432/learnhouse`}`,
5778
+ `LEARNHOUSE_REDIS_CONNECTION_STRING=${config.useExternalRedis ? quoteEnvValue(config.externalRedisConnectionString) : "redis://redis:6379/learnhouse"}`,
5779
+ // Community is single-tenant: cookies stay host-only, so no cookie domain.
5780
+ "LEARNHOUSE_TENANCY=single",
5781
+ `LEARNHOUSE_SSL=${config.useHttps ? "true" : "false"}`,
5782
+ `LEARNHOUSE_FRONTEND_DOMAIN=${domainWithPort}`,
5783
+ // Links and logos in emails; uploads are served from the same origin.
5784
+ `LEARNHOUSE_MEDIA_URL=${baseUrl}`,
5785
+ "LEARNHOUSE_PORT=9000",
5786
+ "",
5787
+ "# =============================================================================",
5788
+ "# Security",
5789
+ "# =============================================================================",
5790
+ "",
5791
+ `LEARNHOUSE_AUTH_JWT_SECRET_KEY=${jwtSecret}`,
5792
+ `LEARNHOUSE_INITIAL_ADMIN_EMAIL=${quoteEnvValue(config.adminEmail)}`,
5793
+ `LEARNHOUSE_INITIAL_ADMIN_PASSWORD=${quoteEnvValue(config.adminPassword)}`,
5794
+ `LEARNHOUSE_INITIAL_ORG_NAME=${quoteEnvValue(config.orgName || "Default Organization")}`,
5795
+ `LEARNHOUSE_INITIAL_ORG_SLUG=${quoteEnvValue(config.orgSlug || "default")}`,
5796
+ "",
5797
+ "# =============================================================================",
5798
+ "# Collaboration Server",
5799
+ "# =============================================================================",
5800
+ "",
5801
+ `COLLAB_INTERNAL_KEY=${collabInternalKey}`,
5802
+ `LEARNHOUSE_REDIS_URL=${config.useExternalRedis ? quoteEnvValue(config.externalRedisConnectionString) : "redis://redis:6379"}`,
5803
+ `NEXT_PUBLIC_COLLAB_URL=${config.useHttps ? "wss" : "ws"}://${domainWithPort}/collab`,
5804
+ "",
5805
+ "# =============================================================================",
5806
+ "# General Settings",
5807
+ "# =============================================================================",
5808
+ "",
5809
+ "LEARNHOUSE_DEVELOPMENT_MODE=False",
5810
+ "LEARNHOUSE_LOGFIRE_ENABLED=False"
5811
+ );
5812
+ if (config.aiEnabled && config.geminiApiKey) {
5813
+ lines.push(
5814
+ "",
5815
+ "# =============================================================================",
5816
+ "# AI Configuration",
5817
+ "# =============================================================================",
5818
+ "",
5819
+ `LEARNHOUSE_GEMINI_API_KEY=${quoteEnvValue(config.geminiApiKey)}`,
5820
+ "LEARNHOUSE_IS_AI_ENABLED=True"
5821
+ );
5822
+ } else {
5823
+ lines.push(
5824
+ "",
5825
+ "# =============================================================================",
5826
+ "# AI Configuration",
5827
+ "# =============================================================================",
5828
+ "",
5829
+ "LEARNHOUSE_IS_AI_ENABLED=False"
5830
+ );
5831
+ }
5832
+ if (config.emailEnabled) {
5833
+ const provider = config.emailProvider || "resend";
5834
+ lines.push(
5835
+ "",
5836
+ "# =============================================================================",
5837
+ "# Email Configuration",
5838
+ "# =============================================================================",
5839
+ "",
5840
+ `LEARNHOUSE_EMAIL_PROVIDER=${provider}`,
5841
+ `LEARNHOUSE_SYSTEM_EMAIL_ADDRESS=${quoteEnvValue(config.systemEmailAddress || `noreply@${config.domain}`)}`
5842
+ );
5843
+ if (provider === "resend" && config.resendApiKey) {
5844
+ lines.push(`LEARNHOUSE_RESEND_API_KEY=${quoteEnvValue(config.resendApiKey)}`);
5845
+ }
5846
+ if (provider === "smtp") {
5847
+ if (config.smtpHost) lines.push(`LEARNHOUSE_SMTP_HOST=${quoteEnvValue(config.smtpHost)}`);
5848
+ lines.push(`LEARNHOUSE_SMTP_PORT=${config.smtpPort || 587}`);
5849
+ if (config.smtpUsername) lines.push(`LEARNHOUSE_SMTP_USERNAME=${quoteEnvValue(config.smtpUsername)}`);
5850
+ if (config.smtpPassword) lines.push(`LEARNHOUSE_SMTP_PASSWORD=${quoteEnvValue(config.smtpPassword)}`);
5851
+ lines.push(`LEARNHOUSE_SMTP_USE_TLS=${config.smtpUseTls !== false ? "True" : "False"}`);
5852
+ }
5853
+ }
5854
+ if (config.s3Enabled && config.s3BucketName) {
5855
+ lines.push(
5856
+ "",
5857
+ "# =============================================================================",
5858
+ "# Content Delivery",
5859
+ "# =============================================================================",
5860
+ "",
5861
+ "LEARNHOUSE_CONTENT_DELIVERY_TYPE=s3api",
5862
+ `LEARNHOUSE_S3_API_BUCKET_NAME=${quoteEnvValue(config.s3BucketName)}`
5863
+ );
5864
+ if (config.s3EndpointUrl) {
5865
+ lines.push(`LEARNHOUSE_S3_API_ENDPOINT_URL=${quoteEnvValue(config.s3EndpointUrl)}`);
5866
+ }
5867
+ if (config.s3Region) {
5868
+ lines.push(
5869
+ `AWS_DEFAULT_REGION=${quoteEnvValue(config.s3Region)}`,
5870
+ `LEARNHOUSE_S3_API_REGION=${quoteEnvValue(config.s3Region)}`
5871
+ );
5872
+ }
5873
+ if (config.s3AccessKeyId && config.s3SecretAccessKey) {
5874
+ lines.push(
5875
+ `AWS_ACCESS_KEY_ID=${quoteEnvValue(config.s3AccessKeyId)}`,
5876
+ `AWS_SECRET_ACCESS_KEY=${quoteEnvValue(config.s3SecretAccessKey)}`
5877
+ );
5878
+ }
5879
+ } else {
5880
+ lines.push(
5881
+ "",
5882
+ "# =============================================================================",
5883
+ "# Content Delivery",
5884
+ "# =============================================================================",
5885
+ "",
5886
+ "LEARNHOUSE_CONTENT_DELIVERY_TYPE=filesystem"
5887
+ );
5888
+ }
5889
+ if (!config.useExternalDb) {
5890
+ lines.push(
5891
+ "",
5892
+ "# =============================================================================",
5893
+ "# Database Configuration",
5894
+ "# =============================================================================",
5895
+ "",
5896
+ "POSTGRES_USER=learnhouse",
5897
+ `POSTGRES_PASSWORD=${config.dbPassword}`,
5898
+ "POSTGRES_DB=learnhouse",
5899
+ ""
5900
+ );
5901
+ } else {
5902
+ lines.push("");
5903
+ }
5904
+ return lines.join("\n");
5905
+ }
5906
+
5644
5907
  // src/utils/network.ts
5645
5908
  import net from "net";
5646
5909
  async function getPublicIp() {
@@ -5740,10 +6003,11 @@ async function promptDomain() {
5740
6003
  let autoSsl = false;
5741
6004
  let sslEmail;
5742
6005
  if (domain !== "localhost") {
6006
+ const ip = isIpAddress(domain);
5743
6007
  const httpsChoice = await select({
5744
6008
  message: "HTTPS configuration?",
5745
6009
  options: [
5746
- { value: "auto", label: "Automatic SSL (Let's Encrypt via Caddy)", hint: "recommended" },
6010
+ ...ip ? [] : [{ value: "auto", label: "Automatic SSL (Let's Encrypt via Caddy)", hint: "recommended" }],
5747
6011
  { value: "manual", label: "I'll handle SSL myself (reverse proxy, Cloudflare, etc.)" },
5748
6012
  { value: "none", label: "No HTTPS (HTTP only)", hint: "not recommended for production" }
5749
6013
  ]
@@ -5810,7 +6074,7 @@ async function promptDomain() {
5810
6074
  }
5811
6075
 
5812
6076
  // src/prompts/database.ts
5813
- import crypto from "crypto";
6077
+ import crypto2 from "crypto";
5814
6078
  var import_picocolors6 = __toESM(require_picocolors(), 1);
5815
6079
  async function promptAndVerifyPostgres() {
5816
6080
  while (true) {
@@ -5926,7 +6190,7 @@ async function promptDatabase() {
5926
6190
  process.exit(0);
5927
6191
  }
5928
6192
  useAiDatabase = dbImageChoice === "ai";
5929
- dbPassword = crypto.randomBytes(24).toString("base64url");
6193
+ dbPassword = crypto2.randomBytes(24).toString("base64url");
5930
6194
  log.info(`Database credentials generated (user ${import_picocolors6.default.cyan("learnhouse")}, host db:5432); the password is saved in .env.`);
5931
6195
  }
5932
6196
  const redisChoice = await select({
@@ -6151,6 +6415,34 @@ async function promptFeatures() {
6151
6415
  process.exit(0);
6152
6416
  }
6153
6417
  if (endpoint) config.s3EndpointUrl = endpoint;
6418
+ const region = await text({
6419
+ message: "S3 region? (leave empty for us-east-1 or a provider that ignores it)",
6420
+ placeholder: "us-east-1"
6421
+ });
6422
+ if (isCancel(region)) {
6423
+ cancel();
6424
+ process.exit(0);
6425
+ }
6426
+ if (region) config.s3Region = region;
6427
+ const accessKeyId = await text({
6428
+ message: "S3 access key ID? (leave empty to use the host's credentials, e.g. an instance role)"
6429
+ });
6430
+ if (isCancel(accessKeyId)) {
6431
+ cancel();
6432
+ process.exit(0);
6433
+ }
6434
+ if (accessKeyId) {
6435
+ config.s3AccessKeyId = accessKeyId;
6436
+ const secret = await password({
6437
+ message: "S3 secret access key?",
6438
+ validate: (v) => validateRequired(v ?? "")
6439
+ });
6440
+ if (isCancel(secret)) {
6441
+ cancel();
6442
+ process.exit(0);
6443
+ }
6444
+ config.s3SecretAccessKey = secret;
6445
+ }
6154
6446
  }
6155
6447
  if (config.googleOAuthEnabled) {
6156
6448
  log.info("Configure Google OAuth");
@@ -6308,6 +6600,10 @@ services:
6308
6600
  # HOSTNAME needs to be set explicitly for the container
6309
6601
  - HOSTNAME=0.0.0.0
6310
6602
  - LEARNHOUSE_API_URL=http://localhost:9000
6603
+ # Server-side rendering calls the API inside the container instead of
6604
+ # going back out through the public URL (which may not resolve or
6605
+ # hairpin from inside Docker).
6606
+ - LEARNHOUSE_INTERNAL_API_URL=http://localhost:9000
6311
6607
  ${appVolumes}${appDependsOn}
6312
6608
  networks:
6313
6609
  - learnhouse-network-${id}
@@ -6326,227 +6622,6 @@ ${volumesSection}
6326
6622
  `;
6327
6623
  }
6328
6624
 
6329
- // src/templates/env.ts
6330
- import crypto2 from "crypto";
6331
-
6332
- // src/utils/env-quote.ts
6333
- function quoteEnvValue(value) {
6334
- if (value === "") return "";
6335
- if (!/[\s#$'"\\`!]/.test(value)) return value;
6336
- if (!value.includes("'")) return `'${value}'`;
6337
- return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
6338
- }
6339
-
6340
- // src/services/stack.ts
6341
- import fs3 from "fs";
6342
- import path4 from "path";
6343
- var COMMUNITY = {
6344
- appService: "learnhouse-app",
6345
- dbClients: ["learnhouse-app"],
6346
- contentPath: "/app/api/content",
6347
- scalableServices: ["learnhouse-app", "db", "redis"]
6348
- };
6349
- var ENTERPRISE = {
6350
- appService: "api",
6351
- dbClients: ["api", "collab"],
6352
- contentPath: "/app/content",
6353
- scalableServices: ["api", "web", "collab", "db", "redis"]
6354
- };
6355
- function stackLayout(config) {
6356
- return config.edition === "enterprise" ? ENTERPRISE : COMMUNITY;
6357
- }
6358
- function hasComposeService(installDir, service) {
6359
- const composePath = path4.join(installDir, "docker-compose.yml");
6360
- if (!fs3.existsSync(composePath)) return false;
6361
- const escaped = service.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
6362
- return new RegExp(`^ ${escaped}:\\s*$`, "m").test(fs3.readFileSync(composePath, "utf-8"));
6363
- }
6364
- function usesExternalDb(installDir) {
6365
- const composePath = path4.join(installDir, "docker-compose.yml");
6366
- return fs3.existsSync(composePath) && !hasComposeService(installDir, "db");
6367
- }
6368
- function usesS3Content(installDir) {
6369
- const envPath = path4.join(installDir, ".env");
6370
- if (!fs3.existsSync(envPath)) return false;
6371
- return /^LEARNHOUSE_CONTENT_DELIVERY_TYPE\s*=\s*['"]?s3api['"]?\s*$/m.test(fs3.readFileSync(envPath, "utf-8"));
6372
- }
6373
- function publicUrl(config) {
6374
- if (config.useHttps) {
6375
- const port = config.autoSsl && config.httpPort !== 443 ? `:${config.httpPort}` : "";
6376
- return `https://${config.domain}${port}`;
6377
- }
6378
- return `http://${config.domain}${config.httpPort === 80 ? "" : `:${config.httpPort}`}`;
6379
- }
6380
-
6381
- // src/templates/env.ts
6382
- function generateSecret() {
6383
- return crypto2.randomBytes(32).toString("base64");
6384
- }
6385
- function generateEnvFile(config, existing = {}) {
6386
- const baseUrl = publicUrl(config);
6387
- const domainWithPort = baseUrl.replace(/^https?:\/\//, "");
6388
- const topDomain = config.domain === "localhost" ? "localhost" : config.domain.split(".").slice(-2).join(".");
6389
- const cookieDomain = config.domain === "localhost" ? ".localhost" : `.${topDomain}`;
6390
- const nextAuthSecret = existing.nextAuthSecret || generateSecret();
6391
- const jwtSecret = existing.jwtSecret || generateSecret();
6392
- const collabInternalKey = existing.collabInternalKey || generateSecret();
6393
- const lines = [
6394
- "# LearnHouse Environment Variables",
6395
- "# Generated by LearnHouse CLI",
6396
- "",
6397
- "# =============================================================================",
6398
- "# Domain & Hosting Configuration",
6399
- "# =============================================================================",
6400
- "",
6401
- `LEARNHOUSE_DOMAIN=${domainWithPort}`,
6402
- `HTTP_PORT=${config.httpPort}`,
6403
- "",
6404
- "# =============================================================================",
6405
- "# Frontend Environment Variables (NEXT_PUBLIC_*)",
6406
- "# =============================================================================",
6407
- "",
6408
- `NEXT_PUBLIC_LEARNHOUSE_API_URL=${baseUrl}/api/v1/`,
6409
- `NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL=${baseUrl}/`,
6410
- `NEXT_PUBLIC_LEARNHOUSE_DOMAIN=${domainWithPort}`,
6411
- `NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN=${topDomain}`,
6412
- "NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG=False",
6413
- `NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG=${config.orgSlug || "default"}`,
6414
- `NEXT_PUBLIC_LEARNHOUSE_HTTPS=${config.useHttps ? "True" : "False"}`
6415
- ];
6416
- lines.push(
6417
- "",
6418
- "# =============================================================================",
6419
- "# NextAuth Configuration",
6420
- "# =============================================================================",
6421
- "",
6422
- `NEXTAUTH_URL=${baseUrl}`,
6423
- `NEXTAUTH_SECRET=${nextAuthSecret}`
6424
- );
6425
- if (config.googleOAuthEnabled && config.googleClientId && config.googleClientSecret) {
6426
- lines.push(
6427
- `LEARNHOUSE_GOOGLE_CLIENT_ID=${quoteEnvValue(config.googleClientId)}`,
6428
- `LEARNHOUSE_GOOGLE_CLIENT_SECRET=${quoteEnvValue(config.googleClientSecret)}`
6429
- );
6430
- }
6431
- lines.push(
6432
- "",
6433
- "# =============================================================================",
6434
- "# Backend Configuration",
6435
- "# =============================================================================",
6436
- "",
6437
- `LEARNHOUSE_SQL_CONNECTION_STRING=${config.useExternalDb ? quoteEnvValue(config.externalDbConnectionString) : `postgresql://learnhouse:${config.dbPassword}@db:5432/learnhouse`}`,
6438
- `LEARNHOUSE_REDIS_CONNECTION_STRING=${config.useExternalRedis ? quoteEnvValue(config.externalRedisConnectionString) : "redis://redis:6379/learnhouse"}`,
6439
- `LEARNHOUSE_COOKIE_DOMAIN=${cookieDomain}`,
6440
- "LEARNHOUSE_PORT=9000",
6441
- "",
6442
- "# =============================================================================",
6443
- "# Security",
6444
- "# =============================================================================",
6445
- "",
6446
- `LEARNHOUSE_AUTH_JWT_SECRET_KEY=${jwtSecret}`,
6447
- `LEARNHOUSE_INITIAL_ADMIN_EMAIL=${quoteEnvValue(config.adminEmail)}`,
6448
- `LEARNHOUSE_INITIAL_ADMIN_PASSWORD=${quoteEnvValue(config.adminPassword)}`,
6449
- `LEARNHOUSE_INITIAL_ORG_NAME=${quoteEnvValue(config.orgName || "Default Organization")}`,
6450
- `LEARNHOUSE_INITIAL_ORG_SLUG=${quoteEnvValue(config.orgSlug || "default")}`,
6451
- "",
6452
- "# =============================================================================",
6453
- "# Collaboration Server",
6454
- "# =============================================================================",
6455
- "",
6456
- `COLLAB_INTERNAL_KEY=${collabInternalKey}`,
6457
- `LEARNHOUSE_REDIS_URL=${config.useExternalRedis ? quoteEnvValue(config.externalRedisConnectionString) : "redis://redis:6379"}`,
6458
- `NEXT_PUBLIC_COLLAB_URL=${config.useHttps ? "wss" : "ws"}://${domainWithPort}/collab`,
6459
- "",
6460
- "# =============================================================================",
6461
- "# General Settings",
6462
- "# =============================================================================",
6463
- "",
6464
- "LEARNHOUSE_DEVELOPMENT_MODE=False",
6465
- "LEARNHOUSE_LOGFIRE_ENABLED=False"
6466
- );
6467
- if (config.aiEnabled && config.geminiApiKey) {
6468
- lines.push(
6469
- "",
6470
- "# =============================================================================",
6471
- "# AI Configuration",
6472
- "# =============================================================================",
6473
- "",
6474
- `LEARNHOUSE_GEMINI_API_KEY=${quoteEnvValue(config.geminiApiKey)}`,
6475
- "LEARNHOUSE_IS_AI_ENABLED=True"
6476
- );
6477
- } else {
6478
- lines.push(
6479
- "",
6480
- "# =============================================================================",
6481
- "# AI Configuration",
6482
- "# =============================================================================",
6483
- "",
6484
- "LEARNHOUSE_IS_AI_ENABLED=False"
6485
- );
6486
- }
6487
- if (config.emailEnabled) {
6488
- const provider = config.emailProvider || "resend";
6489
- lines.push(
6490
- "",
6491
- "# =============================================================================",
6492
- "# Email Configuration",
6493
- "# =============================================================================",
6494
- "",
6495
- `LEARNHOUSE_EMAIL_PROVIDER=${provider}`,
6496
- `LEARNHOUSE_SYSTEM_EMAIL_ADDRESS=${quoteEnvValue(config.systemEmailAddress || `noreply@${config.domain}`)}`
6497
- );
6498
- if (provider === "resend" && config.resendApiKey) {
6499
- lines.push(`LEARNHOUSE_RESEND_API_KEY=${quoteEnvValue(config.resendApiKey)}`);
6500
- }
6501
- if (provider === "smtp") {
6502
- if (config.smtpHost) lines.push(`LEARNHOUSE_SMTP_HOST=${quoteEnvValue(config.smtpHost)}`);
6503
- lines.push(`LEARNHOUSE_SMTP_PORT=${config.smtpPort || 587}`);
6504
- if (config.smtpUsername) lines.push(`LEARNHOUSE_SMTP_USERNAME=${quoteEnvValue(config.smtpUsername)}`);
6505
- if (config.smtpPassword) lines.push(`LEARNHOUSE_SMTP_PASSWORD=${quoteEnvValue(config.smtpPassword)}`);
6506
- lines.push(`LEARNHOUSE_SMTP_USE_TLS=${config.smtpUseTls !== false ? "True" : "False"}`);
6507
- }
6508
- }
6509
- if (config.s3Enabled && config.s3BucketName) {
6510
- lines.push(
6511
- "",
6512
- "# =============================================================================",
6513
- "# Content Delivery",
6514
- "# =============================================================================",
6515
- "",
6516
- "LEARNHOUSE_CONTENT_DELIVERY_TYPE=s3api",
6517
- `LEARNHOUSE_S3_API_BUCKET_NAME=${quoteEnvValue(config.s3BucketName)}`
6518
- );
6519
- if (config.s3EndpointUrl) {
6520
- lines.push(`LEARNHOUSE_S3_API_ENDPOINT_URL=${quoteEnvValue(config.s3EndpointUrl)}`);
6521
- }
6522
- } else {
6523
- lines.push(
6524
- "",
6525
- "# =============================================================================",
6526
- "# Content Delivery",
6527
- "# =============================================================================",
6528
- "",
6529
- "LEARNHOUSE_CONTENT_DELIVERY_TYPE=filesystem"
6530
- );
6531
- }
6532
- if (!config.useExternalDb) {
6533
- lines.push(
6534
- "",
6535
- "# =============================================================================",
6536
- "# Database Configuration",
6537
- "# =============================================================================",
6538
- "",
6539
- "POSTGRES_USER=learnhouse",
6540
- `POSTGRES_PASSWORD=${config.dbPassword}`,
6541
- "POSTGRES_DB=learnhouse",
6542
- ""
6543
- );
6544
- } else {
6545
- lines.push("");
6546
- }
6547
- return lines.join("\n");
6548
- }
6549
-
6550
6625
  // src/templates/nginx.ts
6551
6626
  function generateNginxConf(config = {}) {
6552
6627
  const forwardedProto = config.useHttps ? "https" : "$scheme";
@@ -6965,6 +7040,65 @@ function setEnvVar(installDir, key, value) {
6965
7040
  }
6966
7041
  writeFileAtomic(envPath, txt);
6967
7042
  }
7043
+ var FEATURE_ENV_KEYS = [
7044
+ "LEARNHOUSE_GEMINI_API_KEY",
7045
+ "LEARNHOUSE_IS_AI_ENABLED",
7046
+ "LEARNHOUSE_EMAIL_PROVIDER",
7047
+ "LEARNHOUSE_SYSTEM_EMAIL_ADDRESS",
7048
+ "LEARNHOUSE_RESEND_API_KEY",
7049
+ "LEARNHOUSE_SMTP_HOST",
7050
+ "LEARNHOUSE_SMTP_PORT",
7051
+ "LEARNHOUSE_SMTP_USERNAME",
7052
+ "LEARNHOUSE_SMTP_PASSWORD",
7053
+ "LEARNHOUSE_SMTP_USE_TLS",
7054
+ "LEARNHOUSE_CONTENT_DELIVERY_TYPE",
7055
+ "LEARNHOUSE_S3_API_BUCKET_NAME",
7056
+ "LEARNHOUSE_S3_API_ENDPOINT_URL",
7057
+ "AWS_ACCESS_KEY_ID",
7058
+ "AWS_SECRET_ACCESS_KEY",
7059
+ "AWS_DEFAULT_REGION",
7060
+ "LEARNHOUSE_S3_API_REGION",
7061
+ "LEARNHOUSE_GOOGLE_CLIENT_ID",
7062
+ "LEARNHOUSE_GOOGLE_CLIENT_SECRET"
7063
+ ];
7064
+ var RETIRED_ENV_KEYS = /* @__PURE__ */ new Set(["LEARNHOUSE_COOKIE_DOMAIN"]);
7065
+ function envLines(content) {
7066
+ const lines = /* @__PURE__ */ new Map();
7067
+ for (const line of content.split("\n")) {
7068
+ const m2 = line.match(/^([A-Za-z_][A-Za-z0-9_]*)=/);
7069
+ if (m2) lines.set(m2[1], line);
7070
+ }
7071
+ return lines;
7072
+ }
7073
+ function mergeEnvContent(generated, previous, keepExisting = []) {
7074
+ const prev = envLines(previous);
7075
+ const keep = new Set(keepExisting);
7076
+ const gen = envLines(generated);
7077
+ const groupOf = (key) => FEATURE_ENV_KEYS.includes(key) ? "feature" : "other";
7078
+ let out = generated.split("\n").map((line) => {
7079
+ const m2 = line.match(/^([A-Za-z_][A-Za-z0-9_]*)=/);
7080
+ return m2 && keep.has(m2[1]) && prev.has(m2[1]) ? prev.get(m2[1]) : line;
7081
+ }).join("\n");
7082
+ const carried = [];
7083
+ for (const [key, line] of prev) {
7084
+ if (gen.has(key) || RETIRED_ENV_KEYS.has(key)) continue;
7085
+ if (groupOf(key) === "feature" && !keep.has(key)) continue;
7086
+ carried.push(line);
7087
+ }
7088
+ if (carried.length) {
7089
+ if (!out.endsWith("\n")) out += "\n";
7090
+ out += [
7091
+ "",
7092
+ "# =============================================================================",
7093
+ "# Kept from the previous configuration",
7094
+ "# =============================================================================",
7095
+ "",
7096
+ ...carried,
7097
+ ""
7098
+ ].join("\n");
7099
+ }
7100
+ return out;
7101
+ }
6968
7102
 
6969
7103
  // src/commands/setup-ee.ts
6970
7104
  var import_picocolors8 = __toESM(require_picocolors(), 1);
@@ -7748,6 +7882,11 @@ async function confirmOrBack(message) {
7748
7882
  }
7749
7883
  return result === "back" ? BACK : true;
7750
7884
  }
7885
+ function caddyEmail(dir) {
7886
+ const caddyfile = path10.join(dir, "extra", "Caddyfile");
7887
+ if (!fs9.existsSync(caddyfile)) return void 0;
7888
+ return fs9.readFileSync(caddyfile, "utf-8").match(/^\s*email\s+(\S+)/m)?.[1];
7889
+ }
7751
7890
  function composeImage(dir) {
7752
7891
  const composePath = path10.join(dir, "docker-compose.yml");
7753
7892
  if (!fs9.existsSync(composePath)) return void 0;
@@ -7769,7 +7908,11 @@ function readExistingInstall(dir) {
7769
7908
  running: isDeploymentRunning(config.deploymentId),
7770
7909
  image: composeImage(dir),
7771
7910
  externalDb: hasComposeService(dir, "db") ? void 0 : readEnvVar(dir, "LEARNHOUSE_SQL_CONNECTION_STRING"),
7772
- externalRedis: hasComposeService(dir, "redis") ? void 0 : readEnvVar(dir, "LEARNHOUSE_REDIS_CONNECTION_STRING")
7911
+ externalRedis: hasComposeService(dir, "redis") ? void 0 : readEnvVar(dir, "LEARNHOUSE_REDIS_CONNECTION_STRING"),
7912
+ useHttps: !!config.useHttps,
7913
+ autoSsl: !!config.autoSsl,
7914
+ sslEmail: caddyEmail(dir),
7915
+ s3Enabled: usesS3Content(dir)
7773
7916
  };
7774
7917
  }
7775
7918
  function preserveContent(dir, existing) {
@@ -7880,12 +8023,15 @@ function summaryLines(config) {
7880
8023
  ` ${import_picocolors9.default.dim("Google OAuth:")} ${config.googleOAuthEnabled ? "Enabled" : "Disabled"}`
7881
8024
  ].join("\n");
7882
8025
  }
7883
- function writeInstallFiles(config, appImage, secrets) {
8026
+ function writeInstallFiles(config, appImage, secrets, keepExisting = []) {
7884
8027
  const dir = config.installDir;
7885
8028
  fs9.mkdirSync(dir, { recursive: true, mode: 448 });
7886
8029
  fs9.mkdirSync(path10.join(dir, "extra"), { recursive: true });
7887
8030
  writeFileAtomic(path10.join(dir, "docker-compose.yml"), generateDockerCompose(config, appImage));
7888
- writeFileAtomic(path10.join(dir, ".env"), generateEnvFile(config, secrets), 384);
8031
+ const envPath = path10.join(dir, ".env");
8032
+ let envContent = generateEnvFile(config, secrets);
8033
+ if (fs9.existsSync(envPath)) envContent = mergeEnvContent(envContent, fs9.readFileSync(envPath, "utf-8"), keepExisting);
8034
+ writeFileAtomic(envPath, envContent, 384);
7889
8035
  if (config.autoSsl) {
7890
8036
  writeFileAtomic(path10.join(dir, "extra", "Caddyfile"), generateCaddyfile(config));
7891
8037
  } else {
@@ -7924,6 +8070,19 @@ async function setupCommand(rawOptions) {
7924
8070
  const domainErr = validateDomain(domain);
7925
8071
  if (domainErr) ciFail(`--domain "${options.domain}": ${domainErr}`);
7926
8072
  }
8073
+ if (options.https !== void 0 && !["auto", "manual", "off"].includes(options.https)) {
8074
+ ciFail(`--https "${options.https}": expected auto, manual or off`);
8075
+ }
8076
+ if (options.https === "auto" || options.https === "manual") {
8077
+ if (domain === "localhost") ciFail("--https needs a real --domain, not localhost");
8078
+ }
8079
+ if (options.https === "auto") {
8080
+ if (isIpAddress(domain)) ciFail("--https auto needs a domain name: Let's Encrypt does not issue certificates for IP addresses");
8081
+ const sslEmail = options.sslEmail ?? options.adminEmail;
8082
+ if (!sslEmail) ciFail("--https auto needs --ssl-email (the Let's Encrypt contact)");
8083
+ const err = validateEmail(sslEmail);
8084
+ if (err) ciFail(`--ssl-email "${sslEmail}": ${err}`);
8085
+ }
7927
8086
  let requestedPort;
7928
8087
  if (options.port !== void 0) {
7929
8088
  const portErr = validatePort(String(options.port));
@@ -7958,7 +8117,9 @@ async function setupCommand(rawOptions) {
7958
8117
  const deploymentId2 = existing2?.deploymentId ?? crypto5.randomBytes(4).toString("hex");
7959
8118
  const channel2 = options.channel === "dev" ? "dev" : "stable";
7960
8119
  const dbPassword = existing2?.dbPassword || crypto5.randomBytes(24).toString("base64url");
7961
- let httpPort = requestedPort ?? existing2?.httpPort ?? 80;
8120
+ const httpsMode = options.https ?? (existing2?.autoSsl ? "auto" : existing2?.useHttps ? "manual" : "off");
8121
+ const autoSsl = httpsMode === "auto";
8122
+ let httpPort = requestedPort ?? existing2?.httpPort ?? (autoSsl ? 443 : 80);
7962
8123
  const ownPort = !!existing2?.running && existing2.httpPort === httpPort;
7963
8124
  if (!ownPort) {
7964
8125
  if (requestedPort === void 0) {
@@ -7972,15 +8133,19 @@ async function setupCommand(rawOptions) {
7972
8133
  } else if (!await checkPort(httpPort)) {
7973
8134
  ciFail(`Port ${httpPort} is already in use. Free it or pass a different --port.`);
7974
8135
  }
8136
+ if (autoSsl && options.start !== false && httpPort !== 80 && !await checkPort(80)) {
8137
+ ciFail("Port 80 is in use; --https auto needs it free for Let's Encrypt.");
8138
+ }
7975
8139
  }
7976
8140
  const config2 = {
7977
8141
  deploymentId: deploymentId2,
7978
8142
  installDir: resolvedDir2,
7979
8143
  channel: channel2,
7980
8144
  domain,
7981
- useHttps: false,
8145
+ useHttps: httpsMode !== "off",
7982
8146
  httpPort,
7983
- autoSsl: false,
8147
+ autoSsl,
8148
+ sslEmail: autoSsl ? options.sslEmail ?? existing2?.sslEmail ?? options.adminEmail : void 0,
7984
8149
  // External DB/Redis work for the Community stack too: when a connection
7985
8150
  // string is supplied, the in-container service is omitted from the compose.
7986
8151
  useExternalDb: !!(options.externalDb ?? existing2?.externalDb),
@@ -7995,9 +8160,11 @@ async function setupCommand(rawOptions) {
7995
8160
  orgSlug,
7996
8161
  adminEmail: options.adminEmail || "admin@school.dev",
7997
8162
  adminPassword: options.adminPassword,
8163
+ // --ci has no feature prompts: a reconfigure keeps what the install has
8164
+ // (FEATURE_ENV_KEYS below), a new install starts with them off.
7998
8165
  aiEnabled: false,
7999
8166
  emailEnabled: false,
8000
- s3Enabled: false,
8167
+ s3Enabled: !!existing2?.s3Enabled,
8001
8168
  googleOAuthEnabled: false
8002
8169
  };
8003
8170
  console.log(`${existing2 ? "Reconfiguring" : "Setting up"} LearnHouse in ${resolvedDir2}`);
@@ -8010,7 +8177,7 @@ async function setupCommand(rawOptions) {
8010
8177
  ciFail(`could not move uploaded content into a persistent volume: ${err?.message ?? err}. Nothing was changed.`);
8011
8178
  }
8012
8179
  }
8013
- writeInstallFiles(config2, appImage2, existing2?.secrets ?? {});
8180
+ writeInstallFiles(config2, appImage2, existing2?.secrets ?? {}, FEATURE_ENV_KEYS);
8014
8181
  console.log("Configuration files generated");
8015
8182
  if (options.start !== false) {
8016
8183
  console.log("Starting services...");
@@ -8408,12 +8575,12 @@ async function logsCommand() {
8408
8575
  log.error("No LearnHouse containers found. Start services first.");
8409
8576
  process.exit(1);
8410
8577
  }
8411
- const containers = listDeploymentContainers(id).filter((c2) => c2.status.toLowerCase().startsWith("up"));
8578
+ const containers = listDeploymentContainers(id).filter((c3) => c3.status.toLowerCase().startsWith("up"));
8412
8579
  if (containers.length === 0) {
8413
8580
  log.error("No running containers found. Start services first.");
8414
8581
  process.exit(1);
8415
8582
  }
8416
- dockerLogsMulti(containers.map((c2) => c2.name));
8583
+ dockerLogsMulti(containers.map((c3) => c3.name));
8417
8584
  }
8418
8585
 
8419
8586
  // src/commands/config.ts
@@ -8597,11 +8764,14 @@ function readMeta(folder) {
8597
8764
  }
8598
8765
  }
8599
8766
  async function restoreBackup(archivePath, options = {}) {
8767
+ const { dir: installDir, config } = loadInstall();
8768
+ if (!fs10.existsSync(archivePath) && !path11.isAbsolute(archivePath) && fs10.existsSync(path11.join(installDir, archivePath))) {
8769
+ archivePath = path11.join(installDir, archivePath);
8770
+ }
8600
8771
  if (!fs10.existsSync(archivePath)) {
8601
8772
  log.error(`Backup file not found: ${archivePath}`);
8602
8773
  process.exit(1);
8603
8774
  }
8604
- const { dir: installDir, config } = loadInstall();
8605
8775
  const dbContainer = requireLocalDb(installDir, config, "Restore");
8606
8776
  const layout = stackLayout(config);
8607
8777
  const interactive = !!process.stdin.isTTY && !!process.stdout.isTTY;
@@ -8813,12 +8983,12 @@ function setMemLimit(content, service, limit) {
8813
8983
  if (header < 0) return content;
8814
8984
  const indent = " ";
8815
8985
  const block2 = lines.slice(header + 1, end);
8816
- const existing = block2.findIndex((l2) => /^\s+mem_limit:/.test(l2));
8986
+ const existing = block2.findIndex((l) => /^\s+mem_limit:/.test(l));
8817
8987
  if (existing >= 0) {
8818
8988
  lines[header + 1 + existing] = lines[header + 1 + existing].replace(/mem_limit:.*/, `mem_limit: ${limit}`);
8819
8989
  return lines.join("\n");
8820
8990
  }
8821
- const containerName = block2.findIndex((l2) => /^\s+container_name:/.test(l2));
8991
+ const containerName = block2.findIndex((l) => /^\s+container_name:/.test(l));
8822
8992
  const at = containerName >= 0 ? header + 1 + containerName + 1 : header + 1;
8823
8993
  lines.splice(at, 0, `${indent}mem_limit: ${limit}`);
8824
8994
  return lines.join("\n");
@@ -8831,7 +9001,7 @@ async function scaleResources(config) {
8831
9001
  } catch {
8832
9002
  try {
8833
9003
  const id = config.deploymentId || autoDetectDeploymentId();
8834
- const running = listDeploymentContainers(id || void 0).filter((c2) => c2.status.toLowerCase().startsWith("up")).map((c2) => c2.name);
9004
+ const running = listDeploymentContainers(id || void 0).filter((c3) => c3.status.toLowerCase().startsWith("up")).map((c3) => c3.name);
8835
9005
  if (running.length > 0) {
8836
9006
  const stats = dockerStatsForContainers(running);
8837
9007
  log.message(import_picocolors14.default.dim(stats.trim()));
@@ -8970,16 +9140,16 @@ function showDeployments() {
8970
9140
  log.info(`Found ${import_picocolors15.default.bold(String(deployments.size))} deployment${deployments.size === 1 ? "" : "s"}`);
8971
9141
  console.log();
8972
9142
  for (const [id, dep] of deployments) {
8973
- const running = dep.containers.filter((c2) => c2.status.toLowerCase().startsWith("up")).length;
9143
+ const running = dep.containers.filter((c3) => c3.status.toLowerCase().startsWith("up")).length;
8974
9144
  const total = dep.containers.length;
8975
9145
  const statusColor = running === total ? import_picocolors15.default.green : running > 0 ? import_picocolors15.default.yellow : import_picocolors15.default.red;
8976
9146
  const statusText = statusColor(`${running}/${total} running`);
8977
9147
  console.log(` ${import_picocolors15.default.bold(import_picocolors15.default.white(`Deployment ${id}`))} ${statusText}`);
8978
9148
  console.log();
8979
- for (const c2 of dep.containers) {
8980
- const isUp = c2.status.toLowerCase().startsWith("up");
9149
+ for (const c3 of dep.containers) {
9150
+ const isUp = c3.status.toLowerCase().startsWith("up");
8981
9151
  const icon = isUp ? import_picocolors15.default.green("\u25CF") : import_picocolors15.default.red("\u25CF");
8982
- console.log(` ${icon} ${import_picocolors15.default.white(c2.service.padEnd(24))} ${import_picocolors15.default.dim(c2.status)}`);
9152
+ console.log(` ${icon} ${import_picocolors15.default.white(c3.service.padEnd(24))} ${import_picocolors15.default.dim(c3.status)}`);
8983
9153
  }
8984
9154
  console.log();
8985
9155
  }
@@ -9098,22 +9268,22 @@ async function doctorCommand() {
9098
9268
  if (containers.length === 0) {
9099
9269
  warn("No containers found", "Run: npx learnhouse start");
9100
9270
  } else {
9101
- for (const c2 of containers) {
9102
- const isUp = c2.status.toLowerCase().startsWith("up");
9103
- const svcName = c2.service;
9271
+ for (const c3 of containers) {
9272
+ const isUp = c3.status.toLowerCase().startsWith("up");
9273
+ const svcName = c3.service;
9104
9274
  if (isUp) {
9105
9275
  pass(`${svcName} running`);
9106
- } else if (c2.status.toLowerCase().includes("restarting")) {
9276
+ } else if (c3.status.toLowerCase().includes("restarting")) {
9107
9277
  fail2(`${svcName} is restarting`, "Check logs: npx learnhouse logs");
9108
9278
  } else {
9109
- fail2(`${svcName}: ${c2.status}`, "Run: npx learnhouse start");
9279
+ fail2(`${svcName}: ${c3.status}`, "Run: npx learnhouse start");
9110
9280
  }
9111
9281
  }
9112
9282
  }
9113
9283
  log.step("Restart Counts");
9114
- for (const c2 of containers) {
9115
- const count = getContainerRestartCount(c2.name);
9116
- const svcName = c2.service;
9284
+ for (const c3 of containers) {
9285
+ const count = getContainerRestartCount(c3.name);
9286
+ const svcName = c3.service;
9117
9287
  if (count > 3) {
9118
9288
  warn(`${svcName} has restarted ${count} times`, "Check container logs for crash reasons");
9119
9289
  } else {
@@ -9125,7 +9295,7 @@ async function doctorCommand() {
9125
9295
  if (portFree) {
9126
9296
  pass(`Port ${config.httpPort} is available`);
9127
9297
  } else {
9128
- const hasRunning = containers.some((c2) => c2.status.toLowerCase().startsWith("up"));
9298
+ const hasRunning = containers.some((c3) => c3.status.toLowerCase().startsWith("up"));
9129
9299
  if (hasRunning) {
9130
9300
  pass(`Port ${config.httpPort} in use (by LearnHouse services)`);
9131
9301
  } else {
@@ -9163,12 +9333,12 @@ async function doctorCommand() {
9163
9333
  }
9164
9334
  log.step("Log Analysis");
9165
9335
  const errorPatterns = /\bERROR\b[:\s]|\bFATAL\b[:\s]|\bTraceback\b|\bException\b[:\s]/;
9166
- for (const c2 of containers) {
9167
- if (!isContainerRunning(c2.name)) continue;
9336
+ for (const c3 of containers) {
9337
+ if (!isContainerRunning(c3.name)) continue;
9168
9338
  try {
9169
- const logs = getContainerLogs(c2.name, 50);
9170
- const errorLines = logs.split("\n").filter((l2) => errorPatterns.test(l2));
9171
- const svcName = c2.service;
9339
+ const logs = getContainerLogs(c3.name, 50);
9340
+ const errorLines = logs.split("\n").filter((l) => errorPatterns.test(l));
9341
+ const svcName = c3.service;
9172
9342
  if (errorLines.length > 0) {
9173
9343
  warn(`${svcName}: ${errorLines.length} error(s) in last 50 log lines`);
9174
9344
  for (const line of errorLines.slice(0, 3)) {
@@ -9178,7 +9348,7 @@ async function doctorCommand() {
9178
9348
  pass(`${svcName}: no errors in recent logs`);
9179
9349
  }
9180
9350
  } catch {
9181
- warn(`Could not read logs for ${c2.name}`);
9351
+ warn(`Could not read logs for ${c3.name}`);
9182
9352
  }
9183
9353
  }
9184
9354
  log.step("Environment File");
@@ -9222,10 +9392,10 @@ async function doctorCommand() {
9222
9392
  }
9223
9393
  }
9224
9394
  log.step("Image Freshness");
9225
- for (const c2 of containers) {
9395
+ for (const c3 of containers) {
9226
9396
  try {
9227
- const localDigest = dockerExecFileSync(["inspect", "--format", "{{.Image}}", c2.name], { stdio: "pipe" }).toString().trim();
9228
- pass(`${c2.service}: ${c2.image} (${localDigest.slice(7, 19)})`);
9397
+ const localDigest = dockerExecFileSync(["inspect", "--format", "{{.Image}}", c3.name], { stdio: "pipe" }).toString().trim();
9398
+ pass(`${c3.service}: ${c3.image} (${localDigest.slice(7, 19)})`);
9229
9399
  } catch {
9230
9400
  }
9231
9401
  }
@@ -9252,16 +9422,16 @@ async function shellCommand() {
9252
9422
  log.error("No deployment found. Start services first.");
9253
9423
  process.exit(1);
9254
9424
  }
9255
- const containers = listDeploymentContainers(id).filter((c2) => c2.status.toLowerCase().startsWith("up"));
9425
+ const containers = listDeploymentContainers(id).filter((c3) => c3.status.toLowerCase().startsWith("up"));
9256
9426
  if (containers.length === 0) {
9257
9427
  log.error("No running containers found. Start services first.");
9258
9428
  process.exit(1);
9259
9429
  }
9260
9430
  const selected = await select({
9261
9431
  message: "Select a container",
9262
- options: containers.map((c2) => ({
9263
- value: c2.name,
9264
- label: `${c2.service} ${import_picocolors17.default.dim(`(${c2.name})`)}`
9432
+ options: containers.map((c3) => ({
9433
+ value: c3.name,
9434
+ label: `${c3.service} ${import_picocolors17.default.dim(`(${c3.name})`)}`
9265
9435
  }))
9266
9436
  });
9267
9437
  if (isCancel(selected)) {
@@ -10019,15 +10189,15 @@ function ensureAlembicBaseline(dir, layout, ui) {
10019
10189
  function runAlembicUpgrade(dir, layout, ui, previousHeads = []) {
10020
10190
  try {
10021
10191
  const current = alembic(dir, layout, "current 2>/dev/null");
10022
- const revLines = current.split("\n").map((l2) => l2.trim()).filter((l2) => /^[0-9a-z]{8,40}\b/.test(l2));
10023
- if (revLines.length > 0 && revLines.every((l2) => /head\)/i.test(l2))) {
10192
+ const revLines = current.split("\n").map((l) => l.trim()).filter((l) => /^[0-9a-z]{8,40}\b/.test(l));
10193
+ if (revLines.length > 0 && revLines.every((l) => /head\)/i.test(l))) {
10024
10194
  ui.ok("Database already at head, no migrations needed");
10025
10195
  return true;
10026
10196
  }
10027
10197
  if (revLines.length === 0) {
10028
10198
  try {
10029
10199
  const out2 = alembic(dir, layout, "upgrade heads");
10030
- const applied2 = out2.split("\n").filter((l2) => /Running upgrade/.test(l2)).length;
10200
+ const applied2 = out2.split("\n").filter((l) => /Running upgrade/.test(l)).length;
10031
10201
  ui.ok(applied2 ? `Applied ${applied2} migration(s)` : "Database migrated to head");
10032
10202
  return true;
10033
10203
  } catch (upgradeErr) {
@@ -10041,13 +10211,13 @@ function runAlembicUpgrade(dir, layout, ui, previousHeads = []) {
10041
10211
  }
10042
10212
  alembic(dir, layout, `stamp ${previousHeads.join(" ")}`);
10043
10213
  const out2 = alembic(dir, layout, "upgrade heads");
10044
- const applied2 = out2.split("\n").filter((l2) => /Running upgrade/.test(l2)).length;
10214
+ const applied2 = out2.split("\n").filter((l) => /Running upgrade/.test(l)).length;
10045
10215
  ui.ok(`Schema created via create_all; stamped at the previous revision and applied ${applied2} migration(s)`);
10046
10216
  return true;
10047
10217
  }
10048
10218
  }
10049
10219
  const out = alembic(dir, layout, "upgrade heads");
10050
- const applied = out.split("\n").filter((l2) => /Running upgrade/.test(l2)).length;
10220
+ const applied = out.split("\n").filter((l) => /Running upgrade/.test(l)).length;
10051
10221
  ui.ok(applied ? `Applied ${applied} migration(s)` : "Database migrated to head");
10052
10222
  return true;
10053
10223
  } catch (err) {
@@ -10079,7 +10249,7 @@ function migrateBeforeBoot(dir, layout, previousHeads, ui) {
10079
10249
  ui.log(`Database created via create_all; stamped at the previous image's revision (${previousHeads.join(", ")})`);
10080
10250
  }
10081
10251
  const out = run("upgrade heads");
10082
- const applied = out.split("\n").filter((l2) => /Running upgrade/.test(l2)).length;
10252
+ const applied = out.split("\n").filter((l) => /Running upgrade/.test(l)).length;
10083
10253
  ui.ok(applied ? `Applied ${applied} migration(s) before starting the new image` : "Database migrated to head before starting the new image");
10084
10254
  return true;
10085
10255
  } catch (err) {
@@ -10348,7 +10518,7 @@ async function updateCommand(options) {
10348
10518
  }
10349
10519
  } else {
10350
10520
  log.info("Skipped migrations (--no-migrate). Run later:");
10351
- log.info(' docker compose exec learnhouse-app sh -c "cd /app/api && uv run alembic upgrade head"');
10521
+ log.info(' docker compose exec learnhouse-app sh -c "cd /app/api && uv run alembic upgrade heads"');
10352
10522
  }
10353
10523
  if (!healthy) process.exit(1);
10354
10524
  if (targetVersion) {
@@ -10433,9 +10603,9 @@ async function healthCommand() {
10433
10603
  if (containers.length === 0) {
10434
10604
  log.message(fail3("No containers found. Are services running?"));
10435
10605
  } else {
10436
- for (const c2 of containers) {
10437
- const isUp = c2.status.toLowerCase().startsWith("up");
10438
- log.message(isUp ? pass2(`${c2.service}: ${c2.status}`) : fail3(`${c2.service}: ${c2.status}`));
10606
+ for (const c3 of containers) {
10607
+ const isUp = c3.status.toLowerCase().startsWith("up");
10608
+ log.message(isUp ? pass2(`${c3.service}: ${c3.status}`) : fail3(`${c3.service}: ${c3.status}`));
10439
10609
  }
10440
10610
  }
10441
10611
  log.step("Database");
@@ -10497,7 +10667,7 @@ async function healthCommand() {
10497
10667
  log.message(import_picocolors23.default.dim(stats.trim()));
10498
10668
  } catch {
10499
10669
  try {
10500
- const names = containers.filter((c2) => c2.status.toLowerCase().startsWith("up")).map((c2) => c2.name);
10670
+ const names = containers.filter((c3) => c3.status.toLowerCase().startsWith("up")).map((c3) => c3.name);
10501
10671
  if (names.length > 0) {
10502
10672
  const stats = dockerStatsForContainers(names);
10503
10673
  log.message(import_picocolors23.default.dim(stats.trim()));
@@ -10534,7 +10704,10 @@ var COMMUNITY_CATEGORIES = {
10534
10704
  "NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG",
10535
10705
  "NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG",
10536
10706
  "NEXT_PUBLIC_LEARNHOUSE_HTTPS",
10537
- "NEXTAUTH_URL"
10707
+ "NEXTAUTH_URL",
10708
+ "LEARNHOUSE_FRONTEND_DOMAIN",
10709
+ "LEARNHOUSE_SSL",
10710
+ "LEARNHOUSE_MEDIA_URL"
10538
10711
  ]
10539
10712
  },
10540
10713
  database: {
@@ -10553,8 +10726,7 @@ var COMMUNITY_CATEGORIES = {
10553
10726
  "NEXTAUTH_SECRET",
10554
10727
  "LEARNHOUSE_AUTH_JWT_SECRET_KEY",
10555
10728
  "LEARNHOUSE_INITIAL_ADMIN_EMAIL",
10556
- "LEARNHOUSE_INITIAL_ADMIN_PASSWORD",
10557
- "LEARNHOUSE_COOKIE_DOMAIN"
10729
+ "LEARNHOUSE_INITIAL_ADMIN_PASSWORD"
10558
10730
  ]
10559
10731
  },
10560
10732
  ai: {
@@ -10579,7 +10751,11 @@ var COMMUNITY_CATEGORIES = {
10579
10751
  keys: [
10580
10752
  "LEARNHOUSE_CONTENT_DELIVERY_TYPE",
10581
10753
  "LEARNHOUSE_S3_API_BUCKET_NAME",
10582
- "LEARNHOUSE_S3_API_ENDPOINT_URL"
10754
+ "LEARNHOUSE_S3_API_ENDPOINT_URL",
10755
+ "AWS_DEFAULT_REGION",
10756
+ "LEARNHOUSE_S3_API_REGION",
10757
+ "AWS_ACCESS_KEY_ID",
10758
+ "AWS_SECRET_ACCESS_KEY"
10583
10759
  ]
10584
10760
  },
10585
10761
  oauth: {
@@ -10614,7 +10790,7 @@ var ENTERPRISE_CATEGORIES = {
10614
10790
  }
10615
10791
  };
10616
10792
  var DB_PASSWORD_KEYS = /* @__PURE__ */ new Set(["POSTGRES_PASSWORD", "DB_PASSWORD"]);
10617
- var DERIVED_KEYS = /* @__PURE__ */ new Set(["LEARNHOUSE_DOMAIN", "DOMAIN", "AGENCY_DOMAIN"]);
10793
+ var DERIVED_KEYS = /* @__PURE__ */ new Set(["LEARNHOUSE_DOMAIN", "HTTP_PORT", "DOMAIN", "AGENCY_DOMAIN"]);
10618
10794
  function isSecret(key) {
10619
10795
  const upper = key.toUpperCase();
10620
10796
  return SECRET_PATTERNS.some((pat) => upper.includes(pat));
@@ -10718,7 +10894,7 @@ async function envCommand() {
10718
10894
  );
10719
10895
  }
10720
10896
  if (DERIVED_KEYS.has(key)) {
10721
- log.warn("The URLs, cookie domain and proxy config were generated from the domain at setup; re-run `npx learnhouse setup` to change the domain everywhere.");
10897
+ log.warn("The URLs, cookie domain and proxy config were generated from the domain at setup; re-run `npx learnhouse setup` to change the domain or port everywhere.");
10722
10898
  }
10723
10899
  const newValue = isSecret(key) ? await password({ message: `New value for ${key} (leave empty to keep the current one)` }) : await text({
10724
10900
  message: `New value for ${key}`,
@@ -10810,7 +10986,7 @@ program2.name("learnhouse").description("The official LearnHouse CLI: deploy, ma
10810
10986
  process.exit(2);
10811
10987
  }
10812
10988
  });
10813
- program2.command("setup").description("Interactive setup wizard for LearnHouse").option("--ci", "Non-interactive mode with defaults (for CI/automation)").option("--name <name>", 'Installation name (default: "default")').option("--domain <domain>", 'Domain name (default: "localhost")').option("--port <port>", "HTTP port (default: 80)").option("--admin-email <email>", 'Admin email (default: "admin@school.dev")').option("--admin-password <password>", "Admin password (required in --ci mode; or set LEARNHOUSE_ADMIN_PASSWORD)").option("--org-name <name>", 'Organization display name (default: "Default Organization")').option("--org-slug <slug>", 'Organization slug used in URLs (default: "default")').option("--channel <channel>", 'Release channel: stable or dev (default: "stable")').option("--no-start", "Skip starting services after setup").option("--edition <edition>", "Edition to deploy: community (default) or enterprise").option("--license <key>", "EE license key, also the image-registry password (or set LEARNHOUSE_LICENSE_KEY)").option("--tenancy <mode>", "EE tenancy: single (default) or agency (multi-tenant)").option("--acme-email <email>", "EE: Let's Encrypt contact email (default: admin email)").option("--ee-image-tag <tag>", 'EE image tag (default: "prod")').option("--local-tls", "EE: use Caddy internal CA (self-signed; testing only)").option("--external-db <uri>", "Use an external Postgres (e.g. Supabase) instead of the in-container db (or set LEARNHOUSE_EXTERNAL_DB)").option("--external-redis <uri>", "Community: use an external Redis instead of the in-container redis (or set LEARNHOUSE_EXTERNAL_REDIS)").option("--dns-provider <provider>", "EE: DNS-01 provider for wildcard certs (cloudflare)").option("--cf-api-token <token>", "EE: Cloudflare API token (Zone:DNS:Edit) for DNS-01 (or set LEARNHOUSE_CF_API_TOKEN)").option("--docker-ipv6", "Enable IPv6 on the compose network (needed for IPv6-only external DBs)").option("--install-dir <dir>", "Override the install directory (default: ~/.learnhouse/<name>)").action(setupCommand);
10989
+ program2.command("setup").description("Interactive setup wizard for LearnHouse").option("--ci", "Non-interactive mode with defaults (for CI/automation)").option("--name <name>", 'Installation name (default: "default")').option("--domain <domain>", 'Domain name (default: "localhost")').option("--port <port>", "HTTP port (default: 80)").option("--admin-email <email>", 'Admin email (default: "admin@school.dev")').option("--admin-password <password>", "Admin password (required in --ci mode; or set LEARNHOUSE_ADMIN_PASSWORD)").option("--org-name <name>", 'Organization display name (default: "Default Organization")').option("--org-slug <slug>", 'Organization slug used in URLs (default: "default")').option("--channel <channel>", 'Release channel: stable or dev (default: "stable")').option("--no-start", "Skip starting services after setup").option("--https <mode>", "Community HTTPS: auto (Let's Encrypt via Caddy), manual (TLS ends at your own proxy) or off (default)").option("--ssl-email <email>", "Let's Encrypt contact email for --https auto (default: --admin-email)").option("--edition <edition>", "Edition to deploy: community (default) or enterprise").option("--license <key>", "EE license key, also the image-registry password (or set LEARNHOUSE_LICENSE_KEY)").option("--tenancy <mode>", "EE tenancy: single (default) or agency (multi-tenant)").option("--acme-email <email>", "EE: Let's Encrypt contact email (default: admin email)").option("--ee-image-tag <tag>", 'EE image tag (default: "prod")').option("--local-tls", "EE: use Caddy internal CA (self-signed; testing only)").option("--external-db <uri>", "Use an external Postgres (e.g. Supabase) instead of the in-container db (or set LEARNHOUSE_EXTERNAL_DB)").option("--external-redis <uri>", "Community: use an external Redis instead of the in-container redis (or set LEARNHOUSE_EXTERNAL_REDIS)").option("--dns-provider <provider>", "EE: DNS-01 provider for wildcard certs (cloudflare)").option("--cf-api-token <token>", "EE: Cloudflare API token (Zone:DNS:Edit) for DNS-01 (or set LEARNHOUSE_CF_API_TOKEN)").option("--docker-ipv6", "Enable IPv6 on the compose network (needed for IPv6-only external DBs)").option("--install-dir <dir>", "Override the install directory (default: ~/.learnhouse/<name>)").action(setupCommand);
10814
10990
  program2.command("start").description("Start LearnHouse services").action(startCommand);
10815
10991
  program2.command("stop").description("Stop LearnHouse services").action(stopCommand);
10816
10992
  program2.command("logs").description("Stream logs from LearnHouse services").action(logsCommand);