@quatronic/qore 0.4.0-test.a3fa77f → 0.4.0-test.da8a6cf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -753
- package/dist/cli.js +89 -49
- 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
|
-
###
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
qore login
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
`qore
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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](
|
|
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]="
|
|
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]="b835275c-8d15-5d7d-a7de-97208ff12eb8")}catch(e){}}();
|
|
4
4
|
import { createRequire as __qoreCreateRequire } from "node:module"; const require = __qoreCreateRequire(import.meta.url);
|
|
5
5
|
import {
|
|
6
6
|
addSecretValues,
|
|
@@ -135,6 +135,7 @@ function processIo(interactive, stderrTTY = Boolean(process.stderr.isTTY)) {
|
|
|
135
135
|
stderrTTY,
|
|
136
136
|
stderrRaw: process.stderr,
|
|
137
137
|
async select(message, choices) {
|
|
138
|
+
if (choices.length === 0) throw noChoices(message);
|
|
138
139
|
try {
|
|
139
140
|
return await select({ message, choices });
|
|
140
141
|
} catch (e) {
|
|
@@ -170,6 +171,11 @@ function processIo(interactive, stderrTTY = Boolean(process.stderr.isTTY)) {
|
|
|
170
171
|
openUrl: openBrowser
|
|
171
172
|
};
|
|
172
173
|
}
|
|
174
|
+
function noChoices(message) {
|
|
175
|
+
return new QoreError("QORE_RESOURCE_NOT_FOUND", `Nothing to choose from (${message}): the list is empty`, {
|
|
176
|
+
hint: "Run `qore whoami` to check what your account has access to, or pass the value as an argument."
|
|
177
|
+
});
|
|
178
|
+
}
|
|
173
179
|
function createWaitForEnter(input2, output) {
|
|
174
180
|
return (message, signal) => new Promise((resolve9, reject) => {
|
|
175
181
|
const rl = createInterface({ input: input2, output, terminal: true });
|
|
@@ -617,8 +623,8 @@ var BUILTIN_PORTALS = {
|
|
|
617
623
|
pinnedIssuer: "https://auth.quatronic.app/realms/platform-prod"
|
|
618
624
|
},
|
|
619
625
|
staging: {
|
|
620
|
-
apiOrigin: "https://
|
|
621
|
-
pinnedIssuer: "https://auth-
|
|
626
|
+
apiOrigin: "https://api.qore-release.quatronic.app",
|
|
627
|
+
pinnedIssuer: "https://auth-release.quatronic.app/realms/platform-staging"
|
|
622
628
|
},
|
|
623
629
|
testing: {
|
|
624
630
|
apiOrigin: "https://api.qore-testing.quatronic.app",
|
|
@@ -4615,9 +4621,9 @@ async function erdApp(ctx, f, ws) {
|
|
|
4615
4621
|
|
|
4616
4622
|
// src/cli/commands/dev.ts
|
|
4617
4623
|
import { randomBytes as randomBytes8 } from "crypto";
|
|
4618
|
-
import { realpath as
|
|
4624
|
+
import { realpath as realpath12 } from "fs/promises";
|
|
4619
4625
|
import { constants as constants5 } from "os";
|
|
4620
|
-
import { dirname as dirname10, join as
|
|
4626
|
+
import { dirname as dirname10, join as join29, relative as relative9 } from "path";
|
|
4621
4627
|
import { StringDecoder } from "string_decoder";
|
|
4622
4628
|
|
|
4623
4629
|
// src/core/diagnostics/node.ts
|
|
@@ -4901,6 +4907,10 @@ function noLocalRole(o) {
|
|
|
4901
4907
|
};
|
|
4902
4908
|
}
|
|
4903
4909
|
|
|
4910
|
+
// src/core/dev/preflight.ts
|
|
4911
|
+
import { realpath as realpath10 } from "fs/promises";
|
|
4912
|
+
import { join as join25 } from "path";
|
|
4913
|
+
|
|
4904
4914
|
// src/core/dev/project.ts
|
|
4905
4915
|
import { access, readFile as readFile7 } from "fs/promises";
|
|
4906
4916
|
import { join as join23 } from "path";
|
|
@@ -5189,6 +5199,24 @@ async function installIfNeeded(deps2, r, slug, onLine, report, signal) {
|
|
|
5189
5199
|
}
|
|
5190
5200
|
report({ module: slug, step: "install", status: "done", detail: secs(deps2.now().getTime() - began) });
|
|
5191
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
|
+
}
|
|
5192
5220
|
async function portInUseError(deps2, o) {
|
|
5193
5221
|
const owner = await deps2.ports.owner(o.port);
|
|
5194
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)));
|
|
@@ -5201,6 +5229,12 @@ async function portInUseError(deps2, o) {
|
|
|
5201
5229
|
if (owner) {
|
|
5202
5230
|
if (/^(com\.docker\.backend|com\.docker\.vpnkit|docker-proxy|vpnkit|dockerd)$/.test(owner.command)) {
|
|
5203
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
|
+
}
|
|
5204
5238
|
if (pub) {
|
|
5205
5239
|
return new QoreError("QORE_PORT_IN_USE", `Port ${o.port} is held by the Docker container ${pub.name} (needed by ${o.slug})`, {
|
|
5206
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}.`,
|
|
@@ -5270,7 +5304,7 @@ async function startServices(deps2, r, slug, env, dbPort2, waitMs, signal, onLin
|
|
|
5270
5304
|
const res = await runTool(deps2, cmd, args, { cwd: r.root, env, onLine, signal });
|
|
5271
5305
|
if (res.code !== 0) {
|
|
5272
5306
|
if (dbPort2 !== null && /port is already allocated|address already in use/i.test(res.tail.join("\n"))) {
|
|
5273
|
-
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 });
|
|
5274
5308
|
}
|
|
5275
5309
|
throw await composeFailure(deps2, r, slug, env, signal, `${script} failed in ${slug}`, `${cmd} ${args.join(" ")}`, res.tail);
|
|
5276
5310
|
}
|
|
@@ -5444,11 +5478,11 @@ function hintContext(recipe, pkg, env) {
|
|
|
5444
5478
|
|
|
5445
5479
|
// src/core/dev/runFile.ts
|
|
5446
5480
|
import { readdir as readdir5, unlink as unlink2 } from "fs/promises";
|
|
5447
|
-
import { join as
|
|
5481
|
+
import { join as join26 } from "path";
|
|
5448
5482
|
async function runFilePath(deps2, root) {
|
|
5449
|
-
const dir2 =
|
|
5483
|
+
const dir2 = join26(deps2.config.dir, "run");
|
|
5450
5484
|
const name = `${await stateKey(deps2, root)}.json`;
|
|
5451
|
-
return { dir: dir2, name, path:
|
|
5485
|
+
return { dir: dir2, name, path: join26(dir2, name) };
|
|
5452
5486
|
}
|
|
5453
5487
|
async function writeRunFile(deps2, root, rec) {
|
|
5454
5488
|
const { dir: dir2, name } = await runFilePath(deps2, root);
|
|
@@ -5469,9 +5503,9 @@ async function leftoverRun(deps2, root, o = {}) {
|
|
|
5469
5503
|
return null;
|
|
5470
5504
|
}
|
|
5471
5505
|
async function listRunFiles(deps2) {
|
|
5472
|
-
const dir2 =
|
|
5506
|
+
const dir2 = join26(deps2.config.dir, "run");
|
|
5473
5507
|
const names = await readdir5(dir2).catch(() => []);
|
|
5474
|
-
const recs = await Promise.all(names.filter((n) => n.endsWith(".json")).map((n) => readJson(
|
|
5508
|
+
const recs = await Promise.all(names.filter((n) => n.endsWith(".json")).map((n) => readJson(join26(dir2, n)).catch(() => null)));
|
|
5475
5509
|
return recs.filter((r) => !!r && r.schemaVersion === 1 && Array.isArray(r.children));
|
|
5476
5510
|
}
|
|
5477
5511
|
|
|
@@ -5600,8 +5634,8 @@ async function inPreflight(signals, outer, fn) {
|
|
|
5600
5634
|
// src/cli/commands/devWorkspace.ts
|
|
5601
5635
|
import { randomBytes as randomBytes7 } from "crypto";
|
|
5602
5636
|
import { constants as constants4 } from "os";
|
|
5603
|
-
import { realpath as
|
|
5604
|
-
import { basename as basename7, join as
|
|
5637
|
+
import { realpath as realpath11 } from "fs/promises";
|
|
5638
|
+
import { basename as basename7, join as join28, relative as relative8 } from "path";
|
|
5605
5639
|
|
|
5606
5640
|
// src/core/dev/order.ts
|
|
5607
5641
|
function selectSkips(modules, sel) {
|
|
@@ -5922,7 +5956,7 @@ function supervise(o) {
|
|
|
5922
5956
|
|
|
5923
5957
|
// src/core/workspace/stray.ts
|
|
5924
5958
|
import { lstat as lstat4, readdir as readdir6 } from "fs/promises";
|
|
5925
|
-
import { join as
|
|
5959
|
+
import { join as join27 } from "path";
|
|
5926
5960
|
var VIEW_ENTRIES = /* @__PURE__ */ new Set(["qore.workspace.json", ".idea", ".claude", "CLAUDE.md", "README.md"]);
|
|
5927
5961
|
async function strayRepos(root, slugs, o = {}) {
|
|
5928
5962
|
let entries;
|
|
@@ -5936,8 +5970,8 @@ async function strayRepos(root, slugs, o = {}) {
|
|
|
5936
5970
|
if (slugs.has(name)) continue;
|
|
5937
5971
|
if (o.view && (VIEW_ENTRIES.has(name) || name.endsWith(".code-workspace"))) continue;
|
|
5938
5972
|
try {
|
|
5939
|
-
if ((await readEntry(
|
|
5940
|
-
await lstat4(
|
|
5973
|
+
if ((await readEntry(join27(root, name))).kind !== "dir") continue;
|
|
5974
|
+
await lstat4(join27(root, name, ".git"));
|
|
5941
5975
|
names.push(name);
|
|
5942
5976
|
} catch {
|
|
5943
5977
|
}
|
|
@@ -6141,7 +6175,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
|
|
|
6141
6175
|
let neutral;
|
|
6142
6176
|
const units = [];
|
|
6143
6177
|
for (const u of planned) {
|
|
6144
|
-
u.realDir = await
|
|
6178
|
+
u.realDir = await realpath11(u.dir).catch(() => u.dir);
|
|
6145
6179
|
const match = await findRunning(running, { moduleId: u.m.id, realDir: u.realDir, exceptPid: deps2.pid, exceptRoot: ws.root });
|
|
6146
6180
|
const port = match?.child.port ?? null;
|
|
6147
6181
|
if (!match) {
|
|
@@ -6255,7 +6289,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
|
|
|
6255
6289
|
workspace: ws,
|
|
6256
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] }
|
|
6257
6291
|
});
|
|
6258
|
-
const rootReal = await
|
|
6292
|
+
const rootReal = await realpath11(ws.root);
|
|
6259
6293
|
const withDocker = dockerRecovery(ctx, p.signal);
|
|
6260
6294
|
for (const u of units.filter((x) => x.recipe && x.trusted)) {
|
|
6261
6295
|
const slug = u.m.slug;
|
|
@@ -6281,7 +6315,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
|
|
|
6281
6315
|
warn(`${slug}: the portal is unreachable \u2014 starting from ${relative8(rootReal, dev.envFile)} as last written; values may be stale.`, { module: slug });
|
|
6282
6316
|
}
|
|
6283
6317
|
if (dev.ignored === false) {
|
|
6284
|
-
const repo = await
|
|
6318
|
+
const repo = await realpath11(u.dir);
|
|
6285
6319
|
warn(`${slug}: ${notIgnoredWarning(relative8(repo, dev.envFile), relative8(rootReal, repo))}`, { module: slug });
|
|
6286
6320
|
}
|
|
6287
6321
|
if (dev.kept.length) {
|
|
@@ -6337,7 +6371,7 @@ async function prepareWorkspace(ctx, ws, f, waitTimeout, p) {
|
|
|
6337
6371
|
if (online && units.every((u) => !u.dev.offline)) {
|
|
6338
6372
|
const envFile = (m) => {
|
|
6339
6373
|
const u = units.find((x) => x.m.id === m.id);
|
|
6340
|
-
return u ? relative8(rootReal, u.dev.envFile) :
|
|
6374
|
+
return u ? relative8(rootReal, u.dev.envFile) : join28(m.slug, moduleDefaults(m.type).envFile);
|
|
6341
6375
|
};
|
|
6342
6376
|
await saveLastStart(deps2, ws.root, {
|
|
6343
6377
|
schemaVersion: 1,
|
|
@@ -6622,7 +6656,7 @@ async function providerFindings(ctx, root, mc, app, env) {
|
|
|
6622
6656
|
let fix = `qore clone ${app.slug}`;
|
|
6623
6657
|
if (ws && ws.appId === app.id) fix = cdAndDev(deps2.home, ws.root);
|
|
6624
6658
|
else if (providers.length === 1) {
|
|
6625
|
-
const sibling =
|
|
6659
|
+
const sibling = join29(dirname10(root), providers[0].slug);
|
|
6626
6660
|
if ((await deps2.git.inspect(sibling)).isRepo) fix = cdAndDev(deps2.home, sibling);
|
|
6627
6661
|
}
|
|
6628
6662
|
return providerDown({
|
|
@@ -6758,7 +6792,7 @@ async function prepareModule(ctx, f, waitTimeout, p) {
|
|
|
6758
6792
|
if (c.offlineCause && isOffline(e)) throw c.offlineCause;
|
|
6759
6793
|
throw e;
|
|
6760
6794
|
}
|
|
6761
|
-
const envFile = relative9(await
|
|
6795
|
+
const envFile = relative9(await realpath12(root), dev.envFile);
|
|
6762
6796
|
if (dev.offline) io2.err(`! The portal is unreachable \u2014 starting from ${envFile} as last written; values may be stale.`);
|
|
6763
6797
|
if (dev.ignored === false) io2.err(`! ${notIgnoredWarning(envFile)}`);
|
|
6764
6798
|
if (dev.kept.length) {
|
|
@@ -6819,7 +6853,7 @@ function registerDebugTelemetry(program, ctx) {
|
|
|
6819
6853
|
import pc3 from "picocolors";
|
|
6820
6854
|
|
|
6821
6855
|
// src/core/doctor/checks.ts
|
|
6822
|
-
import { realpath as
|
|
6856
|
+
import { realpath as realpath13, stat as stat6 } from "fs/promises";
|
|
6823
6857
|
import { basename as basename8 } from "path";
|
|
6824
6858
|
|
|
6825
6859
|
// src/core/diagnostics/ssh.ts
|
|
@@ -6998,11 +7032,12 @@ function checkClock(meta) {
|
|
|
6998
7032
|
function ownerText(e) {
|
|
6999
7033
|
const d = e.details ?? {};
|
|
7000
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)})`;
|
|
7001
7036
|
if (d.owner === "docker") return ` by the Docker container ${String(d.name)}`;
|
|
7002
7037
|
if (d.owner === "qore") return ` by a previous qore dev (pid ${String(d.pid)})`;
|
|
7003
7038
|
return "";
|
|
7004
7039
|
}
|
|
7005
|
-
var sameDir = async (a, b) => await
|
|
7040
|
+
var sameDir = async (a, b) => await realpath13(a).catch(() => a) === await realpath13(b).catch(() => b);
|
|
7006
7041
|
async function moduleBody(deps2, m, runs, signal) {
|
|
7007
7042
|
const parts = [];
|
|
7008
7043
|
const part = async (fn) => {
|
|
@@ -7045,7 +7080,7 @@ async function moduleBody(deps2, m, runs, signal) {
|
|
|
7045
7080
|
if (!await deps2.ports.inUse(dbPort2)) return { status: "ok", label: `db:up (DB_PORT ${dbPort2} free)` };
|
|
7046
7081
|
const pub = await deps2.ports.dockerPublisher(dbPort2);
|
|
7047
7082
|
if (pub?.workingDir && await sameDir(pub.workingDir, m.root)) return { status: "ok", label: "db running" };
|
|
7048
|
-
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 });
|
|
7049
7084
|
return { status: "fail", label: `DB_PORT ${dbPort2} in use${ownerText(e)}`, error: e };
|
|
7050
7085
|
});
|
|
7051
7086
|
const status2 = parts.reduce((w, p) => RANK[p.status] > RANK[w] ? p.status : w, "ok");
|
|
@@ -7291,17 +7326,17 @@ function registerDoctor(program, ctx) {
|
|
|
7291
7326
|
|
|
7292
7327
|
// src/cli/commands/env.ts
|
|
7293
7328
|
import { randomBytes as randomBytes9 } from "crypto";
|
|
7294
|
-
import { chmod as chmod4, realpath as
|
|
7295
|
-
import { dirname as dirname11, join as
|
|
7329
|
+
import { chmod as chmod4, realpath as realpath14 } from "fs/promises";
|
|
7330
|
+
import { dirname as dirname11, join as join31, relative as relative10 } from "path";
|
|
7296
7331
|
|
|
7297
7332
|
// src/core/env/mobile.ts
|
|
7298
7333
|
import { chmod as chmod3, stat as stat7 } from "fs/promises";
|
|
7299
|
-
import { join as
|
|
7334
|
+
import { join as join30 } from "path";
|
|
7300
7335
|
var MOBILE_ENV_FILE = "mobile/.env.local";
|
|
7301
7336
|
var MOBILE_KEYS = ["EXPO_PUBLIC_SERVER_URL", "EXPO_PUBLIC_SENTRY_DSN", "EXPO_PUBLIC_QORE_ENV"];
|
|
7302
7337
|
async function hasMobileApp(repoRoot) {
|
|
7303
7338
|
try {
|
|
7304
|
-
return (await stat7(
|
|
7339
|
+
return (await stat7(join30(repoRoot, "mobile"))).isDirectory();
|
|
7305
7340
|
} catch {
|
|
7306
7341
|
return false;
|
|
7307
7342
|
}
|
|
@@ -7353,7 +7388,7 @@ function registerEnv(program, ctx) {
|
|
|
7353
7388
|
const target = f.target ? await resolveTarget(mc.repoRoot, f.target, deps2.cwd) : await resolveTarget(mc.repoRoot, cfg.envFile ?? defaults.envFile);
|
|
7354
7389
|
await ensureTrusted(c, mc, app, { yes: f.yes });
|
|
7355
7390
|
const existing = await readOrNull(target);
|
|
7356
|
-
const example = existing === null ? await readOrNull(
|
|
7391
|
+
const example = existing === null ? await readOrNull(join31(dirname11(target), ".env.example")) : null;
|
|
7357
7392
|
const local = await fetchLocalEnv(deps2, mc, app);
|
|
7358
7393
|
const inputs = {
|
|
7359
7394
|
existing,
|
|
@@ -7394,7 +7429,7 @@ function registerEnv(program, ctx) {
|
|
|
7394
7429
|
} else {
|
|
7395
7430
|
await writeSecurely(target, plan.text);
|
|
7396
7431
|
}
|
|
7397
|
-
const rel = relative10(await
|
|
7432
|
+
const rel = relative10(await realpath14(mc.repoRoot), target);
|
|
7398
7433
|
const mobile = await pullMobile(c, mc, app);
|
|
7399
7434
|
if (g.json) {
|
|
7400
7435
|
const names = {
|
|
@@ -7942,7 +7977,7 @@ function registerErrors(program, ctx) {
|
|
|
7942
7977
|
}
|
|
7943
7978
|
|
|
7944
7979
|
// src/cli/commands/init.ts
|
|
7945
|
-
import { realpath as
|
|
7980
|
+
import { realpath as realpath15 } from "fs/promises";
|
|
7946
7981
|
|
|
7947
7982
|
// src/core/auth/oidc.ts
|
|
7948
7983
|
import * as oc from "openid-client";
|
|
@@ -8186,6 +8221,11 @@ async function useTenant(ctx, slug, known) {
|
|
|
8186
8221
|
const portal = resolvePortal(g.portal, cfg.defaultProfile);
|
|
8187
8222
|
const me = known ?? await (await openSession(deps2, portal, "tenant use", requestLog(ctx))).api.get("/api/cli/v1/me");
|
|
8188
8223
|
const candidates = me.tenants.map((t) => ({ kind: "tenant", id: t.id, slug: t.slug, name: t.name }));
|
|
8224
|
+
if (me.tenants.length === 0) {
|
|
8225
|
+
throw new QoreError("QORE_NO_DEVELOPER_ACCESS", "Your account is not a developer in any organisation", {
|
|
8226
|
+
hint: "Ask an admin to invite you as a developer."
|
|
8227
|
+
});
|
|
8228
|
+
}
|
|
8189
8229
|
let chosen;
|
|
8190
8230
|
if (slug) {
|
|
8191
8231
|
const found = me.tenants.find((t) => t.slug === slug);
|
|
@@ -8216,7 +8256,7 @@ async function rootStep(ctx, f) {
|
|
|
8216
8256
|
input2 = await io2.input("Projects folder", { default: current ?? "~/qore" }) || current || "~/qore";
|
|
8217
8257
|
}
|
|
8218
8258
|
const wanted = await checkRoot(deps2, input2);
|
|
8219
|
-
const asked = await
|
|
8259
|
+
const asked = await realpath15(wanted).catch(() => wanted);
|
|
8220
8260
|
if (current && asked !== current && io2.interactive && !await io2.confirm(`Change the projects folder from ${current} to ${asked}? Nothing is moved.`, ctx.signal)) {
|
|
8221
8261
|
return step("skipped", current);
|
|
8222
8262
|
}
|
|
@@ -8400,7 +8440,7 @@ function registerPortal(program, ctx) {
|
|
|
8400
8440
|
}
|
|
8401
8441
|
|
|
8402
8442
|
// src/core/roles/read.ts
|
|
8403
|
-
import { join as
|
|
8443
|
+
import { join as join32 } from "path";
|
|
8404
8444
|
|
|
8405
8445
|
// src/core/roles/extract.ts
|
|
8406
8446
|
var KNOWN = { user: "User", admin: "App admin" };
|
|
@@ -8431,11 +8471,11 @@ async function extractRoles(source) {
|
|
|
8431
8471
|
|
|
8432
8472
|
// src/core/roles/read.ts
|
|
8433
8473
|
var PERMISSIONS_FILE = "src/lib/permissions.ts";
|
|
8434
|
-
var SLUG = /^[
|
|
8474
|
+
var SLUG = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
8435
8475
|
var MAX_SLUG = 64;
|
|
8436
8476
|
var MAX_ROLES = 100;
|
|
8437
8477
|
async function readCodeRoles(repoRoot) {
|
|
8438
|
-
const source = await readOrNull(
|
|
8478
|
+
const source = await readOrNull(join32(repoRoot, PERMISSIONS_FILE));
|
|
8439
8479
|
if (source === null) {
|
|
8440
8480
|
throw new QoreError("QORE_CONTEXT_UNSUPPORTED", `No ${PERMISSIONS_FILE} in this module`, {
|
|
8441
8481
|
hint: "App roles live in the app's frontend module; run this there."
|
|
@@ -8450,7 +8490,7 @@ async function readCodeRoles(repoRoot) {
|
|
|
8450
8490
|
const invalid4 = roles.filter((r) => !SLUG.test(r.slug) || r.slug.length > MAX_SLUG).map((r) => r.slug);
|
|
8451
8491
|
if (invalid4.length) {
|
|
8452
8492
|
throw new QoreError("QORE_CONTEXT_INVALID", `The portal refuses these role names: ${invalid4.join(", ")}`, {
|
|
8453
|
-
hint: `Use
|
|
8493
|
+
hint: `Use letters, digits, - and _, starting with a letter or digit, at most ${MAX_SLUG} characters.`,
|
|
8454
8494
|
details: { invalid: invalid4 }
|
|
8455
8495
|
});
|
|
8456
8496
|
}
|
|
@@ -8626,8 +8666,8 @@ function registerStatus(program, ctx) {
|
|
|
8626
8666
|
}
|
|
8627
8667
|
|
|
8628
8668
|
// src/cli/commands/sync.ts
|
|
8629
|
-
import { realpath as
|
|
8630
|
-
import { basename as basename9, join as
|
|
8669
|
+
import { realpath as realpath16 } from "fs/promises";
|
|
8670
|
+
import { basename as basename9, join as join33, relative as relative11 } from "path";
|
|
8631
8671
|
import { Option as Option3 } from "commander";
|
|
8632
8672
|
function asFailure2(slug, e) {
|
|
8633
8673
|
if (e instanceof QoreError && e.code !== "QORE_GIT_UNAVAILABLE") {
|
|
@@ -8647,7 +8687,7 @@ async function syncInPlace(deps2, o) {
|
|
|
8647
8687
|
continue;
|
|
8648
8688
|
}
|
|
8649
8689
|
try {
|
|
8650
|
-
dirs[m.slug] = await deps2.git.inspect(
|
|
8690
|
+
dirs[m.slug] = await deps2.git.inspect(join33(root, m.slug));
|
|
8651
8691
|
modulesForPlan.push(m);
|
|
8652
8692
|
} catch (e) {
|
|
8653
8693
|
earlyFailures.push(asFailure2(m.slug, e));
|
|
@@ -8679,7 +8719,7 @@ async function syncTenant(ctx, o) {
|
|
|
8679
8719
|
const { deps: deps2, io: io2 } = ctx;
|
|
8680
8720
|
const { layout, app } = o;
|
|
8681
8721
|
const label3 = (root) => relative11(layout.tenantDir, root) || basename9(root);
|
|
8682
|
-
const own = await
|
|
8722
|
+
const own = await realpath16(o.wsRoot).catch(() => o.wsRoot);
|
|
8683
8723
|
const apps = [{ appSlug: app.app.slug, root: own, kind: o.kind, modules: app.modules }];
|
|
8684
8724
|
const views = [{ appSlug: app.app.slug, name: app.app.name, appId: app.app.id, modules: app.modules }];
|
|
8685
8725
|
const leftAlone = [];
|
|
@@ -9093,7 +9133,7 @@ async function maybeNotifyUpdate(deps2, io2, o, timeoutMs = DEFAULT_TIMEOUT_MS)
|
|
|
9093
9133
|
|
|
9094
9134
|
// src/core/config.ts
|
|
9095
9135
|
import { readFile as readFile8 } from "fs/promises";
|
|
9096
|
-
import { join as
|
|
9136
|
+
import { join as join34 } from "path";
|
|
9097
9137
|
var empty = () => ({ schemaVersion: 1, profiles: {} });
|
|
9098
9138
|
var ConfigStore = class {
|
|
9099
9139
|
constructor(dir2) {
|
|
@@ -9101,7 +9141,7 @@ var ConfigStore = class {
|
|
|
9101
9141
|
}
|
|
9102
9142
|
dir;
|
|
9103
9143
|
get file() {
|
|
9104
|
-
return
|
|
9144
|
+
return join34(this.dir, "config.json");
|
|
9105
9145
|
}
|
|
9106
9146
|
async read() {
|
|
9107
9147
|
let raw;
|
|
@@ -9134,7 +9174,7 @@ var ConfigStore = class {
|
|
|
9134
9174
|
import { execFile, execFileSync } from "child_process";
|
|
9135
9175
|
import { mkdir as mkdir6, readdir as readdir7, stat as stat8 } from "fs/promises";
|
|
9136
9176
|
import { homedir } from "os";
|
|
9137
|
-
import { dirname as dirname12, join as
|
|
9177
|
+
import { dirname as dirname12, join as join35 } from "path";
|
|
9138
9178
|
function parseRemotes(stdout) {
|
|
9139
9179
|
const seen = /* @__PURE__ */ new Set();
|
|
9140
9180
|
const out = [];
|
|
@@ -9292,7 +9332,7 @@ async function inspect(dir2) {
|
|
|
9292
9332
|
throw new QoreError("QORE_INTERNAL", `could not read ${dir2}`, { cause: err });
|
|
9293
9333
|
}
|
|
9294
9334
|
const empty2 = entries.length === 0;
|
|
9295
|
-
const isRepo = await statOrThrow(
|
|
9335
|
+
const isRepo = await statOrThrow(join35(dir2, ".git")) !== void 0;
|
|
9296
9336
|
const dirRemotes = isRepo ? await remotes(dir2) : [];
|
|
9297
9337
|
return { exists: true, empty: empty2, isRepo, remotes: dirRemotes };
|
|
9298
9338
|
}
|
|
@@ -9425,13 +9465,13 @@ var OsKeychain = class extends ChunkedKeychain {
|
|
|
9425
9465
|
|
|
9426
9466
|
// src/platform/lock.ts
|
|
9427
9467
|
import { mkdir as mkdir7, writeFile as writeFile7 } from "fs/promises";
|
|
9428
|
-
import { join as
|
|
9468
|
+
import { join as join36 } from "path";
|
|
9429
9469
|
import lockfile from "proper-lockfile";
|
|
9430
9470
|
function fileLock(dir2) {
|
|
9431
9471
|
return async (name, fn) => {
|
|
9432
|
-
const locks =
|
|
9472
|
+
const locks = join36(dir2, "locks");
|
|
9433
9473
|
await mkdir7(locks, { recursive: true, mode: 448 });
|
|
9434
|
-
const target =
|
|
9474
|
+
const target = join36(locks, `${name}.lock`);
|
|
9435
9475
|
await writeFile7(target, "", { flag: "a" });
|
|
9436
9476
|
let release;
|
|
9437
9477
|
let compromised;
|
|
@@ -9884,4 +9924,4 @@ if (!drained) {
|
|
|
9884
9924
|
process.exit();
|
|
9885
9925
|
}
|
|
9886
9926
|
//# sourceMappingURL=cli.js.map
|
|
9887
|
-
//# debugId=
|
|
9927
|
+
//# debugId=b835275c-8d15-5d7d-a7de-97208ff12eb8
|