var x=Object.defineProperty;var c=(o,e)=>x(o,"name",{value:e,configurable:!0});import{createRequire as y}from"node:module";import{b as C}from"./config.js";import{C as B,K as S}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{C as R,S as O,p as u}from"./bin.js";import{b as T,s as q}from"../packem_shared/cyclonedx-zf9R2jCs.js";const h=y(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=c(o=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,s]=r.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return r.getBuiltinModule(o)}return h(o)},"__cjs_getBuiltinModule"),{writeFileSync:k}=$("node:fs");var D=Object.defineProperty,d=c((o,e)=>D(o,"name",{value:e,configurable:!0}),"m");const f=["json","xml"],E=d(o=>f.includes(o),"isSbomFormat"),G=d(async({options:o,visConfig:e,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:w,workspace:a}=R(s,e),b=O(s,a,w),p=o.focus,g=p?p.split(",").map(v=>v.trim()).filter(Boolean):void 0,t=(o.format??"json").toLowerCase();if(!E(t))throw new Error(`Unknown --format: "${t}". Expected one of: ${f.join(", ")}.`);const n=T({focus:g,includeDev:!!o.includeDev,projectGraph:b,workspace:a,workspaceRoot:s}),m=t==="xml"?q(n):`${JSON.stringify(n,void 0,2)}
`,l=o.output??(t==="xml"?"sbom.cdx.xml":"sbom.cdx.json");if(l==="-"){process.stdout.write(m);return}const i=B(s,l);C(S(i)),k(i,m,"utf8");const _=n.components?.length??0,j=n.dependencies?.length??0;u.success(`SBOM written to ${i}`),u.notice(`${_} components, ${j} dependency edges`)},"execute");export{G as default};
