@xeplr/cli 0.1.5 → 0.1.6
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 +64 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,9 +4,11 @@ Creates a working xeplr application — an API, sign-in, and a UI — from a few
|
|
|
4
4
|
questions, installs it, and sets up its databases.
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
|
-
npx @xeplr/cli new myapp
|
|
7
|
+
npx @xeplr/cli@latest new myapp
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
+
`@latest` makes npx fetch the newest version rather than one it cached earlier.
|
|
11
|
+
|
|
10
12
|
## What you get
|
|
11
13
|
|
|
12
14
|
```
|
|
@@ -28,10 +30,15 @@ Already working, with nothing to wire up:
|
|
|
28
30
|
table. Neither is written by hand: both are screens
|
|
29
31
|
([`@xeplr/ui-factory`](https://www.npmjs.com/package/@xeplr/ui-factory)),
|
|
30
32
|
published when the API first starts.
|
|
31
|
-
- **
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
- **Configure UI** for Super Admin, in the settings menu (top right) — not in
|
|
34
|
+
the side rail, which is for the pages people use:
|
|
35
|
+
- **Forms**: every UI in the app. New form (a **label** people see and a
|
|
36
|
+
**key** that names its table), design its form and its list, publish (which
|
|
37
|
+
creates or changes its table), open it, **add it to the side rail** — no
|
|
38
|
+
code, no Claude needed.
|
|
39
|
+
- **Menu**: rename, reorder and hide the side rail's items.
|
|
40
|
+
|
|
41
|
+
Nobody else sees it, and the API refuses everyone else.
|
|
35
42
|
- **Multi-tenancy, if you ask for it** — companies (or companies and
|
|
36
43
|
workspaces, up to four levels). Every row is stamped with the one it was made
|
|
37
44
|
in, every read sees only its rows, membership is checked on every request,
|
|
@@ -47,6 +54,21 @@ Already working, with nothing to wire up:
|
|
|
47
54
|
> acres (number, at least 0), Started on (date), Notes (long text). Show Name,
|
|
48
55
|
> Region and Area in the list. Follow "Create a new UI" in CLAUDE.md.
|
|
49
56
|
|
|
57
|
+
## Rules the generated app follows
|
|
58
|
+
|
|
59
|
+
These are architecture decisions, not defaults to tune — each one exists because the alternative failed quietly.
|
|
60
|
+
|
|
61
|
+
| Rule | Where | Why |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| **Records live in real tables, one column per field — never JSON.** | `@xeplr/factory` | `select * from tasks` and plain-SQL reports must work. Only a screen's *design* is JSON (the `factory_screens` table). |
|
|
64
|
+
| **A key and a label, everywhere.** A form's key (`farming_department`) names its screens and table and never changes once published; its label is renamed any time. A menu item's key (`menus.name`, used by `drawerItems` / `settingsOverrides` in `ui/src/App.jsx` and `ui/src/menu.js`) is what code matches; its label is what the rail shows. | `@xeplr/auth`, `@xeplr/ui-account` | Code must never break because someone renamed something people read. No label is written in code. |
|
|
65
|
+
| **`REDIS_PREFIX` is required and unique per app** (`api/development.env`, set to `<name>:`). | `@xeplr/auth`, `@xeplr/utils` | Two apps on one Redis under the shared default serve each other's sessions, menus and API permissions. Sign-in refuses to start without it, or with `xeplr:`. |
|
|
66
|
+
| **Designing, new forms and publishing are Super Admin only.** | `api/routes/access.js`, `@xeplr/auth` menu routes | Publishing changes database tables. Every other screen route checks the permission catalog. |
|
|
67
|
+
| **The browser is not a security boundary.** Front-end hooks (`ui/src/pages/Edit<Form>.jsx`) shape what people see and send; anything that must hold goes in server hooks (`api/screens/<form>/<form>.hooks.js`); data shape in the model (`<form>.model.js`). | `@xeplr/ui-factory`, `@xeplr/factory` | |
|
|
68
|
+
| **Every data address is under `/api`.** | `api/routes`, `ui/vite.config.js` | A page path and a data path must never collide. |
|
|
69
|
+
| **No guessed database names or connections.** | `api/development.env` | A wrong-but-present value starts cleanly and reads as empty data. |
|
|
70
|
+
| **Email is checked at start, never fatal.** The sign-in banner shows `email ✓ …` or `✗ NOT WORKING — reason`. | `@xeplr/auth` | Sign-in works without email; activation, invite and reset links cannot be sent until `EMAIL_PROVIDER` is set. |
|
|
71
|
+
|
|
50
72
|
## Before you start
|
|
51
73
|
|
|
52
74
|
- **Node.js** 18 or later
|
|
@@ -83,13 +105,49 @@ cd myapp/api && npm run start-api # your API — publishes the sample screens
|
|
|
83
105
|
cd myapp/ui && npm run dev # the app
|
|
84
106
|
```
|
|
85
107
|
|
|
86
|
-
Open the UI and sign in with the account you named.
|
|
108
|
+
Open the UI and sign in with the account you named. As Super Admin you will
|
|
109
|
+
see **Configure UI** in the settings menu, top right.
|
|
110
|
+
|
|
111
|
+
**Use a new project name for a new app.** The name decides the database names
|
|
112
|
+
(`<name>_auth`, `<name>_api`); an existing database is kept as it is, with its
|
|
113
|
+
accounts — the super admin you enter is created only in a fresh one.
|
|
87
114
|
|
|
88
115
|
`xeplr new myapp --no-install` only writes the files; then run `npm install` in
|
|
89
116
|
`api` and `ui`, and `npm run setup` in `api`, yourself. If set-up stops part
|
|
90
117
|
way (Postgres not running, say), the installer says which step and the command
|
|
91
118
|
to run again.
|
|
92
119
|
|
|
120
|
+
## Creating a new UI
|
|
121
|
+
|
|
122
|
+
Two ways, both in the running app's project:
|
|
123
|
+
|
|
124
|
+
- **No code** — Configure UI → Forms → New form → design → Publish → Add to menu.
|
|
125
|
+
- **With Claude** — open Claude in the project folder and give it this (it is
|
|
126
|
+
also beside the sample, with a Copy button):
|
|
127
|
+
|
|
128
|
+
> Create a new UI for farming departments. One record is a farming department
|
|
129
|
+
> with: Name (required), Region (dropdown: North, South, East, West), Area in
|
|
130
|
+
> acres (number, at least 0), Started on (date), Notes (long text). Show Name,
|
|
131
|
+
> Region and Area in the list. Follow "Create a new UI" in CLAUDE.md.
|
|
132
|
+
|
|
133
|
+
Claude follows `CLAUDE.md`: the screens and server hooks and model
|
|
134
|
+
(`npx xeplr-factory screens … --no-pages`), the page with its front-end hooks,
|
|
135
|
+
the route, the side-rail item and its menu row. Then restart the sign-in
|
|
136
|
+
service and the API — the API publishes the new screens and creates the table.
|
|
137
|
+
|
|
138
|
+
## Commands in a generated project
|
|
139
|
+
|
|
140
|
+
| Where | Command | Does |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| `api/` | `npm run setup` | create both databases, the sign-in tables, permissions and menus |
|
|
143
|
+
| `api/` | `npm run start-auth` | the sign-in service |
|
|
144
|
+
| `api/` | `npm run start-api` | the API — runs migrations and publishes never-published screens on start |
|
|
145
|
+
| `api/` | `npm run migrate:auth` | apply new `migrations-auth/*.sql` (e.g. a new menu row) |
|
|
146
|
+
| `api/` | `npm run db:encrypt` | redo the encrypted database connection |
|
|
147
|
+
| `api/` | `npx xeplr-factory screens screens/<form>/<form>.entity.json -o screens/<form> --no-pages` | a form's screens, server hooks and model from its spec |
|
|
148
|
+
| `api/` | `npx xeplr-factory validate <screen>.json` | check a screen document |
|
|
149
|
+
| `ui/` | `npm run dev` | the app |
|
|
150
|
+
|
|
93
151
|
## Changing the database connection later
|
|
94
152
|
|
|
95
153
|
A password rotates, the database moves, or the first answer was wrong. From
|