bank20baht-cli 0.2.0 → 0.3.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/README.md +155 -0
- package/dist/domain/form-dsl.js +3 -3
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# bank20baht-cli
|
|
2
|
+
|
|
3
|
+
Scaffolding CLI for bun workspaces and [bahtui](https://github.com/bank20baht/bahtui) form
|
|
4
|
+
projects. Ships the `bahtui` binary.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
bun add -g bank20baht-cli # or: npm i -g bank20baht-cli
|
|
8
|
+
bahtui --help
|
|
9
|
+
|
|
10
|
+
# one-off, no install
|
|
11
|
+
bunx bank20baht-cli new my-workspace
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Requires Node ≥ 20.12 (or bun). `bun` and `git` must be on `PATH` for the post-scaffold
|
|
15
|
+
steps.
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
| Command | What it does |
|
|
20
|
+
| ---------------------------------------- | ----------------------------------------------------------------- |
|
|
21
|
+
| `bahtui new <name>` | Bare bun workspace in `./<name>` — toolchain only, no apps |
|
|
22
|
+
| `bahtui create <name>` | Full DDD monorepo in `./<name>` — React + Elysia + Eden |
|
|
23
|
+
| `bahtui init` | Write `bahtui.json` into an existing repo (enables the generators) |
|
|
24
|
+
| `bahtui g model <domain>` | `libs/domain/<domain>/model` package |
|
|
25
|
+
| `bahtui g form <domain>/<name> --fields` | Engine-validated `FormDefinition` JSON inside that model package |
|
|
26
|
+
|
|
27
|
+
### `bahtui new <name>`
|
|
28
|
+
|
|
29
|
+
Angular-style project bootstrap. Generates a bun workspace with the shared toolchain and
|
|
30
|
+
nothing else — you add `apps/*` and `packages/*` yourself.
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
bahtui new acme
|
|
34
|
+
cd acme
|
|
35
|
+
bun run check # lint + format:check + knip + typecheck — green on the empty repo
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
What you get:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
package.json workspaces apps/* + packages/*, lint-staged, check script
|
|
42
|
+
tsconfig.base.json strict, moduleResolution bundler, verbatimModuleSyntax
|
|
43
|
+
tsconfig.json typechecks scripts/ (extend the base from each workspace)
|
|
44
|
+
eslint.config.ts ESLint 10 + typescript-eslint + eslint-config-prettier
|
|
45
|
+
.prettierrc no semicolons, single quotes, printWidth 100
|
|
46
|
+
knip.json dead-code / unused-dependency checks
|
|
47
|
+
commitlint.config.js Conventional Commits
|
|
48
|
+
.husky/ pre-commit → lint-staged · commit-msg → commitlint · pre-push → bun run check
|
|
49
|
+
scripts/dev.ts runs every apps/*/ "dev" script in parallel with prefixed output
|
|
50
|
+
scripts/each.ts `bun run scripts/each.ts <script>` in every workspace that defines it
|
|
51
|
+
.mcp.json, CLAUDE.md zvec_grep code-search MCP wiring for Claude Code
|
|
52
|
+
apps/, packages/ empty (.gitkeep)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
By default the CLI runs `git init`, `bun install`, then makes the first commit — so the
|
|
56
|
+
husky hooks prove themselves before you touch anything. Flags:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
--skip-install (alias --no-install) skip bun install and the initial commit
|
|
60
|
+
--skip-git (alias --no-git) skip git init and the initial commit
|
|
61
|
+
--dry-run print the file list, write nothing
|
|
62
|
+
--force write into a non-empty directory
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Add a workspace by creating `apps/<name>/package.json` with `dev` / `build` / `typecheck`
|
|
66
|
+
scripts; `bun run dev`, `bun run build` and `bun run typecheck` pick it up automatically.
|
|
67
|
+
Add a matching entry to `knip.json` so dead-code checks cover it.
|
|
68
|
+
|
|
69
|
+
### `bahtui create <name>`
|
|
70
|
+
|
|
71
|
+
Same flags as `new`, but scaffolds a complete stack:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
apps/web React 19 + Vite
|
|
75
|
+
apps/api Elysia — exports `type App`, the Eden type anchor
|
|
76
|
+
libs/shared/eden treaty<App> — the one typed HTTP client
|
|
77
|
+
bahtui.json generator config (see below)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
bahtui create shop
|
|
82
|
+
cd shop
|
|
83
|
+
bun run dev # web on :5173, api on :3001
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### `bahtui init`
|
|
87
|
+
|
|
88
|
+
Writes `bahtui.json` into the current directory so `bahtui g …` knows where things live.
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
bahtui init # frontend react, backend elysia
|
|
92
|
+
bahtui init --frontend none # no React feature slices
|
|
93
|
+
bahtui init --backend none # no Elysia plugins
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"apps": { "web": "apps/web", "api": "apps/api" },
|
|
99
|
+
"libsDir": "libs",
|
|
100
|
+
"frontend": "react",
|
|
101
|
+
"backend": "elysia",
|
|
102
|
+
"edenClient": "libs/shared/eden"
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### `bahtui g model <domain>`
|
|
107
|
+
|
|
108
|
+
Creates `<libsDir>/domain/<domain>/model` — a framework-free package for entities and form
|
|
109
|
+
JSON. `<domain>` is kebab-case.
|
|
110
|
+
|
|
111
|
+
### `bahtui g form <domain>/<name> --fields "<dsl>"`
|
|
112
|
+
|
|
113
|
+
Builds a `FormDefinition`, validates it with
|
|
114
|
+
[`bank20baht-validator`](https://www.npmjs.com/package/bank20baht-validator) (the same
|
|
115
|
+
engine the browser components run), and writes
|
|
116
|
+
`<libsDir>/domain/<domain>/model/src/<name>.form.json`.
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
bahtui g form ticket/create \
|
|
120
|
+
--fields "title:text:required,priority:dropdown:options=low|medium|high,qty:number:min=1"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Field DSL — comma-separated `key:type[:modifier…]`:
|
|
124
|
+
|
|
125
|
+
| Part | Values |
|
|
126
|
+
| ---------- | -------------------------------------------------------------------------------------------------------------- |
|
|
127
|
+
| `key` | `[a-z][a-z0-9_]*`; the label is derived (`due_date` → "Due Date") |
|
|
128
|
+
| `type` | `text` `textarea` `number` `email` `password` `dropdown` `multiselect` `checkbox` `radio` `toggle` `date` `file` |
|
|
129
|
+
| modifiers | `required` · `options=a\|b\|c` · `min=N` · `max=N` · `flag=NAME` |
|
|
130
|
+
|
|
131
|
+
Invalid DSL (unknown type, empty options, non-numeric `min`) fails before anything is
|
|
132
|
+
written.
|
|
133
|
+
|
|
134
|
+
## Global flags
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
--dry-run print what would be generated, write nothing
|
|
138
|
+
--force overwrite existing files / write into non-empty dirs
|
|
139
|
+
-h, --help
|
|
140
|
+
-v, --version
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## How it works
|
|
144
|
+
|
|
145
|
+
Every command produces a **blueprint** — plain data listing files and post-commands — then
|
|
146
|
+
adapters write it to disk and run the commands. `--dry-run` prints the blueprint. Template
|
|
147
|
+
files ending in `.hbs` get `{{name}}` substitution; everything else is copied verbatim, and a
|
|
148
|
+
leading `_` in a template filename becomes `.` (so `.gitignore` survives `npm pack`).
|
|
149
|
+
|
|
150
|
+
Generated file paths are confined to the target directory; a hostile `bahtui.json` cannot
|
|
151
|
+
write outside the project root.
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT
|
package/dist/domain/form-dsl.js
CHANGED
|
@@ -91,9 +91,9 @@ export function parseFieldsDsl(dsl) {
|
|
|
91
91
|
/** DSL -> FormDefinition, engine-validated. Throws FormDslError on any problem. */
|
|
92
92
|
export function buildFormDefinition(domain, name, dsl) {
|
|
93
93
|
const form = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
form_id: `${domain}-${name}`,
|
|
95
|
+
form_name: titleCase(name.replace(/-/g, '_')).replace(/ /g, '_'),
|
|
96
|
+
fields: parseFieldsDsl(dsl),
|
|
97
97
|
};
|
|
98
98
|
try {
|
|
99
99
|
return parseSchema(JSON.stringify(form));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bank20baht-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Scaffold bun workspaces (bahtui new) and DDD monorepos (React + Elysia + Eden, bahtui create) plus bahtui generators.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"test:watch": "vitest"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"bank20baht-validator": "^0.
|
|
46
|
+
"bank20baht-validator": "^0.2.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^22",
|