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