@quatronic/qore 0.5.0-rc.4 → 0.5.0-rc.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.
Files changed (3) hide show
  1. package/README.md +34 -753
  2. package/dist/cli.js +74 -45
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -33,758 +33,30 @@ qore traces --env stag --slower-than 1s # slow requests
33
33
  qore logs --env stag --level error # error logs
34
34
  ```
35
35
 
36
- ### Portals
37
-
38
- `qore` talks to `prod` by default. Pass `--portal staging` or
39
- `--portal testing` to use those portals, or `--portal https://your-portal.example` for anything
40
- else (only accepted on `qore login`, which then pins the identity provider
41
- it reports).
42
-
43
- ```sh
44
- qore login --portal staging
45
- ```
46
-
47
- ### Repository context
48
-
49
- Commands like `qore status` need to know which module you mean. By default
50
- that comes from the git remote of the repository you're standing in:
51
- `qore` reads `git remote -v`, prefers `origin`, falls back to `upstream`,
52
- then the rest in git order, and resolves the remote's URL to a module on
53
- the portal. Working from a personal fork whose `origin` the portal doesn't
54
- know? As long as an `upstream` remote points at the real repository, that one
55
- resolves — the context line then says `(upstream)`.
56
-
57
- Outside a repository, with a projects folder set (see `qore init`), the
58
- order is: the project you are standing in; else `[project]` /
59
- `--project <ref>` (`app`, `app/module`, `tenant/app` or `tenant/app/module`,
60
- matched against your local checkouts); else an interactive pick. `qore dev`
61
- and `qore db erd` take the reference as an argument (`qore dev <app>`); `qore
62
- dev`, `qore db erd`, `qore env pull`, `qore run` and `qore status` take
63
- `--project`. `qore run --project`
64
- only chooses which module's secrets are used; the command still runs in the
65
- current directory. `qore env pull --project` writes into the located module,
66
- and a relative `--target` then resolves against that project directory, not
67
- the directory you ran it from.
68
-
69
- A repository that is no module counts as outside one: standing in some other
70
- codebase, `qore dev` asks the portal about its remotes and, when they match no
71
- module (or it has no remote Qore can match), offers your projects just the
72
- same. A repository inside a known project is never asked about, and a portal
73
- that cannot answer keeps today's error.
74
-
75
- Logged out with a projects folder set, the local lookup still runs first: a
76
- folder that holds no projects gives `QORE_PROJECT_NOT_FOUND`; otherwise the
77
- project is located exactly as when logged in (a match, a picker, or
78
- `QORE_CONTEXT_REQUIRED` without a terminal), and the login error comes from
79
- the portal lookup that follows. Only without a projects folder does a logged-out
80
- command outside a project go straight to the login error.
81
-
82
- Pass `--module <slug|id>` to pick a module explicitly (it keeps its meaning and,
83
- like `--app`, still uses the portal lookup when you are not in a project); the flag always wins
84
- over the git remote. Inside a repository, `qore` still looks up the remote's
85
- own module (from the cache, or with one extra request) only so the context
86
- line can tell you when the flag overrides it. If a module is linked to more
87
- than one app you can read, add `--app <slug|id>` to disambiguate.
88
-
89
- Every context-aware command prints a context line to stderr (never stdout,
90
- so it's safe to pipe `--json` output):
91
-
92
- ```
93
- → <Tenant> / <App> / <module> (<source>)
94
- ```
95
-
96
- `<source>` is the remote name that resolved it (`origin`, `upstream`, …),
97
- or `--module` when you passed the flag. If `--module` resolves to a
98
- different module than the repository's own remote would have, it reads
99
- `--module, overrides <remote>`. With `--json`, this same information is
100
- under `data.context` instead, and nothing about it goes to stderr.
101
-
102
- #### `qore status`
103
-
104
- Shows deployment and health per environment for the current module:
105
-
106
- ```sh
107
- qore status
108
- ```
109
-
110
- | Column | Meaning |
111
- |--------|---------|
112
- | ENV | Environment name |
113
- | DEPLOY | Deployment status, or `paused` |
114
- | COMMIT | Deployed commit SHA |
115
- | DEPLOYED | How long ago that commit was deployed |
116
- | APP HEALTH | The app's public health check (not the module's) |
117
-
118
- #### `qore env pull`
119
-
120
- Writes this module's local secrets into an env file in the current
121
- repository:
122
-
123
- ```sh
124
- qore env pull
125
- ```
126
-
127
- - The target file defaults to the module type's own convention (e.g.
128
- `.env.local`), or `.qore.json`'s `envFile`, or `--target <path>` — always
129
- required to stay inside the repository. `envFile` resolves against the
130
- repository root; `--target` against the current directory, or with
131
- `--project` against the located project directory.
132
- - If the file doesn't exist yet, it's seeded from `.env.example` when one is
133
- present.
134
- - Existing values you've hand-edited are kept by default. A key the portal
135
- manages (e.g. `CONN_*`, `DATABASE_URL`) is always taken from the portal.
136
- For any other key that differs between your file and the portal, pass
137
- `--use-portal` to take the portal's value, or answer the interactive
138
- prompt per key (which shows only the **length** of each value, never its
139
- content — see "Values are never printed" below).
140
- - The file is written with mode `0600` via a temp file in the same
141
- directory, then renamed over the target — it's never truncated in place.
142
- (On Windows, POSIX file modes don't apply — setting `0600` there is a
143
- no-op; there's no equivalent file-permission hardening on that platform.)
144
- - When the repository has a `mobile/` directory (an Expo app), the pull also
145
- writes `mobile/.env.local` with the app's **public** staging config:
146
- `EXPO_PUBLIC_SERVER_URL`, `EXPO_PUBLIC_SENTRY_DSN` and
147
- `EXPO_PUBLIC_QORE_ENV=staging`. qore owns those three keys and overwrites
148
- them; every other line in the file is kept. A value the portal does not have
149
- yet is left out rather than written empty, because an empty `EXPO_PUBLIC_*`
150
- value would override the one baked into `app.config.ts`. Until staging is
151
- deployed there is no server URL; the pull says so, and running it again
152
- after the deploy fills it in. A portal too old to serve this config is
153
- skipped with a note, and a failed fetch warns without failing the pull.
154
- `--json` reports it as
155
- `mobile: { target, environment, serverUrl, sentryDsn: <set?>, written }`
156
- (`null` without a `mobile/` directory). `qore dev` does not write this file.
157
-
158
- **First use of a repository** requires confirmation — see "Trust on first
159
- use" below. **Values are never printed**: not in `qore env pull`'s output,
160
- not in the interactive conflict prompt, not in `--verbose` logs, and not in
161
- the portal's own audit trail, which records key names only (see
162
- `app.local_env.fetched`).
163
-
164
- #### `qore roles`
165
-
166
- Run in the app's frontend module. `qore roles sync` does the announcing alone:
167
- local learns every role in `permissions.ts` and your own roles stay as they are.
168
- `qore roles use inspector` reads the roles in
169
- `src/lib/permissions.ts`, tells the portal they exist on `local` (only there —
170
- staging and production learn roles from the code that environment deploys:
171
- `main` for staging, the `production` branch for production), and makes exactly
172
- the named roles yours on `local`. Sign out and back in to the local app
173
- afterwards. `qore roles list` shows the roles in your code, the ones `local`
174
- knows, and yours. Needs write on the module, like `qore env pull`. An announced
175
- role stays on `local`; nothing removes it automatically.
176
-
177
- #### `qore run`
178
-
179
- Runs a command with this module's local secrets injected into its
180
- environment, without ever writing them to disk:
181
-
182
- ```sh
183
- qore run -- node server.js
184
- qore run -- pnpm dev
185
- ```
186
-
187
- - Secrets are fetched fresh on every `run` — never cached — merged with
188
- your current environment, and passed only to the child process.
189
- - The command runs without a shell (`shell: false`); everything after `--`
190
- is passed to it verbatim, including its own flags (a `--json` or
191
- `--no-input` after `--` is the child's, never `qore`'s own). On Windows,
192
- this is true in spirit but not literally for `.cmd` shims (e.g. `pnpm`,
193
- `npm`, or anything installed as a `.cmd` wrapper): `cross-spawn` runs
194
- those through `cmd.exe /d /s /c` under the hood, with its own escaping.
195
- Pressing Ctrl+C there can also surface cmd's own
196
- `Terminate batch job (Y/N)?` prompt.
197
- - The child's exit code, or the signal it was killed with (e.g. Ctrl+C →
198
- 128+signal), becomes `qore run`'s own exit code.
199
- - **Secrets live in the child's environment**, which is inherited by any
200
- process the child spawns (its grandchildren) and is readable by other
201
- processes running as the same user (`/proc/<pid>/environ`, `ps eww`) —
202
- no worse than a `.env.local` on disk, but worth knowing before running an
203
- untrusted command this way.
204
-
205
- #### `qore dev`
206
-
207
- Starts this module's dev server, from a trusted repository:
208
-
209
- ```sh
210
- qore dev
211
- ```
212
-
213
- - **Context + trust**, like `qore run`/`qore env pull` — the same
214
- `--module`/`--app` resolution, the same trust-on-first-use prompt
215
- (`--yes` to skip it non-interactively).
216
- - **Install**, if needed: the package manager comes from package.json's
217
- `"packageManager": "<pnpm|npm|yarn>@<version>"` field, or (absent that)
218
- whichever lockfile is present. `node_modules` missing, or older than the
219
- lockfile, triggers an install; `--no-install` skips this step entirely.
220
- - **Env merge**: this module's local secrets are pulled and merged into its
221
- env file on disk (same target and conflict rules as `qore env pull`) —
222
- unlike `qore run`, which only injects them into the child's environment.
223
- - **`db:up`**, if the repository declares one: run automatically (unless
224
- `--no-services`), then `qore dev` waits for `DB_PORT` to accept
225
- connections before continuing — bounded by `--wait-timeout <s>` (default
226
- `60`), which also bounds a workspace's provider-port wait (below). A
227
- service that needs Docker and finds it missing or not running fails
228
- fast, naming which.
229
- - **Port check**: `PORT` from the merged env must be free; qore never
230
- picks, shifts or suggests a port (see "Ports never move" below).
231
- - **Runs `dev` exactly as `qore run` would** — same package manager, same
232
- child-process semantics, same exit-code passthrough. The script name is
233
- `"dev"` by default, or `dev.script` in `.qore.json` (below).
234
- - `qore dev` in a module repository has no `--json`: the dev server's own
235
- output passes straight through untouched.
236
-
237
- A legacy backend `dev` script (from older templates, which need a
238
- build and a `.env` first) fails fast with `QORE_DEV_UNSUPPORTED`, naming
239
- the old script and the fix — the same code a repository with no `dev`
240
- script at all, or an unsupported package manager, gets.
241
-
242
- **Offline start**: if the portal is unreachable, `qore dev`
243
- still starts — but only when the repository is already trusted **and** its
244
- env file already exists on disk (from a previous `qore dev`/`env pull`).
245
- It starts from that file as last written, with a warning that values may
246
- be stale. This is the one place `qore` starts without confirming secrets
247
- are current; every other command still requires the portal. An untrusted
248
- repository, or one with no env file yet, surfaces the original
249
- "portal unreachable" error instead.
250
-
251
- **In a workspace root** (see "Workspaces" below), `qore dev` starts every
252
- present module of the app, in dependency order, from one process — unless
253
- `--module <slug>` is passed, which takes the module flow above instead
254
- (run it from inside that module's own repository, not the workspace root
255
- itself, or it fails with "Not inside a module repository"). `--app` is
256
- refused in a workspace root: an app is already implied by
257
- `qore.workspace.json`.
258
-
259
- **Shared checkouts.** In the shared layout the modules start from
260
- `modules/<slug>`. A module that another app's `qore dev` already runs from
261
- the same checkout, with its port listening, is not started a second time:
262
-
263
- - a **backend** is reused (`<module> running in qore dev for <app> (pid
264
- <pid>)`) and listed with that app's URL in the summary. This needs the
265
- portal capability `module.local-env-app-neutral`; without it the module is
266
- listed under `! Not running:` as `running in qore dev for <app>`;
267
- - a **frontend** is never reused, because its environment is per app: it is
268
- listed as not running the same way.
269
-
270
- A reused module is only watched. When its port is free for two checks in a
271
- row, qore prints `<module> stopped with qore dev for <app> — restart qore
272
- dev to run it here` (a `reused-stopped` event with `--json`) and does not
273
- restart it. If every module is reused, nothing starts: `qore dev` just
274
- watches, exits `0` once they have all stopped, and `130` (or 128 + signal)
275
- on Ctrl+C or a signal.
276
-
277
- **Ports never move.** If `PORT` (or, for a workspace, a `db:up`'s
278
- `DB_PORT`) is already taken, `qore dev` fails with `QORE_PORT_IN_USE`
279
- naming the port and, when it can determine one, the process already
280
- holding it — it never picks a different port, shifts one, or suggests an
281
- alternative. Ports are part of the local contract between modules
282
- (`CONN_*_URL` values point at fixed ports), so moving one silently would
283
- break every other module that depends on it.
284
-
285
- #### What qore diagnoses
286
-
287
- Beyond the checks above, `qore dev` recognises common failure shapes and adds
288
- a hint rather than leaving a bare error (spec §14.2):
289
-
290
- - **Docker not running**: in a TTY, waits up to 120 s for it (`Ctrl+C` to
291
- stop) instead of failing immediately; non-interactive or `--json` fails at
292
- once.
293
- - **A leftover `qore dev` holds the port**: in a TTY, offers to stop it
294
- (`Stop the previous qore dev (pid N)?`); outside a TTY it's just
295
- `QORE_PORT_IN_USE`.
296
- - **The dev server exits within seconds of starting**: its tail output is
297
- classified into a hint — a missing dependency (`Cannot find module`), an
298
- invalid/missing env var (a `ZodError`'s keys, never values), a port taken
299
- after the free-port check (`EADDRINUSE`), or a Linux file-watcher limit —
300
- printed after the exit, never rewriting the server's own output. An
301
- unrecognised failure falls back to the tool's last lines plus the command
302
- that ran, never a bare "failed".
303
- - **The portal is unreachable behind a corporate proxy**: the connect error
304
- names `HTTPS_PROXY`/`NODE_EXTRA_CA_CERTS` as things to check.
305
-
306
- `QORE_DEV_EXITED` is not a thrown code: when none of this applies, `qore dev`
307
- just passes the child process's own exit code through.
308
-
309
- #### `qore doctor`
310
-
311
- Runs the same checks `qore` makes before other commands, on demand, without
312
- doing anything else — the first thing to run when something's wrong, and
313
- `--json` makes it attachable to a support ticket:
314
-
315
- ```sh
316
- qore doctor
317
- ```
318
-
319
- - Prints one line per check: `✓` ok, `!` warning, `✗` failing.
320
- - Checks qore's own version, Node, git, GitHub SSH, Docker + compose, every
321
- logged-in portal's session, clock skew, and — inside a workspace or module
322
- repository — each module's port, access and database.
323
- - **Never fetches the local env and never starts anything.** Ports are read
324
- from the env file already on disk; access comes from the ordinary
325
- `GET /api/cli/v1/me` and `.../modules` routes.
326
- - Exit code `0` only when every check passes; a `!` warning never fails it,
327
- only a `✗` does.
328
- - No login profile at all is a warning, not a failure.
329
- - `--json` shape: success is `{"ok":true,"data":{"results":[...],"context":{...}}}`;
330
- on failure it's `{"ok":false,"error":{...,"details":{"results":[...],"context":{...}}}}`
331
- — the full report is always in `details`, even though the top-level error
332
- names only the first failing check. A check that throws still lets the
333
- rest run; it just becomes a `fail` with that error attached.
334
-
335
- #### `qore db erd`
336
-
337
- Opens this module's data model — tables, columns, keys and the relations
338
- between them — in your browser, read live from the module's **local**
339
- Postgres:
340
-
341
- ```sh
342
- qore db erd
343
- qore db erd shop # from anywhere (see qore init); no ref → a pick
344
- qore db erd --no-open # just print the URL
345
- qore db erd --port 4100
346
- qore db erd --json > model.json
347
- ```
348
-
349
- - **Context + trust**, like `qore run`: the same `--module`/`--app`
350
- resolution and the same trust-on-first-use prompt (`--yes` to skip it).
351
- - **In a workspace root** it shows the whole app; **in a module checkout of
352
- a workspace** it asks whether you want the whole app or only that module
353
- (without a terminal, or with `--module`, it stays the module).
354
- - **Where the database comes from:** `DATABASE_URL` in the module's env file
355
- (`.env.local` for a frontend module, otherwise `.env`; or the `envFile`
356
- named in `.qore.json`); when that file is missing or has no (or a blank)
357
- `DATABASE_URL`, it is fetched from the portal for this run only — never
358
- written. A module with no `DATABASE_URL` in either has no database to show.
359
- The URL is whatever the env file holds, or what the portal's local-env
360
- endpoint returns (the local development database).
361
- - **Read-only.** The session is opened with `default_transaction_read_only`
362
- on; the viewer has no write route; only structure is read — never rows.
363
- - **Local only.** The server listens on `127.0.0.1` on a free port (or
364
- `--port`) and refuses requests whose `Host` is not `127.0.0.1:<port>` or
365
- `localhost:<port>`. Stop it with Ctrl+C (exit code 130).
366
- - **Fresh on every load.** Each page load opens a new connection and
367
- introspects again, so after a migration — or a database reset or restart —
368
- a refresh is enough.
369
- - **The viewer** is qore's own, bundled with the CLI and fully offline.
370
- Tables are listed in a palette on the left: drag one onto the canvas, or
371
- click it, to place it, and use `+ N related` to pull in the tables it
372
- references or is referenced by. Switch between Keys only and All columns,
373
- Tidy up to re-layout, Fit to frame everything. `/` searches, `Delete`
374
- removes the selected table, `R` adds its related tables, `Esc` deselects.
375
- The URL hash is the canvas: a link only opens again on the same port, so
376
- share it with a fixed `--port`, or copy just the `#…` part. The reload
377
- button in the top strip re-reads the database without losing the canvas.
378
- Light or dark follows the system, with a toggle.
379
- - **A whole app.** In an app's workspace root (the folder with
380
- `qore.workspace.json`, no `--module`) the canvas shows every module's
381
- database at once: one lane per database (modules that share a database
382
- share a lane), ordered so that what others build on sits left. Foreign keys
383
- stay inside a lane; a reference that crosses databases cannot be a foreign
384
- key, so it is declared as a comment on the column that holds the id:
385
- `COMMENT ON COLUMN app.favourite_spots.spot_id IS '-> api:public.spots.id'`
386
- (the `module:` part is optional, free text may follow). The viewer draws it
387
- as a dashed cable and names the owning lane in the detail pane. A module
388
- without a database has no lane; a database that is down leaves the others
389
- on the canvas, with the error in its lane head.
390
- - `--json` prints `{"ok":true,"data":{"context","source","model"}}`, where
391
- `data.model` is the database model the viewer loads and `data.source` is
392
- `env-file` or `portal`, and starts nothing;
393
- combining it with `--port` or `--no-open` is a usage error (exit 2). In a
394
- workspace root it is `{"ok":true,"data":{"context","databases","model"}}`:
395
- `context.module` is `null`, `context.modules` lists every module with its
396
- lane, `databases` holds one entry per lane with its source, and the model
397
- carries `database` on every table plus `databases` and `refs`. It needs every
398
- database to be reachable.
399
- - Not reachable: `QORE_SERVICE_UNHEALTHY` naming the port and the fix
400
- (`qore dev` / `pnpm db:up`); a taken (or reserved) `--port`: `QORE_PORT_IN_USE`.
401
-
402
- #### `.qore.json`
403
-
404
- An optional file at the repository root that configures `qore env pull`
405
- and `qore dev` for that repository. Schema:
406
- [`schema/qore.schema.json`](./schema/qore.schema.json).
407
-
408
- ```json
409
- {
410
- "$schema": "https://unpkg.com/@quatronic/qore/schema/qore.schema.json",
411
- "envFile": ".env.local",
412
- "localSecrets": ["MY_LOCAL_OVERRIDE"],
413
- "dev": {
414
- "install": true,
415
- "services": ["db:up"],
416
- "script": "dev"
417
- }
418
- }
419
- ```
420
-
421
- - **`dev.install`** — run the package manager's install when needed
422
- (default `true`).
423
- - **`dev.services`** — package.json scripts to run before the dev server,
424
- in order (default: `["db:up"]` if that script exists, else none — each
425
- name must be a real script in package.json).
426
- - **`dev.script`** — the package.json script `qore dev` runs (default
427
- `"dev"`).
428
-
429
- It never holds a portal URL, tenant, app or module id — those are always
430
- resolved from the git remote or `--module`/`--app`, never committed.
431
-
432
- #### Trust on first use
433
-
434
- The first time you run `qore env pull` or `qore run` against a given
435
- repository (for a given module), `qore` asks you to confirm before pulling
436
- secrets into it — trust-on-first-use, recorded locally, not a portal-side
437
- grant. Pass `--yes` to trust non-interactively (CI, scripts) instead of
438
- being prompted.
439
-
440
- #### Resolution cache
441
-
442
- Resolved `git remote` → module lookups are cached at
443
- `<config dir>/qore/cache/repos.json` so repeat commands in the same
444
- repository skip an extra request. It's pure cache — deleting the file is
445
- always harmless, at worst the next command re-resolves.
446
-
447
- If a repository resolves to no module on any portal you're logged in to,
448
- the error lists the portals it tried and, when a staging repository looks
449
- likely, suggests `qore login --portal staging`.
450
-
451
- ### Projects folder & `qore init`
452
-
453
- `qore init` is the guided setup. It runs four steps and reports each as
454
- `done`, `already` or `skipped`, so running it again is safe:
455
-
456
- 1. **Projects folder**: where your apps live (default `~/qore`; `--root <path>`
457
- sets it without asking). Nothing existing is moved.
458
- 2. **Login**: skipped when you are already logged in, and with `--no-input`.
459
- 3. **Tenant**: `already` when a tenant is active (`done` right after the login
460
- step logged you in). Otherwise skipped with
461
- `--no-input` or when you are not logged in (run `qore tenant use <slug>`
462
- later), skipped with no tenants, selected without a prompt when you have
463
- one, a picker when you have several.
464
- 4. **First app**: `--clone <app>` (with `--tenant <slug>` to disambiguate)
465
- clones it; interactively it asks.
466
-
467
- With `--json`, stdout is one document: `{"projectsRoot": "<path>|null",
468
- "steps": {"root"|"login"|"tenant"|"clone": {"status", "detail?"}}}`.
469
-
470
- Apps clone into `<root>/<tenant>/apps/<app>/` and their modules into
471
- `<root>/<tenant>/modules/<module>`, shared by every app of the tenant that
472
- uses them (see "Shared module checkouts" below). A checkout outside the
473
- folder registers itself the first time you use it (`qore clone <app> <dir>`,
474
- `qore dev`, ...); a registered checkout that was deleted is dropped. With a
475
- projects folder set, `qore dev`, `qore env pull`, `qore run` and `qore status`
476
- work from any directory (see Repository context).
477
-
478
- ```sh
479
- qore config root # show the folder and how many projects it holds
480
- qore config root <path> # set it
481
- qore config root --unset # clear it; known projects stay findable
482
- ```
483
-
484
- `qore doctor` checks that the folder exists and is writable.
485
-
486
- ### Workspaces
487
-
488
- `qore clone` sets up a local directory for an app and its modules, each in
489
- its own repository; `qore sync` keeps them in step with the app afterwards.
490
- With a projects folder set, modules are shared between apps (next section);
491
- without one, or with an explicit `qore clone <app> <dir>`, the directory
492
- holds the module repositories itself and the rest of this section applies
493
- as written.
494
-
495
- ```sh
496
- qore clone <app> # clones every module of <app> into ./<app-slug>
497
- qore clone <app> <dir> # ...into <dir> instead
498
- cd <app-slug>
499
- qore status # app-level table, one row per module/environment
500
- cd <module>
501
- qore env pull # no trust prompt — a clone made by qore is already trusted
502
- cd ..
503
- qore sync # clone any module that's new, fetch the rest
504
- qore sync --pull # ...and fast-forward every clean repository with an upstream
505
- qore code [app] [-- <claude args>] # start Claude Code in the app's frontend, every module added (--add-dir)
506
- ```
507
-
508
- - **Where it clones.** Without `[dir]` and with a projects folder set, `qore
509
- clone` puts the app folder at `<root>/<tenant>/apps/<app>` and its modules
510
- in `<root>/<tenant>/modules/`. Without a projects folder it behaves as
511
- described above and prints a tip to run `qore init`; with an explicit `[dir]`
512
- it clones into `<dir>` as before, and with a projects folder set the tip
513
- says that `qore init` shares modules between apps.
514
- - **`--protocol https|ssh`** picks the clone URL (default `https`). `ssh`
515
- rewrites `https://github.com/o/r` to `git@github.com:o/r.git`; your own
516
- git `insteadOf` config still applies on top of either.
517
- - **`--tenant <slug>`** on `qore clone` disambiguates an app slug that
518
- exists in more than one tenant you have access to.
519
- - **The workspace file** is `qore.workspace.json` at the directory `qore
520
- clone` created, holding `{"schemaVersion": 1, "portal": "<apiOrigin>",
521
- "appId": "<uuid>"}`. It never lists modules — those always come from the
522
- portal, so a module added to the app later shows up on the next `qore
523
- sync` with no local change needed. `qore` finds it by walking up from the
524
- current directory (stopping at your home directory). The module commands
525
- (`env pull`, `run`, …), `qore status` and `qore sync` pick up its portal
526
- (and, for a module shared by several apps, its app) automatically when run
527
- from inside the workspace — including from a module's own repository;
528
- `qore clone`, `qore whoami` and `qore tenant` do not read it. An explicit
529
- `--portal` flag always wins over it. `qore status` shows the app-level
530
- table only when run in the directory that holds `qore.workspace.json`
531
- itself (not inside one of its module repositories, which shows that
532
- module).
533
- - **Nothing is ever deleted, moved or overwritten** (in this layout; the
534
- shared layout moves and removes only with your consent, below). A present module
535
- directory is left exactly as it is; `sync` only fetches into it, and
536
- only fast-forwards with `--pull`, and only when the tree is clean and has
537
- an upstream — a dirty tree, one with no upstream, or one that would need
538
- a merge is reported, never touched. `sync` runs a plain `git fetch` (no
539
- `--prune`). A module's directory whose `origin` doesn't point at that
540
- module's repository is reported as re-pointed, and one that isn't a git
541
- repository at all is reported too — neither is repaired; move it aside
542
- and run `qore sync` again. A repository directory in the workspace that
543
- isn't one of the app's modules (typically a module that left the app) is
544
- reported as removed, and left on disk.
545
- - **A target directory that already holds something else** — someone
546
- else's files, or another app's or portal's workspace — makes `qore
547
- clone` fail with `QORE_WORKSPACE_CONFLICT` before writing anything,
548
- including `qore.workspace.json`. Pick a different directory
549
- (`qore clone <app> <dir>`).
550
- - **Per-module clone failures** are diagnosed individually and don't stop
551
- the rest of the run:
552
- - `QORE_GITHUB_NOT_LINKED` — your GitHub account isn't linked in Qore;
553
- link it at the account page, then `qore sync`.
554
- - `QORE_REPO_NO_ACCESS` — you have no seat on the repository; the error
555
- names the dev team(s) that build the module and their maintainers to ask.
556
- - `QORE_REPO_ACCESS_PENDING` — access was granted recently, or your
557
- GitHub organisation invitation isn't accepted yet; the error links the
558
- invitation page.
559
- - `QORE_GIT_AUTH` — git itself couldn't authenticate (no SSH key,
560
- GitHub's SSH host key not accepted yet, no `gh auth login`, or SSO
561
- authorisation needed for the org); the error names the fix.
562
-
563
- `clone`/`sync` exits `0` when at least one module cloned or was already
564
- present and every failure is one of the first three above
565
- (`QORE_GITHUB_NOT_LINKED`, `QORE_REPO_NO_ACCESS`,
566
- `QORE_REPO_ACCESS_PENDING`) — so a developer missing a seat on one module
567
- of a multi-module app still gets a usable workspace for the rest.
568
- `QORE_GIT_AUTH` is not an access failure in this sense: it fails the run
569
- (exit `5`). Any other failure, or a run where nothing succeeded at all,
570
- exits with that failure's own code. With `--json`, once the per-module
571
- loop has run its results are under `data.results` (or
572
- `error.details.results` on failure); an error before that (not logged in,
573
- no workspace, a conflicting target directory) is an ordinary error
574
- document without results.
575
-
576
- #### `qore dev` (workspace root)
577
-
578
- Run from the directory holding `qore.workspace.json` (not inside one of its
579
- module repositories — that takes the single-module flow above), starts
580
- every present module of the app as one supervised run:
581
-
582
- ```sh
583
- qore dev # every present, writable module, in dependency order
584
- qore dev --only api,web # just these (comma-separated)
585
- qore dev --skip docs # all but these
586
- qore dev --kill-others # the first module to exit stops the rest
587
- ```
588
-
589
- - Only **present** modules run (cloned into the workspace); one not cloned
590
- yet is skipped with "not cloned — run `qore sync`". A module without
591
- write access is skipped too (local secrets need write) naming who to
592
- ask; its dependents still start, with a warning that the dependency
593
- they point at (`CONN_*_URL`) won't be running — qore never falls back to
594
- staging. `--only`/`--skip` select by slug; a skip is never fatal by
595
- itself, only when it leaves nothing to start.
596
- - **Every module's install, package-manager check and port check run
597
- first, for every module, before anything starts.** Problems are
598
- collected per module and all reported together — one module's install
599
- failure never hides another's, and nothing starts if any of them failed.
600
- Installs run with bounded parallelism (4 at a time).
601
- - **Start order follows `dependsOn`**: providers before their consumers.
602
- A consumer waits (up to `--wait-timeout`, default `60` s) for each
603
- dependency's `PORT` to accept connections before its own `dev` script
604
- runs; a dependency that doesn't come up in time (or that exited) logs a
605
- warning and the consumer starts anyway. Modules that depend on each
606
- other (a cycle) start together, without waiting, and the cycle is
607
- reported once. A backend under `node --watch` that crashes waits for a
608
- file change instead of exiting, so no exit line appears and its
609
- consumers wait up to `--wait-timeout`.
610
- - **`--kill-others`**: the first module to exit on its own (success or
611
- failure) stops every other module; the others' own exit is then reported
612
- quietly, not as a failure. Without it, `qore dev` keeps every surviving
613
- module running until you stop it yourself.
614
- - **Ctrl+C / SIGTERM/SIGHUP** stops every running module in reverse start
615
- order, `SIGKILL` after a 10 s grace if one doesn't exit on its own; a
616
- second Ctrl+C escalates to `SIGKILL` immediately. A `db:up` service a
617
- module started is left running — `qore dev` only stops the dev servers
618
- it launched directly. During the checks, Ctrl+C / SIGTERM / SIGHUP
619
- stops a running install or `db:up` before `qore dev` exits.
620
- - **Offline start** (same rule as module-level): only when every
621
- module that would start is already trusted and has an env file on disk;
622
- one exception fails the whole run with the original error.
623
-
624
- **Feedback.** Before anything starts, a module not yet cloned is offered as
625
- `Clone <module>, <module> now with qore sync? [Y/n]` (a TTY only, never
626
- with `--json`/`--no-input`; `--yes` does not accept it). A module sync
627
- cannot clone (a conflicting directory, no repository yet, an unsupported
628
- repository URL, GitHub not linked, no repository access) gets its own
629
- warning naming the real next step, and no prompt. While preflight runs, one progress line per
630
- module per step (package manager, install, env, ports) is printed as it
631
- completes. Once every module with a port is either listening or has been
632
- reported as not running, a one-line summary follows: `✔ All modules
633
- running:` (or `✔ Running:` / `! Not running:` when some were skipped) lists
634
- each module with its URL or its reason. A module that crashes while others
635
- keep running gets a restart hint
636
- (`Restart it on its own: qore dev --only <module>`, in another terminal;
637
- the others keep running); on shutdown, a final
638
- line lists what stopped cleanly and what crashed, with how long it ran.
639
- When the failure is about the developer's machine rather than the app
640
- (Docker, Node version, a port busy with something other than a previous
641
- `qore dev`, a package manager), the error is followed by a pointer to
642
- `qore doctor` for a full check.
643
-
644
- **Output.** Every line of a dev server's own stdout/stderr is prefixed per
645
- module and column-aligned:
646
-
647
- ```
648
- api │ listening on 8000
649
- web │ listening on 3001
650
- ```
651
-
652
- qore's own start, ready and exit lines (`▶ api (pid 4121)`,
653
- `✓ api is listening on 8000`, `✗ web exited with code 1`) are not prefixed
654
- and go to stderr, so `--json`'s stdout stays pure NDJSON. A module's own
655
- stdout goes to stdout and its stderr to stderr. Colour is disabled with `--json`, `--no-color` or `NO_COLOR`.
656
-
657
- With `--json` — the only qore command that streams instead of printing one
658
- document — stdout is newline-delimited JSON, one event object per line
659
- (`{"type":"start"|"ready"|"line"|"exit"|"warning"|"skip"|...}`), instead of
660
- the usual single `{"ok":...}` document. An `exit` event carries an optional
661
- `hint` (`{"hint":"..."}`, the same early-exit hint the human renderer prints
662
- as ` → ...`) when the module crashed early with a non-zero code and no
663
- signal — never on a signalled or graceful exit.
664
-
665
- ### Shared module checkouts
666
-
667
- With a projects folder (`qore init`), a tenant's apps share their modules.
668
- A module is cloned once, however many apps use it:
669
-
670
- ```
671
- <root>/<tenant>/modules/<slug>/ one checkout per module (the real repository)
672
- <root>/<tenant>/apps/<app>/ one folder per app, holding no code
673
- <root>/@<portal>/<tenant>/... the same, for a non-production portal
674
- ```
675
-
676
- Without a projects folder, and for `qore clone <app> <dir>`, nothing
677
- changes: the module repositories sit in the workspace directory as before.
678
-
679
- **The app folder** holds `qore.workspace.json` and files that make the
680
- app's modules open together in an editor or Claude Code. `qore clone` and
681
- `qore sync` write them from the portal's module list:
682
-
683
- | File | Purpose |
684
- |---|---|
685
- | `<app>.code-workspace` | VS Code / Cursor: the app folder plus every module in `../../modules/` |
686
- | `.idea/` (`modules.xml`, `<app>.iml`, `vcs.xml`) | WebStorm: the same modules as content roots and Git roots |
687
- | `CLAUDE.md` | which modules the app has, where they are, and which other apps share them |
688
- | `.claude/settings.json` | `permissions.additionalDirectories` for the modules |
689
-
690
- Only what qore owns is rewritten; the rest is yours. In `CLAUDE.md` that is
691
- the block between `<!-- qore:app:start -->` and `<!-- qore:app:end -->` —
692
- write anything you like outside it. In `.code-workspace` qore sets
693
- `folders` and keeps every other key (settings, extensions). In
694
- `.claude/settings.json` it keeps every other key, and any
695
- `additionalDirectories` entry of your own as long as it is not under
696
- `../../modules/`. Your indentation and line endings are kept. A file qore
697
- merges into (`<app>.code-workspace`, `.claude/settings.json`, `CLAUDE.md`)
698
- that is a symlink, or that cannot be parsed, is skipped and named in the
699
- output, never overwritten. The three `.idea` files and `qore.workspace.json`
700
- are qore's alone and are rewritten whole, edits included (qore still never
701
- writes through a symlink). A sync that changes nothing rewrites nothing.
702
-
703
- **Opening an app.**
704
-
705
- - VS Code or Cursor: open `apps/<app>/<app>.code-workspace`.
706
- - WebStorm: open `apps/<app>/` as the project.
707
- - Claude Code: `qore code <app>` (see "`qore code`" below). Plain `claude`
708
- in the app folder is not enough: the folder holds no code, and Claude's
709
- search does not reach other directories unless they are added with
710
- `--add-dir`, which `qore code` does for you.
711
-
712
- **Commands inside `modules/<slug>`.** There is no `qore.workspace.json`
713
- there, so qore asks which apps list the module. One app: it is used. Several:
714
- an interactive run asks, otherwise pass `--app <slug>`. When the portal
715
- puts the module in more apps than are cloned here and one of the cloned
716
- ones is used, qore says so on stderr: `Using app <app> (the only app here
717
- using <module>; also in <apps> — pass --app to choose).`
718
-
719
- **`qore sync`** works for the whole tenant, not only the app you are in:
720
- it reads every app folder of the tenant that it can access, clones what is
721
- missing into `modules/`, fetches every checkout once, and rewrites every
722
- readable app's view files. An app folder it cannot read or access is
723
- reported and left alone, and its modules still count as used.
724
-
725
- **Converting the old layout.** Apps cloned before this layout hold real
726
- repositories at `<tenant>/<app>/<module>`. `qore sync` (or `qore clone` of
727
- such an app) converts what it finds:
728
-
729
- - a module checkout is moved to `modules/<slug>` (when several apps hold a
730
- copy you choose which one moves);
731
- - another app's copy of the same module is removed — only when it is clean;
732
- - the old app folder is retired: `qore.workspace.json` moves to
733
- `apps/<app>/` and a `README.md` stays behind saying where everything
734
- went (an existing README is kept, and reported).
735
-
736
- **Qore asks first**, once, listing every path it would change. Without
737
- your yes nothing is moved or removed and sync reports the changes as kept;
738
- it never asks with `--json`, `--no-input` or without a terminal, so run
739
- `qore sync` interactively to convert. A duplicate is **clean** when it has
740
- no uncommitted changes (untracked files that are not git-ignored count,
741
- whatever your `status.showUntrackedFiles` says), no commits that are not
742
- pushed (a detached HEAD counts), no stashes, and no linked worktrees (`git
743
- worktree add`, inside the clone or elsewhere); when git cannot tell, it is
744
- not clean. A clone with linked worktrees, or one that is itself a linked
745
- worktree, is never removed or moved: move it by hand, then run `git worktree
746
- repair`. A copy that is not clean is kept, with
747
- the reason, and you decide what to do with it. If a move fails — an
748
- editor or a running dev server can hold the folder, notably on Windows —
749
- the error says to stop `qore dev` for the app and run `qore sync` again.
750
- A checkout in `modules/` that no app uses any more is reported as `not used
751
- by any app — left in place`; qore never deletes it.
752
-
753
- Known limits:
754
-
755
- - `qore clone` of an app whose shared module still sits in another app's
756
- old-layout folder clones it a second time into `modules/`; the next
757
- `qore sync` offers to remove the old copy.
758
- - A module cloned by `qore dev` shows in an app's view files after the
759
- next `qore sync`.
760
-
761
- #### `qore code`
762
-
763
- ```sh
764
- qore code # the app you are in
765
- qore code <app> # an app of the tenant you are in
766
- qore code <app> -- --resume # arguments after -- go to claude
767
- ```
768
-
769
- Starts Claude Code in the app's frontend module, with every other module of
770
- the app and the app folder added (`--add-dir`), and sets
771
- `CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1` so Claude reads the added
772
- modules' `CLAUDE.md` files. An app without a frontend starts in the app
773
- folder. The module list comes from the portal.
774
-
775
- - **Which app.** `<app>` is looked up in the tenant of the current
776
- directory, else in the projects folder (a slug cloned in several places
777
- asks you to run it from inside one). Without `<app>`: from an app folder,
778
- that app; from `modules/<slug>`, the app that uses the module (a picker
779
- when several do, otherwise `Pass an app: used by …`).
780
- - It needs a projects folder and the shared layout. An old-layout
781
- workspace asks you to run `qore sync` first (`qore code needs the shared
782
- layout: run qore sync to convert this workspace.`); modules not cloned yet
783
- are listed with `Run qore sync first.`
784
- - `claude` not found: `QORE_TOOL_MISSING`, "Install Claude Code: npm i -g
785
- @anthropic-ai/claude-code". Otherwise `claude`'s own exit code (or
786
- 128 + signal) is `qore code`'s.
787
- - No `--json`.
36
+ ### Commands
37
+
38
+ The full reference is in [docs/commands.md](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md) (module commands,
39
+ repository context, `.qore.json`, `qore init`) and [docs/workspaces.md](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/workspaces.md)
40
+ (app workspaces, shared module checkouts, `qore dev` in a workspace root, `qore code`).
41
+
42
+ | Command | What it does |
43
+ |---------|--------------|
44
+ | `qore login` / `qore logout` / `qore whoami` | Device-code login in your browser; show the logged-in user and active tenant |
45
+ | `qore tenant list` / `qore tenant use <slug>` | List the tenants you have access to; set the active one |
46
+ | `qore version` | CLI + portal version info |
47
+ | [`qore init`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#projects-folder--qore-init) | Guided setup: projects folder, login, tenant, first app |
48
+ | [`qore config root`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#projects-folder--qore-init) | Show, set or clear the projects folder |
49
+ | [`qore config telemetry`](#privacy) | Show crash reporting's state, or turn it `on`/`off` |
50
+ | [`qore status`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-status) | Deployment and health per environment for the current module |
51
+ | [`qore env pull`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-env-pull) | Write this module's local secrets into an env file |
52
+ | [`qore run -- <command>`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-run) | Run a command with those secrets in its environment, without writing them to disk |
53
+ | [`qore roles list` / `sync` / `use`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-roles) | Show your code's roles and yours on `local`; announce them; take some |
54
+ | [`qore dev`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-dev) | Start this module's dev server, or [every module of an app](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/workspaces.md#qore-dev-workspace-root) from a workspace root |
55
+ | [`qore doctor`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-doctor) | Run the checks `qore` makes before other commands, on demand |
56
+ | [`qore db erd`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md#qore-db-erd) | Open the module's (or app's) data model in your browser, read from the local Postgres |
57
+ | [`qore clone` / `qore sync`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/workspaces.md#workspaces) | Set up a local directory for an app and its modules; keep it in step with the app |
58
+ | [`qore code`](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/workspaces.md#qore-code) | Start Claude Code in the app's frontend module, with every module added |
59
+ | `qore errors` / `qore traces` / `qore logs` | Recent errors, slow requests and logs per environment (examples above) |
788
60
 
789
61
  ### `--json`
790
62
 
@@ -860,6 +132,15 @@ by the Sentry project's "Prevent Storing of IP Addresses" setting, part of its i
860
132
  `qore config telemetry` and `qore doctor` show the current state and where it
861
133
  comes from. A build from source or a fork carries no DSN and sends nothing.
862
134
 
135
+ ## Documentation
136
+
137
+ - [docs/commands.md](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/commands.md) — every module command, repository context,
138
+ `.qore.json`, trust on first use, the projects folder and `qore init`.
139
+ - [docs/workspaces.md](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/workspaces.md) — `qore clone`/`qore sync`, `qore dev` in a
140
+ workspace root, shared module checkouts and `qore code`.
141
+ - [CLAUDE.md](https://github.com/Quatronic-IT/qore-cli/blob/main/CLAUDE.md) and [docs/internals/](https://github.com/Quatronic-IT/qore-cli/blob/main/docs/internals) — how the CLI is built,
142
+ for contributors.
143
+
863
144
  ## Releasing
864
145
 
865
- See [RELEASING.md](./RELEASING.md).
146
+ See [RELEASING.md](https://github.com/Quatronic-IT/qore-cli/blob/main/RELEASING.md).
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d011143c-a5e4-5dc8-8c44-cb092151ea87")}catch(e){}}();
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="38c248bd-8a58-507a-9332-8b7167190e5d")}catch(e){}}();
4
4
  import { createRequire as __qoreCreateRequire } from "node:module"; const require = __qoreCreateRequire(import.meta.url);
5
5
  import {
6
6
  addSecretValues,
@@ -4621,9 +4621,9 @@ async function erdApp(ctx, f, ws) {
4621
4621
 
4622
4622
  // src/cli/commands/dev.ts
4623
4623
  import { randomBytes as randomBytes8 } from "crypto";
4624
- import { realpath as realpath11 } from "fs/promises";
4624
+ import { realpath as realpath12 } from "fs/promises";
4625
4625
  import { constants as constants5 } from "os";
4626
- import { dirname as dirname10, join as join28, relative as relative9 } from "path";
4626
+ import { dirname as dirname10, join as join29, relative as relative9 } from "path";
4627
4627
  import { StringDecoder } from "string_decoder";
4628
4628
 
4629
4629
  // src/core/diagnostics/node.ts
@@ -4907,6 +4907,10 @@ function noLocalRole(o) {
4907
4907
  };
4908
4908
  }
4909
4909
 
4910
+ // src/core/dev/preflight.ts
4911
+ import { realpath as realpath10 } from "fs/promises";
4912
+ import { join as join25 } from "path";
4913
+
4910
4914
  // src/core/dev/project.ts
4911
4915
  import { access, readFile as readFile7 } from "fs/promises";
4912
4916
  import { join as join23 } from "path";
@@ -5195,6 +5199,24 @@ async function installIfNeeded(deps2, r, slug, onLine, report, signal) {
5195
5199
  }
5196
5200
  report({ module: slug, step: "install", status: "done", detail: secs(deps2.now().getTime() - began) });
5197
5201
  }
5202
+ async function checkoutEnv(dir2) {
5203
+ const named2 = await readRepoConfig(dir2).then((c) => c.envFile, () => void 0);
5204
+ for (const file of [named2, ".env.local", ".env"]) {
5205
+ if (!file) continue;
5206
+ const text2 = await readOrNull(join25(dir2, file));
5207
+ if (text2 !== null) return Object.fromEntries(parseEnv(text2));
5208
+ }
5209
+ return null;
5210
+ }
5211
+ async function isOtherCheckoutOfModule(dir2, o) {
5212
+ const module = o.env?.QORE_MODULE;
5213
+ const customer = o.env?.QORE_CUSTOMER_ID;
5214
+ if (!module || !customer || !o.root) return false;
5215
+ const resolve9 = (p) => realpath10(p).catch(() => p);
5216
+ if (await resolve9(dir2) === await resolve9(o.root)) return false;
5217
+ const other = await checkoutEnv(dir2);
5218
+ return other?.QORE_MODULE === module && other.QORE_CUSTOMER_ID === customer;
5219
+ }
5198
5220
  async function portInUseError(deps2, o) {
5199
5221
  const owner = await deps2.ports.owner(o.port);
5200
5222
  const qoreRun = (o.runs ?? []).find((r) => r.children.some((c) => c.port === o.port) || owner !== null && (r.qorePid === owner.pid || r.children.some((c) => c.pid === owner.pid)));
@@ -5207,6 +5229,12 @@ async function portInUseError(deps2, o) {
5207
5229
  if (owner) {
5208
5230
  if (/^(com\.docker\.backend|com\.docker\.vpnkit|docker-proxy|vpnkit|dockerd)$/.test(owner.command)) {
5209
5231
  const pub = await deps2.ports.dockerPublisher(o.port);
5232
+ if (pub?.workingDir && await isOtherCheckoutOfModule(pub.workingDir, o)) {
5233
+ return new QoreError("QORE_PORT_IN_USE", `Port ${o.port} is held by ${o.slug}'s database from ${pub.workingDir}`, {
5234
+ hint: `That is another checkout of ${o.slug}, and both use port ${o.port}. Stop it there (docker compose down in ${pub.workingDir}, or docker stop ${pub.name}), or run qore dev from that checkout instead.`,
5235
+ details: { port: o.port, module: o.slug, key: o.key, owner: "docker", sameModule: true, ...pub }
5236
+ });
5237
+ }
5210
5238
  if (pub) {
5211
5239
  return new QoreError("QORE_PORT_IN_USE", `Port ${o.port} is held by the Docker container ${pub.name} (needed by ${o.slug})`, {
5212
5240
  hint: `It belongs to compose project ${pub.project} in ${pub.workingDir} \u2014 typically another module's or tenant's database. Stop it there with docker compose down, or docker stop ${pub.name}.`,
@@ -5276,7 +5304,7 @@ async function startServices(deps2, r, slug, env, dbPort2, waitMs, signal, onLin
5276
5304
  const res = await runTool(deps2, cmd, args, { cwd: r.root, env, onLine, signal });
5277
5305
  if (res.code !== 0) {
5278
5306
  if (dbPort2 !== null && /port is already allocated|address already in use/i.test(res.tail.join("\n"))) {
5279
- throw await portInUseError(deps2, { slug, port: dbPort2, key: "DB_PORT" });
5307
+ throw await portInUseError(deps2, { slug, port: dbPort2, key: "DB_PORT", root: r.root, env });
5280
5308
  }
5281
5309
  throw await composeFailure(deps2, r, slug, env, signal, `${script} failed in ${slug}`, `${cmd} ${args.join(" ")}`, res.tail);
5282
5310
  }
@@ -5450,11 +5478,11 @@ function hintContext(recipe, pkg, env) {
5450
5478
 
5451
5479
  // src/core/dev/runFile.ts
5452
5480
  import { readdir as readdir5, unlink as unlink2 } from "fs/promises";
5453
- import { join as join25 } from "path";
5481
+ import { join as join26 } from "path";
5454
5482
  async function runFilePath(deps2, root) {
5455
- const dir2 = join25(deps2.config.dir, "run");
5483
+ const dir2 = join26(deps2.config.dir, "run");
5456
5484
  const name = `${await stateKey(deps2, root)}.json`;
5457
- return { dir: dir2, name, path: join25(dir2, name) };
5485
+ return { dir: dir2, name, path: join26(dir2, name) };
5458
5486
  }
5459
5487
  async function writeRunFile(deps2, root, rec) {
5460
5488
  const { dir: dir2, name } = await runFilePath(deps2, root);
@@ -5475,9 +5503,9 @@ async function leftoverRun(deps2, root, o = {}) {
5475
5503
  return null;
5476
5504
  }
5477
5505
  async function listRunFiles(deps2) {
5478
- const dir2 = join25(deps2.config.dir, "run");
5506
+ const dir2 = join26(deps2.config.dir, "run");
5479
5507
  const names = await readdir5(dir2).catch(() => []);
5480
- const recs = await Promise.all(names.filter((n) => n.endsWith(".json")).map((n) => readJson(join25(dir2, n)).catch(() => null)));
5508
+ const recs = await Promise.all(names.filter((n) => n.endsWith(".json")).map((n) => readJson(join26(dir2, n)).catch(() => null)));
5481
5509
  return recs.filter((r) => !!r && r.schemaVersion === 1 && Array.isArray(r.children));
5482
5510
  }
5483
5511
 
@@ -5606,8 +5634,8 @@ async function inPreflight(signals, outer, fn) {
5606
5634
  // src/cli/commands/devWorkspace.ts
5607
5635
  import { randomBytes as randomBytes7 } from "crypto";
5608
5636
  import { constants as constants4 } from "os";
5609
- import { realpath as realpath10 } from "fs/promises";
5610
- import { basename as basename7, join as join27, relative as relative8 } from "path";
5637
+ import { realpath as realpath11 } from "fs/promises";
5638
+ import { basename as basename7, join as join28, relative as relative8 } from "path";
5611
5639
 
5612
5640
  // src/core/dev/order.ts
5613
5641
  function selectSkips(modules, sel) {
@@ -5928,7 +5956,7 @@ function supervise(o) {
5928
5956
 
5929
5957
  // src/core/workspace/stray.ts
5930
5958
  import { lstat as lstat4, readdir as readdir6 } from "fs/promises";
5931
- import { join as join26 } from "path";
5959
+ import { join as join27 } from "path";
5932
5960
  var VIEW_ENTRIES = /* @__PURE__ */ new Set(["qore.workspace.json", ".idea", ".claude", "CLAUDE.md", "README.md"]);
5933
5961
  async function strayRepos(root, slugs, o = {}) {
5934
5962
  let entries;
@@ -5942,8 +5970,8 @@ async function strayRepos(root, slugs, o = {}) {
5942
5970
  if (slugs.has(name)) continue;
5943
5971
  if (o.view && (VIEW_ENTRIES.has(name) || name.endsWith(".code-workspace"))) continue;
5944
5972
  try {
5945
- if ((await readEntry(join26(root, name))).kind !== "dir") continue;
5946
- await lstat4(join26(root, name, ".git"));
5973
+ if ((await readEntry(join27(root, name))).kind !== "dir") continue;
5974
+ await lstat4(join27(root, name, ".git"));
5947
5975
  names.push(name);
5948
5976
  } catch {
5949
5977
  }
@@ -6147,7 +6175,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
6147
6175
  let neutral;
6148
6176
  const units = [];
6149
6177
  for (const u of planned) {
6150
- u.realDir = await realpath10(u.dir).catch(() => u.dir);
6178
+ u.realDir = await realpath11(u.dir).catch(() => u.dir);
6151
6179
  const match = await findRunning(running, { moduleId: u.m.id, realDir: u.realDir, exceptPid: deps2.pid, exceptRoot: ws.root });
6152
6180
  const port = match?.child.port ?? null;
6153
6181
  if (!match) {
@@ -6261,7 +6289,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
6261
6289
  workspace: ws,
6262
6290
  module: { id: u.m.id, slug: u.m.slug, name: u.m.name, type: u.m.type, access: u.m.access, tenant: am.app.tenant, apps: [appRef] }
6263
6291
  });
6264
- const rootReal = await realpath10(ws.root);
6292
+ const rootReal = await realpath11(ws.root);
6265
6293
  const withDocker = dockerRecovery(ctx, p.signal);
6266
6294
  for (const u of units.filter((x) => x.recipe && x.trusted)) {
6267
6295
  const slug = u.m.slug;
@@ -6287,7 +6315,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
6287
6315
  warn(`${slug}: the portal is unreachable \u2014 starting from ${relative8(rootReal, dev.envFile)} as last written; values may be stale.`, { module: slug });
6288
6316
  }
6289
6317
  if (dev.ignored === false) {
6290
- const repo = await realpath10(u.dir);
6318
+ const repo = await realpath11(u.dir);
6291
6319
  warn(`${slug}: ${notIgnoredWarning(relative8(repo, dev.envFile), relative8(rootReal, repo))}`, { module: slug });
6292
6320
  }
6293
6321
  if (dev.kept.length) {
@@ -6343,7 +6371,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
6343
6371
  if (online && units.every((u) => !u.dev.offline)) {
6344
6372
  const envFile = (m) => {
6345
6373
  const u = units.find((x) => x.m.id === m.id);
6346
- return u ? relative8(rootReal, u.dev.envFile) : join27(m.slug, moduleDefaults(m.type).envFile);
6374
+ return u ? relative8(rootReal, u.dev.envFile) : join28(m.slug, moduleDefaults(m.type).envFile);
6347
6375
  };
6348
6376
  await saveLastStart(deps2, ws.root, {
6349
6377
  schemaVersion: 1,
@@ -6628,7 +6656,7 @@ async function providerFindings(ctx, root, mc, app, env) {
6628
6656
  let fix = `qore clone ${app.slug}`;
6629
6657
  if (ws && ws.appId === app.id) fix = cdAndDev(deps2.home, ws.root);
6630
6658
  else if (providers.length === 1) {
6631
- const sibling = join28(dirname10(root), providers[0].slug);
6659
+ const sibling = join29(dirname10(root), providers[0].slug);
6632
6660
  if ((await deps2.git.inspect(sibling)).isRepo) fix = cdAndDev(deps2.home, sibling);
6633
6661
  }
6634
6662
  return providerDown({
@@ -6764,7 +6792,7 @@ async function prepareModule(ctx, f, waitTimeout, p) {
6764
6792
  if (c.offlineCause && isOffline(e)) throw c.offlineCause;
6765
6793
  throw e;
6766
6794
  }
6767
- const envFile = relative9(await realpath11(root), dev.envFile);
6795
+ const envFile = relative9(await realpath12(root), dev.envFile);
6768
6796
  if (dev.offline) io2.err(`! The portal is unreachable \u2014 starting from ${envFile} as last written; values may be stale.`);
6769
6797
  if (dev.ignored === false) io2.err(`! ${notIgnoredWarning(envFile)}`);
6770
6798
  if (dev.kept.length) {
@@ -6825,7 +6853,7 @@ function registerDebugTelemetry(program, ctx) {
6825
6853
  import pc3 from "picocolors";
6826
6854
 
6827
6855
  // src/core/doctor/checks.ts
6828
- import { realpath as realpath12, stat as stat6 } from "fs/promises";
6856
+ import { realpath as realpath13, stat as stat6 } from "fs/promises";
6829
6857
  import { basename as basename8 } from "path";
6830
6858
 
6831
6859
  // src/core/diagnostics/ssh.ts
@@ -7004,11 +7032,12 @@ function checkClock(meta) {
7004
7032
  function ownerText(e) {
7005
7033
  const d = e.details ?? {};
7006
7034
  if (d.owner === "process") return ` by ${String(d.command)} (pid ${String(d.pid)})`;
7035
+ if (d.owner === "docker" && d.sameModule) return ` by another checkout of ${String(d.module)} (${String(d.workingDir)})`;
7007
7036
  if (d.owner === "docker") return ` by the Docker container ${String(d.name)}`;
7008
7037
  if (d.owner === "qore") return ` by a previous qore dev (pid ${String(d.pid)})`;
7009
7038
  return "";
7010
7039
  }
7011
- var sameDir = async (a, b) => await realpath12(a).catch(() => a) === await realpath12(b).catch(() => b);
7040
+ var sameDir = async (a, b) => await realpath13(a).catch(() => a) === await realpath13(b).catch(() => b);
7012
7041
  async function moduleBody(deps2, m, runs, signal) {
7013
7042
  const parts = [];
7014
7043
  const part = async (fn) => {
@@ -7051,7 +7080,7 @@ async function moduleBody(deps2, m, runs, signal) {
7051
7080
  if (!await deps2.ports.inUse(dbPort2)) return { status: "ok", label: `db:up (DB_PORT ${dbPort2} free)` };
7052
7081
  const pub = await deps2.ports.dockerPublisher(dbPort2);
7053
7082
  if (pub?.workingDir && await sameDir(pub.workingDir, m.root)) return { status: "ok", label: "db running" };
7054
- const e = await portInUseError(deps2, { slug: m.slug, port: dbPort2, key: "DB_PORT" });
7083
+ const e = await portInUseError(deps2, { slug: m.slug, port: dbPort2, key: "DB_PORT", root: m.root, env: env ?? void 0 });
7055
7084
  return { status: "fail", label: `DB_PORT ${dbPort2} in use${ownerText(e)}`, error: e };
7056
7085
  });
7057
7086
  const status2 = parts.reduce((w, p) => RANK[p.status] > RANK[w] ? p.status : w, "ok");
@@ -7297,17 +7326,17 @@ function registerDoctor(program, ctx) {
7297
7326
 
7298
7327
  // src/cli/commands/env.ts
7299
7328
  import { randomBytes as randomBytes9 } from "crypto";
7300
- import { chmod as chmod4, realpath as realpath13 } from "fs/promises";
7301
- import { dirname as dirname11, join as join30, relative as relative10 } from "path";
7329
+ import { chmod as chmod4, realpath as realpath14 } from "fs/promises";
7330
+ import { dirname as dirname11, join as join31, relative as relative10 } from "path";
7302
7331
 
7303
7332
  // src/core/env/mobile.ts
7304
7333
  import { chmod as chmod3, stat as stat7 } from "fs/promises";
7305
- import { join as join29 } from "path";
7334
+ import { join as join30 } from "path";
7306
7335
  var MOBILE_ENV_FILE = "mobile/.env.local";
7307
7336
  var MOBILE_KEYS = ["EXPO_PUBLIC_SERVER_URL", "EXPO_PUBLIC_SENTRY_DSN", "EXPO_PUBLIC_QORE_ENV"];
7308
7337
  async function hasMobileApp(repoRoot) {
7309
7338
  try {
7310
- return (await stat7(join29(repoRoot, "mobile"))).isDirectory();
7339
+ return (await stat7(join30(repoRoot, "mobile"))).isDirectory();
7311
7340
  } catch {
7312
7341
  return false;
7313
7342
  }
@@ -7359,7 +7388,7 @@ function registerEnv(program, ctx) {
7359
7388
  const target = f.target ? await resolveTarget(mc.repoRoot, f.target, deps2.cwd) : await resolveTarget(mc.repoRoot, cfg.envFile ?? defaults.envFile);
7360
7389
  await ensureTrusted(c, mc, app, { yes: f.yes });
7361
7390
  const existing = await readOrNull(target);
7362
- const example = existing === null ? await readOrNull(join30(dirname11(target), ".env.example")) : null;
7391
+ const example = existing === null ? await readOrNull(join31(dirname11(target), ".env.example")) : null;
7363
7392
  const local = await fetchLocalEnv(deps2, mc, app);
7364
7393
  const inputs = {
7365
7394
  existing,
@@ -7400,7 +7429,7 @@ function registerEnv(program, ctx) {
7400
7429
  } else {
7401
7430
  await writeSecurely(target, plan.text);
7402
7431
  }
7403
- const rel = relative10(await realpath13(mc.repoRoot), target);
7432
+ const rel = relative10(await realpath14(mc.repoRoot), target);
7404
7433
  const mobile = await pullMobile(c, mc, app);
7405
7434
  if (g.json) {
7406
7435
  const names = {
@@ -7948,7 +7977,7 @@ function registerErrors(program, ctx) {
7948
7977
  }
7949
7978
 
7950
7979
  // src/cli/commands/init.ts
7951
- import { realpath as realpath14 } from "fs/promises";
7980
+ import { realpath as realpath15 } from "fs/promises";
7952
7981
 
7953
7982
  // src/core/auth/oidc.ts
7954
7983
  import * as oc from "openid-client";
@@ -8227,7 +8256,7 @@ async function rootStep(ctx, f) {
8227
8256
  input2 = await io2.input("Projects folder", { default: current ?? "~/qore" }) || current || "~/qore";
8228
8257
  }
8229
8258
  const wanted = await checkRoot(deps2, input2);
8230
- const asked = await realpath14(wanted).catch(() => wanted);
8259
+ const asked = await realpath15(wanted).catch(() => wanted);
8231
8260
  if (current && asked !== current && io2.interactive && !await io2.confirm(`Change the projects folder from ${current} to ${asked}? Nothing is moved.`, ctx.signal)) {
8232
8261
  return step("skipped", current);
8233
8262
  }
@@ -8411,7 +8440,7 @@ function registerPortal(program, ctx) {
8411
8440
  }
8412
8441
 
8413
8442
  // src/core/roles/read.ts
8414
- import { join as join31 } from "path";
8443
+ import { join as join32 } from "path";
8415
8444
 
8416
8445
  // src/core/roles/extract.ts
8417
8446
  var KNOWN = { user: "User", admin: "App admin" };
@@ -8446,7 +8475,7 @@ var SLUG = /^[a-z0-9][a-z0-9_-]*$/;
8446
8475
  var MAX_SLUG = 64;
8447
8476
  var MAX_ROLES = 100;
8448
8477
  async function readCodeRoles(repoRoot) {
8449
- const source = await readOrNull(join31(repoRoot, PERMISSIONS_FILE));
8478
+ const source = await readOrNull(join32(repoRoot, PERMISSIONS_FILE));
8450
8479
  if (source === null) {
8451
8480
  throw new QoreError("QORE_CONTEXT_UNSUPPORTED", `No ${PERMISSIONS_FILE} in this module`, {
8452
8481
  hint: "App roles live in the app's frontend module; run this there."
@@ -8637,8 +8666,8 @@ function registerStatus(program, ctx) {
8637
8666
  }
8638
8667
 
8639
8668
  // src/cli/commands/sync.ts
8640
- import { realpath as realpath15 } from "fs/promises";
8641
- import { basename as basename9, join as join32, relative as relative11 } from "path";
8669
+ import { realpath as realpath16 } from "fs/promises";
8670
+ import { basename as basename9, join as join33, relative as relative11 } from "path";
8642
8671
  import { Option as Option3 } from "commander";
8643
8672
  function asFailure2(slug, e) {
8644
8673
  if (e instanceof QoreError && e.code !== "QORE_GIT_UNAVAILABLE") {
@@ -8658,7 +8687,7 @@ async function syncInPlace(deps2, o) {
8658
8687
  continue;
8659
8688
  }
8660
8689
  try {
8661
- dirs[m.slug] = await deps2.git.inspect(join32(root, m.slug));
8690
+ dirs[m.slug] = await deps2.git.inspect(join33(root, m.slug));
8662
8691
  modulesForPlan.push(m);
8663
8692
  } catch (e) {
8664
8693
  earlyFailures.push(asFailure2(m.slug, e));
@@ -8690,7 +8719,7 @@ async function syncTenant(ctx, o) {
8690
8719
  const { deps: deps2, io: io2 } = ctx;
8691
8720
  const { layout, app } = o;
8692
8721
  const label3 = (root) => relative11(layout.tenantDir, root) || basename9(root);
8693
- const own = await realpath15(o.wsRoot).catch(() => o.wsRoot);
8722
+ const own = await realpath16(o.wsRoot).catch(() => o.wsRoot);
8694
8723
  const apps = [{ appSlug: app.app.slug, root: own, kind: o.kind, modules: app.modules }];
8695
8724
  const views = [{ appSlug: app.app.slug, name: app.app.name, appId: app.app.id, modules: app.modules }];
8696
8725
  const leftAlone = [];
@@ -9104,7 +9133,7 @@ async function maybeNotifyUpdate(deps2, io2, o, timeoutMs = DEFAULT_TIMEOUT_MS)
9104
9133
 
9105
9134
  // src/core/config.ts
9106
9135
  import { readFile as readFile8 } from "fs/promises";
9107
- import { join as join33 } from "path";
9136
+ import { join as join34 } from "path";
9108
9137
  var empty = () => ({ schemaVersion: 1, profiles: {} });
9109
9138
  var ConfigStore = class {
9110
9139
  constructor(dir2) {
@@ -9112,7 +9141,7 @@ var ConfigStore = class {
9112
9141
  }
9113
9142
  dir;
9114
9143
  get file() {
9115
- return join33(this.dir, "config.json");
9144
+ return join34(this.dir, "config.json");
9116
9145
  }
9117
9146
  async read() {
9118
9147
  let raw;
@@ -9145,7 +9174,7 @@ var ConfigStore = class {
9145
9174
  import { execFile, execFileSync } from "child_process";
9146
9175
  import { mkdir as mkdir6, readdir as readdir7, stat as stat8 } from "fs/promises";
9147
9176
  import { homedir } from "os";
9148
- import { dirname as dirname12, join as join34 } from "path";
9177
+ import { dirname as dirname12, join as join35 } from "path";
9149
9178
  function parseRemotes(stdout) {
9150
9179
  const seen = /* @__PURE__ */ new Set();
9151
9180
  const out = [];
@@ -9303,7 +9332,7 @@ async function inspect(dir2) {
9303
9332
  throw new QoreError("QORE_INTERNAL", `could not read ${dir2}`, { cause: err });
9304
9333
  }
9305
9334
  const empty2 = entries.length === 0;
9306
- const isRepo = await statOrThrow(join34(dir2, ".git")) !== void 0;
9335
+ const isRepo = await statOrThrow(join35(dir2, ".git")) !== void 0;
9307
9336
  const dirRemotes = isRepo ? await remotes(dir2) : [];
9308
9337
  return { exists: true, empty: empty2, isRepo, remotes: dirRemotes };
9309
9338
  }
@@ -9436,13 +9465,13 @@ var OsKeychain = class extends ChunkedKeychain {
9436
9465
 
9437
9466
  // src/platform/lock.ts
9438
9467
  import { mkdir as mkdir7, writeFile as writeFile7 } from "fs/promises";
9439
- import { join as join35 } from "path";
9468
+ import { join as join36 } from "path";
9440
9469
  import lockfile from "proper-lockfile";
9441
9470
  function fileLock(dir2) {
9442
9471
  return async (name, fn) => {
9443
- const locks = join35(dir2, "locks");
9472
+ const locks = join36(dir2, "locks");
9444
9473
  await mkdir7(locks, { recursive: true, mode: 448 });
9445
- const target = join35(locks, `${name}.lock`);
9474
+ const target = join36(locks, `${name}.lock`);
9446
9475
  await writeFile7(target, "", { flag: "a" });
9447
9476
  let release;
9448
9477
  let compromised;
@@ -9895,4 +9924,4 @@ if (!drained) {
9895
9924
  process.exit();
9896
9925
  }
9897
9926
  //# sourceMappingURL=cli.js.map
9898
- //# debugId=d011143c-a5e4-5dc8-8c44-cb092151ea87
9927
+ //# debugId=38c248bd-8a58-507a-9332-8b7167190e5d
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatronic/qore",
3
- "version": "0.5.0-rc.4",
3
+ "version": "0.5.0-rc.6",
4
4
  "description": "Qore developer CLI",
5
5
  "type": "module",
6
6
  "bin": {