learnhouse 1.2.0 → 1.3.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/README.md +39 -40
- package/dist/bin/learnhouse.js +174 -26
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# LearnHouse CLI
|
|
2
2
|
|
|
3
|
-
The official LearnHouse CLI — deploy, manage, and operate your LearnHouse instance.
|
|
3
|
+
The official LearnHouse CLI — deploy, manage, and operate your LearnHouse instance.
|
|
4
4
|
|
|
5
5
|
<img width="915" height="871" alt="image" src="https://github.com/user-attachments/assets/957c6cea-3efb-4cab-a643-55df3ac4c6aa" />
|
|
6
6
|
|
|
@@ -20,82 +20,81 @@ curl -fsSL https://raw.githubusercontent.com/learnhouse/learnhouse/main/apps/cli
|
|
|
20
20
|
irm https://raw.githubusercontent.com/learnhouse/learnhouse/main/apps/cli/install.ps1 | iex
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
### Using npx
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
```bash
|
|
26
|
+
npx learnhouse@latest setup
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Install a specific version
|
|
26
30
|
|
|
27
31
|
```bash
|
|
28
|
-
npx learnhouse@
|
|
32
|
+
npx learnhouse@1.0.0 setup
|
|
29
33
|
```
|
|
30
34
|
|
|
31
35
|
## Requirements
|
|
32
36
|
|
|
33
37
|
- **Node.js** >= 18
|
|
34
|
-
- **Docker**
|
|
38
|
+
- **Docker**
|
|
35
39
|
|
|
36
40
|
## Commands
|
|
37
41
|
|
|
38
42
|
| Command | Description |
|
|
39
43
|
|---------|-------------|
|
|
40
|
-
| `learnhouse setup` | Interactive setup wizard
|
|
44
|
+
| `learnhouse setup` | Interactive setup wizard |
|
|
41
45
|
| `learnhouse start` | Start all services |
|
|
42
46
|
| `learnhouse stop` | Stop all services |
|
|
43
|
-
| `learnhouse
|
|
47
|
+
| `learnhouse update` | Update to the latest version |
|
|
48
|
+
| `learnhouse update --version <x.y.z>` | Update to a specific version |
|
|
49
|
+
| `learnhouse logs` | Stream service logs |
|
|
44
50
|
| `learnhouse config` | Show current configuration |
|
|
45
|
-
| `learnhouse
|
|
51
|
+
| `learnhouse status` | Show service status |
|
|
52
|
+
| `learnhouse health` | Run health checks |
|
|
53
|
+
| `learnhouse backup` | Backup database |
|
|
54
|
+
| `learnhouse restore <archive>` | Restore database from a backup |
|
|
46
55
|
| `learnhouse deployments` | View deployments and set resource limits |
|
|
47
|
-
| `learnhouse doctor` |
|
|
48
|
-
| `learnhouse shell` | Open
|
|
56
|
+
| `learnhouse doctor` | Diagnose common issues |
|
|
57
|
+
| `learnhouse shell` | Open a shell in a running container |
|
|
58
|
+
| `learnhouse env` | Edit environment variables |
|
|
59
|
+
| `learnhouse dev` | Start local development environment |
|
|
49
60
|
|
|
50
|
-
## Setup
|
|
61
|
+
## Setup
|
|
51
62
|
|
|
52
63
|
The setup wizard walks through:
|
|
53
64
|
|
|
54
65
|
1. **Install directory** — where files are generated
|
|
55
|
-
2. **Domain** — hostname, port, HTTPS/SSL
|
|
56
|
-
3. **Database & Redis** — local (Docker) or external
|
|
57
|
-
4. **Organization** — name for your
|
|
66
|
+
2. **Domain** — hostname, port, HTTPS/SSL
|
|
67
|
+
3. **Database & Redis** — local (Docker) or external
|
|
68
|
+
4. **Organization** — name for your instance
|
|
58
69
|
5. **Admin account** — email and password
|
|
59
|
-
6. **
|
|
60
|
-
|
|
61
|
-
You can go back to any previous step during setup, and edit any step from the summary before confirming.
|
|
70
|
+
6. **Features** — AI, email, S3, OAuth, Unsplash
|
|
62
71
|
|
|
63
|
-
|
|
72
|
+
You can go back to any step, and edit from the summary before confirming.
|
|
64
73
|
|
|
65
|
-
##
|
|
74
|
+
## Updating
|
|
66
75
|
|
|
67
76
|
```bash
|
|
68
|
-
#
|
|
69
|
-
npx learnhouse start
|
|
70
|
-
npx learnhouse stop
|
|
71
|
-
|
|
72
|
-
# View logs
|
|
73
|
-
npx learnhouse logs
|
|
74
|
-
|
|
75
|
-
# Backup database
|
|
77
|
+
# Back up first
|
|
76
78
|
npx learnhouse backup
|
|
77
79
|
|
|
78
|
-
#
|
|
79
|
-
npx learnhouse
|
|
80
|
-
|
|
81
|
-
# Open a shell in a container
|
|
82
|
-
npx learnhouse shell
|
|
80
|
+
# Update to latest
|
|
81
|
+
npx learnhouse update
|
|
83
82
|
|
|
84
|
-
#
|
|
85
|
-
npx learnhouse
|
|
83
|
+
# Or a specific version
|
|
84
|
+
npx learnhouse update --version 1.2.0
|
|
86
85
|
```
|
|
87
86
|
|
|
88
|
-
|
|
87
|
+
The update command pulls the new image, restarts services, and asks if you want to run database migrations. Check [docs.learnhouse.app](https://docs.learnhouse.app) for migration guides before proceeding.
|
|
89
88
|
|
|
90
|
-
|
|
89
|
+
## Generated Files
|
|
91
90
|
|
|
92
91
|
```
|
|
93
92
|
learnhouse/
|
|
94
|
-
docker-compose.yml
|
|
95
|
-
.env
|
|
96
|
-
learnhouse.config.json
|
|
93
|
+
docker-compose.yml # Service definitions
|
|
94
|
+
.env # Configuration
|
|
95
|
+
learnhouse.config.json # CLI metadata
|
|
97
96
|
extra/
|
|
98
|
-
nginx.prod.conf
|
|
97
|
+
nginx.prod.conf # Reverse proxy (or Caddyfile for auto-SSL)
|
|
99
98
|
```
|
|
100
99
|
|
|
101
100
|
## License
|
package/dist/bin/learnhouse.js
CHANGED
|
@@ -3613,10 +3613,10 @@ var {
|
|
|
3613
3613
|
} = import_index.default;
|
|
3614
3614
|
|
|
3615
3615
|
// bin/learnhouse.ts
|
|
3616
|
-
var
|
|
3616
|
+
var import_picocolors19 = __toESM(require_picocolors(), 1);
|
|
3617
3617
|
|
|
3618
3618
|
// src/constants.ts
|
|
3619
|
-
var VERSION = "1.
|
|
3619
|
+
var VERSION = "1.3.1";
|
|
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 = "postgres:16-alpine";
|
|
@@ -4832,14 +4832,6 @@ function isDockerInstalled() {
|
|
|
4832
4832
|
return false;
|
|
4833
4833
|
}
|
|
4834
4834
|
}
|
|
4835
|
-
function isDockerComposeV2() {
|
|
4836
|
-
try {
|
|
4837
|
-
const output = execSync("docker compose version", { stdio: "pipe" }).toString();
|
|
4838
|
-
return output.includes("v2");
|
|
4839
|
-
} catch {
|
|
4840
|
-
return false;
|
|
4841
|
-
}
|
|
4842
|
-
}
|
|
4843
4835
|
function isDockerRunning() {
|
|
4844
4836
|
try {
|
|
4845
4837
|
execSync("docker info", { stdio: "pipe" });
|
|
@@ -4993,11 +4985,6 @@ async function checkPrerequisites() {
|
|
|
4993
4985
|
check: isDockerInstalled,
|
|
4994
4986
|
failMsg: `Docker is not installed. Install it from ${import_picocolors6.default.underline("https://docs.docker.com/get-docker/")}`
|
|
4995
4987
|
},
|
|
4996
|
-
{
|
|
4997
|
-
name: "Docker Compose v2",
|
|
4998
|
-
check: isDockerComposeV2,
|
|
4999
|
-
failMsg: `Docker Compose v2 is required. Install it from ${import_picocolors6.default.underline("https://docs.docker.com/compose/install/")}`
|
|
5000
|
-
},
|
|
5001
4988
|
{
|
|
5002
4989
|
name: "Docker daemon",
|
|
5003
4990
|
check: isDockerRunning,
|
|
@@ -6430,8 +6417,8 @@ async function logsCommand() {
|
|
|
6430
6417
|
R2.info("Streaming logs (Ctrl+C to stop)...");
|
|
6431
6418
|
if (config?.installDir) {
|
|
6432
6419
|
try {
|
|
6433
|
-
const { execSync:
|
|
6434
|
-
const ps =
|
|
6420
|
+
const { execSync: execSync7 } = await import("child_process");
|
|
6421
|
+
const ps = execSync7("docker compose ps -q", { cwd: config.installDir, stdio: "pipe" }).toString().trim();
|
|
6435
6422
|
if (ps) {
|
|
6436
6423
|
dockerComposeLogs(config.installDir);
|
|
6437
6424
|
return;
|
|
@@ -6934,11 +6921,6 @@ async function doctorCommand() {
|
|
|
6934
6921
|
process.exit(1);
|
|
6935
6922
|
}
|
|
6936
6923
|
pass("Docker daemon running");
|
|
6937
|
-
if (isDockerComposeV2()) {
|
|
6938
|
-
pass("Docker Compose v2 available");
|
|
6939
|
-
} else {
|
|
6940
|
-
fail("Docker Compose v2 not found", "Update Docker Desktop or install docker-compose-plugin");
|
|
6941
|
-
}
|
|
6942
6924
|
if (!config) {
|
|
6943
6925
|
R2.warn("No LearnHouse installation found. Skipping deployment checks.");
|
|
6944
6926
|
Le(import_picocolors14.default.dim("Done"));
|
|
@@ -7664,11 +7646,176 @@ async function devCommand(opts) {
|
|
|
7664
7646
|
});
|
|
7665
7647
|
}
|
|
7666
7648
|
|
|
7649
|
+
// src/commands/update.ts
|
|
7650
|
+
import { execSync as execSync6 } from "child_process";
|
|
7651
|
+
import { readFileSync as readFileSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
7652
|
+
import { join as join3 } from "path";
|
|
7653
|
+
var import_picocolors18 = __toESM(require_picocolors(), 1);
|
|
7654
|
+
var GHCR_BASE2 = "ghcr.io/learnhouse/app";
|
|
7655
|
+
async function resolveTag(version) {
|
|
7656
|
+
try {
|
|
7657
|
+
const tokenResp = await fetch(
|
|
7658
|
+
"https://ghcr.io/token?scope=repository:learnhouse/app:pull",
|
|
7659
|
+
{ signal: AbortSignal.timeout(5e3) }
|
|
7660
|
+
);
|
|
7661
|
+
if (!tokenResp.ok) return false;
|
|
7662
|
+
const { token } = await tokenResp.json();
|
|
7663
|
+
const manifestResp = await fetch(
|
|
7664
|
+
`https://ghcr.io/v2/learnhouse/app/manifests/${version}`,
|
|
7665
|
+
{
|
|
7666
|
+
signal: AbortSignal.timeout(5e3),
|
|
7667
|
+
headers: {
|
|
7668
|
+
Accept: "application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json",
|
|
7669
|
+
Authorization: `Bearer ${token}`
|
|
7670
|
+
}
|
|
7671
|
+
}
|
|
7672
|
+
);
|
|
7673
|
+
return manifestResp.ok;
|
|
7674
|
+
} catch {
|
|
7675
|
+
return false;
|
|
7676
|
+
}
|
|
7677
|
+
}
|
|
7678
|
+
async function updateCommand(options) {
|
|
7679
|
+
const dir = findInstallDir();
|
|
7680
|
+
const config = readConfig(dir);
|
|
7681
|
+
if (!config) {
|
|
7682
|
+
R2.error("No LearnHouse installation found in the current directory.");
|
|
7683
|
+
process.exit(1);
|
|
7684
|
+
}
|
|
7685
|
+
const targetVersion = options.version?.replace(/^v/, "");
|
|
7686
|
+
if (targetVersion) {
|
|
7687
|
+
We(import_picocolors18.default.cyan(`Updating LearnHouse to v${targetVersion}`));
|
|
7688
|
+
} else {
|
|
7689
|
+
We(import_picocolors18.default.cyan("Updating LearnHouse to latest"));
|
|
7690
|
+
}
|
|
7691
|
+
const s = bt2();
|
|
7692
|
+
try {
|
|
7693
|
+
let targetImage;
|
|
7694
|
+
if (targetVersion) {
|
|
7695
|
+
s.start(`Checking if v${targetVersion} exists`);
|
|
7696
|
+
const exists = await resolveTag(targetVersion);
|
|
7697
|
+
if (!exists) {
|
|
7698
|
+
const existsWithV = await resolveTag(`v${targetVersion}`);
|
|
7699
|
+
if (!existsWithV) {
|
|
7700
|
+
s.stop("Version not found");
|
|
7701
|
+
R2.error(
|
|
7702
|
+
`Version ${targetVersion} not found on ghcr.io/learnhouse/app`
|
|
7703
|
+
);
|
|
7704
|
+
process.exit(1);
|
|
7705
|
+
}
|
|
7706
|
+
targetImage = `${GHCR_BASE2}:v${targetVersion}`;
|
|
7707
|
+
} else {
|
|
7708
|
+
targetImage = `${GHCR_BASE2}:${targetVersion}`;
|
|
7709
|
+
}
|
|
7710
|
+
s.stop(`Found v${targetVersion}`);
|
|
7711
|
+
} else {
|
|
7712
|
+
targetImage = `${GHCR_BASE2}:latest`;
|
|
7713
|
+
}
|
|
7714
|
+
const composePath = join3(config.installDir, "docker-compose.yml");
|
|
7715
|
+
const composeContent = readFileSync2(composePath, "utf-8");
|
|
7716
|
+
const updatedCompose = composeContent.replace(
|
|
7717
|
+
/image:\s*ghcr\.io\/learnhouse\/app:\S+/,
|
|
7718
|
+
`image: ${targetImage}`
|
|
7719
|
+
);
|
|
7720
|
+
writeFileSync3(composePath, updatedCompose);
|
|
7721
|
+
s.start("Pulling image");
|
|
7722
|
+
s.stop("Image reference updated");
|
|
7723
|
+
s.start("Restarting services");
|
|
7724
|
+
dockerComposeDown(config.installDir);
|
|
7725
|
+
dockerComposeUp(config.installDir);
|
|
7726
|
+
s.stop("Services restarted");
|
|
7727
|
+
R2.info("");
|
|
7728
|
+
R2.warn(
|
|
7729
|
+
import_picocolors18.default.bold("This update may include database migrations.")
|
|
7730
|
+
);
|
|
7731
|
+
R2.info(
|
|
7732
|
+
`Before proceeding, check the release notes at ${import_picocolors18.default.cyan("https://docs.learnhouse.app")} for migration guides and breaking changes.`
|
|
7733
|
+
);
|
|
7734
|
+
R2.info("");
|
|
7735
|
+
const runMigrations = await Re({
|
|
7736
|
+
message: "Run database migrations now?",
|
|
7737
|
+
initialValue: false
|
|
7738
|
+
});
|
|
7739
|
+
if (Ct(runMigrations)) {
|
|
7740
|
+
R2.info("Skipped database migrations. You can run them later with:");
|
|
7741
|
+
R2.info(' docker exec <container> sh -c "cd /app/api && uv run alembic upgrade head"');
|
|
7742
|
+
} else if (runMigrations) {
|
|
7743
|
+
s.start("Running database migrations");
|
|
7744
|
+
try {
|
|
7745
|
+
const appContainer = getAppContainerName(config.installDir);
|
|
7746
|
+
if (appContainer) {
|
|
7747
|
+
waitForContainer(appContainer);
|
|
7748
|
+
execSync6(
|
|
7749
|
+
`docker exec ${appContainer} sh -c "cd /app/api && uv run alembic upgrade head"`,
|
|
7750
|
+
{ stdio: "pipe", timeout: 12e4 }
|
|
7751
|
+
);
|
|
7752
|
+
s.stop("Database migrations complete");
|
|
7753
|
+
} else {
|
|
7754
|
+
s.stop("Skipped migrations (container not found)");
|
|
7755
|
+
R2.warn("Could not find the app container to run migrations. Run them manually:");
|
|
7756
|
+
R2.warn(' docker exec <container> sh -c "cd /app/api && uv run alembic upgrade head"');
|
|
7757
|
+
}
|
|
7758
|
+
} catch {
|
|
7759
|
+
s.stop("Migration warning");
|
|
7760
|
+
R2.warn("Database migrations encountered an issue. Your app is running but you may need to run migrations manually:");
|
|
7761
|
+
R2.warn(' docker exec <container> sh -c "cd /app/api && uv run alembic upgrade head"');
|
|
7762
|
+
}
|
|
7763
|
+
} else {
|
|
7764
|
+
R2.info("Skipped database migrations. You can run them later with:");
|
|
7765
|
+
R2.info(' docker exec <container> sh -c "cd /app/api && uv run alembic upgrade head"');
|
|
7766
|
+
}
|
|
7767
|
+
if (targetVersion) {
|
|
7768
|
+
R2.success(`LearnHouse has been updated to v${targetVersion}!`);
|
|
7769
|
+
} else {
|
|
7770
|
+
R2.success("LearnHouse has been updated to the latest version!");
|
|
7771
|
+
}
|
|
7772
|
+
} catch {
|
|
7773
|
+
s.stop("Update failed");
|
|
7774
|
+
R2.error("Failed to update. Check Docker output above.");
|
|
7775
|
+
process.exit(1);
|
|
7776
|
+
}
|
|
7777
|
+
}
|
|
7778
|
+
function getAppContainerName(cwd) {
|
|
7779
|
+
try {
|
|
7780
|
+
const output = execSync6('docker compose ps --format "{{.Name}}"', {
|
|
7781
|
+
cwd,
|
|
7782
|
+
stdio: "pipe"
|
|
7783
|
+
}).toString().trim();
|
|
7784
|
+
const lines = output.split("\n");
|
|
7785
|
+
return lines.find((name) => name.includes("learnhouse-app-")) || null;
|
|
7786
|
+
} catch {
|
|
7787
|
+
return null;
|
|
7788
|
+
}
|
|
7789
|
+
}
|
|
7790
|
+
function waitForContainer(containerName, timeoutMs = 6e4) {
|
|
7791
|
+
const start = Date.now();
|
|
7792
|
+
while (Date.now() - start < timeoutMs) {
|
|
7793
|
+
try {
|
|
7794
|
+
const status = execSync6(
|
|
7795
|
+
`docker inspect -f '{{.State.Health.Status}}' ${containerName}`,
|
|
7796
|
+
{ stdio: "pipe" }
|
|
7797
|
+
).toString().trim();
|
|
7798
|
+
if (status === "healthy") return;
|
|
7799
|
+
} catch {
|
|
7800
|
+
try {
|
|
7801
|
+
const running = execSync6(
|
|
7802
|
+
`docker inspect -f '{{.State.Running}}' ${containerName}`,
|
|
7803
|
+
{ stdio: "pipe" }
|
|
7804
|
+
).toString().trim();
|
|
7805
|
+
if (running === "true") return;
|
|
7806
|
+
} catch {
|
|
7807
|
+
}
|
|
7808
|
+
}
|
|
7809
|
+
execSync6("sleep 2", { stdio: "pipe" });
|
|
7810
|
+
}
|
|
7811
|
+
}
|
|
7812
|
+
|
|
7667
7813
|
// bin/learnhouse.ts
|
|
7668
7814
|
var COMMANDS = [
|
|
7669
7815
|
{ name: "setup", desc: "Interactive setup wizard" },
|
|
7670
7816
|
{ name: "start", desc: "Start services" },
|
|
7671
7817
|
{ name: "stop", desc: "Stop services" },
|
|
7818
|
+
{ name: "update", desc: "Update to latest or specific version" },
|
|
7672
7819
|
{ name: "logs", desc: "Stream logs" },
|
|
7673
7820
|
{ name: "config", desc: "Show configuration" },
|
|
7674
7821
|
{ name: "backup", desc: "Backup & restore database" },
|
|
@@ -7679,13 +7826,13 @@ var COMMANDS = [
|
|
|
7679
7826
|
];
|
|
7680
7827
|
async function showWelcome() {
|
|
7681
7828
|
await printBanner();
|
|
7682
|
-
console.log(
|
|
7829
|
+
console.log(import_picocolors19.default.bold(import_picocolors19.default.white(" Available commands:\n")));
|
|
7683
7830
|
for (const cmd of COMMANDS) {
|
|
7684
|
-
console.log(` ${
|
|
7831
|
+
console.log(` ${import_picocolors19.default.cyan(cmd.name.padEnd(14))} ${import_picocolors19.default.dim(cmd.desc)}`);
|
|
7685
7832
|
}
|
|
7686
7833
|
console.log();
|
|
7687
|
-
console.log(
|
|
7688
|
-
console.log(
|
|
7834
|
+
console.log(import_picocolors19.default.dim(" Run a command with: npx learnhouse <command>"));
|
|
7835
|
+
console.log(import_picocolors19.default.dim(" Get started with: npx learnhouse setup"));
|
|
7689
7836
|
console.log();
|
|
7690
7837
|
}
|
|
7691
7838
|
var program2 = new Command();
|
|
@@ -7699,6 +7846,7 @@ program2.command("backup").description("Backup & restore LearnHouse database").a
|
|
|
7699
7846
|
program2.command("deployments").description("Manage deployments & resource limits").action(deploymentsCommand);
|
|
7700
7847
|
program2.command("doctor").description("Diagnose common issues with LearnHouse").action(doctorCommand);
|
|
7701
7848
|
program2.command("shell").description("Open a shell in a LearnHouse container").action(shellCommand);
|
|
7849
|
+
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);
|
|
7702
7850
|
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);
|
|
7703
7851
|
var updateCheck = checkForUpdates();
|
|
7704
7852
|
program2.parseAsync().then(() => updateCheck.catch(() => {
|