var k=Object.defineProperty;var u=(e,n)=>k(e,"name",{value:n,configurable:!0});import{createRequire as g}from"node:module";import{M as m}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";const b=g(import.meta.url),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,h=u(e=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[n,s]=l.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return l.getBuiltinModule(e)}return b(e)},"__cjs_getBuiltinModule"),{existsSync:f,statSync:p}=h("node:fs");var y=Object.defineProperty,i=u((e,n)=>y(e,"name",{value:n,configurable:!0}),"s");const M={aube:["aube-lock.yaml"],bun:["bun.lock","bun.lockb"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]},_={aube:["node_modules/.aube-state","node_modules/.modules.yaml"],bun:["node_modules/.bun-tag"],npm:["node_modules/.package-lock.json"],pnpm:["node_modules/.modules.yaml","node_modules/.pnpm/lock.yaml"],yarn:["node_modules/.yarn-integrity","node_modules/.yarn-state.yml",".yarn/install-state.gz"]},j={ci:{aube:"aube ci",bun:"bun install --frozen-lockfile",npm:"npm ci",pnpm:"pnpm install --frozen-lockfile",yarn:"yarn install --immutable"},tty:{aube:"aube install",bun:"bun install",npm:"npm install",pnpm:"pnpm install",yarn:"yarn install"}},v=1e3,P=i(e=>{for(const[n,s]of Object.entries(M))for(const t of s)if(f(m(e,t)))return{lockfileFile:t,manager:n}},"detectPackageManager"),C=i((e,n)=>{let s;for(const t of _[n]){const o=m(e,t);if(!f(o))continue;const{mtimeMs:a}=p(o);(!s||a>s.mtimeMs)&&(s={mtimeMs:a,path:t})}return s},"findFreshestMarker"),F=i((e,n={})=>{const s=P(e);if(!s)return{checked:!1};const{lockfileFile:t,manager:o}=s,a=p(m(e,t)).mtimeMs,r=C(e,o),d=j[n.inCi?"ci":"tty"][o],c={installMarkerMtimeMs:r?.mtimeMs,lockfileMtimeMs:a,lockfilePath:t,marker:r?.path,packageManager:o};return r?a>r.mtimeMs+v?{checked:!0,detail:c,failure:"stale-install",message:`${t} is newer than node_modules (${r.path}) — run \`${d}\` to sync.`}:{checked:!0,detail:c}:{checked:!0,detail:c,failure:"missing-install",message:`lockfile detected but node_modules looks uninitialised — run \`${d}\` before \`vis run\`.`}},"checkLockfileFreshness"),w=i((e,n,s,t={})=>{if(t.skip)return{checked:!1,shouldContinue:!0};const o=F(e,{inCi:n});if(!o.failure)return{...o,shouldContinue:!0};const a=`preflight: ${o.message??"lockfile drift detected"}`;return n&&!t.ciAsWarning?{...o,formattedMessage:a,shouldContinue:!1}:(s.warn(a),{...o,formattedMessage:a,shouldContinue:!0})},"runLockfilePreflight");export{P as d,w as r};
