@lunora/cli 0.0.0 → 1.0.0-alpha.2
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 +105 -0
- package/README.md +109 -9
- package/__assets__/package-og.svg +14 -0
- package/dist/bin.mjs +11 -0
- package/dist/index.d.mts +852 -0
- package/dist/index.d.ts +852 -0
- package/dist/index.mjs +19 -0
- package/dist/packem_chunks/handler.mjs +76 -0
- package/dist/packem_chunks/handler10.mjs +22 -0
- package/dist/packem_chunks/handler11.mjs +192 -0
- package/dist/packem_chunks/handler12.mjs +131 -0
- package/dist/packem_chunks/handler13.mjs +65 -0
- package/dist/packem_chunks/handler14.mjs +58 -0
- package/dist/packem_chunks/handler15.mjs +79 -0
- package/dist/packem_chunks/handler16.mjs +41 -0
- package/dist/packem_chunks/handler17.mjs +105 -0
- package/dist/packem_chunks/handler18.mjs +172 -0
- package/dist/packem_chunks/handler19.mjs +89 -0
- package/dist/packem_chunks/handler2.mjs +114 -0
- package/dist/packem_chunks/handler20.mjs +94 -0
- package/dist/packem_chunks/handler21.mjs +311 -0
- package/dist/packem_chunks/handler3.mjs +204 -0
- package/dist/packem_chunks/handler4.mjs +33 -0
- package/dist/packem_chunks/handler5.mjs +49 -0
- package/dist/packem_chunks/handler6.mjs +91 -0
- package/dist/packem_chunks/handler7.mjs +42 -0
- package/dist/packem_chunks/handler8.mjs +174 -0
- package/dist/packem_chunks/handler9.mjs +16 -0
- package/dist/packem_chunks/planDevCommand.mjs +543 -0
- package/dist/packem_chunks/runCodegenCommand.mjs +52 -0
- package/dist/packem_chunks/runDeployCommand.mjs +504 -0
- package/dist/packem_chunks/runInitCommand.mjs +652 -0
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +397 -0
- package/dist/packem_chunks/runResetCommand.mjs +41 -0
- package/dist/packem_chunks/runRpcCommand.mjs +68 -0
- package/dist/packem_shared/COMMANDS-1V_KEx35.mjs +905 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Ck-2bU08.mjs +244 -0
- package/dist/packem_shared/admin-url-4UzT-CI4.mjs +19 -0
- package/dist/packem_shared/api-spec-CtA6ilu4.mjs +13 -0
- package/dist/packem_shared/buildRegistryIndex-BcYe607_.mjs +38 -0
- package/dist/packem_shared/command-BDXcJCCJ.mjs +14 -0
- package/dist/packem_shared/createLogger-CHPNjFw2.mjs +73 -0
- package/dist/packem_shared/defaultSpawner-DxI3mebw.mjs +43 -0
- package/dist/packem_shared/diffSnapshots-RR2ZE8Ya.mjs +161 -0
- package/dist/packem_shared/docker-hMQ97KSQ.mjs +21 -0
- package/dist/packem_shared/features-ocSSpZtS.mjs +24 -0
- package/dist/packem_shared/insertSchemaExtension-BuzF6-t2.mjs +59 -0
- package/dist/packem_shared/open-url-Dfq6fAyT.mjs +41 -0
- package/dist/packem_shared/output-format-7gyGR3h8.mjs +17 -0
- package/dist/packem_shared/parseArgs-YXFuKdEk.mjs +56 -0
- package/dist/packem_shared/parseManifest--vZf2FY1.mjs +94 -0
- package/dist/packem_shared/resolve-target-qbsJ_5sF.mjs +16 -0
- package/dist/packem_shared/runAddCommand-BZGkRnBs.mjs +693 -0
- package/dist/packem_shared/schema-drift-gate-BtBt0as0.mjs +79 -0
- package/dist/packem_shared/schemaIrToSnapshot-aBTo7TM5.mjs +43 -0
- package/dist/packem_shared/wrangler-name-cy4yhm9j.mjs +12 -0
- package/package.json +61 -18
- package/skills/README.md +29 -0
- package/skills/lunora/SKILL.md +83 -0
- package/skills/lunora-create-package/SKILL.md +129 -0
- package/skills/lunora-deploy/SKILL.md +150 -0
- package/skills/lunora-functions/SKILL.md +182 -0
- package/skills/lunora-migration-helper/SKILL.md +194 -0
- package/skills/lunora-performance-audit/SKILL.md +143 -0
- package/skills/lunora-quickstart/SKILL.md +240 -0
- package/skills/lunora-realtime/SKILL.md +177 -0
- package/skills/lunora-setup-auth/SKILL.md +170 -0
- package/skills/lunora-setup-hyperdrive/SKILL.md +154 -0
- package/skills/lunora-setup-hyperdrive-global/SKILL.md +171 -0
- package/skills/lunora-setup-mail/SKILL.md +151 -0
- package/skills/lunora-setup-scheduler/SKILL.md +157 -0
- package/skills/lunora-setup-storage/SKILL.md +154 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,852 @@
|
|
|
1
|
+
import { CodegenOptions, SchemaIR } from '@lunora/codegen';
|
|
2
|
+
import '@visulima/cerebro';
|
|
3
|
+
import { ensureDevVariables, ensureDevVarsExample, materializeRemoteWranglerConfig } from '@lunora/config';
|
|
4
|
+
export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config';
|
|
5
|
+
/** 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
|
+
type CommandName = (typeof COMMANDS)[number];
|
|
8
|
+
declare const VERSION: string;
|
|
9
|
+
interface RunCliOptions {
|
|
10
|
+
argv?: ReadonlyArray<string>;
|
|
11
|
+
cwd?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Inject a console-like logger so callers (tests) can capture cerebro's
|
|
14
|
+
* help / version / usage rendering. Omitted in production, where cerebro
|
|
15
|
+
* uses its default stdout/stderr logger.
|
|
16
|
+
*/
|
|
17
|
+
logger?: Console;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
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
|
+
*/
|
|
25
|
+
declare const runCli: (options?: RunCliOptions) => Promise<number>;
|
|
26
|
+
/**
|
|
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
|
+
*/
|
|
31
|
+
type ApiSpec = NonNullable<CodegenOptions["apiSpec"]>;
|
|
32
|
+
interface Logger {
|
|
33
|
+
debug?: (message: string) => void;
|
|
34
|
+
error: (message: string) => void;
|
|
35
|
+
info: (message: string) => void;
|
|
36
|
+
success: (message: string) => void;
|
|
37
|
+
warn: (message: string) => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
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
|
+
*/
|
|
45
|
+
interface PailLogger {
|
|
46
|
+
debug: (message: string) => void;
|
|
47
|
+
error: (message: string) => void;
|
|
48
|
+
info: (message: string) => void;
|
|
49
|
+
success: (message: string) => void;
|
|
50
|
+
warn: (message: string) => void;
|
|
51
|
+
}
|
|
52
|
+
declare const createLogger: () => Logger;
|
|
53
|
+
/**
|
|
54
|
+
* Logger whose every channel writes to `process.stderr`. Used by commands in
|
|
55
|
+
* `--format json` mode so all human/progress output stays off stdout — leaving
|
|
56
|
+
* stdout for the single JSON document the command prints, so `… --format json`
|
|
57
|
+
* stays cleanly pipeable (`| jq`). Each line carries a one-character level tag
|
|
58
|
+
* so the stream is still readable when a human watches it.
|
|
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
|
+
*/
|
|
66
|
+
declare const pail: PailLogger;
|
|
67
|
+
interface CodegenCommandOptions {
|
|
68
|
+
/** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
|
|
69
|
+
apiSpec?: ApiSpec;
|
|
70
|
+
cwd?: string;
|
|
71
|
+
/** Output format: `pretty` (default) or `json`. */
|
|
72
|
+
format?: string;
|
|
73
|
+
logger: Logger;
|
|
74
|
+
}
|
|
75
|
+
interface CodegenCommandResult {
|
|
76
|
+
advisories: ReadonlyArray<{
|
|
77
|
+
detail: string;
|
|
78
|
+
level: string;
|
|
79
|
+
name: string;
|
|
80
|
+
remediation: string;
|
|
81
|
+
}>;
|
|
82
|
+
cronTriggers: ReadonlyArray<string>;
|
|
83
|
+
/** Set when the run aborted on an invalid `--format` before codegen ran. */
|
|
84
|
+
error?: string;
|
|
85
|
+
outputDirectory: string;
|
|
86
|
+
}
|
|
87
|
+
declare const runCodegenCommand: (options: CodegenCommandOptions) => CodegenCommandResult;
|
|
88
|
+
/** `lunora codegen` handler (lazy-loaded via the command's `loader`). */
|
|
89
|
+
/** Rows per HTTP request when importing. Convex uses ~500; same here. */
|
|
90
|
+
declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
|
|
91
|
+
/**
|
|
92
|
+
* Minimal projection of `globalThis.fetch` for the export path — we need
|
|
93
|
+
* `body` as a stream-iterable, which the shared {@link FetchLike} type
|
|
94
|
+
* intentionally hides for the JSON-only commands.
|
|
95
|
+
*/
|
|
96
|
+
type StreamingFetchLike = (input: string, init?: {
|
|
97
|
+
body?: string;
|
|
98
|
+
headers?: Record<string, string>;
|
|
99
|
+
method?: string;
|
|
100
|
+
}) => Promise<{
|
|
101
|
+
body: ReadableStream<Uint8Array> | null;
|
|
102
|
+
json: () => Promise<unknown>;
|
|
103
|
+
ok: boolean;
|
|
104
|
+
status: number;
|
|
105
|
+
text: () => Promise<string>;
|
|
106
|
+
}>;
|
|
107
|
+
interface ExportCommandOptions {
|
|
108
|
+
cwd?: string;
|
|
109
|
+
fetchImpl?: StreamingFetchLike;
|
|
110
|
+
logger: Logger;
|
|
111
|
+
/** Output file path; `undefined`/`-` streams to stdout. */
|
|
112
|
+
out?: string;
|
|
113
|
+
/** Guardrail: refuse to target localhost when set. */
|
|
114
|
+
prod?: boolean;
|
|
115
|
+
/** Comma-separated table list; omit to export every table. */
|
|
116
|
+
tables?: string;
|
|
117
|
+
/** Admin bearer token (or `LUNORA_ADMIN_TOKEN`). */
|
|
118
|
+
token?: string;
|
|
119
|
+
/** Worker URL (default `http://localhost:8787`). */
|
|
120
|
+
url?: string;
|
|
121
|
+
}
|
|
122
|
+
interface ExportCommandResult {
|
|
123
|
+
bytes: number;
|
|
124
|
+
code: number;
|
|
125
|
+
/** Number of NDJSON lines streamed (0 on error). */
|
|
126
|
+
rows: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Stream an export. The worker emits NDJSON; we count newlines as we go and
|
|
130
|
+
* pipe straight to the output sink, so a 10M-row export doesn't materialise
|
|
131
|
+
* the body in memory.
|
|
132
|
+
*/
|
|
133
|
+
declare const runExportCommand: (options: ExportCommandOptions) => Promise<ExportCommandResult>;
|
|
134
|
+
interface ImportCommandOptions {
|
|
135
|
+
/** Rows per HTTP request. Defaults to {@link DEFAULT_IMPORT_BATCH_SIZE}. */
|
|
136
|
+
batchSize?: number;
|
|
137
|
+
cwd?: string;
|
|
138
|
+
fetchImpl?: StreamingFetchLike;
|
|
139
|
+
/** Source NDJSON file. Required. */
|
|
140
|
+
file: string;
|
|
141
|
+
logger: Logger;
|
|
142
|
+
prod?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Wrap each line as `{table:<name>,doc:<line>}`. Use when the source NDJSON
|
|
145
|
+
* is bare docs from a single table — Convex's `convex import --table users`
|
|
146
|
+
* shape.
|
|
147
|
+
*/
|
|
148
|
+
table?: string;
|
|
149
|
+
token?: string;
|
|
150
|
+
url?: string;
|
|
151
|
+
}
|
|
152
|
+
interface ImportCommandResult {
|
|
153
|
+
body: unknown;
|
|
154
|
+
code: number;
|
|
155
|
+
/** Total inserted rows across batches. */
|
|
156
|
+
inserted: number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Stream an NDJSON file in chunks, POSTing each batch to
|
|
160
|
+
* `/_lunora/admin/import`. We keep the line buffer bounded by `batchSize` so a
|
|
161
|
+
* multi-GiB file imports without buffering everything in memory.
|
|
162
|
+
*/
|
|
163
|
+
declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
|
|
164
|
+
/**
|
|
165
|
+
* Injectable probe for a Docker-compatible container engine. Tests pass a
|
|
166
|
+
* stub; production uses {@link isDockerAvailable}.
|
|
167
|
+
*/
|
|
168
|
+
type DockerProbe = () => boolean;
|
|
169
|
+
/**
|
|
170
|
+
* True when a Docker-compatible engine answers `docker info` — the same
|
|
171
|
+
* prerequisite `wrangler deploy` has for building and pushing a container
|
|
172
|
+
* image from a local Dockerfile. Quiet by design (output discarded): callers
|
|
173
|
+
* own the messaging.
|
|
174
|
+
*/
|
|
175
|
+
interface SpawnDescriptor {
|
|
176
|
+
args: ReadonlyArray<string>;
|
|
177
|
+
/**
|
|
178
|
+
* Capture the child's stdout (in addition to streaming it to the parent), so
|
|
179
|
+
* the caller can parse it — used by `deploy` to read the deployed URL from
|
|
180
|
+
* `wrangler deploy` output. Each chunk is still teed to the parent's stdout
|
|
181
|
+
* so the user sees live progress. Mutually exclusive with `stdoutToStderr`.
|
|
182
|
+
*/
|
|
183
|
+
captureStdout?: boolean;
|
|
184
|
+
command: string;
|
|
185
|
+
cwd?: string;
|
|
186
|
+
env?: Readonly<Record<string, string>>;
|
|
187
|
+
/**
|
|
188
|
+
* Pipe this string into the child's stdin and close it. Used to feed
|
|
189
|
+
* `wrangler secret put` its value without exposing it on the command
|
|
190
|
+
* line or in env. When absent, stdin is inherited from the parent.
|
|
191
|
+
*/
|
|
192
|
+
input?: string;
|
|
193
|
+
/**
|
|
194
|
+
* Route the child's stdout to the parent's STDERR instead of stdout. Set in
|
|
195
|
+
* `--format json` mode so a spawned tool's human output (e.g. `wrangler
|
|
196
|
+
* deploy`'s progress + the deployed URL) can't interleave with — and corrupt
|
|
197
|
+
* — the single JSON document the command prints to stdout.
|
|
198
|
+
*/
|
|
199
|
+
stdoutToStderr?: boolean;
|
|
200
|
+
}
|
|
201
|
+
interface SpawnResult {
|
|
202
|
+
code: number;
|
|
203
|
+
/** The captured stdout, present only when the descriptor set `captureStdout`. */
|
|
204
|
+
stdout?: string;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Injectable spawner. Tests pass a stub that just records the descriptor
|
|
208
|
+
* instead of executing a real subprocess.
|
|
209
|
+
*/
|
|
210
|
+
type Spawner = (descriptor: SpawnDescriptor) => Promise<SpawnResult>;
|
|
211
|
+
declare const defaultSpawner: Spawner;
|
|
212
|
+
interface RecordedSpawn {
|
|
213
|
+
descriptor: SpawnDescriptor;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Test helper: returns a spawner that records every invocation and resolves
|
|
217
|
+
* with the configured exit code.
|
|
218
|
+
*/
|
|
219
|
+
declare const createRecordingSpawner: (exitCode?: number) => {
|
|
220
|
+
calls: RecordedSpawn[];
|
|
221
|
+
spawner: Spawner;
|
|
222
|
+
};
|
|
223
|
+
type FetchLike = (input: string, init?: {
|
|
224
|
+
body?: string;
|
|
225
|
+
headers?: Record<string, string>;
|
|
226
|
+
method?: string;
|
|
227
|
+
}) => Promise<{
|
|
228
|
+
json: () => Promise<unknown>;
|
|
229
|
+
ok: boolean;
|
|
230
|
+
status: number;
|
|
231
|
+
text: () => Promise<string>;
|
|
232
|
+
}>;
|
|
233
|
+
interface RunCommandOptions {
|
|
234
|
+
args?: string;
|
|
235
|
+
cwd?: string;
|
|
236
|
+
fetchImpl?: FetchLike;
|
|
237
|
+
functionPath: string;
|
|
238
|
+
logger: Logger;
|
|
239
|
+
shard?: string;
|
|
240
|
+
url?: string;
|
|
241
|
+
}
|
|
242
|
+
interface RunCommandResult {
|
|
243
|
+
body: unknown;
|
|
244
|
+
code: number;
|
|
245
|
+
requestUrl: string;
|
|
246
|
+
}
|
|
247
|
+
declare const runRpcCommand: (options: RunCommandOptions) => Promise<RunCommandResult>;
|
|
248
|
+
/** `lunora run <functionPath>` handler (lazy-loaded via the command's `loader`). */
|
|
249
|
+
interface DeployCommandOptions {
|
|
250
|
+
/** Override the schema-drift gate — deploy even with breaking drift and no new migration. */
|
|
251
|
+
allowSchemaDrift?: boolean;
|
|
252
|
+
/** Which API spec(s) codegen emits. Defaults to codegen's `"openapi"` when omitted. */
|
|
253
|
+
apiSpec?: ApiSpec;
|
|
254
|
+
cwd?: string;
|
|
255
|
+
/** Docker-availability probe injected in tests. Defaults to a real `docker info` check. */
|
|
256
|
+
dockerAvailable?: DockerProbe;
|
|
257
|
+
/**
|
|
258
|
+
* Validate, bundle, and run all pre-deploy gates without publishing
|
|
259
|
+
* (`wrangler deploy --dry-run`). Post-deploy steps (data migrations, schema
|
|
260
|
+
* baseline re-bless) are skipped since nothing shipped.
|
|
261
|
+
*/
|
|
262
|
+
dryRun?: boolean;
|
|
263
|
+
env?: string;
|
|
264
|
+
/** Fetch implementation injected in tests for `--migrate` RPC calls. */
|
|
265
|
+
fetchImpl?: FetchLike;
|
|
266
|
+
/** Output format: `pretty` (default) or `json`. */
|
|
267
|
+
format?: string;
|
|
268
|
+
/** Set to `false` to disable interactive spinners (test injection). */
|
|
269
|
+
interactive?: boolean;
|
|
270
|
+
logger: Logger;
|
|
271
|
+
/**
|
|
272
|
+
* When true, after a successful `wrangler deploy`, discover and run all
|
|
273
|
+
* pending data migrations via the worker's `/_lunora/migrate` admin RPC.
|
|
274
|
+
* The worker must be live (exit 0) before migrations are attempted.
|
|
275
|
+
*
|
|
276
|
+
* Implementation note: the status RPC returns the full shard-level
|
|
277
|
+
* migration state, but there is no single authoritative "list of pending
|
|
278
|
+
* migration ids" that can be read client-side before running the worker.
|
|
279
|
+
* Instead, `--migrate` runs `migrate status` followed by `migrate up` for
|
|
280
|
+
* each migration id discovered locally via `discoverMigrations`. The
|
|
281
|
+
* worker's `MigrationRunner` is idempotent — running `up` on an already-
|
|
282
|
+
* applied migration is a no-op — so this approach is safe.
|
|
283
|
+
*/
|
|
284
|
+
migrate?: boolean;
|
|
285
|
+
/** Admin bearer token for `--migrate` (falls back to `LUNORA_ADMIN_TOKEN`). */
|
|
286
|
+
migrateToken?: string;
|
|
287
|
+
/**
|
|
288
|
+
* Worker URL for `--migrate`. REQUIRED when `--migrate` is set — the deploy
|
|
289
|
+
* handler never captures the URL `wrangler deploy` published to, so there is
|
|
290
|
+
* no safe default; omitting it would silently target `http://localhost:8787`
|
|
291
|
+
* (the dev worker), applying the migration to local state instead of prod.
|
|
292
|
+
*/
|
|
293
|
+
migrateUrl?: string;
|
|
294
|
+
/**
|
|
295
|
+
* Confirm a production data migration triggered via `--migrate` (the
|
|
296
|
+
* `migrate up --prod` confirmation the standalone command requires). Without
|
|
297
|
+
* it a `--migrate --migrate-url <prod>` deploy refuses to run the migration.
|
|
298
|
+
*/
|
|
299
|
+
migrateYes?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Emit the bundled worker to this directory via `wrangler deploy --outdir`
|
|
302
|
+
* (paired with `dryRun` by `lunora build`). Also writes esbuild metadata to
|
|
303
|
+
* `<outDir>/bundle-meta.json`. When unset, no artifact is written.
|
|
304
|
+
*/
|
|
305
|
+
outDir?: string;
|
|
306
|
+
/**
|
|
307
|
+
* Upload a preview version (`wrangler versions upload`) instead of a live
|
|
308
|
+
* `wrangler deploy`. Codegen + the drift gate + validation still run, but
|
|
309
|
+
* the post-deploy finalize (migrations, baseline re-bless, auto-link, the
|
|
310
|
+
* production summary) is skipped — a preview never shifts live traffic.
|
|
311
|
+
*/
|
|
312
|
+
preview?: boolean;
|
|
313
|
+
/** Railpack-availability probe injected in tests. Defaults to a real `railpack --version` + `BUILDKIT_HOST` check. */
|
|
314
|
+
railpackAvailable?: DockerProbe;
|
|
315
|
+
skipCodegen?: boolean;
|
|
316
|
+
spawner?: Spawner;
|
|
317
|
+
/**
|
|
318
|
+
* Deploy to a temporary Cloudflare account (`wrangler deploy --temporary`).
|
|
319
|
+
* For unauthenticated use only: wrangler provisions a short-lived account +
|
|
320
|
+
* token, deploys, and prints a claim URL; the deployment stays live ~60
|
|
321
|
+
* minutes before the unclaimed account is deleted. Wrangler itself errors
|
|
322
|
+
* if credentials are already present (OAuth / `CLOUDFLARE_API_TOKEN` /
|
|
323
|
+
* global API key), so we pass the flag straight through without guarding.
|
|
324
|
+
*/
|
|
325
|
+
temporary?: boolean;
|
|
326
|
+
/** Re-bless the committed schema baseline with the current shape (accepts breaking drift). */
|
|
327
|
+
updateSchemaBaseline?: boolean;
|
|
328
|
+
}
|
|
329
|
+
interface DeployCommandResult {
|
|
330
|
+
code: number;
|
|
331
|
+
descriptor: SpawnDescriptor | undefined;
|
|
332
|
+
/** Set when the run aborted before reaching the wrangler invocation. */
|
|
333
|
+
error?: string;
|
|
334
|
+
/** The schema-drift gate verdict, when it ran (skipped on `--skip-codegen`). */
|
|
335
|
+
schemaDrift?: {
|
|
336
|
+
blocked: boolean;
|
|
337
|
+
reason: string;
|
|
338
|
+
};
|
|
339
|
+
validation: {
|
|
340
|
+
problems: ReadonlyArray<string>;
|
|
341
|
+
wranglerPath: string | undefined;
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Run a deploy, then (in `--format json` mode) serialize the structured
|
|
346
|
+
* {@link DeployCommandResult} to stdout. Human/progress logging is routed to
|
|
347
|
+
* stderr for json output so stdout carries only the single JSON document.
|
|
348
|
+
*/
|
|
349
|
+
declare const runDeployCommand: (options: DeployCommandOptions) => Promise<DeployCommandResult>;
|
|
350
|
+
/** `lunora deploy` handler (lazy-loaded via the command's `loader`). */
|
|
351
|
+
/**
|
|
352
|
+
* Start the codegen watch loop and return a handle to stop it. Regenerates on
|
|
353
|
+
* startup, then on debounced changes under `lunora/` (ignoring writes to the
|
|
354
|
+
* `_generated/` output to avoid a feedback loop). If the platform can't do a
|
|
355
|
+
* recursive watch, it logs once and falls back to startup-only codegen.
|
|
356
|
+
*/
|
|
357
|
+
declare const startCodegenWatch: (options: CodegenWatcherOptions) => CodegenWatcherHandle;
|
|
358
|
+
interface CodegenWatcherOptions {
|
|
359
|
+
/** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
|
|
360
|
+
apiSpec?: CodegenOptions["apiSpec"];
|
|
361
|
+
/** Debounce window for coalescing rapid edits. Defaults to 100ms. */
|
|
362
|
+
debounceMs?: number;
|
|
363
|
+
logger: Logger;
|
|
364
|
+
/** Override the lunora subdirectory name. Defaults to `"lunora"`. */
|
|
365
|
+
lunoraDirectory?: string;
|
|
366
|
+
/** Project root containing the `lunora/` directory. */
|
|
367
|
+
projectRoot: string;
|
|
368
|
+
}
|
|
369
|
+
interface CodegenWatcherHandle {
|
|
370
|
+
/** Stop watching and cancel any pending regeneration. */
|
|
371
|
+
close: () => void;
|
|
372
|
+
/**
|
|
373
|
+
* `true` when the platform supports recursive watch and the loop is active.
|
|
374
|
+
* `false` when `fs.watch({ recursive })` threw — startup-only codegen was run
|
|
375
|
+
* but schema edits will NOT auto-regenerate. Callers can surface this in the
|
|
376
|
+
* dev banner so the degraded state is visible beyond the single startup warning.
|
|
377
|
+
*/
|
|
378
|
+
watchAvailable: boolean;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Start the studio server and resolve once it is listening. Loads the static
|
|
382
|
+
* bundle + renders the host HTML once up front; serves them and proxies
|
|
383
|
+
* `/_lunora/*` (HTTP + WS) to the worker.
|
|
384
|
+
*/
|
|
385
|
+
declare const startStudioServer: (options: StudioServerOptions) => Promise<StudioServerHandle>;
|
|
386
|
+
interface StudioServerOptions {
|
|
387
|
+
/** Project root — `.dev.vars` is read from here for the admin token. */
|
|
388
|
+
cwd: string;
|
|
389
|
+
/** Loopback host to bind. Defaults to `127.0.0.1` (admin tooling stays local). */
|
|
390
|
+
host?: string;
|
|
391
|
+
/** One-time warning sink for a missing/unbuilt `@lunora/studio`. */
|
|
392
|
+
logger?: {
|
|
393
|
+
warnOnce?: (message: string) => void;
|
|
394
|
+
};
|
|
395
|
+
/** Port to listen on. */
|
|
396
|
+
port: number;
|
|
397
|
+
/** Origin of the `wrangler dev` worker, e.g. `http://localhost:8787`. */
|
|
398
|
+
workerOrigin: string;
|
|
399
|
+
}
|
|
400
|
+
interface StudioServerHandle {
|
|
401
|
+
/** Stop listening and release the port. */
|
|
402
|
+
close: () => Promise<void>;
|
|
403
|
+
/** The URL to open in a browser. */
|
|
404
|
+
url: string;
|
|
405
|
+
}
|
|
406
|
+
/** A running worker child the orchestrator controls: send signals, await its exit. */
|
|
407
|
+
interface WorkerProcess {
|
|
408
|
+
/** Resolves with the worker's exit code (1 if it failed to start). */
|
|
409
|
+
exited: Promise<number>;
|
|
410
|
+
kill: (signal: NodeJS.Signals) => void;
|
|
411
|
+
}
|
|
412
|
+
/** Spawns the worker child. Injectable so tests drive the orchestration without a real process. */
|
|
413
|
+
type WorkerSpawner = (descriptor: SpawnDescriptor & {
|
|
414
|
+
tag: string;
|
|
415
|
+
}, logger: Logger) => WorkerProcess;
|
|
416
|
+
interface DevCommandOptions {
|
|
417
|
+
/** Which API spec(s) the codegen watcher emits. Defaults to codegen's `"openapi"` when omitted. */
|
|
418
|
+
apiSpec?: ApiSpec;
|
|
419
|
+
/** Disable the codegen watch loop. */
|
|
420
|
+
codegen?: boolean;
|
|
421
|
+
cwd?: string;
|
|
422
|
+
/** Injection seam for tests — defaults to the real `.dev.vars` scaffolder. */
|
|
423
|
+
ensureEnv?: typeof ensureDevVariables;
|
|
424
|
+
/** Injection seam for tests — defaults to the real `.dev.vars.example` package-aware scaffolder. */
|
|
425
|
+
ensureExample?: typeof ensureDevVarsExample;
|
|
426
|
+
logger: Logger;
|
|
427
|
+
/** Injection seam for tests — defaults to the real remote-config materializer. */
|
|
428
|
+
materializeRemote?: typeof materializeRemoteWranglerConfig;
|
|
429
|
+
/** Studio server port. */
|
|
430
|
+
port?: number;
|
|
431
|
+
/** Proxy D1/KV/R2 bindings to the deployed worker during dev (`LUNORA_REMOTE=1` / `--remote`); DO shards stay local. */
|
|
432
|
+
remote?: boolean;
|
|
433
|
+
/** Injection seam for tests — defaults to the real codegen watcher. */
|
|
434
|
+
startCodegen?: typeof startCodegenWatch;
|
|
435
|
+
/** Injection seam for tests — defaults to the real studio server. */
|
|
436
|
+
startStudio?: typeof startStudioServer;
|
|
437
|
+
/** Injection seam for tests — defaults to spawning a real `wrangler dev`. */
|
|
438
|
+
startWorker?: WorkerSpawner;
|
|
439
|
+
/** Disable the embedded studio server. */
|
|
440
|
+
studio?: boolean;
|
|
441
|
+
/** `wrangler dev` port. */
|
|
442
|
+
workerPort?: number;
|
|
443
|
+
}
|
|
444
|
+
interface DevRemotePlan {
|
|
445
|
+
/** Short binding labels remoted (e.g. `"DB (D1)"`), for the banner. */
|
|
446
|
+
bindings: string[];
|
|
447
|
+
/**
|
|
448
|
+
* Removes the generated temp wrangler config when dev exits. Always present
|
|
449
|
+
* and idempotent — a no-op when remote mode is off or nothing was
|
|
450
|
+
* materialized. The dev loop calls it on every shutdown path.
|
|
451
|
+
*/
|
|
452
|
+
cleanup: () => void;
|
|
453
|
+
/** Whether remote mode was requested. */
|
|
454
|
+
enabled: boolean;
|
|
455
|
+
/** Why remote mode didn't take effect despite being requested, for logging. */
|
|
456
|
+
reason?: string;
|
|
457
|
+
}
|
|
458
|
+
interface DevCommandPlan {
|
|
459
|
+
codegenEnabled: boolean;
|
|
460
|
+
/** The remote-binding decision: which D1/KV/R2 bindings hit the deployed worker. */
|
|
461
|
+
remote: DevRemotePlan;
|
|
462
|
+
studioEnabled: boolean;
|
|
463
|
+
studioPort: number;
|
|
464
|
+
workerOrigin: string;
|
|
465
|
+
workerPort: number;
|
|
466
|
+
/** The single child process `lunora dev` spawns: `wrangler dev`. */
|
|
467
|
+
wrangler: SpawnDescriptor & {
|
|
468
|
+
tag: string;
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Resolve remote-binding mode into the extra `wrangler dev` args + a banner
|
|
473
|
+
* summary. When `--remote`/`LUNORA_REMOTE` is set we materialize a temp wrangler
|
|
474
|
+
* config with `"remote": true` on each D1/KV/R2 binding (Durable Object shards
|
|
475
|
+
* stay local) and point `wrangler dev --config` at it, so the local worker reads
|
|
476
|
+
* and writes the **deployed** resources. When disabled, or when there's nothing
|
|
477
|
+
* to remote, the args stay empty and dev runs fully local.
|
|
478
|
+
*/
|
|
479
|
+
/**
|
|
480
|
+
* Plan `lunora dev`: it runs the worker via `wrangler dev` and nothing else as a
|
|
481
|
+
* child process. Vite is intentionally NOT spawned — a project may not use Vite,
|
|
482
|
+
* and when it does, the `@lunora/vite` plugin already runs the worker inside
|
|
483
|
+
* Vite, so the user runs `vite` themselves. Pure + synchronous so it's unit-testable.
|
|
484
|
+
*/
|
|
485
|
+
declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
|
|
486
|
+
/**
|
|
487
|
+
* Start codegen watch + the studio server, spawn `wrangler dev`, print the
|
|
488
|
+
* banner, and resolve when the worker exits or the user interrupts — tearing
|
|
489
|
+
* down the sibling servers either way. The three side-effecting pieces (worker,
|
|
490
|
+
* studio, codegen) are injectable so this is testable without real I/O.
|
|
491
|
+
*/
|
|
492
|
+
declare const runDevCommand: (options: DevCommandOptions) => Promise<{
|
|
493
|
+
code: number;
|
|
494
|
+
plan: DevCommandPlan;
|
|
495
|
+
}>;
|
|
496
|
+
/** `lunora dev` handler (lazy-loaded via the command's `loader`). */
|
|
497
|
+
/** Supported CI providers. */
|
|
498
|
+
type CiProvider = "github" | "gitlab";
|
|
499
|
+
/** A registry item a feature can install. */
|
|
500
|
+
type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | "mail";
|
|
501
|
+
/** The auth-provider choices offered for `add auth` / the init auth prompt. Each value is a registry item name. */
|
|
502
|
+
|
|
503
|
+
/** A feature offered in the post-scaffold multi-select. `value` is the stack-feature key, not (yet) a registry item. */
|
|
504
|
+
type StackFeature = "auth" | "email";
|
|
505
|
+
interface OfferDeps {
|
|
506
|
+
/** Apply one or more registry items into the new project; resolves `true` on success. */
|
|
507
|
+
apply: (names: ReadonlyArray<FeatureItem>) => Promise<boolean>;
|
|
508
|
+
/** When `false`, skip all prompts and print the later-setup hint. */
|
|
509
|
+
interactive: boolean;
|
|
510
|
+
logger: Logger;
|
|
511
|
+
/** Multi-select among the stack features to add (TTY-backed in production). */
|
|
512
|
+
multiSelect: (message: string, options: ReadonlyArray<{
|
|
513
|
+
description?: string;
|
|
514
|
+
label: string;
|
|
515
|
+
value: StackFeature;
|
|
516
|
+
}>, settings?: {
|
|
517
|
+
defaults?: ReadonlyArray<StackFeature>;
|
|
518
|
+
}) => Promise<StackFeature[]>;
|
|
519
|
+
/** Single-select among the auth providers (TTY-backed in production). */
|
|
520
|
+
select: (message: string, options: ReadonlyArray<{
|
|
521
|
+
description?: string;
|
|
522
|
+
label: string;
|
|
523
|
+
value: FeatureItem;
|
|
524
|
+
}>, settings?: {
|
|
525
|
+
default?: FeatureItem;
|
|
526
|
+
}) => Promise<FeatureItem | undefined>;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Offer the stack features (authentication, transactional email) in ONE
|
|
530
|
+
* multi-select after a successful scaffold. When auth is picked, a follow-up
|
|
531
|
+
* single-select chooses the provider (email+password / Clerk / Auth0); email
|
|
532
|
+
* maps to the `mail` item. Picked items are applied in selection order.
|
|
533
|
+
* Non-interactive: prints how to add them later and changes nothing.
|
|
534
|
+
*/
|
|
535
|
+
type Template = "astro" | "next" | "nuxt" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid" | "vite";
|
|
536
|
+
interface InitCommandOptions {
|
|
537
|
+
/**
|
|
538
|
+
* When true, accept `--source` values that don't start with `gh:` /
|
|
539
|
+
* `github:` / `https://` or that contain `..`. Defaults to false; the CLI
|
|
540
|
+
* gate exists to stop arbitrary filesystem / scheme sources from being
|
|
541
|
+
* pulled without the caller opting in.
|
|
542
|
+
*/
|
|
543
|
+
allowUnsafeSource?: boolean;
|
|
544
|
+
/** When set, also scaffold a CI deploy pipeline for the given provider. */
|
|
545
|
+
ci?: CiProvider;
|
|
546
|
+
cwd?: string;
|
|
547
|
+
/**
|
|
548
|
+
* Local directory containing the template subdirs (e.g. `vite/`,
|
|
549
|
+
* `standalone/`). When provided, skips the network fetch entirely.
|
|
550
|
+
* Useful for offline runs, the clean-machine smoke test, and unit tests.
|
|
551
|
+
*/
|
|
552
|
+
from?: string;
|
|
553
|
+
/**
|
|
554
|
+
* When true, configure Lunora into the CURRENT project (`cwd`) instead of
|
|
555
|
+
* scaffolding a new directory. Finds an existing `vite.config.*` and
|
|
556
|
+
* patches it via `patchViteConfig`, or creates a minimal one when absent.
|
|
557
|
+
* All other scaffold options (`name`, `templateType`, `source`, `from`)
|
|
558
|
+
* are ignored in this mode.
|
|
559
|
+
*/
|
|
560
|
+
inPlace?: boolean;
|
|
561
|
+
/**
|
|
562
|
+
* Force the post-scaffold "add auth / email?" offer on (the `--interactive`
|
|
563
|
+
* flag). When omitted, the offer runs only when stdin is a TTY. `--yes`
|
|
564
|
+
* suppresses it regardless. Has no effect once {@link prompt} is injected.
|
|
565
|
+
*/
|
|
566
|
+
interactive?: boolean;
|
|
567
|
+
logger: Logger;
|
|
568
|
+
name?: string;
|
|
569
|
+
/**
|
|
570
|
+
* Inject the offer's prompts (tests). When set, the offer is treated as
|
|
571
|
+
* interactive regardless of TTY, and these drive the feature multi-select
|
|
572
|
+
* and the auth-provider sub-select.
|
|
573
|
+
*/
|
|
574
|
+
prompt?: Pick<OfferDeps, "multiSelect" | "select">;
|
|
575
|
+
/** Local registry root for the offer's `runAddCommand` (offline / tests). Mirrors `from` but for registry items. */
|
|
576
|
+
registryFrom?: string;
|
|
577
|
+
/** Override the remote registry source base for the offer (default `gh:anolilab/lunora/registry`). */
|
|
578
|
+
registrySource?: string;
|
|
579
|
+
/**
|
|
580
|
+
* Override the remote source giget downloads from. Default:
|
|
581
|
+
* `gh:anolilab/lunora/templates/<templateType>#v<cliVersion>`. Tests
|
|
582
|
+
* typically use `from` instead to skip the network.
|
|
583
|
+
*/
|
|
584
|
+
source?: string;
|
|
585
|
+
templateType?: Template;
|
|
586
|
+
/** Suppress the offer entirely (the `--yes` flag): scaffold only, print the later-setup hint. */
|
|
587
|
+
yes?: boolean;
|
|
588
|
+
}
|
|
589
|
+
interface InitCommandResult {
|
|
590
|
+
code: number;
|
|
591
|
+
files: ReadonlyArray<string>;
|
|
592
|
+
target: string;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* `lunora init` entry: scaffold (in-place or a new directory), then — on success
|
|
596
|
+
* — offer to add auth + email via the registry. The offer never affects the
|
|
597
|
+
* scaffold's exit code.
|
|
598
|
+
*/
|
|
599
|
+
declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
|
|
600
|
+
/** Narrow a raw `--template` value to a known {@link Template} (defaults to vite). */
|
|
601
|
+
interface MigrateGenerateCommandOptions {
|
|
602
|
+
cwd?: string;
|
|
603
|
+
logger: Logger;
|
|
604
|
+
/** Migration name slug. Defaults to `auto`. */
|
|
605
|
+
name?: string;
|
|
606
|
+
/** Override the current time — used by tests for deterministic file names. */
|
|
607
|
+
now?: () => Date;
|
|
608
|
+
}
|
|
609
|
+
interface MigrateGenerateCommandResult {
|
|
610
|
+
code: number;
|
|
611
|
+
/** Whether the diff was empty (no changes detected). */
|
|
612
|
+
empty: boolean;
|
|
613
|
+
/** Absolute path to the migration file (empty string when nothing was written). */
|
|
614
|
+
migrationFile: string;
|
|
615
|
+
}
|
|
616
|
+
declare const runMigrateGenerateCommand: (options: MigrateGenerateCommandOptions) => MigrateGenerateCommandResult;
|
|
617
|
+
/** One catalog entry as `lunora registry list` reports it. */
|
|
618
|
+
interface CatalogItem {
|
|
619
|
+
description?: string;
|
|
620
|
+
name: string;
|
|
621
|
+
}
|
|
622
|
+
/** A built index entry (catalog item plus its short `title`). */
|
|
623
|
+
interface IndexItem extends CatalogItem {
|
|
624
|
+
title?: string;
|
|
625
|
+
}
|
|
626
|
+
/** Names of the subdirectories under `root` that ship a `registry.json`. */
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* Build the catalog (`index.json` contents) from a local registry root by
|
|
630
|
+
* reading every item's `registry.json`. Used by both `lunora registry build`
|
|
631
|
+
* and the registry tests so the committed index can't drift from the item dirs.
|
|
632
|
+
*/
|
|
633
|
+
declare const buildRegistryIndex: (root: string) => {
|
|
634
|
+
items: IndexItem[];
|
|
635
|
+
};
|
|
636
|
+
/** A single file the item scaffolds into the project. */
|
|
637
|
+
interface RegistryFile {
|
|
638
|
+
/** Source path inside the item dir (e.g. `schema.ts`). */
|
|
639
|
+
from: string;
|
|
640
|
+
/** Merge strategy. `create-or-skip` writes whole files; `schema-extension` AST-merges schema.ts. */
|
|
641
|
+
merge: "create-or-skip" | "schema-extension";
|
|
642
|
+
/** Destination relative to the project root (e.g. `lunora/ratelimit/index.ts`). */
|
|
643
|
+
to: string;
|
|
644
|
+
}
|
|
645
|
+
/** A wrangler.jsonc binding addition. `path` is the jsonc key path; `value` the value to set. */
|
|
646
|
+
interface RegistryBinding {
|
|
647
|
+
path: ReadonlyArray<string>;
|
|
648
|
+
value: unknown;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
|
|
652
|
+
* local-secrets file) on add — non-secrets get their `value`; secrets get an
|
|
653
|
+
* empty placeholder and a reminder to run `wrangler secret put` for production.
|
|
654
|
+
*/
|
|
655
|
+
interface RegistryEnvVariable {
|
|
656
|
+
/** Human note on what the variable is for. */
|
|
657
|
+
description?: string;
|
|
658
|
+
/** The variable name (e.g. `RESEND_API_KEY`). */
|
|
659
|
+
name: string;
|
|
660
|
+
/** Mark as a secret: never write a value, only a placeholder, and remind about prod. Defaults to `true` when no `value` is given. */
|
|
661
|
+
secret?: boolean;
|
|
662
|
+
/** A default/example value for non-secret vars. */
|
|
663
|
+
value?: string;
|
|
664
|
+
}
|
|
665
|
+
/** The `registry.json` manifest shape. */
|
|
666
|
+
interface RegistryManifest {
|
|
667
|
+
/** wrangler.jsonc additions (best-effort structural edits). */
|
|
668
|
+
bindings?: ReadonlyArray<RegistryBinding>;
|
|
669
|
+
/** npm deps to add to the project package.json (name → version range). */
|
|
670
|
+
deps?: Readonly<Record<string, string>>;
|
|
671
|
+
description?: string;
|
|
672
|
+
/** npm devDependencies to add to the project package.json. */
|
|
673
|
+
devDependencies?: Readonly<Record<string, string>>;
|
|
674
|
+
/** Post-install guidance printed after the item is added (per-item next steps). */
|
|
675
|
+
docs?: string;
|
|
676
|
+
/** Environment variables the item needs; scaffolded into `.dev.vars`. */
|
|
677
|
+
envVars?: ReadonlyArray<RegistryEnvVariable>;
|
|
678
|
+
files: ReadonlyArray<RegistryFile>;
|
|
679
|
+
name: string;
|
|
680
|
+
/** Other registry items this one depends on (resolved transitively, deps first). */
|
|
681
|
+
requires?: ReadonlyArray<string>;
|
|
682
|
+
/** Short human-readable label (distinct from the longer `description`). */
|
|
683
|
+
title?: string;
|
|
684
|
+
}
|
|
685
|
+
interface AddCommandOptions {
|
|
686
|
+
/** Bypass the `--source` safety gate (matches init). */
|
|
687
|
+
allowUnsafeSource?: boolean;
|
|
688
|
+
/** `registry build --check`: verify the index is current instead of rewriting it. */
|
|
689
|
+
check?: boolean;
|
|
690
|
+
/** Inject a confirmer for non-interactive callers / tests. */
|
|
691
|
+
confirm?: (prompt: string) => Promise<boolean>;
|
|
692
|
+
cwd?: string;
|
|
693
|
+
/** Preview the file-level changes (a content diff) and write nothing. */
|
|
694
|
+
diff?: boolean;
|
|
695
|
+
/** Print the plan and stop without writing anything. */
|
|
696
|
+
dryRun?: boolean;
|
|
697
|
+
/** Local registry root (offline / tests). Expects per-item subdirs, each with a `registry.json`. */
|
|
698
|
+
from?: string;
|
|
699
|
+
/** Emit a JSON snapshot of the plan/result. */
|
|
700
|
+
json?: boolean;
|
|
701
|
+
/** `--list`: enumerate available items instead of adding. */
|
|
702
|
+
list?: boolean;
|
|
703
|
+
logger: Logger;
|
|
704
|
+
/** Item names to add (positional args). */
|
|
705
|
+
names: ReadonlyArray<string>;
|
|
706
|
+
/** `registry build` output path for the generated catalog (defaults to the root's `index.json`). */
|
|
707
|
+
out?: string;
|
|
708
|
+
/** Force-overwrite existing files (take the incoming copy) instead of skipping/conflicting. */
|
|
709
|
+
overwrite?: boolean;
|
|
710
|
+
/** Override the remote registry source base (default gh:anolilab/lunora/registry). */
|
|
711
|
+
source?: string;
|
|
712
|
+
/** Skip the package.json mutation confirmation prompt. */
|
|
713
|
+
yes?: boolean;
|
|
714
|
+
}
|
|
715
|
+
interface AddCommandResult {
|
|
716
|
+
/** Bindings written to wrangler.jsonc. */
|
|
717
|
+
bindings: ReadonlyArray<string>;
|
|
718
|
+
code: number;
|
|
719
|
+
/** Deps added to package.json. */
|
|
720
|
+
deps: ReadonlyArray<string>;
|
|
721
|
+
/** Files skipped because they already existed. */
|
|
722
|
+
skipped: ReadonlyArray<string>;
|
|
723
|
+
/** Files written (absolute paths). */
|
|
724
|
+
written: ReadonlyArray<string>;
|
|
725
|
+
}
|
|
726
|
+
/** One resolved item: its parsed manifest plus the (possibly staged) directory it lives in. */
|
|
727
|
+
/** `lunora registry add` (one or more item names): scaffold items into the project. */
|
|
728
|
+
declare const runAddCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
729
|
+
/**
|
|
730
|
+
* `lunora registry view` — inspect a registry item without installing it:
|
|
731
|
+
* print its plan (files / deps / env vars) followed by the full contents of each
|
|
732
|
+
* file it would scaffold. Resolves only the named item — no `requires` expansion.
|
|
733
|
+
*/
|
|
734
|
+
declare const runRegistryViewCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
735
|
+
/**
|
|
736
|
+
* `lunora registry build` — regenerate `index.json` from the item directories
|
|
737
|
+
* (the catalog `list` reads). With `--check`, verify the committed index matches
|
|
738
|
+
* instead of rewriting it (exits non-zero on drift) — a CI guard.
|
|
739
|
+
*/
|
|
740
|
+
declare const runBuildIndexCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
741
|
+
/** Validate + narrow a parsed JSON value into a {@link RegistryManifest}. */
|
|
742
|
+
declare const parseManifest: (raw: unknown, itemName: string) => RegistryManifest;
|
|
743
|
+
interface ResetCommandOptions {
|
|
744
|
+
all?: boolean;
|
|
745
|
+
/** Inject a custom confirmer (tests, non-TTY callers). Returns `true` on confirmation. */
|
|
746
|
+
confirm?: (prompt: string) => Promise<boolean>;
|
|
747
|
+
cwd?: string;
|
|
748
|
+
logger: Logger;
|
|
749
|
+
/** Skip confirmation. Required when stdin is not a TTY. */
|
|
750
|
+
yes?: boolean;
|
|
751
|
+
}
|
|
752
|
+
interface ResetCommandResult {
|
|
753
|
+
code: number;
|
|
754
|
+
removed: ReadonlyArray<string>;
|
|
755
|
+
}
|
|
756
|
+
declare const runResetCommand: (options: ResetCommandOptions) => Promise<ResetCommandResult>;
|
|
757
|
+
/** `lunora reset` handler (lazy-loaded via the command's `loader`). */
|
|
758
|
+
/**
|
|
759
|
+
* Tiny argv parser.
|
|
760
|
+
*
|
|
761
|
+
* Supports long options (`--name value`, `--name=value`, `--flag`), short
|
|
762
|
+
* options (`-x value`, `-xvalue`), positional arguments (everything else, in
|
|
763
|
+
* order), and a `--` terminator after which everything is positional.
|
|
764
|
+
*
|
|
765
|
+
* Intentionally small — replaces a full CLI library for the handful of
|
|
766
|
+
* subcommands we need.
|
|
767
|
+
*/
|
|
768
|
+
interface ParsedArgs {
|
|
769
|
+
flags: Record<string, boolean>;
|
|
770
|
+
options: Record<string, string>;
|
|
771
|
+
positional: ReadonlyArray<string>;
|
|
772
|
+
}
|
|
773
|
+
declare const parseArgs: (argv: ReadonlyArray<string>, booleanFlags?: ReadonlySet<string>) => ParsedArgs;
|
|
774
|
+
type InsertSchemaExtensionResult = {
|
|
775
|
+
ok: true;
|
|
776
|
+
text: string;
|
|
777
|
+
} | {
|
|
778
|
+
ok: false;
|
|
779
|
+
reason: "already-applied" | "invalid-identifier" | "no-define-schema" | "non-object-argument";
|
|
780
|
+
};
|
|
781
|
+
/**
|
|
782
|
+
* Append `.extend(<key>.extension)` and a managed import to an existing
|
|
783
|
+
* `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
|
|
784
|
+
* `already-applied` and leaves the text unchanged.
|
|
785
|
+
* @param source the current `lunora/schema.ts` contents
|
|
786
|
+
* @param key the registry item key (e.g. `"ratelimit"`)
|
|
787
|
+
*/
|
|
788
|
+
declare const insertSchemaExtension: (source: string, key: string) => InsertSchemaExtensionResult;
|
|
789
|
+
/** Compact snapshot of a single global table — what we persist + diff. */
|
|
790
|
+
interface TableSnapshot {
|
|
791
|
+
columns: Record<string, ColumnSnapshot>;
|
|
792
|
+
indexes: Record<string, IndexSnapshot>;
|
|
793
|
+
/** Table name (also the JSON key — duplicated for ease of iteration). */
|
|
794
|
+
name: string;
|
|
795
|
+
}
|
|
796
|
+
interface ColumnSnapshot {
|
|
797
|
+
/** True when the column accepts NULL (validator wrapped in v.optional). */
|
|
798
|
+
nullable: boolean;
|
|
799
|
+
/** SQLite type affinity, derived from the validator. */
|
|
800
|
+
sqlType: "BLOB" | "INTEGER" | "REAL" | "TEXT";
|
|
801
|
+
}
|
|
802
|
+
interface IndexSnapshot {
|
|
803
|
+
fields: ReadonlyArray<string>;
|
|
804
|
+
name: string;
|
|
805
|
+
unique: boolean;
|
|
806
|
+
}
|
|
807
|
+
interface SchemaSnapshot {
|
|
808
|
+
tables: Record<string, TableSnapshot>;
|
|
809
|
+
version: 1;
|
|
810
|
+
}
|
|
811
|
+
interface DiffEntry {
|
|
812
|
+
kind: "addColumn" | "createIndex" | "createTable" | "dropIndex" | "dropTable";
|
|
813
|
+
/** Generated SQL for this delta (already terminated with `;`). */
|
|
814
|
+
sql: string;
|
|
815
|
+
/** Human-readable summary, used in migration headers. */
|
|
816
|
+
summary: string;
|
|
817
|
+
}
|
|
818
|
+
interface UnsupportedEntry {
|
|
819
|
+
kind: "columnTypeChange" | "dropColumn" | "indexRename" | "renameColumn";
|
|
820
|
+
/** Human-readable description, embedded as SQL comments. */
|
|
821
|
+
summary: string;
|
|
822
|
+
}
|
|
823
|
+
interface SchemaDiff {
|
|
824
|
+
/** No-op marker — true when there is genuinely nothing to apply. */
|
|
825
|
+
empty: boolean;
|
|
826
|
+
entries: ReadonlyArray<DiffEntry>;
|
|
827
|
+
unsupported: ReadonlyArray<UnsupportedEntry>;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Map a Lunora validator kind to a SQLite type affinity — the canonical
|
|
831
|
+
* `@lunora/d1/dialect` mapping. Re-exported under this name because
|
|
832
|
+
* `schema-snapshot.ts` builds the persisted snapshot from it.
|
|
833
|
+
*/
|
|
834
|
+
declare const validatorKindToSqlType: (kind: string) => ColumnSnapshot["sqlType"];
|
|
835
|
+
/** Emit `CREATE TABLE` SQL for a new global table. */
|
|
836
|
+
declare const renderCreateTable: (table: TableSnapshot) => string;
|
|
837
|
+
declare const renderDropTable: (tableName: string) => string;
|
|
838
|
+
declare const renderAddColumn: (tableName: string, columnName: string, column: ColumnSnapshot) => string;
|
|
839
|
+
declare const renderCreateIndex: (tableName: string, index: IndexSnapshot) => string;
|
|
840
|
+
declare const renderDropIndex: (tableName: string, indexName: string) => string;
|
|
841
|
+
/**
|
|
842
|
+
* Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
|
|
843
|
+
*/
|
|
844
|
+
declare const diffSnapshots: (previous: SchemaSnapshot | undefined, next: SchemaSnapshot) => SchemaDiff;
|
|
845
|
+
/**
|
|
846
|
+
* Render a complete migration file body from a diff. Includes a header,
|
|
847
|
+
* each SQL statement, and (if any) a trailing comment block describing the
|
|
848
|
+
* manual SQL the user needs to fill in for unsupported deltas.
|
|
849
|
+
*/
|
|
850
|
+
declare const renderMigrationFile: (name: string, diff: SchemaDiff, generatedAt: string) => string;
|
|
851
|
+
declare const schemaIrToSnapshot: (ir: SchemaIR) => SchemaSnapshot;
|
|
852
|
+
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, parseArgs, parseManifest, planDevCommand, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, runAddCommand, runBuildIndexCommand, runCli, runCodegenCommand, runDeployCommand, runDevCommand, runExportCommand, runImportCommand, runInitCommand, runMigrateGenerateCommand, runRegistryViewCommand, runResetCommand, runRpcCommand, schemaIrToSnapshot, validatorKindToSqlType };
|