@lunora/cli 1.0.0-alpha.15 → 1.0.0-alpha.151
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/README.md +1 -1
- package/__assets__/package-og.svg +1 -1
- package/dist/bin.mjs +2 -10
- package/dist/index.d.mts +658 -335
- package/dist/index.d.ts +658 -335
- 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 +2 -192
- package/dist/packem_chunks/handler12.mjs +2 -131
- package/dist/packem_chunks/handler13.mjs +1 -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 +3 -105
- package/dist/packem_chunks/handler18.mjs +1 -170
- package/dist/packem_chunks/handler19.mjs +1 -89
- package/dist/packem_chunks/handler2.mjs +2 -114
- package/dist/packem_chunks/handler20.mjs +7 -94
- package/dist/packem_chunks/handler21.mjs +2 -311
- package/dist/packem_chunks/handler22.mjs +2 -0
- package/dist/packem_chunks/handler23.mjs +1 -0
- package/dist/packem_chunks/handler24.mjs +99 -0
- package/dist/packem_chunks/handler25.mjs +10 -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 +3 -174
- package/dist/packem_chunks/handler9.mjs +1 -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 +1018 -1315
- 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-DMyRipjO.mjs +1 -0
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Dqu4Zmi0.mjs +1 -0
- package/dist/packem_shared/admin-token-BKmc3AUm.mjs +1 -0
- package/dist/packem_shared/admin-url-Ca-KI3d_.mjs +1 -0
- package/dist/packem_shared/advisory-gate-yaOOyUQl.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-RVVu3rxm.mjs +3 -0
- package/dist/packem_shared/codegen-error-DJN6pTH5.mjs +3 -0
- package/dist/packem_shared/command-0l-ZPhIX.mjs +1 -0
- package/dist/packem_shared/commands-CG9qEtqR.mjs +19 -0
- package/dist/packem_shared/createLogger-BoSxdb2T.mjs +2 -0
- package/dist/packem_shared/createRecordingSpawner-SKs4R1fc.mjs +1 -0
- package/dist/packem_shared/deploy-target-Dvr9vxpR.mjs +1 -0
- package/dist/packem_shared/detect-package-manager-DXDstphE.mjs +1 -0
- package/dist/packem_shared/diffSnapshots-BbwCuhoN.mjs +5 -0
- package/dist/packem_shared/docker-CKvYE9YF.mjs +1 -0
- package/dist/packem_shared/health-probe-CiFgh1hn.mjs +1 -0
- package/dist/packem_shared/import-DLyCq-2j.mjs +12 -0
- package/dist/packem_shared/insertSchemaExtension-DZReBZ4_.mjs +8 -0
- package/dist/packem_shared/lint-ignore-report-CKDXv9MQ.mjs +2 -0
- package/dist/packem_shared/open-url-zbbAo_D7.mjs +1 -0
- package/dist/packem_shared/output-format-Cv3aLqhP.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-DhL1RH5u.mjs +1 -0
- package/dist/packem_shared/prompt-cancelled-C8Sj7OqI.mjs +1 -0
- package/dist/packem_shared/resolve-target-CeiNrCAx.mjs +1 -0
- package/dist/packem_shared/runAddCommand-a_rW768_.mjs +1 -0
- package/dist/packem_shared/runExportCommand-BpE4AbuX.mjs +5 -0
- package/dist/packem_shared/schema-drift-gate-d12lMICD.mjs +1 -0
- package/dist/packem_shared/schemaIrToSnapshot-Dahp39qH.mjs +1 -0
- package/dist/packem_shared/shared-Ce9bKz5c.mjs +1 -0
- package/dist/packem_shared/tui-prompts-BU3irGxV.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-D0Tv5GWn.mjs +1 -0
- package/package.json +39 -17
- 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 +58 -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-hl0mRqqg.mjs +0 -845
- 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-vJdgiR5t.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-B7hHSTZP.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.ts
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
import { CodegenOptions, SchemaIR } from '@lunora/codegen';
|
|
1
|
+
import { CodegenOptions, Finding, SchemaIR } from '@lunora/codegen';
|
|
2
2
|
import '@visulima/cerebro';
|
|
3
|
-
import { ensureDevVariables, ensureDevVarsExample,
|
|
4
|
-
|
|
3
|
+
import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, LintTool, LintIgnoreOutcome } from '@lunora/config';
|
|
4
|
+
import 'adm-zip';
|
|
5
|
+
import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
|
|
6
|
+
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
7
|
/** 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"];
|
|
8
|
+
declare const COMMANDS: readonly ["init", "add", "dev", "codegen", "build", "deploy", "containers", "prepare", "link", "deployments", "logs", "run", "insights", "reset", "migrate", "export", "import", "seed", "backup", "eval", "verify", "info", "doctor", "env", "analyze", "view", "docs", "registry", "rules", "mcp"];
|
|
7
9
|
type CommandName = (typeof COMMANDS)[number];
|
|
8
10
|
declare const VERSION: string;
|
|
9
11
|
interface RunCliOptions {
|
|
10
12
|
argv?: ReadonlyArray<string>;
|
|
11
13
|
cwd?: string;
|
|
12
14
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
* Inject a console-like logger so callers (tests) can capture cerebro's
|
|
16
|
+
* help / version / usage rendering. Omitted in production, where cerebro
|
|
17
|
+
* uses its default stdout/stderr logger.
|
|
18
|
+
*/
|
|
17
19
|
logger?: Console;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
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
|
-
*/
|
|
22
|
+
* Run the CLI and resolve to the process exit code. cerebro handles help,
|
|
23
|
+
* version, usage, and unknown commands (the latter throws, caught here as 1).
|
|
24
|
+
* `shouldExitProcess: false` keeps the process alive so callers/tests read the
|
|
25
|
+
* captured exit code.
|
|
26
|
+
*/
|
|
25
27
|
declare const runCli: (options?: RunCliOptions) => Promise<number>;
|
|
26
28
|
/**
|
|
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
|
-
*/
|
|
29
|
+
* The `--api-spec` flag's accepted values, mirroring `@lunora/codegen`'s
|
|
30
|
+
* `CodegenOptions["apiSpec"]`. `"openapi"` (the default) emits `openapi.json`;
|
|
31
|
+
* `"openrpc"` emits `openrpc.json`; `"both"` emits both; `"none"` emits neither.
|
|
32
|
+
*/
|
|
31
33
|
type ApiSpec = NonNullable<CodegenOptions["apiSpec"]>;
|
|
32
34
|
interface Logger {
|
|
33
35
|
debug?: (message: string) => void;
|
|
@@ -37,11 +39,11 @@ interface Logger {
|
|
|
37
39
|
warn: (message: string) => void;
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
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
|
-
*/
|
|
42
|
+
* Narrowed view over the pail instance. `createPail` returns an intersection
|
|
43
|
+
* type that includes a constructor signature and `(...args: any[])` logger
|
|
44
|
+
* overloads, which the type-aware linter cannot safely resolve. We only ever
|
|
45
|
+
* call the level methods with a string, so we describe exactly that surface.
|
|
46
|
+
*/
|
|
45
47
|
interface PailLogger {
|
|
46
48
|
debug: (message: string) => void;
|
|
47
49
|
error: (message: string) => void;
|
|
@@ -51,25 +53,12 @@ interface PailLogger {
|
|
|
51
53
|
}
|
|
52
54
|
declare const createLogger: () => Logger;
|
|
53
55
|
/**
|
|
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
|
-
*/
|
|
56
|
+
* Direct access to the underlying pail instance for advanced use-cases.
|
|
57
|
+
* A Proxy keeps the public `pail` binding lazy: the real pail is only
|
|
58
|
+
* constructed on first property access, so importing this module (and thus
|
|
59
|
+
* the package barrel) stays side-effect-free.
|
|
60
|
+
*/
|
|
66
61
|
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
62
|
interface CodegenCommandOptions {
|
|
74
63
|
/** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
|
|
75
64
|
apiSpec?: ApiSpec;
|
|
@@ -77,33 +66,43 @@ interface CodegenCommandOptions {
|
|
|
77
66
|
/** Output format: `pretty` (default) or `json`. */
|
|
78
67
|
format?: string;
|
|
79
68
|
logger: Logger;
|
|
69
|
+
/**
|
|
70
|
+
* Fail the run when any ERROR-level advisory is reported. Defaults to CI
|
|
71
|
+
* detection so a local `lunora codegen` stays advisory while a pipeline
|
|
72
|
+
* gates on it; `--no-strict-advisories` forces it off either way.
|
|
73
|
+
*/
|
|
74
|
+
strictAdvisories?: boolean;
|
|
75
|
+
/** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
|
|
76
|
+
target?: string;
|
|
80
77
|
}
|
|
81
78
|
interface CodegenCommandResult {
|
|
82
79
|
advisories: ReadonlyArray<{
|
|
83
80
|
detail: string;
|
|
84
|
-
level:
|
|
81
|
+
level: Finding["level"];
|
|
85
82
|
name: string;
|
|
86
83
|
remediation: string;
|
|
87
84
|
}>;
|
|
88
85
|
cronTriggers: ReadonlyArray<string>;
|
|
89
|
-
/** Set when the run
|
|
86
|
+
/** Set when the run failed: an invalid `--format`, an unregistered target, or an error-level platform diagnostic. */
|
|
90
87
|
error?: string;
|
|
88
|
+
/** ERROR-level advisories that made the run fail, when strict mode is on. */
|
|
89
|
+
failedAdvisories: number;
|
|
91
90
|
outputDirectory: string;
|
|
92
91
|
}
|
|
93
92
|
declare const runCodegenCommand: (options: CodegenCommandOptions) => CodegenCommandResult;
|
|
94
|
-
/** `lunora codegen` handler (lazy-loaded via the command's `loader`). */
|
|
95
|
-
/** Rows per HTTP request when importing. Convex uses ~500; same here. */
|
|
96
|
-
declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
|
|
97
93
|
/**
|
|
98
|
-
* Minimal projection of `globalThis.fetch` for the
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
|
|
94
|
+
* Minimal projection of `globalThis.fetch` for the transfer commands: `body` is
|
|
95
|
+
* exposed as a stream-iterable (the export path pipes it) and accepts bytes (the
|
|
96
|
+
* blob path uploads them). The JSON-only commands use the narrower `FetchLike`
|
|
97
|
+
* in `../run/handler` instead.
|
|
98
|
+
*/
|
|
102
99
|
type StreamingFetchLike = (input: string, init?: {
|
|
103
|
-
body?: string;
|
|
100
|
+
body?: string | Uint8Array;
|
|
104
101
|
headers?: Record<string, string>;
|
|
105
102
|
method?: string;
|
|
106
103
|
}) => Promise<{
|
|
104
|
+
/** Optional: only the storage transfer reads raw bytes, and only real `fetch` needs to supply it. */
|
|
105
|
+
arrayBuffer?: () => Promise<ArrayBuffer>;
|
|
107
106
|
body: ReadableStream<Uint8Array> | null;
|
|
108
107
|
json: () => Promise<unknown>;
|
|
109
108
|
ok: boolean;
|
|
@@ -132,11 +131,70 @@ interface ExportCommandResult {
|
|
|
132
131
|
rows: number;
|
|
133
132
|
}
|
|
134
133
|
/**
|
|
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
|
-
*/
|
|
134
|
+
* Stream an export. The worker emits NDJSON; we count newlines as we go and
|
|
135
|
+
* pipe straight to the output sink, so a 10M-row export doesn't materialise
|
|
136
|
+
* the body in memory.
|
|
137
|
+
*/
|
|
139
138
|
declare const runExportCommand: (options: ExportCommandOptions) => Promise<ExportCommandResult>;
|
|
139
|
+
/** One row-scoped failure as the admin import endpoint reports it. */
|
|
140
|
+
interface ImportRowError {
|
|
141
|
+
code: string;
|
|
142
|
+
line: number;
|
|
143
|
+
message: string;
|
|
144
|
+
table: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The sources `--from` accepts.
|
|
148
|
+
*
|
|
149
|
+
* Only the two that cannot be detected. A Convex snapshot announces itself (a
|
|
150
|
+
* directory of `<table>/documents.jsonl`, or a `.zip` of one) and anything else
|
|
151
|
+
* is NDJSON, so naming those would advertise a control this does not implement:
|
|
152
|
+
* `--from ndjson` against a Convex export would have to either refuse it or
|
|
153
|
+
* silently import it as Convex, and the second is what an unhonoured flag
|
|
154
|
+
* actually did.
|
|
155
|
+
*/
|
|
156
|
+
declare const IMPORT_SOURCE_NAMES: readonly ["firebase", "supabase"];
|
|
157
|
+
type ImportSourceName = (typeof IMPORT_SOURCE_NAMES)[number];
|
|
158
|
+
/**
|
|
159
|
+
* The storage-reference rewrite: turning a Convex storage id into the
|
|
160
|
+
* content-hash R2 key its blob was migrated to.
|
|
161
|
+
*
|
|
162
|
+
* Split out of `./storage-mapping` (which owns the mapping *file*) because it
|
|
163
|
+
* has two callers that must never diverge — the import rewrite and `--scan`,
|
|
164
|
+
* which runs this same walk as a dry run to propose the mapping. A detector
|
|
165
|
+
* that proposed columns the rewrite would not touch, or missed ones it would,
|
|
166
|
+
* is worse than no detector.
|
|
167
|
+
*/
|
|
168
|
+
/** One reference the walk could not rewrite, with where it was found. */
|
|
169
|
+
interface UnresolvedStorageReference {
|
|
170
|
+
column: string;
|
|
171
|
+
storageId: string;
|
|
172
|
+
table: string;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* What a run's storage references resolved to. The two failure buckets are
|
|
176
|
+
* deliberately separate, because they are not the same problem and do not have
|
|
177
|
+
* the same remedy:
|
|
178
|
+
*
|
|
179
|
+
* `unmigrated` is a reference to a blob that does not exist — the export omitted
|
|
180
|
+
* it, or `--include-file-storage` was not passed. Nothing the operator writes in
|
|
181
|
+
* a mapping file can fix it, and the data is broken after import, so it fails
|
|
182
|
+
* `--verify`.
|
|
183
|
+
*
|
|
184
|
+
* `ambiguous` is a string that exactly matches a blob that *did* migrate, sitting
|
|
185
|
+
* in a column the mapping does not name. It may be a storage reference the
|
|
186
|
+
* mapping forgot, or it may be user text that happens to equal an id. Failing the
|
|
187
|
+
* run on a coincidence is not defensible, so it warns and names the column the
|
|
188
|
+
* operator would add to resolve it.
|
|
189
|
+
*/
|
|
190
|
+
interface StorageRemapReport {
|
|
191
|
+
ambiguous: UnresolvedStorageReference[];
|
|
192
|
+
/** Number of references rewritten to a content-hash key. */
|
|
193
|
+
rewritten: number;
|
|
194
|
+
unmigrated: UnresolvedStorageReference[];
|
|
195
|
+
}
|
|
196
|
+
/** Rows per HTTP request when importing. Convex uses ~500; same here. */
|
|
197
|
+
declare const DEFAULT_IMPORT_BATCH_SIZE = 500;
|
|
140
198
|
interface ImportCommandOptions {
|
|
141
199
|
/** Rows per HTTP request. Defaults to {@link DEFAULT_IMPORT_BATCH_SIZE}. */
|
|
142
200
|
batchSize?: number;
|
|
@@ -144,88 +202,196 @@ interface ImportCommandOptions {
|
|
|
144
202
|
fetchImpl?: StreamingFetchLike;
|
|
145
203
|
/** Source NDJSON file. Required. */
|
|
146
204
|
file: string;
|
|
205
|
+
/**
|
|
206
|
+
* Which reader to use. Omit to auto-detect between a Convex export snapshot
|
|
207
|
+
* and a plain NDJSON file; `supabase`/`firebase` must be explicit, because a
|
|
208
|
+
* directory of CSV or JSON has no signature that distinguishes it from
|
|
209
|
+
* anything else a user might point at.
|
|
210
|
+
*/
|
|
211
|
+
from?: ImportSourceName;
|
|
147
212
|
logger: Logger;
|
|
148
213
|
prod?: boolean;
|
|
149
214
|
/**
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
215
|
+
* Scan the export for columns holding `_storage` ids and write a candidate
|
|
216
|
+
* `lunora/import-convex.json`. Scan-only: nothing is imported.
|
|
217
|
+
*/
|
|
218
|
+
scan?: boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Local directory of storage objects to migrate alongside the rows — how
|
|
221
|
+
* Firebase Cloud Storage arrives, after `gcloud storage cp -r`.
|
|
222
|
+
*/
|
|
223
|
+
storageDir?: string;
|
|
224
|
+
/**
|
|
225
|
+
* Wrap each line as `{table:<name>,doc:<line>}`. Use when the source NDJSON
|
|
226
|
+
* is bare docs from a single table — Convex's `convex import --table users`
|
|
227
|
+
* shape.
|
|
228
|
+
*/
|
|
154
229
|
table?: string;
|
|
155
230
|
token?: string;
|
|
156
231
|
url?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Verify per-table row parity + dangling-storage after import. Exits non-zero
|
|
234
|
+
* when a table's inserted count differs from its source line count, or when a
|
|
235
|
+
* document references a storage id that was not migrated.
|
|
236
|
+
*/
|
|
237
|
+
verify?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Also migrate Convex `_storage` blobs: read `_storage/documents.jsonl`, upload
|
|
240
|
+
* each blob with sha256+size verification, and build the `storageId → key` map.
|
|
241
|
+
* Off by default so the plain-document import path is unchanged.
|
|
242
|
+
*/
|
|
243
|
+
withStorage?: boolean;
|
|
244
|
+
/** Confirm bulk-writing production. Required alongside `--prod`. */
|
|
245
|
+
yes?: boolean;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The JSON summary a run prints and returns — the same object either way, so a
|
|
249
|
+
* caller reading `body.conflicts` does not have to cast its way there.
|
|
250
|
+
*
|
|
251
|
+
* `undefined` on every path that imports nothing: a rejected source, a failed
|
|
252
|
+
* storage phase, or `--scan` (whose product is the mapping file it writes, not
|
|
253
|
+
* a return value).
|
|
254
|
+
*/
|
|
255
|
+
interface ImportSummary {
|
|
256
|
+
conflicts: number;
|
|
257
|
+
errors: ImportRowError[];
|
|
258
|
+
inserted: Record<string, number>;
|
|
259
|
+
received: number;
|
|
260
|
+
storage?: {
|
|
261
|
+
ambiguous: StorageRemapReport["ambiguous"];
|
|
262
|
+
blobs: number;
|
|
263
|
+
rewritten: number;
|
|
264
|
+
unmigrated: StorageRemapReport["unmigrated"];
|
|
265
|
+
};
|
|
266
|
+
warnings?: string[];
|
|
157
267
|
}
|
|
158
268
|
interface ImportCommandResult {
|
|
159
|
-
body:
|
|
269
|
+
body: ImportSummary | undefined;
|
|
160
270
|
code: number;
|
|
161
271
|
/** Total inserted rows across batches. */
|
|
162
272
|
inserted: number;
|
|
163
273
|
}
|
|
164
|
-
/**
|
|
165
|
-
* Stream an NDJSON file in chunks, POSTing each batch to
|
|
166
|
-
* `/_lunora/admin/import`. We keep the line buffer bounded by `batchSize` so a
|
|
167
|
-
* multi-GiB file imports without buffering everything in memory.
|
|
168
|
-
*/
|
|
169
274
|
declare const runImportCommand: (options: ImportCommandOptions) => Promise<ImportCommandResult>;
|
|
170
275
|
/**
|
|
171
|
-
* Injectable probe for a Docker-compatible container engine. Tests pass a
|
|
172
|
-
* stub; production uses {@link isDockerAvailable}.
|
|
173
|
-
*/
|
|
276
|
+
* Injectable probe for a Docker-compatible container engine. Tests pass a
|
|
277
|
+
* stub; production uses {@link isDockerAvailable}.
|
|
278
|
+
*/
|
|
174
279
|
type DockerProbe = () => boolean;
|
|
175
280
|
/**
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
|
|
281
|
+
* The shared `/_lunora/health` probe used by `lunora verify --health-url` and
|
|
282
|
+
* `lunora deploy --health-check`.
|
|
283
|
+
*
|
|
284
|
+
* Both commands ask the same question — "does this deployment answer?" — so
|
|
285
|
+
* they ask it through one implementation with one error-message shape. The
|
|
286
|
+
* runtime auto-registers both routes (`packages/runtime/src/health-routes.ts`):
|
|
287
|
+
* `/_lunora/health/ready` is the readiness gate ("can this version serve"), and
|
|
288
|
+
* `/_lunora/health` is the aggregate that also exists on older deployments.
|
|
289
|
+
*
|
|
290
|
+
* The probe is transport-only: it never throws, and reports its verdict as an
|
|
291
|
+
* `{ error }` message the caller decides what to do with.
|
|
292
|
+
*/
|
|
293
|
+
/**
|
|
294
|
+
* Minimal fetch surface the probe needs — a subset of the global `fetch`,
|
|
295
|
+
* injectable so a test can feed a canned response without a network.
|
|
296
|
+
*/
|
|
297
|
+
type HealthFetch = (url: string) => Promise<{
|
|
298
|
+
ok: boolean;
|
|
299
|
+
status: number;
|
|
300
|
+
}>;
|
|
181
301
|
interface SpawnDescriptor {
|
|
182
302
|
args: ReadonlyArray<string>;
|
|
183
303
|
/**
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
304
|
+
* Capture the child's stderr (in addition to streaming it to the parent).
|
|
305
|
+
* Needed when a tool reports the *expected* outcome as an error there —
|
|
306
|
+
* `wrangler vectorize create-metadata-index` writes "already exists" to
|
|
307
|
+
* stderr, and without this the caller can only see a bare exit code and
|
|
308
|
+
* would warn on every re-run. Composes with `stdoutToStderr`, so a caller
|
|
309
|
+
* can keep stdout clean for `--format json` and still read the reason.
|
|
310
|
+
*/
|
|
311
|
+
captureStderr?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Capture the child's stdout (in addition to streaming it to the parent), so
|
|
314
|
+
* the caller can parse it — used by `deploy` to read the deployed URL from
|
|
315
|
+
* `wrangler deploy` output. Each chunk is still teed to the parent's stdout
|
|
316
|
+
* so the user sees live progress. Mutually exclusive with `stdoutToStderr`
|
|
317
|
+
* and `captureStdoutSilently`.
|
|
318
|
+
*/
|
|
189
319
|
captureStdout?: boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Capture the child's stdout WITHOUT teeing it to the parent's stdout —
|
|
322
|
+
* for output that is parsed, never displayed (e.g. `wrangler secret list
|
|
323
|
+
* --format json`). Unlike `captureStdout`, nothing is written to
|
|
324
|
+
* `process.stdout`, so it can't interleave with — and corrupt — a
|
|
325
|
+
* caller's own stdout (notably `lunora deploy --format json`, which must
|
|
326
|
+
* emit exactly one JSON document). Mutually exclusive with `captureStdout`
|
|
327
|
+
* and `stdoutToStderr`.
|
|
328
|
+
*/
|
|
329
|
+
captureStdoutSilently?: boolean;
|
|
190
330
|
command: string;
|
|
191
331
|
cwd?: string;
|
|
192
332
|
env?: Readonly<Record<string, string>>;
|
|
193
333
|
/**
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
334
|
+
* Pipe this string into the child's stdin and close it. Used to feed
|
|
335
|
+
* `wrangler secret put` its value without exposing it on the command
|
|
336
|
+
* line or in env. When absent, stdin is inherited from the parent.
|
|
337
|
+
*/
|
|
198
338
|
input?: string;
|
|
199
339
|
/**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
340
|
+
* Route the child's stdout to the parent's STDERR instead of stdout. Set in
|
|
341
|
+
* `--format json` mode so a spawned tool's human output (e.g. `wrangler
|
|
342
|
+
* deploy`'s progress + the deployed URL) can't interleave with — and corrupt
|
|
343
|
+
* — the single JSON document the command prints to stdout.
|
|
344
|
+
*/
|
|
205
345
|
stdoutToStderr?: boolean;
|
|
206
346
|
}
|
|
207
347
|
interface SpawnResult {
|
|
208
348
|
code: number;
|
|
209
|
-
/** The captured
|
|
349
|
+
/** The captured stderr, present only when the descriptor set `captureStderr`. */
|
|
350
|
+
stderr?: string;
|
|
351
|
+
/** The captured stdout, present only when the descriptor set `captureStdout` or `captureStdoutSilently`. */
|
|
210
352
|
stdout?: string;
|
|
211
353
|
}
|
|
212
354
|
/**
|
|
213
|
-
* Injectable spawner. Tests pass a stub that just records the descriptor
|
|
214
|
-
* instead of executing a real subprocess.
|
|
215
|
-
*/
|
|
355
|
+
* Injectable spawner. Tests pass a stub that just records the descriptor
|
|
356
|
+
* instead of executing a real subprocess.
|
|
357
|
+
*/
|
|
216
358
|
type Spawner = (descriptor: SpawnDescriptor) => Promise<SpawnResult>;
|
|
217
359
|
declare const defaultSpawner: Spawner;
|
|
218
360
|
interface RecordedSpawn {
|
|
219
361
|
descriptor: SpawnDescriptor;
|
|
220
362
|
}
|
|
221
363
|
/**
|
|
222
|
-
* Test helper: returns a spawner that records every invocation and resolves
|
|
223
|
-
* with the configured exit code.
|
|
224
|
-
*/
|
|
364
|
+
* Test helper: returns a spawner that records every invocation and resolves
|
|
365
|
+
* with the configured exit code.
|
|
366
|
+
*/
|
|
225
367
|
declare const createRecordingSpawner: (exitCode?: number) => {
|
|
226
368
|
calls: RecordedSpawn[];
|
|
227
369
|
spawner: Spawner;
|
|
228
370
|
};
|
|
371
|
+
interface SecretListRunnerResult {
|
|
372
|
+
code: number;
|
|
373
|
+
stderr: string;
|
|
374
|
+
stdout: string;
|
|
375
|
+
}
|
|
376
|
+
/** Runs an argv and resolves its captured output. Injected in tests. */
|
|
377
|
+
type SecretListRunner = (command: string, args: ReadonlyArray<string>, cwd: string) => Promise<SecretListRunnerResult>;
|
|
378
|
+
interface ListRemoteSecretsInputs {
|
|
379
|
+
cwd: string;
|
|
380
|
+
/** Cloudflare environment name (`--env`). */
|
|
381
|
+
env?: string;
|
|
382
|
+
/** Injected command runner; defaults to a real `wrangler secret list`. */
|
|
383
|
+
runner?: SecretListRunner;
|
|
384
|
+
/** Target a temporary-account deployment (`--temporary`). */
|
|
385
|
+
temporary?: boolean;
|
|
386
|
+
}
|
|
387
|
+
interface ListRemoteSecretsResult {
|
|
388
|
+
/** Diagnostic message when `ok` is false. */
|
|
389
|
+
error?: string;
|
|
390
|
+
/** Remote secret names (sorted), empty when none or on failure. */
|
|
391
|
+
names: ReadonlyArray<string>;
|
|
392
|
+
/** False when wrangler failed or its output could not be parsed. */
|
|
393
|
+
ok: boolean;
|
|
394
|
+
}
|
|
229
395
|
type FetchLike = (input: string, init?: {
|
|
230
396
|
body?: string;
|
|
231
397
|
headers?: Record<string, string>;
|
|
@@ -238,11 +404,17 @@ type FetchLike = (input: string, init?: {
|
|
|
238
404
|
}>;
|
|
239
405
|
interface RunCommandOptions {
|
|
240
406
|
args?: string;
|
|
407
|
+
/** Forge this user id for the call (dispatches through the admin-gated `runAs` op). */
|
|
408
|
+
as?: string;
|
|
409
|
+
/** JSON-encoded extra identity claims to accompany {@link RunCommandOptions.as}. */
|
|
410
|
+
claims?: string;
|
|
241
411
|
cwd?: string;
|
|
242
412
|
fetchImpl?: FetchLike;
|
|
243
413
|
functionPath: string;
|
|
244
414
|
logger: Logger;
|
|
245
415
|
shard?: string;
|
|
416
|
+
/** Admin bearer for the `runAs` dispatch; resolved from the environment / `.dev.vars` when absent. */
|
|
417
|
+
token?: string;
|
|
246
418
|
url?: string;
|
|
247
419
|
}
|
|
248
420
|
interface RunCommandResult {
|
|
@@ -251,7 +423,6 @@ interface RunCommandResult {
|
|
|
251
423
|
requestUrl: string;
|
|
252
424
|
}
|
|
253
425
|
declare const runRpcCommand: (options: RunCommandOptions) => Promise<RunCommandResult>;
|
|
254
|
-
/** `lunora run <functionPath>` handler (lazy-loaded via the command's `loader`). */
|
|
255
426
|
interface DeployCommandOptions {
|
|
256
427
|
/** Override the schema-drift gate — deploy even with breaking drift and no new migration. */
|
|
257
428
|
allowSchemaDrift?: boolean;
|
|
@@ -261,82 +432,165 @@ interface DeployCommandOptions {
|
|
|
261
432
|
/** Docker-availability probe injected in tests. Defaults to a real `docker info` check. */
|
|
262
433
|
dockerAvailable?: DockerProbe;
|
|
263
434
|
/**
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
435
|
+
* Validate, bundle, and run all pre-deploy gates without publishing
|
|
436
|
+
* (`wrangler deploy --dry-run`). Post-deploy steps (data migrations, schema
|
|
437
|
+
* baseline re-bless) are skipped since nothing shipped.
|
|
438
|
+
*/
|
|
268
439
|
dryRun?: boolean;
|
|
269
440
|
env?: string;
|
|
270
441
|
/** Fetch implementation injected in tests for `--migrate` RPC calls. */
|
|
271
442
|
fetchImpl?: FetchLike;
|
|
272
443
|
/** Output format: `pretty` (default) or `json`. */
|
|
273
444
|
format?: string;
|
|
445
|
+
/**
|
|
446
|
+
* After a successful live deploy, probe the new version's health route
|
|
447
|
+
* (`/_lunora/health/ready`, falling back to `/_lunora/health`) and fail the
|
|
448
|
+
* command when it never answers. Opt-in, not default-on: a worker whose
|
|
449
|
+
* health route is admin-gated or unreachable from CI must still be
|
|
450
|
+
* deployable, and a default network step would turn a successful deploy
|
|
451
|
+
* into a red build for an unrelated reason.
|
|
452
|
+
*/
|
|
453
|
+
healthCheck?: boolean;
|
|
454
|
+
/** Injectable fetch for `--health-check`; defaults to the global `fetch`. */
|
|
455
|
+
healthFetch?: HealthFetch;
|
|
456
|
+
/** Injectable inter-attempt delay for `--health-check`; injected in tests to skip the real wait. */
|
|
457
|
+
healthSleep?: (ms: number) => Promise<void>;
|
|
274
458
|
/** Set to `false` to disable interactive spinners (test injection). */
|
|
275
459
|
interactive?: boolean;
|
|
276
460
|
logger: Logger;
|
|
277
461
|
/**
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
462
|
+
* When true, after a successful `wrangler deploy`, discover and run all
|
|
463
|
+
* pending data migrations via the worker's `/_lunora/migrate` admin RPC.
|
|
464
|
+
* The worker must be live (exit 0) before migrations are attempted.
|
|
465
|
+
*
|
|
466
|
+
* Implementation note: the status RPC returns the full shard-level
|
|
467
|
+
* migration state, but there is no single authoritative "list of pending
|
|
468
|
+
* migration ids" that can be read client-side before running the worker.
|
|
469
|
+
* Instead, `--migrate` runs `migrate status` followed by `migrate up` for
|
|
470
|
+
* each migration id discovered locally via `discoverMigrations`. The
|
|
471
|
+
* worker's `MigrationRunner` is idempotent — running `up` on an already-
|
|
472
|
+
* applied migration is a no-op — so this approach is safe.
|
|
473
|
+
*/
|
|
290
474
|
migrate?: boolean;
|
|
291
475
|
/** Admin bearer token for `--migrate` (falls back to `LUNORA_ADMIN_TOKEN`). */
|
|
292
476
|
migrateToken?: string;
|
|
293
477
|
/**
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
478
|
+
* Worker URL for `--migrate`. REQUIRED when `--migrate` is set — the deploy
|
|
479
|
+
* handler never captures the URL `wrangler deploy` published to, so there is
|
|
480
|
+
* no safe default; omitting it would silently target `http://localhost:8787`
|
|
481
|
+
* (the dev worker), applying the migration to local state instead of prod.
|
|
482
|
+
*/
|
|
299
483
|
migrateUrl?: string;
|
|
300
484
|
/**
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
485
|
+
* Confirm a production data migration triggered via `--migrate` (the
|
|
486
|
+
* `migrate up --prod` confirmation the standalone command requires). Without
|
|
487
|
+
* it a `--migrate --migrate-url <prod>` deploy refuses to run the migration.
|
|
488
|
+
*/
|
|
305
489
|
migrateYes?: boolean;
|
|
306
490
|
/**
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
491
|
+
* Emit the bundled worker to this directory via `wrangler deploy --outdir`
|
|
492
|
+
* (paired with `dryRun` by `lunora build`). Also writes esbuild metadata to
|
|
493
|
+
* `<outDir>/bundle-meta.json`. When unset, no artifact is written.
|
|
494
|
+
*/
|
|
311
495
|
outDir?: string;
|
|
312
496
|
/**
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
497
|
+
* Upload a preview version (`wrangler versions upload`) instead of a live
|
|
498
|
+
* `wrangler deploy`. Codegen + the drift gate + validation still run, but
|
|
499
|
+
* the post-deploy finalize (migrations, baseline re-bless, auto-link, the
|
|
500
|
+
* production summary) is skipped — a preview never shifts live traffic.
|
|
501
|
+
*/
|
|
318
502
|
preview?: boolean;
|
|
319
503
|
/** Railpack-availability probe injected in tests. Defaults to a real `railpack --version` + `BUILDKIT_HOST` check. */
|
|
320
504
|
railpackAvailable?: DockerProbe;
|
|
505
|
+
/** Confirm prompt for the missing-secret offer; injected in tests. Defaults to the TTY prompt. */
|
|
506
|
+
secretConfirm?: (message: string) => Promise<boolean>;
|
|
507
|
+
/** Remote-secret lister for the missing-secret offer; injected in tests. Defaults to `wrangler secret list`. */
|
|
508
|
+
secretLister?: (inputs: ListRemoteSecretsInputs) => Promise<ListRemoteSecretsResult>;
|
|
321
509
|
skipCodegen?: boolean;
|
|
322
510
|
spawner?: Spawner;
|
|
323
511
|
/**
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
512
|
+
* Fail the deploy when codegen reports an ERROR-level advisory. Same
|
|
513
|
+
* option `lunora codegen` exposes as `--no-strict-advisories`; defaults to
|
|
514
|
+
* CI detection (on in CI, off locally) so a legitimately-partial target
|
|
515
|
+
* can still be shipped interactively. Does NOT gate platform diagnostics
|
|
516
|
+
* (`platform_unsupported_feature` / `platform_unknown_target`), which
|
|
517
|
+
* always block — those mean the emitted `ctx.*` surface does not match
|
|
518
|
+
* what the target can serve, not merely a style nit.
|
|
519
|
+
*/
|
|
520
|
+
strictAdvisories?: boolean;
|
|
521
|
+
/**
|
|
522
|
+
* Deploy target. Falls back to `"target"` in `lunora.json`, then
|
|
523
|
+
* `"cloudflare"`, which selects the wrangler
|
|
524
|
+
* toolchain — i.e. today's behavior for every project. An unregistered name
|
|
525
|
+
* throws rather than falling back, so a typo can never ship the app to the
|
|
526
|
+
* wrong provider.
|
|
527
|
+
*/
|
|
528
|
+
target?: string;
|
|
529
|
+
/**
|
|
530
|
+
* Deploy to a temporary Cloudflare account (`wrangler deploy --temporary`).
|
|
531
|
+
* For unauthenticated use only: wrangler provisions a short-lived account +
|
|
532
|
+
* token, deploys, and prints a claim URL; the deployment stays live ~60
|
|
533
|
+
* minutes before the unclaimed account is deleted. Wrangler itself errors
|
|
534
|
+
* if credentials are already present (OAuth / `CLOUDFLARE_API_TOKEN` /
|
|
535
|
+
* global API key), so we pass the flag straight through without guarding.
|
|
536
|
+
*/
|
|
331
537
|
temporary?: boolean;
|
|
332
538
|
/** Re-bless the committed schema baseline with the current shape (accepts breaking drift). */
|
|
333
539
|
updateSchemaBaseline?: boolean;
|
|
334
540
|
}
|
|
541
|
+
/**
|
|
542
|
+
* What this run put where — the identity of the thing that was just deployed.
|
|
543
|
+
*
|
|
544
|
+
* Present on every run that reached (and completed) the wrangler invocation,
|
|
545
|
+
* including `--dry-run` and `--preview`, so a consumer can tell "nothing went
|
|
546
|
+
* live" from "went live" without inferring it from a missing `url`. A dry run
|
|
547
|
+
* publishes nothing and therefore never carries a `url`.
|
|
548
|
+
*
|
|
549
|
+
* No `versionId`: the pinned wrangler (4.114.0) has no structured deploy output
|
|
550
|
+
* and no flag that returns the version id — it only prints it in prose, and
|
|
551
|
+
* scraping a second value out of prose is exactly what this shouldn't do. The
|
|
552
|
+
* id is available from `lunora deployments list` after the fact.
|
|
553
|
+
*/
|
|
554
|
+
interface DeployedIdentity {
|
|
555
|
+
/** ISO-8601 stamp taken when the wrangler invocation returned. */
|
|
556
|
+
deployedAt: string;
|
|
557
|
+
/** True when `--dry-run` validated + bundled without publishing. */
|
|
558
|
+
dryRun: boolean;
|
|
559
|
+
/** The Cloudflare environment this run targeted, when `--env` named one. */
|
|
560
|
+
env?: string;
|
|
561
|
+
/** True when `--preview` uploaded a version instead of shifting live traffic. */
|
|
562
|
+
preview: boolean;
|
|
563
|
+
/** The URL wrangler reported publishing to; absent on a dry run, or when the output carried no URL. */
|
|
564
|
+
url?: string;
|
|
565
|
+
/** The Worker name from the project's wrangler config. */
|
|
566
|
+
workerName?: string;
|
|
567
|
+
}
|
|
335
568
|
interface DeployCommandResult {
|
|
336
569
|
code: number;
|
|
570
|
+
/** What was deployed and where — set once the wrangler invocation completed. */
|
|
571
|
+
deployment?: DeployedIdentity;
|
|
337
572
|
descriptor: SpawnDescriptor | undefined;
|
|
338
573
|
/** Set when the run aborted before reaching the wrangler invocation. */
|
|
339
574
|
error?: string;
|
|
575
|
+
/**
|
|
576
|
+
* The `--health-check` probe's verdict, when the flag was set and the probe
|
|
577
|
+
* ran. A red probe fails the command (`code` is non-zero) — but the deploy
|
|
578
|
+
* itself still succeeded, which is why the reason is reported separately
|
|
579
|
+
* from `error`.
|
|
580
|
+
*/
|
|
581
|
+
healthCheck?: {
|
|
582
|
+
error?: string;
|
|
583
|
+
ok: boolean;
|
|
584
|
+
url: string;
|
|
585
|
+
};
|
|
586
|
+
/**
|
|
587
|
+
* The `.dev.vars`-shaped filename (never a full path, never a value) a
|
|
588
|
+
* secret minted during this run was recorded into, when the missing-
|
|
589
|
+
* secret gate minted one — `.dev.vars` for the default environment, or a
|
|
590
|
+
* `.dev.vars.<env>` sibling for an explicit `--env`. `undefined` when
|
|
591
|
+
* nothing was minted this run.
|
|
592
|
+
*/
|
|
593
|
+
mintedSecretsFile?: string;
|
|
340
594
|
/** The schema-drift gate verdict, when it ran (skipped on `--skip-codegen`). */
|
|
341
595
|
schemaDrift?: {
|
|
342
596
|
blocked: boolean;
|
|
@@ -348,18 +602,17 @@ interface DeployCommandResult {
|
|
|
348
602
|
};
|
|
349
603
|
}
|
|
350
604
|
/**
|
|
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
|
-
*/
|
|
605
|
+
* Run a deploy, then (in `--format json` mode) serialize the structured
|
|
606
|
+
* {@link DeployCommandResult} to stdout. Human/progress logging is routed to
|
|
607
|
+
* stderr for json output so stdout carries only the single JSON document.
|
|
608
|
+
*/
|
|
355
609
|
declare const runDeployCommand: (options: DeployCommandOptions) => Promise<DeployCommandResult>;
|
|
356
|
-
/** `lunora deploy` handler (lazy-loaded via the command's `loader`). */
|
|
357
610
|
/**
|
|
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
|
-
*/
|
|
611
|
+
* Start the codegen watch loop and return a handle to stop it. Regenerates on
|
|
612
|
+
* startup, then on debounced changes under `lunora/` (ignoring writes to the
|
|
613
|
+
* `_generated/` output to avoid a feedback loop). If the platform can't do a
|
|
614
|
+
* recursive watch, it logs once and falls back to startup-only codegen.
|
|
615
|
+
*/
|
|
363
616
|
declare const startCodegenWatch: (options: CodegenWatcherOptions) => CodegenWatcherHandle;
|
|
364
617
|
interface CodegenWatcherOptions {
|
|
365
618
|
/** Which API spec(s) to emit. Defaults to codegen's `"openapi"` when omitted. */
|
|
@@ -371,23 +624,25 @@ interface CodegenWatcherOptions {
|
|
|
371
624
|
lunoraDirectory?: string;
|
|
372
625
|
/** Project root containing the `lunora/` directory. */
|
|
373
626
|
projectRoot: string;
|
|
627
|
+
/** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
|
|
628
|
+
target?: string;
|
|
374
629
|
}
|
|
375
630
|
interface CodegenWatcherHandle {
|
|
376
631
|
/** Stop watching and cancel any pending regeneration. */
|
|
377
632
|
close: () => void;
|
|
378
633
|
/**
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
634
|
+
* `true` when the platform supports recursive watch and the loop is active.
|
|
635
|
+
* `false` when `fs.watch({ recursive })` threw — startup-only codegen was run
|
|
636
|
+
* but schema edits will NOT auto-regenerate. Callers can surface this in the
|
|
637
|
+
* dev banner so the degraded state is visible beyond the single startup warning.
|
|
638
|
+
*/
|
|
384
639
|
watchAvailable: boolean;
|
|
385
640
|
}
|
|
386
641
|
/**
|
|
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
|
-
*/
|
|
642
|
+
* Start the studio server and resolve once it is listening. Loads the static
|
|
643
|
+
* bundle + renders the host HTML once up front; serves them and proxies
|
|
644
|
+
* `/_lunora/*` (HTTP + WS) to the worker.
|
|
645
|
+
*/
|
|
391
646
|
declare const startStudioServer: (options: StudioServerOptions) => Promise<StudioServerHandle>;
|
|
392
647
|
interface StudioServerOptions {
|
|
393
648
|
/** Project root — `.dev.vars` is read from here for the admin token. */
|
|
@@ -409,6 +664,24 @@ interface StudioServerHandle {
|
|
|
409
664
|
/** The URL to open in a browser. */
|
|
410
665
|
url: string;
|
|
411
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* How the dev child runs. `wrangler` is the classic `lunora dev` stack (wrangler
|
|
669
|
+
* worker + embedded studio + codegen watch) for a standalone class-C project.
|
|
670
|
+
* `vite` is a project on `@lunora/vite`: the plugin already runs the worker,
|
|
671
|
+
* studio, and codegen inside the Vite dev server, so `lunora dev` runs the
|
|
672
|
+
* project's own dev script and gets out of the way — this also covers class-B
|
|
673
|
+
* frameworks whose own dev server runs the worker in `workerd` (Astro 6 +
|
|
674
|
+
* `@astrojs/cloudflare`, which embeds `@cloudflare/vite-plugin` in `astro dev`:
|
|
675
|
+
* SSR + `/_lunora/*` + `ShardDO` in one process, HMR intact). `framework-worker`
|
|
676
|
+
* is a class-B framework whose dev server CANNOT host the `ShardDO` Durable
|
|
677
|
+
* Object (SvelteKit / Nuxt: their adapters use wrangler's `getPlatformProxy()`,
|
|
678
|
+
* which runs an empty-script Miniflare and does not emulate internal DOs); there
|
|
679
|
+
* `lunora dev` runs the framework's own dev server (front door, HMR, and — via
|
|
680
|
+
* its `@lunora/vite` plugin — studio + codegen) AND a second `wrangler dev`
|
|
681
|
+
* sidecar that owns the real `ShardDO` in `workerd`, wired via the committed
|
|
682
|
+
* `wrangler.dev.jsonc`.
|
|
683
|
+
*/
|
|
684
|
+
type DevFlavor = "framework-worker" | "vite" | "wrangler";
|
|
412
685
|
/** A running worker child the orchestrator controls: send signals, await its exit. */
|
|
413
686
|
interface WorkerProcess {
|
|
414
687
|
/** Resolves with the worker's exit code (1 if it failed to start). */
|
|
@@ -429,6 +702,14 @@ interface DevCommandOptions {
|
|
|
429
702
|
ensureEnv?: typeof ensureDevVariables;
|
|
430
703
|
/** Injection seam for tests — defaults to the real `.dev.vars.example` package-aware scaffolder. */
|
|
431
704
|
ensureExample?: typeof ensureDevVarsExample;
|
|
705
|
+
/** Injection seam for tests — defaults to the real empty-secret/admin-token filler. */
|
|
706
|
+
fillSecrets?: typeof fillDevSecrets;
|
|
707
|
+
/** Injection seam for tests — defaults to the real free-port probe ({@link findAvailablePort}). */
|
|
708
|
+
findFreePort?: (preferred: number) => Promise<number>;
|
|
709
|
+
/** Dev flavor override (tests / callers that already detected it) — defaults to {@link detectDevFlavor}. */
|
|
710
|
+
flavor?: DevFlavor;
|
|
711
|
+
/** Injection seam for tests — defaults to the real IPv6-loopback probe ({@link hasIpv6Loopback}). */
|
|
712
|
+
hasIpv6Loopback?: () => boolean;
|
|
432
713
|
logger: Logger;
|
|
433
714
|
/** Injection seam for tests — defaults to the real remote-config materializer. */
|
|
434
715
|
materializeRemote?: typeof materializeRemoteWranglerConfig;
|
|
@@ -444,6 +725,10 @@ interface DevCommandOptions {
|
|
|
444
725
|
startWorker?: WorkerSpawner;
|
|
445
726
|
/** Disable the embedded studio server. */
|
|
446
727
|
studio?: boolean;
|
|
728
|
+
/** Deploy target the emitted `ctx.*` surface is tailored to. Resolved by the caller; falls back to `"target"` in `lunora.json`, then `"cloudflare"`. */
|
|
729
|
+
target?: string;
|
|
730
|
+
/** Disable the `wrangler dev` spawn — an external task runner owns the worker. */
|
|
731
|
+
worker?: boolean;
|
|
447
732
|
/** `wrangler dev` port. */
|
|
448
733
|
workerPort?: number;
|
|
449
734
|
}
|
|
@@ -451,10 +736,10 @@ interface DevRemotePlan {
|
|
|
451
736
|
/** Short binding labels remoted (e.g. `"DB (D1)"`), for the banner. */
|
|
452
737
|
bindings: string[];
|
|
453
738
|
/**
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
739
|
+
* Removes the generated temp wrangler config when dev exits. Always present
|
|
740
|
+
* and idempotent — a no-op when remote mode is off or nothing was
|
|
741
|
+
* materialized. The dev loop calls it on every shutdown path.
|
|
742
|
+
*/
|
|
458
743
|
cleanup: () => void;
|
|
459
744
|
/** Whether remote mode was requested. */
|
|
460
745
|
enabled: boolean;
|
|
@@ -463,57 +748,83 @@ interface DevRemotePlan {
|
|
|
463
748
|
}
|
|
464
749
|
interface DevCommandPlan {
|
|
465
750
|
codegenEnabled: boolean;
|
|
751
|
+
/** Which stack the child runs — see {@link DevFlavor}. */
|
|
752
|
+
flavor: DevFlavor;
|
|
753
|
+
/**
|
|
754
|
+
* One-line redirect hint printed when a meta-framework is detected on the
|
|
755
|
+
* wrangler flavor: without `@lunora/vite` in the dependencies the worker
|
|
756
|
+
* still runs *inside* the framework's dev server, so the user should run
|
|
757
|
+
* their framework dev script for the full app. `undefined` for the vite
|
|
758
|
+
* flavor (`lunora dev` already runs the project's dev script there) and
|
|
759
|
+
* for a standalone project. Purely informational: the wrangler spawn runs
|
|
760
|
+
* regardless.
|
|
761
|
+
*/
|
|
762
|
+
frameworkHint?: string;
|
|
763
|
+
/**
|
|
764
|
+
* True when `wrangler dev` was given `--ip 127.0.0.1` because the host has no
|
|
765
|
+
* IPv6 loopback (`::1`) — surfaced so the dev loop can note the rebind.
|
|
766
|
+
* Always `false` for the vite flavor (the plugin owns its own bind).
|
|
767
|
+
*/
|
|
768
|
+
ipv4LoopbackForced: boolean;
|
|
466
769
|
/** The remote-binding decision: which D1/KV/R2 bindings hit the deployed worker. */
|
|
467
770
|
remote: DevRemotePlan;
|
|
771
|
+
/**
|
|
772
|
+
* The `wrangler dev` sidecar for the `framework-worker` flavor (SvelteKit /
|
|
773
|
+
* Nuxt): a second child that owns the real `ShardDO` in `workerd`, wired via
|
|
774
|
+
* the committed `wrangler.dev.jsonc`. `undefined` for every other flavor —
|
|
775
|
+
* only the two-process class-B stack has a sidecar. When present, `wrangler`
|
|
776
|
+
* (above) is the framework's own dev server (the front door / HMR) and this
|
|
777
|
+
* is the Lunora realtime plane.
|
|
778
|
+
*/
|
|
779
|
+
sidecar?: SpawnDescriptor & {
|
|
780
|
+
tag: string;
|
|
781
|
+
};
|
|
468
782
|
studioEnabled: boolean;
|
|
469
783
|
studioPort: number;
|
|
784
|
+
/**
|
|
785
|
+
* Whether this process spawns `wrangler dev`.
|
|
786
|
+
*
|
|
787
|
+
* `--no-worker` turns it off so an external task runner (Turbo, Nx, vis, a
|
|
788
|
+
* Procfile) can own worker supervision while `lunora dev` still provides
|
|
789
|
+
* codegen-watch and Studio. Without it, `lunora dev` insisted on being the
|
|
790
|
+
* process root, which is what blocked running the Lunora worker as one node
|
|
791
|
+
* in a larger dev graph.
|
|
792
|
+
*/
|
|
793
|
+
workerEnabled: boolean;
|
|
470
794
|
workerOrigin: string;
|
|
471
795
|
workerPort: number;
|
|
472
|
-
/** The
|
|
796
|
+
/** The primary child `lunora dev` spawns: `wrangler dev` (wrangler flavor) or the framework/`vite dev` server (vite / framework-worker). */
|
|
473
797
|
wrangler: SpawnDescriptor & {
|
|
474
798
|
tag: string;
|
|
475
799
|
};
|
|
476
800
|
}
|
|
477
801
|
/**
|
|
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
|
-
*/
|
|
802
|
+
* Plan `lunora dev`. Wrangler flavor: the worker runs via `wrangler dev` and
|
|
803
|
+
* nothing else as a child process. Vite flavor (`@lunora/vite` declared): the
|
|
804
|
+
* plugin already runs the worker inside the Vite dev server, so the one child
|
|
805
|
+
* is the project's own dev script (`vite dev`, `astro dev`, …) and every CLI
|
|
806
|
+
* sibling is disabled. Pure + synchronous so it's unit-testable.
|
|
807
|
+
*/
|
|
491
808
|
declare const planDevCommand: (options: DevCommandOptions) => DevCommandPlan;
|
|
492
809
|
/**
|
|
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
|
-
*/
|
|
810
|
+
* Start codegen watch + the studio server, spawn `wrangler dev`, print the
|
|
811
|
+
* banner, and resolve when the worker exits or the user interrupts — tearing
|
|
812
|
+
* down the sibling servers either way. The three side-effecting pieces (worker,
|
|
813
|
+
* studio, codegen) are injectable so this is testable without real I/O.
|
|
814
|
+
*/
|
|
498
815
|
declare const runDevCommand: (options: DevCommandOptions) => Promise<{
|
|
499
816
|
code: number;
|
|
500
817
|
plan: DevCommandPlan;
|
|
501
818
|
}>;
|
|
502
|
-
/** `lunora dev` handler (lazy-loaded via the command's `loader`). */
|
|
503
|
-
/** Supported CI providers. */
|
|
504
|
-
type CiProvider = "github" | "gitlab";
|
|
505
819
|
type PackageManager = "pnpm" | "npm" | "yarn" | "bun";
|
|
506
|
-
/** True when `manager` is on PATH — probed by running
|
|
820
|
+
/** True when `manager` is on PATH — probed by running `<manager> --version`. Injectable for tests. */
|
|
507
821
|
type PackageManagerProbe = (manager: PackageManager) => boolean;
|
|
508
|
-
/**
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
* picks from. Empty when none are found.
|
|
513
|
-
*/
|
|
822
|
+
/** Supported CI providers. */
|
|
823
|
+
type CiProvider = "github" | "gitlab";
|
|
824
|
+
/** The per-framework auth-UI registry items (`auth-ui` resolves to one of these). */
|
|
825
|
+
type AuthUiItem = "auth-ui-angular" | "auth-ui-react" | "auth-ui-solid" | "auth-ui-svelte" | "auth-ui-vue";
|
|
514
826
|
/** 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. */
|
|
827
|
+
type FeatureItem = "auth" | "auth-auth0" | "auth-clerk" | AuthUiItem | "mail";
|
|
517
828
|
/** A single file the item scaffolds into the project. */
|
|
518
829
|
interface RegistryFile {
|
|
519
830
|
/** Source path inside the item dir (e.g. `schema.ts`). */
|
|
@@ -529,10 +840,10 @@ interface RegistryBinding {
|
|
|
529
840
|
value: unknown;
|
|
530
841
|
}
|
|
531
842
|
/**
|
|
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
|
-
*/
|
|
843
|
+
* An environment variable an item needs. Scaffolded into `.dev.vars` (Workers'
|
|
844
|
+
* local-secrets file) on add — non-secrets get their `value`; secrets get an
|
|
845
|
+
* empty placeholder and a reminder to run `wrangler secret put` for production.
|
|
846
|
+
*/
|
|
536
847
|
interface RegistryEnvVariable {
|
|
537
848
|
/** Human note on what the variable is for. */
|
|
538
849
|
description?: string;
|
|
@@ -543,6 +854,13 @@ interface RegistryEnvVariable {
|
|
|
543
854
|
/** A default/example value for non-secret vars. */
|
|
544
855
|
value?: string;
|
|
545
856
|
}
|
|
857
|
+
/** A re-export the item needs injected into the worker entry point (class-B/C only). */
|
|
858
|
+
interface EntrypointReexport {
|
|
859
|
+
/** Optional JS comment placed above the re-export line. */
|
|
860
|
+
comment?: string;
|
|
861
|
+
/** Module specifier (e.g. `"_generated/workflows"` → `export * from "./lunora/_generated/workflows"`). */
|
|
862
|
+
module: string;
|
|
863
|
+
}
|
|
546
864
|
/** The `registry.json` manifest shape. */
|
|
547
865
|
interface RegistryManifest {
|
|
548
866
|
/** wrangler.jsonc additions (best-effort structural edits). */
|
|
@@ -554,6 +872,8 @@ interface RegistryManifest {
|
|
|
554
872
|
devDependencies?: Readonly<Record<string, string>>;
|
|
555
873
|
/** Post-install guidance printed after the item is added (per-item next steps). */
|
|
556
874
|
docs?: string;
|
|
875
|
+
/** Worker-entry re-exports the item needs (class-B/C only). */
|
|
876
|
+
entrypointReexports?: ReadonlyArray<EntrypointReexport>;
|
|
557
877
|
/** Environment variables the item needs; scaffolded into `.dev.vars`. */
|
|
558
878
|
envVars?: ReadonlyArray<RegistryEnvVariable>;
|
|
559
879
|
files: ReadonlyArray<RegistryFile>;
|
|
@@ -593,11 +913,11 @@ interface AddCommandOptions {
|
|
|
593
913
|
/** Override the remote registry source base (default gh:anolilab/lunora/registry). */
|
|
594
914
|
source?: string;
|
|
595
915
|
/**
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
916
|
+
* Customize each resolved manifest after it is loaded but before the plan is
|
|
917
|
+
* printed / reconciled — used to inject user-chosen values into otherwise
|
|
918
|
+
* static manifests (e.g. the R2 `bucket_name` the init storage prompt asks
|
|
919
|
+
* for). Applied to every item; return the manifest unchanged to leave it as-is.
|
|
920
|
+
*/
|
|
601
921
|
transformManifest?: (manifest: RegistryManifest) => RegistryManifest;
|
|
602
922
|
/** Skip the package.json mutation confirmation prompt. */
|
|
603
923
|
yes?: boolean;
|
|
@@ -613,21 +933,20 @@ interface AddCommandResult {
|
|
|
613
933
|
/** Files written (absolute paths). */
|
|
614
934
|
written: ReadonlyArray<string>;
|
|
615
935
|
}
|
|
616
|
-
/** One resolved item: its parsed manifest plus the (possibly staged) directory it lives in. */
|
|
617
936
|
/**
|
|
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" | "
|
|
937
|
+
* A feature offered in the post-scaffold multi-select. `auth`/`email` carry a
|
|
938
|
+
* sub-prompt or alias; every other value IS the registry item name applied
|
|
939
|
+
* directly (`storage` → the `storage` registry item, etc.).
|
|
940
|
+
*/
|
|
941
|
+
type StackFeature = "ai" | "auth" | "auth-ui" | "backup" | "browser" | "cloudflare-access" | "crons" | "email" | "flags" | "hyperdrive" | "payment" | "presence" | "queue" | "storage" | "workflow";
|
|
623
942
|
/** Customize a resolved manifest before it is written (e.g. inject the chosen R2 bucket name). */
|
|
624
943
|
type OfferTransformManifest = (manifest: RegistryManifest) => RegistryManifest;
|
|
625
944
|
/**
|
|
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
|
-
*/
|
|
945
|
+
* One feature ready to apply: the registry item name(s), an optional manifest
|
|
946
|
+
* transform, and a short `label` (the feature value) shown on the combined
|
|
947
|
+
* progress line. Built up-front by the collectors so every prompt is answered
|
|
948
|
+
* before any apply runs.
|
|
949
|
+
*/
|
|
631
950
|
interface FeatureApply {
|
|
632
951
|
label: string;
|
|
633
952
|
names: ReadonlyArray<string>;
|
|
@@ -635,11 +954,11 @@ interface FeatureApply {
|
|
|
635
954
|
}
|
|
636
955
|
interface OfferDeps {
|
|
637
956
|
/**
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
957
|
+
* Apply the collected features into the new project in one batch — resolves
|
|
958
|
+
* `true` when every item succeeds. The CLI renders this as a single progress
|
|
959
|
+
* line whose label changes per feature; each plan's `transformManifest`
|
|
960
|
+
* customizes that item's manifest before it is written.
|
|
961
|
+
*/
|
|
643
962
|
applyAll: (plans: ReadonlyArray<FeatureApply>) => Promise<boolean>;
|
|
644
963
|
/** When `false`, skip all prompts and print the later-setup hint. */
|
|
645
964
|
interactive: boolean;
|
|
@@ -653,13 +972,19 @@ interface OfferDeps {
|
|
|
653
972
|
defaults?: ReadonlyArray<StackFeature>;
|
|
654
973
|
}) => Promise<StackFeature[]>;
|
|
655
974
|
/**
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
975
|
+
* Features chosen non-interactively (the `--add` flag). When set, the
|
|
976
|
+
* multi-select and every sub-prompt are skipped — each feature is applied with
|
|
977
|
+
* its shipped defaults (base registry item, placeholder bindings).
|
|
978
|
+
*/
|
|
660
979
|
preselected?: ReadonlyArray<StackFeature>;
|
|
661
980
|
/** The new project's name — seeds smart defaults like the `project-uploads` bucket name. */
|
|
662
981
|
projectName: string;
|
|
982
|
+
/**
|
|
983
|
+
* Resolve which per-framework auth-UI item (`auth-ui-react|vue|…`) fits the
|
|
984
|
+
* scaffolded project. Injected by the CLI (detected from the template's deps);
|
|
985
|
+
* defaults to `auth-ui-react` when absent so this module stays pure/testable.
|
|
986
|
+
*/
|
|
987
|
+
resolveAuthUiItem?: () => string;
|
|
663
988
|
/** Single-select among the auth providers (TTY-backed in production). */
|
|
664
989
|
select: (message: string, options: ReadonlyArray<{
|
|
665
990
|
description?: string;
|
|
@@ -674,114 +999,127 @@ interface OfferDeps {
|
|
|
674
999
|
placeholder?: string;
|
|
675
1000
|
}) => Promise<string>;
|
|
676
1001
|
}
|
|
677
|
-
/**
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
1002
|
+
/** One choice in the multi-select. */
|
|
1003
|
+
interface LintToolOption {
|
|
1004
|
+
description: string;
|
|
1005
|
+
label: string;
|
|
1006
|
+
value: LintTool;
|
|
1007
|
+
}
|
|
1008
|
+
interface LintToolOfferDeps {
|
|
1009
|
+
/** Write the ignores for the chosen tools — `applyLintIgnores` in production. */
|
|
1010
|
+
apply: (tools: ReadonlyArray<LintTool>) => LintIgnoreOutcome[];
|
|
1011
|
+
/** Tools already detectable in the scaffolded project — pre-selected in the prompt. */
|
|
1012
|
+
detected: ReadonlyArray<LintTool>;
|
|
1013
|
+
/** False in CI / `--yes` / off a TTY: skip the prompt and configure whatever was detected. */
|
|
1014
|
+
interactive: boolean;
|
|
1015
|
+
logger: Logger;
|
|
1016
|
+
multiSelect: (message: string, choices: ReadonlyArray<LintToolOption>, settings?: {
|
|
1017
|
+
defaults?: ReadonlyArray<LintTool>;
|
|
1018
|
+
}) => Promise<LintTool[]>;
|
|
1019
|
+
}
|
|
1020
|
+
type Template = "analog" | "astro" | "expo" | "next" | "nuxt" | "react-router" | "standalone" | "sveltekit" | "tanstack-start-react" | "tanstack-start-solid";
|
|
689
1021
|
interface InitCommandOptions {
|
|
690
1022
|
/**
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
1023
|
+
* Add features non-interactively after scaffolding (the `--add` flag): a
|
|
1024
|
+
* comma-separated list of `ai | auth | backup | browser | cloudflare-access | crons | email | flags | hyperdrive | payment | presence | queue | storage | workflow`.
|
|
1025
|
+
* Bypasses the interactive multi-select and sub-prompts —
|
|
1026
|
+
* each named feature is applied with its shipped defaults.
|
|
1027
|
+
*/
|
|
696
1028
|
add?: string;
|
|
697
1029
|
/**
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
1030
|
+
* When true, accept `--source` values that don't start with `gh:` /
|
|
1031
|
+
* `github:` / `https://` or that contain `..`. Defaults to false; the CLI
|
|
1032
|
+
* gate exists to stop arbitrary filesystem / scheme sources from being
|
|
1033
|
+
* pulled without the caller opting in.
|
|
1034
|
+
*/
|
|
703
1035
|
allowUnsafeSource?: boolean;
|
|
704
1036
|
/** When set, also scaffold a CI deploy pipeline for the given provider. */
|
|
705
1037
|
ci?: CiProvider;
|
|
706
1038
|
cwd?: string;
|
|
707
1039
|
/**
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
1040
|
+
* Walk the whole flow — prompts, task list, next-steps, mascot — but make no
|
|
1041
|
+
* changes: skip the template fetch/copy, the feature applies, the dependency
|
|
1042
|
+
* install, and `git init`. Each skipped action logs a `would …` line instead.
|
|
1043
|
+
*/
|
|
712
1044
|
dryRun?: boolean;
|
|
713
1045
|
/**
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
1046
|
+
* Local directory containing the template subdirs (e.g. `vite/`,
|
|
1047
|
+
* `standalone/`). When provided, skips the network fetch entirely.
|
|
1048
|
+
* Useful for offline runs, the clean-machine smoke test, and unit tests.
|
|
1049
|
+
*/
|
|
718
1050
|
from?: string;
|
|
719
1051
|
/**
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
1052
|
+
* When true, configure Lunora into the CURRENT project (`cwd`) instead of
|
|
1053
|
+
* scaffolding a new directory. Finds an existing `vite.config.*` and
|
|
1054
|
+
* patches it via `patchViteConfig`, or creates a minimal one when absent.
|
|
1055
|
+
* All other scaffold options (`name`, `templateType`, `source`, `from`)
|
|
1056
|
+
* are ignored in this mode.
|
|
1057
|
+
*/
|
|
726
1058
|
inPlace?: boolean;
|
|
727
1059
|
/**
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
1060
|
+
* Inject the post-scaffold install offer's prompts (tests). When set, the
|
|
1061
|
+
* offer runs regardless of TTY: `confirmInstall` drives the yes/no, and
|
|
1062
|
+
* `selectManager` picks among the detected managers.
|
|
1063
|
+
*/
|
|
732
1064
|
installPrompt?: {
|
|
733
1065
|
confirmInstall: () => Promise<boolean>;
|
|
734
1066
|
selectManager: (managers: ReadonlyArray<PackageManager>) => Promise<PackageManager>;
|
|
735
1067
|
};
|
|
736
1068
|
/**
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
1069
|
+
* Force the post-scaffold "add auth / email?" offer on (the `--interactive`
|
|
1070
|
+
* flag). When omitted, the offer runs only when stdin is a TTY. `--yes`
|
|
1071
|
+
* suppresses it regardless. Has no effect once {@link prompt} is injected.
|
|
1072
|
+
*/
|
|
741
1073
|
interactive?: boolean;
|
|
1074
|
+
/**
|
|
1075
|
+
* Test seam for the lint/formatter multi-select. Separate from {@link prompt}
|
|
1076
|
+
* because that one is pinned to the feature-offer's value union — reusing it
|
|
1077
|
+
* here would only typecheck through a cast.
|
|
1078
|
+
*/
|
|
1079
|
+
lintPrompt?: LintToolOfferDeps["multiSelect"];
|
|
742
1080
|
logger: Logger;
|
|
743
1081
|
name?: string;
|
|
744
1082
|
/**
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
1083
|
+
* Local directory holding create-vite bases (one `template-<id>/` subdir per
|
|
1084
|
+
* framework). When set with `vite`, the overlay copies the base from disk
|
|
1085
|
+
* instead of fetching `create-vite` over the network — offline mode + tests.
|
|
1086
|
+
*/
|
|
749
1087
|
overlayBaseFrom?: string;
|
|
750
|
-
/** Probe for which package managers are installed (tests). Defaults to a real
|
|
1088
|
+
/** Probe for which package managers are installed (tests). Defaults to a real `<pm> --version` check. */
|
|
751
1089
|
packageManagerProbe?: PackageManagerProbe;
|
|
752
1090
|
/**
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
1091
|
+
* Inject the offer's prompts (tests). When set, the offer is treated as
|
|
1092
|
+
* interactive regardless of TTY, and these drive the feature multi-select,
|
|
1093
|
+
* the auth-provider sub-select, and the storage bucket-name text input.
|
|
1094
|
+
*/
|
|
757
1095
|
prompt?: Pick<OfferDeps, "multiSelect" | "select" | "text">;
|
|
758
1096
|
/**
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
1097
|
+
* Override the git ref (branch, tag, or commit) the default template source
|
|
1098
|
+
* is fetched from. Takes precedence over the version-derived ref. Ignored
|
|
1099
|
+
* when `source` or `from` is set.
|
|
1100
|
+
*/
|
|
763
1101
|
ref?: string;
|
|
764
1102
|
/** Local registry root for the offer's `runAddCommand` (offline / tests). Mirrors `from` but for registry items. */
|
|
765
1103
|
registryFrom?: string;
|
|
766
1104
|
/** Override the remote registry source base for the offer (default `gh:anolilab/lunora/registry`). */
|
|
767
1105
|
registrySource?: string;
|
|
768
1106
|
/**
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
1107
|
+
* Override the remote source giget downloads from. Default:
|
|
1108
|
+
* `gh:anolilab/lunora/templates/<templateType>#<ref>`, where `<ref>` is
|
|
1109
|
+
* the `ref` option when set, else derived from the CLI version (pre-release
|
|
1110
|
+
* channels → their branch, stable → `main`). Tests typically use `from`
|
|
1111
|
+
* instead to skip the network.
|
|
1112
|
+
*/
|
|
775
1113
|
source?: string;
|
|
776
1114
|
/** Spawner for the post-scaffold dependency install (tests inject a recording stub). Defaults to a real subprocess. */
|
|
777
1115
|
spawner?: Spawner;
|
|
778
1116
|
templateType?: Template;
|
|
779
1117
|
/**
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
1118
|
+
* Scaffold via the **create-vite overlay** for this framework (`react`,
|
|
1119
|
+
* `vue`, `solid`, `svelte`, `vanilla`) instead of a bespoke template: fetch
|
|
1120
|
+
* the official create-vite base and apply the Lunora layer on top. Takes
|
|
1121
|
+
* precedence over `templateType`.
|
|
1122
|
+
*/
|
|
785
1123
|
vite?: string;
|
|
786
1124
|
/** Suppress the offer entirely (the `--yes` flag): scaffold only, print the later-setup hint. */
|
|
787
1125
|
yes?: boolean;
|
|
@@ -791,8 +1129,12 @@ interface InitCommandResult {
|
|
|
791
1129
|
files: ReadonlyArray<string>;
|
|
792
1130
|
target: string;
|
|
793
1131
|
}
|
|
1132
|
+
/**
|
|
1133
|
+
* `lunora init` entry: scaffold (in-place or a new directory), then — on success
|
|
1134
|
+
* — offer to add auth + email via the registry. The offer never affects the
|
|
1135
|
+
* scaffold's exit code.
|
|
1136
|
+
*/
|
|
794
1137
|
declare const runInitCommand: (options: InitCommandOptions) => Promise<InitCommandResult>;
|
|
795
|
-
/** Narrow a raw `--template` value to a known {@link Template}. */
|
|
796
1138
|
interface MigrateGenerateCommandOptions {
|
|
797
1139
|
cwd?: string;
|
|
798
1140
|
logger: Logger;
|
|
@@ -818,29 +1160,27 @@ interface CatalogItem {
|
|
|
818
1160
|
interface IndexItem extends CatalogItem {
|
|
819
1161
|
title?: string;
|
|
820
1162
|
}
|
|
821
|
-
/** Names of the subdirectories under `root` that ship a `registry.json`. */
|
|
822
|
-
|
|
823
1163
|
/**
|
|
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
|
-
*/
|
|
1164
|
+
* Build the catalog (`index.json` contents) from a local registry root by
|
|
1165
|
+
* reading every item's `registry.json`. Used by both `lunora registry build`
|
|
1166
|
+
* and the registry tests so the committed index can't drift from the item dirs.
|
|
1167
|
+
*/
|
|
828
1168
|
declare const buildRegistryIndex: (root: string) => {
|
|
829
1169
|
items: IndexItem[];
|
|
830
1170
|
};
|
|
831
1171
|
/** `lunora registry add` (one or more item names): scaffold items into the project. */
|
|
832
1172
|
declare const runAddCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
833
1173
|
/**
|
|
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
|
-
*/
|
|
1174
|
+
* `lunora registry view` — inspect a registry item without installing it:
|
|
1175
|
+
* print its plan (files / deps / env vars) followed by the full contents of each
|
|
1176
|
+
* file it would scaffold. Resolves only the named item — no `requires` expansion.
|
|
1177
|
+
*/
|
|
838
1178
|
declare const runRegistryViewCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
839
1179
|
/**
|
|
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
|
-
*/
|
|
1180
|
+
* `lunora registry build` — regenerate `index.json` from the item directories
|
|
1181
|
+
* (the catalog `list` reads). With `--check`, verify the committed index matches
|
|
1182
|
+
* instead of rewriting it (exits non-zero on drift) — a CI guard.
|
|
1183
|
+
*/
|
|
844
1184
|
declare const runBuildIndexCommand: (options: AddCommandOptions) => Promise<AddCommandResult>;
|
|
845
1185
|
/** Validate + narrow a parsed JSON value into a {@link RegistryManifest}. */
|
|
846
1186
|
declare const parseManifest: (raw: unknown, itemName: string) => RegistryManifest;
|
|
@@ -858,23 +1198,6 @@ interface ResetCommandResult {
|
|
|
858
1198
|
removed: ReadonlyArray<string>;
|
|
859
1199
|
}
|
|
860
1200
|
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
1201
|
type InsertSchemaExtensionResult = {
|
|
879
1202
|
ok: true;
|
|
880
1203
|
text: string;
|
|
@@ -883,12 +1206,12 @@ type InsertSchemaExtensionResult = {
|
|
|
883
1206
|
reason: "already-applied" | "invalid-identifier" | "no-define-schema" | "non-object-argument";
|
|
884
1207
|
};
|
|
885
1208
|
/**
|
|
886
|
-
* Append `.extend(
|
|
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
|
-
*/
|
|
1209
|
+
* Append `.extend(<key>.extension)` and a managed import to an existing
|
|
1210
|
+
* `lunora/schema.ts`. Idempotent: a second call for the same `key` returns
|
|
1211
|
+
* `already-applied` and leaves the text unchanged.
|
|
1212
|
+
* @param source the current `lunora/schema.ts` contents
|
|
1213
|
+
* @param key the registry item key (e.g. `"ratelimit"`)
|
|
1214
|
+
*/
|
|
892
1215
|
declare const insertSchemaExtension: (source: string, key: string) => InsertSchemaExtensionResult;
|
|
893
1216
|
/** Compact snapshot of a single global table — what we persist + diff. */
|
|
894
1217
|
interface TableSnapshot {
|
|
@@ -931,10 +1254,10 @@ interface SchemaDiff {
|
|
|
931
1254
|
unsupported: ReadonlyArray<UnsupportedEntry>;
|
|
932
1255
|
}
|
|
933
1256
|
/**
|
|
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
|
-
*/
|
|
1257
|
+
* Map a Lunora validator kind to a SQLite type affinity — the canonical
|
|
1258
|
+
* `@lunora/d1/dialect` mapping. Re-exported under this name because
|
|
1259
|
+
* `schema-snapshot.ts` builds the persisted snapshot from it.
|
|
1260
|
+
*/
|
|
938
1261
|
declare const validatorKindToSqlType: (kind: string) => ColumnSnapshot["sqlType"];
|
|
939
1262
|
/** Emit `CREATE TABLE` SQL for a new global table. */
|
|
940
1263
|
declare const renderCreateTable: (table: TableSnapshot) => string;
|
|
@@ -943,14 +1266,14 @@ declare const renderAddColumn: (tableName: string, columnName: string, column: C
|
|
|
943
1266
|
declare const renderCreateIndex: (tableName: string, index: IndexSnapshot) => string;
|
|
944
1267
|
declare const renderDropIndex: (tableName: string, indexName: string) => string;
|
|
945
1268
|
/**
|
|
946
|
-
* Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
|
|
947
|
-
*/
|
|
1269
|
+
* Compute a {@link SchemaDiff} from two snapshots. Pure function — no I/O.
|
|
1270
|
+
*/
|
|
948
1271
|
declare const diffSnapshots: (previous: SchemaSnapshot | undefined, next: SchemaSnapshot) => SchemaDiff;
|
|
949
1272
|
/**
|
|
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
|
-
*/
|
|
1273
|
+
* Render a complete migration file body from a diff. Includes a header,
|
|
1274
|
+
* each SQL statement, and (if any) a trailing comment block describing the
|
|
1275
|
+
* manual SQL the user needs to fill in for unsupported deltas.
|
|
1276
|
+
*/
|
|
954
1277
|
declare const renderMigrationFile: (name: string, diff: SchemaDiff, generatedAt: string) => string;
|
|
955
1278
|
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,
|
|
1279
|
+
export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DeployedIdentity, 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 };
|