@forinda/kickjs-cli 8.15.0 → 8.16.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/dist/agent-docs-DhiaLsBj.mjs +591 -0
- package/dist/agent-docs-DhiaLsBj.mjs.map +1 -0
- package/dist/agent-docs-lNvu1K1x.mjs +590 -0
- package/dist/{build-Czsf4CBN.mjs → build-BNHMWtNY.mjs} +2 -2
- package/dist/{build-gqxIH3D8.mjs → build-vY0bmwuH.mjs} +3 -3
- package/dist/{build-gqxIH3D8.mjs.map → build-vY0bmwuH.mjs.map} +1 -1
- package/dist/{builtins-6euI1-lN.mjs → builtins-CRRb7Lq1.mjs} +2 -2
- package/dist/{builtins-xahWxQLw.mjs → builtins-tE4nrAZ_.mjs} +59 -59
- package/dist/cli.mjs +2 -2
- package/dist/{config-DCM2vXUJ.mjs → config-mXO3F69m.mjs} +2 -2
- package/dist/{config-8jdSKLKJ.mjs → config-zWl1-NCq.mjs} +3 -3
- package/dist/{config-8jdSKLKJ.mjs.map → config-zWl1-NCq.mjs.map} +1 -1
- package/dist/{doctor-CwGU9orm.mjs → doctor-z92r35fo.mjs} +9 -9
- package/dist/{doctor-CwGU9orm.mjs.map → doctor-z92r35fo.mjs.map} +1 -1
- package/dist/{fullstack-9HywHQL-.mjs → fullstack-BqevN8LJ.mjs} +13 -13
- package/dist/{fullstack-9HywHQL-.mjs.map → fullstack-BqevN8LJ.mjs.map} +1 -1
- package/dist/{fullstack-BmIFnryN.mjs → fullstack-eMi-9BtZ.mjs} +9 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{plugin-DLZP4hZ0.mjs → plugin-BbbHEAzr.mjs} +2 -2
- package/dist/{plugin-BjmLRF7t.mjs → plugin-CH4X4T0O.mjs} +2 -2
- package/dist/project-Bp6SIRyt.mjs +132 -0
- package/dist/project-D96UoR0P.mjs +133 -0
- package/dist/project-D96UoR0P.mjs.map +1 -0
- package/dist/{project-root-Dk8r8FMi.mjs → project-root-Bw3CEPC7.mjs} +3 -3
- package/dist/{project-root-Dk8r8FMi.mjs.map → project-root-Bw3CEPC7.mjs.map} +1 -1
- package/dist/{project-root-8DH00M-b.mjs → project-root-DN0YbQE5.mjs} +2 -2
- package/dist/{rolldown-runtime-CRasMkPY.mjs → rolldown-runtime-CYy3EyO3.mjs} +1 -1
- package/dist/{run-plugins-R0bVf_nK.mjs → run-plugins-f7i7TlPV.mjs} +67 -67
- package/dist/run-plugins-f7i7TlPV.mjs.map +1 -0
- package/dist/{typegen-BZ8cQ1YM.mjs → typegen-Bq4Fis9G.mjs} +5 -5
- package/dist/{typegen-BZ8cQ1YM.mjs.map → typegen-Bq4Fis9G.mjs.map} +1 -1
- package/dist/{typegen-DNufBmjE.mjs → typegen-_x_Q5O0b.mjs} +4 -4
- package/dist/{types-DOcxTXlP.mjs → types-BLZecxnS.mjs} +1 -1
- package/package.json +2 -2
- package/templates/base/files/_dot_vscode/extensions.json +3 -0
- package/templates/base/files/kick.config.ts +4 -0
- package/templates/base/skills/add-adapter.txt +56 -0
- package/templates/base/skills/add-module.txt +53 -0
- package/templates/base/skills/add-plugin.txt +69 -0
- package/templates/base/skills/bootstrap-export.txt +21 -0
- package/templates/base/skills/cli-commands-cheatsheet.txt +46 -0
- package/templates/base/skills/cli-plugin.txt +61 -0
- package/templates/base/skills/context-contributor.txt +73 -0
- package/templates/base/skills/deny-list.txt +44 -0
- package/templates/base/skills/deploy.txt +99 -0
- package/templates/base/skills/docs-lookup.txt +40 -0
- package/templates/base/skills/env-wiring-check.txt +44 -0
- package/templates/base/skills/guard-vs-middleware-vs-contributor.txt +95 -0
- package/templates/base/skills/query-parsing-list-endpoint.txt +48 -0
- package/templates/base/skills/refresh-agent-docs.txt +27 -0
- package/templates/base/skills/route-flags.txt +73 -0
- package/templates/base/skills/thin-entry-file.txt +49 -0
- package/templates/base/skills/use-asset-manager.txt +61 -0
- package/templates/base/skills/write-controller-test.txt +63 -0
- package/templates/feature-views/feature.json +21 -0
- package/templates/feature-views/files/src/adapters/views.ts +5 -0
- package/templates/feature-views/files/src/views/home.kick +3 -0
- package/templates/feature-views/files/src/views/layouts/main.kick +13 -0
- package/templates/feature-views/files/src/views.ts +9 -0
- package/templates/feature-views/skills/views-forms.txt +68 -0
- package/templates/feature-views/skills/views.txt +49 -0
- package/templates/fullstack-root/files/_dot_vscode/extensions.json +3 -0
- package/dist/agent-docs-CrVQtJgn.mjs +0 -932
- package/dist/agent-docs-D7K6R5C3.mjs +0 -933
- package/dist/agent-docs-D7K6R5C3.mjs.map +0 -1
- package/dist/package-manager-9XxrErw1.mjs +0 -11
- package/dist/package-manager-Dwaolesm.mjs +0 -12
- package/dist/package-manager-Dwaolesm.mjs.map +0 -1
- package/dist/project-CFi3NvO9.mjs +0 -136
- package/dist/project-CFi3NvO9.mjs.map +0 -1
- package/dist/project-CO0D8B0V.mjs +0 -135
- package/dist/run-plugins-R0bVf_nK.mjs.map +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": ["@forinda/kickjs-view"],
|
|
3
|
+
"integrations": [
|
|
4
|
+
{
|
|
5
|
+
"import": {
|
|
6
|
+
"from": "./adapters/views",
|
|
7
|
+
"names": ["viewsAdapter"]
|
|
8
|
+
},
|
|
9
|
+
"slot": "adapter",
|
|
10
|
+
"code": "// .kick templates in src/views: ctx.render('home').\nviewsAdapter()"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"import": {
|
|
14
|
+
"from": "@forinda/kickjs-view/cli",
|
|
15
|
+
"names": ["viewCliPlugin"]
|
|
16
|
+
},
|
|
17
|
+
"slot": "config-plugin",
|
|
18
|
+
"code": "// kick check:views and kick fmt:views\nviewCliPlugin"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="@forinda/kickjs-view/virtual" />
|
|
2
|
+
import kickViews from 'virtual:kick-views'
|
|
3
|
+
import { createViews } from '@forinda/kickjs-view'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The app's `.kick` templates (src/views). `kick build` checks them and ships
|
|
7
|
+
* them in the build; `kick dev` reads them on each request.
|
|
8
|
+
*/
|
|
9
|
+
export const views = createViews({ ...kickViews, layout: 'layouts/main' })
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kickjs-views-forms
|
|
3
|
+
description: Use when building an HTML form with .kick views — validation errors back on the form, refilled values, flash messages, browser-side checks (validate="…"), CSRF for form posts — or when a form post arrives with an empty body.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
**Wiring** (once):
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import express from 'express'
|
|
10
|
+
import { bootstrap, csrf, formErrorHandler, getEnv, session } from '@forinda/kickjs'
|
|
11
|
+
import { KickView } from '@forinda/kickjs-view'
|
|
12
|
+
import { views } from './views'
|
|
13
|
+
|
|
14
|
+
export const app = await bootstrap({
|
|
15
|
+
modules,
|
|
16
|
+
middlewares: [
|
|
17
|
+
// Express only: listing middlewares replaces the default body parsers —
|
|
18
|
+
// forms post urlencoded, and keep JSON for any JSON routes.
|
|
19
|
+
express.urlencoded({ extended: false }),
|
|
20
|
+
express.json(),
|
|
21
|
+
session({ secret: getEnv('SESSION_SECRET'), store: 'cookie' }),
|
|
22
|
+
csrf(),
|
|
23
|
+
],
|
|
24
|
+
adapters: [KickView({ views })],
|
|
25
|
+
onError: formErrorHandler(),
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Without `express.urlencoded` on Express, `ctx.body` is empty for form posts; without `express.json()`, for JSON. When the app already lists `middlewares`, add these to its list rather than replacing it. Fastify and h3 parse bodies themselves.
|
|
30
|
+
|
|
31
|
+
**The round trip**
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
@Post('/tasks', { body: taskSchema })
|
|
35
|
+
async create(ctx: RequestContext) {
|
|
36
|
+
await this.tasks.create(ctx.body)
|
|
37
|
+
flash(ctx, { success: 'Task added' })
|
|
38
|
+
ctx.redirect('/tasks', 303)
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
A failed `body` schema on a browser form post: `formErrorHandler()` stores the errors and the submitted values in the session and redirects (303) back to the page the form was on. API and `fetch()` calls get the usual 422.
|
|
43
|
+
|
|
44
|
+
```kick
|
|
45
|
+
<form method="post" action="/tasks">
|
|
46
|
+
<input type="hidden" name="_csrf" value="{{ csrfToken }}">
|
|
47
|
+
<input name="title" validate="required | maxLength:200">
|
|
48
|
+
@error('title') {
|
|
49
|
+
{{ $message }}
|
|
50
|
+
}
|
|
51
|
+
<button>Add</button>
|
|
52
|
+
</form>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- Every template has `$errors` (field → first message, `form` for the whole body), `$old` and `$flash` — for the next page only.
|
|
56
|
+
- Named inputs refill from `$old` by themselves; passwords, hidden fields and secret-looking names never do.
|
|
57
|
+
- A check the schema can't do (email already taken): re-render with `ctx.render('tasks/new', { $errors: { email: '…' }, $old: ctx.body })`.
|
|
58
|
+
- Flash messages: `@for ([kind, message] of $flash | entries; track kind) { … }` in the layout.
|
|
59
|
+
|
|
60
|
+
**CSRF.** `csrf()` takes the token from the `_csrf` form field when there's no `x-csrf-token` header. Give pages the token with `createViews({ share: (ctx) => ({ csrfToken: csrfToken(ctx) }) })` (`csrfToken` from `@forinda/kickjs`).
|
|
61
|
+
|
|
62
|
+
**Checking in the browser**
|
|
63
|
+
|
|
64
|
+
- `validate="required | email | minLength:3"` on a named field: built-ins `required`, `email`, `url`, `minLength:n`, `maxLength:n`, `min:n`, `max:n`, `pattern:'re'`, `in:'a, b'`. Messages land in the field's `@error` spot. Only pages with such a field get the small validator script.
|
|
65
|
+
- Rich rules: a component with a `<script client>` can import the route's own schema (`import { taskSchema } from '@/modules/tasks/tasks.schemas'`) and run `safeParse` on blur and submit — one set of rules for server and browser. Keep the schema file free of server imports.
|
|
66
|
+
- The browser checks are for quick feedback. The route's schema still decides.
|
|
67
|
+
|
|
68
|
+
Full guide: https://kickjs.app/guide/views#forms.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: kickjs-views
|
|
3
|
+
description: Use when rendering server-side HTML with .kick templates — setting up views, adding a page, layout, component or pipe, a component with a <script client>, or when a template fails kick build / kick check:views.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
**Setup** (once): `{{kick}} add views` does it all. By hand: `{{pm}} add @forinda/kickjs-view`, then
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
// src/views.ts
|
|
10
|
+
/// <reference types="@forinda/kickjs-view/virtual" />
|
|
11
|
+
import kickViews from 'virtual:kick-views'
|
|
12
|
+
import { createViews } from '@forinda/kickjs-view'
|
|
13
|
+
|
|
14
|
+
export const views = createViews({ ...kickViews, layout: 'layouts/main' })
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
and `adapters: [KickView({ views })]` in `bootstrap()`. For `kick check:views` / `kick fmt:views`, register the CLI plugin in `kick.config.ts`: `import { viewCliPlugin } from '@forinda/kickjs-view/cli'` and `plugins: [viewCliPlugin]` (`kick add views` prints this line; `kick new --packages views` writes it). `virtual:kick-views` comes from `kickjsVitePlugin()`: `kick build` checks every template and ships them; `kick dev` reads `src/views` on each request.
|
|
18
|
+
|
|
19
|
+
**Where things go**
|
|
20
|
+
|
|
21
|
+
| Thing | File | Used as |
|
|
22
|
+
| --- | --- | --- |
|
|
23
|
+
| Page | `src/views/users/show.kick` | `await ctx.render('users/show', { user })` |
|
|
24
|
+
| Layout | `src/views/layouts/main.kick` (`<slot />`, `<slot name="head">`) | `@layout('layouts/main')` or `createViews({ layout })` |
|
|
25
|
+
| Component | `src/views/components/user-card.kick` (`@input user`) | `<user-card [user]="u" />` |
|
|
26
|
+
| Pipe | an export of `src/views/pipes.ts` | `{{ total \| money }}` |
|
|
27
|
+
| Data every page gets | `createViews({ share: (ctx) => ({ user: ctx?.get('user') }) })` | `{{ user.email }}` |
|
|
28
|
+
|
|
29
|
+
**Syntax that trips people**
|
|
30
|
+
|
|
31
|
+
- `{{ expr }}` escapes. Expressions read data: **no function calls**, no object literals. Compute in the controller and pass the result.
|
|
32
|
+
- `class` and `style` can't be interpolated: use `[class.done]="task.done"` and `[style.width.px]="n"`. `[attr]="expr"` drops the attribute for `null`/`false`.
|
|
33
|
+
- `@if (items.length)`, not `@if (items)`: an empty array is truthy. Or `@for (x of items; track x.id) { … } @empty { … }`.
|
|
34
|
+
- `[flag]="false"` on a component input, not `flag="false"` (a non-empty string is truthy).
|
|
35
|
+
- A component tag needs a hyphen and matches `components/<path>.kick`, folders joined by `-` (`components/forms/text-field.kick` → `<forms-text-field>`). A missing or unknown input fails the check.
|
|
36
|
+
- `{{-- comment --}}` stays out of the output.
|
|
37
|
+
|
|
38
|
+
**Components with a script.** A top-level `<script client>` in a component is TypeScript that runs in the browser — typically a custom element that the component's markup contains. It ships once per page that renders the component, as `/_kick/c/<tag>.<hash>.js`. It can `import` npm packages and your own files (`@/…` aliases work): `kick build` bundles them into `dist/public/_kick/c/`, `kick dev` serves them through Vite. Running from source without either, a script that imports fails with "client scripts that import need kick dev or a kick build". Keep imported files browser-safe — whatever they import ships too.
|
|
39
|
+
|
|
40
|
+
**Check before claiming done**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
{{kick}} check:views # every template parsed and checked, as kick build does
|
|
44
|
+
{{kick}} fmt:views # format .kick files (--check in CI)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Errors name the file, line and column. An unknown pipe, input or slot, a `{{ }}` inside `<script>`/`<style>` or an `on*` attribute, and an unquoted attribute value are all check errors — fix the template, not the checker.
|
|
48
|
+
|
|
49
|
+
Full guide: https://kickjs.app/guide/views. Forms and validation: the `kickjs-views-forms` skill.
|