@lunora/cli 1.0.0-alpha.151 → 1.0.0-alpha.153

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.
@@ -1 +1 @@
1
- import{existsSync as y,readFileSync as R}from"node:fs";import{runCodegen as O,discoverMigrations as _}from"@lunora/codegen";import{readLinkedProject as A,writeLinkedProject as B,resolveDeployDriver as D,inferLunoraBindings as U,DEV_VARS_FILE as w,parseDevVariableEntries as F,isMintableSecretKey as C,discoverContainerInfo as I,packageNamesFromBindings as P,requiredSecrets as W,generateSecretValue as K,upsertDevVariableLine as q,writeDevVariablesFileAtomically as M,discoverSchemaInfo as V}from"@lunora/config";import{validateWranglerProject as Y,reconcileWranglerBindings as G,reconcileWranglerCompatibilityDate as z,reconcileWranglerCrons as H,findWranglerFile as J,readWranglerJsonc as Q}from"@lunora/config/cloudflare";import{join as h}from"@visulima/path";import{Spinner as X}from"@visulima/spinner";import{Project as Z}from"ts-morph";import{n as ee,t as re}from"../packem_shared/advisory-gate-yaOOyUQl.mjs";import{r as te}from"../packem_shared/api-spec-BENwiyUa.mjs";import{d as j}from"../packem_shared/wrangler-name-CHDf3rMP.mjs";import{i as oe}from"../packem_shared/command-0l-ZPhIX.mjs";import{i as ne}from"../packem_shared/deploy-target-Dvr9vxpR.mjs";import{M as k,l as $}from"../packem_shared/detect-package-manager-DXDstphE.mjs";import{o as ie,r as ae}from"../packem_shared/docker-CKvYE9YF.mjs";import{p as se,b as ce,c as le}from"../packem_shared/health-probe-CiFgh1hn.mjs";import{i as de,t as b,d as ue,s as ge}from"../packem_shared/output-format-Cv3aLqhP.mjs";import{a as pe}from"../packem_shared/platform-diagnostics-C4TFj5Pu.mjs";import{m as me}from"../packem_shared/post-codegen-hook-DhL1RH5u.mjs";import{containerBuildTag as fe}from"@lunora/container";import{defaultSpawner as S}from"../packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{i as E}from"../packem_shared/resolve-target-CeiNrCAx.mjs";import{R as he}from"../packem_shared/schema-drift-gate-d12lMICD.mjs";import{I as ve}from"../packem_shared/tui-prompts-BU3irGxV.mjs";import{m as we,p as ye}from"../packem_shared/vectorize-metadata-BvZbbqUD.mjs";import{f as ke}from"../packem_shared/wrangler-secrets-D0Tv5GWn.mjs";import{runMigrateDataCommand as $e}from"./runMigrateGenerateCommand.mjs";const be=/https?:\/\/[^\s"'<>]+\.workers\.dev[^\s"'<>]*/u,Se=/https:\/\/[^\s"'<>]+/u,Re=e=>{if(e===void 0)return;const r=be.exec(e);return r?r[0]:Se.exec(e)?.[0]},N=e=>e===void 0?"":` (--env ${e})`,De=({cwd:e,env:r,logger:t,now:o,url:n})=>{if(n!==void 0)try{const i=A(e);if(i!==void 0){if(i.workerUrl===n&&i.env===r)return;t.warn(`link: .lunora/project.json records ${i.workerUrl??"(no url)"}${N(i.env)}, but this deploy published ${n}${N(r)}. Keeping the recorded value — run \`lunora link --url ${n}${r===void 0?"":` --env ${r}`}\` to update it.`);return}const a=(o??(()=>new Date().toISOString()))();B(e,{env:r,linkedAt:a,workerName:j(e),workerUrl:n}),t.success(`link: recorded ${n} in .lunora/project.json (run \`lunora link\` to change)`)}catch{}},je=e=>{const{cwd:r,env:t,logger:o,migrated:n,mintedSecretsFile:i}=e;try{const a=A(r),c=a?.workerName??j(r),l=e.url??a?.workerUrl;o.success("deploy complete"),o.info(` worker: ${c??"(see wrangler output above)"}`),t!==void 0&&o.info(` env: ${t}`),l===void 0?o.info(" url: run `lunora link --url <https://your-worker>` to record it"):o.info(` url: ${l}`),n&&o.info(" migrations: applied"),i!==void 0&&o.info(` secrets: generated value(s) recorded in ${i}`),o.info(" studio: lunora view --remote"),o.info(" logs: lunora logs")}catch{}},xe=async e=>{if(e.targets.length===0)return{builtTags:[],code:0};if(!(e.railpackAvailable??ie)()){const o="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(o),{builtTags:[],code:1,error:o}}const r=e.spawner??S,t=[];for(const o of e.targets){const n=fe(o.exportName),i={args:["build",o.buildDir,"--name",n],command:"railpack",cwd:e.cwd},a=k($(e.cwd),"wrangler",["containers","push",n]),c={args:a.args,command:a.command,cwd:e.cwd};e.logger.info(`railpack: building "${o.exportName}" → ${n} from ${o.buildDir}`);const l=await r(i);if(l.code!==0){const s=`railpack build failed for container "${o.exportName}" (${o.buildDir})`;return e.logger.error(s),{builtTags:t,code:l.code,error:s}}e.logger.info(`railpack: pushing ${n} to the Cloudflare Registry`);const d=await r(c);if(d.code!==0){const s=`wrangler containers push failed for "${o.exportName}" (${n})`;return e.logger.error(s),{builtTags:t,code:d.code,error:s}}t.push(n)}return{builtTags:t,code:0}},L="<replace-with-d1-create-id>",x=e=>{const r=J(e);return r?Q(r).parsed:void 0},Ce=["LUNORA_ORIGIN_URL","LUNORA_WORKER_ORIGIN","AUTH_URL"],Ne=e=>{try{const{hostname:r}=new URL(e);return r==="localhost"||r==="127.0.0.1"||r==="::1"||r==="[::1]"}catch{return!1}},Te=e=>e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.includes("Dockerfile"),Ae=(e,r,t)=>{const o=(x(e)?.containers??[]).filter(i=>typeof i?.image=="string"&&Te(i.image));if(o.length===0||t())return;const n=`deploy blocked: wrangler.jsonc declares ${String(o.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(n),n},Ue=e=>y(h(e,"src","worker.ts"))?"src/worker.ts":void 0,Fe=(e,r)=>{for(const t of I(e,"lunora").containers){const{image:o}=t;if(o.kind==="dockerfile"&&!y(h(e,o.dockerfilePath))){const n=`deploy blocked: container "${t.exportName}" references a Dockerfile at "${o.dockerfilePath}" that does not exist. Create it or fix the \`image\` path in lunora/containers.ts.`;return r.error(n),n}if(o.kind==="build"&&!y(h(e,o.buildDir))){const n=`deploy blocked: container "${t.exportName}" references a Railpack build directory "${o.buildDir}" that does not exist. Create it or fix the \`image.build\` path in lunora/containers.ts.`;return r.error(n),n}}},Ie=e=>b(e.format)?!1:e.interactive!==void 0?e.interactive:process.stdout.isTTY&&!process.env.CI,Ee=e=>(x(e)?.d1_databases??[]).find(r=>r.database_id===L)?.binding,Le=async(e,r)=>{const t=I(e,"lunora").containers.filter(n=>n.image.kind==="build").map(n=>({buildDir:n.image.buildDir,exportName:n.exportName}));if(t.length===0)return;const o=await xe({cwd:e,logger:r.logger,railpackAvailable:r.railpackAvailable,spawner:r.spawner,targets:t});return o.code===0?void 0:o.error??"railpack build failed"},Oe=(e,r,t)=>{if(t!==void 0)try{const o=H(e,t);o.changed&&r.success(`synced ${String(t.length)} cron trigger(s) → ${o.wranglerPath??"wrangler.jsonc"}`)}catch(o){const n=o instanceof Error?o.message:String(o);r.warn(`cron trigger sync skipped: ${n}`)}},_e=async(e,r,t,o,n)=>{try{D(o);const i=await U({projectRoot:e}),a=G(e,i,n);a.changed&&r.success(`provisioned bindings: ${a.added.join(", ")} → ${a.wranglerPath??"wrangler.jsonc"}`);for(const c of a.warnings)r.warn(c)}catch(i){const a=i instanceof Error?i.message:String(i);r.warn(`binding inference skipped: ${a}`)}try{const i=z(e);i.changed&&r.success(`bumped compatibility_date to ${i.date??"unknown"} (Workers Cache enabled) → ${i.wranglerPath??"wrangler.jsonc"}`)}catch(i){const a=i instanceof Error?i.message:String(i);r.warn(`compatibility date sync skipped: ${a}`)}Oe(e,r,t)},Be=(e,r)=>{const t=h(e,w);if(!y(t))return;let o;try{o=F(R(t,"utf8")).length}catch{return}o!==0&&r.warn(`Note: \`lunora deploy\` does not push secrets. ${w} has ${String(o)} key(s); if you changed them, run \`lunora env push --yes\` to update the deployed secrets.`)},Pe=/(?:KEY|PASSWORD|SECRET|TOKEN)$/u,We=async e=>{let r=[];try{r=P(await U({projectRoot:e}))}catch{}const t=W(r).map(n=>n.key);let o=[];try{const n=h(e,w);y(n)&&(o=F(R(n,"utf8")).map(i=>i.key).filter(i=>Pe.test(i)))}catch{}return[...new Set([...t,...o])]},Ke=async(e,r,t,o)=>{const{logger:n}=r,i=r.spawner??S,a=$(e),c=r.env===void 0?"":` --env ${r.env}`,{toolchain:l}=D(o);if(l===void 0)return n.error("deploy target has no command-line toolchain; cannot push secrets"),{minted:[],ok:!1};const d=[];for(const s of t){const u=K(),m=l.secretPut({environment:r.env,key:s,temporary:r.temporary}),f=k(a,m.tool,m.args),g=await i({args:f.args,command:f.command,cwd:e,input:u});if(g.code!==0)return n.error(`failed to push secret ${s} (exit ${String(g.code)}); set it manually with \`wrangler secret put ${s}${c}\`.`),{minted:d,ok:!1};d.push({key:s,value:u}),n.success(`generated + pushed ${s}`)}return{minted:d,ok:!0}},qe=/^[\w-]+$/u,Me=(e,r,t)=>{if(t.length===0)return;const o=t.map(c=>c.key).join(", ");if(r.env!==void 0&&!qe.test(r.env)){r.logger.warn(`${o}: 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?w:`${w}.${r.env}`,i=h(e,n);let a=y(i)?R(i,"utf8"):"";for(const c of t)a=q(a,c.key,c.value);return M(i,a),r.logger.success(r.env===void 0?`${o}: value(s) recorded in ${n}`:`${o}: value(s) recorded in ${n} (kept separate from ${w} so \`lunora dev\` and a plain \`lunora env push\` don't inherit the --env ${r.env} value)`),n},Ve=async(e,r,t,o)=>{if(r.dryRun===!0||r.preview===!0)return{};const{logger:n}=r,i=r.env===void 0?"":` --env ${r.env}`;let a;try{a=await(r.secretLister??ke)({cwd:e,env:r.env,temporary:r.temporary})}catch{return{}}if(!a.ok)return{};const c=new Set(a.names),l=(await We(e)).filter(s=>!c.has(s));if(l.length===0)return{};if(!t)return{error:`missing required secret(s) on the deploy target: ${l.join(", ")}. Set them with \`wrangler secret put <KEY>${i}\` (or \`lunora env generate --set\` then \`lunora env push --yes${i}\`), then re-deploy.`};for(const s of l.filter(u=>!C(u)))n.warn(`required secret ${s} is not set on the target — set it with: wrangler secret put ${s}${i}`);const d=l.filter(s=>C(s));if(d.length===0)return{};if(await(r.secretConfirm??ve())(`${String(d.length)} required secret(s) not set on the target (${d.join(", ")}). Generate strong values and push them now?`)){const{minted:s,ok:u}=await Ke(e,r,d,o),m=Me(e,r,s);return u?{mintedSecretsFile:m}:{error:"failed to push required secret(s) — set them manually and re-deploy",mintedSecretsFile:m}}return n.warn(`${String(d.length)} required secret(s) not set on the target: ${d.join(", ")}. Generate + push with \`lunora env generate --set\` then \`lunora env push --yes${i}\`.`),{}},Ye=async(e,r)=>{const t=new Z({skipAddingFilesFromTsConfig:!0}),o=h(r,"lunora");let n;try{n=_(t,o)}catch(i){const a=i instanceof Error?i.message:String(i);return e.logger.warn(`--migrate: could not discover migrations (${a}); 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 i of n){e.logger.info(`--migrate: up "${i.id}" (table "${i.table}")`);const a={cwd:r,fetchImpl:e.fetchImpl,id:i.id,logger:e.logger,prod:!0,subcommand:"up",token:e.migrateToken,url:e.migrateUrl,yes:e.migrateYes===!0},c=await $e(a);if(c.code!==0)return e.logger.error(`--migrate: migration "${i.id}" failed — see output above`),c.code;e.logger.success(`--migrate: "${i.id}" applied`)}return 0},Ge=e=>{if(!e.migrate||e.dryRun||e.preview)return;if(e.migrateUrl===void 0){const t="--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(t),t}if(e.migrateYes!==!0){const t="--migrate runs production data migrations after deploy. Re-run with --migrate-yes to confirm.";return e.logger.error(t),t}const r=e.migrateToken??process.env.LUNORA_ADMIN_TOKEN;if(r===void 0||r===""){const t="admin token required for --migrate — pass --migrate-token or set LUNORA_ADMIN_TOKEN";return e.logger.error(t),t}},ze=async(e,r,t,o,n,i,a,c)=>{let l;r?(l=new X({name:"dots"}),l.start("running codegen")):t.info("running codegen");try{const d=O({apiSpec:o,projectRoot:e,target:n});l?.succeed("codegen complete"),l||t.success("codegen complete");const s=pe(d.platformDiagnostics,t);if(s!==void 0)return{error:s};const{errorAdvisories:u,names:m,shouldBlock:f}=ee(d.advisories,c);if(f){const p=`${u.length.toString()} ERROR-level ${u.length===1?"advisory":"advisories"} (${m.join(", ")}). Pass --no-strict-advisories to downgrade this to a warning and deploy anyway.`;return t.error(p),{error:p}}const g=await me({cwd:e,logger:t,spawner:i,stdoutToStderr:a});return g.error!==void 0?(t.error(g.error),{error:g.error}):{result:d}}catch(d){l?.failed("codegen failed");const s=d instanceof Error?d.message:String(d);return t.error(`codegen failed: ${s}`),{error:`codegen failed: ${s}`}}},He=(e,r)=>{const t=Ee(e);if(t===void 0)return;const o=`deploy blocked: the "${t}" D1 binding has a placeholder database_id ("${L}"). 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(o),o},Je=(e,r)=>{const t=x(e)?.vars;if(!t)return;const o=Ce.filter(i=>typeof t[i]=="string"&&Ne(t[i]));if(o.length===0)return;const n=`deploy blocked: ${o.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(n),n},Qe=async(e,r)=>{const{info:t}=V(r,"lunora"),o=t?.vectorMetadata??[];if(o.length===0)return;const n=[];for(const a of o){const c=ye(a.kind);if(c===void 0){e.logger.warn(`vector index "${a.index}" declares metadata "${a.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:a.index,property:a.property,type:c})}if(n.length===0)return;const i=(await we({cwd:r,entries:n,exec:k($(r),"wrangler",[]),logger:e.logger,spawner:e.spawner??S})).filter(a=>a.status!=="failed").length;i>0&&e.logger.success(`vectorize metadata indexes ready: ${String(i)}/${String(n.length)}`)},T=5,Xe=2e3,Ze=async(e,r,t)=>{if(e.healthCheck!==!0)return;const o=t??E({cwd:r,env:e.env});if(o===void 0){const i="--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(i),{error:i,ok:!1,url:""}}const n=await se({attempts:T,baseUrl:o,delayMs:Xe,fetchImpl:e.healthFetch,paths:[ce,le],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(T)} attempt(s) — ${n.error}`),{error:n.error,ok:!1,url:n.url})},er=async(e,r,t,o,n,i)=>{await Qe(e,r);const a=e.migrate?await Ye(e,r):0;return a===0&&n?.(),{code:a,descriptor:t,mintedSecretsFile:i,validation:o}},rr=async(e,r)=>{const t=He(e,r.logger);if(t!==void 0)return t;const o=Je(e,r.logger);if(o!==void 0)return o;const n=Fe(e,r.logger);if(n!==void 0)return n;const i=Ae(e,r.logger,r.dockerAvailable??ae);return i!==void 0?i:Le(e,r)},tr=(e,r,t)=>{const o=Ue(e);o!==void 0&&r.logger.info(`class-B composition: deploying ${o} (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(t),i={dryRun:r.dryRun,entry:o,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(i)},v=(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 t of e.problems)r.error(` - ${t}`);return!0},nr=(e,r,t)=>{const o=b(r.format),n=r.dryRun!==!0,i=tr(e,r,t),a=k($(e),i.tool,i.args);return{args:a.args,captureStdout:n&&!o,captureStdoutSilently:n&&o,command:a.command,cwd:e,stdoutToStderr:o&&!n}},ir=async({cwd:e,descriptor:r,mintedSecretsFile:t,options:o,reblessSchemaBaseline:n,stdout:i,validation:a})=>{const c={deployedAt:new Date().toISOString(),dryRun:o.dryRun===!0,env:o.env,preview:o.preview===!0,url:o.dryRun===!0?void 0:Re(i),workerName:j(e)};if(o.dryRun===!0||o.preview===!0)return o.healthCheck===!0&&o.logger.warn(`--health-check skipped: ${o.dryRun===!0?"a dry run publishes nothing":"a preview version serves no live traffic"}`),{code:0,deployment:c,descriptor:r,mintedSecretsFile:t,validation:a};o.temporary!==!0&&De({cwd:e,env:o.env,logger:o.logger,url:c.url});const l=await Ze(o,e,c.url);return l?.error!==void 0?{code:1,deployment:c,descriptor:r,healthCheck:l,mintedSecretsFile:t,validation:a}:{...await er(o,e,r,a,n,t),deployment:c,healthCheck:l}},ar=async e=>{const r=e.cwd??process.cwd(),t=Ie(e),o=re(e),n=ne(r,e.target);if(n.target===void 0){const p=n.error??"unknown deploy target";return e.logger.error(p),v(p)}const{target:i}=n;let a;if(!e.skipCodegen){const p=await ze(r,t,e.logger,e.apiSpec,i,e.spawner,b(e.format),o);if(p.error!==void 0)return v(p.error);a=p.result}let c;if(a!==void 0){const p=he({allowDrift:e.allowSchemaDrift===!0,codegen:a,command:"deploy",logger:e.logger,updateBaseline:e.updateSchemaBaseline===!0});if(p.blocked)return v("schema drift gate blocked deploy",{schemaDrift:{blocked:!0,reason:p.reason}});c=p.rebless}await _e(r,e.logger,a?.cronTriggers,i,e.env);const l=Ge(e);if(l!==void 0)return v(l);const d=await rr(r,e);if(d!==void 0)return v(d);const s=Y({environment:e.env,projectRoot:r});if(or(s,e.logger))return{code:1,descriptor:void 0,error:"wrangler validation failed",validation:s};Be(r,e.logger);const{error:u,mintedSecretsFile:m}=await Ve(r,e,t,i);if(u!==void 0)return e.logger.error(u),{code:1,descriptor:void 0,error:u,mintedSecretsFile:m,validation:s};const f=nr(r,e,i);e.logger.info(`deploying via ${f.command} ${f.args.join(" ")}`);const g=await(e.spawner??S)(f);return f.captureStdoutSilently===!0&&g.stdout!==void 0&&g.stdout!==""&&process.stderr.write(g.stdout),g.code!==0?{code:g.code,descriptor:f,mintedSecretsFile:m,validation:s}:ir({cwd:r,descriptor:f,mintedSecretsFile:m,options:e,reblessSchemaBaseline:c,stdout:g.stdout,validation:s})},sr=async e=>{const r=de("deploy",e.format);if(r!==void 0)return e.logger.error(r),v(r);const t=await ar({...e,logger:ge(e.format,e.logger)});if(b(e.format))return ue(t),t;if(t.code===0&&e.dryRun!==!0&&e.preview!==!0)je({cwd:e.cwd??process.cwd(),env:e.env,logger:e.logger,migrated:e.migrate===!0,mintedSecretsFile:t.mintedSecretsFile,url:t.deployment?.url});else if(t.code===0&&e.preview===!0){const o=t.deployment?.url;e.logger.success(o===void 0?"preview version uploaded":`preview version uploaded — ${o}`)}return t},Ir=oe(async({cwd:e,logger:r,options:t})=>({code:(await sr({allowSchemaDrift:t.allowSchemaDrift===!0,apiSpec:te(t.apiSpec),cwd:e,dryRun:t.dryRun===!0,env:t.env,format:t.format,healthCheck:t.healthCheck===!0,logger:r,migrate:t.migrate===!0,migrateToken:t.migrateToken,migrateUrl:E({cwd:e,env:t.env,url:t.migrateUrl}),migrateYes:t.migrateYes===!0,preview:t.preview===!0,skipCodegen:t.prebuilt===!0,strictAdvisories:t.strictAdvisories,target:t.target,temporary:t.temporary===!0,updateSchemaBaseline:t.updateSchemaBaseline===!0})).code}));export{Ir as execute,sr as runDeployCommand};
1
+ import{existsSync as y,readFileSync as R}from"node:fs";import{runCodegen as _,discoverMigrations as O}from"@lunora/codegen";import{readLinkedProject as A,writeLinkedProject as B,resolveDeployDriver as D,inferLunoraBindings as U,DEV_VARS_FILE as w,parseDevVariableEntries as F,isMintableSecretKey as C,discoverContainerInfo as I,packageNamesFromBindings as P,requiredSecrets as W,generateSecretValue as K,upsertDevVariableLine as q,writeDevVariablesFileAtomically as M,discoverSchemaInfo as V}from"@lunora/config";import{validateWranglerProject as Y,reconcileWranglerBindings as G,reconcileWranglerCompatibilityDate as z,reconcileWranglerCrons as H,findWranglerFile as J,readWranglerJsonc as Q}from"@lunora/config/cloudflare";import{join as h}from"@visulima/path";import{Spinner as X}from"@visulima/spinner";import{Project as Z}from"ts-morph";import{n as ee,t as re}from"../packem_shared/advisory-gate-yaOOyUQl.mjs";import{r as te}from"../packem_shared/api-spec-BENwiyUa.mjs";import{d as j}from"../packem_shared/wrangler-name-CHDf3rMP.mjs";import{i as oe}from"../packem_shared/command-0l-ZPhIX.mjs";import{i as ne}from"../packem_shared/deploy-target-Dvr9vxpR.mjs";import{M as k,l as $}from"../packem_shared/detect-package-manager-DXDstphE.mjs";import{o as ie,r as ae}from"../packem_shared/docker-CKvYE9YF.mjs";import{p as se,b as ce,c as le}from"../packem_shared/health-probe-CiFgh1hn.mjs";import{i as de,t as b,d as ue,s as ge}from"../packem_shared/output-format-Cv3aLqhP.mjs";import{a as pe}from"../packem_shared/platform-diagnostics-C4TFj5Pu.mjs";import{m as me}from"../packem_shared/post-codegen-hook-DhL1RH5u.mjs";import{containerBuildTag as fe}from"@lunora/container";import{defaultSpawner as S}from"../packem_shared/createRecordingSpawner-SKs4R1fc.mjs";import{i as E}from"../packem_shared/resolve-target-CeiNrCAx.mjs";import{R as he}from"../packem_shared/schema-drift-gate-d12lMICD.mjs";import{I as ve}from"../packem_shared/tui-prompts-BU3irGxV.mjs";import{m as we,p as ye}from"../packem_shared/vectorize-metadata-BvZbbqUD.mjs";import{f as ke}from"../packem_shared/wrangler-secrets-D0Tv5GWn.mjs";import{runMigrateDataCommand as $e}from"./runMigrateGenerateCommand.mjs";const be=/https?:\/\/[^\s"'<>]+\.workers\.dev[^\s"'<>]*/u,Se=/https:\/\/[^\s"'<>]+/u,Re=e=>{if(e===void 0)return;const r=be.exec(e);return r?r[0]:Se.exec(e)?.[0]},N=e=>e===void 0?"":` (--env ${e})`,De=({cwd:e,env:r,logger:t,now:o,url:n})=>{if(n!==void 0)try{const i=A(e);if(i!==void 0){if(i.workerUrl===n&&i.env===r)return;t.warn(`link: .lunora/project.json records ${i.workerUrl??"(no url)"}${N(i.env)}, but this deploy published ${n}${N(r)}. Keeping the recorded value — run \`lunora link --url ${n}${r===void 0?"":` --env ${r}`}\` to update it.`);return}const a=(o??(()=>new Date().toISOString()))();B(e,{env:r,linkedAt:a,workerName:j(e),workerUrl:n}),t.success(`link: recorded ${n} in .lunora/project.json (run \`lunora link\` to change)`)}catch{}},je=e=>{const{cwd:r,env:t,logger:o,migrated:n,mintedSecretsFile:i}=e;try{const a=A(r),c=a?.workerName??j(r),l=e.url??a?.workerUrl;o.success("deploy complete"),o.info(` worker: ${c??"(see wrangler output above)"}`),t!==void 0&&o.info(` env: ${t}`),l===void 0?o.info(" url: run `lunora link --url <https://your-worker>` to record it"):o.info(` url: ${l}`),n&&o.info(" migrations: applied"),i!==void 0&&o.info(` secrets: generated value(s) recorded in ${i}`),o.info(" studio: lunora view --remote"),o.info(" logs: lunora logs")}catch{}},xe=async e=>{if(e.targets.length===0)return{builtTags:[],code:0};if(!(e.railpackAvailable??ie)()){const o="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(o),{builtTags:[],code:1,error:o}}const r=e.spawner??S,t=[];for(const o of e.targets){const n=fe(o.exportName),i={args:["build",o.buildDir,"--name",n],command:"railpack",cwd:e.cwd},a=k($(e.cwd),"wrangler",["containers","push",n]),c={args:a.args,command:a.command,cwd:e.cwd};e.logger.info(`railpack: building "${o.exportName}" → ${n} from ${o.buildDir}`);const l=await r(i);if(l.code!==0){const s=`railpack build failed for container "${o.exportName}" (${o.buildDir})`;return e.logger.error(s),{builtTags:t,code:l.code,error:s}}e.logger.info(`railpack: pushing ${n} to the Cloudflare Registry`);const d=await r(c);if(d.code!==0){const s=`wrangler containers push failed for "${o.exportName}" (${n})`;return e.logger.error(s),{builtTags:t,code:d.code,error:s}}t.push(n)}return{builtTags:t,code:0}},L="<replace-with-d1-create-id>",x=e=>{const r=J(e);return r?Q(r).parsed:void 0},Ce=["LUNORA_ORIGIN_URL","LUNORA_WORKER_ORIGIN","AUTH_URL"],Ne=e=>{try{const{hostname:r}=new URL(e);return r==="localhost"||r==="127.0.0.1"||r==="::1"||r==="[::1]"}catch{return!1}},Te=e=>e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||e.includes("Dockerfile"),Ae=(e,r,t)=>{const o=(x(e)?.containers??[]).filter(i=>typeof i?.image=="string"&&Te(i.image));if(o.length===0||t())return;const n=`deploy blocked: wrangler.jsonc declares ${String(o.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(n),n},Ue=e=>y(h(e,"src","worker.ts"))?"src/worker.ts":void 0,Fe=(e,r)=>{for(const t of I(e,"lunora").containers){const{image:o}=t;if(o.kind==="dockerfile"&&!y(h(e,o.dockerfilePath))){const n=`deploy blocked: container "${t.exportName}" references a Dockerfile at "${o.dockerfilePath}" that does not exist. Create it or fix the \`image\` path in lunora/containers.ts.`;return r.error(n),n}if(o.kind==="build"&&!y(h(e,o.buildDir))){const n=`deploy blocked: container "${t.exportName}" references a Railpack build directory "${o.buildDir}" that does not exist. Create it or fix the \`image.build\` path in lunora/containers.ts.`;return r.error(n),n}}},Ie=e=>b(e.format)?!1:e.interactive!==void 0?e.interactive:process.stdout.isTTY&&!process.env.CI,Ee=e=>(x(e)?.d1_databases??[]).find(r=>r.database_id===L)?.binding,Le=async(e,r)=>{const t=I(e,"lunora").containers.filter(n=>n.image.kind==="build").map(n=>({buildDir:n.image.buildDir,exportName:n.exportName}));if(t.length===0)return;const o=await xe({cwd:e,logger:r.logger,railpackAvailable:r.railpackAvailable,spawner:r.spawner,targets:t});return o.code===0?void 0:o.error??"railpack build failed"},_e=(e,r,t)=>{if(t!==void 0)try{const o=H(e,t);o.changed&&r.success(`synced ${String(t.length)} cron trigger(s) → ${o.wranglerPath??"wrangler.jsonc"}`)}catch(o){const n=o instanceof Error?o.message:String(o);r.warn(`cron trigger sync skipped: ${n}`)}},Oe=async(e,r,t,o,n)=>{try{D(o);const i=await U({projectRoot:e}),a=G(e,i,n);a.changed&&r.success(`provisioned bindings: ${a.added.join(", ")} → ${a.wranglerPath??"wrangler.jsonc"}`);for(const c of a.warnings)r.warn(c)}catch(i){const a=i instanceof Error?i.message:String(i);r.warn(`binding inference skipped: ${a}`)}try{const i=z(e);i.changed&&r.success(`bumped compatibility_date to ${i.date??"unknown"} (Workers Cache enabled) → ${i.wranglerPath??"wrangler.jsonc"}`)}catch(i){const a=i instanceof Error?i.message:String(i);r.warn(`compatibility date sync skipped: ${a}`)}_e(e,r,t)},Be=(e,r)=>{const t=h(e,w);if(!y(t))return;let o;try{o=F(R(t,"utf8")).length}catch{return}o!==0&&r.warn(`Note: \`lunora deploy\` does not push secrets. ${w} has ${String(o)} key(s); if you changed them, run \`lunora env push --yes\` to update the deployed secrets.`)},Pe=/(?:KEY|PASSWORD|SECRET|TOKEN)$/u,We=async e=>{let r=[];try{r=P(await U({projectRoot:e}))}catch{}const t=W(r).map(n=>n.key);let o=[];try{const n=h(e,w);y(n)&&(o=F(R(n,"utf8")).map(i=>i.key).filter(i=>Pe.test(i)))}catch{}return[...new Set([...t,...o])]},Ke=async(e,r,t,o)=>{const{logger:n}=r,i=r.spawner??S,a=$(e),c=r.env===void 0?"":` --env ${r.env}`,{toolchain:l}=D(o);if(l===void 0)return n.error("deploy target has no command-line toolchain; cannot push secrets"),{minted:[],ok:!1};const d=[];for(const s of t){const u=K(),m=l.secretPut({environment:r.env,key:s,temporary:r.temporary}),f=k(a,m.tool,m.args),g=await i({args:f.args,command:f.command,cwd:e,input:u});if(g.code!==0)return n.error(`failed to push secret ${s} (exit ${String(g.code)}); set it manually with \`wrangler secret put ${s}${c}\`.`),{minted:d,ok:!1};d.push({key:s,value:u}),n.success(`generated + pushed ${s}`)}return{minted:d,ok:!0}},qe=/^[\w-]+$/u,Me=(e,r,t)=>{if(t.length===0)return;const o=t.map(c=>c.key).join(", ");if(r.env!==void 0&&!qe.test(r.env)){r.logger.warn(`${o}: 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?w:`${w}.${r.env}`,i=h(e,n);let a=y(i)?R(i,"utf8"):"";for(const c of t)a=q(a,c.key,c.value);return M(i,a),r.logger.success(r.env===void 0?`${o}: value(s) recorded in ${n}`:`${o}: value(s) recorded in ${n} (kept separate from ${w} so \`lunora dev\` and a plain \`lunora env push\` don't inherit the --env ${r.env} value)`),n},Ve=async(e,r,t,o)=>{if(r.dryRun===!0||r.preview===!0)return{};const{logger:n}=r,i=r.env===void 0?"":` --env ${r.env}`;let a;try{a=await(r.secretLister??ke)({cwd:e,env:r.env,temporary:r.temporary})}catch{return{}}if(!a.ok)return{};const c=new Set(a.names),l=(await We(e)).filter(s=>!c.has(s));if(l.length===0)return{};if(!t)return{error:`missing required secret(s) on the deploy target: ${l.join(", ")}. Set them with \`wrangler secret put <KEY>${i}\` (or \`lunora env generate --set\` then \`lunora env push --yes${i}\`), then re-deploy.`};for(const s of l.filter(u=>!C(u)))n.warn(`required secret ${s} is not set on the target — set it with: wrangler secret put ${s}${i}`);const d=l.filter(s=>C(s));if(d.length===0)return{};if(await(r.secretConfirm??ve())(`${String(d.length)} required secret(s) not set on the target (${d.join(", ")}). Generate strong values and push them now?`)){const{minted:s,ok:u}=await Ke(e,r,d,o),m=Me(e,r,s);return u?{mintedSecretsFile:m}:{error:"failed to push required secret(s) — set them manually and re-deploy",mintedSecretsFile:m}}return n.warn(`${String(d.length)} required secret(s) not set on the target: ${d.join(", ")}. Generate + push with \`lunora env generate --set\` then \`lunora env push --yes${i}\`.`),{}},Ye=async(e,r)=>{const t=new Z({skipAddingFilesFromTsConfig:!0}),o=h(r,"lunora");let n;try{n=O(t,o)}catch(i){const a=i instanceof Error?i.message:String(i);return e.logger.warn(`--migrate: could not discover migrations (${a}); 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 i of n){e.logger.info(`--migrate: up "${i.id}" (table "${i.table}")`);const a={cwd:r,fetchImpl:e.fetchImpl,id:i.id,logger:e.logger,prod:!0,subcommand:"up",token:e.migrateToken,url:e.migrateUrl,yes:e.migrateYes===!0},c=await $e(a);if(c.code!==0)return e.logger.error(`--migrate: migration "${i.id}" failed — see output above`),c.code;e.logger.success(`--migrate: "${i.id}" applied`)}return 0},Ge=e=>{if(!e.migrate||e.dryRun||e.preview)return;if(e.migrateUrl===void 0){const t="--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(t),t}if(e.migrateYes!==!0){const t="--migrate runs production data migrations after deploy. Re-run with --migrate-yes to confirm.";return e.logger.error(t),t}const r=e.migrateToken??process.env.LUNORA_ADMIN_TOKEN;if(r===void 0||r===""){const t="admin token required for --migrate — pass --migrate-token or set LUNORA_ADMIN_TOKEN";return e.logger.error(t),t}},ze=async(e,r,t,o,n,i,a,c)=>{let l;r?(l=new X({name:"dots"}),l.start("running codegen")):t.info("running codegen");try{const d=_({apiSpec:o,projectRoot:e,target:n});l?.succeed("codegen complete"),l||t.success("codegen complete");const s=pe(d.platformDiagnostics,t);if(s!==void 0)return{error:s};const{errorAdvisories:u,names:m,shouldBlock:f}=ee(d.advisories,c);if(f){const p=`${u.length.toString()} ERROR-level ${u.length===1?"advisory":"advisories"} (${m.join(", ")}). Pass --no-strict-advisories to downgrade this to a warning and deploy anyway.`;return t.error(p),{error:p}}const g=await me({cwd:e,logger:t,spawner:i,stdoutToStderr:a});return g.error!==void 0?(t.error(g.error),{error:g.error}):{result:d}}catch(d){l?.failed("codegen failed");const s=d instanceof Error?d.message:String(d);return t.error(`codegen failed: ${s}`),{error:`codegen failed: ${s}`}}},He=(e,r)=>{const t=Ee(e);if(t===void 0)return;const o=`deploy blocked: the "${t}" D1 binding has a placeholder database_id ("${L}"). 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(o),o},Je=(e,r)=>{const t=x(e)?.vars;if(!t)return;const o=Ce.filter(i=>typeof t[i]=="string"&&Ne(t[i]));if(o.length===0)return;const n=`deploy blocked: ${o.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(n),n},Qe=async(e,r)=>{const{info:t}=V(r,"lunora"),o=t?.vectorMetadata??[];if(o.length===0)return;const n=[];for(const a of o){const c=ye(a.kind);if(c===void 0){e.logger.warn(`vector index "${a.index}" declares metadata "${a.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:a.index,property:a.property,type:c})}if(n.length===0)return;const i=(await we({cwd:r,entries:n,exec:k($(r),"wrangler",[]),logger:e.logger,spawner:e.spawner??S})).filter(a=>a.status!=="failed").length;i>0&&e.logger.success(`vectorize metadata indexes ready: ${String(i)}/${String(n.length)}`)},T=5,Xe=2e3,Ze=async(e,r,t)=>{if(e.healthCheck!==!0)return;const o=t??E({cwd:r,env:e.env});if(o===void 0){const i="--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(i),{error:i,ok:!1,url:""}}const n=await se({attempts:T,baseUrl:o,delayMs:Xe,fetchImpl:e.healthFetch,paths:[ce,le],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(T)} attempt(s) — ${n.error}`),{error:n.error,ok:!1,url:n.url})},er=async(e,r,t,o,n,i)=>{await Qe(e,r);const a=e.migrate?await Ye(e,r):0;return a===0&&n?.(),{code:a,descriptor:t,mintedSecretsFile:i,validation:o}},rr=async(e,r)=>{const t=He(e,r.logger);if(t!==void 0)return t;const o=Je(e,r.logger);if(o!==void 0)return o;const n=Fe(e,r.logger);if(n!==void 0)return n;const i=Ae(e,r.logger,r.dockerAvailable??ae);return i!==void 0?i:Le(e,r)},tr=(e,r,t)=>{const o=Ue(e);o!==void 0&&r.logger.info(`class-B composition: deploying ${o} (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(t),i={dryRun:r.dryRun,entry:o,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(i)},v=(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 t of e.problems)r.error(` - ${t}`);return!0},nr=(e,r,t)=>{const o=b(r.format),n=r.dryRun!==!0,i=tr(e,r,t),a=k($(e),i.tool,i.args);return{args:a.args,captureStdout:n&&!o,captureStdoutSilently:n&&o,command:a.command,cwd:e,stdoutToStderr:o&&!n}},ir=async({cwd:e,descriptor:r,mintedSecretsFile:t,options:o,reblessSchemaBaseline:n,stdout:i,validation:a})=>{const c={deployedAt:new Date().toISOString(),dryRun:o.dryRun===!0,env:o.env,preview:o.preview===!0,url:o.dryRun===!0?void 0:Re(i),workerName:j(e)};if(o.dryRun===!0||o.preview===!0)return o.healthCheck===!0&&o.logger.warn(`--health-check skipped: ${o.dryRun===!0?"a dry run publishes nothing":"a preview version serves no live traffic"}`),{code:0,deployment:c,descriptor:r,mintedSecretsFile:t,validation:a};o.temporary!==!0&&De({cwd:e,env:o.env,logger:o.logger,url:c.url});const l=await Ze(o,e,c.url);return l?.error!==void 0?{code:1,deployment:c,descriptor:r,healthCheck:l,mintedSecretsFile:t,validation:a}:{...await er(o,e,r,a,n,t),deployment:c,healthCheck:l}},ar=async e=>{const r=e.cwd??process.cwd(),t=Ie(e),o=re(e),n=ne(r,e.target);if(n.target===void 0){const p=n.error??"unknown deploy target";return e.logger.error(p),v(p)}const{target:i}=n;let a;if(!e.skipCodegen){const p=await ze(r,t,e.logger,e.apiSpec,i,e.spawner,b(e.format),o);if(p.error!==void 0)return v(p.error);a=p.result}let c;if(a!==void 0){const p=he({allowDrift:e.allowSchemaDrift===!0,codegen:a,command:"deploy",logger:e.logger,updateBaseline:e.updateSchemaBaseline===!0});if(p.blocked)return v("schema drift gate blocked deploy",{schemaDrift:{blocked:!0,reason:p.reason}});c=p.rebless}await Oe(r,e.logger,a?.cronTriggers,i,e.env);const l=Ge(e);if(l!==void 0)return v(l);const d=await rr(r,e);if(d!==void 0)return v(d);const s=Y({environment:e.env,projectRoot:r});if(or(s,e.logger))return{code:1,descriptor:void 0,error:"wrangler validation failed",validation:s};Be(r,e.logger);const{error:u,mintedSecretsFile:m}=await Ve(r,e,t,i);if(u!==void 0)return e.logger.error(u),{code:1,descriptor:void 0,error:u,mintedSecretsFile:m,validation:s};const f=nr(r,e,i);e.logger.info(`deploying via ${f.command} ${f.args.join(" ")}`);const g=await(e.spawner??S)(f);return f.captureStdoutSilently===!0&&g.stdout!==void 0&&g.stdout!==""&&process.stderr.write(g.stdout),g.code!==0?{code:g.code,descriptor:f,mintedSecretsFile:m,validation:s}:ir({cwd:r,descriptor:f,mintedSecretsFile:m,options:e,reblessSchemaBaseline:c,stdout:g.stdout,validation:s})},sr=async e=>{const r=de("deploy",e.format);if(r!==void 0)return e.logger.error(r),v(r);const t=await ar({...e,logger:ge(e.format,e.logger)});if(b(e.format))return ue(t),t;if(t.code===0&&e.dryRun!==!0&&e.preview!==!0)je({cwd:e.cwd??process.cwd(),env:e.env,logger:e.logger,migrated:e.migrate===!0,mintedSecretsFile:t.mintedSecretsFile,url:t.deployment?.url});else if(t.code===0&&e.preview===!0){const o=t.deployment?.url;e.logger.success(o===void 0?"preview version uploaded":`preview version uploaded — ${o}`)}return t},Ir=oe(async({cwd:e,logger:r,options:t})=>({code:(await sr({allowSchemaDrift:t.allowSchemaDrift===!0,apiSpec:te(t.apiSpec),cwd:e,dryRun:t.dryRun===!0,env:t.env,format:t.format,healthCheck:t.healthCheck===!0,logger:r,migrate:t.migrate===!0,migrateToken:t.migrateToken,migrateUrl:E({cwd:e,env:t.env,url:t.migrateUrl}),migrateYes:t.migrateYes===!0,preview:t.preview===!0,skipCodegen:t.prebuilt===!0,strictAdvisories:t.strictAdvisories,target:t.target,temporary:t.temporary===!0,updateSchemaBaseline:t.updateSchemaBaseline===!0})).code}));export{Ir as execute,sr as runDeployCommand};
@@ -1,11 +1,11 @@
1
- import{existsSync as u,mkdirSync as S,writeFileSync as p,mkdtempSync as C,rmSync as I,readFileSync as k}from"node:fs";import{tmpdir as M}from"node:os";import{discoverSchema as T,readPackageDependencies as A,discoverMigrations as E}from"@lunora/codegen";import{isInteractive as z,promptSelect as F,promptText as N}from"@lunora/config";import{LunoraError as $}from"@lunora/errors";import{join as c}from"@visulima/path";import{Project as f}from"ts-morph";import{u as R}from"../packem_shared/admin-url-Ca-KI3d_.mjs";import{i as q}from"../packem_shared/command-0l-ZPhIX.mjs";import{diffSnapshots as O,renderMigrationFile as D}from"../packem_shared/diffSnapshots-BbwCuhoN.mjs";import{d as L}from"../packem_shared/resolve-target-CeiNrCAx.mjs";import j from"../packem_shared/schemaIrToSnapshot-Dahp39qH.mjs";import{readAndLogBody as B}from"./runRpcCommand.mjs";import{runExportCommand as H}from"../packem_shared/runExportCommand-BpE4AbuX.mjs";import{S as P}from"../packem_shared/import-DLyCq-2j.mjs";const Z=".snapshot.json",x=/[^\da-z]+/gu,U=(r,e)=>{let o=0,t=r.length;for(;o<t&&r[o]===e;)o+=1;for(;t>o&&r[t-1]===e;)t-=1;return r.slice(o,t)},J=r=>{const e=U(r.toLowerCase().replaceAll(x,"_"),"_");return e===""?"auto":e},K=r=>{const e=(o,t=2)=>o.toString().padStart(t,"0");return`${String(r.getUTCFullYear())}${e(r.getUTCMonth()+1)}${e(r.getUTCDate())}${e(r.getUTCHours())}${e(r.getUTCMinutes())}${e(r.getUTCSeconds())}`},Q=r=>{if(u(r))try{const e=k(r,"utf8"),o=JSON.parse(e);if(o.version!==1)throw new $("INTERNAL",`unsupported snapshot version: ${o.version}`);return o}catch(e){const o=e instanceof Error?e.message:String(e);throw new $("INTERNAL",`failed to read ${r}: ${o}`,{cause:e})}},W=r=>{const e=r.cwd??process.cwd(),o=c(e,"lunora","schema.ts");if(!u(o))return r.logger.error(`schema not found: ${o} — run \`vis generate lunora-table --name=<name>\` to create one`),{code:1,empty:!0,migrationFile:""};const t=new f({skipAddingFilesFromTsConfig:!0}),n=T(t,o),s=j(n),i=c(e,"lunora","migrations"),a=c(i,Z);let d;try{d=Q(a)}catch(g){return r.logger.error(g instanceof Error?g.message:String(g)),{code:1,empty:!0,migrationFile:""}}const l=O(d,s);if(l.empty)return r.logger.info("no schema changes detected — snapshot is already up to date"),{code:0,empty:!0,migrationFile:""};const h=(r.now??(()=>new Date))(),w=J(r.name??"auto"),b=`${K(h)}_${w}.sql`,m=c(i,b);S(i,{recursive:!0});const _=D(w,l,h.toISOString());return p(m,_,"utf8"),p(a,`${JSON.stringify(s,void 0,4)}
2
- `,"utf8"),r.logger.success(`wrote ${m}`),l.unsupported.length>0&&r.logger.warn(`${String(l.unsupported.length)} unsupported diff(s) — see the comment block in ${b} and write the SQL manually`),{code:0,empty:!1,migrationFile:m}},Y="migrations.ts",y=/^[A-Za-z_]\w*$/u,G=new Set(["await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","return","static","super","switch","this","throw","true","try","typeof","var","void","while","with","yield"]),v=/^import\s*\{\s*defineMigration\s*\}\s*from\s*["'](?:@lunora\/server|lunorash\/server)["'][^\n]*$/mu,V=r=>`import { defineMigration } from "${A(r)?.has("lunorash")??!1?"lunorash/server":"@lunora/server"}";`,X="__lunora_admin__:runMigration",rr="__lunora_admin__:migrationStatus",er="/_lunora/migrate",tr=r=>U(r.trim().toLowerCase().replaceAll(x,"-"),"-"),or=r=>r.split("-").filter(e=>e.length>0).map((e,o)=>o===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join(""),nr=r=>{const e=c(r,"lunora","schema.ts");if(!u(e))return[];try{const o=new f({skipAddingFilesFromTsConfig:!0});return T(o,e).tables.map(t=>t.name)}catch{return[]}},ir=async r=>r.length>0?F("Which table does this migration iterate?",r.map(e=>({label:e,value:e}))):N("Target table for the migration: "),ar=async(r,e)=>{if(e.table!==void 0)return e.table;const o=e.promptTable??(z()?ir:void 0);if(o===void 0){e.logger.error("migrate create requires a target table when not running interactively — re-run with --table <table>");return}const t=(await o(nr(r)))?.trim();if(t===void 0||t===""){e.logger.error("no table selected — re-run with --table <table>");return}return t},sr=async r=>{const e=r.cwd??process.cwd(),o=tr(r.name);if(o==="")return r.logger.error(`invalid migration name: "${r.name}" — must contain at least one alphanumeric character`),{code:1,file:""};const t=or(o);if(!y.test(t)||G.has(t))return r.logger.error(`invalid migration name: "${r.name}" derives the export \`${t}\`, which is not a valid identifier — pick a name that starts with a letter and isn't a reserved word`),{code:1,file:""};const n=await ar(e,r);if(n===void 0)return{code:1,file:""};if(!y.test(n))return r.logger.error(`invalid table: "${n}" — must be a valid identifier ([A-Za-z_][A-Za-z0-9_]*)`),{code:1,file:""};const s=c(e,"lunora"),i=c(s,Y);let a=u(i)?k(i,"utf8"):"";if(a.includes(`id: "${o}"`)||new RegExp(String.raw`\bexport const ${t}\b`,"u").test(a))return r.logger.error(`a migration with id "${o}" (export \`${t}\`) already exists in ${i}`),{code:1,file:""};const d=V(e);a.trim()===""?a=`${d}
3
- `:v.test(a)?a=a.replace(v,d):a=`${d}
1
+ import{existsSync as m,mkdirSync as k,writeFileSync as f,mkdtempSync as A,rmSync as I,readFileSync as T}from"node:fs";import{tmpdir as M}from"node:os";import{discoverSchema as _,readPackageDependencies as E,discoverMigrations as z}from"@lunora/codegen";import{isInteractive as F,promptSelect as N,promptText as R}from"@lunora/config";import{LunoraError as y}from"@lunora/errors";import{join as c}from"@visulima/path";import{Project as h}from"ts-morph";import{u as q}from"../packem_shared/admin-url-Ca-KI3d_.mjs";import{i as O}from"../packem_shared/command-0l-ZPhIX.mjs";import{diffSnapshots as D,renderMigrationFile as L}from"../packem_shared/diffSnapshots-BbwCuhoN.mjs";import{d as j}from"../packem_shared/resolve-target-CeiNrCAx.mjs";import B from"../packem_shared/schemaIrToSnapshot-Dahp39qH.mjs";import{readAndLogBody as H}from"./runRpcCommand.mjs";import{runExportCommand as P}from"../packem_shared/runExportCommand-BpE4AbuX.mjs";import{S as J}from"../packem_shared/import-DLyCq-2j.mjs";const u="__lunora_reproject__",W=r=>{if(!r.startsWith(u))return;const e=r.slice(u.length);return e===""?void 0:e},Z=".snapshot.json",x=/[^\da-z]+/gu,U=(r,e)=>{let o=0,t=r.length;for(;o<t&&r[o]===e;)o+=1;for(;t>o&&r[t-1]===e;)t-=1;return r.slice(o,t)},K=r=>{const e=U(r.toLowerCase().replaceAll(x,"_"),"_");return e===""?"auto":e},Q=r=>{const e=(o,t=2)=>o.toString().padStart(t,"0");return`${String(r.getUTCFullYear())}${e(r.getUTCMonth()+1)}${e(r.getUTCDate())}${e(r.getUTCHours())}${e(r.getUTCMinutes())}${e(r.getUTCSeconds())}`},Y=r=>{if(m(r))try{const e=T(r,"utf8"),o=JSON.parse(e);if(o.version!==1)throw new y("INTERNAL",`unsupported snapshot version: ${o.version}`);return o}catch(e){const o=e instanceof Error?e.message:String(e);throw new y("INTERNAL",`failed to read ${r}: ${o}`,{cause:e})}},G=r=>{const e=r.cwd??process.cwd(),o=c(e,"lunora","schema.ts");if(!m(o))return r.logger.error(`schema not found: ${o} — run \`vis generate lunora-table --name=<name>\` to create one`),{code:1,empty:!0,migrationFile:""};const t=new h({skipAddingFilesFromTsConfig:!0}),n=_(t,o),s=B(n),i=c(e,"lunora","migrations"),a=c(i,Z);let d;try{d=Y(a)}catch(p){return r.logger.error(p instanceof Error?p.message:String(p)),{code:1,empty:!0,migrationFile:""}}const l=D(d,s);if(l.empty)return r.logger.info("no schema changes detected — snapshot is already up to date"),{code:0,empty:!0,migrationFile:""};const b=(r.now??(()=>new Date))(),w=K(r.name??"auto"),$=`${Q(b)}_${w}.sql`,g=c(i,$);k(i,{recursive:!0});const C=L(w,l,b.toISOString());return f(g,C,"utf8"),f(a,`${JSON.stringify(s,void 0,4)}
2
+ `,"utf8"),r.logger.success(`wrote ${g}`),l.unsupported.length>0&&r.logger.warn(`${String(l.unsupported.length)} unsupported diff(s) — see the comment block in ${$} and write the SQL manually`),{code:0,empty:!1,migrationFile:g}},V="migrations.ts",v=/^[A-Za-z_]\w*$/u,X=new Set(["await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","implements","import","in","instanceof","interface","let","new","null","package","private","protected","public","return","static","super","switch","this","throw","true","try","typeof","var","void","while","with","yield"]),S=/^import\s*\{\s*defineMigration\s*\}\s*from\s*["'](?:@lunora\/server|lunorash\/server)["'][^\n]*$/mu,rr=r=>`import { defineMigration } from "${E(r)?.has("lunorash")??!1?"lunorash/server":"@lunora/server"}";`,er="__lunora_admin__:runMigration",tr="__lunora_admin__:migrationStatus",or="/_lunora/migrate",nr=r=>U(r.trim().toLowerCase().replaceAll(x,"-"),"-"),ir=r=>r.split("-").filter(e=>e.length>0).map((e,o)=>o===0?e:e.charAt(0).toUpperCase()+e.slice(1)).join(""),ar=r=>{const e=c(r,"lunora","schema.ts");if(!m(e))return[];try{const o=new h({skipAddingFilesFromTsConfig:!0});return _(o,e).tables.map(t=>t.name)}catch{return[]}},sr=async r=>r.length>0?N("Which table does this migration iterate?",r.map(e=>({label:e,value:e}))):R("Target table for the migration: "),cr=async(r,e)=>{if(e.table!==void 0)return e.table;const o=e.promptTable??(F()?sr:void 0);if(o===void 0){e.logger.error("migrate create requires a target table when not running interactively — re-run with --table <table>");return}const t=(await o(ar(r)))?.trim();if(t===void 0||t===""){e.logger.error("no table selected — re-run with --table <table>");return}return t},dr=async r=>{const e=r.cwd??process.cwd(),o=nr(r.name);if(o==="")return r.logger.error(`invalid migration name: "${r.name}" — must contain at least one alphanumeric character`),{code:1,file:""};const t=ir(o);if(!v.test(t)||X.has(t))return r.logger.error(`invalid migration name: "${r.name}" derives the export \`${t}\`, which is not a valid identifier — pick a name that starts with a letter and isn't a reserved word`),{code:1,file:""};const n=await cr(e,r);if(n===void 0)return{code:1,file:""};if(!v.test(n))return r.logger.error(`invalid table: "${n}" — must be a valid identifier ([A-Za-z_][A-Za-z0-9_]*)`),{code:1,file:""};const s=c(e,"lunora"),i=c(s,V);let a=m(i)?T(i,"utf8"):"";if(a.includes(`id: "${o}"`)||new RegExp(String.raw`\bexport const ${t}\b`,"u").test(a))return r.logger.error(`a migration with id "${o}" (export \`${t}\`) already exists in ${i}`),{code:1,file:""};const d=rr(e);a.trim()===""?a=`${d}
3
+ `:S.test(a)?a=a.replace(S,d):a=`${d}
4
4
  ${a}`;const l=`export const ${t} = defineMigration({
5
5
  id: "${o}",
6
6
  table: "${n}",
7
7
  up: (document) => document,
8
- });`;return S(s,{recursive:!0}),p(i,`${a.trimEnd()}
8
+ });`;return k(s,{recursive:!0}),f(i,`${a.trimEnd()}
9
9
 
10
10
  ${l}
11
- `,"utf8"),r.logger.success(`scaffolded migration "${o}" in ${i}`),{code:0,file:i}},cr=(r,e)=>{const o=new f({skipAddingFilesFromTsConfig:!0});return E(o,c(r,"lunora")).find(t=>t.id===e)?.table},dr=(r,e)=>{let o;try{o=cr(r,e.id)}catch(t){e.logger.error(t instanceof Error?t.message:String(t));return}if(o===void 0){e.logger.error(`migration "${e.id}" not found under lunora/ — declare it with defineMigration({ id: "${e.id}", ... })`);return}if(o===""){e.logger.error(`migration "${e.id}" must declare \`table\` as a static string literal`);return}return o},lr=r=>{const e=r.cwd??process.cwd();if(r.prod&&r.url===void 0){r.logger.error("--prod requires an explicit --url (refusing to migrate the implicit localhost worker)");return}if(r.prod&&(r.subcommand==="up"||r.subcommand==="down")&&!r.yes){r.logger.error(`migrate ${r.subcommand} --prod runs the migration against production. Re-run with --yes to confirm.`);return}const o=r.token??process.env.LUNORA_ADMIN_TOKEN;if(!o){r.logger.error("admin token required — pass --token or set LUNORA_ADMIN_TOKEN");return}const t=dr(e,r);if(t===void 0)return;const n=R(r.url,r.logger,r.cwd);if(n===void 0)return;const s=r.fetchImpl??globalThis.fetch;if(typeof s!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");return{fetchImpl:s,requestUrl:`${n}${er}`,table:t,token:o}},ur=r=>{const e={id:r.id};return r.subcommand==="status"||(e.direction=r.subcommand,r.dryRun&&(e.dryRun=!0),r.batchSize!==void 0&&(e.batchSize=r.batchSize),r.maxBatches!==void 0&&(e.maxBatches=r.maxBatches)),e},mr=async r=>{const e=lr(r);if(e===void 0)return{body:void 0,code:1,requestUrl:""};const{fetchImpl:o,requestUrl:t,table:n,token:s}=e,i=r.subcommand==="status"?rr:X,a=ur(r);r.logger.info(`POST ${t} -> ${r.subcommand} ${r.id} (table "${n}")`);const d=await o(t,{body:JSON.stringify({args:a,functionPath:i,table:n}),headers:{authorization:`Bearer ${s}`,"content-type":"application/json"},method:"POST"});return{body:await B(d,r.logger),code:d.ok?0:1,requestUrl:t}},gr=async r=>{const{logger:e}=r,o=r.fromUrl??r.toUrl,t=r.toUrl??r.fromUrl;if(o!==void 0&&o===t)return e.error("source and target are the same deployment — pass distinct --from-url and --to-url so the D1 export and Hyperdrive import don't run against one database"),{code:1};const n=r.out===void 0?C(c(M(),"lunora-d1ps-")):void 0,s=r.out??c(n,"dump.ndjson");try{e.info(`Exporting .global() data from the D1 source (${o??"http://localhost:8787"}) …`);const i=await H({fetchImpl:r.fetchImpl,logger:e,out:s,prod:r.prod,tables:r.tables,token:r.fromToken,url:o});if(i.code!==0)return{code:i.code};e.info(`Exported ${String(i.rows)} row(s) (${String(i.bytes)} bytes).`),e.info(`Importing into the Hyperdrive target (${t??"http://localhost:8787"}) …`);const a=await P({batchSize:r.batchSize,fetchImpl:r.fetchImpl,file:s,logger:e,prod:r.prod,token:r.toToken,url:t});return a.code!==0?{code:a.code}:(a.inserted===i.rows?e.info(`✓ Migrated ${String(i.rows)} row(s) — counts match. Verify your app reads from Hyperdrive, then decommission the D1 binding.`):e.warn(`Imported ${String(a.inserted)} of ${String(i.rows)} exported row(s) — the remainder likely already existed in the target (see conflicts above). Re-run after resolving, or inspect the dump with --out.`),{code:0})}finally{n!==void 0&&I(n,{force:!0,recursive:!0})}},Ir=q(({argument:r,cwd:e,logger:o,options:t})=>{const n=r[0];if(n==="generate")return W({cwd:e,logger:o,name:r[1]??t.name});if(n==="d1-to-hyperdrive")return gr({batchSize:t.batchSize,fromToken:t.fromToken??t.token,fromUrl:t.fromUrl??t.url,logger:o,out:t.out,prod:t.prod===!0,tables:t.tables,toToken:t.toToken??t.token,toUrl:t.toUrl??t.url});if(n==="create"){const s=r[1]??t.name;return s?sr({cwd:e,logger:o,name:s,table:t.table}):(o.error("migrate create requires a name. Usage: lunora migrate create <name> [--table <table>]"),{code:1})}if(n==="up"||n==="down"||n==="status"){const s=r[1]??t.name;return s?mr({batchSize:t.batchSize,cwd:e,dryRun:t.dryRun===!0,id:s,logger:o,maxBatches:t.steps,prod:t.prod===!0,subcommand:n,token:t.token,url:L({cwd:e,prod:t.prod===!0,url:t.url}),yes:t.yes===!0}):(o.error(`migrate ${n} requires a migration id. Usage: lunora migrate ${n} <id>`),{code:1})}return o.error(`unknown migrate subcommand: "${n??""}" — expected generate | create | up | down | status`),{code:1}});export{Ir as execute,sr as runMigrateCreateCommand,mr as runMigrateDataCommand,W as runMigrateGenerateCommand,gr as runMigrateToHyperdriveCommand};
11
+ `,"utf8"),r.logger.success(`scaffolded migration "${o}" in ${i}`),{code:0,file:i}},lr=(r,e)=>{const o=new h({skipAddingFilesFromTsConfig:!0});return z(o,c(r,"lunora")).find(t=>t.id===e)?.table},ur=(r,e)=>{const o=W(e.id);if(o!==void 0)return o;if(e.id.startsWith(u)){e.logger.error(`"${e.id}" names no table — use ${u}<table>`);return}let t;try{t=lr(r,e.id)}catch(n){e.logger.error(n instanceof Error?n.message:String(n));return}if(t===void 0){e.logger.error(`migration "${e.id}" not found under lunora/ — declare it with defineMigration({ id: "${e.id}", ... })`);return}if(t===""){e.logger.error(`migration "${e.id}" must declare \`table\` as a static string literal`);return}return t},mr=r=>{const e=r.cwd??process.cwd();if(r.prod&&r.url===void 0){r.logger.error("--prod requires an explicit --url (refusing to migrate the implicit localhost worker)");return}if(r.prod&&(r.subcommand==="up"||r.subcommand==="down")&&!r.yes){r.logger.error(`migrate ${r.subcommand} --prod runs the migration against production. Re-run with --yes to confirm.`);return}const o=r.token??process.env.LUNORA_ADMIN_TOKEN;if(!o){r.logger.error("admin token required — pass --token or set LUNORA_ADMIN_TOKEN");return}const t=ur(e,r);if(t===void 0)return;const n=q(r.url,r.logger,r.cwd);if(n===void 0)return;const s=r.fetchImpl??globalThis.fetch;if(typeof s!="function")throw new TypeError("no fetch implementation available — pass fetchImpl or run on Node >= 18");return{fetchImpl:s,requestUrl:`${n}${or}`,table:t,token:o}},gr=r=>{const e={id:r.id};return r.subcommand==="status"||(e.direction=r.subcommand,r.dryRun&&(e.dryRun=!0),r.batchSize!==void 0&&(e.batchSize=r.batchSize),r.maxBatches!==void 0&&(e.maxBatches=r.maxBatches)),e},pr=async r=>{const e=mr(r);if(e===void 0)return{body:void 0,code:1,requestUrl:""};const{fetchImpl:o,requestUrl:t,table:n,token:s}=e,i=r.subcommand==="status"?tr:er,a=gr(r);r.logger.info(`POST ${t} -> ${r.subcommand} ${r.id} (table "${n}")`);const d=await o(t,{body:JSON.stringify({args:a,functionPath:i,table:n}),headers:{authorization:`Bearer ${s}`,"content-type":"application/json"},method:"POST"});return{body:await H(d,r.logger),code:d.ok?0:1,requestUrl:t}},fr=async r=>{const{logger:e}=r,o=r.fromUrl??r.toUrl,t=r.toUrl??r.fromUrl;if(o!==void 0&&o===t)return e.error("source and target are the same deployment — pass distinct --from-url and --to-url so the D1 export and Hyperdrive import don't run against one database"),{code:1};const n=r.out===void 0?A(c(M(),"lunora-d1ps-")):void 0,s=r.out??c(n,"dump.ndjson");try{e.info(`Exporting .global() data from the D1 source (${o??"http://localhost:8787"}) …`);const i=await P({fetchImpl:r.fetchImpl,logger:e,out:s,prod:r.prod,tables:r.tables,token:r.fromToken,url:o});if(i.code!==0)return{code:i.code};e.info(`Exported ${String(i.rows)} row(s) (${String(i.bytes)} bytes).`),e.info(`Importing into the Hyperdrive target (${t??"http://localhost:8787"}) …`);const a=await J({batchSize:r.batchSize,fetchImpl:r.fetchImpl,file:s,logger:e,prod:r.prod,token:r.toToken,url:t});return a.code!==0?{code:a.code}:(a.inserted===i.rows?e.info(`✓ Migrated ${String(i.rows)} row(s) — counts match. Verify your app reads from Hyperdrive, then decommission the D1 binding.`):e.warn(`Imported ${String(a.inserted)} of ${String(i.rows)} exported row(s) — the remainder likely already existed in the target (see conflicts above). Re-run after resolving, or inspect the dump with --out.`),{code:0})}finally{n!==void 0&&I(n,{force:!0,recursive:!0})}},Mr=O(({argument:r,cwd:e,logger:o,options:t})=>{const n=r[0];if(n==="generate")return G({cwd:e,logger:o,name:r[1]??t.name});if(n==="d1-to-hyperdrive")return fr({batchSize:t.batchSize,fromToken:t.fromToken??t.token,fromUrl:t.fromUrl??t.url,logger:o,out:t.out,prod:t.prod===!0,tables:t.tables,toToken:t.toToken??t.token,toUrl:t.toUrl??t.url});if(n==="create"){const s=r[1]??t.name;return s?dr({cwd:e,logger:o,name:s,table:t.table}):(o.error("migrate create requires a name. Usage: lunora migrate create <name> [--table <table>]"),{code:1})}if(n==="up"||n==="down"||n==="status"){const s=r[1]??t.name;return s?pr({batchSize:t.batchSize,cwd:e,dryRun:t.dryRun===!0,id:s,logger:o,maxBatches:t.steps,prod:t.prod===!0,subcommand:n,token:t.token,url:j({cwd:e,prod:t.prod===!0,url:t.url}),yes:t.yes===!0}):(o.error(`migrate ${n} requires a migration id. Usage: lunora migrate ${n} <id>`),{code:1})}return o.error(`unknown migrate subcommand: "${n??""}" — expected generate | create | up | down | status`),{code:1}});export{Mr as execute,dr as runMigrateCreateCommand,pr as runMigrateDataCommand,G as runMigrateGenerateCommand,fr as runMigrateToHyperdriveCommand};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/cli",
3
- "version": "1.0.0-alpha.151",
3
+ "version": "1.0.0-alpha.153",
4
4
  "description": "The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands",
5
5
  "keywords": [
6
6
  "agent-skills",
@@ -54,12 +54,12 @@
54
54
  "@bomb.sh/tab": "0.0.21",
55
55
  "@lunora/advisor": "1.0.0-alpha.71",
56
56
  "@lunora/bindings": "1.0.0-alpha.23",
57
- "@lunora/codegen": "1.0.0-alpha.96",
58
- "@lunora/config": "1.0.0-alpha.125",
57
+ "@lunora/codegen": "1.0.0-alpha.98",
58
+ "@lunora/config": "1.0.0-alpha.127",
59
59
  "@lunora/container": "1.0.0-alpha.25",
60
- "@lunora/d1": "1.0.0-alpha.68",
60
+ "@lunora/d1": "1.0.0-alpha.69",
61
61
  "@lunora/errors": "1.0.0-alpha.16",
62
- "@lunora/mcp": "1.0.0-alpha.61",
62
+ "@lunora/mcp": "1.0.0-alpha.62",
63
63
  "@lunora/runtime": "1.0.0-alpha.57",
64
64
  "@lunora/seed": "1.0.0-alpha.66",
65
65
  "@visulima/cerebro": "3.0.0",