learnhouse 1.4.2 → 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.
- package/dist/bin/learnhouse.js +74 -23
- package/package.json +2 -2
package/dist/bin/learnhouse.js
CHANGED
|
@@ -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.
|
|
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
|
|
@@ -5713,6 +5725,12 @@ import crypto2 from "crypto";
|
|
|
5713
5725
|
function generateSecret() {
|
|
5714
5726
|
return crypto2.randomBytes(32).toString("base64");
|
|
5715
5727
|
}
|
|
5728
|
+
function quoteEnvValue(value) {
|
|
5729
|
+
if (/[\s#$'"\\`!]/.test(value)) {
|
|
5730
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
5731
|
+
}
|
|
5732
|
+
return value;
|
|
5733
|
+
}
|
|
5716
5734
|
function generateEnvFile(config) {
|
|
5717
5735
|
const protocol = config.useHttps ? "https" : "http";
|
|
5718
5736
|
const portSuffix = config.useHttps && config.httpPort === 443 || !config.useHttps && config.httpPort === 80 ? "" : `:${config.httpPort}`;
|
|
@@ -5747,7 +5765,7 @@ function generateEnvFile(config) {
|
|
|
5747
5765
|
`NEXT_PUBLIC_LEARNHOUSE_HTTPS=${config.useHttps ? "True" : "False"}`
|
|
5748
5766
|
];
|
|
5749
5767
|
if (config.unsplashEnabled && config.unsplashAccessKey) {
|
|
5750
|
-
lines.push(`NEXT_PUBLIC_UNSPLASH_ACCESS_KEY=${config.unsplashAccessKey}`);
|
|
5768
|
+
lines.push(`NEXT_PUBLIC_UNSPLASH_ACCESS_KEY=${quoteEnvValue(config.unsplashAccessKey)}`);
|
|
5751
5769
|
}
|
|
5752
5770
|
lines.push(
|
|
5753
5771
|
"",
|
|
@@ -5760,8 +5778,8 @@ function generateEnvFile(config) {
|
|
|
5760
5778
|
);
|
|
5761
5779
|
if (config.googleOAuthEnabled && config.googleClientId && config.googleClientSecret) {
|
|
5762
5780
|
lines.push(
|
|
5763
|
-
`LEARNHOUSE_GOOGLE_CLIENT_ID=${config.googleClientId}`,
|
|
5764
|
-
`LEARNHOUSE_GOOGLE_CLIENT_SECRET=${config.googleClientSecret}`
|
|
5781
|
+
`LEARNHOUSE_GOOGLE_CLIENT_ID=${quoteEnvValue(config.googleClientId)}`,
|
|
5782
|
+
`LEARNHOUSE_GOOGLE_CLIENT_SECRET=${quoteEnvValue(config.googleClientSecret)}`
|
|
5765
5783
|
);
|
|
5766
5784
|
}
|
|
5767
5785
|
lines.push(
|
|
@@ -5770,8 +5788,8 @@ function generateEnvFile(config) {
|
|
|
5770
5788
|
"# Backend Configuration",
|
|
5771
5789
|
"# =============================================================================",
|
|
5772
5790
|
"",
|
|
5773
|
-
`LEARNHOUSE_SQL_CONNECTION_STRING=${config.useExternalDb ? config.externalDbConnectionString : `postgresql://learnhouse:${config.dbPassword}@db:5432/learnhouse`}`,
|
|
5774
|
-
`LEARNHOUSE_REDIS_CONNECTION_STRING=${config.useExternalRedis ? config.externalRedisConnectionString : "redis://redis:6379/learnhouse"}`,
|
|
5791
|
+
`LEARNHOUSE_SQL_CONNECTION_STRING=${config.useExternalDb ? quoteEnvValue(config.externalDbConnectionString) : `postgresql://learnhouse:${config.dbPassword}@db:5432/learnhouse`}`,
|
|
5792
|
+
`LEARNHOUSE_REDIS_CONNECTION_STRING=${config.useExternalRedis ? quoteEnvValue(config.externalRedisConnectionString) : "redis://redis:6379/learnhouse"}`,
|
|
5775
5793
|
`LEARNHOUSE_COOKIE_DOMAIN=${cookieDomain}`,
|
|
5776
5794
|
"LEARNHOUSE_PORT=9000",
|
|
5777
5795
|
"",
|
|
@@ -5780,8 +5798,8 @@ function generateEnvFile(config) {
|
|
|
5780
5798
|
"# =============================================================================",
|
|
5781
5799
|
"",
|
|
5782
5800
|
`LEARNHOUSE_AUTH_JWT_SECRET_KEY=${jwtSecret}`,
|
|
5783
|
-
`LEARNHOUSE_INITIAL_ADMIN_EMAIL=${config.adminEmail}`,
|
|
5784
|
-
`LEARNHOUSE_INITIAL_ADMIN_PASSWORD=${config.adminPassword}`,
|
|
5801
|
+
`LEARNHOUSE_INITIAL_ADMIN_EMAIL=${quoteEnvValue(config.adminEmail)}`,
|
|
5802
|
+
`LEARNHOUSE_INITIAL_ADMIN_PASSWORD=${quoteEnvValue(config.adminPassword)}`,
|
|
5785
5803
|
"",
|
|
5786
5804
|
"# =============================================================================",
|
|
5787
5805
|
"# Collaboration Server",
|
|
@@ -5902,7 +5920,10 @@ server {
|
|
|
5902
5920
|
# The app container has internal nginx routing between frontend, backend, and collab
|
|
5903
5921
|
location / {
|
|
5904
5922
|
proxy_pass http://learnhouse-app:80;
|
|
5905
|
-
|
|
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;
|
|
5906
5927
|
proxy_set_header X-Real-IP $remote_addr;
|
|
5907
5928
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
5908
5929
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
@@ -5995,12 +6016,15 @@ function listInstallations() {
|
|
|
5995
6016
|
return results;
|
|
5996
6017
|
}
|
|
5997
6018
|
function findInstallDir() {
|
|
5998
|
-
const baseDir = path.join(os.homedir(), ".learnhouse");
|
|
5999
|
-
const defaultDir = path.join(baseDir, "default");
|
|
6000
6019
|
const installations = listInstallations();
|
|
6001
6020
|
if (installations.length === 1) return installations[0].dir;
|
|
6002
|
-
if (
|
|
6003
|
-
|
|
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
|
+
}
|
|
6004
6028
|
const cwd = process.cwd();
|
|
6005
6029
|
if (isCompleteInstall(cwd)) return cwd;
|
|
6006
6030
|
return process.cwd();
|
|
@@ -6116,6 +6140,7 @@ async function setupCommand(options) {
|
|
|
6116
6140
|
fs2.mkdirSync(resolvedDir2, { recursive: true });
|
|
6117
6141
|
const deploymentId2 = crypto3.randomBytes(4).toString("hex");
|
|
6118
6142
|
const channel2 = options.channel === "dev" ? "dev" : "stable";
|
|
6143
|
+
const dbPassword = crypto3.randomBytes(24).toString("base64url");
|
|
6119
6144
|
const config2 = {
|
|
6120
6145
|
deploymentId: deploymentId2,
|
|
6121
6146
|
installDir: resolvedDir2,
|
|
@@ -6125,6 +6150,7 @@ async function setupCommand(options) {
|
|
|
6125
6150
|
httpPort: options.port || 80,
|
|
6126
6151
|
autoSsl: false,
|
|
6127
6152
|
useExternalDb: false,
|
|
6153
|
+
dbPassword,
|
|
6128
6154
|
useAiDatabase: false,
|
|
6129
6155
|
useExternalRedis: false,
|
|
6130
6156
|
orgName: "Default",
|
|
@@ -7087,7 +7113,7 @@ async function doctorCommand() {
|
|
|
7087
7113
|
} catch {
|
|
7088
7114
|
}
|
|
7089
7115
|
R2.step("Log Analysis");
|
|
7090
|
-
const errorPatterns =
|
|
7116
|
+
const errorPatterns = /\bERROR\b[:\s]|\bFATAL\b[:\s]|\bTraceback\b|\bException\b[:\s]/;
|
|
7091
7117
|
for (const c of containers) {
|
|
7092
7118
|
if (!isContainerRunning(c.name)) continue;
|
|
7093
7119
|
try {
|
|
@@ -7490,10 +7516,11 @@ function spawnService(command, args, cwd, label, color) {
|
|
|
7490
7516
|
const child = spawn2(command, args, {
|
|
7491
7517
|
cwd,
|
|
7492
7518
|
stdio: ["ignore", "pipe", "pipe"],
|
|
7519
|
+
shell: process.platform === "win32",
|
|
7493
7520
|
env: {
|
|
7494
7521
|
...process.env,
|
|
7495
7522
|
...serviceEnv,
|
|
7496
|
-
PATH: `${localBin}
|
|
7523
|
+
PATH: `${localBin}${path7.delimiter}${process.env.PATH ?? ""}`
|
|
7497
7524
|
}
|
|
7498
7525
|
});
|
|
7499
7526
|
prefixStream(child, label, color);
|
|
@@ -7531,10 +7558,22 @@ async function devCommand(opts) {
|
|
|
7531
7558
|
if (!envOk) process.exit(1);
|
|
7532
7559
|
const eePath = path7.join(root, "apps", "api", "ee");
|
|
7533
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
|
+
}
|
|
7534
7575
|
if (fs7.existsSync(eePath)) {
|
|
7535
7576
|
R2.info(`Running in ${import_picocolors17.default.bold("EE")} mode`);
|
|
7536
|
-
} else {
|
|
7537
|
-
R2.warning("--ee was passed but no ee/ folder found \u2014 running in OSS mode");
|
|
7538
7577
|
}
|
|
7539
7578
|
}
|
|
7540
7579
|
if (!isDockerInstalled()) {
|
|
@@ -7590,9 +7629,12 @@ async function devCommand(opts) {
|
|
|
7590
7629
|
}
|
|
7591
7630
|
serviceEnv = {
|
|
7592
7631
|
FORCE_COLOR: "1",
|
|
7632
|
+
LEARNHOUSE_DEVELOPMENT_MODE: "true",
|
|
7593
7633
|
...adminEmail && { LEARNHOUSE_INITIAL_ADMIN_EMAIL: adminEmail },
|
|
7594
7634
|
...adminPassword && { LEARNHOUSE_INITIAL_ADMIN_PASSWORD: adminPassword },
|
|
7595
|
-
...!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" }
|
|
7596
7638
|
};
|
|
7597
7639
|
const healthSpinner = bt2();
|
|
7598
7640
|
healthSpinner.start("Waiting for DB and Redis to be healthy...");
|
|
@@ -7836,10 +7878,19 @@ async function updateCommand(options) {
|
|
|
7836
7878
|
R2.warn("Could not find the app container to run migrations. Run them manually:");
|
|
7837
7879
|
R2.warn(' docker exec <container> sh -c "cd /app/api && uv run alembic upgrade head"');
|
|
7838
7880
|
}
|
|
7839
|
-
} catch {
|
|
7840
|
-
s.stop("
|
|
7841
|
-
|
|
7842
|
-
|
|
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
|
+
);
|
|
7843
7894
|
}
|
|
7844
7895
|
} else {
|
|
7845
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
|
+
"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": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^25.0.0",
|
|
44
44
|
"tsup": "^8.0.1",
|
|
45
|
-
"typescript": "^
|
|
45
|
+
"typescript": "^6.0.0",
|
|
46
46
|
"vitest": "^4.1.1"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|