@pracht/cli 1.4.0 → 1.5.1

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,69 @@
1
1
  # @pracht/cli
2
2
 
3
+ ## 1.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`9b089c6`](https://github.com/JoviDeCroock/pracht/commit/9b089c65a51ff724737fffce18f6b08259cfb76e), [`a1c44ab`](https://github.com/JoviDeCroock/pracht/commit/a1c44ab966bcf1afafc33d26d846a1f91a15011e), [`c656bbd`](https://github.com/JoviDeCroock/pracht/commit/c656bbd622f73567f38c02e4346039d2595568b7), [`b3be9a0`](https://github.com/JoviDeCroock/pracht/commit/b3be9a0563f3f66df1f18cc91929b9191b834646)]:
8
+ - @pracht/core@0.8.1
9
+
10
+ ## 1.5.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [#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
15
+ `MiddlewareFn` signature changes from `(args) => MiddlewareResult` to
16
+ `(args, next) => Promise<Response>`.
17
+
18
+ ```ts
19
+ // Before
20
+ export const middleware: MiddlewareFn = async ({ request }) => {
21
+ if (!hasSession(request)) return { redirect: "/login" };
22
+ return { context: { user: "jovi" } };
23
+ };
24
+
25
+ // After
26
+ import { redirect, type MiddlewareFn } from "@pracht/core";
27
+
28
+ export const middleware: MiddlewareFn = async (
29
+ { context, request },
30
+ next
31
+ ) => {
32
+ if (!hasSession(request)) return redirect("/login");
33
+ (context as { user?: string }).user = "jovi";
34
+ return next();
35
+ };
36
+ ```
37
+
38
+ Why: middleware can now wrap `try / catch / finally` around the rest of the
39
+ request, which is the standard shape for tracing, logging, and observability
40
+ libraries (Honeycomb, OpenTelemetry, Sentry). It also matches what users
41
+ arriving from honox / Hono / Astro / SvelteKit / Koa expect.
42
+
43
+ Migration notes:
44
+
45
+ - Replace `return { redirect: "/path" }` with `return redirect("/path")`
46
+ using the new `redirect` helper exported from `@pracht/core`.
47
+ - Replace `return { context: { ... } }` with direct mutation of
48
+ `args.context`. Context is shared by reference between middleware and
49
+ the loader/handler.
50
+ - Replace bare `return` (continue) with `return next()`.
51
+ - Middleware that returns a `Response` directly still works as a
52
+ short-circuit.
53
+ - The `MiddlewareResult` type is removed; `MiddlewareNext` is exported.
54
+ - One `AbortSignal` is now shared per request across all middleware and
55
+ the loader/handler instead of a fresh 30s timer per phase. This makes
56
+ long-running middleware count toward the same overall budget as the
57
+ loader/handler, which matches how most users reason about per-request
58
+ timeouts.
59
+
60
+ The CLI's `pracht generate middleware` scaffold emits the new signature.
61
+
62
+ ### Patch Changes
63
+
64
+ - 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)]:
65
+ - @pracht/core@0.8.0
66
+
3
67
  ## 1.4.0
4
68
 
5
69
  ### 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.1",
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.1"
43
43
  },
44
44
  "scripts": {
45
45
  "build": "tsdown"