@kaooffline/quickhost 0.1.0 → 0.1.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 CHANGED
@@ -23,7 +23,7 @@ bunx @kaooffline/quickhost deploy --app demo
23
23
  ## Commands
24
24
 
25
25
  ```
26
- quickhost register -u <name> claim username (asks password)
26
+ quickhost register -u <name> [--email you@mail] claim username (email + password twice, verification link)
27
27
  quickhost login -u <name> login on this machine
28
28
  quickhost deploy [--app x] [--dir ./dist] [--api URL]
29
29
  quickhost list live apps + expiry dates
package/bin/quickhost.js CHANGED
@@ -38,13 +38,26 @@ async function promptSecret(q) {
38
38
  });
39
39
  }
40
40
 
41
+ async function prompt(q) {
42
+ const rl = await import("node:readline");
43
+ const r = rl.createInterface({ input: process.stdin, output: process.stdout });
44
+ return await new Promise((res) => r.question(q, (a) => { r.close(); res(a.trim()); }));
45
+ }
46
+
41
47
  async function registerOrLogin(mode) {
42
48
  const u = (arg("-u") || arg("--username") || "").toLowerCase().trim();
43
49
  if (!u) { console.error(`Usage: quickhost ${mode} -u <username>`); process.exit(1); }
44
50
  const p = arg("-p") || arg("--password") || await promptSecret("password: ");
45
- const r = await fetch(`${apiBase()}/api/${mode}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ username: u, password: p }) });
51
+ const body = { username: u, password: p };
52
+ if (mode === "register") {
53
+ body.email = arg("--email") || await prompt("email: ");
54
+ const p2 = (arg("-p") || arg("--password")) ? p : await promptSecret("password again: ");
55
+ body.password2 = p2;
56
+ }
57
+ const r = await fetch(`${apiBase()}/api/${mode}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
46
58
  const j = await r.json().catch(() => ({}));
47
59
  if (!r.ok) { console.error("ERR:", j.error || r.status); process.exit(1); }
60
+ if (j.verify === "email-sent") { console.log(`ok: verification mail sent to ${j.email}. Click the link, then: quickhost login -u ${u}`); return; }
48
61
  save({ ...load(), api: apiBase(), username: j.username, token: j.token });
49
62
  console.log(`ok: logged in as ${j.username}`);
50
63
  }
@@ -91,6 +104,11 @@ async function deploy() {
91
104
  const files = walk(dir).filter((f) => !f.rel.startsWith("."));
92
105
  if (!files.length) { console.error("ERR: empty dir", dir); process.exit(1); }
93
106
  if (files.length > 500) { console.error("ERR: >500 files (limit)"); process.exit(1); }
107
+ try {
108
+ const idx = readFileSync(join(dir, "index.html"), "utf8");
109
+ if (/(src|href)="\/(?!\/)/.test(idx))
110
+ console.log("note: absolute asset paths (src=\"/assets/...\") detected. Works via platform fallback, but for cleanest hosting set base:'./' in vite.config (or Astro base) and rebuild.");
111
+ } catch {}
94
112
  console.log(`deploying ${files.length} files from ${dir} as ${cfg.username}/${app} ...`);
95
113
  const t0 = Date.now();
96
114
  let i = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaooffline/quickhost",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "quickHOST CLI - one-command static hosting (Vite/Astro/HTML) to username.kaooffline.top/app. Free, 30-day rolling expiry.",
5
5
  "type": "module",
6
6
  "bin": { "quickhost": "bin/quickhost.js" },