@blazetrails/activerecord-cli 0.0.0-stage → 0.1.0-alpha0.1

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.
Files changed (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +323 -2
  3. package/bin/ar.js +2 -0
  4. package/bin/trails-models-dump.js +2 -0
  5. package/bin/trails-tsc.js +10 -0
  6. package/dist/bin/trails-models-dump.d.ts +2 -0
  7. package/dist/bin/trails-models-dump.js +181 -0
  8. package/dist/bin/trails-models-dump.js.map +1 -0
  9. package/dist/bin.d.ts +2 -0
  10. package/dist/bin.js +9 -0
  11. package/dist/bin.js.map +1 -0
  12. package/dist/cli.d.ts +39 -0
  13. package/dist/cli.js +440 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/console.d.ts +11 -0
  16. package/dist/console.js +43 -0
  17. package/dist/console.js.map +1 -0
  18. package/dist/db-helpers.d.ts +4 -0
  19. package/dist/db-helpers.js +39 -0
  20. package/dist/db-helpers.js.map +1 -0
  21. package/dist/db-tasks.d.ts +13 -0
  22. package/dist/db-tasks.js +384 -0
  23. package/dist/db-tasks.js.map +1 -0
  24. package/dist/delegate.d.ts +2 -0
  25. package/dist/delegate.js +23 -0
  26. package/dist/delegate.js.map +1 -0
  27. package/dist/destroy.d.ts +22 -0
  28. package/dist/destroy.js +127 -0
  29. package/dist/destroy.js.map +1 -0
  30. package/dist/environment.d.ts +6 -0
  31. package/dist/environment.js +46 -0
  32. package/dist/environment.js.map +1 -0
  33. package/dist/generate-manifest.d.ts +16 -0
  34. package/dist/generate-manifest.js +233 -0
  35. package/dist/generate-manifest.js.map +1 -0
  36. package/dist/generate-migration.d.ts +24 -0
  37. package/dist/generate-migration.js +129 -0
  38. package/dist/generate-migration.js.map +1 -0
  39. package/dist/generate-model.d.ts +11 -0
  40. package/dist/generate-model.js +69 -0
  41. package/dist/generate-model.js.map +1 -0
  42. package/dist/index.d.ts +8 -0
  43. package/dist/index.js +6 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/init.d.ts +37 -0
  46. package/dist/init.js +252 -0
  47. package/dist/init.js.map +1 -0
  48. package/dist/model-codegen.d.ts +20 -0
  49. package/dist/model-codegen.js +222 -0
  50. package/dist/model-codegen.js.map +1 -0
  51. package/dist/new.d.ts +11 -0
  52. package/dist/new.js +118 -0
  53. package/dist/new.js.map +1 -0
  54. package/dist/pending-migrations.d.ts +4 -0
  55. package/dist/pending-migrations.js +38 -0
  56. package/dist/pending-migrations.js.map +1 -0
  57. package/dist/runner.d.ts +2 -0
  58. package/dist/runner.js +71 -0
  59. package/dist/runner.js.map +1 -0
  60. package/dist/tsc-wrapper/ar-models-plugin.d.ts +14 -0
  61. package/dist/tsc-wrapper/ar-models-plugin.js +46 -0
  62. package/dist/tsc-wrapper/ar-models-plugin.js.map +1 -0
  63. package/dist/tsc-wrapper/ar-program.d.ts +58 -0
  64. package/dist/tsc-wrapper/ar-program.js +274 -0
  65. package/dist/tsc-wrapper/ar-program.js.map +1 -0
  66. package/dist/tsc-wrapper/cli.d.ts +18 -0
  67. package/dist/tsc-wrapper/cli.js +501 -0
  68. package/dist/tsc-wrapper/cli.js.map +1 -0
  69. package/dist/tsc-wrapper/fixture-sets-plugin.d.ts +12 -0
  70. package/dist/tsc-wrapper/fixture-sets-plugin.js +121 -0
  71. package/dist/tsc-wrapper/fixture-sets-plugin.js.map +1 -0
  72. package/dist/tsc-wrapper/index.d.ts +6 -0
  73. package/dist/tsc-wrapper/index.js +5 -0
  74. package/dist/tsc-wrapper/index.js.map +1 -0
  75. package/dist/tsc-wrapper/schema-ts-model-parser.d.ts +3 -0
  76. package/dist/tsc-wrapper/schema-ts-model-parser.js +121 -0
  77. package/dist/tsc-wrapper/schema-ts-model-parser.js.map +1 -0
  78. package/dist/tsc-wrapper/schema-ts-parser.d.ts +23 -0
  79. package/dist/tsc-wrapper/schema-ts-parser.js +170 -0
  80. package/dist/tsc-wrapper/schema-ts-parser.js.map +1 -0
  81. package/dist/tsconfig-merge.d.ts +16 -0
  82. package/dist/tsconfig-merge.js +110 -0
  83. package/dist/tsconfig-merge.js.map +1 -0
  84. package/dist/type-virtualization/auto-import.d.ts +2 -0
  85. package/dist/type-virtualization/auto-import.js +112 -0
  86. package/dist/type-virtualization/auto-import.js.map +1 -0
  87. package/dist/type-virtualization/index.d.ts +8 -0
  88. package/dist/type-virtualization/index.js +5 -0
  89. package/dist/type-virtualization/index.js.map +1 -0
  90. package/dist/type-virtualization/resolve-target.d.ts +7 -0
  91. package/dist/type-virtualization/resolve-target.js +61 -0
  92. package/dist/type-virtualization/resolve-target.js.map +1 -0
  93. package/dist/type-virtualization/synthesize.d.ts +27 -0
  94. package/dist/type-virtualization/synthesize.js +474 -0
  95. package/dist/type-virtualization/synthesize.js.map +1 -0
  96. package/dist/type-virtualization/transitive-extends-walker.d.ts +9 -0
  97. package/dist/type-virtualization/transitive-extends-walker.js +94 -0
  98. package/dist/type-virtualization/transitive-extends-walker.js.map +1 -0
  99. package/dist/type-virtualization/ts-api.d.ts +3 -0
  100. package/dist/type-virtualization/ts-api.js +6 -0
  101. package/dist/type-virtualization/ts-api.js.map +1 -0
  102. package/dist/type-virtualization/type-registry.d.ts +5 -0
  103. package/dist/type-virtualization/type-registry.js +67 -0
  104. package/dist/type-virtualization/type-registry.js.map +1 -0
  105. package/dist/type-virtualization/virtualize.d.ts +43 -0
  106. package/dist/type-virtualization/virtualize.js +413 -0
  107. package/dist/type-virtualization/virtualize.js.map +1 -0
  108. package/dist/type-virtualization/walker.d.ts +73 -0
  109. package/dist/type-virtualization/walker.js +522 -0
  110. package/dist/type-virtualization/walker.js.map +1 -0
  111. package/package.json +52 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Dean Marano and Trails contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,324 @@
1
- # Temporary Holding Version
1
+ # @blazetrails/activerecord-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The `ar` CLI, for using `@blazetrails/activerecord` without the rest of trails.
4
+ It plays the part of the `rails db:*` / `rails generate` tasks for a
5
+ standalone ActiveRecord project: `ar new` / `ar init` / `ar generate:*` /
6
+ `ar destroy:*` / `ar db:*` / `ar console` / `ar runner` / `ar typecheck` /
7
+ `ar models:dump`. It also ships the `trails-tsc` binary, the schema-aware `tsc`
8
+ that types models from `db/schema.ts`.
9
+
10
+ It is the tooling layer on top of `@blazetrails/activerecord`. The runtime
11
+ package carries no CLI dependency. A full trails application (`trails new`)
12
+ does not need this package's commands. It uses `bin/trails db:...` and
13
+ `bin/trails generate ...`, and takes only `trails-tsc` from here.
14
+
15
+ ## Install
16
+
17
+ None of the `@blazetrails/*` packages is on npm yet. Build them from a checkout
18
+ and link them into your project, as the
19
+ [root README's quickstart](../../README.md#quickstart) shows. Once published,
20
+ the split will be:
21
+
22
+ ```sh
23
+ pnpm add -D @blazetrails/activerecord-cli # tooling: dev dependency
24
+ pnpm add @blazetrails/activerecord # runtime: prod dependency
25
+ pnpm add <driver> # one of: better-sqlite3 | pg | mysql2
26
+ ```
27
+
28
+ ## Quickstart
29
+
30
+ Verified on 2026-09-29 (`main` at `41b8c7edb7`, Node 24.16.0, SQLite), with
31
+ the packages linked from a checkout, and with no `TRAILS_ENV` or `NODE_ENV`
32
+ set:
33
+
34
+ ```sh
35
+ ar new shop --driver better-sqlite3
36
+ cd shop
37
+ pnpm install
38
+ npx ar db:create
39
+ npx ar generate:model Product name:string price:integer
40
+ pnpm migrate
41
+ npx ar db:migrate:status
42
+ npx ar generate:manifest
43
+ npx ar db:schema:dump
44
+ ```
45
+
46
+ ```text
47
+ Created database '.../shop/db/development.sqlite3'
48
+ create .../shop/app/models/product.ts
49
+ create .../shop/db/migrate/20260929192331_create_products.ts
50
+ == 20260929192331 CreateProducts: migrating ===================================
51
+ -- createTable("products")
52
+ -> 0.0090s
53
+ == 20260929192331 CreateProducts: migrated (0.0090s) ==========================
54
+ database: .../shop/db/development.sqlite3
55
+ Status Migration ID Migration Name
56
+ --------------------------------------------------
57
+ up 20260929192331 Create products
58
+ write .../shop/.trails/models/index.ts
59
+ Dumped schema to .../shop/db/schema.ts
60
+ ```
61
+
62
+ Commands that load app code (`console`, `runner`, `db:migrate`, `db:seed`)
63
+ must run under the `tsx` loader, because models import each other with `.js`
64
+ specifiers. The generated `package.json` scripts do this: `pnpm migrate`,
65
+ `pnpm seed`, `pnpm console`, `pnpm runner <script.ts>`, or `pnpm ar <command>`
66
+ for any other command.
67
+
68
+ ```ts
69
+ // try-runner.ts
70
+ import { Product } from "./.trails/models/index.js";
71
+
72
+ const p = await Product.createBang({ name: "Gadget", price: 7 });
73
+ console.log(p.id, await Product.count(), Product.where({ price: 7 }).toSql());
74
+ ```
75
+
76
+ ```sh
77
+ pnpm runner try-runner.ts
78
+ ```
79
+
80
+ ```text
81
+ 1 1 SELECT "products".* FROM "products" WHERE "products"."price" = 7
82
+ ```
83
+
84
+ For code that runs outside `ar` (a server, a worker), the generated `db.ts`
85
+ exports `connect()`, described under [Bootstrap](#bootstrap). It connects to
86
+ `development` when `TRAILS_ENV` and `NODE_ENV` are unset, as the `ar` commands do.
87
+
88
+ `ar typecheck` runs `trails-tsc`, and passes on a fresh project.
89
+
90
+ ## Project layout
91
+
92
+ `ar new <name>` creates the directory and runs `ar init` in it. `ar init`
93
+ writes:
94
+
95
+ | Path | Purpose |
96
+ | ------------------------- | ----------------------------------------------------------------------------------------------- |
97
+ | `package.json` | `ar` / `migrate` / `seed` / `console` / `runner` scripts (through `tsx`), the driver dependency |
98
+ | `tsconfig.json` | AR-required compiler settings (merged if one exists) |
99
+ | `config/database.ts` | Connection config keyed by environment, like Rails' `config/database.yml` |
100
+ | `db/migrate/` | Timestamped migration files |
101
+ | `db/seeds.ts` | Seed data loaded by `ar db:seed` |
102
+ | `.trails/models/index.ts` | Generated, gitignored manifest that registers every model class |
103
+ | `db.ts` | A `connect()` helper for code that runs outside `ar` |
104
+ | `.gitignore` | Ignores `node_modules/`, `dist/`, `.trails/`, SQLite files |
105
+
106
+ `ar db:schema:dump` later writes `db/schema.ts`, and `ar generate:model` writes
107
+ `app/models/<name>.ts`.
108
+
109
+ **`TRAILS_ENV`, not `NODE_ENV`.** The JS ecosystem treats `NODE_ENV` as a
110
+ build-time hint, so reusing it to select a database silently picks the wrong
111
+ environment in many setups. `ar` reads `TRAILS_ENV` first, then `NODE_ENV`,
112
+ then falls back to `development`.
113
+
114
+ ## Commands
115
+
116
+ ### Scaffolding
117
+
118
+ | Command | Description |
119
+ | -------------------------------------------- | ---------------------------------------------------------- |
120
+ | `ar new <app-name>` | Create directory + scaffold (does not run install) |
121
+ | `ar init` | Scaffold into the current directory |
122
+ | `ar generate:migration <Name> [field:type…]` | Emit `db/migrate/<ts>_<snake>.ts` |
123
+ | `ar generate:model <Name> [field:type…]` | Emit model (with a `declare` per field) + create migration |
124
+ | `ar generate:manifest` | Scan `app/models/` and rewrite `.trails/models/index.ts` |
125
+ | `ar destroy:migration <Name>` | Delete the matching migration file |
126
+ | `ar destroy:model <Name>` | Delete model + its create migration |
127
+
128
+ ### Database
129
+
130
+ | Command | Description |
131
+ | ----------------------------------- | ----------------------------------------------------- |
132
+ | `ar db:create` | Create the database for the current `TRAILS_ENV` |
133
+ | `ar db:drop` | Drop the database (production-protected) |
134
+ | `ar db:migrate` | Run pending migrations |
135
+ | `ar db:rollback` | Roll back the last migration (`--step N` for N) |
136
+ | `ar db:migrate:status` | Show up/down status for each migration |
137
+ | `ar db:version` | Print the current schema version |
138
+ | `ar db:seed` | Run `db/seeds.ts` |
139
+ | `ar db:schema:dump` | Dump the current database schema to `db/schema.ts` |
140
+ | `ar db:schema:load` | Load `db/schema.ts` into the database |
141
+ | `ar db:setup` | `db:create` + `db:schema:load` + `db:seed` |
142
+ | `ar db:reset` | `db:drop` + `db:setup` |
143
+ | `ar db:prepare` | Idempotent setup — create if missing, migrate, seed |
144
+ | `ar db:abort_if_pending_migrations` | Exit 1 if any migration is pending (pre-deploy check) |
145
+
146
+ ### Runtime
147
+
148
+ | Command | Description |
149
+ | -------------------- | ------------------------------------------------------------- |
150
+ | `ar console` | REPL with `Base` + all models pre-loaded (prompt: `trails> `) |
151
+ | `ar runner <script>` | Run a script with models registered and connection open |
152
+
153
+ ### Tooling
154
+
155
+ | Command | Description |
156
+ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
157
+ | `ar typecheck` | Type-check models via `trails-tsc` |
158
+ | `ar models:dump` | Emit one model class per table in `db/schema.ts`, with `belongsTo` / `hasMany` from foreign keys. `--schema`, `--out`, `--only`, `--ignore`, `--strip-prefix`, `--strip-suffix` |
159
+ | `ar generate:manifest` | Regenerate `.trails/models/index.ts` (also listed under Scaffolding) |
160
+
161
+ Pass `--help` to any command for its full option set.
162
+
163
+ ## Registration: the generated manifest
164
+
165
+ Rails uses Zeitwerk + Ruby's `inherited` hook to auto-register model classes at
166
+ load time. TypeScript has no equivalent hook for ES modules. The solution is a
167
+ generated barrel:
168
+
169
+ ```ts
170
+ // .trails/models/index.ts, as `ar generate:manifest` wrote it for the quickstart
171
+ // AUTO-GENERATED by @blazetrails/activerecord-cli. Do not edit by hand.
172
+ // Re-run `ar generate:manifest` (or `ar init`) to update.
173
+ import { TopLevel } from "@blazetrails/activesupport";
174
+ import { Product } from "../../app/models/product.js";
175
+
176
+ export const models = [Product] as const;
177
+ Object.assign(TopLevel, { Product });
178
+
179
+ export { Product };
180
+ ```
181
+
182
+ Importing this file registers every model with ActiveRecord, so that
183
+ string class names in associations (`className:`, `through:`) resolve. `ar generate:manifest` keeps it current whenever you add
184
+ or remove a model file. It is build output under `.trails/`: gitignore it and
185
+ run `ar generate:manifest` after any model change (`ar init` runs it too);
186
+ never commit it.
187
+
188
+ The optional ESLint rule `blazetrails/manifest-complete` enforces the same
189
+ check at lint time.
190
+
191
+ ## Programmatic API
192
+
193
+ ```ts
194
+ import {
195
+ init, // scaffold a project directory
196
+ scanModels, // scan a directory for model exports
197
+ renderManifest, // render an index.ts string from ModelEntry[]
198
+ buildManifest, // scan + render in one step
199
+ generateManifest, // scan + render + write to disk
200
+ run, // dispatch an argv array (the CLI entry point)
201
+ checkPendingMigrations, // resolve pending migrations for the current env
202
+ } from "@blazetrails/activerecord-cli";
203
+ ```
204
+
205
+ **`checkPendingMigrations(cwd?: string): Promise<MigrationProxy[]>`**
206
+
207
+ Loads `config/database.ts` and the migration registry from `cwd` (defaults to
208
+ `process.cwd()`), connects to the primary database, and returns the list of
209
+ migrations that have not yet been applied. Returns `[]` when all migrations are
210
+ up to date. Suitable for pre-request or pre-deploy checks without shelling out
211
+ to `ar db:abort_if_pending_migrations`.
212
+
213
+ ```ts
214
+ import { checkPendingMigrations } from "@blazetrails/activerecord-cli";
215
+
216
+ const pending = await checkPendingMigrations();
217
+ if (pending.length > 0) {
218
+ throw new Error(`${pending.length} pending migrations — run ar db:migrate`);
219
+ }
220
+ ```
221
+
222
+ ## Bootstrap
223
+
224
+ `ar init` writes a `db.ts` with a `connect()` helper:
225
+
226
+ ```ts
227
+ import { Base, DatabaseTasks } from "@blazetrails/activerecord";
228
+ import { loadDatabaseConfig } from "@blazetrails/activerecord-cli";
229
+ import { models } from "./.trails/models/index.js";
230
+
231
+ let connected = false;
232
+
233
+ export async function connect(): Promise<void> {
234
+ if (connected) return;
235
+ await loadDatabaseConfig(import.meta.dirname);
236
+ await Base.establishConnection(`:${DatabaseTasks.env}`);
237
+ await Promise.all(models.map((m) => m.loadSchema()));
238
+ connected = true;
239
+ }
240
+ ```
241
+
242
+ `loadDatabaseConfig` reads `config/database.ts` into `Base.configurations`, the
243
+ way Rails' railtie loads `config/database.yml`, and resolves `DatabaseTasks.env`:
244
+ `TRAILS_ENV` (or `NODE_ENV`), or `"development"` when neither is set, which is
245
+ `Rails.env`'s default. `establishConnection` with that env name raises
246
+ `AdapterNotSpecified` when the config has no entry for it. A bare
247
+ `Base.establishConnection()` resolves `DEFAULT_ENV` instead, which is
248
+ `default_env` when both vars are unset, as in Rails. In the quickstart project,
249
+ with `TRAILS_ENV` and `NODE_ENV` unset, this script printed `2`:
250
+
251
+ ```ts
252
+ import { connect } from "./db.js";
253
+ import { Product } from "./.trails/models/index.js";
254
+
255
+ await connect();
256
+ await Product.createBang({ name: "Widget", price: 5 });
257
+ console.log(await Product.count());
258
+ ```
259
+
260
+ ## Architecture / design choices
261
+
262
+ - **Generated manifest, not autoload.** ES module loading is static and
263
+ asynchronous — there is no reliable runtime hook equivalent to Ruby's
264
+ `inherited`. A generated barrel is deterministic and tree-shakeable, and is
265
+ build output under `.trails/`, never committed.
266
+
267
+ - **`TRAILS_ENV`, not `NODE_ENV`.** `NODE_ENV` is a build-time optimization
268
+ flag in the JS ecosystem (tree-shaking, minification). Using it to pick a
269
+ database connection silently selects the wrong environment when bundlers or
270
+ test runners override it. `TRAILS_ENV` is explicit and unambiguous.
271
+
272
+ - **Runtime / tooling split.** `@blazetrails/activerecord` is a pure runtime
273
+ package with no CLI dependency. `@blazetrails/activerecord-cli` owns all
274
+ tooling (codegen, schema introspection, REPL, type-checker delegation). This
275
+ split prevents the CLI and its dependencies (TypeScript compiler API, node
276
+ readline, etc.) from landing in production bundles.
277
+
278
+ - **Lazy async reflection (`ensureSchemaLoaded`).** The class-level query and
279
+ persistence paths await a one-shot schema-load gate, so most consumers do not
280
+ need to call `loadSchema()` explicitly. Association creates reflect their
281
+ target the same way. One edge remains, and it is accepted: attributes on
282
+ `new Model()` before any query has fired read an empty attribute set, since
283
+ the common path is query-first.
284
+
285
+ - **`_abstractClass` as per-class own-property.** Rails sets
286
+ `self.abstract_class = true` on the declaring class, not on a shared
287
+ prototype. The TS port mirrors this with a static own-property so subclasses
288
+ do not inherit the flag — Rails parity.
289
+
290
+ - **`ar new` does not run `pnpm install` or `git init`.** These are
291
+ side-effects the user controls. The command prints the next-step commands
292
+ instead of running them.
293
+
294
+ - **`ar init` merges `tsconfig.json`, never overwrites.** Required compiler
295
+ settings are merged JSONC-aware; conflicting keys are preserved and reported
296
+ as warnings. Pass `--force` to overwrite.
297
+
298
+ - **`db:abort_if_pending_migrations` for deploy gates.** Designed as a
299
+ zero-dependency pre-deploy health check — connects, checks, prints, exits.
300
+ No application server needs to be running.
301
+
302
+ - **Driver selection at scaffold time.** `--driver` writes the adapter key
303
+ into `config/database.ts` and the driver into `package.json`'s
304
+ `dependencies`, so `pnpm install` pulls the right native module.
305
+
306
+ ## Testing
307
+
308
+ The package has unit tests co-located with source files (`*.test.ts`) and
309
+ end-to-end suites under `src/__e2e__/` covering the happy path for each
310
+ supported driver:
311
+
312
+ - `src/__e2e__/sqlite-happy-path.test.ts`
313
+ - `src/__e2e__/postgres-happy-path.test.ts`
314
+ - `src/__e2e__/mysql-happy-path.test.ts`
315
+
316
+ E2E suites exercise `ar init → ar db:migrate → ar db:version` against a real
317
+ database in a temp directory, and CI runs them against SQLite, PostgreSQL and
318
+ MySQL. The SQLite suite also runs `db:create` → `db:migrate` with `TRAILS_ENV`
319
+ and `NODE_ENV` unset, to pin the `development` default.
320
+
321
+ ## Versioning / stability
322
+
323
+ Pre-release. Command names, option flags, and programmatic API surface are
324
+ still evolving. No backwards-compatibility promises before 1.0.
package/bin/ar.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/bin.js";
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/bin/trails-models-dump-bin.js";
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { main } from "../dist/tsc-wrapper/cli.js";
3
+
4
+ try {
5
+ await main();
6
+ } catch (err) {
7
+ const msg = err instanceof Error ? err.message : String(err);
8
+ process.stderr.write(`trails-tsc: ${msg}\n`);
9
+ process.exit(1);
10
+ }
@@ -0,0 +1,2 @@
1
+ export declare function run(argv: readonly string[]): Promise<number>;
2
+ //# sourceMappingURL=trails-models-dump.d.ts.map
@@ -0,0 +1,181 @@
1
+ import { Dir, File, FileUtils } from "@blazetrails/ruby-compat";
2
+ import { generateModels } from "../model-codegen.js";
3
+ import { parseSchemaForModels } from "../tsc-wrapper/schema-ts-model-parser.js";
4
+ function usage(stream) {
5
+ stream.write("Usage: ar models:dump [--schema <path>] [--out <path>]\n" +
6
+ " [--ignore t1,t2] [--only t1,t2]\n" +
7
+ " [--strip-prefix <str>] [--strip-suffix <str>]\n" +
8
+ " [--no-header] [--format]\n");
9
+ }
10
+ function parseArgs(argv) {
11
+ const out = { ignore: [], only: [], noHeader: false, format: false };
12
+ for (let i = 0; i < argv.length; i++) {
13
+ const a = argv[i];
14
+ const readValue = (flag) => {
15
+ const next = argv[i + 1];
16
+ if (!next || next.startsWith("-")) {
17
+ process.stderr.write(`ar models:dump: ${flag} expects a value.\n`);
18
+ return 1;
19
+ }
20
+ i++;
21
+ return next;
22
+ };
23
+ if (a === "--schema") {
24
+ const v = readValue("--schema");
25
+ if (typeof v === "number")
26
+ return v;
27
+ out.schemaPath = v;
28
+ }
29
+ else if (a.startsWith("--schema=")) {
30
+ const v = a.slice("--schema=".length);
31
+ if (!v) {
32
+ process.stderr.write("ar models:dump: --schema expects a value.\n");
33
+ return 1;
34
+ }
35
+ out.schemaPath = v;
36
+ }
37
+ else if (a === "--out") {
38
+ const v = readValue("--out");
39
+ if (typeof v === "number")
40
+ return v;
41
+ out.outPath = v;
42
+ }
43
+ else if (a.startsWith("--out=")) {
44
+ out.outPath = a.slice("--out=".length);
45
+ }
46
+ else if (a === "--ignore") {
47
+ const v = readValue("--ignore");
48
+ if (typeof v === "number")
49
+ return v;
50
+ out.ignore.push(...v.split(",").filter(Boolean));
51
+ }
52
+ else if (a.startsWith("--ignore=")) {
53
+ out.ignore.push(...a.slice("--ignore=".length).split(",").filter(Boolean));
54
+ }
55
+ else if (a === "--only") {
56
+ const v = readValue("--only");
57
+ if (typeof v === "number")
58
+ return v;
59
+ out.only.push(...v.split(",").filter(Boolean));
60
+ }
61
+ else if (a.startsWith("--only=")) {
62
+ out.only.push(...a.slice("--only=".length).split(",").filter(Boolean));
63
+ }
64
+ else if (a === "--strip-prefix") {
65
+ const v = readValue("--strip-prefix");
66
+ if (typeof v === "number")
67
+ return v;
68
+ out.stripPrefix = v;
69
+ }
70
+ else if (a.startsWith("--strip-prefix=")) {
71
+ out.stripPrefix = a.slice("--strip-prefix=".length);
72
+ }
73
+ else if (a === "--strip-suffix") {
74
+ const v = readValue("--strip-suffix");
75
+ if (typeof v === "number")
76
+ return v;
77
+ out.stripSuffix = v;
78
+ }
79
+ else if (a.startsWith("--strip-suffix=")) {
80
+ out.stripSuffix = a.slice("--strip-suffix=".length);
81
+ }
82
+ else if (a === "--no-header") {
83
+ out.noHeader = true;
84
+ }
85
+ else if (a === "--format") {
86
+ out.format = true;
87
+ }
88
+ else if (a === "-h" || a === "--help") {
89
+ usage(process.stdout);
90
+ return 0;
91
+ }
92
+ else {
93
+ process.stderr.write(`ar models:dump: unknown argument: ${a}\n`);
94
+ return 1;
95
+ }
96
+ }
97
+ if (out.ignore.length > 0 && out.only.length > 0) {
98
+ process.stderr.write("ar models:dump: --only and --ignore are mutually exclusive\n");
99
+ return 1;
100
+ }
101
+ return out;
102
+ }
103
+ const BUILTIN_IGNORE = new Set(["schema_migrations", "ar_internal_metadata"]);
104
+ export async function run(argv) {
105
+ const parsed = parseArgs(argv);
106
+ if (typeof parsed === "number")
107
+ return parsed;
108
+ const args = parsed;
109
+ const ignoreSet = new Set([...BUILTIN_IGNORE, ...args.ignore]);
110
+ const onlySet = args.only.length > 0 ? new Set(args.only) : null;
111
+ const keep = (name) => {
112
+ if (ignoreSet.has(name))
113
+ return false;
114
+ if (onlySet)
115
+ return onlySet.has(name);
116
+ return true;
117
+ };
118
+ let schemaFilePath;
119
+ if (args.schemaPath) {
120
+ schemaFilePath = File.expandPath(args.schemaPath);
121
+ }
122
+ else {
123
+ const conventionPath = File.join(Dir.pwd(), "db", "schema.ts");
124
+ if (File.isExist(conventionPath)) {
125
+ schemaFilePath = conventionPath;
126
+ }
127
+ else {
128
+ process.stderr.write("ar models:dump: no schema file found — pass --schema <path> or run `ar db:schema:dump` to create db/schema.ts.\n");
129
+ return 1;
130
+ }
131
+ }
132
+ let source;
133
+ try {
134
+ source = File.read(schemaFilePath);
135
+ }
136
+ catch {
137
+ process.stderr.write(`ar models:dump: cannot read schema file: ${schemaFilePath}\n`);
138
+ return 1;
139
+ }
140
+ const sourceHint = schemaFilePath;
141
+ const parsedTables = parseSchemaForModels(source, schemaFilePath);
142
+ if (parsedTables.length === 0) {
143
+ process.stderr.write(`ar models:dump: no createTable found in ${schemaFilePath} — is it a db/schema.ts?\n`);
144
+ return 1;
145
+ }
146
+ const introspected = parsedTables.filter((t) => keep(t.name));
147
+ if (introspected.length === 0) {
148
+ process.stderr.write("ar models:dump: no tables to generate (check --only/--ignore)\n");
149
+ return 1;
150
+ }
151
+ let output = generateModels(introspected, {
152
+ sourceHint,
153
+ stripPrefix: args.stripPrefix,
154
+ stripSuffix: args.stripSuffix,
155
+ noHeader: args.noHeader,
156
+ });
157
+ if (args.format) {
158
+ output = await maybePrettierFormat(output);
159
+ }
160
+ if (args.outPath) {
161
+ const resolved = File.expandPath(args.outPath);
162
+ FileUtils.mkdirP(File.dirname(resolved));
163
+ File.write(resolved, output);
164
+ process.stdout.write(`ar models:dump: wrote ${resolved}\n`);
165
+ }
166
+ else {
167
+ process.stdout.write(output);
168
+ }
169
+ return 0;
170
+ }
171
+ async function maybePrettierFormat(code) {
172
+ try {
173
+ const prettier = (await import("prettier"));
174
+ return await prettier.format(code, { parser: "typescript" });
175
+ }
176
+ catch {
177
+ process.stderr.write("ar models:dump: warning: --format requested but prettier is not installed; writing unformatted output\n");
178
+ return code;
179
+ }
180
+ }
181
+ //# sourceMappingURL=trails-models-dump.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trails-models-dump.js","sourceRoot":"","sources":["../../lib/bin/trails-models-dump.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAahF,SAAS,KAAK,CAAC,MAA0B;IACvC,MAAM,CAAC,KAAK,CACV,0DAA0D;QACxD,wDAAwD;QACxD,sEAAsE;QACtE,iDAAiD,CACpD,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,IAAuB;IACxC,MAAM,GAAG,GASL,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC7D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC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CAAC;QAChB,MAAM,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,QAAQ,IAAI,CAAC,CAAC;IAC9D,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,IAAY;IAC7C,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAEzC,CAAC;QACF,OAAO,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,yGAAyG,CAC1G,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
package/dist/bin.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bin.d.ts.map
package/dist/bin.js ADDED
@@ -0,0 +1,9 @@
1
+ import { setArg0 } from "@blazetrails/ruby-compat";
2
+ import { run } from "./cli.js";
3
+ setArg0("ar");
4
+ run(process.argv.slice(2), process.cwd()).then((code) => process.exit(code), (err) => {
5
+ const message = err instanceof Error ? err.message : String(err);
6
+ console.error(`ar: ${message}`);
7
+ process.exit(1);
8
+ });
9
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","sourceRoot":"","sources":["../lib/bin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,CAAC,IAAI,CAAC,CAAC;AAEd,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAC5C,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,CAAC,GAAG,EAAE,EAAE;IACN,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO,CAAC,KAAK,CAAC,OAAO,OAAO,EAAE,CAAC,CAAC;IAChC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CACF,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ import { Thor } from "@blazetrails/thor";
2
+ import { type Base as ThorBase, type BaseConfig } from "@blazetrails/thor/base";
3
+ import type { Basic } from "@blazetrails/thor/shell/basic";
4
+ /** @noRailsEquivalent PERMANENT */
5
+ export declare class Cli extends Thor {
6
+ options: ThorBase["options"];
7
+ destinationRoot: string;
8
+ shell: Basic;
9
+ static isExitOnFailure(): boolean;
10
+ static perform(command: string | null, args: (string | null)[], config: BaseConfig): Promise<unknown>;
11
+ help(command?: string | null, subcommand?: unknown): Promise<void>;
12
+ new(appName: string): Promise<number>;
13
+ init(): Promise<number>;
14
+ generateManifest(): Promise<number>;
15
+ generateMigration(name: string, ...fieldTokens: string[]): Promise<number>;
16
+ generateModel(name: string, ...fieldTokens: string[]): Promise<number>;
17
+ destroyMigration(name: string, ...fieldTokens: string[]): Promise<number>;
18
+ destroyModel(name: string, ...fieldTokens: string[]): Promise<number>;
19
+ typecheck(...args: string[]): number;
20
+ modelsDump(...args: string[]): Promise<number>;
21
+ dbCreate(...args: string[]): Promise<number>;
22
+ dbDrop(...args: string[]): Promise<number>;
23
+ dbMigrate(...args: string[]): Promise<number>;
24
+ dbMigrateStatus(...args: string[]): Promise<number>;
25
+ dbVersion(...args: string[]): Promise<number>;
26
+ dbRollback(...args: string[]): Promise<number>;
27
+ dbSchemaDump(...args: string[]): Promise<number>;
28
+ dbSchemaLoad(...args: string[]): Promise<number>;
29
+ dbSeed(...args: string[]): Promise<number>;
30
+ dbSetup(...args: string[]): Promise<number>;
31
+ dbReset(...args: string[]): Promise<number>;
32
+ dbPrepare(...args: string[]): Promise<number>;
33
+ dbAbortIfPendingMigrations(): Promise<number>;
34
+ console(...args: string[]): Promise<number>;
35
+ runner(...args: string[]): Promise<number>;
36
+ }
37
+ /** @noRailsEquivalent PERMANENT */
38
+ export declare function run(argv: string[], cwd: string): Promise<number>;
39
+ //# sourceMappingURL=cli.d.ts.map