@mostajs/orm-cli 0.6.4 → 0.7.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/CHANGELOG.md +474 -0
- package/bin/fix-mongo-id.mjs +259 -0
- package/bin/mongo-introspect.mjs +196 -0
- package/bin/mostajs.sh +205 -2
- package/bin/validate.mjs +98 -0
- package/llms.txt +75 -0
- package/package.json +6 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@mostajs/orm-cli` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.7.0] — 2026-06-15
|
|
6
|
+
|
|
7
|
+
### Added — Mongo migration trio : `mongo-introspect` · `validate` · `fix-ids`
|
|
8
|
+
|
|
9
|
+
Three commands turn a live Mongo project into a data-plug one, using the ORM's
|
|
10
|
+
own mongo dialect (which normalizes `_id`→`id`, ids as strings, every dialect) :
|
|
11
|
+
|
|
12
|
+
- **`mostajs mongo-introspect`** (`bin/mongo-introspect.mjs`, menu `m`) — *migrer* :
|
|
13
|
+
connects to a live MongoDB, samples docs per collection, infers `EntitySchema[]`
|
|
14
|
+
(types, `required`, real indexes, `timestamps`; `_id`/`__v` dropped, ObjectId →
|
|
15
|
+
`string`) and writes `.mostajs/generated/entities.json` — so a Mongo project with
|
|
16
|
+
no Prisma/OpenAPI schema can adopt `@mostajs/orm`. Uses `$SGBD_URI` by default.
|
|
17
|
+
- **`mostajs validate`** (`bin/validate.mjs`, menu `v`) — *valider* : runs the
|
|
18
|
+
published `@mostajs/orm/validator` (ORMConceptValidator, rules R001–R021) over
|
|
19
|
+
`entities.json` with text/json/markdown reporters, `--src` for cross-file rules,
|
|
20
|
+
and a `--ci`/`--max-warnings` gate.
|
|
21
|
+
- **`mostajs fix-ids`** (`bin/fix-mongo-id.mjs`, menu `f`) — *corriger* : see below.
|
|
22
|
+
- **`mostajs load-data`** (menu `l`) — *charger* : `.env`-piloted cross-dialect data
|
|
23
|
+
load. Thin DELEGATE to `@mostajs/orm-copy-data`'s new `mostajs-load` bin (where the
|
|
24
|
+
feature lives) — picks one of four sources (live Mongo · mongodump+mongorestore ·
|
|
25
|
+
JSON · SQL), reads the destination from `.env` (`DB_DIALECT`/`SGBD_URI`, MOSTA_ENV
|
|
26
|
+
cascade), and calls `copyData()`. Schemas from `entities.json` (chain with
|
|
27
|
+
`mongo-introspect`). NB : for large collections use `--batch-size ≥ collection size`
|
|
28
|
+
(a skip/limit pagination instability in copy-data's db-loader can otherwise re-read
|
|
29
|
+
rows → duplicate-PK errors ; copy-data's writer now surfaces the first error).
|
|
30
|
+
|
|
31
|
+
### Added — `mostajs fix-ids` : Mongo → data-plug code repair codemod
|
|
32
|
+
|
|
33
|
+
New codemod (`bin/fix-mongo-id.mjs`, menu `f`, subcommand `fix-ids`) that repairs
|
|
34
|
+
the residue a Mongoose → `@mostajs/orm` migration leaves in **application code**.
|
|
35
|
+
The ORM normalizer maps `_id`→`id` and exposes ids as plain strings for **every
|
|
36
|
+
dialect, MongoDB included** — so the app must read `obj.id`, never `obj._id`, and
|
|
37
|
+
must stop wrapping ids in `ObjectId`. The codemod, conservative and reversible:
|
|
38
|
+
|
|
39
|
+
- renames member access `obj._id` / `obj?._id` / `obj['_id']` → `obj.id`
|
|
40
|
+
(object **keys** like a schema's `_id:` declaration are left intact) ;
|
|
41
|
+
- unwraps `new ObjectId(x)` / `mongoose.Types.ObjectId(x)` / `Types.ObjectId(x)`
|
|
42
|
+
→ `x` (balanced-paren aware) ;
|
|
43
|
+
- reports `ObjectId.isValid(...)` and `ObjectId` imports for manual review ;
|
|
44
|
+
- skips files importing `mongoose` (real models) unless `--include-mongoose` ;
|
|
45
|
+
- dry-run by default ; `--apply` writes with `*.mongoid.bak` backups ;
|
|
46
|
+
`--restore --apply` reverts. Extra `--map old:new` for custom member renames.
|
|
47
|
+
|
|
48
|
+
Usage : `mostajs fix-ids` (preview) · `mostajs fix-ids --apply` · `--restore --apply`.
|
|
49
|
+
|
|
50
|
+
## [0.5.10] — 2026-04-15
|
|
51
|
+
|
|
52
|
+
### Changed — `'*'` kept literal in tree for dynamic resolution
|
|
53
|
+
|
|
54
|
+
Previous behaviour (0.5.9) expanded `'*'` into the entity list from
|
|
55
|
+
`entities.json` at config time. Problem : if you add a table later, the
|
|
56
|
+
rule stays frozen on the old list. Fix requires re-running menu r → 6.
|
|
57
|
+
|
|
58
|
+
Now `'*'` is stored **verbatim** in the tree. The `services/replicator.mjs`
|
|
59
|
+
generated by `@mostajs/replicator@0.2.2+` resolves the wildcard at every
|
|
60
|
+
sync tick by introspecting the master DB catalogue — so new tables are
|
|
61
|
+
replicated automatically.
|
|
62
|
+
|
|
63
|
+
Prompt text updated to make the behaviour explicit :
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
Collections : '*' = all tables of the master DB — resolved LIVE at
|
|
67
|
+
each sync tick from the master's table catalogue
|
|
68
|
+
(so new tables added later are picked up automatically).
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## [0.5.9] — 2026-04-15
|
|
72
|
+
|
|
73
|
+
### Added — menu `r → 6` accepts `*` for full-DB replication
|
|
74
|
+
|
|
75
|
+
Previously the user had to list every collection manually
|
|
76
|
+
(`User,Member,Payment,…`). Now the prompt defaults to `*` which expands
|
|
77
|
+
into the full list of entity names read from
|
|
78
|
+
`.mostajs/generated/entities.json`. The tree.json stays self-contained
|
|
79
|
+
(explicit list, not a wildcard) so the emitted `replicator.mjs` doesn't
|
|
80
|
+
need any special-case handling — it iterates the same way whether you
|
|
81
|
+
picked all 40 or just 2 entities.
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
? Collections [*]:
|
|
85
|
+
✓ expanded '*' → 40 tables from entities.json
|
|
86
|
+
User, Profile, Session, Member, Note, SubscriptionPlan, …
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Fallback : if `entities.json` is missing or empty, the wildcard is kept
|
|
90
|
+
as-is and a warning recommends running menu 1 (Convert) first.
|
|
91
|
+
|
|
92
|
+
## [0.5.8] — 2026-04-15
|
|
93
|
+
|
|
94
|
+
### Fixed — menu `r → s` scaffold crash on force-overwrite
|
|
95
|
+
|
|
96
|
+
Bash `${var:+true}${var:-false}` substitution produced `true--force` when
|
|
97
|
+
the user answered "yes" to "Overwrite existing services/*.mjs?", which
|
|
98
|
+
generated invalid JavaScript (`force: true--force`) → both scaffolders
|
|
99
|
+
threw SyntaxError. `services/*.mjs` were never written, then `dev:all`
|
|
100
|
+
crashed with `MODULE_NOT_FOUND`.
|
|
101
|
+
|
|
102
|
+
Now the shell passes `FORCE=true|false` via env var to the Node snippet,
|
|
103
|
+
and the snippet uses `process.env.FORCE === 'true'`.
|
|
104
|
+
|
|
105
|
+
## [0.5.7] — 2026-04-15
|
|
106
|
+
|
|
107
|
+
### Fixed — menu `r → m` proposes restart when a monitor is already running
|
|
108
|
+
|
|
109
|
+
Previously the menu printed `Monitor already running at …` and returned,
|
|
110
|
+
leaving the user stuck with an old (possibly pre-0.2.0) monitor process
|
|
111
|
+
showing a stale / empty dashboard. Now the user is prompted :
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
Monitor already running (pid=12345) at http://127.0.0.1:14499
|
|
115
|
+
? Restart it now? (picks up recent tree-file changes) [y/N]:
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Answering `y` kills the old process and spawns a fresh one against the
|
|
119
|
+
latest tree. `n` keeps the existing instance and just re-opens the URL.
|
|
120
|
+
|
|
121
|
+
## [0.5.6] — 2026-04-15
|
|
122
|
+
|
|
123
|
+
### Fixed — state loss across menu actions
|
|
124
|
+
|
|
125
|
+
Root cause : `ReplicationManager.saveToFile()` masks credentials in the
|
|
126
|
+
tree JSON (`oracle://user:***@host`), and `loadFromFile()` can't then
|
|
127
|
+
rebuild the live manager — every subsequent `getReplicaStatus()` returned
|
|
128
|
+
an empty array, making it look like replicas had disappeared.
|
|
129
|
+
|
|
130
|
+
Also : adding a slave with a dialect whose driver isn't installed
|
|
131
|
+
(`better-sqlite3`, `oracledb`, etc.) threw at `addReplica()` time before
|
|
132
|
+
state could be persisted, preventing experimental topologies from being
|
|
133
|
+
saved.
|
|
134
|
+
|
|
135
|
+
**Fix** : the menu no longer routes add/list/remove/set-routing/add-rule/
|
|
136
|
+
remove-rule actions through the live `ReplicationManager`. Instead it
|
|
137
|
+
reads and writes the tree JSON directly (via new `_tree_patch`
|
|
138
|
+
helper), preserving URIs verbatim. The services (`replicator.mjs` +
|
|
139
|
+
`monitor.mjs` scaffolded via menu `r → s`) still use the real lib for
|
|
140
|
+
actual sync/monitoring work.
|
|
141
|
+
|
|
142
|
+
Side benefits :
|
|
143
|
+
- No DB driver required just to *register* a slave in the config
|
|
144
|
+
- Credentials preserved (no masking) so `loadFromFile` in services can
|
|
145
|
+
reconnect — `.mostajs/replicator-tree.json` should be in `.gitignore`
|
|
146
|
+
(ensured by `mostajs init`).
|
|
147
|
+
|
|
148
|
+
## [0.5.5] — 2026-04-15
|
|
149
|
+
|
|
150
|
+
### Fixed — Replicator menu : smart project picker
|
|
151
|
+
|
|
152
|
+
Every replicator action that asked for a project name was hard-coded to
|
|
153
|
+
default to `'default'`, even when the tree-file had `'fitzone'` registered.
|
|
154
|
+
Result : after adding a replica to `fitzone`, listing replicas
|
|
155
|
+
(`menu r → 2`) showed an empty list because the user pressed Enter and
|
|
156
|
+
got `default`.
|
|
157
|
+
|
|
158
|
+
New `_pick_project` helper :
|
|
159
|
+
- Reads `.mostajs/replicator-tree.json` and lists known projects
|
|
160
|
+
- Defaults to the first one (or `'fitzone'` if empty)
|
|
161
|
+
- When >1 projects exist, displays them inline above the prompt
|
|
162
|
+
- Used by Add / List / Promote / Remove / Set-routing actions
|
|
163
|
+
|
|
164
|
+
## [0.5.4] — 2026-04-15
|
|
165
|
+
|
|
166
|
+
### Fixed — Menu `r → 1` (Add replica) UX
|
|
167
|
+
|
|
168
|
+
- **Clearer prompts.** The previous prompts ("Project name", "Replica name")
|
|
169
|
+
were ambiguous — a user reported typing a full URI into the project name
|
|
170
|
+
and hitting `Projet "…" introuvable dans ProjectManager`.
|
|
171
|
+
Prompts now include hints and examples, and the dialect prompt lists the
|
|
172
|
+
13 supported options inline.
|
|
173
|
+
- **Auto-register the project.** `rm.addReplica('fitzone', …)` requires the
|
|
174
|
+
project to exist in `ProjectManager` — previously the user had to run
|
|
175
|
+
something else first. The CLI now calls `pm.addProject({ name, dialect,
|
|
176
|
+
uri, schemas: [] })` behind the scenes when the project is missing, using
|
|
177
|
+
the replica's own dialect/uri as the baseline config (typically the master).
|
|
178
|
+
- **Basic input validation** rejects project/replica names that look like
|
|
179
|
+
URIs or paths.
|
|
180
|
+
|
|
181
|
+
## [0.5.3] — 2026-04-15
|
|
182
|
+
|
|
183
|
+
### Added — Menu `r → s) Scaffold services`
|
|
184
|
+
|
|
185
|
+
One-shot bootstrap for background replicator + monitor processes :
|
|
186
|
+
|
|
187
|
+
1. Calls `scaffoldReplicatorService()` from `@mostajs/replicator@0.2.0+` →
|
|
188
|
+
emits `services/replicator.mjs` (sync loop reading .env + tree.json).
|
|
189
|
+
2. Calls `scaffoldMonitorService()` from `@mostajs/replica-monitor@0.2.0+` →
|
|
190
|
+
emits `services/monitor.mjs` (read-only tree-backed dashboard).
|
|
191
|
+
3. Patches `package.json` scripts (only adds keys that don't already exist) :
|
|
192
|
+
- `replicator` : `node services/replicator.mjs`
|
|
193
|
+
- `monitor` : `node services/monitor.mjs`
|
|
194
|
+
- `dev:all` : `concurrently --names next,rep,mon -c blue,magenta,cyan "npm:dev" "npm:replicator" "npm:monitor"`
|
|
195
|
+
4. Installs `concurrently` as devDependency if missing (Braille spinner UX).
|
|
196
|
+
|
|
197
|
+
After scaffold : `npm run dev:all` launches the three processes in parallel
|
|
198
|
+
with coloured per-stream prefixes. Monitor opens on `http://localhost:14499`.
|
|
199
|
+
|
|
200
|
+
### Design
|
|
201
|
+
|
|
202
|
+
Each lib owns its own template — orm-cli is just the orchestrator. When a
|
|
203
|
+
scaffolder evolves (new config, new env var), the emitted file moves in
|
|
204
|
+
lockstep with the lib version.
|
|
205
|
+
|
|
206
|
+
## [0.5.2] — 2026-04-15
|
|
207
|
+
|
|
208
|
+
### Added
|
|
209
|
+
|
|
210
|
+
- **Menu `r → m) Open monitor`** — spawns
|
|
211
|
+
[`@mostajs/replica-monitor`](https://www.npmjs.com/package/@mostajs/replica-monitor)
|
|
212
|
+
in background and opens the dashboard in the default browser :
|
|
213
|
+
- auto-installs `@mostajs/replica-monitor` if missing
|
|
214
|
+
- port + token prompted (default `14499`, no auth)
|
|
215
|
+
- pid tracked in `.mostajs/monitor.pid`, logs to `.mostajs/monitor.log`
|
|
216
|
+
- idempotent : if a monitor is already running, just re-opens the URL
|
|
217
|
+
- launcher : `xdg-open` (Linux) / `open` (macOS)
|
|
218
|
+
- stop with `kill $(cat .mostajs/monitor.pid)`
|
|
219
|
+
|
|
220
|
+
## [0.5.1] — 2026-04-15
|
|
221
|
+
|
|
222
|
+
### Added — Replicator menu (`r`)
|
|
223
|
+
|
|
224
|
+
- **Menu `r) Replicator`** — thin CLI wrapper around
|
|
225
|
+
[`@mostajs/replicator`](https://www.npmjs.com/package/@mostajs/replicator).
|
|
226
|
+
State is persisted to `.mostajs/replicator-tree.json` (auto-loaded at menu
|
|
227
|
+
start, auto-saved after each mutating action).
|
|
228
|
+
- Actions exposed :
|
|
229
|
+
1. **Add replica** (master / slave) to a project (dialect, URI, pool,
|
|
230
|
+
lag tolerance).
|
|
231
|
+
2. **List replicas** with role + live lag.
|
|
232
|
+
3. **Promote a slave to master** (failover).
|
|
233
|
+
4. **Remove a replica**.
|
|
234
|
+
5. **Set read-routing strategy** (`round-robin` / `least-lag` / `random`).
|
|
235
|
+
6. **Add CDC rule** (source → target, mode `snapshot` / `cdc` /
|
|
236
|
+
`bidirectional`, collections, conflict resolution).
|
|
237
|
+
7. **List CDC rules**.
|
|
238
|
+
8. **Run a CDC sync** + show stats (inserted / updated / deleted / failed).
|
|
239
|
+
9. **Remove a CDC rule**.
|
|
240
|
+
- **`v`** view the raw tree file (pretty-printed with `jq` when available).
|
|
241
|
+
- **`c`** clear (delete tree file — destructive, confirms).
|
|
242
|
+
- Auto-installs `@mostajs/replicator` + `@mostajs/mproject` if missing
|
|
243
|
+
(uses the existing `ensure_pkg` Braille spinner UX from 0.4.6).
|
|
244
|
+
|
|
245
|
+
## [0.5.0] — 2026-04-15
|
|
246
|
+
|
|
247
|
+
### Added — `mostajs init` + `mostajs migrate` subcommands (Sprint 3)
|
|
248
|
+
|
|
249
|
+
- **`mostajs init [--dialect sqlite|postgres|…] [--uri URI] [--force]`**
|
|
250
|
+
Scaffolds a fresh bridge-ready project in PROJECT_ROOT :
|
|
251
|
+
- `.env` (PORT=3000, DB_DIALECT, SGBD_URI, DB_SCHEMA_STRATEGY, NEXTAUTH_URL,
|
|
252
|
+
AUTH_SECRET auto-generated via `crypto.randomBytes`)
|
|
253
|
+
- `.mostajs/config.env` (mirror consumed by the seed-runner)
|
|
254
|
+
- `.mostajs/generated/entities.json` (empty array, filled by menu 1)
|
|
255
|
+
- `prisma/schema.prisma` (minimal `User` model — provider auto-mapped :
|
|
256
|
+
`postgres → postgresql`, `mssql → sqlserver`, `mariadb → mysql`)
|
|
257
|
+
- `src/lib/db.ts` (the 3-line `createPrismaLikeDb` bridge)
|
|
258
|
+
Refuses to overwrite existing files unless `--force`.
|
|
259
|
+
|
|
260
|
+
- **`mostajs migrate <diff | apply | status>`** — incremental DDL diff.
|
|
261
|
+
Compares `entities.json` to the live DB's column catalogue (via dialect
|
|
262
|
+
`getExistingColumns`) and :
|
|
263
|
+
- **`diff`** : prints the ALTER TABLE statements needed to make the live
|
|
264
|
+
DB match the schema.
|
|
265
|
+
- **`apply`** : executes those ALTERs (confirmation prompt, or `--yes` to
|
|
266
|
+
skip). Reports `N ok, M failed`.
|
|
267
|
+
- **`status`** : per-entity summary `✓ / ⚠ missing N cols / ✗ table missing`
|
|
268
|
+
+ global counter.
|
|
269
|
+
|
|
270
|
+
Validated end-to-end on the FitZoneGym fixture (Oracle, 40 entities) :
|
|
271
|
+
detected 3 missing inverse-1:1 FK columns, ALTERed them, subsequent diff
|
|
272
|
+
returned `✓ Schema is up to date`.
|
|
273
|
+
|
|
274
|
+
### Fixed
|
|
275
|
+
|
|
276
|
+
- **`load_env` preserves existing env vars.** Pre-0.5.0, `load_env` did
|
|
277
|
+
`set -a; source config.env; set +a` — which overwrote any CLI-provided
|
|
278
|
+
`DB_DIALECT=… mostajs migrate` env, breaking multi-DB workflows. Now
|
|
279
|
+
parses `.mostajs/config.env` line-by-line and only exports keys not
|
|
280
|
+
already set in the process environment.
|
|
281
|
+
- **`PROJECT_ROOT` is now overridable.** `PROJECT_ROOT=/path/to/target
|
|
282
|
+
mostajs init` previously ignored the override (hardcoded `$(pwd)`).
|
|
283
|
+
Now uses `"${PROJECT_ROOT:-$(pwd)}"` so automated tests and scripts
|
|
284
|
+
can target arbitrary directories.
|
|
285
|
+
|
|
286
|
+
## [0.4.7] — 2026-04-15
|
|
287
|
+
|
|
288
|
+
### Added — Export entities menu
|
|
289
|
+
|
|
290
|
+
- **Menu `e`) Export entities** — interactive picker that converts the
|
|
291
|
+
project's `entities.json` into another schema format using
|
|
292
|
+
`@mostajs/orm-adapter@0.6.0+` reverse adapters :
|
|
293
|
+
- `1) Prisma` → `prisma/schema.prisma`
|
|
294
|
+
- `2) JSON Schema` → `schema.json` (2020-12)
|
|
295
|
+
- `3) OpenAPI 3.1` → `openapi.json`
|
|
296
|
+
- `4) Native (TS)` → `src/schemas.ts` (`export const schemas: EntitySchema[]`)
|
|
297
|
+
- Output path is configurable at prompt time. Parent directory is
|
|
298
|
+
auto-created if missing.
|
|
299
|
+
|
|
300
|
+
## [0.4.6] — 2026-04-15
|
|
301
|
+
|
|
302
|
+
### Fixed
|
|
303
|
+
|
|
304
|
+
- **`ensure_pkg` now shows a live spinner** while npm/pnpm/yarn/bun installs
|
|
305
|
+
missing packages. Pre-0.4.6 the install ran inside `... 2>&1 | tail -5`,
|
|
306
|
+
which buffers all output until completion — leaving the user staring at
|
|
307
|
+
a blank line for 1-2 minutes with no feedback. Now a Braille spinner +
|
|
308
|
+
elapsed seconds tick every 200ms while the install runs in background.
|
|
309
|
+
|
|
310
|
+
## [0.4.5] — 2026-04-15
|
|
311
|
+
|
|
312
|
+
### Added — Drop table(s) action in seed menu
|
|
313
|
+
|
|
314
|
+
- **Menu S → d) Drop table(s)** — interactive picker that lists the live
|
|
315
|
+
tables (intersected with the project's entities — junction tables
|
|
316
|
+
included), lets the user pick one / many / all, asks for explicit
|
|
317
|
+
`DROP` typing as confirmation, then issues `dialect.dropTable()` for
|
|
318
|
+
each. Useful when a legacy schema has incompatible NOT NULL columns
|
|
319
|
+
that ALTER cannot reconcile (e.g. the `users.firstName` Prisma legacy
|
|
320
|
+
refactored out of the new schema). Drop + menu 3 (init) recreates the
|
|
321
|
+
table cleanly so menu S → 4 (apply) succeeds.
|
|
322
|
+
|
|
323
|
+
## [0.4.4] — 2026-04-14
|
|
324
|
+
|
|
325
|
+
### Added — seed-aware codemod + new menu actions
|
|
326
|
+
|
|
327
|
+
- **`install-bridge` skips seed scripts by default.** Files matching
|
|
328
|
+
`**/seeds/**`, `**/seeders/**`, `**/fixtures/**`, `**/seed-*.{ts,js}`,
|
|
329
|
+
`**/seeder-*.{ts,js}` or `prisma/seed.{ts,js}` are now **preserved** instead
|
|
330
|
+
of being rewritten to a 2-line `createPrismaLikeDb()` stub. These files are
|
|
331
|
+
usually standalone scripts that create their own Prisma client inline —
|
|
332
|
+
rewriting them destroys their logic.
|
|
333
|
+
```bash
|
|
334
|
+
# legacy behavior (if you really want it)
|
|
335
|
+
mostajs install-bridge --apply --rewrite-seeds
|
|
336
|
+
```
|
|
337
|
+
- **`install-bridge --restore-seeds`** — restores only seed-like `.prisma.bak`
|
|
338
|
+
files. Useful when a previous run of `install-bridge` (pre-0.4.4) destroyed
|
|
339
|
+
your seed scripts :
|
|
340
|
+
```bash
|
|
341
|
+
mostajs install-bridge --restore-seeds --apply
|
|
342
|
+
```
|
|
343
|
+
- **Menu S → r)** — interactive version of `--restore-seeds` with a dry-run
|
|
344
|
+
preview before applying.
|
|
345
|
+
- **Menu S → s)** — **Run seed scripts**. Auto-detects `prisma/seed.ts`,
|
|
346
|
+
`scripts/seed.ts`, `scripts/seed-*.ts` (and `.js` variants) and runs them
|
|
347
|
+
with `tsx` (or `npx tsx`). Preserves the `a` option to run all sequentially.
|
|
348
|
+
|
|
349
|
+
### Fixed
|
|
350
|
+
|
|
351
|
+
- **`walk()` now yields `.prisma.bak` files** so `--restore` actually finds
|
|
352
|
+
backups to restore (the pre-0.4.4 version filtered by extension and
|
|
353
|
+
silently missed every `.bak`, leaving the feature non-functional).
|
|
354
|
+
- **Seed validator recognises relation FK columns.** Fields declared via a
|
|
355
|
+
relation `joinColumn` (e.g. `User.profile → profileId`, `UserRole.user →
|
|
356
|
+
userId`) no longer trigger spurious `unknown field` warnings when present
|
|
357
|
+
in seed JSONs. The validator now accepts : explicit fields + relation
|
|
358
|
+
names + resolved `joinColumn` (or conventional `<relation>Id` fallback).
|
|
359
|
+
|
|
360
|
+
## [0.4.3] — 2026-04-14
|
|
361
|
+
|
|
362
|
+
### Added
|
|
363
|
+
|
|
364
|
+
- **`bootstrap` now asks for the database.** Instead of silently writing
|
|
365
|
+
`DB_DIALECT=sqlite` / `SGBD_URI=./data.sqlite`, bootstrap now presents an
|
|
366
|
+
interactive picker covering the 13 supported dialects, with a sensible
|
|
367
|
+
example URI for each. Users who want SQLite still type Enter.
|
|
368
|
+
- **Non-interactive flags** for CI / scripting :
|
|
369
|
+
```
|
|
370
|
+
mostajs bootstrap --dialect=postgres --uri=postgres://... --strategy=update
|
|
371
|
+
```
|
|
372
|
+
Also honours `DB_DIALECT` / `SGBD_URI` environment variables if present.
|
|
373
|
+
- **Existing `.mostajs/config.env` is honoured** with no prompt — so a user
|
|
374
|
+
who runs `mostajs` menu 2 (Configure database URIs) first then runs
|
|
375
|
+
`bootstrap` flows smoothly into DDL init without being re-asked.
|
|
376
|
+
|
|
377
|
+
### Fixed
|
|
378
|
+
|
|
379
|
+
- **Cosmetic bug in the success banner** — the final line used an escaped
|
|
380
|
+
shell substitution (`\$(...)`) which printed literally instead of being
|
|
381
|
+
expanded. Replaced with direct `$DB_DIALECT` / `$SGBD_URI` variables.
|
|
382
|
+
|
|
383
|
+
## [0.4.2] — 2026-04-14
|
|
384
|
+
|
|
385
|
+
### Fixed
|
|
386
|
+
|
|
387
|
+
- Codemod no longer emits `import 'server-only'` in the generated `db.ts`
|
|
388
|
+
template. The guard crashed apps that still use the Next.js `pages/`
|
|
389
|
+
directory alongside `app/` (FitZoneGym-style mixed projects). The lazy
|
|
390
|
+
dialect loading in `@mostajs/orm@1.9.3+` makes the guard redundant for
|
|
391
|
+
correctness.
|
|
392
|
+
|
|
393
|
+
## [0.4.1] — 2026-04-14
|
|
394
|
+
|
|
395
|
+
### Fixed — `mostajs bootstrap` reliability
|
|
396
|
+
|
|
397
|
+
- **Hard stop-on-error** : each step now verifies its outcome and aborts
|
|
398
|
+
with an actionable message instead of silently continuing. Previous
|
|
399
|
+
behaviour printed a success banner even when convert/DDL had failed.
|
|
400
|
+
- **Install `@mostajs/orm-adapter`** alongside `@mostajs/orm` / `-bridge` /
|
|
401
|
+
`server-only` in step 2. Without the adapter, step 3 (schema conversion)
|
|
402
|
+
was failing silently on a fresh project. Root cause : 0.4.0 only
|
|
403
|
+
installed the runtime packages, not the build-time adapter.
|
|
404
|
+
- **Visible npm output** : step 2 no longer pipes through `tail -3`. Users
|
|
405
|
+
can see the installer progress, which matters on slow networks.
|
|
406
|
+
- **Reload config.env** : after writing the default config, reload env
|
|
407
|
+
vars so `action_init_dialects` sees `DB_DIALECT=sqlite` + `SGBD_URI`.
|
|
408
|
+
|
|
409
|
+
## [0.4.0] — 2026-04-14
|
|
410
|
+
|
|
411
|
+
### Added — the automated migration release
|
|
412
|
+
|
|
413
|
+
- **`mostajs install-bridge`** : codemod that scans a Prisma project, finds
|
|
414
|
+
every `new PrismaClient(...)` instantiation site, and rewrites each file
|
|
415
|
+
to use `createPrismaLikeDb()` from `@mostajs/orm-bridge`. Preserves the
|
|
416
|
+
original export name (`prisma`, `db`, `client`, `default`), so none of
|
|
417
|
+
the call-sites elsewhere in the codebase have to change.
|
|
418
|
+
|
|
419
|
+
Dry-run by default. Flags :
|
|
420
|
+
- `--apply` actually write files
|
|
421
|
+
- `--file <path>` restrict to a single file
|
|
422
|
+
- `--project <root>` override working directory
|
|
423
|
+
- `--restore --apply` revert .prisma.bak backups
|
|
424
|
+
|
|
425
|
+
Example :
|
|
426
|
+
```
|
|
427
|
+
$ mostajs install-bridge
|
|
428
|
+
▶ mostajs install-bridge — scanning /home/me/my-app
|
|
429
|
+
Found 3 PrismaClient instantiation site(s):
|
|
430
|
+
→ src/lib/db.ts (const db)
|
|
431
|
+
→ src/server/prisma.ts (const prisma)
|
|
432
|
+
→ scripts/seed.ts (const prisma)
|
|
433
|
+
Dry-run — no files written. Re-run with --apply to execute.
|
|
434
|
+
|
|
435
|
+
$ mostajs install-bridge --apply
|
|
436
|
+
✓ rewrote src/lib/db.ts (backup: src/lib/db.ts.prisma.bak)
|
|
437
|
+
✓ rewrote src/server/prisma.ts (backup: …)
|
|
438
|
+
✓ rewrote scripts/seed.ts (backup: …)
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
- **`mostajs bootstrap`** : one-shot full migration for a Prisma project.
|
|
442
|
+
Runs the codemod, installs runtime deps, converts `schema.prisma` to
|
|
443
|
+
`entities.json`, writes `.mostajs/config.env`, and applies DDL. Zero
|
|
444
|
+
manual file edits required after this point.
|
|
445
|
+
|
|
446
|
+
```
|
|
447
|
+
$ cd my-prisma-app
|
|
448
|
+
$ npx @mostajs/orm-cli bootstrap
|
|
449
|
+
▶ Step 1/4 : rewrite PrismaClient sites
|
|
450
|
+
✓ rewrote src/lib/db.ts (backup: src/lib/db.ts.prisma.bak)
|
|
451
|
+
▶ Step 2/4 : install runtime deps
|
|
452
|
+
added 42 packages in 3s
|
|
453
|
+
▶ Step 3/4 : convert schema + init DDL
|
|
454
|
+
✓ 18 entities extracted
|
|
455
|
+
✓ 18 tables created in ./data.sqlite
|
|
456
|
+
▶ Step 4/4 : done
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
- **Interactive menu entries** : `b` (Bootstrap) and `i` (Install bridge)
|
|
460
|
+
for users who prefer the menu flow.
|
|
461
|
+
|
|
462
|
+
### Why this matters
|
|
463
|
+
|
|
464
|
+
Before 0.4.0, migrating a Prisma project required hand-editing every
|
|
465
|
+
`db.ts`-style file. For a project like FitZoneGym (15 instantiation
|
|
466
|
+
sites across `src/` and `scripts/`), that was 15 error-prone edits.
|
|
467
|
+
With `install-bridge`, the same migration takes one command and is
|
|
468
|
+
reversible with `--restore --apply`.
|
|
469
|
+
|
|
470
|
+
## [0.3.2] and earlier
|
|
471
|
+
|
|
472
|
+
See git history. Covers the interactive menu, Prisma/OpenAPI/JSON Schema
|
|
473
|
+
conversion, seeding pipeline (hash + validate + apply), health checks,
|
|
474
|
+
subcommands `convert`, `hash`, `verify`, `diagnose`, `health`, `detect`.
|