create-volt 0.10.0 → 0.11.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/CHANGELOG.md +17 -0
- package/README.md +13 -0
- package/addons/db/files/lib/stores/memory.js +1 -1
- package/addons/db/files/lib/stores/mongo.js +8 -1
- package/addons/db/files/lib/stores/sql.js +3 -0
- package/addons/db/files/public/db-admin-ui.js +72 -0
- package/index.js +16 -0
- package/package.json +1 -1
- package/templates/default/server.js +88 -2
- package/templates/default/setup/studio.html +28 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ All notable changes to `create-volt` are documented here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/), and this project adheres to
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.11.0] - 2026-06-28
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- **`create-volt studio`** (and `npm run dev -- --studio`) — an ephemeral,
|
|
11
|
+
localhost-only **data browser**, à la Prisma Studio. Browse collections and
|
|
12
|
+
documents across any driver (memory / MongoDB / MySQL / Postgres) and delete
|
|
13
|
+
docs. It's **never a route in the running app** — it exists only while you run
|
|
14
|
+
it, binds `127.0.0.1`, and disappears on Ctrl-C (shell/SSH access is the auth).
|
|
15
|
+
Internal collections (auth tokens/sessions) are hidden.
|
|
16
|
+
- Stores gained `collections()` (enumerate collection names) on every adapter.
|
|
17
|
+
|
|
18
|
+
### Security
|
|
19
|
+
- Admin/data surfaces are **ephemeral by design** — no standing `/admin` route in
|
|
20
|
+
the running app to attack (verified: the app 404s admin routes). Same model as
|
|
21
|
+
the config editor: on-demand, loopback-only, gone when the app runs.
|
|
22
|
+
|
|
7
23
|
## [0.10.0] - 2026-06-28
|
|
8
24
|
|
|
9
25
|
### Added
|
|
@@ -146,6 +162,7 @@ All notable changes to `create-volt` are documented here. The format follows
|
|
|
146
162
|
watching and full-page hot reload. Supports `--skip-install` and `--force`,
|
|
147
163
|
and auto-detects npm / pnpm / yarn / bun for the install step.
|
|
148
164
|
|
|
165
|
+
[0.11.0]: https://github.com/MIR-2025/volt/releases/tag/v0.11.0
|
|
149
166
|
[0.10.0]: https://github.com/MIR-2025/volt/releases/tag/v0.10.0
|
|
150
167
|
[0.9.0]: https://github.com/MIR-2025/volt/releases/tag/v0.9.0
|
|
151
168
|
[0.8.0]: https://github.com/MIR-2025/volt/releases/tag/v0.8.0
|
package/README.md
CHANGED
|
@@ -66,6 +66,19 @@ SSH-tunnel hint on a remote box). Enabling an add-on wires its **backend**
|
|
|
66
66
|
automatically — the **frontend** UI (login form, chat) is yours to build, or
|
|
67
67
|
start from `--template guestbook`, which has it wired end-to-end.
|
|
68
68
|
|
|
69
|
+
## Studio (data browser)
|
|
70
|
+
|
|
71
|
+
Browse your database on demand — ephemeral and localhost-only, like Prisma Studio:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm run dev -- --studio # or: npx create-volt studio
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
It connects the DB in your `.env`, lets you view/delete documents across any
|
|
78
|
+
driver, and is **never** a route in the running app (no standing `/admin` to
|
|
79
|
+
attack — shell/SSH access is the gate). Needs a persistent driver (MongoDB /
|
|
80
|
+
MySQL / Postgres) to show data; the memory driver is per-process.
|
|
81
|
+
|
|
69
82
|
## Updating Volt
|
|
70
83
|
|
|
71
84
|
Volt is vendored as a single file (`public/volt.js`), not an npm dependency.
|
|
@@ -39,5 +39,12 @@ export async function createMongoStore({ uri, dbName }) {
|
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
return {
|
|
42
|
+
return {
|
|
43
|
+
name: "mongodb",
|
|
44
|
+
async init() {},
|
|
45
|
+
collection,
|
|
46
|
+
async collections() {
|
|
47
|
+
return (await db.listCollections().toArray()).map((c) => c.name);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
43
50
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// db-admin-ui.js — a tiny, auth-gated data browser (frontend for the db add-on).
|
|
2
|
+
// Served at /db-admin-ui.js; mounted by public/app.js only when db + auth are on.
|
|
3
|
+
// Works for every driver — it reads through the generic store API on the server.
|
|
4
|
+
// Documents render as escaped JSON text (Volt holes → text nodes), never HTML.
|
|
5
|
+
import { signal, computed, html } from "/volt.js";
|
|
6
|
+
|
|
7
|
+
const j = async (url, opts) => {
|
|
8
|
+
const res = await fetch(url, opts);
|
|
9
|
+
return { status: res.status, body: await res.json().catch(() => ({})) };
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function dbAdminPanel() {
|
|
13
|
+
const ready = signal(false); // signed in + loaded
|
|
14
|
+
const denied = signal(false); // 401
|
|
15
|
+
const driver = signal("");
|
|
16
|
+
const collections = signal([]);
|
|
17
|
+
const current = signal("");
|
|
18
|
+
const docs = signal([]);
|
|
19
|
+
const note = signal("");
|
|
20
|
+
|
|
21
|
+
async function loadCollections() {
|
|
22
|
+
const { status, body } = await j("/admin/db/collections");
|
|
23
|
+
if (status === 401) {
|
|
24
|
+
denied(true);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
denied(false);
|
|
28
|
+
driver(body.driver || "");
|
|
29
|
+
collections(body.collections || []);
|
|
30
|
+
ready(true);
|
|
31
|
+
if (!current() && collections().length) openCollection(collections()[0]);
|
|
32
|
+
}
|
|
33
|
+
async function openCollection(name) {
|
|
34
|
+
current(name);
|
|
35
|
+
note("");
|
|
36
|
+
const { body } = await j(`/admin/db/collection?name=${encodeURIComponent(name)}`);
|
|
37
|
+
docs(body.ok ? body.docs : []);
|
|
38
|
+
}
|
|
39
|
+
async function del(id) {
|
|
40
|
+
if (!id) return;
|
|
41
|
+
await j(`/admin/db/doc?name=${encodeURIComponent(current())}&id=${encodeURIComponent(id)}`, { method: "DELETE" });
|
|
42
|
+
docs(docs().filter((d) => d.id !== id));
|
|
43
|
+
note("Deleted.");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
loadCollections();
|
|
47
|
+
|
|
48
|
+
const collTab = (name) =>
|
|
49
|
+
html`<button class=${() => "btn btn-sm " + (current() === name ? "btn-primary" : "btn-outline-secondary")} onclick=${() => openCollection(name)}>${name}</button>`;
|
|
50
|
+
|
|
51
|
+
const docRow = (d) =>
|
|
52
|
+
html`<div class="d-flex justify-content-between align-items-start gap-2 py-1" style="border-top:1px solid #232a36">
|
|
53
|
+
<pre class="mb-0 small flex-grow-1" style="white-space:pre-wrap;color:#cfe3ff">${JSON.stringify(d, null, 2)}</pre>
|
|
54
|
+
<button class="btn btn-sm btn-outline-danger" onclick=${() => del(d.id)}>✕</button>
|
|
55
|
+
</div>`;
|
|
56
|
+
|
|
57
|
+
const heading = computed(() => `Data ${driver() ? `— ${driver()}` : ""}`);
|
|
58
|
+
|
|
59
|
+
return html`<div class="card-x p-4 mb-4">
|
|
60
|
+
<h2 class="h6 mb-3">${heading} <span class="text-muted small">— admin</span></h2>
|
|
61
|
+
${() =>
|
|
62
|
+
denied()
|
|
63
|
+
? html`<p class="text-muted small mb-0">Sign in to browse your data.</p>`
|
|
64
|
+
: !ready()
|
|
65
|
+
? html`<p class="text-muted small mb-0">Loading…</p>`
|
|
66
|
+
: html`<div class="d-flex flex-wrap gap-1 mb-2">${() => (collections().length ? collections().map(collTab) : html`<span class="text-muted small">No collections yet.</span>`)}</div>
|
|
67
|
+
<div style="max-height:260px;overflow:auto">
|
|
68
|
+
${() => (docs().length ? docs().map(docRow) : html`<span class="text-muted small">Empty.</span>`)}
|
|
69
|
+
</div>
|
|
70
|
+
${() => (note() ? html`<p class="small text-muted mb-0 mt-2">${note}</p>` : null)}`}
|
|
71
|
+
</div>`;
|
|
72
|
+
}
|
package/index.js
CHANGED
|
@@ -36,6 +36,7 @@ ${bold("Usage")}
|
|
|
36
36
|
npx create-volt <project-directory> [options]
|
|
37
37
|
npx create-volt@latest update # refresh public/volt.js in an existing app
|
|
38
38
|
npx create-volt@latest config # open the app's setup wizard (edit add-ons + settings)
|
|
39
|
+
npx create-volt@latest studio # browse your data — ephemeral, localhost (like Prisma Studio)
|
|
39
40
|
|
|
40
41
|
${bold("Options")}
|
|
41
42
|
--template <name> Starter template: default | guestbook (default: default)
|
|
@@ -131,6 +132,21 @@ if (positionals[0] === "config") {
|
|
|
131
132
|
process.exit(res.status ?? 0);
|
|
132
133
|
}
|
|
133
134
|
|
|
135
|
+
// --- `studio` subcommand: ephemeral, localhost-only data browser (server.js --studio) ---
|
|
136
|
+
if (positionals[0] === "studio") {
|
|
137
|
+
const cwd = process.cwd();
|
|
138
|
+
if (!fs.existsSync(path.join(cwd, "server.js"))) {
|
|
139
|
+
die(`No ${cyan("server.js")} here — run ${cyan("create-volt studio")} from inside a Volt app.`);
|
|
140
|
+
}
|
|
141
|
+
if (portArg) process.env.PORT = String(Number(portArg) || "");
|
|
142
|
+
const res = spawnSync(process.execPath, ["server.js", "--studio"], {
|
|
143
|
+
cwd,
|
|
144
|
+
stdio: "inherit",
|
|
145
|
+
env: flags.has("--no-open") ? { ...process.env, VOLT_NO_OPEN: "1" } : process.env,
|
|
146
|
+
});
|
|
147
|
+
process.exit(res.status ?? 0);
|
|
148
|
+
}
|
|
149
|
+
|
|
134
150
|
// Resolve the dev port: --port wins, else derive it from today's date as
|
|
135
151
|
// two-digit-year + month (no leading zero) + two-digit-day (house convention),
|
|
136
152
|
// so apps scaffolded on different days don't collide on the same port.
|
package/package.json
CHANGED
|
@@ -299,9 +299,95 @@ function readEnvFileLines() {
|
|
|
299
299
|
return fs.existsSync(ENV_PATH) ? fs.readFileSync(ENV_PATH, "utf8").split("\n") : [];
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
// ---
|
|
302
|
+
// --- Studio: an ephemeral, localhost-only data browser (à la Prisma Studio).
|
|
303
|
+
// Not a route in the running app — it only exists while you run `--studio`, on
|
|
304
|
+
// loopback, and disappears on Ctrl-C. Shell/SSH access is the auth. ---
|
|
305
|
+
const HIDDEN_COLLECTIONS = new Set(["auth_tokens", "auth_sessions", "__voltcheck"]);
|
|
306
|
+
async function startStudio() {
|
|
307
|
+
loadEnv();
|
|
308
|
+
if (!enabledFrom(process.env).has("db")) {
|
|
309
|
+
console.error("Studio needs the db add-on. Enable it: npm run dev -- --edit");
|
|
310
|
+
process.exit(1);
|
|
311
|
+
}
|
|
312
|
+
let store;
|
|
313
|
+
try {
|
|
314
|
+
store = await (await addonMod("db")).createStore();
|
|
315
|
+
} catch (e) {
|
|
316
|
+
console.error("Studio: couldn't connect the store — " + e.message);
|
|
317
|
+
process.exit(1);
|
|
318
|
+
}
|
|
319
|
+
const PORT = Number(process.env.PORT) || Number(readEnvFile().PORT) || DEFAULT_PORT;
|
|
320
|
+
const visible = (n) => n && !HIDDEN_COLLECTIONS.has(n);
|
|
321
|
+
const assets = {
|
|
322
|
+
"/volt.js": ["text/javascript; charset=utf-8", fs.readFileSync(path.join(__dirname, "public", "volt.js"))],
|
|
323
|
+
"/db-admin-ui.js": ["text/javascript; charset=utf-8", fs.readFileSync(path.join(ADDONS_DIR, "db", "files", "public", "db-admin-ui.js"))],
|
|
324
|
+
};
|
|
325
|
+
const studioHtml = fs.readFileSync(path.join(__dirname, "setup", "studio.html"));
|
|
326
|
+
const json = (res, code, obj) => {
|
|
327
|
+
res.statusCode = code;
|
|
328
|
+
res.setHeader("Content-Type", "application/json");
|
|
329
|
+
res.end(JSON.stringify(obj));
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
const server = http.createServer(async (req, res) => {
|
|
333
|
+
const u = new URL(req.url, "http://localhost");
|
|
334
|
+
const p = u.pathname;
|
|
335
|
+
try {
|
|
336
|
+
if (req.method === "GET" && p === "/") {
|
|
337
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
338
|
+
return res.end(studioHtml);
|
|
339
|
+
}
|
|
340
|
+
if (req.method === "GET" && assets[p]) {
|
|
341
|
+
res.setHeader("Content-Type", assets[p][0]);
|
|
342
|
+
return res.end(assets[p][1]);
|
|
343
|
+
}
|
|
344
|
+
if (req.method === "GET" && p === "/admin/db/collections") {
|
|
345
|
+
const all = (await store.collections()) || [];
|
|
346
|
+
return json(res, 200, { driver: store.name, collections: all.filter(visible) });
|
|
347
|
+
}
|
|
348
|
+
if (req.method === "GET" && p === "/admin/db/collection") {
|
|
349
|
+
const name = u.searchParams.get("name") || "";
|
|
350
|
+
if (!visible(name)) return json(res, 403, { ok: false, error: "hidden" });
|
|
351
|
+
const docs = (await store.collection(name).all()).slice(0, 500);
|
|
352
|
+
return json(res, 200, { ok: true, name, docs });
|
|
353
|
+
}
|
|
354
|
+
if (req.method === "DELETE" && p === "/admin/db/doc") {
|
|
355
|
+
const name = u.searchParams.get("name") || "";
|
|
356
|
+
const id = u.searchParams.get("id") || "";
|
|
357
|
+
if (!visible(name)) return json(res, 403, { ok: false, error: "hidden" });
|
|
358
|
+
if (!id) return json(res, 400, { ok: false, error: "missing id" });
|
|
359
|
+
await store.collection(name).delete(id);
|
|
360
|
+
return json(res, 200, { ok: true });
|
|
361
|
+
}
|
|
362
|
+
res.statusCode = 404;
|
|
363
|
+
res.end("not found");
|
|
364
|
+
} catch (e) {
|
|
365
|
+
json(res, 500, { ok: false, error: e.message });
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
server.listen(PORT, "127.0.0.1", () => {
|
|
370
|
+
const url = `http://localhost:${PORT}`;
|
|
371
|
+
console.log(`\n⚡ Volt Studio → ${url} (${store.name})`);
|
|
372
|
+
console.log(" Browse your data. localhost-only, disposable — Ctrl-C when done.");
|
|
373
|
+
const ssh = process.env.SSH_CONNECTION;
|
|
374
|
+
if (ssh) {
|
|
375
|
+
const host = ssh.split(" ")[2];
|
|
376
|
+
const user = process.env.USER || process.env.USERNAME || "you";
|
|
377
|
+
console.log(" Remote box — from your LOCAL machine:");
|
|
378
|
+
console.log(` ssh -N -L 127.0.0.1:${PORT}:localhost:${PORT} ${user}@${host}`);
|
|
379
|
+
console.log(` …then open ${url}.`);
|
|
380
|
+
}
|
|
381
|
+
console.log("");
|
|
382
|
+
openBrowser(url);
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// --- gate: studio / setup (first run, --edit) / the app ---
|
|
303
387
|
const editMode = process.argv.includes("--edit") || process.argv.includes("-e");
|
|
304
|
-
if (
|
|
388
|
+
if (process.argv.includes("--studio")) {
|
|
389
|
+
startStudio();
|
|
390
|
+
} else if (editMode || !fs.existsSync(ENV_PATH)) {
|
|
305
391
|
startSetup();
|
|
306
392
|
} else {
|
|
307
393
|
loadEnv();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>Volt Studio</title>
|
|
7
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
|
|
8
|
+
<style>
|
|
9
|
+
body { background: #0f1115; color: #e7e9ee; }
|
|
10
|
+
.accent { color: #ffd24a; }
|
|
11
|
+
.card-x { background: #161a22; border: 1px solid #232a36; border-radius: 14px; }
|
|
12
|
+
</style>
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<main class="container py-5" style="max-width: 820px;">
|
|
16
|
+
<header class="mb-4">
|
|
17
|
+
<h1 class="h3"><span class="accent">⚡ Volt Studio</span> <small class="text-muted">data browser</small></h1>
|
|
18
|
+
<p class="text-muted mb-0">Browse the database in your <code>.env</code>. Disposable & localhost-only — close the terminal when done.</p>
|
|
19
|
+
</header>
|
|
20
|
+
<div id="app"></div>
|
|
21
|
+
</main>
|
|
22
|
+
<script type="module">
|
|
23
|
+
import { mount } from "/volt.js";
|
|
24
|
+
import { dbAdminPanel } from "/db-admin-ui.js";
|
|
25
|
+
mount("#app", dbAdminPanel());
|
|
26
|
+
</script>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|