@visulima/vis 1.0.0-alpha.14 → 1.0.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/LICENSE.md +1023 -277
- package/dist/bin.js +1 -1
- package/dist/config/index.d.ts +121 -94
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/bin.js +305 -302
- package/dist/packem_chunks/config.js +18 -0
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +5 -5
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +4 -4
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +5 -5
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +2 -1
- package/dist/packem_chunks/handler21.js +18 -1
- package/dist/packem_chunks/handler22.js +1 -5
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +5 -3
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.js +3 -1
- package/dist/packem_chunks/handler27.js +1 -7
- package/dist/packem_chunks/handler28.js +1 -23
- package/dist/packem_chunks/handler29.js +7 -3
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +23 -18
- package/dist/packem_chunks/handler31.js +3 -1
- package/dist/packem_chunks/handler32.js +1 -2
- package/dist/packem_chunks/handler33.js +2 -25
- package/dist/packem_chunks/handler34.js +25 -2
- package/dist/packem_chunks/handler35.js +3 -3
- package/dist/packem_chunks/handler36.js +20 -20
- package/dist/packem_chunks/handler37.js +3 -3
- package/dist/packem_chunks/handler38.js +4 -4
- package/dist/packem_chunks/handler39.js +11 -11
- package/dist/packem_chunks/handler40.js +5 -5
- package/dist/packem_chunks/handler41.js +10 -24
- package/dist/packem_chunks/handler42.js +24 -10
- package/dist/packem_chunks/handler43.js +5 -5
- package/dist/packem_chunks/handler44.js +6 -6
- package/dist/packem_chunks/handler45.js +3 -3
- package/dist/packem_chunks/handler46.js +11 -11
- package/dist/packem_chunks/handler47.js +161 -36
- package/dist/packem_chunks/handler48.js +6 -6
- package/dist/packem_chunks/handler5.js +5 -5
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +2 -2
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +16 -16
- package/dist/packem_chunks/index.js +2 -2
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/tar.js +1 -1
- package/dist/packem_shared/{ai-analysis-Dzs_nUwM.js → ai-analysis-C_GpXikx.js} +3 -3
- package/dist/packem_shared/ai-cache-DrCLD4gc.js +1 -0
- package/dist/packem_shared/ai-fix-CWOz12Om.js +43 -0
- package/dist/packem_shared/applyDefaults-DLY94gWA.js +1 -0
- package/dist/packem_shared/cache-directory-C_U1qsIw.js +1 -0
- package/dist/packem_shared/definePlugin-CWm4Dv_t.js +1 -0
- package/dist/packem_shared/dependency-scan-YdgNVvoz.js +2 -0
- package/dist/packem_shared/docker-Dl0AoVTZ.js +60 -0
- package/dist/packem_shared/failure-log-CSC6KfcO.js +2 -0
- package/dist/packem_shared/flakiness-Dzz-I3dB.js +1 -0
- package/dist/packem_shared/{giget-BX2ixMoa.js → giget-CcEy_Elm.js} +2 -2
- package/dist/packem_shared/lifecycle-BC6Nst6i.js +2 -0
- package/dist/packem_shared/lockfile-i-qvq_k8.js +1 -0
- package/dist/packem_shared/otelPlugin-CJR2T_lk.js +1 -0
- package/dist/packem_shared/readTomlSync-1fKo0R52-DtxWULlF.js +109 -0
- package/dist/packem_shared/run-summary-utils-CJv75pla.js +1 -0
- package/dist/packem_shared/runtime-check-CBU6W8qG.js +1 -0
- package/dist/packem_shared/{selectors-BvtUXWGY.js → selectors-B2ISH581.js} +1 -1
- package/dist/packem_shared/toolchain-B7dckBQ1.js +5 -0
- package/dist/packem_shared/typosquats-B3A38-qx.js +1 -0
- package/dist/packem_shared/verify-WDStBFvK.js +1 -0
- package/dist/packem_shared/vis-update-app-D0uL3eO5.js +1 -0
- package/package.json +13 -15
- package/schemas/project.schema.json +12 -2
- package/schemas/vis-config.schema.json +248 -3
- package/dist/packem_chunks/applyDefaults.js +0 -2
- package/dist/packem_shared/ai-cache-Dtvmbsru.js +0 -1
- package/dist/packem_shared/ai-fix-BmLM72GS.js +0 -43
- package/dist/packem_shared/cache-directory-xASJia6M.js +0 -1
- package/dist/packem_shared/dependency-scan-DmwPKwLy.js +0 -2
- package/dist/packem_shared/docker-CA-scYu0.js +0 -2
- package/dist/packem_shared/failure-log-fD4DiFb1.js +0 -2
- package/dist/packem_shared/flakiness-BIg1rwvp.js +0 -1
- package/dist/packem_shared/index-OlP7U_t5.js +0 -6
- package/dist/packem_shared/lockfile-BXylopgH.js +0 -1
- package/dist/packem_shared/otelPlugin-y5hoCw4b.js +0 -1
- package/dist/packem_shared/registry-BHqKXiLb.js +0 -2
- package/dist/packem_shared/run-summary-utils-D39XBHWW.js +0 -1
- package/dist/packem_shared/runtime-check-BaKni2y1.js +0 -1
- package/dist/packem_shared/toolchain-B7sIiJxK.js +0 -5
- package/dist/packem_shared/typosquats-XkC1CnOa.js +0 -1
- package/dist/packem_shared/verify-BVTcVfoW.js +0 -1
- package/dist/packem_shared/vis-update-app-DR8c4OfG.js +0 -1
|
@@ -1,42 +1,167 @@
|
|
|
1
|
-
var Cr=Object.defineProperty;var S=(r,e)=>Cr(r,"name",{value:e,configurable:!0});import{createRequire as xr}from"node:module";import{runConcurrently as tt,TerminalBuffer as Vt,readLastRunSummary as Mr,enforceProjectConstraints as Er,expandTokensInString as jr,parsePartition as Rr,TaskScheduler as Or,createTaskGraph as Pr,reverseTaskGraph as _r,generateRunSummary as St,writeChromeTrace as Fr,CompositeLifeCycle as Ct,defaultTaskRunner as xt,createLogReporter as Ar,writeRunSummary as Lr}from"@visulima/task-runner";import{aA as Dr,p as It,aw as zt,b0 as Hr,av as Br,y as Nr,m as Gr,b1 as qr,b2 as Wr,s as ze,b3 as Ur}from"./bin.js";import{E as Vr,a as zr}from"../packem_shared/cache-directory-xASJia6M.js";import{M as Ce,Q as Kr,K as Qr,C as Qt,z as Xr}from"../packem_shared/index-OlP7U_t5.js";import{F as Zr}from"../packem_shared/failure-log-fD4DiFb1.js";import{f as Jr,l as eo,c as to,a as ro,b as oo}from"../packem_shared/flakiness-BIg1rwvp.js";import{r as so}from"../packem_shared/toolchain-B7sIiJxK.js";import{i as no,c as io,b as ao}from"../packem_shared/registry-BHqKXiLb.js";import{p as co,r as lo,f as uo}from"../packem_shared/selectors-BvtUXWGY.js";import{Box as p,Text as n,StaticRender as Mt,renderToString as re,ScrollView as Xt,Spinner as po,useApp as mo,useWindowSize as go,useInput as Et,Dialog as wo,render as ko}from"@visulima/tui";import N,{useSyncExternalStore as vo,useState as jt,useRef as Ee,useCallback as Ye,useEffect as Ke,useMemo as Rt}from"react";import{jsxs as u,jsx as l}from"react/jsx-runtime";import{T as Zt,C as rt,D as He,E as Jt}from"../packem_shared/symbols-CQmER5MT.js";const Ir=xr(import.meta.url),Me=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,De=S(r=>{if(typeof Me<"u"&&Me.versions&&Me.versions.node){const[e,t]=Me.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return Me.getBuiltinModule(r)}return Ir(r)},"__cjs_getBuiltinModule"),{existsSync:Yt,statSync:Kt,watch:Yr}=De("node:fs"),{createInterface:ho,emitKeypressEvents:fo}=De("node:readline"),{appendFile:ot}=De("node:fs/promises"),{platform:yo,homedir:st}=De("node:os");var bo=Object.defineProperty,$o=S((r,e)=>bo(r,"name",{value:e,configurable:!0}),"u$3"),To=Object.defineProperty,So=$o((r,e)=>To(r,"name",{value:e,configurable:!0}),"v"),Co=Object.defineProperty,xo=So((r,e)=>Co(r,"name",{value:e,configurable:!0}),"D");const Io=xo((r,e,t,o,s,a,c,d,h,f,i,k,v,$)=>{const M={d:o,h:s,m:a,mo:e,ms:d,s:c,w:t,y:r};return h!==void 0&&(M.future=h),f!==void 0&&(M.past=f),i!==void 0&&(M.decimal=i),k!==void 0&&(M.unitMap=k),v!==void 0&&(M.groupSeparator=v),$!==void 0&&(M.placeholderSeparator=$),M},"createDurationLanguage"),Mo={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},Eo=Io(r=>`year${r===1?"":"s"}`,r=>`month${r===1?"":"s"}`,r=>`week${r===1?"":"s"}`,r=>`day${r===1?"":"s"}`,r=>`hour${r===1?"":"s"}`,r=>`minute${r===1?"":"s"}`,r=>`second${r===1?"":"s"}`,r=>`millisecond${r===1?"":"s"}`,"in %s","%s ago",".",Mo,",","_");var jo=Object.defineProperty,Ro=S((r,e)=>jo(r,"name",{value:e,configurable:!0}),"o$3"),Oo=Object.defineProperty,Po=Ro((r,e)=>Oo(r,"name",{value:e,configurable:!0}),"o"),_o=Object.defineProperty,Fo=Po((r,e)=>_o(r,"name",{value:e,configurable:!0}),"o");const Ao=Fo(r=>{const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const o of e)if(!Object.hasOwn(r,o))throw new TypeError(`Missing required property: ${o}`);if(typeof r.future!="string"||typeof r.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const o of t)if(typeof r[o]!="string"&&typeof r[o]!="function")throw new TypeError(`Property ${o} must be of type string or function`);if(r.decimal&&typeof r.decimal!="string")throw new TypeError("Property decimal must be of type string");if(r.delimiter&&typeof r.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(r._digitReplacements&&!Array.isArray(r._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(r._numberFirst&&typeof r._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(r.unitMap&&typeof r.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(r.unitMap&&Object.values(r.unitMap).some(o=>typeof o!="string"))throw new TypeError("All values in unitMap must be of type string")},"validateDurationLanguage");var Lo=Object.defineProperty,Do=S((r,e)=>Lo(r,"name",{value:e,configurable:!0}),"b$3"),Ho=Object.defineProperty,Bo=Do((r,e)=>Ho(r,"name",{value:e,configurable:!0}),"b"),No=Object.defineProperty,Re=Bo((r,e)=>No(r,"name",{value:e,configurable:!0}),"g");const er=Re((r,e)=>{e=e||-1;const t=new RegExp(String.raw`^-?\d+(?:.\d{0,${String(e)}})?`).exec(r.toString());return t===null?r:Number.parseFloat(t[0])},"toFixed"),Ot=Re(({unitCount:r,unitName:e},t,o)=>{let{spacer:s}=o;const{maxDecimalPoints:a}=o;let c=".";o.decimal!==void 0?c=o.decimal:t.decimal!==void 0&&(c=t.decimal);let d;"digitReplacements"in o?d=o.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let h,f=r;a!==void 0&&(f=er(r,a));const i=f.toString();if(!t._hideCountIf2||r!==2)if(d){h="";for(const $ of i)h+=$==="."?c:d[$]}else h=i.replace(".",c);else h="";const k=t[e];let v=k;return typeof k=="function"&&(v=k(r)),t._hideCountIf2&&r===2&&(s=""),t._numberFirst?v+s+h:h+s+v},"renderPiece"),Go=Re((r,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:o}=e,s=e.largest??Number.POSITIVE_INFINITY,a={};let c,d,h,f=r;for(d=0;d<t.length;d++){c=t[d];const k=o[c];h=d===t.length-1?f/k:Math.floor(f/k),a[c]=h,f-=h*k}if(e.round){let k=s;for(d=0;d<t.length;d++)if(c=t[d],h=a[c],h!==0&&(k--,k===0)){for(let v=d+1;v<t.length;v++){const $=t[v],M=a[$];a[c]=(a[c]??0)+M*o[$]/o[c],a[$]=0}break}for(d=t.length-1;d>=0;d--){if(c=t[d],h=a[c],h===0)continue;const v=Math.round(h);if(a[c]=v,d===0)break;const $=t[d-1],M=o[$],R=Math.floor(v*o[c]/M);if(R)a[$]=(a[$]??0)+R,a[c]=0;else break}}const i=[];for(d=0;d<t.length&&i.length<s;d++){if(c=t[d],h=a[c],h&&!e.round&&i.length===s-1){let k,v=0;for(k=d+1,t.length;k<t.length;k++){const $=t[k];v+=a[$]*(e.unitMeasures[$]/e.unitMeasures[c])}h+=v,e.maxDecimalPoints!==void 0&&(h=er(h,e.maxDecimalPoints))}h&&i.push({unitCount:h,unitName:c})}return i},"getPieces"),qo=Re((r,e,t)=>{const{language:o,units:s}=e;if(r.length===0){const k=s.at(-1);return Ot({unitCount:0,unitName:k},o,e)}const{conjunction:a,serialComma:c}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:o.delimiter!==void 0&&(d=o.delimiter);let h="";e.timeAdverb&&t!==0&&(h=o.future??"",t<0&&(h=o.past??""));const f=r.map(k=>Ot(k,o,e));let i;return!a||r.length===1?i=f.join(d):r.length===2?i=f.join(a):i=f.slice(0,-1).join(d)+(c?",":"")+a+(f.at(-1)??""),h&&(i=h.replace("%s",i)),i},"formatPieces"),tr=Re((r,e)=>{if(Number.isNaN(r))throw new TypeError("Expected a valid number");if(typeof r!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:Eo,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Ao(t.language);const o=Math.abs(r),s=Go(o,t);return qo(s,t,r)},"duration");var Wo=Object.defineProperty,Be=S((r,e)=>Wo(r,"name",{value:e,configurable:!0}),"s$2");const Uo={bun:["bun.lock","bun.lockb"],npm:["package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]},Vo={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"]},zo={ci:{bun:"bun install --frozen-lockfile",npm:"npm ci",pnpm:"pnpm install --frozen-lockfile",yarn:"yarn install --immutable"},tty:{bun:"bun install",npm:"npm install",pnpm:"pnpm install",yarn:"yarn install"}},Yo=1e3,Ko=Be(r=>{for(const[e,t]of Object.entries(Uo))for(const o of t)if(Yt(Ce(r,o)))return{lockfileFile:o,manager:e}},"detectPackageManager"),Qo=Be((r,e)=>{let t;for(const o of Vo[e]){const s=Ce(r,o);if(!Yt(s))continue;const{mtimeMs:a}=Kt(s);(!t||a>t.mtimeMs)&&(t={mtimeMs:a,path:o})}return t},"findFreshestMarker"),Xo=Be((r,e={})=>{const t=Ko(r);if(!t)return{checked:!1};const{lockfileFile:o,manager:s}=t,a=Kt(Ce(r,o)).mtimeMs,c=Qo(r,s),d=zo[e.inCi?"ci":"tty"][s],h={installMarkerMtimeMs:c?.mtimeMs,lockfileMtimeMs:a,lockfilePath:o,marker:c?.path,packageManager:s};return c?a>c.mtimeMs+Yo?{checked:!0,detail:h,failure:"stale-install",message:`${o} is newer than node_modules (${c.path}) — run \`${d}\` to sync.`}:{checked:!0,detail:h}:{checked:!0,detail:h,failure:"missing-install",message:`lockfile detected but node_modules looks uninitialised — run \`${d}\` before \`vis run\`.`}},"checkLockfileFreshness"),Zo=Be((r,e,t,o={})=>{if(o.skip)return{checked:!1,shouldContinue:!0};const s=Xo(r,{inCi:e});if(!s.failure)return{...s,shouldContinue:!0};const a=`preflight: ${s.message??"lockfile drift detected"}`;return e&&!o.ciAsWarning?{...s,formattedMessage:a,shouldContinue:!1}:(t.warn(a),{...s,formattedMessage:a,shouldContinue:!0})},"runLockfilePreflight");var Jo=Object.defineProperty,rr=S((r,e)=>Jo(r,"name",{value:e,configurable:!0}),"p$5");const es=rr(r=>r.split(",").map(e=>e.trim()).filter(e=>e!==""),"splitPatterns"),ts=rr((r,e,t)=>{const o=new Set,s=[];if(r===void 0||r.trim()==="")return{skipTaskIds:o,unmatchedPatterns:s};const a=[...t],c=new Set(a),d=new Map;for(const h of a){const f=h.lastIndexOf(":");if(f===-1)continue;const i=h.slice(f+1),k=d.get(i);k===void 0?d.set(i,[h]):k.push(h)}for(const h of es(r)){if(h.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${h}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(c.has(h)){o.add(h);continue}const f=co(h);if(!f){s.push(h);continue}let i=!1;if(f.kind==="all"){const k=d.get(f.target)??[];for(const v of k)o.add(v),i=!0}else if(f.kind==="project"){const k=f.projects?.[0];if(k!==void 0){const v=`${k}:${f.target}`;c.has(v)&&(o.add(v),i=!0)}}else if(f.kind==="tag"){const k=f.tag;if(k!==void 0){const v=d.get(f.target)??[];for(const $ of v){const M=$.slice(0,$.lastIndexOf(":"));e.projects[M]?.tags?.includes(k)===!0&&(o.add($),i=!0)}}}i||s.push(h)}return{skipTaskIds:o,unmatchedPatterns:s}},"resolveSkipCachePatterns");var rs=Object.defineProperty,nt=S((r,e)=>rs(r,"name",{value:e,configurable:!0}),"a$2");const os=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,ss=new Set(["0","!","#","$","*","-","?","@","_"]),ns=nt(r=>{const e=new Map;for(const t of r.matchAll(os)){const o=t[1],s=t[3],a=t[2],c=o??s;if(c===void 0||ss.has(c))continue;const d=a!==void 0,h=e.get(c);h===void 0?e.set(c,d):h&&!d&&e.set(c,!1)}return[...e.entries()].map(([t,o])=>({hasDefault:o,name:t}))},"extractEnvReferences"),is=nt(r=>{const{command:e,processEnv:t,taskEnv:o,taskId:s}=r,a=ns(e);if(a.length===0)return;const c=[];for(const{hasDefault:d,name:h}of a){if(d)continue;const f=o[h],i=t[h];f===void 0&&i===void 0&&c.push(h)}if(c.length!==0)return{missing:c.toSorted(),taskId:s}},"checkStrictEnv"),as=nt(r=>{const e=r.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${r.taskId} references unset variable${r.missing.length===1?"":"s"} ${e}. Set ${r.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},"formatStrictEnvError");var cs=Object.defineProperty,we=S((r,e)=>cs(r,"name",{value:e,configurable:!0}),"i$2");const Pt=we(r=>{const e=new Set;for(const t of Object.values(r.projects))for(const o of Object.keys(t.targets??{}))e.add(o);return[...e].sort()},"collectAvailableTargets"),ls=we(r=>{const e=new Map;for(const t of r.values())for(const[o,s]of Object.entries(t))for(const a of s.aliases??[])e.has(a)||e.set(a,o);return e},"buildAliasMap"),ds=we((r,e)=>e.get(r)??r,"resolveTargetAlias"),us=we((r,e)=>{if(r.length===0)return e.length;if(e.length===0)return r.length;const t=[];for(let o=0;o<=e.length;o++)t[o]=[o];for(let o=0;o<=r.length;o++)t[0][o]=o;for(let o=1;o<=e.length;o++)for(let s=1;s<=r.length;s++){const a=e[o-1]===r[s-1]?0:1;t[o][s]=Math.min(t[o-1][s]+1,t[o][s-1]+1,t[o-1][s-1]+a)}return t[e.length][r.length]},"levenshtein"),hs=we((r,e,t=3)=>or(r,e,1,t)[0],"suggestTarget"),or=we((r,e,t=3,o=3)=>{const s=[];for(const a of e){const c=us(r.toLowerCase(),a.toLowerCase());c<=o&&s.push({distance:c,name:a})}return s.sort((a,c)=>a.distance-c.distance||a.name.localeCompare(c.name)),s.slice(0,t).map(a=>a.name)},"suggestTargets"),fs=we(r=>r.length===0?" (no targets found)":r.map(e=>` - ${e}`).join(`
|
|
2
|
-
`),"formatTargetList"),
|
|
3
|
-
`);for(const[
|
|
1
|
+
var as=Object.defineProperty;var M=(r,e)=>as(r,"name",{value:e,configurable:!0});import{createRequire as cs}from"node:module";import{M as ve,Q as ds,K as us,C as xr,z as hs,B as Mr,$ as fs}from"./config.js";import{aJ as ps,p as tr,Y as It,Z as xt,bb as gs,bc as ms,Q as at,bd as ws,X as vs,y as ks,m as ys,be as bs,bf as Ss,s as tt,bg as $s}from"./bin.js";import{runConcurrently as ct,TerminalBuffer as Er,readLastRunSummary as Ts,getLastRunSummaryPath as Cs,enforceProjectConstraints as Is,expandTokensInString as rr,parsePartition as xs,TaskScheduler as Ms,createTaskGraph as Es,reverseTaskGraph as Ps,generateRunSummary as sr,writeChromeTrace as Rs,CompositeLifeCycle as or,defaultTaskRunner as ir,createLogReporter as Fs,writeRunSummary as Os}from"@visulima/task-runner";import{E as js,a as Ds}from"../packem_shared/cache-directory-C_U1qsIw.js";import{F as Gs}from"../packem_shared/failure-log-CSC6KfcO.js";import{f as qs,l as Ws,c as Vs,a as zs,b as Us}from"../packem_shared/flakiness-Dzz-I3dB.js";import{r as Ys}from"../packem_shared/toolchain-B7dckBQ1.js";import{i as Ks,b as Qs,a as Xs,s as Js,r as Zs,d as eo,c as to}from"../packem_shared/lifecycle-BC6Nst6i.js";import{p as ro,r as so,f as oo}from"../packem_shared/selectors-B2ISH581.js";import{renderToString as ue,render as ao}from"@visulima/tui";import{Text as a}from"@visulima/tui/components/text";import X,{useSyncExternalStore as ot,useCallback as rt,useState as ze,useRef as Ue,useEffect as kt,useMemo as nr}from"react";import{jsxs as h,jsx as c,Fragment as Pr}from"react/jsx-runtime";import{Box as g}from"@visulima/tui/components/box";import{StaticRender as ar}from"@visulima/tui/components/static-render";import{T as Rr,C as Et,D as ht,E as Fr}from"../packem_shared/symbols-CQmER5MT.js";import{Dialog as co}from"@visulima/tui/components/dialog";import{useApp as lo}from"@visulima/tui/hooks/use-app";import{useInput as cr}from"@visulima/tui/hooks/use-input";import{useWindowSize as uo}from"@visulima/tui/hooks/use-window-size";import{ScrollView as Or}from"@visulima/tui/components/scroll-view";import{Spinner as jr}from"@visulima/tui/components/spinner";const ls=cs(import.meta.url),Ve=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ke=M(r=>{if(typeof Ve<"u"&&Ve.versions&&Ve.versions.node){const[e,t]=Ve.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return Ve.getBuiltinModule(r)}return ls(r)},"__cjs_getBuiltinModule"),{existsSync:Mt,statSync:lt,watch:_s,openSync:Ls,readSync:As,closeSync:Bs,readFileSync:Ns,mkdtempSync:Hs}=Ke("node:fs"),{createInterface:io,emitKeypressEvents:no}=Ke("node:readline"),{appendFile:Pt}=Ke("node:fs/promises"),{platform:ho,homedir:Rt,tmpdir:fo}=Ke("node:os"),{spawn:po}=Ke("node:child_process");var go=Object.defineProperty,mo=M((r,e)=>go(r,"name",{value:e,configurable:!0}),"u$3"),wo=Object.defineProperty,vo=mo((r,e)=>wo(r,"name",{value:e,configurable:!0}),"v"),ko=Object.defineProperty,yo=vo((r,e)=>ko(r,"name",{value:e,configurable:!0}),"D");const bo=yo((r,e,t,s,o,n,i,l,f,p,u,w,d,T)=>{const R={d:s,h:o,m:n,mo:e,ms:l,s:i,w:t,y:r};return f!==void 0&&(R.future=f),p!==void 0&&(R.past=p),u!==void 0&&(R.decimal=u),w!==void 0&&(R.unitMap=w),d!==void 0&&(R.groupSeparator=d),T!==void 0&&(R.placeholderSeparator=T),R},"createDurationLanguage"),So={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},$o=bo(r=>`year${r===1?"":"s"}`,r=>`month${r===1?"":"s"}`,r=>`week${r===1?"":"s"}`,r=>`day${r===1?"":"s"}`,r=>`hour${r===1?"":"s"}`,r=>`minute${r===1?"":"s"}`,r=>`second${r===1?"":"s"}`,r=>`millisecond${r===1?"":"s"}`,"in %s","%s ago",".",So,",","_");var To=Object.defineProperty,Co=M((r,e)=>To(r,"name",{value:e,configurable:!0}),"o$4"),Io=Object.defineProperty,xo=Co((r,e)=>Io(r,"name",{value:e,configurable:!0}),"o"),Mo=Object.defineProperty,Eo=xo((r,e)=>Mo(r,"name",{value:e,configurable:!0}),"o");const Po=Eo(r=>{const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const s of e)if(!Object.hasOwn(r,s))throw new TypeError(`Missing required property: ${s}`);if(typeof r.future!="string"||typeof r.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const s of t)if(typeof r[s]!="string"&&typeof r[s]!="function")throw new TypeError(`Property ${s} must be of type string or function`);if(r.decimal&&typeof r.decimal!="string")throw new TypeError("Property decimal must be of type string");if(r.delimiter&&typeof r.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(r._digitReplacements&&!Array.isArray(r._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(r._numberFirst&&typeof r._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(r.unitMap&&typeof r.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(r.unitMap&&Object.values(r.unitMap).some(s=>typeof s!="string"))throw new TypeError("All values in unitMap must be of type string")},"validateDurationLanguage");var Ro=Object.defineProperty,Fo=M((r,e)=>Ro(r,"name",{value:e,configurable:!0}),"b$3"),Oo=Object.defineProperty,jo=Fo((r,e)=>Oo(r,"name",{value:e,configurable:!0}),"b"),Do=Object.defineProperty,Qe=jo((r,e)=>Do(r,"name",{value:e,configurable:!0}),"g");const Dr=Qe((r,e)=>{e=e||-1;const t=new RegExp(String.raw`^-?\d+(?:.\d{0,${String(e)}})?`).exec(r.toString());return t===null?r:Number.parseFloat(t[0])},"toFixed"),lr=Qe(({unitCount:r,unitName:e},t,s)=>{let{spacer:o}=s;const{maxDecimalPoints:n}=s;let i=".";s.decimal!==void 0?i=s.decimal:t.decimal!==void 0&&(i=t.decimal);let l;"digitReplacements"in s?l=s.digitReplacements:"_digitReplacements"in t&&(l=t._digitReplacements);let f,p=r;n!==void 0&&(p=Dr(r,n));const u=p.toString();if(!t._hideCountIf2||r!==2)if(l){f="";for(const T of u)f+=T==="."?i:l[T]}else f=u.replace(".",i);else f="";const w=t[e];let d=w;return typeof w=="function"&&(d=w(r)),t._hideCountIf2&&r===2&&(o=""),t._numberFirst?d+o+f:f+o+d},"renderPiece"),_o=Qe((r,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:s}=e,o=e.largest??Number.POSITIVE_INFINITY,n={};let i,l,f,p=r;for(l=0;l<t.length;l++){i=t[l];const w=s[i];f=l===t.length-1?p/w:Math.floor(p/w),n[i]=f,p-=f*w}if(e.round){let w=o;for(l=0;l<t.length;l++)if(i=t[l],f=n[i],f!==0&&(w--,w===0)){for(let d=l+1;d<t.length;d++){const T=t[d],R=n[T];n[i]=(n[i]??0)+R*s[T]/s[i],n[T]=0}break}for(l=t.length-1;l>=0;l--){if(i=t[l],f=n[i],f===0)continue;const d=Math.round(f);if(n[i]=d,l===0)break;const T=t[l-1],R=s[T],G=Math.floor(d*s[i]/R);if(G)n[T]=(n[T]??0)+G,n[i]=0;else break}}const u=[];for(l=0;l<t.length&&u.length<o;l++){if(i=t[l],f=n[i],f&&!e.round&&u.length===o-1){let w,d=0;for(w=l+1,t.length;w<t.length;w++){const T=t[w];d+=n[T]*(e.unitMeasures[T]/e.unitMeasures[i])}f+=d,e.maxDecimalPoints!==void 0&&(f=Dr(f,e.maxDecimalPoints))}f&&u.push({unitCount:f,unitName:i})}return u},"getPieces"),Lo=Qe((r,e,t)=>{const{language:s,units:o}=e;if(r.length===0){const w=o.at(-1);return lr({unitCount:0,unitName:w},s,e)}const{conjunction:n,serialComma:i}=e;let l=", ";e.delimiter!==void 0?l=e.delimiter:s.delimiter!==void 0&&(l=s.delimiter);let f="";e.timeAdverb&&t!==0&&(f=s.future??"",t<0&&(f=s.past??""));const p=r.map(w=>lr(w,s,e));let u;return!n||r.length===1?u=p.join(l):r.length===2?u=p.join(n):u=p.slice(0,-1).join(l)+(i?",":"")+n+(p.at(-1)??""),f&&(u=f.replace("%s",u)),u},"formatPieces"),_r=Qe((r,e)=>{if(Number.isNaN(r))throw new TypeError("Expected a valid number");if(typeof r!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:$o,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Po(t.language);const s=Math.abs(r),o=_o(s,t);return Lo(o,t,r)},"duration");var Ao=Object.defineProperty,ft=M((r,e)=>Ao(r,"name",{value:e,configurable:!0}),"s$2");const Bo={bun:["bun.lock","bun.lockb"],npm:["package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]},No={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"]},Ho={ci:{bun:"bun install --frozen-lockfile",npm:"npm ci",pnpm:"pnpm install --frozen-lockfile",yarn:"yarn install --immutable"},tty:{bun:"bun install",npm:"npm install",pnpm:"pnpm install",yarn:"yarn install"}},Go=1e3,qo=ft(r=>{for(const[e,t]of Object.entries(Bo))for(const s of t)if(Mt(ve(r,s)))return{lockfileFile:s,manager:e}},"detectPackageManager"),Wo=ft((r,e)=>{let t;for(const s of No[e]){const o=ve(r,s);if(!Mt(o))continue;const{mtimeMs:n}=lt(o);(!t||n>t.mtimeMs)&&(t={mtimeMs:n,path:s})}return t},"findFreshestMarker"),Vo=ft((r,e={})=>{const t=qo(r);if(!t)return{checked:!1};const{lockfileFile:s,manager:o}=t,n=lt(ve(r,s)).mtimeMs,i=Wo(r,o),l=Ho[e.inCi?"ci":"tty"][o],f={installMarkerMtimeMs:i?.mtimeMs,lockfileMtimeMs:n,lockfilePath:s,marker:i?.path,packageManager:o};return i?n>i.mtimeMs+Go?{checked:!0,detail:f,failure:"stale-install",message:`${s} is newer than node_modules (${i.path}) — run \`${l}\` to sync.`}:{checked:!0,detail:f}:{checked:!0,detail:f,failure:"missing-install",message:`lockfile detected but node_modules looks uninitialised — run \`${l}\` before \`vis run\`.`}},"checkLockfileFreshness"),zo=ft((r,e,t,s={})=>{if(s.skip)return{checked:!1,shouldContinue:!0};const o=Vo(r,{inCi:e});if(!o.failure)return{...o,shouldContinue:!0};const n=`preflight: ${o.message??"lockfile drift detected"}`;return e&&!s.ciAsWarning?{...o,formattedMessage:n,shouldContinue:!1}:(t.warn(n),{...o,formattedMessage:n,shouldContinue:!0})},"runLockfilePreflight");var Uo=Object.defineProperty,Lr=M((r,e)=>Uo(r,"name",{value:e,configurable:!0}),"p$7");const Yo=Lr(r=>r.split(",").map(e=>e.trim()).filter(e=>e!==""),"splitPatterns"),Ko=Lr((r,e,t)=>{const s=new Set,o=[];if(r===void 0||r.trim()==="")return{skipTaskIds:s,unmatchedPatterns:o};const n=[...t],i=new Set(n),l=new Map;for(const f of n){const p=f.lastIndexOf(":");if(p===-1)continue;const u=f.slice(p+1),w=l.get(u);w===void 0?l.set(u,[f]):w.push(f)}for(const f of Yo(r)){if(f.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${f}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(i.has(f)){s.add(f);continue}const p=ro(f);if(!p){o.push(f);continue}let u=!1;if(p.kind==="all"){const w=l.get(p.target)??[];for(const d of w)s.add(d),u=!0}else if(p.kind==="project"){const w=p.projects?.[0];if(w!==void 0){const d=`${w}:${p.target}`;i.has(d)&&(s.add(d),u=!0)}}else if(p.kind==="tag"){const w=p.tag;if(w!==void 0){const d=l.get(p.target)??[];for(const T of d){const R=T.slice(0,T.lastIndexOf(":"));e.projects[R]?.tags?.includes(w)===!0&&(s.add(T),u=!0)}}}u||o.push(f)}return{skipTaskIds:s,unmatchedPatterns:o}},"resolveSkipCachePatterns");var Qo=Object.defineProperty,Ft=M((r,e)=>Qo(r,"name",{value:e,configurable:!0}),"a$2");const Xo=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,Jo=new Set(["0","!","#","$","*","-","?","@","_"]),Zo=Ft(r=>{const e=new Map;for(const t of r.matchAll(Xo)){const s=t[1],o=t[3],n=t[2],i=s??o;if(i===void 0||Jo.has(i))continue;const l=n!==void 0,f=e.get(i);f===void 0?e.set(i,l):f&&!l&&e.set(i,!1)}return[...e.entries()].map(([t,s])=>({hasDefault:s,name:t}))},"extractEnvReferences"),ei=Ft(r=>{const{command:e,processEnv:t,taskEnv:s,taskId:o}=r,n=Zo(e);if(n.length===0)return;const i=[];for(const{hasDefault:l,name:f}of n){if(l)continue;const p=s[f],u=t[f];p===void 0&&u===void 0&&i.push(f)}if(i.length!==0)return{missing:i.toSorted(),taskId:o}},"checkStrictEnv"),ti=Ft(r=>{const e=r.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${r.taskId} references unset variable${r.missing.length===1?"":"s"} ${e}. Set ${r.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},"formatStrictEnvError");var ri=Object.defineProperty,Fe=M((r,e)=>ri(r,"name",{value:e,configurable:!0}),"i$2");const dr=Fe(r=>{const e=new Set;for(const t of Object.values(r.projects))for(const s of Object.keys(t.targets??{}))e.add(s);return[...e].sort()},"collectAvailableTargets"),si=Fe(r=>{const e=new Map;for(const t of r.values())for(const[s,o]of Object.entries(t))for(const n of o.aliases??[])e.has(n)||e.set(n,s);return e},"buildAliasMap"),oi=Fe((r,e)=>e.get(r)??r,"resolveTargetAlias"),ii=Fe((r,e)=>{if(r.length===0)return e.length;if(e.length===0)return r.length;const t=[];for(let s=0;s<=e.length;s++)t[s]=[s];for(let s=0;s<=r.length;s++)t[0][s]=s;for(let s=1;s<=e.length;s++)for(let o=1;o<=r.length;o++){const n=e[s-1]===r[o-1]?0:1;t[s][o]=Math.min(t[s-1][o]+1,t[s][o-1]+1,t[s-1][o-1]+n)}return t[e.length][r.length]},"levenshtein"),ni=Fe((r,e,t=3)=>Ar(r,e,1,t)[0],"suggestTarget"),Ar=Fe((r,e,t=3,s=3)=>{const o=[];for(const n of e){const i=ii(r.toLowerCase(),n.toLowerCase());i<=s&&o.push({distance:i,name:n})}return o.sort((n,i)=>n.distance-i.distance||n.name.localeCompare(i.name)),o.slice(0,t).map(n=>n.name)},"suggestTargets"),ai=Fe(r=>r.length===0?" (no targets found)":r.map(e=>` - ${e}`).join(`
|
|
2
|
+
`),"formatTargetList"),ci=Fe(async r=>{if(r.length===0||!process.stdin.isTTY||!process.stdout.isTTY)return;const e=io({input:process.stdin,output:process.stdout});try{process.stdout.write(`Available targets:
|
|
3
|
+
`);for(const[o,n]of r.entries())process.stdout.write(` ${String(o+1).padStart(2," ")}. ${n}
|
|
4
4
|
`);process.stdout.write(`
|
|
5
|
-
`);const t=(await new Promise(
|
|
6
|
-
|
|
7
|
-
`).map(T=>T.replace(/\r$/,"")):[];return!o&&(h==="running"||h==="pending")?l(p,{borderBottomTitle:M,borderColor:k,borderStyle:i,borderTopRightTitle:$,borderTopTitle:v,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:l(p,{alignItems:"center",flexGrow:1,justifyContent:"center",children:l(n,{dimColor:!0,children:"Waiting for task output..."})})}):u(p,{borderBottomTitle:M,borderColor:t?"yellow":k,borderStyle:i,borderTopRightTitle:$,borderTopTitle:v,flexDirection:"column",flexGrow:1,children:[l(p,{flexGrow:1,flexShrink:1,paddingY:1,children:l(Xt,{flexGrow:1,followOutput:!0,paddingX:2,ref:s,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:R.map((T,O)=>l(n,{children:T},String(O)))})}),t&&l(p,{flexShrink:0,justifyContent:"center",paddingX:1,children:l(n,{bold:!0,color:"yellow",children:"INTERACTIVE — keystrokes forwarded to task — Esc to exit"})})]})},"OutputPanel");var js=Object.defineProperty,Ne=S((r,e)=>js(r,"name",{value:e,configurable:!0}),"x$1");const cr=6,lr=8,dr=10,Rs=Ne(r=>r==="running"||r==="pending"?Jt:r==="local-cache"||r==="local-cache-kept-existing"?"Local":r==="remote-cache"?"Remote":He,"getCacheLabel"),Ft=Ne((r,e)=>e[0]===r?"[1]":e[1]===r?"[2]":"","getPinLabel"),At=Ne(({compact:r,isSelected:e,pinLabel:t,row:o})=>{const{status:s,taskId:a}=o,c=e?">":" ";let d;if(s==="running")d=u(n,{bold:!0,color:"white",children:[" ",l(po,{type:"dots"})," "]});else if(s==="pending")d=l(n,{bold:!0,color:"gray",children:" · "});else{const{color:f,icon:i}=Pe(s);d=u(n,{bold:!0,color:f,children:[" ",i," "]})}let h=Jt;return s!=="running"&&s!=="pending"?h=o.duration===void 0?He:ve(o.duration):s==="running"&&o.elapsed!==void 0&&(h=ve(o.elapsed)),u(p,{children:[l(n,{children:c}),l(p,{width:cr,children:d}),u(p,{flexGrow:1,children:[l(n,{bold:e,inverse:e,children:a}),t?l(n,{dimColor:!0,children:` ${t}`}):null]}),!r&&l(p,{justifyContent:"flex-end",width:lr,children:l(n,{dimColor:!Te(s),children:Rs(s)})}),!r&&l(p,{justifyContent:"flex-end",width:dr,children:l(n,{dimColor:s==="pending",children:h})})]})},"TaskListRow"),Lt=Ne(({compact:r,filterActive:e,filterText:t,focused:o,headerStatus:s,parallelSlots:a=3,pinnedTaskIds:c,rows:d,scrollRef:h,selectedIndex:f,title:i})=>{const k=s==="error"?"red":s==="success"?"green":o?"white":"gray",v=d[f]?.taskId,$=d.filter(T=>T.status==="running"),M=$.length>0||d.some(T=>T.status==="pending"),R=[];if(M)for(let T=0;T<a;T++){const O=$[T];O?R.push(l(At,{compact:r,isSelected:O.taskId===v,pinLabel:Ft(O.taskId,c),row:O},`par-${O.taskId}`)):R.push(u(p,{children:[l(n,{children:" "}),l(p,{width:cr,children:l(n,{bold:!0,color:"gray",children:" · "})}),l(n,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(T)}`))}return u(p,{borderColor:k,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(p,{flexShrink:0,gap:1,paddingX:1,children:[l(n,{bold:!0,inverse:!0,children:" VIS "}),l(n,{children:i}),!r&&u(p,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[l(p,{justifyContent:"flex-end",width:lr,children:l(n,{dimColor:!0,children:"Cache"})}),l(p,{justifyContent:"flex-end",width:dr,children:l(n,{dimColor:!0,children:"Duration"})})]})]}),l(Xt,{flexGrow:1,flexShrink:1,paddingLeft:1,paddingY:1,ref:h,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:d.map(T=>l(At,{compact:r,isSelected:T.taskId===v,pinLabel:Ft(T.taskId,c),row:T},T.taskId))}),M&&l(p,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingLeft:1,paddingY:1,children:R}),e&&u(p,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[l(n,{bold:!0,color:"white",children:"/ "}),l(n,{children:t}),l(n,{inverse:!0,children:" "})]})]})},"TaskListPanel");var Os=Object.defineProperty,Ps=S((r,e)=>Os(r,"name",{value:e,configurable:!0}),"y$2");const Dt=40,Ht=10,Bt=100,_s=Ps(({autoExitSeconds:r,parallelSlots:e,projectNames:t,stdinRegistry:o,store:s,targets:a,tasks:c})=>{const{exit:d}=mo(),{columns:h,rows:f}=go(),i=vo(s.subscribe,s.getSnapshot),[k,v]=jt(!1),$=Ee(null),M=Ee(null),R=Ee(null),[T,O]=jt(!1),P=Ee({list:0,splitList:0,splitOutput:0}),Q=Ye(()=>{i.viewMode==="list"?P.current.list=M.current?.getScrollOffset()??0:i.viewMode==="split"&&(P.current.splitList=M.current?.getScrollOffset()??0,P.current.splitOutput=R.current?.getScrollOffset()??0)},[i.viewMode]),F=Ye(y=>{setTimeout(()=>{if(y==="list"){const m=P.current.list;M.current?.scrollTo(m)}else if(y==="split"){const m=P.current.splitList;m>0?M.current?.scrollTo(m):M.current?.scrollTo(Math.max(0,s.getSnapshot().selectedIndex-2)),R.current?.scrollTo(P.current.splitOutput)}},0)},[s]),w=Ee(!1);Ke(()=>{i.done&&!w.current&&(w.current=!0,r>0&&O(!0)),!i.done&&w.current&&(w.current=!1,O(!1))},[i.done,r]);const I=Rt(()=>{let y=i.rows;if(i.statusFilter!=="all"&&(y=y.filter(m=>i.statusFilter==="failed"?m.status==="failure":i.statusFilter==="running"?m.status==="running"||m.status==="pending":i.statusFilter==="passed"?m.status==="success"||Te(m.status):!0)),i.filterText){const m=i.filterText.toLowerCase();y=y.filter(x=>x.taskId.toLowerCase().includes(m))}return y},[i.rows,i.filterText,i.statusFilter]),_=Rt(()=>i.rows.filter(y=>y.status==="running").length,[i.rows]),G=(I[i.selectedIndex]??null)?.taskId??null,C=i.pinnedTaskIds[0]??G,H=C?i.rows.find(y=>y.taskId===C):null,ie=C?i.outputs.get(C)??"":"",L=at(t,a,c),q=i.done?`Completed ${L} (${ve((i.endTime??Date.now())-i.startTime)})`:`Running ${L}...`,ae=i.done?i.failed>0?"error":"success":"running",J=Ye(y=>{M.current?.scrollTo(Math.max(0,y-2))},[]);if(Ke(()=>{i.interactiveMode&&H?.status!=="running"&&s.setInteractiveMode(!1)},[i.interactiveMode,H?.status,s]),Ke(()=>{if(!C)return;let y=h;i.viewMode==="split"&&h>=Bt?y=h-Math.floor(h*.4)-2:(i.viewMode==="split"||i.viewMode==="fullscreen")&&(y=h-2);const m=Math.max(1,f-4);o.get(C)?.resize?.(y,m)},[h,f,i.viewMode,C]),Et((y,m)=>{if(m.escape){s.setInteractiveMode(!1);return}if(!C)return;const x=o.get(C);if(!x){s.setInteractiveMode(!1);return}if(m.return)x.write("\r");else if(m.upArrow)x.write("\x1B[A");else if(m.downArrow)x.write("\x1B[B");else if(m.rightArrow)x.write("\x1B[C");else if(m.leftArrow)x.write("\x1B[D");else if(m.backspace)x.write("");else if(m.delete)x.write("\x1B[3~");else if(m.tab)x.write(" ");else if(m.home)x.write("\x1B[H");else if(m.end)x.write("\x1B[F");else if(m.pageUp)x.write("\x1B[5~");else if(m.pageDown)x.write("\x1B[6~");else if(m.ctrl&&y){const ee=y.toUpperCase().codePointAt(0);ee!==void 0&&ee>=65&&ee<=90&&x.write(String.fromCodePoint(ee-64))}else y&&x.write(y)},{isActive:i.interactiveMode}),Et((y,m)=>{if(y==="c"&&m.ctrl){d();return}if(!T){if(k){m.escape||y==="?"?v(!1):y==="q"?(v(!1),O(!0)):m.downArrow||y==="j"?$.current?.scrollBy(1):m.upArrow||y==="k"?$.current?.scrollBy(-1):m.pageDown?$.current?.scrollBy(5):m.pageUp?$.current?.scrollBy(-5):m.home?$.current?.scrollToTop():m.end&&$.current?.scrollToBottom();return}if(y==="?"){v(!0);return}if(y==="q"){O(!0);return}if(y==="r"&&i.done){s.requestRerun();return}if(y==="R"&&i.done){const x=I[i.selectedIndex];x?.status==="failure"&&s.requestRetry(x.taskId);return}if(y==="F"&&!i.filterActive){const x=["all","failed","running","passed"],ee=x.indexOf(i.statusFilter);s.setStatusFilter(x[(ee+1)%x.length]);return}if(i.filterActive){if(m.escape){s.setFilterActive(!1);return}if(m.return){s.setFilterActive(!1);return}if(m.backspace){s.setFilter(i.filterText.slice(0,-1));return}if(y&&!m.ctrl&&!m.meta){s.setFilter(i.filterText+y);return}return}if(y==="i"&&H?.status==="running"&&(i.viewMode==="fullscreen"||i.viewMode==="split"&&i.focusedPanel==="output")){s.setInteractiveMode(!0);return}if(i.viewMode==="fullscreen"){if(m.escape){s.setViewMode("split"),F("split");return}if(m.downArrow||y==="j"){R.current?.scrollBy(1);return}if(m.upArrow||y==="k"){R.current?.scrollBy(-1);return}if(m.pageDown||m.ctrl&&y==="d"){R.current?.scrollBy(12);return}if(m.pageUp||m.ctrl&&y==="u"){R.current?.scrollBy(-12);return}if(m.home){R.current?.scrollToTop();return}if(m.end){R.current?.scrollToBottom();return}return}if(i.viewMode==="split"){if(m.tab){const x=i.focusedPanel==="tasks"?"output":"tasks";s.setFocusedPanel(x);return}if(i.focusedPanel==="output"){if(m.escape){s.setFocusedPanel("tasks");return}if(m.return){Q(),s.setViewMode("fullscreen");return}if(m.downArrow||y==="j"){R.current?.scrollBy(1);return}if(m.upArrow||y==="k"){R.current?.scrollBy(-1);return}if(m.pageDown||m.ctrl&&y==="d"){R.current?.scrollBy(12);return}if(m.pageUp||m.ctrl&&y==="u"){R.current?.scrollBy(-12);return}if(m.home){R.current?.scrollToTop();return}if(m.end){R.current?.scrollToBottom();return}return}if(m.escape){s.setViewMode("list"),F("list");return}if(m.return){s.setFocusedPanel("output");return}}if(i.viewMode==="list"||i.viewMode==="split"&&i.focusedPanel==="tasks"){if(m.downArrow||y==="j"){const x=Math.min(i.selectedIndex+1,Math.max(0,I.length-1));s.setSelectedIndex(x),J(x);return}if(m.upArrow||y==="k"){const x=Math.max(i.selectedIndex-1,0);s.setSelectedIndex(x),J(x);return}if(m.return&&i.viewMode==="list"){Q(),P.current.splitList=0,P.current.splitOutput=0,s.setViewMode("split"),s.setFocusedPanel("output"),F("split");return}if(y==="/"){s.setFilterActive(!0);return}if(y==="1"&&G){s.pinTask(0,G);return}if(y==="2"&&G){s.pinTask(1,G);return}if(y==="0"){s.clearPins();return}m.escape&&i.filterText&&s.setFilter("")}}},{isActive:!i.interactiveMode}),h<Dt||f<Ht)return l(p,{alignItems:"center",height:f,justifyContent:"center",width:h,children:u(n,{color:"yellow",children:["Terminal too small (",h,"x",f,"). Minimum:"," ",Dt,"x",Ht]})});const B=u(p,{gap:1,children:[i.succeeded>0&&u(n,{bold:!0,color:"green",children:["✓"," ",i.succeeded]}),i.failed>0&&u(n,{bold:!0,color:"red",children:["✗"," ",i.failed]}),_>0&&u(n,{color:"cyan",children:["◷"," ",_]}),u(n,{dimColor:!0,children:[i.rows.length," ","total"]}),i.statusFilter!=="all"&&u(n,{color:"yellow",children:["[",i.statusFilter,"]"]})]});let he;if(i.viewMode==="fullscreen")he=[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"Esc"}),l(n,{dimColor:!0,children:"BACK"})]},"esc"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"↑↓"}),l(n,{dimColor:!0,children:"SCROLL"})]},"scroll"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"^u ^d"}),l(n,{dimColor:!0,children:"PAGE"})]},"page"),...H?.status==="running"?[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"i"}),l(n,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"q"}),l(n,{dimColor:!0,children:"QUIT"})]},"q")];else if(i.done){const y=I[i.selectedIndex]?.status==="failure";he=[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"q"}),l(n,{dimColor:!0,children:"QUIT"})]},"q"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"r"}),l(n,{dimColor:!0,children:"RERUN"})]},"r"),...y?[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"R"}),l(n,{dimColor:!0,children:"RETRY"})]},"R")]:[],u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"?"}),l(n,{dimColor:!0,children:"HELP"})]},"?"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"↑↓"}),l(n,{dimColor:!0,children:"NAV"})]},"nav"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"F"}),l(n,{dimColor:!0,children:"FILTER"})]},"F"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"⏎"}),l(n,{dimColor:!0,children:i.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else i.viewMode==="split"&&i.focusedPanel==="output"?he=[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"q"}),l(n,{dimColor:!0,children:"QUIT"})]},"q"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"Esc"}),l(n,{dimColor:!0,children:"BACK"})]},"esc"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"↑↓"}),l(n,{dimColor:!0,children:"SCROLL"})]},"scroll"),...H?.status==="running"?[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"i"}),l(n,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"⏎"}),l(n,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"Tab"}),l(n,{dimColor:!0,children:"PANEL"})]},"tab"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"?"}),l(n,{dimColor:!0,children:"HELP"})]},"?")]:he=[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"q"}),l(n,{dimColor:!0,children:"QUIT"})]},"q"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"?"}),l(n,{dimColor:!0,children:"HELP"})]},"?"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"↑↓"}),l(n,{dimColor:!0,children:"NAV"})]},"nav"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"/"}),l(n,{dimColor:!0,children:"FILTER"})]},"/"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"F"}),l(n,{dimColor:!0,children:"STATUS"})]},"F"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"⏎"}),l(n,{dimColor:!0,children:i.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...i.viewMode==="split"?[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"Tab"}),l(n,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const ce=u(p,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[l(p,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:he}),l(p,{flexShrink:0,paddingX:1,children:B})]}),D=u(wo,{backgroundColor:"#1e1e1e",footer:u(n,{dimColor:!0,children:[l(n,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",l(n,{bold:!0,color:"white",children:"?"}),"/",l(n,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:$,title:"KEYBOARD SHORTCUTS",visible:k,width:52,children:[u(p,{flexDirection:"column",marginBottom:1,children:[u(p,{marginBottom:1,children:[l(n,{dimColor:!0,children:"── "}),l(n,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↑","/k"]}),l(n,{dimColor:!0,children:" Move up"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↓","/j"]}),l(n,{dimColor:!0,children:" Move down"})]})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Tab"]}),l(n,{dimColor:!0,children:" Switch panel (split)"})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Esc"]}),l(n,{dimColor:!0,children:" Back / close"})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Enter"]}),l(n,{dimColor:!0,children:" Show output / fullscreen"})]})]}),u(p,{flexDirection:"column",marginBottom:1,children:[u(p,{marginBottom:1,children:[l(n,{dimColor:!0,children:"── "}),l(n,{bold:!0,color:"white",children:"VIEWS"})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Enter"]}),u(n,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Esc"]}),u(n,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),u(p,{flexDirection:"column",marginBottom:1,children:[u(p,{marginBottom:1,children:[l(n,{dimColor:!0,children:"── "}),l(n,{bold:!0,color:"white",children:"ACTIONS"})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","/"]}),l(n,{dimColor:!0,children:" Filter by text"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","F"]}),l(n,{dimColor:!0,children:" Filter by status"})]})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","1"]}),l(n,{dimColor:!0,children:"/"}),l(n,{bold:!0,color:"white",children:"2"}),l(n,{dimColor:!0,children:" Pin to output pane"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","0"]}),l(n,{dimColor:!0,children:" Clear pins"})]})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","r"]}),l(n,{dimColor:!0,children:" Rerun all (done)"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","R"]}),l(n,{dimColor:!0,children:" Retry failed task"})]})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","i"]}),l(n,{dimColor:!0,children:" Interactive input (running task)"})]})]}),u(p,{flexDirection:"column",marginBottom:1,children:[u(p,{marginBottom:1,children:[l(n,{dimColor:!0,children:"── "}),l(n,{bold:!0,color:"white",children:"SCROLLING"}),l(n,{dimColor:!0,children:" (output panel)"})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↑","/k"]}),l(n,{dimColor:!0,children:" Scroll up"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↓","/j"]}),l(n,{dimColor:!0,children:" Scroll down"})]})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","^u"]}),l(n,{dimColor:!0,children:" Page up"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","^d"]}),l(n,{dimColor:!0,children:" Page down"})]})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Home"]}),l(n,{dimColor:!0,children:" Top"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","End"]}),l(n,{dimColor:!0,children:" Bottom"})]})]})]}),u(p,{flexDirection:"column",children:[u(p,{marginBottom:1,children:[l(n,{dimColor:!0,children:"── "}),l(n,{bold:!0,color:"white",children:"GENERAL"})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","q"]}),l(n,{dimColor:!0,children:" Quit"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","?"]}),l(n,{dimColor:!0,children:" Toggle help"})]})]})]})]}),U=l(Dr,{autoExitSeconds:r>0?r:3,onCancel:S(()=>{O(!1)},"onCancel"),visible:T});if(i.viewMode==="fullscreen")return u(p,{flexDirection:"column",height:f,width:h,children:[l(p,{flexGrow:1,children:l(_t,{duration:H?.duration??H?.elapsed,focused:!0,interactiveMode:i.interactiveMode,output:ie,scrollRef:R,status:H?.status,taskId:C})}),ce,U,D]});if(i.viewMode==="split"){const y=h>=Bt,m=l(Lt,{compact:!0,filterActive:i.filterActive,filterText:i.filterText,focused:i.focusedPanel==="tasks",headerStatus:ae,parallelSlots:e,pinnedTaskIds:i.pinnedTaskIds,rows:I,scrollRef:M,selectedIndex:i.selectedIndex,title:q}),x=l(_t,{duration:H?.duration??H?.elapsed,focused:i.focusedPanel==="output",interactiveMode:i.interactiveMode,output:ie,scrollRef:R,showFullscreenHint:!0,status:H?.status,taskId:C});if(y){const fe=Math.floor(h*.4);return u(p,{flexDirection:"column",height:f,width:h,children:[u(p,{flexDirection:"row",flexGrow:1,children:[l(p,{width:fe,children:m}),l(p,{flexGrow:1,children:x})]}),ce,U,D]})}const ee=Math.floor(f*.45);return u(p,{flexDirection:"column",height:f,width:h,children:[l(p,{height:ee,children:m}),l(p,{flexGrow:1,children:x}),ce,U,D]})}return u(p,{flexDirection:"column",height:f,width:h,children:[l(p,{flexGrow:1,children:l(Lt,{filterActive:i.filterActive,filterText:i.filterText,focused:!0,headerStatus:ae,parallelSlots:e,pinnedTaskIds:i.pinnedTaskIds,rows:I,scrollRef:M,selectedIndex:i.selectedIndex,title:q})}),ce,U,D]})},"VisTaskRunnerApp");var Fs=Object.defineProperty,$e=S((r,e)=>Fs(r,"name",{value:e,configurable:!0}),"n$2");const As=$e(r=>{const{args:e,autoExit:t=!1,outputStyle:o="normal",projectNames:s,stdinRegistry:a,tasks:c}=r,d=new Le(c),h=typeof e.parallel=="number"?e.parallel:3,f=t===!0?3:typeof t=="number"?t:0;let i,k;const v=new Promise(F=>{k=F});let $;const M=$e(()=>{$&&(clearInterval($),$=void 0)},"cleanup"),R=$e(()=>{if(a){for(const F of a.values())F.kill?.();a.clear()}},"killAllPtyProcesses"),T=$e(()=>{M(),Q(),R(),process.stdout.write("\x1B[?1049l\x1B[?25h"),i?.cleanup(),process.exit(1)},"onSignal"),O=$e(()=>{const F=d.getSnapshot(),w=ve(Date.now()-F.startTime),I=F.rows.filter(C=>C.status==="failure").map(C=>C.taskId),_=process.stdout.columns||80;process.stdout.write(`
|
|
8
|
-
`)
|
|
5
|
+
`);const t=(await new Promise(o=>{e.question("Select a target (number or name, blank to cancel): ",o)})).trim();if(t.length===0)return;const s=Number.parseInt(t,10);return Number.isFinite(s)&&s>=1&&s<=r.length?r[s-1]:r.includes(t)?t:ni(t,r)}finally{e.close()}},"promptTargetInteractively");var li=Object.defineProperty,it=M((r,e)=>li(r,"name",{value:e,configurable:!0}),"n$3");const di=new RegExp("[\x1B]\\[[0-?]*[ -/]*[@-~]","g"),yt=it(r=>r.replaceAll(di,"").replaceAll("\r",""),"sanitizeLogLine");class ur{static{M(this,"ServiceDockStore")}static{it(this,"ServiceDockStore")}#e=[];#o=new Set;#t=new Map;#s=new Map;constructor(e=[]){for(const t of e)this.#s.set(t,{id:t,status:"pending",tailLines:[]});this.#e=[...e],this.#i()}getSnapshot=it(()=>this.#t,"getSnapshot");subscribe=it(e=>(this.#o.add(e),()=>{this.#o.delete(e)}),"subscribe");getIds(){return this.#e}getState(e){return this.#s.get(e)}getDockState(){let e=!1,t=!1;for(const s of this.#s.values())s.status==="crashed"||s.status==="failed"?e=!0:(s.status==="pending"||s.status==="starting")&&(t=!0);return e?"crash":t?"boot":"ready"}registerService(e){this.#s.has(e)||(this.#s.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#n())}markStarting(e){this.#r(e,t=>({...t,errorMessage:void 0,startedAt:t.startedAt??Date.now(),status:"starting"}))}markStarted(e,t){this.#r(e,s=>({...s,startedAt:s.startedAt??Date.now(),status:s.status==="ready"?"ready":"starting"}))}markReady(e,t){this.#r(e,s=>({...s,errorMessage:void 0,port:t.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,t,s){const o=s?.message;this.#r(e,n=>({...n,errorMessage:yt(o??t),status:"failed"}))}markCrashed(e,t){const s=t.slice(-256).map(yt);this.#r(e,o=>({...o,errorMessage:s.length>0?s[s.length-1]:"process exited",status:"crashed",tailLines:s}))}appendLog(e,t){const s=t.split(`
|
|
6
|
+
`).map(yt).filter(o=>o.length>0);s.length!==0&&this.#r(e,o=>{const n=[...o.tailLines,...s];for(;n.length>256;)n.shift();let i=0;for(let l=n.length-1;l>=0;l--)if(i+=n[l].length+1,i>65536){n.splice(0,l+1);break}return{...o,lastLine:s[s.length-1],tailLines:n}})}abortBoot(e){let t=!1;const s=new Map(this.#s);for(const[o,n]of s)(n.status==="pending"||n.status==="starting")&&(s.set(o,{...n,errorMessage:e,status:"failed"}),t=!0);t&&(this.#s=s,this.#i(),this.#n())}#r(e,t){const s=this.#s.get(e);s&&(this.#s.set(e,t(s)),this.#i(),this.#n())}#i(){this.#t=new Map(this.#s)}#n(){for(const e of this.#o)try{e()}catch{}}}var ui=Object.defineProperty,Ot=M((r,e)=>ui(r,"name",{value:e,configurable:!0}),"i$1");const hi=Ot(r=>Array.isArray(r)?`[${r.join(",")}]`:typeof r=="object"&&r!==null?JSON.stringify(r):String(r),"formatValue"),fi=Ot((r,e,t)=>e==="_"?`${r}${Array.isArray(t)?t.join(" "):String(t)}`:`${r}--${e}=${hi(t)}`,"formatFlags"),jt=Ot((r,e,t)=>{const s=new Set(new Set(t.map(d=>d.target.target))),o=new Set(new Set(t.map(d=>d.target.project))),n=e.filter(d=>s.has(d)),i=r.filter(d=>o.has(d)),l=t.length-i.length*n.length,f=n.length===1?"target":"targets",p=n.join(", "),u=i.length===1?`project ${i[0]}`:`${i.length} projects`;let w=`${f} ${p} for ${u}`;return l>0&&(w+=` and ${l} ${l===1?"task":"tasks"} ${l===1?"it depends":"they depend"} on`),w},"formatTargetsAndProjects");var pi=Object.defineProperty,gi=M((r,e)=>pi(r,"name",{value:e,configurable:!0}),"c$4");const mi={error:"red",info:"white",success:"green"},$t=gi(({children:r,title:e,variant:t})=>{const s=mi[t];return h(g,{flexDirection:"column",children:[h(g,{gap:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),c(a,{bold:!0,color:s,children:"•"}),c(a,{children:e})]}),r]})},"Header");var wi=Object.defineProperty,vi=M((r,e)=>wi(r,"name",{value:e,configurable:!0}),"s$1");const Br=vi(({cached:r,failed:e,failedIds:t,projectNames:s,skippedIds:o,succeeded:n,targets:i,tasks:l,took:f})=>{const p=jt(s,i,l);if(e===0&&(!o||o.length===0)){const u=r>0?` (${r} read from cache)`:"";return c(ar,{children:M(()=>c($t,{title:`Successfully ran ${p}`,variant:"success",children:c(g,{marginTop:1,paddingLeft:3,children:h(a,{children:[c(a,{color:"green",children:Rr})," ",n+r," tasks completed",u?c(a,{dimColor:!0,children:u}):null,c(a,{dimColor:!0,children:` · Took ${f}`})]})})}),"children")})}return c(ar,{children:M(()=>c($t,{title:`Ran ${p}`,variant:"error",children:h(g,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&h(g,{flexDirection:"column",children:[h(a,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(u=>h(a,{dimColor:!0,children:[" - ",u]},u)),c(a,{})]}),e>0&&h(g,{flexDirection:"column",children:[h(a,{children:[c(a,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(u=>h(a,{children:[" ",c(a,{color:"red",children:Et})," ",u]},u)),c(a,{})]}),c(a,{dimColor:!0,children:` Took ${f}`})]})}),"children")})},"CommandSummary");var ki=Object.defineProperty,bt=M((r,e)=>ki(r,"name",{value:e,configurable:!0}),"o$3");class dt{static{M(this,"TaskStore")}static{bt(this,"TaskStore")}#e;#o=new Set;#t=new Map;constructor(e){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retryTaskId:null,rows:e.map(t=>({persistent:!!t.overrides.visOptions?.persistent,status:"pending",taskId:t.id})),selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,viewMode:"list"}}getSnapshot=bt(()=>this.#e,"getSnapshot");subscribe=bt(e=>(this.#o.add(e),()=>{this.#o.delete(e)}),"subscribe");startTasks(e){const t=[...this.#e.rows];for(const s of e){const o=t.findIndex(n=>n.taskId===s.id);o!==-1&&(t[o]={...t[o],elapsed:0,status:"running"},this.#t.set(s.id,process.hrtime()))}this.#r({...this.#e,rows:t})}endTasks(e){const t=[...this.#e.rows];let{cached:s,completed:o,failed:n,succeeded:i}=this.#e;const l=new Map(this.#e.outputs);for(const p of e){const u=t.findIndex(w=>w.taskId===p.task.id);switch(u!==-1&&(t[u]={...t[u],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,status:p.status}),o++,p.status){case"failure":{n++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{s++;break}case"success":{i++;break}}p.terminalOutput&&!l.has(p.task.id)&&l.set(p.task.id,p.terminalOutput),this.#t.delete(p.task.id)}let{selectedIndex:f}=this.#e;if(n>this.#e.failed){const p=t.findIndex(u=>u.status==="failure");p!==-1&&(f=p)}this.#r({...this.#e,cached:s,completed:o,failed:n,outputs:l,rows:t,selectedIndex:f,succeeded:i})}static#s=256*1024;addOutput(e,t){if(!t.trim())return;let s=(this.#e.outputs.get(e)??"")+t;s.length>dt.#s&&(s=s.slice(-dt.#s)),this.#e.outputs.set(e,s),this.#r({...this.#e})}setOutput(e,t){this.#e.outputs.set(e,t),this.#r({...this.#e})}markDone(){this.#r({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#r({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#t.size===0)return;let e=!1;const t=[...this.#e.rows];for(let s=0;s<t.length;s++){const o=t[s];if(o.status==="running"){const n=this.#t.get(o.taskId);if(n){const i=process.hrtime(n),l=i[0]*1e3+i[1]/1e6;t[s]={...o,elapsed:l},e=!0}}}e&&this.#r({...this.#e,rows:t})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#r({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#r({...this.#e,focusedPanel:e})}setFilter(e){this.#r({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#r({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,t){const s=[...this.#e.pinnedTaskIds];s[e]=t,this.#r({...this.#e,pinnedTaskIds:s})}clearPins(){this.#r({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const t=[...this.#e.rows],s=t.findIndex(l=>l.taskId===e);let{completed:o,failed:n,succeeded:i}=this.#e;if(s!==-1){const l=t[s].status;l==="failure"?(n=Math.max(0,n-1),o=Math.max(0,o-1)):l==="success"&&(i=Math.max(0,i-1),o=Math.max(0,o-1)),t[s]={...t[s],elapsed:0,status:"running"},this.#t.set(e,process.hrtime())}this.#r({...this.#e,completed:o,done:!1,endTime:null,failed:n,interactiveMode:!1,retryTaskId:e,rows:t,succeeded:i})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#r({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#r({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#r({...this.#e,viewMode:e})}setStatusFilter(e){this.#r({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#t.clear(),this.#r({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#r({...this.#e,rerunRequested:!1})}#r(e){this.#e=e;for(const t of this.#o)try{t()}catch{}}}var yi=Object.defineProperty,$e=M((r,e)=>yi(r,"name",{value:e,configurable:!0}),"t$1");const Nr={delimiter:" ",language:{d:$e(()=>" d","d"),future:"in %s",h:$e(()=>" h","h"),m:$e(()=>" m","m"),mo:$e(()=>" mo","mo"),ms:$e(()=>" ms","ms"),past:"%s ago",s:$e(()=>" s","s"),w:$e(()=>" w","w"),y:$e(()=>" y","y")},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]};$e(r=>{const e=r[0]*1e3+r[1]/1e6;return _r(e,Nr)},"formatHrtime");const _e=$e(r=>_r(r,Nr),"formatMs");var bi=Object.defineProperty,Xe=M((r,e)=>bi(r,"name",{value:e,configurable:!0}),"n$2");const Ne=Xe(r=>r==="local-cache"||r==="local-cache-kept-existing"||r==="remote-cache","isCacheStatus"),Je=Xe(r=>{switch(r){case"failure":return{color:"red",icon:Et};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Rr};case"skipped":return{color:"gray",icon:ht};default:return{color:"gray",icon:"?"}}},"getStatusInfo"),Hr=Xe(r=>{const{color:e,icon:t}=Je(r);return ue(X.createElement(a,{color:e},t),{columns:10}).trim()},"getStatusIcon"),Si=Xe(r=>{const{color:e,icon:t}=Je(r);switch(r){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return ue(X.createElement(a,null,X.createElement(a,{color:e},t)," ",X.createElement(a,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return ue(X.createElement(a,null,X.createElement(a,{dimColor:!0},t)," ",X.createElement(a,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return ue(X.createElement(a,{color:e},t),{columns:10}).trim()}},"getStatusPrefix"),$i=Xe((r,e,t)=>{const s=t.trim();if(!s)return;const o=`
|
|
7
|
+
`;if(process.env.GITHUB_ACTIONS==="true")process.stdout.write(`::group::${Hr(e)} ${r}${o}`),process.stdout.write(s+o),process.stdout.write(`::endgroup::${o}`);else{const n=process.stdout.columns||80,i=ue(X.createElement(a,{dimColor:!0},ht.repeat(n)),{columns:n}).trim(),l=Si(e),f=ue(X.createElement(a,{bold:!0},r),{columns:n}).trim();process.stdout.write(`${i}${o}`),process.stdout.write(`${l} ${f}${o}`),process.stdout.write(s+o),process.stdout.write(`${i}${o}`)}},"logCommandOutputCI");var Ti=Object.defineProperty,Dt=M((r,e)=>Ti(r,"name",{value:e,configurable:!0}),"d$3");const Ci=Dt(r=>r==="running"?{color:"white",icon:"•"}:r==="pending"?{color:"gray",icon:"·"}:Je(r),"getDisplayInfo"),Ii=Dt(({autoScroll:r,focused:e,interactiveMode:t,showFullscreenHint:s,statusValue:o,supportsInteractive:n,taskId:i})=>{if(!i)return;if(t)return"Esc cancel | Enter send";const l=r?"":" PAUSED (f resume)",f=n?" i INPUT":"";return e&&o==="running"&&s?`⏎ FULLSCREEN${f} f FOLLOW${l}`:e&&o==="running"?`f FOLLOW${f}${l}`:e&&s?`<enter> full screen${l}`:e?l||void 0:"<tab> or <enter> to focus"},"deriveBottomTitle"),hr=Dt(({autoScroll:r=!0,duration:e,focused:t,interactiveMode:s,output:o,scrollRef:n,showFullscreenHint:i,status:l,supportsInteractive:f=!0,taskId:p})=>{const u=l??"pending",{icon:w}=Ci(u),d=t?"bold":"single",T=u==="failure"?"red":u==="success"||Ne(u)?t?"green":"gray":u==="running"?t?"white":"cyan":t?"white":"gray",R=p?`${w} ${p}`:void 0,G=e===void 0?void 0:_e(e),E=Ii({autoScroll:r,focused:t,interactiveMode:s??!1,showFullscreenHint:i??!1,statusValue:u,supportsInteractive:f,taskId:p});if(!p)return h(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[c(a,{dimColor:!0,children:"Select a task to view output"}),c(a,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const k=[];if(o)for(const S of o.split(`
|
|
8
|
+
`))k.push(S.endsWith("\r")?S.slice(0,-1):S);return!o&&(u==="running"||u==="pending")?c(g,{borderBottomTitle:E,borderColor:T,borderStyle:d,borderTopRightTitle:G,borderTopTitle:R,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:c(g,{alignItems:"center",flexGrow:1,justifyContent:"center",children:c(a,{dimColor:!0,children:"Waiting for task output…"})})}):h(g,{borderBottomTitle:E,borderColor:s?"yellow":T,borderStyle:d,borderTopRightTitle:G,borderTopTitle:R,flexDirection:"column",flexGrow:1,children:[c(g,{flexGrow:1,flexShrink:1,paddingY:1,children:c(Or,{flexGrow:1,followOutput:r,paddingX:2,ref:n,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:c(a,{children:k.join(`
|
|
9
|
+
`)})})}),s&&c(g,{flexShrink:0,justifyContent:"center",paddingX:1,children:c(a,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},"OutputPanel");var xi=Object.defineProperty,Ge=M((r,e)=>xi(r,"name",{value:e,configurable:!0}),"d$2");const Mi={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Gr=Ge(r=>r==="ready"?"green":r==="crashed"||r==="failed"?"red":r==="starting"?"cyan":"gray","statusColor"),Ei=Ge(({status:r})=>r==="starting"?c(a,{color:"cyan",children:c(jr,{type:"dots"})}):c(a,{bold:!0,color:Gr(r),children:Mi[r]}),"StatusGlyph"),Pi=Ge(({active:r,focused:e,state:t})=>{const s=e&&r,o=s?">":" ",n=t.status==="ready"?t.port?`running, port ${String(t.port)}`:"running":t.status==="failed"||t.status==="crashed"?t.errorMessage??"exited":t.lastLine??"booting…";return h(g,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[c(a,{children:o}),c(a,{children:" "}),c(g,{flexShrink:0,width:3,children:c(Ei,{status:t.status})}),c(g,{flexGrow:0,flexShrink:0,width:28,children:c(a,{bold:s,inverse:s,children:t.id})}),c(g,{flexGrow:1,flexShrink:1,overflow:"hidden",children:h(a,{color:Gr(t.status),dimColor:t.status!=="crashed"&&t.status!=="failed",wrap:"truncate-end",children:[" ",n]})})]})},"ServiceRow"),Ri=Ge(({states:r})=>{const e=[];for(const s of r)s.status==="ready"&&e.push(s.id);const t=e.join(", ");return h(g,{paddingX:1,children:[h(a,{bold:!0,color:"green",children:["● ","Services"]}),h(a,{children:[" ",String(e.length)," / ",String(r.length)," running"]}),t.length>0&&h(a,{dimColor:!0,children:[" ",t]}),c(a,{dimColor:!0,children:" [Tab ↓]"})]})},"StatusPill"),Fi=Ge(({states:r})=>{const e=r.find(t=>t.status==="crashed"||t.status==="failed");return e?h(g,{flexDirection:"column",paddingX:1,children:[h(a,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((t,s)=>h(a,{color:"red",dimColor:!0,children:[" ",t]},`crash-${String(s)}`))]}):c(Pr,{})},"CrashHeader"),Oi=Ge(({activeIndex:r,focused:e,store:t})=>{const s=ot(t.subscribe,t.getSnapshot),o=t.getIds();if(o.length===0)return c(Pr,{});const n=[];for(const u of o){const w=s.get(u);w!==void 0&&n.push(w)}const i=t.getDockState(),l=i==="crash"?"red":i==="ready"?"gray":e?"white":"cyan";return i==="ready"&&!e?c(g,{borderColor:l,borderStyle:"single",flexDirection:"row",flexShrink:0,children:c(Ri,{states:n})}):h(g,{borderBottomTitle:e?i==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services",borderColor:l,borderStyle:e?"bold":"single",borderTopTitle:i==="crash"?"Services (crashed)":i==="ready"?"Services":"Services (starting)",flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[i==="crash"&&c(Fi,{states:n}),n.map((u,w)=>c(Pi,{active:w===r,focused:e,state:u},u.id))]})},"ServiceDock");var ji=Object.defineProperty,pt=M((r,e)=>ji(r,"name",{value:e,configurable:!0}),"T$1");const qr=6,Wr=8,Vr=12,Di=pt(r=>r==="running"||r==="pending"?Fr:r==="local-cache"||r==="local-cache-kept-existing"?"Local":r==="remote-cache"?"Remote":ht,"getCacheLabel"),fr=pt((r,e)=>e[0]===r?"[1]":e[1]===r?"[2]":"","getPinLabel"),pr=pt(({compact:r,focused:e,isSelected:t,pinLabel:s,row:o})=>{const{persistent:n,status:i,taskId:l}=o,f=e&&t,p=f?">":" ",u=i==="running"&&n===!0;let w;if(u)w=c(a,{bold:!0,color:"green",children:" ● "});else if(i==="running")w=h(a,{bold:!0,color:"white",children:[" ",c(jr,{type:"dots"})," "]});else if(i==="pending")w=c(a,{bold:!0,color:"gray",children:" · "});else{const{color:T,icon:R}=Je(i);w=h(a,{bold:!0,color:T,children:[" ",R," "]})}let d=Fr;return u?d="running":i!=="running"&&i!=="pending"?d=o.duration===void 0?ht:_e(o.duration):i==="running"&&o.elapsed!==void 0&&(d=_e(o.elapsed)),h(g,{children:[c(a,{children:p}),c(g,{width:qr,children:w}),h(g,{flexGrow:1,children:[c(a,{bold:f,inverse:f,children:l}),s?c(a,{dimColor:!0,children:` ${s}`}):null]}),!r&&c(g,{justifyContent:"flex-end",width:Wr,children:c(a,{dimColor:!Ne(i),children:Di(i)})}),!r&&c(g,{justifyContent:"flex-end",width:Vr,children:c(a,{color:u?"green":void 0,dimColor:i==="pending"||u,children:d})})]})},"TaskListRow"),gr=pt(({compact:r,filterActive:e,filterText:t,focused:s,headerStatus:o,parallelSlots:n=3,pinnedTaskIds:i,rows:l,scrollRef:f,selectedIndex:p,title:u})=>{const w=o==="error"?"red":o==="success"?"green":s?"white":"gray",d=l[p]?.taskId,T=[];let R=0;for(const S of l)S.status==="running"?T.push(S):S.status==="pending"&&(R+=1);const G=Math.min(n,T.length+R),E=G>1,k=[];if(E)for(let S=0;S<G;S++){const O=T[S];O?k.push(c(pr,{compact:r,focused:s,isSelected:O.taskId===d,pinLabel:fr(O.taskId,i),row:O},`par-${O.taskId}`)):k.push(h(g,{children:[c(a,{children:" "}),c(g,{width:qr,children:c(a,{bold:!0,color:"gray",children:" · "})}),c(a,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(S)}`))}return h(g,{borderColor:w,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[h(g,{flexShrink:0,paddingX:1,children:[c(a,{bold:!0,inverse:!0,children:" VIS "}),c(a,{children:` ${u}`}),!r&&h(g,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[c(g,{justifyContent:"flex-end",width:Wr,children:c(a,{dimColor:!0,children:"Cache"})}),c(g,{justifyContent:"flex-end",width:Vr,children:c(a,{dimColor:!0,children:"Duration"})})]})]}),c(Or,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:f,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:l.map(S=>c(pr,{compact:r,focused:s,isSelected:S.taskId===d,pinLabel:fr(S.taskId,i),row:S},S.taskId))}),E&&c(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:k}),e&&h(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[c(a,{bold:!0,color:"white",children:"/ "}),c(a,{children:t}),c(a,{inverse:!0,children:" "})]})]})},"TaskListPanel");var _i=Object.defineProperty,Li=M((r,e)=>_i(r,"name",{value:e,configurable:!0}),"ne");const mr=40,wr=10,vr=100,Ai=Object.freeze([]),Bi=Li(({autoExitSeconds:r,onRetryService:e,parallelSlots:t,projectNames:s,serviceDockStore:o,stdinRegistry:n,store:i,targets:l,tasks:f})=>{const{exit:p}=lo(),{columns:u,rows:w}=uo(),d=ot(i.subscribe,i.getSnapshot),T=rt($=>o?o.subscribe($):()=>{},[o]);ot(T,()=>o?o.getDockState():"ready");const R=o?o.getIds():Ai,G=R.length>0,[E,k]=ze(0),[S,O]=ze(null),J=ot(T,()=>S&&o?o.getState(S):void 0),[m,D]=ze(!1),x=Ue(null),Y=Ue(null),F=Ue(null),[ne,he]=ze(!1),[W,A]=ze(!0),K=Ue({list:0,splitList:0,splitOutput:0}),oe=rt(()=>{d.viewMode==="list"?K.current.list=Y.current?.getScrollOffset()??0:d.viewMode==="split"&&(K.current.splitList=Y.current?.getScrollOffset()??0,K.current.splitOutput=F.current?.getScrollOffset()??0)},[d.viewMode]),_=rt($=>{setTimeout(()=>{if($==="list"){const y=K.current.list;Y.current?.scrollTo(y)}else if($==="split"){const y=K.current.splitList;y>0?Y.current?.scrollTo(y):Y.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),F.current?.scrollTo(K.current.splitOutput)}},0)},[i]),fe=Ue(!1);kt(()=>{d.done&&!fe.current&&(fe.current=!0,r>0&&he(!0)),!d.done&&fe.current&&(fe.current=!1,he(!1))},[d.done,r]);const ae=nr(()=>{const $=R.length>0?new Set(R):null,y=d.filterText?d.filterText.toLowerCase():null,C=[];for(const ee of d.rows)$?.has(ee.taskId)||d.statusFilter==="failed"&&ee.status!=="failure"||d.statusFilter==="running"&&ee.status!=="running"&&ee.status!=="pending"||d.statusFilter==="passed"&&ee.status!=="success"&&!Ne(ee.status)||y&&!ee.taskId.toLowerCase().includes(y)||C.push(ee);return C},[d.rows,d.filterText,d.statusFilter,R]),Te=nr(()=>{let $=0;for(const y of d.rows)y.status==="running"&&($+=1);return $},[d.rows]),B=(ae[d.selectedIndex]??null)?.taskId??null,Z=S?null:d.pinnedTaskIds[0]??B,U=Z?d.rows.find($=>$.taskId===Z):null,ke=J??null,Me=S?(ke?.tailLines??[]).join(`
|
|
10
|
+
`):Z?d.outputs.get(Z)??"":"",ce=S??Z,Ce=S?ke?.status==="crashed"||ke?.status==="failed"?"failure":"running":U?.status,Ee=jt(s,l,f),Pe=d.done?`Completed ${Ee} (${_e((d.endTime??Date.now())-d.startTime)})`:`Running ${Ee}...`,Re=d.done?d.failed>0?"error":"success":"running",ge=rt($=>{Y.current?.scrollTo(Math.max(0,$-2))},[]);if(kt(()=>{d.interactiveMode&&U?.status!=="running"&&i.setInteractiveMode(!1)},[d.interactiveMode,U?.status,i]),kt(()=>{if(!Z)return;let $=u;d.viewMode==="split"&&u>=vr?$=u-Math.floor(u*.4)-2:(d.viewMode==="split"||d.viewMode==="fullscreen")&&($=u-2);const y=Math.max(1,w-4);n.get(Z)?.resize?.($,y)},[u,w,d.viewMode,Z]),cr(($,y)=>{if(y.escape){i.setInteractiveMode(!1);return}if(!Z)return;const C=n.get(Z);if(!C){i.setInteractiveMode(!1);return}if(y.return)C.write("\r");else if(y.upArrow)C.write("\x1B[A");else if(y.downArrow)C.write("\x1B[B");else if(y.rightArrow)C.write("\x1B[C");else if(y.leftArrow)C.write("\x1B[D");else if(y.backspace)C.write("");else if(y.delete)C.write("\x1B[3~");else if(y.tab)C.write(" ");else if(y.home)C.write("\x1B[H");else if(y.end)C.write("\x1B[F");else if(y.pageUp)C.write("\x1B[5~");else if(y.pageDown)C.write("\x1B[6~");else if(y.ctrl&&$){const ee=$.toUpperCase().codePointAt(0);ee!==void 0&&ee>=65&&ee<=90&&C.write(String.fromCodePoint(ee-64))}else $&&C.write($)},{isActive:d.interactiveMode}),cr(($,y)=>{if($==="c"&&y.ctrl){p();return}if(!ne){if(m){y.escape||$==="?"?D(!1):$==="q"?(D(!1),he(!0)):y.downArrow||$==="j"?x.current?.scrollBy(1):y.upArrow||$==="k"?x.current?.scrollBy(-1):y.pageDown?x.current?.scrollBy(5):y.pageUp?x.current?.scrollBy(-5):y.home?x.current?.scrollToTop():y.end&&x.current?.scrollToBottom();return}if($==="?"){D(!0);return}if($==="q"){he(!0);return}if($==="r"&&d.done){i.requestRerun();return}if($==="R"&&d.done){const C=ae[d.selectedIndex];C?.status==="failure"&&i.requestRetry(C.taskId);return}if($==="F"&&!d.filterActive){const C=["all","failed","running","passed"],ee=C.indexOf(d.statusFilter);i.setStatusFilter(C[(ee+1)%C.length]);return}if(d.filterActive){if(y.escape){i.setFilterActive(!1);return}if(y.return){i.setFilterActive(!1);return}if(y.backspace){i.setFilter(d.filterText.slice(0,-1));return}if($&&!y.ctrl&&!y.meta){i.setFilter(d.filterText+$);return}return}if($==="i"&&U?.status==="running"&&(d.viewMode==="fullscreen"||d.viewMode==="split"&&d.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(d.viewMode==="fullscreen"){if(y.escape){i.setViewMode("split"),_("split");return}if($==="f"){const C=!W;A(C),C&&F.current?.scrollToBottom();return}if(y.downArrow||$==="j"){A(!1),F.current?.scrollBy(1);return}if(y.upArrow||$==="k"){A(!1),F.current?.scrollBy(-1);return}if(y.pageDown||y.ctrl&&$==="d"){A(!1),F.current?.scrollBy(12);return}if(y.pageUp||y.ctrl&&$==="u"){A(!1),F.current?.scrollBy(-12);return}if(y.home){A(!1),F.current?.scrollToTop();return}if(y.end){A(!0),F.current?.scrollToBottom();return}return}if(d.focusedPanel==="dock"&&G&&o){if(y.tab){O(null),i.setFocusedPanel("tasks");return}if(y.escape){i.setFocusedPanel("tasks"),O(null),d.viewMode==="split"&&(i.setViewMode("list"),_("list"));return}if(y.downArrow||$==="j"){k(C=>Math.min(C+1,R.length-1));return}if(y.upArrow||$==="k"){k(C=>Math.max(C-1,0));return}if(y.return){const C=R[E];C&&(O(C),A(!0),oe(),K.current.splitList=0,K.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),_("split"));return}if(($==="r"||$==="R")&&e){const C=R[E],ee=C?o.getState(C)?.status:void 0;if(C&&(ee==="crashed"||ee==="failed")){const Ae=e(C);Ae instanceof Promise&&Ae.catch(()=>{})}return}return}if(d.viewMode==="split"){if(y.tab){d.focusedPanel==="tasks"?i.setFocusedPanel("output"):G?i.setFocusedPanel("dock"):(O(null),i.setFocusedPanel("tasks"));return}if(d.focusedPanel==="output"){if(y.escape){if(S&&G){O(null),i.setViewMode("list"),i.setFocusedPanel("dock"),_("list");return}O(null),i.setFocusedPanel("tasks");return}if(y.return){oe(),i.setViewMode("fullscreen");return}if($==="f"){const C=!W;A(C),C&&F.current?.scrollToBottom();return}if(y.downArrow||$==="j"){A(!1),F.current?.scrollBy(1);return}if(y.upArrow||$==="k"){A(!1),F.current?.scrollBy(-1);return}if(y.pageDown||y.ctrl&&$==="d"){A(!1),F.current?.scrollBy(12);return}if(y.pageUp||y.ctrl&&$==="u"){A(!1),F.current?.scrollBy(-12);return}if(y.home){A(!1),F.current?.scrollToTop();return}if(y.end){A(!0),F.current?.scrollToBottom();return}return}if(y.escape){i.setViewMode("list"),_("list");return}if(y.return){i.setFocusedPanel("output");return}}if(d.viewMode==="list"||d.viewMode==="split"&&d.focusedPanel==="tasks"){if(y.tab&&d.viewMode==="list"&&G){i.setFocusedPanel("dock");return}if(y.downArrow||$==="j"){const C=Math.min(d.selectedIndex+1,Math.max(0,ae.length-1));i.setSelectedIndex(C),ge(C);return}if(y.upArrow||$==="k"){const C=Math.max(d.selectedIndex-1,0);i.setSelectedIndex(C),ge(C);return}if(y.return&&d.viewMode==="list"){A(!0),oe(),K.current.splitList=0,K.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),_("split");return}if($==="/"){i.setFilterActive(!0);return}if($==="1"&&B){i.pinTask(0,B);return}if($==="2"&&B){i.pinTask(1,B);return}if($==="0"){i.clearPins();return}y.escape&&d.filterText&&i.setFilter("")}}},{isActive:!d.interactiveMode}),u<mr||w<wr)return c(g,{alignItems:"center",height:w,justifyContent:"center",width:u,children:h(a,{color:"yellow",children:["Terminal too small (",u,"x",w,"). Minimum:"," ",mr,"x",wr]})});const me=h(g,{gap:1,children:[d.succeeded>0&&h(a,{bold:!0,color:"green",children:["✓"," ",d.succeeded]}),d.failed>0&&h(a,{bold:!0,color:"red",children:["✗"," ",d.failed]}),Te>0&&h(a,{color:"cyan",children:["◷"," ",Te]}),h(a,{dimColor:!0,children:[d.rows.length," ","total"]}),d.statusFilter!=="all"&&h(a,{color:"yellow",children:["[",d.statusFilter,"]"]})]});let Oe;if(d.viewMode==="fullscreen")Oe=[h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Esc"}),c(a,{dimColor:!0,children:"BACK"})]},"esc"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"^u ^d"}),c(a,{dimColor:!0,children:"PAGE"})]},"page"),...U?.status==="running"?[h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"i"}),c(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q")];else if(d.done){const $=ae[d.selectedIndex]?.status==="failure";Oe=[h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"r"}),c(a,{dimColor:!0,children:"RERUN"})]},"r"),...$?[h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"R"}),c(a,{dimColor:!0,children:"RETRY"})]},"R")]:[],h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]},"nav"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"F"}),c(a,{dimColor:!0,children:"FILTER"})]},"F"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"⏎"}),c(a,{dimColor:!0,children:d.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else d.viewMode==="split"&&d.focusedPanel==="output"?Oe=[h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Esc"}),c(a,{dimColor:!0,children:"BACK"})]},"esc"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),...U?.status==="running"?[h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"i"}),c(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"⏎"}),c(a,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]},"tab"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?")]:Oe=[h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"q"}),c(a,{dimColor:!0,children:"QUIT"})]},"q"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"?"}),c(a,{dimColor:!0,children:"HELP"})]},"?"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"↑↓"}),c(a,{dimColor:!0,children:"NAV"})]},"nav"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"/"}),c(a,{dimColor:!0,children:"FILTER"})]},"/"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"F"}),c(a,{dimColor:!0,children:"STATUS"})]},"F"),h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"⏎"}),c(a,{dimColor:!0,children:d.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...d.viewMode==="split"?[h(g,{gap:1,children:[c(a,{bold:!0,color:"white",children:"Tab"}),c(a,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const Ie=h(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c(g,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:Oe}),c(g,{flexShrink:0,paddingX:1,children:me})]}),je=h(co,{backgroundColor:"#1e1e1e",footer:h(a,{dimColor:!0,children:[c(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(a,{bold:!0,color:"white",children:"?"}),"/",c(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:x,title:"KEYBOARD SHORTCUTS",visible:m,width:52,children:[h(g,{flexDirection:"column",marginBottom:1,children:[h(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),h(g,{children:[c(g,{width:24,children:h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(a,{dimColor:!0,children:" Move up"})]})}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(a,{dimColor:!0,children:" Move down"})]})]}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","Tab"]}),c(a,{dimColor:!0,children:" Switch panel (split)"})]}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","Esc"]}),c(a,{dimColor:!0,children:" Back / close"})]}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","Enter"]}),c(a,{dimColor:!0,children:" Show output / fullscreen"})]})]}),h(g,{flexDirection:"column",marginBottom:1,children:[h(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"VIEWS"})]}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","Enter"]}),h(a,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","Esc"]}),h(a,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),h(g,{flexDirection:"column",marginBottom:1,children:[h(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"ACTIONS"})]}),h(g,{children:[c(g,{width:24,children:h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","/"]}),c(a,{dimColor:!0,children:" Filter by text"})]})}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","F"]}),c(a,{dimColor:!0,children:" Filter by status"})]})]}),h(g,{children:[c(g,{width:24,children:h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","1"]}),c(a,{dimColor:!0,children:"/"}),c(a,{bold:!0,color:"white",children:"2"}),c(a,{dimColor:!0,children:" Pin to output pane"})]})}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","0"]}),c(a,{dimColor:!0,children:" Clear pins"})]})]}),h(g,{children:[c(g,{width:24,children:h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","r"]}),c(a,{dimColor:!0,children:" Rerun all (done)"})]})}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","R"]}),c(a,{dimColor:!0,children:" Retry failed task"})]})]}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","i"]}),c(a,{dimColor:!0,children:" Interactive input (running task)"})]})]}),h(g,{flexDirection:"column",marginBottom:1,children:[h(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"SCROLLING"}),c(a,{dimColor:!0,children:" (output panel)"})]}),h(g,{children:[c(g,{width:24,children:h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(a,{dimColor:!0,children:" Scroll up"})]})}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(a,{dimColor:!0,children:" Scroll down"})]})]}),h(g,{children:[c(g,{width:24,children:h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","^u"]}),c(a,{dimColor:!0,children:" Page up"})]})}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","^d"]}),c(a,{dimColor:!0,children:" Page down"})]})]}),h(g,{children:[c(g,{width:24,children:h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","Home"]}),c(a,{dimColor:!0,children:" Top"})]})}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","End"]}),c(a,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","f"]}),c(a,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),h(g,{flexDirection:"column",children:[h(g,{marginBottom:1,children:[c(a,{dimColor:!0,children:"── "}),c(a,{bold:!0,color:"white",children:"GENERAL"})]}),h(g,{children:[c(g,{width:24,children:h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","q"]}),c(a,{dimColor:!0,children:" Quit"})]})}),h(a,{children:[h(a,{bold:!0,color:"white",children:[" ","?"]}),c(a,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ye=c(ps,{autoExitSeconds:r>0?r:3,onCancel:M(()=>{he(!1)},"onCancel"),visible:ne}),Le=G&&o?c(Oi,{activeIndex:E,focused:d.focusedPanel==="dock",store:o}):null;if(d.viewMode==="fullscreen")return h(g,{flexDirection:"column",height:w,width:u,children:[c(g,{flexGrow:1,children:c(hr,{autoScroll:W,duration:U?.duration??U?.elapsed,focused:!0,interactiveMode:d.interactiveMode,output:Me,scrollRef:F,status:Ce,supportsInteractive:!S,taskId:ce})}),Le,Ie,ye,je]});if(d.viewMode==="split"){const $=u>=vr,y=c(gr,{compact:!0,filterActive:d.filterActive,filterText:d.filterText,focused:d.focusedPanel==="tasks",headerStatus:Re,parallelSlots:t,pinnedTaskIds:d.pinnedTaskIds,rows:ae,scrollRef:Y,selectedIndex:d.selectedIndex,title:Pe}),C=c(hr,{autoScroll:W,duration:U?.duration??U?.elapsed,focused:d.focusedPanel==="output",interactiveMode:d.interactiveMode,output:Me,scrollRef:F,showFullscreenHint:!0,status:Ce,supportsInteractive:!S,taskId:ce});if($){const Ae=Math.floor(u*.4);return h(g,{flexDirection:"column",height:w,width:u,children:[h(g,{flexDirection:"row",flexGrow:1,children:[c(g,{width:Ae,children:y}),c(g,{flexGrow:1,children:C})]}),Le,Ie,ye,je]})}const ee=Math.floor(w*.45);return h(g,{flexDirection:"column",height:w,width:u,children:[c(g,{height:ee,children:y}),c(g,{flexGrow:1,children:C}),Le,Ie,ye,je]})}return h(g,{flexDirection:"column",height:w,width:u,children:[c(g,{flexGrow:1,children:c(gr,{filterActive:d.filterActive,filterText:d.filterText,focused:d.focusedPanel!=="dock",headerStatus:Re,parallelSlots:t,pinnedTaskIds:d.pinnedTaskIds,rows:ae,scrollRef:Y,selectedIndex:d.selectedIndex,title:Pe})}),Le,Ie,ye,je]})},"VisTaskRunnerApp");var Ni=Object.defineProperty,De=M((r,e)=>Ni(r,"name",{value:e,configurable:!0}),"r$2");const Hi=De(r=>{const{args:e,autoExit:t=!1,onRetryService:s,outputStyle:o="normal",projectNames:n,serviceDockStore:i,stdinRegistry:l,tasks:f}=r,p=new dt(f),u=typeof e.parallel=="number"?e.parallel:3,w=t===!0?3:typeof t=="number"?t:0;let d,T;const R=new Promise(x=>{T=x});let G;const E=De(()=>{G&&(clearInterval(G),G=void 0)},"cleanup"),k=De(()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},"releaseStdin"),S=De(()=>{if(l){for(const x of l.values())x.kill?.();l.clear()}},"killAllPtyProcesses"),O=De(()=>{E(),D(),S(),k(),process.stdout.write("\x1B[?1049l\x1B[?25h"),d?.cleanup(),process.exit(1)},"onSignal"),J=De(()=>{const x=p.getSnapshot(),Y=_e(Date.now()-x.startTime),F=x.rows.filter(W=>W.status==="failure").map(W=>W.taskId),ne=process.stdout.columns||80;process.stdout.write(`
|
|
11
|
+
`);for(const W of x.rows){const{persistent:A,status:K,taskId:oe}=W,_=K==="running"||K==="pending",fe=Je(K),ae=_&&A?"■":fe.icon,Te=_&&A?"gray":fe.color;let B="";switch(K){case"local-cache":case"local-cache-kept-existing":{B=" [local cache]";break}case"remote-cache":{B=" [remote cache]";break}case"skipped":{B=" [skipped]";break}default:{_&&A?B=" [stopped]":_&&(B=" [skipped]");break}}const Z=ue(X.createElement(a,null," ",X.createElement(a,{color:Te},ae),` vis run ${oe}`,B?X.createElement(a,{dimColor:!0},` ${B}`):null),{columns:ne});process.stdout.write(`${Z}
|
|
9
12
|
`)}process.stdout.write(`
|
|
10
|
-
`);const
|
|
11
|
-
`),
|
|
12
|
-
`,
|
|
13
|
-
|
|
14
|
-
`);const
|
|
15
|
-
`).map(
|
|
16
|
-
`);process.stdout.write(`${
|
|
17
|
-
`)}}},"printExitSummary");let
|
|
13
|
+
`);const he=ue(X.createElement(Br,{cached:x.cached,failed:x.failed,failedIds:F,projectNames:n,succeeded:x.succeeded,targets:e.targets,tasks:f,took:Y}),{columns:ne});if(process.stdout.write(`${he}
|
|
14
|
+
`),F.length>0&&o!=="quiet")for(const W of F){const A=x.outputs.get(W);if(A?.trim()){const K=ue(X.createElement(a,null,`
|
|
15
|
+
`,X.createElement(a,{bold:!0,color:"red"},` ${Et} vis run ${W}`)),{columns:ne});process.stdout.write(`${K}
|
|
16
|
+
|
|
17
|
+
`);const oe=A.trim().split(`
|
|
18
|
+
`).map(_=>` ${_}`).join(`
|
|
19
|
+
`);process.stdout.write(`${oe}
|
|
20
|
+
`)}}},"printExitSummary");let m;const D=De(()=>{m&&(clearInterval(m),m=void 0)},"clearKeepAlive");return{lifeCycle:{endCommand(){E(),p.markDone(),m||(m=setInterval(()=>{},1e3))},endTasks(x){p.endTasks(x)},printTaskTerminalOutput(x,Y,F){p.getSnapshot().outputs.has(x.id)||p.addOutput(x.id,F)},startCommand(){process.on("SIGINT",O),process.on("SIGTERM",O),m||(m=setInterval(()=>{},1e3)),d=ao(X.createElement(Bi,{autoExitSeconds:w,onRetryService:s,parallelSlots:u,projectNames:n,serviceDockStore:i,stdinRegistry:l??new Map,store:p,targets:e.targets,tasks:f}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),d.waitUntilExit().then(()=>{D(),S(),k(),process.removeListener("SIGINT",O),process.removeListener("SIGTERM",O),J(),T()}).catch(()=>{D(),S(),k(),process.removeListener("SIGINT",O),process.removeListener("SIGTERM",O),T()})},startTasks(x){p.startTasks(x),G||(G=setInterval(()=>{p.tick()},100))}},renderIsDone:R,store:p}},"createDynamicOutputRenderer");var Gi=Object.defineProperty,_t=M((r,e)=>Gi(r,"name",{value:e,configurable:!0}),"l$2");const qi=_t(r=>r==="quiet"?"quiet":"normal","parseOutputStyle"),Wi=_t((r,e)=>{const t=r.overrides.visOptions;return t?.outputStyle==="normal"||t?.outputStyle==="quiet"?t.outputStyle:e},"resolveTaskOutputStyle");class Vi{static{M(this,"StaticOutputLifeCycle")}static{_t(this,"StaticOutputLifeCycle")}#e;#o;#t;#s=[];#r=[];#i=new Map;#n;#a;#c=0;constructor(e){this.#e=e.projectNames,this.#o=e.args.targets,this.#t=e.tasks,this.#n=e.logReporter,this.#a=e.outputStyle??"normal"}startCommand(){this.#c=Date.now();const e=process.stdout.columns||80,t=`Running ${jt(this.#e,this.#o,this.#t)}`,s=ue(X.createElement($t,{title:t,variant:"info"}),{columns:e});process.stdout.write(s);const o=this.#t[0],n=o?.overrides?Object.entries(o.overrides).filter(([i])=>i!=="command"):[];if(n.length>0){process.stdout.write(`
|
|
18
21
|
With additional flags:
|
|
19
|
-
`);for(const[
|
|
22
|
+
`);for(const[i,l]of n)process.stdout.write(`${fi(" ",i,l)}
|
|
20
23
|
`)}process.stdout.write(`
|
|
21
|
-
`)}startTasks(e){const t=process.stdout.columns||80;for(const
|
|
22
|
-
`)}}endTasks(e){const t=process.stdout.columns||80;for(const
|
|
23
|
-
`)}}printTaskTerminalOutput(e,t,
|
|
24
|
-
`);const
|
|
25
|
-
`)}}var
|
|
26
|
-
`;await
|
|
27
|
-
`)},"writeBashHistory"),
|
|
24
|
+
`)}startTasks(e){const t=process.stdout.columns||80;for(const s of e){const o=ue(X.createElement(a,null,X.createElement(a,{dimColor:!0},">"),` ${s.id}`),{columns:t});process.stdout.write(`${o}
|
|
25
|
+
`)}}endTasks(e){const t=process.stdout.columns||80;for(const s of e){this.#i.set(s.task.id,s),s.status==="failure"?this.#s.push(s):Ne(s.status)&&this.#r.push(s);const o=Hr(s.status),n=s.startTime&&s.endTime?` (${_e(s.endTime-s.startTime)})`:"",i=Ne(s.status)?" [cache]":"",l=ue(X.createElement(a,null,o,` ${s.task.id}`,i?X.createElement(a,{color:"cyan"},i):null,n?X.createElement(a,{dimColor:!0},n):null),{columns:t});process.stdout.write(`${l}
|
|
26
|
+
`)}}printTaskTerminalOutput(e,t,s){if(!(Wi(e,this.#a)==="quiet"&&(t==="success"||Ne(t)))){if(this.#n){this.#n.printTaskTerminalOutput(e,t,s);return}$i(e.id,t,s)}}endCommand(){const e=_e(Date.now()-this.#c),t=this.#t.filter(n=>!this.#i.has(n.id)).map(n=>n.id);process.stdout.write(`
|
|
27
|
+
`);const s=process.stdout.columns||80,o=ue(X.createElement(Br,{cached:this.#r.length,failed:this.#s.length,failedIds:this.#s.map(n=>n.task.id),projectNames:this.#e,skippedIds:t.length>0?t:void 0,succeeded:this.#i.size-this.#s.length-this.#r.length,targets:this.#o,tasks:this.#t,took:e}),{columns:s});process.stdout.write(`${o}
|
|
28
|
+
`)}}var zi=Object.defineProperty,te=M((r,e)=>zi(r,"name",{value:e,configurable:!0}),"r$1");function Ye(r,e={},t){for(const s in r){const o=r[s],n=t?`${t}:${s}`:s;typeof o=="object"&&o!==null?Ye(o,e,n):typeof o=="function"&&(e[n]=o)}return e}M(Ye,"c$3");te(Ye,"flatHooks");function Ui(...r){const e={};for(const t of r){const s=Ye(t);for(const o in s)e[o]?e[o].push(s[o]):e[o]=[s[o]]}for(const t in e)if(e[t].length>1){const s=e[t];e[t]=(...o)=>zr(s,n=>n(...o))}else e[t]=e[t][0];return e}M(Ui,"v$1");te(Ui,"mergeHooks");function zr(r,e){return r.reduce((t,s)=>t.then(()=>e(s)),Promise.resolve())}M(zr,"d$1");te(zr,"serial");const Ur=(()=>{if(console.createTask)return console.createTask;const r={run:te(e=>e(),"run")};return()=>r})();function gt(r,e,t,s){for(let o=t;o<r.length;o+=1)try{const n=s?s.run(()=>r[o](...e)):r[o](...e);if(n&&typeof n.then=="function")return Promise.resolve(n).then(()=>gt(r,e,o+1,s))}catch(n){return Promise.reject(n)}}M(gt,"k");te(gt,"callHooks");function Yr(r,e,t){if(r.length>0)return gt(r,e,0,Ur(t))}M(Yr,"y$1");te(Yr,"serialTaskCaller");function Kr(r,e,t){if(r.length>0){const s=Ur(t);return Promise.all(r.map(o=>s.run(()=>o(...e))))}}M(Kr,"m");te(Kr,"parallelTaskCaller");function Yi(r,e){return r.reduce((t,s)=>t.then(()=>s(...e||[])),Promise.resolve())}M(Yi,"x");te(Yi,"serialCaller");function Ki(r,e){return Promise.all(r.map(t=>t(...e||[])))}M(Ki,"P");te(Ki,"parallelCaller");function nt(r,e){for(const t of[...r])t(e)}M(nt,"a$1");te(nt,"callEachWith");var Qi=class{static{M(this,"p")}static{te(this,"Hookable")}_hooks;_before;_after;_deprecatedHooks;_deprecatedMessages;constructor(){this._hooks={},this._before=void 0,this._after=void 0,this._deprecatedMessages=void 0,this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this),this.callHookWith=this.callHookWith.bind(this)}hook(e,t,s={}){if(!e||typeof t!="function")return()=>{};const o=e;let n;for(;this._deprecatedHooks[e];)n=this._deprecatedHooks[e],e=n.to;if(n&&!s.allowDeprecated){let i=n.message;i||(i=`${o} hook has been deprecated`+(n.to?`, please use ${n.to}`:"")),this._deprecatedMessages||(this._deprecatedMessages=new Set),this._deprecatedMessages.has(i)||(console.warn(i),this._deprecatedMessages.add(i))}if(!t.name)try{Object.defineProperty(t,"name",{get:te(()=>"_"+e.replace(/\W+/g,"_")+"_hook_cb","get"),configurable:!0})}catch{}return this._hooks[e]=this._hooks[e]||[],this._hooks[e].push(t),()=>{t&&(this.removeHook(e,t),t=void 0)}}hookOnce(e,t){let s,o=te((...n)=>(typeof s=="function"&&s(),s=void 0,o=void 0,t(...n)),"_function");return s=this.hook(e,o),s}removeHook(e,t){const s=this._hooks[e];if(s){const o=s.indexOf(t);o!==-1&&s.splice(o,1),s.length===0&&(this._hooks[e]=void 0)}}clearHook(e){this._hooks[e]=void 0}deprecateHook(e,t){this._deprecatedHooks[e]=typeof t=="string"?{to:t}:t;const s=this._hooks[e]||[];this._hooks[e]=void 0;for(const o of s)this.hook(e,o)}deprecateHooks(e){for(const t in e)this.deprecateHook(t,e[t])}addHooks(e){const t=Ye(e),s=Object.keys(t).map(o=>this.hook(o,t[o]));return()=>{for(const o of s)o();s.length=0}}removeHooks(e){const t=Ye(e);for(const s in t)this.removeHook(s,t[s])}removeAllHooks(){this._hooks={}}callHook(e,...t){return this.callHookWith(Yr,e,t)}callHookParallel(e,...t){return this.callHookWith(Kr,e,t)}callHookWith(e,t,s){const o=this._before||this._after?{name:t,args:s,context:{}}:void 0;this._before&&nt(this._before,o);const n=e(this._hooks[t]?[...this._hooks[t]]:[],s,t);return n instanceof Promise?n.finally(()=>{this._after&&o&&nt(this._after,o)}):(this._after&&o&&nt(this._after,o),n)}beforeEach(e){return this._before=this._before||[],this._before.push(e),()=>{if(this._before!==void 0){const t=this._before.indexOf(e);t!==-1&&this._before.splice(t,1)}}}afterEach(e){return this._after=this._after||[],this._after.push(e),()=>{if(this._after!==void 0){const t=this._after.indexOf(e);t!==-1&&this._after.splice(t,1)}}}};function Qr(){return new Qi}M(Qr,"w$1");te(Qr,"createHooks");(class{static{te(this,"HookableCore")}_hooks;constructor(){this._hooks={}}hook(r,e){return!r||typeof e!="function"?()=>{}:(this._hooks[r]=this._hooks[r]||[],this._hooks[r].push(e),()=>{e&&(this.removeHook(r,e),e=void 0)})}removeHook(r,e){const t=this._hooks[r];if(t){const s=t.indexOf(e);s!==-1&&t.splice(s,1),t.length===0&&(this._hooks[r]=void 0)}}callHook(r,...e){const t=this._hooks[r];if(!(!t||t.length===0))return gt(t,e,0)}});const kr=typeof window<"u";function Xi(r,e={}){const t={inspect:kr,group:kr,filter:te(()=>!0,"filter"),...e},s=t.filter,o=typeof s=="string"?u=>u.startsWith(s):s,n=t.tag?`[${t.tag}] `:"",i=te(u=>n+u.name+"".padEnd(u._id,"\0"),"logPrefix"),l={},f=r.beforeEach(u=>{o!==void 0&&!o(u.name)||(l[u.name]=l[u.name]||0,u._id=l[u.name]++,console.time(i(u)))}),p=r.afterEach(u=>{o!==void 0&&!o(u.name)||(t.group&&console.groupCollapsed(u.name),t.inspect?console.timeLog(i(u),u.args):console.timeEnd(i(u)),t.group&&console.groupEnd(),l[u.name]--)});return{close:te(()=>{f(),p()},"close")}}M(Xi,"W$1");te(Xi,"createDebugger");var Ji=Object.defineProperty,mt=M((r,e)=>Ji(r,"name",{value:e,configurable:!0}),"t");const Zi=mt(()=>Qr(),"createVisHooks"),en=mt(async(r,e)=>{if(!(!e||e.length===0))for(const t of e){if(t.hooks)for(const[s,o]of Object.entries(t.hooks)){const n=Array.isArray(o)?o:[o];for(const i of n)r.hook(s,i)}t.setup&&await t.setup(r)}},"registerPlugins");class tn{static{M(this,"HookableLifeCycle")}static{mt(this,"HookableLifeCycle")}#e;#o;#t=new Map;constructor(e,t){this.#e=e,this.#o=t}startTasks(e){for(const t of e)this.#t.set(t.id,t),this.#s("task:before",t)}endTasks(e){for(const t of e)this.#t.delete(t.task.id),this.#s("task:after",t.task,t),t.status==="failure"?this.#s("task:failure",t.task,t):rn(t.status)&&this.#s("task:cacheHit",t.task,t)}printCacheMiss(e,t){this.#s("task:cacheMiss",e,t)}onTaskStdout(e,t){this.#s("task:stdout",e,t)}onTaskStderr(e,t){this.#s("task:stderr",e,t)}#s(e,...t){Promise.resolve(this.#e.callHook(e,...t)).catch(s=>{if(this.#o)try{this.#o(e,s)}catch{}})}}const rn=mt(r=>r==="local-cache"||r==="local-cache-kept-existing"||r==="remote-cache","isCacheStatus");var sn=Object.defineProperty,wt=M((r,e)=>sn(r,"name",{value:e,configurable:!0}),"o$1");const on=wt(async r=>{if(process.env.VIS_NO_SHELL_HISTORY||ho()==="win32")return;const e=process.env.SHELL;if(!e)return;const t=ds(e);try{if(t==="zsh"){await nn(r);return}if(t==="bash"){await an(r);return}t==="fish"&&await cn(r)}catch{}},"appendToShellHistory"),nn=wt(async r=>{const e=process.env.HISTFILE??ve(process.env.ZDOTDIR??Rt(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${r}
|
|
29
|
+
`;await Pt(e,t)},"writeZshHistory"),an=wt(async r=>{const e=process.env.HISTFILE??ve(Rt(),".bash_history");await Pt(e,`${r}
|
|
30
|
+
`)},"writeBashHistory"),cn=wt(async r=>{const e=ve(Rt(),".local","share","fish","fish_history"),t=`- cmd: ${r.replaceAll("\\","\\\\").replaceAll(`
|
|
28
31
|
`,String.raw`\n`)}
|
|
29
32
|
when: ${Math.floor(Date.now()/1e3)}
|
|
30
|
-
`;await
|
|
31
|
-
`),
|
|
32
|
-
`)},"writeHelp"),
|
|
33
|
-
`);if(
|
|
34
|
-
`):await e.onFilter(
|
|
35
|
-
`)})},"onKeypress"),
|
|
36
|
-
`)}
|
|
37
|
-
|
|
38
|
-
`)
|
|
39
|
-
|
|
40
|
-
[
|
|
41
|
-
`
|
|
42
|
-
`).filter(Boolean):void 0,_=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,G=_?new Set(_.split(",").map(g=>g.trim()).filter(Boolean)):void 0,C=[],H=new Map;for(const g of P){const b=k.get(g)?.[O];if(!b)continue;const E=b.options;if(!E?.internal){if(!Wr(E,!!ze)){e.debug?.(`Skipping ${g}:${O} — runInCI filter`);continue}if(!Ur(E,G)){e.debug?.(`Skipping ${g}:${O} — runner-tags filter`);continue}C.push(g),H.set(g,b)}}if(C.length===0){const g=Pt(v),b=Object.entries(v.projects).filter(([,E])=>E.targets?.[O]!==void 0).map(([E])=>E);if(e.error(`No projects have the "${O}" target.`),b.length>0){e.info(""),e.info(`Target "${O}" exists in these projects but was filtered out:`);for(const E of b.slice(0,5))e.info(` - ${E}`);b.length>5&&e.info(` …and ${b.length-5} more`)}else{const E=or(O,g,3);E.length>0&&(e.info(""),e.info(E.length===1?`Did you mean "${E[0]}"?`:`Did you mean one of: ${E.map(V=>`"${V}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const ie=t.pty===!0;let L=C.map(g=>{const b=v.projects[g],E=H.get(g),V={project:g,target:O},W=`${g}:${O}`,pe=ie?{...E.options,pty:E.options?.pty??!0}:E.options,oe=E.command?jr(E.command,{affectedFiles:I,projectRoot:b?.root}):E.command;return{cache:E.cache,id:W,outputs:E.outputs??[],overrides:{command:oe,...Q.length>0?{[kr]:Q}:{},...pe?{visOptions:pe}:{}},parallelism:E.parallelism,projectRoot:b?.root,target:V}});const q=[],ae=[];for(const g of L)wr(g)?.persistent?(g.cache=!1,q.push(g)):ae.push(g);L=ae;const J=Rr(t.partition);if(J&&(L=Or.partitionTasks(L,J),e.info(`Partition ${J.index}/${J.total}: running ${L.length} task(s)`),L.length===0)){e.info("No tasks assigned to this partition.");return}let B=Pr(L,{projectGraph:$,targetDefaults:f.targetDefaults,workspace:v});for(const[g,b]of Object.entries(B.tasks)){if(b.overrides.visOptions!==void 0)continue;const E=b.target.project,V=b.target.target,W=k.get(E)?.[V];W?.options&&(b.overrides={...b.overrides,visOptions:W.options},B.tasks[g]=b)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const g=ts(t.skipCache,v,Object.keys(B.tasks));for(const b of g.skipTaskIds){const E=B.tasks[b];E!==void 0&&(E.cache=!1)}g.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${g.unmatchedPatterns.map(b=>`"${b}"`).join(", ")}`),g.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(g.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await so(c,f.toolchain,{error:j(g=>{e.error(g)},"error"),info:j(g=>{e.info(g)},"info"),warn:j(g=>{e.warn(g)},"warn")},!!t.skipToolchain);const he=t.preflight!==!1&&f.preflight?.lockfile!==!1,ce=Zo(c,ze,{warn:j(g=>{e.warn(g)},"warn")},{skip:!he});if(!ce.shouldContinue)throw new Error(`${ce.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);const D=await io(c),U=await yn({initialTasks:L,probe:t.dryRun?void 0:async g=>{try{return await ao(g.config,{timeoutMs:$n}),!0}catch{return!1}},registeredEntries:D,taskGraph:B,visVersion:process.env.VIS_VERSION??"0.0.0"});if(U.diagnostics.length>0){for(const g of U.diagnostics)e.error(g.message);throw new Error(`${U.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`)}L=U.initialTasks,B=U.taskGraph;const{serviceEnvByTaskId:y}=U;if(U.satisfiedServices.length>0){const g=U.satisfiedServices.map(b=>b.id).join(", ");e.debug?.(`Auto-attached to running services: ${g}`)}if(t.reverse&&(B=_r(B),e.debug?.(`Reversed task graph: ${String(B.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const g=Object.keys(B.tasks).length,b=B.roots.length;e.info(`Execution plan (${String(g)} task(s), ${String(b)} root(s)):`),e.info("");const E=new Set,V=j((W,pe)=>{if(E.has(W))return;E.add(W);for(const ke of B.dependencies[W]??[])V(ke,pe+1);const oe=B.tasks[W],se=" ".repeat(pe+1);e.info(`${se}${W}${oe?.cache===!1?" (no-cache)":""}`)},"walkPlan");for(const W of B.roots)V(W,0);for(const W of Object.keys(B.tasks))V(W,0);q.length>0&&(e.info(""),e.info(` + ${String(q.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const m=Date.now(),x=Ys(),ee=j((g,b)=>{const E=b instanceof Error?b.message:String(b);e.warn(`Plugin error in ${g}: ${E}`)},"onHookError");await Ks(x,f.plugins);const fe=typeof t.profile=="string"?t.profile:void 0,xe=j(async g=>{if(!fe)return;const b=St(g,B,m),E=fe.startsWith("/")?fe:`${c}/${fe}`;await Fr(b,E),e.info(`Profile written to ${fe}`)},"maybeWriteProfile"),ye=f.taskRunnerOptions??{},_e=Vr(c,t.cacheDir,ye.cacheDirectory,f.sharedWorktreeCache),Ue=zr(_e,c,f.branchScopedCache),be=En(process.env.VIS_RUN_CONCURRENCY_LIMIT);be&&"invalid"in be&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${be.invalid} is not a positive number; falling back to default concurrency.`);const vr=be&&"value"in be?be.value:void 0,yr=t.parallel??vr??3,ut=t.strictEnv??f.strictEnv??!1,Fe={dryRun:t.dryRun??!1,parallel:yr,skipNxCache:!t.cache,summarize:t.summarize??!1,...ye,cacheDirectory:Ue};if(ye.remoteCache){const g=Rn(t.cacheMode),b=On(t.cacheBackend);(g||b)&&(Fe.remoteCache={...ye.remoteCache,...g?{mode:g}:{},...b?{backend:b}:{}})}else(t.cacheMode||t.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts; ignoring.");const br=process.stdout.isTTY&&!ze,$r=f.tui?.autoExit??!1,ht={args:{parallel:Fe.parallel,targets:[O]},autoExit:$r,projectNames:C,tasks:L},ft=typeof t.retryBudget=="number"?t.retryBudget:void 0,pt=ft===void 0?void 0:In(ft),mt=new Qs(x,ee),gt=new Zr(c),wt=Ds(typeof t.outputStyle=="string"?t.outputStyle.toLowerCase():void 0);if(await x.callHook("run:before",{tasks:L,workspaceRoot:c}),br){const g=new Map,b=As({...ht,outputStyle:wt,stdinRegistry:g}),{lifeCycle:E,store:V}=b,W=new Ct([E,mt,gt]),pe=Ut({affectedFiles:I,currentOs:F,initCwd:d,lifeCycle:W,mutexPool:new Map,onOutput:j((A,z)=>{V.addOutput(A,z)},"onOutput"),onOutputReplace:j((A,z)=>{V.setOutput(A,z)},"onOutputReplace"),retryBudget:pt,serviceEnvByTaskId:y,stdinRegistry:g,strictEnv:ut,workspaceRoot:c});let oe="rerun",se=null,ke=new Map;for(;oe!=="quit";){if(oe==="rerun")ke=await xt(L,Fe,{lifeCycle:W,projectGraph:$,taskExecutor:pe,taskGraph:B,workspaceRoot:c});else if(oe==="retry"&&se){const A=L.find(Z=>Z.id===se),z=A?.overrides.command;if(A&&z){const Z=A.projectRoot??c,ge=Z.startsWith("/")?Z:`${c}/${Z}`;W.startTasks?.([A]);const ne=new Vt(et),le=(await tt([{command:z,cwd:ge,name:A.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:j(K=>{K.kind==="started"&&K.write&&g.set(A.id,{kill:K.kill,resize:K.resize,write:K.write}),(K.kind==="stdout"||K.kind==="stderr")&&K.text&&(ne.write(K.text),V.setOutput(A.id,ne.toString())),K.kind==="close"&&g.delete(A.id)},"onEvent")})).closeEvents[0];W.endTasks?.([{code:le?.exitCode??1,status:le?.exitCode===0?"success":"failure",task:A,terminalOutput:V.getSnapshot().outputs.get(A.id)}])}else A&&W.endTasks?.([{code:1,status:"failure",task:A,terminalOutput:`No command configured for ${A.id}`}]);se=null,V.markDone()}oe=await new Promise(A=>{const z=V.subscribe(()=>{const Z=V.getSnapshot();Z.rerunRequested&&(V.acknowledgeRerun(),z(),A("rerun")),Z.retryTaskId&&(se=V.acknowledgeRetry(),z(),A("retry"))});b.renderIsDone.then(()=>{z(),A("quit")}).catch(()=>{z(),A("quit")})})}await b.renderIsDone,await x.callHook("run:after",ke),await xe(ke),q.length>0&&!t.failFast&&await Wt(q,c,I,d)}else{const g=new Map,b=typeof t.log=="string"?t.log.toLowerCase():"",E=b==="labeled"||b==="grouped"||b==="interleaved"?b:void 0,V=E?Ar(E):void 0,W=new Ct([new Bs({...ht,logReporter:V,outputStyle:wt}),mt,gt]),pe=Ut({affectedFiles:I,currentOs:F,initCwd:d,lifeCycle:W,mutexPool:g,retryBudget:pt,serviceEnvByTaskId:y,strictEnv:ut,workspaceRoot:c}),oe=j(async()=>{const A=Date.now(),z=await xt(L,Fe,{lifeCycle:W,projectGraph:$,taskExecutor:pe,taskGraph:B,workspaceRoot:c}),Z=Date.now()-A;if(t.summarize){const de=St(z,B,m);await Lr(de,c)}let ge=!1;for(const[,de]of z)de.status==="failure"&&(ge=!0);const ne=Jr(z,Z),le=eo(c),K=to(c,Z,le);return e.info(""),e.info(` ${ne}${K?` ${K}`:""}`),{hasFailure:ge,results:z,runHistory:le}},"runOnce"),se=await oe();await x.callHook("run:after",se.results),await xe(se.results);const{hasFailure:ke}=se;if(t.watch){const A=C.map(X=>{const te=v.projects[X]?.root;if(te)return te.startsWith("/")?te:`${c}/${te}`}).filter(X=>X!==void 0),z=L;let Z;const ge=j(X=>{const te=hn(z,X);return Z=te.filter,L=te.tasks,te.tasks.length},"applyFilter");let ne=!1,le=se.results;const K=j(()=>{const X=Gt(le,c);if(X.directories.length>0&&X.files.size>0){const te=cn(X.files,c,X.directories);return{handle:qt({filter:te,onChange:kt,paths:X.directories}),mode:"tracked"}}return{handle:qt({onChange:kt,paths:A}),mode:"roots"}},"buildHandle");let de;const kt=j(async X=>{if(!ne){ne=!0;try{e.info(`Change detected in ${X.length} file(s), rerunning…`),le=(await oe()).results,de?.close(),de=K().handle}finally{ne=!1}}},"onChangeHandler"),vt=K();de=vt.handle;const Tr=vt.mode==="tracked"?`Watching ${String(Gt(le,c).files.size)} tracked file(s)`:`Watching ${String(A.length)} project root(s)`;e.info(`${Tr} — edit a file to rerun, press h for keybinds, q to quit.`);const Ve=j(async()=>{if(!ne){ne=!0;try{if(L.length===0){e.info("No tasks match the active filter — press a to clear it.");return}le=(await oe()).results,de?.close(),de=K().handle}finally{ne=!1}}},"triggerRerun");await new Promise(X=>{let te=!1,yt;const bt=j(()=>{$t()},"onSigint"),$t=j(()=>{te||(te=!0,yt?.close(),process.off("SIGINT",bt),de?.close(),X())},"exit");process.on("SIGINT",bt),yt=wn({handlers:{onClearFilter:j(async()=>{const Ie=ge(void 0);e.info(`Filter cleared — running ${String(Ie)} task(s).`),await Ve()},"onClearFilter"),onFilter:j(async Ie=>{const Sr=Z,Tt=ge(Ie);if(Tt===0){e.info(`Filter "${Ie}" matched no projects — keeping previous filter.`),ge(Sr);return}e.info(`Filter "${Ie}" matched ${String(Tt)} task(s).`),await Ve()},"onFilter"),onHelp:j(()=>{mn(process.stdout)},"onHelp"),onQuit:j(()=>{$t()},"onQuit"),onRerun:Ve}})});return}if(ke){if(t.flaky!==!1){const A=ro(c,{minRuns:2},se.runHistory);if(A.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const z of oo(A))e.info(` ${z}`);e.info("")}}throw new Error("Some tasks failed.")}q.length>0&&!t.failFast&&await Wt(q,c,I,d)}},"execute");export{In as createRetryBudget,Kn as default};
|
|
33
|
+
`;await Pt(e,t)},"writeFishHistory");var ln=Object.defineProperty,St=M((r,e)=>ln(r,"name",{value:e,configurable:!0}),"e");const dn=St(r=>{const{killGracePeriodMs:e=5e3,onTimeout:t,sendSignal:s,timeoutMs:o}=r;if(o<=0)return{cancel:St(()=>{},"cancel")};const n=Math.max(e,0);let i;const l=setTimeout(()=>{t?.(),s("SIGTERM"),n>0&&(i=setTimeout(()=>{s("SIGKILL")},n))},o);return{cancel:St(()=>{clearTimeout(l),i&&clearTimeout(i)},"cancel")}},"scheduleTimeoutKill");var un=Object.defineProperty,He=M((r,e)=>un(r,"name",{value:e,configurable:!0}),"l$1");const hn=[/node_modules(?:\/|$)/,/\.git(?:\/|$)/,/\.vis(?:\/|$)/],yr=He((r,e)=>{const t=new Set,s=new Set;for(const[,i]of r){const l=i.task.hashDetails?.nodes;if(l)for(const f of Object.keys(l))t.add(f),s.add(us(xr(e,f)))}const o=[...s].sort(),n=[];for(const i of o)n.some(l=>i===l||i.startsWith(`${l}/`))||n.push(i);return{directories:n,files:t}},"collectTrackedWatchTargets"),fn=He((r,e,t)=>{const s=new Set;for(const o of r){const n=xr(e,o);for(const i of t)if(n===i||n.startsWith(`${i}/`)){const l=hs(i,n);l.length>0&&s.add(l)}}return o=>{const n=o.replaceAll("\\","/");return s.has(n)}},"createTrackedFileFilter"),pn=He(r=>{const e=r.replaceAll("\\","/");return hn.some(t=>t.test(e))},"shouldIgnore"),br=He(r=>{const{debounceMs:e=150,filter:t,onChange:s,paths:o}=r,n=[];let i=new Set,l;const f=He(()=>{l=void 0;const p=[...i];i=new Set,p.length!==0&&Promise.resolve(s(p)).catch(u=>{tr.error("[vis watch] onChange handler failed:",u)})},"flush");for(const p of o)try{const u=_s(p,{recursive:!0},(w,d)=>{d&&(pn(d)||t&&!t(d)||(i.add(d),l&&clearTimeout(l),l=setTimeout(f,e)))});n.push(u)}catch(u){tr.warn(`[vis watch] unable to watch ${p}: ${u.message}`)}return{close:He(()=>{l&&clearTimeout(l);for(const p of n)try{p.close()}catch{}},"close")}},"startWatcher");var gn=Object.defineProperty,mn=M((r,e)=>gn(r,"name",{value:e,configurable:!0}),"n");const wn=mn((r,e)=>{const t=e?.trim();if(!t)return{filter:void 0,tasks:[...r]};const s=t.toLowerCase();return{filter:t,tasks:r.filter(o=>o.target.project.toLowerCase().includes(s))}},"applyProjectFilter");var vn=Object.defineProperty,xe=M((r,e)=>vn(r,"name",{value:e,configurable:!0}),"a");const kn=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
|
|
34
|
+
`),yn=xe(r=>{r.write(`${kn}
|
|
35
|
+
`)},"writeHelp"),bn=xe(async(r,e)=>{e.write("filter projects (empty to cancel) > ");const t=r,s=t.isRaw===!0;if(s)try{t.setRawMode?.(!1)}catch{}return await new Promise(o=>{let n="";const i=xe(l=>{n+=typeof l=="string"?l:l.toString("utf8");const f=n.indexOf(`
|
|
36
|
+
`);if(f===-1)return;const p=n.slice(0,f).replace(/\r$/,"").trim();if(r.off("data",i),s)try{t.setRawMode?.(!0)}catch{}o(p.length>0?p:void 0)},"onData");r.on("data",i)})},"defaultPromptFilter"),Sn=xe(r=>{const{handlers:e}=r,t=r.input??process.stdin,s=r.output??process.stdout,o=r.promptFilter??bn;if(!t||t.isTTY===!1)return{close:xe(()=>{},"close")};no(t);const n=t.isRaw===!0;try{t.setRawMode?.(!0)}catch{return{close:xe(()=>{},"close")}}typeof t.resume=="function"&&t.resume();let i=!1;const l=xe(async u=>{if(u.ctrl===!0&&u.name==="c"){await e.onQuit();return}if(!i)switch(u.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{i=!0;try{const w=await o(t,s);w===void 0?s.write(`filter cancelled.
|
|
37
|
+
`):await e.onFilter(w)}finally{i=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},"dispatch"),f=xe((u,w)=>{l(w).catch(d=>{s.write(`[vis watch] keybind handler failed: ${d.message}
|
|
38
|
+
`)})},"onKeypress"),p=t;return p.on("keypress",f),{close:xe(()=>{if(p.off("keypress",f),!n)try{t.setRawMode?.(!1)}catch{}const u=t;if(typeof u.pause=="function")try{u.pause()}catch{}},"close")}},"installKeybinds");var $n=Object.defineProperty,Tt=M((r,e)=>$n(r,"name",{value:e,configurable:!0}),"u");const Tn=Tt(r=>{const e=r.overrides.visOptions;return e&&typeof e=="object"?e:void 0},"getVisOptions"),Cn=Tt(async r=>{const{initialTasks:e,probe:t,registeredEntries:s,taskGraph:o,visVersion:n}=r,i=new Map,l=new Map,f=new Map;for(const m of s)if(Ks(m.pid)){if(m.visVersion!==n){l.set(m.id,m);continue}i.set(m.id,m)}if(t){const m=[...i.values()],D=await Promise.all(m.map(async x=>{try{return[x.id,await t(x)]}catch{return[x.id,!1]}}));for(const[x,Y]of D)if(!Y){const F=i.get(x);i.delete(x),F&&f.set(x,F)}}const p=new Set(e.map(m=>m.id)),u=new Set,w=[],d=[],T=new Set;for(const m of Object.values(o.dependencies))for(const D of m)T.add(D);for(const[m,D]of Object.entries(o.tasks)){if(!Tn(D)?.service)continue;if(i.has(m)){u.add(m),d.push(i.get(m));continue}if(p.has(m)||!T.has(m))continue;const x=l.get(m),Y=f.get(m);let F;x?F=`Service ${m} is registered with vis ${x.visVersion}, but this invocation is vis ${n}. Restart with \`vis service restart ${m}\` to pick up the new version.`:Y?F=`Service ${m} is registered (PID ${String(Y.pid)}) but failed its readiness probe — the wrapper process is alive but the underlying server is not responding. Run \`vis service restart ${m}\` to recover.`:F=`Target depends on the service ${m}, which is not running. Run \`vis service start ${m}\` first, or invoke \`${m}\` directly.`,w.push({message:F,targetId:m})}if(u.size===0)return{diagnostics:w,initialTasks:e,satisfiedServices:d,serviceEnvByTaskId:new Map,taskGraph:o};const R=new Map,G=Tt(m=>{const D=new Set,x=[...o.dependencies[m]??[]],Y=new Set;for(;x.length>0;){const F=x.pop();if(!Y.has(F)){Y.add(F),u.has(F)&&D.add(F);for(const ne of o.dependencies[F]??[])Y.has(ne)||x.push(ne)}}return[...D].sort()},"collectTransitiveServices");for(const m of Object.keys(o.dependencies)){if(u.has(m))continue;const D=G(m);if(D.length===0)continue;const x={};for(const Y of D){const F=i.get(Y);F&&Object.assign(x,F.env)}Object.keys(x).length>0&&R.set(m,x)}const E={};for(const[m,D]of Object.entries(o.tasks))u.has(m)||(E[m]=D);const k={};for(const[m,D]of Object.entries(o.dependencies))u.has(m)||(k[m]=D.filter(x=>!u.has(x)));const S=new Map;for(const m of Object.keys(E))S.set(m,0);for(const m of Object.values(k))for(const D of m)S.has(D)&&S.set(D,(S.get(D)??0)+1);const O=[];for(const m of o.roots)!u.has(m)&&E[m]&&O.push(m);for(const[m,D]of S)D===0&&!O.includes(m)&&E[m]&&O.push(m);const J=e.filter(m=>!u.has(m.id));return{diagnostics:w,initialTasks:J,satisfiedServices:d,serviceEnvByTaskId:R,taskGraph:{dependencies:k,roots:O,tasks:E}}},"applyServiceRegistry");var In=Object.defineProperty,ut=M((r,e)=>In(r,"name",{value:e,configurable:!0}),"c");const st="[[VIS_BOOT]]",xn=250,Mn=1e3,Sr=3,En=ut(r=>{try{return process.kill(r,0),!0}catch{return!1}},"isAlive"),$r=ut(r=>{try{const e=Ns(r,"utf8").trim(),t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}},"readPidFile");class Pn{static{M(this,"ServiceEventBridge")}static{ut(this,"ServiceEventBridge")}#e;#o;#t;#s;#r=new Map;#i=new Map;#n=new Map;#a=new Map;constructor(e){this.#e=e.indexToId,this.#o=new Map(e.services),this.#t=e.sink,this.#s=e.workspaceRoot}onProcessEvent=ut(e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const t=this.#e.get(e.index);t===void 0||e.text===void 0||this.onTaskOutput(t,e.text)},"onProcessEvent");onTaskOutput(e,t){if(!this.#o.has(e))return;const s=((this.#r.get(e)??"")+t).split(`
|
|
39
|
+
`),o=s.pop()??"";this.#r.set(e,o);for(const n of s)this.#c(e,n)}notifyRegistryStarting(e){this.#t.starting(e)}notifyRegistryStarted(e,t){this.#t.started(e,t)}onRegistryTaskStarted(e){this.#o.get(e)?.mode==="registry"&&this.notifyRegistryStarting(e)}async onRegistryTaskClosed(e,t,s){if(this.#o.get(e)?.mode!=="registry")return;if(s||t!==0){this.notifyRegistryFailed(e,"exit-code",{exitCode:t,killed:s});return}const o=await Qs(this.#s,e);if(!o){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:n}=o,i=n.readiness?.tcp?.port??n.port??0,l=n.readiness?.tcp?.host??"127.0.0.1";this.notifyRegistryReady(e,{host:l,logFile:o.logFile,pid:o.pid,port:i})}notifyRegistryReady(e,t){this.#t.ready(e,{host:t.host,port:t.port}),this.#d(e,t.logFile),t.pid!==null&&this.#u(e,t.pid)}notifyRegistryFailed(e,t,s){this.#t.failed(e,t,s)}async retry(e){const t=this.#o.get(e);if(t){if(this.#l(e),this.#r.delete(e),this.#i.delete(e),this.#t.starting(e),t.mode==="registry"){await this.#v(e,t.registry);return}t.mode==="ephemeral"&&this.#w(e,t.ephemeral)}}async dispose(){for(const e of[...this.#n.keys(),...this.#a.keys()])this.#l(e);this.#r.clear(),this.#i.clear()}#c(e,t){if(t.startsWith(st)){this.#f(e,t.slice(st.length));return}const s=this.#i.get(e)??[];s.push(t),s.length>Sr&&s.shift(),this.#i.set(e,s),this.#t.log(e,`${t}
|
|
40
|
+
`)}#f(e,t){let s;try{s=JSON.parse(t)}catch{this.#t.log(e,`${st+t}
|
|
41
|
+
`);return}switch(s.event){case"failed":{const o=typeof s.reason=="string"?s.reason:"unknown",n={};for(const[i,l]of Object.entries(s))i!=="event"&&i!=="id"&&i!=="reason"&&(n[i]=l);this.#t.failed(e,o,n);break}case"ready":{const o=typeof s.host=="string"?s.host:"127.0.0.1",n=typeof s.port=="number"?s.port:0;this.#t.ready(e,{host:o,port:n}),this.#p(e);break}case"started":{const o=typeof s.pid=="number"?s.pid:null;this.#t.started(e,o);break}default:this.#t.log(e,`${st+t}
|
|
42
|
+
`)}}#p(e){const t=this.#o.get(e);if(t?.ephemeral===void 0)return;this.#d(e,t.ephemeral.logFile);const s=$r(t.ephemeral.pidFile);s!==null&&this.#u(e,s)}#d(e,t){if(this.#n.has(e)||!Mt(t))return;const s=Ls(t,"r"),o=(()=>{try{return lt(t).size}catch{return 0}})(),n={fd:s,logFile:t,pollTimer:setInterval(()=>{this.#g(e)},xn),position:o};this.#n.set(e,n)}#g(e){const t=this.#n.get(e);if(t)try{const s=lt(t.logFile);if(s.size<=t.position)return;const o=Buffer.alloc(s.size-t.position),n=As(t.fd,o,0,o.length,t.position);if(n>0){t.position+=n;const i=o.subarray(0,n).toString("utf8");for(const l of i.split(`
|
|
43
|
+
`))l.length!==0&&this.#m(e,l);this.#t.log(e,i)}}catch{}}#m(e,t){const s=this.#i.get(e)??[];for(s.push(t);s.length>Sr;)s.shift();this.#i.set(e,s)}#u(e,t){if(this.#a.has(e))return;const s={pid:t,timer:setInterval(()=>{if(!En(t)){const o=[...this.#i.get(e)??[]];this.#l(e),this.#t.crashed(e,o)}},Mn)};this.#a.set(e,s)}#l(e){const t=this.#n.get(e);if(t){clearInterval(t.pollTimer);try{Bs(t.fd)}catch{}this.#n.delete(e)}const s=this.#a.get(e);s&&(clearInterval(s.timer),this.#a.delete(e))}#w(e,t){if(t===void 0)return;const s=$r(t.pidFile);if(s!==null)try{process.kill(-s,"SIGTERM")}catch{}const o=po("node",[t.scriptPath,t.configFile],{cwd:t.cwd,stdio:["ignore","pipe","pipe"]});o.stdout.on("data",n=>{this.#h(e,n)}),o.stderr.on("data",n=>{this.#h(e,n)}),o.on("error",n=>{this.#t.failed(e,"respawn-error",{message:n.message})})}#h(e,t){const s=((this.#r.get(e)??"")+t.toString("utf8")).split(`
|
|
44
|
+
`),o=s.pop()??"";this.#r.set(e,o);for(const n of s)this.#c(e,n)}async#v(e,t){if(t!==void 0){try{await Xs({id:e,workspaceRoot:this.#s})}catch{}try{const s=await Js({command:t.command,config:t.config,cwd:t.cwd,env:t.env,id:e,workspaceRoot:this.#s}),o=t.config.readiness?.tcp?.port??t.config.port??0,n=t.config.readiness?.tcp?.host??"127.0.0.1";this.#t.started(e,s.entry.pid),this.notifyRegistryReady(e,{host:n,logFile:s.entry.logFile,pid:s.entry.pid,port:o})}catch(s){const o=s instanceof Error?s.message:String(s);this.#t.failed(e,"retry-failed",{message:o})}}}}var Rn=Object.defineProperty,pe=M((r,e)=>Rn(r,"name",{value:e,configurable:!0}),"p");const Fn=pe(r=>{const e=r.overrides.visOptions;return e&&typeof e=="object"?e:void 0},"getVisOptions"),Xr=pe((r,e,t)=>{const s=[],o=[];for(const n of e){const i=t.tasks[n];if(!i){o.push({id:n,reason:"task not in graph"});continue}const l=i.overrides.command;if(!l){o.push({id:n,reason:"no command resolved"});continue}const f=Fn(i);if(!f?.service){o.push({id:n,reason:"no service config"});continue}const p=It(r,i.projectRoot,!!f.runFromWorkspaceRoot),{envFile:u}=f,w=u===void 0||u===!1?{}:xt(p,u),d=f.service.env??{};s.push({command:l,config:f.service,cwd:p,env:{...w,...d},id:n})}return{services:s,skipped:o}},"extractPreflightTasks"),On=pe((r,e)=>{const t=new Set(r),s=new Map;for(const i of r){const l=(e.dependencies[i]??[]).filter(f=>t.has(f));s.set(i,new Set(l))}const o=[],n=new Set;for(;s.size>0;){const i=[];for(const[l,f]of s){for(const p of f)n.has(p)&&f.delete(p);f.size===0&&i.push(l)}i.length===0&&i.push(...s.keys());for(const l of i)n.add(l),s.delete(l);i.sort(),o.push({ids:i})}return o},"planTopoLevels"),jn=pe((r,e)=>{const t=[];for(const s of On(r,e))t.push(...s.ids);return t},"linearize"),Dn=String.raw`import { spawn } from "node:child_process";
|
|
45
|
+
import { closeSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "node:fs";
|
|
46
|
+
import { createConnection } from "node:net";
|
|
47
|
+
|
|
48
|
+
const cfgPath = process.argv[2];
|
|
49
|
+
|
|
50
|
+
if (!cfgPath) {
|
|
51
|
+
console.error("[vis-service-bootstrap] missing config path");
|
|
52
|
+
process.exit(2);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const cfg = JSON.parse(readFileSync(cfgPath, "utf8"));
|
|
56
|
+
|
|
57
|
+
// Structured marker for service-event-bridge.ts to consume. Plain
|
|
58
|
+
// process.stdout.write keeps the line atomic and on the same stream
|
|
59
|
+
// as the tailed child log, so the parser sees one stream.
|
|
60
|
+
const emit = (event) => {
|
|
61
|
+
process.stdout.write("[[VIS_BOOT]]" + JSON.stringify({ ...event, id: cfg.id }) + "\n");
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Spawn the child with its stdio bound to a real file descriptor on
|
|
65
|
+
// disk — NOT inherited from the bootstrap. If the child inherited
|
|
66
|
+
// our stdio, it would inherit vis run's task pipes, and vis run would
|
|
67
|
+
// block waiting for those pipes to close even after this bootstrap
|
|
68
|
+
// exits. The logfile gives the grandchild a stable target it can keep
|
|
69
|
+
// writing to long after this bootstrap is gone.
|
|
70
|
+
const childLogFd = openSync(cfg.logFile, "a");
|
|
71
|
+
|
|
72
|
+
const child = spawn(cfg.command, {
|
|
73
|
+
cwd: cfg.cwd,
|
|
74
|
+
detached: true,
|
|
75
|
+
env: { ...process.env, ...cfg.env },
|
|
76
|
+
shell: true,
|
|
77
|
+
stdio: ["ignore", childLogFd, childLogFd],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Close the bootstrap's copy of the fd; the child kept its own.
|
|
81
|
+
closeSync(childLogFd);
|
|
82
|
+
|
|
83
|
+
if (child.pid !== undefined) {
|
|
84
|
+
try {
|
|
85
|
+
writeFileSync(cfg.pidFile, String(child.pid));
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error("[vis] failed to write pid file: " + (error?.message ?? String(error)));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
emit({ event: "started", pid: child.pid ?? null });
|
|
92
|
+
|
|
93
|
+
let exitedEarly = false;
|
|
94
|
+
|
|
95
|
+
child.once("exit", (code, signal) => {
|
|
96
|
+
exitedEarly = true;
|
|
97
|
+
emit({ code, event: "failed", reason: "exited-before-ready", signal });
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Forward new bytes from the logfile to our stdout while we're alive.
|
|
101
|
+
// Polling-based tail; preflight is short, ~200ms per cycle is fine.
|
|
102
|
+
let tailPos = 0;
|
|
103
|
+
const tailFd = openSync(cfg.logFile, "r");
|
|
104
|
+
|
|
105
|
+
const flushTail = () => {
|
|
106
|
+
try {
|
|
107
|
+
const stat = statSync(cfg.logFile);
|
|
108
|
+
if (stat.size <= tailPos) return;
|
|
109
|
+
const remaining = stat.size - tailPos;
|
|
110
|
+
const buf = Buffer.alloc(remaining);
|
|
111
|
+
const n = readSync(tailFd, buf, 0, remaining, tailPos);
|
|
112
|
+
if (n > 0) {
|
|
113
|
+
process.stdout.write(buf.subarray(0, n));
|
|
114
|
+
tailPos += n;
|
|
115
|
+
}
|
|
116
|
+
} catch {}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const probeOnce = () => new Promise((resolve) => {
|
|
120
|
+
const socket = createConnection({ host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
121
|
+
let settled = false;
|
|
122
|
+
const finish = (ok) => {
|
|
123
|
+
if (settled) return;
|
|
124
|
+
settled = true;
|
|
125
|
+
try { socket.destroy(); } catch {}
|
|
126
|
+
resolve(ok);
|
|
127
|
+
};
|
|
128
|
+
socket.once("connect", () => finish(true));
|
|
129
|
+
socket.once("error", () => finish(false));
|
|
130
|
+
socket.setTimeout(1000, () => finish(false));
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
134
|
+
|
|
135
|
+
(async () => {
|
|
136
|
+
const deadline = Date.now() + (cfg.timeoutMs ?? 30000);
|
|
137
|
+
while (Date.now() < deadline) {
|
|
138
|
+
flushTail();
|
|
139
|
+
if (exitedEarly) {
|
|
140
|
+
try { closeSync(tailFd); } catch {}
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
if (await probeOnce()) {
|
|
144
|
+
flushTail();
|
|
145
|
+
emit({ event: "ready", host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
146
|
+
try { closeSync(tailFd); } catch {}
|
|
147
|
+
child.unref();
|
|
148
|
+
process.exit(0);
|
|
149
|
+
}
|
|
150
|
+
await sleep(200);
|
|
151
|
+
}
|
|
152
|
+
flushTail();
|
|
153
|
+
emit({ event: "failed", reason: "timeout", timeoutMs: cfg.timeoutMs ?? 30000 });
|
|
154
|
+
try { closeSync(tailFd); } catch {}
|
|
155
|
+
try { process.kill(-child.pid, "SIGTERM"); } catch {}
|
|
156
|
+
process.exit(1);
|
|
157
|
+
})();
|
|
158
|
+
`,_n=pe(()=>{const r=Hs(ve(fo(),"vis-services-")),e=ve(r,"bootstrap.mjs");return Mr(e,Dn),{runDir:r,scriptPath:e}},"prepareBootstrap"),Jr=pe((r,e,t)=>{const s=t.replaceAll(/[^\w-]/g,"_");return{configFile:ve(r,`${s}.json`),logFile:ve(r,`${s}.log`),pidFile:ve(r,`${s}.pid`),scriptPath:e}},"buildBootstrapPaths"),Ln=pe(r=>{const{paths:e,service:t}=r,s=t.config.readiness?.tcp?.port??t.config.port;if(typeof s!="number")throw new TypeError(`Service ${t.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);return{command:t.command,cwd:t.cwd,env:t.env,host:t.config.readiness?.tcp?.host??"127.0.0.1",id:t.id,logFile:e.logFile,pidFile:e.pidFile,port:s,timeoutMs:t.config.readiness?.tcp?.timeoutMs??3e4}},"buildEphemeralConfig"),An=pe(r=>`node ${JSON.stringify(r.scriptPath)} ${JSON.stringify(r.configFile)}`,"buildEphemeralCommand"),Bn=pe(r=>{const{id:e,visBin:t,workspaceRoot:s}=r;return`node ${JSON.stringify(t)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(s)}`},"buildRegistryCommand"),Nn=pe(r=>{const{missingServiceIds:e,mode:t,taskGraph:s,visBin:o,workspaceRoot:n}=r,{services:i,skipped:l}=Xr(n,e,s);if(i.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:l};const f=jn(i.map(k=>k.id),s),p=new Map(i.map(k=>[k.id,k])),u=[],w=[];if(t==="ephemeral")for(const k of f){const S=p.get(k);S&&w.push({id:k,payload:Ln({paths:{logFile:"",pidFile:""},service:S})})}let d;t==="ephemeral"&&(d=_n());let T;for(const k of f){const S=p.get(k),O=s.tasks[k];if(!S||!O)continue;let J;if(t==="ephemeral"){const m=Jr(d.runDir,d.scriptPath,k),D={...w.find(x=>x.id===k).payload,logFile:m.logFile,pidFile:m.pidFile};Mr(m.configFile,JSON.stringify(D)),J=An(m),u.push(m.pidFile)}else J=Bn({id:k,visBin:o,workspaceRoot:n});if(O.overrides={...O.overrides,command:J},O.cache=!1,s.tasks[k]=O,T!==void 0){const m=s.dependencies[k]??[];m.includes(T)||(s.dependencies[k]=[...m,T])}T=k}const R=new Set(f),G=new Map,E=pe(k=>{const S=new Set,O=[...s.dependencies[k]??[]],J=new Set;for(;O.length>0;){const m=O.pop();if(!J.has(m)){J.add(m),R.has(m)&&S.add(m);for(const D of s.dependencies[m]??[])J.has(D)||O.push(D)}}return[...S].sort()},"collectTransitive");for(const k of Object.keys(s.dependencies)){if(R.has(k))continue;const S=E(k);if(S.length===0)continue;const O={};for(const J of S){const m=p.get(J);m?.config.env&&Object.assign(O,m.config.env)}Object.keys(O).length>0&&G.set(k,O)}return{chain:f,ephemeralPidFiles:u,runDir:d?.runDir,serviceEnvByTaskId:G,skipped:l}},"injectServiceTasks"),Hn=new Set(["auto","ephemeral","off","persistent"]),Gn=pe(r=>{const{cli:e,config:t,isCi:s,isPersistentTarget:o,isTty:n,target:i}=r;if(e!==void 0&&!Hn.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const l=e??t??(n&&!s?"auto":"off");return l==="off"?"off":l==="ephemeral"?"ephemeral":l==="persistent"?"registry":o||i==="dev"?"ephemeral":"registry"},"resolveServicesPolicy");var qn=Object.defineProperty,I=M((r,e)=>qn(r,"name",{value:e,configurable:!0}),"o");const Lt="VIS_AFFECTED_FILES",Wn=2e3,Tr=I(async(r,e,t,s,o,n)=>{const i=r.map(E=>{const k=E.overrides.command;if(!k)return;const S=E.overrides.visOptions,O=It(e,E.projectRoot,!!S?.runFromWorkspaceRoot),J=S?.envFile?xt(O,S.envFile):{},m=t&&(S?.affectedFiles==="env"||S?.affectedFiles==="both")?{[Lt]:t.join(`
|
|
159
|
+
`)}:{},D=n?.get(E.id)??{};return{command:k,cwd:O,env:{INIT_CWD:s,...J,...D,...m},name:E.id}}).filter(E=>E!==void 0);if(i.length===0)return;if(!o){await ct(i,{killOthers:["failure"],onEvent:I(()=>{},"onEvent")});return}const{abortSignal:l,lifeCycle:f,store:p}=o,u=i.map(E=>r.find(k=>k.id===E.name)).filter(Boolean);p.unmarkDone(),f.startTasks?.(u);const w=new Map,d=new Map;let T;const R=I(()=>{for(const E of d.values())try{E("SIGTERM")}catch{}T||(T=setTimeout(()=>{for(const E of d.values())try{E("SIGKILL")}catch{}d.clear()},2e3),T.unref?.())},"killAll");let G;l&&(G=I(()=>{R()},"abortListener"),l.then(()=>{G?.()}).catch(()=>{G?.()}));try{await ct(i,{killOthers:["failure"],onEvent:I(E=>{const k=u[E.index];if(k)switch(E.kind){case"close":{const S=w.get(k.id)??Date.now(),O=E.killed||E.exitCode===0?"success":"failure";f.endTasks?.([{code:E.exitCode??0,endTime:Date.now(),startTime:S,status:O,task:k,terminalOutput:p.getSnapshot().outputs.get(k.id)??""}]),d.delete(E.index);break}case"error":{E.message&&p.addOutput(k.id,`${E.message}
|
|
160
|
+
`);break}case"started":{w.set(k.id,Date.now()),E.kill&&d.set(E.index,E.kill);break}case"stderr":case"stdout":{E.text&&p.addOutput(k.id,`${E.text}
|
|
161
|
+
`);break}}},"onEvent")})}finally{T&&(clearTimeout(T),T=void 0),p.markDone()}},"runPersistentTasks"),Cr=I(r=>{try{return process.kill(-r,0),!0}catch{try{return process.kill(r,0),!0}catch{return!1}}},"isPidAlive"),Vn=I(r=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r)},"sleepSyncMs"),zn=I(r=>{const{extraPids:e=[],pidFiles:t,runDir:s}=r,o=[],n=I(i=>{try{process.kill(-i,"SIGTERM")}catch{try{process.kill(i,"SIGTERM")}catch{}}},"sendSigterm");for(const i of t){let l;try{const f=fs(i),p=Number.parseInt(f.trim(),10);l=Number.isFinite(p)&&p>0?p:void 0}catch{continue}l!==void 0&&(o.push(l),n(l))}for(const i of e)!Number.isFinite(i)||i<=0||(o.push(i),n(i));if(o.length>0){const i=Date.now()+1500;for(;Date.now()<i;){let l=!0;for(const f of o)if(Cr(f)){l=!1;break}if(l)break;Vn(100)}for(const l of o)if(Cr(l))try{process.kill(-l,"SIGKILL")}catch{try{process.kill(l,"SIGKILL")}catch{}}}s&&gs(s)},"cleanupEphemeralServices"),Ct=256*1024;class Un{static{M(this,"Fn")}static{I(this,"OutputRingBuffer")}#e;#o="";#t=!1;constructor(e){this.#e=e}append(e){this.#o+=e,this.#o.length>this.#e&&(this.#o=this.#o.slice(-this.#e),this.#t=!0)}toString(){return this.#t?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
|
|
162
|
+
${this.#o}`:this.#o}}const Zr=I(r=>{const e=r.overrides.visOptions;if(e&&typeof e=="object")return e},"getTaskOptions"),At=I(r=>`'${r.replaceAll("'",String.raw`'\''`)}'`,"singleQuoteEscape"),Yn=I((r,e,t)=>{if(!e||e.length===0||t===!1||t===void 0)return r;if(t==="args"||t==="both"){const s=e.map(o=>At(o)).join(" ");return`${r} ${s}`}return r},"buildAffectedFilesArgs"),es="visForwardedArgs",Kn=I((r,e)=>{const t=e.overrides[es];if(!Array.isArray(t)||t.length===0)return r;const s=t.map(o=>At(o)).join(" ");return`${r} ${s}`},"appendForwardedArgs"),Qn=I(async(r,e,t)=>{if(!e)return t();const s=r.get(e)??Promise.resolve();let o;const n=new Promise(l=>{o=l}),i=s.then(()=>n);r.set(e,i),await s;try{return await t()}finally{o(),r.get(e)===i&&r.delete(e)}},"withMutex"),Xn=I(r=>{let e=Math.max(0,Math.floor(r));return{claim(t){const s=Math.max(0,Math.min(t,e));return e-=s,s},get remaining(){return e}}},"createRetryBudget"),Jn=I((r,e,t)=>{const s=`${e}\0${typeof t=="string"?t:String(t)}`,o=r.get(s);if(o)return o;const n=xt(e,t);return r.set(s,n),n},"loadEnvFileCached"),Ir=I(r=>{const e=new Map;return async(t,s)=>{const{affectedFiles:o,currentOs:n,initCwd:i,lifeCycle:l,mutexPool:f,onOutput:p,onOutputReplace:u,retryBudget:w,serviceEnvByTaskId:d,serviceEventBridge:T,stdinRegistry:R,strictEnv:G,workspaceRoot:E}=r,k=Zr(t),S=It(E,s.cwd??t.projectRoot,k?.runFromWorkspaceRoot===!0),O=t.overrides.command;if(!O)return{code:0,terminalOutput:`No command configured for ${t.target.project}:${t.target.target}`};const J=Kn(O,t),m=Yn(J,o,k?.affectedFiles),D=ms(k,n),x=D?`${D} -c ${At(m)}`:m,Y=k?.envFile?Jn(e,S,k.envFile):void 0,F={};o&&o.length>0&&(k?.affectedFiles==="env"||k?.affectedFiles==="both")&&(F[Lt]=o.join(`
|
|
163
|
+
`));const ne=d?.get(t.id),he={INIT_CWD:i,...Y,...ne,...s.env,...F};if(k?.strictEnv??G??!1){const B=ei({command:m,processEnv:process.env,taskEnv:he,taskId:t.id});if(B){const Z=ti(B);return l?.onTaskStderr?.(t,Z),{code:1,terminalOutput:Z}}}const W=k?.pty===!0,A=!!R,K=A||W;K&&(t.cache=!1);const oe=K?void 0:new Un(Ct),_=K?new Er(Ct):void 0;let fe;const ae=I(B=>{if(B.kind==="started"&&(fe=B.kill,B.write&&R&&R.set(t.id,{kill:B.kill,resize:B.resize,write:B.write}),T?.onRegistryTaskStarted(t.id)),(B.kind==="stdout"||B.kind==="stderr")&&B.text!==void 0)if(B.kind==="stdout"?l?.onTaskStdout?.(t,B.text):l?.onTaskStderr?.(t,B.text),_)_.write(B.text),A&&u?.(t.id,_.toString()),T&&T.onTaskOutput(t.id,B.text);else{const Z=`${B.text}
|
|
164
|
+
`;oe.append(Z),p?.(t.id,Z)}B.kind==="close"&&(R&&R.delete(t.id),T&&T.onRegistryTaskClosed(t.id,B.exitCode??0,!!B.killed).catch(()=>{}))},"onEvent"),Te=I(async()=>{const B=k?.retryCount??0,Z=k?.retryDelay,U=w?w.claim(B):B,ke=typeof k?.timeout=="number"&&k.timeout>0?k.timeout:0,Me=typeof k?.killGracePeriodMs=="number"&&k.killGracePeriodMs>=0?k.killGracePeriodMs:5e3;let ce=!1;const Ce=dn({killGracePeriodMs:Me,onTimeout:I(()=>{ce=!0},"onTimeout"),sendSignal:I(ge=>{fe?.(ge)},"sendSignal"),timeoutMs:ke});let Ee;try{Ee=await ct([{command:x,cwd:S,env:he,name:t.id,...K?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:ae,...U>0?{restart:{delay:Z??"exponential",tries:U}}:{}})}finally{Ce.cancel()}const Pe=Ee.closeEvents[0],Re=_?_.toString():oe.toString();return ce?{code:124,terminalOutput:`${Re}
|
|
165
|
+
[timeout] Task "${t.id}" exceeded ${ke}ms budget.
|
|
166
|
+
`}:{code:Pe?.exitCode??1,terminalOutput:Re}},"runOnce");return f?Qn(f,k?.mutex,Te):Te()}},"createConcurrentExecutor"),Zn=I(r=>{if(!r||r.trim().length===0)return;const e=Number.parseFloat(r);return!Number.isFinite(e)||e<=0?{invalid:r}:{value:Math.floor(e)}},"parseEnvConcurrency"),ea=I(async(r,e)=>{const t=await Ts(r,{dataDirectory:at(r)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${Cs(r,{dataDirectory:at(r)})}.`);return}const s=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${s}s)`),e.info(""),e.info(` Total: ${String(t.stats.total)}`),e.info(` Succeeded: ${String(t.stats.succeeded)}`),e.info(` Cached: ${String(t.stats.cached)}`),e.info(` Failed: ${String(t.stats.failed)}`),e.info(` Skipped: ${String(t.stats.skipped)}`),e.info(""),t.stats.failed>0){const n=t.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of n){const l=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${l}ms)`)}e.info("")}const o=[...t.tasks].filter(n=>typeof n.duration=="number").sort((n,i)=>(i.duration??0)-(n.duration??0)).slice(0,5);if(o.length>0){e.info("Slowest tasks:");for(const n of o)e.info(` ${n.taskId.padEnd(40)} ${String(n.duration??0).padStart(6)}ms [${n.cacheStatus}]`);e.info("")}},"renderLastRunSummary"),ta=I(r=>{if(!(r===void 0||r==="")){if(r!=="read"&&r!=="write"&&r!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${r}")`);return r}},"parseCacheMode"),ra=I(r=>{if(!(r===void 0||r==="")){if(r!=="http"&&r!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${r}")`);return r}},"parseCacheBackend"),Ma=I(async({argument:r,logger:e,options:t,runtime:s,visConfig:o,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=n;if(ws(i),t.lastDetails===!0){await ea(i,e);return}const l=process.cwd(),f=await vs(i),{config:p,packageJsons:u,projectOptions:w,workspace:d}=ks(i,o,f),T=ys(i,d,u);let R=r[0];if(!R){const v=dr(d);if(process.stdout.isTTY&&process.stdin.isTTY){const b=await ci(v);if(!b){e.info("No target selected.");return}R=b,await on(`vis run ${b}`)}else{e.info("Available targets:"),e.info(""),e.info(ai(v)),e.info(""),e.info("Usage: vis run <target>");return}}if(p.constraints&&!t.skipConstraints){const v=Is(T,p.constraints);if(v.length>0){for(const b of v)e.error(`[${b.rule}] ${b.message}`);throw new Error(`${v.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(t.affected){const v=[R];t.parallel!==void 0&&v.push(`--parallel=${String(t.parallel)}`),t.cache||v.push("--no-cache"),t.query&&v.push(`--query=${String(t.query)}`),t.reverse&&v.push("--reverse"),typeof t.runnerTags=="string"&&t.runnerTags!==""&&v.push(`--runner-tags=${t.runnerTags}`),await s.runCommand("affected",{argv:v});return}const G=await so(R,d,process.cwd(),i),E=si(w),k=oi(G.target,E);k!==G.target&&e.debug?.(`Resolved alias "${G.target}" → "${k}"`);let S=G.projects;const O=r.slice(1).map(String);if(t.projects){const v=new Set(t.projects.split(",").map(b=>b.trim()));if(S=S.filter(b=>v.has(b)),S.length===0)throw new Error(`No matching projects found for: ${String(t.projects)}`)}if(t.query&&(S=oo(S,d,t.query),S.length===0)){e.info(`Query "${String(t.query)}" matched no projects.`);return}const J=bs(),m=process.env[Lt],D=m?m.split(`
|
|
167
|
+
`).filter(Boolean):void 0,x=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,Y=x?new Set(x.split(",").map(v=>v.trim()).filter(Boolean)):void 0,F=[],ne=new Map;for(const v of S){const b=w.get(v)?.[k];if(!b)continue;const P=b.options;if(!P?.internal){if(!Ss(P,!!tt)){e.debug?.(`Skipping ${v}:${k} — runInCI filter`);continue}if(!$s(P,Y)){e.debug?.(`Skipping ${v}:${k} — runner-tags filter`);continue}F.push(v),ne.set(v,b)}}if(F.length===0){const v=dr(d),b=Object.entries(d.projects).filter(([,P])=>P.targets?.[k]!==void 0).map(([P])=>P);if(e.error(`No projects have the "${k}" target.`),b.length>0){e.info(""),e.info(`Target "${k}" exists in these projects but was filtered out:`);for(const P of b.slice(0,5))e.info(` - ${P}`);b.length>5&&e.info(` …and ${b.length-5} more`)}else{const P=Ar(k,v,3);P.length>0&&(e.info(""),e.info(P.length===1?`Did you mean "${P[0]}"?`:`Did you mean one of: ${P.map(q=>`"${q}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const he=t.pty===!0;let W=F.map(v=>{const b=d.projects[v],P=ne.get(v),q={project:v,target:k},V=`${v}:${k}`,Q=he?{...P.options,pty:P.options?.pty??!0}:P.options,N=P.command?rr(P.command,{affectedFiles:D,projectRoot:b?.root}):P.command;return{cache:P.cache,id:V,outputs:P.outputs??[],overrides:{command:N,...O.length>0?{[es]:O}:{},...Q?{visOptions:Q}:{}},parallelism:P.parallelism,projectRoot:b?.root,target:q}});const A=[],K=[];for(const v of W)Zr(v)?.persistent?(v.cache=!1,A.push(v)):K.push(v);W=K;const oe=xs(t.partition);if(oe&&(W=Ms.partitionTasks(W,oe),e.info(`Partition ${oe.index}/${oe.total}: running ${W.length} task(s)`),W.length===0)){e.info("No tasks assigned to this partition.");return}let _=Es([...W,...A],{projectGraph:T,targetDefaults:p.targetDefaults,workspace:d});for(const[v,b]of Object.entries(_.tasks)){const P=b.target.project,q=b.target.target,V=w.get(P)?.[q];if(!V)continue;const Q=d.projects[P];let N=!1;const H={...b.overrides};H.visOptions===void 0&&V.options&&(H.visOptions=V.options,N=!0),H.command===void 0&&V.command&&(H.command=rr(V.command,{affectedFiles:D,projectRoot:Q?.root}),N=!0),N&&(b.overrides=H,_.tasks[v]=b)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const v=Ko(t.skipCache,d,Object.keys(_.tasks));for(const b of v.skipTaskIds){const P=_.tasks[b];P!==void 0&&(P.cache=!1)}v.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${v.unmatchedPatterns.map(b=>`"${b}"`).join(", ")}`),v.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(v.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await Ys(i,p.toolchain,{error:I(v=>{e.error(v)},"error"),info:I(v=>{e.info(v)},"info"),warn:I(v=>{e.warn(v)},"warn")},!!t.skipToolchain);const fe=t.preflight!==!1&&p.preflight?.lockfile!==!1,ae=zo(i,tt,{warn:I(v=>{e.warn(v)},"warn")},{skip:!fe});if(!ae.shouldContinue)throw new Error(`${ae.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);const Te=process.env.VIS_VERSION??"0.0.0",B=t.dryRun?void 0:async v=>{try{return await to(v.config,{timeoutMs:Wn}),!0}catch{return!1}},Z=await Zs(i),U=await Cn({initialTasks:[...W,...A],probe:B,registeredEntries:Z,taskGraph:_,visVersion:Te}),ke=[];let Me,ce=0;const Ce=[],Ee=new Map;let Pe=[];const Re=new Set;let ge=null,me=null;if(U.diagnostics.length>0){const v=!!(process.stdout.isTTY&&process.stdin.isTTY),b=t.dryRun?"off":Gn({cli:t.services,config:p.run?.services,isCi:!!tt,isPersistentTarget:A.length>0,isTty:v,target:k});if(b==="off"){for(const H of U.diagnostics)e.error(H.message);throw new Error(`${U.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`)}const P=U.diagnostics.map(H=>H.targetId),q=b,V=q==="registry"?Xr(i,P,_):void 0,Q=process.argv[1]??"vis",N=Nn({missingServiceIds:P,mode:q,taskGraph:_,visBin:Q,workspaceRoot:i});if(N.skipped.length>0){for(const{id:H,reason:se}of N.skipped)e.error(`Cannot auto-start ${H}: ${se}`);throw new Error(`${N.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}ke.push(...N.ephemeralPidFiles),Me=N.runDir,Pe=N.chain;for(const H of N.chain)Re.add(H);if(q==="registry"&&(ce=N.chain.length,Ce.push(...N.chain)),N.chain.length>0){const H=new ur(N.chain),se=new Map;if(q==="ephemeral"&&N.runDir)for(const j of N.chain){const L=Jr(N.runDir,`${N.runDir}/bootstrap.mjs`,j);se.set(j,{ephemeral:{configFile:L.configFile,cwd:i,logFile:L.logFile,pidFile:L.pidFile,scriptPath:L.scriptPath},mode:"ephemeral"})}else if(q==="registry"&&V)for(const j of V.services)se.set(j.id,{mode:"registry",registry:{command:j.command,config:j.config,cwd:j.cwd,env:j.env}});if(se.size>0){const j=new Pn({indexToId:new Map,services:se,sink:{crashed:I((L,z)=>{H.markCrashed(L,z)},"crashed"),failed:I((L,z,le)=>{H.markFailed(L,z,le)},"failed"),log:I((L,z)=>{H.appendLog(L,z)},"log"),ready:I((L,z)=>{H.markReady(L,z)},"ready"),started:I((L,z)=>{H.markStarted(L,z),q==="registry"&&z!==null&&Ee.set(L,z)},"started"),starting:I(L=>{H.markStarting(L)},"starting")},workspaceRoot:i});ge=H,me=j}}for(const[H,se]of N.serviceEnvByTaskId){const j=U.serviceEnvByTaskId.get(H)??{};U.serviceEnvByTaskId.set(H,{...j,...se})}}const Oe=new Set(A.map(v=>v.id));if(W=U.initialTasks.filter(v=>!Oe.has(v.id)),_=U.taskGraph,Pe.length>0&&(W=[...Pe.map(v=>_.tasks[v]).filter(v=>v!==void 0),...W]),A.length>0){const v=new Set(A.map(Q=>Q.id)),b={};for(const[Q,N]of Object.entries(_.tasks))v.has(Q)||(b[Q]=N);const P={};for(const[Q,N]of Object.entries(_.dependencies))v.has(Q)||(P[Q]=N.filter(H=>!v.has(H)));const q=new Set;for(const Q of Object.values(P))for(const N of Q)q.add(N);const V=Object.keys(b).filter(Q=>!q.has(Q));_={dependencies:P,roots:V,tasks:b}}const{serviceEnvByTaskId:Ie}=U;if(U.satisfiedServices.length>0){const v=U.satisfiedServices.map(b=>b.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${v}`),!ge)ge=new ur(U.satisfiedServices.map(b=>b.id));else for(const b of U.satisfiedServices)ge.registerService(b.id);for(const b of U.satisfiedServices){const P=b.config.readiness?.tcp?.port??b.config.port??0,q=b.config.readiness?.tcp?.host??"127.0.0.1";ge.markReady(b.id,{host:q,port:P})}}if(t.reverse&&(_=Ps(_),e.debug?.(`Reversed task graph: ${String(_.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const v=Object.keys(_.tasks).length,b=_.roots.length;e.info(`Execution plan (${String(v)} task(s), ${String(b)} root(s)):`),e.info("");const P=new Set,q=I((V,Q)=>{if(P.has(V))return;P.add(V);for(const se of _.dependencies[V]??[])q(se,Q+1);const N=_.tasks[V],H=" ".repeat(Q+1);e.info(`${H}${V}${N?.cache===!1?" (no-cache)":""}`)},"walkPlan");for(const V of _.roots)q(V,0);for(const V of Object.keys(_.tasks))q(V,0);A.length>0&&(e.info(""),e.info(` + ${String(A.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const je=Date.now(),ye=Zi(),Le=I((v,b)=>{const P=b instanceof Error?b.message:String(b);e.warn(`Plugin error in ${v}: ${P}`)},"onHookError");await en(ye,p.plugins);const $=typeof t.profile=="string"?t.profile:void 0,y=I(async v=>{if(!$)return;const b=sr(v,_,je),P=$.startsWith("/")?$:`${i}/${$}`;await Rs(b,P),e.info(`Profile written to ${$}`)},"maybeWriteProfile"),C=p.taskRunnerOptions??{},ee=js(i,t.cacheDir,C.cacheDirectory,p.sharedWorktreeCache),Ae=Ds(ee,i,p.branchScopedCache),Be=Zn(process.env.VIS_RUN_CONCURRENCY_LIMIT);Be&&"invalid"in Be&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${Be.invalid} is not a positive number; falling back to default concurrency.`);const ts=Be&&"value"in Be?Be.value:void 0,rs=t.parallel??ts??3,Bt=t.strictEnv??p.strictEnv??!1,Ze={dryRun:t.dryRun??!1,parallel:rs,skipNxCache:!t.cache,summarize:t.summarize??!1,...C,cacheDirectory:Ae,dataDirectory:C.dataDirectory??at(i)};if(C.remoteCache){const v=ta(t.cacheMode),b=ra(t.cacheBackend);(v||b)&&(Ze.remoteCache={...C.remoteCache,...v?{mode:v}:{},...b?{backend:b}:{}})}else(t.cacheMode||t.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts; ignoring.");const ss=process.stdout.isTTY&&!tt,os=p.tui?.autoExit??!1,Nt={args:{parallel:Ze.parallel,targets:[k]},autoExit:os,projectNames:F,tasks:[...W,...A]},Ht=typeof t.retryBudget=="number"?t.retryBudget:void 0,Gt=Ht===void 0?void 0:Xn(Ht),qt=new tn(ye,Le),Wt=new Gs(i),Vt=qi(typeof t.outputStyle=="string"?t.outputStyle.toLowerCase():void 0);await ye.callHook("run:before",{tasks:W,workspaceRoot:i});const qe=t.stopServices===!0;let zt=!1;const Ut=I(()=>{if(zt)return;zt=!0,me&&me.dispose().catch(()=>{});const v=qe?[...Ee.values()]:void 0;zn({extraPids:v,pidFiles:ke,runDir:Me})},"runCleanupOnce"),et=I(()=>{Ut()},"onCleanupSignal"),Yt=ke.length>0||Me!==void 0||qe&&Ce.length>0;Yt&&(process.on("SIGINT",et),process.on("SIGTERM",et));try{if(ss){const v=new Map,b=Hi({...Nt,onRetryService:me?j=>me.retry(j):void 0,outputStyle:Vt,serviceDockStore:ge,stdinRegistry:v}),{lifeCycle:P,store:q}=b,V=new or([P,qt,Wt]),Q=Ir({affectedFiles:D,currentOs:J,initCwd:l,lifeCycle:V,mutexPool:new Map,onOutput:I((j,L)=>{me&&Re.has(j)?me.onTaskOutput(j,L):q.addOutput(j,L)},"onOutput"),onOutputReplace:I((j,L)=>{q.setOutput(j,L)},"onOutputReplace"),retryBudget:Gt,serviceEnvByTaskId:Ie,serviceEventBridge:me??void 0,stdinRegistry:v,strictEnv:Bt,workspaceRoot:i});let N="rerun",H=null,se=new Map;for(;N!=="quit";){if(N==="rerun"){if(se=await ir(W,Ze,{lifeCycle:V,projectGraph:T,taskExecutor:Q,taskGraph:_,workspaceRoot:i}),A.length>0&&!t.failFast){const j=new Promise(L=>{const z=q.subscribe(()=>{const le=q.getSnapshot();(le.rerunRequested||le.retryTaskId)&&(z(),L())});b.renderIsDone.then(()=>{z(),L()}).catch(()=>{z(),L()})});await Tr(A,i,D,l,{abortSignal:j,lifeCycle:V,store:q},Ie)}}else if(N==="retry"&&H){const j=W.find(z=>z.id===H),L=j?.overrides.command;if(j&&L){const z=j.projectRoot??i,le=z.startsWith("/")?z:`${i}/${z}`;V.startTasks?.([j]);const we=new Er(Ct),be=(await ct([{command:L,cwd:le,name:j.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:I(re=>{re.kind==="started"&&re.write&&v.set(j.id,{kill:re.kill,resize:re.resize,write:re.write}),(re.kind==="stdout"||re.kind==="stderr")&&re.text&&(we.write(re.text),q.setOutput(j.id,we.toString())),re.kind==="close"&&v.delete(j.id)},"onEvent")})).closeEvents[0];V.endTasks?.([{code:be?.exitCode??1,status:be?.exitCode===0?"success":"failure",task:j,terminalOutput:q.getSnapshot().outputs.get(j.id)}])}else j&&V.endTasks?.([{code:1,status:"failure",task:j,terminalOutput:`No command configured for ${j.id}`}]);H=null,q.markDone()}N=await new Promise(j=>{const L=q.subscribe(()=>{const z=q.getSnapshot();z.rerunRequested&&(q.acknowledgeRerun(),L(),j("rerun")),z.retryTaskId&&(H=q.acknowledgeRetry(),L(),j("retry"))});b.renderIsDone.then(()=>{L(),j("quit")}).catch(()=>{L(),j("quit")})})}await b.renderIsDone,await ye.callHook("run:after",se),await y(se),ce>0&&(e.info(""),qe?e.info(`${String(ce)} service(s) stopped (--stop-services).`):e.info(`${String(ce)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const v=new Map,b=typeof t.log=="string"?t.log.toLowerCase():"",P=b==="labeled"||b==="grouped"||b==="interleaved"?b:void 0,q=P?Fs(P):void 0,V=new or([new Vi({...Nt,logReporter:q,outputStyle:Vt}),qt,Wt]),Q=Ir({affectedFiles:D,currentOs:J,initCwd:l,lifeCycle:V,mutexPool:v,retryBudget:Gt,serviceEnvByTaskId:Ie,serviceEventBridge:me??void 0,strictEnv:Bt,workspaceRoot:i}),N=I(async()=>{const j=Date.now(),L=await ir(W,Ze,{lifeCycle:V,projectGraph:T,taskExecutor:Q,taskGraph:_,workspaceRoot:i}),z=Date.now()-j;if(t.summarize){const Se=sr(L,_,je);await Os(Se,i,{dataDirectory:at(i)})}let le=!1;for(const[,Se]of L)Se.status==="failure"&&(le=!0);const we=qs(L,z),be=Ws(i),re=Vs(i,z,be);return e.info(""),e.info(` ${we}${re?` ${re}`:""}`),{hasFailure:le,results:L,runHistory:be}},"runOnce"),H=await N();await ye.callHook("run:after",H.results),await y(H.results);const{hasFailure:se}=H;if(t.watch){const j=F.map(ie=>{const de=d.projects[ie]?.root;if(de)return de.startsWith("/")?de:`${i}/${de}`}).filter(ie=>ie!==void 0),L=W;let z;const le=I(ie=>{const de=wn(L,ie);return z=de.filter,W=de.tasks,de.tasks.length},"applyFilter");let we=!1,be=H.results;const re=I(()=>{const ie=yr(be,i);if(ie.directories.length>0&&ie.files.size>0){const de=fn(ie.files,i,ie.directories);return{handle:br({filter:de,onChange:Kt,paths:ie.directories}),mode:"tracked"}}return{handle:br({onChange:Kt,paths:j}),mode:"roots"}},"buildHandle");let Se;const Kt=I(async ie=>{if(!we){we=!0;try{e.info(`Change detected in ${ie.length} file(s), rerunning…`),be=(await N()).results,Se?.close(),Se=re().handle}finally{we=!1}}},"onChangeHandler"),Qt=re();Se=Qt.handle;const is=Qt.mode==="tracked"?`Watching ${String(yr(be,i).files.size)} tracked file(s)`:`Watching ${String(j.length)} project root(s)`;e.info(`${is} — edit a file to rerun, press h for keybinds, q to quit.`);const vt=I(async()=>{if(!we){we=!0;try{if(W.length===0){e.info("No tasks match the active filter — press a to clear it.");return}be=(await N()).results,Se?.close(),Se=re().handle}finally{we=!1}}},"triggerRerun");await new Promise(ie=>{let de=!1,Xt;const Jt=I(()=>{Zt()},"onSigint"),Zt=I(()=>{de||(de=!0,Xt?.close(),process.off("SIGINT",Jt),Se?.close(),ie())},"exit");process.on("SIGINT",Jt),Xt=Sn({handlers:{onClearFilter:I(async()=>{const We=le(void 0);e.info(`Filter cleared — running ${String(We)} task(s).`),await vt()},"onClearFilter"),onFilter:I(async We=>{const ns=z,er=le(We);if(er===0){e.info(`Filter "${We}" matched no projects — keeping previous filter.`),le(ns);return}e.info(`Filter "${We}" matched ${String(er)} task(s).`),await vt()},"onFilter"),onHelp:I(()=>{yn(process.stdout)},"onHelp"),onQuit:I(()=>{Zt()},"onQuit"),onRerun:vt}})});return}if(se){if(t.flaky!==!1){const j=zs(i,{minRuns:2},H.runHistory);if(j.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const L of Us(j))e.info(` ${L}`);e.info("")}}throw new Error("Some tasks failed.")}A.length>0&&!t.failFast&&await Tr(A,i,D,l,void 0,Ie),ce>0&&(e.info(""),qe?e.info(`${String(ce)} service(s) stopped (--stop-services).`):e.info(`${String(ce)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{Ut(),Yt&&(process.off("SIGINT",et),process.off("SIGTERM",et)),qe&&Ce.length>0&&await Promise.all(Ce.map(async v=>{try{await eo(i,v)}catch{}}))}},"execute");export{Xn as createRetryBudget,Ma as default};
|