create-wervt 0.2.16 → 0.2.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-wervt",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "Create a new wervt app: Nuxt 5, Postgres with Drizzle, live data with Electric.",
5
5
  "homepage": "https://wervt.app",
6
6
  "license": "MIT",
@@ -20,6 +20,8 @@ pnpm exec wervt logs <app> # last hour, oldest f
20
20
  pnpm exec wervt logs <app> 'level:error' --since 1d --json # every field, one JSON object per line
21
21
  pnpm exec wervt logs <app> 'status:>=500' --since 6h --limit 50 --json
22
22
  pnpm exec wervt logs <app> -f # follow while reproducing
23
+ pnpm exec wervt logs <app> --requests --since 1h # one line per request (requestId)
24
+ pnpm exec wervt queries <app> # saved queries; run one with --saved <name>
23
25
  ```
24
26
 
25
27
  The app name is the `name` in package.json. Prefer `--json` and a narrow query: the output goes into
@@ -27,18 +29,18 @@ your context, so ask for what you need (`--limit`, `--since`, filters) instead o
27
29
 
28
30
  ## Fields
29
31
 
30
- | Field | From | |
31
- | ---------------------------------------------- | ------- | ------------------------------------------------------------- |
32
- | `_time`, `_msg` | wervt | Time and the line (`GET /api/x 500` for requests) |
33
- | `level` | wervt | `error`, `warn`, `info`, `debug`. 4xx requests are `warn` |
34
- | `type` | wervt | `log`, `Boot`, `BootFailure`, `UncaughtException`, `Shutdown` |
35
- | `release` | wervt | Which deploy wrote it |
36
- | `execution_id` | wervt | One isolate's lifetime (boot to shutdown) |
37
- | `reason` | wervt | Shutdowns: `CPUTime`, `Memory` (killed) or idle ones |
38
- | `method`, `path`, `status` | evlog | The request |
39
- | `duration`, `requestId` | evlog | Timing and the id to correlate with |
40
- | `error.message`, `error.stack`, `error.status` | evlog | Why it failed |
41
- | anything else | the app | Set with `useLogger(event).set({...})`, e.g. `user.id` |
32
+ | Field | From | |
33
+ | ---------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
34
+ | `_time`, `_msg` | wervt | Time and the line (`GET /api/x 500` for requests) |
35
+ | `level` | wervt | `error`, `warn`, `info`, `debug`. 4xx requests are `warn` |
36
+ | `type` | wervt | `log`, `Boot`, `BootFailure`, `UncaughtException`, `Shutdown`, `Runtime` (the runtime couldn't hand a request to the app), `Alert`, `Task` |
37
+ | `release` | wervt | Which deploy wrote it |
38
+ | `execution_id` | wervt | One isolate's lifetime (boot to shutdown) |
39
+ | `reason` | wervt | Shutdowns: `CPUTime`, `Memory` (killed) or idle ones |
40
+ | `method`, `path`, `status` | evlog | The request |
41
+ | `duration`, `requestId` | evlog | Timing and the id to correlate with |
42
+ | `error.message`, `error.stack`, `error.status` | evlog | Why it failed |
43
+ | anything else | the app | Set with `useLogger(event).set({...})`, e.g. `user.id` |
42
44
 
43
45
  ## Queries (LogsQL)
44
46
 
@@ -61,7 +63,8 @@ https://docs.victoriametrics.com/victorialogs/logsql/
61
63
 
62
64
  1. Start broad and recent: `'level:error' --since 1d --json --limit 20`. Note `release` and
63
65
  `_time` of the first occurrence: did it start with a deploy (`pnpm exec wervt releases <app>`)?
64
- 2. Narrow to the failing route (`path:`), then to one request (`requestId:=`), and read
66
+ 2. Narrow to the failing route (`path:`). `--requests` lists requests with their error counts;
67
+ take one request (`requestId:=`) and read
65
68
  `error.stack`. Stack lines point into the built server, so map them back to the source by the
66
69
  function names and the route.
67
70
  3. `UncaughtException` or `Shutdown` with `reason` `CPUTime` / `Memory`: work outside a request's
@@ -0,0 +1,67 @@
1
+ name: preview
2
+
3
+ # Deploys every pull request to its own preview, <app>--pr-<number>, and deletes it once the pull
4
+ # request is closed or merged. Uses the same WERVT_TOKEN and WERVT_URL as deploy.yml. A preview
5
+ # starts with an empty database, lets in who the app lets in and gets the app's env, with the
6
+ # preview env on top (`wervt env <app> --preview --set KEY=value`, or Preview variables in the
7
+ # dashboard). The pull request shows the preview's URL under Deployments.
8
+
9
+ on:
10
+ pull_request:
11
+ types: [opened, reopened, synchronize, closed]
12
+
13
+ # One run per pull request; a newer push or the close replaces a deploy still running.
14
+ concurrency:
15
+ group: preview-${{ github.event.pull_request.number }}
16
+ cancel-in-progress: true
17
+
18
+ permissions:
19
+ contents: read
20
+
21
+ jobs:
22
+ deploy:
23
+ # Pull requests from forks get no secrets, and their code shouldn't get the app's env anyway.
24
+ if: github.event.action != 'closed' && github.event.pull_request.head.repo.full_name == github.repository
25
+ runs-on: ubuntu-latest
26
+ environment:
27
+ name: preview
28
+ url: ${{ steps.deploy.outputs.url }}
29
+ steps:
30
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31
+
32
+ # The pnpm version comes from packageManager in package.json.
33
+ - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
34
+
35
+ - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
36
+ with:
37
+ node-version: 24
38
+ cache: pnpm
39
+
40
+ - run: pnpm install --frozen-lockfile
41
+
42
+ - id: deploy
43
+ run: pnpm exec wervt deploy --preview pr-${{ github.event.pull_request.number }}
44
+ env:
45
+ WERVT_URL: ${{ vars.WERVT_URL }}
46
+ WERVT_TOKEN: ${{ secrets.WERVT_TOKEN }}
47
+
48
+ remove:
49
+ if: github.event.action == 'closed' && github.event.pull_request.head.repo.full_name == github.repository
50
+ runs-on: ubuntu-latest
51
+ steps:
52
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
53
+
54
+ - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
55
+
56
+ - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
57
+ with:
58
+ node-version: 24
59
+ cache: pnpm
60
+
61
+ - run: pnpm install --frozen-lockfile
62
+
63
+ # Drops the preview's database and files too. A preview that never deployed is fine.
64
+ - run: pnpm exec wervt delete --preview pr-${{ github.event.pull_request.number }} --yes || true
65
+ env:
66
+ WERVT_URL: ${{ vars.WERVT_URL }}
67
+ WERVT_TOKEN: ${{ secrets.WERVT_TOKEN }}
@@ -186,6 +186,12 @@ version polling. For a banner in the app's own design, set `wervt: { updates: 'm
186
186
  auto-imported) give the signed-in wervt user or nothing. Private apps always have one; public
187
187
  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
188
188
  external links. Never build your own login or OAuth.
189
+ - Users are one row per wervt account: key them by `user.id`, not by email (addresses change).
190
+ When an admin merges two accounts of the same person, wervt runs the task
191
+ `wervt:account-merged` (`server/tasks/wervt/account-merged.ts`) with
192
+ `{ from: { id, email }, into: { id, email } }` (type `AccountMergedPayload`). Apps with their
193
+ own users table define it and move `from`'s rows to `into`, merging where both have one (e.g.
194
+ membership in the same room). Make it idempotent: it can be run again by hand.
189
195
  - `user.role` is what they are to the app: `owner`, `member`, `admin` (wervt), `invited`,
190
196
  `allowed` or `public`. Guard the app's admin features with
191
197
  `requireWervtRole(event, 'owner', 'member', 'admin')` from `@wervt/nuxt/server`; don't keep
@@ -467,6 +473,12 @@ Queries are LogsQL. Logs may contain user data: quote only what's needed.
467
473
  - Deploys: pushing to `main` deploys through `.github/workflows/deploy.yml`.
468
474
  `pnpm exec wervt releases <app>` lists releases with their commits. Don't deploy, roll back or
469
475
  create deploy tokens unless asked.
476
+ - Pull requests get a preview at `https://<app>--pr-<number>.wervt.app`
477
+ (`.github/workflows/preview.yml`), deleted when the pull request closes. It has its own empty
478
+ database (seed it with `pnpm exec wervt tasks <app>--pr-<number> --run db:seed`), the app's
479
+ access rules and env, with preview-only values on top:
480
+ `pnpm exec wervt env <app> --preview --set NUXT_<KEY>=…` (from the previews' next deploy).
481
+ Test changes on a preview instead of deploying them to production.
470
482
 
471
483
  ## Checking the deployed app
472
484
 
@@ -10,7 +10,7 @@
10
10
  "postinstall": "nuxt prepare"
11
11
  },
12
12
  "dependencies": {
13
- "@wervt/nuxt": "^0.3.4",
13
+ "@wervt/nuxt": "^0.3.11",
14
14
  "drizzle-orm": "1.0.0-rc.5",
15
15
  "nuxt": "npm:nuxt-nightly@5x",
16
16
  "valibot": "^1.5.0",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "devDependencies": {
20
20
  "@golar/vue": "^0.1.11",
21
- "@wervt/cli": "^0.2.16",
21
+ "@wervt/cli": "^0.2.19",
22
22
  "drizzle-kit": "1.0.0-rc.5",
23
23
  "golar": "^0.1.11",
24
24
  "vite-plus": "^1.3.0"