@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) • 2.15 kB
JavaScript
import{join as l,resolve as m}from"node:path";import{p as u}from"../packem_shared/deploy-target-B0Xcb2jV.mjs";import{d as f}from"../packem_shared/command-DwC11Cwe.mjs";import{v as p,l as g,i as w,p as y}from"../packem_shared/output-format-DfogXx0p.mjs";import{defaultSpawner as v}from"../packem_shared/createRecordingSpawner-DJlNacZ6.mjs";import{runDeployCommand as b}from"./runDeployCommand.mjs";import{readdirSync as S,readFileSync as h}from"node:fs";import{gzipSync as B}from"node:zlib";const D=e=>!e.endsWith(".map")&&e!=="bundle-meta.json"&&e!=="README.md",F=e=>{let t;try{t=S(e,{recursive:!0,withFileTypes:!0})}catch{return}let r=0,i=0,d=0;for(const a of t){if(!a.isFile()||!D(a.name))continue;const o=h(l(a.parentPath,a.name));r+=1,d+=o.byteLength,i+=B(o).byteLength}return r===0?void 0:{files:r,gzipBytes:i,rawBytes:d}},A=".lunora/build",z=async e=>v({...e,stdoutToStderr:!0}),c=e=>`${(e/1024).toFixed(1)} KiB`,$=async e=>{const t=e.outDir??A,r=w(e.format),i=g(e.format,e.logger),d=s=>(r&&y(s),s),a=p("build",e.format);if(a!==void 0)return e.logger.error(a),{code:1,descriptor:void 0,error:a,validation:{problems:[],wranglerPath:void 0}};const o=await b({allowSchemaDrift:e.allowSchemaDrift,apiSpec:e.apiSpec,commandName:"build",cwd:e.cwd,dryRun:!0,emitBindings:e.emitBindings,format:void 0,interactive:r?!1:void 0,logger:i,outDir:t,spawner:e.spawner??(r?z:void 0),strictAdvisories:e.strictAdvisories,target:e.target});if(o.code!==0)return d(o);i.success(`build complete — bundle written to ${t}`);const n=F(m(e.cwd??process.cwd(),t));return n===void 0?i.warn(`could not weigh the bundle — nothing uploadable was found in ${t}`):i.info(`bundle: ${c(n.rawBytes)} raw, ${c(n.gzipBytes)} gzipped across ${String(n.files)} file(s) — Cloudflare's Worker size limit (3 MB Free, 10 MB Paid) applies to the gzipped number`),d({...o,bundle:n})},P=f(async({cwd:e,logger:t,options:r})=>({code:(await $({allowSchemaDrift:r.allowSchemaDrift===!0,apiSpec:u(r.apiSpec),cwd:e,emitBindings:r.emitBindings,format:r.format,logger:t,outDir:r.outDir,strictAdvisories:r.strictAdvisories,target:r.target})).code}));export{P as execute,$ as runBuildCommand};