create-apexjs 0.6.3 → 0.6.5
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 +1 -1
- package/templates/default/AGENTS.md +16 -3
- package/templates/default/pages/about.alpine +1 -1
- package/templates/default/pages/blog/[slug].alpine +1 -1
- package/templates/default/pages/blog/index.alpine +1 -1
- package/templates/default/pages/index.alpine +1 -1
- package/templates/features/auth/pages/account.alpine +1 -1
- package/templates/features/data/pages/guestbook.alpine +1 -1
- package/templates/features/i18n/pages/hello.alpine +1 -1
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ apex make component Card # components/Card.alpine (<Card /> in templat
|
|
|
22
22
|
apex make component ui/Navbar # group in a folder → components/ui/Navbar.alpine (<UiNavbar />)
|
|
23
23
|
apex make client # app.client.ts — register Alpine plugins/directives/magics
|
|
24
24
|
apex make model Post title:string body:string # models/Post.ts → migration + REST + MCP CRUD
|
|
25
|
+
apex make composable Post # composables/usePosts.ts — typed client data-hook off the model
|
|
25
26
|
apex make api webhooks # server/api/webhooks.ts (defineApexRoute; also an MCP tool)
|
|
26
27
|
apex make service Billing # services/BillingService.ts
|
|
27
28
|
apex extend auth # add sealed-cookie sessions + login/logout + /account
|
|
@@ -33,7 +34,17 @@ apex check # type-check (tsc --noEmit; fast with the nati
|
|
|
33
34
|
apex build --preset vercel # build + Vercel config (also: netlify, docker); then deploy
|
|
34
35
|
apex test # run Vitest
|
|
35
36
|
```
|
|
36
|
-
`apex make <kind> …` kinds: `page component api service store layout middleware test model migration auth client`.
|
|
37
|
+
`apex make <kind> …` kinds: `page component api service store layout middleware test model migration auth client composable`.
|
|
38
|
+
|
|
39
|
+
**Data flow, end to end.** One `defineModel` drives the whole stack: schema + migration + REST (`/api/posts` list/get/create/update/delete) + MCP tools **and** the client. `apex make composable Post` emits `composables/usePosts.ts` — a typed `usePosts()` returning `items / loading / error` + `fetch / find / create / update / remove` bound to that resource. Spread it into an x-data:
|
|
40
|
+
```alpine
|
|
41
|
+
<script client>
|
|
42
|
+
import { usePosts } from '../composables/usePosts'
|
|
43
|
+
</script>
|
|
44
|
+
<template x-data="{ ...usePosts(), init() { this.fetch() } }">
|
|
45
|
+
<template x-for="p in items" :key="p.id"><li x-text="p.title"></li></template>
|
|
46
|
+
</template>
|
|
47
|
+
```
|
|
37
48
|
|
|
38
49
|
## Project structure
|
|
39
50
|
```
|
|
@@ -56,13 +67,15 @@ tests/*.test.ts Vitest. createTestApp boots the whole app in-process.
|
|
|
56
67
|
```
|
|
57
68
|
|
|
58
69
|
## The `.alpine` single-file component
|
|
70
|
+
`.alpine` is **TypeScript-only** — `<script>` blocks are always TS; `lang` is optional
|
|
71
|
+
(a `lang="js"` is a parse error).
|
|
59
72
|
```alpine
|
|
60
|
-
<script server
|
|
73
|
+
<script server>
|
|
61
74
|
// Runs on the server. loader() data becomes the page's x-data (real HTML first).
|
|
62
75
|
export function loader() { return { title: 'Hello' } }
|
|
63
76
|
export function head() { return { title: 'Hello' } } // SEO
|
|
64
77
|
</script>
|
|
65
|
-
<script client
|
|
78
|
+
<script client>
|
|
66
79
|
// Optional client-only logic; import composables here.
|
|
67
80
|
</script>
|
|
68
81
|
<template x-data>
|