learnhouse 1.4.3 → 1.4.4

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.
@@ -3616,7 +3616,7 @@ var {
3616
3616
  var import_picocolors23 = __toESM(require_picocolors(), 1);
3617
3617
 
3618
3618
  // src/constants.ts
3619
- var VERSION = "1.4.3";
3619
+ var VERSION = "1.4.4";
3620
3620
  var APP_IMAGE = "ghcr.io/learnhouse/app:latest";
3621
3621
  var DEV_IMAGE = "ghcr.io/learnhouse/app:dev";
3622
3622
  var POSTGRES_IMAGE = "pgvector/pgvector:pg16";
@@ -5630,6 +5630,18 @@ ${deps.join("\n")}` : "";
5630
5630
  timeout: 10s
5631
5631
  retries: 3
5632
5632
  `;
5633
+ const needsSsrPortForward = !config.autoSsl && !config.useHttps && config.httpPort !== 80;
5634
+ const ssrForwardService = needsSsrPortForward ? `
5635
+ ssr-fwd:
5636
+ image: alpine/socat:1.8.0.0
5637
+ container_name: learnhouse-ssr-fwd-${id}
5638
+ restart: unless-stopped
5639
+ network_mode: "service:learnhouse-app"
5640
+ command: TCP-LISTEN:${config.httpPort},fork,reuseaddr TCP:localhost:80
5641
+ depends_on:
5642
+ learnhouse-app:
5643
+ condition: service_healthy
5644
+ ` : "";
5633
5645
  const dbImage = config.useAiDatabase ? POSTGRES_AI_IMAGE : POSTGRES_IMAGE;
5634
5646
  const dbService = useLocalDb ? `
5635
5647
  db:
@@ -5699,7 +5711,7 @@ ${appDependsOn}
5699
5711
  timeout: 10s
5700
5712
  retries: 3
5701
5713
  start_period: 60s
5702
- ${proxyService}${dbService}${redisService}
5714
+ ${proxyService}${ssrForwardService}${dbService}${redisService}
5703
5715
  networks:
5704
5716
  learnhouse-network-${id}:
5705
5717
  driver: bridge
@@ -5908,7 +5920,10 @@ server {
5908
5920
  # The app container has internal nginx routing between frontend, backend, and collab
5909
5921
  location / {
5910
5922
  proxy_pass http://learnhouse-app:80;
5911
- proxy_set_header Host $host;
5923
+ # Use $http_host (not $host) so the port is preserved \u2014 Next.js Server
5924
+ # Actions reject POSTs where origin and x-forwarded-host disagree.
5925
+ proxy_set_header Host $http_host;
5926
+ proxy_set_header X-Forwarded-Host $http_host;
5912
5927
  proxy_set_header X-Real-IP $remote_addr;
5913
5928
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
5914
5929
  proxy_set_header X-Forwarded-Proto $scheme;
@@ -6001,12 +6016,15 @@ function listInstallations() {
6001
6016
  return results;
6002
6017
  }
6003
6018
  function findInstallDir() {
6004
- const baseDir = path.join(os.homedir(), ".learnhouse");
6005
- const defaultDir = path.join(baseDir, "default");
6006
6019
  const installations = listInstallations();
6007
6020
  if (installations.length === 1) return installations[0].dir;
6008
- if (isCompleteInstall(defaultDir)) return defaultDir;
6009
- if (installations.length > 0) return installations[0].dir;
6021
+ if (installations.length > 1) {
6022
+ const running = installations.find(
6023
+ (i) => isContainerRunning(`learnhouse-app-${i.config.deploymentId}`)
6024
+ );
6025
+ if (running) return running.dir;
6026
+ return installations[0].dir;
6027
+ }
6010
6028
  const cwd = process.cwd();
6011
6029
  if (isCompleteInstall(cwd)) return cwd;
6012
6030
  return process.cwd();
@@ -6122,6 +6140,7 @@ async function setupCommand(options) {
6122
6140
  fs2.mkdirSync(resolvedDir2, { recursive: true });
6123
6141
  const deploymentId2 = crypto3.randomBytes(4).toString("hex");
6124
6142
  const channel2 = options.channel === "dev" ? "dev" : "stable";
6143
+ const dbPassword = crypto3.randomBytes(24).toString("base64url");
6125
6144
  const config2 = {
6126
6145
  deploymentId: deploymentId2,
6127
6146
  installDir: resolvedDir2,
@@ -6131,6 +6150,7 @@ async function setupCommand(options) {
6131
6150
  httpPort: options.port || 80,
6132
6151
  autoSsl: false,
6133
6152
  useExternalDb: false,
6153
+ dbPassword,
6134
6154
  useAiDatabase: false,
6135
6155
  useExternalRedis: false,
6136
6156
  orgName: "Default",
@@ -7093,7 +7113,7 @@ async function doctorCommand() {
7093
7113
  } catch {
7094
7114
  }
7095
7115
  R2.step("Log Analysis");
7096
- const errorPatterns = /ERROR|FATAL|Traceback/i;
7116
+ const errorPatterns = /\bERROR\b[:\s]|\bFATAL\b[:\s]|\bTraceback\b|\bException\b[:\s]/;
7097
7117
  for (const c of containers) {
7098
7118
  if (!isContainerRunning(c.name)) continue;
7099
7119
  try {
@@ -7538,10 +7558,22 @@ async function devCommand(opts) {
7538
7558
  if (!envOk) process.exit(1);
7539
7559
  const eePath = path7.join(root, "apps", "api", "ee");
7540
7560
  if (opts.ee) {
7561
+ if (!fs7.existsSync(eePath)) {
7562
+ const parentDir = path7.dirname(root);
7563
+ const eeRepoPath = path7.join(parentDir, "ee", "apps", "api", "ee");
7564
+ if (fs7.existsSync(eeRepoPath)) {
7565
+ try {
7566
+ fs7.symlinkSync(eeRepoPath, eePath);
7567
+ R2.success(`Linked EE folder \u2192 ${eeRepoPath}`);
7568
+ } catch (err) {
7569
+ R2.warning(`Could not create EE symlink: ${err.message}`);
7570
+ }
7571
+ } else {
7572
+ R2.warning(`--ee passed but no ee/ folder found at ${eeRepoPath} \u2014 running in OSS mode`);
7573
+ }
7574
+ }
7541
7575
  if (fs7.existsSync(eePath)) {
7542
7576
  R2.info(`Running in ${import_picocolors17.default.bold("EE")} mode`);
7543
- } else {
7544
- R2.warning("--ee was passed but no ee/ folder found \u2014 running in OSS mode");
7545
7577
  }
7546
7578
  }
7547
7579
  if (!isDockerInstalled()) {
@@ -7597,9 +7629,12 @@ async function devCommand(opts) {
7597
7629
  }
7598
7630
  serviceEnv = {
7599
7631
  FORCE_COLOR: "1",
7632
+ LEARNHOUSE_DEVELOPMENT_MODE: "true",
7600
7633
  ...adminEmail && { LEARNHOUSE_INITIAL_ADMIN_EMAIL: adminEmail },
7601
7634
  ...adminPassword && { LEARNHOUSE_INITIAL_ADMIN_PASSWORD: adminPassword },
7602
- ...!opts.ee && { LEARNHOUSE_DISABLE_EE: "1" }
7635
+ ...!opts.ee && { LEARNHOUSE_DISABLE_EE: "1" },
7636
+ // Bypass license verification for local dev when --ee is active
7637
+ ...opts.ee && { LEARNHOUSE_FORCE_EE: "1" }
7603
7638
  };
7604
7639
  const healthSpinner = bt2();
7605
7640
  healthSpinner.start("Waiting for DB and Redis to be healthy...");
@@ -7843,10 +7878,19 @@ async function updateCommand(options) {
7843
7878
  R2.warn("Could not find the app container to run migrations. Run them manually:");
7844
7879
  R2.warn(' docker exec <container> sh -c "cd /app/api && uv run alembic upgrade head"');
7845
7880
  }
7846
- } catch {
7847
- s.stop("Migration warning");
7848
- R2.warn("Database migrations encountered an issue. Your app is running but you may need to run migrations manually:");
7849
- R2.warn(' docker exec <container> sh -c "cd /app/api && uv run alembic upgrade head"');
7881
+ } catch (err) {
7882
+ s.stop("Database migrations failed");
7883
+ const stderr = err?.stderr?.toString?.() ?? "";
7884
+ const stdout = err?.stdout?.toString?.() ?? "";
7885
+ const output = (stderr || stdout).trim();
7886
+ if (output) {
7887
+ for (const line of output.split("\n")) R2.error(` ${line}`);
7888
+ }
7889
+ const container = getAppContainerName(config.installDir) ?? "<container>";
7890
+ R2.warn("Retry manually with:");
7891
+ R2.warn(
7892
+ ` docker exec ${container} sh -c "cd /app/api && uv run alembic upgrade head"`
7893
+ );
7850
7894
  }
7851
7895
  } else {
7852
7896
  R2.info("Skipped database migrations. You can run them later with:");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "learnhouse",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "The official LearnHouse CLI — deploy, manage, and operate your LearnHouse instance",
5
5
  "type": "module",
6
6
  "bin": {