@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.15 kB
JavaScript
const p=/(?:key|password|secret|token)$/iu,x=e=>p.test(e),g=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}},l=/already (?:exists|indexed)|duplicate/iu,i=e=>["vectorize","create-metadata-index",e.index,`--property-name=${e.property}`,`--type=${e.type}`],m=async(e,n)=>{try{return await e(n)}catch(r){return{code:1,stderr:r instanceof Error?r.message:String(r)}}},y=async e=>{const{cwd:n,entries:r,exec:o,logger:d,spawner:u}=e,s=[];for(const t of r){const a=await m(u,{args:[...o.args,...i(t)],captureStderr:!0,command:o.command,cwd:n,stdoutToStderr:!0});if(a.code===0){s.push({entry:t,status:"created"});continue}const c=`${a.stderr??""}${a.stdout??""}`;if(l.test(c)){s.push({entry:t,status:"exists"});continue}s.push({entry:t,error:c.trim()||`exit code ${String(a.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 s};export{i as c,y as e,x as i,g as m};