var O=Object.defineProperty;var v=(r,e)=>O(r,"name",{value:e,configurable:!0});import{createTaskGraph as E}from"@visulima/task-runner";import{C as R,S}from"./bin.js";import{r as C,f as P}from"../packem_shared/selectors-DkgYFzdq.js";var x=Object.defineProperty,d=v((r,e)=>x(r,"name",{value:e,configurable:!0}),"u");const G=d((r,e,n)=>{const c=[],t=new Set,i=d((o,f)=>{if(t.has(o))return;t.add(o);const m=e[o]??[];for(const u of m)i(u,f+1);const s=n[o],h="  ".repeat(f);c.push(`${h}${o}${s?.cache===!1?" (no-cache)":""}`)},"walk");for(const o of r)i(o,0);return c},"renderPlan"),J=d((r,e,n)=>({roots:r,tasks:Object.fromEntries(Object.entries(n).map(([c,t])=>[c,{cache:t.cache,dependsOn:e[c]??[],outputs:t.outputs,parallelism:t.parallelism,projectRoot:t.projectRoot,target:t.target}]))}),"toJson"),D=d(async({argument:r,logger:e,options:n,process:c,visConfig:t,workspaceRoot:i})=>{const o=r[0];if(!o)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!i)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:f,packageJsons:m,workspace:s}=R(i,t),h=S(i,s,m),u=await C(o,s,c.cwd,i),{target:l}=u;let j=u.projects;n.query&&(j=P(j,s,n.query));const k=j.filter(p=>s.projects[p]?.targets?.[l]!==void 0);if(k.length===0){e.info(`No projects have a "${l}" target.`);return}const y=k.map(p=>{const w=s.projects[p],g=w.targets?.[l],b={project:p,target:l};return{cache:g?.cache,id:`${p}:${l}`,outputs:g?.outputs??[],overrides:{command:g?.command},parallelism:g?.parallelism,projectRoot:w.root,target:b}}),a=E(y,{projectGraph:h,targetDefaults:f.tasks,workspace:s});if(n.json){e.info(JSON.stringify(J(a.roots,a.dependencies,a.tasks),null,2));return}const $=G(a.roots,a.dependencies,a.tasks);e.info(`Execution plan (${Object.keys(a.tasks).length} task(s), ${a.roots.length} root(s)):`),e.info("");for(const p of $)e.info(p)},"execute");export{D as default};
