@ghentcdh/crouton-cli 0.0.1-alpha.88 → 0.0.1-alpha.89
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/agent-files/.claude/skills/crouton/SKILL.md +19 -8
- package/agent-files/.claude/skills/crouton/references/common-mistakes.md +17 -23
- package/agent-files/.claude/skills/crouton/references/relations.md +45 -18
- package/agent-files/.claude/skills/crouton/references/resource-json.md +1 -1
- package/dist/create-datasource/index.js +6686 -4097
- package/dist/create-datasource/index.js.map +1 -1
- package/dist/index.js +9087 -6469
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +3 -1
|
@@ -4,16 +4,19 @@ description: Add or change crouton resources, relations, field inputs, layouts,
|
|
|
4
4
|
crouton-version: 0.0.1-alpha.82
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
> If `crouton --version` differs from `crouton-version` above,
|
|
7
|
+
> If `crouton --version` differs from `crouton-version` above, the skill may be stale — check the installed version's docs in `node_modules/@ghentcdh/crouton-core/agent-docs/`.
|
|
8
8
|
|
|
9
9
|
# Crouton skill
|
|
10
10
|
|
|
11
|
-
Crouton is a resource-driven admin UI framework. This skill teaches the correct workflow for adding and changing
|
|
11
|
+
Crouton is a resource-driven admin UI framework. This skill teaches the correct workflow for adding and changing
|
|
12
|
+
resources.
|
|
12
13
|
|
|
13
14
|
## What crouton is
|
|
15
|
+
|
|
14
16
|
- Resources live in `<resourcesDir>` (see `crouton.json`). Each is a folder with `resource.json`.
|
|
15
17
|
- Data sources live in `<dataSourcesDir>`. Each is a folder with `datasource.json`.
|
|
16
|
-
- The Prisma schema (`schema.prisma`) is the source of truth for models and columns. Never hand-edit column lists that
|
|
18
|
+
- The Prisma schema (`schema.prisma`) is the source of truth for models and columns. Never hand-edit column lists that
|
|
19
|
+
`crouton update` owns.
|
|
17
20
|
|
|
18
21
|
## The workflow loop
|
|
19
22
|
|
|
@@ -24,19 +27,26 @@ Crouton is a resource-driven admin UI framework. This skill teaches the correct
|
|
|
24
27
|
5. Typecheck/build to confirm no TS errors.
|
|
25
28
|
|
|
26
29
|
## Key rules
|
|
30
|
+
|
|
27
31
|
- Never hand-edit auto-generated sections inside `resource.json` (marked with comments).
|
|
28
32
|
- Use `manyToOne` for autocomplete lookups; `oneToMany` for embedded tables.
|
|
29
|
-
- `kind: "custom"` only when you have a `repository.ts` (config-only resource). For non-Prisma data, use `adapter` in
|
|
33
|
+
- `kind: "custom"` only when you have a `repository.ts` (config-only resource). For non-Prisma data, use `adapter` in
|
|
34
|
+
`datasource.json`.
|
|
30
35
|
- After any `resource.json` or `crouton.json` change, run `crouton validate`.
|
|
31
36
|
- Layout nodes use `items` only — there is no `controls` list. Items render in declared order.
|
|
32
|
-
- Table settings (`rowActions`, `tableActions`, `searchFields`, `filterFields`) go on the `type: "table"` node inside
|
|
33
|
-
|
|
34
|
-
-
|
|
37
|
+
- Table settings (`rowActions`, `tableActions`, `searchFields`, `filterFields`) go on the `type: "table"` node inside
|
|
38
|
+
`layout.table`, never on an outer wrapper node.
|
|
39
|
+
- When `layout.<ctx>` is defined, it is the **full list** for that context — only listed columns render. Unlisted
|
|
40
|
+
columns are hidden regardless of `hiddenIn*` flags.
|
|
41
|
+
- After editing layouts, run `crouton validate` to confirm no migration is needed.
|
|
35
42
|
|
|
36
43
|
## Project-specific notes
|
|
37
|
-
|
|
44
|
+
|
|
45
|
+
If `.claude/skills/crouton/project.md` exists, read it first — it holds project conventions that override these
|
|
46
|
+
defaults.
|
|
38
47
|
|
|
39
48
|
## References
|
|
49
|
+
|
|
40
50
|
- `references/resource-json.md` — annotated full example + key table
|
|
41
51
|
- `references/relations.md` — relation recipes
|
|
42
52
|
- `references/field-inputs.md` — which input for which column type
|
|
@@ -45,4 +55,5 @@ If `.claude/skills/crouton/project.md` exists, read it first — it holds projec
|
|
|
45
55
|
- `references/common-mistakes.md` — common mistakes
|
|
46
56
|
|
|
47
57
|
## Docs for the installed version
|
|
58
|
+
|
|
48
59
|
`node_modules/@ghentcdh/crouton-core/agent-docs/README.md`
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
# Common mistakes
|
|
2
2
|
|
|
3
|
-
## 1. Using removed root keys
|
|
4
|
-
|
|
5
|
-
Many root keys moved.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
|
13
|
-
|
|
14
|
-
| `"
|
|
15
|
-
| `"
|
|
16
|
-
| `"
|
|
17
|
-
| `
|
|
18
|
-
| `"display": { "mode": "page" }` at root | `"layout": { "view": { "container": { "mode": "page" } } }` |
|
|
19
|
-
| `"modalSize": "lg"` at root | `"layout": { "form": { "container": { "size": "lg" } } }` |
|
|
20
|
-
| `"include": ["author"]` at root | `"operations": { "findAll": { "include": ["author"] }, "findOne": { "include": ["author"] } }` |
|
|
21
|
-
| `"calculatedColumns": [...]` | `"columns": { "myCol": { "computed": { "sql": "..." } } }` |
|
|
22
|
-
| `column.showInLookup: true` | `"lookup": { "labels": ["colId"] }` on resource root |
|
|
3
|
+
## 1. Using removed root keys
|
|
4
|
+
|
|
5
|
+
Many root keys moved. Run `crouton validate` to detect them — it reports the correct replacement path for each key.
|
|
6
|
+
|
|
7
|
+
| Wrong (old) | Right (new) |
|
|
8
|
+
|-----------------------------------------|------------------------------------------------------------------------------------------------|
|
|
9
|
+
| `"model": "Book"` at root | `"source": { "model": "Book" }` |
|
|
10
|
+
| `"database": "main"` at root | `"source": { "datasource": "main" }` |
|
|
11
|
+
| `"table": "books"` at root | `"source": { "dbTable": "books" }` |
|
|
12
|
+
| `"idType": "number"` at root | `"source": { "idType": "number" }` |
|
|
13
|
+
| `"display": { "mode": "page" }` at root | `"layout": { "view": { "container": { "mode": "page" } } }` |
|
|
14
|
+
| `"modalSize": "lg"` at root | `"layout": { "form": { "container": { "size": "lg" } } }` |
|
|
15
|
+
| `"include": ["author"]` at root | `"operations": { "findAll": { "include": ["author"] }, "findOne": { "include": ["author"] } }` |
|
|
16
|
+
| `"calculatedColumns": [...]` | `"columns": { "myCol": { "computed": { "sql": "..." } } }` |
|
|
17
|
+
| `column.showInLookup: true` | `"lookup": { "labels": ["colId"] }` on resource root |
|
|
23
18
|
|
|
24
19
|
## 2. Putting relation config in fieldInput instead of column.relation
|
|
25
20
|
|
|
@@ -48,8 +43,6 @@ crouton migrate # apply
|
|
|
48
43
|
}
|
|
49
44
|
```
|
|
50
45
|
|
|
51
|
-
Run `crouton migrate` to auto-move relation keys.
|
|
52
|
-
|
|
53
46
|
## 3. Using `format: "relation"` to detect relations
|
|
54
47
|
|
|
55
48
|
`fieldInput.format` is removed. Use `isRelation(col)` from `@ghentcdh/crouton-core` or check `!!col.relation`.
|
|
@@ -61,7 +54,8 @@ Use `enum` for shared lists, `fieldInput.options.values` for local inline lists
|
|
|
61
54
|
|
|
62
55
|
## 5. Hand-editing auto-generated columns
|
|
63
56
|
|
|
64
|
-
`crouton update` owns columns derived from Prisma. Edits to column names or types are overwritten on the next
|
|
57
|
+
`crouton update` owns columns derived from Prisma. Edits to column names or types are overwritten on the next
|
|
58
|
+
`crouton update`.
|
|
65
59
|
Only edit `fieldInput`, `label`, `hidden`, `required`, `relation` inside each column entry.
|
|
66
60
|
|
|
67
61
|
## 6. `kind: "custom"` when you need `adapter: "custom"`
|
|
@@ -18,12 +18,22 @@ Use when: this resource has a FK column pointing to another resource (e.g. `book
|
|
|
18
18
|
"foreignKey": "authorId",
|
|
19
19
|
"displayKey": "name"
|
|
20
20
|
},
|
|
21
|
-
"fieldInput": {
|
|
21
|
+
"fieldInput": {
|
|
22
|
+
"type": "autocomplete"
|
|
23
|
+
}
|
|
22
24
|
}
|
|
23
25
|
},
|
|
24
26
|
"operations": {
|
|
25
|
-
"findAll": {
|
|
26
|
-
|
|
27
|
+
"findAll": {
|
|
28
|
+
"include": [
|
|
29
|
+
"author"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"findOne": {
|
|
33
|
+
"include": [
|
|
34
|
+
"author"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
27
37
|
}
|
|
28
38
|
}
|
|
29
39
|
```
|
|
@@ -51,11 +61,17 @@ Use when: another resource has a FK pointing to this one (e.g. `review.bookId
|
|
|
51
61
|
"sort": "createdAt",
|
|
52
62
|
"sortDir": "desc"
|
|
53
63
|
},
|
|
54
|
-
"fieldInput": {
|
|
64
|
+
"fieldInput": {
|
|
65
|
+
"type": "relation"
|
|
66
|
+
}
|
|
55
67
|
}
|
|
56
68
|
},
|
|
57
69
|
"operations": {
|
|
58
|
-
"findOne": {
|
|
70
|
+
"findOne": {
|
|
71
|
+
"include": [
|
|
72
|
+
"reviews"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
59
75
|
}
|
|
60
76
|
}
|
|
61
77
|
```
|
|
@@ -80,7 +96,9 @@ Use when: a join table connects both resources.
|
|
|
80
96
|
"foreignKey": "bookId",
|
|
81
97
|
"name": "tags"
|
|
82
98
|
},
|
|
83
|
-
"fieldInput": {
|
|
99
|
+
"fieldInput": {
|
|
100
|
+
"type": "relation"
|
|
101
|
+
}
|
|
84
102
|
}
|
|
85
103
|
}
|
|
86
104
|
}
|
|
@@ -93,31 +111,40 @@ Do not check `fieldInput.format` — that is removed.
|
|
|
93
111
|
|
|
94
112
|
## column.relation full reference
|
|
95
113
|
|
|
96
|
-
| Field
|
|
97
|
-
|
|
98
|
-
| `resource`
|
|
99
|
-
| `type`
|
|
100
|
-
| `foreignKey` | FK column name
|
|
101
|
-
| `name`
|
|
114
|
+
| Field | Description |
|
|
115
|
+
|--------------|------------------------------------------------------------|
|
|
116
|
+
| `resource` | Relative path to target `resource.json` |
|
|
117
|
+
| `type` | `"manyToOne"` \| `"oneToMany"` \| `"manyToMany"` |
|
|
118
|
+
| `foreignKey` | FK column name |
|
|
119
|
+
| `name` | Prisma relation field name (when different from column id) |
|
|
102
120
|
| `displayKey` | Field on the related record to show in autocomplete/lookup |
|
|
103
|
-
| `sort`
|
|
104
|
-
| `sortDir`
|
|
121
|
+
| `sort` | Default sort field for the related list |
|
|
122
|
+
| `sortDir` | `"asc"` \| `"desc"` (default `"asc"`) |
|
|
105
123
|
|
|
106
124
|
## include goes in operations, not at root
|
|
107
125
|
|
|
108
126
|
```json
|
|
109
127
|
// WRONG
|
|
110
128
|
{
|
|
111
|
-
"include": [
|
|
129
|
+
"include": [
|
|
130
|
+
"author"
|
|
131
|
+
]
|
|
112
132
|
}
|
|
113
133
|
|
|
114
134
|
// RIGHT
|
|
115
135
|
{
|
|
116
136
|
"operations": {
|
|
117
|
-
"findAll": {
|
|
118
|
-
|
|
137
|
+
"findAll": {
|
|
138
|
+
"include": [
|
|
139
|
+
"author"
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"findOne": {
|
|
143
|
+
"include": [
|
|
144
|
+
"author"
|
|
145
|
+
]
|
|
146
|
+
}
|
|
119
147
|
}
|
|
120
148
|
}
|
|
121
149
|
```
|
|
122
150
|
|
|
123
|
-
Run `crouton migrate` to auto-move root `include` to `operations`.
|
|
@@ -323,4 +323,4 @@ All table-specific settings (`rowActions`, `tableActions`, `searchFields`, `filt
|
|
|
323
323
|
|
|
324
324
|
## Layout is the full list
|
|
325
325
|
|
|
326
|
-
When `layout.<ctx>` is defined, its `items` list is exhaustive — only listed columns render. Columns not listed are hidden regardless of `hiddenIn*`.
|
|
326
|
+
When `layout.<ctx>` is defined, its `items` list is exhaustive — only listed columns render. Columns not listed are hidden regardless of `hiddenIn*`.
|