@pracht/cli 1.4.0 → 1.5.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 CHANGED
@@ -1,5 +1,62 @@
1
1
  # @pracht/cli
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#153](https://github.com/JoviDeCroock/pracht/pull/153) [`39860bd`](https://github.com/JoviDeCroock/pracht/commit/39860bd31e8559916d8f81ffa6122ac4cf1cffd1) Thanks [@JoviDeCroock](https://github.com/JoviDeCroock)! - **Breaking:** Middleware is now wrap-around (Hono/Koa/Astro shape). The
8
+ `MiddlewareFn` signature changes from `(args) => MiddlewareResult` to
9
+ `(args, next) => Promise<Response>`.
10
+
11
+ ```ts
12
+ // Before
13
+ export const middleware: MiddlewareFn = async ({ request }) => {
14
+ if (!hasSession(request)) return { redirect: "/login" };
15
+ return { context: { user: "jovi" } };
16
+ };
17
+
18
+ // After
19
+ import { redirect, type MiddlewareFn } from "@pracht/core";
20
+
21
+ export const middleware: MiddlewareFn = async (
22
+ { context, request },
23
+ next
24
+ ) => {
25
+ if (!hasSession(request)) return redirect("/login");
26
+ (context as { user?: string }).user = "jovi";
27
+ return next();
28
+ };
29
+ ```
30
+
31
+ Why: middleware can now wrap `try / catch / finally` around the rest of the
32
+ request, which is the standard shape for tracing, logging, and observability
33
+ libraries (Honeycomb, OpenTelemetry, Sentry). It also matches what users
34
+ arriving from honox / Hono / Astro / SvelteKit / Koa expect.
35
+
36
+ Migration notes:
37
+
38
+ - Replace `return { redirect: "/path" }` with `return redirect("/path")`
39
+ using the new `redirect` helper exported from `@pracht/core`.
40
+ - Replace `return { context: { ... } }` with direct mutation of
41
+ `args.context`. Context is shared by reference between middleware and
42
+ the loader/handler.
43
+ - Replace bare `return` (continue) with `return next()`.
44
+ - Middleware that returns a `Response` directly still works as a
45
+ short-circuit.
46
+ - The `MiddlewareResult` type is removed; `MiddlewareNext` is exported.
47
+ - One `AbortSignal` is now shared per request across all middleware and
48
+ the loader/handler instead of a fresh 30s timer per phase. This makes
49
+ long-running middleware count toward the same overall budget as the
50
+ loader/handler, which matches how most users reason about per-request
51
+ timeouts.
52
+
53
+ The CLI's `pracht generate middleware` scaffold emits the new signature.
54
+
55
+ ### Patch Changes
56
+
57
+ - Updated dependencies [[`39860bd`](https://github.com/JoviDeCroock/pracht/commit/39860bd31e8559916d8f81ffa6122ac4cf1cffd1), [`39860bd`](https://github.com/JoviDeCroock/pracht/commit/39860bd31e8559916d8f81ffa6122ac4cf1cffd1), [`51d0de1`](https://github.com/JoviDeCroock/pracht/commit/51d0de12bcda8a1cadd3749f56f03bac2e95c3a6), [`f4763b1`](https://github.com/JoviDeCroock/pracht/commit/f4763b13dc85c7310d9a737b77b708c03a61b57c)]:
58
+ - @pracht/core@0.8.0
59
+
3
60
  ## 1.4.0
4
61
 
5
62
  ### Minor Changes
@@ -71,8 +71,8 @@ function buildMiddlewareModuleSource() {
71
71
  return [
72
72
  "import type { MiddlewareFn } from \"@pracht/core\";",
73
73
  "",
74
- "export const middleware: MiddlewareFn = async (_args) => {",
75
- " return;",
74
+ "export const middleware: MiddlewareFn = async (_args, next) => {",
75
+ " return next();",
76
76
  "};",
77
77
  ""
78
78
  ].join("\n");
package/dist/index.mjs CHANGED
@@ -44,7 +44,7 @@ runMain(defineCommand({
44
44
  build: () => import("./build-B7_6RUBf.mjs").then((m) => m.default),
45
45
  dev: () => import("./dev-BCFe3g38.mjs").then((m) => m.default),
46
46
  doctor: () => import("./doctor-DyOWEA42.mjs").then((m) => m.default),
47
- generate: () => import("./generate-V7pQExlW.mjs").then((m) => m.default),
47
+ generate: () => import("./generate-DTMte0kd.mjs").then((m) => m.default),
48
48
  inspect: () => import("./inspect-WF08uLOl.mjs").then((m) => m.default),
49
49
  typegen: () => import("./typegen-Bl4fYQIy.mjs").then((m) => m.default),
50
50
  verify: () => import("./verify-FwVbdlxh.mjs").then((m) => m.default)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pracht/cli",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "CLI for developing, building, validating, inspecting, and scaffolding Pracht apps.",
5
5
  "keywords": [
6
6
  "pracht",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "citty": "^0.1.6",
42
- "@pracht/core": "0.7.0"
42
+ "@pracht/core": "0.8.0"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "tsdown"