@lunora/cli 1.0.0-alpha.150 → 1.0.0-alpha.152
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/dist/bin.mjs +1 -1
- package/dist/index.d.mts +75 -1
- package/dist/index.d.ts +75 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/handler10.mjs +1 -1
- package/dist/packem_chunks/handler11.mjs +2 -1
- package/dist/packem_chunks/handler12.mjs +2 -2
- package/dist/packem_chunks/handler13.mjs +1 -2
- package/dist/packem_chunks/handler14.mjs +1 -1
- package/dist/packem_chunks/handler15.mjs +1 -1
- package/dist/packem_chunks/handler16.mjs +1 -1
- package/dist/packem_chunks/handler17.mjs +3 -1
- package/dist/packem_chunks/handler18.mjs +1 -3
- package/dist/packem_chunks/handler19.mjs +1 -1
- package/dist/packem_chunks/handler20.mjs +7 -1
- package/dist/packem_chunks/handler21.mjs +2 -7
- package/dist/packem_chunks/handler25.mjs +1 -1
- package/dist/packem_chunks/handler4.mjs +1 -2
- package/dist/packem_chunks/handler5.mjs +1 -1
- package/dist/packem_chunks/handler6.mjs +1 -1
- package/dist/packem_chunks/handler7.mjs +1 -1
- package/dist/packem_chunks/handler8.mjs +3 -1
- package/dist/packem_chunks/handler9.mjs +1 -3
- package/dist/packem_chunks/runDeployCommand.mjs +1 -1
- package/dist/packem_shared/{COMMANDS-DkO6XHZS.mjs → COMMANDS-DMyRipjO.mjs} +1 -1
- package/dist/packem_shared/cli-RVVu3rxm.mjs +3 -0
- package/dist/packem_shared/health-probe-CiFgh1hn.mjs +1 -0
- package/package.json +4 -4
- package/dist/packem_shared/cli-DYGVS96x.mjs +0 -3
package/dist/bin.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{f as s}from"./packem_shared/cli-
|
|
2
|
+
import{f as s}from"./packem_shared/cli-RVVu3rxm.mjs";try{const r=await s();process.exit(r)}catch(r){process.stderr.write(`${r instanceof Error?r.message:String(r)}
|
|
3
3
|
`),process.exit(1)}
|
package/dist/index.d.mts
CHANGED
|
@@ -277,6 +277,27 @@ declare const runImportCommand: (options: ImportCommandOptions) => Promise<Impor
|
|
|
277
277
|
* stub; production uses {@link isDockerAvailable}.
|
|
278
278
|
*/
|
|
279
279
|
type DockerProbe = () => boolean;
|
|
280
|
+
/**
|
|
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
|
+
}>;
|
|
280
301
|
interface SpawnDescriptor {
|
|
281
302
|
args: ReadonlyArray<string>;
|
|
282
303
|
/**
|
|
@@ -421,6 +442,19 @@ interface DeployCommandOptions {
|
|
|
421
442
|
fetchImpl?: FetchLike;
|
|
422
443
|
/** Output format: `pretty` (default) or `json`. */
|
|
423
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>;
|
|
424
458
|
/** Set to `false` to disable interactive spinners (test injection). */
|
|
425
459
|
interactive?: boolean;
|
|
426
460
|
logger: Logger;
|
|
@@ -504,11 +538,51 @@ interface DeployCommandOptions {
|
|
|
504
538
|
/** Re-bless the committed schema baseline with the current shape (accepts breaking drift). */
|
|
505
539
|
updateSchemaBaseline?: boolean;
|
|
506
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
|
+
}
|
|
507
568
|
interface DeployCommandResult {
|
|
508
569
|
code: number;
|
|
570
|
+
/** What was deployed and where — set once the wrangler invocation completed. */
|
|
571
|
+
deployment?: DeployedIdentity;
|
|
509
572
|
descriptor: SpawnDescriptor | undefined;
|
|
510
573
|
/** Set when the run aborted before reaching the wrangler invocation. */
|
|
511
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
|
+
};
|
|
512
586
|
/**
|
|
513
587
|
* The `.dev.vars`-shaped filename (never a full path, never a value) a
|
|
514
588
|
* secret minted during this run was recorded into, when the missing-
|
|
@@ -1202,4 +1276,4 @@ declare const diffSnapshots: (previous: SchemaSnapshot | undefined, next: Schema
|
|
|
1202
1276
|
*/
|
|
1203
1277
|
declare const renderMigrationFile: (name: string, diff: SchemaDiff, generatedAt: string) => string;
|
|
1204
1278
|
declare const schemaIrToSnapshot: (ir: SchemaIR) => SchemaSnapshot;
|
|
1205
|
-
export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DevCommandOptions, type DevCommandPlan, type DiffEntry, type ExportCommandOptions, type ExportCommandResult, type FetchLike, type ImportCommandOptions, type ImportCommandResult, type IndexSnapshot, type InitCommandOptions, type InitCommandResult, type InsertSchemaExtensionResult, type Logger, type MigrateGenerateCommandOptions, type MigrateGenerateCommandResult, type RecordedSpawn, type RegistryBinding, type RegistryFile, type RegistryManifest, type ResetCommandOptions, type ResetCommandResult, type RunCliOptions, type RunCommandOptions, type RunCommandResult, type SchemaDiff, type SchemaSnapshot, type SpawnDescriptor, type SpawnResult, type Spawner, type StreamingFetchLike, type TableSnapshot, type Template, type UnsupportedEntry, VERSION, buildRegistryIndex, createLogger, createRecordingSpawner, defaultSpawner, diffSnapshots, insertSchemaExtension, pail, parseManifest, planDevCommand, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, runAddCommand, runBuildIndexCommand, runCli, runCodegenCommand, runDeployCommand, runDevCommand, runExportCommand, runImportCommand, runInitCommand, runMigrateGenerateCommand, runRegistryViewCommand, runResetCommand, runRpcCommand, schemaIrToSnapshot, validatorKindToSqlType };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -277,6 +277,27 @@ declare const runImportCommand: (options: ImportCommandOptions) => Promise<Impor
|
|
|
277
277
|
* stub; production uses {@link isDockerAvailable}.
|
|
278
278
|
*/
|
|
279
279
|
type DockerProbe = () => boolean;
|
|
280
|
+
/**
|
|
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
|
+
}>;
|
|
280
301
|
interface SpawnDescriptor {
|
|
281
302
|
args: ReadonlyArray<string>;
|
|
282
303
|
/**
|
|
@@ -421,6 +442,19 @@ interface DeployCommandOptions {
|
|
|
421
442
|
fetchImpl?: FetchLike;
|
|
422
443
|
/** Output format: `pretty` (default) or `json`. */
|
|
423
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>;
|
|
424
458
|
/** Set to `false` to disable interactive spinners (test injection). */
|
|
425
459
|
interactive?: boolean;
|
|
426
460
|
logger: Logger;
|
|
@@ -504,11 +538,51 @@ interface DeployCommandOptions {
|
|
|
504
538
|
/** Re-bless the committed schema baseline with the current shape (accepts breaking drift). */
|
|
505
539
|
updateSchemaBaseline?: boolean;
|
|
506
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
|
+
}
|
|
507
568
|
interface DeployCommandResult {
|
|
508
569
|
code: number;
|
|
570
|
+
/** What was deployed and where — set once the wrangler invocation completed. */
|
|
571
|
+
deployment?: DeployedIdentity;
|
|
509
572
|
descriptor: SpawnDescriptor | undefined;
|
|
510
573
|
/** Set when the run aborted before reaching the wrangler invocation. */
|
|
511
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
|
+
};
|
|
512
586
|
/**
|
|
513
587
|
* The `.dev.vars`-shaped filename (never a full path, never a value) a
|
|
514
588
|
* secret minted during this run was recorded into, when the missing-
|
|
@@ -1202,4 +1276,4 @@ declare const diffSnapshots: (previous: SchemaSnapshot | undefined, next: Schema
|
|
|
1202
1276
|
*/
|
|
1203
1277
|
declare const renderMigrationFile: (name: string, diff: SchemaDiff, generatedAt: string) => string;
|
|
1204
1278
|
declare const schemaIrToSnapshot: (ir: SchemaIR) => SchemaSnapshot;
|
|
1205
|
-
export { type AddCommandOptions, type AddCommandResult, COMMANDS, type ColumnSnapshot, type CommandName, DEFAULT_IMPORT_BATCH_SIZE, type DeployCommandOptions, type DeployCommandResult, type DevCommandOptions, type DevCommandPlan, type DiffEntry, type ExportCommandOptions, type ExportCommandResult, type FetchLike, type ImportCommandOptions, type ImportCommandResult, type IndexSnapshot, type InitCommandOptions, type InitCommandResult, type InsertSchemaExtensionResult, type Logger, type MigrateGenerateCommandOptions, type MigrateGenerateCommandResult, type RecordedSpawn, type RegistryBinding, type RegistryFile, type RegistryManifest, type ResetCommandOptions, type ResetCommandResult, type RunCliOptions, type RunCommandOptions, type RunCommandResult, type SchemaDiff, type SchemaSnapshot, type SpawnDescriptor, type SpawnResult, type Spawner, type StreamingFetchLike, type TableSnapshot, type Template, type UnsupportedEntry, VERSION, buildRegistryIndex, createLogger, createRecordingSpawner, defaultSpawner, diffSnapshots, insertSchemaExtension, pail, parseManifest, planDevCommand, renderAddColumn, renderCreateIndex, renderCreateTable, renderDropIndex, renderDropTable, renderMigrationFile, runAddCommand, runBuildIndexCommand, runCli, runCodegenCommand, runDeployCommand, runDevCommand, runExportCommand, runImportCommand, runInitCommand, runMigrateGenerateCommand, runRegistryViewCommand, runResetCommand, runRpcCommand, schemaIrToSnapshot, validatorKindToSqlType };
|
|
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as o,i as a,f as n}from"./packem_shared/cli-
|
|
1
|
+
import{d as o,i as a,f as n}from"./packem_shared/cli-RVVu3rxm.mjs";import{runCodegenCommand as t}from"./packem_chunks/runCodegenCommand.mjs";import{runDeployCommand as p}from"./packem_chunks/runDeployCommand.mjs";import{planDevCommand as x,runDevCommand as i}from"./packem_chunks/planDevCommand.mjs";import{runInitCommand as C}from"./packem_chunks/runInitCommand.mjs";import{runMigrateGenerateCommand as u}from"./packem_chunks/runMigrateGenerateCommand.mjs";import{runResetCommand as g}from"./packem_chunks/runResetCommand.mjs";import{runRpcCommand as E}from"./packem_chunks/runRpcCommand.mjs";import{insertSchemaExtension as D}from"./packem_shared/insertSchemaExtension-DZReBZ4_.mjs";import{createLogger as A,pail as c}from"./packem_shared/createLogger-BoSxdb2T.mjs";import{diffSnapshots as v,renderAddColumn as _,renderCreateIndex as h,renderCreateTable as y,renderDropIndex as F,renderDropTable as L,renderMigrationFile as O,validatorKindToSqlType as b}from"./packem_shared/diffSnapshots-BbwCuhoN.mjs";import{default as B}from"./packem_shared/schemaIrToSnapshot-Dahp39qH.mjs";import{createRecordingSpawner as U,defaultSpawner as W}from"./packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{default as N}from"./packem_shared/parseManifest-x3WsxKHz.mjs";import{R as V,S as j}from"./packem_shared/import-DLyCq-2j.mjs";import{REQUIRED_COMPATIBILITY_DATE as H,REQUIRED_FLAG as K,validateWranglerProject as Y,validateWranglerConfig as Z}from"@lunora/config/cloudflare";import{buildRegistryIndex as z}from"./packem_shared/buildRegistryIndex-DwySASBu.mjs";import{I as X,F as $,E as rr}from"./packem_shared/commands-CG9qEtqR.mjs";import{runExportCommand as or}from"./packem_shared/runExportCommand-BpE4AbuX.mjs";export{o as COMMANDS,V as DEFAULT_IMPORT_BATCH_SIZE,H as REQUIRED_COMPATIBILITY_DATE,K as REQUIRED_FLAG,a as VERSION,z as buildRegistryIndex,A as createLogger,U as createRecordingSpawner,W as defaultSpawner,v as diffSnapshots,D as insertSchemaExtension,c as pail,N as parseManifest,x as planDevCommand,_ as renderAddColumn,h as renderCreateIndex,y as renderCreateTable,F as renderDropIndex,L as renderDropTable,O as renderMigrationFile,X as runAddCommand,$ as runBuildIndexCommand,n as runCli,t as runCodegenCommand,p as runDeployCommand,i as runDevCommand,or as runExportCommand,j as runImportCommand,C as runInitCommand,u as runMigrateGenerateCommand,rr as runRegistryViewCommand,g as runResetCommand,E as runRpcCommand,B as schemaIrToSnapshot,Y as validateWrangler,Z as validateWranglerConfig,b as validatorKindToSqlType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as
|
|
1
|
+
import{i as n}from"../packem_shared/command-0l-ZPhIX.mjs";import{d as m}from"../packem_shared/resolve-target-CeiNrCAx.mjs";import{w as i,S as s}from"../packem_shared/import-DLyCq-2j.mjs";const f=n(({argument:a,cwd:r,logger:e,options:o})=>{const t=a[0];return t?o.from!==void 0&&!i.includes(o.from)?(e.error(`--from ${o.from} is not a known source. Expected one of: ${i.join(", ")}.`),{code:1}):s({batchSize:o.batchSize,cwd:r,file:t,from:o.from,logger:e,prod:o.prod===!0,scan:o.scan===!0,storageDir:o.storageDir,table:o.table,token:o.token,url:m({cwd:r,prod:o.prod===!0,url:o.url}),verify:o.verify===!0,withStorage:o.withStorage===!0,yes:o.yes===!0}):(e.error("import requires a path. Usage: lunora import <file.ndjson | convex-export-dir> [--table <name>]"),{code:1})});export{f as execute};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{readFileSync as f,existsSync as m}from"node:fs";import{join as g}from"node:path";import{discoverSchema as p}from"@lunora/codegen";import{readLinkedProject as u}from"@lunora/config";import{findWranglerFile as b}from"@lunora/config/cloudflare";import{parse as h}from"jsonc-parser";import{Project as y}from"ts-morph";import{i as j}from"../packem_shared/command-0l-ZPhIX.mjs";const l=(e,o)=>{if(e===null||typeof e!="object")return;const r=e[o];return typeof r=="string"&&r.length>0?r:void 0},c=(e,o)=>{if(e===null||typeof e!="object")return[];const r=e[o];return Array.isArray(r)?r:[]},w=e=>{const o=c(e.durable_objects??{},"bindings"),r=c(e,"d1_databases"),s=c(e,"vectorize");return{bindings:{d1:r.map(n=>l(n,"binding")??"<unnamed>"),durableObjects:o.map(n=>l(n,"name")??"<unnamed>"),vectorize:s.map(n=>l(n,"binding")??"<unnamed>")},compatibilityDate:l(e,"compatibility_date"),compatibilityFlags:c(e,"compatibility_flags").filter(n=>typeof n=="string"),main:l(e,"main"),name:l(e,"name")}},$=e=>({tables:e.tables.map(o=>{let r="root";return o.shardMode==="global"?r="global":typeof o.shardMode=="object"&&(r=`shardBy(${o.shardMode.field})`),{indexes:o.indexes.length,name:o.name,shard:r}}),vectorIndexes:e.vectorIndexes.length}),k=e=>{const o=g(e,"package.json");if(!m(o))return[];let r;try{r=JSON.parse(f(o,"utf8"))}catch{return[]}if(r===null||typeof r!="object")return[];const s=["dependencies","devDependencies","peerDependencies","optionalDependencies"],n=new Map;for(const a of s){const t=r[a];if(!(t===null||typeof t!="object"))for(const[i,d]of Object.entries(t))i.startsWith("@lunora/")&&typeof d=="string"&&!n.has(i)&&n.set(i,d)}return[...n.entries()].toSorted(([a],[t])=>a.localeCompare(t)).map(([a,t])=>({name:a,version:t}))},v=e=>{const o=k(e),r=b(e);let s;if(r)try{s=w(h(f(r,"utf8")))}catch{s=void 0}const n=g(e,"lunora","schema.ts");let a,t;if(m(n))try{const i=new y({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});a=$(p(i,n))}catch(i){t=i instanceof Error?i.message:String(i)}return{link:u(e),lunoraPackages:o,projectRoot:e,schema:a,schemaError:t,wrangler:s,wranglerPath:r}},x=(e,o)=>{if(o.info(`project: ${e.projectRoot}`),o.info(""),o.info("@lunora/* packages:"),e.lunoraPackages.length===0)o.info(" (none found in package.json)");else for(const r of e.lunoraPackages)o.info(` ${r.name}@${r.version}`);if(o.info(""),e.wrangler?(o.info(`wrangler: ${e.wranglerPath??""}`),o.info(` name: ${e.wrangler.name??"<unset>"}`),o.info(` main: ${e.wrangler.main??"<unset>"}`),o.info(` compatibility_date: ${e.wrangler.compatibilityDate??"<unset>"}`),o.info(` compatibility_flags: ${e.wrangler.compatibilityFlags.join(", ")||"<none>"}`),o.info(` durable objects: ${e.wrangler.bindings.durableObjects.join(", ")||"<none>"}`),o.info(` d1 databases: ${e.wrangler.bindings.d1.join(", ")||"<none>"}`),o.info(` vectorize indexes: ${e.wrangler.bindings.vectorize.join(", ")||"<none>"}`)):o.info("wrangler: (not found)"),o.info(""),e.link?(o.info(`link: ${e.link.workerName??"(unnamed)"} -> ${e.link.workerUrl??"<no url>"}`),e.link.env!==void 0&&o.info(` env: ${e.link.env}`)):o.info("link: (not linked — run `lunora link --url <https://your-worker>`)"),o.info(""),e.schemaError!==void 0)o.warn(`schema: parse error — ${e.schemaError}`);else if(e.schema){o.info(`schema: ${String(e.schema.tables.length)} table(s), ${String(e.schema.vectorIndexes)} vector index(es)`);for(const r of e.schema.tables)o.info(` ${r.name} [${r.shard}, ${String(r.indexes)} index(es)]`)}else o.info("schema: (no lunora/schema.ts)")},S=e=>{const o=e.cwd??process.cwd(),r=v(o);return e.json?process.stdout.write(`${JSON.stringify(r,void 0,2)}
|
|
2
|
+
`):x(r,e.logger),{code:0,snapshot:r}},E=j(({cwd:e,logger:o,options:r})=>S({cwd:e,json:r.json===!0,logger:o}));export{v as collectInfo,E as execute,S as runInfoCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`):
|
|
1
|
+
import{u as m}from"../packem_shared/admin-url-Ca-KI3d_.mjs";import{i as $}from"../packem_shared/command-0l-ZPhIX.mjs";import{d as S}from"../packem_shared/resolve-target-CeiNrCAx.mjs";const M="__lunora_admin__:getFunctionStats",y=10,u=(o,e)=>({calls:o.calls,conflicts:o.conflicts??0,errors:o.errors,lastErrorMessage:o.lastErrorMessage,maxDurationMs:o.maxDurationMs,meanDurationMs:o.calls===0?0:o.totalDurationMs/o.calls,path:o.path,rate:e}),v=(o,e)=>{const t=o.filter(r=>(r.conflicts??0)>0).map(r=>u(r,r.calls===0?0:(r.conflicts??0)/r.calls)).toSorted((r,s)=>s.rate-r.rate||s.conflicts-r.conflicts).slice(0,e),n=o.filter(r=>r.errors>0).map(r=>u(r,r.calls===0?0:r.errors/r.calls)).toSorted((r,s)=>s.rate-r.rate||s.errors-r.errors).slice(0,e),i=o.map(r=>u(r,0)).toSorted((r,s)=>s.maxDurationMs-r.maxDurationMs).slice(0,e);return{errorHotspots:n,latencyOutliers:i,totalFunctions:o.length,writeContention:t}},p=o=>`${(o*100).toFixed(1)}%`,f=o=>o<1e3?`${Math.round(o).toString()}ms`:`${(o/1e3).toFixed(2)}s`,d=(o,e,t,n)=>[o,...e.length===0?[` ${t}`]:e.map(i=>` ${n(i)}`)],w=o=>{const e=t=>t.lastErrorMessage?` — ${t.lastErrorMessage}`:"";return[`Insights over ${o.totalFunctions.toString()} function${o.totalFunctions===1?"":"s"}`,"",...d("Write-conflict hot-spots (OCC contention — candidates for sharding):",o.writeContention,"none — no write conflicts observed",t=>`${t.path} ${t.conflicts.toString()}/${t.calls.toString()} calls (${p(t.rate)})`),"",...d("Error hot-spots:",o.errorHotspots,"none — no errors observed",t=>`${t.path} ${t.errors.toString()}/${t.calls.toString()} calls (${p(t.rate)})${e(t)}`),"",...d("Latency outliers (slowest single call):",o.latencyOutliers,"none — no functions have run",t=>`${t.path} max ${f(t.maxDurationMs)}, mean ${f(t.meanDurationMs)} over ${t.calls.toString()} calls`)].join(`
|
|
2
|
+
`)},O=o=>o===void 0||!Number.isFinite(o)||o<=0?y:Math.floor(o),N=async o=>{if(o.prod&&o.url===void 0)return o.logger.error("--prod requires an explicit --url (refusing to report from the implicit localhost worker)"),{code:1};const e=o.token??process.env.LUNORA_ADMIN_TOKEN;if(!e)return o.logger.error("admin token required — pass --token or set LUNORA_ADMIN_TOKEN"),{code:1};const t=m(o.url,o.logger,o.cwd);if(t===void 0)return{code:1};const n=`${t}/_lunora/rpc`,i=globalThis.fetch;if(typeof i!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");const r={args:{},functionPath:M};o.shard!==void 0&&(r.shardKey=o.shard),o.logger.info(`POST ${n} -> insights`);const s=await i(n,{body:JSON.stringify(r),headers:{authorization:`Bearer ${e}`,"content-type":"application/json"},method:"POST"}),a=await s.text();if(!s.ok)return o.logger.error(`insights failed: HTTP ${String(s.status)}: ${a}`),{code:1};let l;try{l=JSON.parse(a)}catch{return o.logger.error(`insights failed: worker returned non-JSON: ${a}`),{code:1}}const h=l.result??l,{functions:g}=h;if(!Array.isArray(g))return o.logger.error("insights failed: response carried no `functions` array"),{code:1};const c=v(g,O(o.limit));return o.logger.info(o.json?JSON.stringify(c,void 0,2):w(c)),{code:0,report:c}},b=$(({cwd:o,logger:e,options:t})=>{const n=t.limit===void 0?void 0:Number.parseInt(t.limit,10);return N({cwd:o,json:t.json,limit:n,logger:e,prod:t.prod,shard:t.shard,token:t.token,url:S({cwd:o,prod:t.prod===!0,url:t.url})})});export{v as buildInsightsReport,b as execute,w as formatInsightsReport,N as runInsightsCommand};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)},O=o=>o===void 0||!Number.isFinite(o)||o<=0?y:Math.floor(o),N=async o=>{if(o.prod&&o.url===void 0)return o.logger.error("--prod requires an explicit --url (refusing to report from the implicit localhost worker)"),{code:1};const e=o.token??process.env.LUNORA_ADMIN_TOKEN;if(!e)return o.logger.error("admin token required — pass --token or set LUNORA_ADMIN_TOKEN"),{code:1};const t=m(o.url,o.logger,o.cwd);if(t===void 0)return{code:1};const n=`${t}/_lunora/rpc`,i=globalThis.fetch;if(typeof i!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");const r={args:{},functionPath:M};o.shard!==void 0&&(r.shardKey=o.shard),o.logger.info(`POST ${n} -> insights`);const s=await i(n,{body:JSON.stringify(r),headers:{authorization:`Bearer ${e}`,"content-type":"application/json"},method:"POST"}),a=await s.text();if(!s.ok)return o.logger.error(`insights failed: HTTP ${String(s.status)}: ${a}`),{code:1};let l;try{l=JSON.parse(a)}catch{return o.logger.error(`insights failed: worker returned non-JSON: ${a}`),{code:1}}const h=l.result??l,{functions:g}=h;if(!Array.isArray(g))return o.logger.error("insights failed: response carried no `functions` array"),{code:1};const c=v(g,O(o.limit));return o.logger.info(o.json?JSON.stringify(c,void 0,2):w(c)),{code:0,report:c}},b=$(({cwd:o,logger:e,options:t})=>{const n=t.limit===void 0?void 0:Number.parseInt(t.limit,10);return N({cwd:o,json:t.json,limit:n,logger:e,prod:t.prod,shard:t.shard,token:t.token,url:S({cwd:o,prod:t.prod===!0,url:t.url})})});export{v as buildInsightsReport,b as execute,w as formatInsightsReport,N as runInsightsCommand};
|
|
1
|
+
import{existsSync as c,rmSync as m}from"node:fs";import{join as u}from"node:path";import{writeLinkedProject as s,LINKED_PROJECT_FILE as t}from"@lunora/config";import{i as d}from"../packem_shared/command-0l-ZPhIX.mjs";import{d as a}from"../packem_shared/wrangler-name-CHDf3rMP.mjs";const k=r=>{try{const{protocol:o}=new URL(r);return o==="http:"||o==="https:"}catch{return!1}},p=(r,o)=>{const e=u(r,t);return c(e)?(m(e),o.success(`link: removed ${t}`),{code:0}):(o.warn(`link: no ${t} to remove`),{code:0})},v=r=>{const o=r.cwd??process.cwd(),{logger:e}=r;if(r.remove)return p(o,e);if(r.url===void 0||r.url==="")return e.error("link requires a deployed Worker URL. Usage: lunora link --url <https://your-worker>"),{code:1};if(!k(r.url))return e.error(`link: invalid --url "${r.url}" — expected an http(s) URL`),{code:1};const i=r.now??(()=>new Date().toISOString()),n={env:r.env,linkedAt:i(),workerName:r.name??a(o),workerUrl:r.url},l=s(o,n);return e.success(`link: ${n.workerName??"(unnamed worker)"} -> ${r.url}`),e.info(`link: wrote ${l}`),n.env!==void 0&&e.info(`link: environment "${n.env}"`),{code:0,link:n}},h=d(({cwd:r,logger:o,options:e})=>v({cwd:r,env:e.env,logger:o,name:e.name,remove:e.remove===!0,url:e.url}));export{h as execute,v as runLinkCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{runCodegen as g}from"@lunora/codegen";import{resolveTargetOrThrow as d,resolveDeployDriver as p}from"@lunora/config";import{r as m}from"../packem_shared/api-spec-BENwiyUa.mjs";import{l as f}from"../packem_shared/codegen-error-DJN6pTH5.mjs";import{i as u}from"../packem_shared/command-0l-ZPhIX.mjs";import{a as w}from"../packem_shared/platform-diagnostics-C4TFj5Pu.mjs";import{m as h}from"../packem_shared/post-codegen-hook-DhL1RH5u.mjs";import{R as v}from"../packem_shared/schema-drift-gate-d12lMICD.mjs";import{validateWranglerProject as S}from"@lunora/config/cloudflare";const b=async(r,o,a=[],i)=>{const l={crons:a,projectRoot:r},n=p(i);try{const e=await n.infer(l),s=[e.shardNamespaces.length>0?`${String(e.shardNamespaces.length)} shard namespace(s)`:void 0,e.queues.length>0?`${String(e.queues.length)} queue(s)`:void 0,e.workflows.length>0?`${String(e.workflows.length)} workflow(s)`:void 0,e.containers.length>0?`${String(e.containers.length)} container(s)`:void 0,e.globalDatabase?"global database":void 0,e.objectStorage?"object storage":void 0,e.keyValueStore?"key-value store":void 0].filter(c=>c!==void 0);s.length>0&&o.info(`${n.name} target requires: ${s.join(", ")}`)}catch{}const t=await n.provision(l);t.changed&&o.success(`provisioned: ${t.added.join(", ")} → ${t.configPath??"wrangler.jsonc"}`);for(const e of t.warnings)o.warn(e)},$=async r=>{const o=r.cwd??process.cwd(),a=d(o,r.target);r.logger.info("running codegen");let i;try{i=g({apiSpec:r.apiSpec,projectRoot:o,target:a}),r.logger.success("codegen complete"),w(i.platformDiagnostics,r.logger)}catch(e){const s=e instanceof Error?e.message:String(e);return r.logger.error(f(e)),{code:1,error:`codegen failed: ${s}`,validation:{problems:[],wranglerPath:void 0}}}const l=await h({cwd:o,logger:r.logger,spawner:r.spawner});if(l.error!==void 0)return r.logger.error(l.error),{code:1,error:l.error,validation:{problems:[],wranglerPath:void 0}};const n=v({allowDrift:r.allowSchemaDrift===!0,codegen:i,command:"prepare",logger:r.logger,updateBaseline:r.updateSchemaBaseline===!0});if(n.blocked)return{code:1,error:"schema drift gate blocked prepare",schemaDrift:{blocked:!0,reason:n.reason},validation:{problems:[],wranglerPath:void 0}};await b(o,r.logger,i.cronTriggers,a);const t=S({projectRoot:o});if(t.problems.length>0){r.logger.error("wrangler.jsonc validation failed:");for(const e of t.problems)r.logger.error(` - ${e}`);return{code:1,error:"wrangler validation failed",validation:t}}return n.rebless?.(),r.logger.success("project is ready to deploy"),{code:0,validation:t}},x=u(({cwd:r,logger:o,options:a})=>$({allowSchemaDrift:a.allowSchemaDrift===!0,apiSpec:m(a.apiSpec),cwd:r,logger:o,target:a.target,updateSchemaBaseline:a.updateSchemaBaseline===!0}));export{x as execute,$ as runPrepareCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{i as n}from"../packem_shared/command-0l-ZPhIX.mjs";import{I as c,E as f,F as a}from"../packem_shared/commands-CG9qEtqR.mjs";const i=n(({argument:u,cwd:s,logger:o,options:e})=>{const r=u[0],t=u.slice(1);return r==="add"?c({allowUnsafeSource:e.allowUnsafeSource===!0,cwd:s,diff:e.diff===!0,dryRun:e.dryRun===!0,from:e.from,json:e.json===!0,logger:o,names:t,overwrite:e.overwrite===!0,ref:e.ref,source:e.source,yes:e.yes===!0}):r==="list"?c({cwd:s,from:e.from,json:e.json===!0,list:!0,logger:o,names:[],ref:e.ref,source:e.source}):r==="view"?f({allowUnsafeSource:e.allowUnsafeSource===!0,cwd:s,from:e.from,logger:o,names:t,ref:e.ref,source:e.source}):r==="build"?a({check:e.check===!0,from:e.from,logger:o,out:e.out}):(o.error("registry: unknown subcommand. Usage: lunora registry <add|list|view|build> [names…]"),{code:1})});export{i as execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{existsSync as c,readFileSync as g,readdirSync as p,statSync as k,mkdirSync as S,writeFileSync as y}from"node:fs";import{fileURLToPath as v}from"node:url";import{AGENT_RULES_DIR as u,detectAgentRules as L,LUNORA_SKILL_NAMES as R}from"@lunora/config";import{join as l,relative as $,resolve as j,dirname as d}from"@visulima/path";import{i as I}from"../packem_shared/command-0l-ZPhIX.mjs";const b=(r=d(v(import.meta.url)))=>{let e=r;for(let n=0;n<6;n+=1){const t=l(e,"package.json");if(c(t))try{if(JSON.parse(g(t,"utf8")).name==="@lunora/cli"){const s=l(e,"skills");return c(s)?s:void 0}}catch{}const o=d(e);if(o===e)break;e=o}},A=r=>p(r).filter(e=>{const n=l(r,e);return k(n).isDirectory()&&c(l(n,"SKILL.md"))}),m=(r,e,n)=>{S(e,{recursive:!0});let t=!1;for(const o of p(r)){const s=l(r,o),i=l(e,o);if(k(s).isDirectory()){t=m(s,i,n)||t;continue}c(i)&&!n||(y(i,g(s)),t=!0)}return t},_=["pnpm-workspace.yaml","pnpm-lock.yaml","yarn.lock","package-lock.json","bun.lock","bun.lockb",".git"],x=r=>{let e=r;for(;;){if(_.some(t=>c(l(e,t))))return e;const n=d(e);if(n===e)return r;e=n}},f=(r,e)=>e===void 0?x(r):j(r,e),D=r=>{const e=r.cwd??process.cwd(),n=f(e,r.dir),t=r.overwrite===!0,o=b();if(o===void 0)return r.logger.error("rules: could not locate the bundled skills (is @lunora/cli installed correctly?)."),{code:1,installed:[],skipped:[]};const s=[],i=[];for(const a of A(o)){const w=l(n,u,a);m(l(o,a),w,t)?s.push(a):i.push(a)}const h=$(e,l(n,u))||u;return s.length>0&&r.logger.success(`Installed ${String(s.length)} Lunora skill(s) into ${h}/: ${s.join(", ")}.`),i.length>0&&r.logger.info(`Skipped ${String(i.length)} existing skill(s) (re-run with --overwrite to replace): ${i.join(", ")}.`),r.logger.info("Your AI coding agent will pick these up automatically. Start with the `lunora` skill."),{code:0,installed:s,skipped:i}},E=r=>{const e=r.cwd??process.cwd(),n=f(e,r.dir),t=L(n);return t.installed?(r.logger.success(`Lunora agent rules are installed (${String(t.present.length)}/${String(R.length)} skills).`),t.missing.length>0&&r.logger.info(`Missing: ${t.missing.join(", ")}. Run \`lunora rules install\` to add them.`),{code:0,installed:t.present,skipped:[]}):(r.logger.warn("Lunora agent rules are not installed. Run `lunora rules install` so your AI agent knows how to use Lunora."),{code:r.strict===!0?1:0,installed:t.present,skipped:[]})},M=I(({argument:r,cwd:e,logger:n,options:t})=>{const o=r[0]??"check";return o==="install"?D({cwd:e,dir:t.dir,logger:n,overwrite:t.overwrite===!0}):o==="check"?E({cwd:e,dir:t.dir,logger:n,strict:t.strict===!0}):(n.error("rules: unknown subcommand. Usage: lunora rules <install|check>"),{code:1})});export{M as execute,b as resolveBundledSkillsDirectory,E as runRulesCheck,D as runRulesInstall};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as y}from"node:fs";import{mkdtemp as S,writeFile as v,rm as $}from"node:fs/promises";import{tmpdir as j}from"node:os";import{discoverSchema as k,schemaFromIr as C}from"@lunora/codegen";import{seedPlan as x}from"@lunora/seed";import{join as m}from"@visulima/path";import{Project as z}from"ts-morph";import{d as F}from"../packem_shared/admin-token-BKmc3AUm.mjs";import{i as R}from"../packem_shared/command-0l-ZPhIX.mjs";import{d as T}from"../packem_shared/resolve-target-CeiNrCAx.mjs";import{o as A}from"../packem_shared/tui-prompts-BU3irGxV.mjs";import{runResetCommand as I}from"./runResetCommand.mjs";import{S as N}from"../packem_shared/import-DLyCq-2j.mjs";const p=e=>e===""?!1:F(e),B=(e,r)=>typeof r=="bigint"?Number(r):r instanceof ArrayBuffer?[...new Uint8Array(r)]:r,c=e=>({code:e,conflicts:0,generated:0,inserted:0,ndjson:""}),P=(e,r)=>{if(!y(r))return e.logger.error(`schema not found: ${r} — run \`vis generate lunora-table --name=<name>\` to create one`),c(1);if(e.reset===!0&&(e.prod===!0||!p(e.url)))return e.logger.error("--reset only clears local .wrangler/state and cannot be combined with --prod or a remote --url"),c(1)},U=async(e,r,o,t)=>{const l=await S(m(j(),"lunora-seed-")),a=m(l,"rows.ndjson");await v(a,e,"utf8");try{const n=await N({batchSize:t.batchSize,cwd:o,fetchImpl:t.fetchImpl,file:a,logger:t.logger,prod:t.prod,token:t.token,url:t.url}),d=n.body?.conflicts??0;return d>0&&t.logger.warn(`${String(d)} row(s) skipped — their _id already exists. Seeding is deterministic; re-run with --reset to wipe local state first, or a different --seed for fresh ids.`),{code:n.code,conflicts:d,generated:r,inserted:n.inserted,ndjson:e}}finally{await $(l,{force:!0,recursive:!0}).catch(()=>{})}},_=(e,r)=>{if(e.table===void 0||r.tables.some(t=>t.name===e.table))return;const o=r.tables.map(t=>t.name).join(", ");return e.logger.error(`unknown table "${e.table}" — schema defines: ${o||"(no tables)"}`),c(1)},H=async(e,r)=>{if(!(!(e.prod===!0||!p(e.url))||e.yes===!0)){if(!process.stdin.isTTY&&e.confirm===void 0)return e.logger.error("seed: refusing to insert into a non-local target without confirmation — re-run with --yes"),c(1);if(!await(e.confirm??A)(`This will insert ${String(r)} generated row(s) into ${e.url??"the production worker"}. Continue?`))return e.logger.info("seed: aborted"),c(1)}},J=async e=>{const r=e.cwd??process.cwd(),o=m(r,"lunora","schema.ts"),t=P(e,o);if(t!==void 0)return t;const l=new z({skipAddingFilesFromTsConfig:!0}),a=k(l,o),n=_(e,a);if(n!==void 0)return n;const d=C(a),g=x(d,{defaultCount:e.count??10,now:e.now,only:e.table===void 0?void 0:[e.table],seed:e.seed??0}),u=[];for(const{rows:f,table:h}of g)for(const b of f)u.push(JSON.stringify({doc:b,table:h},B));const i=u.length>0?`${u.join(`
|
|
2
|
+
`)}
|
|
3
|
+
`:"",s=u.length;if(e.dryRun===!0)return i.length>0&&process.stdout.write(i),e.logger.info(`generated ${String(s)} row(s) across ${String(g.length)} table(s) — dry run, nothing inserted`),{code:0,conflicts:0,generated:s,inserted:0,ndjson:i};if(e.reset===!0){const f=await I({cwd:r,logger:e.logger,yes:!0});if(f.code!==0)return{code:f.code,conflicts:0,generated:s,inserted:0,ndjson:i}}if(s===0)return e.logger.warn("no rows generated — nothing to insert"),{code:0,conflicts:0,generated:0,inserted:0,ndjson:i};const w=await H(e,s);return w!==void 0?w:U(i,s,r,e)},Z=R(async({cwd:e,logger:r,options:o})=>({code:(await J({batchSize:o.batchSize,count:o.count,cwd:e,dryRun:o.dryRun===!0,logger:r,prod:o.prod===!0,reset:o.reset===!0,now:o.now,seed:o.seed,table:o.table,token:o.token,url:T({cwd:e,prod:o.prod===!0,url:o.url}),yes:o.yes===!0})).code}));export{Z as execute,J as runSeedCommand};
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
`)}
|
|
3
|
-
`:"",s=u.length;if(e.dryRun===!0)return i.length>0&&process.stdout.write(i),e.logger.info(`generated ${String(s)} row(s) across ${String(g.length)} table(s) — dry run, nothing inserted`),{code:0,conflicts:0,generated:s,inserted:0,ndjson:i};if(e.reset===!0){const f=await I({cwd:r,logger:e.logger,yes:!0});if(f.code!==0)return{code:f.code,conflicts:0,generated:s,inserted:0,ndjson:i}}if(s===0)return e.logger.warn("no rows generated — nothing to insert"),{code:0,conflicts:0,generated:0,inserted:0,ndjson:i};const w=await H(e,s);return w!==void 0?w:U(i,s,r,e)},Z=R(async({cwd:e,logger:r,options:o})=>({code:(await J({batchSize:o.batchSize,count:o.count,cwd:e,dryRun:o.dryRun===!0,logger:r,prod:o.prod===!0,reset:o.reset===!0,now:o.now,seed:o.seed,table:o.table,token:o.token,url:T({cwd:e,prod:o.prod===!0,url:o.url}),yes:o.yes===!0})).code}));export{Z as execute,J as runSeedCommand};
|
|
1
|
+
import{existsSync as m}from"node:fs";import{join as d}from"node:path";import{runCodegen as h}from"@lunora/codegen";import{r as w}from"../packem_shared/api-spec-BENwiyUa.mjs";import{c as u}from"../packem_shared/codegen-error-DJN6pTH5.mjs";import{i as y}from"../packem_shared/command-0l-ZPhIX.mjs";import{i as v}from"../packem_shared/deploy-target-Dvr9vxpR.mjs";import{M as S,l as $}from"../packem_shared/detect-package-manager-DXDstphE.mjs";import{p as j}from"../packem_shared/health-probe-CiFgh1hn.mjs";import{i as k,t as P,d as U,s as D}from"../packem_shared/output-format-Cv3aLqhP.mjs";import{R as x}from"../packem_shared/schema-drift-gate-d12lMICD.mjs";import{defaultSpawner as E}from"../packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{validateWranglerProject as R}from"@lunora/config/cloudflare";const b=async(r,e)=>{if(!m(d(r,"tsconfig.json")))return{warning:"no tsconfig.json found — skipping TypeScript type-check"};const o=S($(r),"tsc",["--noEmit","-p","tsconfig.json"]),n=await e({args:o.args,command:o.command,cwd:r});return n.code===0?{}:{error:`type errors: tsc --noEmit exited ${String(n.code)}`}},C=async(r,e)=>{if(r.healthUrl===void 0||r.healthUrl==="")return;const o=await j({baseUrl:r.healthUrl,fetchImpl:r.healthFetch});if(o.error===void 0){e.success(`verify: health probe ok (${o.url})`);return}return o.error},A=(r,e,o,n)=>{if(e.length===0&&o.length===0)return r.success("verify: project is valid"),{code:0,errors:[],warnings:[],wranglerPath:n};if(o.length>0){r.warn("verify: warnings:");for(const a of o)r.warn(` - ${a}`)}if(e.length>0){r.error("verify: errors:");for(const a of e){r.error(` - ${a}`);const i=u(a);i!==void 0&&r.error(i)}return{code:1,errors:e,warnings:o,wranglerPath:n}}return r.success("verify: project is valid (with warnings)"),{code:0,errors:[],warnings:o,wranglerPath:n}},F=async r=>{const e=r.cwd??process.cwd(),o=D(r.format,r.logger),n=k("verify",r.format);if(n!==void 0)return r.logger.error(n),{code:1,error:n,errors:[],warnings:[],wranglerPath:void 0};const a=R({projectRoot:e}),i=[...a.report.errors],f=[...a.report.warnings];try{const t=v(e,r.target);if(t.target===void 0){const c=t.error??"unknown deploy target";return o.error(c),{code:1,error:c,errors:[c],warnings:[],wranglerPath:void 0}}const s=h({apiSpec:r.apiSpec,dryRun:!0,projectRoot:e,target:t.target}),g=x({allowDrift:r.allowSchemaDrift===!0,codegen:s,command:"verify",logger:o,readOnly:!0});g.blocked&&i.push(g.reason)}catch(t){const s=t instanceof Error?t.message:String(t);i.push(`codegen failed: ${s}`)}if(r.typecheck!==!1){const t=await b(e,r.spawner??E);t.error!==void 0&&i.push(t.error),t.warning!==void 0&&f.push(t.warning)}const l=await C(r,o);l!==void 0&&i.push(l);const p=A(o,i,f,a.wranglerPath);return P(r.format)&&U(p),p},L=y(async({cwd:r,logger:e,options:o})=>({code:(await F({allowSchemaDrift:o.allowSchemaDrift===!0,apiSpec:w(o.apiSpec),cwd:r,format:o.format,healthUrl:o.healthUrl,logger:e,target:o.target,typecheck:o.typecheck===!1?!1:void 0})).code}));export{L as execute,F as runVerifyCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{readFileSync as u,existsSync as l}from"node:fs";import{join as p}from"node:path";import{parse as a}from"jsonc-parser";import{i as m}from"../packem_shared/command-0l-ZPhIX.mjs";import{f as g}from"../packem_shared/open-url-zbbAo_D7.mjs";const c=8787,i="/_lunora/studio",d=e=>{for(const t of["wrangler.jsonc","wrangler.json"]){const r=p(e,t);if(l(r))return r}},y=e=>{const t=d(e);if(t)try{const r=a(u(t,"utf8"));return r!==null&&typeof r=="object"?r:void 0}catch{return}},w=e=>{if(!e)return c;const{dev:t}=e;if(t!==null&&typeof t=="object"){const{port:r}=t;if(typeof r=="number"&&Number.isFinite(r))return r}return c},h=e=>{if(!e)return;const{routes:t}=e;if(Array.isArray(t)&&t.length>0){const n=t[0];if(typeof n=="string")return`https://${n.split("/")[0]??n}${i}`;if(n!==null&&typeof n=="object"){const{pattern:o}=n;if(typeof o=="string"&&o.length>0)return`https://${o.split("/")[0]??o}${i}`}}const{name:r}=e;if(typeof r=="string"&&r.length>0)return`https://${r}.workers.dev${i}`},$=async e=>{const t=e.cwd??process.cwd(),r=y(t),{logger:n}=e;let o;if(e.remote){if(o=h(r),!o)return n.error("view --remote: could not determine the remote URL from wrangler config (set `routes` or `name`)."),{code:1,url:void 0}}else o=`http://localhost:${String(w(r))}${i}`;n.info(`opening ${o}`);try{await g(o,{opener:e.opener})}catch(s){const f=s instanceof Error?s.message:String(s);return n.error(`view: failed to open URL: ${f}`),{code:1,url:o}}return{code:0,url:o}},R=m(({cwd:e,logger:t,options:r})=>$({cwd:e,logger:t,remote:r.remote===!0}));export{R as execute,$ as runViewCommand};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{writeFileSync as h,existsSync as v,readFileSync as S}from"node:fs";import{isAbsolute as w,join as b}from"node:path";import{byCodepoint as y,scoreAdvisor as x,parseAdvisorMap as j,compareToBaseline as R}from"@lunora/advisor";import{runCodegen as k}from"@lunora/codegen";import{i as A}from"../packem_shared/command-0l-ZPhIX.mjs";import{i as D,d as M,s as F,t as N}from"../packem_shared/output-format-Cv3aLqhP.mjs";import{o as g}from"../packem_shared/cli-RVVu3rxm.mjs";const l={clean:"·",exempt:"–",failing:"✗",warned:"!"},u=(r,e)=>r.length>=e?r:r+" ".repeat(e-r.length),C=r=>`${r.id} (${r.visibility} ${r.kind})`,m=r=>{let e=0;for(const o of r)e=Math.max(e,o.id.length);return e},p=(r,e)=>` ${u(String(r.score),3)} ${l[r.coverage]} ${u(r.id,e)} ${r.visibility} ${r.kind}`,E=r=>{if(!r.comparable)return[` baseline not comparable (${r.reason}) — regenerate it; this run cannot verify anything`];if(!r.regressed)return[` no regression against baseline (score ${r.scoreDelta>=0?"+":""}${String(r.scoreDelta)})`];const e=[` REGRESSED against baseline (score ${r.scoreDelta>=0?"+":""}${String(r.scoreDelta)})`];for(const o of r.dropped)e.push(` ${o.id}: ${String(o.before)} → ${String(o.after)}`);for(const o of r.newFailing)e.push(` ${o}: now failing`);for(const o of r.worsened)e.push(` ${o}: more findings than the baseline`);return r.projectRegressed&&e.push(" project: new schema/config rules fired"),e},J=(r,e)=>{const o=r.procedures.filter(i=>i.coverage!=="clean"&&i.coverage!=="exempt"),n=m(o),t=[`advisor health ${String(r.score)}/100 — ${r.grade}`,` ${String(r.summary.clean)} clean · ${String(r.summary.warned)} warned · ${String(r.summary.failing)} failing · ${String(r.summary.exempt)} exempt (${String(r.summary.procedures)} procedures, ${String(r.summary.rulesFired)} rules fired)`];return r.project.checks.length>0&&t.push("",` project ${String(r.project.score)}/100 — ${r.project.checks.map(i=>i.name).join(", ")}`),o.length>0&&t.push("",...o.map(i=>p(i,n)),""," run with --all for every procedure, or --entry <file#export> for one"),e!==void 0&&t.push("",...E(e)),t.join(`
|
|
2
|
+
`)},O=r=>r.coverage==="exempt"?[` exempt: ${r.exemptReason===void 0||r.exemptReason===""?"no reason given":r.exemptReason}`]:r.checks.map(e=>{const o=e.occurrences>1?`, ×${String(e.occurrences)}`:"";return` ${e.name} (−${String(e.weight)}${o})`}),B=r=>{const e=new Map;for(const o of r){const n=e.get(o.file);n===void 0?e.set(o.file,[o]):n.push(o)}return[...e].toSorted(([o],[n])=>y(o,n))},P=r=>{const e=m(r.procedures),o=[`advisor health ${String(r.score)}/100 — ${r.grade}`,"",` legend: ${l.clean} clean ${l.warned} warned ${l.failing} failing ${l.exempt} exempt`];for(const[n,t]of B(r.procedures)){o.push("",` ${n}`);for(const i of t)o.push(p(i,e),...O(i))}return o.join(`
|
|
3
|
+
`)},T=(r,e)=>{const o=r.procedures.find(t=>t.id===e);if(o===void 0){const t=r.procedures.slice(0,10).map(i=>` ${i.id}`);return[`no procedure ${e} in the map. Known ids:`,...t,r.procedures.length>10?" …":""].filter(Boolean).join(`
|
|
4
|
+
`)}const n=[`${C(o)} — ${String(o.score)}/100, ${o.coverage}`,` weight in the global mean: ${String(o.weight)}`];if(o.checks.length===0)return n.push(""," no rule fired"),n.join(`
|
|
5
|
+
`);n.push(""," rules fired:");for(const t of o.checks)n.push(` [${t.level}] ${t.name} −${String(t.weight)}${t.occurrences>1?` (×${String(t.occurrences)})`:""}`);return n.join(`
|
|
6
|
+
`)},q=new Date(0).toISOString(),f=(r,e)=>w(e)?e:b(r,e),G=r=>{if(r===void 0)return{value:void 0};if(r===null||r==="")return{error:"--min-score needs a value between 0 and 100"};const e=Number(r);return Number.isFinite(e)&&e>=0&&e<=100?{value:e}:{error:"--min-score must be a number between 0 and 100"}},H=(r,e,o)=>{const n=f(e,o===null||o===""?g:o);if(!v(n))return{error:`baseline not found at ${n} — generate one with \`lunora advisor\` and commit it`};const t=j(JSON.parse(S(n,"utf8")));return t===void 0?{error:`baseline at ${n} is malformed — regenerate it with \`lunora advisor\``}:{comparison:R(r,t)}},I=r=>`baseline is not comparable (${r}) — regenerate it; this run verified nothing`,K=(r,e,o)=>e.entry!==void 0?T(r,e.entry):e.all===!0?P(r):J(r,o),L=r=>{const e=r.cwd??process.cwd(),o=N(r.format),n=F(r.format,r.logger),t=D("advisor",r.format);if(t!==void 0)return r.logger.error(t),{error:t};const i=G(r.minScore);if("error"in i)return r.logger.error(i.error),{error:i.error};const{advisorContext:d,advisories:$}=k({dryRun:!0,projectRoot:e});if(d===void 0){const s="advisor evidence unavailable — codegen ran with linting disabled";return r.logger.error(s),{error:s}}const c=x(d.procedureProtections??[],$,{generatedAt:r.generatedAt??q}),a={map:c};if(r.baseline!==void 0){const s=H(c,e,r.baseline);if("error"in s)return r.logger.error(s.error),{...a,error:s.error};a.comparison=s.comparison,s.comparison.comparable||r.logger.error(I(s.comparison.reason))}if(r.write!==!1){const s=f(e,r.out??g);h(s,`${JSON.stringify(c,void 0,4)}
|
|
7
|
+
`,"utf8"),a.written=s}return a.belowMinScore=i.value!==void 0&&c.score<i.value,a.belowMinScore&&n.error(`advisor score ${String(c.score)} is below the required ${String(i.value)}`),o?(M(a),a):(n.info(K(c,r,a.comparison)),a.written!==void 0&&n.success(`wrote ${a.written}`),a)},z=r=>r.error!==void 0||r.belowMinScore===!0?!0:r.comparison!==void 0&&(!r.comparison.comparable||r.comparison.regressed),_=A(({cwd:r,logger:e,options:o})=>{const n=L({all:o.all,baseline:o.baseline,cwd:r,entry:o.entry,format:o.format,logger:e,minScore:o.minScore,out:o.out,write:o.write});return{code:z(n)?1:0}});export{_ as execute,L as runAdvisorCommand};
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
`)},T=(r,e)=>{const o=r.procedures.find(t=>t.id===e);if(o===void 0){const t=r.procedures.slice(0,10).map(i=>` ${i.id}`);return[`no procedure ${e} in the map. Known ids:`,...t,r.procedures.length>10?" …":""].filter(Boolean).join(`
|
|
4
|
-
`)}const n=[`${C(o)} — ${String(o.score)}/100, ${o.coverage}`,` weight in the global mean: ${String(o.weight)}`];if(o.checks.length===0)return n.push(""," no rule fired"),n.join(`
|
|
5
|
-
`);n.push(""," rules fired:");for(const t of o.checks)n.push(` [${t.level}] ${t.name} −${String(t.weight)}${t.occurrences>1?` (×${String(t.occurrences)})`:""}`);return n.join(`
|
|
6
|
-
`)},q=new Date(0).toISOString(),f=(r,e)=>w(e)?e:b(r,e),G=r=>{if(r===void 0)return{value:void 0};if(r===null||r==="")return{error:"--min-score needs a value between 0 and 100"};const e=Number(r);return Number.isFinite(e)&&e>=0&&e<=100?{value:e}:{error:"--min-score must be a number between 0 and 100"}},H=(r,e,o)=>{const n=f(e,o===null||o===""?g:o);if(!v(n))return{error:`baseline not found at ${n} — generate one with \`lunora advisor\` and commit it`};const t=j(JSON.parse(S(n,"utf8")));return t===void 0?{error:`baseline at ${n} is malformed — regenerate it with \`lunora advisor\``}:{comparison:R(r,t)}},I=r=>`baseline is not comparable (${r}) — regenerate it; this run verified nothing`,K=(r,e,o)=>e.entry!==void 0?T(r,e.entry):e.all===!0?P(r):J(r,o),L=r=>{const e=r.cwd??process.cwd(),o=N(r.format),n=F(r.format,r.logger),t=D("advisor",r.format);if(t!==void 0)return r.logger.error(t),{error:t};const i=G(r.minScore);if("error"in i)return r.logger.error(i.error),{error:i.error};const{advisorContext:d,advisories:$}=k({dryRun:!0,projectRoot:e});if(d===void 0){const s="advisor evidence unavailable — codegen ran with linting disabled";return r.logger.error(s),{error:s}}const c=x(d.procedureProtections??[],$,{generatedAt:r.generatedAt??q}),a={map:c};if(r.baseline!==void 0){const s=H(c,e,r.baseline);if("error"in s)return r.logger.error(s.error),{...a,error:s.error};a.comparison=s.comparison,s.comparison.comparable||r.logger.error(I(s.comparison.reason))}if(r.write!==!1){const s=f(e,r.out??g);h(s,`${JSON.stringify(c,void 0,4)}
|
|
7
|
-
`,"utf8"),a.written=s}return a.belowMinScore=i.value!==void 0&&c.score<i.value,a.belowMinScore&&n.error(`advisor score ${String(c.score)} is below the required ${String(i.value)}`),o?(M(a),a):(n.info(K(c,r,a.comparison)),a.written!==void 0&&n.success(`wrote ${a.written}`),a)},z=r=>r.error!==void 0||r.belowMinScore===!0?!0:r.comparison!==void 0&&(!r.comparison.comparable||r.comparison.regressed),_=A(({cwd:r,logger:e,options:o})=>{const n=L({all:o.all,baseline:o.baseline,cwd:r,entry:o.entry,format:o.format,logger:e,minScore:o.minScore,out:o.out,write:o.write});return{code:z(n)?1:0}});export{_ as execute,L as runAdvisorCommand};
|
|
1
|
+
import{readdirSync as m,readFileSync as u,mkdirSync as g,writeFileSync as p}from"node:fs";import{join as f,resolve as l,isAbsolute as w,dirname as b}from"node:path";import{findWranglerFile as h,readWranglerJsonc as y,buildBindingManifest as v}from"@lunora/config/cloudflare";import{r as $}from"../packem_shared/api-spec-BENwiyUa.mjs";import{i as S}from"../packem_shared/command-0l-ZPhIX.mjs";import{i as B,s as z,t as F,d as D}from"../packem_shared/output-format-Cv3aLqhP.mjs";import{defaultSpawner as k}from"../packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{runDeployCommand as x}from"./runDeployCommand.mjs";import{gzipSync as M}from"node:zlib";const W=e=>!e.endsWith(".map")&&e!=="bundle-meta.json"&&e!=="README.md",j=e=>{let t;try{t=m(e,{recursive:!0,withFileTypes:!0})}catch{return}let r=0,o=0,d=0;for(const i of t){if(!i.isFile()||!W(i.name))continue;const n=u(f(i.parentPath,i.name));r+=1,d+=n.byteLength,o+=M(n).byteLength}return r===0?void 0:{files:r,gzipBytes:o,rawBytes:d}},A=".lunora/build",C=async e=>k({...e,stdoutToStderr:!0}),c=e=>`${(e/1024).toFixed(1)} KiB`,P=(e,t,r)=>{const o=h(e),d=o===void 0?void 0:y(o).parsed;if(d===void 0)return{error:`--emit-bindings found no readable wrangler config in ${e}. The manifest is derived from it, and an empty one would tell a deployer this Worker needs nothing.`};const i=v(d),n=w(t)?t:l(e,t);return g(b(n),{recursive:!0}),p(n,`${JSON.stringify(i,void 0,2)}
|
|
2
|
+
`,"utf8"),r.success(`binding manifest written to ${n} (${i.bindings.length.toString()} bindings, ${i.crons.length.toString()} crons)`),i.unknown.length>0&&r.warn(`binding manifest does not model these wrangler sections: ${i.unknown.join(", ")}. Anything they bind must be provisioned by hand — please report them so the manifest can cover them.`),{}},R=async e=>{const t=e.outDir??A,r=F(e.format),o=z(e.format,e.logger),d=a=>(r&&D(a),a),i=B("build",e.format);if(i!==void 0)return e.logger.error(i),{code:1,descriptor:void 0,error:i,validation:{problems:[],wranglerPath:void 0}};const n=await x({apiSpec:e.apiSpec,cwd:e.cwd,dryRun:!0,format:void 0,interactive:r?!1:void 0,logger:o,outDir:t,spawner:e.spawner??(r?C:void 0),target:e.target});if(n.code!==0)return d(n);o.success(`build complete — bundle written to ${t}`);const s=j(l(e.cwd??process.cwd(),t));if(s===void 0?o.warn(`could not weigh the bundle — nothing uploadable was found in ${t}`):o.info(`bundle: ${c(s.rawBytes)} raw, ${c(s.gzipBytes)} gzipped across ${String(s.files)} file(s) — Cloudflare's Worker size limit (3 MB Free, 10 MB Paid) applies to the gzipped number`),e.emitBindings!==void 0){const{error:a}=P(e.cwd??process.cwd(),e.emitBindings,o);if(a!==void 0)return o.error(a),d({...n,bundle:s,code:1})}return d({...n,bundle:s})},H=S(async({cwd:e,logger:t,options:r})=>({code:(await R({apiSpec:$(r.apiSpec),cwd:e,emitBindings:r.emitBindings,format:r.format,logger:t,outDir:r.outDir,target:r.target})).code}));export{H as execute,R as runBuildCommand};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as L}from"../packem_shared/cli-
|
|
1
|
+
import{i as L}from"../packem_shared/cli-RVVu3rxm.mjs";import{i as J}from"../packem_shared/command-0l-ZPhIX.mjs";import{existsSync as p,readFileSync as h,mkdirSync as P,realpathSync as W,statSync as D,writeFileSync as T,chmodSync as z,renameSync as H,unlinkSync as I}from"node:fs";import{homedir as $}from"node:os";import{findWranglerFile as K}from"@lunora/config/cloudflare";import{join as s,dirname as q,relative as G}from"@visulima/path";import{l as V,M as Z}from"../packem_shared/detect-package-manager-DXDstphE.mjs";import{stringify as B}from"smol-toml";import{parse as Q,modify as X,applyEdits as Y}from"jsonc-parser";import{readLiveDevServerState as y}from"@lunora/config";import{resolveAdminToken as oo}from"@lunora/config/studio-host";import{connectLocalStdio as to}from"@lunora/mcp";const u=o=>({args:[...o.args],command:o.command,...o.env===void 0?{}:{env:o.env}}),v=o=>o.transport==="http"?{type:"http",url:o.url}:u(o),eo=o=>o.transport==="http"?{httpUrl:o.url}:u(o),ro=o=>o.transport==="http"?{serverUrl:o.url}:u(o),no=o=>({args:["-y","mcp-remote",o],command:"npx"}),ao=o=>o.transport==="http"?no(o.url):u(o),io=o=>o.transport==="http"?{url:o.url}:u(o),lo=o=>o.transport==="http"?{enabled:!0,type:"remote",url:o.url}:{command:[o.command,...o.args],enabled:!0,type:"local",...o.env===void 0?{}:{environment:o.env}},so=o=>o.transport==="http"?{disabled:!1,type:"streamableHttp",url:o.url}:{disabled:!1,...u(o)},co=({home:o,platform:t})=>{if(t==="darwin")return{global:s(o,"Library","Application Support","Claude","claude_desktop_config.json")};if(t==="win32"){const e=process.env.APPDATA;return e===void 0||e===""?{}:{global:s(e,"Claude","claude_desktop_config.json")}}return t==="linux"?{global:s(o,".config","Claude","claude_desktop_config.json")}:{}},po=(o,t)=>B({mcp_servers:{[o]:t.transport==="http"?{url:t.url}:{args:[...t.args],command:t.command,...t.env===void 0?{}:{env:t.env}}}}),g=[{buildEntry:v,paths:({projectRoot:o})=>({project:s(o,".mcp.json")}),format:"json",id:"claude-code",key:"mcpServers",label:"Claude Code"},{buildEntry:v,paths:({home:o,projectRoot:t})=>({global:s(o,".cursor","mcp.json"),project:s(t,".cursor","mcp.json")}),format:"json",id:"cursor",key:"mcpServers",label:"Cursor"},{buildEntry:v,paths:({projectRoot:o})=>({project:s(o,".vscode","mcp.json")}),format:"json",id:"vscode",key:"servers",label:"VS Code (GitHub Copilot)"},{buildEntry:eo,paths:({home:o,projectRoot:t})=>({global:s(o,".gemini","settings.json"),project:s(t,".gemini","settings.json")}),format:"json",id:"gemini",key:"mcpServers",label:"Gemini CLI"},{buildEntry:ao,paths:co,format:"json",id:"claude-desktop",key:"mcpServers",label:"Claude Desktop"},{buildEntry:ro,paths:({home:o})=>({global:s(o,".codeium","windsurf","mcp_config.json")}),format:"json",id:"windsurf",key:"mcpServers",label:"Windsurf"},{buildEntry:lo,paths:({home:o,projectRoot:t})=>({global:s(o,".config","opencode","opencode.json"),project:s(t,"opencode.json")}),format:"json",id:"opencode",key:"mcp",label:"OpenCode"},{buildEntry:so,paths:({home:o})=>({global:s(o,".cline","mcp.json")}),format:"json",id:"cline",key:"mcpServers",label:"Cline"},{buildEntry:io,paths:({home:o})=>({global:s(o,".config","zed","settings.json")}),format:"json",id:"zed",key:"context_servers",label:"Zed"},{paths:({home:o,projectRoot:t})=>({global:s(o,".codex","config.toml"),project:s(t,".codex","config.toml")}),format:"manual",id:"codex",label:"Codex CLI",renderSnippet:po}],O=g.map(o=>o.id),uo=o=>g.find(t=>t.id===o.toLowerCase()),x=(o,t)=>{let e=o,r;try{e=W(o),r=D(e).mode}catch{}const a=`${e}.lunora-${Math.random().toString(36).slice(2,10)}.tmp`;try{T(a,t,"utf8"),r!==void 0&&z(a,r),H(a,e)}catch(n){try{I(a)}catch{}throw n}},mo={formattingOptions:{insertSpaces:!0,tabSize:4}},b=o=>{const t=[],e=Q(o,t,{allowTrailingComma:!0});return{errors:t,value:e}},f=o=>typeof o=="object"&&o!==null&&!Array.isArray(o),w=(o,t,e)=>{if(!f(o))return;const r=o[t];return f(r)?r[e]:void 0},C=o=>{if(!p(o.path))return"absent";let t;try{t=h(o.path,"utf8")}catch{return"invalid"}if(t.trim().length===0)return"absent";const{errors:e,value:r}=b(t);return e.length>0||!f(r)?"invalid":w(r,o.key,o.name)===void 0?"absent":"present"},fo=o=>C(o)==="present",E=(o,t,e,r,a)=>{try{const n=X(o,[e,r],a,mo);n.length>0&&x(t,Y(o,n));return}catch(n){return n instanceof Error?n.message:String(n)}},go=o=>{const{entry:t,force:e=!1,key:r,name:a,path:n}=o,i=p(n)?h(n,"utf8"):"";if(i.trim().length===0)return P(q(n),{recursive:!0}),x(n,`${JSON.stringify({[r]:{[a]:t}},void 0,4)}
|
|
2
2
|
`),{action:"created",path:n};const{errors:l,value:c}=b(i);if(l.length>0)return{action:"invalid",error:`parse error at offset ${String(l[0]?.offset??0)}`,path:n};if(!f(c))return{action:"invalid",error:"the file's root is not a JSON object",path:n};const m=c[r];if(m!==void 0&&!f(m))return{action:"invalid",error:`"${r}" is not an object`,path:n};if(w(c,r,a)!==void 0&&!e)return{action:"skipped",path:n};const j=E(i,n,r,a,t);return j===void 0?{action:"updated",path:n}:{action:"invalid",error:j,path:n}},ho=o=>{const{key:t,name:e,path:r}=o;if(!p(r))return{action:"absent",path:r};let a;try{a=h(r,"utf8")}catch(c){return{action:"invalid",error:c instanceof Error?c.message:String(c),path:r}}const{errors:n,value:i}=b(a);if(n.length>0)return{action:"invalid",error:`parse error at offset ${String(n[0]?.offset??0)}`,path:r};if(w(i,t,e)===void 0)return{action:"absent",path:r};const l=E(a,r,t,e,void 0);return l===void 0?{action:"removed",path:r}:{action:"invalid",error:l,path:r}},vo=["global","project"],d=(o,t)=>{const e=G(t,o);return e.length>0&&!e.startsWith("..")?e:o},yo=(o,t)=>{const e=o.paths(t);return vo.flatMap(r=>{const a=e[r];return a===void 0?[]:[{client:o,path:a,scope:r}]})},$o=(o,t,e,r)=>{const a=o.paths(t),n=e==="global"?"project":"global",i=a[e]??(r?void 0:a[n]);if(i!==void 0)return{client:o,path:i,scope:a[e]===void 0?n:e}},bo=o=>g.filter(t=>Object.values(t.paths(o)).some(e=>p(e))),R=(o,t,e,r)=>{if(o.length===0)return t();const a=[];for(const n of o){const i=uo(n);if(i===void 0){e.error(`mcp ${r}: unknown client "${n}". Known clients: ${O.join(", ")}.`);return}a.push(i)}return a},wo=o=>o.client.format==="json",jo="https://lunora.sh/mcp",U="lunora-docs",N="lunora",ko=o=>p(s(o,"lunora"))&&K(o)!==void 0,So=o=>{const{args:t,command:e}=Z(o,"lunora",["mcp","serve"]);return{args:t,command:e,transport:"stdio"}},Oo=o=>({transport:"http",url:o}),xo=o=>({home:o.home,platform:o.platform,projectRoot:o.cwd}),_=(o,t,e)=>$o(o,xo(e),e.scope??t.preferredScope,e.scope!==void 0||!t.allowScopeFallback),Co=(o,t,e)=>{const r=_(o,t,e);if(r===void 0){e.logger.warn(`${o.label}: has no ${e.scope??t.preferredScope}-scoped config — skipped "${t.name}".`);return}const{path:a}=r,n=o.buildEntry(t.spec);if(e.print===!0){const c=d(a,e.cwd);return e.force!==!0&&fo({key:o.key,name:t.name,path:a})?(e.logger.info(`${o.label}: "${t.name}" already configured in ${c} — a real install would skip it (re-run with --force to replace).`),{action:"printed",path:a}):(e.logger.info(`${o.label} → ${c}
|
|
3
3
|
${JSON.stringify({[o.key]:{[t.name]:n}},void 0,4)}`),{action:"printed",path:a})}const i=go({entry:n,force:e.force===!0,key:o.key,name:t.name,path:a}),l=d(a,e.cwd);return i.action==="invalid"?e.logger.error(`${o.label}: ${l} is not valid JSON (${i.error??"unknown error"}) — left untouched.`):i.action==="skipped"?e.logger.info(`${o.label}: "${t.name}" already configured in ${l} — re-run with --force to replace it.`):e.logger.success(`${o.label}: ${i.action==="created"?"created":"updated"} ${l} with "${t.name}".`),{action:i.action,path:a}},Eo=(o,t,e)=>{const r=_(o,t,e)?.path;if(r===void 0){e.logger.warn(`${o.label}: no known config location on ${e.platform} — skipped.`);return}return e.logger.info(`${o.label}: add this to ${d(r,e.cwd)}
|
|
4
4
|
|