learnhouse 1.3.2 → 1.4.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.
package/README.md CHANGED
@@ -97,6 +97,55 @@ learnhouse/
97
97
  nginx.prod.conf # Reverse proxy (or Caddyfile for auto-SSL)
98
98
  ```
99
99
 
100
+ ## CI / Non-interactive Mode
101
+
102
+ All commands support non-interactive usage for CI pipelines:
103
+
104
+ ```bash
105
+ # Setup without prompts
106
+ npx learnhouse setup --ci \
107
+ --name production \
108
+ --domain example.com \
109
+ --port 80 \
110
+ --admin-email admin@example.com \
111
+ --admin-password secretpass123
112
+
113
+ # Update with auto-migration
114
+ npx learnhouse update --version 1.2.0 --migrate
115
+
116
+ # Update without migrations
117
+ npx learnhouse update --no-migrate
118
+
119
+ # Setup without starting services
120
+ npx learnhouse setup --ci --admin-password pass123 --no-start
121
+ ```
122
+
123
+ ## Testing
124
+
125
+ ```bash
126
+ # Unit tests (no Docker required)
127
+ bun run test
128
+
129
+ # E2E tests (requires Docker)
130
+ bun run test:e2e
131
+
132
+ # All tests
133
+ bun run test:all
134
+ ```
135
+
136
+ **Unit tests** cover template generation (docker-compose, .env, nginx, caddyfile) and config store operations.
137
+
138
+ **E2E tests** run the full lifecycle with real Docker containers: setup → start → status → health → doctor → stop → restart. They use `--ci` mode to run without prompts.
139
+
140
+ **Not yet tested:**
141
+ - Interactive commands (backup create/restore, env editor, shell, deployments scaling)
142
+ - `update` with actual version swap between two published images
143
+ - `update --migrate` with pending Alembic migrations
144
+ - `logs` (streams indefinitely)
145
+ - `dev` mode (requires full monorepo source)
146
+ - Multi-installation discovery (`findInstallDir` with multiple `~/.learnhouse/*` entries)
147
+ - Error recovery (Docker daemon down, port conflicts, corrupted config)
148
+
100
149
  ## License
101
150
 
102
151
  GPL-3.0
@@ -1202,8 +1202,8 @@ var require_command = __commonJS({
1202
1202
  "use strict";
1203
1203
  var EventEmitter = __require("events").EventEmitter;
1204
1204
  var childProcess = __require("child_process");
1205
- var path8 = __require("path");
1206
- var fs8 = __require("fs");
1205
+ var path10 = __require("path");
1206
+ var fs10 = __require("fs");
1207
1207
  var process2 = __require("process");
1208
1208
  var { Argument: Argument2, humanReadableArgName } = require_argument();
1209
1209
  var { CommanderError: CommanderError2 } = require_error();
@@ -2197,7 +2197,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2197
2197
  * @param {string} subcommandName
2198
2198
  */
2199
2199
  _checkForMissingExecutable(executableFile, executableDir, subcommandName) {
2200
- if (fs8.existsSync(executableFile)) return;
2200
+ if (fs10.existsSync(executableFile)) return;
2201
2201
  const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
2202
2202
  const executableMissing = `'${executableFile}' does not exist
2203
2203
  - if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
@@ -2215,11 +2215,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2215
2215
  let launchWithNode = false;
2216
2216
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
2217
2217
  function findFile(baseDir, baseName) {
2218
- const localBin = path8.resolve(baseDir, baseName);
2219
- if (fs8.existsSync(localBin)) return localBin;
2220
- if (sourceExt.includes(path8.extname(baseName))) return void 0;
2218
+ const localBin = path10.resolve(baseDir, baseName);
2219
+ if (fs10.existsSync(localBin)) return localBin;
2220
+ if (sourceExt.includes(path10.extname(baseName))) return void 0;
2221
2221
  const foundExt = sourceExt.find(
2222
- (ext) => fs8.existsSync(`${localBin}${ext}`)
2222
+ (ext) => fs10.existsSync(`${localBin}${ext}`)
2223
2223
  );
2224
2224
  if (foundExt) return `${localBin}${foundExt}`;
2225
2225
  return void 0;
@@ -2231,21 +2231,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
2231
2231
  if (this._scriptPath) {
2232
2232
  let resolvedScriptPath;
2233
2233
  try {
2234
- resolvedScriptPath = fs8.realpathSync(this._scriptPath);
2234
+ resolvedScriptPath = fs10.realpathSync(this._scriptPath);
2235
2235
  } catch {
2236
2236
  resolvedScriptPath = this._scriptPath;
2237
2237
  }
2238
- executableDir = path8.resolve(
2239
- path8.dirname(resolvedScriptPath),
2238
+ executableDir = path10.resolve(
2239
+ path10.dirname(resolvedScriptPath),
2240
2240
  executableDir
2241
2241
  );
2242
2242
  }
2243
2243
  if (executableDir) {
2244
2244
  let localFile = findFile(executableDir, executableFile);
2245
2245
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
2246
- const legacyName = path8.basename(
2246
+ const legacyName = path10.basename(
2247
2247
  this._scriptPath,
2248
- path8.extname(this._scriptPath)
2248
+ path10.extname(this._scriptPath)
2249
2249
  );
2250
2250
  if (legacyName !== this._name) {
2251
2251
  localFile = findFile(
@@ -2256,7 +2256,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2256
2256
  }
2257
2257
  executableFile = localFile || executableFile;
2258
2258
  }
2259
- launchWithNode = sourceExt.includes(path8.extname(executableFile));
2259
+ launchWithNode = sourceExt.includes(path10.extname(executableFile));
2260
2260
  let proc;
2261
2261
  if (process2.platform !== "win32") {
2262
2262
  if (launchWithNode) {
@@ -3171,7 +3171,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
3171
3171
  * @return {Command}
3172
3172
  */
3173
3173
  nameFromFilename(filename) {
3174
- this._name = path8.basename(filename, path8.extname(filename));
3174
+ this._name = path10.basename(filename, path10.extname(filename));
3175
3175
  return this;
3176
3176
  }
3177
3177
  /**
@@ -3185,9 +3185,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
3185
3185
  * @param {string} [path]
3186
3186
  * @return {(string|null|Command)}
3187
3187
  */
3188
- executableDir(path9) {
3189
- if (path9 === void 0) return this._executableDir;
3190
- this._executableDir = path9;
3188
+ executableDir(path11) {
3189
+ if (path11 === void 0) return this._executableDir;
3190
+ this._executableDir = path11;
3191
3191
  return this;
3192
3192
  }
3193
3193
  /**
@@ -3613,13 +3613,13 @@ var {
3613
3613
  } = import_index.default;
3614
3614
 
3615
3615
  // bin/learnhouse.ts
3616
- var import_picocolors19 = __toESM(require_picocolors(), 1);
3616
+ var import_picocolors23 = __toESM(require_picocolors(), 1);
3617
3617
 
3618
3618
  // src/constants.ts
3619
- var VERSION = "1.3.2";
3619
+ var VERSION = "1.4.0";
3620
3620
  var APP_IMAGE = "ghcr.io/learnhouse/app:latest";
3621
3621
  var DEV_IMAGE = "ghcr.io/learnhouse/app:dev";
3622
- var POSTGRES_IMAGE = "postgres:16-alpine";
3622
+ var POSTGRES_IMAGE = "pgvector/pgvector:pg16";
3623
3623
  var POSTGRES_AI_IMAGE = "pgvector/pgvector:pg16";
3624
3624
  var HEALTH_CHECK_TIMEOUT_MS = 18e4;
3625
3625
  var HEALTH_CHECK_INTERVAL_MS = 3e3;
@@ -3765,6 +3765,7 @@ async function resolveAppImage(channel = "stable") {
3765
3765
  // src/commands/setup.ts
3766
3766
  import crypto3 from "crypto";
3767
3767
  import fs2 from "fs";
3768
+ import os2 from "os";
3768
3769
  import path2 from "path";
3769
3770
 
3770
3771
  // node_modules/@clack/core/dist/index.mjs
@@ -4853,8 +4854,9 @@ function isDockerRunning() {
4853
4854
  return false;
4854
4855
  }
4855
4856
  }
4856
- function dockerComposeUp(cwd) {
4857
- execSync("docker compose up -d --pull always", {
4857
+ function dockerComposeUp(cwd, pull = false) {
4858
+ const cmd = pull ? "docker compose up -d --pull always" : "docker compose up -d";
4859
+ execSync(cmd, {
4858
4860
  cwd,
4859
4861
  stdio: "inherit"
4860
4862
  });
@@ -4865,6 +4867,12 @@ function dockerComposeDown(cwd) {
4865
4867
  stdio: "inherit"
4866
4868
  });
4867
4869
  }
4870
+ function dockerComposePs(cwd) {
4871
+ return execSync("docker compose ps", {
4872
+ cwd,
4873
+ stdio: "pipe"
4874
+ }).toString();
4875
+ }
4868
4876
  function dockerComposeLogs(cwd) {
4869
4877
  const child = spawn("docker", ["compose", "logs", "--tail", "all", "-f"], {
4870
4878
  cwd,
@@ -4930,6 +4938,12 @@ function dockerStatsForContainers(containerNames) {
4930
4938
  { stdio: "pipe" }
4931
4939
  ).toString();
4932
4940
  }
4941
+ function dockerExec(containerName, cmd) {
4942
+ return execSync(`docker exec ${containerName} ${cmd}`, {
4943
+ stdio: "pipe",
4944
+ timeout: 1e4
4945
+ }).toString().trim();
4946
+ }
4933
4947
  function getContainerLogs(containerName, lines = 50) {
4934
4948
  return execSync(`docker logs --tail ${lines} ${containerName}`, {
4935
4949
  stdio: "pipe"
@@ -5911,6 +5925,7 @@ ${config.domain} {
5911
5925
 
5912
5926
  // src/services/config-store.ts
5913
5927
  import fs from "fs";
5928
+ import os from "os";
5914
5929
  import path from "path";
5915
5930
  function writeConfig(config) {
5916
5931
  const data = {
@@ -5949,61 +5964,35 @@ function isCompleteInstall(dir) {
5949
5964
  return false;
5950
5965
  }
5951
5966
  }
5952
- function collectCandidates(dir, depth, results) {
5953
- if (depth < 0) return;
5954
- if (fs.existsSync(path.join(dir, CONFIG_FILENAME))) {
5955
- results.push(dir);
5956
- }
5967
+ function listInstallations() {
5968
+ const baseDir = path.join(os.homedir(), ".learnhouse");
5969
+ if (!fs.existsSync(baseDir)) return [];
5970
+ const results = [];
5957
5971
  try {
5958
- const entries = fs.readdirSync(dir, { withFileTypes: true });
5972
+ const entries = fs.readdirSync(baseDir, { withFileTypes: true });
5959
5973
  for (const entry of entries) {
5960
- if (!entry.isDirectory() || entry.name === "node_modules" || entry.name === ".git" || entry.name === "dist" || entry.name === "backups") continue;
5961
- collectCandidates(path.join(dir, entry.name), depth - 1, results);
5974
+ if (!entry.isDirectory()) continue;
5975
+ const dir = path.join(baseDir, entry.name);
5976
+ if (isCompleteInstall(dir)) {
5977
+ const config = JSON.parse(fs.readFileSync(path.join(dir, CONFIG_FILENAME), "utf-8"));
5978
+ results.push({ name: entry.name, dir, config });
5979
+ }
5962
5980
  }
5963
5981
  } catch {
5964
5982
  }
5965
- }
5966
- function pickBest(candidates) {
5967
- if (candidates.length === 0) return null;
5968
- const completeInstalls = candidates.filter(isCompleteInstall);
5969
- if (completeInstalls.length > 0) {
5970
- completeInstalls.sort((a, b) => {
5971
- try {
5972
- const configA = JSON.parse(fs.readFileSync(path.join(a, CONFIG_FILENAME), "utf-8"));
5973
- const configB = JSON.parse(fs.readFileSync(path.join(b, CONFIG_FILENAME), "utf-8"));
5974
- return (configB.createdAt || "").localeCompare(configA.createdAt || "");
5975
- } catch {
5976
- return 0;
5977
- }
5978
- });
5979
- return completeInstalls[0];
5980
- }
5981
- return candidates[0];
5983
+ results.sort((a, b) => (b.config.createdAt || "").localeCompare(a.config.createdAt || ""));
5984
+ return results;
5982
5985
  }
5983
5986
  function findInstallDir() {
5987
+ const baseDir = path.join(os.homedir(), ".learnhouse");
5988
+ const defaultDir = path.join(baseDir, "default");
5989
+ const installations = listInstallations();
5990
+ if (installations.length === 1) return installations[0].dir;
5991
+ if (isCompleteInstall(defaultDir)) return defaultDir;
5992
+ if (installations.length > 0) return installations[0].dir;
5984
5993
  const cwd = process.cwd();
5985
5994
  if (isCompleteInstall(cwd)) return cwd;
5986
- const subDir = path.join(cwd, "learnhouse");
5987
- if (isCompleteInstall(subDir)) return subDir;
5988
- const candidates = [];
5989
- collectCandidates(cwd, 10, candidates);
5990
- const best = pickBest(candidates);
5991
- if (best) return best;
5992
- let current = cwd;
5993
- let fallbackDir = null;
5994
- while (true) {
5995
- const parent = path.dirname(current);
5996
- if (parent === current) break;
5997
- if (isCompleteInstall(parent)) return parent;
5998
- const parentSub = path.join(parent, "learnhouse");
5999
- if (isCompleteInstall(parentSub)) return parentSub;
6000
- if (!fallbackDir && fs.existsSync(path.join(parent, CONFIG_FILENAME))) {
6001
- fallbackDir = parent;
6002
- }
6003
- current = parent;
6004
- }
6005
- if (fallbackDir) return fallbackDir;
6006
- return cwd;
5995
+ return process.cwd();
6007
5996
  }
6008
5997
 
6009
5998
  // src/services/health.ts
@@ -6047,19 +6036,25 @@ async function confirmOrBack(message) {
6047
6036
  return result === "back" ? BACK : true;
6048
6037
  }
6049
6038
  async function stepInstallDir() {
6050
- const defaultDir = fs2.existsSync(path2.join(process.cwd(), "learnhouse", "learnhouse.config.json")) ? "./learnhouse-new" : "./learnhouse";
6051
- const installDir = await text({
6052
- message: "Where should LearnHouse be installed?",
6053
- placeholder: defaultDir,
6054
- defaultValue: defaultDir
6039
+ const baseDir = path2.join(os2.homedir(), ".learnhouse");
6040
+ R2.info(`All installations are stored in ${import_picocolors8.default.cyan("~/.learnhouse/<name>")}`);
6041
+ const name = await text({
6042
+ message: "Name for this installation:",
6043
+ placeholder: "default",
6044
+ defaultValue: "default",
6045
+ validate: (value) => {
6046
+ if (!value) return "Name is required";
6047
+ if (/[/\\]/.test(value)) return "Name cannot contain slashes";
6048
+ return void 0;
6049
+ }
6055
6050
  });
6056
- if (Ct(installDir)) {
6051
+ if (Ct(name)) {
6057
6052
  Ne();
6058
6053
  process.exit(0);
6059
6054
  }
6060
- const resolved = path2.resolve(installDir);
6055
+ const resolved = path2.join(baseDir, name);
6061
6056
  if (fs2.existsSync(path2.join(resolved, "learnhouse.config.json"))) {
6062
- R2.warn(`${resolved} already contains a LearnHouse installation.`);
6057
+ R2.warn(`~/.learnhouse/${name} already contains a LearnHouse installation.`);
6063
6058
  const overwrite = await Re({
6064
6059
  message: "Overwrite existing installation?",
6065
6060
  initialValue: false
@@ -6069,6 +6064,7 @@ async function stepInstallDir() {
6069
6064
  process.exit(0);
6070
6065
  }
6071
6066
  }
6067
+ fs2.mkdirSync(resolved, { recursive: true });
6072
6068
  return resolved;
6073
6069
  }
6074
6070
  async function stepDomain() {
@@ -6096,7 +6092,70 @@ async function stepFeatures() {
6096
6092
  R2.step(import_picocolors8.default.cyan(`Step 6/6`) + " Optional Features");
6097
6093
  return await promptFeatures();
6098
6094
  }
6099
- async function setupCommand() {
6095
+ async function setupCommand(options) {
6096
+ if (options.ci) {
6097
+ if (!options.adminPassword) {
6098
+ console.error("Error: --admin-password is required in --ci mode");
6099
+ process.exit(1);
6100
+ }
6101
+ await checkPrerequisites();
6102
+ const installName = options.name || "default";
6103
+ const baseDir = path2.join(os2.homedir(), ".learnhouse");
6104
+ const resolvedDir2 = path2.join(baseDir, installName);
6105
+ fs2.mkdirSync(resolvedDir2, { recursive: true });
6106
+ const deploymentId2 = crypto3.randomBytes(4).toString("hex");
6107
+ const channel2 = options.channel === "dev" ? "dev" : "stable";
6108
+ const config2 = {
6109
+ deploymentId: deploymentId2,
6110
+ installDir: resolvedDir2,
6111
+ channel: channel2,
6112
+ domain: options.domain || "localhost",
6113
+ useHttps: false,
6114
+ httpPort: options.port || 80,
6115
+ autoSsl: false,
6116
+ useExternalDb: false,
6117
+ useAiDatabase: false,
6118
+ useExternalRedis: false,
6119
+ orgName: "Default",
6120
+ adminEmail: options.adminEmail || "admin@school.dev",
6121
+ adminPassword: options.adminPassword,
6122
+ aiEnabled: false,
6123
+ emailEnabled: false,
6124
+ s3Enabled: false,
6125
+ googleOAuthEnabled: false,
6126
+ unsplashEnabled: false
6127
+ };
6128
+ console.log(`Setting up LearnHouse in ~/.learnhouse/${installName}`);
6129
+ const { image: appImage2 } = await resolveAppImage(config2.channel);
6130
+ console.log(`Using image: ${appImage2}`);
6131
+ fs2.mkdirSync(resolvedDir2, { recursive: true });
6132
+ fs2.mkdirSync(path2.join(resolvedDir2, "extra"), { recursive: true });
6133
+ fs2.writeFileSync(path2.join(resolvedDir2, "docker-compose.yml"), generateDockerCompose(config2, appImage2));
6134
+ fs2.writeFileSync(path2.join(resolvedDir2, ".env"), generateEnvFile(config2));
6135
+ fs2.writeFileSync(path2.join(resolvedDir2, "extra", "nginx.prod.conf"), generateNginxConf());
6136
+ writeConfig(config2);
6137
+ console.log("Configuration files generated");
6138
+ if (options.start !== false) {
6139
+ console.log("Starting services...");
6140
+ try {
6141
+ dockerComposeUp(resolvedDir2);
6142
+ const healthy = await waitForHealth(`http://localhost:${config2.httpPort}`);
6143
+ if (healthy) {
6144
+ console.log("LearnHouse is ready!");
6145
+ } else {
6146
+ console.log("Health check timed out \u2014 services may still be starting");
6147
+ }
6148
+ } catch {
6149
+ console.error("Failed to start services");
6150
+ process.exit(1);
6151
+ }
6152
+ }
6153
+ const portSuffix2 = config2.httpPort === 80 ? "" : `:${config2.httpPort}`;
6154
+ console.log(`URL: http://${config2.domain}${portSuffix2}`);
6155
+ console.log(`Admin: ${config2.adminEmail}`);
6156
+ console.log(`Install dir: ${resolvedDir2}`);
6157
+ return;
6158
+ }
6100
6159
  await printBanner();
6101
6160
  We(import_picocolors8.default.cyan("LearnHouse Setup Wizard"));
6102
6161
  await checkPrerequisites();
@@ -6390,8 +6449,7 @@ async function startCommand() {
6390
6449
  const dir = findInstallDir();
6391
6450
  const config = readConfig(dir);
6392
6451
  if (!config) {
6393
- R2.error("No LearnHouse installation found in the current directory.");
6394
- R2.info("Run `npx learnhouse` to set up a new installation.");
6452
+ R2.error("No LearnHouse installation found. Run `npx learnhouse setup` first.");
6395
6453
  process.exit(1);
6396
6454
  }
6397
6455
  We(import_picocolors9.default.cyan("Starting LearnHouse"));
@@ -6410,7 +6468,7 @@ async function stopCommand() {
6410
6468
  const dir = findInstallDir();
6411
6469
  const config = readConfig(dir);
6412
6470
  if (!config) {
6413
- R2.error("No LearnHouse installation found in the current directory.");
6471
+ R2.error("No LearnHouse installation found. Run `npx learnhouse setup` first.");
6414
6472
  process.exit(1);
6415
6473
  }
6416
6474
  We(import_picocolors10.default.cyan("Stopping LearnHouse"));
@@ -6430,8 +6488,8 @@ async function logsCommand() {
6430
6488
  R2.info("Streaming logs (Ctrl+C to stop)...");
6431
6489
  if (config?.installDir) {
6432
6490
  try {
6433
- const { execSync: execSync7 } = await import("child_process");
6434
- const ps = execSync7("docker compose ps -q", { cwd: config.installDir, stdio: "pipe" }).toString().trim();
6491
+ const { execSync: execSync8 } = await import("child_process");
6492
+ const ps = execSync8("docker compose ps -q", { cwd: config.installDir, stdio: "pipe" }).toString().trim();
6435
6493
  if (ps) {
6436
6494
  dockerComposeLogs(config.installDir);
6437
6495
  return;
@@ -6458,7 +6516,7 @@ async function configCommand() {
6458
6516
  const dir = findInstallDir();
6459
6517
  const config = readConfig(dir);
6460
6518
  if (!config) {
6461
- R2.error("No LearnHouse installation found in the current directory.");
6519
+ R2.error("No LearnHouse installation found. Run `npx learnhouse setup` first.");
6462
6520
  process.exit(1);
6463
6521
  }
6464
6522
  We(import_picocolors11.default.cyan("LearnHouse Configuration"));
@@ -7692,7 +7750,7 @@ async function updateCommand(options) {
7692
7750
  const dir = findInstallDir();
7693
7751
  const config = readConfig(dir);
7694
7752
  if (!config) {
7695
- R2.error("No LearnHouse installation found in the current directory.");
7753
+ R2.error("No LearnHouse installation found. Run `npx learnhouse setup` first.");
7696
7754
  process.exit(1);
7697
7755
  }
7698
7756
  const targetVersion = options.version?.replace(/^v/, "");
@@ -7737,22 +7795,27 @@ async function updateCommand(options) {
7737
7795
  dockerComposeDown(config.installDir);
7738
7796
  dockerComposeUp(config.installDir);
7739
7797
  s.stop("Services restarted");
7740
- R2.info("");
7741
- R2.warn(
7742
- import_picocolors18.default.bold("This update may include database migrations.")
7743
- );
7744
- R2.info(
7745
- `Before proceeding, check the release notes at ${import_picocolors18.default.cyan("https://docs.learnhouse.app")} for migration guides and breaking changes.`
7746
- );
7747
- R2.info("");
7748
- const runMigrations = await Re({
7749
- message: "Run database migrations now?",
7750
- initialValue: false
7751
- });
7752
- if (Ct(runMigrations)) {
7753
- R2.info("Skipped database migrations. You can run them later with:");
7754
- R2.info(' docker exec <container> sh -c "cd /app/api && uv run alembic upgrade head"');
7755
- } else if (runMigrations) {
7798
+ let shouldMigrate;
7799
+ if (options.migrate === true) {
7800
+ shouldMigrate = true;
7801
+ } else if (options.migrate === false) {
7802
+ shouldMigrate = false;
7803
+ } else {
7804
+ R2.info("");
7805
+ R2.warn(
7806
+ import_picocolors18.default.bold("This update may include database migrations.")
7807
+ );
7808
+ R2.info(
7809
+ `Before proceeding, check the release notes at ${import_picocolors18.default.cyan("https://docs.learnhouse.app")} for migration guides and breaking changes.`
7810
+ );
7811
+ R2.info("");
7812
+ const runMigrations = await Re({
7813
+ message: "Run database migrations now?",
7814
+ initialValue: false
7815
+ });
7816
+ shouldMigrate = !Ct(runMigrations) && !!runMigrations;
7817
+ }
7818
+ if (shouldMigrate) {
7756
7819
  s.start("Running database migrations");
7757
7820
  try {
7758
7821
  const appContainer = getAppContainerName(config.installDir);
@@ -7823,15 +7886,441 @@ function waitForContainer(containerName, timeoutMs = 6e4) {
7823
7886
  }
7824
7887
  }
7825
7888
 
7889
+ // src/commands/status.ts
7890
+ var import_picocolors19 = __toESM(require_picocolors(), 1);
7891
+ async function statusCommand() {
7892
+ const dir = findInstallDir();
7893
+ const config = readConfig(dir);
7894
+ if (!config) {
7895
+ R2.error("No LearnHouse installation found. Run `npx learnhouse setup` first.");
7896
+ process.exit(1);
7897
+ }
7898
+ We(import_picocolors19.default.cyan("LearnHouse Status"));
7899
+ const protocol = config.useHttps ? "https" : "http";
7900
+ const portSuffix = config.useHttps && config.httpPort === 443 || !config.useHttps && config.httpPort === 80 ? "" : `:${config.httpPort}`;
7901
+ R2.info(`URL: ${protocol}://${config.domain}${portSuffix}`);
7902
+ try {
7903
+ const output = dockerComposePs(config.installDir);
7904
+ console.log(output);
7905
+ } catch {
7906
+ R2.error("Failed to get status. Is Docker running?");
7907
+ process.exit(1);
7908
+ }
7909
+ }
7910
+
7911
+ // src/commands/health.ts
7912
+ var import_picocolors20 = __toESM(require_picocolors(), 1);
7913
+ function pass2(msg) {
7914
+ return `${import_picocolors20.default.green("\u25CF")} ${msg}`;
7915
+ }
7916
+ function fail2(msg) {
7917
+ return `${import_picocolors20.default.red("\u25CF")} ${msg}`;
7918
+ }
7919
+ async function healthCommand() {
7920
+ const dir = findInstallDir();
7921
+ const config = readConfig(dir);
7922
+ if (!config) {
7923
+ R2.error("No LearnHouse installation found. Run setup first.");
7924
+ process.exit(1);
7925
+ }
7926
+ We(import_picocolors20.default.cyan("LearnHouse Health Check"));
7927
+ const id = config.deploymentId || autoDetectDeploymentId();
7928
+ if (!id) {
7929
+ R2.error("No deployment found. Start services first.");
7930
+ process.exit(1);
7931
+ }
7932
+ R2.step("Container Status");
7933
+ const containers = listDeploymentContainers(id);
7934
+ if (containers.length === 0) {
7935
+ R2.message(fail2("No containers found. Are services running?"));
7936
+ } else {
7937
+ for (const c of containers) {
7938
+ const isUp = c.status.toLowerCase().startsWith("up");
7939
+ const svcName = c.name.replace(`-${id}`, "");
7940
+ R2.message(isUp ? pass2(`${svcName} \u2014 ${c.status}`) : fail2(`${svcName} \u2014 ${c.status}`));
7941
+ }
7942
+ }
7943
+ R2.step("Database");
7944
+ const dbContainer = `learnhouse-db-${id}`;
7945
+ if (isContainerRunning(dbContainer)) {
7946
+ try {
7947
+ dockerExec(dbContainer, "pg_isready -U learnhouse");
7948
+ R2.message(pass2("PostgreSQL accepting connections"));
7949
+ } catch {
7950
+ R2.message(fail2("PostgreSQL not ready"));
7951
+ }
7952
+ } else {
7953
+ R2.message(fail2("Database container not running"));
7954
+ }
7955
+ R2.step("Redis");
7956
+ const redisContainer = `learnhouse-redis-${id}`;
7957
+ if (isContainerRunning(redisContainer)) {
7958
+ try {
7959
+ const pong = dockerExec(redisContainer, "redis-cli ping");
7960
+ R2.message(pong === "PONG" ? pass2("Redis responding") : fail2(`Redis returned: ${pong}`));
7961
+ } catch {
7962
+ R2.message(fail2("Redis not responding"));
7963
+ }
7964
+ } else {
7965
+ R2.message(fail2("Redis container not running"));
7966
+ }
7967
+ R2.step("HTTP Endpoint");
7968
+ const protocol = config.useHttps ? "https" : "http";
7969
+ const portSuffix = config.useHttps && config.httpPort === 443 || !config.useHttps && config.httpPort === 80 ? "" : `:${config.httpPort}`;
7970
+ const healthUrl = `${protocol}://${config.domain}${portSuffix}/api/v1/health`;
7971
+ try {
7972
+ const start = Date.now();
7973
+ const resp = await fetch(healthUrl, { signal: AbortSignal.timeout(5e3) });
7974
+ const elapsed = Date.now() - start;
7975
+ if (resp.ok) {
7976
+ R2.message(pass2(`${healthUrl} \u2014 ${resp.status} (${elapsed}ms)`));
7977
+ } else {
7978
+ R2.message(fail2(`${healthUrl} \u2014 ${resp.status} (${elapsed}ms)`));
7979
+ }
7980
+ } catch (err) {
7981
+ R2.message(fail2(`${healthUrl} \u2014 ${err.message || "unreachable"}`));
7982
+ }
7983
+ R2.step("Disk Usage");
7984
+ try {
7985
+ const diskOutput = getDockerDiskUsage();
7986
+ R2.message(import_picocolors20.default.dim(diskOutput.trim()));
7987
+ } catch {
7988
+ R2.message(fail2("Could not retrieve disk usage"));
7989
+ }
7990
+ R2.step("Resource Usage");
7991
+ try {
7992
+ const stats = dockerStats(config.installDir);
7993
+ R2.message(import_picocolors20.default.dim(stats.trim()));
7994
+ } catch {
7995
+ try {
7996
+ const names = containers.filter((c) => c.status.toLowerCase().startsWith("up")).map((c) => c.name);
7997
+ if (names.length > 0) {
7998
+ const stats = dockerStatsForContainers(names);
7999
+ R2.message(import_picocolors20.default.dim(stats.trim()));
8000
+ } else {
8001
+ R2.message(fail2("No running containers to get stats from"));
8002
+ }
8003
+ } catch {
8004
+ R2.message(fail2("Could not retrieve resource stats"));
8005
+ }
8006
+ }
8007
+ Le(import_picocolors20.default.dim("Health check complete"));
8008
+ }
8009
+
8010
+ // src/commands/env.ts
8011
+ import fs8 from "fs";
8012
+ import path8 from "path";
8013
+ var import_picocolors21 = __toESM(require_picocolors(), 1);
8014
+ var SECRET_PATTERNS = ["PASSWORD", "SECRET", "API_KEY", "CLIENT_SECRET"];
8015
+ var CATEGORIES = {
8016
+ domain: {
8017
+ label: "Domain & Hosting",
8018
+ keys: [
8019
+ "LEARNHOUSE_DOMAIN",
8020
+ "HTTP_PORT",
8021
+ "NEXT_PUBLIC_LEARNHOUSE_API_URL",
8022
+ "NEXT_PUBLIC_LEARNHOUSE_BACKEND_URL",
8023
+ "NEXT_PUBLIC_LEARNHOUSE_DOMAIN",
8024
+ "NEXT_PUBLIC_LEARNHOUSE_TOP_DOMAIN",
8025
+ "NEXT_PUBLIC_LEARNHOUSE_MULTI_ORG",
8026
+ "NEXT_PUBLIC_LEARNHOUSE_DEFAULT_ORG",
8027
+ "NEXT_PUBLIC_LEARNHOUSE_HTTPS",
8028
+ "NEXTAUTH_URL"
8029
+ ]
8030
+ },
8031
+ database: {
8032
+ label: "Database & Redis",
8033
+ keys: [
8034
+ "LEARNHOUSE_SQL_CONNECTION_STRING",
8035
+ "LEARNHOUSE_REDIS_CONNECTION_STRING",
8036
+ "POSTGRES_USER",
8037
+ "POSTGRES_PASSWORD",
8038
+ "POSTGRES_DB"
8039
+ ]
8040
+ },
8041
+ security: {
8042
+ label: "Security",
8043
+ keys: [
8044
+ "NEXTAUTH_SECRET",
8045
+ "LEARNHOUSE_AUTH_JWT_SECRET_KEY",
8046
+ "LEARNHOUSE_INITIAL_ADMIN_EMAIL",
8047
+ "LEARNHOUSE_INITIAL_ADMIN_PASSWORD",
8048
+ "LEARNHOUSE_COOKIE_DOMAIN"
8049
+ ]
8050
+ },
8051
+ ai: {
8052
+ label: "AI",
8053
+ keys: ["LEARNHOUSE_GEMINI_API_KEY", "LEARNHOUSE_IS_AI_ENABLED"]
8054
+ },
8055
+ email: {
8056
+ label: "Email",
8057
+ keys: ["LEARNHOUSE_RESEND_API_KEY", "LEARNHOUSE_SYSTEM_EMAIL_ADDRESS"]
8058
+ },
8059
+ s3: {
8060
+ label: "S3 Storage",
8061
+ keys: [
8062
+ "LEARNHOUSE_CONTENT_DELIVERY_TYPE",
8063
+ "LEARNHOUSE_S3_API_BUCKET_NAME",
8064
+ "LEARNHOUSE_S3_API_ENDPOINT_URL"
8065
+ ]
8066
+ },
8067
+ oauth: {
8068
+ label: "OAuth",
8069
+ keys: [
8070
+ "LEARNHOUSE_GOOGLE_CLIENT_ID",
8071
+ "LEARNHOUSE_GOOGLE_CLIENT_SECRET",
8072
+ "NEXT_PUBLIC_UNSPLASH_ACCESS_KEY"
8073
+ ]
8074
+ }
8075
+ };
8076
+ function isSecret(key) {
8077
+ const upper = key.toUpperCase();
8078
+ return SECRET_PATTERNS.some((pat) => upper.includes(pat));
8079
+ }
8080
+ function maskValue(key, value) {
8081
+ if (isSecret(key) && value.length > 0) {
8082
+ return value.slice(0, 4) + "****";
8083
+ }
8084
+ return value;
8085
+ }
8086
+ function parseEnv(content) {
8087
+ const map = /* @__PURE__ */ new Map();
8088
+ for (const line of content.split("\n")) {
8089
+ const trimmed = line.trim();
8090
+ if (!trimmed || trimmed.startsWith("#")) continue;
8091
+ const eqIdx = trimmed.indexOf("=");
8092
+ if (eqIdx === -1) continue;
8093
+ map.set(trimmed.slice(0, eqIdx), trimmed.slice(eqIdx + 1));
8094
+ }
8095
+ return map;
8096
+ }
8097
+ function serializeEnv(original, updated) {
8098
+ const lines = original.split("\n");
8099
+ const result = [];
8100
+ const written = /* @__PURE__ */ new Set();
8101
+ for (const line of lines) {
8102
+ const trimmed = line.trim();
8103
+ if (!trimmed || trimmed.startsWith("#")) {
8104
+ result.push(line);
8105
+ continue;
8106
+ }
8107
+ const eqIdx = trimmed.indexOf("=");
8108
+ if (eqIdx === -1) {
8109
+ result.push(line);
8110
+ continue;
8111
+ }
8112
+ const key = trimmed.slice(0, eqIdx);
8113
+ if (updated.has(key)) {
8114
+ result.push(`${key}=${updated.get(key)}`);
8115
+ written.add(key);
8116
+ } else {
8117
+ result.push(line);
8118
+ }
8119
+ }
8120
+ for (const [key, value] of updated) {
8121
+ if (!written.has(key)) {
8122
+ result.push(`${key}=${value}`);
8123
+ }
8124
+ }
8125
+ return result.join("\n");
8126
+ }
8127
+ async function envCommand() {
8128
+ const dir = findInstallDir();
8129
+ const config = readConfig(dir);
8130
+ if (!config) {
8131
+ R2.error("No LearnHouse installation found. Run setup first.");
8132
+ process.exit(1);
8133
+ }
8134
+ const envPath = path8.join(config.installDir, ".env");
8135
+ if (!fs8.existsSync(envPath)) {
8136
+ R2.error(`No .env file found at ${envPath}`);
8137
+ process.exit(1);
8138
+ }
8139
+ We(import_picocolors21.default.cyan("LearnHouse Environment Editor"));
8140
+ const originalContent = fs8.readFileSync(envPath, "utf-8");
8141
+ const envMap = parseEnv(originalContent);
8142
+ let editing = true;
8143
+ while (editing) {
8144
+ const category = await Je({
8145
+ message: "Select a category to edit",
8146
+ options: [
8147
+ ...Object.entries(CATEGORIES).map(([value, { label }]) => ({ value, label })),
8148
+ { value: "_done", label: import_picocolors21.default.dim("Done editing") }
8149
+ ]
8150
+ });
8151
+ if (Ct(category) || category === "_done") {
8152
+ editing = false;
8153
+ break;
8154
+ }
8155
+ const cat = CATEGORIES[category];
8156
+ const presentKeys = cat.keys.filter((k2) => envMap.has(k2));
8157
+ const missingKeys = cat.keys.filter((k2) => !envMap.has(k2));
8158
+ if (presentKeys.length === 0 && missingKeys.length === 0) {
8159
+ R2.info("No variables in this category.");
8160
+ continue;
8161
+ }
8162
+ R2.step(`${cat.label} \u2014 Current Values`);
8163
+ for (const key2 of presentKeys) {
8164
+ R2.message(` ${import_picocolors21.default.dim(key2)} = ${maskValue(key2, envMap.get(key2))}`);
8165
+ }
8166
+ const keyToEdit = await Je({
8167
+ message: "Select a variable to edit",
8168
+ options: [
8169
+ ...presentKeys.map((k2) => ({ value: k2, label: `${k2} = ${maskValue(k2, envMap.get(k2))}` })),
8170
+ ...missingKeys.map((k2) => ({ value: k2, label: `${k2} ${import_picocolors21.default.dim("(not set)")}` })),
8171
+ { value: "_back", label: import_picocolors21.default.dim("Back") }
8172
+ ]
8173
+ });
8174
+ if (Ct(keyToEdit) || keyToEdit === "_back") continue;
8175
+ const key = keyToEdit;
8176
+ const currentValue = envMap.get(key) || "";
8177
+ const newValue = await text({
8178
+ message: `New value for ${key}`,
8179
+ placeholder: currentValue,
8180
+ defaultValue: currentValue
8181
+ });
8182
+ if (Ct(newValue)) continue;
8183
+ envMap.set(key, newValue);
8184
+ R2.success(`Updated ${key}`);
8185
+ }
8186
+ const newContent = serializeEnv(originalContent, envMap);
8187
+ if (newContent !== originalContent) {
8188
+ fs8.writeFileSync(envPath, newContent);
8189
+ R2.success(".env file updated");
8190
+ const restart = await Re({
8191
+ message: "Restart services to apply changes?",
8192
+ initialValue: false
8193
+ });
8194
+ if (!Ct(restart) && restart) {
8195
+ const s = bt2();
8196
+ s.start("Restarting services");
8197
+ try {
8198
+ dockerComposeDown(config.installDir);
8199
+ dockerComposeUp(config.installDir);
8200
+ s.stop("Services restarted");
8201
+ } catch {
8202
+ s.stop("Restart failed");
8203
+ R2.error("Failed to restart services. Check Docker output above.");
8204
+ }
8205
+ }
8206
+ } else {
8207
+ R2.info("No changes made.");
8208
+ }
8209
+ Le(import_picocolors21.default.dim("Done"));
8210
+ }
8211
+
8212
+ // src/commands/restore.ts
8213
+ import fs9 from "fs";
8214
+ import path9 from "path";
8215
+ import { execSync as execSync7 } from "child_process";
8216
+ var import_picocolors22 = __toESM(require_picocolors(), 1);
8217
+ async function restoreCommand(archivePath) {
8218
+ if (!archivePath) {
8219
+ R2.error("Please provide the path to a backup archive.");
8220
+ R2.info("Usage: npx learnhouse restore <backup-file.tar.gz>");
8221
+ process.exit(1);
8222
+ }
8223
+ if (!fs9.existsSync(archivePath)) {
8224
+ R2.error(`Backup file not found: ${archivePath}`);
8225
+ process.exit(1);
8226
+ }
8227
+ const installDir = findInstallDir();
8228
+ const config = readConfig(installDir);
8229
+ if (!config) {
8230
+ R2.error("No LearnHouse installation found. Run setup first.");
8231
+ process.exit(1);
8232
+ }
8233
+ if (config.useExternalDb) {
8234
+ R2.error("Restore is only supported for local (Docker) databases.");
8235
+ R2.info("For external databases, use your database provider's restore tools.");
8236
+ process.exit(1);
8237
+ }
8238
+ const id = config.deploymentId || autoDetectDeploymentId();
8239
+ if (!id) {
8240
+ R2.error("No deployment found. Start services first.");
8241
+ process.exit(1);
8242
+ }
8243
+ const dbContainer = `learnhouse-db-${id}`;
8244
+ if (!isContainerRunning(dbContainer)) {
8245
+ R2.error("Database container is not running. Start services first.");
8246
+ process.exit(1);
8247
+ }
8248
+ R2.warn(import_picocolors22.default.yellow("This will overwrite the current database with the backup data."));
8249
+ const confirm = await Re({
8250
+ message: "Are you sure you want to restore from this backup?",
8251
+ initialValue: false
8252
+ });
8253
+ if (Ct(confirm) || !confirm) {
8254
+ Ne("Restore cancelled.");
8255
+ process.exit(0);
8256
+ }
8257
+ const tmpDir = path9.join(installDir, ".restore-tmp");
8258
+ fs9.mkdirSync(tmpDir, { recursive: true });
8259
+ const s = bt2();
8260
+ s.start("Extracting backup archive");
8261
+ try {
8262
+ execSync7(`tar -xzf "${archivePath}" -C "${tmpDir}"`, { stdio: "pipe" });
8263
+ s.stop("Archive extracted");
8264
+ } catch {
8265
+ s.stop("Extraction failed");
8266
+ fs9.rmSync(tmpDir, { recursive: true, force: true });
8267
+ R2.error("Failed to extract backup archive.");
8268
+ process.exit(1);
8269
+ }
8270
+ const entries = fs9.readdirSync(tmpDir);
8271
+ const backupFolder = entries.find(
8272
+ (e2) => fs9.existsSync(path9.join(tmpDir, e2, "database.sql"))
8273
+ );
8274
+ if (!backupFolder) {
8275
+ R2.error("No database.sql found in the backup archive.");
8276
+ fs9.rmSync(tmpDir, { recursive: true, force: true });
8277
+ process.exit(1);
8278
+ }
8279
+ const dumpPath = path9.join(tmpDir, backupFolder, "database.sql");
8280
+ const s2 = bt2();
8281
+ s2.start("Restoring database");
8282
+ try {
8283
+ dockerExecFromFile(
8284
+ dbContainer,
8285
+ "psql -U learnhouse -d learnhouse",
8286
+ dumpPath
8287
+ );
8288
+ s2.stop("Database restored");
8289
+ } catch {
8290
+ s2.stop("Database restore failed");
8291
+ fs9.rmSync(tmpDir, { recursive: true, force: true });
8292
+ R2.error("Failed to restore database. The backup file may be corrupted.");
8293
+ process.exit(1);
8294
+ }
8295
+ const envBackup = path9.join(tmpDir, backupFolder, ".env");
8296
+ if (fs9.existsSync(envBackup)) {
8297
+ const restoreEnv = await Re({
8298
+ message: "Backup contains a .env file. Restore it? (overwrites current .env)",
8299
+ initialValue: false
8300
+ });
8301
+ if (!Ct(restoreEnv) && restoreEnv) {
8302
+ fs9.copyFileSync(envBackup, path9.join(installDir, ".env"));
8303
+ R2.info(".env file restored");
8304
+ }
8305
+ }
8306
+ fs9.rmSync(tmpDir, { recursive: true, force: true });
8307
+ R2.success(import_picocolors22.default.green(import_picocolors22.default.bold("Restore complete!")));
8308
+ R2.info("You may want to restart services: npx learnhouse stop && npx learnhouse start");
8309
+ }
8310
+
7826
8311
  // bin/learnhouse.ts
7827
8312
  var COMMANDS = [
7828
8313
  { name: "setup", desc: "Interactive setup wizard" },
7829
8314
  { name: "start", desc: "Start services" },
7830
8315
  { name: "stop", desc: "Stop services" },
7831
8316
  { name: "update", desc: "Update to latest or specific version" },
8317
+ { name: "status", desc: "Show service status" },
8318
+ { name: "health", desc: "Run health checks" },
7832
8319
  { name: "logs", desc: "Stream logs" },
7833
8320
  { name: "config", desc: "Show configuration" },
7834
- { name: "backup", desc: "Backup & restore database" },
8321
+ { name: "env", desc: "Edit environment variables" },
8322
+ { name: "backup", desc: "Backup database" },
8323
+ { name: "restore", desc: "Restore database from backup" },
7835
8324
  { name: "deployments", desc: "Manage deployments & resources" },
7836
8325
  { name: "doctor", desc: "Diagnose issues" },
7837
8326
  { name: "shell", desc: "Container shell access" },
@@ -7839,18 +8328,18 @@ var COMMANDS = [
7839
8328
  ];
7840
8329
  async function showWelcome() {
7841
8330
  await printBanner();
7842
- console.log(import_picocolors19.default.bold(import_picocolors19.default.white(" Available commands:\n")));
8331
+ console.log(import_picocolors23.default.bold(import_picocolors23.default.white(" Available commands:\n")));
7843
8332
  for (const cmd of COMMANDS) {
7844
- console.log(` ${import_picocolors19.default.cyan(cmd.name.padEnd(14))} ${import_picocolors19.default.dim(cmd.desc)}`);
8333
+ console.log(` ${import_picocolors23.default.cyan(cmd.name.padEnd(14))} ${import_picocolors23.default.dim(cmd.desc)}`);
7845
8334
  }
7846
8335
  console.log();
7847
- console.log(import_picocolors19.default.dim(" Run a command with: npx learnhouse <command>"));
7848
- console.log(import_picocolors19.default.dim(" Get started with: npx learnhouse setup"));
8336
+ console.log(import_picocolors23.default.dim(" Run a command with: npx learnhouse <command>"));
8337
+ console.log(import_picocolors23.default.dim(" Get started with: npx learnhouse setup"));
7849
8338
  console.log();
7850
8339
  }
7851
8340
  var program2 = new Command();
7852
8341
  program2.name("learnhouse").description("The official LearnHouse CLI \u2014 deploy, manage, and operate your LearnHouse instance").version(VERSION).action(showWelcome);
7853
- program2.command("setup").description("Interactive setup wizard for LearnHouse").action(setupCommand);
8342
+ 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)", parseInt).option("--admin-email <email>", 'Admin email (default: "admin@school.dev")').option("--admin-password <password>", "Admin password (required in --ci mode)").option("--channel <channel>", 'Release channel: stable or dev (default: "stable")').option("--no-start", "Skip starting services after setup").action(setupCommand);
7854
8343
  program2.command("start").description("Start LearnHouse services").action(startCommand);
7855
8344
  program2.command("stop").description("Stop LearnHouse services").action(stopCommand);
7856
8345
  program2.command("logs").description("Stream logs from LearnHouse services").action(logsCommand);
@@ -7859,7 +8348,11 @@ program2.command("backup").description("Backup & restore LearnHouse database").a
7859
8348
  program2.command("deployments").description("Manage deployments & resource limits").action(deploymentsCommand);
7860
8349
  program2.command("doctor").description("Diagnose common issues with LearnHouse").action(doctorCommand);
7861
8350
  program2.command("shell").description("Open a shell in a LearnHouse container").action(shellCommand);
7862
- program2.command("update").description("Update LearnHouse to latest or a specific version").option("-v, --version <version>", "Target version (e.g. 1.0.0)").action(updateCommand);
8351
+ program2.command("update").description("Update LearnHouse to latest or a specific version").option("-v, --version <version>", "Target version (e.g. 1.0.0)").option("--migrate", "Run database migrations automatically").option("--no-migrate", "Skip database migrations").action(updateCommand);
8352
+ program2.command("status").description("Show service status").action(statusCommand);
8353
+ program2.command("health").description("Run health checks").action(healthCommand);
8354
+ program2.command("env").description("Edit environment variables").action(envCommand);
8355
+ program2.command("restore").description("Restore database from a backup archive").argument("<archive>", "Path to backup archive").action(restoreCommand);
7863
8356
  program2.command("dev").description("Start development environment (DB + Redis in Docker, API + Web locally)").option("--ee", "Enable Enterprise Edition features (keeps ee/ folder)").action(devCommand);
7864
8357
  var updateCheck = checkForUpdates();
7865
8358
  program2.parseAsync().then(() => updateCheck.catch(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "learnhouse",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "The official LearnHouse CLI — deploy, manage, and operate your LearnHouse instance",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,6 +13,9 @@
13
13
  "build": "tsup",
14
14
  "dev": "tsup --watch",
15
15
  "prepublishOnly": "tsup",
16
+ "test": "bun run build && vitest run tests/unit.test.ts",
17
+ "test:e2e": "bun run build && vitest run tests/e2e.test.ts",
18
+ "test:all": "bun run build && vitest run",
16
19
  "version:patch": "node scripts/bump-version.js patch",
17
20
  "version:minor": "node scripts/bump-version.js minor",
18
21
  "version:major": "node scripts/bump-version.js major"
@@ -39,7 +42,8 @@
39
42
  "devDependencies": {
40
43
  "@types/node": "^25.0.0",
41
44
  "tsup": "^8.0.1",
42
- "typescript": "^5.3.3"
45
+ "typescript": "^5.3.3",
46
+ "vitest": "^4.1.1"
43
47
  },
44
48
  "dependencies": {
45
49
  "@clack/core": "^1.0.1",