var l=Object.defineProperty;var c=(s,e)=>l(s,"name",{value:e,configurable:!0});import{e as v,E as f,I as p}from"../packem_shared/Table-3pFgIUZ2-DABgc6rj.js";import{p as r}from"./bin.js";import{r as g,g as h}from"../packem_shared/advisories-CGKZo9Rx.js";var $=Object.defineProperty,i=c((s,e)=>$(s,"name",{value:e,configurable:!0}),"a");const B=i(s=>{if(s===0)return"0 B";const e=["B","KB","MB","GB"],a=Math.min(Math.floor(Math.log(s)/Math.log(1024)),e.length-1),o=s/1024**a;return`${o.toFixed(o<10&&a>0?1:0)} ${e[a]}`},"formatBytes"),w=i(s=>{if(!s)return"never";const e=Date.parse(s);if(Number.isNaN(e))return s;const a=Date.now()-e;if(a<0)return s;const o=Math.floor(a/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const t=Math.floor(o/60);return t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`},"formatRelative"),S=i(async({logger:s,options:e,workspaceRoot:a})=>{if(!a)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const o=e.db??g(a),t=await h(a,o);if(e.format==="json"){process.stdout.write(`${JSON.stringify({dbPath:o,ecosystems:t.ecosystems.map(n=>({advisoryCount:n.advisoryCount,lastSyncIso:n.lastSyncIso,manifestEtag:n.manifestEtag??null,name:n.name})),exists:t.exists,schemaVersion:t.schemaVersion,sizeBytes:t.sizeBytes},void 0,2)}
`);return}if(r.info(`DB: ${o}`),!t.exists){r.warn(`No advisory DB yet. Run ${v("vis advisories sync")} to populate.`);return}if(r.info(`Schema: v${t.schemaVersion}   Size: ${B(t.sizeBytes)}`),t.ecosystems.length===0){r.warn("DB exists but contains no ecosystems. Run `vis advisories sync`.");return}r.info(""),r.info("Ecosystem    Advisories   Last sync           ETag"),r.info(f("──────────   ──────────   ─────────────────   ──────"));for(const n of t.ecosystems){const m=n.name.padEnd(10),u=n.advisoryCount.toLocaleString().padStart(10),d=`${n.lastSyncIso||"never"} (${w(n.lastSyncIso)})`.padEnd(19),y=n.manifestEtag??f("—");r.info(`${p(m)}   ${u}   ${d}   ${y}`)}},"execute"),D=S;export{D as advisoriesStatusExecute};
