helloruntime 0.0.1 → 0.0.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cli/deploy.ts"],"names":[],"mappings":"AAkCA,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8D5E"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/cli/deploy.ts"],"names":[],"mappings":"AAkCA,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgE5E"}
@@ -2,7 +2,7 @@ import { readFile } from "node:fs/promises";
2
2
  import { basename, join } from "node:path";
3
3
  import { readConfig } from "./config.js";
4
4
  import { helloruntimeRequest } from "./http.js";
5
- import { packageSource } from "./packager.js";
5
+ import { packageBundle, runBuild } from "./packager.js";
6
6
  import { readProjectConfig } from "./project-config.js";
7
7
  const TERMINAL = new Set(["active", "failed"]);
8
8
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -21,19 +21,21 @@ export async function deployCommand(options) {
21
21
  .then((raw) => JSON.parse(raw))
22
22
  .catch(() => ({}));
23
23
  const appName = options.app ?? pkg.name ?? basename(cwd);
24
- process.stdout.write("Packaging source… ");
25
- const { tarPath, sourceHash, entries } = await packageSource(cwd);
26
- console.log(`${entries.length} files (${sourceHash.slice(0, 12)})`);
24
+ // Build locally (Vite/Nitro .output), then package the bundle and reject natives.
25
+ await runBuild(cwd, projectConfig.build?.command);
26
+ process.stdout.write("Packaging bundle… ");
27
+ const { tarPath, bundleSha, fileCount } = await packageBundle(cwd);
28
+ console.log(`${fileCount} files (${bundleSha.slice(0, 12)})`);
27
29
  process.stdout.write("Uploading… ");
28
30
  const tarball = await readFile(tarPath);
29
- const uploaded = await helloruntimeRequest(config, `/v1/artifacts?sourceHash=${encodeURIComponent(sourceHash)}`, { method: "POST", headers: { "content-type": "application/gzip" }, body: tarball });
31
+ const uploaded = await helloruntimeRequest(config, `/v1/artifacts?bundleSha=${encodeURIComponent(bundleSha)}`, { method: "POST", headers: { "content-type": "application/gzip" }, body: tarball });
30
32
  console.log(`${(uploaded.artifactSizeBytes / 1024).toFixed(0)} KiB`);
31
33
  const created = await helloruntimeRequest(config, "/v1/deployments", {
32
34
  method: "POST",
33
35
  body: JSON.stringify({
34
36
  appName,
35
37
  appSlug: appName,
36
- sourceHash,
38
+ bundleSha,
37
39
  artifactKey: uploaded.artifactKey,
38
40
  artifactSizeBytes: uploaded.artifactSizeBytes,
39
41
  manifest: projectConfig
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/cli/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAkBxD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC/C,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAEpE,SAAS,cAAc,CAAC,EAAU;IAChC,MAAM,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC;IAC1B,IAAI,OA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AAI,CAAC,GAAG,EAAE,CAAC;IAC5B,SAAS,CAAC;QACR,MAAM,MAAM,GAAG,MAAM,mBAAmB,CACtC,MAAM,EACN,mBAAmB,OAAO,CAAC,YAAY,EAAE,CAC1C,CAAC;QACF,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,EAAE,CAAC;YAC5B,2EAA2E;YAC3E,6EAA6E;YAC7E,yDAAyD;YACzD,IAAI,KAAK,KAAK,EAAE;gBAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;YAC1F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7C,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;YACtB,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1B,CAAC;QACD,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC3B,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,KAAK,IAAI,eAAe,EAAE,CAAC,CAAC;YACvE,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,iBAAiB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;YAC/B,OAAO;QACT,CAAC;QACD,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC"}
package/dist/cli/index.js CHANGED
@@ -1,29 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
- import { writeConfig } from "./config.js";
4
3
  import { deployCommand } from "./deploy.js";
5
4
  import { destroyCommand } from "./destroy.js";
5
+ import { loginCommand } from "./login.js";
6
6
  import { cronList, cronTrigger, jobsList, jobsTrigger } from "./triggers.js";
7
7
  const program = new Command();
8
- program.name("helloruntime").description("Deploy server-rendered JS/TS apps to Helloruntime").version("0.0.1");
8
+ program.name("helloruntime").description("Deploy server-rendered JS/TS apps to Helloruntime").version("0.0.2");
9
9
  program
10
10
  .command("login")
11
+ .description("Authenticate via the browser (device flow)")
11
12
  .option("--api-url <url>", "Helloruntime API URL", process.env.HELLORUNTIME_API_URL ?? "http://localhost:3000")
12
- .option("--email <email>", "Dev login email", "dev@helloruntime.local")
13
- .option("--dev", "Use the dev-login fallback (no real IdP yet)")
14
- .action(async (options) => {
15
- const response = await fetch(new URL("/v1/auth/dev-login", options.apiUrl), {
16
- method: "POST",
17
- headers: { "content-type": "application/json" },
18
- body: JSON.stringify({ email: options.email })
19
- });
20
- const body = (await response.json().catch(() => null));
21
- if (!response.ok || !body) {
22
- throw new Error(`Login failed (${response.status})`);
23
- }
24
- await writeConfig({ apiUrl: options.apiUrl, token: body.token });
25
- console.log(`Logged in to ${options.apiUrl} as ${body.user.email}`);
26
- });
13
+ .action(loginCommand);
27
14
  program
28
15
  .command("deploy")
29
16
  .description("Build + deploy the app in the current directory")
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE7E,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO,CA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,MAAM,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;AAEtE,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC5C,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function loginCommand(options: {
2
+ apiUrl: string;
3
+ }): Promise<void>;
4
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/cli/login.ts"],"names":[],"mappings":"AAgCA,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD7E"}
@@ -0,0 +1,75 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createInterface } from "node:readline";
3
+ import { setTimeout as sleep } from "node:timers/promises";
4
+ import { writeConfig } from "./config.js";
5
+ function openBrowser(url) {
6
+ const platform = process.platform;
7
+ const command = platform === "darwin" ? "open" : platform === "win32" ? "cmd" : "xdg-open";
8
+ const args = platform === "win32" ? ["/c", "start", "", url] : [url];
9
+ try {
10
+ spawn(command, args, { stdio: "ignore", detached: true }).unref();
11
+ }
12
+ catch {
13
+ // Non-fatal — the URL is already printed for the user to open manually.
14
+ }
15
+ }
16
+ async function waitForEnter(prompt) {
17
+ if (!process.stdin.isTTY)
18
+ return; // non-interactive (piped/CI): skip the prompt
19
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
20
+ await new Promise((resolve) => rl.question(prompt, () => resolve()));
21
+ rl.close();
22
+ }
23
+ export async function loginCommand(options) {
24
+ const startRes = await fetch(new URL("/v1/auth/device/start", options.apiUrl), {
25
+ method: "POST",
26
+ headers: { "content-type": "application/json" },
27
+ body: "{}"
28
+ });
29
+ if (!startRes.ok)
30
+ throw new Error(`Could not start login (${startRes.status})`);
31
+ const session = (await startRes.json());
32
+ console.log(`\nTo authenticate, visit:\n\n ${session.verificationUrl}\n`);
33
+ console.log(`and confirm this code: ${session.userCode}\n`);
34
+ await waitForEnter("Press ENTER to open the URL in your browser… ");
35
+ openBrowser(session.verificationUrl);
36
+ const deadline = Date.now() + session.expiresIn * 1000;
37
+ let interval = session.interval * 1000;
38
+ process.stdout.write("Waiting for approval…");
39
+ for (;;) {
40
+ if (Date.now() > deadline) {
41
+ process.stdout.write("\n");
42
+ throw new Error("Login timed out. Run `helloruntime login` again.");
43
+ }
44
+ await sleep(interval);
45
+ const res = await fetch(new URL("/v1/auth/device/token", options.apiUrl), {
46
+ method: "POST",
47
+ headers: { "content-type": "application/json" },
48
+ body: JSON.stringify({ deviceCode: session.deviceCode })
49
+ });
50
+ if (res.ok) {
51
+ const body = (await res.json());
52
+ await writeConfig({ apiUrl: options.apiUrl, token: body.token });
53
+ process.stdout.write("\n");
54
+ console.log(`Logged in to ${options.apiUrl} as ${body.user.email}`);
55
+ return;
56
+ }
57
+ const err = (await res.json().catch(() => ({})));
58
+ if (err.error === "authorization_pending") {
59
+ process.stdout.write(".");
60
+ continue;
61
+ }
62
+ if (err.error === "slow_down") {
63
+ interval += 2000;
64
+ process.stdout.write(".");
65
+ continue;
66
+ }
67
+ process.stdout.write("\n");
68
+ if (err.error === "access_denied")
69
+ throw new Error("Login was denied in the browser.");
70
+ if (err.error === "expired_token")
71
+ throw new Error("Login expired. Run `helloruntime login` again.");
72
+ throw new Error(`Login failed: ${err.error ?? res.status}`);
73
+ }
74
+ }
75
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/cli/login.ts"],"names":[],"mappings":"AAAA,OAAO,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,CAAC,kCAAkC,CAAC,CAAC;QACvF,IAAI,GAAG,CAAC,KAAK,KAAK,eAAe;YAAE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACrG,MAAM,IAAI,KAAK,CAAC,iBAAiB,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9D,CAAC;AACH,CAAC"}
@@ -1,7 +1,8 @@
1
- export interface PackagedSource {
1
+ export declare function runBuild(cwd: string, command?: string): Promise<void>;
2
+ export interface PackagedBundle {
2
3
  tarPath: string;
3
- sourceHash: string;
4
- entries: string[];
4
+ bundleSha: string;
5
+ fileCount: number;
5
6
  }
6
- export declare function packageSource(cwd: string): Promise<PackagedSource>;
7
+ export declare function packageBundle(cwd: string): Promise<PackagedBundle>;
7
8
  //# sourceMappingURL=packager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packager.d.ts","sourceRoot":"","sources":["../../src/cli/packager.ts"],"names":[],"mappings":"AA+BA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAGD,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAoBxE"}
1
+ {"version":3,"file":"packager.d.ts","sourceRoot":"","sources":["../../src/cli/packager.ts"],"names":[],"mappings":"AAwBA,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkB3E;AAgBD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAKD,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAqCxE"}
@@ -1,49 +1,85 @@
1
+ import { spawnSync } from "node:child_process";
1
2
  import { createHash } from "node:crypto";
2
- import { mkdir, readdir, readFile } from "node:fs/promises";
3
+ import { createReadStream } from "node:fs";
4
+ import { access, mkdir, readdir } from "node:fs/promises";
3
5
  import { join, relative, sep } from "node:path";
6
+ import { Transform } from "node:stream";
7
+ import { pipeline } from "node:stream/promises";
4
8
  import * as tar from "tar";
5
- // Directories never uploaded: build outputs + vcs + deps. node_modules is installed
6
- // server-side; .output/dist are rebuilt; excluding them keeps the source hash stable.
7
- const DENY_DIRS = new Set([
8
- "node_modules",
9
- ".git",
10
- "dist",
11
- ".output",
12
- ".helloruntime",
13
- ".turbo",
14
- "coverage",
15
- ".next",
16
- ".vite"
17
- ]);
18
- const DENY_FILES = new Set([".DS_Store", ".env", ".env.local"]);
19
- async function walk(dir, out) {
9
+ const OUTPUT_DIR = ".output";
10
+ const ENTRY = join(OUTPUT_DIR, "server", "index.mjs");
11
+ // Detect the package manager from the lockfile so `<pm> run build` matches what the
12
+ // developer uses. Defaults to npm.
13
+ function detectPackageManager(files) {
14
+ if (files.has("pnpm-lock.yaml"))
15
+ return "pnpm";
16
+ if (files.has("yarn.lock"))
17
+ return "yarn";
18
+ if (files.has("bun.lockb"))
19
+ return "bun";
20
+ return "npm";
21
+ }
22
+ // Run the project's build (Vite/Nitro → .output) on the developer's machine, streaming
23
+ // logs straight to their terminal. `command` overrides the default `<pm> run build`.
24
+ export async function runBuild(cwd, command) {
25
+ const top = new Set(await readdir(cwd).catch(() => []));
26
+ const [cmd, args] = command
27
+ ? ["sh", ["-c", command]]
28
+ : [detectPackageManager(top), ["run", "build"]];
29
+ process.stdout.write(`Building (${command ?? `${cmd} run build`})…\n`);
30
+ const result = spawnSync(cmd, args, { cwd, stdio: "inherit" });
31
+ if (result.status !== 0) {
32
+ throw new Error(`build failed (${cmd} exited ${result.status ?? result.signal})`);
33
+ }
34
+ await access(join(cwd, ENTRY)).catch(() => {
35
+ throw new Error(`no Nitro output at ${ENTRY} after build. Ensure the app builds with the ` +
36
+ `node-server preset (Nitro \`preset: "node-server"\`).`);
37
+ });
38
+ }
39
+ // Recursively walk .output, collecting relative file paths and any native addons.
40
+ async function walkOutput(dir, base, files, native) {
20
41
  for (const entry of await readdir(dir, { withFileTypes: true })) {
42
+ const full = join(dir, entry.name);
21
43
  if (entry.isDirectory()) {
22
- if (!DENY_DIRS.has(entry.name))
23
- await walk(join(dir, entry.name), out);
44
+ await walkOutput(full, base, files, native);
24
45
  }
25
- else if (entry.isFile() && !DENY_FILES.has(entry.name)) {
26
- out.push(join(dir, entry.name));
46
+ else if (entry.isFile()) {
47
+ const rel = relative(base, full).split(sep).join("/");
48
+ files.push(rel);
49
+ if (entry.name.endsWith(".node"))
50
+ native.push(rel);
27
51
  }
28
52
  }
29
53
  }
30
- // Tar SOURCE ONLY (sorted, deterministic), hash over relative path + content.
31
- export async function packageSource(cwd) {
32
- const absFiles = [];
33
- await walk(cwd, absFiles);
34
- absFiles.sort();
35
- const entries = absFiles.map((f) => relative(cwd, f).split(sep).join("/"));
36
- const hash = createHash("sha256");
37
- for (let i = 0; i < absFiles.length; i++) {
38
- hash.update(entries[i]);
39
- hash.update("\0");
40
- hash.update(await readFile(absFiles[i]));
54
+ // Package the built `.output/` into a gzip tarball and hash the EXACT tarball bytes
55
+ // (this is what the runtime loader verifies). Rejects native modules: pure-JS bundles
56
+ // only, so a macOS-built `.node` can never silently crash on a Linux node.
57
+ export async function packageBundle(cwd) {
58
+ const outputDir = join(cwd, OUTPUT_DIR);
59
+ await access(outputDir).catch(() => {
60
+ throw new Error(`no ${OUTPUT_DIR}/ to package — did the build run?`);
61
+ });
62
+ const files = [];
63
+ const native = [];
64
+ await walkOutput(outputDir, cwd, files, native);
65
+ if (native.length > 0) {
66
+ throw new Error(`native modules are not supported (pure-JS bundles only). Found:\n` +
67
+ native.map((n) => ` - ${n}`).join("\n") +
68
+ `\nRemove the native dependency, or request it be added to the runtime image.`);
41
69
  }
42
- const sourceHash = hash.digest("hex");
43
70
  const outDir = join(cwd, ".helloruntime", "artifacts");
44
71
  await mkdir(outDir, { recursive: true });
45
- const tarPath = join(outDir, `${sourceHash}.tgz`);
46
- await tar.c({ gzip: true, file: tarPath, cwd, portable: true }, entries);
47
- return { tarPath, sourceHash, entries };
72
+ const tarPath = join(outDir, "bundle.tgz");
73
+ // Tar the .output directory (entries like `.output/server/index.mjs`); the loader
74
+ // extracts to /app /app/.output/server/index.mjs.
75
+ await tar.c({ gzip: true, file: tarPath, cwd, portable: true }, [OUTPUT_DIR]);
76
+ const hash = createHash("sha256");
77
+ await pipeline(createReadStream(tarPath), new Transform({
78
+ transform(chunk, _enc, cb) {
79
+ hash.update(chunk);
80
+ cb();
81
+ }
82
+ }));
83
+ return { tarPath, bundleSha: hash.digest("hex"), fileCount: files.length };
48
84
  }
49
85
  //# sourceMappingURL=packager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packager.js","sourceRoot":"","sources":["../../src/cli/packager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,oFAAoF;AACpF,sFAAsF;AACtF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,cAAc;IACd,MAAM;IACN,MAAM;IACN,SAAS;IACT,eAAe;IACf,QAAQ;IACR,UAAU;IACV,OAAO;IACP,OAAO;CACR,CAAC,CAAC;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAEhE,KAAK,UAAU,IAAI,CAAC,GAAW,EAAE,GAAa;IAC5C,KAAK,MAAM,KAAK,IAAI,M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}
@@ -5,6 +5,7 @@ export { sendJob, type SendJobOptions, type SendJobResult } from "./send-job.js"
5
5
  export { createHelloruntimeHandler, type HelloruntimeHandlerOptions } from "./runtime/handler.js";
6
6
  export { helloruntimeExpress } from "./runtime/express.js";
7
7
  export { helloruntimeHono } from "./runtime/hono.js";
8
+ export { helloruntimeNitro, type HelloruntimeNitroPlugin } from "./runtime/nitro.js";
8
9
  export { registerHelloruntime } from "./runtime/register.js";
9
10
  export type { JobContext, CronContext, JobHandler, CronHandler } from "@helloruntime/protocol";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGjF,OAAO,EAAE,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGjF,OAAO,EAAE,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,KAAK,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/sdk/index.js CHANGED
@@ -7,5 +7,6 @@ export { sendJob } from "./send-job.js";
7
7
  export { createHelloruntimeHandler } from "./runtime/handler.js";
8
8
  export { helloruntimeExpress } from "./runtime/express.js";
9
9
  export { helloruntimeHono } from "./runtime/hono.js";
10
+ export { helloruntimeNitro } from "./runtime/nitro.js";
10
11
  export { registerHelloruntime } from "./runtime/register.js";
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,SAAS,EAAsB,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAuB,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,OAAO,EAA2C,MAAM,eAAe,CAAC;AAEjF,mFAAmF;AACnF,OAAO,EAAE,yBAAyB,EAAmC,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,SAAS,EAAsB,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAuB,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,OAAO,EAA2C,MAAM,eAAe,CAAC;AAEjF,mFAAmF;AACnF,OAAO,EAAE,yBAAyB,EAAmC,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAgC,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { IncomingMessage } from "node:http";
2
+ import { type HelloruntimeHandlerOptions } from "./handler.js";
3
+ interface H3EventLike {
4
+ node: {
5
+ req: IncomingMessage;
6
+ };
7
+ }
8
+ interface NitroAppLike {
9
+ h3App: {
10
+ use: (handler: (event: H3EventLike) => Promise<Response | undefined>) => void;
11
+ };
12
+ }
13
+ export type HelloruntimeNitroPlugin = (nitroApp: NitroAppLike) => void;
14
+ /**
15
+ * Nitro server plugin that serves the platform's job/cron dispatch from inside a Nitro
16
+ * (node-server preset) app. Register it once:
17
+ *
18
+ * // server/plugins/helloruntime.ts (Nitro auto-loads server/plugins/*)
19
+ * export { default } from "helloruntime/nitro";
20
+ *
21
+ * It adds an early h3 middleware that intercepts `/_helloruntime/jobs|cron/*`, verifies
22
+ * the HMAC over the EXACT raw request bytes (read straight off the Node request stream —
23
+ * NOT via h3's readRawBody, which can normalize/cache the body and break the signature),
24
+ * runs the registered handler, and returns the response. All other requests pass through
25
+ * untouched. Requires a Nitro/h3 that supports returning a Web `Response` from middleware.
26
+ */
27
+ export declare function helloruntimeNitro(options?: HelloruntimeHandlerOptions): HelloruntimeNitroPlugin;
28
+ /** Ready-to-use plugin with default options (re-export as a Nitro server plugin). */
29
+ declare const _default: HelloruntimeNitroPlugin;
30
+ export default _default;
31
+ //# sourceMappingURL=nitro.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nitro.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,OAAO,EAA6B,KAAK,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAO1F,UAAU,WAAW;IACnB,IAAI,EAAE;QAAE,GAAG,EAAE,eAAe,CAAA;KAAE,CAAC;CAChC;AACD,UAAU,YAAY;IACpB,KAAK,EAAE;QAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,KAAK,IAAI,CAAA;KAAE,CAAC;CAC1F;AAED,MAAM,MAAM,uBAAuB,GAAG,CAAC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC;AAEvE;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,0BAA+B,GAAG,uBAAuB,CAcnG;AAED,qFAAqF;;AACrF,wBAAmC"}
@@ -0,0 +1,58 @@
1
+ import { createHelloruntimeHandler } from "./handler.js";
2
+ import { registerHelloruntime } from "./register.js";
3
+ const HELLORUNTIME_PREFIX = "/_helloruntime/";
4
+ /**
5
+ * Nitro server plugin that serves the platform's job/cron dispatch from inside a Nitro
6
+ * (node-server preset) app. Register it once:
7
+ *
8
+ * // server/plugins/helloruntime.ts (Nitro auto-loads server/plugins/*)
9
+ * export { default } from "helloruntime/nitro";
10
+ *
11
+ * It adds an early h3 middleware that intercepts `/_helloruntime/jobs|cron/*`, verifies
12
+ * the HMAC over the EXACT raw request bytes (read straight off the Node request stream —
13
+ * NOT via h3's readRawBody, which can normalize/cache the body and break the signature),
14
+ * runs the registered handler, and returns the response. All other requests pass through
15
+ * untouched. Requires a Nitro/h3 that supports returning a Web `Response` from middleware.
16
+ */
17
+ export function helloruntimeNitro(options = {}) {
18
+ const handle = createHelloruntimeHandler(options);
19
+ return (nitroApp) => {
20
+ nitroApp.h3App.use(async (event) => {
21
+ const req = event.node.req;
22
+ if (!req.url?.startsWith(HELLORUNTIME_PREFIX))
23
+ return undefined; // not ours → pass through
24
+ const body = await readBody(req);
25
+ const response = await handle(toWebRequest(req, body));
26
+ return response ?? undefined;
27
+ });
28
+ // Fire self-registration after the entry module's defineJob/defineCron have run.
29
+ setImmediate(() => void registerHelloruntime());
30
+ };
31
+ }
32
+ /** Ready-to-use plugin with default options (re-export as a Nitro server plugin). */
33
+ export default helloruntimeNitro();
34
+ function readBody(req) {
35
+ return new Promise((resolve, reject) => {
36
+ const chunks = [];
37
+ req.on("data", (c) => chunks.push(Buffer.from(c)));
38
+ req.on("end", () => resolve(Buffer.concat(chunks)));
39
+ req.on("error", reject);
40
+ });
41
+ }
42
+ function toWebRequest(req, body) {
43
+ const host = req.headers.host ?? "app.internal";
44
+ const headers = new Headers();
45
+ for (const [key, value] of Object.entries(req.headers)) {
46
+ if (Array.isArray(value))
47
+ for (const v of value)
48
+ headers.append(key, v);
49
+ else if (value != null)
50
+ headers.set(key, value);
51
+ }
52
+ return new Request(`http://${host}${req.url}`, {
53
+ method: req.method ?? "GET",
54
+ headers,
55
+ body: body.length ? body : undefined
56
+ });
57
+ }
58
+ //# sourceMappingURL=nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nitro.js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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACpD,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CAAC,GAAoB,EAAE,IAAY;IACtD,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,cAAc,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACvD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,KAAK,MAAM,CAAC,IAAI,KAAK;gBAAE,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;aACnE,IAAI,KAAK,IAAI,IAAI;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,IAAI,OAAO,CAAC,UAAU,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,EAAE;QAC7C,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,KAAK;QAC3B,OAAO;QACP,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;KACrC,CAAC,CAAC;AACL,CAAC"}
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://helloruntime.dev/schema/helloruntime.json",
4
4
  "title": "Helloruntime app config",
5
- "description": "Build + deploy knobs for a Helloruntime app (helloruntime.json). All fields are optional. Helloruntime builds the Dockerfile your source ships (./Dockerfile, or build.dockerfile).",
5
+ "description": "Build + deploy knobs for a Helloruntime app (helloruntime.json). All fields are optional. The CLI builds your app locally (Vite/Nitro → .output) and ships the bundle; there is no Docker build.",
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
8
  "properties": {
@@ -13,11 +13,11 @@
13
13
  "build": {
14
14
  "type": "object",
15
15
  "additionalProperties": false,
16
- "description": "How the source becomes an image.",
16
+ "description": "How the bundle is produced locally.",
17
17
  "properties": {
18
- "dockerfile": {
18
+ "command": {
19
19
  "type": "string",
20
- "description": "Path to the Dockerfile to build, relative to the project root. Defaults to ./Dockerfile (required)."
20
+ "description": "Override the build command the CLI runs (default: your package.json \"build\" script, e.g. vite/nitro build .output)."
21
21
  }
22
22
  }
23
23
  },
@@ -28,7 +28,7 @@
28
28
  "properties": {
29
29
  "release": {
30
30
  "type": "string",
31
- "description": "One-shot command run in the built image before cutover (e.g. database migrations). The deploy fails if it exits non-zero."
31
+ "description": "One-shot command run on the runtime image (with the bundle hydrated at /app) before cutover (e.g. database migrations). The deploy fails if it exits non-zero."
32
32
  }
33
33
  }
34
34
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "helloruntime",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "CLI + runtime SDK for Helloruntime — a small self-hostable PaaS for server-rendered JS/TS apps.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://helloruntime.com",
@@ -25,6 +25,10 @@
25
25
  ".": {
26
26
  "types": "./dist/sdk/index.d.ts",
27
27
  "default": "./dist/sdk/index.js"
28
+ },
29
+ "./nitro": {
30
+ "types": "./dist/sdk/runtime/nitro.d.ts",
31
+ "default": "./dist/sdk/runtime/nitro.js"
28
32
  }
29
33
  },
30
34
  "files": [
@@ -37,7 +41,7 @@
37
41
  "pg": "^8.16.2",
38
42
  "tar": "^7.4.3",
39
43
  "zod": "^3.25.67",
40
- "@helloruntime/protocol": "^0.0.1"
44
+ "@helloruntime/protocol": "^0.0.3"
41
45
  },
42
46
  "devDependencies": {
43
47
  "@types/pg": "^8.15.4",
@@ -1,2 +0,0 @@
1
- export { getRegistry, snapshotRegistration, type RuntimeRegistry } from "@lakebed/protocol";
2
- //# sourceMappingURL=registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/sdk/registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,5 +0,0 @@
1
- // The `lakebed/_supervisor` subpath. The supervisor reads the populated registry
2
- // after importing the user entry. (The registry itself lives in @lakebed/protocol
3
- // so both the SDK and the supervisor depend only downward on protocol.)
4
- export { getRegistry, snapshotRegistration } from "@lakebed/protocol";
5
- //# sourceMappingURL=registry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/sdk/registry.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,kFAAkF;AAClF,wEAAwE;AACxE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAwB,MAAM,mBAAmB,CAAC"}