@lunora/cli 1.0.0-alpha.215 → 1.0.0-alpha.217
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 +36 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/handler.mjs +1 -1
- package/dist/packem_chunks/handler10.mjs +1 -4
- package/dist/packem_chunks/handler11.mjs +4 -2
- package/dist/packem_chunks/handler12.mjs +2 -1
- package/dist/packem_chunks/handler13.mjs +1 -1
- package/dist/packem_chunks/handler14.mjs +1 -1
- package/dist/packem_chunks/handler15.mjs +1 -1
- package/dist/packem_chunks/handler16.mjs +1 -3
- package/dist/packem_chunks/handler17.mjs +3 -1
- package/dist/packem_chunks/handler18.mjs +1 -1
- package/dist/packem_chunks/handler19.mjs +1 -7
- package/dist/packem_chunks/handler2.mjs +1 -2
- package/dist/packem_chunks/handler20.mjs +7 -1
- package/dist/packem_chunks/handler21.mjs +1 -2
- package/dist/packem_chunks/handler22.mjs +2 -3
- package/dist/packem_chunks/handler23.mjs +3 -3
- package/dist/packem_chunks/handler24.mjs +3 -1
- package/dist/packem_chunks/handler25.mjs +1 -99
- package/dist/packem_chunks/handler26.mjs +99 -10
- package/dist/packem_chunks/handler27.mjs +10 -0
- package/dist/packem_chunks/handler3.mjs +2 -1
- package/dist/packem_chunks/handler4.mjs +1 -1
- package/dist/packem_chunks/handler5.mjs +1 -1
- package/dist/packem_chunks/handler6.mjs +1 -1
- package/dist/packem_chunks/handler7.mjs +1 -3
- package/dist/packem_chunks/handler8.mjs +3 -1
- package/dist/packem_chunks/handler9.mjs +1 -1
- package/dist/packem_chunks/planDevCommand.mjs +1 -1
- package/dist/packem_chunks/runCodegenCommand.mjs +2 -2
- package/dist/packem_chunks/runInitCommand.mjs +38 -38
- package/dist/packem_chunks/runMigrateGenerateCommand.mjs +6 -6
- package/dist/packem_chunks/runRpcCommand.mjs +1 -1
- package/dist/packem_shared/{COMMANDS-BuKOBthp.mjs → COMMANDS-Cf45cyJN.mjs} +1 -1
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-CYq3UJmD.mjs +1 -0
- package/dist/packem_shared/admin-token-VdUnvnKW.mjs +1 -0
- package/dist/packem_shared/admin-url-BhF5ufg1.mjs +1 -0
- package/dist/packem_shared/buildRegistryIndex-BcJgAx76.mjs +1 -0
- package/dist/packem_shared/catalog-CJaormx0.mjs +1 -0
- package/dist/packem_shared/cli-CqNvbTR1.mjs +3 -0
- package/dist/packem_shared/commands-YfMX-Mto.mjs +19 -0
- package/dist/packem_shared/diffSnapshots-Cnoe8Ob4.mjs +5 -0
- package/dist/packem_shared/{import-CdHdZRjj.mjs → import-8FCB0cUX.mjs} +10 -10
- package/dist/packem_shared/platform-diagnostics-D0YzAdXm.mjs +4 -0
- package/dist/packem_shared/runAddCommand-vE21wRIK.mjs +1 -0
- package/dist/packem_shared/runDeployCommand-o64lz-UD.mjs +1 -0
- package/dist/packem_shared/runExportCommand-Dq-SpjAe.mjs +5 -0
- package/dist/packem_shared/schema-drift-gate-BDCkQ1S6.mjs +1 -0
- package/dist/packem_shared/schemaIrToSnapshot-ogkcpHjM.mjs +1 -0
- package/dist/packem_shared/{storage-wIUel5Az.mjs → storage-D5s4vbtJ.mjs} +1 -1
- package/package.json +11 -11
- package/dist/packem_chunks/runDeployCommand.mjs +0 -1
- package/dist/packem_shared/DEFAULT_IMPORT_BATCH_SIZE-Cf8ZymM1.mjs +0 -1
- package/dist/packem_shared/admin-token-rxXZbVMZ.mjs +0 -1
- package/dist/packem_shared/admin-url-Cil3Or6N.mjs +0 -1
- package/dist/packem_shared/buildRegistryIndex-Zi3bBqpc.mjs +0 -1
- package/dist/packem_shared/cli-CiD-rkxB.mjs +0 -3
- package/dist/packem_shared/commands-BNKj7r1R.mjs +0 -19
- package/dist/packem_shared/diffSnapshots-CIOFQN_a.mjs +0 -5
- package/dist/packem_shared/platform-diagnostics-uOXqysk3.mjs +0 -4
- package/dist/packem_shared/runAddCommand-D1Dj8-pK.mjs +0 -1
- package/dist/packem_shared/runExportCommand-DmXKEWSq.mjs +0 -5
- package/dist/packem_shared/schema-drift-gate-Bt_plRtS.mjs +0 -1
- package/dist/packem_shared/schemaIrToSnapshot-qpRoV7HY.mjs +0 -1
package/dist/bin.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{r as e}from"./packem_shared/cli-
|
|
2
|
+
import{r as e}from"./packem_shared/cli-CqNvbTR1.mjs";try{const r=await e();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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodegenOptions, Finding, SchemaIR } from '@lunora/codegen';
|
|
1
|
+
import { CodegenOptions, Finding, FieldSnapshot, SchemaIR } from '@lunora/codegen';
|
|
2
2
|
import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, LintTool, LintIgnoreOutcome, PackageManager, PackageManagerProbe } from '@lunora/config';
|
|
3
3
|
import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
|
|
4
4
|
export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config/cloudflare';
|
|
@@ -440,6 +440,12 @@ interface DeployCommandOptions {
|
|
|
440
440
|
allowSchemaDrift?: boolean;
|
|
441
441
|
/** Which API spec(s) codegen emits. Defaults to codegen's `"openapi"` when omitted. */
|
|
442
442
|
apiSpec?: ApiSpec;
|
|
443
|
+
/**
|
|
444
|
+
* The command the operator actually ran. `build` delegates here with
|
|
445
|
+
* `dryRun: true`; without this the gate names the wrong command in its
|
|
446
|
+
* blocked message and offers flags the real caller does not accept.
|
|
447
|
+
*/
|
|
448
|
+
commandName?: PreDeployCommand;
|
|
443
449
|
cwd?: string;
|
|
444
450
|
/** Docker-availability probe injected in tests. Defaults to a real `docker info` check. */
|
|
445
451
|
dockerAvailable?: DockerProbe;
|
|
@@ -613,6 +619,21 @@ interface DeployCommandResult {
|
|
|
613
619
|
wranglerPath: string | undefined;
|
|
614
620
|
};
|
|
615
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* The commands that run the pre-deploy pipeline, as the OPERATOR typed them.
|
|
624
|
+
*
|
|
625
|
+
* These checks are reached from `lunora deploy`, `lunora prepare` and
|
|
626
|
+
* `lunora build`, and a blocked run naming a command the operator never ran
|
|
627
|
+
* reads as a bug in the tool rather than a problem in the project.
|
|
628
|
+
*
|
|
629
|
+
* `build` is one of them: it delegates to `runDeployCommand({ dryRun: true })`.
|
|
630
|
+
* The name is threaded through rather than assumed, because the drift gate uses
|
|
631
|
+
* it for two operator-facing decisions — which override flags to offer, and what
|
|
632
|
+
* to call the thing that was blocked. Hardcoding `"deploy"` here meant `lunora
|
|
633
|
+
* build` reported "deploy blocked" for a deploy nobody attempted and recommended
|
|
634
|
+
* a flag `build` rejects with a raw stack trace.
|
|
635
|
+
*/
|
|
636
|
+
type PreDeployCommand = "build" | "deploy" | "prepare";
|
|
616
637
|
/**
|
|
617
638
|
* Run a deploy, then (in `--format json` mode) serialize the structured
|
|
618
639
|
* {@link DeployCommandResult} to stdout. Human/progress logging is routed to
|
|
@@ -1294,6 +1315,20 @@ interface TableSnapshot {
|
|
|
1294
1315
|
name: string;
|
|
1295
1316
|
}
|
|
1296
1317
|
interface ColumnSnapshot {
|
|
1318
|
+
/**
|
|
1319
|
+
* The column's full validator shape — the SAME {@link FieldSnapshot} the
|
|
1320
|
+
* deploy gate diffs (`shared/schema-snapshot.ts`), not a second parallel
|
|
1321
|
+
* format.
|
|
1322
|
+
*
|
|
1323
|
+
* `sqlType` alone is lossy: `bigint`, `array`, `record`, `id`, `literal` and
|
|
1324
|
+
* `string` all map to the TEXT affinity, so `v.string()` → `v.bigint()` was
|
|
1325
|
+
* byte-identical here and `migrate generate` answered "no schema changes
|
|
1326
|
+
* detected" for a change `lunora prepare` blocks as breaking.
|
|
1327
|
+
*
|
|
1328
|
+
* Optional so a `.snapshot.json` written before this existed still parses —
|
|
1329
|
+
* it simply gets no deep check until the next generate rewrites it.
|
|
1330
|
+
*/
|
|
1331
|
+
field?: FieldSnapshot;
|
|
1297
1332
|
/** True when the column accepts NULL (validator wrapped in v.optional). */
|
|
1298
1333
|
nullable: boolean;
|
|
1299
1334
|
/** SQLite type affinity, derived from the validator. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodegenOptions, Finding, SchemaIR } from '@lunora/codegen';
|
|
1
|
+
import { CodegenOptions, Finding, FieldSnapshot, SchemaIR } from '@lunora/codegen';
|
|
2
2
|
import { ensureDevVariables, ensureDevVarsExample, fillDevSecrets, LintTool, LintIgnoreOutcome, PackageManager, PackageManagerProbe } from '@lunora/config';
|
|
3
3
|
import { materializeRemoteWranglerConfig } from '@lunora/config/cloudflare';
|
|
4
4
|
export { REQUIRED_COMPATIBILITY_DATE, REQUIRED_FLAG, type WranglerProjectValidationOptions as WranglerValidationOptions, type WranglerValidationReport, type WranglerProjectValidationResult as WranglerValidationResult, validateWranglerProject as validateWrangler, validateWranglerConfig } from '@lunora/config/cloudflare';
|
|
@@ -440,6 +440,12 @@ interface DeployCommandOptions {
|
|
|
440
440
|
allowSchemaDrift?: boolean;
|
|
441
441
|
/** Which API spec(s) codegen emits. Defaults to codegen's `"openapi"` when omitted. */
|
|
442
442
|
apiSpec?: ApiSpec;
|
|
443
|
+
/**
|
|
444
|
+
* The command the operator actually ran. `build` delegates here with
|
|
445
|
+
* `dryRun: true`; without this the gate names the wrong command in its
|
|
446
|
+
* blocked message and offers flags the real caller does not accept.
|
|
447
|
+
*/
|
|
448
|
+
commandName?: PreDeployCommand;
|
|
443
449
|
cwd?: string;
|
|
444
450
|
/** Docker-availability probe injected in tests. Defaults to a real `docker info` check. */
|
|
445
451
|
dockerAvailable?: DockerProbe;
|
|
@@ -613,6 +619,21 @@ interface DeployCommandResult {
|
|
|
613
619
|
wranglerPath: string | undefined;
|
|
614
620
|
};
|
|
615
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* The commands that run the pre-deploy pipeline, as the OPERATOR typed them.
|
|
624
|
+
*
|
|
625
|
+
* These checks are reached from `lunora deploy`, `lunora prepare` and
|
|
626
|
+
* `lunora build`, and a blocked run naming a command the operator never ran
|
|
627
|
+
* reads as a bug in the tool rather than a problem in the project.
|
|
628
|
+
*
|
|
629
|
+
* `build` is one of them: it delegates to `runDeployCommand({ dryRun: true })`.
|
|
630
|
+
* The name is threaded through rather than assumed, because the drift gate uses
|
|
631
|
+
* it for two operator-facing decisions — which override flags to offer, and what
|
|
632
|
+
* to call the thing that was blocked. Hardcoding `"deploy"` here meant `lunora
|
|
633
|
+
* build` reported "deploy blocked" for a deploy nobody attempted and recommended
|
|
634
|
+
* a flag `build` rejects with a raw stack trace.
|
|
635
|
+
*/
|
|
636
|
+
type PreDeployCommand = "build" | "deploy" | "prepare";
|
|
616
637
|
/**
|
|
617
638
|
* Run a deploy, then (in `--format json` mode) serialize the structured
|
|
618
639
|
* {@link DeployCommandResult} to stdout. Human/progress logging is routed to
|
|
@@ -1294,6 +1315,20 @@ interface TableSnapshot {
|
|
|
1294
1315
|
name: string;
|
|
1295
1316
|
}
|
|
1296
1317
|
interface ColumnSnapshot {
|
|
1318
|
+
/**
|
|
1319
|
+
* The column's full validator shape — the SAME {@link FieldSnapshot} the
|
|
1320
|
+
* deploy gate diffs (`shared/schema-snapshot.ts`), not a second parallel
|
|
1321
|
+
* format.
|
|
1322
|
+
*
|
|
1323
|
+
* `sqlType` alone is lossy: `bigint`, `array`, `record`, `id`, `literal` and
|
|
1324
|
+
* `string` all map to the TEXT affinity, so `v.string()` → `v.bigint()` was
|
|
1325
|
+
* byte-identical here and `migrate generate` answered "no schema changes
|
|
1326
|
+
* detected" for a change `lunora prepare` blocks as breaking.
|
|
1327
|
+
*
|
|
1328
|
+
* Optional so a `.snapshot.json` written before this existed still parses —
|
|
1329
|
+
* it simply gets no deep check until the next generate rewrites it.
|
|
1330
|
+
*/
|
|
1331
|
+
field?: FieldSnapshot;
|
|
1297
1332
|
/** True when the column accepts NULL (validator wrapped in v.optional). */
|
|
1298
1333
|
nullable: boolean;
|
|
1299
1334
|
/** SQLite type affinity, derived from the validator. */
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as o,V as a,r as n}from"./packem_shared/cli-
|
|
1
|
+
import{C as o,V as a,r as n}from"./packem_shared/cli-CqNvbTR1.mjs";import{runCodegenCommand as t}from"./packem_chunks/runCodegenCommand.mjs";import{r as p}from"./packem_chunks/handler.mjs";import{planDevCommand as x,runDevCommand as s}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 R}from"./packem_chunks/runRpcCommand.mjs";import{insertSchemaExtension as E}from"./packem_shared/insertSchemaExtension-DY4pA8wE.mjs";import{createLogger as A,pail as c}from"./packem_shared/createLogger-hGafwf-3.mjs";import{diffSnapshots as v,renderAddColumn as _,renderCreateIndex as b,renderCreateTable as h,renderDropIndex as y,renderDropTable as L,renderMigrationFile as O,validatorKindToSqlType as w}from"./packem_shared/diffSnapshots-Cnoe8Ob4.mjs";import{default as F}from"./packem_shared/schemaIrToSnapshot-ogkcpHjM.mjs";import{createRecordingSpawner as U,defaultSpawner as V}from"./packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{default as G}from"./packem_shared/parseManifest-CwPTKdtS.mjs";import{D as Q,r as j}from"./packem_shared/import-8FCB0cUX.mjs";import{REQUIRED_COMPATIBILITY_DATE as H,REQUIRED_FLAG as K,validateWranglerProject as Y,validateWranglerConfig as Z}from"@lunora/config/cloudflare";import{b as z}from"./packem_shared/catalog-CJaormx0.mjs";import{r as X,a as $,b as rr}from"./packem_shared/commands-YfMX-Mto.mjs";import{runExportCommand as or}from"./packem_shared/runExportCommand-Dq-SpjAe.mjs";export{o as COMMANDS,Q 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,V as defaultSpawner,v as diffSnapshots,E as insertSchemaExtension,c as pail,G as parseManifest,x as planDevCommand,_ as renderAddColumn,b as renderCreateIndex,h as renderCreateTable,y as renderDropIndex,L as renderDropTable,O as renderMigrationFile,X as runAddCommand,$ as runBuildIndexCommand,n as runCli,t as runCodegenCommand,p as runDeployCommand,s as runDevCommand,or as runExportCommand,j as runImportCommand,C as runInitCommand,u as runMigrateGenerateCommand,rr as runRegistryViewCommand,g as runResetCommand,R as runRpcCommand,F as schemaIrToSnapshot,Y as validateWrangler,Z as validateWranglerConfig,w as validatorKindToSqlType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as k,readFileSync as T}from"node:fs";import{applyLintIgnores as N,detectLintTools as I}from"@lunora/config";import{findWranglerFile as A}from"@lunora/config/cloudflare";import{join as v,basename as g}from"@visulima/path";import{d as D}from"../packem_shared/command-DwC11Cwe.mjs";import{r as S}from"../packem_shared/lint-ignore-report-DKZagpqk.mjs";import{v as U,l as L,i as M,p as _}from"../packem_shared/output-format-DfogXx0p.mjs";import{t as w,a as F}from"../packem_shared/tui-prompts-Dd0pDuNr.mjs";import{n as O,i as E,E as P,s as j,d as l,p,r as f,M as R,a as $,b as h,c as x,D as o,e as B,f as z,g as d,A as H,h as C,w as J,j as W,k as q}from"../packem_shared/storage-wIUel5Az.mjs";import{r as V}from"../packem_shared/commands-BNKj7r1R.mjs";const G=e=>{const r=e.trim().toLowerCase();return C.find(a=>a.value===r||a.label.toLowerCase()===r||r==="auth0"&&a.value==="auth-auth0"||r==="clerk"&&a.value==="auth-clerk")?.value},y=e=>{try{const r=JSON.parse(T(v(e,"package.json"),"utf8"));return{...r.dependencies,...r.devDependencies}}catch{return{}}},K=async e=>{const r=e.cwd??process.cwd(),t=z(y(r));return t!==void 0?t:e.yes===!0?(e.logger.warn(`add: couldn't detect your framework — using "${d}". Pass a specific item (e.g. \`lunora add auth-ui-vue\`) to override.`),d):await(e.promptSelect??((s,i,n)=>w(s,i,n)))("Which framework is your app?",H,{default:d})??d},Q=async e=>{if(e.provider!==void 0&&e.provider!==""){const t=G(e.provider);return t===void 0?(e.logger.warn(`add: unknown --provider "${e.provider}" — using "${o}" (email & password).`),o):t}if(e.yes===!0)return o;const r=e.promptSelect??((t,a,s)=>w(t,a,s));return B(r)},m=e=>e.promptText??((r,t)=>F(r,t)),X=async e=>{const r=g(e.cwd??process.cwd());if(e.bucket!==void 0&&e.bucket!==""){const t=j(e.bucket);if(t!==void 0)return t;const a=l(r);return e.logger.warn(`add: "${e.bucket}" isn't a valid R2 bucket name (lowercase alphanumeric + hyphens, 3–63 chars) — using "${a}".`),a}return e.yes===!0?l(r):p(m(e),r)},Y=async e=>{const r=t=>{e.logger.warn(`add: ${t}`)};if(e.mailTo!==void 0&&e.mailTo!=="")return f(e.mailTo,r);if(e.yes!==!0)return f(await m(e)(R,{placeholder:"you@yourdomain.com"}),r)},Z=async e=>{const r=g(e.cwd??process.cwd());if(e.db!==void 0&&e.db!==""){const t=$(e.db);if(t!==void 0)return t;const a=h(r);return e.logger.warn(`add: "${e.db}" isn't a usable D1 database name — using "${a}".`),a}return e.yes===!0?h(r):x(m(e),r)},ee=async(e,r)=>e.kind==="auth"?[await Q(r)]:e.kind==="auth-ui"?[await K(r)]:e.kind==="email"?[P]:[e.item],re=(e,r)=>{S(N(e,I(e)),r)},ae=async e=>{const r=e.cwd??process.cwd(),t=e.feature===void 0?void 0:O(e.feature);if(t===void 0)return e.logger.error("add requires a feature or registry item. Usage: lunora add <auth|email|storage|crons|presence|…>"),{code:1,items:[]};if(!k(v(r,"lunora"))||A(r)===void 0)return e.logger.error("add: not a Lunora project here (need a lunora/ directory and a wrangler.jsonc). Run `lunora init` first."),{code:1,items:[]};if(t.kind==="auth-ui"&&E(y(r)))return e.logger.error("add: auth-ui has no React Native port — the screens render DOM elements and a stylesheet, which Metro has nothing to mount. Build the screens with React Native primitives against the same better-auth client (`@lunora/react-native/auth`); `lunora add auth` still installs the server half."),{code:1,items:[]};const a=await ee(t,e),s=[];if(a.includes("storage")){const c=await X(e);s.push(u=>J(u,c))}if(a.includes("mail")){const c=await Y(e);c!==void 0&&s.push(u=>W(u,c))}if(a.some(c=>c==="auth"||c.startsWith("auth-"))){const c=await Z(e);s.push(u=>q(u,c))}const i=s.length>0?c=>{let u=c;for(const b of s)u=b(u);return u}:void 0,n=await V({allowUnsafeSource:e.allowUnsafeSource,cwd:r,from:e.from,logger:e.logger,names:[...a],ref:e.ref,source:e.source,transformManifest:i,yes:!0});return n.code===0&&re(r,e.logger),{code:n.code,items:a}},fe=D(async({argument:e,cwd:r,logger:t,options:a})=>{const s=U("add",a.format);if(s!==void 0)return t.error(s),{code:1};const i=L(a.format,t),n=await ae({allowUnsafeSource:a.allowUnsafeSource===!0,bucket:a.bucket,cwd:r,db:a.db,feature:e[0],from:a.from,logger:i,mailTo:a.mailTo,provider:a.provider,ref:a.ref,source:a.source,yes:a.yes===!0});return M(a.format)&&_({code:n.code,items:n.items}),{code:n.code}});export{fe as execute,ae as runAddFeature};
|
|
1
|
+
import{readFileSync as w,writeFileSync as O,existsSync as y}from"node:fs";import{runCodegen as H,discoverMigrations as W}from"@lunora/codegen";import{readLinkedProject as N,writeLinkedProject as M,execArgsFor as k,detectPackageManager as b,discoverContainerInfo as L,DEV_VARS_FILE as v,parseDevVariableEntries as T,isMintableSecretKey as E,runPostCodegenHook as B,resolveDeployDriver as D,inferLunoraBindings as _,packageNamesFromBindings as V,requiredSecrets as K,generateSecretValue as q,upsertDevVariableLine as Y,writeDevVariablesFileAtomically as G,discoverSchemaInfo as z}from"@lunora/config";import{findWranglerFile as j,validateWranglerProject as J,reconcileWranglerBindings as Q,reconcileWranglerCompatibilityDate as X,reconcileWranglerCrons as Z,readWranglerJsonc as ee}from"@lunora/config/cloudflare";import{join as h}from"@visulima/path";import{Spinner as re}from"@visulima/spinner";import{Project as te}from"ts-morph";import{i as ae,m as ne,e as oe}from"../packem_shared/vectorize-metadata-DbziRKpX.mjs";import{r as ie,e as se}from"../packem_shared/advisory-gate-Cl8IEFIj.mjs";import{p as ce,a as le}from"../packem_shared/deploy-target-B0Xcb2jV.mjs";import{r as R}from"../packem_shared/wrangler-name-Dsk5K1f-.mjs";import{d as de}from"../packem_shared/command-DwC11Cwe.mjs";import{a as ue,i as ge}from"../packem_shared/docker-DpVxvYpL.mjs";import{r as me,p as fe,H as he,a as ve}from"../packem_shared/schema-drift-gate-BDCkQ1S6.mjs";import{v as ye,l as pe,i as $,p as we}from"../packem_shared/output-format-DfogXx0p.mjs";import{r as ke}from"../packem_shared/platform-diagnostics-D0YzAdXm.mjs";import{containerBuildTag as be}from"@lunora/container";import{defaultSpawner as S}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{a as I}from"../packem_shared/resolve-target-BRvw8Pf7.mjs";import{c as $e}from"../packem_shared/tui-prompts-Dd0pDuNr.mjs";import{l as Se}from"../packem_shared/wrangler-secrets-CCdt0mUl.mjs";import{runMigrateDataCommand as De}from"./runMigrateGenerateCommand.mjs";const Re=/https?:\/\/[^\s"'<>]+\.workers\.dev[^\s"'<>]*/u,Ce=/https:\/\/[^\s"'<>]+/u,Ae=e=>{if(e===void 0)return;const r=Re.exec(e);return r?r[0]:Ce.exec(e)?.[0]},P=e=>e===void 0?"":` (--env ${e})`,Ee=({cwd:e,env:r,logger:a,now:t,url:n})=>{if(n!==void 0)try{const o=N(e);if(o!==void 0){if(o.workerUrl===n&&o.env===r)return;a.warn(`link: .lunora/project.json records ${o.workerUrl??"(no url)"}${P(o.env)}, but this deploy published ${n}${P(r)}. Keeping the recorded value — run \`lunora link --url ${n}${r===void 0?"":` --env ${r}`}\` to update it.`);return}const i=(t??(()=>new Date().toISOString()))();M(e,{env:r,linkedAt:i,workerName:R(e),workerUrl:n}),a.success(`link: recorded ${n} in .lunora/project.json (run \`lunora link\` to change)`)}catch{}},Pe=e=>{const{cwd:r,env:a,logger:t,mintedSecretsFile:n}=e;try{const o=N(r),i=o?.workerName??R(r),s=e.url??o?.workerUrl;t.success("deploy complete"),t.info(` worker: ${i??"(see wrangler output above)"}`),a!==void 0&&t.info(` env: ${a}`),s===void 0?t.info(" url: run `lunora link --url <https://your-worker>` to record it"):t.info(` url: ${s}`),n!==void 0&&t.info(` secrets: generated value(s) recorded in ${n}`),t.info(" studio: lunora view --remote"),t.info(" logs: lunora logs")}catch{}},xe=async e=>{if(e.targets.length===0)return{builtTags:[],code:0};if(!(e.railpackAvailable??ue)()){const t="deploy blocked: a container uses `image: { build }` (Railpack), but Railpack isn't ready. Install the `railpack` CLI and start a BuildKit instance, e.g. `docker run --rm --privileged -d --name buildkit moby/buildkit` then `export BUILDKIT_HOST=docker-container://buildkit`. Alternatively switch the container's `image` to a Dockerfile path or a pre-built registry reference.";return e.logger.error(t),{builtTags:[],code:1,error:t}}const r=e.spawner??S,a=[];for(const t of e.targets){const n=be(t.exportName),o={args:["build",t.buildDir,"--name",n],command:"railpack",cwd:e.cwd},i=k(b(e.cwd),"wrangler",["containers","push",n]),s={args:i.args,command:i.command,cwd:e.cwd};e.logger.info(`railpack: building "${t.exportName}" → ${n} from ${t.buildDir}`);const l=await r(o);if(l.code!==0){const c=`railpack build failed for container "${t.exportName}" (${t.buildDir})`;return e.logger.error(c),{builtTags:a,code:l.code,error:c}}e.logger.info(`railpack: pushing ${n} to the Cloudflare Registry`);const d=await r(s);if(d.code!==0){const c=`wrangler containers push failed for "${t.exportName}" (${n})`;return e.logger.error(c),{builtTags:a,code:d.code,error:c}}a.push(n)}return{builtTags:a,code:0}},Ne=e=>{const r=j(e),a=r===void 0?void 0:w(r,"utf8");return()=>{r!==void 0&&a!==void 0&&O(r,a,"utf8")}},U="<replace-with-d1-create-id>",C=e=>{const r=j(e);return r?ee(r).parsed:void 0},Le=["LUNORA_ORIGIN_URL","LUNORA_WORKER_ORIGIN","AUTH_URL"],Te=e=>{try{const{hostname:r}=new URL(e);return r==="localhost"||r==="127.0.0.1"||r==="::1"||r==="[::1]"}catch{return!1}},_e=e=>e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.includes("Dockerfile"),je=(e,r,a,t="deploy")=>{const n=(C(e)?.containers??[]).filter(i=>typeof i?.image=="string"&&_e(i.image));if(n.length===0||a())return;const o=`${t} blocked: wrangler.jsonc declares ${String(n.length)} container(s) built from a local Dockerfile, but no Docker-compatible engine is available. Start Docker (or Colima), or point the container's \`image\` at a pre-built registry reference. Note: container images must target linux/amd64.`;return r.error(o),o},Ie=e=>y(h(e,"src","worker.ts"))?"src/worker.ts":void 0,Ue=(e,r,a="deploy")=>{for(const t of L(e,"lunora").containers){const{image:n}=t;if(n.kind==="dockerfile"&&!y(h(e,n.dockerfilePath))){const o=`${a} blocked: container "${t.exportName}" references a Dockerfile at "${n.dockerfilePath}" that does not exist. Create it or fix the \`image\` path in lunora/containers.ts.`;return r.error(o),o}if(n.kind==="build"&&!y(h(e,n.buildDir))){const o=`${a} blocked: container "${t.exportName}" references a Railpack build directory "${n.buildDir}" that does not exist. Create it or fix the \`image.build\` path in lunora/containers.ts.`;return r.error(o),o}}},F=e=>$(e.format)?!1:e.interactive!==void 0?e.interactive:process.stdout.isTTY&&!process.env.CI,Fe=e=>(C(e)?.d1_databases??[]).find(r=>r.database_id===U)?.binding,Oe=async(e,r)=>{if(r.dryRun===!0)return;const a=L(e,"lunora").containers.filter(n=>n.image.kind==="build").map(n=>({buildDir:n.image.buildDir,exportName:n.exportName}));if(a.length===0)return;const t=await xe({cwd:e,logger:r.logger,railpackAvailable:r.railpackAvailable,spawner:r.spawner,targets:a});return t.code===0?void 0:t.error??"railpack build failed"},He=(e,r,a)=>{if(a!==void 0)try{const t=Z(e,a);t.changed&&r.success(`synced ${String(a.length)} cron trigger(s) → ${t.wranglerPath??"wrangler.jsonc"}`)}catch(t){const n=t instanceof Error?t.message:String(t);r.warn(`cron trigger sync skipped: ${n}`)}},We=async(e,r,a,t,n)=>{try{D(t);const o=await _({projectRoot:e}),i=Q(e,o,n);i.changed&&r.success(`provisioned bindings: ${i.added.join(", ")} → ${i.wranglerPath??"wrangler.jsonc"}`);for(const s of i.warnings)r.warn(s)}catch(o){const i=o instanceof Error?o.message:String(o);r.warn(`binding inference skipped: ${i}`)}try{const o=X(e);o.changed&&r.success(`bumped compatibility_date to ${o.date??"unknown"} (Workers Cache enabled) → ${o.wranglerPath??"wrangler.jsonc"}`)}catch(o){const i=o instanceof Error?o.message:String(o);r.warn(`compatibility date sync skipped: ${i}`)}He(e,r,a)},Me=(e,r)=>{const a=h(e,v);if(!y(a))return;let t;try{t=T(w(a,"utf8")).length}catch{return}t!==0&&r.warn(`Note: \`lunora deploy\` does not push secrets. ${v} has ${String(t)} key(s); if you changed them, run \`lunora env push --yes\` to update the deployed secrets.`)},Be=async e=>{let r=[];try{r=V(await _({projectRoot:e}))}catch{}const a=K(r).map(n=>n.key);let t=[];try{const n=h(e,v);y(n)&&(t=T(w(n,"utf8")).map(o=>o.key).filter(o=>ae(o)))}catch{}return[...new Set([...a,...t])]},Ve=async(e,r,a,t)=>{const{logger:n}=r,o=r.spawner??S,i=b(e),s=r.env===void 0?"":` --env ${r.env}`,{toolchain:l}=D(t);if(l===void 0)return n.error("deploy target has no command-line toolchain; cannot push secrets"),{minted:[],ok:!1};const d=[];for(const c of a){const g=q(),u=l.secretPut({environment:r.env,key:c,temporary:r.temporary}),m=k(i,u.tool,u.args),f=await o({args:m.args,command:m.command,cwd:e,input:g});if(f.code!==0)return n.error(`failed to push secret ${c} (exit ${String(f.code)}); set it manually with \`wrangler secret put ${c}${s}\`.`),{minted:d,ok:!1};d.push({key:c,value:g}),n.success(`generated + pushed ${c}`)}return{minted:d,ok:!0}},Ke=/^[\w-]+$/u,qe=(e,r,a)=>{if(a.length===0)return;const t=a.map(s=>s.key).join(", ");if(r.env!==void 0&&!Ke.test(r.env)){r.logger.warn(`${t}: minted and pushed for --env ${r.env}, but "${r.env}" isn't a safe filename fragment — the value could not be recorded. Capture it manually if you need it again.`);return}const n=r.env===void 0?v:`${v}.${r.env}`,o=h(e,n);let i=y(o)?w(o,"utf8"):"";for(const s of a)i=Y(i,s.key,s.value);return G(o,i),r.logger.success(r.env===void 0?`${t}: value(s) recorded in ${n}`:`${t}: value(s) recorded in ${n} (kept separate from ${v} so \`lunora dev\` and a plain \`lunora env push\` don't inherit the --env ${r.env} value)`),n},Ye=async(e,r,a,t)=>{if(r.dryRun===!0||r.preview===!0)return{};const{logger:n}=r,o=r.env===void 0?"":` --env ${r.env}`;let i;try{i=await(r.secretLister??Se)({cwd:e,env:r.env,temporary:r.temporary})}catch{return{}}if(!i.ok)return{};const s=new Set(i.names),d=(await Be(e)).filter(u=>!s.has(u));if(d.length===0)return{};if(!a)return{error:`missing required secret(s) on the deploy target: ${d.join(", ")}. Set them with \`wrangler secret put <KEY>${o}\` (or \`lunora env generate --set\` then \`lunora env push --yes${o}\`), then re-deploy.`};for(const u of d.filter(m=>!E(m)))n.warn(`required secret ${u} is not set on the target — set it with: wrangler secret put ${u}${o}`);const c=d.filter(u=>E(u));if(c.length===0)return{};if(await(r.secretConfirm??$e())(`${String(c.length)} required secret(s) not set on the target (${c.join(", ")}). Generate strong values and push them now?`)){const{minted:u,ok:m}=await Ve(e,r,c,t),f=qe(e,r,u);return m?{mintedSecretsFile:f}:{error:"failed to push required secret(s) — set them manually and re-deploy",mintedSecretsFile:f}}return n.warn(`${String(c.length)} required secret(s) not set on the target: ${c.join(", ")}. Generate + push with \`lunora env generate --set\` then \`lunora env push --yes${o}\`.`),{}},Ge=async(e,r)=>{const a=new te({skipAddingFilesFromTsConfig:!0}),t=h(r,"lunora");let n;try{n=W(a,t)}catch(o){const i=o instanceof Error?o.message:String(o);return e.logger.warn(`--migrate: could not discover migrations (${i}); skipping`),0}if(n.length===0)return e.logger.info("--migrate: no data migrations declared in lunora/"),0;e.logger.info(`--migrate: running ${String(n.length)} migration(s) against deployed worker`);for(const o of n){e.logger.info(`--migrate: up "${o.id}" (table "${o.table}")`);const i={cwd:r,fetchImpl:e.fetchImpl,id:o.id,logger:e.logger,prod:!0,subcommand:"up",token:e.migrateToken,url:e.migrateUrl,yes:e.migrateYes===!0},s=await De(i);if(s.code!==0)return e.logger.error(`--migrate: migration "${o.id}" failed — see output above`),s.code;e.logger.success(`--migrate: "${o.id}" applied`)}return 0},ze=e=>{if(!e.migrate||e.dryRun||e.preview)return;if(e.migrateUrl===void 0){const a="--migrate requires --migrate-url <https://your-worker> — the deploy target URL is only known after wrangler runs, and this gate runs before it; refusing to default to localhost";return e.logger.error(a),a}if(e.migrateYes!==!0){const a="--migrate runs production data migrations after deploy. Re-run with --migrate-yes to confirm.";return e.logger.error(a),a}const r=e.migrateToken??process.env.LUNORA_ADMIN_TOKEN;if(r===void 0||r===""){const a="admin token required for --migrate — pass --migrate-token or set LUNORA_ADMIN_TOKEN";return e.logger.error(a),a}},Je=async(e,r,a,t,n,o,i,s)=>{let l;r?(l=new re({name:"dots"}),l.start("running codegen")):a.info("running codegen");try{const d=H({apiSpec:t,projectRoot:e,target:n});l?.succeed("codegen complete"),l||a.success("codegen complete");const c=ke(d.platformDiagnostics,a);if(c.errors.length>0)return{error:c.errors.join("; ")};const{errorAdvisories:g,names:u,shouldBlock:m}=se(d.advisories,s);if(m){const A=`${g.length.toString()} ERROR-level ${g.length===1?"advisory":"advisories"} (${u.join(", ")}). Pass --no-strict-advisories to downgrade this to a warning and deploy anyway.`;return a.error(A),{error:A}}const f=await B({cwd:e,logger:a,spawner:o,stdoutToStderr:i});return f.error!==void 0?{error:f.error}:{result:d}}catch(d){l?.failed("codegen failed");const c=d instanceof Error?d.message:String(d);return a.error(`codegen failed: ${c}`),{error:`codegen failed: ${c}`}}},Qe=(e,r,a="deploy")=>{const t=Fe(e);if(t===void 0)return;const n=`${a} blocked: the "${t}" D1 binding has a placeholder database_id ("${U}"). Run \`wrangler d1 create <name>\` to create the database, then replace the placeholder in wrangler.jsonc with the real id before deploying.`;return r.error(n),n},Xe=(e,r,a="deploy")=>{const t=C(e)?.vars;if(!t)return;const n=Le.filter(i=>typeof t[i]=="string"&&Te(t[i]));if(n.length===0)return;const o=`${a} blocked: ${n.join(", ")} in wrangler.jsonc point at localhost. A deployed Worker can't reach a loopback address, so this silently breaks scheduled-job dispatch / auth callbacks. Set each to the deployed worker's public URL (or move it to a secret with \`wrangler secret put\`) before deploying.`;return r.error(o),o},Ze=async(e,r)=>{const{info:a}=z(r,"lunora"),t=a?.vectorMetadata??[];if(t.length===0)return;const n=[];for(const s of t){const l=ne(s.kind);if(l===void 0){e.logger.warn(`vector index "${s.index}" declares metadata "${s.property}", whose column type cannot be filtered on in Vectorize — it is stored with each vector but no filter will match it.`);continue}n.push({index:s.index,property:s.property,type:l})}if(n.length===0)return;const i=(await oe({cwd:r,entries:n,exec:k(b(r),"wrangler",[]),logger:e.logger,spawner:e.spawner??S})).filter(s=>s.status!=="failed").length;i>0&&e.logger.success(`vectorize metadata indexes ready: ${String(i)}/${String(n.length)}`)},x=5,er=2e3,rr=async(e,r,a)=>{if(e.healthCheck!==!0)return;const t=a??I({cwd:r,env:e.env});if(t===void 0){const o="--health-check: the deploy succeeded, but no URL to probe could be resolved — wrangler's output carried none and this checkout has no link for this environment. Run `lunora link --url <https://your-worker>` and re-deploy, or drop --health-check.";return e.logger.error(o),{error:o,ok:!1,url:""}}const n=await fe({attempts:x,baseUrl:t,delayMs:er,fetchImpl:e.healthFetch,paths:[he,ve],sleep:e.healthSleep});return n.error===void 0?(e.logger.success(`health check ok (${n.url})`),{ok:!0,url:n.url}):(e.logger.error(`--health-check: the deploy succeeded, but the new version did not answer after ${String(x)} attempt(s) — ${n.error}`),{error:n.error,ok:!1,url:n.url})},tr=async(e,r,a,t,n,o)=>{await Ze(e,r);const i=e.migrate?await Ge(e,r):0;return i===0&&n?.(),{code:i,descriptor:a,mintedSecretsFile:o,validation:t}},ar=(e,r,a)=>{const t=Qe(e,r.logger,a);if(t!==void 0)return t;const n=Xe(e,r.logger,a);if(n!==void 0)return n;const o=Ue(e,r.logger,a);return o!==void 0?o:je(e,r.logger,r.dockerAvailable??ge,a)},nr=(e,r,a)=>{const t=Ie(e);t!==void 0&&r.logger.info(`class-B composition: deploying ${t} (overrides wrangler main)`),r.temporary&&r.logger.info("temporary account: deploying to a short-lived Cloudflare account (~60min); wrangler will print a claim URL"),r.dryRun&&r.logger.info("dry run: validating + bundling without publishing"),r.outDir!==void 0&&r.logger.info(`build artifact: emitting bundle to ${r.outDir}`);const n=D(a),o={dryRun:r.dryRun,entry:t,environment:r.env,outDir:r.outDir,preview:r.preview,temporary:r.temporary};if(n.toolchain===void 0)throw new Error(`deploy target "${n.id}" has no command-line toolchain`);return n.toolchain.deploy(o)},p=(e,r)=>({code:1,descriptor:void 0,error:e,validation:{problems:[],wranglerPath:void 0},...r}),or=(e,r)=>{if(e.problems.length===0)return!1;r.error("wrangler.jsonc validation failed:");for(const a of e.problems)r.error(` - ${a}`);return!0},ir=(e,r,a)=>{const t=$(r.format),n=r.dryRun!==!0,o=nr(e,r,a),i=k(b(e),o.tool,o.args);return{args:i.args,captureStdout:n&&!t,captureStdoutSilently:n&&t,command:i.command,cwd:e,stdoutToStderr:t&&!n}},sr=async({cwd:e,descriptor:r,mintedSecretsFile:a,options:t,reblessSchemaBaseline:n,stdout:o,validation:i})=>{const s={deployedAt:new Date().toISOString(),dryRun:t.dryRun===!0,env:t.env,preview:t.preview===!0,url:t.dryRun===!0?void 0:Ae(o),workerName:R(e)};if(t.dryRun===!0||t.preview===!0)return t.healthCheck===!0&&t.logger.warn(`--health-check skipped: ${t.dryRun===!0?"a dry run publishes nothing":"a preview version serves no live traffic"}`),{code:0,deployment:s,descriptor:r,mintedSecretsFile:a,validation:i};t.temporary!==!0&&Ee({cwd:e,env:t.env,logger:t.logger,url:s.url});const l=await rr(t,e,s.url);return l?.error!==void 0?{code:1,deployment:s,descriptor:r,healthCheck:l,mintedSecretsFile:a,validation:i}:{...await tr(t,e,r,i,n,a),deployment:s,healthCheck:l}},cr=async(e,r)=>{const a=e.cwd??process.cwd(),t=F(e),n=ie(e),o={problems:[],wranglerPath:void 0},i=le(a,e.target);if(i.target===void 0){const u=i.error??"unknown deploy target";return e.logger.error(u),{error:u,validation:o}}const{target:s}=i;let l;if(!e.skipCodegen){const u=await Je(a,t,e.logger,e.apiSpec,s,e.spawner,$(e.format),n);if(u.error!==void 0)return{error:u.error,target:s,validation:o};l=u.result}let d;if(l!==void 0){const u=me({allowDrift:e.allowSchemaDrift===!0,codegen:l,command:r,logger:e.logger,updateBaseline:e.updateSchemaBaseline===!0});if(u.blocked)return{error:`schema drift gate blocked ${r}`,schemaDrift:{blocked:!0,reason:u.reason},target:s,validation:o};d=u.rebless}await We(a,e.logger,l?.cronTriggers,s,e.env);const c=ar(a,e,r);if(c!==void 0)return{error:c,target:s,validation:o};const g=J({environment:e.env,projectRoot:a});return or(g,e.logger)?{error:"wrangler validation failed",target:s,validation:g}:{codegen:l,reblessSchemaBaseline:d,target:s,validation:g}},lr=async e=>{const r=e.cwd??process.cwd(),a=F(e),t=await cr(e,e.commandName??"deploy");if(t.error!==void 0){if(t.validation.problems.length>0)return{code:1,descriptor:void 0,error:t.error,validation:t.validation};const f=t.schemaDrift===void 0?void 0:{schemaDrift:t.schemaDrift};return p(t.error,f)}const{reblessSchemaBaseline:n,validation:o}=t,i=t.target,s=ze(e);if(s!==void 0)return p(s);const l=await Oe(r,e);if(l!==void 0)return p(l);Me(r,e.logger);const{error:d,mintedSecretsFile:c}=await Ye(r,e,a,i);if(d!==void 0)return e.logger.error(d),{code:1,descriptor:void 0,error:d,mintedSecretsFile:c,validation:o};const g=ir(r,e,i);e.logger.info(`deploying via ${g.command} ${g.args.join(" ")}`);const m=await(e.spawner??S)(g);return g.captureStdoutSilently===!0&&m.stdout!==void 0&&m.stdout!==""&&process.stderr.write(m.stdout),m.code!==0?{code:m.code,descriptor:g,mintedSecretsFile:c,validation:o}:sr({cwd:r,descriptor:g,mintedSecretsFile:c,options:e,reblessSchemaBaseline:n,stdout:m.stdout,validation:o})},dr=async e=>{const r=ye("deploy",e.format);if(r!==void 0)return e.logger.error(r),p(r);const a=e.dryRun===!0&&e.commandName!=="build"?Ne(e.cwd??process.cwd()):void 0;let t;try{t=await lr({...e,logger:pe(e.format,e.logger)})}finally{a?.()}if($(e.format))return we(t),t;if(t.code===0&&e.dryRun!==!0&&e.preview!==!0)Pe({cwd:e.cwd??process.cwd(),env:e.env,logger:e.logger,mintedSecretsFile:t.mintedSecretsFile,url:t.deployment?.url});else if(t.code===0&&e.preview===!0){const n=t.deployment?.url;e.logger.success(n===void 0?"preview version uploaded":`preview version uploaded — ${n}`)}return t},Tr=de(async({cwd:e,logger:r,options:a})=>({code:(await dr({allowSchemaDrift:a.allowSchemaDrift===!0,apiSpec:ce(a.apiSpec),cwd:e,dryRun:a.dryRun===!0,env:a.env,format:a.format,healthCheck:a.healthCheck===!0,logger:r,migrate:a.migrate===!0,migrateToken:a.migrateToken,migrateUrl:I({cwd:e,env:a.env,url:a.migrateUrl}),migrateYes:a.migrateYes===!0,preview:a.preview===!0,skipCodegen:a.prebuilt===!0,strictAdvisories:a.strictAdvisories,target:a.target,temporary:a.temporary===!0,updateSchemaBaseline:a.updateSchemaBaseline===!0})).code}));export{cr as a,Tr as e,dr as r,Ne as s};
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,"utf8"),t.success(`binding manifest written to ${o}`),{code:0}}if(i)return process.stdout.write(`${JSON.stringify(r,void 0,2)}
|
|
3
|
-
`),{code:0};if(r.bindings.length===0)t.info("No bindings declared.");else{const o=Math.max(...r.bindings.map(c=>c.type.length));t.info(`${String(r.bindings.length)} binding(s):`);for(const c of r.bindings){const f=[c.resource,c.className,c.resourceId].filter(b=>b!==void 0).join(" ");t.info(` ${c.type.padEnd(o)} ${c.binding}${f===""?"":` ${f}`}`)}}return r.crons.length>0&&t.info(`${String(r.crons.length)} cron trigger(s): ${r.crons.join(", ")}`),r.vars.length>0&&t.info(`${String(r.vars.length)} var(s): ${r.vars.join(", ")}`),r.unknown.length>0&&t.warn(`not modelled by the manifest: ${r.unknown.join(", ")} — anything they bind must be provisioned by hand.`),{code:0}},A=n=>{const e=n.cwd??process.cwd();if(n.bindings===!0)return{...O({cwd:e,json:n.json===!0,logger:n.logger,out:n.out}),snapshot:void 0};if(n.out!==void 0)return n.logger.error("--out only applies with --bindings; the full info snapshot prints to stdout under --json."),{code:1,snapshot:void 0};const i=D(e);return n.json?process.stdout.write(`${JSON.stringify(i,void 0,2)}
|
|
4
|
-
`):E(i,n.logger),{code:0,snapshot:i}},q=F(({cwd:n,logger:e,options:i})=>A({bindings:i.bindings===!0,cwd:n,json:i.json===!0,logger:e,out:i.out}));export{D as collectInfo,q as execute,A as runInfoCommand};
|
|
1
|
+
import{d as o}from"../packem_shared/command-DwC11Cwe.mjs";import{r as f}from"../packem_shared/resolve-target-BRvw8Pf7.mjs";import{I as u,r as d}from"../packem_shared/import-8FCB0cUX.mjs";const n=o(({argument:m,cwd:a,logger:e,options:r})=>{const t=m[0];return t?r.from!==void 0&&!u.includes(r.from)?(e.error(`--from ${r.from} is not a known source. Expected one of: ${u.join(", ")}.`),{code:1}):d({batchSize:r.batchSize,cwd:a,file:t,from:r.from,logger:e,prod:r.prod===!0,scan:r.scan===!0,storageDir:r.storageDir,table:r.table,token:r.token,url:f({cwd:a,prod:r.prod===!0,url:r.url}),verify:r.verify===!0,withStorage:r.withStorage===!0,yes:r.yes===!0}):(e.error("import requires a path. Usage: lunora import <file.ndjson | convex-export-dir> [--table <name>]"),{code:1})});export{n as execute};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
1
|
+
import{mkdirSync as y,writeFileSync as h,readFileSync as l,existsSync as m}from"node:fs";import{isAbsolute as v,resolve as $,dirname as p,join as u}from"node:path";import{discoverSchema as k}from"@lunora/codegen";import{readLinkedProject as w}from"@lunora/config";import{findWranglerFile as j}from"@lunora/config/cloudflare";import{parse as S}from"jsonc-parser";import{Project as x}from"ts-morph";import{d as g}from"../packem_shared/binding-manifest-file-CQ1eQYy1.mjs";import{d as F}from"../packem_shared/command-DwC11Cwe.mjs";const d=(n,e)=>{if(n===null||typeof n!="object")return;const i=n[e];return typeof i=="string"&&i.length>0?i:void 0},P=(n,e)=>{if(n===null||typeof n!="object")return[];const i=n[e];return Array.isArray(i)?i:[]},I=(n,e)=>{const{manifest:i}=g(e);return{bindings:(i?.bindings??[]).map(t=>`${t.type}:${t.binding}`),compatibilityDate:d(n,"compatibility_date"),compatibilityFlags:P(n,"compatibility_flags").filter(t=>typeof t=="string"),main:d(n,"main"),name:d(n,"name")}},M=n=>({tables:n.tables.map(e=>{let i="root";return e.shardMode==="global"?i="global":typeof e.shardMode=="object"&&(i=`shardBy(${e.shardMode.field})`),{indexes:e.indexes.length,name:e.name,shard:i}}),vectorIndexes:n.vectorIndexes.length}),N=n=>{const e=u(n,"package.json");if(!m(e))return[];let i;try{i=JSON.parse(l(e,"utf8"))}catch{return[]}if(i===null||typeof i!="object")return[];const t=["dependencies","devDependencies","peerDependencies","optionalDependencies"],s=new Map;for(const a of t){const r=i[a];if(!(r===null||typeof r!="object"))for(const[o,c]of Object.entries(r))o.startsWith("@lunora/")&&typeof c=="string"&&!s.has(o)&&s.set(o,c)}return[...s.entries()].toSorted(([a],[r])=>a.localeCompare(r)).map(([a,r])=>({name:a,version:r}))},D=n=>{const e=N(n),i=j(n);let t;if(i)try{t=I(S(l(i,"utf8")),n)}catch{t=void 0}const s=u(n,"lunora","schema.ts");let a,r;if(m(s))try{const o=new x({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1});a=M(k(o,s))}catch(o){r=o instanceof Error?o.message:String(o)}return{link:w(n),lunoraPackages:e,projectRoot:n,schema:a,schemaError:r,wrangler:t,wranglerPath:i}},E=(n,e)=>{if(e.info(`project: ${n.projectRoot}`),e.info(""),e.info("@lunora/* packages:"),n.lunoraPackages.length===0)e.info(" (none found in package.json)");else for(const i of n.lunoraPackages)e.info(` ${i.name}@${i.version}`);if(e.info(""),n.wrangler?(e.info(`wrangler: ${n.wranglerPath??""}`),e.info(` name: ${n.wrangler.name??"<unset>"}`),e.info(` main: ${n.wrangler.main??"<unset>"}`),e.info(` compatibility_date: ${n.wrangler.compatibilityDate??"<unset>"}`),e.info(` compatibility_flags: ${n.wrangler.compatibilityFlags.join(", ")||"<none>"}`),e.info(` bindings: ${n.wrangler.bindings.join(", ")||"<none>"}`)):e.info("wrangler: (not found)"),e.info(""),n.link?(e.info(`link: ${n.link.workerName??"(unnamed)"} -> ${n.link.workerUrl??"<no url>"}`),n.link.env!==void 0&&e.info(` env: ${n.link.env}`)):e.info("link: (not linked — run `lunora link --url <https://your-worker>`)"),e.info(""),n.schemaError!==void 0)e.warn(`schema: parse error — ${n.schemaError}`);else if(n.schema){e.info(`schema: ${String(n.schema.tables.length)} table(s), ${String(n.schema.vectorIndexes)} vector index(es)`);for(const i of n.schema.tables)e.info(` ${i.name} [${i.shard}, ${String(i.indexes)} index(es)]`)}else e.info("schema: (no lunora/schema.ts)")},O=n=>{const{cwd:e,json:i,logger:t,out:s}=n,{error:a,manifest:r}=g(e);if(r===void 0)return t.error(a??"could not derive the binding manifest"),{code:1};if(s!==void 0){const o=v(s)?s:$(e,s);return y(p(o),{recursive:!0}),h(o,`${JSON.stringify(r,void 0,2)}
|
|
2
|
+
`,"utf8"),t.success(`binding manifest written to ${o}`),{code:0}}if(i)return process.stdout.write(`${JSON.stringify(r,void 0,2)}
|
|
3
|
+
`),{code:0};if(r.bindings.length===0)t.info("No bindings declared.");else{const o=Math.max(...r.bindings.map(c=>c.type.length));t.info(`${String(r.bindings.length)} binding(s):`);for(const c of r.bindings){const f=[c.resource,c.className,c.resourceId].filter(b=>b!==void 0).join(" ");t.info(` ${c.type.padEnd(o)} ${c.binding}${f===""?"":` ${f}`}`)}}return r.crons.length>0&&t.info(`${String(r.crons.length)} cron trigger(s): ${r.crons.join(", ")}`),r.vars.length>0&&t.info(`${String(r.vars.length)} var(s): ${r.vars.join(", ")}`),r.unknown.length>0&&t.warn(`not modelled by the manifest: ${r.unknown.join(", ")} — anything they bind must be provisioned by hand.`),{code:0}},A=n=>{const e=n.cwd??process.cwd();if(n.bindings===!0)return{...O({cwd:e,json:n.json===!0,logger:n.logger,out:n.out}),snapshot:void 0};if(n.out!==void 0)return n.logger.error("--out only applies with --bindings; the full info snapshot prints to stdout under --json."),{code:1,snapshot:void 0};const i=D(e);return n.json?process.stdout.write(`${JSON.stringify(i,void 0,2)}
|
|
4
|
+
`):E(i,n.logger),{code:0,snapshot:i}},q=F(({cwd:n,logger:e,options:i})=>A({bindings:i.bindings===!0,cwd:n,json:i.json===!0,logger:e,out:i.out}));export{D as collectInfo,q as execute,A as runInfoCommand};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{r as $}from"../packem_shared/admin-url-BhF5ufg1.mjs";import{d as p}from"../packem_shared/command-DwC11Cwe.mjs";import{r as S}from"../packem_shared/resolve-target-BRvw8Pf7.mjs";const v="__lunora_admin__:getFunctionStats",M=10,d=(r,o)=>({calls:r.calls,conflicts:r.conflicts??0,errors:r.errors,lastErrorMessage:r.lastErrorMessage,maxDurationMs:r.maxDurationMs,meanDurationMs:r.calls===0?0:r.totalDurationMs/r.calls,path:r.path,rate:o}),y=(r,o)=>{const e=r.filter(t=>(t.conflicts??0)>0).map(t=>d(t,t.calls===0?0:(t.conflicts??0)/t.calls)).toSorted((t,n)=>n.rate-t.rate||n.conflicts-t.conflicts).slice(0,o),s=r.filter(t=>t.errors>0).map(t=>d(t,t.calls===0?0:t.errors/t.calls)).toSorted((t,n)=>n.rate-t.rate||n.errors-t.errors).slice(0,o),l=r.map(t=>d(t,0)).toSorted((t,n)=>n.maxDurationMs-t.maxDurationMs).slice(0,o);return{errorHotspots:s,latencyOutliers:l,totalFunctions:r.length,writeContention:e}},f=r=>`${(r*100).toFixed(1)}%`,h=r=>r<1e3?`${Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,u=(r,o,e,s)=>[r,...o.length===0?[` ${e}`]:o.map(l=>` ${s(l)}`)],N=r=>{const o=e=>e.lastErrorMessage?` — ${e.lastErrorMessage}`:"";return[`Insights over ${r.totalFunctions.toString()} function${r.totalFunctions===1?"":"s"}`,"",...u("Write-conflict hot-spots (OCC contention — candidates for sharding):",r.writeContention,"none — no write conflicts observed",e=>`${e.path} ${e.conflicts.toString()}/${e.calls.toString()} calls (${f(e.rate)})`),"",...u("Error hot-spots:",r.errorHotspots,"none — no errors observed",e=>`${e.path} ${e.errors.toString()}/${e.calls.toString()} calls (${f(e.rate)})${o(e)}`),"",...u("Latency outliers (slowest single call):",r.latencyOutliers,"none — no functions have run",e=>`${e.path} max ${h(e.maxDurationMs)}, mean ${h(e.meanDurationMs)} over ${e.calls.toString()} calls`)].join(`
|
|
2
|
+
`)},O=r=>r===void 0||!Number.isFinite(r)||r<=0?M:Math.floor(r),T=async r=>{if(r.prod&&r.url===void 0)return r.logger.error("--prod requires an explicit --url (refusing to report from the implicit localhost worker)"),{code:1};const o=r.token??process.env.LUNORA_ADMIN_TOKEN;if(!o)return r.logger.error("admin token required — pass --token or set LUNORA_ADMIN_TOKEN"),{code:1};const e=$(r.url,r.logger,r.cwd);if(e===void 0)return{code:1};const s=`${e}/_lunora/rpc`,l=globalThis.fetch;if(typeof l!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");const t={args:{},functionPath:v};r.shard!==void 0&&(t.shardKey=r.shard),r.logger.info(`POST ${s} -> insights`);const n=await l(s,{body:JSON.stringify(t),headers:{authorization:`Bearer ${o}`,"content-type":"application/json"},method:"POST"}),i=await n.text();if(!n.ok)return r.logger.error(`insights failed: HTTP ${String(n.status)}: ${i}`),{code:1};let a;try{a=JSON.parse(i)}catch{return r.logger.error(`insights failed: worker returned non-JSON: ${i}`),{code:1}}const m=a.result??a,{functions:g}=m;if(!Array.isArray(g))return r.logger.error("insights failed: response carried no `functions` array"),{code:1};const c=y(g,O(r.limit));return r.logger.info(r.json?JSON.stringify(c,void 0,2):N(c)),{code:0,report:c}},D=p(({cwd:r,logger:o,options:e})=>{const s=e.limit===void 0?void 0:Number.parseInt(e.limit,10);return T({cwd:r,fetchImpl:void 0,json:e.json,limit:s,logger:o,prod:e.prod,shard:e.shard,token:e.token,url:S({cwd:r,prod:e.prod===!0,url:e.url})})});export{y as buildInsightsReport,D as execute,N as formatInsightsReport,T as runInsightsCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{existsSync as u,rmSync as m}from"node:fs";import{join as a}from"node:path";import{writeLinkedProject as d,LINKED_PROJECT_FILE as o}from"@lunora/config";import{d as i}from"../packem_shared/command-DwC11Cwe.mjs";import{r as k}from"../packem_shared/wrangler-name-Dsk5K1f-.mjs";const s=r=>{try{const{protocol:n}=new URL(r);return n==="http:"||n==="https:"}catch{return!1}},v=(r,n)=>{const e=a(r,o);return u(e)?(m(e),n.success(`link: removed ${o}`),{code:0}):(n.warn(`link: no ${o} to remove`),{code:0})},w=r=>{const n=r.cwd??process.cwd(),{logger:e}=r;if(r.remove)return v(n,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(!s(r.url))return e.error(`link: invalid --url "${r.url}" — expected an http(s) URL`),{code:1};const c=r.now??(()=>new Date().toISOString()),t={env:r.env,linkedAt:c(),workerName:r.name??k(n),workerUrl:r.url},l=d(n,t);return e.success(`link: ${t.workerName??"(unnamed worker)"} -> ${r.url}`),e.info(`link: wrote ${l}`),t.env!==void 0&&e.info(`link: environment "${t.env}"`),{code:0,link:t}},y=i(({cwd:r,logger:n,options:e})=>w({cwd:r,env:e.env,logger:n,name:e.name,remove:e.remove===!0,url:e.url}));export{y as execute,w as runLinkCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{p as c}from"../packem_shared/deploy-target-B0Xcb2jV.mjs";import{d as t}from"../packem_shared/command-DwC11Cwe.mjs";import{a as i}from"./handler.mjs";const l=async a=>{const r=a.cwd??process.cwd(),e=await i({allowSchemaDrift:a.allowSchemaDrift,apiSpec:a.apiSpec,cwd:r,logger:a.logger,spawner:a.spawner,target:a.target,updateSchemaBaseline:a.updateSchemaBaseline},"prepare");return e.error!==void 0?{code:1,error:e.error,...e.schemaDrift===void 0?{}:{schemaDrift:e.schemaDrift},validation:e.validation}:(e.reblessSchemaBaseline?.(),a.logger.success("project is ready to deploy"),{code:0,validation:e.validation})},s=t(({cwd:a,logger:r,options:e})=>l({allowSchemaDrift:e.allowSchemaDrift===!0,apiSpec:c(e.apiSpec),cwd:a,logger:r,target:e.target,updateSchemaBaseline:e.updateSchemaBaseline===!0}));export{s as execute,l as runPrepareCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as c}from"../packem_shared/command-DwC11Cwe.mjs";import{r as d,b as s,a as n}from"../packem_shared/commands-YfMX-Mto.mjs";const w=c(({argument:a,cwd:u,logger:e,options:r})=>{const f=a[0],m=a.slice(1);return f==="add"?d({allowUnsafeSource:r.allowUnsafeSource===!0,cwd:u,diff:r.diff===!0,dryRun:r.dryRun===!0,from:r.from,json:r.json===!0,logger:e,names:m,overwrite:r.overwrite===!0,ref:r.ref,source:r.source,yes:r.yes===!0}):f==="list"?d({cwd:u,from:r.from,json:r.json===!0,list:!0,logger:e,names:[],ref:r.ref,source:r.source}):f==="view"?s({allowUnsafeSource:r.allowUnsafeSource===!0,cwd:u,from:r.from,logger:e,names:m,ref:r.ref,source:r.source}):f==="build"?n({check:r.check===!0,cwd:u,from:r.from,logger:e,names:[],out:r.out}):(e.error("registry: unknown subcommand. Usage: lunora registry <add|list|view|build> [names…]"),{code:1})});export{w as execute};
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
import{existsSync as
|
|
2
|
-
`)}
|
|
3
|
-
`:"",c=u.length;if(e.dryRun===!0)return a.length>0&&process.stdout.write(a),e.logger.info(`generated ${String(c)} row(s) across ${String(g.length)} table(s) — dry run, nothing inserted`),{code:0,conflicts:0,generated:c,inserted:0,ndjson:a};if(e.reset===!0){const f=await P({cwd:r,logger:e.logger,yes:!0});if(f.code!==0)return{code:f.code,conflicts:0,generated:c,inserted:0,ndjson:a}}if(c===0)return e.logger.warn("no rows generated — nothing to insert"),{code:0,conflicts:0,generated:0,inserted:0,ndjson:a};const w=await D(e,c);return w!==void 0?w:_(a,c,r,e)},p=z(async({cwd:e,logger:r,options:t})=>({code:(await H({batchSize:t.batchSize,count:t.count,cwd:e,dryRun:t.dryRun===!0,logger:r,prod:t.prod===!0,reset:t.reset===!0,now:t.now,seed:t.seed,table:t.table,token:t.token,url:I({cwd:e,prod:t.prod===!0,url:t.url}),yes:t.yes===!0})).code}));export{p as execute,H as runSeedCommand};
|
|
1
|
+
import{existsSync as c,readFileSync as g,readdirSync as f,statSync as k,mkdirSync as w,writeFileSync as y}from"node:fs";import{fileURLToPath as R}from"node:url";import{AGENT_RULES_DIR as u,detectAgentRules as v,LUNORA_SKILL_NAMES as L}from"@lunora/config";import{join as i,relative as A,resolve as $,dirname as d}from"@visulima/path";import{d as b}from"../packem_shared/command-DwC11Cwe.mjs";const I=(e=d(R(import.meta.url)))=>{let r=e;for(let n=0;n<6;n+=1){const t=i(r,"package.json");if(c(t))try{if(JSON.parse(g(t,"utf8")).name==="@lunora/cli"){const l=i(r,"skills");return c(l)?l:void 0}}catch{}const s=d(r);if(s===r)break;r=s}},j=e=>f(e).filter(r=>{const n=i(e,r);return k(n).isDirectory()&&c(i(n,"SKILL.md"))}),m=(e,r,n)=>{w(r,{recursive:!0});let t=!1;for(const s of f(e)){const o=i(e,s),l=i(r,s);if(k(o).isDirectory()){t=m(o,l,n)||t;continue}c(l)&&!n||(y(l,g(o)),t=!0)}return t},_=["pnpm-workspace.yaml","pnpm-lock.yaml","yarn.lock","package-lock.json","bun.lock","bun.lockb",".git"],x=e=>{let r=e;for(;;){if(_.some(t=>c(i(r,t))))return r;const n=d(r);if(n===r)return e;r=n}},p=(e,r)=>r===void 0?x(e):$(e,r),E=e=>{const r=e.cwd??process.cwd(),n=p(r,e.dir),t=e.overwrite===!0,s=I();if(s===void 0)return e.logger.error("rules: could not locate the bundled skills (is @lunora/cli installed correctly?)."),{code:1,installed:[],skipped:[]};const o=[],l=[];for(const a of j(s)){const S=i(n,u,a);m(i(s,a),S,t)?o.push(a):l.push(a)}const h=A(r,i(n,u))||u;return o.length>0&&e.logger.success(`Installed ${String(o.length)} Lunora skill(s) into ${h}/: ${o.join(", ")}.`),l.length>0&&e.logger.info(`Skipped ${String(l.length)} existing skill(s) (re-run with --overwrite to replace): ${l.join(", ")}.`),e.logger.info("Your AI coding agent will pick these up automatically. Start with the `lunora` skill."),{code:0,installed:o,skipped:l}},O=e=>{const r=e.cwd??process.cwd(),n=p(r,e.dir),t=v(n);return t.installed?(e.logger.success(`Lunora agent rules are installed (${String(t.present.length)}/${String(L.length)} skills).`),t.missing.length>0&&e.logger.info(`Missing: ${t.missing.join(", ")}. Run \`lunora rules install\` to add them.`),{code:0,installed:t.present,skipped:[]}):(e.logger.warn("Lunora agent rules are not installed. Run `lunora rules install` so your AI agent knows how to use Lunora."),{code:e.strict===!0?1:0,installed:t.present,skipped:[]})},T=b(({argument:e,cwd:r,logger:n,options:t})=>{const s=e[0]??"check";return s==="install"?E({cwd:r,dir:t.dir,logger:n,overwrite:t.overwrite===!0}):s==="check"?O({cwd:r,dir:t.dir,logger:n,strict:t.strict===!0}):(n.error("rules: unknown subcommand. Usage: lunora rules <install|check>"),{code:1})});export{T as execute,I as resolveBundledSkillsDirectory,O as runRulesCheck,E as runRulesInstall};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as S}from"node:fs";import{mkdtemp as k,writeFile as v,rm as R}from"node:fs/promises";import{tmpdir as $}from"node:os";import{discoverSchema as j,schemaFromIr as T}from"@lunora/codegen";import{seedPlan as C}from"@lunora/seed";import{join as m}from"@visulima/path";import{Project as F}from"ts-morph";import{t as b}from"../packem_shared/admin-token-VdUnvnKW.mjs";import{d as x}from"../packem_shared/command-DwC11Cwe.mjs";import{r as z}from"../packem_shared/resolve-target-BRvw8Pf7.mjs";import{b as I}from"../packem_shared/tui-prompts-Dd0pDuNr.mjs";import{runResetCommand as A}from"./runResetCommand.mjs";import{r as P}from"../packem_shared/import-8FCB0cUX.mjs";const N=(e,r)=>typeof r=="bigint"?Number(r):r instanceof ArrayBuffer?[...new Uint8Array(r)]:r,l=e=>({code:e,conflicts:0,generated:0,inserted:0,ndjson:""}),U=(e,r)=>{if(!S(r))return e.logger.error(`schema not found: ${r} — run \`vis generate lunora-table --name=<name>\` to create one`),l(1);if(e.reset===!0&&b({prod:e.prod,url:e.url}))return e.logger.error("--reset only clears local .wrangler/state and cannot be combined with --prod or a remote --url"),l(1)},W=async(e,r,t,n)=>{const d=await k(m($(),"lunora-seed-")),i=m(d,"rows.ndjson");await v(i,e,"utf8");try{const o=await P({batchSize:n.batchSize,cwd:t,fetchImpl:n.fetchImpl,file:i,logger:n.logger,prod:n.prod,token:n.token,url:n.url,yes:!0}),s=o.body?.conflicts??0;return s>0&&n.logger.warn(`${String(s)} 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:o.code,conflicts:s,generated:r,inserted:o.inserted,ndjson:e}}finally{await R(d,{force:!0,recursive:!0}).catch(()=>{})}},_=(e,r)=>{if(e.table===void 0||r.tables.some(n=>n.name===e.table))return;const t=r.tables.map(n=>n.name).join(", ");return e.logger.error(`unknown table "${e.table}" — schema defines: ${t||"(no tables)"}`),l(1)},B=async(e,r)=>{if(!b({prod:e.prod,url:e.url})||e.yes===!0)return;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"),l(1);if(!await(e.confirm??I)(`This will insert ${String(r)} generated row(s) into ${e.url??"the production worker"}. Continue?`))return e.logger.info("seed: aborted"),l(1)},D=async e=>{const r=e.cwd??process.cwd(),t=m(r,"lunora","schema.ts"),n=U(e,t);if(n!==void 0)return n;const d=new F({skipAddingFilesFromTsConfig:!0}),i=j(d,t),o=_(e,i);if(o!==void 0)return o;const s=T(i),g=C(s,{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 y of f)u.push(JSON.stringify({doc:y,table:h},N));const c=u.length>0?`${u.join(`
|
|
2
|
+
`)}
|
|
3
|
+
`:"",a=u.length;if(e.dryRun===!0)return c.length>0&&process.stdout.write(c),e.logger.info(`generated ${String(a)} row(s) across ${String(g.length)} table(s) — dry run, nothing inserted`),{code:0,conflicts:0,generated:a,inserted:0,ndjson:c};if(a===0)return e.logger.warn("no rows generated — nothing to insert"),{code:0,conflicts:0,generated:0,inserted:0,ndjson:c};if(e.reset===!0){const f=await A({confirm:e.confirm,cwd:r,logger:e.logger,yes:e.yes});if(f.code!==0)return{code:f.code,conflicts:0,generated:a,inserted:0,ndjson:c}}const w=await B(e,a);return w!==void 0?w:W(c,a,r,e)},Z=x(async({cwd:e,logger:r,options:t})=>({code:(await D({batchSize:t.batchSize,count:t.count,cwd:e,dryRun:t.dryRun===!0,logger:r,prod:t.prod===!0,reset:t.reset===!0,now:t.now,seed:t.seed,table:t.table,token:t.token,url:z({cwd:e,prod:t.prod===!0,url:t.url}),yes:t.yes===!0})).code}));export{Z as execute,D as runSeedCommand};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{existsSync as h}from"node:fs";import{join as u}from"node:path";import{runCodegen as g}from"@lunora/codegen";import{p as v,r as y}from"../packem_shared/deploy-target-B0Xcb2jV.mjs";import{r as w}from"../packem_shared/codegen-error-AmH54ofi.mjs";import{d as S}from"../packem_shared/command-DwC11Cwe.mjs";import{r as k,p as j}from"../packem_shared/schema-drift-gate-BDCkQ1S6.mjs";import{v as D,i as b,p as x,l as E}from"../packem_shared/output-format-DfogXx0p.mjs";import{r as F}from"../packem_shared/platform-diagnostics-D0YzAdXm.mjs";import{defaultSpawner as U}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{validateWranglerProject as R}from"@lunora/config/cloudflare";import{execArgsFor as $,detectPackageManager as H}from"@lunora/config";const P=async(r,t)=>{if(!h(u(r,"tsconfig.json")))return{warning:"no tsconfig.json found — skipping TypeScript type-check"};const e=$(H(r),"tsc",["--noEmit","-p","tsconfig.json"]),a=await t({args:e.args,command:e.command,cwd:r});return a.code===0?{}:{error:`type errors: tsc --noEmit exited ${String(a.code)}`}},T=async(r,t)=>{if(r.healthUrl===void 0||r.healthUrl==="")return;const e=await j({baseUrl:r.healthUrl,fetchImpl:r.healthFetch});if(e.error===void 0){t.success(`verify: health probe ok (${e.url})`);return}return e.error},C=(r,t,e,a)=>{if(t.length===0&&e.length===0)return r.success("verify: project is valid"),{code:0,errors:[],warnings:[],wranglerPath:a};if(e.length>0){r.warn("verify: warnings:");for(const n of e)r.warn(` - ${n}`)}if(t.length>0){r.error("verify: errors:");for(const n of t){r.error(` - ${n}`);const c=w(n);c!==void 0&&r.error(c)}return{code:1,errors:t,warnings:e,wranglerPath:a}}return r.success("verify: project is valid (with warnings)"),{code:0,errors:[],warnings:e,wranglerPath:a}},O=async r=>{const t=r.cwd??process.cwd(),e=E(r.format,r.logger),a=D("verify",r.format);if(a!==void 0)return r.logger.error(a),{code:1,error:a,errors:[],warnings:[],wranglerPath:void 0};const n=R({projectRoot:t}),c=[...n.report.errors],i=[...n.report.warnings];try{const o=y(t,r.target);if(o.target===void 0){const f=o.error??"unknown deploy target";return e.error(f),{code:1,error:f,errors:[f],warnings:[],wranglerPath:void 0}}const s=g({apiSpec:r.apiSpec,dryRun:!0,projectRoot:t,target:o.target}),d=F(s.platformDiagnostics,e);c.push(...d.errors),i.push(...d.warnings);const p=k({allowDrift:r.allowSchemaDrift===!0,codegen:s,command:"verify",logger:e,readOnly:!0});p.blocked&&c.push(p.reason)}catch(o){const s=o instanceof Error?o.message:String(o);c.push(`codegen failed: ${s}`)}if(r.typecheck!==!1){const o=await P(t,r.spawner??U);o.error!==void 0&&c.push(o.error),o.warning!==void 0&&i.push(o.warning)}const l=await T(r,e);l!==void 0&&c.push(l);const m=C(e,c,i,n.wranglerPath);return b(r.format)&&x(m),m},N=S(async({cwd:r,logger:t,options:e})=>({code:(await O({allowSchemaDrift:e.allowSchemaDrift===!0,apiSpec:v(e.apiSpec),cwd:r,format:e.format,healthUrl:e.healthUrl,logger:t,target:e.target,typecheck:e.typecheck===!1?!1:void 0})).code}));export{N as execute,O as runVerifyCommand};
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)},J=e=>e.coverage==="exempt"?[` exempt: ${e.exemptReason===void 0||e.exemptReason===""?"no reason given":e.exemptReason}`]:e.checks.map(r=>{const n=r.occurrences>1?`, ×${String(r.occurrences)}`:"";return` ${r.name} (−${String(r.weight)}${n})`}),L=e=>{const r=new Map;for(const n of e){const o=r.get(n.file);o===void 0?r.set(n.file,[n]):o.push(n)}return[...r].toSorted(([n],[o])=>y(n,o))},N=e=>{const r=f(e.procedures),n=[`advisor health ${String(e.score)}/100 — ${e.grade}`,"",` legend: ${l.clean} clean ${l.warned} warned ${l.failing} failing ${l.exempt} exempt`];for(const[o,t]of L(e.procedures)){n.push("",` ${o}`);for(const i of t)n.push(g(i,r),...J(i))}return n.join(`
|
|
3
|
-
`)},P=(e,r)=>{const n=e.procedures.find(t=>t.id===r);if(n===void 0){const t=e.procedures.slice(0,10).map(i=>` ${i.id}`);return[`no procedure ${r} in the map. Known ids:`,...t,e.procedures.length>10?" …":""].filter(Boolean).join(`
|
|
4
|
-
`)}const o=[`${B(n)} — ${String(n.score)}/100, ${n.coverage}`,` weight in the global mean: ${String(n.weight)}`];if(n.checks.length===0)return o.push(""," no rule fired"),o.join(`
|
|
5
|
-
`);o.push(""," rules fired:");for(const t of n.checks)o.push(` [${t.level}] ${t.name} −${String(t.weight)}${t.occurrences>1?` (×${String(t.occurrences)})`:""}`);return o.join(`
|
|
6
|
-
`)},I=new Date(0).toISOString(),m=(e,r)=>p(r)?r:w(e,r),_=e=>{if(e===void 0)return{value:void 0};if(e===null||e==="")return{error:"--min-score needs a value between 0 and 100"};const r=Number(e);return Number.isFinite(r)&&r>=0&&r<=100?{value:r}:{error:"--min-score must be a number between 0 and 100"}},H=(e,r,n)=>{const o=m(r,n===null||n===""?u:n);if(!S(o))return{error:`baseline not found at ${o} — generate one with \`lunora advisor\` and commit it`};const t=j(JSON.parse(b(o,"utf8")));return t===void 0?{error:`baseline at ${o} is malformed — regenerate it with \`lunora advisor\``}:{comparison:A(e,t)}},K=e=>`baseline is not comparable (${e}) — regenerate it; this run verified nothing`,O=(e,r,n)=>r.entry!==void 0?P(e,r.entry):r.all===!0?N(e):C(e,n),q=e=>{const r=e.cwd??process.cwd(),n=E(e.format),o=k(e.format,e.logger),t=R("advisor",e.format);if(t!==void 0)return e.logger.error(t),{error:t};const i=_(e.minScore);if("error"in i)return e.logger.error(i.error),{error:i.error};const{advisorContext:$,advisories:h}=F({dryRun:!0,projectRoot:r}),a=x($?.procedureProtections??[],h,{generatedAt:e.generatedAt??I}),s={map:a};if(e.baseline!==void 0){const c=H(a,r,e.baseline);if("error"in c)return e.logger.error(c.error),{...s,error:c.error};s.comparison=c.comparison,c.comparison.comparable||e.logger.error(K(c.comparison.reason))}if(e.write!==!1){const c=m(r,e.out??u);v(c,`${JSON.stringify(a,void 0,4)}
|
|
7
|
-
`,"utf8"),s.written=c}return s.belowMinScore=i.value!==void 0&&a.score<i.value,s.belowMinScore&&o.error(`advisor score ${String(a.score)} is below the required ${String(i.value)}`),n?(D(s),s):(o.info(O(a,e,s.comparison)),s.written!==void 0&&o.success(`wrote ${s.written}`),s)},G=e=>e.error!==void 0||e.belowMinScore===!0?!0:e.comparison!==void 0&&(!e.comparison.comparable||e.comparison.regressed),Z=M(({cwd:e,logger:r,options:n})=>{const o=q({all:n.all,baseline:n.baseline,cwd:e,entry:n.entry,format:n.format,logger:r,minScore:n.minScore,out:n.out,write:n.write});return{code:G(o)?1:0}});export{Z as execute,q as runAdvisorCommand};
|
|
1
|
+
import{readFileSync as l,existsSync as u}from"node:fs";import{join as a}from"node:path";import{parse as d}from"jsonc-parser";import{d as m}from"../packem_shared/command-DwC11Cwe.mjs";import{o as p}from"../packem_shared/open-url-EnKy--w-.mjs";const c=8787,s="/_lunora/studio",g=r=>{for(const t of["wrangler.jsonc","wrangler.json"]){const e=a(r,t);if(u(e))return e}},v=r=>{const t=g(r);if(t)try{const e=d(l(t,"utf8"));return e!==null&&typeof e=="object"?e:void 0}catch{return}},y=r=>{if(!r)return c;const{dev:t}=r;if(t!==null&&typeof t=="object"){const{port:e}=t;if(typeof e=="number"&&Number.isFinite(e))return e}return c},h=r=>{if(!r)return;const{routes:t}=r;if(Array.isArray(t)&&t.length>0){const n=t[0];if(typeof n=="string")return`https://${n.split("/")[0]??n}${s}`;if(n!==null&&typeof n=="object"){const{pattern:o}=n;if(typeof o=="string"&&o.length>0)return`https://${o.split("/")[0]??o}${s}`}}const{name:e}=r;if(typeof e=="string"&&e.length>0)return`https://${e}.workers.dev${s}`},$=async r=>{const t=r.cwd??process.cwd(),e=v(t),{logger:n}=r;let o;if(r.remote){if(o=h(e),!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(y(e))}${s}`;n.info(`opening ${o}`);try{await p(o,{opener:r.opener})}catch(i){const f=i instanceof Error?i.message:String(i);return n.error(`view: failed to open URL: ${f}`),{code:1,url:o}}return{code:0,url:o}},A=m(({cwd:r,logger:t,options:e})=>$({cwd:r,logger:t,remote:e.remote===!0}));export{A as execute,$ as runViewCommand};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`):h(o,r),{code:0,descriptor:s,report:o}}finally{if(i&&l(n))try{d(n,{force:!0,recursive:!0})}catch{}}},C=S(({cwd:e,logger:t,options:r})=>x({cwd:e,json:r.json===!0,logger:t}));export{C as execute,x as runAnalyzeCommand};
|
|
1
|
+
import{existsSync as k,readFileSync as T}from"node:fs";import{applyLintIgnores as N,detectLintTools as I}from"@lunora/config";import{findWranglerFile as A}from"@lunora/config/cloudflare";import{join as v,basename as g}from"@visulima/path";import{d as D}from"../packem_shared/command-DwC11Cwe.mjs";import{r as S}from"../packem_shared/lint-ignore-report-DKZagpqk.mjs";import{v as U,l as L,i as M,p as _}from"../packem_shared/output-format-DfogXx0p.mjs";import{t as w,a as F}from"../packem_shared/tui-prompts-Dd0pDuNr.mjs";import{r as O,i as E}from"../packem_shared/commands-YfMX-Mto.mjs";import{n as P,i as R,E as j,s as $,d as l,p,r as f,M as x,a as B,b as h,c as z,D as o,e as C,f as H,g as d,A as J,h as W,w as q,j as V,k as G}from"../packem_shared/storage-D5s4vbtJ.mjs";const K=e=>{const r=e.trim().toLowerCase();return W.find(a=>a.value===r||a.label.toLowerCase()===r||r==="auth0"&&a.value==="auth-auth0"||r==="clerk"&&a.value==="auth-clerk")?.value},y=e=>{try{const r=JSON.parse(T(v(e,"package.json"),"utf8"));return{...r.dependencies,...r.devDependencies}}catch{return{}}},Q=async e=>{const r=e.cwd??process.cwd(),t=H(y(r));return t!==void 0?t:e.yes===!0?(e.logger.warn(`add: couldn't detect your framework — using "${d}". Pass a specific item (e.g. \`lunora add auth-ui-vue\`) to override.`),d):await(e.promptSelect??((s,n,i)=>w(s,n,i)))("Which framework is your app?",J,{default:d})??d},X=async e=>{if(e.provider!==void 0&&e.provider!==""){const t=K(e.provider);return t===void 0?(e.logger.warn(`add: unknown --provider "${e.provider}" — using "${o}" (email & password).`),o):t}if(e.yes===!0)return o;const r=e.promptSelect??((t,a,s)=>w(t,a,s));return C(r)},m=e=>e.promptText??((r,t)=>F(r,t)),Y=async e=>{const r=g(e.cwd??process.cwd());if(e.bucket!==void 0&&e.bucket!==""){const t=$(e.bucket);if(t!==void 0)return t;const a=l(r);return e.logger.warn(`add: "${e.bucket}" isn't a valid R2 bucket name (lowercase alphanumeric + hyphens, 3–63 chars) — using "${a}".`),a}return e.yes===!0?l(r):p(m(e),r)},Z=async e=>{const r=t=>{e.logger.warn(`add: ${t}`)};if(e.mailTo!==void 0&&e.mailTo!=="")return f(e.mailTo,r);if(e.yes!==!0)return f(await m(e)(x,{placeholder:"you@yourdomain.com"}),r)},ee=async e=>{const r=g(e.cwd??process.cwd());if(e.db!==void 0&&e.db!==""){const t=B(e.db);if(t!==void 0)return t;const a=h(r);return e.logger.warn(`add: "${e.db}" isn't a usable D1 database name — using "${a}".`),a}return e.yes===!0?h(r):z(m(e),r)},re=async(e,r)=>e.kind==="auth"?[await X(r)]:e.kind==="auth-ui"?[await Q(r)]:e.kind==="email"?[j]:[e.item],ae=(e,r)=>{S(N(e,I(e)),r)},te=e=>!E(e)||e.yes===!0,se=async e=>{const r=e.cwd??process.cwd(),t=e.feature===void 0?void 0:P(e.feature);if(t===void 0)return e.logger.error("add requires a feature or registry item. Usage: lunora add <auth|email|storage|crons|presence|…>"),{code:1,items:[]};if(!k(v(r,"lunora"))||A(r)===void 0)return e.logger.error("add: not a Lunora project here (need a lunora/ directory and a wrangler.jsonc). Run `lunora init` first."),{code:1,items:[]};if(t.kind==="auth-ui"&&R(y(r)))return e.logger.error("add: auth-ui has no React Native port — the screens render DOM elements and a stylesheet, which Metro has nothing to mount. Build the screens with React Native primitives against the same better-auth client (`@lunora/react-native/auth`); `lunora add auth` still installs the server half."),{code:1,items:[]};const a=await re(t,e),s=[];if(a.includes("storage")){const c=await Y(e);s.push(u=>q(u,c))}if(a.includes("mail")){const c=await Z(e);c!==void 0&&s.push(u=>V(u,c))}if(a.some(c=>c==="auth"||c.startsWith("auth-"))){const c=await ee(e);s.push(u=>G(u,c))}const n=s.length>0?c=>{let u=c;for(const b of s)u=b(u);return u}:void 0,i=await O({allowUnsafeSource:e.allowUnsafeSource,confirm:e.confirm,cwd:r,from:e.from,logger:e.logger,names:[...a],ref:e.ref,source:e.source,transformManifest:n,yes:te(e)});return i.code===0&&ae(r,e.logger),{code:i.code,items:a}},ve=D(async({argument:e,cwd:r,logger:t,options:a})=>{const s=U("add",a.format);if(s!==void 0)return t.error(s),{code:1};const n=L(a.format,t),i=await se({allowUnsafeSource:a.allowUnsafeSource===!0,bucket:a.bucket,cwd:r,db:a.db,feature:e[0],from:a.from,logger:n,mailTo:a.mailTo,provider:a.provider,ref:a.ref,source:a.source,yes:a.yes===!0});return M(a.format)&&_({code:i.code,items:i.items}),{code:i.code}});export{ve as execute,se as runAddFeature};
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{writeFileSync as v,existsSync as S,readFileSync as b}from"node:fs";import{isAbsolute as p,join as w}from"node:path";import{byCodepoint as y,scoreAdvisor as x,parseAdvisorMap as j,compareToBaseline as A}from"@lunora/advisor";import{runCodegen as F}from"@lunora/codegen";import{d as M}from"../packem_shared/command-DwC11Cwe.mjs";import{v as R,p as D,l as k,i as E}from"../packem_shared/output-format-DfogXx0p.mjs";import{D as u}from"../packem_shared/cli-CqNvbTR1.mjs";const l={clean:"·",exempt:"–",failing:"✗",warned:"!"},d=(e,r)=>e.length>=r?e:e+" ".repeat(r-e.length),B=e=>`${e.id} (${e.visibility} ${e.kind})`,f=e=>{let r=0;for(const n of e)r=Math.max(r,n.id.length);return r},g=(e,r)=>` ${d(String(e.score),3)} ${l[e.coverage]} ${d(e.id,r)} ${e.visibility} ${e.kind}`,T=e=>{if(!e.comparable)return[` baseline not comparable (${e.reason}) — regenerate it; this run cannot verify anything`];if(!e.regressed)return[` no regression against baseline (score ${e.scoreDelta>=0?"+":""}${String(e.scoreDelta)})`];const r=[` REGRESSED against baseline (score ${e.scoreDelta>=0?"+":""}${String(e.scoreDelta)})`];for(const n of e.dropped)r.push(` ${n.id}: ${String(n.before)} → ${String(n.after)}`);for(const n of e.newFailing)r.push(` ${n}: now failing`);for(const n of e.worsened)r.push(` ${n}: more findings than the baseline`);return e.projectRegressed&&r.push(" project: new schema/config rules fired"),r},C=(e,r)=>{const n=e.procedures.filter(i=>i.coverage!=="clean"&&i.coverage!=="exempt"),o=f(n),t=[`advisor health ${String(e.score)}/100 — ${e.grade}`,` ${String(e.summary.clean)} clean · ${String(e.summary.warned)} warned · ${String(e.summary.failing)} failing · ${String(e.summary.exempt)} exempt (${String(e.summary.procedures)} procedures, ${String(e.summary.rulesFired)} rules fired)`];return e.project.checks.length>0&&t.push("",` project ${String(e.project.score)}/100 — ${e.project.checks.map(i=>i.name).join(", ")}`),n.length>0&&t.push("",...n.map(i=>g(i,o)),""," run with --all for every procedure, or --entry <file#export> for one"),r!==void 0&&t.push("",...T(r)),t.join(`
|
|
2
|
+
`)},J=e=>e.coverage==="exempt"?[` exempt: ${e.exemptReason===void 0||e.exemptReason===""?"no reason given":e.exemptReason}`]:e.checks.map(r=>{const n=r.occurrences>1?`, ×${String(r.occurrences)}`:"";return` ${r.name} (−${String(r.weight)}${n})`}),L=e=>{const r=new Map;for(const n of e){const o=r.get(n.file);o===void 0?r.set(n.file,[n]):o.push(n)}return[...r].toSorted(([n],[o])=>y(n,o))},N=e=>{const r=f(e.procedures),n=[`advisor health ${String(e.score)}/100 — ${e.grade}`,"",` legend: ${l.clean} clean ${l.warned} warned ${l.failing} failing ${l.exempt} exempt`];for(const[o,t]of L(e.procedures)){n.push("",` ${o}`);for(const i of t)n.push(g(i,r),...J(i))}return n.join(`
|
|
3
|
+
`)},P=(e,r)=>{const n=e.procedures.find(t=>t.id===r);if(n===void 0){const t=e.procedures.slice(0,10).map(i=>` ${i.id}`);return[`no procedure ${r} in the map. Known ids:`,...t,e.procedures.length>10?" …":""].filter(Boolean).join(`
|
|
4
|
+
`)}const o=[`${B(n)} — ${String(n.score)}/100, ${n.coverage}`,` weight in the global mean: ${String(n.weight)}`];if(n.checks.length===0)return o.push(""," no rule fired"),o.join(`
|
|
5
|
+
`);o.push(""," rules fired:");for(const t of n.checks)o.push(` [${t.level}] ${t.name} −${String(t.weight)}${t.occurrences>1?` (×${String(t.occurrences)})`:""}`);return o.join(`
|
|
6
|
+
`)},I=new Date(0).toISOString(),m=(e,r)=>p(r)?r:w(e,r),_=e=>{if(e===void 0)return{value:void 0};if(e===null||e==="")return{error:"--min-score needs a value between 0 and 100"};const r=Number(e);return Number.isFinite(r)&&r>=0&&r<=100?{value:r}:{error:"--min-score must be a number between 0 and 100"}},H=(e,r,n)=>{const o=m(r,n===null||n===""?u:n);if(!S(o))return{error:`baseline not found at ${o} — generate one with \`lunora advisor\` and commit it`};const t=j(JSON.parse(b(o,"utf8")));return t===void 0?{error:`baseline at ${o} is malformed — regenerate it with \`lunora advisor\``}:{comparison:A(e,t)}},K=e=>`baseline is not comparable (${e}) — regenerate it; this run verified nothing`,O=(e,r,n)=>r.entry!==void 0?P(e,r.entry):r.all===!0?N(e):C(e,n),q=e=>{const r=e.cwd??process.cwd(),n=E(e.format),o=k(e.format,e.logger),t=R("advisor",e.format);if(t!==void 0)return e.logger.error(t),{error:t};const i=_(e.minScore);if("error"in i)return e.logger.error(i.error),{error:i.error};const{advisorContext:$,advisories:h}=F({dryRun:!0,projectRoot:r}),a=x($?.procedureProtections??[],h,{generatedAt:e.generatedAt??I}),s={map:a};if(e.baseline!==void 0){const c=H(a,r,e.baseline);if("error"in c)return e.logger.error(c.error),{...s,error:c.error};s.comparison=c.comparison,c.comparison.comparable||e.logger.error(K(c.comparison.reason))}if(e.write!==!1){const c=m(r,e.out??u);v(c,`${JSON.stringify(a,void 0,4)}
|
|
7
|
+
`,"utf8"),s.written=c}return s.belowMinScore=i.value!==void 0&&a.score<i.value,s.belowMinScore&&o.error(`advisor score ${String(a.score)} is below the required ${String(i.value)}`),n?(D(s),s):(o.info(O(a,e,s.comparison)),s.written!==void 0&&o.success(`wrote ${s.written}`),s)},G=e=>e.error!==void 0||e.belowMinScore===!0?!0:e.comparison!==void 0&&(!e.comparison.comparable||e.comparison.regressed),Z=M(({cwd:e,logger:r,options:n})=>{const o=q({all:n.all,baseline:n.baseline,cwd:e,entry:n.entry,format:n.format,logger:r,minScore:n.minScore,out:n.out,write:n.write});return{code:G(o)?1:0}});export{Z as execute,q as runAdvisorCommand};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`);return c.rows.length===0?e.logger.info("logs --durable: no matching log records"):c.nextCursor!==void 0&&e.logger.info(`logs --durable: more rows available — pass --cursor ${T(c.nextCursor)} for the next page`),{code:0,rows:c.rows}},E=new Set(["json","pretty"]),N=async e=>{const t=e.cwd??process.cwd();if(e.format!==void 0&&!E.has(e.format))return e.logger.error(`logs: unknown --format "${e.format}" — expected pretty | json`),{code:1,descriptor:void 0,error:"invalid format"};const a=e.env??g(t)?.env,r=v(e.target);if(r.toolchain===void 0)return e.logger.error(`logs: deploy target "${r.id}" has no command-line toolchain`),{code:1,descriptor:void 0,error:"no toolchain"};const i=r.toolchain.tail({environment:a,format:e.format,search:e.search,status:e.status,temporary:e.temporary,worker:e.worker}),n=h(y(t),i.tool,i.args),s={args:n.args,command:n.command,cwd:t};return e.logger.info(`tailing logs via ${s.command} ${s.args.join(" ")}`),{code:(await(e.spawner??w)(s)).code,descriptor:s}},Q=b(({argument:e,cwd:t,logger:a,options:r})=>r.durable===!0?x({cursor:r.cursor,functionPrefix:r.functionPrefix,level:r.level,limit:r.limit,logger:a,minLevel:r.minLevel,namespace:r.namespace,ndjson:r.ndjson===!0,shardKey:r.shardKey,since:r.since,table:r.table,traceId:r.traceId,until:r.until,userId:r.userId}):N({cwd:t,env:r.env,format:r.format,logger:a,search:r.search,status:r.status,target:r.target,temporary:r.temporary===!0,worker:e[0]}));export{Q as execute,N as runLogsCommand};
|
|
1
|
+
import{join as c,resolve as l}from"node:path";import{p as m}from"../packem_shared/deploy-target-B0Xcb2jV.mjs";import{w as u}from"../packem_shared/binding-manifest-file-CQ1eQYy1.mjs";import{d as f}from"../packem_shared/command-DwC11Cwe.mjs";import{v as p,i as w,l as g,p as y}from"../packem_shared/output-format-DfogXx0p.mjs";import{defaultSpawner as v}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{s as b,r as h}from"./handler.mjs";import{readdirSync as S,readFileSync as B}from"node:fs";import{gzipSync as F}from"node:zlib";const D=e=>!e.endsWith(".map")&&e!=="bundle-meta.json"&&e!=="README.md",z=e=>{let t;try{t=S(e,{recursive:!0,withFileTypes:!0})}catch{return}let r=0,a=0,o=0;for(const i of t){if(!i.isFile()||!D(i.name))continue;const n=B(c(i.parentPath,i.name));r+=1,o+=n.byteLength,a+=F(n).byteLength}return r===0?void 0:{files:r,gzipBytes:a,rawBytes:o}},$=".lunora/build",C=async e=>v({...e,stdoutToStderr:!0}),s=e=>`${(e/1024).toFixed(1)} KiB`,M=(e,t,r)=>u({destination:t,logger:r,projectRoot:e}),W=async(e,t,r,a,o)=>{const i=await h({allowSchemaDrift:e.allowSchemaDrift,apiSpec:e.apiSpec,commandName:"build",cwd:e.cwd,dryRun:!0,format:void 0,interactive:r?!1:void 0,logger:a,outDir:t,spawner:e.spawner??(r?C:void 0),target:e.target});if(i.code!==0)return o(i);a.success(`build complete — bundle written to ${t}`);const n=z(l(e.cwd??process.cwd(),t));if(n===void 0?a.warn(`could not weigh the bundle — nothing uploadable was found in ${t}`):a.info(`bundle: ${s(n.rawBytes)} raw, ${s(n.gzipBytes)} gzipped across ${String(n.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:d}=M(e.cwd??process.cwd(),e.emitBindings,a);if(d!==void 0)return a.error(d),o({...i,bundle:n,code:1})}return o({...i,bundle:n})},E=async e=>{const t=e.outDir??$,r=w(e.format),a=g(e.format,e.logger),o=d=>(r&&y(d),d),i=p("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=b(e.cwd??process.cwd());try{return await W(e,t,r,a,o)}finally{n()}},k=f(async({cwd:e,logger:t,options:r})=>({code:(await E({allowSchemaDrift:r.allowSchemaDrift===!0,apiSpec:m(r.apiSpec),cwd:e,emitBindings:r.emitBindings,format:r.format,logger:t,outDir:r.outDir,target:r.target})).code}));export{k as execute,E as runBuildCommand};
|