@lunora/cli 1.0.0-alpha.429 → 1.0.0-alpha.430
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/handler.mjs +11 -17
- package/dist/packem_chunks/handler18.mjs +1 -1
- package/dist/packem_chunks/handler25.mjs +1 -99
- package/dist/packem_chunks/handler26.mjs +99 -2
- package/dist/packem_chunks/handler27.mjs +1 -1
- package/dist/packem_chunks/handler28.mjs +1 -1
- package/dist/packem_chunks/handler5.mjs +3 -3
- package/dist/packem_chunks/runDevCommand.mjs +5 -5
- package/dist/packem_shared/{COMMANDS-DtyQBrMA.mjs → COMMANDS-D7MfgxzU.mjs} +1 -1
- package/dist/packem_shared/{cli-D7VWwtaw.mjs → cli-CDNZwrAT.mjs} +1 -1
- package/dist/packem_shared/{plan-CuoEuHK9.mjs → plan-lzllz0Cn.mjs} +3 -3
- package/dist/packem_shared/{planDevCommand-opPvknj3.mjs → planDevCommand-HmQ01PRq.mjs} +1 -1
- package/dist/packem_shared/runDeployCommand-DsFzrpXY.mjs +1 -0
- package/dist/packem_shared/vectorize-metadata-BDrKVEF4.mjs +2 -0
- package/dist/packem_shared/{wrangler-secrets-CvOCvsB9.mjs → wrangler-secrets-DlSlWvRH.mjs} +1 -1
- package/package.json +9 -9
- package/dist/packem_shared/runDeployCommand-vYNbXHHs.mjs +0 -1
- package/dist/packem_shared/secret-key-8DPOH98z.mjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as b,c as f}from"./cloudflare-credentials-BVmZnDZk.mjs";const g=5e3,E=(e,s,r)=>`POST https://api.cloudflare.com/client/v4/accounts/${e}/artifacts/namespaces with body { "namespace": "${s}", "jurisdiction": "${r}" }`,C=e=>{let s="";try{const{errors:r}=JSON.parse(e.text);s=(r??[]).flatMap(t=>typeof t.message=="string"?[t.message]:[]).slice(0,2).join("; ")}catch{}return s===""?`HTTP ${String(e.status)}`:`HTTP ${String(e.status)}: ${s}`},j=async(e,s,r)=>{const{jurisdiction:t,namespace:n}=e;try{const a=await f({accountId:s,apiToken:r,...e.fetch===void 0?{}:{fetch:e.fetch},init:{body:JSON.stringify({jurisdiction:t,namespace:n}),method:"POST",signal:AbortSignal.timeout(g)},path:"/artifacts/namespaces"});return a.ok?{}:{reason:C(a)}}catch(a){return{reason:a instanceof Error?a.message:String(a)}}},T=async(e,s,r)=>{const t=await f({accountId:s,apiToken:r,...e.fetch===void 0?{}:{fetch:e.fetch},init:{signal:AbortSignal.timeout(g)},path:`/artifacts/namespaces/${encodeURIComponent(e.namespace)}`}).catch(()=>{}),n=t?.ok===!0?t.body.result:void 0;return typeof n=="object"&&n!==null&&"jurisdiction"in n?n.jurisdiction:void 0},v=(e,s,r,t)=>({fix:`A namespace's jurisdiction cannot change: create one with ${E(e,"<name>",r)}, point the binding's "namespace" at it, and move the repos over.`,message:`${s} is in the "${t}" jurisdiction, but the schema pins data to "${r}".`,verdict:"mismatch"}),k=async(e,s,r,t)=>{const{jurisdiction:n,namespace:a}=e;let i;if(e.create===!0){if(i=(await j(e,s,r)).reason,i===void 0)return{changesAccount:!0,message:`created ${t} in the "${n}" jurisdiction, as the schema pins.`,verdict:"ok"};const u=await T(e,s,r);if(u===n)return{message:`${t} is in the "${n}" jurisdiction, as the schema pins.`,verdict:"ok"};if(typeof u=="string")return v(s,t,n,u)}if(e.missingOk===!0)return{changesAccount:!0,message:`${t} does not exist yet; it will be created in the "${n}" jurisdiction just before the deploy.`,verdict:"ok"};const c=i===void 0?"":` (${i})`,o=e.create===!0?` and could not be created${c}`:"";return{fix:`Create it before the first repo: ${E(s,a,n)}.`,message:`${t} does not exist${o}, and the first repo create() would make it unrestricted — the schema pins data to "${n}".`,verdict:"missing"}},N=async e=>{const{binding:s,jurisdiction:r,namespace:t}=e,n=`Artifacts namespace "${t}" (binding ${s})`,{accountId:a,token:i}=b(e.environment??process.env,e.accountId);if(i===void 0||a===void 0)return{fix:"Set CLOUDFLARE_API_TOKEN (with Artifacts edit access, which creating a missing namespace needs) and CLOUDFLARE_ACCOUNT_ID (or `account_id` in wrangler.jsonc) to check it.",message:`the jurisdiction of ${n} was not checked against the schema's "${r}".`,verdict:"unchecked"};let c;try{c=await f({accountId:a,apiToken:i,...e.fetch===void 0?{}:{fetch:e.fetch},init:{signal:AbortSignal.timeout(g)},path:`/artifacts/namespaces/${encodeURIComponent(t)}`})}catch(u){return{message:`the jurisdiction of ${n} could not be read (${u instanceof Error?u.message:String(u)}).`,verdict:"unchecked"}}if(!c.ok&&c.status===404)return k(e,a,i,n);if(!c.ok)return{...c.status===401||c.status===403?{fix:`Give CLOUDFLARE_API_TOKEN Artifacts edit access on account ${a}.`}:{},message:`the jurisdiction of ${n} could not be read (HTTP ${String(c.status)}).`,verdict:"unchecked"};const{result:o}=c.body,d=typeof o=="object"&&o!==null&&"jurisdiction"in o?o.jurisdiction:void 0;return typeof d!="string"?{message:`the jurisdiction of ${n} could not be read (the response carried none).`,verdict:"unchecked"}:d===r?{message:`${n} is in the "${d}" jurisdiction, as the schema pins.`,verdict:"ok"}:v(a,n,r,d)},h=100,l=500,p=10,O=5e3,m="Delete the Workers you no longer need (old preview / staging deploys free their classes), or set `durableObjects: { merge: true }` in lunora.config before an app's first deploy so it spends one class instead of up to three.",R=e=>e>=l?{fix:m,message:`the Cloudflare account has ${String(e)} Durable Object classes — the Workers Paid cap is ${String(l)}, so a deploy that adds one will fail.`,verdict:"full"}:e>=l-p?{fix:m,message:`the Cloudflare account has ${String(e)} of ${String(l)} Durable Object classes (Workers Paid cap).`,verdict:"near"}:e>=h-p&&e<=h?{fix:m,message:`the Cloudflare account has ${String(e)} Durable Object classes — on Workers Free the cap is ${String(h)} (Paid: ${String(l)}).`,verdict:"near"}:{message:`the Cloudflare account has ${String(e)} Durable Object classes (caps: ${String(h)} Free, ${String(l)} Paid).`,verdict:"ok"},L=async(e={})=>{const{accountId:s,token:r}=b(e.environment??process.env,e.accountId);if(r===void 0||s===void 0)return{fix:"Set CLOUDFLARE_API_TOKEN (Workers Scripts Read) and CLOUDFLARE_ACCOUNT_ID (or `account_id` in wrangler.jsonc) to check it.",message:"the account's Durable Object class count was not checked.",verdict:"unchecked"};try{const t=await f({accountId:s,apiToken:r,...e.fetch===void 0?{}:{fetch:e.fetch},init:{signal:AbortSignal.timeout(O)},path:"/workers/durable_objects/namespaces?per_page=1"}),n=t.ok?t.body.result_info:void 0,a=typeof n=="object"&&n!==null&&"total_count"in n?n.total_count:void 0;return typeof a!="number"?{message:`the account's Durable Object class count could not be read${t.ok?"":` (HTTP ${String(t.status)})`}.`,verdict:"unchecked"}:R(a)}catch(t){return{message:`the account's Durable Object class count could not be read (${t instanceof Error?t.message:String(t)}).`,verdict:"unchecked"}}},U=e=>{switch(e){case"boolean":return"boolean";case"date":case"number":case"timestamp":return"number";case"id":case"literal":case"string":return"string";default:return}},w=/already (?:exists|indexed)|duplicate/iu,S=e=>["vectorize","create-metadata-index",e.index,`--property-name=${e.property}`,`--type=${e.type}`],P=async(e,s)=>{try{return await e(s)}catch(r){return{code:1,stderr:r instanceof Error?r.message:String(r)}}},K=async e=>{const{cwd:s,entries:r,exec:t,logger:n,spawner:a}=e,i=[];for(const c of r){const o=await P(a,{args:[...t.args,...S(c)],captureStderr:!0,command:t.command,cwd:s,stdoutToStderr:!0});if(o.code===0){i.push({entry:c,status:"created"});continue}const d=`${o.stderr??""}${o.stdout??""}`;if(w.test(d)){i.push({entry:c,status:"exists"});continue}i.push({entry:c,error:d.trim()||`exit code ${String(o.code)}`,status:"failed"}),n.warn(`could not create the Vectorize metadata index for "${c.property}" on "${c.index}" — filters on that property will match nothing until it exists. Run: wrangler ${S(c).join(" ")}`)}return i},$=e=>e.endsWith("S")?e.slice(0,-1):e,A=e=>e.replaceAll(/([a-z\d])([A-Z])/gu,"$1_$2").toUpperCase().split(/[_-]+/u).filter(s=>s.length>0),_=new Set(["CREDENTIAL","DSN","PASSPHRASE","PASSWD","PASSWORD","SECRET","TOKEN"]),y=["ACCESS_KEY","API_KEY","ENCRYPTION_KEY","PRIVATE_KEY","SIGNING_KEY"],I=new RegExp(`(?:${[..._,...y.map(e=>e.replaceAll("_",""))].join("|")})S?$`,"iu"),x=e=>A(e).some(s=>s==="PUBLIC"||s==="PUBLISHABLE"),F=e=>{if(x(e))return!1;const s=A(e);if(s.some(t=>_.has($(t))))return!0;const r=$(s.join("_"));return y.some(t=>r===t||r.endsWith(`_${t}`))||I.test(e)};export{L as a,N as b,S as c,K as e,F as i,U as m};
|