@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.08 kB
JavaScript
const m=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}},p=/already (?:exists|indexed)|duplicate/iu,i=e=>["vectorize","create-metadata-index",e.index,`--property-name=${e.property}`,`--type=${e.type}`],l=async(e,n)=>{try{return await e(n)}catch(r){return{code:1,stderr:r instanceof Error?r.message:String(r)}}},x=async e=>{const{cwd:n,entries:r,exec:o,logger:d,spawner:u}=e,a=[];for(const t of r){const s=await l(u,{args:[...o.args,...i(t)],captureStderr:!0,command:o.command,cwd:n,stdoutToStderr:!0});if(s.code===0){a.push({entry:t,status:"created"});continue}const c=`${s.stderr??""}${s.stdout??""}`;if(p.test(c)){a.push({entry:t,status:"exists"});continue}a.push({entry:t,error:c.trim()||`exit code ${String(s.code)}`,status:"failed"}),d.warn(`could not create the Vectorize metadata index for "${t.property}" on "${t.index}" — filters on that property will match nothing until it exists. Run: wrangler ${i(t).join(" ")}`)}return a};export{i as c,x as e,m};