@lunora/cli 1.0.0-alpha.13 → 1.0.0-alpha.131
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/LICENSE.md +6 -0
- package/__assets__/package-og.svg +1 -1
- package/dist/bin.mjs +2 -10
- package/dist/index.d.mts +410 -324
- package/dist/index.d.ts +410 -324
- package/dist/index.mjs +1 -19
- package/dist/packem_chunks/handler.mjs +1 -150
- package/dist/packem_chunks/handler10.mjs +1 -22
- package/dist/packem_chunks/handler11.mjs +1 -192
- package/dist/packem_chunks/handler12.mjs +2 -131
- package/dist/packem_chunks/handler13.mjs +2 -65
- package/dist/packem_chunks/handler14.mjs +1 -58
- package/dist/packem_chunks/handler15.mjs +1 -79
- package/dist/packem_chunks/handler16.mjs +1 -43
- package/dist/packem_chunks/handler17.mjs +1 -105
- package/dist/packem_chunks/handler18.mjs +3 -170
- package/dist/packem_chunks/handler19.mjs +1 -89
- package/dist/packem_chunks/handler2.mjs +2 -114
- package/dist/packem_chunks/handler20.mjs +1 -94
- package/dist/packem_chunks/handler21.mjs +7 -311
- package/dist/packem_chunks/handler22.mjs +2 -0
- package/dist/packem_chunks/handler23.mjs +99 -0
- package/dist/packem_chunks/handler24.mjs +11 -0
- package/dist/packem_chunks/handler3.mjs +2 -204
- package/dist/packem_chunks/handler4.mjs +1 -33
- package/dist/packem_chunks/handler5.mjs +1 -49
- package/dist/packem_chunks/handler6.mjs +1 -91
- package/dist/packem_chunks/handler7.mjs +1 -42
- package/dist/packem_chunks/handler8.mjs +1 -174
- package/dist/packem_chunks/handler9.mjs +8 -16
- package/dist/packem_chunks/planDevCommand.mjs +7 -500
- package/dist/packem_chunks/runCodegenCommand.mjs +4 -52
- package/dist/packem_chunks/runDeployCommand.mjs +1 -504
- package/dist/packem_chunks/runInitCommand.mjs +996 -1295
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +9 -395
- package/dist/packem_chunks/runResetCommand.mjs +1 -41
- package/dist/packem_chunks/runRpcCommand.mjs +1 -68
- package/dist/packem_shared/COMMANDS-CCuhsVyI.mjs +1 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-xn-frBqK.mjs +12 -0
- package/dist/packem_shared/admin-token-DV5A9T5b.mjs +1 -0
- package/dist/packem_shared/admin-url-Ca-KI3d_.mjs +1 -0
- package/dist/packem_shared/api-spec-BENwiyUa.mjs +1 -0
- package/dist/packem_shared/buildRegistryIndex-DwySASBu.mjs +1 -0
- package/dist/packem_shared/cli-0uJWyeda.mjs +3 -0
- package/dist/packem_shared/codegen-error-DJN6pTH5.mjs +3 -0
- package/dist/packem_shared/command-Bjv4VmYA.mjs +1 -0
- package/dist/packem_shared/commands-C5pu77HK.mjs +19 -0
- package/dist/packem_shared/createLogger--C3x1FNE.mjs +2 -0
- package/dist/packem_shared/createRecordingSpawner-ByIqBepG.mjs +1 -0
- package/dist/packem_shared/deploy-target-Dvr9vxpR.mjs +1 -0
- package/dist/packem_shared/detect-package-manager-C4aS7HE4.mjs +1 -0
- package/dist/packem_shared/diffSnapshots-9bDd9nOK.mjs +5 -0
- package/dist/packem_shared/docker-CKvYE9YF.mjs +1 -0
- package/dist/packem_shared/insertSchemaExtension-DZReBZ4_.mjs +8 -0
- package/dist/packem_shared/open-url-CTU_g9gr.mjs +1 -0
- package/dist/packem_shared/output-format-D7cKB-O5.mjs +2 -0
- package/dist/packem_shared/parseManifest-x3WsxKHz.mjs +1 -0
- package/dist/packem_shared/platform-diagnostics-C4TFj5Pu.mjs +4 -0
- package/dist/packem_shared/post-codegen-hook-CjhP1OmV.mjs +1 -0
- package/dist/packem_shared/prompt-cancelled-C8Sj7OqI.mjs +1 -0
- package/dist/packem_shared/resolve-target-vxaXHmvg.mjs +1 -0
- package/dist/packem_shared/runAddCommand-CuvJ0l7a.mjs +1 -0
- package/dist/packem_shared/schema-drift-gate-d12lMICD.mjs +1 -0
- package/dist/packem_shared/schemaIrToSnapshot-Clwd2A8e.mjs +1 -0
- package/dist/packem_shared/storage-BazhWFmM.mjs +1 -0
- package/dist/packem_shared/tui-prompts-CCt3jm1k.mjs +4 -0
- package/dist/packem_shared/vectorize-metadata-BvZbbqUD.mjs +1 -0
- package/dist/packem_shared/wrangler-name-CHDf3rMP.mjs +1 -0
- package/dist/packem_shared/wrangler-secrets-DHpbsDN9.mjs +1 -0
- package/package.json +36 -16
- package/skills/README.md +28 -14
- package/skills/lunora/SKILL.md +48 -9
- package/skills/lunora-functions/SKILL.md +38 -3
- package/skills/lunora-migration-helper/SKILL.md +70 -17
- package/skills/lunora-performance-audit/SKILL.md +36 -6
- package/skills/lunora-quickstart/SKILL.md +86 -24
- package/skills/lunora-realtime/SKILL.md +43 -30
- package/dist/packem_shared/COMMANDS-D3h9Iwvl.mjs +0 -944
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs +0 -244
- package/dist/packem_shared/admin-url-4UzT-CI4.mjs +0 -19
- package/dist/packem_shared/api-spec-CtA6ilu4.mjs +0 -13
- package/dist/packem_shared/buildRegistryIndex-BcYe607_.mjs +0 -38
- package/dist/packem_shared/command-BC30oSBW.mjs +0 -14
- package/dist/packem_shared/commands-DGo2VAsr.mjs +0 -833
- package/dist/packem_shared/createLogger-B40gPzQo.mjs +0 -78
- package/dist/packem_shared/createRecordingSpawner-DxI3mebw.mjs +0 -43
- package/dist/packem_shared/detect-package-manager-DYp7n3mJ.mjs +0 -61
- package/dist/packem_shared/diffSnapshots-BeDvvNiF.mjs +0 -161
- package/dist/packem_shared/docker-hMQ97KSQ.mjs +0 -21
- package/dist/packem_shared/insertSchemaExtension-DAqbfr9Z.mjs +0 -64
- package/dist/packem_shared/open-url-Dfq6fAyT.mjs +0 -41
- package/dist/packem_shared/output-format-wUvAN6AL.mjs +0 -17
- package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +0 -56
- package/dist/packem_shared/parseManifest--vZf2FY1.mjs +0 -94
- package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +0 -16
- package/dist/packem_shared/runAddCommand-4TpVekdC.mjs +0 -4
- package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +0 -79
- package/dist/packem_shared/schemaIrToSnapshot-DdsljJT-.mjs +0 -43
- package/dist/packem_shared/storage-CaFkHfqA.mjs +0 -84
- package/dist/packem_shared/tui-prompts-M6OWsuyw.mjs +0 -663
- package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +0 -12
package/dist/index.d.mts
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
1
|
import { CodegenOptions, SchemaIR } from '@lunora/codegen';
|
|
2
2
|
import '@visulima/cerebro';
|
|
3
|
-
import { ensureDevVariables, ensureDevVarsExample,
|
|
4
|
-
|
|
3
|
+
import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets } from '@lunora/config';
|
|
4
|
+
import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
|
|
5
|
+
export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config/cloudflare';
|
|
5
6
|
/** Every command name the CLI registers (drives the `CommandName` type + tests). */
|
|
6
|
-
declare const COMMANDS: readonly ["init", "add", "dev", "codegen", "build", "deploy", "containers", "prepare", "link", "deployments", "logs", "run", "insights", "reset", "migrate", "export", "import", "seed", "backup", "verify", "info", "doctor", "env", "analyze", "view", "docs", "registry", "rules"];
|
|
7
|
+
declare const COMMANDS: readonly ["init", "add", "dev", "codegen", "build", "deploy", "containers", "prepare", "link", "deployments", "logs", "run", "insights", "reset", "migrate", "export", "import", "seed", "backup", "verify", "info", "doctor", "env", "analyze", "view", "docs", "registry", "rules", "mcp"];
|
|
7
8
|
type CommandName = (typeof COMMANDS)[number];
|
|
8
9
|
declare const VERSION: string;
|
|
9
10
|
interface RunCliOptions {
|
|
10
11
|
argv?: ReadonlyArray<string>;
|
|
11
12
|
cwd?: string;
|
|
12
13
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
* Inject a console-like logger so callers (tests) can capture cerebro's
|
|
15
|
+
* help / version / usage rendering. Omitted in production, where cerebro
|
|
16
|
+
* uses its default stdout/stderr logger.
|
|
17
|
+
*/
|
|
17
18
|
logger?: Console;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
|
-
* Run the CLI and resolve to the process exit code. cerebro handles help,
|
|
21
|
-
* version, usage, and unknown commands (the latter throws, caught here as 1).
|
|
22
|
-
* `shouldExitProcess: false` keeps the process alive so callers/tests read the
|
|
23
|
-
* captured exit code.
|
|
24
|
-
*/
|
|
21
|
+
* Run the CLI and resolve to the process exit code. cerebro handles help,
|
|
22
|
+
* version, usage, and unknown commands (the latter throws, caught here as 1).
|
|
23
|
+
* `shouldExitProcess: false` keeps the process alive so callers/tests read the
|
|
24
|
+
* captured exit code.
|
|
25
|
+
*/
|
|
25
26
|
declare const runCli: (options?: RunCliOptions) => Promise<number>;
|
|
26
27
|
/**
|
|
27
|
-
* The `--api-spec` flag's accepted values, mirroring `@lunora/codegen`'s
|
|
28
|
-
* `CodegenOptions["apiSpec"]`. `"openapi"` (the default) emits `openapi.json`;
|
|
29
|
-
* `"openrpc"` emits `openrpc.json`; `"both"` emits both; `"none"` emits neither.
|
|
30
|
-
*/
|
|
28
|
+
* The `--api-spec` flag's accepted values, mirroring `@lunora/codegen`'s
|
|
29
|
+
* `CodegenOptions["apiSpec"]`. `"openapi"` (the default) emits `openapi.json`;
|
|
30
|
+
* `"openrpc"` emits `openrpc.json`; `"both"` emits both; `"none"` emits neither.
|
|
31
|
+
*/
|
|
31
32
|
type ApiSpec = NonNullable<CodegenOptions["apiSpec"]>;
|
|
32
33
|
interface Logger {
|
|
33
34
|
debug?: (message: string) => void;
|
|
@@ -37,11 +38,11 @@ interface Logger {
|
|
|
37
38
|
warn: (message: string) => void;
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
|
-
* Narrowed view over the pail instance. `createPail` returns an intersection
|
|
41
|
-
* type that includes a constructor signature and `(...args: any[])` logger
|
|
42
|
-
* overloads, which the type-aware linter cannot safely resolve. We only ever
|
|
43
|
-
* call the level methods with a string, so we describe exactly that surface.
|
|
44
|
-
*/
|
|
41
|
+
* Narrowed view over the pail instance. `createPail` returns an intersection
|
|
42
|
+
* type that includes a constructor signature and `(...args: any[])` logger
|
|
43
|
+
* overloads, which the type-aware linter cannot safely resolve. We only ever
|
|
44
|
+
* call the level methods with a string, so we describe exactly that surface.
|
|
45
|
+
*/
|
|
45
46
|
interface PailLogger {
|
|
46
47
|
debug: (message: string) => void;
|
|
47
48
|
error: (message: string) => void;
|
|
@@ -51,25 +52,12 @@ interface PailLogger {
|
|
|
51
52
|
}
|
|
52
53
|
declare const createLogger: () => Logger;
|
|
53
54
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
|
|
59
|
-
*/
|
|
60
|
-
/**
|
|
61
|
-
* Direct access to the underlying pail instance for advanced use-cases.
|
|
62
|
-
* A Proxy keeps the public `pail` binding lazy: the real pail is only
|
|
63
|
-
* constructed on first property access, so importing this module (and thus
|
|
64
|
-
* the package barrel) stays side-effect-free.
|
|
65
|
-
*/
|
|
55
|
+
* Direct access to the underlying pail instance for advanced use-cases.
|
|
56
|
+
* A Proxy keeps the public `pail` binding lazy: the real pail is only
|
|
57
|
+
* constructed on first property access, so importing this module (and thus
|
|
58
|
+
* the package barrel) stays side-effect-free.
|
|
59
|
+
*/
|
|
66
60
|
declare const pail: PailLogger;
|
|
67
|
-
/**
|
|
68
|
-
* Emit a badged step line through the shared pail (the `init` flow's off-TTY
|
|
69
|
-
* fallback for the create-astro-style transcript). The `message` may contain
|
|
70
|
-
* newlines — `LunoraReporter` indents continuation lines under the badge so a
|
|
71
|
-
* dimmed answer sits below its question.
|
|
72
|
-
*/
|
|
73
61
|
interface CodegenCommandOptions {
|
|
74
62
|
/** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
|
|
75
63
|
apiSpec?: ApiSpec;
|
|
@@ -77,6 +65,14 @@ interface CodegenCommandOptions {
|
|
|
77
65
|
/** Output format: `pretty` (default) or `json`. */
|
|
78
66
|
format?: string;
|
|
79
67
|
logger: Logger;
|
|
68
|
+
/**
|
|
69
|
+
* Fail the run when any ERROR-level advisory is reported. Defaults to CI
|
|
70
|
+
* detection so a local `lunora codegen` stays advisory while a pipeline
|
|
71
|
+
* gates on it; `--no-strict-advisories` forces it off either way.
|
|
72
|
+
*/
|
|
73
|
+
strictAdvisories?: boolean;
|
|
74
|
+
/** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
|
|
75
|
+
target?: string;
|
|
80
76
|
}
|
|
81
77
|
interface CodegenCommandResult {
|
|
82
78
|
advisories: ReadonlyArray<{
|
|
@@ -86,19 +82,20 @@ interface CodegenCommandResult {
|
|
|
86
82
|
remediation: string;
|
|
87
83
|
}>;
|
|
88
84
|
cronTriggers: ReadonlyArray<string>;
|
|
89
|
-
/** Set when the run
|
|
85
|
+
/** Set when the run failed: an invalid `--format`, an unregistered target, or an error-level platform diagnostic. */
|
|
90
86
|
error?: string;
|
|
87
|
+
/** ERROR-level advisories that made the run fail, when strict mode is on. */
|
|
88
|
+
failedAdvisories: number;
|
|
91
89
|
outputDirectory: string;
|
|
92
90
|
}
|
|
93
91
|
declare const runCodegenCommand: (options: CodegenCommandOptions) => CodegenCommandResult;
|
|
94
|
-
/** `lunora codegen` handler (lazy-loaded via the command's `loader`). */
|
|
95
92
|
/** Rows per HTTP request when importing. Convex uses ~500; same here. */
|
|
96
93
|
declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
|
|
97
94
|
/**
|
|
98
|
-
* Minimal projection of `globalThis.fetch` for the export path — we need
|
|
99
|
-
* `body` as a stream-iterable, which the shared {@link FetchLike} type
|
|
100
|
-
* intentionally hides for the JSON-only commands.
|
|
101
|
-
*/
|
|
95
|
+
* Minimal projection of `globalThis.fetch` for the export path — we need
|
|
96
|
+
* `body` as a stream-iterable, which the shared {@link FetchLike} type
|
|
97
|
+
* intentionally hides for the JSON-only commands.
|
|
98
|
+
*/
|
|
102
99
|
type StreamingFetchLike = (input: string, init?: {
|
|
103
100
|
body?: string;
|
|
104
101
|
headers?: Record<string, string>;
|
|
@@ -132,10 +129,10 @@ interface ExportCommandResult {
|
|
|
132
129
|
rows: number;
|
|
133
130
|
}
|
|
134
131
|
/**
|
|
135
|
-
* Stream an export. The worker emits NDJSON; we count newlines as we go and
|
|
136
|
-
* pipe straight to the output sink, so a 10M-row export doesn't materialise
|
|
137
|
-
* the body in memory.
|
|
138
|
-
*/
|
|
132
|
+
* Stream an export. The worker emits NDJSON; we count newlines as we go and
|
|
133
|
+
* pipe straight to the output sink, so a 10M-row export doesn't materialise
|
|
134
|
+
* the body in memory.
|
|
135
|
+
*/
|
|
139
136
|
declare const runExportCommand: (options: ExportCommandOptions) => Promise<ExportCommandResult>;
|
|
140
137
|
interface ImportCommandOptions {
|
|
141
138
|
/** Rows per HTTP request. Defaults to {@link DEFAULT_IMPORT_BATCH_SIZE}. */
|
|
@@ -147,13 +144,15 @@ interface ImportCommandOptions {
|
|
|
147
144
|
logger: Logger;
|
|
148
145
|
prod?: boolean;
|
|
149
146
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
147
|
+
* Wrap each line as `{table:<name>,doc:<line>}`. Use when the source NDJSON
|
|
148
|
+
* is bare docs from a single table — Convex's `convex import --table users`
|
|
149
|
+
* shape.
|
|
150
|
+
*/
|
|
154
151
|
table?: string;
|
|
155
152
|
token?: string;
|
|
156
153
|
url?: string;
|
|
154
|
+
/** Confirm bulk-writing production. Required alongside `--prod`. */
|
|
155
|
+
yes?: boolean;
|
|
157
156
|
}
|
|
158
157
|
interface ImportCommandResult {
|
|
159
158
|
body: unknown;
|
|
@@ -162,70 +161,100 @@ interface ImportCommandResult {
|
|
|
162
161
|
inserted: number;
|
|
163
162
|
}
|
|
164
163
|
/**
|
|
165
|
-
* Stream an NDJSON file
|
|
166
|
-
* `/_lunora/admin/import`.
|
|
167
|
-
* multi-GiB
|
|
168
|
-
|
|
164
|
+
* Stream an NDJSON file — or a `npx convex export --path <dir>` directory — in
|
|
165
|
+
* chunks, POSTing each batch to `/_lunora/admin/import`. The line buffer stays
|
|
166
|
+
* bounded by `batchSize`, so a multi-GiB source imports without buffering
|
|
167
|
+
* everything in memory.
|
|
168
|
+
*/
|
|
169
169
|
declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
|
|
170
170
|
/**
|
|
171
|
-
* Injectable probe for a Docker-compatible container engine. Tests pass a
|
|
172
|
-
* stub; production uses {@link isDockerAvailable}.
|
|
173
|
-
*/
|
|
171
|
+
* Injectable probe for a Docker-compatible container engine. Tests pass a
|
|
172
|
+
* stub; production uses {@link isDockerAvailable}.
|
|
173
|
+
*/
|
|
174
174
|
type DockerProbe = () => boolean;
|
|
175
|
-
/**
|
|
176
|
-
* True when a Docker-compatible engine answers `docker info` — the same
|
|
177
|
-
* prerequisite `wrangler deploy` has for building and pushing a container
|
|
178
|
-
* image from a local Dockerfile. Quiet by design (output discarded): callers
|
|
179
|
-
* own the messaging.
|
|
180
|
-
*/
|
|
181
175
|
interface SpawnDescriptor {
|
|
182
176
|
args: ReadonlyArray<string>;
|
|
183
177
|
/**
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
178
|
+
* Capture the child's stderr (in addition to streaming it to the parent).
|
|
179
|
+
* Needed when a tool reports the *expected* outcome as an error there —
|
|
180
|
+
* `wrangler vectorize create-metadata-index` writes "already exists" to
|
|
181
|
+
* stderr, and without this the caller can only see a bare exit code and
|
|
182
|
+
* would warn on every re-run. Composes with `stdoutToStderr`, so a caller
|
|
183
|
+
* can keep stdout clean for `--format json` and still read the reason.
|
|
184
|
+
*/
|
|
185
|
+
captureStderr?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Capture the child's stdout (in addition to streaming it to the parent), so
|
|
188
|
+
* the caller can parse it — used by `deploy` to read the deployed URL from
|
|
189
|
+
* `wrangler deploy` output. Each chunk is still teed to the parent's stdout
|
|
190
|
+
* so the user sees live progress. Mutually exclusive with `stdoutToStderr`.
|
|
191
|
+
*/
|
|
189
192
|
captureStdout?: boolean;
|
|
190
193
|
command: string;
|
|
191
194
|
cwd?: string;
|
|
192
195
|
env?: Readonly<Record<string, string>>;
|
|
193
196
|
/**
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
197
|
+
* Pipe this string into the child's stdin and close it. Used to feed
|
|
198
|
+
* `wrangler secret put` its value without exposing it on the command
|
|
199
|
+
* line or in env. When absent, stdin is inherited from the parent.
|
|
200
|
+
*/
|
|
198
201
|
input?: string;
|
|
199
202
|
/**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
* Route the child's stdout to the parent's STDERR instead of stdout. Set in
|
|
204
|
+
* `--format json` mode so a spawned tool's human output (e.g. `wrangler
|
|
205
|
+
* deploy`'s progress + the deployed URL) can't interleave with — and corrupt
|
|
206
|
+
* — the single JSON document the command prints to stdout.
|
|
207
|
+
*/
|
|
205
208
|
stdoutToStderr?: boolean;
|
|
206
209
|
}
|
|
207
210
|
interface SpawnResult {
|
|
208
211
|
code: number;
|
|
212
|
+
/** The captured stderr, present only when the descriptor set `captureStderr`. */
|
|
213
|
+
stderr?: string;
|
|
209
214
|
/** The captured stdout, present only when the descriptor set `captureStdout`. */
|
|
210
215
|
stdout?: string;
|
|
211
216
|
}
|
|
212
217
|
/**
|
|
213
|
-
* Injectable spawner. Tests pass a stub that just records the descriptor
|
|
214
|
-
* instead of executing a real subprocess.
|
|
215
|
-
*/
|
|
218
|
+
* Injectable spawner. Tests pass a stub that just records the descriptor
|
|
219
|
+
* instead of executing a real subprocess.
|
|
220
|
+
*/
|
|
216
221
|
type Spawner = (descriptor: SpawnDescriptor) => Promise<SpawnResult>;
|
|
217
222
|
declare const defaultSpawner: Spawner;
|
|
218
223
|
interface RecordedSpawn {
|
|
219
224
|
descriptor: SpawnDescriptor;
|
|
220
225
|
}
|
|
221
226
|
/**
|
|
222
|
-
* Test helper: returns a spawner that records every invocation and resolves
|
|
223
|
-
* with the configured exit code.
|
|
224
|
-
*/
|
|
227
|
+
* Test helper: returns a spawner that records every invocation and resolves
|
|
228
|
+
* with the configured exit code.
|
|
229
|
+
*/
|
|
225
230
|
declare const createRecordingSpawner: (exitCode?: number) => {
|
|
226
231
|
calls: RecordedSpawn[];
|
|
227
232
|
spawner: Spawner;
|
|
228
233
|
};
|
|
234
|
+
interface SecretListRunnerResult {
|
|
235
|
+
code: number;
|
|
236
|
+
stderr: string;
|
|
237
|
+
stdout: string;
|
|
238
|
+
}
|
|
239
|
+
/** Runs an argv and resolves its captured output. Injected in tests. */
|
|
240
|
+
type SecretListRunner = (command: string, args: ReadonlyArray<string>, cwd: string) => Promise<SecretListRunnerResult>;
|
|
241
|
+
interface ListRemoteSecretsInputs {
|
|
242
|
+
cwd: string;
|
|
243
|
+
/** Cloudflare environment name (`--env`). */
|
|
244
|
+
env?: string;
|
|
245
|
+
/** Injected command runner; defaults to a real `wrangler secret list`. */
|
|
246
|
+
runner?: SecretListRunner;
|
|
247
|
+
/** Target a temporary-account deployment (`--temporary`). */
|
|
248
|
+
temporary?: boolean;
|
|
249
|
+
}
|
|
250
|
+
interface ListRemoteSecretsResult {
|
|
251
|
+
/** Diagnostic message when `ok` is false. */
|
|
252
|
+
error?: string;
|
|
253
|
+
/** Remote secret names (sorted), empty when none or on failure. */
|
|
254
|
+
names: ReadonlyArray<string>;
|
|
255
|
+
/** False when wrangler failed or its output could not be parsed. */
|
|
256
|
+
ok: boolean;
|
|
257
|
+
}
|
|
229
258
|
type FetchLike = (input: string, init?: {
|
|
230
259
|
body?: string;
|
|
231
260
|
headers?: Record<string, string>;
|
|
@@ -238,11 +267,17 @@ type FetchLike = (input: string, init?: {
|
|
|
238
267
|
}>;
|
|
239
268
|
interface RunCommandOptions {
|
|
240
269
|
args?: string;
|
|
270
|
+
/** Forge this user id for the call (dispatches through the admin-gated `runAs` op). */
|
|
271
|
+
as?: string;
|
|
272
|
+
/** JSON-encoded extra identity claims to accompany {@link RunCommandOptions.as}. */
|
|
273
|
+
claims?: string;
|
|
241
274
|
cwd?: string;
|
|
242
275
|
fetchImpl?: FetchLike;
|
|
243
276
|
functionPath: string;
|
|
244
277
|
logger: Logger;
|
|
245
278
|
shard?: string;
|
|
279
|
+
/** Admin bearer for the `runAs` dispatch; resolved from the environment / `.dev.vars` when absent. */
|
|
280
|
+
token?: string;
|
|
246
281
|
url?: string;
|
|
247
282
|
}
|
|
248
283
|
interface RunCommandResult {
|
|
@@ -251,7 +286,6 @@ interface RunCommandResult {
|
|
|
251
286
|
requestUrl: string;
|
|
252
287
|
}
|
|
253
288
|
declare const runRpcCommand: (options: RunCommandOptions) => Promise<RunCommandResult>;
|
|
254
|
-
/** `lunora run <functionPath>` handler (lazy-loaded via the command's `loader`). */
|
|
255
289
|
interface DeployCommandOptions {
|
|
256
290
|
/** Override the schema-drift gate — deploy even with breaking drift and no new migration. */
|
|
257
291
|
allowSchemaDrift?: boolean;
|
|
@@ -261,10 +295,10 @@ interface DeployCommandOptions {
|
|
|
261
295
|
/** Docker-availability probe injected in tests. Defaults to a real `docker info` check. */
|
|
262
296
|
dockerAvailable?: DockerProbe;
|
|
263
297
|
/**
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
298
|
+
* Validate, bundle, and run all pre-deploy gates without publishing
|
|
299
|
+
* (`wrangler deploy --dry-run`). Post-deploy steps (data migrations, schema
|
|
300
|
+
* baseline re-bless) are skipped since nothing shipped.
|
|
301
|
+
*/
|
|
268
302
|
dryRun?: boolean;
|
|
269
303
|
env?: string;
|
|
270
304
|
/** Fetch implementation injected in tests for `--migrate` RPC calls. */
|
|
@@ -275,59 +309,71 @@ interface DeployCommandOptions {
|
|
|
275
309
|
interactive?: boolean;
|
|
276
310
|
logger: Logger;
|
|
277
311
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
312
|
+
* When true, after a successful `wrangler deploy`, discover and run all
|
|
313
|
+
* pending data migrations via the worker's `/_lunora/migrate` admin RPC.
|
|
314
|
+
* The worker must be live (exit 0) before migrations are attempted.
|
|
315
|
+
*
|
|
316
|
+
* Implementation note: the status RPC returns the full shard-level
|
|
317
|
+
* migration state, but there is no single authoritative "list of pending
|
|
318
|
+
* migration ids" that can be read client-side before running the worker.
|
|
319
|
+
* Instead, `--migrate` runs `migrate status` followed by `migrate up` for
|
|
320
|
+
* each migration id discovered locally via `discoverMigrations`. The
|
|
321
|
+
* worker's `MigrationRunner` is idempotent — running `up` on an already-
|
|
322
|
+
* applied migration is a no-op — so this approach is safe.
|
|
323
|
+
*/
|
|
290
324
|
migrate?: boolean;
|
|
291
325
|
/** Admin bearer token for `--migrate` (falls back to `LUNORA_ADMIN_TOKEN`). */
|
|
292
326
|
migrateToken?: string;
|
|
293
327
|
/**
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
328
|
+
* Worker URL for `--migrate`. REQUIRED when `--migrate` is set — the deploy
|
|
329
|
+
* handler never captures the URL `wrangler deploy` published to, so there is
|
|
330
|
+
* no safe default; omitting it would silently target `http://localhost:8787`
|
|
331
|
+
* (the dev worker), applying the migration to local state instead of prod.
|
|
332
|
+
*/
|
|
299
333
|
migrateUrl?: string;
|
|
300
334
|
/**
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
335
|
+
* Confirm a production data migration triggered via `--migrate` (the
|
|
336
|
+
* `migrate up --prod` confirmation the standalone command requires). Without
|
|
337
|
+
* it a `--migrate --migrate-url <prod>` deploy refuses to run the migration.
|
|
338
|
+
*/
|
|
305
339
|
migrateYes?: boolean;
|
|
306
340
|
/**
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
341
|
+
* Emit the bundled worker to this directory via `wrangler deploy --outdir`
|
|
342
|
+
* (paired with `dryRun` by `lunora build`). Also writes esbuild metadata to
|
|
343
|
+
* `<outDir>/bundle-meta.json`. When unset, no artifact is written.
|
|
344
|
+
*/
|
|
311
345
|
outDir?: string;
|
|
312
346
|
/**
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
347
|
+
* Upload a preview version (`wrangler versions upload`) instead of a live
|
|
348
|
+
* `wrangler deploy`. Codegen + the drift gate + validation still run, but
|
|
349
|
+
* the post-deploy finalize (migrations, baseline re-bless, auto-link, the
|
|
350
|
+
* production summary) is skipped — a preview never shifts live traffic.
|
|
351
|
+
*/
|
|
318
352
|
preview?: boolean;
|
|
319
353
|
/** Railpack-availability probe injected in tests. Defaults to a real `railpack --version` + `BUILDKIT_HOST` check. */
|
|
320
354
|
railpackAvailable?: DockerProbe;
|
|
355
|
+
/** Confirm prompt for the missing-secret offer; injected in tests. Defaults to the TTY prompt. */
|
|
356
|
+
secretConfirm?: (message: string) => Promise<boolean>;
|
|
357
|
+
/** Remote-secret lister for the missing-secret offer; injected in tests. Defaults to `wrangler secret list`. */
|
|
358
|
+
secretLister?: (inputs: ListRemoteSecretsInputs) => Promise<ListRemoteSecretsResult>;
|
|
321
359
|
skipCodegen?: boolean;
|
|
322
360
|
spawner?: Spawner;
|
|
323
361
|
/**
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
362
|
+
* Deploy target. Falls back to `"target"` in `lunora.json`, then
|
|
363
|
+
* `"cloudflare"`, which selects the wrangler
|
|
364
|
+
* toolchain — i.e. today's behavior for every project. An unregistered name
|
|
365
|
+
* throws rather than falling back, so a typo can never ship the app to the
|
|
366
|
+
* wrong provider.
|
|
367
|
+
*/
|
|
368
|
+
target?: string;
|
|
369
|
+
/**
|
|
370
|
+
* Deploy to a temporary Cloudflare account (`wrangler deploy --temporary`).
|
|
371
|
+
* For unauthenticated use only: wrangler provisions a short-lived account +
|
|
372
|
+
* token, deploys, and prints a claim URL; the deployment stays live ~60
|
|
373
|
+
* minutes before the unclaimed account is deleted. Wrangler itself errors
|
|
374
|
+
* if credentials are already present (OAuth / `CLOUDFLARE_API_TOKEN` /
|
|
375
|
+
* global API key), so we pass the flag straight through without guarding.
|
|
376
|
+
*/
|
|
331
377
|
temporary?: boolean;
|
|
332
378
|
/** Re-bless the committed schema baseline with the current shape (accepts breaking drift). */
|
|
333
379
|
updateSchemaBaseline?: boolean;
|
|
@@ -348,18 +394,17 @@ interface DeployCommandResult {
|
|
|
348
394
|
};
|
|
349
395
|
}
|
|
350
396
|
/**
|
|
351
|
-
* Run a deploy, then (in `--format json` mode) serialize the structured
|
|
352
|
-
* {@link DeployCommandResult} to stdout. Human/progress logging is routed to
|
|
353
|
-
* stderr for json output so stdout carries only the single JSON document.
|
|
354
|
-
*/
|
|
397
|
+
* Run a deploy, then (in `--format json` mode) serialize the structured
|
|
398
|
+
* {@link DeployCommandResult} to stdout. Human/progress logging is routed to
|
|
399
|
+
* stderr for json output so stdout carries only the single JSON document.
|
|
400
|
+
*/
|
|
355
401
|
declare const runDeployCommand: (options: DeployCommandOptions) => Promise<DeployCommandResult>;
|
|
356
|
-
/** `lunora deploy` handler (lazy-loaded via the command's `loader`). */
|
|
357
402
|
/**
|
|
358
|
-
* Start the codegen watch loop and return a handle to stop it. Regenerates on
|
|
359
|
-
* startup, then on debounced changes under `lunora/` (ignoring writes to the
|
|
360
|
-
* `_generated/` output to avoid a feedback loop). If the platform can't do a
|
|
361
|
-
* recursive watch, it logs once and falls back to startup-only codegen.
|
|
362
|
-
*/
|
|
403
|
+
* Start the codegen watch loop and return a handle to stop it. Regenerates on
|
|
404
|
+
* startup, then on debounced changes under `lunora/` (ignoring writes to the
|
|
405
|
+
* `_generated/` output to avoid a feedback loop). If the platform can't do a
|
|
406
|
+
* recursive watch, it logs once and falls back to startup-only codegen.
|
|
407
|
+
*/
|
|
363
408
|
declare const startCodegenWatch: (options: CodegenWatcherOptions) => CodegenWatcherHandle;
|
|
364
409
|
interface CodegenWatcherOptions {
|
|
365
410
|
/** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
|
|
@@ -371,23 +416,25 @@ interface CodegenWatcherOptions {
|
|
|
371
416
|
lunoraDirectory?: string;
|
|
372
417
|
/** Project root containing the `lunora/` directory. */
|
|
373
418
|
projectRoot: string;
|
|
419
|
+
/** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
|
|
420
|
+
target?: string;
|
|
374
421
|
}
|
|
375
422
|
interface CodegenWatcherHandle {
|
|
376
423
|
/** Stop watching and cancel any pending regeneration. */
|
|
377
424
|
close: () => void;
|
|
378
425
|
/**
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
426
|
+
* `true` when the platform supports recursive watch and the loop is active.
|
|
427
|
+
* `false` when `fs.watch({ recursive })` threw — startup-only codegen was run
|
|
428
|
+
* but schema edits will NOT auto-regenerate. Callers can surface this in the
|
|
429
|
+
* dev banner so the degraded state is visible beyond the single startup warning.
|
|
430
|
+
*/
|
|
384
431
|
watchAvailable: boolean;
|
|
385
432
|
}
|
|
386
433
|
/**
|
|
387
|
-
* Start the studio server and resolve once it is listening. Loads the static
|
|
388
|
-
* bundle + renders the host HTML once up front; serves them and proxies
|
|
389
|
-
* `/_lunora/*` (HTTP + WS) to the worker.
|
|
390
|
-
*/
|
|
434
|
+
* Start the studio server and resolve once it is listening. Loads the static
|
|
435
|
+
* bundle + renders the host HTML once up front; serves them and proxies
|
|
436
|
+
* `/_lunora/*` (HTTP + WS) to the worker.
|
|
437
|
+
*/
|
|
391
438
|
declare const startStudioServer: (options: StudioServerOptions) => Promise<StudioServerHandle>;
|
|
392
439
|
interface StudioServerOptions {
|
|
393
440
|
/** Project root — `.dev.vars` is read from here for the admin token. */
|
|
@@ -409,6 +456,24 @@ interface StudioServerHandle {
|
|
|
409
456
|
/** The URL to open in a browser. */
|
|
410
457
|
url: string;
|
|
411
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* How the dev child runs. `wrangler` is the classic `lunora dev` stack (wrangler
|
|
461
|
+
* worker + embedded studio + codegen watch) for a standalone class-C project.
|
|
462
|
+
* `vite` is a project on `@lunora/vite`: the plugin already runs the worker,
|
|
463
|
+
* studio, and codegen inside the Vite dev server, so `lunora dev` runs the
|
|
464
|
+
* project's own dev script and gets out of the way — this also covers class-B
|
|
465
|
+
* frameworks whose own dev server runs the worker in `workerd` (Astro 6 +
|
|
466
|
+
* `@astrojs/cloudflare`, which embeds `@cloudflare/vite-plugin` in `astro dev`:
|
|
467
|
+
* SSR + `/_lunora/*` + `ShardDO` in one process, HMR intact). `framework-worker`
|
|
468
|
+
* is a class-B framework whose dev server CANNOT host the `ShardDO` Durable
|
|
469
|
+
* Object (SvelteKit / Nuxt: their adapters use wrangler's `getPlatformProxy()`,
|
|
470
|
+
* which runs an empty-script Miniflare and does not emulate internal DOs); there
|
|
471
|
+
* `lunora dev` runs the framework's own dev server (front door, HMR, and — via
|
|
472
|
+
* its `@lunora/vite` plugin — studio + codegen) AND a second `wrangler dev`
|
|
473
|
+
* sidecar that owns the real `ShardDO` in `workerd`, wired via the committed
|
|
474
|
+
* `wrangler.dev.jsonc`.
|
|
475
|
+
*/
|
|
476
|
+
type DevFlavor = "framework-worker" | "vite" | "wrangler";
|
|
412
477
|
/** A running worker child the orchestrator controls: send signals, await its exit. */
|
|
413
478
|
interface WorkerProcess {
|
|
414
479
|
/** Resolves with the worker's exit code (1 if it failed to start). */
|
|
@@ -429,6 +494,14 @@ interface DevCommandOptions {
|
|
|
429
494
|
ensureEnv?: typeof ensureDevVariables;
|
|
430
495
|
/** Injection seam for tests — defaults to the real `.dev.vars.example` package-aware scaffolder. */
|
|
431
496
|
ensureExample?: typeof ensureDevVarsExample;
|
|
497
|
+
/** Injection seam for tests — defaults to the real empty-secret/admin-token filler. */
|
|
498
|
+
fillSecrets?: typeof fillDevSecrets;
|
|
499
|
+
/** Injection seam for tests — defaults to the real free-port probe ({@link findAvailablePort}). */
|
|
500
|
+
findFreePort?: (preferred: number) => Promise<number>;
|
|
501
|
+
/** Dev flavor override (tests / callers that already detected it) — defaults to {@link detectDevFlavor}. */
|
|
502
|
+
flavor?: DevFlavor;
|
|
503
|
+
/** Injection seam for tests — defaults to the real IPv6-loopback probe ({@link hasIpv6Loopback}). */
|
|
504
|
+
hasIpv6Loopback?: () => boolean;
|
|
432
505
|
logger: Logger;
|
|
433
506
|
/** Injection seam for tests — defaults to the real remote-config materializer. */
|
|
434
507
|
materializeRemote?: typeof materializeRemoteWranglerConfig;
|
|
@@ -444,6 +517,10 @@ interface DevCommandOptions {
|
|
|
444
517
|
startWorker?: WorkerSpawner;
|
|
445
518
|
/** Disable the embedded studio server. */
|
|
446
519
|
studio?: boolean;
|
|
520
|
+
/** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
|
|
521
|
+
target?: string;
|
|
522
|
+
/** Disable the `wrangler dev` spawn — an external task runner owns the worker. */
|
|
523
|
+
worker?: boolean;
|
|
447
524
|
/** `wrangler dev` port. */
|
|
448
525
|
workerPort?: number;
|
|
449
526
|
}
|
|
@@ -451,10 +528,10 @@ interface DevRemotePlan {
|
|
|
451
528
|
/** Short binding labels remoted (e.g. `"DB (D1)"`), for the banner. */
|
|
452
529
|
bindings: string[];
|
|
453
530
|
/**
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
531
|
+
* Removes the generated temp wrangler config when dev exits. Always present
|
|
532
|
+
* and idempotent — a no-op when remote mode is off or nothing was
|
|
533
|
+
* materialized. The dev loop calls it on every shutdown path.
|
|
534
|
+
*/
|
|
458
535
|
cleanup: () => void;
|
|
459
536
|
/** Whether remote mode was requested. */
|
|
460
537
|
enabled: boolean;
|
|
@@ -463,57 +540,83 @@ interface DevRemotePlan {
|
|
|
463
540
|
}
|
|
464
541
|
interface DevCommandPlan {
|
|
465
542
|
codegenEnabled: boolean;
|
|
543
|
+
/** Which stack the child runs — see {@link DevFlavor}. */
|
|
544
|
+
flavor: DevFlavor;
|
|
545
|
+
/**
|
|
546
|
+
* One-line redirect hint printed when a meta-framework is detected on the
|
|
547
|
+
* wrangler flavor: without `@lunora/vite` in the dependencies the worker
|
|
548
|
+
* still runs *inside* the framework's dev server, so the user should run
|
|
549
|
+
* their framework dev script for the full app. `undefined` for the vite
|
|
550
|
+
* flavor (`lunora dev` already runs the project's dev script there) and
|
|
551
|
+
* for a standalone project. Purely informational: the wrangler spawn runs
|
|
552
|
+
* regardless.
|
|
553
|
+
*/
|
|
554
|
+
frameworkHint?: string;
|
|
555
|
+
/**
|
|
556
|
+
* True when `wrangler dev` was given `--ip 127.0.0.1` because the host has no
|
|
557
|
+
* IPv6 loopback (`::1`) — surfaced so the dev loop can note the rebind.
|
|
558
|
+
* Always `false` for the vite flavor (the plugin owns its own bind).
|
|
559
|
+
*/
|
|
560
|
+
ipv4LoopbackForced: boolean;
|
|
466
561
|
/** The remote-binding decision: which D1/KV/R2 bindings hit the deployed worker. */
|
|
467
562
|
remote: DevRemotePlan;
|
|
563
|
+
/**
|
|
564
|
+
* The `wrangler dev` sidecar for the `framework-worker` flavor (SvelteKit /
|
|
565
|
+
* Nuxt): a second child that owns the real `ShardDO` in `workerd`, wired via
|
|
566
|
+
* the committed `wrangler.dev.jsonc`. `undefined` for every other flavor —
|
|
567
|
+
* only the two-process class-B stack has a sidecar. When present, `wrangler`
|
|
568
|
+
* (above) is the framework's own dev server (the front door / HMR) and this
|
|
569
|
+
* is the Lunora realtime plane.
|
|
570
|
+
*/
|
|
571
|
+
sidecar?: SpawnDescriptor & {
|
|
572
|
+
tag: string;
|
|
573
|
+
};
|
|
468
574
|
studioEnabled: boolean;
|
|
469
575
|
studioPort: number;
|
|
576
|
+
/**
|
|
577
|
+
* Whether this process spawns `wrangler dev`.
|
|
578
|
+
*
|
|
579
|
+
* `--no-worker` turns it off so an external task runner (Turbo, Nx, vis, a
|
|
580
|
+
* Procfile) can own worker supervision while `lunora dev` still provides
|
|
581
|
+
* codegen-watch and Studio. Without it, `lunora dev` insisted on being the
|
|
582
|
+
* process root, which is what blocked running the Lunora worker as one node
|
|
583
|
+
* in a larger dev graph.
|
|
584
|
+
*/
|
|
585
|
+
workerEnabled: boolean;
|
|
470
586
|
workerOrigin: string;
|
|
471
587
|
workerPort: number;
|
|
472
|
-
/** The
|
|
588
|
+
/** The primary child `lunora dev` spawns: `wrangler dev` (wrangler flavor) or the framework/`vite dev` server (vite / framework-worker). */
|
|
473
589
|
wrangler: SpawnDescriptor & {
|
|
474
590
|
tag: string;
|
|
475
591
|
};
|
|
476
592
|
}
|
|
477
593
|
/**
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
|
|
484
|
-
*/
|
|
485
|
-
/**
|
|
486
|
-
* Plan `lunora dev`: it runs the worker via `wrangler dev` and nothing else as a
|
|
487
|
-
* child process. Vite is intentionally NOT spawned — a project may not use Vite,
|
|
488
|
-
* and when it does, the `@lunora/vite` plugin already runs the worker inside
|
|
489
|
-
* Vite, so the user runs `vite` themselves. Pure + synchronous so it's unit-testable.
|
|
490
|
-
*/
|
|
594
|
+
* Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
|
|
595
|
+
* nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
|
|
596
|
+
* plugin already runs the worker inside the Vite dev server, so the one child
|
|
597
|
+
* is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
|
|
598
|
+
* sibling is disabled. Pure + synchronous so it's unit-testable.
|
|
599
|
+
*/
|
|
491
600
|
declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
|
|
492
601
|
/**
|
|
493
|
-
* Start codegen watch + the studio server, spawn `wrangler dev`, print the
|
|
494
|
-
* banner, and resolve when the worker exits or the user interrupts — tearing
|
|
495
|
-
* down the sibling servers either way. The three side-effecting pieces (worker,
|
|
496
|
-
* studio, codegen) are injectable so this is testable without real I/O.
|
|
497
|
-
*/
|
|
602
|
+
* Start codegen watch + the studio server, spawn `wrangler dev`, print the
|
|
603
|
+
* banner, and resolve when the worker exits or the user interrupts — tearing
|
|
604
|
+
* down the sibling servers either way. The three side-effecting pieces (worker,
|
|
605
|
+
* studio, codegen) are injectable so this is testable without real I/O.
|
|
606
|
+
*/
|
|
498
607
|
declare const runDevCommand: (options: DevCommandOptions) => Promise<{
|
|
499
608
|
code: number;
|
|
500
609
|
plan: DevCommandPlan;
|
|
501
610
|
}>;
|
|
502
|
-
/** `lunora dev` handler (lazy-loaded via the command's `loader`). */
|
|
503
611
|
/** Supported CI providers. */
|
|
504
612
|
type CiProvider = "github" | "gitlab";
|
|
505
613
|
type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
|
|
506
614
|
/** True when `manager` is on PATH — probed by running `<manager> --version`. Injectable for tests. */
|
|
507
615
|
type PackageManagerProbe = (manager: PackageManager) => boolean;
|
|
508
|
-
/**
|
|
509
|
-
|
|
510
|
-
* ({@link INSTALL_PREFERENCE} — pnpm > bun > yarn > npm). The first entry is the
|
|
511
|
-
* recommended default for the install prompt; the whole list is what the user
|
|
512
|
-
* picks from. Empty when none are found.
|
|
513
|
-
*/
|
|
616
|
+
/** The per-framework auth-UI registry items (`auth-ui` resolves to one of these). */
|
|
617
|
+
type AuthUiItem = "auth-ui-angular" | "auth-ui-react" | "auth-ui-solid" | "auth-ui-svelte" | "auth-ui-vue";
|
|
514
618
|
/** A registry item a feature can install. */
|
|
515
|
-
type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | "mail";
|
|
516
|
-
/** The auth-provider choices offered for `add auth` / the init auth prompt. Each value is a registry item name. */
|
|
619
|
+
type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | AuthUiItem | "mail";
|
|
517
620
|
/** A single file the item scaffolds into the project. */
|
|
518
621
|
interface RegistryFile {
|
|
519
622
|
/** Source path inside the item dir (e.g. `schema.ts`). */
|
|
@@ -529,10 +632,10 @@ interface RegistryBinding {
|
|
|
529
632
|
value: unknown;
|
|
530
633
|
}
|
|
531
634
|
/**
|
|
532
|
-
* An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
|
|
533
|
-
* local-secrets file) on add — non-secrets get their `value`; secrets get an
|
|
534
|
-
* empty placeholder and a reminder to run `wrangler secret put` for production.
|
|
535
|
-
*/
|
|
635
|
+
* An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
|
|
636
|
+
* local-secrets file) on add — non-secrets get their `value`; secrets get an
|
|
637
|
+
* empty placeholder and a reminder to run `wrangler secret put` for production.
|
|
638
|
+
*/
|
|
536
639
|
interface RegistryEnvVariable {
|
|
537
640
|
/** Human note on what the variable is for. */
|
|
538
641
|
description?: string;
|
|
@@ -543,6 +646,13 @@ interface RegistryEnvVariable {
|
|
|
543
646
|
/** A default/example value for non-secret vars. */
|
|
544
647
|
value?: string;
|
|
545
648
|
}
|
|
649
|
+
/** A re-export the item needs injected into the worker entry point (class-B/C only). */
|
|
650
|
+
interface EntrypointReexport {
|
|
651
|
+
/** Optional JS comment placed above the re-export line. */
|
|
652
|
+
comment?: string;
|
|
653
|
+
/** Module specifier (e.g. `"_generated/workflows"` → `export * from "./lunora/_generated/workflows"`). */
|
|
654
|
+
module: string;
|
|
655
|
+
}
|
|
546
656
|
/** The `registry.json` manifest shape. */
|
|
547
657
|
interface RegistryManifest {
|
|
548
658
|
/** wrangler.jsonc additions (best-effort structural edits). */
|
|
@@ -554,6 +664,8 @@ interface RegistryManifest {
|
|
|
554
664
|
devDependencies?: Readonly<Record<string, string>>;
|
|
555
665
|
/** Post-install guidance printed after the item is added (per-item next steps). */
|
|
556
666
|
docs?: string;
|
|
667
|
+
/** Worker-entry re-exports the item needs (class-B/C only). */
|
|
668
|
+
entrypointReexports?: ReadonlyArray<EntrypointReexport>;
|
|
557
669
|
/** Environment variables the item needs; scaffolded into `.dev.vars`. */
|
|
558
670
|
envVars?: ReadonlyArray<RegistryEnvVariable>;
|
|
559
671
|
files: ReadonlyArray<RegistryFile>;
|
|
@@ -593,11 +705,11 @@ interface AddCommandOptions {
|
|
|
593
705
|
/** Override the remote registry source base (default gh:anolilab/lunora/registry). */
|
|
594
706
|
source?: string;
|
|
595
707
|
/**
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
708
|
+
* Customize each resolved manifest after it is loaded but before the plan is
|
|
709
|
+
* printed / reconciled — used to inject user-chosen values into otherwise
|
|
710
|
+
* static manifests (e.g. the R2 `bucket_name` the init storage prompt asks
|
|
711
|
+
* for). Applied to every item; return the manifest unchanged to leave it as-is.
|
|
712
|
+
*/
|
|
601
713
|
transformManifest?: (manifest: RegistryManifest) => RegistryManifest;
|
|
602
714
|
/** Skip the package.json mutation confirmation prompt. */
|
|
603
715
|
yes?: boolean;
|
|
@@ -613,21 +725,20 @@ interface AddCommandResult {
|
|
|
613
725
|
/** Files written (absolute paths). */
|
|
614
726
|
written: ReadonlyArray<string>;
|
|
615
727
|
}
|
|
616
|
-
/** One resolved item: its parsed manifest plus the (possibly staged) directory it lives in. */
|
|
617
728
|
/**
|
|
618
|
-
* A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
|
|
619
|
-
* sub-prompt or alias; every other value IS the registry item name applied
|
|
620
|
-
* directly (`storage` → the `storage` registry item, etc.).
|
|
621
|
-
*/
|
|
622
|
-
type StackFeature = "auth" | "backup" | "crons" | "email" | "presence" | "
|
|
729
|
+
* A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
|
|
730
|
+
* sub-prompt or alias; every other value IS the registry item name applied
|
|
731
|
+
* directly (`storage` → the `storage` registry item, etc.).
|
|
732
|
+
*/
|
|
733
|
+
type StackFeature = "ai" | "auth" | "auth-ui" | "backup" | "browser" | "cloudflare-access" | "crons" | "email" | "flags" | "hyperdrive" | "payment" | "presence" | "queue" | "storage" | "workflow";
|
|
623
734
|
/** Customize a resolved manifest before it is written (e.g. inject the chosen R2 bucket name). */
|
|
624
735
|
type OfferTransformManifest = (manifest: RegistryManifest) => RegistryManifest;
|
|
625
736
|
/**
|
|
626
|
-
* One feature ready to apply: the registry item name(s), an optional manifest
|
|
627
|
-
* transform, and a short `label` (the feature value) shown on the combined
|
|
628
|
-
* progress line. Built up-front by the collectors so every prompt is answered
|
|
629
|
-
* before any apply runs.
|
|
630
|
-
*/
|
|
737
|
+
* One feature ready to apply: the registry item name(s), an optional manifest
|
|
738
|
+
* transform, and a short `label` (the feature value) shown on the combined
|
|
739
|
+
* progress line. Built up-front by the collectors so every prompt is answered
|
|
740
|
+
* before any apply runs.
|
|
741
|
+
*/
|
|
631
742
|
interface FeatureApply {
|
|
632
743
|
label: string;
|
|
633
744
|
names: ReadonlyArray<string>;
|
|
@@ -635,11 +746,11 @@ interface FeatureApply {
|
|
|
635
746
|
}
|
|
636
747
|
interface OfferDeps {
|
|
637
748
|
/**
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
749
|
+
* Apply the collected features into the new project in one batch — resolves
|
|
750
|
+
* `true` when every item succeeds. The CLI renders this as a single progress
|
|
751
|
+
* line whose label changes per feature; each plan's `transformManifest`
|
|
752
|
+
* customizes that item's manifest before it is written.
|
|
753
|
+
*/
|
|
643
754
|
applyAll: (plans: ReadonlyArray<FeatureApply>) => Promise<boolean>;
|
|
644
755
|
/** When `false`, skip all prompts and print the later-setup hint. */
|
|
645
756
|
interactive: boolean;
|
|
@@ -653,13 +764,19 @@ interface OfferDeps {
|
|
|
653
764
|
defaults?: ReadonlyArray<StackFeature>;
|
|
654
765
|
}) => Promise<StackFeature[]>;
|
|
655
766
|
/**
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
767
|
+
* Features chosen non-interactively (the `--add` flag). When set, the
|
|
768
|
+
* multi-select and every sub-prompt are skipped — each feature is applied with
|
|
769
|
+
* its shipped defaults (base registry item, placeholder bindings).
|
|
770
|
+
*/
|
|
660
771
|
preselected?: ReadonlyArray<StackFeature>;
|
|
661
772
|
/** The new project's name — seeds smart defaults like the `project-uploads` bucket name. */
|
|
662
773
|
projectName: string;
|
|
774
|
+
/**
|
|
775
|
+
* Resolve which per-framework auth-UI item (`auth-ui-react|vue|…`) fits the
|
|
776
|
+
* scaffolded project. Injected by the CLI (detected from the template's deps);
|
|
777
|
+
* defaults to `auth-ui-react` when absent so this module stays pure/testable.
|
|
778
|
+
*/
|
|
779
|
+
resolveAuthUiItem?: () => string;
|
|
663
780
|
/** Single-select among the auth providers (TTY-backed in production). */
|
|
664
781
|
select: (message: string, options: ReadonlyArray<{
|
|
665
782
|
description?: string;
|
|
@@ -674,114 +791,103 @@ interface OfferDeps {
|
|
|
674
791
|
placeholder?: string;
|
|
675
792
|
}) => Promise<string>;
|
|
676
793
|
}
|
|
677
|
-
|
|
678
|
-
* Offer the stack features (auth, email, storage, rate limiting, crons,
|
|
679
|
-
* presence, backups) in ONE multi-select after a successful scaffold. Auth,
|
|
680
|
-
* email, and storage run a follow-up prompt (provider / destination / bucket
|
|
681
|
-
* name); every other feature value is applied as its registry item directly.
|
|
682
|
-
*
|
|
683
|
-
* Every question is asked FIRST (in selection order), then the picked features
|
|
684
|
-
* are applied together via {@link OfferDeps.applyAll} — the CLI renders that as a
|
|
685
|
-
* single progress line whose label changes per feature, instead of one spinner
|
|
686
|
-
* per item. Non-interactive: prints how to add them later and changes nothing.
|
|
687
|
-
*/
|
|
688
|
-
type Template = "analog" | "astro" | "next" | "nuxt" | "react-router" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid";
|
|
794
|
+
type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid";
|
|
689
795
|
interface InitCommandOptions {
|
|
690
796
|
/**
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
797
|
+
* Add features non-interactively after scaffolding (the `--add` flag): a
|
|
798
|
+
* comma-separated list of `ai | auth | backup | browser | cloudflare-access | crons | email | flags | hyperdrive | payment | presence | queue | storage | workflow`.
|
|
799
|
+
* Bypasses the interactive multi-select and sub-prompts —
|
|
800
|
+
* each named feature is applied with its shipped defaults.
|
|
801
|
+
*/
|
|
696
802
|
add?: string;
|
|
697
803
|
/**
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
804
|
+
* When true, accept `--source` values that don't start with `gh:` /
|
|
805
|
+
* `github:` / `https://` or that contain `..`. Defaults to false; the CLI
|
|
806
|
+
* gate exists to stop arbitrary filesystem / scheme sources from being
|
|
807
|
+
* pulled without the caller opting in.
|
|
808
|
+
*/
|
|
703
809
|
allowUnsafeSource?: boolean;
|
|
704
810
|
/** When set, also scaffold a CI deploy pipeline for the given provider. */
|
|
705
811
|
ci?: CiProvider;
|
|
706
812
|
cwd?: string;
|
|
707
813
|
/**
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
814
|
+
* Walk the whole flow — prompts, task list, next-steps, mascot — but make no
|
|
815
|
+
* changes: skip the template fetch/copy, the feature applies, the dependency
|
|
816
|
+
* install, and `git init`. Each skipped action logs a `would …` line instead.
|
|
817
|
+
*/
|
|
712
818
|
dryRun?: boolean;
|
|
713
819
|
/**
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
820
|
+
* Local directory containing the template subdirs (e.g. `vite/`,
|
|
821
|
+
* `standalone/`). When provided, skips the network fetch entirely.
|
|
822
|
+
* Useful for offline runs, the clean-machine smoke test, and unit tests.
|
|
823
|
+
*/
|
|
718
824
|
from?: string;
|
|
719
825
|
/**
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
826
|
+
* When true, configure Lunora into the CURRENT project (`cwd`) instead of
|
|
827
|
+
* scaffolding a new directory. Finds an existing `vite.config.*` and
|
|
828
|
+
* patches it via `patchViteConfig`, or creates a minimal one when absent.
|
|
829
|
+
* All other scaffold options (`name`, `templateType`, `source`, `from`)
|
|
830
|
+
* are ignored in this mode.
|
|
831
|
+
*/
|
|
726
832
|
inPlace?: boolean;
|
|
727
833
|
/**
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
834
|
+
* Inject the post-scaffold install offer's prompts (tests). When set, the
|
|
835
|
+
* offer runs regardless of TTY: `confirmInstall` drives the yes/no, and
|
|
836
|
+
* `selectManager` picks among the detected managers.
|
|
837
|
+
*/
|
|
732
838
|
installPrompt?: {
|
|
733
839
|
confirmInstall: () => Promise<boolean>;
|
|
734
840
|
selectManager: (managers: ReadonlyArray<PackageManager>) => Promise<PackageManager>;
|
|
735
841
|
};
|
|
736
842
|
/**
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
843
|
+
* Force the post-scaffold "add auth / email?" offer on (the `--interactive`
|
|
844
|
+
* flag). When omitted, the offer runs only when stdin is a TTY. `--yes`
|
|
845
|
+
* suppresses it regardless. Has no effect once {@link prompt} is injected.
|
|
846
|
+
*/
|
|
741
847
|
interactive?: boolean;
|
|
742
848
|
logger: Logger;
|
|
743
849
|
name?: string;
|
|
744
850
|
/**
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
851
|
+
* Local directory holding create-vite bases (one `template-<id>/` subdir per
|
|
852
|
+
* framework). When set with `vite`, the overlay copies the base from disk
|
|
853
|
+
* instead of fetching `create-vite` over the network — offline mode + tests.
|
|
854
|
+
*/
|
|
749
855
|
overlayBaseFrom?: string;
|
|
750
856
|
/** Probe for which package managers are installed (tests). Defaults to a real `<pm> --version` check. */
|
|
751
857
|
packageManagerProbe?: PackageManagerProbe;
|
|
752
858
|
/**
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
859
|
+
* Inject the offer's prompts (tests). When set, the offer is treated as
|
|
860
|
+
* interactive regardless of TTY, and these drive the feature multi-select,
|
|
861
|
+
* the auth-provider sub-select, and the storage bucket-name text input.
|
|
862
|
+
*/
|
|
757
863
|
prompt?: Pick<OfferDeps, "multiSelect" | "select" | "text">;
|
|
758
864
|
/**
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
865
|
+
* Override the git ref (branch, tag, or commit) the default template source
|
|
866
|
+
* is fetched from. Takes precedence over the version-derived ref. Ignored
|
|
867
|
+
* when `source` or `from` is set.
|
|
868
|
+
*/
|
|
763
869
|
ref?: string;
|
|
764
870
|
/** Local registry root for the offer's `runAddCommand` (offline / tests). Mirrors `from` but for registry items. */
|
|
765
871
|
registryFrom?: string;
|
|
766
872
|
/** Override the remote registry source base for the offer (default `gh:anolilab/lunora/registry`). */
|
|
767
873
|
registrySource?: string;
|
|
768
874
|
/**
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
875
|
+
* Override the remote source giget downloads from. Default:
|
|
876
|
+
* `gh:anolilab/lunora/templates/<templateType>#<ref>`, where `<ref>` is
|
|
877
|
+
* the `ref` option when set, else derived from the CLI version (pre-release
|
|
878
|
+
* channels → their branch, stable → `main`). Tests typically use `from`
|
|
879
|
+
* instead to skip the network.
|
|
880
|
+
*/
|
|
775
881
|
source?: string;
|
|
776
882
|
/** Spawner for the post-scaffold dependency install (tests inject a recording stub). Defaults to a real subprocess. */
|
|
777
883
|
spawner?: Spawner;
|
|
778
884
|
templateType?: Template;
|
|
779
885
|
/**
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
886
|
+
* Scaffold via the **create-vite overlay** for this framework (`react`,
|
|
887
|
+
* `vue`, `solid`, `svelte`, `vanilla`) instead of a bespoke template: fetch
|
|
888
|
+
* the official create-vite base and apply the Lunora layer on top. Takes
|
|
889
|
+
* precedence over `templateType`.
|
|
890
|
+
*/
|
|
785
891
|
vite?: string;
|
|
786
892
|
/** Suppress the offer entirely (the `--yes` flag): scaffold only, print the later-setup hint. */
|
|
787
893
|
yes?: boolean;
|
|
@@ -792,7 +898,6 @@ interface InitCommandResult {
|
|
|
792
898
|
target: string;
|
|
793
899
|
}
|
|
794
900
|
declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
|
|
795
|
-
/** Narrow a raw `--template` value to a known {@link Template}. */
|
|
796
901
|
interface MigrateGenerateCommandOptions {
|
|
797
902
|
cwd?: string;
|
|
798
903
|
logger: Logger;
|
|
@@ -818,29 +923,27 @@ interface CatalogItem {
|
|
|
818
923
|
interface IndexItem extends CatalogItem {
|
|
819
924
|
title?: string;
|
|
820
925
|
}
|
|
821
|
-
/** Names of the subdirectories under `root` that ship a `registry.json`. */
|
|
822
|
-
|
|
823
926
|
/**
|
|
824
|
-
* Build the catalog (`index.json` contents) from a local registry root by
|
|
825
|
-
* reading every item's `registry.json`. Used by both `lunora registry build`
|
|
826
|
-
* and the registry tests so the committed index can't drift from the item dirs.
|
|
827
|
-
*/
|
|
927
|
+
* Build the catalog (`index.json` contents) from a local registry root by
|
|
928
|
+
* reading every item's `registry.json`. Used by both `lunora registry build`
|
|
929
|
+
* and the registry tests so the committed index can't drift from the item dirs.
|
|
930
|
+
*/
|
|
828
931
|
declare const buildRegistryIndex: (root: string) => {
|
|
829
932
|
items: IndexItem[];
|
|
830
933
|
};
|
|
831
934
|
/** `lunora registry add` (one or more item names): scaffold items into the project. */
|
|
832
935
|
declare const runAddCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
833
936
|
/**
|
|
834
|
-
* `lunora registry view` — inspect a registry item without installing it:
|
|
835
|
-
* print its plan (files / deps / env vars) followed by the full contents of each
|
|
836
|
-
* file it would scaffold. Resolves only the named item — no `requires` expansion.
|
|
837
|
-
*/
|
|
937
|
+
* `lunora registry view` — inspect a registry item without installing it:
|
|
938
|
+
* print its plan (files / deps / env vars) followed by the full contents of each
|
|
939
|
+
* file it would scaffold. Resolves only the named item — no `requires` expansion.
|
|
940
|
+
*/
|
|
838
941
|
declare const runRegistryViewCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
839
942
|
/**
|
|
840
|
-
* `lunora registry build` — regenerate `index.json` from the item directories
|
|
841
|
-
* (the catalog `list` reads). With `--check`, verify the committed index matches
|
|
842
|
-
* instead of rewriting it (exits non-zero on drift) — a CI guard.
|
|
843
|
-
*/
|
|
943
|
+
* `lunora registry build` — regenerate `index.json` from the item directories
|
|
944
|
+
* (the catalog `list` reads). With `--check`, verify the committed index matches
|
|
945
|
+
* instead of rewriting it (exits non-zero on drift) — a CI guard.
|
|
946
|
+
*/
|
|
844
947
|
declare const runBuildIndexCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
845
948
|
/** Validate + narrow a parsed JSON value into a {@link RegistryManifest}. */
|
|
846
949
|
declare const parseManifest: (raw: unknown, itemName: string) => RegistryManifest;
|
|
@@ -858,23 +961,6 @@ interface ResetCommandResult {
|
|
|
858
961
|
removed: ReadonlyArray<string>;
|
|
859
962
|
}
|
|
860
963
|
declare const runResetCommand: (options: ResetCommandOptions) => Promise<ResetCommandResult>;
|
|
861
|
-
/** `lunora reset` handler (lazy-loaded via the command's `loader`). */
|
|
862
|
-
/**
|
|
863
|
-
* Tiny argv parser.
|
|
864
|
-
*
|
|
865
|
-
* Supports long options (`--name value`, `--name=value`, `--flag`), short
|
|
866
|
-
* options (`-x value`, `-xvalue`), positional arguments (everything else, in
|
|
867
|
-
* order), and a `--` terminator after which everything is positional.
|
|
868
|
-
*
|
|
869
|
-
* Intentionally small — replaces a full CLI library for the handful of
|
|
870
|
-
* subcommands we need.
|
|
871
|
-
*/
|
|
872
|
-
interface ParsedArgs {
|
|
873
|
-
flags: Record<string, boolean>;
|
|
874
|
-
options: Record<string, string>;
|
|
875
|
-
positional: ReadonlyArray<string>;
|
|
876
|
-
}
|
|
877
|
-
declare const parseArgs: (argv: ReadonlyArray<string>, booleanFlags?: ReadonlySet<string>) => ParsedArgs;
|
|
878
964
|
type InsertSchemaExtensionResult = {
|
|
879
965
|
ok: true;
|
|
880
966
|
text: string;
|
|
@@ -883,12 +969,12 @@ type InsertSchemaExtensionResult = {
|
|
|
883
969
|
reason: "already-applied" | "invalid-identifier" | "no-define-schema" | "non-object-argument";
|
|
884
970
|
};
|
|
885
971
|
/**
|
|
886
|
-
* Append `.extend(<key>.extension)` and a managed import to an existing
|
|
887
|
-
* `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
|
|
888
|
-
* `already-applied` and leaves the text unchanged.
|
|
889
|
-
* @param source the current `lunora/schema.ts` contents
|
|
890
|
-
* @param key the registry item key (e.g. `"ratelimit"`)
|
|
891
|
-
*/
|
|
972
|
+
* Append `.extend(<key>.extension)` and a managed import to an existing
|
|
973
|
+
* `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
|
|
974
|
+
* `already-applied` and leaves the text unchanged.
|
|
975
|
+
* @param source the current `lunora/schema.ts` contents
|
|
976
|
+
* @param key the registry item key (e.g. `"ratelimit"`)
|
|
977
|
+
*/
|
|
892
978
|
declare const insertSchemaExtension: (source: string, key: string) => InsertSchemaExtensionResult;
|
|
893
979
|
/** Compact snapshot of a single global table — what we persist + diff. */
|
|
894
980
|
interface TableSnapshot {
|
|
@@ -931,10 +1017,10 @@ interface SchemaDiff {
|
|
|
931
1017
|
unsupported: ReadonlyArray<UnsupportedEntry>;
|
|
932
1018
|
}
|
|
933
1019
|
/**
|
|
934
|
-
* Map a Lunora validator kind to a SQLite type affinity — the canonical
|
|
935
|
-
* `@lunora/d1/dialect` mapping. Re-exported under this name because
|
|
936
|
-
* `schema-snapshot.ts` builds the persisted snapshot from it.
|
|
937
|
-
*/
|
|
1020
|
+
* Map a Lunora validator kind to a SQLite type affinity — the canonical
|
|
1021
|
+
* `@lunora/d1/dialect` mapping. Re-exported under this name because
|
|
1022
|
+
* `schema-snapshot.ts` builds the persisted snapshot from it.
|
|
1023
|
+
*/
|
|
938
1024
|
declare const validatorKindToSqlType: (kind: string) => ColumnSnapshot["sqlType"];
|
|
939
1025
|
/** Emit `CREATE TABLE` SQL for a new global table. */
|
|
940
1026
|
declare const renderCreateTable: (table: TableSnapshot) => string;
|
|
@@ -943,14 +1029,14 @@ declare const renderAddColumn: (tableName: string, columnName: string, column: C
|
|
|
943
1029
|
declare const renderCreateIndex: (tableName: string, index: IndexSnapshot) => string;
|
|
944
1030
|
declare const renderDropIndex: (tableName: string, indexName: string) => string;
|
|
945
1031
|
/**
|
|
946
|
-
* Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
|
|
947
|
-
*/
|
|
1032
|
+
* Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
|
|
1033
|
+
*/
|
|
948
1034
|
declare const diffSnapshots: (previous: SchemaSnapshot | undefined, next: SchemaSnapshot) => SchemaDiff;
|
|
949
1035
|
/**
|
|
950
|
-
* Render a complete migration file body from a diff. Includes a header,
|
|
951
|
-
* each SQL statement, and (if any) a trailing comment block describing the
|
|
952
|
-
* manual SQL the user needs to fill in for unsupported deltas.
|
|
953
|
-
*/
|
|
1036
|
+
* Render a complete migration file body from a diff. Includes a header,
|
|
1037
|
+
* each SQL statement, and (if any) a trailing comment block describing the
|
|
1038
|
+
* manual SQL the user needs to fill in for unsupported deltas.
|
|
1039
|
+
*/
|
|
954
1040
|
declare const renderMigrationFile: (name: string, diff: SchemaDiff, generatedAt: string) => string;
|
|
955
1041
|
declare const schemaIrToSnapshot: (ir: SchemaIR) => SchemaSnapshot;
|
|
956
|
-
export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DevCommandOptions, type DevCommandPlan, type DiffEntry, type ExportCommandOptions, type ExportCommandResult, type FetchLike, type ImportCommandOptions, type ImportCommandResult, type IndexSnapshot, type InitCommandOptions, type InitCommandResult, type InsertSchemaExtensionResult, type Logger, type MigrateGenerateCommandOptions, type MigrateGenerateCommandResult, type RecordedSpawn, type RegistryBinding, type RegistryFile, type RegistryManifest, type ResetCommandOptions, type ResetCommandResult, type RunCliOptions, type RunCommandOptions, type RunCommandResult, type SchemaDiff, type SchemaSnapshot, type SpawnDescriptor, type SpawnResult, type Spawner, type StreamingFetchLike, type TableSnapshot, type Template, type UnsupportedEntry, VERSION, buildRegistryIndex, createLogger, createRecordingSpawner, defaultSpawner, diffSnapshots, insertSchemaExtension, pail,
|
|
1042
|
+
export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DevCommandOptions, type DevCommandPlan, type DiffEntry, type ExportCommandOptions, type ExportCommandResult, type FetchLike, type ImportCommandOptions, type ImportCommandResult, type IndexSnapshot, type InitCommandOptions, type InitCommandResult, type InsertSchemaExtensionResult, type Logger, type MigrateGenerateCommandOptions, type MigrateGenerateCommandResult, type RecordedSpawn, type RegistryBinding, type RegistryFile, type RegistryManifest, type ResetCommandOptions, type ResetCommandResult, type RunCliOptions, type RunCommandOptions, type RunCommandResult, type SchemaDiff, type SchemaSnapshot, type SpawnDescriptor, type SpawnResult, type Spawner, type StreamingFetchLike, type TableSnapshot, type Template, type UnsupportedEntry, VERSION, buildRegistryIndex, createLogger, createRecordingSpawner, defaultSpawner, diffSnapshots, insertSchemaExtension, pail, parseManifest, planDevCommand, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, runAddCommand, runBuildIndexCommand, runCli, runCodegenCommand, runDeployCommand, runDevCommand, runExportCommand, runImportCommand, runInitCommand, runMigrateGenerateCommand, runRegistryViewCommand, runResetCommand, runRpcCommand, schemaIrToSnapshot, validatorKindToSqlType };
|