Comparing version 2.11.11 to 2.11.12
@@ -101,2 +101,6 @@ | ||
hidden?: boolean; | ||
/** | ||
* Whether the target should be run | ||
*/ | ||
shouldRun?: boolean; | ||
} | ||
@@ -167,2 +171,3 @@ /** | ||
options?: Record<string, any>; | ||
shouldRun?: (target: Target) => boolean | Promise<boolean>; | ||
} | ||
@@ -169,0 +174,0 @@ export interface PipelineDefinition { |
@@ -24,4 +24,4 @@ "use strict"; | ||
async run(runOptions) { | ||
const { target } = runOptions; | ||
const { clearPaths } = target.options; | ||
const { target } = runOptions; | ||
const { clearPaths } = target.options; | ||
for (const cachePath of clearPaths){ | ||
@@ -28,0 +28,0 @@ if (_fs.default.existsSync(cachePath)) { |
@@ -53,7 +53,8 @@ "use strict"; | ||
// By convention, do not run anything if there is no script for this task defined in package.json (counts as "success") | ||
return await this.hasNpmScript(target); | ||
const hasNpmScript = await this.hasNpmScript(target); | ||
return hasNpmScript && (target.shouldRun ?? true); | ||
} | ||
async run(runOptions) { | ||
const { target , weight , abortSignal } = runOptions; | ||
const { nodeOptions , npmCmd , taskArgs } = this.options; | ||
const { target, weight, abortSignal } = runOptions; | ||
const { nodeOptions, npmCmd, taskArgs } = this.options; | ||
const task = target.options?.script ?? target.task; | ||
@@ -136,3 +137,3 @@ let childProcess; | ||
}; | ||
const { pid } = childProcess; | ||
const { pid } = childProcess; | ||
process.stdout.write(`Running ${[ | ||
@@ -139,0 +140,0 @@ npmCmd, |
@@ -25,4 +25,4 @@ "use strict"; | ||
async run(runOptions) { | ||
const { target } = runOptions; | ||
const { clearPaths , prunePeriod , now } = target.options; | ||
const { target } = runOptions; | ||
const { clearPaths, prunePeriod, now } = target.options; | ||
for (const cachePath of clearPaths){ | ||
@@ -29,0 +29,0 @@ if (_fs.default.existsSync(cachePath)) { |
@@ -29,9 +29,9 @@ "use strict"; | ||
if (typeof scriptModule.shouldRun === "function") { | ||
return await scriptModule.shouldRun(target); | ||
return await scriptModule.shouldRun(target) && (target.shouldRun ?? true); | ||
} | ||
return true; | ||
return target.shouldRun ?? true; | ||
} | ||
async run(runOptions) { | ||
const { target , weight , abortSignal } = runOptions; | ||
const { taskArgs } = this.options; | ||
const { target, weight, abortSignal } = runOptions; | ||
const { taskArgs } = this.options; | ||
const scriptModule = await this.getScriptModule(target); | ||
@@ -38,0 +38,0 @@ const runFn = typeof scriptModule.run === "function" ? scriptModule.run : typeof scriptModule.default === "function" ? scriptModule.default : scriptModule; |
@@ -1,10 +0,10 @@ | ||
"use strict";var It=Object.create;var $e=Object.defineProperty;var qt=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty;var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Nt=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of xt(e))!Dt.call(r,n)&&n!==t&&$e(r,n,{get:()=>e[n],enumerable:!(s=qt(e,n))||s.enumerable});return r};var At=(r,e,t)=>(t=r!=null?It(Et(r)):{},Nt(e||!r||!r.__esModule?$e(t,"default",{value:r,enumerable:!0}):t,r));var q=f(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});function jt(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}jt(G,{START_MARKER_PREFIX:function(){return Ce},END_MARKER_PREFIX:function(){return Le},startMarker:function(){return Ft},endMarker:function(){return $t}});var Ce="## WORKER:START:",Le="## WORKER:END:";function Ft(r){return`${Ce}${r}`}function $t(r){return`${Le}${r}`}});var Be=f(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});Object.defineProperty(U,"registerWorker",{enumerable:!0,get:function(){return Ct}});var x=require("worker_threads"),E=q();function Ct(r){var s;(s=x.parentPort)==null||s.on("message",async n=>{let i;switch(n.type){case"start":return i=new AbortController,n.task&&await e(n.id,n.task,i.signal);case"abort":return i==null?void 0:i.abort();case"check-memory-usage":return t(x.parentPort)}});async function e(n,i,o){var a,c;try{process.stdout.write(`${(0,E.startMarker)(n)} | ||
`),process.stderr.write(`${(0,E.startMarker)(n)} | ||
`);let u=await r(i,o);(a=x.parentPort)==null||a.postMessage({type:"status",err:void 0,results:u})}catch(u){(c=x.parentPort)==null||c.postMessage({type:"status",err:u,results:void 0})}finally{process.stdout.write(`${(0,E.endMarker)(n)} | ||
`),process.stderr.write(`${(0,E.endMarker)(n)} | ||
`)}}function t(n){let i={type:"report-memory-usage",memoryUsage:process.memoryUsage().heapUsed};n.postMessage(i)}}});var Ge=f(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});Object.defineProperty(K,"createFilteredStreamTransform",{enumerable:!0,get:function(){return Bt}});var Lt=require("stream"),D=q();function Bt(){return new Lt.Transform({transform(e,t,s){let n=e.toString();n.includes(D.START_MARKER_PREFIX)&&(n=n.replace(new RegExp(D.START_MARKER_PREFIX+`[0-9a-z]{64} | ||
`),"")),n.includes(D.END_MARKER_PREFIX)&&(n=n.replace(new RegExp(D.END_MARKER_PREFIX+`[0-9a-z]{64} | ||
`),"")),s(null,n)}})}});var Ue=f(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});Object.defineProperty(H,"TaskInfo",{enumerable:!0,get:function(){return z}});var Gt=require("async_hooks");function Ut(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var z=class extends Gt.AsyncResource{get id(){return this.options.id}get weight(){return this.options.weight}get abortSignal(){return this.options.abortSignal}done(e,t){let{cleanup:s,worker:n,resolve:i,reject:o}=this.options;s&&this.runInAsyncScope(s,null,n),e?this.runInAsyncScope(o,null,e,n):this.runInAsyncScope(i,null,t,n),this.emitDestroy()}constructor(e){super("WorkerPoolTaskInfo"),Ut(this,"options",void 0),this.options=e,e.setup&&this.runInAsyncScope(e.setup,null,e.worker,e.worker.stdout,e.worker.stderr)}}});var tt=f(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Object.defineProperty(Q,"ThreadWorker",{enumerable:!0,get:function(){return V}});var Ke=Ge(),ze=require("readline"),He=q(),Kt=require("events"),Xe=require("stream"),zt=Ue(),Ht=require("worker_threads"),Xt=Ze(require("crypto")),Jt=Ze(require("os"));function Ye(r,e){if(e.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Vt(r,e){return e.get?e.get.call(r):e.value}function Yt(r,e,t){if(e.set)e.set.call(r,t);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=t}}function Qe(r,e,t){if(!e.has(r))throw new TypeError("attempted to "+t+" private field on non-instance");return e.get(r)}function p(r,e){var t=Qe(r,e,"get");return Vt(r,t)}function N(r,e,t){Ye(r,e),e.set(r,t)}function M(r,e,t){var s=Qe(r,e,"set");return Yt(r,s,t),t}function b(r,e,t){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return t}function A(r,e){Ye(r,e),e.add(r)}function O(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Ze(r){return r&&r.__esModule?r:{default:r}}var Qt="free",y=new WeakMap,v=new WeakMap,P=new WeakMap,_=new WeakMap,X=new WeakSet,J=new WeakSet,et=new WeakSet,j=new WeakSet,V=class extends Kt.EventEmitter{start(e,t){this.status="busy";let{task:s,resolve:n,reject:i,cleanup:o,setup:a}=e;t==null||t.addEventListener("abort",b(this,j,Y));let c=Xt.default.randomBytes(32).toString("hex");M(this,y,new zt.TaskInfo({id:c,weight:e.weight,cleanup:o,resolve:n,reject:i,worker:this,setup:a,abortSignal:t})),p(this,v).promise=new Promise(u=>{p(this,v).resolve=u}),p(this,P).promise=new Promise(u=>{p(this,P).resolve=u}),p(this,_).postMessage({type:"start",task:{...s,weight:e.weight},id:c})}get weight(){var e;return((e=p(this,y))==null?void 0:e.weight)??1}get stdout(){return p(this,v).stream}get stderr(){return p(this,P).stream}get resourceLimits(){return p(this,_).resourceLimits}get threadId(){return p(this,_).threadId}terminate(){p(this,_).removeAllListeners(),p(this,_).terminate(),p(this,_).unref()}restart(){this.restarts++,this.status="busy",p(this,_).terminate(),b(this,X,Je).call(this)}async checkMemoryUsage(){p(this,_).postMessage({type:"check-memory-usage"})}postMessage(e,t){p(this,_).postMessage(e,t)}constructor(e,t){super(),A(this,X),A(this,J),A(this,et),A(this,j),O(this,"script",void 0),O(this,"options",void 0),N(this,y,{writable:!0,value:void 0}),N(this,v,{writable:!0,value:void 0}),N(this,P,{writable:!0,value:void 0}),N(this,_,{writable:!0,value:void 0}),O(this,"status",void 0),O(this,"restarts",void 0),O(this,"maxWorkerMemoryUsage",void 0),this.script=e,this.options=t,M(this,v,{stream:new Xe.Readable,promise:Promise.resolve(),resolve:()=>{}}),M(this,P,{stream:new Xe.Readable,promise:Promise.resolve(),resolve:()=>{}}),this.status="busy",this.restarts=0,this.maxWorkerMemoryUsage=0,b(this,X,Je).call(this)}};function Je(){let{workerOptions:r}=this.options,e=this.script,t=new Ht.Worker(e,{...r,stdout:!0,stderr:!0});b(this,et,Zt).call(this,t);let s=t.stdout.pipe((0,Ke.createFilteredStreamTransform)()),n=t.stderr.pipe((0,Ke.createFilteredStreamTransform)()),i=()=>{},o=new Promise(d=>{i=d,d()}),a=()=>{},c=new Promise(d=>{a=d,d()}),u=d=>{if(d.type==="status")Promise.all([p(this,v).promise,p(this,P).promise]).then(()=>{var g;let{err:h,results:m}=d;p(this,y)&&((g=p(this,y).abortSignal)==null||g.removeEventListener("abort",b(this,j,Y)),p(this,y).done(h,m)),this.checkMemoryUsage()});else if(d.type==="report-memory-usage"){this.maxWorkerMemoryUsage=Math.max(this.maxWorkerMemoryUsage,d.memoryUsage);let h=this.options.workerIdleMemoryLimit??Jt.default.totalmem();h&&d.memoryUsage>h?this.restart():b(this,J,Ve).call(this)}else this.emit("message",d)};t.on("message",u);let l=d=>{var h;p(this,v).resolve(),p(this,P).resolve(),p(this,y)?((h=p(this,y).abortSignal)==null||h.removeEventListener("abort",b(this,j,Y)),p(this,y).done(d,null)):this.emit("error",d)};t.on("error",l),M(this,_,t),M(this,v,{stream:s,promise:o,resolve:i}),M(this,P,{stream:n,promise:c,resolve:a}),b(this,J,Ve).call(this)}function Ve(){let r=1;p(this,y)&&(r=p(this,y).weight,M(this,y,void 0)),this.status="free",this.emit(Qt,{weight:r})}function Zt(r){let e=r.stdout,t=(0,ze.createInterface)({input:e,crlfDelay:1/0}),s=r.stderr,n=(0,ze.createInterface)({input:s,crlfDelay:1/0}),i=c=>{let u=[],l;return d=>{p(this,y)&&(d.includes((0,He.startMarker)(p(this,y).id))?(u=[],c==="stdout"?l=p(this,v).resolve:l=p(this,P).resolve):d.includes((0,He.endMarker)(p(this,y).id))?l():u.push(d))}},o=i("stdout"),a=i("stderr");t.on("line",o),n.on("line",a)}function Y(){p(this,_)&&p(this,_).postMessage({type:"abort"})}});var te=f(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});Object.defineProperty(ee,"WorkerPool",{enumerable:!0,get:function(){return Z}});var er=require("events"),tr=tt(),rr=nr(require("os"));function T(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function nr(r){return r&&r.__esModule?r:{default:r}}var rt="free",Z=class extends er.EventEmitter{get workerRestarts(){return this.workers.reduce((e,t)=>e+t.restarts,0)}get maxWorkerMemoryUsage(){return this.workers.reduce((e,t)=>Math.max(e,t.maxWorkerMemoryUsage),0)}stats(){return{maxWorkerMemoryUsage:this.maxWorkerMemoryUsage,workerRestarts:this.workerRestarts}}createInitialWorkers(){if(this.workers.length===0)for(let e=0;e<this.minWorkers;e++)this.addNewWorker()}addNewWorker(){if(this.workers.length<=this.maxWorkers){let{script:e,workerOptions:t}=this.options,s=new tr.ThreadWorker(e,{workerOptions:t,workerIdleMemoryLimit:this.options.workerIdleMemoryLimit});return s.on("free",n=>{let{weight:i}=n;this.availability+=i,this.emit(rt)}),this.workers.push(s),s}}exec(e,t,s,n,i){return i!=null&&i.aborted?Promise.resolve():(t=Math.min(Math.max(1,t),this.maxWorkers),new Promise((o,a)=>{this.queue.push({task:{...e,weight:t},weight:t,resolve:o,reject:a,cleanup:n,setup:s}),this._exec(i)}))}_exec(e){let t=this.queue.findIndex(n=>n.weight<=this.availability);if(t===-1)return;let s=this.workers.find(n=>n.status==="free");if(s||(s=this.addNewWorker()),s){let n=this.queue[t];this.queue.splice(t,1),this.availability-=n.weight,s.start(n,e)}}async close(){await Promise.all(this.workers.map(e=>e.terminate()))}constructor(e){super(),T(this,"options",void 0),T(this,"workers",void 0),T(this,"freeWorkers",void 0),T(this,"queue",void 0),T(this,"minWorkers",void 0),T(this,"maxWorkers",void 0),T(this,"availability",void 0),this.options=e,this.workers=[],this.freeWorkers=[],this.queue=[],this.minWorkers=0,this.maxWorkers=0,this.availability=0,this.minWorkers=this.options.minWorkers??2,this.maxWorkers=this.options.maxWorkers??rr.default.cpus().length-1,this.availability=this.maxWorkers,this.workers=[],this.freeWorkers=[],this.queue=[],this.createInitialWorkers(),this.on(rt,()=>{this.queue.length>0?this._exec():this.workers.every(t=>t.status==="free")&&this.emit("idle")})}}});var st=f(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});Object.defineProperty(se,"AggregatedPool",{enumerable:!0,get:function(){return ne}});var nt=te();function re(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var ne=class{stats(){return[...this.groupedPools.values(),this.defaultPool].reduce((t,s)=>{if(s){let n=s.stats();t.maxWorkerMemoryUsage=Math.max(t.maxWorkerMemoryUsage,n.maxWorkerMemoryUsage),t.workerRestarts=t.workerRestarts+n.workerRestarts}return t},{maxWorkerMemoryUsage:0,workerRestarts:0})}async exec(e,t,s,n,i){let o=this.options.groupBy(e),a=this.groupedPools.get(o)??this.defaultPool;if(!a)throw new Error(`No pool found to be able to run ${o} tasks, try adjusting the maxWorkers & concurrency values`);return a.exec(e,t,s,n,i)}async close(){let e=[...this.groupedPools.values(),this.defaultPool].map(t=>t==null?void 0:t.close());return Promise.all(e)}constructor(e){re(this,"options",void 0),re(this,"groupedPools",void 0),re(this,"defaultPool",void 0),this.options=e,this.groupedPools=new Map;let{maxWorkers:t,maxWorkersByGroup:s,script:n,workerOptions:i}=e,o=0;for(let[c,u]of s.entries()){let l=new nt.WorkerPool({maxWorkers:u,workerOptions:i,script:n,workerIdleMemoryLimit:e.workerIdleMemoryLimit});this.groupedPools.set(c,l),o+=u}if(o>t)throw new Error(`Total maxWorkers (${o}) configured across all groups exceeds concurrency (${t}). Try reducing the maxWorkers, or increasing the --concurrency CLI argument, or separate the tasks to be run`);let a=t-o;a>0&&(this.defaultPool=new nt.WorkerPool({maxWorkers:a,workerOptions:i,script:n,workerIdleMemoryLimit:e.workerIdleMemoryLimit})),this.options.logger.verbose(`Workers pools created: ${[...s.entries(),["default",a]].map(([c,u])=>`${c} (${u})`).join(", ")}`)}}});var it=f(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});function sr(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}sr(ie,{registerWorker:function(){return ir.registerWorker},WorkerPool:function(){return or.WorkerPool},AggregatedPool:function(){return ar.AggregatedPool}});var ir=Be(),or=te(),ar=st()});var at=f(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});Object.defineProperty(oe,"NpmScriptRunner",{enumerable:!0,get:function(){return F}});var ur=require("path"),cr=require("fs/promises"),dr=require("child_process"),pr=lr(require("os"));function ot(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function lr(r){return r&&r.__esModule?r:{default:r}}var F=class r{getNpmArgs(e,t){let s=t.length>0?["--",...t]:[];return["run",e,...s]}async hasNpmScript(e){var i,o;let t=((i=e.options)==null?void 0:i.script)??e.task,s=(0,ur.join)(e.cwd,"package.json");return!!((o=JSON.parse(await(0,cr.readFile)(s,"utf8")).scripts)!=null&&o[t])}async shouldRun(e){return await this.hasNpmScript(e)}async run(e){var h,m;let{target:t,weight:s,abortSignal:n}=e,{nodeOptions:i,npmCmd:o,taskArgs:a}=this.options,c=((h=t.options)==null?void 0:h.script)??t.task,u;if(n){if(n.aborted)return;let g=()=>{if(n.removeEventListener("abort",g),u&&!u.killed){let k=u.pid;process.stdout.write(`Abort signal detected, attempting to killing process id ${k} | ||
`),u.kill("SIGTERM");let w=setTimeout(()=>{u&&!u.killed&&u.kill("SIGKILL")},r.gracefulKillTimeout);w.unref&&w.unref()}};n.addEventListener("abort",g)}let l=this.getNpmArgs(c,a),d=[i,(m=t.options)==null?void 0:m.nodeOptions].filter(g=>g).join(" ");await new Promise((g,k)=>{u=(0,dr.spawn)(o,l,{cwd:t.cwd,stdio:["inherit","pipe","pipe"],...pr.default.platform()==="win32"&&{shell:!0},env:{...process.stdout.isTTY&&{FORCE_COLOR:"1"},...process.env,...d&&{NODE_OPTIONS:d},LAGE_PACKAGE_NAME:t.packageName,LAGE_TASK:t.task,LAGE_WEIGHT:String(s)}});let w=!1,I=Ne=>{var Ae,je,Fe;if(u==null||u.off("exit",I),u==null||u.off("error",I),!w){if(w=!0,(Ae=u==null?void 0:u.stdout)==null||Ae.destroy(),(je=u==null?void 0:u.stderr)==null||je.destroy(),(Fe=u==null?void 0:u.stdin)==null||Fe.destroy(),Ne===0)return g();k(new Error(`NPM Script Runner: ${o} ${l.join(" ")} exited with code ${Ne}`))}},{pid:Ot}=u;process.stdout.write(`Running ${[o,...l].join(" ")}, pid: ${Ot} | ||
`);let St=u.stdout,Rt=u.stderr;St.pipe(process.stdout),Rt.pipe(process.stderr),u.on("exit",I),u.on("error",()=>I(1))})}constructor(e){ot(this,"options",void 0),this.options=e}};ot(F,"gracefulKillTimeout",2500)});var ct=f(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});Object.defineProperty(ae,"WorkerRunner",{enumerable:!0,get:function(){return $}});var fr=require("url");function ut(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var $=class{async shouldRun(e){let t=await this.getScriptModule(e);return typeof t.shouldRun=="function"?await t.shouldRun(e):!0}async run(e){let{target:t,weight:s,abortSignal:n}=e,{taskArgs:i}=this.options,o=await this.getScriptModule(t),a=typeof o.run=="function"?o.run:typeof o.default=="function"?o.default:o;if(typeof a!="function")throw new Error("WorkerRunner: worker script must export a function; you likely need to use `module.exports = function() {...}`");return await a({target:t,weight:s,taskArgs:i,abortSignal:n})}async getScriptModule(e){var n,i;let t=((n=e.options)==null?void 0:n.worker)??((i=e.options)==null?void 0:i.script);if(!t)throw new Error('WorkerRunner: "script" configuration is required - e.g. { type: "worker", script: "./worker.js" }');let s=t;return s.startsWith("file://")||(s=(0,fr.pathToFileURL)(s).toString()),await import(s)}constructor(e){ut(this,"options",void 0),this.options=e}};ut($,"gracefulKillTimeout",2500)});var de=f(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});Object.defineProperty(ce,"NoOpRunner",{enumerable:!0,get:function(){return ue}});var ue=class{async shouldRun(){return!0}async run(){}}});var dt=f(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});Object.defineProperty(pe,"sortTargetsByPriority",{enumerable:!0,get:function(){return hr}});function hr(r){return r.sort((e,t)=>(t.priority??0)-(e.priority??0))}});var W=f(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});function gr(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}gr(le,{getTargetId:function(){return mr},getPackageAndTask:function(){return yr},getStartTargetId:function(){return kr}});function mr(r,e){return`${typeof r=="string"?r:""}#${e}`}function yr(r){if(r.includes("#")){let e=r.split("#");return r.startsWith("#")||e[0]==="//"?{packageName:void 0,task:e[1]}:{packageName:e[0],task:e[1]}}else return{packageName:void 0,task:r}}var _r="__start";function kr(){return _r}});var he=f(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});Object.defineProperty(fe,"detectCycles",{enumerable:!0,get:function(){return wr}});function wr(r){let e=new Map;for(let[t]of r.entries())if(!e.has(t)){let s=vr(r,e,t);if(s.length>0)return{hasCycle:!0,cycle:s}}return{hasCycle:!1}}var vr=(r,e,t)=>{let s=[{node:t,traversing:!1}];for(;s.length>0;){let n=s[s.length-1];if(n.traversing)e.set(n.node,!1),s.pop();else{if(e.has(n.node))if(e.get(n.node)){let o=s.filter(a=>a.traversing).map(a=>a.node);return o.slice(o.indexOf(n.node))}else{s.pop();continue}e.set(n.node,!0),s[s.length-1]={...n,traversing:!0};let i=r.get(n.node);if(!i)throw new Error(`Could not find node "${n.node}" in the graph`);s.push(...[...i.dependents].map(o=>({node:o,traversing:!1})))}}return[]}});var pt=f(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.getPackageDependencies=void 0;function Pr(r,e){var s,n,i;let t=((s=r.dependencies)==null?void 0:s[e])||((n=r.devDependencies)==null?void 0:n[e])||((i=r.peerDependencies)==null?void 0:i[e]);return t?!t.startsWith("npm:")&&!t.startsWith("file:"):!1}function br(r,e,t={withDevDependencies:!0}){let s=[];if(r.dependencies)for(let i of Object.keys(r.dependencies))i!==r.name&&e.has(i)&&s.push(i);if(r.devDependencies&&t.withDevDependencies)for(let i of Object.keys(r.devDependencies))i!==r.name&&e.has(i)&&s.push(i);if(r.peerDependencies&&t.withPeerDependencies)for(let i of Object.keys(r.peerDependencies))i!==r.name&&e.has(i)&&s.push(i);return s.filter(i=>Pr(r,i))}C.getPackageDependencies=br});var lt=f(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.createDependencyMap=void 0;var Mr=pt();function Tr(r,e={withDevDependencies:!0,withPeerDependencies:!1}){let t={dependencies:new Map,dependents:new Map},s=new Set(Object.keys(r));for(let[n,i]of Object.entries(r)){let o=(0,Mr.getPackageDependencies)(i,s,e);for(let a of o)t.dependencies.has(n)||t.dependencies.set(n,new Set),t.dependencies.get(n).add(a),t.dependents.has(a)||t.dependents.set(a,new Set),t.dependents.get(a).add(n)}return t}L.createDependencyMap=Tr});var ht=f(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});Object.defineProperty(me,"expandDepSpecs",{enumerable:!0,get:function(){return Wr}});var S=W();function Wr(r,e){let t=[],s=(o,a)=>{t.push([o,a])},n=(o,a)=>a?i.filter(c=>{let{task:u,packageName:l}=c;return u===o&&a.some(d=>d===l)}).map(c=>c.id):i.filter(c=>c.task===o).map(c=>c.id),i=[...r.values()];for(let o of i){let{depSpecs:a,packageName:c,id:u}=o;if(t.push([(0,S.getStartTargetId)(),u]),!(!a||a.length===0))for(let l of a)if(l.includes("#")){let{packageName:d,task:h}=(0,S.getPackageAndTask)(l),m=(0,S.getTargetId)(d,h);s(m,u)}else if(l.startsWith("^^")&&c){let d=l.substring(2),h=[...ft(c,e)??[]],m=n(d,h);for(let g of m)s(g,u)}else if(l.startsWith("^")&&c){let d=l.substring(1),h=[...e.dependencies.get(c)??[]],m=n(d,h);for(let g of m)s(g,u)}else if(c){let d=l;r.has((0,S.getTargetId)(c,d))&&s((0,S.getTargetId)(c,d),u)}else{if(l.startsWith("^"))throw new Error(`invalid pipeline config detected: ${o.id}, packageName: ${c}, dep: ${l}`);{let h=n(l);for(let m of h)s(m,u)}}}return t}var ge=new Map;function ft(r,e){let t=ge.get(r);if(t)return t==="walk-in-progress"?new Set:t;{ge.set(r,"walk-in-progress");let s=[...e.dependencies.get(r)??[]],n=new Set(s);for(let i of s)for(let o of ft(i,e))n.add(o);return ge.set(r,n),n}}});var gt=f(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});Object.defineProperty(ye,"prioritize",{enumerable:!0,get:function(){return Ir}});function Or(r){let e=[];for(let[t,s]of r)s.dependencies.length===0&&e.push(t);return e}function Sr(r){return new Map([...r.entries()].map(([e,t])=>[e,new Set(t.dependencies)]))}function Rr(r,e){let t=[],s=Sr(r),n=[...e];for(;n.length>0;){let i=n.pop();t.push(i),r.get(i).dependents.forEach(a=>{let c=s.get(a);c.delete(i),c.size===0&&n.push(a)})}return t}function Ir(r){let e=new Map,t=Or(r),s=Rr(r,t);for(let n of s){let i=r.get(n),o=i.priority||0,a=i.dependencies.map(l=>{let d=e.get(l);if(d===void 0)throw new Error(`Expected to have already computed the cumulative priority for node ${l}`);return d}),c=Math.max(...a,0),u=o+c;e.set(n,u)}for(let n of r.values()){let i=e.get(n.id);if(i===void 0)throw new Error(`Expected to have already computed the cumulative priority for node ${n.id}`);n.priority=i}}});var ve=f(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});Object.defineProperty(we,"TargetGraphBuilder",{enumerable:!0,get:function(){return ke}});var _e=W(),qr=gt(),xr=he();function Er(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var ke=class r{addTarget(e){return this.targets.set(e.id,e),this.addDependency((0,_e.getStartTargetId)(),e.id),e}addDependency(e,t){if(this.targets.has(t)){let s=this.targets.get(t);s.dependencies.includes(e)||s.dependencies.push(e)}if(this.targets.has(e)){let s=this.targets.get(e);s.dependents.includes(t)||s.dependents.push(t)}}build(){let e=(0,xr.detectCycles)(this.targets);if(e.hasCycle)throw new Error("Cycles detected in the target graph: "+e.cycle.concat(e.cycle[0]).join(" -> "));return(0,qr.prioritize)(this.targets),{targets:this.targets}}subgraph(e){let t=new r,s=new Set,n=[];for(let i of e)if(this.targets.has(i)){let o=this.targets.get(i);t.addTarget({...o,dependencies:[],dependents:[]}),n.push(i)}for(;n.length>0;){let i=n.shift();if(s.has(i))continue;s.add(i);let o=this.targets.get(i);if(!o)throw new Error("Subgraph builder failed - target not found: "+i);for(let a of o.dependencies)a!==(0,_e.getStartTargetId)()&&(t.targets.has(a)||t.addTarget({...this.targets.get(a),dependencies:[],dependents:[]}),t.addDependency(a,i)),s.has(a)||n.push(a)}return t.build()}constructor(){Er(this,"targets",new Map);let e=(0,_e.getStartTargetId)();this.targets.set(e,{id:e,task:e,cwd:"",label:"Start",hidden:!0,dependencies:[],dependents:[],depSpecs:[],weight:1,priority:0})}}});var mt=f(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Object.defineProperty(Pe,"getWeight",{enumerable:!0,get:function(){return Dr}});function Dr(r,e,t){return typeof e=="number"?e:typeof e=="function"?e(r,t):1}});var Te=f(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Object.defineProperty(Me,"TargetFactory",{enumerable:!0,get:function(){return be}});var yt=W(),_t=mt();function kt(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var be=class{getTargetType(e,t){return t.type?t.type:this.packageScripts.has(e)?"npmScript":"noop"}createPackageTarget(e,t,s){let{resolve:n}=this.options,{options:i,deps:o,dependsOn:a,cache:c,inputs:u,priority:l,maxWorkers:d,environmentGlob:h,weight:m}=s,g=n(e),k=this.getTargetType(t,s),w={id:(0,yt.getTargetId)(e,t),label:`${e} - ${t}`,type:k,packageName:e,task:t,cache:c!==!1,cwd:g,depSpecs:a??o??[],dependencies:[],dependents:[],inputs:u,outputs:k==="noop"?[]:s.outputs,priority:l,maxWorkers:d,environmentGlob:h,weight:1,options:i};return w.weight=(0,_t.getWeight)(w,m,d),w}createGlobalTarget(e,t){let{root:s}=this.options,{options:n,deps:i,dependsOn:o,cache:a,inputs:c,outputs:u,priority:l,maxWorkers:d,environmentGlob:h,weight:m}=t,{task:g}=(0,yt.getPackageAndTask)(e),k={id:e,label:e,type:this.getTargetType(g,t),task:g,cache:a!==!1,cwd:s,depSpecs:o??i??[],dependencies:[],dependents:[],inputs:c,outputs:u,priority:l,maxWorkers:d,environmentGlob:h,weight:1,options:n};return k.weight=(0,_t.getWeight)(k,m,d),k}constructor(e){kt(this,"options",void 0),kt(this,"packageScripts",void 0),this.options=e,this.packageScripts=new Set;let{packageInfos:t}=e;for(let s of Object.values(t))for(let n of Object.keys(s.scripts??{}))this.packageScripts.add(n)}}});var wt=f(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Object.defineProperty(Oe,"WorkspaceTargetGraphBuilder",{enumerable:!0,get:function(){return We}});var Nr=lt(),B=W(),Ar=ht(),jr=Cr(require("path")),Fr=ve(),$r=Te();function R(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Cr(r){return r&&r.__esModule?r:{default:r}}var We=class{addTargetConfig(e,t={}){if(e.startsWith("//")||e.startsWith("#")){let s=this.targetFactory.createGlobalTarget(e,t);this.graphBuilder.addTarget(s),this.hasRootTarget=!0}else if(e.includes("#")){let{packageName:s,task:n}=(0,B.getPackageAndTask)(e),i=this.targetFactory.createPackageTarget(s,n,t);this.graphBuilder.addTarget(i)}else{let s=Object.keys(this.packageInfos);for(let n of s){let i=e,o=this.targetFactory.createPackageTarget(n,i,t);this.graphBuilder.addTarget(o)}}}build(e,t){let s=(0,Ar.expandDepSpecs)(this.graphBuilder.targets,this.dependencyMap);for(let[o,a]of s)this.graphBuilder.addDependency(o,a);let n=[];for(let o of e){if(t)for(let a of t)n.push((0,B.getTargetId)(a,o));else for(let a of Object.keys(this.packageInfos))n.push((0,B.getTargetId)(a,o));if(this.hasRootTarget){let a=(0,B.getTargetId)(void 0,o);this.graphBuilder.targets.has(a)&&n.push(a)}}return{targets:this.graphBuilder.subgraph(n).targets}}constructor(e,t){R(this,"packageInfos",void 0),R(this,"dependencyMap",void 0),R(this,"graphBuilder",void 0),R(this,"targetFactory",void 0),R(this,"hasRootTarget",void 0),this.packageInfos=t,this.hasRootTarget=!1,this.dependencyMap=(0,Nr.createDependencyMap)(t,{withDevDependencies:!0,withPeerDependencies:!1}),this.graphBuilder=new Fr.TargetGraphBuilder,this.targetFactory=new $r.TargetFactory({root:e,packageInfos:t,resolve(s){try{return jr.default.dirname(t[s].packageJsonPath)}catch{throw new Error(`Cannot open package.json file for ${s}`)}}})}}});var vt=f(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Object.defineProperty(Se,"removeNodes",{enumerable:!0,get:function(){return Lr}});async function Lr(r,e){let t=new Map;r.forEach(n=>t.set(n.id,n));let s=new Map;for(let n of r)if(await e(n)){t.delete(n.id);for(let o of n.dependencies)s.has(n.id)||s.set(n.id,new Set),s.get(n.id).add(o)}for(let n of t.values()){let i=new Set(n.dependencies);for(let o of n.dependencies)s.has(o)&&s.get(o).forEach(a=>i.add(a));n.dependencies=Array.from(i).filter(o=>t.has(o))}return Array.from(t.values())}});var Pt=f(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Object.defineProperty(Re,"transitiveReduction",{enumerable:!0,get:function(){return Br}});function Br(r){let e=new Map,t=new Map;r.forEach(i=>{e.set(i.id,i),t.set(i.id,new Map),i.dependencies.forEach(o=>{t.get(i.id).set(o,!0)})});function s(i,o,a){var l;if(i===o)return!0;if(a.has(i))return!1;if(a.add(i),(l=t.get(i))!=null&&l.has(o))return t.get(i).get(o);let c=e.get(i);if(!c)return!1;let u=c.dependencies.some(d=>s(d,o,a));return t.get(i).set(o,u),u}return r.map(i=>({...i,dependencies:i.dependencies.filter(o=>{let a=new Set;return!i.dependencies.some(c=>c!==o&&s(c,o,a))})}))}});var bt=f(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});function Gr(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}Gr(qe,{sortTargetsByPriority:function(){return Ur.sortTargetsByPriority},getTargetId:function(){return Ie.getTargetId},getStartTargetId:function(){return Ie.getStartTargetId},getPackageAndTask:function(){return Ie.getPackageAndTask},detectCycles:function(){return Kr.detectCycles},WorkspaceTargetGraphBuilder:function(){return zr.WorkspaceTargetGraphBuilder},TargetGraphBuilder:function(){return Hr.TargetGraphBuilder},TargetFactory:function(){return Xr.TargetFactory},removeNodes:function(){return Jr.removeNodes},transitiveReduction:function(){return Vr.transitiveReduction}});var Ur=dt(),Ie=W(),Kr=he(),zr=wt(),Hr=ve(),Xr=Te(),Jr=vt(),Vr=Pt()});var Tt=f(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Object.defineProperty(Ee,"TargetRunnerPicker",{enumerable:!0,get:function(){return xe}});var Mt=en(require("path")),Yr=bt(),Qr=require("url");function Zr(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function en(r){return r&&r.__esModule?r:{default:r}}var xe=class{async pick(e){if(e.id===(0,Yr.getStartTargetId)())return new(await Promise.resolve().then(()=>At(de()))).NoOpRunner;if(e.type||(e.type="npmScript"),this.options[e.type]){let t=this.options[e.type],{script:s,options:n}=t,i=s;i.startsWith("file://")||(i=(0,Qr.pathToFileURL)(i).toString());let o=await import(i),a=Mt.default.basename(s),c=a.replace(Mt.default.extname(a),""),u=typeof o[c]=="function"?o[c]:typeof o.default=="function"?o.default:typeof o.default[c]=="function"?o.default[c]:o;return new u(n)}throw new Error(`No runner found for target ${e.id}`)}constructor(e){Zr(this,"options",void 0),this.options=e}}});var Wt=f(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});function tn(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}tn(De,{NpmScriptRunner:function(){return rn.NpmScriptRunner},WorkerRunner:function(){return nn.WorkerRunner},NoOpRunner:function(){return sn.NoOpRunner},TargetRunnerPicker:function(){return on.TargetRunnerPicker}});var rn=at(),nn=ct(),sn=de(),on=Tt()});Object.defineProperty(exports,"__esModule",{value:!0});var an=it(),un=Wt(),cn=require("worker_threads");async function dn(r){let{runners:e}=r,t=new un.TargetRunnerPicker(e);return{options:r,runnerPicker:t}}(async()=>{let{runnerPicker:r}=await dn(cn.workerData);async function e(t,s){let n;return n=await(await r.pick(t.target)).run({target:t.target,weight:0,abortSignal:s}),{skipped:!1,hash:void 0,value:n}}(0,an.registerWorker)(e)})(); | ||
"use strict";var jt=Object.create;var Le=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var $t=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Bt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ft(e))!Lt.call(r,s)&&s!==t&&Le(r,s,{get:()=>e[s],enumerable:!(n=Ct(e,s))||n.enumerable});return r};var Gt=(r,e,t)=>(t=r!=null?jt($t(r)):{},Bt(e||!r||!r.__esModule?Le(t,"default",{value:r,enumerable:!0}):t,r));var q=f(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});function Ut(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}Ut(G,{END_MARKER_PREFIX:function(){return Ge},START_MARKER_PREFIX:function(){return Be},endMarker:function(){return Kt},startMarker:function(){return zt}});var Be="## WORKER:START:",Ge="## WORKER:END:";function zt(r){return`${Be}${r}`}function Kt(r){return`${Ge}${r}`}});var Ue=f(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});Object.defineProperty(U,"registerWorker",{enumerable:!0,get:function(){return Ht}});var x=require("worker_threads"),E=q();function Ht(r){var n;(n=x.parentPort)==null||n.on("message",async s=>{let i;switch(s.type){case"start":return i=new AbortController,s.task&&await e(s.id,s.task,i.signal);case"abort":return i==null?void 0:i.abort();case"check-memory-usage":return t(x.parentPort)}});async function e(s,i,o){var u,c;try{process.stdout.write(`${(0,E.startMarker)(s)} | ||
`),process.stderr.write(`${(0,E.startMarker)(s)} | ||
`);let a=await r(i,o);(u=x.parentPort)==null||u.postMessage({type:"status",err:void 0,results:a})}catch(a){(c=x.parentPort)==null||c.postMessage({type:"status",err:a,results:void 0})}finally{process.stdout.write(`${(0,E.endMarker)(s)} | ||
`),process.stderr.write(`${(0,E.endMarker)(s)} | ||
`)}}function t(s){let i={type:"report-memory-usage",memoryUsage:process.memoryUsage().heapUsed};s.postMessage(i)}}});var ze=f(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});Object.defineProperty(z,"createFilteredStreamTransform",{enumerable:!0,get:function(){return Jt}});var Xt=require("stream"),D=q();function Jt(){return new Xt.Transform({transform(e,t,n){let s=e.toString();s.includes(D.START_MARKER_PREFIX)&&(s=s.replace(new RegExp(D.START_MARKER_PREFIX+`[0-9a-z]{64} | ||
`),"")),s.includes(D.END_MARKER_PREFIX)&&(s=s.replace(new RegExp(D.END_MARKER_PREFIX+`[0-9a-z]{64} | ||
`),"")),n(null,s)}})}});var Ke=f(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});Object.defineProperty(H,"TaskInfo",{enumerable:!0,get:function(){return K}});var Qt=require("async_hooks");function Vt(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var K=class extends Qt.AsyncResource{get id(){return this.options.id}get weight(){return this.options.weight}get abortSignal(){return this.options.abortSignal}done(e,t){let{cleanup:n,worker:s,resolve:i,reject:o}=this.options;n&&this.runInAsyncScope(n,null,s),e?this.runInAsyncScope(o,null,e,s):this.runInAsyncScope(i,null,t,s),this.emitDestroy()}constructor(e){super("WorkerPoolTaskInfo"),Vt(this,"options",void 0),this.options=e,e.setup&&this.runInAsyncScope(e.setup,null,e.worker,e.worker.stdout,e.worker.stderr)}}});var st=f(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Object.defineProperty(Y,"ThreadWorker",{enumerable:!0,get:function(){return Q}});var He=ze(),Xe=require("readline"),Je=q(),Yt=require("events"),Qe=require("stream"),Zt=Ke(),er=require("worker_threads"),tr=tt(require("crypto")),rr=tt(require("os"));function Ze(r,e){if(e.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object")}function sr(r,e){return e.get?e.get.call(r):e.value}function nr(r,e,t){if(e.set)e.set.call(r,t);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=t}}function et(r,e,t){if(!e.has(r))throw new TypeError("attempted to "+t+" private field on non-instance");return e.get(r)}function l(r,e){var t=et(r,e,"get");return sr(r,t)}function N(r,e,t){Ze(r,e),e.set(r,t)}function M(r,e,t){var n=et(r,e,"set");return nr(r,n,t),t}function b(r,e,t){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return t}function A(r,e){Ze(r,e),e.add(r)}function O(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function tt(r){return r&&r.__esModule?r:{default:r}}var ir="free",y=new WeakMap,v=new WeakMap,P=new WeakMap,_=new WeakMap,X=new WeakSet,J=new WeakSet,rt=new WeakSet,j=new WeakSet,Q=class extends Yt.EventEmitter{start(e,t){this.status="busy";let{task:n,resolve:s,reject:i,cleanup:o,setup:u}=e;t==null||t.addEventListener("abort",b(this,j,V));let c=tr.default.randomBytes(32).toString("hex");M(this,y,new Zt.TaskInfo({id:c,weight:e.weight,cleanup:o,resolve:s,reject:i,worker:this,setup:u,abortSignal:t})),l(this,v).promise=new Promise(a=>{l(this,v).resolve=a}),l(this,P).promise=new Promise(a=>{l(this,P).resolve=a}),l(this,_).postMessage({type:"start",task:{...n,weight:e.weight},id:c})}get weight(){var e;return((e=l(this,y))==null?void 0:e.weight)??1}get stdout(){return l(this,v).stream}get stderr(){return l(this,P).stream}get resourceLimits(){return l(this,_).resourceLimits}get threadId(){return l(this,_).threadId}terminate(){l(this,_).removeAllListeners(),l(this,_).terminate(),l(this,_).unref()}restart(){this.restarts++,this.status="busy",l(this,_).terminate(),b(this,X,Ve).call(this)}async checkMemoryUsage(){l(this,_).postMessage({type:"check-memory-usage"})}postMessage(e,t){l(this,_).postMessage(e,t)}constructor(e,t){super(),A(this,X),A(this,J),A(this,rt),A(this,j),O(this,"script",void 0),O(this,"options",void 0),N(this,y,{writable:!0,value:void 0}),N(this,v,{writable:!0,value:void 0}),N(this,P,{writable:!0,value:void 0}),N(this,_,{writable:!0,value:void 0}),O(this,"status",void 0),O(this,"restarts",void 0),O(this,"maxWorkerMemoryUsage",void 0),this.script=e,this.options=t,M(this,v,{stream:new Qe.Readable,promise:Promise.resolve(),resolve:()=>{}}),M(this,P,{stream:new Qe.Readable,promise:Promise.resolve(),resolve:()=>{}}),this.status="busy",this.restarts=0,this.maxWorkerMemoryUsage=0,b(this,X,Ve).call(this)}};function Ve(){let{workerOptions:r}=this.options,e=this.script,t=new er.Worker(e,{...r,stdout:!0,stderr:!0});b(this,rt,or).call(this,t);let n=t.stdout.pipe((0,He.createFilteredStreamTransform)()),s=t.stderr.pipe((0,He.createFilteredStreamTransform)()),i=()=>{},o=new Promise(d=>{i=d,d()}),u=()=>{},c=new Promise(d=>{u=d,d()}),a=d=>{if(d.type==="status")Promise.all([l(this,v).promise,l(this,P).promise]).then(()=>{var g;let{err:h,results:m}=d;l(this,y)&&((g=l(this,y).abortSignal)==null||g.removeEventListener("abort",b(this,j,V)),l(this,y).done(h,m)),this.checkMemoryUsage()});else if(d.type==="report-memory-usage"){this.maxWorkerMemoryUsage=Math.max(this.maxWorkerMemoryUsage,d.memoryUsage);let h=this.options.workerIdleMemoryLimit??rr.default.totalmem();h&&d.memoryUsage>h?this.restart():b(this,J,Ye).call(this)}else this.emit("message",d)};t.on("message",a);let p=d=>{var h;l(this,v).resolve(),l(this,P).resolve(),l(this,y)?((h=l(this,y).abortSignal)==null||h.removeEventListener("abort",b(this,j,V)),l(this,y).done(d,null)):this.emit("error",d)};t.on("error",p),M(this,_,t),M(this,v,{stream:n,promise:o,resolve:i}),M(this,P,{stream:s,promise:c,resolve:u}),b(this,J,Ye).call(this)}function Ye(){let r=1;l(this,y)&&(r=l(this,y).weight,M(this,y,void 0)),this.status="free",this.emit(ir,{weight:r})}function or(r){let e=r.stdout,t=(0,Xe.createInterface)({input:e,crlfDelay:1/0}),n=r.stderr,s=(0,Xe.createInterface)({input:n,crlfDelay:1/0}),i=c=>{let a=[],p;return d=>{l(this,y)&&(d.includes((0,Je.startMarker)(l(this,y).id))?(a=[],c==="stdout"?p=l(this,v).resolve:p=l(this,P).resolve):d.includes((0,Je.endMarker)(l(this,y).id))?p():a.push(d))}},o=i("stdout"),u=i("stderr");t.on("line",o),s.on("line",u)}function V(){l(this,_)&&l(this,_).postMessage({type:"abort"})}});var te=f(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});Object.defineProperty(ee,"WorkerPool",{enumerable:!0,get:function(){return Z}});var ar=require("events"),ur=st(),cr=dr(require("os"));function T(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function dr(r){return r&&r.__esModule?r:{default:r}}var nt="free",Z=class extends ar.EventEmitter{get workerRestarts(){return this.workers.reduce((e,t)=>e+t.restarts,0)}get maxWorkerMemoryUsage(){return this.workers.reduce((e,t)=>Math.max(e,t.maxWorkerMemoryUsage),0)}stats(){return{maxWorkerMemoryUsage:this.maxWorkerMemoryUsage,workerRestarts:this.workerRestarts}}createInitialWorkers(){if(this.workers.length===0)for(let e=0;e<this.minWorkers;e++)this.addNewWorker()}addNewWorker(){if(this.workers.length<=this.maxWorkers){let{script:e,workerOptions:t}=this.options,n=new ur.ThreadWorker(e,{workerOptions:t,workerIdleMemoryLimit:this.options.workerIdleMemoryLimit});return n.on("free",s=>{let{weight:i}=s;this.availability+=i,this.emit(nt)}),this.workers.push(n),n}}exec(e,t,n,s,i){return i!=null&&i.aborted?Promise.resolve():(t=Math.min(Math.max(1,t),this.maxWorkers),new Promise((o,u)=>{this.queue.push({task:{...e,weight:t},weight:t,resolve:o,reject:u,cleanup:s,setup:n}),this._exec(i)}))}_exec(e){let t=this.queue.findIndex(s=>s.weight<=this.availability);if(t===-1)return;let n=this.workers.find(s=>s.status==="free");if(n||(n=this.addNewWorker()),n){let s=this.queue[t];this.queue.splice(t,1),this.availability-=s.weight,n.start(s,e)}}async close(){await Promise.all(this.workers.map(e=>e.terminate()))}constructor(e){super(),T(this,"options",void 0),T(this,"workers",void 0),T(this,"freeWorkers",void 0),T(this,"queue",void 0),T(this,"minWorkers",void 0),T(this,"maxWorkers",void 0),T(this,"availability",void 0),this.options=e,this.workers=[],this.freeWorkers=[],this.queue=[],this.minWorkers=0,this.maxWorkers=0,this.availability=0,this.minWorkers=this.options.minWorkers??2,this.maxWorkers=this.options.maxWorkers??cr.default.cpus().length-1,this.availability=this.maxWorkers,this.workers=[],this.freeWorkers=[],this.queue=[],this.createInitialWorkers(),this.on(nt,()=>{this.queue.length>0?this._exec():this.workers.every(t=>t.status==="free")&&this.emit("idle")})}}});var ot=f(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});Object.defineProperty(ne,"AggregatedPool",{enumerable:!0,get:function(){return se}});var it=te();function re(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var se=class{stats(){return[...this.groupedPools.values(),this.defaultPool].reduce((t,n)=>{if(n){let s=n.stats();t.maxWorkerMemoryUsage=Math.max(t.maxWorkerMemoryUsage,s.maxWorkerMemoryUsage),t.workerRestarts=t.workerRestarts+s.workerRestarts}return t},{maxWorkerMemoryUsage:0,workerRestarts:0})}async exec(e,t,n,s,i){let o=this.options.groupBy(e),u=this.groupedPools.get(o)??this.defaultPool;if(!u)throw new Error(`No pool found to be able to run ${o} tasks, try adjusting the maxWorkers & concurrency values`);return u.exec(e,t,n,s,i)}async close(){let e=[...this.groupedPools.values(),this.defaultPool].map(t=>t==null?void 0:t.close());return Promise.all(e)}constructor(e){re(this,"options",void 0),re(this,"groupedPools",void 0),re(this,"defaultPool",void 0),this.options=e,this.groupedPools=new Map;let{maxWorkers:t,maxWorkersByGroup:n,script:s,workerOptions:i}=e,o=0;for(let[c,a]of n.entries()){let p=new it.WorkerPool({maxWorkers:a,workerOptions:i,script:s,workerIdleMemoryLimit:e.workerIdleMemoryLimit});this.groupedPools.set(c,p),o+=a}if(o>t)throw new Error(`Total maxWorkers (${o}) configured across all groups exceeds concurrency (${t}). Try reducing the maxWorkers, or increasing the --concurrency CLI argument, or separate the tasks to be run`);let u=t-o;u>0&&(this.defaultPool=new it.WorkerPool({maxWorkers:u,workerOptions:i,script:s,workerIdleMemoryLimit:e.workerIdleMemoryLimit})),this.options.logger.verbose(`Workers pools created: ${[...n.entries(),["default",u]].map(([c,a])=>`${c} (${a})`).join(", ")}`)}}});var at=f(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});function pr(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}pr(ie,{AggregatedPool:function(){return hr.AggregatedPool},WorkerPool:function(){return fr.WorkerPool},registerWorker:function(){return lr.registerWorker}});var lr=Ue(),fr=te(),hr=ot()});var ct=f(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});Object.defineProperty(oe,"NpmScriptRunner",{enumerable:!0,get:function(){return C}});var gr=require("path"),mr=require("fs/promises"),yr=require("child_process"),_r=wr(require("os"));function ut(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function wr(r){return r&&r.__esModule?r:{default:r}}var C=class r{getNpmArgs(e,t){let n=t.length>0?["--",...t]:[];return["run",e,...n]}async hasNpmScript(e){var i,o;let t=((i=e.options)==null?void 0:i.script)??e.task,n=(0,gr.join)(e.cwd,"package.json");return!!((o=JSON.parse(await(0,mr.readFile)(n,"utf8")).scripts)!=null&&o[t])}async shouldRun(e){return await this.hasNpmScript(e)&&(e.shouldRun??!0)}async run(e){var h,m;let{target:t,weight:n,abortSignal:s}=e,{nodeOptions:i,npmCmd:o,taskArgs:u}=this.options,c=((h=t.options)==null?void 0:h.script)??t.task,a;if(s){if(s.aborted)return;let g=()=>{if(s.removeEventListener("abort",g),a&&!a.killed){let w=a.pid;process.stdout.write(`Abort signal detected, attempting to killing process id ${w} | ||
`),a.kill("SIGTERM");let k=setTimeout(()=>{a&&!a.killed&&a.kill("SIGKILL")},r.gracefulKillTimeout);k.unref&&k.unref()}};s.addEventListener("abort",g)}let p=this.getNpmArgs(c,u),d=[i,(m=t.options)==null?void 0:m.nodeOptions].filter(g=>g).join(" ");await new Promise((g,w)=>{a=(0,yr.spawn)(o,p,{cwd:t.cwd,stdio:["inherit","pipe","pipe"],..._r.default.platform()==="win32"&&{shell:!0},env:{...process.stdout.isTTY&&{FORCE_COLOR:"1"},...process.env,...d&&{NODE_OPTIONS:d},LAGE_PACKAGE_NAME:t.packageName,LAGE_TASK:t.task,LAGE_WEIGHT:String(n)}});let k=!1,I=je=>{var Ce,Fe,$e;if(a==null||a.off("exit",I),a==null||a.off("error",I),!k){if(k=!0,(Ce=a==null?void 0:a.stdout)==null||Ce.destroy(),(Fe=a==null?void 0:a.stderr)==null||Fe.destroy(),($e=a==null?void 0:a.stdin)==null||$e.destroy(),je===0)return g();w(new Error(`NPM Script Runner: ${o} ${p.join(" ")} exited with code ${je}`))}},{pid:Dt}=a;process.stdout.write(`Running ${[o,...p].join(" ")}, pid: ${Dt} | ||
`);let Nt=a.stdout,At=a.stderr;Nt.pipe(process.stdout),At.pipe(process.stderr),a.on("exit",I),a.on("error",()=>I(1))})}constructor(e){ut(this,"options",void 0),this.options=e}};ut(C,"gracefulKillTimeout",2500)});var pt=f(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});Object.defineProperty(ae,"WorkerRunner",{enumerable:!0,get:function(){return F}});var kr=require("url");function dt(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var F=class{async shouldRun(e){let t=await this.getScriptModule(e);return typeof t.shouldRun=="function"?await t.shouldRun(e)&&(e.shouldRun??!0):e.shouldRun??!0}async run(e){let{target:t,weight:n,abortSignal:s}=e,{taskArgs:i}=this.options,o=await this.getScriptModule(t),u=typeof o.run=="function"?o.run:typeof o.default=="function"?o.default:o;if(typeof u!="function")throw new Error("WorkerRunner: worker script must export a function; you likely need to use `module.exports = function() {...}`");return await u({target:t,weight:n,taskArgs:i,abortSignal:s})}async getScriptModule(e){var s,i;let t=((s=e.options)==null?void 0:s.worker)??((i=e.options)==null?void 0:i.script);if(!t)throw new Error('WorkerRunner: "script" configuration is required - e.g. { type: "worker", script: "./worker.js" }');let n=t;return n.startsWith("file://")||(n=(0,kr.pathToFileURL)(n).toString()),await import(n)}constructor(e){dt(this,"options",void 0),this.options=e}};dt(F,"gracefulKillTimeout",2500)});var de=f(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});Object.defineProperty(ce,"NoOpRunner",{enumerable:!0,get:function(){return ue}});var ue=class{async shouldRun(){return!0}async run(){}}});var lt=f(pe=>{"use strict";Object.defineProperty(pe,"__esModule",{value:!0});Object.defineProperty(pe,"sortTargetsByPriority",{enumerable:!0,get:function(){return vr}});function vr(r){return r.sort((e,t)=>(t.priority??0)-(e.priority??0))}});var W=f(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});function Pr(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}Pr(le,{getPackageAndTask:function(){return Mr},getStartTargetId:function(){return Wr},getTargetId:function(){return br}});function br(r,e){return`${typeof r=="string"?r:""}#${e}`}function Mr(r){if(r.includes("#")){let e=r.split("#");return r.startsWith("#")||e[0]==="//"?{packageName:void 0,task:e[1]}:{packageName:e[0],task:e[1]}}else return{packageName:void 0,task:r}}var Tr="__start";function Wr(){return Tr}});var he=f(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});Object.defineProperty(fe,"detectCycles",{enumerable:!0,get:function(){return Rr}});function Rr(r){let e=new Map;for(let[t]of r.entries())if(!e.has(t)){let n=Or(r,e,t);if(n.length>0)return{hasCycle:!0,cycle:n}}return{hasCycle:!1}}var Or=(r,e,t)=>{let n=[{node:t,traversing:!1}];for(;n.length>0;){let s=n[n.length-1];if(s.traversing)e.set(s.node,!1),n.pop();else{if(e.has(s.node))if(e.get(s.node)){let o=n.filter(u=>u.traversing).map(u=>u.node);return o.slice(o.indexOf(s.node))}else{n.pop();continue}e.set(s.node,!0),n[n.length-1]={...s,traversing:!0};let i=r.get(s.node);if(!i)throw new Error(`Could not find node "${s.node}" in the graph`);n.push(...[...i.dependents].map(o=>({node:o,traversing:!1})))}}return[]}});var ft=f($=>{"use strict";Object.defineProperty($,"__esModule",{value:!0});$.getPackageDependencies=void 0;function Sr(r,e){var n,s,i;let t=((n=r.dependencies)==null?void 0:n[e])||((s=r.devDependencies)==null?void 0:s[e])||((i=r.peerDependencies)==null?void 0:i[e]);return t?!t.startsWith("npm:")&&!t.startsWith("file:"):!1}function Ir(r,e,t={withDevDependencies:!0}){let n=[];if(r.dependencies)for(let i of Object.keys(r.dependencies))i!==r.name&&e.has(i)&&n.push(i);if(r.devDependencies&&t.withDevDependencies)for(let i of Object.keys(r.devDependencies))i!==r.name&&e.has(i)&&n.push(i);if(r.peerDependencies&&t.withPeerDependencies)for(let i of Object.keys(r.peerDependencies))i!==r.name&&e.has(i)&&n.push(i);return n.filter(i=>Sr(r,i))}$.getPackageDependencies=Ir});var ht=f(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.createDependencyMap=void 0;var qr=ft();function xr(r,e={withDevDependencies:!0,withPeerDependencies:!1}){let t={dependencies:new Map,dependents:new Map},n=new Set(Object.keys(r));for(let[s,i]of Object.entries(r)){let o=(0,qr.getPackageDependencies)(i,n,e);for(let u of o)t.dependencies.has(s)||t.dependencies.set(s,new Set),t.dependencies.get(s).add(u),t.dependents.has(u)||t.dependents.set(u,new Set),t.dependents.get(u).add(s)}return t}L.createDependencyMap=xr});var mt=f(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});Object.defineProperty(me,"expandDepSpecs",{enumerable:!0,get:function(){return Er}});var S=W();function Er(r,e){let t=[],n=(o,u)=>{t.push([o,u])},s=(o,u)=>u?i.filter(c=>{let{task:a,packageName:p}=c;return a===o&&u.some(d=>d===p)}).map(c=>c.id):i.filter(c=>c.task===o).map(c=>c.id),i=[...r.values()];for(let o of i){let{depSpecs:u,packageName:c,id:a}=o;if(t.push([(0,S.getStartTargetId)(),a]),!(!u||u.length===0))for(let p of u)if(p.includes("#")){let{packageName:d,task:h}=(0,S.getPackageAndTask)(p),m=(0,S.getTargetId)(d,h);n(m,a)}else if(p.startsWith("^^")&&c){let d=p.substring(2),h=[...gt(c,e)??[]],m=s(d,h);for(let g of m)n(g,a)}else if(p.startsWith("^")&&c){let d=p.substring(1),h=[...e.dependencies.get(c)??[]],m=s(d,h);for(let g of m)n(g,a)}else if(c){let d=p;r.has((0,S.getTargetId)(c,d))&&n((0,S.getTargetId)(c,d),a)}else{if(p.startsWith("^"))throw new Error(`invalid pipeline config detected: ${o.id}, packageName: ${c}, dep: ${p}`);{let h=s(p);for(let m of h)n(m,a)}}}return t}var ge=new Map;function gt(r,e){let t=ge.get(r);if(t)return t==="walk-in-progress"?new Set:t;{ge.set(r,"walk-in-progress");let n=[...e.dependencies.get(r)??[]],s=new Set(n);for(let i of n)for(let o of gt(i,e))s.add(o);return ge.set(r,s),s}}});var yt=f(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});Object.defineProperty(ye,"prioritize",{enumerable:!0,get:function(){return jr}});function Dr(r){let e=[];for(let[t,n]of r)n.dependencies.length===0&&e.push(t);return e}function Nr(r){return new Map([...r.entries()].map(([e,t])=>[e,new Set(t.dependencies)]))}function Ar(r,e){let t=[],n=Nr(r),s=[...e];for(;s.length>0;){let i=s.pop();t.push(i),r.get(i).dependents.forEach(u=>{let c=n.get(u);c.delete(i),c.size===0&&s.push(u)})}return t}function jr(r){let e=new Map,t=Dr(r),n=Ar(r,t);for(let s of n){let i=r.get(s),o=i.priority||0,u=i.dependencies.map(p=>{let d=e.get(p);if(d===void 0)throw new Error(`Expected to have already computed the cumulative priority for node ${p}`);return d}),c=Math.max(...u,0),a=o+c;e.set(s,a)}for(let s of r.values()){let i=e.get(s.id);if(i===void 0)throw new Error(`Expected to have already computed the cumulative priority for node ${s.id}`);s.priority=i}}});var ve=f(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});Object.defineProperty(ke,"TargetGraphBuilder",{enumerable:!0,get:function(){return we}});var _e=W(),Cr=yt(),Fr=he();function $r(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var we=class r{addTarget(e){return this.targets.set(e.id,e),this.addDependency((0,_e.getStartTargetId)(),e.id),e}addDependency(e,t){if(this.targets.has(t)){let n=this.targets.get(t);n.dependencies.includes(e)||n.dependencies.push(e)}if(this.targets.has(e)){let n=this.targets.get(e);n.dependents.includes(t)||n.dependents.push(t)}}build(){let e=(0,Fr.detectCycles)(this.targets);if(e.hasCycle)throw new Error("Cycles detected in the target graph: "+e.cycle.concat(e.cycle[0]).join(" -> "));return(0,Cr.prioritize)(this.targets),{targets:this.targets}}subgraph(e){let t=new r,n=new Set,s=[];for(let i of e)if(this.targets.has(i)){let o=this.targets.get(i);t.addTarget({...o,dependencies:[],dependents:[]}),s.push(i)}for(;s.length>0;){let i=s.shift();if(n.has(i))continue;n.add(i);let o=this.targets.get(i);if(!o)throw new Error("Subgraph builder failed - target not found: "+i);for(let u of o.dependencies)u!==(0,_e.getStartTargetId)()&&(t.targets.has(u)||t.addTarget({...this.targets.get(u),dependencies:[],dependents:[]}),t.addDependency(u,i)),n.has(u)||s.push(u)}return t.build()}constructor(){$r(this,"targets",new Map);let e=(0,_e.getStartTargetId)();this.targets.set(e,{id:e,task:e,cwd:"",label:"Start",hidden:!0,dependencies:[],dependents:[],depSpecs:[],weight:1,priority:0})}}});var _t=f(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Object.defineProperty(Pe,"getWeight",{enumerable:!0,get:function(){return Lr}});function Lr(r,e,t){return typeof e=="number"?e:typeof e=="function"?e(r,t):1}});var Te=f(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Object.defineProperty(Me,"TargetFactory",{enumerable:!0,get:function(){return be}});var wt=W(),kt=_t();function vt(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var be=class{getTargetType(e,t){return t.type?t.type:this.packageScripts.has(e)?"npmScript":"noop"}createPackageTarget(e,t,n){let{resolve:s}=this.options,{options:i,deps:o,dependsOn:u,cache:c,inputs:a,priority:p,maxWorkers:d,environmentGlob:h,weight:m}=n,g=s(e),w=this.getTargetType(t,n),k={id:(0,wt.getTargetId)(e,t),label:`${e} - ${t}`,type:w,packageName:e,task:t,cache:c!==!1,cwd:g,depSpecs:u??o??[],dependencies:[],dependents:[],inputs:a,outputs:w==="noop"?[]:n.outputs,priority:p,maxWorkers:d,environmentGlob:h,weight:1,options:i,shouldRun:!0};return k.weight=(0,kt.getWeight)(k,m,d),k}createGlobalTarget(e,t){let{root:n}=this.options,{options:s,deps:i,dependsOn:o,cache:u,inputs:c,outputs:a,priority:p,maxWorkers:d,environmentGlob:h,weight:m}=t,{task:g}=(0,wt.getPackageAndTask)(e),w={id:e,label:e,type:this.getTargetType(g,t),task:g,cache:u!==!1,cwd:n,depSpecs:o??i??[],dependencies:[],dependents:[],inputs:c,outputs:a,priority:p,maxWorkers:d,environmentGlob:h,weight:1,options:s,shouldRun:!0};return w.weight=(0,kt.getWeight)(w,m,d),w}constructor(e){vt(this,"options",void 0),vt(this,"packageScripts",void 0),this.options=e,this.packageScripts=new Set;let{packageInfos:t}=e;for(let n of Object.values(t))for(let s of Object.keys(n.scripts??{}))this.packageScripts.add(s)}}});var bt=f((Ls,Pt)=>{var We=class{constructor(e){this.value=e,this.next=void 0}},Re=class{constructor(){this.clear()}enqueue(e){let t=new We(e);this._head?(this._tail.next=t,this._tail=t):(this._head=t,this._tail=t),this._size++}dequeue(){let e=this._head;if(e)return this._head=this._head.next,this._size--,e.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let e=this._head;for(;e;)yield e.value,e=e.next}};Pt.exports=Re});var Tt=f((Bs,Mt)=>{"use strict";var Br=bt(),Gr=r=>{if(!((Number.isInteger(r)||r===1/0)&&r>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let e=new Br,t=0,n=()=>{t--,e.size>0&&e.dequeue()()},s=async(u,c,...a)=>{t++;let p=(async()=>u(...a))();c(p);try{await p}catch{}n()},i=(u,c,...a)=>{e.enqueue(s.bind(null,u,c,...a)),(async()=>(await Promise.resolve(),t<r&&e.size>0&&e.dequeue()()))()},o=(u,...c)=>new Promise(a=>{i(u,a,...c)});return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o};Mt.exports=Gr});var Rt=f(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Object.defineProperty(Se,"WorkspaceTargetGraphBuilder",{enumerable:!0,get:function(){return Oe}});var Ur=ht(),B=W(),zr=mt(),Kr=Wt(require("path")),Hr=ve(),Xr=Te(),Jr=Wt(Tt());function R(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Wt(r){return r&&r.__esModule?r:{default:r}}var Oe=class{async addTargetConfig(e,t={}){if(e.startsWith("//")||e.startsWith("#")){let n=this.targetFactory.createGlobalTarget(e,t);this.graphBuilder.addTarget(n),this.targetConfigMap.set(e,t),this.hasRootTarget=!0}else if(e.includes("#")){let{packageName:n,task:s}=(0,B.getPackageAndTask)(e),i=this.targetFactory.createPackageTarget(n,s,t);this.graphBuilder.addTarget(i),this.targetConfigMap.set(e,t)}else{let n=Object.keys(this.packageInfos);for(let s of n){let i=e,o=this.targetFactory.createPackageTarget(s,i,t);this.graphBuilder.addTarget(o),this.targetConfigMap.set(e,t)}}}shouldRun(e,t){return typeof e.shouldRun=="function"?e.shouldRun(t):!0}async build(e,t){let n=(0,zr.expandDepSpecs)(this.graphBuilder.targets,this.dependencyMap);for(let[c,a]of n)this.graphBuilder.addDependency(c,a);let s=[];for(let c of e){if(t)for(let a of t)s.push((0,B.getTargetId)(a,c));else for(let a of Object.keys(this.packageInfos))s.push((0,B.getTargetId)(a,c));if(this.hasRootTarget){let a=(0,B.getTargetId)(void 0,c);this.graphBuilder.targets.has(a)&&s.push(a)}}let i=this.graphBuilder.subgraph(s),o=(0,Jr.default)(8),u=[];for(let c of i.targets.values()){let a=this.targetConfigMap.get(c.id);a&&u.push(o(async()=>{c.shouldRun=await this.shouldRun(a,c)}))}return await Promise.all(u),{targets:i.targets}}constructor(e,t){R(this,"packageInfos",void 0),R(this,"dependencyMap",void 0),R(this,"graphBuilder",void 0),R(this,"targetFactory",void 0),R(this,"hasRootTarget",void 0),R(this,"targetConfigMap",void 0),this.packageInfos=t,this.hasRootTarget=!1,this.targetConfigMap=new Map,this.dependencyMap=(0,Ur.createDependencyMap)(t,{withDevDependencies:!0,withPeerDependencies:!1}),this.graphBuilder=new Hr.TargetGraphBuilder,this.targetFactory=new Xr.TargetFactory({root:e,packageInfos:t,resolve(n){try{return Kr.default.dirname(t[n].packageJsonPath)}catch{throw new Error(`Cannot open package.json file for ${n}`)}}})}}});var Ot=f(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Object.defineProperty(Ie,"removeNodes",{enumerable:!0,get:function(){return Qr}});async function Qr(r,e){let t=new Map;r.forEach(s=>t.set(s.id,s));let n=new Map;for(let s of r)if(await e(s)){t.delete(s.id);for(let o of s.dependencies)n.has(s.id)||n.set(s.id,new Set),n.get(s.id).add(o)}for(let s of t.values()){let i=new Set(s.dependencies);for(let o of s.dependencies)n.has(o)&&n.get(o).forEach(u=>i.add(u));s.dependencies=Array.from(i).filter(o=>t.has(o))}return Array.from(t.values())}});var St=f(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});Object.defineProperty(qe,"transitiveReduction",{enumerable:!0,get:function(){return Vr}});function Vr(r){let e=new Map,t=new Map;r.forEach(i=>{e.set(i.id,i),t.set(i.id,new Map),i.dependencies.forEach(o=>{t.get(i.id).set(o,!0)})});function n(i,o,u){var p;if(i===o)return!0;if(u.has(i))return!1;if(u.add(i),(p=t.get(i))!=null&&p.has(o))return t.get(i).get(o);let c=e.get(i);if(!c)return!1;let a=c.dependencies.some(d=>n(d,o,u));return t.get(i).set(o,a),a}return r.map(i=>({...i,dependencies:i.dependencies.filter(o=>{let u=new Set;return!i.dependencies.some(c=>c!==o&&n(c,o,u))})}))}});var It=f(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});function Yr(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}Yr(Ee,{TargetFactory:function(){return ss.TargetFactory},TargetGraphBuilder:function(){return rs.TargetGraphBuilder},WorkspaceTargetGraphBuilder:function(){return ts.WorkspaceTargetGraphBuilder},detectCycles:function(){return es.detectCycles},getPackageAndTask:function(){return xe.getPackageAndTask},getStartTargetId:function(){return xe.getStartTargetId},getTargetId:function(){return xe.getTargetId},removeNodes:function(){return ns.removeNodes},sortTargetsByPriority:function(){return Zr.sortTargetsByPriority},transitiveReduction:function(){return is.transitiveReduction}});var Zr=lt(),xe=W(),es=he(),ts=Rt(),rs=ve(),ss=Te(),ns=Ot(),is=St()});var xt=f(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Object.defineProperty(Ne,"TargetRunnerPicker",{enumerable:!0,get:function(){return De}});var qt=cs(require("path")),os=It(),as=require("url");function us(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function cs(r){return r&&r.__esModule?r:{default:r}}var De=class{async pick(e){if(e.id===(0,os.getStartTargetId)())return new(await Promise.resolve().then(()=>Gt(de()))).NoOpRunner;if(e.type||(e.type="npmScript"),this.options[e.type]){let t=this.options[e.type],{script:n,options:s}=t,i=n;i.startsWith("file://")||(i=(0,as.pathToFileURL)(i).toString());let o=await import(i),u=qt.default.basename(n),c=u.replace(qt.default.extname(u),""),a=typeof o[c]=="function"?o[c]:typeof o.default=="function"?o.default:typeof o.default[c]=="function"?o.default[c]:o;return new a(s)}throw new Error(`No runner found for target ${e.id}`)}constructor(e){us(this,"options",void 0),this.options=e}}});var Et=f(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});function ds(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}ds(Ae,{NoOpRunner:function(){return fs.NoOpRunner},NpmScriptRunner:function(){return ps.NpmScriptRunner},TargetRunnerPicker:function(){return hs.TargetRunnerPicker},WorkerRunner:function(){return ls.WorkerRunner}});var ps=ct(),ls=pt(),fs=de(),hs=xt()});Object.defineProperty(exports,"__esModule",{value:!0});var gs=at(),ms=Et(),ys=require("worker_threads");async function _s(r){let{runners:e}=r,t=new ms.TargetRunnerPicker(e);return{options:r,runnerPicker:t}}(async()=>{let{runnerPicker:r}=await _s(ys.workerData);async function e(t,n){let s;return s=await(await r.pick(t.target)).run({target:t.target,weight:0,abortSignal:n}),{skipped:!1,hash:void 0,value:s}}(0,gs.registerWorker)(e)})(); | ||
//# sourceMappingURL=singleTargetWorker.js.map |
{ | ||
"name": "lage", | ||
"version": "2.11.11", | ||
"version": "2.11.12", | ||
"repository": { | ||
@@ -26,4 +26,4 @@ "type": "git", | ||
"devDependencies": { | ||
"@lage-run/cli": "^0.23.11", | ||
"@lage-run/runners": "^1.0.7", | ||
"@lage-run/cli": "^0.24.0", | ||
"@lage-run/runners": "^1.1.0", | ||
"backfill-config": "6.4.2", | ||
@@ -30,0 +30,0 @@ "dts-bundle-generator": "^9.5.1", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
29165448
32278