var M=Object.defineProperty;var d=(s,r)=>M(s,"name",{value:r,configurable:!0});import{createRequire as T}from"node:module";import{l as F,M as h,K as N,O as H}from"../packem_shared/readFileSync-DseCu8sg-DEq4Fn3a.js";import{p as n}from"./bin.js";import{A as J,R as K,I as Q,C as U}from"../packem_shared/pm-runner-DmKT2FqF.js";import{s as W}from"../packem_shared/typosquats-acxQ7blw.js";import{h as G,P as V}from"../packem_shared/peer-warnings-EvSJ18gE.js";import{o as X}from"../packem_shared/utils-DrNg0XTR.js";const B=T(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=d(s=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[r,t]=l.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return l.getBuiltinModule(s)}return B(s)},"__cjs_getBuiltinModule"),{rmSync:$}=A("node:fs");var Y=Object.defineProperty,y=d((s,r)=>Y(s,"name",{value:r,configurable:!0}),"u");const Z=["pnpm-lock.yaml","yarn.lock","package-lock.json","npm-shrinkwrap.json","bun.lock","bun.lockb"],ee=y(s=>{let r=s;for(;;){for(const e of Z)if(F(h(r,e)))return!0;const t=N(r);if(t===r||H(r).root===r)return!1;r=t}},"hasLockfile"),g=new Set(["aube","auto","bun","npm","pnpm","yarn"]),ce=y(async s=>{const{argument:r,logger:t,options:e,visConfig:c,workspaceRoot:C}=s,a=C??process.cwd();if(r&&r.length>0){const o=e,{default:j}=await import("./handler16.js"),q=o.marshallCheck===!1||o["no-marshall-check"]===!0?!1:void 0,S=o.socketCheck===!1||o["no-socket-check"]===!0?!1:void 0,P=o.typosquatCheck===!1||o["no-typosquat-check"]===!0?!1:void 0,z=o.runScripts===!0||o["run-scripts"]===!0,E=o.workspaceRoot===!0||o["workspace-root"]===!0,I=o.saveOptional===!0||o["save-optional"]===!0,D=e.dev===!0,L={autoInstallPeers:!1,exact:o.exact===!0,filter:e.filter,global:!1,marshallCheck:q,runScripts:z,saveDev:D,saveOptional:I,savePeer:!1,socketCheck:S,to:void 0,typosquatCheck:P,workspace:!1,workspaceRoot:E};await j({...s,argument:r,options:L});return}if(e.typosquatCheck!==!1&&!await W(a,c?.security?.typosquatAllowlist)){process.exitCode=1;return}const i=e.installer;if(i&&!g.has(i)){n.error(`Invalid --installer value: "${i}". Expected one of: ${[...g].join(", ")}.`),process.exitCode=1;return}const w=i,b=e.aube===!1;let f;try{f=b?J(a):K(a,{backend:w,configBackend:c?.install?.backend,configCorepack:c?.install?.corepack})}catch(o){n.error(o instanceof Error?o.message:String(o)),process.exitCode=1;return}const k=Q(a,f);k&&n.warn(k);const _=X(e.filter),p=e.ci||!1,m=e.frozenLockfile||p,O=e.frozenLockfile===!1||e.force||e.lockfileOnly,x=ee(a),v=m||!O&&x;if(!m&&v&&!e.silent&&n.info("Defaulting to frozen lockfile (pass --no-frozen-lockfile to allow lockfile updates)."),p){n.info("Clean install: removing node_modules...");try{$(h(a,"node_modules"),{force:!0,recursive:!0})}catch(o){n.error(`Failed to remove node_modules: ${o instanceof Error?o.message:String(o)}`),process.exitCode=1;return}}const{code:u,output:R}=await U(f,{dev:e.dev||!1,filter:_,force:e.force||!1,frozenLockfile:v,ignoreScripts:!e.runScripts,lockfileOnly:e.lockfileOnly||!1,noOptional:e.optional===!1,offline:e.offline||!1,prod:e.prod||!1,recursive:e.recursive||!1,silent:e.silent||!1,workspaceRoot:e.workspaceRoot||!1},a,t,{ciMode:p,preferOffline:e.preferOffline||!1});u!==0&&(process.exitCode=u),u===0&&!e.silent&&G(R)&&n.info(V)},"execute");export{ce as default};
