learnhouse 1.4.8 → 1.5.1
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 +242 -41
- package/package.json +6 -4
package/dist/bin/learnhouse.js
CHANGED
|
@@ -3267,9 +3267,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3267
3267
|
* @param {string} [path]
|
|
3268
3268
|
* @return {(string|null|Command)}
|
|
3269
3269
|
*/
|
|
3270
|
-
executableDir(
|
|
3271
|
-
if (
|
|
3272
|
-
this._executableDir =
|
|
3270
|
+
executableDir(path15) {
|
|
3271
|
+
if (path15 === void 0) return this._executableDir;
|
|
3272
|
+
this._executableDir = path15;
|
|
3273
3273
|
return this;
|
|
3274
3274
|
}
|
|
3275
3275
|
/**
|
|
@@ -3525,10 +3525,10 @@ function useColor() {
|
|
|
3525
3525
|
var program = new Command();
|
|
3526
3526
|
|
|
3527
3527
|
// bin/learnhouse.ts
|
|
3528
|
-
var
|
|
3528
|
+
var import_picocolors27 = __toESM(require_picocolors(), 1);
|
|
3529
3529
|
|
|
3530
3530
|
// src/constants.ts
|
|
3531
|
-
var VERSION = "1.
|
|
3531
|
+
var VERSION = "1.5.1";
|
|
3532
3532
|
var APP_IMAGE = "ghcr.io/learnhouse/app:latest";
|
|
3533
3533
|
var DEV_IMAGE = "ghcr.io/learnhouse/app:dev";
|
|
3534
3534
|
var POSTGRES_IMAGE = "pgvector/pgvector:pg16";
|
|
@@ -5106,8 +5106,15 @@ function validateDomain(value) {
|
|
|
5106
5106
|
return void 0;
|
|
5107
5107
|
}
|
|
5108
5108
|
function validatePort(value) {
|
|
5109
|
+
if (!/^\d+$/.test(value.trim())) return "Port must be between 1 and 65535";
|
|
5109
5110
|
const num = parseInt(value, 10);
|
|
5110
|
-
if (
|
|
5111
|
+
if (num < 1 || num > 65535) return "Port must be between 1 and 65535";
|
|
5112
|
+
return void 0;
|
|
5113
|
+
}
|
|
5114
|
+
function validateSlug(value) {
|
|
5115
|
+
if (!value) return "Slug is required";
|
|
5116
|
+
const re = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
5117
|
+
if (!re.test(value)) return "Slug must be lowercase alphanumeric with hyphens only";
|
|
5111
5118
|
return void 0;
|
|
5112
5119
|
}
|
|
5113
5120
|
function validateRequired(value) {
|
|
@@ -5452,13 +5459,9 @@ async function promptOrganization() {
|
|
|
5452
5459
|
message: 'Organization slug? (used in URLs like /orgs/<slug> \u2014 keep "default" unless you know you need to change it)',
|
|
5453
5460
|
placeholder: "default",
|
|
5454
5461
|
defaultValue: "default",
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
return "Lowercase letters, numbers and hyphens only";
|
|
5459
|
-
}
|
|
5460
|
-
return void 0;
|
|
5461
|
-
}
|
|
5462
|
+
// Use the canonical slug rule (rejects leading/trailing/double hyphens) so
|
|
5463
|
+
// the wizard can't accept a slug the API seeder / URLs would choke on.
|
|
5464
|
+
validate: validateSlug
|
|
5462
5465
|
});
|
|
5463
5466
|
if (Ct(orgSlug)) {
|
|
5464
5467
|
Ne();
|
|
@@ -6018,7 +6021,10 @@ server {
|
|
|
6018
6021
|
listen 80;
|
|
6019
6022
|
listen [::]:80;
|
|
6020
6023
|
server_name _;
|
|
6021
|
-
|
|
6024
|
+
# Must match the app container's internal nginx (6G). A lower value here
|
|
6025
|
+
# makes the outer proxy reject large uploads (e.g. videos) with a 413
|
|
6026
|
+
# before the request ever reaches the app \u2014 see docker/nginx.conf.
|
|
6027
|
+
client_max_body_size 6G;
|
|
6022
6028
|
|
|
6023
6029
|
# Increase header buffer size
|
|
6024
6030
|
large_client_header_buffers 4 32k;
|
|
@@ -7003,6 +7009,11 @@ async function setupCommand(options) {
|
|
|
7003
7009
|
console.error("Error: --admin-password is required in --ci mode");
|
|
7004
7010
|
process.exit(1);
|
|
7005
7011
|
}
|
|
7012
|
+
const pwErr = validatePassword(options.adminPassword);
|
|
7013
|
+
if (pwErr) {
|
|
7014
|
+
console.error(`Error: --admin-password \u2014 ${pwErr}`);
|
|
7015
|
+
process.exit(1);
|
|
7016
|
+
}
|
|
7006
7017
|
if (options.adminEmail) {
|
|
7007
7018
|
const emailErr = validateEmail(options.adminEmail);
|
|
7008
7019
|
if (emailErr) {
|
|
@@ -7010,6 +7021,20 @@ async function setupCommand(options) {
|
|
|
7010
7021
|
process.exit(1);
|
|
7011
7022
|
}
|
|
7012
7023
|
}
|
|
7024
|
+
if (options.domain && options.domain !== "localhost") {
|
|
7025
|
+
const domainErr = validateDomain(options.domain);
|
|
7026
|
+
if (domainErr) {
|
|
7027
|
+
console.error(`Error: --domain "${options.domain}" \u2014 ${domainErr}`);
|
|
7028
|
+
process.exit(1);
|
|
7029
|
+
}
|
|
7030
|
+
}
|
|
7031
|
+
if (options.port !== void 0) {
|
|
7032
|
+
const portErr = validatePort(String(options.port));
|
|
7033
|
+
if (portErr) {
|
|
7034
|
+
console.error(`Error: --port ${options.port} \u2014 ${portErr}`);
|
|
7035
|
+
process.exit(1);
|
|
7036
|
+
}
|
|
7037
|
+
}
|
|
7013
7038
|
await checkPrerequisites();
|
|
7014
7039
|
const installName = options.name || "default";
|
|
7015
7040
|
const baseDir = path4.join(os3.homedir(), ".learnhouse");
|
|
@@ -7077,12 +7102,12 @@ async function setupCommand(options) {
|
|
|
7077
7102
|
dockerComposeUp(resolvedDir2);
|
|
7078
7103
|
const healthy = await waitForHealth(`http://localhost:${config2.httpPort}`);
|
|
7079
7104
|
if (healthy) {
|
|
7080
|
-
const seeded = await waitForOrgSeed(`http://localhost:${config2.httpPort}`,
|
|
7105
|
+
const seeded = await waitForOrgSeed(`http://localhost:${config2.httpPort}`, config2.orgSlug);
|
|
7081
7106
|
if (seeded) {
|
|
7082
7107
|
console.log("LearnHouse is ready!");
|
|
7083
7108
|
} else {
|
|
7084
7109
|
console.error("");
|
|
7085
|
-
console.error(
|
|
7110
|
+
console.error(`API is healthy but organization "${config2.orgSlug}" was not seeded.`);
|
|
7086
7111
|
console.error("Run `npx learnhouse logs` to inspect; pin a different image tag and re-run.");
|
|
7087
7112
|
console.error("");
|
|
7088
7113
|
process.exit(1);
|
|
@@ -7398,13 +7423,13 @@ async function setupCommand(options) {
|
|
|
7398
7423
|
s3.start("Waiting for LearnHouse to be ready (up to 3 minutes)");
|
|
7399
7424
|
const healthy = await waitForHealth(`http://localhost:${config.httpPort}`);
|
|
7400
7425
|
if (healthy) {
|
|
7401
|
-
const seeded = await waitForOrgSeed(`http://localhost:${config.httpPort}`,
|
|
7426
|
+
const seeded = await waitForOrgSeed(`http://localhost:${config.httpPort}`, config.orgSlug);
|
|
7402
7427
|
if (seeded) {
|
|
7403
7428
|
s3.stop("LearnHouse is ready!");
|
|
7404
7429
|
} else {
|
|
7405
|
-
s3.stop(
|
|
7430
|
+
s3.stop(`API is healthy but organization "${config.orgSlug}" was not seeded`);
|
|
7406
7431
|
R2.error(
|
|
7407
|
-
|
|
7432
|
+
`\`/api/v1/orgs/slug/${config.orgSlug}\` returns no org. Run \`learnhouse logs\` to inspect, pin a different image tag, and re-run setup.`
|
|
7408
7433
|
);
|
|
7409
7434
|
process.exit(1);
|
|
7410
7435
|
}
|
|
@@ -7709,7 +7734,7 @@ async function createBackup() {
|
|
|
7709
7734
|
const dumpPath = path6.join(tmpDir, "database.sql");
|
|
7710
7735
|
dockerExecToFile(
|
|
7711
7736
|
dbContainer,
|
|
7712
|
-
"pg_dump -U learnhouse learnhouse",
|
|
7737
|
+
"pg_dump -U learnhouse --clean --if-exists learnhouse",
|
|
7713
7738
|
dumpPath
|
|
7714
7739
|
);
|
|
7715
7740
|
s.stop("Database dump created");
|
|
@@ -7838,6 +7863,10 @@ async function backupCommand(archivePath, options) {
|
|
|
7838
7863
|
return;
|
|
7839
7864
|
}
|
|
7840
7865
|
We(import_picocolors14.default.cyan("LearnHouse Backup"));
|
|
7866
|
+
if (!process.stdout.isTTY) {
|
|
7867
|
+
await createBackup();
|
|
7868
|
+
return;
|
|
7869
|
+
}
|
|
7841
7870
|
const action = await Je({
|
|
7842
7871
|
message: "What would you like to do?",
|
|
7843
7872
|
options: [
|
|
@@ -8887,6 +8916,12 @@ import { readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "
|
|
|
8887
8916
|
import { join as join3 } from "path";
|
|
8888
8917
|
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
8889
8918
|
|
|
8919
|
+
// src/services/compose-utils.ts
|
|
8920
|
+
var GHCR_IMAGE_RE = /image:\s*ghcr\.io\/learnhouse\/app:\S+/;
|
|
8921
|
+
function replaceComposeImageTag(compose, newImage) {
|
|
8922
|
+
return compose.replace(GHCR_IMAGE_RE, `image: ${newImage}`);
|
|
8923
|
+
}
|
|
8924
|
+
|
|
8890
8925
|
// src/commands/update-ee.ts
|
|
8891
8926
|
import { execSync as execSync6 } from "child_process";
|
|
8892
8927
|
import fs11 from "fs";
|
|
@@ -8973,6 +9008,23 @@ function runAlembicUpgrade(dir, layout, ui) {
|
|
|
8973
9008
|
ui.ok("Database already at head \u2014 no migrations needed");
|
|
8974
9009
|
return true;
|
|
8975
9010
|
}
|
|
9011
|
+
if (revLines.length === 0) {
|
|
9012
|
+
try {
|
|
9013
|
+
const out2 = alembic(dir, layout, "upgrade heads");
|
|
9014
|
+
const applied2 = out2.split("\n").filter((l) => /Running upgrade/.test(l)).length;
|
|
9015
|
+
ui.ok(applied2 ? `Applied ${applied2} migration(s)` : "Database migrated to head");
|
|
9016
|
+
return true;
|
|
9017
|
+
} catch (upgradeErr) {
|
|
9018
|
+
const e2 = upgradeErr;
|
|
9019
|
+
const upgradeOut = (e2.stderr?.toString() ?? "") + (e2.stdout?.toString() ?? "");
|
|
9020
|
+
if (/already exists|DuplicateTable/i.test(upgradeOut)) {
|
|
9021
|
+
alembic(dir, layout, "stamp heads");
|
|
9022
|
+
ui.ok("Schema created via create_all \u2014 stamped Alembic at current heads");
|
|
9023
|
+
return true;
|
|
9024
|
+
}
|
|
9025
|
+
throw upgradeErr;
|
|
9026
|
+
}
|
|
9027
|
+
}
|
|
8976
9028
|
const out = alembic(dir, layout, "upgrade heads");
|
|
8977
9029
|
const applied = out.split("\n").filter((l) => /Running upgrade/.test(l)).length;
|
|
8978
9030
|
ui.ok(applied ? `Applied ${applied} migration(s)` : "Database migrated to head");
|
|
@@ -9144,13 +9196,7 @@ async function updateCommand(options) {
|
|
|
9144
9196
|
}
|
|
9145
9197
|
const composePath = join3(config.installDir, "docker-compose.yml");
|
|
9146
9198
|
const composeContent = readFileSync2(composePath, "utf-8");
|
|
9147
|
-
|
|
9148
|
-
/image:\s*ghcr\.io\/learnhouse\/app:\S+/,
|
|
9149
|
-
`image: ${targetImage}`
|
|
9150
|
-
);
|
|
9151
|
-
writeFileSync3(composePath, updatedCompose);
|
|
9152
|
-
s.start("Pulling image");
|
|
9153
|
-
s.stop("Image reference updated");
|
|
9199
|
+
writeFileSync3(composePath, replaceComposeImageTag(composeContent, targetImage));
|
|
9154
9200
|
s.start("Checking content storage");
|
|
9155
9201
|
try {
|
|
9156
9202
|
const migration = migrateContentVolume(config.installDir, config.deploymentId);
|
|
@@ -9178,9 +9224,12 @@ async function updateCommand(options) {
|
|
|
9178
9224
|
const msg = err instanceof Error ? err.message : String(err);
|
|
9179
9225
|
R2.warn(`Could not migrate uploaded content: ${msg}`);
|
|
9180
9226
|
}
|
|
9227
|
+
s.start("Pulling new image (this may take a minute)");
|
|
9228
|
+
dockerComposePull(config.installDir);
|
|
9229
|
+
s.stop("Image pulled");
|
|
9181
9230
|
s.start("Restarting services");
|
|
9182
9231
|
dockerComposeDown(config.installDir);
|
|
9183
|
-
dockerComposeUp(config.installDir);
|
|
9232
|
+
dockerComposeUp(config.installDir, true);
|
|
9184
9233
|
s.stop("Services restarted");
|
|
9185
9234
|
s.start("Waiting for LearnHouse to be ready");
|
|
9186
9235
|
await waitForHealth(`http://localhost:${config.httpPort}`);
|
|
@@ -9573,13 +9622,17 @@ async function restoreCommand(archivePath) {
|
|
|
9573
9622
|
process.exit(1);
|
|
9574
9623
|
}
|
|
9575
9624
|
R2.warn(import_picocolors25.default.yellow("This will overwrite the current database with the backup data."));
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9625
|
+
if (process.stdout.isTTY) {
|
|
9626
|
+
const confirm = await Re({
|
|
9627
|
+
message: "Are you sure you want to restore from this backup?",
|
|
9628
|
+
initialValue: false
|
|
9629
|
+
});
|
|
9630
|
+
if (Ct(confirm) || !confirm) {
|
|
9631
|
+
Ne("Restore cancelled.");
|
|
9632
|
+
process.exit(0);
|
|
9633
|
+
}
|
|
9634
|
+
} else {
|
|
9635
|
+
R2.info("Non-interactive mode \u2014 proceeding with restore.");
|
|
9583
9636
|
}
|
|
9584
9637
|
const tmpDir = path13.join(installDir, ".restore-tmp");
|
|
9585
9638
|
fs13.mkdirSync(tmpDir, { recursive: true });
|
|
@@ -9620,7 +9673,7 @@ async function restoreCommand(archivePath) {
|
|
|
9620
9673
|
process.exit(1);
|
|
9621
9674
|
}
|
|
9622
9675
|
const envBackup = path13.join(tmpDir, backupFolder, ".env");
|
|
9623
|
-
if (fs13.existsSync(envBackup)) {
|
|
9676
|
+
if (fs13.existsSync(envBackup) && process.stdout.isTTY) {
|
|
9624
9677
|
const restoreEnv = await Re({
|
|
9625
9678
|
message: "Backup contains a .env file. Restore it? (overwrites current .env)",
|
|
9626
9679
|
initialValue: false
|
|
@@ -9635,6 +9688,152 @@ async function restoreCommand(archivePath) {
|
|
|
9635
9688
|
R2.info("You may want to restart services: npx learnhouse stop && npx learnhouse start");
|
|
9636
9689
|
}
|
|
9637
9690
|
|
|
9691
|
+
// src/commands/scale.ts
|
|
9692
|
+
import fs14 from "fs";
|
|
9693
|
+
import path14 from "path";
|
|
9694
|
+
var import_picocolors26 = __toESM(require_picocolors(), 1);
|
|
9695
|
+
var SERVICES2 = ["learnhouse-app", "db", "redis"];
|
|
9696
|
+
function parseMemLimit2(composePath) {
|
|
9697
|
+
const content = fs14.readFileSync(composePath, "utf-8");
|
|
9698
|
+
const limits = /* @__PURE__ */ new Map();
|
|
9699
|
+
let currentService = null;
|
|
9700
|
+
let inServices = false;
|
|
9701
|
+
for (const line of content.split("\n")) {
|
|
9702
|
+
if (line.match(/^services:\s*$/)) {
|
|
9703
|
+
inServices = true;
|
|
9704
|
+
continue;
|
|
9705
|
+
}
|
|
9706
|
+
if (inServices && line.match(/^ \w/) && line.includes(":")) {
|
|
9707
|
+
const match = line.match(/^\s{2}(\S+):/);
|
|
9708
|
+
currentService = match ? match[1] : null;
|
|
9709
|
+
}
|
|
9710
|
+
if (currentService && line.match(/^\s+mem_limit:/)) {
|
|
9711
|
+
const value = line.split(":")[1].trim();
|
|
9712
|
+
limits.set(currentService, value);
|
|
9713
|
+
}
|
|
9714
|
+
}
|
|
9715
|
+
return limits;
|
|
9716
|
+
}
|
|
9717
|
+
function setMemLimit2(content, service, limit) {
|
|
9718
|
+
const lines = content.split("\n");
|
|
9719
|
+
const result = [];
|
|
9720
|
+
let currentService = null;
|
|
9721
|
+
let inServices = false;
|
|
9722
|
+
let serviceIndent = 0;
|
|
9723
|
+
let insertedForService = false;
|
|
9724
|
+
for (let i = 0; i < lines.length; i++) {
|
|
9725
|
+
const line = lines[i];
|
|
9726
|
+
if (line.match(/^services:\s*$/)) {
|
|
9727
|
+
inServices = true;
|
|
9728
|
+
result.push(line);
|
|
9729
|
+
continue;
|
|
9730
|
+
}
|
|
9731
|
+
if (inServices && line.match(/^ \w/) && line.includes(":")) {
|
|
9732
|
+
const match = line.match(/^(\s{2})(\S+):/);
|
|
9733
|
+
if (match) {
|
|
9734
|
+
currentService = match[2];
|
|
9735
|
+
serviceIndent = match[1].length;
|
|
9736
|
+
insertedForService = false;
|
|
9737
|
+
}
|
|
9738
|
+
}
|
|
9739
|
+
if (currentService === service && line.match(/^\s+mem_limit:/)) {
|
|
9740
|
+
result.push(line.replace(/mem_limit:.*/, `mem_limit: ${limit}`));
|
|
9741
|
+
insertedForService = true;
|
|
9742
|
+
continue;
|
|
9743
|
+
}
|
|
9744
|
+
if (currentService === service && !insertedForService && line.match(/^\s+container_name:/)) {
|
|
9745
|
+
result.push(line);
|
|
9746
|
+
result.push(`${" ".repeat(serviceIndent + 2)}mem_limit: ${limit}`);
|
|
9747
|
+
insertedForService = true;
|
|
9748
|
+
continue;
|
|
9749
|
+
}
|
|
9750
|
+
result.push(line);
|
|
9751
|
+
}
|
|
9752
|
+
return result.join("\n");
|
|
9753
|
+
}
|
|
9754
|
+
async function scaleCommand() {
|
|
9755
|
+
const dir = findInstallDir();
|
|
9756
|
+
const config = readConfig(dir);
|
|
9757
|
+
if (!config) {
|
|
9758
|
+
R2.error("No LearnHouse installation found. Run setup first.");
|
|
9759
|
+
process.exit(1);
|
|
9760
|
+
}
|
|
9761
|
+
We(import_picocolors26.default.cyan("LearnHouse Resource Limits"));
|
|
9762
|
+
R2.step("Current Resource Usage");
|
|
9763
|
+
try {
|
|
9764
|
+
const stats = dockerStats(config.installDir);
|
|
9765
|
+
R2.message(import_picocolors26.default.dim(stats.trim()));
|
|
9766
|
+
} catch {
|
|
9767
|
+
try {
|
|
9768
|
+
const id = config.deploymentId || autoDetectDeploymentId();
|
|
9769
|
+
const running = listDeploymentContainers(id || void 0).filter((c) => c.status.toLowerCase().startsWith("up")).map((c) => c.name);
|
|
9770
|
+
if (running.length > 0) {
|
|
9771
|
+
const stats = dockerStatsForContainers(running);
|
|
9772
|
+
R2.message(import_picocolors26.default.dim(stats.trim()));
|
|
9773
|
+
} else {
|
|
9774
|
+
R2.warn("No running containers found.");
|
|
9775
|
+
}
|
|
9776
|
+
} catch {
|
|
9777
|
+
R2.warn("Could not retrieve current stats. Services may not be running.");
|
|
9778
|
+
}
|
|
9779
|
+
}
|
|
9780
|
+
const composePath = path14.join(config.installDir, "docker-compose.yml");
|
|
9781
|
+
if (!fs14.existsSync(composePath)) {
|
|
9782
|
+
R2.error("docker-compose.yml not found.");
|
|
9783
|
+
process.exit(1);
|
|
9784
|
+
}
|
|
9785
|
+
let composeContent = fs14.readFileSync(composePath, "utf-8");
|
|
9786
|
+
const currentLimits = parseMemLimit2(composePath);
|
|
9787
|
+
R2.step("Set Memory Limits");
|
|
9788
|
+
R2.info(import_picocolors26.default.dim("Examples: 256m, 512m, 1g, 2g (leave empty to skip)"));
|
|
9789
|
+
let changed = false;
|
|
9790
|
+
for (const service of SERVICES2) {
|
|
9791
|
+
const current = currentLimits.get(service);
|
|
9792
|
+
const label = current ? `Memory limit for ${import_picocolors26.default.bold(service)} (current: ${current})` : `Memory limit for ${import_picocolors26.default.bold(service)} (not set)`;
|
|
9793
|
+
const value = await text({
|
|
9794
|
+
message: label,
|
|
9795
|
+
placeholder: current ? void 0 : "e.g. 512m",
|
|
9796
|
+
defaultValue: current || ""
|
|
9797
|
+
});
|
|
9798
|
+
if (Ct(value)) {
|
|
9799
|
+
Ne();
|
|
9800
|
+
process.exit(0);
|
|
9801
|
+
}
|
|
9802
|
+
const trimmed = value.trim();
|
|
9803
|
+
if (trimmed && trimmed.match(/^\d+[mgMG]$/)) {
|
|
9804
|
+
composeContent = setMemLimit2(composeContent, service, trimmed);
|
|
9805
|
+
changed = true;
|
|
9806
|
+
R2.success(`${service}: ${trimmed}`);
|
|
9807
|
+
} else if (trimmed) {
|
|
9808
|
+
R2.warn(`Invalid format "${trimmed}" \u2014 skipping. Use format like 512m or 1g.`);
|
|
9809
|
+
}
|
|
9810
|
+
}
|
|
9811
|
+
if (!changed) {
|
|
9812
|
+
R2.info("No changes made.");
|
|
9813
|
+
Le(import_picocolors26.default.dim("Done"));
|
|
9814
|
+
return;
|
|
9815
|
+
}
|
|
9816
|
+
fs14.writeFileSync(composePath, composeContent);
|
|
9817
|
+
R2.success("docker-compose.yml updated");
|
|
9818
|
+
const restart = await Re({
|
|
9819
|
+
message: "Restart services to apply limits?",
|
|
9820
|
+
initialValue: false
|
|
9821
|
+
});
|
|
9822
|
+
if (!Ct(restart) && restart) {
|
|
9823
|
+
const s = bt2();
|
|
9824
|
+
s.start("Restarting services");
|
|
9825
|
+
try {
|
|
9826
|
+
dockerComposeDown(config.installDir);
|
|
9827
|
+
dockerComposeUp(config.installDir);
|
|
9828
|
+
s.stop("Services restarted");
|
|
9829
|
+
} catch {
|
|
9830
|
+
s.stop("Restart failed");
|
|
9831
|
+
R2.error("Failed to restart services. Check Docker output above.");
|
|
9832
|
+
}
|
|
9833
|
+
}
|
|
9834
|
+
Le(import_picocolors26.default.dim("Done"));
|
|
9835
|
+
}
|
|
9836
|
+
|
|
9638
9837
|
// bin/learnhouse.ts
|
|
9639
9838
|
var COMMANDS = [
|
|
9640
9839
|
{ name: "setup", desc: "Interactive setup wizard" },
|
|
@@ -9651,17 +9850,18 @@ var COMMANDS = [
|
|
|
9651
9850
|
{ name: "deployments", desc: "Manage deployments & resources" },
|
|
9652
9851
|
{ name: "doctor", desc: "Diagnose issues" },
|
|
9653
9852
|
{ name: "shell", desc: "Container shell access" },
|
|
9853
|
+
{ name: "scale", desc: "Set resource limits (memory) per service" },
|
|
9654
9854
|
{ name: "dev", desc: "Development mode" }
|
|
9655
9855
|
];
|
|
9656
9856
|
async function showWelcome() {
|
|
9657
9857
|
await printBanner();
|
|
9658
|
-
console.log(
|
|
9858
|
+
console.log(import_picocolors27.default.bold(import_picocolors27.default.white(" Available commands:\n")));
|
|
9659
9859
|
for (const cmd of COMMANDS) {
|
|
9660
|
-
console.log(` ${
|
|
9860
|
+
console.log(` ${import_picocolors27.default.cyan(cmd.name.padEnd(14))} ${import_picocolors27.default.dim(cmd.desc)}`);
|
|
9661
9861
|
}
|
|
9662
9862
|
console.log();
|
|
9663
|
-
console.log(
|
|
9664
|
-
console.log(
|
|
9863
|
+
console.log(import_picocolors27.default.dim(" Run a command with: npx learnhouse <command>"));
|
|
9864
|
+
console.log(import_picocolors27.default.dim(" Get started with: npx learnhouse setup"));
|
|
9665
9865
|
console.log();
|
|
9666
9866
|
}
|
|
9667
9867
|
var program2 = new Command();
|
|
@@ -9675,11 +9875,12 @@ program2.command("backup").description("Backup & restore LearnHouse database").a
|
|
|
9675
9875
|
program2.command("deployments").description("Manage deployments & resource limits").action(deploymentsCommand);
|
|
9676
9876
|
program2.command("doctor").description("Diagnose common issues with LearnHouse").action(doctorCommand);
|
|
9677
9877
|
program2.command("shell").description("Open a shell in a LearnHouse container").action(shellCommand);
|
|
9678
|
-
program2.command("update").description("Update LearnHouse to latest or a specific version (EE: backs up the DB + runs migrations)").option("-v, --
|
|
9878
|
+
program2.command("update").description("Update LearnHouse to latest or a specific version (EE: backs up the DB + runs migrations)").option("-v, --to <version>", 'Target version (e.g. 1.4.2 or v1.4.2; EE default: "prod")').option("--migrate", "Run database migrations automatically").option("--no-migrate", "Skip database migrations").option("--no-backup", "Skip the pre-upgrade database backup (not recommended)").action((opts) => updateCommand({ ...opts, version: opts.to }));
|
|
9679
9879
|
program2.command("status").description("Show service status").action(statusCommand);
|
|
9680
9880
|
program2.command("health").description("Run health checks").action(healthCommand);
|
|
9681
9881
|
program2.command("env").description("Edit environment variables").action(envCommand);
|
|
9682
9882
|
program2.command("restore").description("Restore database from a backup archive").argument("<archive>", "Path to backup archive").action(restoreCommand);
|
|
9883
|
+
program2.command("scale").description("Set memory limits per service (app, db, redis)").action(scaleCommand);
|
|
9683
9884
|
program2.command("dev").description("Start development environment (DB + Redis in Docker, API + Web locally)").option("--ee", "Enable Enterprise Edition features (keeps ee/ folder)").option("--admin-email <email>", "Admin email (default: admin@school.dev)").option("--admin-password <password>", "Admin password (skips interactive prompt)").action(devCommand);
|
|
9684
9885
|
var updateCheck = checkForUpdates();
|
|
9685
9886
|
program2.parseAsync().then(() => updateCheck.catch(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "learnhouse",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "The official LearnHouse CLI — deploy, manage, and operate your LearnHouse instance",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,12 +13,13 @@
|
|
|
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:
|
|
16
|
+
"test": "bun run build && vitest run tests/unit.test.ts tests/ee.test.ts tests/commands.test.ts tests/backup-restore.test.ts tests/prompt.test.ts tests/content-migration.test.ts tests/doctor-port.test.ts tests/doctor-dns.test.ts tests/start-migrated.test.ts tests/domain-port.test.ts tests/update-migration.test.ts tests/backup-archive-fail.test.ts tests/setup-ee-preflight.test.ts tests/update-ee.test.ts tests/setup-ci-port.test.ts",
|
|
17
|
+
"test:integration": "bun run build && vitest run tests/integration.test.ts",
|
|
18
18
|
"test:all": "bun run build && vitest run",
|
|
19
19
|
"version:patch": "node scripts/bump-version.js patch",
|
|
20
20
|
"version:minor": "node scripts/bump-version.js minor",
|
|
21
|
-
"version:major": "node scripts/bump-version.js major"
|
|
21
|
+
"version:major": "node scripts/bump-version.js major",
|
|
22
|
+
"test:coverage": "bun run build && vitest run --coverage --coverage.provider=v8 --coverage.include='src/**' tests/unit.test.ts tests/ee.test.ts tests/commands.test.ts tests/backup-restore.test.ts tests/prompt.test.ts tests/content-migration.test.ts tests/doctor-port.test.ts tests/doctor-dns.test.ts tests/start-migrated.test.ts tests/domain-port.test.ts tests/update-migration.test.ts tests/backup-archive-fail.test.ts tests/setup-ee-preflight.test.ts tests/update-ee.test.ts tests/setup-ci-port.test.ts"
|
|
22
23
|
},
|
|
23
24
|
"repository": {
|
|
24
25
|
"type": "git",
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"author": "LearnHouse",
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@types/node": "^25.0.0",
|
|
45
|
+
"@vitest/coverage-v8": "^4",
|
|
44
46
|
"tsup": "^8.0.1",
|
|
45
47
|
"typescript": "^6.0.0",
|
|
46
48
|
"vitest": "^4.1.1"
|