@lunora/config 1.0.0-alpha.44 → 1.0.0-alpha.440
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +135 -0
- package/README.md +3 -3
- package/dist/cli/index.d.mts +2 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.mjs +1 -0
- package/dist/cloudflare/index.d.mts +1336 -0
- package/dist/cloudflare/index.d.ts +1336 -0
- package/dist/cloudflare/index.mjs +1 -0
- package/dist/index.d.mts +962 -974
- package/dist/index.d.ts +962 -974
- package/dist/index.mjs +1 -23
- package/dist/packem_shared/ACCENT-CotPTfv7.mjs +7 -0
- package/dist/packem_shared/AGENT_MODE_ENV-D8MvSwPE.mjs +1 -0
- package/dist/packem_shared/AGENT_RULES_DIR-Bd6JPtNa.mjs +1 -0
- package/dist/packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs +1 -0
- package/dist/packem_shared/BINDING_MANIFEST_VERSION-CfXEYG8e.mjs +1 -0
- package/dist/packem_shared/BUILD_ROOT_ENV-Dg4MV3wY.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_CLI_CONFIG_WARNING_ENV-BKMrOuXV.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_DRIVER-DJwtY5NT.mjs +1 -0
- package/dist/packem_shared/CLOUDFLARE_TOOLCHAIN_VERSIONS-DV5E_f_q.mjs +1 -0
- package/dist/packem_shared/COMPOSED_WORKER_ENTRY-Ciiba5g_.mjs +1 -0
- package/dist/packem_shared/D1_PLACEHOLDER_ID-ZnDjVymH.mjs +1 -0
- package/dist/packem_shared/DEFAULT_DEPLOY_TARGET-D_krePy-.mjs +1 -0
- package/dist/packem_shared/DEFAULT_OBSERVABILITY-CPLADr5u.mjs +1 -0
- package/dist/packem_shared/DEV_BINDINGS_FILE-C0ZN_XlP.mjs +4 -0
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs +6 -0
- package/dist/packem_shared/DEV_WORKER_ENV_VALUE-CgozgOxh.mjs +1 -0
- package/dist/packem_shared/GLOBAL_FETCH_STRICTLY_PUBLIC_FLAG-f8CnJha3.mjs +1 -0
- package/dist/packem_shared/LINKED_PROJECT_DIR-Ba5qPEwo.mjs +2 -0
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-B9ZVohjO.mjs +1 -0
- package/dist/packem_shared/LUNORA_IGNORED_PATHS-U93uPxrW.mjs +19 -0
- package/dist/packem_shared/LUNORA_TAG-DQTGPqcJ.mjs +1 -0
- package/dist/packem_shared/LunoraReporter-f277GLNT.mjs +6 -0
- package/dist/packem_shared/MissingBuildOutputError-BAyekzof.mjs +1 -0
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-ByJhGJMf.mjs +1 -0
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-D5PpQPkf.mjs +1 -0
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-DooK0pzs.mjs +1 -0
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-D4UcOP_t.mjs +1 -0
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-CtxWqfDe.mjs +1 -0
- package/dist/packem_shared/SEED_ENDPOINT-C1fhrehH.mjs +1 -0
- package/dist/packem_shared/STUDIO_PATH-Dc-3nLO6.mjs +1 -0
- package/dist/packem_shared/STUDIO_WRITE_TEMP_SUFFIX-BTTELz3K.mjs +1 -0
- package/dist/packem_shared/UNEXPORTED_CLASS_MARKER-B06-1J8H.mjs +1 -0
- package/dist/packem_shared/WORKERS_CACHE_MIN_DATE-0k9ABJtF.mjs +1 -0
- package/dist/packem_shared/WRANGLER_FILES-UNW-xY5u.mjs +1 -0
- package/dist/packem_shared/acceptsConnection-DHhUYGjT.mjs +2 -0
- package/dist/packem_shared/addArgsFor-CYZKhNIo.mjs +1 -0
- package/dist/packem_shared/applyAdditiveEdit-DEwPKcJg.mjs +6 -0
- package/dist/packem_shared/applyModify-DKP2l6S9.mjs +1 -0
- package/dist/packem_shared/assertBuildTargetMatches-t0UvJp_O.mjs +1 -0
- package/dist/packem_shared/assertWranglerSatisfiesSchema-CNwRRCbB.mjs +3 -0
- package/dist/packem_shared/assetContentType-CUb5bpbI.mjs +1 -0
- package/dist/packem_shared/bindingsNeedingDatabase-6eD6Qtqf.mjs +3 -0
- package/dist/packem_shared/blockingFindingsMessage-CRbg1sla.mjs +1 -0
- package/dist/packem_shared/buildPackageSecretsBlock-GvaLgvFN.mjs +19 -0
- package/dist/packem_shared/canonicalPath-DrfMiT3U.mjs +1 -0
- package/dist/packem_shared/celld-binding-id-9MiUoteo.mjs +1 -0
- package/dist/packem_shared/celld-config-DoBVipuN.mjs +3 -0
- package/dist/packem_shared/classifyPolicyEdit-DJi9Fk8G.mjs +24 -0
- package/dist/packem_shared/clearApiSpecMarker-DMGpP41V.mjs +2 -0
- package/dist/packem_shared/collectExportGaps-B53R2mba.mjs +2 -0
- package/dist/packem_shared/createConfirm-D5mKTMHj.mjs +7 -0
- package/dist/packem_shared/createDiscoveryCache-npJI4uej.mjs +1 -0
- package/dist/packem_shared/createStudioDocumentCache-B3Sf1bIl.mjs +1 -0
- package/dist/packem_shared/deploy-driver.d-BqO40t1Q.d.mts +186 -0
- package/dist/packem_shared/deploy-driver.d-BqO40t1Q.d.ts +186 -0
- package/dist/packem_shared/describePreservedCrons-Bt2rPPeY.mjs +1 -0
- package/dist/packem_shared/describeWithheld-CbyzZjZF.mjs +1 -0
- package/dist/packem_shared/detectFramework-Dfpvu6rD.mjs +1 -0
- package/dist/packem_shared/devVariablesStamp-Cetr3qFz.mjs +1 -0
- package/dist/packem_shared/discover-info-DC2MrAIM.mjs +1 -0
- package/dist/packem_shared/discoverAgentInfo-pqFMJBtJ.mjs +1 -0
- package/dist/packem_shared/discoverContainerInfo-DzXr7Vm3.mjs +1 -0
- package/dist/packem_shared/discoverSchemaInfo-DRPnqgif.mjs +1 -0
- package/dist/packem_shared/discoverWorkflowInfo-zW7Tt0Tn.mjs +1 -0
- package/dist/packem_shared/ensureGitignoreEntries-Tsk8Qkw7.mjs +7 -0
- package/dist/packem_shared/guards-Buu_E7mP.mjs +1 -0
- package/dist/packem_shared/hasCloudflareCredentials-Bak5w1_6.mjs +1 -0
- package/dist/packem_shared/index.d-BuYbPa9W.d.ts +270 -0
- package/dist/packem_shared/index.d-CGlT0loP.d.mts +270 -0
- package/dist/packem_shared/infer-bindings.d-BUdWC3tw.d.mts +323 -0
- package/dist/packem_shared/infer-bindings.d-BUdWC3tw.d.ts +323 -0
- package/dist/packem_shared/inferLunoraBindings-DvB8IpbN.mjs +1 -0
- package/dist/packem_shared/materializeServiceDevConfigs-qUY4_iu1.mjs +1 -0
- package/dist/packem_shared/mergeWranglerEnvironment-D5ekKj5x.mjs +1 -0
- package/dist/packem_shared/package-secrets-registry-UQ_uEAB_.mjs +1 -0
- package/dist/packem_shared/parseSchema-D1Wbr1qv.mjs +1 -0
- package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.mts +86 -0
- package/dist/packem_shared/policy-scaffold.d-D2H4_G01.d.ts +86 -0
- package/dist/packem_shared/probeCelldToolchain-DxDttfHy.mjs +1 -0
- package/dist/packem_shared/process-tree-once-Ou4SfxKM.mjs +1 -0
- package/dist/packem_shared/readManifest-Cighz3WC.mjs +6 -0
- package/dist/packem_shared/readProjectDependencies-l3uhUKjo.mjs +1 -0
- package/dist/packem_shared/reconcile-services-C4TwY8YH.mjs +1 -0
- package/dist/packem_shared/reconcileBindingsSafely-t02cOkaF.mjs +1 -0
- package/dist/packem_shared/reconcileWranglerCompatibilityDate-hocXEuRA.mjs +1 -0
- package/dist/packem_shared/renderStudioHtml-ByowDtMl.mjs +15 -0
- package/dist/packem_shared/resolveSchemaDirectory-Ca5P6KuP.mjs +1 -0
- package/dist/packem_shared/runPostCodegenHook-Dx3yTsYZ.mjs +1 -0
- package/dist/packem_shared/scanWranglerVariablesForSecrets-DRBYlMYb.mjs +1 -0
- package/dist/packem_shared/sendStudioAsset-XBmVLqiI.mjs +1 -0
- package/dist/packem_shared/serveJsonHandler-B8_GE6QC.mjs +1 -0
- package/dist/packem_shared/startCelldDevSession-BKRiLvt-.mjs +1 -0
- package/dist/packem_shared/streamContainerLogs-0nko1qpv.mjs +2 -0
- package/dist/packem_shared/validate-bindings-PVHSAU6M.mjs +1 -0
- package/dist/packem_shared/withTailConsumer-CF3pk_Ov.mjs +1 -0
- package/dist/packem_shared/worker-entry-checks-AIASCYl7.mjs +1 -0
- package/dist/packem_shared/wranglerCodegenInputs-BZamZrPz.mjs +1 -0
- package/dist/packem_shared/wranglerToAlchemy-CBO2ucRm.mjs +6 -0
- package/dist/packem_shared/write-atomic-DRRKWKF-.mjs +3 -0
- package/dist/studio-host/index.d.mts +358 -136
- package/dist/studio-host/index.d.ts +358 -136
- package/dist/studio-host/index.mjs +1 -7
- package/package.json +32 -7
- package/dist/packem_shared/ACCENT-DW1XJn8i.mjs +0 -40
- package/dist/packem_shared/AGENT_RULES_DIR-lcgC08aE.mjs +0 -40
- package/dist/packem_shared/DEV_VARS_EXAMPLE_FILE-dJPNTEnK.mjs +0 -37
- package/dist/packem_shared/LINKED_PROJECT_DIR-CXwXzV_C.mjs +0 -52
- package/dist/packem_shared/LUNORA_CONFIG_FILE-CtcIcB5-.mjs +0 -34
- package/dist/packem_shared/LUNORA_EVENT_SOURCE-D2fDeGB6.mjs +0 -86
- package/dist/packem_shared/LunoraReporter-Ci-bDCK9.mjs +0 -70
- package/dist/packem_shared/PACKAGE_SECRETS_REGISTRY-B8t_SdoZ.mjs +0 -70
- package/dist/packem_shared/POLICY_SCAFFOLD_ENDPOINT-CiC2IGKx.mjs +0 -103
- package/dist/packem_shared/REMOTE_ELIGIBLE_KEYS-BC7_e9Bz.mjs +0 -105
- package/dist/packem_shared/REQUIRED_COMPATIBILITY_DATE-2YYyWJUq.mjs +0 -561
- package/dist/packem_shared/SCHEMA_EDIT_ENDPOINT-Df-Wrix-.mjs +0 -99
- package/dist/packem_shared/SEED_ENDPOINT-DVCjaGO-.mjs +0 -61
- package/dist/packem_shared/WRANGLER_FILES-DwSuC-Kn.mjs +0 -25
- package/dist/packem_shared/applyAdditiveEdit-C-snTFEV.mjs +0 -228
- package/dist/packem_shared/assetContentType-ByZjeV3D.mjs +0 -72
- package/dist/packem_shared/buildPackageSecretsBlock-BCHtfQ2A.mjs +0 -280
- package/dist/packem_shared/classifyPolicyEdit-BHeAqF8P.mjs +0 -99
- package/dist/packem_shared/createConfirm-fvpdgJ9s.mjs +0 -100
- package/dist/packem_shared/detectFramework-Br-BcPBq.mjs +0 -41
- package/dist/packem_shared/discoverContainerInfo-BXFs6Wav.mjs +0 -19
- package/dist/packem_shared/discoverSchemaInfo-BB-CKlTK.mjs +0 -25
- package/dist/packem_shared/discoverWorkflowInfo-CedvR0mn.mjs +0 -19
- package/dist/packem_shared/inferLunoraBindings-ByMwG-gH.mjs +0 -352
- package/dist/packem_shared/parseDevVariable-CJiq2IwE.mjs +0 -30
- package/dist/packem_shared/parseSchema-DSeyktvG.mjs +0 -107
- package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.mts +0 -74
- package/dist/packem_shared/policy-scaffold.d-DCmwn7zQ.d.ts +0 -74
- package/dist/packem_shared/reconcileWranglerBindings-Cruwwx1M.mjs +0 -334
- package/dist/packem_shared/renderStudioHtml-449Ysn75.mjs +0 -37
- package/dist/packem_shared/serveJsonHandler-B4OLTGLS.mjs +0 -86
- package/dist/packem_shared/streamContainerLogs-BZ4cOZwH.mjs +0 -157
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{readFileSync as ee,writeFileSync as ne}from"node:fs";import{createRequire as se}from"node:module";import{join as Q}from"node:path";import{containerBuildTag as te}from"@lunora/container";import{readJsonSync as ie}from"@visulima/fs";import{c as oe}from"./celld-binding-id-9MiUoteo.mjs";import{applyModify as w}from"./applyModify-DKP2l6S9.mjs";import{recordManifestKey as ae,readManifest as Y}from"./readManifest-Cighz3WC.mjs";import{D1_PLACEHOLDER_ID as U,HYPERDRIVE_PLACEHOLDER_ID as re}from"./D1_PLACEHOLDER_ID-ZnDjVymH.mjs";import{parseTree as de,findNodeAtLocation as ce}from"jsonc-parser";import{r as le,a as ue,b as ge,c as me}from"./reconcile-services-C4TwY8YH.mjs";import{DEV_VARS_FILE as pe,parseDevVariableEntries as fe}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";import{secretSourcesFromBindings as be}from"./inferLunoraBindings-DvB8IpbN.mjs";import{requiredSecrets as he}from"./buildPackageSecretsBlock-GvaLgvFN.mjs";import{w as ve,m as we,s as G,o as P,n as I,p as _e}from"./validate-bindings-PVHSAU6M.mjs";import{s as ye}from"./worker-entry-checks-AIASCYl7.mjs";import{DEFAULT_OBSERVABILITY as Se}from"./DEFAULT_OBSERVABILITY-CPLADr5u.mjs";import{findWranglerFile as Ee,readWranglerJsonc as xe}from"./WRANGLER_FILES-UNW-xY5u.mjs";const Ae=[["maxBatchSize","max_batch_size"],["maxBatchTimeout","max_batch_timeout"],["maxConcurrency","max_concurrency"],["maxRetries","max_retries"],["deadLetterQueue","dead_letter_queue"],["retryDelay","retry_delay"]],B=e=>Object.fromEntries(Ae.filter(([n])=>e.tuning[n]!==void 0).map(([n,s])=>[s,e.tuning[n]])),L="queueTuning",Oe=/^[\t ]*(?:,[\t ]*)?(?:\/\/[^\n\r]*)?\r?\n/u,Ne=/^[\t ]*,/u,ke=(e,n)=>{const s=de(e),t=s===void 0?void 0:ce(s,[...n])?.parent;if(t?.type==="property"){const o=t.offset+t.length,i=e.lastIndexOf(`
|
|
2
|
+
`,t.offset-1)+1,a=Oe.exec(e.slice(o));if(a!==null&&e.slice(i,t.offset).trim()===""){const m=t.parent?.children??[],u=m.indexOf(t),d=u===m.length-1&&u>0?m[u-1]:void 0,c=d===void 0?void 0:Ne.exec(e.slice(d.offset+d.length))??void 0;return(c===void 0||d===void 0?e.slice(0,i):e.slice(0,d.offset+d.length)+e.slice(d.offset+d.length+c[0].length,i))+e.slice(o+a[0].length)}}return w(e,n,void 0)},J=(e,n,s,t,o,i=new Set)=>{const a=s.join("."),m={},u=[],d=[];let c=e;return{entries:n.map((l,v)=>{const g=t(l);if(g===void 0||l.queue===void 0)return l;const b=Object.fromEntries(Object.entries(B(g)).filter(([f])=>!i.has(f))),h=Object.entries(o[l.queue]??{}).filter(([f])=>!Object.hasOwn(b,f)),_=Object.entries(b).filter(([f,y])=>l[f]!==y),E=h.filter(([f,y])=>l[f]===y).map(([f])=>f),O=Object.fromEntries(Object.entries({...l,...b}).filter(([f])=>!E.includes(f)));for(const[f,y]of _)c=w(c,[...s,v,f],y);for(const f of E)c=ke(c,[...s,v,f]);for(const[f,y]of h){const A=l[f];A!==void 0&&A!==y&&d.push(`${a}/${l.queue}: ${f} is no longer declared by defineQueue, but it was changed by hand to ${JSON.stringify(A)} from the declared ${JSON.stringify(y)}, so it was kept. Delete it from wrangler.jsonc if it should go.`)}return(_.length>0||E.length>0)&&u.push(`${a}/${l.queue} (${[..._.map(([f])=>f),...E.map(f=>`removed ${f}`)].join(", ")})`),Object.keys(b).length>0&&(m[l.queue]=b),O}),owned:m,text:c,updated:u,warnings:d}},$e=(e,n,s,t)=>{const o=n.queues??{},i=o.producers??[],a=o.consumers??[],m=new Set(i.map(g=>g?.binding)),u=new Set(a.map(g=>g.queue)),d=s.filter(g=>!m.has(g.bindingName)),c=s.filter(g=>!u.has(g.name)),p=J(e,a,["queues","consumers"],g=>s.find(b=>b.name===g.queue),t);let l=p.text;const v={...p.owned};if(d.length>0||c.length>0){const g=[...i,...d.map(h=>({binding:h.bindingName,queue:h.name}))],b=[...p.entries,...c.map(h=>({queue:h.name,...h.mode==="pull"?{type:"http_pull"}:{},...B(h)}))];for(const h of c){const _=B(h);Object.keys(_).length>0&&(v[h.name]=_)}l=w(l,["queues"],{consumers:b,producers:g})}return{added:[...d.map(g=>`queues.producers/${g.bindingName}`),...c.map(g=>`queues.consumers/${g.name}`)],owned:v,text:l,updated:p.updated,warnings:p.warnings}},Ce=(e,n,s,t,o)=>{const i=n.env?.[t],a=i?.queues?.consumers??[],m=i?.queues?.producers??[],u=l=>{const v=m.find(g=>g?.queue===l.queue)?.binding;return v!==void 0?s.find(g=>g.bindingName===v):s.find(g=>g.name===l.queue&&!m.some(b=>b?.binding===g.bindingName))},d=J(e,a,["env",t,"queues","consumers"],u,o,new Set(["dead_letter_queue"])),c=a.filter(l=>l.queue!==void 0&&u(l)===void 0).map(l=>`env.${t}.queues.consumers/${String(l.queue)}: no defineQueue export matches it — this block declares no producer mapping one of their bindings to "${String(l.queue)}", and no export is named that — so it was not retuned. A consumer for a queue another worker produces is skipped the same way.`),p=a.flatMap(l=>{const v=u(l)?.tuning.deadLetterQueue;return v===void 0||l.dead_letter_queue!==void 0?[]:[`env.${t}.queues.consumers/${String(l.queue)}: defineQueue declares deadLetterQueue "${v}", but this consumer has no dead_letter_queue, so its exhausted messages are dropped. Queue names differ per environment, so reconcile does not write it here; add it by hand.`]});return{added:[],owned:d.owned,text:d.text,updated:d.updated,warnings:[...d.warnings,...p,...c]}},Te=(e,n)=>{if(e?.lunoraIsForeign===!0)return n.push(`${e.path}: \`lunora\` is not an object, so the queue tuning ownership record cannot be read or written — an option removed from defineQueue stays deployed.`),{};const s=e?.lunora?.[L],t=o=>typeof o=="object"&&o!==null&&!Array.isArray(o);return s===void 0?{}:!t(s)||!Object.values(s).every(o=>t(o)&&Object.values(o).every(i=>t(i)))?(n.push(`${e?.path??"package.json"}: \`lunora.${L}\` is not a map of scope → queue → fields, so it is ignored — an option removed from defineQueue stays deployed until the next pass records it again.`),{}):s},Ie=(e,n,s)=>{const t=Object.fromEntries(Object.entries({...n,...s}).filter(([,o])=>Object.keys(o).length>0));ae(e,L,Object.keys(t).length===0?void 0:t)},je="https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/artifacts/namespaces",Re=e=>{const n='add an "artifacts" binding ({ binding: "ARTIFACTS", namespace }) — codegen reads env.ARTIFACTS unless `.artifacts()` on defineApp points ctx.artifacts at another binding';return e===void 0?`ctx.artifacts is used; ${n}. The namespace is created by the first repo create() if it does not exist yet.`:`ctx.artifacts is used and the schema pins data to "${e}"; create the namespace in that jurisdiction BEFORE the first repo, with POST ${je} and body { "namespace": "<name>", "jurisdiction": "${e}" }, then ${n}. A namespace's jurisdiction cannot be changed, and one created implicitly by the first repo create() is unrestricted. With CLOUDFLARE_API_TOKEN set, \`lunora deploy\` creates a missing namespace in that jurisdiction for a binding you have added.`},j="PIPELINES",R="ARTIFACTS",qe=(e,n,s)=>{const t=n!==void 0&&(s===void 0||s==="cloudflare"),o=e.flagshipBinding!==void 0&&!(n?.flagship??[]).some(d=>d.binding===e.flagshipBinding),i=e.usesPipelines&&!(n?.pipelines??[]).some(d=>d.binding===j),a=e.usesArtifacts?n?.artifacts??[]:[],m=a.some(d=>d.binding===R)?[]:a.flatMap(d=>d.binding===void 0?[]:[d.binding]);return[[e.usesKv&&(n?.kv_namespaces?.length??0)===0&&(!t||e.jurisdiction!==void 0),e.jurisdiction===void 0?'ctx.kv is used but no kv_namespaces binding exists; add one ({ binding: "KV" }) — wrangler creates the namespace on the first deploy.':`ctx.kv is used and the schema pins data to "${e.jurisdiction}"; run \`wrangler kv namespace create <name> --jurisdiction ${e.jurisdiction}\` and add a kv_namespaces entry ({ binding: "KV", id }) — a namespace wrangler creates on deploy is unrestricted.`],[e.usesHyperdrive&&(n?.hyperdrive?.length??0)===0&&!t,'@lunora/hyperdrive is used but no hyperdrive binding exists; add one ({ binding: "HYPERDRIVE", id }) — on a Cloudflare target `lunora deploy` creates the Hyperdrive config from a connection string.'],[e.usesArtifacts&&a.length===0&&(!t||e.jurisdiction!==void 0),Re(e.jurisdiction)],[i,`ctx.pipelines is used but no "${j}" pipelines binding exists; run 'wrangler pipelines create <name>' and add a 'pipelines' binding ({ binding: "${j}", stream }) — codegen resolves this one name, and the pipeline resource can't be auto-provisioned.`],[m.length>0,`ctx.artifacts is used and ${m.map(d=>`"${d}"`).join(", ")} ${m.length===1?"is":"are"} bound, but none is named "${R}"; make sure \`.artifacts()\` on defineApp points ctx.artifacts at it — otherwise it reads env.${R} and throws.`],[o,`lunora/flags.ts uses Flagship in binding mode but no flagship binding "${e.flagshipBinding??""}" exists; add a flagship entry ({ binding: "${e.flagshipBinding??""}", app_id }) — the app_id can't be auto-provisioned.`]].filter(([d])=>d).map(([,d])=>d)},De=e=>[[e.usesX402Charge,"@lunora/x402/charge is used; set the recipient wallet address as a [vars] entry (the var name is your choice) and pass it to the charge config — the x402 facilitator settles USDC to that address."],[e.usesX402,"@lunora/x402/pay is used (ActionCtx-only, spends real funds); add a secrets_store_secrets[] binding holding the agent wallet key (binding name == signer.secretName) and pair the pay rail with a spend policy — ctx.secrets reads a Secrets Store binding, not .dev.vars."]].filter(([s])=>s).map(([,s])=>s),q=(e,n,s)=>s.filter(t=>!t.exported).map(t=>`${e} "${t.exportName}" is declared but ${t.className} is not exported by the worker entry; add \`export * from "./lunora/_generated/${n}"\` so its binding can be provisioned.`),Pe=(e,n)=>{const s=new Set([...e.workflows,...e.agents].map(i=>i.className));if(s.size===0)return[];const t=Object.entries(n.exports??{}).flatMap(([i,a])=>a?.type==="workflow"?[i]:[]),o=(n.workflows??[]).flatMap(i=>i.class_name===void 0||i.script_name!==void 0?[]:[i.class_name]);return[...new Set([...t,...o])].filter(i=>!s.has(i)).map(i=>`wrangler.jsonc declares workflow "${i}" but no defineWorkflow/defineAgent export generates that class — a leftover from a rename will fail the deploy (wrangler rejects a class the worker does not export). Remove it if it is not hand-wired.`)},Be=(e,n)=>{if(e.queues.length===0)return[];const s=new Set(e.queues.map(o=>o.name)),t=new Set(e.queues.map(o=>o.bindingName));return[...(n.queues?.consumers??[]).flatMap(o=>{const{queue:i}=o;return i===void 0||s.has(i)?[]:[`wrangler.jsonc subscribes queues.consumers[] to "${i}" but no defineQueue export declares that queue — a leftover from a rename keeps delivering batches this worker has no handler for (they retry to exhaustion, then drop or dead-letter). Remove it if it is not hand-wired.`]}),...(n.queues?.producers??[]).flatMap(o=>{const i=o?.binding;return i===void 0||t.has(i)?[]:[`wrangler.jsonc declares queues.producers[] binding "${i}" but no defineQueue export declares it — a leftover from a rename. Remove it if it is not hand-wired.`]})]},Le=(e,n)=>[...Pe(e,n),...Be(e,n)],X=[{keys:["STRIPE_SECRET_KEY","STRIPE_WEBHOOK_SECRET"],label:"Stripe"},{keys:["POLAR_ACCESS_TOKEN","POLAR_WEBHOOK_SECRET"],label:"Polar"},{keys:["CREEM_API_KEY","CREEM_WEBHOOK_SECRET"],label:"Creem"},{keys:["AUTUMN_SECRET_KEY","AUTUMN_WEBHOOK_SECRET"],label:"Autumn"},{keys:["DODO_PAYMENTS_API_KEY","DODO_PAYMENTS_WEBHOOK_KEY"],label:"Dodo Payments"}],We=()=>X.map(({keys:e,label:n})=>`${e[0]} + ${e[1]} (${n})`).join(" or "),Me=e=>{let n;try{n=ee(Q(e,pe),"utf8")}catch{return!1}const s=new Map(fe(n).map(t=>[t.key,t.value]));return X.some(({keys:t})=>t.every(o=>(s.get(o)??"")!==""))},Ke=(e,n)=>{const s=n?.secrets?.required;if(!Array.isArray(s))return[];const t=new Set(s),o=he(be(e)).map(i=>i.key).filter(i=>!t.has(i));return o.length===0?[]:[`wrangler.jsonc declares secrets.required without ${o.join(", ")}, which this app needs — wrangler dev loads only the listed keys from .dev.vars, so add ${o.length===1?"it":"them"} to secrets.required.`]},D=(e,n,s,t)=>{const o=new Set(e.durableObjects.map(u=>u.className)),i=[],a=(s?.r2_buckets?.length??0)>0,m=(s?.d1_databases?.some(u=>u.binding==="DB")??!1)||e.needsD1;return e.usesStorage&&!a&&i.push("@lunora/storage is used but R2 bucket bindings have user-defined names; add an r2_buckets entry and pass env.<BINDING> to createStorage()."),e.usesAuth&&!o.has("SessionDO")&&!m&&i.push("@lunora/auth is used but the worker entry exports no SessionDO; sessions are D1-backed, or export SessionDO to enable DO-backed sessions."),e.usesScheduler&&!o.has("SchedulerDO")&&i.push("@lunora/scheduler is used but the worker entry exports no SchedulerDO; export it so the SCHEDULER binding can be provisioned."),i.push(...q("container","containers",e.containers),...q("workflow","workflows",e.workflows),...q("agent","agents",e.agents)),e.containers.length>0&&s?.observability?.enabled===!1&&i.push("containers are declared but observability is explicitly disabled in wrangler.jsonc — container logs will not be captured."),e.usesPayments&&!Me(n)&&i.push(`@lunora/payment is used; set one provider's secret pair in .dev.vars — ${We()}.`),i.push(...De(e),...qe(e,s,t),...Ke(e,s)),s!==void 0&&i.push(...Le(e,s)),i},Fe=e=>[["container","containers",e.containers],["workflow","workflows",e.workflows],["agent","agents",e.agents]].flatMap(([s,t,o])=>o.filter(i=>!i.exported).map(({className:i,exportName:a})=>({className:i,exportName:a,kind:s,module:t}))),He=e=>{const n=new Set(P(e).map(t=>t.tag));let s=1;for(;n.has(`v${String(s)}`);)s+=1;return`v${String(s)}`},Ye=e=>{const n=new Set;for(const s of P(e)){for(const t of I(s.deleted_classes))n.delete(t);for(const{from:t,to:o}of P(s.renamed_classes))t!==void 0&&n.delete(t),o!==void 0&&n.add(o);for(const t of[...I(s.new_classes),...I(s.new_sqlite_classes)])n.add(t)}return n},Ve=(e,n,s)=>{const t=n.durable_objects?.bindings??[],o=new Set(t.map(c=>c.name)),i=s.filter(c=>!o.has(c.binding));let a=e;const m=[];if(i.length>0){const c=[...t,...i.map(p=>({class_name:p.className,name:p.binding}))];a=w(a,["durable_objects","bindings"],c),m.push(...i.map(p=>`${p.binding}/${p.className}`))}const u=n.migrations??[],d=s.map(c=>c.className).filter(c=>!Ye(u).has(c));if(d.length>0){const c=[...u,{new_sqlite_classes:d,tag:He(u)}];a=w(a,["migrations"],c)}return{added:m,text:a}},M=e=>e===void 0||e==="cloudflare",Qe=(e,n)=>e.includes("DB (D1)")&&M(n)?[`wrote a DB binding with a placeholder database_id ("${U}") — run \`wrangler d1 create <name>\` and replace it before deploying.`]:[],Ue=(e,n)=>{const s=n.d1_databases??[];if(s.some(i=>i.binding==="DB"))return{added:[],text:e};const t=typeof n.name=="string"&&n.name.length>0?n.name:"lunora",o=[...s,{binding:"DB",database_id:U,database_name:t}];return{added:["DB (D1)"],text:w(e,["d1_databases"],o)}},Ge={ai:{binding:"AI",label:"AI (Workers AI)"},analytics:{binding:"ANALYTICS_SQL",label:"ANALYTICS_SQL (Analytics SQL)"},browser:{binding:"BROWSER",label:"BROWSER (Browser Rendering)"},images:{binding:"IMAGES",label:"IMAGES (Cloudflare Images)"}},k=(e,n,s)=>{const{binding:t,label:o}=Ge[s],i=n[s]?.binding;return typeof i=="string"&&i.length>0?{added:[],text:e}:{added:[o],text:w(e,[s],{binding:t})}},Je=(e,n)=>e.usesAnalyticsSql&&ye(n,new Set(["analyticsSql"]))?.chained.has("analyticsSql")!==!0,Xe=new Set(["ratelimits","send_email"]),ze=["durable_objects","logfwdr","unsafe"],Ze=new Set(["data_blobs","text_blobs","vars","wasm_modules"]),K=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),W=(e,n,s)=>K(e)&&e[n]===s,en=(e,n,s)=>{if(Ze.has(e))return K(n)&&Object.hasOwn(n,s);const t=Xe.has(e)?"name":"binding";return Array.isArray(n)?n.some(o=>W(o,t,s)):W(n,"binding",s)},$=(e,n)=>{const s=e,t=Object.entries(s).find(([i,a])=>i!=="env"&&en(i,a,n));if(t!==void 0)return t[0];for(const i of ze){const a=s[i];if(K(a)&&Array.isArray(a.bindings)&&a.bindings.some(m=>W(m,"name",n)))return`${i}.bindings`}if(e.queues?.producers?.some(i=>i?.binding===n)===!0)return"queues.producers";const o=e.secrets?.required;if(Array.isArray(o)&&o.includes(n))return"secrets.required"},F=(e,n,s)=>`${e}: not adding "${n}" — the name is already bound by \`${s}\` in wrangler.jsonc. Add a ${e} entry under another binding name and point the matching \`defineApp()\` override at it.`,nn=(e,n,s)=>{if(!M(s)||(n.hyperdrive?.length??0)>0)return{added:[],text:e};const t=$(n,"HYPERDRIVE");return t!==void 0?{added:[],text:e,warnings:[F("hyperdrive","HYPERDRIVE",t)]}:{added:["HYPERDRIVE (Hyperdrive, created on deploy)"],text:w(e,["hyperdrive"],[{binding:"HYPERDRIVE",id:re}])}},sn=new Set(["celld","cloudflare"]),tn=(e,n,s,t)=>{if(t!==void 0&&!sn.has(t)||s!==void 0||(n.kv_namespaces?.length??0)>0)return{added:[],text:e};const o=$(n,"KV");return o!==void 0?{added:[],text:e,warnings:[F("kv_namespaces","KV",o)]}:{added:[t==="celld"?`KV (Workers KV, celld namespace ${oe(n.name,"KV")})`:"KV (Workers KV, created on deploy)"],text:w(e,["kv_namespaces"],[{binding:"KV"}])}},on=(e,n,s,t)=>{if(!M(t)||s!==void 0||(n.artifacts?.length??0)>0)return{added:[],text:e};const o=$(n,"ARTIFACTS");if(o!==void 0)return{added:[],text:e,warnings:[F("artifacts","ARTIFACTS",o)]};const i=typeof n.name=="string"&&n.name.length>0?n.name:"lunora";return{added:["ARTIFACTS (Cloudflare Artifacts)"],text:w(e,["artifacts"],[{binding:"ARTIFACTS",namespace:i}])}},V=(e,n,s,t,o)=>{if((n[s]?.length??0)>0)return{added:[],text:e};const i=$(n,t.binding);return i!==void 0?{added:[],text:e,warnings:[`${s}: not adding ${JSON.stringify(t)} — the name "${t.binding}" is already bound by \`${i}\` in wrangler.jsonc. Add a ${s} entry under another binding name and point the matching \`defineApp()\` override at it.`]}:{added:[o],text:w(e,[s],[t])}},an=(e,n)=>{const s=n.worker_loaders??[];return s.some(t=>t.binding==="LOADER")?{added:[],text:e}:{added:["LOADER (Worker Loader)"],text:w(e,["worker_loaders"],[...s,{binding:"LOADER"}])}},rn=e=>{if(typeof e=="string")return e;const n={};return e.diskMb!==void 0&&(n.disk_mb=e.diskMb),e.memoryMib!==void 0&&(n.memory_mib=e.memoryMib),e.vcpu!==void 0&&(n.vcpu=e.vcpu),n},dn=e=>{const{image:n}=e;return n.kind==="dockerfile"?n.dockerfilePath:n.kind==="registry"?n.reference:te(e.exportName)},z=e=>{const n={};for(const[s,t]of Object.entries(e.images??{}))n[s]=t.kind==="registry"?{image:t.reference}:{build_context:t.buildContext,dockerfile:t.dockerfilePath,...e.buildArgs===void 0?{}:{build_vars:e.buildArgs}};return{class_name:e.className,scheduling_policy:"durable_object",...Object.keys(n).length>0?{images:n}:{},...e.name===void 0?{}:{name:e.name}}},cn=e=>{if(e.schedulingPolicy==="durable_object")return z(e);const{image:n}=e,s={class_name:e.className,image:dn(e)};return n.kind==="dockerfile"&&(s.image_build_context=n.buildContext),e.buildArgs!==void 0&&n.kind!=="registry"&&(s.image_vars=e.buildArgs),e.instanceType!==void 0&&(s.instance_type=rn(e.instanceType)),e.maxInstances!==void 0&&(s.max_instances=e.maxInstances),e.name!==void 0&&(s.name=e.name),e.rollout?.stepPercentage!==void 0&&(s.rollout_step_percentage=e.rollout.stepPercentage),e.rollout?.gracePeriodSeconds!==void 0&&(s.rollout_active_grace_period=e.rollout.gracePeriodSeconds),s},ln=(e,n,s)=>{const t=n.containers??[],o=new Set(t.map(d=>d.class_name)),i=s.filter(d=>!o.has(d.className));let a=i.length===0?e:w(e,["containers"],[...t,...i.map(d=>cn(d))]);const m=[],u=[];for(const[d,c]of t.entries()){const p=s.find(g=>g.className===c.class_name);if(p===void 0)continue;const l=p.schedulingPolicy??"default";if((c.scheduling_policy??"default")!==l){u.push(`containers/${p.className} has scheduling_policy "${c.scheduling_policy??"default"}" in wrangler.jsonc but defineContainer "${p.exportName}" declares "${l}" — the policy is immutable, so replace the entry (and its container application) by hand.`);continue}const v=p.schedulingPolicy==="durable_object"?z(p).images:void 0;v!==void 0&&JSON.stringify(c.images)!==JSON.stringify(v)&&(a=w(a,["containers",d,"images"],v),m.push(`containers/${p.className}.images`))}return{added:i.map(d=>`containers/${d.className}`),text:a,updated:m,warnings:u}},un=(e,n)=>{if(n.observability!==void 0)return{added:[],text:e};const s=w(e,["observability"],{...Se});return{added:["observability"],text:s}},gn=(e,n)=>n.upload_source_maps!==void 0?{added:[],text:e}:{added:["upload_source_maps"],text:w(e,["upload_source_maps"],!0)},Z=[{minimum:[4,142],name:"wrangler"},{minimum:[1,61],name:"@cloudflare/vite-plugin"}],mn=Z.map(({minimum:e,name:n})=>`${n}@^${e.join(".")}.0`).join(" "),pn=(e,n)=>{try{const s=se(Q(e,"package.json")).resolve(`${n}/package.json`),[t=0,o=0]=String(ie(s).version).split(".").map(Number);return[t,o]}catch{return}},fn=e=>{const n=Z.flatMap(({minimum:s,name:t})=>{const o=pn(e,t);return o!==void 0&&(o[0]<s[0]||o[0]===s[0]&&o[1]<s[1])?[`${t} ${o.join(".")} (needs >= ${s.join(".")})`]:[]});return n.length===0?void 0:`workflows are declared in wrangler \`exports\`, which ${n.join(" and ")} cannot run — reconcile left workflows[] untouched. Upgrade (\`pnpm add -D ${mn}\`) and re-run.`},bn=e=>Object.entries(e.env??{}).flatMap(([n,s])=>Array.isArray(s?.workflows)?[`env.${n}.workflows declares workflow bindings, but Lunora now declares workflows in \`exports\` and resolves them on ctx.exports — move them to that environment's own \`exports\` by hand.`]:[]),hn=(e,n,s)=>{let t=e;const o=[],i=[];for(const a of s){const m=n[a.className];if(m?.type==="workflow")for(const{of:u,path:d}of _e){const c=u(a),p=G(m,d),l=`exports/${a.className}.${d.join(".")}`;if(c===void 0){p!==void 0&&i.push(`${l} is set in wrangler.jsonc but defineWorkflow "${a.exportName}" does not declare it — reconcile leaves it in place. Remove it by hand if it was dropped from the definition.`);continue}JSON.stringify(p)!==JSON.stringify(c)&&(t=w(t,["exports",a.className,...d],c),o.push(l))}}return{text:t,updated:o,warnings:i}},vn=(e,n,s,t,o)=>{if(o!==void 0)return{added:[],text:e,warnings:[o]};const i=[...s.map(b=>({settings:ve(b),workflow:b})),...t.map(b=>({settings:{},workflow:b}))],a=new Set(i.map(({workflow:b})=>b.className)),m=n.workflows??[],u=m.filter(b=>b.script_name===void 0&&b.class_name!==void 0&&a.has(b.class_name)),d=n.exports??{},c=[],p=[],l=[];let v=e;for(const{settings:b,workflow:h}of i){if(d[h.className]!==void 0&&d[h.className]!==null)continue;const _=u.find(f=>f.class_name===h.className),E=Object.fromEntries(we.flatMap(f=>{const y=G(_,[f]);return y===void 0?[]:[[f,y]]})),O=_?.name??h.name;_?.name!==void 0&&_.name!==h.name&&l.push(`workflows/${h.className} is deployed as "${_.name}" but declared as "${h.name}" — its export keeps "${_.name}" so running instances survive. Change the declaration to match, or rename deliberately (it starts a new, empty workflow).`),v=w(v,["exports",h.className],{type:"workflow",...E,...b,name:O}),(_===void 0?c:p).push(`exports/${h.className}`)}if(u.length>0){const b=m.filter(h=>!u.includes(h));v=w(v,["workflows"],b.length===0?void 0:b),p.push(...u.map(h=>`workflows/${String(h.class_name)} → exports`))}l.push(...bn(n));const g=hn(v,d,s);return{added:c,text:g.text,updated:[...p,...g.updated],warnings:[...l,...g.warnings]}},Pn=(e,n,{environment:s,target:t}={})=>{const o=Ee(e),i=Fe(n);if(!o)return{added:[],changed:!1,exportGaps:i,reason:"wrangler.jsonc not found",updated:[],warnings:D(n,e)};const{parsed:a,text:m}=xe(o);if(a===void 0)return{added:[],changed:!1,exportGaps:i,reason:`failed to parse ${o} as JSONC`,updated:[],warnings:D(n,e),wranglerPath:o};const u=D(n,e,a,t);if(s!==void 0){const r=a.env?.[s]!==void 0;u.push(r?`auto-provisioned bindings are written to the top level of wrangler.jsonc only (queue consumers "env.${s}" already declares are retuned, nothing is added) — "env.${s}" has its own (non-inheritable) bindings and must be reconciled by hand; \`lunora deploy --env ${s}\` now validates them, so a gap here will be reported at deploy time.`:`--env "${s}" was requested but wrangler.jsonc declares no "env.${s}" block — auto-provisioned bindings are written to the top level only and will not apply to that environment.`)}const d=n.containers.filter(r=>r.exported),c=n.agents.filter(r=>r.exported&&r.voice===!0&&r.voiceBindingName!==void 0&&r.voiceClassName!==void 0),p=[...n.durableObjects,...d.map(r=>({binding:r.bindingName,className:r.className})),...c.map(r=>({binding:r.voiceBindingName,className:r.voiceClassName}))],l=n.workflows.filter(r=>r.exported),v=n.agents.filter(r=>r.exported),g=Y(e),b=Te(g,u),h={},_=le(g);let E;const O=[{enabled:!0,run:r=>Ve(r,a,p)},{enabled:n.needsD1,run:r=>Ue(r,a)},{enabled:n.usesKv,run:r=>tn(r,a,n.jurisdiction,t)},{enabled:n.usesHyperdrive,run:r=>nn(r,a,t)},{enabled:n.usesArtifacts,run:r=>on(r,a,n.jurisdiction,t)},{enabled:n.usesAi,run:r=>k(r,a,"ai")},{enabled:n.usesAiSearch,run:r=>V(r,a,"ai_search_namespaces",{binding:"AI_SEARCH",namespace:"default"},"AI_SEARCH (AI Search namespace)")},{enabled:Je(n,e),run:r=>k(r,a,"analytics")},{enabled:n.usesBrowser,run:r=>k(r,a,"browser")},{enabled:n.usesImages,run:r=>k(r,a,"images")},{enabled:n.usesAnalytics,run:r=>V(r,a,"analytics_engine_datasets",{binding:"ANALYTICS",dataset:"ANALYTICS"},"ANALYTICS (Analytics Engine)")},{enabled:n.usesWorkerLoader,run:r=>an(r,a)},{enabled:!0,run:r=>un(r,a)},{enabled:t===void 0||t==="cloudflare",run:r=>gn(r,a)},{enabled:d.length>0,run:r=>ln(r,a,d)},{enabled:l.length>0||v.length>0,run:r=>vn(r,a,l,v,fn(e))},{enabled:n.queues.length>0,run:r=>{const S=$e(r,a,n.queues,b.queues??{});return h.queues=S.owned,S}},{enabled:n.services!==void 0&&(n.services.length>0||Object.keys(_).length>0),run:r=>{const S=ue(r,a,n.services??[],_);return E=S.owned,S}},...s===void 0||a.env?.[s]===void 0?[]:[{enabled:n.queues.length>0,run:r=>{const S=`env.${s}.queues`,N=Ce(r,a,n.queues,s,b[S]??{});return h[S]=N.owned,N}}]];let f=m;const y=[],A=[];for(const r of O){if(!r.enabled)continue;const S=r.run(f);f=S.text,y.push(...S.added),A.push(...S.updated??[]),u.push(...S.warnings??[])}const H=r=>{if(g===void 0)return;const S=E,N=[...Object.keys(h).length>0?[{consequence:"an option removed from defineQueue stays deployed",key:"queueTuning",label:"queue tuning",write:x=>{Ie(x,b,h)}}]:[],...S===void 0?[]:[{consequence:"a service removed from lunora.config stays bound",key:"services",label:"service bindings",write:x=>{me(x,S)}}]];for(const x of N)try{x.write(Y(e)??g)}catch(T){u.push(`${r?"wrangler.jsonc was updated, but ":""}recording the ${x.label} reconcile owns in ${g.path} (lunora.${x.key}) failed: ${T instanceof Error?T.message:String(T)}. Until it is recorded, ${x.consequence}.`)}};let C;if(n.services!==void 0){const r=ge(e,n.services,_);u.push(...r.warnings),E={...E,...r.owned},C=r.added.length>0||r.updated.length>0?{added:r.added,path:r.path,updated:r.updated}:void 0}return u.push(...Qe(y,t)),f===m?(H(!1),{added:y,changed:!1,devConfig:C,exportGaps:i,reason:"bindings already in sync",updated:A,warnings:u,wranglerPath:o}):(ne(o,f,"utf8"),H(!0),{added:y,changed:!0,devConfig:C,exportGaps:i,updated:A,warnings:u,wranglerPath:o})};export{Fe as collectExportGaps,Pn as reconcileWranglerBindings};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{createInterface as v}from"node:readline";const y=/[\s,]+/u,u=()=>process.stdin.isTTY,d=async a=>{const e=v({input:process.stdin,output:process.stdout});try{return await new Promise(s=>{e.question(a,r=>{s(r)})})}finally{e.close()}},b=async(a,e)=>{const r=(await d(a)).trim().toLowerCase();return r===""?e?.defaultYes===!0:r==="y"||r==="yes"},S=(a="")=>u()?e=>b(`${a}${e} [Y/n] `,{defaultYes:!0}):()=>Promise.resolve(!1),T=async(a,e,s)=>{if(!u()||e.length===0)return s?.default;const r=s?.default===void 0?-1:e.findIndex(n=>n.value===s.default),f=e.map((n,t)=>` ${String(t+1)}) ${n.label}${n.description===void 0?"":` — ${n.description}`}`),m=`${a}
|
|
2
|
+
${f.join(`
|
|
3
|
+
`)}
|
|
4
|
+
> ${r>=0?`[${String(r+1)}] `:""}`,i=(await d(m)).trim();if(i==="")return s?.default;const c=Number.parseInt(i,10);return Number.isInteger(c)&&c>=1&&c<=e.length?e[c-1]?.value:e.find(n=>n.value===i||n.label.toLowerCase()===i.toLowerCase())?.value??s?.default},g=async(a,e)=>{if(!u())return e?.default;const r=(await d(a)).trim();return r===""?e?.default:r},h=async(a,e,s)=>{const r=s?.defaults??[];if(!u()||e.length===0)return[...r];const f=e.map((t,o)=>` ${String(o+1)}) ${t.label}${t.description===void 0?"":` — ${t.description}`}`),m=r.length===0?"":`[${r.join(", ")}] `,w=`${a} (comma-separated; Enter for default)
|
|
5
|
+
${f.join(`
|
|
6
|
+
`)}
|
|
7
|
+
> ${m}`,c=(await d(w)).trim();if(c==="")return[...r];const $=c.split(y).map(t=>t.trim()).filter(t=>t!==""),n=new Set;for(const t of $){const o=Number.parseInt(t,10);if(Number.isInteger(o)&&o>=1&&o<=e.length&&String(o)===t){const l=e[o-1]?.value;l!==void 0&&n.add(l);continue}const p=e.find(l=>l.value===t||l.label.toLowerCase()===t.toLowerCase());p!==void 0&&n.add(p.value)}return e.filter(t=>n.has(t.value)).map(t=>t.value)};export{S as createConfirm,u as isInteractive,h as promptMultiSelect,T as promptSelect,g as promptText,b as promptYesNo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=()=>{const e=new Map;return{clear:()=>{e.clear()},memo:(r,c)=>{if(e.has(r))return e.get(r);const t=c();return e.set(r,t),t}}};export{n as createDiscoveryCache};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{devVariablesStamp as u}from"./devVariablesStamp-Cetr3qFz.mjs";const c=(o,r)=>{let t,e;return()=>{const a=u(o);return(t===void 0||a!==e)&&(e=a,t={value:r()}),t.value}};export{c as default};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `DeployDriver` — the provider-neutral seam between a Lunora command and the
|
|
3
|
+
* host CLI that carries it out (plan 114, §5.3).
|
|
4
|
+
*
|
|
5
|
+
* The seam is the **toolchain surface**: which command a host runs to deploy,
|
|
6
|
+
* serve, tail, or set a secret. A driver only *describes* that command
|
|
7
|
+
* ({@link ToolchainCommand}); it never spawns. The CLI keeps ownership of
|
|
8
|
+
* running it — package-manager resolution (`pnpm exec` / `npx --` / `bun x`)
|
|
9
|
+
* and the injected spawner its tests substitute — so the driver stays free of
|
|
10
|
+
* process concerns and remains trivially testable as a pure function.
|
|
11
|
+
*
|
|
12
|
+
* Each request type below is deliberately neutral: `preview`, `environment`,
|
|
13
|
+
* `temporary` are concepts, not wrangler flags. A second host maps the same
|
|
14
|
+
* request onto its own CLI without the caller changing.
|
|
15
|
+
*
|
|
16
|
+
* Three drivers are registered: Cloudflare (`cloudflare/cloudflare-driver.ts`)
|
|
17
|
+
* and celld (`celld/celld-driver.ts`), which ship toolchains, and Node
|
|
18
|
+
* (`node/node-driver.ts`), which has none — it is a codegen target, and
|
|
19
|
+
* `lunora deploy` / `lunora dev` refuse it at selection.
|
|
20
|
+
*
|
|
21
|
+
* **What this seam deliberately does NOT carry: configuration inference.** It
|
|
22
|
+
* used to, through an `infer`/`provision` pair over a provider-neutral
|
|
23
|
+
* `ResourceGraph`. Nothing ever called either one — every consumer reads
|
|
24
|
+
* `.toolchain` or just validates the target — and the arm rotted in place: the
|
|
25
|
+
* Node driver was *only* `infer` + `provision`, so its report of what that
|
|
26
|
+
* target cannot serve (containers, undispatched crons) could not reach an
|
|
27
|
+
* operator however wrong the app was. The reason it never got wired is worth
|
|
28
|
+
* keeping: writing real host configuration needs the host's own encodings —
|
|
29
|
+
* binding names, DO class wiring, migration tags — which a neutral graph
|
|
30
|
+
* necessarily discards, so `provision` re-derived them anyway and the graph was
|
|
31
|
+
* decorative. A second target that needs to share inference should grow the
|
|
32
|
+
* seam back with a caller attached, and with an encoding escape hatch.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* A host CLI invocation, described but not run.
|
|
36
|
+
*
|
|
37
|
+
* `tool` is the binary name only (`"wrangler"`); the caller resolves how to
|
|
38
|
+
* execute it through the project's package manager (see `toolchainExecArgs`).
|
|
39
|
+
* Keeping that split means a driver never has to know whether the project uses
|
|
40
|
+
* pnpm, npm, yarn, or bun.
|
|
41
|
+
*/
|
|
42
|
+
interface ToolchainCommand {
|
|
43
|
+
/** Arguments for {@link ToolchainCommand.tool}. */
|
|
44
|
+
args: ReadonlyArray<string>;
|
|
45
|
+
/**
|
|
46
|
+
* The tool is a standalone binary installed on `PATH`, not a project
|
|
47
|
+
* dependency: run it directly. Going through the package manager would be
|
|
48
|
+
* wrong for it — `npx --` / `bun x` fetch an npm package of the same name
|
|
49
|
+
* when none is installed locally, which for a non-npm binary is somebody
|
|
50
|
+
* else's code.
|
|
51
|
+
*/
|
|
52
|
+
onPath?: boolean;
|
|
53
|
+
/** The host CLI binary, e.g. `"wrangler"`. */
|
|
54
|
+
tool: string;
|
|
55
|
+
}
|
|
56
|
+
/** Neutral options for a deploy. */
|
|
57
|
+
interface DeployRequest {
|
|
58
|
+
/** Host config file to deploy, when the flow uses a projected one (see {@link DeployDriver.projectConfig}). */
|
|
59
|
+
configPath?: string;
|
|
60
|
+
/** Validate and bundle without publishing — nothing ships. */
|
|
61
|
+
dryRun?: boolean;
|
|
62
|
+
/** Deploy this entry file instead of the host config's default (framework composition). */
|
|
63
|
+
entry?: string;
|
|
64
|
+
/** Named deployment environment, when the host supports them. */
|
|
65
|
+
environment?: string;
|
|
66
|
+
/** Write the built bundle (and any build metadata) to this directory. */
|
|
67
|
+
outDir?: string;
|
|
68
|
+
/** A file of secrets (JSON object of name to value) uploaded with the deployment, so a Worker's first version boots with them. */
|
|
69
|
+
secretsFile?: string;
|
|
70
|
+
/** Deploy to a short-lived, unauthenticated account where the host offers one. */
|
|
71
|
+
temporary?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Neutral options for a local dev server. */
|
|
74
|
+
interface DevRequest {
|
|
75
|
+
/** Host config file to run against, when the flow uses a generated one. */
|
|
76
|
+
configPath?: string;
|
|
77
|
+
/** Named environment. */
|
|
78
|
+
environment?: string;
|
|
79
|
+
/** Extra host-specific flags the caller has already resolved. */
|
|
80
|
+
extraArgs?: ReadonlyArray<string>;
|
|
81
|
+
}
|
|
82
|
+
/** Neutral options for tailing live logs. */
|
|
83
|
+
interface TailRequest {
|
|
84
|
+
/** Named environment. */
|
|
85
|
+
environment?: string;
|
|
86
|
+
/** Output format the host tail supports (`"json"`, `"pretty"`, …). */
|
|
87
|
+
format?: string;
|
|
88
|
+
/** Free-text filter. */
|
|
89
|
+
search?: string;
|
|
90
|
+
/** Status filter (`"error"`, `"ok"`, …). */
|
|
91
|
+
status?: string;
|
|
92
|
+
/** Tail a short-lived account's deployment. */
|
|
93
|
+
temporary?: boolean;
|
|
94
|
+
/** Tail a specific deployed worker/service by name, when the host addresses them individually. */
|
|
95
|
+
worker?: string;
|
|
96
|
+
}
|
|
97
|
+
/** Neutral options for reading or writing deployment secrets. */
|
|
98
|
+
interface SecretRequest {
|
|
99
|
+
/** Named environment. */
|
|
100
|
+
environment?: string;
|
|
101
|
+
/** The secret's name — required for `put`, unused for `list`. */
|
|
102
|
+
key?: string;
|
|
103
|
+
/** Operate against a short-lived account. */
|
|
104
|
+
temporary?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The host's command-line surface. Optional as a whole: a host with no vendor
|
|
108
|
+
* CLI (the Node target; a hypothetical API-driven one) declares none, and
|
|
109
|
+
* `isRunnableTarget` refuses it for the commands that would have to shell out.
|
|
110
|
+
*
|
|
111
|
+
* `deploy` and `dev` are what make a target runnable. The secret and tail
|
|
112
|
+
* commands are optional on their own, because a runnable host can simply not
|
|
113
|
+
* have them — celld keeps configuration in plain `vars` and has no log tail —
|
|
114
|
+
* and the commands that need one say so rather than guessing a substitute.
|
|
115
|
+
*/
|
|
116
|
+
interface DriverToolchain {
|
|
117
|
+
/** The command that deploys the app. */
|
|
118
|
+
deploy: (request: DeployRequest) => ToolchainCommand;
|
|
119
|
+
/** The command that runs a local dev server. */
|
|
120
|
+
dev: (request: DevRequest) => ToolchainCommand;
|
|
121
|
+
/**
|
|
122
|
+
* Where `lunora dev` runs the worker. `"workerd"`: `wrangler dev`, or the
|
|
123
|
+
* Vite plugin's `@cloudflare/vite-plugin`, whichever flavor the project
|
|
124
|
+
* picks. `"own"`: the host's dev server ({@link DriverToolchain.dev}) on
|
|
125
|
+
* the projected config, always the standalone flavor — neither Vite nor a
|
|
126
|
+
* framework sidecar can serve the worker on that runtime.
|
|
127
|
+
*/
|
|
128
|
+
readonly devServer: "own" | "workerd";
|
|
129
|
+
/**
|
|
130
|
+
* Whether `lunora deploy` builds and pushes container images itself
|
|
131
|
+
* (railpack, into the host's registry) before `deploy`. `false` when the
|
|
132
|
+
* host CLI builds each image from its Dockerfile during the deploy.
|
|
133
|
+
*/
|
|
134
|
+
readonly prebuildsContainerImages: boolean;
|
|
135
|
+
/** The command that writes many secrets in one call, as a JSON object of name to value on stdin. Optional: hosts without it get one `secretPut` per key. */
|
|
136
|
+
secretBulk?: (request: SecretRequest) => ToolchainCommand;
|
|
137
|
+
/** The command that lists remote secret names, when the host has a secret store. */
|
|
138
|
+
secretList?: (request: SecretRequest) => ToolchainCommand;
|
|
139
|
+
/** The command that writes one secret, when the host has a secret store. Its value is passed on stdin, never argv. */
|
|
140
|
+
secretPut?: (request: SecretRequest) => ToolchainCommand;
|
|
141
|
+
/** The command that tails live logs, when the host has one. */
|
|
142
|
+
tail?: (request: TailRequest) => ToolchainCommand;
|
|
143
|
+
}
|
|
144
|
+
/** What a {@link DeployDriver.projectConfig} projection is for — a dev server may need a different source than a deploy. */
|
|
145
|
+
type ProjectionPurpose = "deploy" | "dev";
|
|
146
|
+
/**
|
|
147
|
+
* The result of {@link DeployDriver.projectConfig}: a plan, not yet on disk.
|
|
148
|
+
* The caller validates the request it is for (the toolchain's argv builder
|
|
149
|
+
* refuses unsupported options), then calls `write` — so a refused command
|
|
150
|
+
* changes nothing.
|
|
151
|
+
*/
|
|
152
|
+
interface ProjectedConfig {
|
|
153
|
+
/** Where the projection goes, to pass as the request's `configPath`. */
|
|
154
|
+
configPath: string;
|
|
155
|
+
/** Every key removed, as a dotted path (`observability`, `containers[0].rollout_step_percentage`). */
|
|
156
|
+
dropped: ReadonlyArray<string>;
|
|
157
|
+
/** The `vars` the projection deploys — for a host with no secret store, the only channel a secret has. */
|
|
158
|
+
vars: Readonly<Record<string, unknown>>;
|
|
159
|
+
/** Write the projection (and any build-artifact cleanup it planned). */
|
|
160
|
+
write: () => void;
|
|
161
|
+
}
|
|
162
|
+
/** A deploy target's implementation: an identity the registry resolves, and the host CLI surface (if any) behind it. */
|
|
163
|
+
interface DeployDriver {
|
|
164
|
+
/** The target id this driver serves (`"cloudflare"`, …) — matches codegen's `target`. */
|
|
165
|
+
readonly id: string;
|
|
166
|
+
/** Human-readable target name, for logs. */
|
|
167
|
+
readonly name: string;
|
|
168
|
+
/**
|
|
169
|
+
* Rewrite the project's wrangler config into the form this host's CLI
|
|
170
|
+
* accepts, and return the file to hand `deploy`/`dev` as `configPath`.
|
|
171
|
+
* Absent when the host reads the project's config as-is (Cloudflare).
|
|
172
|
+
*
|
|
173
|
+
* Needed because Lunora's reconcilers and templates write Cloudflare-only
|
|
174
|
+
* keys (`observability`, `limits`, …) that a Workers-compatible host with a
|
|
175
|
+
* strict config reader refuses outright. `dropped` names what was removed,
|
|
176
|
+
* so the caller can say so instead of silently deploying less than the
|
|
177
|
+
* config describes.
|
|
178
|
+
*/
|
|
179
|
+
readonly projectConfig?: (projectRoot: string, purpose: ProjectionPurpose) => ProjectedConfig;
|
|
180
|
+
/**
|
|
181
|
+
* The host's command-line surface, or `undefined` for a host that has none.
|
|
182
|
+
* Pure: these build argv, they never spawn.
|
|
183
|
+
*/
|
|
184
|
+
readonly toolchain?: DriverToolchain;
|
|
185
|
+
}
|
|
186
|
+
export { DeployDriver as D, ProjectedConfig as P, SecretRequest as S, TailRequest as T, DeployRequest as a, DevRequest as b, DriverToolchain as c, ProjectionPurpose as d, ToolchainCommand as e };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `DeployDriver` — the provider-neutral seam between a Lunora command and the
|
|
3
|
+
* host CLI that carries it out (plan 114, §5.3).
|
|
4
|
+
*
|
|
5
|
+
* The seam is the **toolchain surface**: which command a host runs to deploy,
|
|
6
|
+
* serve, tail, or set a secret. A driver only *describes* that command
|
|
7
|
+
* ({@link ToolchainCommand}); it never spawns. The CLI keeps ownership of
|
|
8
|
+
* running it — package-manager resolution (`pnpm exec` / `npx --` / `bun x`)
|
|
9
|
+
* and the injected spawner its tests substitute — so the driver stays free of
|
|
10
|
+
* process concerns and remains trivially testable as a pure function.
|
|
11
|
+
*
|
|
12
|
+
* Each request type below is deliberately neutral: `preview`, `environment`,
|
|
13
|
+
* `temporary` are concepts, not wrangler flags. A second host maps the same
|
|
14
|
+
* request onto its own CLI without the caller changing.
|
|
15
|
+
*
|
|
16
|
+
* Three drivers are registered: Cloudflare (`cloudflare/cloudflare-driver.ts`)
|
|
17
|
+
* and celld (`celld/celld-driver.ts`), which ship toolchains, and Node
|
|
18
|
+
* (`node/node-driver.ts`), which has none — it is a codegen target, and
|
|
19
|
+
* `lunora deploy` / `lunora dev` refuse it at selection.
|
|
20
|
+
*
|
|
21
|
+
* **What this seam deliberately does NOT carry: configuration inference.** It
|
|
22
|
+
* used to, through an `infer`/`provision` pair over a provider-neutral
|
|
23
|
+
* `ResourceGraph`. Nothing ever called either one — every consumer reads
|
|
24
|
+
* `.toolchain` or just validates the target — and the arm rotted in place: the
|
|
25
|
+
* Node driver was *only* `infer` + `provision`, so its report of what that
|
|
26
|
+
* target cannot serve (containers, undispatched crons) could not reach an
|
|
27
|
+
* operator however wrong the app was. The reason it never got wired is worth
|
|
28
|
+
* keeping: writing real host configuration needs the host's own encodings —
|
|
29
|
+
* binding names, DO class wiring, migration tags — which a neutral graph
|
|
30
|
+
* necessarily discards, so `provision` re-derived them anyway and the graph was
|
|
31
|
+
* decorative. A second target that needs to share inference should grow the
|
|
32
|
+
* seam back with a caller attached, and with an encoding escape hatch.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* A host CLI invocation, described but not run.
|
|
36
|
+
*
|
|
37
|
+
* `tool` is the binary name only (`"wrangler"`); the caller resolves how to
|
|
38
|
+
* execute it through the project's package manager (see `toolchainExecArgs`).
|
|
39
|
+
* Keeping that split means a driver never has to know whether the project uses
|
|
40
|
+
* pnpm, npm, yarn, or bun.
|
|
41
|
+
*/
|
|
42
|
+
interface ToolchainCommand {
|
|
43
|
+
/** Arguments for {@link ToolchainCommand.tool}. */
|
|
44
|
+
args: ReadonlyArray<string>;
|
|
45
|
+
/**
|
|
46
|
+
* The tool is a standalone binary installed on `PATH`, not a project
|
|
47
|
+
* dependency: run it directly. Going through the package manager would be
|
|
48
|
+
* wrong for it — `npx --` / `bun x` fetch an npm package of the same name
|
|
49
|
+
* when none is installed locally, which for a non-npm binary is somebody
|
|
50
|
+
* else's code.
|
|
51
|
+
*/
|
|
52
|
+
onPath?: boolean;
|
|
53
|
+
/** The host CLI binary, e.g. `"wrangler"`. */
|
|
54
|
+
tool: string;
|
|
55
|
+
}
|
|
56
|
+
/** Neutral options for a deploy. */
|
|
57
|
+
interface DeployRequest {
|
|
58
|
+
/** Host config file to deploy, when the flow uses a projected one (see {@link DeployDriver.projectConfig}). */
|
|
59
|
+
configPath?: string;
|
|
60
|
+
/** Validate and bundle without publishing — nothing ships. */
|
|
61
|
+
dryRun?: boolean;
|
|
62
|
+
/** Deploy this entry file instead of the host config's default (framework composition). */
|
|
63
|
+
entry?: string;
|
|
64
|
+
/** Named deployment environment, when the host supports them. */
|
|
65
|
+
environment?: string;
|
|
66
|
+
/** Write the built bundle (and any build metadata) to this directory. */
|
|
67
|
+
outDir?: string;
|
|
68
|
+
/** A file of secrets (JSON object of name to value) uploaded with the deployment, so a Worker's first version boots with them. */
|
|
69
|
+
secretsFile?: string;
|
|
70
|
+
/** Deploy to a short-lived, unauthenticated account where the host offers one. */
|
|
71
|
+
temporary?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Neutral options for a local dev server. */
|
|
74
|
+
interface DevRequest {
|
|
75
|
+
/** Host config file to run against, when the flow uses a generated one. */
|
|
76
|
+
configPath?: string;
|
|
77
|
+
/** Named environment. */
|
|
78
|
+
environment?: string;
|
|
79
|
+
/** Extra host-specific flags the caller has already resolved. */
|
|
80
|
+
extraArgs?: ReadonlyArray<string>;
|
|
81
|
+
}
|
|
82
|
+
/** Neutral options for tailing live logs. */
|
|
83
|
+
interface TailRequest {
|
|
84
|
+
/** Named environment. */
|
|
85
|
+
environment?: string;
|
|
86
|
+
/** Output format the host tail supports (`"json"`, `"pretty"`, …). */
|
|
87
|
+
format?: string;
|
|
88
|
+
/** Free-text filter. */
|
|
89
|
+
search?: string;
|
|
90
|
+
/** Status filter (`"error"`, `"ok"`, …). */
|
|
91
|
+
status?: string;
|
|
92
|
+
/** Tail a short-lived account's deployment. */
|
|
93
|
+
temporary?: boolean;
|
|
94
|
+
/** Tail a specific deployed worker/service by name, when the host addresses them individually. */
|
|
95
|
+
worker?: string;
|
|
96
|
+
}
|
|
97
|
+
/** Neutral options for reading or writing deployment secrets. */
|
|
98
|
+
interface SecretRequest {
|
|
99
|
+
/** Named environment. */
|
|
100
|
+
environment?: string;
|
|
101
|
+
/** The secret's name — required for `put`, unused for `list`. */
|
|
102
|
+
key?: string;
|
|
103
|
+
/** Operate against a short-lived account. */
|
|
104
|
+
temporary?: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The host's command-line surface. Optional as a whole: a host with no vendor
|
|
108
|
+
* CLI (the Node target; a hypothetical API-driven one) declares none, and
|
|
109
|
+
* `isRunnableTarget` refuses it for the commands that would have to shell out.
|
|
110
|
+
*
|
|
111
|
+
* `deploy` and `dev` are what make a target runnable. The secret and tail
|
|
112
|
+
* commands are optional on their own, because a runnable host can simply not
|
|
113
|
+
* have them — celld keeps configuration in plain `vars` and has no log tail —
|
|
114
|
+
* and the commands that need one say so rather than guessing a substitute.
|
|
115
|
+
*/
|
|
116
|
+
interface DriverToolchain {
|
|
117
|
+
/** The command that deploys the app. */
|
|
118
|
+
deploy: (request: DeployRequest) => ToolchainCommand;
|
|
119
|
+
/** The command that runs a local dev server. */
|
|
120
|
+
dev: (request: DevRequest) => ToolchainCommand;
|
|
121
|
+
/**
|
|
122
|
+
* Where `lunora dev` runs the worker. `"workerd"`: `wrangler dev`, or the
|
|
123
|
+
* Vite plugin's `@cloudflare/vite-plugin`, whichever flavor the project
|
|
124
|
+
* picks. `"own"`: the host's dev server ({@link DriverToolchain.dev}) on
|
|
125
|
+
* the projected config, always the standalone flavor — neither Vite nor a
|
|
126
|
+
* framework sidecar can serve the worker on that runtime.
|
|
127
|
+
*/
|
|
128
|
+
readonly devServer: "own" | "workerd";
|
|
129
|
+
/**
|
|
130
|
+
* Whether `lunora deploy` builds and pushes container images itself
|
|
131
|
+
* (railpack, into the host's registry) before `deploy`. `false` when the
|
|
132
|
+
* host CLI builds each image from its Dockerfile during the deploy.
|
|
133
|
+
*/
|
|
134
|
+
readonly prebuildsContainerImages: boolean;
|
|
135
|
+
/** The command that writes many secrets in one call, as a JSON object of name to value on stdin. Optional: hosts without it get one `secretPut` per key. */
|
|
136
|
+
secretBulk?: (request: SecretRequest) => ToolchainCommand;
|
|
137
|
+
/** The command that lists remote secret names, when the host has a secret store. */
|
|
138
|
+
secretList?: (request: SecretRequest) => ToolchainCommand;
|
|
139
|
+
/** The command that writes one secret, when the host has a secret store. Its value is passed on stdin, never argv. */
|
|
140
|
+
secretPut?: (request: SecretRequest) => ToolchainCommand;
|
|
141
|
+
/** The command that tails live logs, when the host has one. */
|
|
142
|
+
tail?: (request: TailRequest) => ToolchainCommand;
|
|
143
|
+
}
|
|
144
|
+
/** What a {@link DeployDriver.projectConfig} projection is for — a dev server may need a different source than a deploy. */
|
|
145
|
+
type ProjectionPurpose = "deploy" | "dev";
|
|
146
|
+
/**
|
|
147
|
+
* The result of {@link DeployDriver.projectConfig}: a plan, not yet on disk.
|
|
148
|
+
* The caller validates the request it is for (the toolchain's argv builder
|
|
149
|
+
* refuses unsupported options), then calls `write` — so a refused command
|
|
150
|
+
* changes nothing.
|
|
151
|
+
*/
|
|
152
|
+
interface ProjectedConfig {
|
|
153
|
+
/** Where the projection goes, to pass as the request's `configPath`. */
|
|
154
|
+
configPath: string;
|
|
155
|
+
/** Every key removed, as a dotted path (`observability`, `containers[0].rollout_step_percentage`). */
|
|
156
|
+
dropped: ReadonlyArray<string>;
|
|
157
|
+
/** The `vars` the projection deploys — for a host with no secret store, the only channel a secret has. */
|
|
158
|
+
vars: Readonly<Record<string, unknown>>;
|
|
159
|
+
/** Write the projection (and any build-artifact cleanup it planned). */
|
|
160
|
+
write: () => void;
|
|
161
|
+
}
|
|
162
|
+
/** A deploy target's implementation: an identity the registry resolves, and the host CLI surface (if any) behind it. */
|
|
163
|
+
interface DeployDriver {
|
|
164
|
+
/** The target id this driver serves (`"cloudflare"`, …) — matches codegen's `target`. */
|
|
165
|
+
readonly id: string;
|
|
166
|
+
/** Human-readable target name, for logs. */
|
|
167
|
+
readonly name: string;
|
|
168
|
+
/**
|
|
169
|
+
* Rewrite the project's wrangler config into the form this host's CLI
|
|
170
|
+
* accepts, and return the file to hand `deploy`/`dev` as `configPath`.
|
|
171
|
+
* Absent when the host reads the project's config as-is (Cloudflare).
|
|
172
|
+
*
|
|
173
|
+
* Needed because Lunora's reconcilers and templates write Cloudflare-only
|
|
174
|
+
* keys (`observability`, `limits`, …) that a Workers-compatible host with a
|
|
175
|
+
* strict config reader refuses outright. `dropped` names what was removed,
|
|
176
|
+
* so the caller can say so instead of silently deploying less than the
|
|
177
|
+
* config describes.
|
|
178
|
+
*/
|
|
179
|
+
readonly projectConfig?: (projectRoot: string, purpose: ProjectionPurpose) => ProjectedConfig;
|
|
180
|
+
/**
|
|
181
|
+
* The host's command-line surface, or `undefined` for a host that has none.
|
|
182
|
+
* Pure: these build argv, they never spawn.
|
|
183
|
+
*/
|
|
184
|
+
readonly toolchain?: DriverToolchain;
|
|
185
|
+
}
|
|
186
|
+
export { DeployDriver as D, ProjectedConfig as P, SecretRequest as S, TailRequest as T, DeployRequest as a, DevRequest as b, DriverToolchain as c, ProjectionPurpose as d, ToolchainCommand as e };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{writeFileSync as u}from"node:fs";import{modify as y,applyEdits as w}from"jsonc-parser";import{readManifest as m,formattingFor as v,recordManifestKey as $}from"./readManifest-Cighz3WC.mjs";import{findWranglerFile as x,readWranglerJsonc as C}from"./WRANGLER_FILES-UNW-xY5u.mjs";const b=(r,n)=>r.length===n.length&&r.every((e,t)=>e===n[t]),j=(r,n)=>{if(r?.lunoraIsForeign===!0)return n.push(`${r.path}: \`lunora\` is not an object, so the cron ownership record cannot be read or written — a removed cron will keep firing.`),[];const e=r?.lunora?.crons;if(e===void 0)return[];if(!Array.isArray(e))return n.push(`${r?.path??"package.json"}: \`lunora.crons\` is not an array of cron expressions — the crons it recorded are now treated as hand-written and will not be cleared.`),[];const t=e.filter(o=>typeof o=="string");return t.length!==e.length&&n.push(`${r?.path??"package.json"}: \`lunora.crons\` dropped ${String(e.length-t.length)} non-string entry(s) — anything it recorded there is now treated as hand-written and will not be cleared.`),t},k=(r,n)=>{$(r,"crons",n.length===0?void 0:[...n])},W=(r,n)=>{const e=x(r);if(!e)return{changed:!1,preserved:[],reason:"wrangler.jsonc not found",warnings:[]};const{parsed:t,text:o}=C(e);if(t===void 0)return{changed:!1,preserved:[],reason:`failed to parse ${e} as JSONC`,warnings:[],wranglerPath:e};const g=Array.isArray(t.triggers?.crons)?t.triggers.crons.filter(i=>typeof i=="string"):[],c=[...n],s=[],d=m(r),p=j(d,s),a=g.filter(i=>!c.includes(i)&&!p.includes(i)),l=[...c,...a],f=()=>{d!==void 0&&k(d,c)};if(b(g,l))return f(),{changed:!1,preserved:a,reason:"triggers.crons already in sync",warnings:s,wranglerPath:e};const h=y(o,["triggers","crons"],l,{formattingOptions:v(o)});return h.length===0?{changed:!1,preserved:a,reason:"no structural edit produced",warnings:s,wranglerPath:e}:(u(e,w(o,h),"utf8"),f(),{changed:!0,preserved:a,warnings:s,wranglerPath:e})},J=r=>r.length===0?void 0:`kept ${String(r.length)} hand-written cron trigger(s): ${r.join(", ")}`;export{J as describePreservedCrons,W as reconcileWranglerCrons};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{rmSync as l,readdirSync as c,writeFileSync as u}from"node:fs";import{join as a}from"node:path";const d=/^\.wrangler\.lunora-(?:dev|service)\.(\d+)\.\d+\.jsonc$/;let s=0;const f=n=>(s+=1,`.wrangler.lunora-${n}.${String(process.pid)}.${String(s)}.jsonc`),g=n=>{try{return process.kill(n,0),!0}catch(r){return r.code==="EPERM"}},p=n=>{let r;try{r=c(n)}catch{return}for(const t of r){const e=d.exec(t);if(!(e===null||Number(e[1])===process.pid||g(Number(e[1]))))try{l(a(n,t),{force:!0})}catch{}}},w=()=>{},m=n=>{let r=!1;return()=>{if(!r){r=!0;try{l(n,{force:!0})}catch{}}}},y=(n,r,t)=>{p(n);const e=a(n,f(r));return u(e,t,"utf8"),{cleanup:m(e),configPath:e}},b=(n,r)=>{const t=n?.ai,e=n?.artifacts,i=(Array.isArray(e)?e:[]).flatMap(o=>typeof o?.binding=="string"?[o.binding]:[]);return t==null&&i.length===0?[]:r()?[]:[...t==null?[]:[{binding:typeof t.binding=="string"?t.binding:"AI",kind:"ai"}],...i.map(o=>({binding:o,kind:"artifacts"}))]},v=({binding:n,kind:r})=>r==="ai"?`Workers AI is off in this dev session (${n} binding left out): no usable Cloudflare login found, and Workers AI only runs remotely. \`@cf/…\` models will throw; AI SDK models and \`LUNORA_AI_PROXY_URL\` slugs still work. Run \`wrangler login\` or set CLOUDFLARE_API_TOKEN to turn it on.`:`Artifacts is off in this dev session (${n} binding left out): no usable Cloudflare login found, and Artifacts only runs remotely. \`ctx.artifacts\` will throw. Run \`wrangler login\` or set CLOUDFLARE_API_TOKEN to turn it on.`;export{d as STALE_DEV_CONFIG,m as createCleanup,v as describeWithheld,f as devConfigBasename,w as noopCleanup,p as sweepStaleDevConfigs,b as withheldBindings,y as writeDevConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readProjectDependencyNames as a}from"./readProjectDependencies-l3uhUKjo.mjs";const n=[{class:"A",dependency:"@tanstack/react-start",framework:"tanstack-start"},{class:"A",dependency:"@tanstack/solid-start",framework:"tanstack-start-solid"},{class:"A",dependency:"@react-router/dev",framework:"react-router"},{class:"A",dependency:"vinext",framework:"vinext"},{class:"A",dependency:"@solidjs/start",framework:"solid-start"},{class:"A",dependency:"solid-start",framework:"solid-start"},{class:"B",dependency:"@sveltejs/kit",framework:"sveltekit"},{class:"B",dependency:"nuxt",framework:"nuxt"},{class:"B",dependency:"astro",framework:"astro"}],t={class:"C",framework:"none"},o=e=>a(e).has("lunorash"),d=e=>{const r=a(e);if(r.size===0)return t;for(const s of n)if(r.has(s.dependency))return{class:s.class,framework:s.framework};return t};export{d as detectFramework,o as projectUsesUmbrella};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{statSync as n,readFileSync as i}from"node:fs";import{join as o}from"node:path";import{parseDevVariableEntries as a}from"./DEV_VARS_EXAMPLE_FILE-CqLorAxT.mjs";const v=(t,e)=>{const r=a(t).find(s=>s.key===e);return r===void 0||r.value===""?void 0:r.value},f=t=>{let e;try{e=v(i(o(t,".dev.vars"),"utf8"),"LUNORA_ADMIN_TOKEN")}catch{e=void 0}const r=process.env.LUNORA_ADMIN_TOKEN;return typeof r=="string"&&r!==""&&r!==e&&console.warn("[lunora] LUNORA_ADMIN_TOKEN is exported in this shell but differs from .dev.vars — the local worker only verifies the .dev.vars token, so the studio uses that one."),e},m=t=>{try{const e=n(o(t,".dev.vars"));return`${String(e.ctimeMs)}:${String(e.size)}`}catch{return"0"}};export{m as devVariablesStamp,v as parseDevVariable,f as resolveAdminToken};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as m}from"node:fs";import{Project as f}from"ts-morph";import{join as t}from"node:path";const p=(e,o,n,s,i={})=>{if(!m(t(e,o,n??"")))return{};try{const r=new f({skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1,...i});return{value:s(r,t(e,o))}}catch(r){return{error:r instanceof Error?r.message:String(r)}}};export{p as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{discoverAgents as s,AGENTS_FILENAME as n}from"@lunora/codegen";import{d as i}from"./discover-info-DC2MrAIM.mjs";const v=(o,e)=>{const{error:r,value:t}=i(o,e,n,s);return r===void 0?{agents:t??[]}:{agents:[],error:r}};export{v as discoverAgentInfo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{discoverContainers as s,CONTAINERS_FILENAME as t}from"@lunora/codegen";import{d}from"./discover-info-DC2MrAIM.mjs";const e=(n,o)=>{const{error:r,value:i}=d(n,o,t,s,{skipFileDependencyResolution:!0});return r===void 0?{containers:i??[]}:{containers:[],error:r}},I=(n,o,r)=>r===void 0?e(n,o):r.memo(`containers:${n}:${o}`,()=>e(n,o));export{I as discoverContainerInfo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as l}from"node:fs";import{discoverSchema as d,isHyperdriveGlobalTable as f,isD1GlobalTable as b}from"@lunora/codegen";import{Project as u}from"ts-morph";import{join as p}from"node:path";const a=e=>{if(e?.kind==="optional")return a(e.inner);if(e?.kind==="union"){const s=new Set((e.members??[]).filter(i=>i.kind!=="null").map(i=>a(i)));return s.size===1?[...s][0]:e.kind}return e?.kind},m=(e,s)=>{const i=p(e,s,"schema.ts");if(!l(i))return{info:void 0};try{const o=new u({compilerOptions:{noLib:!0},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!1}),r=d(o,i,e),c=n=>r.tables.find(t=>t.name===n)?.shape??{};return{info:{hasD1GlobalTable:r.tables.some(n=>b(n)),hasHyperdriveGlobalTable:r.tables.some(n=>f(n)),...r.jurisdiction===void 0?{}:{jurisdiction:r.jurisdiction},vectorIndexNames:r.vectorIndexes.map(n=>n.name),vectorMetadata:r.vectorIndexes.flatMap(n=>(n.metadata??[]).map(t=>({index:n.name,kind:a(c(n.table)[t]),property:t})))}}}catch(o){return{error:o instanceof Error?o.message:String(o),info:void 0}}},I=(e,s,i)=>i===void 0?m(e,s):i.memo(`schema:${e}:${s}`,()=>m(e,s));export{I as discoverSchemaInfo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{discoverWorkflows as f,WORKFLOWS_FILENAME as i}from"@lunora/codegen";import{d as t}from"./discover-info-DC2MrAIM.mjs";const d=(r,s)=>{const{error:o,value:e}=t(r,s,i,f);return o===void 0?{workflows:e??[]}:{error:o,workflows:[]}};export{d as discoverWorkflowInfo};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{existsSync as d,readFileSync as g,writeFileSync as m}from"node:fs";import{join as u}from"node:path";const h=/\r?\n/u,I=(a,s)=>{const e=u(a,".gitignore"),n=d(e)?g(e,"utf8"):"",r=n.split(h).map(t=>t.trim()),c=r.findLastIndex(t=>t.startsWith("!")&&!s.includes(t)),i=s.filter(t=>{const o=r.lastIndexOf(t);return o===-1||!t.startsWith("!")&&o<c});if(i.length===0)return[];const l=i.some(t=>!t.startsWith("!"))?[...i.filter(t=>!t.startsWith("!")),...s.filter(t=>t.startsWith("!"))]:i,f=n.length>0&&!n.endsWith(`
|
|
2
|
+
`)?`
|
|
3
|
+
`:"";return m(e,`${n}${f}
|
|
4
|
+
# Lunora — local secrets and dev state, never commit
|
|
5
|
+
${l.join(`
|
|
6
|
+
`)}
|
|
7
|
+
`,"utf8"),i};export{I as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),s=t=>typeof t=="string"&&t.length>0;export{s as a,n as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawnSync as m}from"node:child_process";import{readFileSync as L,readdirSync as A,existsSync as O}from"node:fs";import{homedir as S}from"node:os";import{join as r,dirname as d}from"node:path";const v=[".env",".env.local",".env.development",".env.development.local"],E=["CLOUDFLARE_API_TOKEN","CF_API_TOKEN"],g=["CLOUDFLARE_API_KEY","CF_API_KEY"],_=["CLOUDFLARE_EMAIL","CF_EMAIL"],w=new Set([...E,...g,..._]),p=/^export\s+/u,D=/\r?\n/u,I=/"loggedIn"\s*:\s*false/u,T=1e4,f=new Map,C=/^(["'])(.*)\1$/u,a=e=>e!==void 0&&e.trim()!=="",h=(e,t)=>[t,e.XDG_CONFIG_HOME,r(t,"Library","Preferences"),r(t,".config"),e.APPDATA===void 0?void 0:r(e.APPDATA,"xdg.config"),r(t,"AppData","Roaming","xdg.config")].filter(o=>a(o)),F=e=>{try{return A(e).length>0}catch{return!1}},K=e=>{for(let t=e;;t=d(t)){const o=r(t,"node_modules","wrangler","bin","wrangler.js");if(O(o))return o;if(d(t)===t)return}},P=(e,t)=>{const o=f.get(e);if(o!==void 0&&Date.now()-o.at<T)return o.loggedOut;const s=K(e);if(s===void 0)return!1;const{stdout:i}=m(process.execPath,[s,"whoami","--json"],{cwd:e,encoding:"utf8",env:{...t,WRANGLER_SEND_METRICS:"false"},stdio:["ignore","pipe","ignore"],timeout:3e3}),n=I.test(i);return f.set(e,{at:Date.now(),loggedOut:n}),n},R=e=>{const t=new Set;for(const o of v){let s;try{s=L(r(e,o),"utf8")}catch{continue}for(const i of s.split(D)){const n=i.trim().replace(p,""),c=n.indexOf("=");if(n.startsWith("#")||c===-1)continue;const l=n.slice(0,c).trim(),u=n.slice(c+1).trim().replace(C,"$2");w.has(l)&&a(u)&&t.add(l)}}return t},M=(e={})=>{const t=e.env??process.env,o=e.projectRoot===void 0?new Set:R(e.projectRoot),s=n=>a(t[n])||o.has(n);return E.some(n=>s(n))||g.some(n=>s(n))&&_.some(n=>s(n))?!0:h(t,e.home??S()).some(n=>F(r(n,".wrangler","config")))&&(e.projectRoot===void 0||!P(e.projectRoot,t))};export{M as hasCloudflareCredentials};
|