@lunora/cli
Version:
The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands
2 lines (1 loc) • 1.09 kB
JavaScript
const m=t=>{switch(t){case"boolean":return"boolean";case"date":case"number":case"timestamp":return"number";case"id":case"literal":case"string":return"string";default:return}},p=/already (?:exists|indexed)|duplicate/iu,i=t=>["vectorize","create-metadata-index",t.index,`--property-name=${t.property}`,`--type=${t.type}`],l=async(t,s)=>{try{return await t(s)}catch(r){return{code:1,stderr:r instanceof Error?r.message:String(r)}}},y=async t=>{const{cwd:s,entries:r,exec:o,logger:d,spawner:u}=t,n=[];for(const e of r){const a=await l(u,{args:[...o.args,...i(e)],captureStderr:!0,command:o.command,cwd:s,stdoutToStderr:!0});if(a.code===0){n.push({entry:e,status:"created"});continue}const c=`${a.stderr??""}${a.stdout??""}`;if(p.test(c)){n.push({entry:e,status:"exists"});continue}n.push({entry:e,error:c.trim()||`exit code ${String(a.code)}`,status:"failed"}),d.warn(`could not create the Vectorize metadata index for "${e.property}" on "${e.index}" — filters on that property will match nothing until it exists. Run: wrangler ${i(e).join(" ")}`)}return n};export{y as m,i as o,m as p};