Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lage

Package Overview
Dependencies
Maintainers
0
Versions
276
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lage - npm Package Compare versions

Comparing version 2.11.15 to 2.12.0

46

dist/index.d.ts

@@ -170,4 +170,50 @@

options?: Record<string, any>;
/**
* An optionally async function that determines whether a target should run or not.
*/
shouldRun?: (target: Target) => boolean | Promise<boolean>;
/**
* Whether this task is one that can be run as a task that runs over a list of git staged files
* e.g. `lage run --since origin/master`, when encountering this task, it'll add this single task into the graph instead of
* package tasks.
*/
stagedTarget?: StagedTargetConfig;
}
interface StagedTargetConfig {
/**
* The type of the target - The configuration parser will use the id of the target to determine the type.
* e.g. npmScript, worker
*/
type?: string;
/**
* The dependencies of the target. Dependencies are target specs in one of these forms:
* - "pkg-a#build"
* - "build"
* - "^build"
* - "^^build"
*/
dependsOn?: string[];
/**
* Priority of the target. A priority of >0 will always be prioritized over the default targets in queue
*/
priority?: number;
/**
* Weight of a target - used to determine the number of "worker slots" to dedicate to a target
*
* Even if we have workers "free", we might not want to dedicate them to a target that is very heavy (i.e. takes multiple CPU cores).
* An example is jest targets that can take up multiple cores with its own worker pool.
*
* This weight will be "culled" to the max number of workers (concurrency) for the target type. (i.e. maxWorkers above)
*/
weight?: number | ((target: Target, maxWorkers?: number) => number);
/**
* Run options for the Target Runner. (e.g. `{ env: ...process.env, colors: true, ... }`)
*/
options?: Record<string, any>;
/**
* A threshold of changed files that determines whether a target should run or not. Target will only run if number of changed files
* is below this threshold.
*/
threshold?: number;
}
export interface PipelineDefinition {

@@ -174,0 +220,0 @@ [task: string]: string[] | TargetConfig;

12

dist/runners/NpmScriptRunner.js

@@ -34,6 +34,6 @@ "use strict";

class NpmScriptRunner {
getNpmArgs(task, taskTargs) {
const extraArgs = taskTargs.length > 0 ? [
getNpmArgs(task, taskArgs) {
const extraArgs = taskArgs.length > 0 ? [
"--",
...taskTargs
...taskArgs
] : [];

@@ -93,3 +93,7 @@ return [

* Actually spawn the npm client to run the task
*/ const npmRunArgs = this.getNpmArgs(task, taskArgs);
*/ const args = [
...taskArgs,
...target.options?.taskArgs ?? []
];
const npmRunArgs = this.getNpmArgs(task, args);
const npmRunNodeOptions = [

@@ -96,0 +100,0 @@ nodeOptions,

@@ -1,10 +0,10 @@

"use strict";var Ct=Object.create;var Le=Object.defineProperty;var jt=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,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ft(e))!Lt.call(r,n)&&n!==t&&Le(r,n,{get:()=>e[n],enumerable:!(s=jt(e,n))||s.enumerable});return r};var Gt=(r,e,t)=>(t=r!=null?Ct($t(r)):{},Bt(e||!r||!r.__esModule?Le(t,"default",{value:r,enumerable:!0}):t,r));var q=f(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});function Ut(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}Ut(U,{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(z=>{"use strict";Object.defineProperty(z,"__esModule",{value:!0});Object.defineProperty(z,"registerWorker",{enumerable:!0,get:function(){return Ht}});var D=require("worker_threads"),E=q();function Ht(r){var s;(s=D.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(D.parentPort)}});async function e(n,i,o){var u,c;try{process.stdout.write(`${(0,E.startMarker)(n)}
`),process.stderr.write(`${(0,E.startMarker)(n)}
`);let a=await r(i,o);(u=D.parentPort)==null||u.postMessage({type:"status",err:void 0,results:a})}catch(a){(c=D.parentPort)==null||c.postMessage({type:"status",err:a,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 ze=f(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});Object.defineProperty(K,"createFilteredStreamTransform",{enumerable:!0,get:function(){return Jt}});var Xt=require("stream"),N=q();function Jt(){return new Xt.Transform({transform(e,t,s){let n=e.toString();n.includes(N.START_MARKER_PREFIX)&&(n=n.replace(new RegExp(N.START_MARKER_PREFIX+`[0-9a-z]{64}
`),"")),n.includes(N.END_MARKER_PREFIX)&&(n=n.replace(new RegExp(N.END_MARKER_PREFIX+`[0-9a-z]{64}
`),"")),s(null,n)}})}});var Ke=f(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});Object.defineProperty(X,"TaskInfo",{enumerable:!0,get:function(){return H}});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 H=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: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"),Vt(this,"options",void 0),this.options=e,e.setup&&this.runInAsyncScope(e.setup,null,e.worker,e.worker.stdout,e.worker.stderr)}}});var nt=f(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Object.defineProperty(Z,"ThreadWorker",{enumerable:!0,get:function(){return V}});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 nr(r,e){return e.get?e.get.call(r):e.value}function sr(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 nr(r,t)}function A(r,e,t){Ze(r,e),e.set(r,t)}function M(r,e,t){var s=et(r,e,"set");return sr(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 C(r,e){Ze(r,e),e.add(r)}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 tt(r){return r&&r.__esModule?r:{default:r}}var ir="free",y=new WeakMap,v=new WeakMap,P=new WeakMap,_=new WeakMap,J=new WeakSet,Q=new WeakSet,rt=new WeakSet,j=new WeakSet,V=class extends Yt.EventEmitter{start(e,t){this.status="busy";let{task:s,resolve:n,reject:i,cleanup:o,setup:u}=e;t==null||t.addEventListener("abort",b(this,j,Y));let c=tr.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: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:{...s,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,J,Ve).call(this)}async checkMemoryUsage(){l(this,_).postMessage({type:"check-memory-usage"})}postMessage(e,t){l(this,_).postMessage(e,t)}constructor(e,t){super(),C(this,J),C(this,Q),C(this,rt),C(this,j),R(this,"script",void 0),R(this,"options",void 0),A(this,y,{writable:!0,value:void 0}),A(this,v,{writable:!0,value:void 0}),A(this,P,{writable:!0,value:void 0}),A(this,_,{writable:!0,value:void 0}),R(this,"status",void 0),R(this,"restarts",void 0),R(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,J,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 s=t.stdout.pipe((0,He.createFilteredStreamTransform)()),n=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,Y)),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,Q,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,Y)),l(this,y).done(d,null)):this.emit("error",d)};t.on("error",p),M(this,_,t),M(this,v,{stream:s,promise:o,resolve:i}),M(this,P,{stream:n,promise:c,resolve:u}),b(this,Q,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}),s=r.stderr,n=(0,Xe.createInterface)({input:s,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),n.on("line",u)}function Y(){l(this,_)&&l(this,_).postMessage({type:"abort"})}});var re=f(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});Object.defineProperty(te,"WorkerPool",{enumerable:!0,get:function(){return ee}});var ar=require("events"),ur=nt(),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 st="free",ee=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,s=new ur.ThreadWorker(e,{workerOptions:t,workerIdleMemoryLimit:this.options.workerIdleMemoryLimit});return s.on("free",n=>{let{weight:i}=n;this.availability+=i,this.emit(st)}),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,u)=>{this.queue.push({task:{...e,weight:t},weight:t,resolve:o,reject:u,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??cr.default.cpus().length-1,this.availability=this.maxWorkers,this.workers=[],this.freeWorkers=[],this.queue=[],this.createInitialWorkers(),this.on(st,()=>{this.queue.length>0?this._exec():this.workers.every(t=>t.status==="free")&&this.emit("idle")})}}});var ot=f(ie=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});Object.defineProperty(ie,"AggregatedPool",{enumerable:!0,get:function(){return se}});var it=re();function ne(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,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),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,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){ne(this,"options",void 0),ne(this,"groupedPools",void 0),ne(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,a]of s.entries()){let p=new it.WorkerPool({maxWorkers:a,workerOptions:i,script:n,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:n,workerIdleMemoryLimit:e.workerIdleMemoryLimit})),this.options.logger.verbose(`Workers pools created: ${[...s.entries(),["default",u]].map(([c,a])=>`${c} (${a})`).join(", ")}`)}}});var at=f(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});function pr(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}pr(oe,{AggregatedPool:function(){return hr.AggregatedPool},WorkerPool:function(){return fr.WorkerPool},registerWorker:function(){return lr.registerWorker}});var lr=Ue(),fr=re(),hr=ot()});var ct=f(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});Object.defineProperty(ae,"NpmScriptRunner",{enumerable:!0,get:function(){return F}});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 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,gr.join)(e.cwd,"package.json");return!!((o=JSON.parse(await(0,mr.readFile)(s,"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:s,abortSignal:n}=e,{nodeOptions:i,npmCmd:o,taskArgs:u}=this.options,c=((h=t.options)==null?void 0:h.script)??t.task,a;if(n){if(n.aborted)return{exitCode:1};let g=()=>{if(n.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()}};n.addEventListener("abort",g)}let p=this.getNpmArgs(c,u),d=[i,(m=t.options)==null?void 0:m.nodeOptions].filter(g=>g).join(" ");return 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(s)}});let k=!1,x=I=>{var je,Fe,$e;if(a==null||a.off("exit",x),a==null||a.off("error",x),!k){if(k=!0,(je=a==null?void 0:a.stdout)==null||je.destroy(),(Fe=a==null?void 0:a.stderr)==null||Fe.destroy(),($e=a==null?void 0:a.stdin)==null||$e.destroy(),I===0)return g({exitCode:I});w({exitCode:I,error:new Error(`NPM Script Runner: ${o} ${p.join(" ")} exited with code ${I}`)})}},{pid:Et}=a;process.stdout.write(`Running ${[o,...p].join(" ")}, pid: ${Et}
`);let Nt=a.stdout,At=a.stderr;Nt.pipe(process.stdout),At.pipe(process.stderr),a.on("exit",x),a.on("error",()=>x(1))})}constructor(e){ut(this,"options",void 0),this.options=e}};ut(F,"gracefulKillTimeout",2500)});var pt=f(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});Object.defineProperty(ue,"WorkerRunner",{enumerable:!0,get:function(){return $}});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 $=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:s,abortSignal:n}=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: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,kr.pathToFileURL)(s).toString()),await import(s)}constructor(e){dt(this,"options",void 0),this.options=e}};dt($,"gracefulKillTimeout",2500)});var pe=f(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});Object.defineProperty(de,"NoOpRunner",{enumerable:!0,get:function(){return ce}});var ce=class{async shouldRun(){return!0}async run(){}}});var lt=f(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});Object.defineProperty(le,"sortTargetsByPriority",{enumerable:!0,get:function(){return vr}});function vr(r){return r.sort((e,t)=>(t.priority??0)-(e.priority??0))}});var W=f(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});function Pr(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}Pr(fe,{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 ge=f(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});Object.defineProperty(he,"detectCycles",{enumerable:!0,get:function(){return Or}});function Or(r){let e=new Map;for(let[t]of r.entries())if(!e.has(t)){let s=Rr(r,e,t);if(s.length>0)return{hasCycle:!0,cycle:s}}return{hasCycle:!1}}var Rr=(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(u=>u.traversing).map(u=>u.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 ft=f(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.getPackageDependencies=void 0;function Sr(r,e){var s,n,i,o;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])||((o=r.optionalDependencies)==null?void 0:o[e]);return t?!t.startsWith("npm:")&&!t.startsWith("file:"):!1}function xr(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);if(r.optionalDependencies&&t.withOptionalDependencies)for(let i of Object.keys(r.optionalDependencies))i!==r.name&&e.has(i)&&s.push(i);return s.filter(i=>Sr(r,i))}L.getPackageDependencies=xr});var ht=f(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.createDependencyMap=void 0;var Ir=ft();function qr(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,Ir.getPackageDependencies)(i,s,e);for(let u of o)t.dependencies.has(n)||t.dependencies.set(n,new Set),t.dependencies.get(n).add(u),t.dependents.has(u)||t.dependents.set(u,new Set),t.dependents.get(u).add(n)}return t}B.createDependencyMap=qr});var mt=f(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});Object.defineProperty(ye,"expandDepSpecs",{enumerable:!0,get:function(){return Dr}});var S=W();function Dr(r,e){let t=[],s=(o,u)=>{t.push([o,u])},n=(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);s(m,a)}else if(p.startsWith("^^")&&c){let d=p.substring(2),h=[...gt(c,e)??[]],m=n(d,h);for(let g of m)s(g,a)}else if(p.startsWith("^")&&c){let d=p.substring(1),h=[...e.dependencies.get(c)??[]],m=n(d,h);for(let g of m)s(g,a)}else if(c){let d=p;r.has((0,S.getTargetId)(c,d))&&s((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=n(p);for(let m of h)s(m,a)}}}return t}var me=new Map;function gt(r,e){let t=me.get(r);if(t)return t==="walk-in-progress"?new Set:t;{me.set(r,"walk-in-progress");let s=[...e.dependencies.get(r)??[]],n=new Set(s);for(let i of s)for(let o of gt(i,e))n.add(o);return me.set(r,n),n}}});var yt=f(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});Object.defineProperty(_e,"prioritize",{enumerable:!0,get:function(){return Cr}});function Er(r){let e=[];for(let[t,s]of r)s.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=[],s=Nr(r),n=[...e];for(;n.length>0;){let i=n.pop();t.push(i),r.get(i).dependents.forEach(u=>{let c=s.get(u);c.delete(i),c.size===0&&n.push(u)})}return t}function Cr(r){let e=new Map,t=Er(r),s=Ar(r,t);for(let n of s){let i=r.get(n),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(n,a)}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 Pe=f(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});Object.defineProperty(ve,"TargetGraphBuilder",{enumerable:!0,get:function(){return ke}});var we=W(),jr=yt(),Fr=ge();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 ke=class r{addTarget(e){return this.targets.set(e.id,e),this.addDependency((0,we.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,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,jr.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 u of o.dependencies)u!==(0,we.getStartTargetId)()&&(t.targets.has(u)||t.addTarget({...this.targets.get(u),dependencies:[],dependents:[]}),t.addDependency(u,i)),s.has(u)||n.push(u)}return t.build()}constructor(){$r(this,"targets",new Map);let e=(0,we.getStartTargetId)();this.targets.set(e,{id:e,task:e,cwd:"",label:"Start",hidden:!0,dependencies:[],dependents:[],depSpecs:[],weight:1,priority:0})}}});var _t=f(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});Object.defineProperty(be,"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 We=f(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:!0});Object.defineProperty(Te,"TargetFactory",{enumerable:!0,get:function(){return Me}});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 Me=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:u,cache:c,inputs:a,priority:p,maxWorkers:d,environmentGlob:h,weight:m}=s,g=n(e),w=this.getTargetType(t,s),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"?[]:s.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:s}=this.options,{options:n,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:s,depSpecs:o??i??[],dependencies:[],dependents:[],inputs:c,outputs:a,priority:p,maxWorkers:d,environmentGlob:h,weight:1,options:n,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 s of Object.values(t))for(let n of Object.keys(s.scripts??{}))this.packageScripts.add(n)}}});var bt=f((Bn,Pt)=>{var Oe=class{constructor(e){this.value=e,this.next=void 0}},Re=class{constructor(){this.clear()}enqueue(e){let t=new Oe(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((Gn,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,s=()=>{t--,e.size>0&&e.dequeue()()},n=async(u,c,...a)=>{t++;let p=(async()=>u(...a))();c(p);try{await p}catch{}s()},i=(u,c,...a)=>{e.enqueue(n.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 Ot=f(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});Object.defineProperty(xe,"WorkspaceTargetGraphBuilder",{enumerable:!0,get:function(){return Se}});var Ur=ht(),G=W(),zr=mt(),Kr=Wt(require("path")),Hr=Pe(),Xr=We(),Jr=Wt(Tt());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 Wt(r){return r&&r.__esModule?r:{default:r}}var Se=class{async addTargetConfig(e,t={}){if(e.startsWith("//")||e.startsWith("#")){let s=this.targetFactory.createGlobalTarget(e,t);this.graphBuilder.addTarget(s),this.targetConfigMap.set(e,t),this.hasRootTarget=!0}else if(e.includes("#")){let{packageName:s,task:n}=(0,G.getPackageAndTask)(e),i=this.targetFactory.createPackageTarget(s,n,t);this.graphBuilder.addTarget(i),this.targetConfigMap.set(e,t)}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),this.targetConfigMap.set(e,t)}}}shouldRun(e,t){return typeof e.shouldRun=="function"?e.shouldRun(t):!0}async build(e,t){let s=(0,zr.expandDepSpecs)(this.graphBuilder.targets,this.dependencyMap);for(let[c,a]of s)this.graphBuilder.addDependency(c,a);let n=[];for(let c of e){if(t)for(let a of t)n.push((0,G.getTargetId)(a,c));else for(let a of Object.keys(this.packageInfos))n.push((0,G.getTargetId)(a,c));if(this.hasRootTarget){let a=(0,G.getTargetId)(void 0,c);this.graphBuilder.targets.has(a)&&n.push(a)}}let i=this.graphBuilder.subgraph(n),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){O(this,"packageInfos",void 0),O(this,"dependencyMap",void 0),O(this,"graphBuilder",void 0),O(this,"targetFactory",void 0),O(this,"hasRootTarget",void 0),O(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(s){try{return Kr.default.dirname(t[s].packageJsonPath)}catch{throw new Error(`Cannot open package.json file for ${s}`)}}})}}});var Rt=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(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(u=>i.add(u));n.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 s(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=>s(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&&s(c,o,u))})}))}});var xt=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 nn.TargetFactory},TargetGraphBuilder:function(){return rn.TargetGraphBuilder},WorkspaceTargetGraphBuilder:function(){return tn.WorkspaceTargetGraphBuilder},detectCycles:function(){return en.detectCycles},getPackageAndTask:function(){return De.getPackageAndTask},getStartTargetId:function(){return De.getStartTargetId},getTargetId:function(){return De.getTargetId},removeNodes:function(){return sn.removeNodes},sortTargetsByPriority:function(){return Zr.sortTargetsByPriority},transitiveReduction:function(){return on.transitiveReduction}});var Zr=lt(),De=W(),en=ge(),tn=Ot(),rn=Pe(),nn=We(),sn=Rt(),on=St()});var qt=f(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Object.defineProperty(Ae,"TargetRunnerPicker",{enumerable:!0,get:function(){return Ne}});var It=dn(require("path")),an=xt(),un=require("url");function cn(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function dn(r){return r&&r.__esModule?r:{default:r}}var Ne=class{async pick(e){if(e.id===(0,an.getStartTargetId)())return new(await Promise.resolve().then(()=>Gt(pe()))).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,un.pathToFileURL)(i).toString());let o=await import(i),u=It.default.basename(s),c=u.replace(It.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(n)}throw new Error(`No runner found for target ${e.id}`)}constructor(e){cn(this,"options",void 0),this.options=e}}});var Dt=f(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});function pn(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}pn(Ce,{NoOpRunner:function(){return hn.NoOpRunner},NpmScriptRunner:function(){return ln.NpmScriptRunner},TargetRunnerPicker:function(){return gn.TargetRunnerPicker},WorkerRunner:function(){return fn.WorkerRunner}});var ln=ct(),fn=pt(),hn=pe(),gn=qt()});Object.defineProperty(exports,"__esModule",{value:!0});var mn=at(),yn=Dt(),_n=require("worker_threads");async function wn(r){let{runners:e}=r,t=new yn.TargetRunnerPicker(e);return{options:r,runnerPicker:t}}(async()=>{let{runnerPicker:r}=await wn(_n.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,mn.registerWorker)(e)})();
"use strict";var $t=Object.create;var Ue=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var Ft=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,Gt=Object.prototype.hasOwnProperty;var f=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Ut=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ft(e))!Gt.call(r,s)&&s!==t&&Ue(r,s,{get:()=>e[s],enumerable:!(i=Bt(e,s))||i.enumerable});return r};var zt=(r,e,t)=>(t=r!=null?$t(Lt(r)):{},Ut(e||!r||!r.__esModule?Ue(t,"default",{value:r,enumerable:!0}):t,r));var D=f(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});function Kt(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}Kt(K,{END_MARKER_PREFIX:function(){return Ke},START_MARKER_PREFIX:function(){return ze},endMarker:function(){return Xt},startMarker:function(){return Ht}});var ze="## WORKER:START:",Ke="## WORKER:END:";function Ht(r){return`${ze}${r}`}function Xt(r){return`${Ke}${r}`}});var He=f(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});Object.defineProperty(H,"registerWorker",{enumerable:!0,get:function(){return Jt}});var A=require("worker_threads"),N=D();function Jt(r){var i;(i=A.parentPort)==null||i.on("message",async s=>{let n;switch(s.type){case"start":return n=new AbortController,s.task&&await e(s.id,s.task,n.signal);case"abort":return n==null?void 0:n.abort();case"check-memory-usage":return t(A.parentPort)}});async function e(s,n,o){var u,c;try{process.stdout.write(`${(0,N.startMarker)(s)}
`),process.stderr.write(`${(0,N.startMarker)(s)}
`);let a=await r(n,o);(u=A.parentPort)==null||u.postMessage({type:"status",err:void 0,results:a})}catch(a){(c=A.parentPort)==null||c.postMessage({type:"status",err:a,results:void 0})}finally{process.stdout.write(`${(0,N.endMarker)(s)}
`),process.stderr.write(`${(0,N.endMarker)(s)}
`)}}function t(s){let n={type:"report-memory-usage",memoryUsage:process.memoryUsage().heapUsed};s.postMessage(n)}}});var Xe=f(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});Object.defineProperty(X,"createFilteredStreamTransform",{enumerable:!0,get:function(){return Vt}});var Qt=require("stream"),C=D();function Vt(){return new Qt.Transform({transform(e,t,i){let s=e.toString();s.includes(C.START_MARKER_PREFIX)&&(s=s.replace(new RegExp(C.START_MARKER_PREFIX+`[0-9a-z]{64}
`),"")),s.includes(C.END_MARKER_PREFIX)&&(s=s.replace(new RegExp(C.END_MARKER_PREFIX+`[0-9a-z]{64}
`),"")),i(null,s)}})}});var Je=f(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Object.defineProperty(Q,"TaskInfo",{enumerable:!0,get:function(){return J}});var Yt=require("async_hooks");function Zt(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var J=class extends Yt.AsyncResource{get id(){return this.options.id}get weight(){return this.options.weight}get abortSignal(){return this.options.abortSignal}done(e,t){let{cleanup:i,worker:s,resolve:n,reject:o}=this.options;i&&this.runInAsyncScope(i,null,s),e?this.runInAsyncScope(o,null,e,s):this.runInAsyncScope(n,null,t,s),this.emitDestroy()}constructor(e){super("WorkerPoolTaskInfo"),Zt(this,"options",void 0),this.options=e,e.setup&&this.runInAsyncScope(e.setup,null,e.worker,e.worker.stdout,e.worker.stderr)}}});var ot=f(te=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});Object.defineProperty(te,"ThreadWorker",{enumerable:!0,get:function(){return Z}});var Qe=Xe(),Ve=require("readline"),Ye=D(),er=require("events"),Ze=require("stream"),tr=Je(),rr=require("worker_threads"),sr=nt(require("crypto")),nr=nt(require("os"));function rt(r,e){if(e.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ir(r,e){return e.get?e.get.call(r):e.value}function or(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 st(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=st(r,e,"get");return ir(r,t)}function j(r,e,t){rt(r,e),e.set(r,t)}function T(r,e,t){var i=st(r,e,"set");return or(r,i,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 $(r,e){rt(r,e),e.add(r)}function I(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function nt(r){return r&&r.__esModule?r:{default:r}}var ar="free",m=new WeakMap,v=new WeakMap,P=new WeakMap,_=new WeakMap,V=new WeakSet,Y=new WeakSet,it=new WeakSet,B=new WeakSet,Z=class extends er.EventEmitter{start(e,t){this.status="busy";let{task:i,resolve:s,reject:n,cleanup:o,setup:u}=e;t==null||t.addEventListener("abort",b(this,B,ee));let c=sr.default.randomBytes(32).toString("hex");T(this,m,new tr.TaskInfo({id:c,weight:e.weight,cleanup:o,resolve:s,reject:n,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:{...i,weight:e.weight},id:c})}get weight(){var e;return((e=l(this,m))==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,V,et).call(this)}async checkMemoryUsage(){l(this,_).postMessage({type:"check-memory-usage"})}postMessage(e,t){l(this,_).postMessage(e,t)}constructor(e,t){super(),$(this,V),$(this,Y),$(this,it),$(this,B),I(this,"script",void 0),I(this,"options",void 0),j(this,m,{writable:!0,value:void 0}),j(this,v,{writable:!0,value:void 0}),j(this,P,{writable:!0,value:void 0}),j(this,_,{writable:!0,value:void 0}),I(this,"status",void 0),I(this,"restarts",void 0),I(this,"maxWorkerMemoryUsage",void 0),this.script=e,this.options=t,T(this,v,{stream:new Ze.Readable,promise:Promise.resolve(),resolve:()=>{}}),T(this,P,{stream:new Ze.Readable,promise:Promise.resolve(),resolve:()=>{}}),this.status="busy",this.restarts=0,this.maxWorkerMemoryUsage=0,b(this,V,et).call(this)}};function et(){let{workerOptions:r}=this.options,e=this.script,t=new rr.Worker(e,{...r,stdout:!0,stderr:!0});b(this,it,ur).call(this,t);let i=t.stdout.pipe((0,Qe.createFilteredStreamTransform)()),s=t.stderr.pipe((0,Qe.createFilteredStreamTransform)()),n=()=>{},o=new Promise(d=>{n=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 y;let{err:h,results:g}=d;l(this,m)&&((y=l(this,m).abortSignal)==null||y.removeEventListener("abort",b(this,B,ee)),l(this,m).done(h,g)),this.checkMemoryUsage()});else if(d.type==="report-memory-usage"){this.maxWorkerMemoryUsage=Math.max(this.maxWorkerMemoryUsage,d.memoryUsage);let h=this.options.workerIdleMemoryLimit??nr.default.totalmem();h&&d.memoryUsage>h?this.restart():b(this,Y,tt).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,m)?((h=l(this,m).abortSignal)==null||h.removeEventListener("abort",b(this,B,ee)),l(this,m).done(d,null)):this.emit("error",d)};t.on("error",p),T(this,_,t),T(this,v,{stream:i,promise:o,resolve:n}),T(this,P,{stream:s,promise:c,resolve:u}),b(this,Y,tt).call(this)}function tt(){let r=1;l(this,m)&&(r=l(this,m).weight,T(this,m,void 0)),this.status="free",this.emit(ar,{weight:r})}function ur(r){let e=r.stdout,t=(0,Ve.createInterface)({input:e,crlfDelay:1/0}),i=r.stderr,s=(0,Ve.createInterface)({input:i,crlfDelay:1/0}),n=c=>{let a=[],p;return d=>{l(this,m)&&(d.includes((0,Ye.startMarker)(l(this,m).id))?(a=[],c==="stdout"?p=l(this,v).resolve:p=l(this,P).resolve):d.includes((0,Ye.endMarker)(l(this,m).id))?p():a.push(d))}},o=n("stdout"),u=n("stderr");t.on("line",o),s.on("line",u)}function ee(){l(this,_)&&l(this,_).postMessage({type:"abort"})}});var ne=f(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});Object.defineProperty(se,"WorkerPool",{enumerable:!0,get:function(){return re}});var cr=require("events"),dr=ot(),pr=lr(require("os"));function M(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 at="free",re=class extends cr.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,i=new dr.ThreadWorker(e,{workerOptions:t,workerIdleMemoryLimit:this.options.workerIdleMemoryLimit});return i.on("free",s=>{let{weight:n}=s;this.availability+=n,this.emit(at)}),this.workers.push(i),i}}exec(e,t,i,s,n){return n!=null&&n.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:i}),this._exec(n)}))}_exec(e){let t=this.queue.findIndex(s=>s.weight<=this.availability);if(t===-1)return;let i=this.workers.find(s=>s.status==="free");if(i||(i=this.addNewWorker()),i){let s=this.queue[t];this.queue.splice(t,1),this.availability-=s.weight,i.start(s,e)}}async close(){await Promise.all(this.workers.map(e=>e.terminate()))}constructor(e){super(),M(this,"options",void 0),M(this,"workers",void 0),M(this,"freeWorkers",void 0),M(this,"queue",void 0),M(this,"minWorkers",void 0),M(this,"maxWorkers",void 0),M(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??pr.default.cpus().length-1,this.availability=this.maxWorkers,this.workers=[],this.freeWorkers=[],this.queue=[],this.createInitialWorkers(),this.on(at,()=>{this.queue.length>0?this._exec():this.workers.every(t=>t.status==="free")&&this.emit("idle")})}}});var ct=f(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});Object.defineProperty(ae,"AggregatedPool",{enumerable:!0,get:function(){return oe}});var ut=ne();function ie(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var oe=class{stats(){return[...this.groupedPools.values(),this.defaultPool].reduce((t,i)=>{if(i){let s=i.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,i,s,n){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,i,s,n)}async close(){let e=[...this.groupedPools.values(),this.defaultPool].map(t=>t==null?void 0:t.close());return Promise.all(e)}constructor(e){ie(this,"options",void 0),ie(this,"groupedPools",void 0),ie(this,"defaultPool",void 0),this.options=e,this.groupedPools=new Map;let{maxWorkers:t,maxWorkersByGroup:i,script:s,workerOptions:n}=e,o=0;for(let[c,a]of i.entries()){let p=new ut.WorkerPool({maxWorkers:a,workerOptions:n,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 ut.WorkerPool({maxWorkers:u,workerOptions:n,script:s,workerIdleMemoryLimit:e.workerIdleMemoryLimit})),this.options.logger.verbose(`Workers pools created: ${[...i.entries(),["default",u]].map(([c,a])=>`${c} (${a})`).join(", ")}`)}}});var dt=f(ue=>{"use strict";Object.defineProperty(ue,"__esModule",{value:!0});function fr(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}fr(ue,{AggregatedPool:function(){return mr.AggregatedPool},WorkerPool:function(){return gr.WorkerPool},registerWorker:function(){return hr.registerWorker}});var hr=He(),gr=ne(),mr=ct()});var lt=f(ce=>{"use strict";Object.defineProperty(ce,"__esModule",{value:!0});Object.defineProperty(ce,"NpmScriptRunner",{enumerable:!0,get:function(){return F}});var yr=require("path"),_r=require("fs/promises"),wr=require("child_process"),kr=vr(require("os"));function pt(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function vr(r){return r&&r.__esModule?r:{default:r}}var F=class r{getNpmArgs(e,t){let i=t.length>0?["--",...t]:[];return["run",e,...i]}async hasNpmScript(e){var n,o;let t=((n=e.options)==null?void 0:n.script)??e.task,i=(0,yr.join)(e.cwd,"package.json");return!!((o=JSON.parse(await(0,_r.readFile)(i,"utf8")).scripts)!=null&&o[t])}async shouldRun(e){return await this.hasNpmScript(e)&&(e.shouldRun??!0)}async run(e){var g,y,k;let{target:t,weight:i,abortSignal:s}=e,{nodeOptions:n,npmCmd:o,taskArgs:u}=this.options,c=((g=t.options)==null?void 0:g.script)??t.task,a;if(s){if(s.aborted)return{exitCode:1};let w=()=>{if(s.removeEventListener("abort",w),a&&!a.killed){let z=a.pid;process.stdout.write(`Abort signal detected, attempting to killing process id ${z}
`),a.kill("SIGTERM");let O=setTimeout(()=>{a&&!a.killed&&a.kill("SIGKILL")},r.gracefulKillTimeout);O.unref&&O.unref()}};s.addEventListener("abort",w)}let p=[...u,...((y=t.options)==null?void 0:y.taskArgs)??[]],d=this.getNpmArgs(c,p),h=[n,(k=t.options)==null?void 0:k.nodeOptions].filter(w=>w).join(" ");return await new Promise((w,z)=>{a=(0,wr.spawn)(o,d,{cwd:t.cwd,stdio:["inherit","pipe","pipe"],...kr.default.platform()==="win32"&&{shell:!0},env:{...process.stdout.isTTY&&{FORCE_COLOR:"1"},...process.env,...h&&{NODE_OPTIONS:h},LAGE_PACKAGE_NAME:t.packageName,LAGE_TASK:t.task,LAGE_WEIGHT:String(i)}});let O=!1,q=E=>{var Fe,Le,Ge;if(a==null||a.off("exit",q),a==null||a.off("error",q),!O){if(O=!0,(Fe=a==null?void 0:a.stdout)==null||Fe.destroy(),(Le=a==null?void 0:a.stderr)==null||Le.destroy(),(Ge=a==null?void 0:a.stdin)==null||Ge.destroy(),E===0)return w({exitCode:E});z({exitCode:E,error:new Error(`NPM Script Runner: ${o} ${d.join(" ")} exited with code ${E}`)})}},{pid:Nt}=a;process.stdout.write(`Running ${[o,...d].join(" ")}, pid: ${Nt}
`);let Ct=a.stdout,jt=a.stderr;Ct.pipe(process.stdout),jt.pipe(process.stderr),a.on("exit",q),a.on("error",()=>q(1))})}constructor(e){pt(this,"options",void 0),this.options=e}};pt(F,"gracefulKillTimeout",2500)});var ht=f(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});Object.defineProperty(de,"WorkerRunner",{enumerable:!0,get:function(){return L}});var Pr=require("url");function ft(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var L=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:i,abortSignal:s}=e,{taskArgs:n}=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:i,taskArgs:n,abortSignal:s})}async getScriptModule(e){var s,n;let t=((s=e.options)==null?void 0:s.worker)??((n=e.options)==null?void 0:n.script);if(!t)throw new Error('WorkerRunner: "script" configuration is required - e.g. { type: "worker", script: "./worker.js" }');let i=t;return i.startsWith("file://")||(i=(0,Pr.pathToFileURL)(i).toString()),await import(i)}constructor(e){ft(this,"options",void 0),this.options=e}};ft(L,"gracefulKillTimeout",2500)});var fe=f(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});Object.defineProperty(le,"NoOpRunner",{enumerable:!0,get:function(){return pe}});var pe=class{async shouldRun(){return!0}async run(){}}});var gt=f(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});Object.defineProperty(he,"sortTargetsByPriority",{enumerable:!0,get:function(){return br}});function br(r){return r.sort((e,t)=>(t.priority??0)-(e.priority??0))}});var W=f(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});function Tr(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}Tr(ge,{getPackageAndTask:function(){return Sr},getStagedTargetId:function(){return Or},getStartTargetId:function(){return Rr},getTargetId:function(){return Mr}});function Mr(r,e){return`${typeof r=="string"?r:""}#${e}`}function Sr(r){if(r.startsWith("\u0394"))return{packageName:void 0,task:r.slice(1)};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 Wr="__start";function Rr(){return Wr}function Or(r){return`\u0394${r}`}});var ye=f(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});Object.defineProperty(me,"detectCycles",{enumerable:!0,get:function(){return Ir}});function Ir(r){let e=new Map;for(let[t]of r.entries())if(!e.has(t)){let i=xr(r,e,t);if(i.length>0)return{hasCycle:!0,cycle:i}}return{hasCycle:!1}}var xr=(r,e,t)=>{let i=[{node:t,traversing:!1}];for(;i.length>0;){let s=i[i.length-1];if(s.traversing)e.set(s.node,!1),i.pop();else{if(e.has(s.node))if(e.get(s.node)){let o=i.filter(u=>u.traversing).map(u=>u.node);return o.slice(o.indexOf(s.node))}else{i.pop();continue}e.set(s.node,!0),i[i.length-1]={...s,traversing:!0};let n=r.get(s.node);if(!n)throw new Error(`Could not find node "${s.node}" in the graph`);i.push(...[...n.dependents].map(o=>({node:o,traversing:!1})))}}return[]}});var mt=f(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.getPackageDependencies=void 0;function qr(r,e){var i,s,n,o;let t=((i=r.dependencies)==null?void 0:i[e])||((s=r.devDependencies)==null?void 0:s[e])||((n=r.peerDependencies)==null?void 0:n[e])||((o=r.optionalDependencies)==null?void 0:o[e]);return t?!t.startsWith("npm:")&&!t.startsWith("file:"):!1}function Er(r,e,t={withDevDependencies:!0}){let i=[];if(r.dependencies)for(let n of Object.keys(r.dependencies))n!==r.name&&e.has(n)&&i.push(n);if(r.devDependencies&&t.withDevDependencies)for(let n of Object.keys(r.devDependencies))n!==r.name&&e.has(n)&&i.push(n);if(r.peerDependencies&&t.withPeerDependencies)for(let n of Object.keys(r.peerDependencies))n!==r.name&&e.has(n)&&i.push(n);if(r.optionalDependencies&&t.withOptionalDependencies)for(let n of Object.keys(r.optionalDependencies))n!==r.name&&e.has(n)&&i.push(n);return i.filter(n=>qr(r,n))}G.getPackageDependencies=Er});var yt=f(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.createDependencyMap=void 0;var Dr=mt();function Ar(r,e={withDevDependencies:!0,withPeerDependencies:!1}){let t={dependencies:new Map,dependents:new Map},i=new Set(Object.keys(r));for(let[s,n]of Object.entries(r)){let o=(0,Dr.getPackageDependencies)(n,i,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}U.createDependencyMap=Ar});var wt=f(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});Object.defineProperty(we,"expandDepSpecs",{enumerable:!0,get:function(){return Nr}});var x=W();function Nr(r,e){let t=[],i=(o,u)=>{t.push([o,u])},s=(o,u)=>u?n.filter(c=>{let{task:a,packageName:p}=c;return a===o&&u.some(d=>d===p)}).map(c=>c.id):n.filter(c=>c.task===o).map(c=>c.id),n=[...r.values()];for(let o of n){let{depSpecs:u,packageName:c,id:a}=o;if(t.push([(0,x.getStartTargetId)(),a]),!(!u||u.length===0))for(let p of u)if(p.includes("#")){let{packageName:d,task:h}=(0,x.getPackageAndTask)(p),g=(0,x.getTargetId)(d,h);i(g,a)}else if(p.startsWith("^^")&&c){let d=p.substring(2),h=[..._t(c,e)??[]],g=s(d,h);for(let y of g)i(y,a)}else if(p.startsWith("^")&&c){let d=p.substring(1),h=[...e.dependencies.get(c)??[]],g=s(d,h);for(let y of g)i(y,a)}else if(c){let d=p;r.has((0,x.getTargetId)(c,d))&&i((0,x.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 g of h)i(g,a)}}}return t}var _e=new Map;function _t(r,e){let t=_e.get(r);if(t)return t==="walk-in-progress"?new Set:t;{_e.set(r,"walk-in-progress");let i=[...e.dependencies.get(r)??[]],s=new Set(i);for(let n of i)for(let o of _t(n,e))s.add(o);return _e.set(r,s),s}}});var kt=f(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});Object.defineProperty(ke,"prioritize",{enumerable:!0,get:function(){return Br}});function Cr(r){let e=[];for(let[t,i]of r)i.dependencies.length===0&&e.push(t);return e}function jr(r){return new Map([...r.entries()].map(([e,t])=>[e,new Set(t.dependencies)]))}function $r(r,e){let t=[],i=jr(r),s=[...e];for(;s.length>0;){let n=s.pop();t.push(n),r.get(n).dependents.forEach(u=>{let c=i.get(u);c.delete(n),c.size===0&&s.push(u)})}return t}function Br(r){let e=new Map,t=Cr(r),i=$r(r,t);for(let s of i){let n=r.get(s),o=n.priority||0,u=n.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 n=e.get(s.id);if(n===void 0)throw new Error(`Expected to have already computed the cumulative priority for node ${s.id}`);s.priority=n}}});var Te=f(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});Object.defineProperty(be,"TargetGraphBuilder",{enumerable:!0,get:function(){return Pe}});var ve=W(),Fr=kt(),Lr=ye();function Gr(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var Pe=class r{addTarget(e){return this.targets.set(e.id,e),this.addDependency((0,ve.getStartTargetId)(),e.id),e}addDependency(e,t){if(this.targets.has(t)){let i=this.targets.get(t);i.dependencies.includes(e)||i.dependencies.push(e)}if(this.targets.has(e)){let i=this.targets.get(e);i.dependents.includes(t)||i.dependents.push(t)}}build(){let e=(0,Lr.detectCycles)(this.targets);if(e.hasCycle)throw new Error("Cycles detected in the target graph: "+e.cycle.concat(e.cycle[0]).join(" -> "));return(0,Fr.prioritize)(this.targets),{targets:this.targets}}subgraph(e){let t=new r,i=new Set,s=[];for(let n of e)if(this.targets.has(n)){let o=this.targets.get(n);t.addTarget({...o,dependencies:[],dependents:[]}),s.push(n)}for(;s.length>0;){let n=s.shift();if(i.has(n))continue;i.add(n);let o=this.targets.get(n);if(!o)throw new Error("Subgraph builder failed - target not found: "+n);for(let u of o.dependencies)u!==(0,ve.getStartTargetId)()&&(t.targets.has(u)||t.addTarget({...this.targets.get(u),dependencies:[],dependents:[]}),t.addDependency(u,n)),i.has(u)||s.push(u)}return t.build()}constructor(){Gr(this,"targets",new Map);let e=(0,ve.getStartTargetId)();this.targets.set(e,{id:e,task:e,cwd:"",label:"Start",hidden:!0,dependencies:[],dependents:[],depSpecs:[],weight:1,priority:0})}}});var vt=f(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Object.defineProperty(Me,"getWeight",{enumerable:!0,get:function(){return Ur}});function Ur(r,e,t){return typeof e=="number"?e:typeof e=="function"?e(r,t):1}});var Oe=f(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Object.defineProperty(Re,"TargetFactory",{enumerable:!0,get:function(){return We}});var Se=W(),Pt=vt();function bt(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{getTargetType(e,t){return t.type?t.type:this.packageScripts.has(e)?"npmScript":"noop"}createPackageTarget(e,t,i){let{resolve:s}=this.options,{options:n,deps:o,dependsOn:u,cache:c,inputs:a,priority:p,maxWorkers:d,environmentGlob:h,weight:g}=i,y=s(e),k=this.getTargetType(t,i),w={id:(0,Se.getTargetId)(e,t),label:`${e} - ${t}`,type:k,packageName:e,task:t,cache:c!==!1,cwd:y,depSpecs:u??o??[],dependencies:[],dependents:[],inputs:a,outputs:k==="noop"?[]:i.outputs,priority:p,maxWorkers:d,environmentGlob:h,weight:1,options:n,shouldRun:!0};return w.weight=(0,Pt.getWeight)(w,g,d),w}createGlobalTarget(e,t){let{root:i}=this.options,{options:s,deps:n,dependsOn:o,cache:u,inputs:c,outputs:a,priority:p,maxWorkers:d,environmentGlob:h,weight:g}=t,{task:y}=(0,Se.getPackageAndTask)(e),k={id:e,label:e,type:this.getTargetType(y,t),task:y,cache:u!==!1,cwd:i,depSpecs:o??n??[],dependencies:[],dependents:[],inputs:c,outputs:a,priority:p,maxWorkers:d,environmentGlob:h,weight:1,options:s,shouldRun:!0};return k.weight=(0,Pt.getWeight)(k,g,d),k}createStagedTarget(e,t,i){let{root:s}=this.options,{dependsOn:n,priority:o}=t,u={...t.options};switch(t.type){case"noop":break;default:u.taskArgs=u.taskArgs??[],u.taskArgs.push(...i);break}let c=(0,Se.getStagedTargetId)(e);return{id:c,label:c,type:t.type,task:e,cache:!1,cwd:s,depSpecs:n??[],dependencies:[],dependents:[],inputs:[],outputs:[],priority:o,maxWorkers:1,environmentGlob:[],weight:1,options:u,shouldRun:!0}}constructor(e){bt(this,"options",void 0),bt(this,"packageScripts",void 0),this.options=e,this.packageScripts=new Set;let{packageInfos:t}=e;for(let i of Object.values(t))for(let s of Object.keys(i.scripts??{}))this.packageScripts.add(s)}}});var Mt=f((zs,Tt)=>{var Ie=class{constructor(e){this.value=e,this.next=void 0}},xe=class{constructor(){this.clear()}enqueue(e){let t=new Ie(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}};Tt.exports=xe});var Wt=f((Ks,St)=>{"use strict";var zr=Mt(),Kr=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 zr,t=0,i=()=>{t--,e.size>0&&e.dequeue()()},s=async(u,c,...a)=>{t++;let p=(async()=>u(...a))();c(p);try{await p}catch{}i()},n=(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=>{n(u,a,...c)});return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o};St.exports=Kr});var Ot=f(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Object.defineProperty(Ee,"WorkspaceTargetGraphBuilder",{enumerable:!0,get:function(){return qe}});var Hr=yt(),R=W(),Xr=wt(),Jr=Rt(require("path")),Qr=Te(),Vr=Oe(),Yr=Rt(Wt());function S(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Rt(r){return r&&r.__esModule?r:{default:r}}var Zr=50,qe=class{async addTargetConfig(e,t={},i){if(e.startsWith("//")||e.startsWith("#")){let s=this.targetFactory.createGlobalTarget(e,t);this.graphBuilder.addTarget(s),this.targetConfigMap.set(e,t),this.hasRootTarget=!0,this.processStagedConfig(s,t,i)}else if(e.includes("#")){let{packageName:s,task:n}=(0,R.getPackageAndTask)(e),o=this.targetFactory.createPackageTarget(s,n,t);this.graphBuilder.addTarget(o),this.targetConfigMap.set(e,t),this.processStagedConfig(o,t,i)}else{let s=Object.keys(this.packageInfos);for(let n of s){let o=e,u=this.targetFactory.createPackageTarget(n,o,t);this.graphBuilder.addTarget(u),this.targetConfigMap.set(e,t),this.processStagedConfig(u,t,i)}}}async processStagedConfig(e,t,i){if(typeof t.stagedTarget>"u"||typeof i>"u"||i.length===0||i.length>(t.stagedTarget.threshold??Zr))return;this.hasStagedTarget=!0,e.type="noop",e.cache=!1,e.shouldRun=!1;let s=(0,R.getStagedTargetId)(e.task),n=this.graphBuilder.targets.has(s)?this.graphBuilder.targets.get(s):this.targetFactory.createStagedTarget(e.task,t.stagedTarget,i);this.graphBuilder.addTarget(n);let o=new Set(n.dependencies);for(let u of e.dependencies)o.add(u);if(n.dependencies=Array.from(o),e.dependents.length>0)throw new Error(`Parent target ${e.id} cannot have dependents when it has a staged target while running with a --since flag`)}shouldRun(e,t){return typeof e.shouldRun=="function"?e.shouldRun(t):!0}async build(e,t){let i=(0,Xr.expandDepSpecs)(this.graphBuilder.targets,this.dependencyMap);for(let[c,a]of i)this.graphBuilder.addDependency(c,a);let s=[];for(let c of e){if(t)for(let a of t)s.push((0,R.getTargetId)(a,c));else for(let a of Object.keys(this.packageInfos))s.push((0,R.getTargetId)(a,c));if(this.hasRootTarget){let a=(0,R.getTargetId)(void 0,c);this.graphBuilder.targets.has(a)&&s.push(a)}if(this.hasStagedTarget){let a=(0,R.getStagedTargetId)(c);this.graphBuilder.targets.has(a)&&s.push(a)}}let n=this.graphBuilder.subgraph(s),o=(0,Yr.default)(8),u=[];for(let c of n.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:n.targets}}constructor(e,t){S(this,"packageInfos",void 0),S(this,"dependencyMap",void 0),S(this,"graphBuilder",void 0),S(this,"targetFactory",void 0),S(this,"hasRootTarget",void 0),S(this,"hasStagedTarget",void 0),S(this,"targetConfigMap",void 0),this.packageInfos=t,this.hasRootTarget=!1,this.hasStagedTarget=!1,this.targetConfigMap=new Map,this.dependencyMap=(0,Hr.createDependencyMap)(t,{withDevDependencies:!0,withPeerDependencies:!1}),this.graphBuilder=new Qr.TargetGraphBuilder,this.targetFactory=new Vr.TargetFactory({root:e,packageInfos:t,resolve(i){try{return Jr.default.dirname(t[i].packageJsonPath)}catch{throw new Error(`Cannot open package.json file for ${i}`)}}})}}});var It=f(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});Object.defineProperty(De,"removeNodes",{enumerable:!0,get:function(){return es}});async function es(r,e){let t=new Map;r.forEach(s=>t.set(s.id,s));let i=new Map;for(let s of r)if(await e(s)){t.delete(s.id);for(let o of s.dependencies)i.has(s.id)||i.set(s.id,new Set),i.get(s.id).add(o)}for(let s of t.values()){let n=new Set(s.dependencies);for(let o of s.dependencies)i.has(o)&&i.get(o).forEach(u=>n.add(u));s.dependencies=Array.from(n).filter(o=>t.has(o))}return Array.from(t.values())}});var xt=f(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Object.defineProperty(Ae,"transitiveReduction",{enumerable:!0,get:function(){return ts}});function ts(r){let e=new Map,t=new Map;r.forEach(n=>{e.set(n.id,n),t.set(n.id,new Map),n.dependencies.forEach(o=>{t.get(n.id).set(o,!0)})});function i(n,o,u){var p;if(n===o)return!0;if(u.has(n))return!1;if(u.add(n),(p=t.get(n))!=null&&p.has(o))return t.get(n).get(o);let c=e.get(n);if(!c)return!1;let a=c.dependencies.some(d=>i(d,o,u));return t.get(n).set(o,a),a}return r.map(n=>({...n,dependencies:n.dependencies.filter(o=>{let u=new Set;return!n.dependencies.some(c=>c!==o&&i(c,o,u))})}))}});var qt=f(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});function rs(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}rs(Ce,{TargetFactory:function(){return as.TargetFactory},TargetGraphBuilder:function(){return os.TargetGraphBuilder},WorkspaceTargetGraphBuilder:function(){return is.WorkspaceTargetGraphBuilder},detectCycles:function(){return ns.detectCycles},getPackageAndTask:function(){return Ne.getPackageAndTask},getStartTargetId:function(){return Ne.getStartTargetId},getTargetId:function(){return Ne.getTargetId},removeNodes:function(){return us.removeNodes},sortTargetsByPriority:function(){return ss.sortTargetsByPriority},transitiveReduction:function(){return cs.transitiveReduction}});var ss=gt(),Ne=W(),ns=ye(),is=Ot(),os=Te(),as=Oe(),us=It(),cs=xt()});var Dt=f($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});Object.defineProperty($e,"TargetRunnerPicker",{enumerable:!0,get:function(){return je}});var Et=fs(require("path")),ds=qt(),ps=require("url");function ls(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function fs(r){return r&&r.__esModule?r:{default:r}}var je=class{async pick(e){if(e.id===(0,ds.getStartTargetId)())return new(await Promise.resolve().then(()=>zt(fe()))).NoOpRunner;if(e.type||(e.type="npmScript"),this.options[e.type]){let t=this.options[e.type],{script:i,options:s}=t,n=i;n.startsWith("file://")||(n=(0,ps.pathToFileURL)(n).toString());let o=await import(n),u=Et.default.basename(i),c=u.replace(Et.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){ls(this,"options",void 0),this.options=e}}});var At=f(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});function hs(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:e[t]})}hs(Be,{NoOpRunner:function(){return ys.NoOpRunner},NpmScriptRunner:function(){return gs.NpmScriptRunner},TargetRunnerPicker:function(){return _s.TargetRunnerPicker},WorkerRunner:function(){return ms.WorkerRunner}});var gs=lt(),ms=ht(),ys=fe(),_s=Dt()});Object.defineProperty(exports,"__esModule",{value:!0});var ws=dt(),ks=At(),vs=require("worker_threads");async function Ps(r){let{runners:e}=r,t=new ks.TargetRunnerPicker(e);return{options:r,runnerPicker:t}}(async()=>{let{runnerPicker:r}=await Ps(vs.workerData);async function e(t,i){let s;return s=await(await r.pick(t.target)).run({target:t.target,weight:0,abortSignal:i}),{skipped:!1,hash:void 0,value:s}}(0,ws.registerWorker)(e)})();
//# sourceMappingURL=singleTargetWorker.js.map
{
"name": "lage",
"version": "2.11.15",
"version": "2.12.0",
"repository": {

@@ -26,4 +26,4 @@ "type": "git",

"devDependencies": {
"@lage-run/cli": "^0.24.3",
"@lage-run/runners": "^1.1.2",
"@lage-run/cli": "^0.24.4",
"@lage-run/runners": "^1.2.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc