learnhouse 1.4.8 → 1.5.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/dist/bin/learnhouse.js +238 -40
- 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.0";
|
|
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();
|
|
@@ -7003,6 +7006,11 @@ async function setupCommand(options) {
|
|
|
7003
7006
|
console.error("Error: --admin-password is required in --ci mode");
|
|
7004
7007
|
process.exit(1);
|
|
7005
7008
|
}
|
|
7009
|
+
const pwErr = validatePassword(options.adminPassword);
|
|
7010
|
+
if (pwErr) {
|
|
7011
|
+
console.error(`Error: --admin-password \u2014 ${pwErr}`);
|
|
7012
|
+
process.exit(1);
|
|
7013
|
+
}
|
|
7006
7014
|
if (options.adminEmail) {
|
|
7007
7015
|
const emailErr = validateEmail(options.adminEmail);
|
|
7008
7016
|
if (emailErr) {
|
|
@@ -7010,6 +7018,20 @@ async function setupCommand(options) {
|
|
|
7010
7018
|
process.exit(1);
|
|
7011
7019
|
}
|
|
7012
7020
|
}
|
|
7021
|
+
if (options.domain && options.domain !== "localhost") {
|
|
7022
|
+
const domainErr = validateDomain(options.domain);
|
|
7023
|
+
if (domainErr) {
|
|
7024
|
+
console.error(`Error: --domain "${options.domain}" \u2014 ${domainErr}`);
|
|
7025
|
+
process.exit(1);
|
|
7026
|
+
}
|
|
7027
|
+
}
|
|
7028
|
+
if (options.port !== void 0) {
|
|
7029
|
+
const portErr = validatePort(String(options.port));
|
|
7030
|
+
if (portErr) {
|
|
7031
|
+
console.error(`Error: --port ${options.port} \u2014 ${portErr}`);
|
|
7032
|
+
process.exit(1);
|
|
7033
|
+
}
|
|
7034
|
+
}
|
|
7013
7035
|
await checkPrerequisites();
|
|
7014
7036
|
const installName = options.name || "default";
|
|
7015
7037
|
const baseDir = path4.join(os3.homedir(), ".learnhouse");
|
|
@@ -7077,12 +7099,12 @@ async function setupCommand(options) {
|
|
|
7077
7099
|
dockerComposeUp(resolvedDir2);
|
|
7078
7100
|
const healthy = await waitForHealth(`http://localhost:${config2.httpPort}`);
|
|
7079
7101
|
if (healthy) {
|
|
7080
|
-
const seeded = await waitForOrgSeed(`http://localhost:${config2.httpPort}`,
|
|
7102
|
+
const seeded = await waitForOrgSeed(`http://localhost:${config2.httpPort}`, config2.orgSlug);
|
|
7081
7103
|
if (seeded) {
|
|
7082
7104
|
console.log("LearnHouse is ready!");
|
|
7083
7105
|
} else {
|
|
7084
7106
|
console.error("");
|
|
7085
|
-
console.error(
|
|
7107
|
+
console.error(`API is healthy but organization "${config2.orgSlug}" was not seeded.`);
|
|
7086
7108
|
console.error("Run `npx learnhouse logs` to inspect; pin a different image tag and re-run.");
|
|
7087
7109
|
console.error("");
|
|
7088
7110
|
process.exit(1);
|
|
@@ -7398,13 +7420,13 @@ async function setupCommand(options) {
|
|
|
7398
7420
|
s3.start("Waiting for LearnHouse to be ready (up to 3 minutes)");
|
|
7399
7421
|
const healthy = await waitForHealth(`http://localhost:${config.httpPort}`);
|
|
7400
7422
|
if (healthy) {
|
|
7401
|
-
const seeded = await waitForOrgSeed(`http://localhost:${config.httpPort}`,
|
|
7423
|
+
const seeded = await waitForOrgSeed(`http://localhost:${config.httpPort}`, config.orgSlug);
|
|
7402
7424
|
if (seeded) {
|
|
7403
7425
|
s3.stop("LearnHouse is ready!");
|
|
7404
7426
|
} else {
|
|
7405
|
-
s3.stop(
|
|
7427
|
+
s3.stop(`API is healthy but organization "${config.orgSlug}" was not seeded`);
|
|
7406
7428
|
R2.error(
|
|
7407
|
-
|
|
7429
|
+
`\`/api/v1/orgs/slug/${config.orgSlug}\` returns no org. Run \`learnhouse logs\` to inspect, pin a different image tag, and re-run setup.`
|
|
7408
7430
|
);
|
|
7409
7431
|
process.exit(1);
|
|
7410
7432
|
}
|
|
@@ -7709,7 +7731,7 @@ async function createBackup() {
|
|
|
7709
7731
|
const dumpPath = path6.join(tmpDir, "database.sql");
|
|
7710
7732
|
dockerExecToFile(
|
|
7711
7733
|
dbContainer,
|
|
7712
|
-
"pg_dump -U learnhouse learnhouse",
|
|
7734
|
+
"pg_dump -U learnhouse --clean --if-exists learnhouse",
|
|
7713
7735
|
dumpPath
|
|
7714
7736
|
);
|
|
7715
7737
|
s.stop("Database dump created");
|
|
@@ -7838,6 +7860,10 @@ async function backupCommand(archivePath, options) {
|
|
|
7838
7860
|
return;
|
|
7839
7861
|
}
|
|
7840
7862
|
We(import_picocolors14.default.cyan("LearnHouse Backup"));
|
|
7863
|
+
if (!process.stdout.isTTY) {
|
|
7864
|
+
await createBackup();
|
|
7865
|
+
return;
|
|
7866
|
+
}
|
|
7841
7867
|
const action = await Je({
|
|
7842
7868
|
message: "What would you like to do?",
|
|
7843
7869
|
options: [
|
|
@@ -8887,6 +8913,12 @@ import { readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "
|
|
|
8887
8913
|
import { join as join3 } from "path";
|
|
8888
8914
|
var import_picocolors21 = __toESM(require_picocolors(), 1);
|
|
8889
8915
|
|
|
8916
|
+
// src/services/compose-utils.ts
|
|
8917
|
+
var GHCR_IMAGE_RE = /image:\s*ghcr\.io\/learnhouse\/app:\S+/;
|
|
8918
|
+
function replaceComposeImageTag(compose, newImage) {
|
|
8919
|
+
return compose.replace(GHCR_IMAGE_RE, `image: ${newImage}`);
|
|
8920
|
+
}
|
|
8921
|
+
|
|
8890
8922
|
// src/commands/update-ee.ts
|
|
8891
8923
|
import { execSync as execSync6 } from "child_process";
|
|
8892
8924
|
import fs11 from "fs";
|
|
@@ -8973,6 +9005,23 @@ function runAlembicUpgrade(dir, layout, ui) {
|
|
|
8973
9005
|
ui.ok("Database already at head \u2014 no migrations needed");
|
|
8974
9006
|
return true;
|
|
8975
9007
|
}
|
|
9008
|
+
if (revLines.length === 0) {
|
|
9009
|
+
try {
|
|
9010
|
+
const out2 = alembic(dir, layout, "upgrade heads");
|
|
9011
|
+
const applied2 = out2.split("\n").filter((l) => /Running upgrade/.test(l)).length;
|
|
9012
|
+
ui.ok(applied2 ? `Applied ${applied2} migration(s)` : "Database migrated to head");
|
|
9013
|
+
return true;
|
|
9014
|
+
} catch (upgradeErr) {
|
|
9015
|
+
const e2 = upgradeErr;
|
|
9016
|
+
const upgradeOut = (e2.stderr?.toString() ?? "") + (e2.stdout?.toString() ?? "");
|
|
9017
|
+
if (/already exists|DuplicateTable/i.test(upgradeOut)) {
|
|
9018
|
+
alembic(dir, layout, "stamp heads");
|
|
9019
|
+
ui.ok("Schema created via create_all \u2014 stamped Alembic at current heads");
|
|
9020
|
+
return true;
|
|
9021
|
+
}
|
|
9022
|
+
throw upgradeErr;
|
|
9023
|
+
}
|
|
9024
|
+
}
|
|
8976
9025
|
const out = alembic(dir, layout, "upgrade heads");
|
|
8977
9026
|
const applied = out.split("\n").filter((l) => /Running upgrade/.test(l)).length;
|
|
8978
9027
|
ui.ok(applied ? `Applied ${applied} migration(s)` : "Database migrated to head");
|
|
@@ -9144,13 +9193,7 @@ async function updateCommand(options) {
|
|
|
9144
9193
|
}
|
|
9145
9194
|
const composePath = join3(config.installDir, "docker-compose.yml");
|
|
9146
9195
|
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");
|
|
9196
|
+
writeFileSync3(composePath, replaceComposeImageTag(composeContent, targetImage));
|
|
9154
9197
|
s.start("Checking content storage");
|
|
9155
9198
|
try {
|
|
9156
9199
|
const migration = migrateContentVolume(config.installDir, config.deploymentId);
|
|
@@ -9178,9 +9221,12 @@ async function updateCommand(options) {
|
|
|
9178
9221
|
const msg = err instanceof Error ? err.message : String(err);
|
|
9179
9222
|
R2.warn(`Could not migrate uploaded content: ${msg}`);
|
|
9180
9223
|
}
|
|
9224
|
+
s.start("Pulling new image (this may take a minute)");
|
|
9225
|
+
dockerComposePull(config.installDir);
|
|
9226
|
+
s.stop("Image pulled");
|
|
9181
9227
|
s.start("Restarting services");
|
|
9182
9228
|
dockerComposeDown(config.installDir);
|
|
9183
|
-
dockerComposeUp(config.installDir);
|
|
9229
|
+
dockerComposeUp(config.installDir, true);
|
|
9184
9230
|
s.stop("Services restarted");
|
|
9185
9231
|
s.start("Waiting for LearnHouse to be ready");
|
|
9186
9232
|
await waitForHealth(`http://localhost:${config.httpPort}`);
|
|
@@ -9573,13 +9619,17 @@ async function restoreCommand(archivePath) {
|
|
|
9573
9619
|
process.exit(1);
|
|
9574
9620
|
}
|
|
9575
9621
|
R2.warn(import_picocolors25.default.yellow("This will overwrite the current database with the backup data."));
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9622
|
+
if (process.stdout.isTTY) {
|
|
9623
|
+
const confirm = await Re({
|
|
9624
|
+
message: "Are you sure you want to restore from this backup?",
|
|
9625
|
+
initialValue: false
|
|
9626
|
+
});
|
|
9627
|
+
if (Ct(confirm) || !confirm) {
|
|
9628
|
+
Ne("Restore cancelled.");
|
|
9629
|
+
process.exit(0);
|
|
9630
|
+
}
|
|
9631
|
+
} else {
|
|
9632
|
+
R2.info("Non-interactive mode \u2014 proceeding with restore.");
|
|
9583
9633
|
}
|
|
9584
9634
|
const tmpDir = path13.join(installDir, ".restore-tmp");
|
|
9585
9635
|
fs13.mkdirSync(tmpDir, { recursive: true });
|
|
@@ -9620,7 +9670,7 @@ async function restoreCommand(archivePath) {
|
|
|
9620
9670
|
process.exit(1);
|
|
9621
9671
|
}
|
|
9622
9672
|
const envBackup = path13.join(tmpDir, backupFolder, ".env");
|
|
9623
|
-
if (fs13.existsSync(envBackup)) {
|
|
9673
|
+
if (fs13.existsSync(envBackup) && process.stdout.isTTY) {
|
|
9624
9674
|
const restoreEnv = await Re({
|
|
9625
9675
|
message: "Backup contains a .env file. Restore it? (overwrites current .env)",
|
|
9626
9676
|
initialValue: false
|
|
@@ -9635,6 +9685,152 @@ async function restoreCommand(archivePath) {
|
|
|
9635
9685
|
R2.info("You may want to restart services: npx learnhouse stop && npx learnhouse start");
|
|
9636
9686
|
}
|
|
9637
9687
|
|
|
9688
|
+
// src/commands/scale.ts
|
|
9689
|
+
import fs14 from "fs";
|
|
9690
|
+
import path14 from "path";
|
|
9691
|
+
var import_picocolors26 = __toESM(require_picocolors(), 1);
|
|
9692
|
+
var SERVICES2 = ["learnhouse-app", "db", "redis"];
|
|
9693
|
+
function parseMemLimit2(composePath) {
|
|
9694
|
+
const content = fs14.readFileSync(composePath, "utf-8");
|
|
9695
|
+
const limits = /* @__PURE__ */ new Map();
|
|
9696
|
+
let currentService = null;
|
|
9697
|
+
let inServices = false;
|
|
9698
|
+
for (const line of content.split("\n")) {
|
|
9699
|
+
if (line.match(/^services:\s*$/)) {
|
|
9700
|
+
inServices = true;
|
|
9701
|
+
continue;
|
|
9702
|
+
}
|
|
9703
|
+
if (inServices && line.match(/^ \w/) && line.includes(":")) {
|
|
9704
|
+
const match = line.match(/^\s{2}(\S+):/);
|
|
9705
|
+
currentService = match ? match[1] : null;
|
|
9706
|
+
}
|
|
9707
|
+
if (currentService && line.match(/^\s+mem_limit:/)) {
|
|
9708
|
+
const value = line.split(":")[1].trim();
|
|
9709
|
+
limits.set(currentService, value);
|
|
9710
|
+
}
|
|
9711
|
+
}
|
|
9712
|
+
return limits;
|
|
9713
|
+
}
|
|
9714
|
+
function setMemLimit2(content, service, limit) {
|
|
9715
|
+
const lines = content.split("\n");
|
|
9716
|
+
const result = [];
|
|
9717
|
+
let currentService = null;
|
|
9718
|
+
let inServices = false;
|
|
9719
|
+
let serviceIndent = 0;
|
|
9720
|
+
let insertedForService = false;
|
|
9721
|
+
for (let i = 0; i < lines.length; i++) {
|
|
9722
|
+
const line = lines[i];
|
|
9723
|
+
if (line.match(/^services:\s*$/)) {
|
|
9724
|
+
inServices = true;
|
|
9725
|
+
result.push(line);
|
|
9726
|
+
continue;
|
|
9727
|
+
}
|
|
9728
|
+
if (inServices && line.match(/^ \w/) && line.includes(":")) {
|
|
9729
|
+
const match = line.match(/^(\s{2})(\S+):/);
|
|
9730
|
+
if (match) {
|
|
9731
|
+
currentService = match[2];
|
|
9732
|
+
serviceIndent = match[1].length;
|
|
9733
|
+
insertedForService = false;
|
|
9734
|
+
}
|
|
9735
|
+
}
|
|
9736
|
+
if (currentService === service && line.match(/^\s+mem_limit:/)) {
|
|
9737
|
+
result.push(line.replace(/mem_limit:.*/, `mem_limit: ${limit}`));
|
|
9738
|
+
insertedForService = true;
|
|
9739
|
+
continue;
|
|
9740
|
+
}
|
|
9741
|
+
if (currentService === service && !insertedForService && line.match(/^\s+container_name:/)) {
|
|
9742
|
+
result.push(line);
|
|
9743
|
+
result.push(`${" ".repeat(serviceIndent + 2)}mem_limit: ${limit}`);
|
|
9744
|
+
insertedForService = true;
|
|
9745
|
+
continue;
|
|
9746
|
+
}
|
|
9747
|
+
result.push(line);
|
|
9748
|
+
}
|
|
9749
|
+
return result.join("\n");
|
|
9750
|
+
}
|
|
9751
|
+
async function scaleCommand() {
|
|
9752
|
+
const dir = findInstallDir();
|
|
9753
|
+
const config = readConfig(dir);
|
|
9754
|
+
if (!config) {
|
|
9755
|
+
R2.error("No LearnHouse installation found. Run setup first.");
|
|
9756
|
+
process.exit(1);
|
|
9757
|
+
}
|
|
9758
|
+
We(import_picocolors26.default.cyan("LearnHouse Resource Limits"));
|
|
9759
|
+
R2.step("Current Resource Usage");
|
|
9760
|
+
try {
|
|
9761
|
+
const stats = dockerStats(config.installDir);
|
|
9762
|
+
R2.message(import_picocolors26.default.dim(stats.trim()));
|
|
9763
|
+
} catch {
|
|
9764
|
+
try {
|
|
9765
|
+
const id = config.deploymentId || autoDetectDeploymentId();
|
|
9766
|
+
const running = listDeploymentContainers(id || void 0).filter((c) => c.status.toLowerCase().startsWith("up")).map((c) => c.name);
|
|
9767
|
+
if (running.length > 0) {
|
|
9768
|
+
const stats = dockerStatsForContainers(running);
|
|
9769
|
+
R2.message(import_picocolors26.default.dim(stats.trim()));
|
|
9770
|
+
} else {
|
|
9771
|
+
R2.warn("No running containers found.");
|
|
9772
|
+
}
|
|
9773
|
+
} catch {
|
|
9774
|
+
R2.warn("Could not retrieve current stats. Services may not be running.");
|
|
9775
|
+
}
|
|
9776
|
+
}
|
|
9777
|
+
const composePath = path14.join(config.installDir, "docker-compose.yml");
|
|
9778
|
+
if (!fs14.existsSync(composePath)) {
|
|
9779
|
+
R2.error("docker-compose.yml not found.");
|
|
9780
|
+
process.exit(1);
|
|
9781
|
+
}
|
|
9782
|
+
let composeContent = fs14.readFileSync(composePath, "utf-8");
|
|
9783
|
+
const currentLimits = parseMemLimit2(composePath);
|
|
9784
|
+
R2.step("Set Memory Limits");
|
|
9785
|
+
R2.info(import_picocolors26.default.dim("Examples: 256m, 512m, 1g, 2g (leave empty to skip)"));
|
|
9786
|
+
let changed = false;
|
|
9787
|
+
for (const service of SERVICES2) {
|
|
9788
|
+
const current = currentLimits.get(service);
|
|
9789
|
+
const label = current ? `Memory limit for ${import_picocolors26.default.bold(service)} (current: ${current})` : `Memory limit for ${import_picocolors26.default.bold(service)} (not set)`;
|
|
9790
|
+
const value = await text({
|
|
9791
|
+
message: label,
|
|
9792
|
+
placeholder: current ? void 0 : "e.g. 512m",
|
|
9793
|
+
defaultValue: current || ""
|
|
9794
|
+
});
|
|
9795
|
+
if (Ct(value)) {
|
|
9796
|
+
Ne();
|
|
9797
|
+
process.exit(0);
|
|
9798
|
+
}
|
|
9799
|
+
const trimmed = value.trim();
|
|
9800
|
+
if (trimmed && trimmed.match(/^\d+[mgMG]$/)) {
|
|
9801
|
+
composeContent = setMemLimit2(composeContent, service, trimmed);
|
|
9802
|
+
changed = true;
|
|
9803
|
+
R2.success(`${service}: ${trimmed}`);
|
|
9804
|
+
} else if (trimmed) {
|
|
9805
|
+
R2.warn(`Invalid format "${trimmed}" \u2014 skipping. Use format like 512m or 1g.`);
|
|
9806
|
+
}
|
|
9807
|
+
}
|
|
9808
|
+
if (!changed) {
|
|
9809
|
+
R2.info("No changes made.");
|
|
9810
|
+
Le(import_picocolors26.default.dim("Done"));
|
|
9811
|
+
return;
|
|
9812
|
+
}
|
|
9813
|
+
fs14.writeFileSync(composePath, composeContent);
|
|
9814
|
+
R2.success("docker-compose.yml updated");
|
|
9815
|
+
const restart = await Re({
|
|
9816
|
+
message: "Restart services to apply limits?",
|
|
9817
|
+
initialValue: false
|
|
9818
|
+
});
|
|
9819
|
+
if (!Ct(restart) && restart) {
|
|
9820
|
+
const s = bt2();
|
|
9821
|
+
s.start("Restarting services");
|
|
9822
|
+
try {
|
|
9823
|
+
dockerComposeDown(config.installDir);
|
|
9824
|
+
dockerComposeUp(config.installDir);
|
|
9825
|
+
s.stop("Services restarted");
|
|
9826
|
+
} catch {
|
|
9827
|
+
s.stop("Restart failed");
|
|
9828
|
+
R2.error("Failed to restart services. Check Docker output above.");
|
|
9829
|
+
}
|
|
9830
|
+
}
|
|
9831
|
+
Le(import_picocolors26.default.dim("Done"));
|
|
9832
|
+
}
|
|
9833
|
+
|
|
9638
9834
|
// bin/learnhouse.ts
|
|
9639
9835
|
var COMMANDS = [
|
|
9640
9836
|
{ name: "setup", desc: "Interactive setup wizard" },
|
|
@@ -9651,17 +9847,18 @@ var COMMANDS = [
|
|
|
9651
9847
|
{ name: "deployments", desc: "Manage deployments & resources" },
|
|
9652
9848
|
{ name: "doctor", desc: "Diagnose issues" },
|
|
9653
9849
|
{ name: "shell", desc: "Container shell access" },
|
|
9850
|
+
{ name: "scale", desc: "Set resource limits (memory) per service" },
|
|
9654
9851
|
{ name: "dev", desc: "Development mode" }
|
|
9655
9852
|
];
|
|
9656
9853
|
async function showWelcome() {
|
|
9657
9854
|
await printBanner();
|
|
9658
|
-
console.log(
|
|
9855
|
+
console.log(import_picocolors27.default.bold(import_picocolors27.default.white(" Available commands:\n")));
|
|
9659
9856
|
for (const cmd of COMMANDS) {
|
|
9660
|
-
console.log(` ${
|
|
9857
|
+
console.log(` ${import_picocolors27.default.cyan(cmd.name.padEnd(14))} ${import_picocolors27.default.dim(cmd.desc)}`);
|
|
9661
9858
|
}
|
|
9662
9859
|
console.log();
|
|
9663
|
-
console.log(
|
|
9664
|
-
console.log(
|
|
9860
|
+
console.log(import_picocolors27.default.dim(" Run a command with: npx learnhouse <command>"));
|
|
9861
|
+
console.log(import_picocolors27.default.dim(" Get started with: npx learnhouse setup"));
|
|
9665
9862
|
console.log();
|
|
9666
9863
|
}
|
|
9667
9864
|
var program2 = new Command();
|
|
@@ -9675,11 +9872,12 @@ program2.command("backup").description("Backup & restore LearnHouse database").a
|
|
|
9675
9872
|
program2.command("deployments").description("Manage deployments & resource limits").action(deploymentsCommand);
|
|
9676
9873
|
program2.command("doctor").description("Diagnose common issues with LearnHouse").action(doctorCommand);
|
|
9677
9874
|
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, --
|
|
9875
|
+
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
9876
|
program2.command("status").description("Show service status").action(statusCommand);
|
|
9680
9877
|
program2.command("health").description("Run health checks").action(healthCommand);
|
|
9681
9878
|
program2.command("env").description("Edit environment variables").action(envCommand);
|
|
9682
9879
|
program2.command("restore").description("Restore database from a backup archive").argument("<archive>", "Path to backup archive").action(restoreCommand);
|
|
9880
|
+
program2.command("scale").description("Set memory limits per service (app, db, redis)").action(scaleCommand);
|
|
9683
9881
|
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
9882
|
var updateCheck = checkForUpdates();
|
|
9685
9883
|
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.0",
|
|
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"
|