create-wervt 0.2.19 → 0.2.21
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/index.js +2 -2
- package/package.json +1 -1
- package/template/AGENTS.md +20 -3
- package/template/app.vue +1 -35
- package/template/package.json +4 -3
- package/template/pages/index.vue +37 -0
package/index.js
CHANGED
|
@@ -42,7 +42,7 @@ const EMPTY_SCHEMA = `// Tables are declared without a schema: on wervt the app'
|
|
|
42
42
|
// })
|
|
43
43
|
export {}
|
|
44
44
|
`
|
|
45
|
-
const
|
|
45
|
+
const EMPTY_PAGE = `<template>
|
|
46
46
|
<main>
|
|
47
47
|
<h1>Hello from wervt</h1>
|
|
48
48
|
</main>
|
|
@@ -134,7 +134,7 @@ const main = defineCommand({
|
|
|
134
134
|
if (args.empty) {
|
|
135
135
|
for (const file of EXAMPLE_FILES) await rm(join(dir, file), { recursive: true, force: true })
|
|
136
136
|
await writeFile(join(dir, 'server/db/schema.ts'), EMPTY_SCHEMA)
|
|
137
|
-
await writeFile(join(dir, '
|
|
137
|
+
await writeFile(join(dir, 'pages/index.vue'), EMPTY_PAGE)
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
const pkgPath = join(dir, 'package.json')
|
package/package.json
CHANGED
package/template/AGENTS.md
CHANGED
|
@@ -6,7 +6,8 @@ Supabase Edge Runtime) with its own Postgres schema and live data through Electr
|
|
|
6
6
|
|
|
7
7
|
## Layout
|
|
8
8
|
|
|
9
|
-
- `
|
|
9
|
+
- `pages/`: one route per file, `pages/index.vue` is `/`. `app.vue` is the shell around every page
|
|
10
|
+
(`<NuxtPage />`, wrapped in `<UApp>` with Nuxt UI). `components/`: the Vue components.
|
|
10
11
|
- `server/api/`: API routes. `server/api/shapes/`: live data routes.
|
|
11
12
|
- `server/tools/`: tools that AI agents can call: in the browser (WebMCP) and at `/mcp` (MCP).
|
|
12
13
|
API routes become tools with `defineToolRoute`.
|
|
@@ -114,6 +115,10 @@ const rows = await useDb().select().from(todos).where(eq(todos.done, false))
|
|
|
114
115
|
schema** (no `pgSchema`): the app's role only sees its own schema.
|
|
115
116
|
- After changing `server/db/schema.ts`, run `pnpm db:generate` and commit the new folder in
|
|
116
117
|
`drizzle/`. Never edit generated migrations. Migrations run on deploy and on `nuxt dev`.
|
|
118
|
+
- Renaming a table or column in the schema can generate a `DROP` and a new one. Check the generated
|
|
119
|
+
SQL for `DROP TABLE`, `DROP COLUMN` and `TRUNCATE`. `wervt deploy` refuses migrations that would
|
|
120
|
+
delete rows and prints the `--allow-drop TABLE=ROWS` command to deploy anyway; run it only when
|
|
121
|
+
losing that data is intended, never just to get the deploy through.
|
|
117
122
|
- Don't read `DATABASE_URL` yourself and don't create other clients. Use `useDb()`.
|
|
118
123
|
- For relational queries (`db.query.rooms.findFirst({ with: … })`), define relations with
|
|
119
124
|
`defineRelations` in `server/db/relations.ts` and use `useDb({ relations })`.
|
|
@@ -190,8 +195,11 @@ version polling. For a banner in the app's own design, set `wervt: { updates: 'm
|
|
|
190
195
|
apps only when the visitor signed in. It works with `ssr: false` too (no own `/api/me` needed). Link to `wervtLoginUrl(path)` / `wervtLogoutUrl(path)` as
|
|
191
196
|
external links. Never build your own login or OAuth.
|
|
192
197
|
- Name, picture and email change on wervt's account page: link to `wervtAccountUrl(path)`
|
|
193
|
-
(external), which shows it in the app's look and comes back.
|
|
194
|
-
|
|
198
|
+
(external), which shows it in the app's look and comes back. Keep app-only profile data (bio,
|
|
199
|
+
display name) in the app's tables under `user.id`. Only if an admin allowed the app the profile
|
|
200
|
+
API (dashboard, the app's Access page) may it change name and picture itself, with
|
|
201
|
+
`useWervtProfile(event).setName(name)` / `.setImage(bytes)` / `.removeImage()` from
|
|
202
|
+
`@wervt/nuxt/server`. The email address always stays on the account page.
|
|
195
203
|
- Users are one row per wervt account: key them by `user.id`, not by email (addresses change).
|
|
196
204
|
When an admin merges two accounts of the same person, wervt runs the task
|
|
197
205
|
`wervt:account-merged` (`server/tasks/wervt/account-merged.ts`) with
|
|
@@ -202,6 +210,10 @@ version polling. For a banner in the app's own design, set `wervt: { updates: 'm
|
|
|
202
210
|
`allowed` or `public`. Guard the app's admin features with
|
|
203
211
|
`requireWervtRole(event, 'owner', 'member', 'admin')` from `@wervt/nuxt/server`; don't keep
|
|
204
212
|
admin emails in env variables.
|
|
213
|
+
- Under `pnpm dev`, `/_wervt/login` signs in the dev user (the app's owner).
|
|
214
|
+
`/_wervt/login?as=alice&role=member&redirect=/` signs in another user with a role instead: test
|
|
215
|
+
role checks and multi-user flows with one persona per browser context (Playwright), e.g. `alice`
|
|
216
|
+
as `member` and `bob` as `public`. Plain `/_wervt/login` switches back.
|
|
205
217
|
- Private apps show a link preview to visitors without a login (chats unfurling a shared link):
|
|
206
218
|
only the app name and icon unless `wervt: { preview: { title, description, image: '/og.png' } }`
|
|
207
219
|
is set (`true` takes them from `app.head`; `false` turns it off). Put the image (1200×630) in
|
|
@@ -484,6 +496,11 @@ Queries are LogsQL. Logs may contain user data: quote only what's needed.
|
|
|
484
496
|
- Deploys: pushing to `main` deploys through `.github/workflows/deploy.yml`.
|
|
485
497
|
`pnpm exec wervt releases <app>` lists releases with their commits. Don't deploy, roll back or
|
|
486
498
|
create deploy tokens unless asked.
|
|
499
|
+
- Data of the deployed app: `pnpm exec wervt db sql <app> "select …"` runs one read-only
|
|
500
|
+
statement, `pnpm exec wervt db export <app> --out before.json` dumps the tables (`--format sql`
|
|
501
|
+
for inserts), and `pnpm exec wervt storage list|get|put <app> …` works with the app's files.
|
|
502
|
+
Export before changes that touch data. Don't run `db sql --write`, `storage put` over existing
|
|
503
|
+
files or `storage delete` unless asked.
|
|
487
504
|
- Pull requests get a preview at `https://<app>--pr-<number>.wervt.app`
|
|
488
505
|
(`.github/workflows/preview.yml`), deleted when the pull request closes. It has its own empty
|
|
489
506
|
database (seed it with `pnpm exec wervt tasks <app>--pr-<number> --run db:seed`), the app's
|
package/template/app.vue
CHANGED
|
@@ -1,37 +1,3 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { Todo } from './server/db/schema'
|
|
3
|
-
|
|
4
|
-
// Rows arrive with SSR and then stay live: every write below shows up here (and in every
|
|
5
|
-
// other open tab) through Electric, so there is nothing to refetch.
|
|
6
|
-
const { data, isLive } = await useShape('/api/shapes/todos')
|
|
7
|
-
const todos = computed(() => data.value.toSorted((a, b) => a.id - b.id))
|
|
8
|
-
const title = ref('')
|
|
9
|
-
|
|
10
|
-
async function add() {
|
|
11
|
-
await $fetch('/api/todos', { method: 'POST', body: { title: title.value } })
|
|
12
|
-
title.value = ''
|
|
13
|
-
}
|
|
14
|
-
const toggle = (todo: Todo) =>
|
|
15
|
-
$fetch(`/api/todos/${todo.id}`, { method: 'PATCH', body: { done: !todo.done } })
|
|
16
|
-
const remove = (todo: Todo) => $fetch(`/api/todos/${todo.id}`, { method: 'DELETE' })
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
1
|
<template>
|
|
20
|
-
<
|
|
21
|
-
<h1>Todos</h1>
|
|
22
|
-
<p>{{ isLive ? 'Live' : 'Connecting…' }}</p>
|
|
23
|
-
<form @submit.prevent="add">
|
|
24
|
-
<input v-model="title" placeholder="What needs doing?" required />
|
|
25
|
-
<button>Add</button>
|
|
26
|
-
</form>
|
|
27
|
-
<ul>
|
|
28
|
-
<li v-for="todo in todos" :key="todo.id">
|
|
29
|
-
<label>
|
|
30
|
-
<input type="checkbox" :checked="todo.done" @change="toggle(todo)" />
|
|
31
|
-
{{ todo.title }}
|
|
32
|
-
</label>
|
|
33
|
-
<button @click="remove(todo)">Delete</button>
|
|
34
|
-
</li>
|
|
35
|
-
</ul>
|
|
36
|
-
</main>
|
|
2
|
+
<NuxtPage />
|
|
37
3
|
</template>
|
package/template/package.json
CHANGED
|
@@ -10,15 +10,16 @@
|
|
|
10
10
|
"postinstall": "nuxt prepare"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@wervt/nuxt": "^0.3.
|
|
13
|
+
"@wervt/nuxt": "^0.3.26",
|
|
14
14
|
"drizzle-orm": "1.0.0-rc.5",
|
|
15
15
|
"nuxt": "npm:nuxt-nightly@5x",
|
|
16
16
|
"valibot": "^1.5.0",
|
|
17
|
-
"vue": "^3.5.
|
|
17
|
+
"vue": "^3.5.45",
|
|
18
|
+
"vue-router": "^5.5.1"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@golar/vue": "^0.1.11",
|
|
21
|
-
"@wervt/cli": "^0.2.
|
|
22
|
+
"@wervt/cli": "^0.2.31",
|
|
22
23
|
"drizzle-kit": "1.0.0-rc.5",
|
|
23
24
|
"golar": "^0.1.11",
|
|
24
25
|
"vite-plus": "^1.3.0"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Todo } from '../server/db/schema'
|
|
3
|
+
|
|
4
|
+
// Rows arrive with SSR and then stay live: every write below shows up here (and in every
|
|
5
|
+
// other open tab) through Electric, so there is nothing to refetch.
|
|
6
|
+
const { data, isLive } = await useShape('/api/shapes/todos')
|
|
7
|
+
const todos = computed(() => data.value.toSorted((a, b) => a.id - b.id))
|
|
8
|
+
const title = ref('')
|
|
9
|
+
|
|
10
|
+
async function add() {
|
|
11
|
+
await $fetch('/api/todos', { method: 'POST', body: { title: title.value } })
|
|
12
|
+
title.value = ''
|
|
13
|
+
}
|
|
14
|
+
const toggle = (todo: Todo) =>
|
|
15
|
+
$fetch(`/api/todos/${todo.id}`, { method: 'PATCH', body: { done: !todo.done } })
|
|
16
|
+
const remove = (todo: Todo) => $fetch(`/api/todos/${todo.id}`, { method: 'DELETE' })
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<main>
|
|
21
|
+
<h1>Todos</h1>
|
|
22
|
+
<p>{{ isLive ? 'Live' : 'Connecting…' }}</p>
|
|
23
|
+
<form @submit.prevent="add">
|
|
24
|
+
<input v-model="title" placeholder="What needs doing?" required />
|
|
25
|
+
<button>Add</button>
|
|
26
|
+
</form>
|
|
27
|
+
<ul>
|
|
28
|
+
<li v-for="todo in todos" :key="todo.id">
|
|
29
|
+
<label>
|
|
30
|
+
<input type="checkbox" :checked="todo.done" @change="toggle(todo)" />
|
|
31
|
+
{{ todo.title }}
|
|
32
|
+
</label>
|
|
33
|
+
<button @click="remove(todo)">Delete</button>
|
|
34
|
+
</li>
|
|
35
|
+
</ul>
|
|
36
|
+
</main>
|
|
37
|
+
</template>
|