spfn 0.2.0-beta.67 → 0.2.0-beta.68
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 +46 -4
- package/dist/index.js +349 -455
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -24,8 +24,8 @@ pnpm dlx spfn@beta <command>
|
|
|
24
24
|
Or add it as a project dependency (`spfn init`/`spfn create` do this for you), then
|
|
25
25
|
call it via `pnpm spfn <command>` / `npm run spfn:<script>`.
|
|
26
26
|
|
|
27
|
-
Requirements: Node.js
|
|
28
|
-
|
|
27
|
+
Requirements: Node.js 20+ in both modes, Next.js 16.2.11+ (App Router, `src/` dir),
|
|
28
|
+
PostgreSQL 14+ (Redis optional). Next.js 15
|
|
29
29
|
is not supported — see [the root README](../../README.md#what-do-i-need-installed).
|
|
30
30
|
|
|
31
31
|
## Usage
|
|
@@ -137,9 +137,13 @@ no pre-build needed.
|
|
|
137
137
|
| `-p, --port <port>` | Server port | from `server.config.ts` / env (`4000` in server-only fallback) |
|
|
138
138
|
| `-H, --host <host>` | Server host | `localhost` |
|
|
139
139
|
| `--routes <path>` | Routes directory path | server default |
|
|
140
|
+
| `--allow-pending-migrations` | Start even when migrations are pending (they are listed as a warning) | off |
|
|
140
141
|
|
|
141
142
|
Note: hot reload is **off by default** — pass `--watch` to restart on file changes.
|
|
142
143
|
|
|
144
|
+
Pending migrations stop the boot — see [Database](#spfn-db) for what the refusal looks
|
|
145
|
+
like and how to override it.
|
|
146
|
+
|
|
143
147
|
### `spfn build`
|
|
144
148
|
|
|
145
149
|
Runs codegen, builds Next.js (via the project's `build` script), and compiles
|
|
@@ -163,9 +167,14 @@ if `.spfn/server`, `.spfn/prod-server.mjs`, or `.next` are missing.
|
|
|
163
167
|
| `--next-only` | Run only Next.js | off |
|
|
164
168
|
| `-p, --port <port>` | SPFN server port (sets `SPFN_PORT`) | `8790` |
|
|
165
169
|
| `-h, --host <host>` | SPFN server host (sets `SPFN_HOST`) | `0.0.0.0` |
|
|
170
|
+
| `--allow-pending-migrations` | Start even when migrations are pending (they are listed as a warning) | off |
|
|
166
171
|
|
|
167
172
|
Next.js is started on `0.0.0.0:3790`. Both run together via `concurrently --kill-others`.
|
|
168
173
|
|
|
174
|
+
Pending migrations stop the boot unless `--allow-pending-migrations` or
|
|
175
|
+
`SPFN_ALLOW_PENDING_MIGRATIONS=true` is set — see [Database](#spfn-db). `--next-only`
|
|
176
|
+
skips the check: no SPFN server starts, so nothing can drift.
|
|
177
|
+
|
|
169
178
|
### `spfn codegen`
|
|
170
179
|
|
|
171
180
|
Manages code generators driven by `.spfnrc.ts`. The default generator is
|
|
@@ -259,6 +268,27 @@ loaded `.env` chain.
|
|
|
259
268
|
> `db push` is for development. For production, use `db generate` + `db migrate` to keep
|
|
260
269
|
> migration history.
|
|
261
270
|
|
|
271
|
+
**A server refuses to start while migrations are pending.** Bumping `@spfn/auth` and
|
|
272
|
+
skipping `db migrate` used to boot fine, pass the health check, and then fail every
|
|
273
|
+
request that touched a new column as an opaque 500. `spfn dev` and `spfn start` now
|
|
274
|
+
compare the migrations each installed function package ships (and `src/server/drizzle`,
|
|
275
|
+
where present) against what the database records as applied, print the ones still
|
|
276
|
+
waiting, and stop:
|
|
277
|
+
|
|
278
|
+
```
|
|
279
|
+
❌ Refusing to start: 1 pending migration(s) in @spfn/auth
|
|
280
|
+
@spfn/auth: 1 pending migration(s) (12/13 applied)
|
|
281
|
+
- 20260805143152_client_identity
|
|
282
|
+
|
|
283
|
+
Run: pnpm spfn db migrate
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
`--allow-pending-migrations` starts anyway and logs the same list as a warning.
|
|
287
|
+
`SPFN_ALLOW_PENDING_MIGRATIONS=true` does the same where no flag can be passed — a
|
|
288
|
+
container's env, a CI job. The check is skipped when the app initializes no database
|
|
289
|
+
or no package ships migrations, and a database it cannot reach is reported as
|
|
290
|
+
"could not verify", never as drift.
|
|
291
|
+
|
|
262
292
|
`db push` and `db migrate` also replay migrations shipped by installed SPFN function
|
|
263
293
|
packages (`@spfn/auth`, `@spfn/cms`, …) into per-package tracking tables
|
|
264
294
|
(`drizzle.__spfn_fn_<pkg>_migrations`). The CLI applies these with a built-in runner
|
|
@@ -487,6 +517,18 @@ Run migrations against the target DB before/with deploy:
|
|
|
487
517
|
docker exec <container> npx spfn db migrate
|
|
488
518
|
```
|
|
489
519
|
|
|
520
|
+
Forget, and the container will not come up: the server refuses to serve while migrations
|
|
521
|
+
are pending and prints which ones. That is the intended failure — a deploy that stops at
|
|
522
|
+
the gate is one that never served the 500s. If a rollout has to proceed anyway, set
|
|
523
|
+
`SPFN_ALLOW_PENDING_MIGRATIONS=true` in the container's environment; the pending list is
|
|
524
|
+
logged as a warning instead.
|
|
525
|
+
|
|
526
|
+
A readiness probe can catch the same drift on a cluster the local gate never sees. When
|
|
527
|
+
detailed health is on, `GET /health` carries a `migrations` object with per-package
|
|
528
|
+
applied/pending counts — assert `migrations.pending === 0` in the probe to hold a
|
|
529
|
+
drifted pod out of rotation. Reporting drift does not, by itself, change the overall
|
|
530
|
+
health `status`.
|
|
531
|
+
|
|
490
532
|
`spfn.config.js` (committed) configures the managed `*.spfn.app` deployment: `subdomain`,
|
|
491
533
|
`region` (`us` default, `kr`, …), `customDomains`, and non-secret `env`. Its `SpfnConfig`
|
|
492
534
|
type ships from `spfn` (`@type {import('spfn').SpfnConfig}`).
|
|
@@ -516,8 +558,8 @@ and `docker compose up -d` is also the convenient way to get PostgreSQL and Redi
|
|
|
516
558
|
pointing at your own PostgreSQL works too. PostgreSQL itself is not optional.
|
|
517
559
|
|
|
518
560
|
**Which Node version do I need?**
|
|
519
|
-
|
|
520
|
-
MCP server.
|
|
561
|
+
20 or later, in both modes. `@spfn/core` runs on `@hono/node-server` 2, which declares
|
|
562
|
+
that floor, and full mode's MCP server needs the same.
|
|
521
563
|
|
|
522
564
|
**When do I have to run codegen by hand?**
|
|
523
565
|
Whenever routes change outside `spfn dev`, which runs a codegen watcher for you. A stale or
|