monocart-coverage-reports
Advanced tools
Comparing version 2.8.3 to 2.8.4
@@ -35,6 +35,6 @@ const Util = require('../utils/util.js'); | ||
const getFunctionRange = (start, end, coverageInfo) => { | ||
const getFunctionRange = (start, end, type, coverageInfo) => { | ||
const { | ||
functionMap, functionNameMap, functionUncoveredRanges | ||
functionMap, functionNameMap, functionStaticRanges, functionUncoveredRanges | ||
} = coverageInfo; | ||
@@ -53,2 +53,9 @@ | ||
if (type === 'StaticBlock' && functionStaticRanges.length) { | ||
const staticRange = Util.findInRanges(start, end, functionStaticRanges, 'startOffset', 'endOffset'); | ||
if (staticRange) { | ||
return staticRange; | ||
} | ||
} | ||
// find in uncoveredRanges | ||
@@ -288,4 +295,6 @@ return Util.findInRanges(start, end, functionUncoveredRanges, 'startOffset', 'endOffset'); | ||
} | ||
item.block = getFunctionBlock(start, end, functionState); | ||
setGeneratedOnly(item.block, group.generatedOnly); | ||
}); | ||
@@ -470,2 +479,11 @@ | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static | ||
// as a function "functionName": "<static_initializer>", | ||
StaticBlock: (node, parents) => { | ||
const reverseParents = [].concat(parents).reverse(); | ||
functionNodes.push({ | ||
node, | ||
reverseParents | ||
}); | ||
}, | ||
@@ -624,6 +642,8 @@ // =============================================================================== | ||
const { node, reverseParents } = item; | ||
const { start, end } = node; | ||
const { | ||
start, end, type | ||
} = node; | ||
// try function start/end | ||
const functionRange = getFunctionRange(start, end, coverageInfo); | ||
const functionRange = getFunctionRange(start, end, type, coverageInfo); | ||
if (functionRange) { | ||
@@ -637,3 +657,3 @@ return functionRange; | ||
if (parent && parent.type === 'MethodDefinition') { | ||
return getFunctionRange(parent.start, parent.end, coverageInfo); | ||
return getFunctionRange(parent.start, parent.end, parent.type, coverageInfo); | ||
} | ||
@@ -640,0 +660,0 @@ |
@@ -11,3 +11,5 @@ const { | ||
const functionNameMap = new Map(); | ||
const functionStaticRanges = []; | ||
const functionUncoveredRanges = []; | ||
let rootRange; | ||
@@ -42,5 +44,3 @@ coverageList.forEach((block) => { | ||
const blockUncoveredRanges = blockRanges.filter((it) => it.count === 0); | ||
blockUncoveredRanges.sort((a, b) => { | ||
return a.startOffset - b.startOffset; | ||
}); | ||
Util.sortOffsetRanges(blockUncoveredRanges); | ||
functionRange.blockUncoveredRanges = blockUncoveredRanges; | ||
@@ -66,3 +66,7 @@ functionRange.blockCoveredRanges = blockRanges.filter((it) => it.count > 0); | ||
// uncovered is unique | ||
if (functionName === '<static_initializer>') { | ||
functionStaticRanges.push(functionRange); | ||
} | ||
// cache uncovered | ||
if (functionRange.count === 0) { | ||
@@ -75,5 +79,3 @@ functionUncoveredRanges.push(functionRange); | ||
// sort ranges | ||
functionUncoveredRanges.sort((a, b) => { | ||
return a.startOffset - b.startOffset; | ||
}); | ||
Util.sortOffsetRanges(functionUncoveredRanges); | ||
@@ -83,2 +85,3 @@ return { | ||
functionNameMap, | ||
functionStaticRanges, | ||
functionUncoveredRanges, | ||
@@ -85,0 +88,0 @@ rootRange |
@@ -52,3 +52,3 @@ /** | ||
list.forEach((item) => { | ||
const range = Util.findInRanges(item.start, item.end, ignoredRanges, 'start', 'end'); | ||
const range = Util.findInRanges(item.start, item.end, ignoredRanges); | ||
if (range) { | ||
@@ -78,29 +78,4 @@ // console.log(item, range); | ||
const lines = Util.getRangeLines(sLoc, eLoc); | ||
Util.updateLinesCoverage(lines, count, lineMap); | ||
lines.forEach((it) => { | ||
const lineItem = lineMap.get(it.line); | ||
if (!lineItem) { | ||
// not found line, could be comment or blank line | ||
return; | ||
} | ||
if (lineItem.ignored) { | ||
return; | ||
} | ||
it.count = count; | ||
// default is covered, so only focus on | ||
// 1, biggest covered count | ||
// 2, uncovered entire and pieces | ||
if (count > 0) { | ||
lineItem.coveredCount = Math.max(lineItem.coveredCount, count); | ||
} else { | ||
if (it.entire) { | ||
lineItem.uncoveredEntire = it; | ||
} else { | ||
lineItem.uncoveredPieces.push(it); | ||
} | ||
} | ||
}); | ||
}); | ||
@@ -1242,2 +1217,80 @@ | ||
const initJsCoverageList = (item) => { | ||
const coverageList = filterCoverageList(item); | ||
// function could be covered even it is defined after an uncovered return, see case closures.js | ||
// fix uncovered range if there are covered ranges in uncovered range | ||
const uncoveredBlocks = []; | ||
const uncoveredList = []; | ||
coverageList.forEach((block) => { | ||
block.ranges.forEach((range, i) => { | ||
const { | ||
count, startOffset, endOffset | ||
} = range; | ||
if (i === 0) { | ||
// check only first level | ||
if (count > 0) { | ||
const inUncoveredRange = Util.findInRanges(startOffset, endOffset, uncoveredBlocks, 'startOffset', 'endOffset'); | ||
if (inUncoveredRange) { | ||
if (!inUncoveredRange.coveredList) { | ||
inUncoveredRange.coveredList = []; | ||
uncoveredList.push(inUncoveredRange); | ||
} | ||
inUncoveredRange.coveredList.push(range); | ||
} | ||
} | ||
} else { | ||
if (count === 0) { | ||
uncoveredBlocks.push({ | ||
... range, | ||
index: i, | ||
ranges: block.ranges | ||
}); | ||
} | ||
} | ||
}); | ||
}); | ||
if (uncoveredList.length) { | ||
uncoveredList.forEach((it) => { | ||
const { | ||
ranges, index, count, coveredList | ||
} = it; | ||
// remove previous range first | ||
const args = [index, 1]; | ||
Util.sortOffsetRanges(coveredList); | ||
let startOffset = it.startOffset; | ||
coveredList.forEach((cov) => { | ||
// ignore sub functions in the function | ||
if (cov.startOffset > startOffset) { | ||
args.push({ | ||
startOffset, | ||
endOffset: cov.startOffset, | ||
count | ||
}); | ||
startOffset = cov.endOffset; | ||
} | ||
}); | ||
if (it.endOffset > startOffset) { | ||
args.push({ | ||
startOffset, | ||
endOffset: it.endOffset, | ||
count | ||
}); | ||
} | ||
ranges.splice.apply(ranges, args); | ||
}); | ||
} | ||
return coverageList; | ||
}; | ||
// ======================================================================================================== | ||
@@ -1470,3 +1523,3 @@ | ||
if (js) { | ||
coverageList = filterCoverageList(item); | ||
coverageList = initJsCoverageList(item); | ||
// remove original functions | ||
@@ -1473,0 +1526,0 @@ if (!Util.isDebug()) { |
@@ -209,6 +209,7 @@ declare namespace MCR { | ||
export type LoggingType = "off" | "error" | "info" | "debug"; | ||
export interface CoverageReportOptions { | ||
/** {string} logging levels: off, error, info, debug */ | ||
logging?: string; | ||
logging?: LoggingType; | ||
@@ -226,3 +227,3 @@ /** {string} Report name. Defaults to "Coverage Report". */ | ||
*/ | ||
reports?: string | string[] | ReportDescription[]; | ||
reports?: string | (string | ReportDescription)[]; | ||
@@ -499,2 +500,6 @@ /** {string} output dir */ | ||
export const Util: { | ||
initLoggingLevel: (logging: LoggingType) => string; | ||
}; | ||
} | ||
@@ -501,0 +506,0 @@ |
@@ -282,3 +282,4 @@ const fs = require('fs'); | ||
MCR.CDPClient = CDPClient; | ||
MCR.Util = Util; | ||
module.exports = MCR; |
@@ -1,23 +0,23 @@ | ||
var Ct=Object.create;var y=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var wt=Object.getPrototypeOf,Et=Object.prototype.hasOwnProperty;var g=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),At=(s,e)=>{for(var t in e)y(s,t,{get:e[t],enumerable:!0})},le=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of bt(e))!Et.call(s,n)&&n!==t&&y(s,n,{get:()=>e[n],enumerable:!(i=xt(e,n))||i.enumerable});return s};var V=(s,e,t)=>(t=s!=null?Ct(wt(s)):{},le(e||!s||!s.__esModule?y(t,"default",{value:s,enumerable:!0}):t,s)),yt=s=>le(y({},"__esModule",{value:!0}),s);var A=g(P=>{var S=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},I=class extends S{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};P.CommanderError=S;P.InvalidArgumentError=I});var v=g(N=>{var{InvalidArgumentError:St}=A(),T=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new St(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function vt(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}N.Argument=T;N.humanReadableArgName=vt});var F=g(ue=>{var{humanReadableArgName:$t}=v(),q=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(n=>!n._hidden),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort((n,r)=>n.name().localeCompare(r.name())),t}compareOptions(e,t){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){let t=e.options.filter(n=>!n.hidden),i=e._getHelpOption();if(i&&!i.hidden){let n=i.short&&e._findOption(i.short),r=i.long&&e._findOption(i.long);!n&&!r?t.push(i):i.long&&!r?t.push(e.createOption(i.long,i.description)):i.short&&!n&&t.push(e.createOption(i.short,i.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let i=e.parent;i;i=i.parent){let n=i.options.filter(r=>!r.hidden);t.push(...n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(i=>$t(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,n)=>Math.max(i,t.subcommandTerm(n).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,n)=>Math.max(i,t.argumentTerm(n).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let n=e.parent;n;n=n.parent)i=n.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){let i=t.padWidth(e,t),n=t.helpWidth||80,r=2,o=2;function l(m,_){if(_){let E=`${m.padEnd(i+o)}${_}`;return t.wrap(E,n-r,i+o)}return m}function a(m){return m.join(` | ||
`).replace(/^/gm," ".repeat(r))}let u=[`Usage: ${t.commandUsage(e)}`,""],c=t.commandDescription(e);c.length>0&&(u=u.concat([t.wrap(c,n,0),""]));let h=t.visibleArguments(e).map(m=>l(t.argumentTerm(m),t.argumentDescription(m)));h.length>0&&(u=u.concat(["Arguments:",a(h),""]));let f=t.visibleOptions(e).map(m=>l(t.optionTerm(m),t.optionDescription(m)));if(f.length>0&&(u=u.concat(["Options:",a(f),""])),this.showGlobalOptions){let m=t.visibleGlobalOptions(e).map(_=>l(t.optionTerm(_),t.optionDescription(_)));m.length>0&&(u=u.concat(["Global Options:",a(m),""]))}let d=t.visibleCommands(e).map(m=>l(t.subcommandTerm(m),t.subcommandDescription(m)));return d.length>0&&(u=u.concat(["Commands:",a(d),""])),u.join(` | ||
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){let r=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",o=new RegExp(`[\\n][${r}]+`);if(e.match(o))return e;let l=t-i;if(l<n)return e;let a=e.slice(0,i),u=e.slice(i).replace(`\r | ||
var Ct=Object.create;var y=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var d=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),yt=(s,e)=>{for(var t in e)y(s,t,{get:e[t],enumerable:!0})},le=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of wt(e))!At.call(s,n)&&n!==t&&y(s,n,{get:()=>e[n],enumerable:!(i=bt(e,n))||i.enumerable});return s};var V=(s,e,t)=>(t=s!=null?Ct(Et(s)):{},le(e||!s||!s.__esModule?y(t,"default",{value:s,enumerable:!0}):t,s)),St=s=>le(y({},"__esModule",{value:!0}),s);var A=d(I=>{var S=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},P=class extends S{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};I.CommanderError=S;I.InvalidArgumentError=P});var v=d(N=>{var{InvalidArgumentError:vt}=A(),T=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new vt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function $t(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}N.Argument=T;N.humanReadableArgName=$t});var F=d(ue=>{var{humanReadableArgName:Ht}=v(),q=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(n=>!n._hidden),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort((n,r)=>n.name().localeCompare(r.name())),t}compareOptions(e,t){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){let t=e.options.filter(n=>!n.hidden),i=e._getHelpOption();if(i&&!i.hidden){let n=i.short&&e._findOption(i.short),r=i.long&&e._findOption(i.long);!n&&!r?t.push(i):i.long&&!r?t.push(e.createOption(i.long,i.description)):i.short&&!n&&t.push(e.createOption(i.short,i.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let i=e.parent;i;i=i.parent){let n=i.options.filter(r=>!r.hidden);t.push(...n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(i=>Ht(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,n)=>Math.max(i,t.subcommandTerm(n).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,n)=>Math.max(i,t.argumentTerm(n).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let n=e.parent;n;n=n.parent)i=n.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){let i=t.padWidth(e,t),n=t.helpWidth||80,r=2,o=2;function u(m,_){if(_){let E=`${m.padEnd(i+o)}${_}`;return t.wrap(E,n-r,i+o)}return m}function a(m){return m.join(` | ||
`).replace(/^/gm," ".repeat(r))}let l=[`Usage: ${t.commandUsage(e)}`,""],c=t.commandDescription(e);c.length>0&&(l=l.concat([t.wrap(c,n,0),""]));let h=t.visibleArguments(e).map(m=>u(t.argumentTerm(m),t.argumentDescription(m)));h.length>0&&(l=l.concat(["Arguments:",a(h),""]));let f=t.visibleOptions(e).map(m=>u(t.optionTerm(m),t.optionDescription(m)));if(f.length>0&&(l=l.concat(["Options:",a(f),""])),this.showGlobalOptions){let m=t.visibleGlobalOptions(e).map(_=>u(t.optionTerm(_),t.optionDescription(_)));m.length>0&&(l=l.concat(["Global Options:",a(m),""]))}let g=t.visibleCommands(e).map(m=>u(t.subcommandTerm(m),t.subcommandDescription(m)));return g.length>0&&(l=l.concat(["Commands:",a(g),""])),l.join(` | ||
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){let r=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",o=new RegExp(`[\\n][${r}]+`);if(e.match(o))return e;let u=t-i;if(u<n)return e;let a=e.slice(0,i),l=e.slice(i).replace(`\r | ||
`,` | ||
`),c=" ".repeat(i),f="\\s\u200B",d=new RegExp(` | ||
|.{1,${l-1}}([${f}]|$)|[^${f}]+?([${f}]|$)`,"g"),m=u.match(d)||[];return a+m.map((_,E)=>_===` | ||
`),c=" ".repeat(i),f="\\s\u200B",g=new RegExp(` | ||
|.{1,${u-1}}([${f}]|$)|[^${f}]+?([${f}]|$)`,"g"),m=l.match(g)||[];return a+m.map((_,E)=>_===` | ||
`?"":(E>0?c:"")+_.trimEnd()).join(` | ||
`)}};ue.Help=q});var M=g(D=>{var{InvalidArgumentError:Ht}=A(),j=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=Vt(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new Ht(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return kt(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},G=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(e,t){let i=t.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,r=n!==void 0?n:!1;return t.negate===(r===e)}};function kt(s){return s.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Vt(s){let e,t,i=s.split(/[ |,]+/);return i.length>1&&!/^[[<]/.test(i[1])&&(e=i.shift()),t=i.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}D.Option=j;D.DualOptions=G});var he=g(ce=>{function It(s,e){if(Math.abs(s.length-e.length)>3)return Math.max(s.length,e.length);let t=[];for(let i=0;i<=s.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let n=1;n<=s.length;n++){let r=1;s[n-1]===e[i-1]?r=0:r=1,t[n][i]=Math.min(t[n-1][i]+1,t[n][i-1]+1,t[n-1][i-1]+r),n>1&&i>1&&s[n-1]===e[i-2]&&s[n-2]===e[i-1]&&(t[n][i]=Math.min(t[n][i],t[n-2][i-2]+1))}return t[s.length][e.length]}function Pt(s,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=s.startsWith("--");t&&(s=s.slice(2),e=e.map(o=>o.slice(2)));let i=[],n=3,r=.4;return e.forEach(o=>{if(o.length<=1)return;let l=It(s,o),a=Math.max(s.length,o.length);(a-l)/a>r&&(l<n?(n=l,i=[o]):l===n&&i.push(o))}),i.sort((o,l)=>o.localeCompare(l)),t&&(i=i.map(o=>`--${o}`)),i.length>1?` | ||
`)}};ue.Help=q});var W=d(D=>{var{InvalidArgumentError:kt}=A(),j=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=Pt(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return typeof e=="string"&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new kt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Vt(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},G=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(t=>{t.negate?this.negativeOptions.set(t.attributeName(),t):this.positiveOptions.set(t.attributeName(),t)}),this.negativeOptions.forEach((t,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(e,t){let i=t.attributeName();if(!this.dualOptions.has(i))return!0;let n=this.negativeOptions.get(i).presetArg,r=n!==void 0?n:!1;return t.negate===(r===e)}};function Vt(s){return s.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function Pt(s){let e,t,i=s.split(/[ |,]+/);return i.length>1&&!/^[[<]/.test(i[1])&&(e=i.shift()),t=i.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}D.Option=j;D.DualOptions=G});var he=d(ce=>{function It(s,e){if(Math.abs(s.length-e.length)>3)return Math.max(s.length,e.length);let t=[];for(let i=0;i<=s.length;i++)t[i]=[i];for(let i=0;i<=e.length;i++)t[0][i]=i;for(let i=1;i<=e.length;i++)for(let n=1;n<=s.length;n++){let r=1;s[n-1]===e[i-1]?r=0:r=1,t[n][i]=Math.min(t[n-1][i]+1,t[n][i-1]+1,t[n-1][i-1]+r),n>1&&i>1&&s[n-1]===e[i-2]&&s[n-2]===e[i-1]&&(t[n][i]=Math.min(t[n][i],t[n-2][i-2]+1))}return t[s.length][e.length]}function Tt(s,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=s.startsWith("--");t&&(s=s.slice(2),e=e.map(o=>o.slice(2)));let i=[],n=3,r=.4;return e.forEach(o=>{if(o.length<=1)return;let u=It(s,o),a=Math.max(s.length,o.length);(a-u)/a>r&&(u<n?(n=u,i=[o]):u===n&&i.push(o))}),i.sort((o,u)=>o.localeCompare(u)),t&&(i=i.map(o=>`--${o}`)),i.length>1?` | ||
(Did you mean one of ${i.join(", ")}?)`:i.length===1?` | ||
(Did you mean ${i[0]}?)`:""}ce.suggestSimilar=Pt});var ge=g(de=>{var Tt=require("node:events").EventEmitter,W=require("node:child_process"),C=require("node:path"),L=require("node:fs"),p=require("node:process"),{Argument:Nt,humanReadableArgName:qt}=v(),{CommanderError:R}=A(),{Help:Ft}=F(),{Option:fe,DualOptions:jt}=M(),{suggestSimilar:me}=he(),U=class s extends Tt{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>p.stdout.write(t),writeErr:t=>p.stderr.write(t),getOutHelpWidth:()=>p.stdout.isTTY?p.stdout.columns:void 0,getErrHelpWidth:()=>p.stderr.isTTY?p.stderr.columns:void 0,outputError:(t,i)=>i(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let n=t,r=i;typeof n=="object"&&n!==null&&(r=n,n=null),r=r||{};let[,o,l]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(o);return n&&(a.description(n),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(r.noHelp||r.hidden),a._executableFile=r.executableFile||null,l&&a.arguments(l),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(e){return new s(e)}createHelp(){return Object.assign(new Ft,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name | ||
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new Nt(e,t)}argument(e,t,i,n){let r=this.createArgument(e,t);return typeof i=="function"?r.default(n).argParser(i):r.default(i),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,i,n]=e.match(/([^ ]+) *(.*)/),r=t??"display help for command",o=this.createCommand(i);return o.helpOption(!1),n&&o.arguments(n),r&&o.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'. | ||
(Did you mean ${i[0]}?)`:""}ce.suggestSimilar=Tt});var ge=d(de=>{var Nt=require("node:events").EventEmitter,M=require("node:child_process"),x=require("node:path"),L=require("node:fs"),p=require("node:process"),{Argument:qt,humanReadableArgName:Ft}=v(),{CommanderError:R}=A(),{Help:jt}=F(),{Option:fe,DualOptions:Gt}=W(),{suggestSimilar:me}=he(),U=class s extends Nt{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:t=>p.stdout.write(t),writeErr:t=>p.stderr.write(t),getOutHelpWidth:()=>p.stdout.isTTY?p.stdout.columns:void 0,getErrHelpWidth:()=>p.stderr.isTTY?p.stderr.columns:void 0,outputError:(t,i)=>i(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let n=t,r=i;typeof n=="object"&&n!==null&&(r=n,n=null),r=r||{};let[,o,u]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(o);return n&&(a.description(n),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(r.noHelp||r.hidden),a._executableFile=r.executableFile||null,u&&a.arguments(u),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}createCommand(e){return new s(e)}createHelp(){return Object.assign(new jt,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name | ||
- specify the name in Command constructor or using .name()`);return t=t||{},t.isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new qt(e,t)}argument(e,t,i,n){let r=this.createArgument(e,t);return typeof i=="function"?r.default(n).argParser(i):r.default(i),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach(t=>{this.argument(t)}),this}addArgument(e){let t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,this;e=e??"help [command]";let[,i,n]=e.match(/([^ ]+) *(.*)/),r=t??"display help for command",o=this.createCommand(i);return o.helpOption(!1),n&&o.arguments(n),r&&o.description(r),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(e,t){return typeof e!="object"?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){let i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'. | ||
Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=t=>{if(t.code!=="commander.executeSubCommandAsync")throw t},this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new R(e,t,i)),p.exit(e)}action(e){let t=i=>{let n=this.registeredArguments.length,r=i.slice(0,n);return this._storeOptionsAsProperties?r[n]=this:r[n]=this.opts(),r.push(this),e.apply(this,r)};return this._actionHandler=t,this}createOption(e,t){return new fe(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(r){if(r.code==="commander.invalidArgument"){let o=`${n} ${r.message}`;this.error(o,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let i=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${i}' | ||
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=n=>[n.name()].concat(n.aliases()),i=t(e).find(n=>this._findCommand(n));if(i){let n=t(this._findCommand(i)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${n}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let r=e.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let n=(r,o,l)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let a=this.getOptionValue(i);r!==null&&e.parseArg?r=this._callParseArg(e,r,a,o):r!==null&&e.variadic&&(r=e._concatValue(r,a)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(i,r,l)};return this.on("option:"+t,r=>{let o=`error: option '${e.flags}' argument '${r}' is invalid.`;n(r,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let o=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;n(r,o,"env")}),this}_optionEx(e,t,i,n,r){if(typeof t=="object"&&t instanceof fe)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,i);if(o.makeOptionMandatory(!!e.mandatory),typeof n=="function")o.default(r).argParser(n);else if(n instanceof RegExp){let l=n;n=(a,u)=>{let c=l.exec(a);return c?c[0]:u},o.default(r).argParser(n)}else o.default(n);return this.addOption(o)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:!0},e,t,i,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(e)!==void 0&&(t=i.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){var n;if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){(n=p.versions)!=null&&n.electron&&(t.from="electron");let r=p.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(t.from="eval")}e===void 0&&(e=p.argv),this.rawArgs=e.slice();let i;switch(t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":p.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(e,t){let i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){let i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_executeSubCommand(e,t){t=t.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function r(c,h){let f=C.resolve(c,h);if(L.existsSync(f))return f;if(n.includes(C.extname(h)))return;let d=n.find(m=>L.existsSync(`${f}${m}`));if(d)return`${f}${d}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,l=this._executableDir||"";if(this._scriptPath){let c;try{c=L.realpathSync(this._scriptPath)}catch{c=this._scriptPath}l=C.resolve(C.dirname(c),l)}if(l){let c=r(l,o);if(!c&&!e._executableFile&&this._scriptPath){let h=C.basename(this._scriptPath,C.extname(this._scriptPath));h!==this._name&&(c=r(l,`${h}-${e._name}`))}o=c||o}i=n.includes(C.extname(o));let a;p.platform!=="win32"?i?(t.unshift(o),t=pe(p.execArgv).concat(t),a=W.spawn(p.argv[0],t,{stdio:"inherit"})):a=W.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=pe(p.execArgv).concat(t),a=W.spawn(p.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{p.on(h,()=>{a.killed===!1&&a.exitCode===null&&a.kill(h)})});let u=this._exitCallback;a.on("close",c=>{c=c??1,u?u(new R(c,"commander.executeSubCommandAsync","(close)")):p.exit(c)}),a.on("error",c=>{if(c.code==="ENOENT"){let h=l?`searched for local subcommand relative to directory '${l}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",f=`'${o}' does not exist | ||
- already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=n=>[n.name()].concat(n.aliases()),i=t(e).find(n=>this._findCommand(n));if(i){let n=t(this._findCommand(i)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${n}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),i=e.attributeName();if(e.negate){let r=e.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(i,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(i,e.defaultValue,"default");let n=(r,o,u)=>{r==null&&e.presetArg!==void 0&&(r=e.presetArg);let a=this.getOptionValue(i);r!==null&&e.parseArg?r=this._callParseArg(e,r,a,o):r!==null&&e.variadic&&(r=e._concatValue(r,a)),r==null&&(e.negate?r=!1:e.isBoolean()||e.optional?r=!0:r=""),this.setOptionValueWithSource(i,r,u)};return this.on("option:"+t,r=>{let o=`error: option '${e.flags}' argument '${r}' is invalid.`;n(r,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,r=>{let o=`error: option '${e.flags}' value '${r}' from env '${e.envVar}' is invalid.`;n(r,o,"env")}),this}_optionEx(e,t,i,n,r){if(typeof t=="object"&&t instanceof fe)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,i);if(o.makeOptionMandatory(!!e.mandatory),typeof n=="function")o.default(r).argParser(n);else if(n instanceof RegExp){let u=n;n=(a,l)=>{let c=u.exec(a);return c?c[0]:l},o.default(r).argParser(n)}else o.default(n);return this.addOption(o)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:!0},e,t,i,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(e)!==void 0&&(t=i.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){var n;if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},e===void 0&&t.from===void 0){(n=p.versions)!=null&&n.electron&&(t.from="electron");let r=p.execArgv??[];(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))&&(t.from="eval")}e===void 0&&(e=p.argv),this.rawArgs=e.slice();let i;switch(t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":p.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(e,t){let i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){let i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_executeSubCommand(e,t){t=t.slice();let i=!1,n=[".js",".ts",".tsx",".mjs",".cjs"];function r(c,h){let f=x.resolve(c,h);if(L.existsSync(f))return f;if(n.includes(x.extname(h)))return;let g=n.find(m=>L.existsSync(`${f}${m}`));if(g)return`${f}${g}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,u=this._executableDir||"";if(this._scriptPath){let c;try{c=L.realpathSync(this._scriptPath)}catch{c=this._scriptPath}u=x.resolve(x.dirname(c),u)}if(u){let c=r(u,o);if(!c&&!e._executableFile&&this._scriptPath){let h=x.basename(this._scriptPath,x.extname(this._scriptPath));h!==this._name&&(c=r(u,`${h}-${e._name}`))}o=c||o}i=n.includes(x.extname(o));let a;p.platform!=="win32"?i?(t.unshift(o),t=pe(p.execArgv).concat(t),a=M.spawn(p.argv[0],t,{stdio:"inherit"})):a=M.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=pe(p.execArgv).concat(t),a=M.spawn(p.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(h=>{p.on(h,()=>{a.killed===!1&&a.exitCode===null&&a.kill(h)})});let l=this._exitCallback;a.on("close",c=>{c=c??1,l?l(new R(c,"commander.executeSubCommandAsync","(close)")):p.exit(c)}),a.on("error",c=>{if(c.code==="ENOENT"){let h=u?`searched for local subcommand relative to directory '${u}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",f=`'${o}' does not exist | ||
- if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead | ||
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path | ||
- ${h}`;throw new Error(f)}else if(c.code==="EACCES")throw new Error(`'${o}' not executable`);if(!u)p.exit(1);else{let h=new R(1,"commander.executeSubCommandAsync","(error)");h.nestedError=c,u(h)}}),this.runningCommand=a}_dispatchSubcommand(e,t,i){let n=this._findCommand(e);n||this.help({error:!0});let r;return r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,()=>{if(n._executableHandler)this._executeSubCommand(n,t.concat(i));else return n._parseCommand(t,i)}),r}_dispatchHelpCommand(e){var i,n;e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[((i=this._getHelpOption())==null?void 0:i.long)??((n=this._getHelpOption())==null?void 0:n.short)??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(i,n,r)=>{let o=n;if(n!==null&&i.parseArg){let l=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;o=this._callParseArg(i,n,r,l)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((i,n)=>{let r=i.defaultValue;i.variadic?n<this.args.length?(r=this.args.slice(n),i.parseArg&&(r=r.reduce((o,l)=>e(i,l,o),i.defaultValue))):r===void 0&&(r=[]):n<this.args.length&&(r=this.args[n],i.parseArg&&(r=e(i,r,i.defaultValue))),t[n]=r}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let i=e,n=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(o=>{n.push({hookedCommand:r,callback:o})})}),t==="postAction"&&n.reverse(),n.forEach(r=>{i=this._chainOrCall(i,()=>r.callback(r.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(r=>{n=this._chainOrCall(n,()=>r(this,t))}),n}_parseCommand(e,t){let i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(r))n(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});e.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=e.find(r=>i.conflictsWith.includes(r.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],n=t,r=e.slice();function o(a){return a.length>1&&a[0]==="-"}let l=null;for(;r.length;){let a=r.shift();if(a==="--"){n===i&&n.push(a),n.push(...r);break}if(l&&!o(a)){this.emit(`option:${l.name()}`,a);continue}if(l=null,o(a)){let u=this._findOption(a);if(u){if(u.required){let c=r.shift();c===void 0&&this.optionMissingArgument(u),this.emit(`option:${u.name()}`,c)}else if(u.optional){let c=null;r.length>0&&!o(r[0])&&(c=r.shift()),this.emit(`option:${u.name()}`,c)}else this.emit(`option:${u.name()}`);l=u.variadic?u:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let u=this._findOption(`-${a[1]}`);if(u){u.required||u.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${u.name()}`,a.slice(2)):(this.emit(`option:${u.name()}`),r.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let u=a.indexOf("="),c=this._findOption(a.slice(0,u));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,a.slice(u+1));continue}}if(o(a)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(a)){t.push(a),r.length>0&&i.push(...r);break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a),r.length>0&&t.push(...r);break}else if(this._defaultCommandName){i.push(a),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){n.push(a),r.length>0&&n.push(...r);break}n.push(a)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let i=0;i<t;i++){let n=this.options[i].attributeName();e[n]=n===this._versionOptionName?this._version:this[n]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e} | ||
- ${h}`;throw new Error(f)}else if(c.code==="EACCES")throw new Error(`'${o}' not executable`);if(!l)p.exit(1);else{let h=new R(1,"commander.executeSubCommandAsync","(error)");h.nestedError=c,l(h)}}),this.runningCommand=a}_dispatchSubcommand(e,t,i){let n=this._findCommand(e);n||this.help({error:!0});let r;return r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,()=>{if(n._executableHandler)this._executeSubCommand(n,t.concat(i));else return n._parseCommand(t,i)}),r}_dispatchHelpCommand(e){var i,n;e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[((i=this._getHelpOption())==null?void 0:i.long)??((n=this._getHelpOption())==null?void 0:n.short)??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&this.args[t]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(i,n,r)=>{let o=n;if(n!==null&&i.parseArg){let u=`error: command-argument value '${n}' is invalid for argument '${i.name()}'.`;o=this._callParseArg(i,n,r,u)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((i,n)=>{let r=i.defaultValue;i.variadic?n<this.args.length?(r=this.args.slice(n),i.parseArg&&(r=r.reduce((o,u)=>e(i,u,o),i.defaultValue))):r===void 0&&(r=[]):n<this.args.length&&(r=this.args[n],i.parseArg&&(r=e(i,r,i.defaultValue))),t[n]=r}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let i=e,n=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[t]!==void 0).forEach(r=>{r._lifeCycleHooks[t].forEach(o=>{n.push({hookedCommand:r,callback:o})})}),t==="postAction"&&n.reverse(),n.forEach(r=>{i=this._chainOrCall(i,()=>r.callback(r.hookedCommand,this))}),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(r=>{n=this._chainOrCall(n,()=>r(this,t))}),n}_parseCommand(e,t){let i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){n(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(r))n(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&e.getOptionValue(t.attributeName())===void 0&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(i=>{let n=i.attributeName();return this.getOptionValue(n)===void 0?!1:this.getOptionValueSource(n)!=="default"});e.filter(i=>i.conflictsWith.length>0).forEach(i=>{let n=e.find(r=>i.conflictsWith.includes(r.attributeName()));n&&this._conflictingOption(i,n)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],i=[],n=t,r=e.slice();function o(a){return a.length>1&&a[0]==="-"}let u=null;for(;r.length;){let a=r.shift();if(a==="--"){n===i&&n.push(a),n.push(...r);break}if(u&&!o(a)){this.emit(`option:${u.name()}`,a);continue}if(u=null,o(a)){let l=this._findOption(a);if(l){if(l.required){let c=r.shift();c===void 0&&this.optionMissingArgument(l),this.emit(`option:${l.name()}`,c)}else if(l.optional){let c=null;r.length>0&&!o(r[0])&&(c=r.shift()),this.emit(`option:${l.name()}`,c)}else this.emit(`option:${l.name()}`);u=l.variadic?l:null;continue}}if(a.length>2&&a[0]==="-"&&a[1]!=="-"){let l=this._findOption(`-${a[1]}`);if(l){l.required||l.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${l.name()}`,a.slice(2)):(this.emit(`option:${l.name()}`),r.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let l=a.indexOf("="),c=this._findOption(a.slice(0,l));if(c&&(c.required||c.optional)){this.emit(`option:${c.name()}`,a.slice(l+1));continue}}if(o(a)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(a)){t.push(a),r.length>0&&i.push(...r);break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a),r.length>0&&t.push(...r);break}else if(this._defaultCommandName){i.push(a),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){n.push(a),r.length>0&&n.push(...r);break}n.push(a)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let i=0;i<t;i++){let n=this.options[i].attributeName();e[n]=n===this._versionOptionName?this._version:this[n]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e} | ||
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError} | ||
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(` | ||
`),this.outputHelp({error:!0}));let i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in p.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,p.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new jt(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!t(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=o=>{let l=o.attributeName(),a=this.getOptionValue(l),u=this.options.find(h=>h.negate&&l===h.attributeName()),c=this.options.find(h=>!h.negate&&l===h.attributeName());return u&&(u.presetArg===void 0&&a===!1||u.presetArg!==void 0&&a===u.presetArg)?u:c||o},n=o=>{let l=i(o),a=l.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${l.envVar}'`:`option '${l.flags}'`},r=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(l=>l.long).map(l=>l.long);n=n.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);t=me(e,n)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(r=>{n.push(r.name()),r.alias()&&n.push(r.alias())}),t=me(e,n)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e} | ||
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){var n;if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=(n=this.parent)==null?void 0:n._findCommand(e);if(i){let r=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>qt(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=C.basename(e,C.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},i;return t.error?i=n=>this._outputConfiguration.writeErr(n):i=n=>this._outputConfiguration.writeOut(n),t.write=e.write||i,t.command=this,t}outputHelp(e){var r;let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),(r=this._getHelpOption())!=null&&r.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=p.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText. | ||
`),this.outputHelp({error:!0}));let i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in p.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,p.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Gt(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!t(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=o=>{let u=o.attributeName(),a=this.getOptionValue(u),l=this.options.find(h=>h.negate&&u===h.attributeName()),c=this.options.find(h=>!h.negate&&u===h.attributeName());return l&&(l.presetArg===void 0&&a===!1||l.presetArg!==void 0&&a===l.presetArg)?l:c||o},n=o=>{let u=i(o),a=u.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},r=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(u=>u.long).map(u=>u.long);n=n.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);t=me(e,n)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(r=>{n.push(r.name()),r.alias()&&n.push(r.alias())}),t=me(e,n)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e} | ||
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){var n;if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=(n=this.parent)==null?void 0:n._findCommand(e);if(i){let r=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>Ft(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=x.basename(e,x.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},i;return t.error?i=n=>this._outputConfiguration.writeErr(n):i=n=>this._outputConfiguration.writeOut(n),t.write=e.write||i,t.command=this,t}outputHelp(e){var r;let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),(r=this._getHelpOption())!=null&&r.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=p.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText. | ||
Expecting one of '${i.join("', '")}'`);let n=`${e}Help`;return this.on(n,r=>{let o;typeof t=="function"?o=t({error:r.error,command:r.command}):o=t,o&&r.write(`${o} | ||
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function pe(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?n=r[3]:i=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],i=r[3],n=r[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}de.Command=U});var xe=g(O=>{var{Argument:_e}=v(),{Command:B}=ge(),{CommanderError:Gt,InvalidArgumentError:Oe}=A(),{Help:Dt}=F(),{Option:Ce}=M();O.program=new B;O.createCommand=s=>new B(s);O.createOption=(s,e)=>new Ce(s,e);O.createArgument=(s,e)=>new _e(s,e);O.Command=B;O.Option=Ce;O.Argument=_e;O.Help=Dt;O.CommanderError=Gt;O.InvalidArgumentError=Oe;O.InvalidOptionArgumentError=Oe});var ve=g((Di,Se)=>{Se.exports=ye;ye.sync=Wt;var Ee=require("fs");function Mt(s,e){var t=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!t||(t=t.split(";"),t.indexOf("")!==-1))return!0;for(var i=0;i<t.length;i++){var n=t[i].toLowerCase();if(n&&s.substr(-n.length).toLowerCase()===n)return!0}return!1}function Ae(s,e,t){return!s.isSymbolicLink()&&!s.isFile()?!1:Mt(e,t)}function ye(s,e,t){Ee.stat(s,function(i,n){t(i,i?!1:Ae(n,s,e))})}function Wt(s,e){return Ae(Ee.statSync(s),s,e)}});var Ie=g((Mi,Ve)=>{Ve.exports=He;He.sync=Lt;var $e=require("fs");function He(s,e,t){$e.stat(s,function(i,n){t(i,i?!1:ke(n,e))})}function Lt(s,e){return ke($e.statSync(s),e)}function ke(s,e){return s.isFile()&&Rt(s,e)}function Rt(s,e){var t=s.mode,i=s.uid,n=s.gid,r=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),o=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),l=parseInt("100",8),a=parseInt("010",8),u=parseInt("001",8),c=l|a,h=t&u||t&a&&n===o||t&l&&i===r||t&c&&r===0;return h}});var Te=g((Li,Pe)=>{var Wi=require("fs"),$;process.platform==="win32"||global.TESTING_WINDOWS?$=ve():$=Ie();Pe.exports=K;K.sync=Ut;function K(s,e,t){if(typeof e=="function"&&(t=e,e={}),!t){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(i,n){K(s,e||{},function(r,o){r?n(r):i(o)})})}$(s,e||{},function(i,n){i&&(i.code==="EACCES"||e&&e.ignoreErrors)&&(i=null,n=!1),t(i,n)})}function Ut(s,e){try{return $.sync(s,e||{})}catch(t){if(e&&e.ignoreErrors||t.code==="EACCES")return!1;throw t}}});var Me=g((Ri,De)=>{var b=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Ne=require("path"),Bt=b?";":":",qe=Te(),Fe=s=>Object.assign(new Error(`not found: ${s}`),{code:"ENOENT"}),je=(s,e)=>{let t=e.colon||Bt,i=s.match(/\//)||b&&s.match(/\\/)?[""]:[...b?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(t)],n=b?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",r=b?n.split(t):[""];return b&&s.indexOf(".")!==-1&&r[0]!==""&&r.unshift(""),{pathEnv:i,pathExt:r,pathExtExe:n}},Ge=(s,e,t)=>{typeof e=="function"&&(t=e,e={}),e||(e={});let{pathEnv:i,pathExt:n,pathExtExe:r}=je(s,e),o=[],l=u=>new Promise((c,h)=>{if(u===i.length)return e.all&&o.length?c(o):h(Fe(s));let f=i[u],d=/^".*"$/.test(f)?f.slice(1,-1):f,m=Ne.join(d,s),_=!d&&/^\.[\\\/]/.test(s)?s.slice(0,2)+m:m;c(a(_,u,0))}),a=(u,c,h)=>new Promise((f,d)=>{if(h===n.length)return f(l(c+1));let m=n[h];qe(u+m,{pathExt:r},(_,E)=>{if(!_&&E)if(e.all)o.push(u+m);else return f(u+m);return f(a(u,c,h+1))})});return t?l(0).then(u=>t(null,u),t):l(0)},Kt=(s,e)=>{e=e||{};let{pathEnv:t,pathExt:i,pathExtExe:n}=je(s,e),r=[];for(let o=0;o<t.length;o++){let l=t[o],a=/^".*"$/.test(l)?l.slice(1,-1):l,u=Ne.join(a,s),c=!a&&/^\.[\\\/]/.test(s)?s.slice(0,2)+u:u;for(let h=0;h<i.length;h++){let f=c+i[h];try{if(qe.sync(f,{pathExt:n}))if(e.all)r.push(f);else return f}catch{}}}if(e.all&&r.length)return r;if(e.nothrow)return null;throw Fe(s)};De.exports=Ge;Ge.sync=Kt});var Le=g((Ui,z)=>{"use strict";var We=(s={})=>{let e=s.env||process.env;return(s.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};z.exports=We;z.exports.default=We});var Ke=g((Bi,Be)=>{"use strict";var Re=require("path"),zt=Me(),Jt=Le();function Ue(s,e){let t=s.options.env||process.env,i=process.cwd(),n=s.options.cwd!=null,r=n&&process.chdir!==void 0&&!process.chdir.disabled;if(r)try{process.chdir(s.options.cwd)}catch{}let o;try{o=zt.sync(s.command,{path:t[Jt({env:t})],pathExt:e?Re.delimiter:void 0})}catch{}finally{r&&process.chdir(i)}return o&&(o=Re.resolve(n?s.options.cwd:"",o)),o}function Xt(s){return Ue(s)||Ue(s,!0)}Be.exports=Xt});var ze=g((Ki,X)=>{"use strict";var J=/([()\][%!^"`<>&|;, *?])/g;function Yt(s){return s=s.replace(J,"^$1"),s}function Qt(s,e){return s=`${s}`,s=s.replace(/(\\*)"/g,'$1$1\\"'),s=s.replace(/(\\*)$/,"$1$1"),s=`"${s}"`,s=s.replace(J,"^$1"),e&&(s=s.replace(J,"^$1")),s}X.exports.command=Yt;X.exports.argument=Qt});var Xe=g((zi,Je)=>{"use strict";Je.exports=/^#!(.*)/});var Qe=g((Ji,Ye)=>{"use strict";var Zt=Xe();Ye.exports=(s="")=>{let e=s.match(Zt);if(!e)return null;let[t,i]=e[0].replace(/#! ?/,"").split(" "),n=t.split("/").pop();return n==="env"?i:i?`${n} ${i}`:n}});var et=g((Xi,Ze)=>{"use strict";var Y=require("fs"),ei=Qe();function ti(s){let t=Buffer.alloc(150),i;try{i=Y.openSync(s,"r"),Y.readSync(i,t,0,150,0),Y.closeSync(i)}catch{}return ei(t.toString())}Ze.exports=ti});var st=g((Yi,nt)=>{"use strict";var ii=require("path"),tt=Ke(),it=ze(),ni=et(),si=process.platform==="win32",ri=/\.(?:com|exe)$/i,oi=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function ai(s){s.file=tt(s);let e=s.file&&ni(s.file);return e?(s.args.unshift(s.file),s.command=e,tt(s)):s.file}function li(s){if(!si)return s;let e=ai(s),t=!ri.test(e);if(s.options.forceShell||t){let i=oi.test(e);s.command=ii.normalize(s.command),s.command=it.command(s.command),s.args=s.args.map(r=>it.argument(r,i));let n=[s.command].concat(s.args).join(" ");s.args=["/d","/s","/c",`"${n}"`],s.command=process.env.comspec||"cmd.exe",s.options.windowsVerbatimArguments=!0}return s}function ui(s,e,t){e&&!Array.isArray(e)&&(t=e,e=null),e=e?e.slice(0):[],t=Object.assign({},t);let i={command:s,args:e,options:t,file:void 0,original:{command:s,args:e}};return t.shell?i:li(i)}nt.exports=ui});var at=g((Qi,ot)=>{"use strict";var Q=process.platform==="win32";function Z(s,e){return Object.assign(new Error(`${e} ${s.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${s.command}`,path:s.command,spawnargs:s.args})}function ci(s,e){if(!Q)return;let t=s.emit;s.emit=function(i,n){if(i==="exit"){let r=rt(n,e,"spawn");if(r)return t.call(s,"error",r)}return t.apply(s,arguments)}}function rt(s,e){return Q&&s===1&&!e.file?Z(e.original,"spawn"):null}function hi(s,e){return Q&&s===1&&!e.file?Z(e.original,"spawnSync"):null}ot.exports={hookChildProcess:ci,verifyENOENT:rt,verifyENOENTSync:hi,notFoundError:Z}});var ct=g((Zi,w)=>{"use strict";var lt=require("child_process"),ee=st(),te=at();function ut(s,e,t){let i=ee(s,e,t),n=lt.spawn(i.command,i.args,i.options);return te.hookChildProcess(n,i),n}function fi(s,e,t){let i=ee(s,e,t),n=lt.spawnSync(i.command,i.args,i.options);return n.error=n.error||te.verifyENOENTSync(n.status,i),n}w.exports=ut;w.exports.spawn=ut;w.exports.sync=fi;w.exports._parse=ee;w.exports._enoent=te});var xi={};At(xi,{foregroundChild:()=>Ot,program:()=>we});module.exports=yt(xi);var be=V(xe(),1),{program:we,createCommand:Hi,createArgument:ki,createOption:Vi,CommanderError:Ii,InvalidArgumentError:Pi,InvalidOptionArgumentError:Ti,Command:Ni,Argument:qi,Option:Fi,Help:ji}=be.default;var gt=require("child_process"),_t=V(ct(),1);var x=[];x.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&x.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&x.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var H=s=>!!s&&typeof s=="object"&&typeof s.removeListener=="function"&&typeof s.emit=="function"&&typeof s.reallyExit=="function"&&typeof s.listeners=="function"&&typeof s.kill=="function"&&typeof s.pid=="number"&&typeof s.on=="function",ie=Symbol.for("signal-exit emitter"),ne=globalThis,mi=Object.defineProperty.bind(Object),se=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ne[ie])return ne[ie];mi(ne,ie,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let i=this.listeners[e],n=i.indexOf(t);n!==-1&&(n===0&&i.length===1?i.length=0:i.splice(n,1))}emit(e,t,i){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(let r of this.listeners[e])n=r(t,i)===!0||n;return e==="exit"&&(n=this.emit("afterExit",t,i)||n),n}},k=class{},pi=s=>({onExit(e,t){return s.onExit(e,t)},load(){return s.load()},unload(){return s.unload()}}),re=class extends k{onExit(){return()=>{}}load(){}unload(){}},oe=class extends k{#o=ae.platform==="win32"?"SIGINT":"SIGHUP";#t=new se;#e;#s;#r;#n={};#i=!1;constructor(e){super(),this.#e=e,this.#n={};for(let t of x)this.#n[t]=()=>{let i=this.#e.listeners(t),{count:n}=this.#t,r=e;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(n+=r.__signal_exit_emitter__.count),i.length===n){this.unload();let o=this.#t.emit("exit",null,t),l=t==="SIGHUP"?this.#o:t;o||e.kill(e.pid,l)}};this.#r=e.reallyExit,this.#s=e.emit}onExit(e,t){if(!H(this.#e))return()=>{};this.#i===!1&&this.load();let i=t!=null&&t.alwaysLast?"afterExit":"exit";return this.#t.on(i,e),()=>{this.#t.removeListener(i,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#i){this.#i=!0,this.#t.count+=1;for(let e of x)try{let t=this.#n[e];t&&this.#e.on(e,t)}catch{}this.#e.emit=(e,...t)=>this.#l(e,...t),this.#e.reallyExit=e=>this.#a(e)}}unload(){this.#i&&(this.#i=!1,x.forEach(e=>{let t=this.#n[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,t)}catch{}}),this.#e.emit=this.#s,this.#e.reallyExit=this.#r,this.#t.count-=1)}#a(e){return H(this.#e)?(this.#e.exitCode=e||0,this.#t.emit("exit",this.#e.exitCode,null),this.#r.call(this.#e,this.#e.exitCode)):0}#l(e,...t){let i=this.#s;if(e==="exit"&&H(this.#e)){typeof t[0]=="number"&&(this.#e.exitCode=t[0]);let n=i.call(this.#e,e,...t);return this.#t.emit("exit",this.#e.exitCode,null),n}else return i.call(this.#e,e,...t)}},ae=globalThis.process,{onExit:ht,load:nn,unload:sn}=pi(H(ae)?new oe(ae):new re);var ft=V(require("node:constants"),1),mt=Object.keys(ft.default).filter(s=>s.startsWith("SIG")&&s!=="SIGPROF"&&s!=="SIGKILL");var pt=require("child_process"),di=String.raw` | ||
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function pe(s){return s.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?n=r[3]:i=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],i=r[3],n=r[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}de.Command=U});var Ce=d(O=>{var{Argument:_e}=v(),{Command:B}=ge(),{CommanderError:Dt,InvalidArgumentError:Oe}=A(),{Help:Wt}=F(),{Option:xe}=W();O.program=new B;O.createCommand=s=>new B(s);O.createOption=(s,e)=>new xe(s,e);O.createArgument=(s,e)=>new _e(s,e);O.Command=B;O.Option=xe;O.Argument=_e;O.Help=Wt;O.CommanderError=Dt;O.InvalidArgumentError=Oe;O.InvalidOptionArgumentError=Oe});var ve=d((Di,Se)=>{Se.exports=ye;ye.sync=Lt;var Ee=require("fs");function Mt(s,e){var t=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!t||(t=t.split(";"),t.indexOf("")!==-1))return!0;for(var i=0;i<t.length;i++){var n=t[i].toLowerCase();if(n&&s.substr(-n.length).toLowerCase()===n)return!0}return!1}function Ae(s,e,t){return!s.isSymbolicLink()&&!s.isFile()?!1:Mt(e,t)}function ye(s,e,t){Ee.stat(s,function(i,n){t(i,i?!1:Ae(n,s,e))})}function Lt(s,e){return Ae(Ee.statSync(s),s,e)}});var Pe=d((Wi,Ve)=>{Ve.exports=He;He.sync=Rt;var $e=require("fs");function He(s,e,t){$e.stat(s,function(i,n){t(i,i?!1:ke(n,e))})}function Rt(s,e){return ke($e.statSync(s),e)}function ke(s,e){return s.isFile()&&Ut(s,e)}function Ut(s,e){var t=s.mode,i=s.uid,n=s.gid,r=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),o=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),u=parseInt("100",8),a=parseInt("010",8),l=parseInt("001",8),c=u|a,h=t&l||t&a&&n===o||t&u&&i===r||t&c&&r===0;return h}});var Te=d((Li,Ie)=>{var Mi=require("fs"),$;process.platform==="win32"||global.TESTING_WINDOWS?$=ve():$=Pe();Ie.exports=K;K.sync=Bt;function K(s,e,t){if(typeof e=="function"&&(t=e,e={}),!t){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(i,n){K(s,e||{},function(r,o){r?n(r):i(o)})})}$(s,e||{},function(i,n){i&&(i.code==="EACCES"||e&&e.ignoreErrors)&&(i=null,n=!1),t(i,n)})}function Bt(s,e){try{return $.sync(s,e||{})}catch(t){if(e&&e.ignoreErrors||t.code==="EACCES")return!1;throw t}}});var We=d((Ri,De)=>{var b=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Ne=require("path"),Kt=b?";":":",qe=Te(),Fe=s=>Object.assign(new Error(`not found: ${s}`),{code:"ENOENT"}),je=(s,e)=>{let t=e.colon||Kt,i=s.match(/\//)||b&&s.match(/\\/)?[""]:[...b?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(t)],n=b?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",r=b?n.split(t):[""];return b&&s.indexOf(".")!==-1&&r[0]!==""&&r.unshift(""),{pathEnv:i,pathExt:r,pathExtExe:n}},Ge=(s,e,t)=>{typeof e=="function"&&(t=e,e={}),e||(e={});let{pathEnv:i,pathExt:n,pathExtExe:r}=je(s,e),o=[],u=l=>new Promise((c,h)=>{if(l===i.length)return e.all&&o.length?c(o):h(Fe(s));let f=i[l],g=/^".*"$/.test(f)?f.slice(1,-1):f,m=Ne.join(g,s),_=!g&&/^\.[\\\/]/.test(s)?s.slice(0,2)+m:m;c(a(_,l,0))}),a=(l,c,h)=>new Promise((f,g)=>{if(h===n.length)return f(u(c+1));let m=n[h];qe(l+m,{pathExt:r},(_,E)=>{if(!_&&E)if(e.all)o.push(l+m);else return f(l+m);return f(a(l,c,h+1))})});return t?u(0).then(l=>t(null,l),t):u(0)},zt=(s,e)=>{e=e||{};let{pathEnv:t,pathExt:i,pathExtExe:n}=je(s,e),r=[];for(let o=0;o<t.length;o++){let u=t[o],a=/^".*"$/.test(u)?u.slice(1,-1):u,l=Ne.join(a,s),c=!a&&/^\.[\\\/]/.test(s)?s.slice(0,2)+l:l;for(let h=0;h<i.length;h++){let f=c+i[h];try{if(qe.sync(f,{pathExt:n}))if(e.all)r.push(f);else return f}catch{}}}if(e.all&&r.length)return r;if(e.nothrow)return null;throw Fe(s)};De.exports=Ge;Ge.sync=zt});var Le=d((Ui,z)=>{"use strict";var Me=(s={})=>{let e=s.env||process.env;return(s.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(i=>i.toUpperCase()==="PATH")||"Path"};z.exports=Me;z.exports.default=Me});var Ke=d((Bi,Be)=>{"use strict";var Re=require("path"),Jt=We(),Xt=Le();function Ue(s,e){let t=s.options.env||process.env,i=process.cwd(),n=s.options.cwd!=null,r=n&&process.chdir!==void 0&&!process.chdir.disabled;if(r)try{process.chdir(s.options.cwd)}catch{}let o;try{o=Jt.sync(s.command,{path:t[Xt({env:t})],pathExt:e?Re.delimiter:void 0})}catch{}finally{r&&process.chdir(i)}return o&&(o=Re.resolve(n?s.options.cwd:"",o)),o}function Yt(s){return Ue(s)||Ue(s,!0)}Be.exports=Yt});var ze=d((Ki,X)=>{"use strict";var J=/([()\][%!^"`<>&|;, *?])/g;function Qt(s){return s=s.replace(J,"^$1"),s}function Zt(s,e){return s=`${s}`,s=s.replace(/(\\*)"/g,'$1$1\\"'),s=s.replace(/(\\*)$/,"$1$1"),s=`"${s}"`,s=s.replace(J,"^$1"),e&&(s=s.replace(J,"^$1")),s}X.exports.command=Qt;X.exports.argument=Zt});var Xe=d((zi,Je)=>{"use strict";Je.exports=/^#!(.*)/});var Qe=d((Ji,Ye)=>{"use strict";var ei=Xe();Ye.exports=(s="")=>{let e=s.match(ei);if(!e)return null;let[t,i]=e[0].replace(/#! ?/,"").split(" "),n=t.split("/").pop();return n==="env"?i:i?`${n} ${i}`:n}});var et=d((Xi,Ze)=>{"use strict";var Y=require("fs"),ti=Qe();function ii(s){let t=Buffer.alloc(150),i;try{i=Y.openSync(s,"r"),Y.readSync(i,t,0,150,0),Y.closeSync(i)}catch{}return ti(t.toString())}Ze.exports=ii});var st=d((Yi,nt)=>{"use strict";var ni=require("path"),tt=Ke(),it=ze(),si=et(),ri=process.platform==="win32",oi=/\.(?:com|exe)$/i,ai=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function li(s){s.file=tt(s);let e=s.file&&si(s.file);return e?(s.args.unshift(s.file),s.command=e,tt(s)):s.file}function ui(s){if(!ri)return s;let e=li(s),t=!oi.test(e);if(s.options.forceShell||t){let i=ai.test(e);s.command=ni.normalize(s.command),s.command=it.command(s.command),s.args=s.args.map(r=>it.argument(r,i));let n=[s.command].concat(s.args).join(" ");s.args=["/d","/s","/c",`"${n}"`],s.command=process.env.comspec||"cmd.exe",s.options.windowsVerbatimArguments=!0}return s}function ci(s,e,t){e&&!Array.isArray(e)&&(t=e,e=null),e=e?e.slice(0):[],t=Object.assign({},t);let i={command:s,args:e,options:t,file:void 0,original:{command:s,args:e}};return t.shell?i:ui(i)}nt.exports=ci});var at=d((Qi,ot)=>{"use strict";var Q=process.platform==="win32";function Z(s,e){return Object.assign(new Error(`${e} ${s.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${s.command}`,path:s.command,spawnargs:s.args})}function hi(s,e){if(!Q)return;let t=s.emit;s.emit=function(i,n){if(i==="exit"){let r=rt(n,e,"spawn");if(r)return t.call(s,"error",r)}return t.apply(s,arguments)}}function rt(s,e){return Q&&s===1&&!e.file?Z(e.original,"spawn"):null}function fi(s,e){return Q&&s===1&&!e.file?Z(e.original,"spawnSync"):null}ot.exports={hookChildProcess:hi,verifyENOENT:rt,verifyENOENTSync:fi,notFoundError:Z}});var ct=d((Zi,w)=>{"use strict";var lt=require("child_process"),ee=st(),te=at();function ut(s,e,t){let i=ee(s,e,t),n=lt.spawn(i.command,i.args,i.options);return te.hookChildProcess(n,i),n}function mi(s,e,t){let i=ee(s,e,t),n=lt.spawnSync(i.command,i.args,i.options);return n.error=n.error||te.verifyENOENTSync(n.status,i),n}w.exports=ut;w.exports.spawn=ut;w.exports.sync=mi;w.exports._parse=ee;w.exports._enoent=te});var Ci={};yt(Ci,{foregroundChild:()=>xt,program:()=>we});module.exports=St(Ci);var be=V(Ce(),1),{program:we,createCommand:Hi,createArgument:ki,createOption:Vi,CommanderError:Pi,InvalidArgumentError:Ii,InvalidOptionArgumentError:Ti,Command:Ni,Argument:qi,Option:Fi,Help:ji}=be.default;var _t=require("child_process"),Ot=V(ct(),1);var C=[];C.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&C.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&C.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var H=s=>!!s&&typeof s=="object"&&typeof s.removeListener=="function"&&typeof s.emit=="function"&&typeof s.reallyExit=="function"&&typeof s.listeners=="function"&&typeof s.kill=="function"&&typeof s.pid=="number"&&typeof s.on=="function",ie=Symbol.for("signal-exit emitter"),ne=globalThis,pi=Object.defineProperty.bind(Object),se=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(ne[ie])return ne[ie];pi(ne,ie,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,t){this.listeners[e].push(t)}removeListener(e,t){let i=this.listeners[e],n=i.indexOf(t);n!==-1&&(n===0&&i.length===1?i.length=0:i.splice(n,1))}emit(e,t,i){if(this.emitted[e])return!1;this.emitted[e]=!0;let n=!1;for(let r of this.listeners[e])n=r(t,i)===!0||n;return e==="exit"&&(n=this.emit("afterExit",t,i)||n),n}},k=class{},di=s=>({onExit(e,t){return s.onExit(e,t)},load(){return s.load()},unload(){return s.unload()}}),re=class extends k{onExit(){return()=>{}}load(){}unload(){}},oe=class extends k{#o=ae.platform==="win32"?"SIGINT":"SIGHUP";#t=new se;#e;#s;#r;#n={};#i=!1;constructor(e){super(),this.#e=e,this.#n={};for(let t of C)this.#n[t]=()=>{let i=this.#e.listeners(t),{count:n}=this.#t,r=e;if(typeof r.__signal_exit_emitter__=="object"&&typeof r.__signal_exit_emitter__.count=="number"&&(n+=r.__signal_exit_emitter__.count),i.length===n){this.unload();let o=this.#t.emit("exit",null,t),u=t==="SIGHUP"?this.#o:t;o||e.kill(e.pid,u)}};this.#r=e.reallyExit,this.#s=e.emit}onExit(e,t){if(!H(this.#e))return()=>{};this.#i===!1&&this.load();let i=t!=null&&t.alwaysLast?"afterExit":"exit";return this.#t.on(i,e),()=>{this.#t.removeListener(i,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#i){this.#i=!0,this.#t.count+=1;for(let e of C)try{let t=this.#n[e];t&&this.#e.on(e,t)}catch{}this.#e.emit=(e,...t)=>this.#l(e,...t),this.#e.reallyExit=e=>this.#a(e)}}unload(){this.#i&&(this.#i=!1,C.forEach(e=>{let t=this.#n[e];if(!t)throw new Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,t)}catch{}}),this.#e.emit=this.#s,this.#e.reallyExit=this.#r,this.#t.count-=1)}#a(e){return H(this.#e)?(this.#e.exitCode=e||0,this.#t.emit("exit",this.#e.exitCode,null),this.#r.call(this.#e,this.#e.exitCode)):0}#l(e,...t){let i=this.#s;if(e==="exit"&&H(this.#e)){typeof t[0]=="number"&&(this.#e.exitCode=t[0]);let n=i.call(this.#e,e,...t);return this.#t.emit("exit",this.#e.exitCode,null),n}else return i.call(this.#e,e,...t)}},ae=globalThis.process,{onExit:ht,load:nn,unload:sn}=di(H(ae)?new oe(ae):new re);var ft=V(require("node:constants"),1),mt=Object.keys(ft.default).filter(s=>s.startsWith("SIG")&&s!=="SIGPROF"&&s!=="SIGKILL");var pt=s=>{let e=new Map;for(let i of mt){let n=()=>{try{s.kill(i)}catch{}};try{process.on(i,n),e.set(i,n)}catch{}}let t=()=>{for(let[i,n]of e)process.removeListener(i,n)};return s.on("exit",t),t};var dt=require("child_process"),gi=String.raw` | ||
const pid = parseInt(process.argv[1], 10) | ||
@@ -43,2 +43,2 @@ process.title = 'node (foreground-child watchdog pid=' + pid + ')' | ||
} | ||
`,dt=s=>{let e=!1,t=(0,pt.spawn)(process.execPath,["-e",di,String(s.pid)],{stdio:"ignore"});return t.on("exit",()=>e=!0),s.on("exit",()=>{e||t.kill("SIGTERM")}),t};var gi=(process==null?void 0:process.platform)==="win32"?_t.default:gt.spawn,_i=s=>{let[e,t=[],i={},n=()=>{}]=s;if(typeof t=="function"?(n=t,i={},t=[]):t&&typeof t=="object"&&!Array.isArray(t)?(typeof i=="function"&&(n=i),i=t,t=[]):typeof i=="function"&&(n=i,i={}),Array.isArray(e)){let[r,...o]=e;e=r,t=o}return[e,t,{...i},n]};function Ot(...s){let[e,t,i,n]=_i(s);i.stdio=[0,1,2],process.send&&i.stdio.push("ipc");let r=gi(e,t,i),o=Oi(r),a=ht(()=>{try{r.kill("SIGHUP")}catch{r.kill("SIGTERM")}}),u=dt(r),c=!1;return r.on("close",async(h,f)=>{if(u.kill("SIGKILL"),c)return;c=!0;let d=n(h,f),m=Ci(d)?await d:d;if(a(),o(),m!==!1)if(typeof m=="string"?(f=m,h=null):typeof m=="number"&&(h=m,f=null),f){setTimeout(()=>{},2e3);try{process.kill(process.pid,f)}catch{process.kill(process.pid,"SIGTERM")}}else process.exit(h||0)}),process.send&&(process.removeAllListeners("message"),r.on("message",(h,f)=>{var d;(d=process.send)==null||d.call(process,h,f)}),process.on("message",(h,f)=>{r.send(h,f)})),r}var Oi=s=>{let e=new Map;for(let t of mt){let i=()=>{try{s.kill(t)}catch{}};try{process.on(t,i),e.set(t,i)}catch{}}return()=>{for(let[t,i]of e)process.removeListener(t,i)}},Ci=s=>!!s&&typeof s=="object"&&typeof s.then=="function";0&&(module.exports={foregroundChild,program}); | ||
`,gt=s=>{let e=!1,t=(0,dt.spawn)(process.execPath,["-e",gi,String(s.pid)],{stdio:"ignore"});return t.on("exit",()=>e=!0),s.on("exit",()=>{e||t.kill("SIGKILL")}),t};var _i=(process==null?void 0:process.platform)==="win32"?Ot.default:_t.spawn,Oi=s=>{let[e,t=[],i={},n=()=>{}]=s;if(typeof t=="function"?(n=t,i={},t=[]):t&&typeof t=="object"&&!Array.isArray(t)?(typeof i=="function"&&(n=i),i=t,t=[]):typeof i=="function"&&(n=i,i={}),Array.isArray(e)){let[r,...o]=e;e=r,t=o}return[e,t,{...i},n]};function xt(...s){let[e,t,i,n]=Oi(s);i.stdio=[0,1,2],process.send&&i.stdio.push("ipc");let r=_i(e,t,i),u=ht(()=>{try{r.kill("SIGHUP")}catch{r.kill("SIGTERM")}});pt(r),gt(r);let a=!1;return r.on("close",async(l,c)=>{if(a)return;a=!0;let h=n(l,c),f=xi(h)?await h:h;if(u(),f!==!1)if(typeof f=="string"?(c=f,l=null):typeof f=="number"&&(l=f,c=null),c){setTimeout(()=>{},2e3);try{process.kill(process.pid,c)}catch{process.kill(process.pid,"SIGTERM")}}else process.exit(l||0)}),process.send&&(process.removeAllListeners("message"),r.on("message",(l,c)=>{var h;(h=process.send)==null||h.call(process,l,c)}),process.on("message",(l,c)=>{r.send(l,c)})),r}var xi=s=>!!s&&typeof s=="object"&&typeof s.then=="function";0&&(module.exports={foregroundChild,program}); |
@@ -207,30 +207,20 @@ const Util = { | ||
const quickFindRange = (position, ranges) => { | ||
let start = 0; | ||
let end = ranges.length - 1; | ||
while (end - start > 1) { | ||
const i = Math.floor((start + end) * 0.5); | ||
const item = ranges[i]; | ||
if (position < item[startKey]) { | ||
end = i; | ||
continue; | ||
} | ||
if (position > item[endKey]) { | ||
start = i; | ||
continue; | ||
} | ||
return ranges[i]; | ||
} | ||
// last two items, less is start | ||
const endItem = ranges[end]; | ||
if (position < endItem[startKey]) { | ||
return ranges[start]; | ||
} | ||
return ranges[end]; | ||
}; | ||
// rangeList should be sorted by startKey, but seems useless here | ||
const range = quickFindRange(startPos, rangeList); | ||
if (startPos >= range[startKey] && endPos <= range[endKey]) { | ||
return range; | ||
const listStart = rangeList.filter((it) => startPos >= it[startKey]); | ||
if (!listStart.length) { | ||
return; | ||
} | ||
const list = listStart.filter((it) => endPos <= it[endKey]); | ||
if (!list.length) { | ||
return; | ||
} | ||
// could be multiple results, but seems no case for now | ||
// if (list.length > 1) { | ||
// console.log('==============', list); | ||
// } | ||
return list[0]; | ||
}, | ||
@@ -342,2 +332,33 @@ | ||
updateLinesCoverage: (lines, count, lineMap) => { | ||
lines.forEach((it) => { | ||
const lineItem = lineMap.get(it.line); | ||
if (!lineItem) { | ||
// not found line, could be comment or blank line | ||
return; | ||
} | ||
if (lineItem.ignored) { | ||
return; | ||
} | ||
it.count = count; | ||
// default is covered, so only focus on | ||
// 1, biggest covered count | ||
// 2, uncovered entire and pieces | ||
if (count > 0) { | ||
lineItem.coveredCount = Math.max(lineItem.coveredCount, count); | ||
} else { | ||
if (it.entire) { | ||
lineItem.uncoveredEntire = it; | ||
} else { | ||
lineItem.uncoveredPieces.push(it); | ||
} | ||
} | ||
}); | ||
}, | ||
// ============================================================================= | ||
@@ -344,0 +365,0 @@ // svg |
@@ -0,0 +0,0 @@ const { register } = require('module'); |
@@ -0,0 +0,0 @@ const CG = require('console-grid'); |
@@ -369,2 +369,12 @@ const fs = require('fs'); | ||
// offset key | ||
sortOffsetRanges: (ranges) => { | ||
ranges.sort((a, b) => { | ||
if (a.startOffset === b.startOffset) { | ||
return a.endOffset - b.endOffset; | ||
} | ||
return a.startOffset - b.startOffset; | ||
}); | ||
}, | ||
forEachFile: function(dir, extList, callback) { | ||
@@ -371,0 +381,0 @@ if (!fs.existsSync(dir)) { |
{ | ||
"name": "monocart-coverage-reports", | ||
"version": "2.8.3", | ||
"version": "2.8.4", | ||
"description": "A code coverage tool to generate native V8 reports or Istanbul reports.", | ||
@@ -58,4 +58,5 @@ "main": "./lib/index.js", | ||
"test:snap": "cross-env TEST_SNAPSHOT=true npm run test", | ||
"dev": "sf d v8", | ||
"dev": "sf d app", | ||
"open": "node ./scripts/open.js", | ||
"eol": "git rm -rf --cached . && git reset --hard HEAD", | ||
"patch": "npm run build && npm run test && sf publish patch -r" | ||
@@ -83,12 +84,12 @@ }, | ||
"lz-utils": "^2.0.2", | ||
"monocart-code-viewer": "^1.1.3", | ||
"monocart-code-viewer": "^1.1.4", | ||
"monocart-formatter": "^3.0.0", | ||
"monocart-locator": "^1.0.0", | ||
"turbogrid": "^3.0.13" | ||
"turbogrid": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"commander": "^12.1.0", | ||
"esbuild": "^0.21.4", | ||
"eslint": "~9.3.0", | ||
"eslint-config-plus": "^2.0.0", | ||
"esbuild": "^0.21.5", | ||
"eslint": "~9.5.0", | ||
"eslint-config-plus": "^2.0.2", | ||
"eslint-plugin-html": "^8.1.1", | ||
@@ -98,8 +99,8 @@ "eslint-plugin-vue": "^9.26.0", | ||
"minimatch": "^9.0.4", | ||
"stylelint": "^16.6.0", | ||
"stylelint": "^16.6.1", | ||
"stylelint-config-plus": "^1.1.2", | ||
"supports-color": "^9.4.0", | ||
"tsx": "^4.11.0", | ||
"tsx": "^4.15.5", | ||
"ws": "^8.17.0" | ||
} | ||
} |
@@ -42,2 +42,3 @@ # Monocart Coverage Reports | ||
- [Playwright](#playwright) | ||
- [c8](#c8) | ||
- [CodeceptJS](#codeceptjs) | ||
@@ -918,3 +919,2 @@ - [Jest](#jest) | ||
- [monocart-reporter](https://github.com/cenfun/monocart-reporter) - Playwright custom reporter, supports generating [Code coverage report](https://github.com/cenfun/monocart-reporter?#code-coverage-report) | ||
- [merge-code-coverage](https://github.com/cenfun/merge-code-coverage) - Example for merging code coverage (unit + e2e shard) | ||
- Coverage for component testing with `monocart-reporter`: | ||
@@ -929,10 +929,18 @@ - [playwright-ct-vue](https://github.com/cenfun/playwright-ct-vue) | ||
### [c8](https://github.com/bcoe/c8) | ||
- c8 has integrated `MCR` as an experimental feature since [v10.1.0](https://github.com/bcoe/c8/releases/tag/v10.1.0) | ||
```sh | ||
c8 --experimental-monocart --reporter=v8 --reporter=console-details node foo.js | ||
``` | ||
### [CodeceptJS](https://github.com/codeceptjs/CodeceptJS) | ||
- CodeceptJS is a [BDD](https://codecept.io/bdd/) + [AI](https://codecept.io/ai/) testing framework for e2e testing, it has integrated `MCR` since [v3.5.15](https://github.com/codeceptjs/CodeceptJS/releases/tag/3.5.15), see [plugins/coverage](https://codecept.io/plugins/#coverage). There's no need to use ~~[codeceptjs-monocart-coverage](https://github.com/cenfun/codeceptjs-monocart-coverage)~~ anymore. | ||
- CodeceptJS is a [BDD](https://codecept.io/bdd/) + [AI](https://codecept.io/ai/) testing framework for e2e testing, it has integrated `MCR` since [v3.5.15](https://github.com/codeceptjs/CodeceptJS/releases/tag/3.5.15), see [plugins/coverage](https://codecept.io/plugins/#coverage) | ||
### [Jest](https://github.com/jestjs/jest/) | ||
- [jest-monocart-coverage](https://github.com/cenfun/jest-monocart-coverage) - Jest custom reporter for coverage reports | ||
- [merge-code-coverage](https://github.com/cenfun/merge-code-coverage) - Example for merging code coverage (Jest unit + Playwright e2e sharding) | ||
### [Vitest](https://github.com/vitest-dev/vitest) | ||
- [vitest-monocart-coverage](https://github.com/cenfun/vitest-monocart-coverage) - Vitest custom provider module for coverage reports | ||
- [merge-code-coverage-vitest](https://github.com/cenfun/merge-code-coverage-vitest) - Example for merging code coverage (Vitest unit + Playwright e2e sharding) | ||
@@ -1068,3 +1076,10 @@ ### [Puppeteer](https://github.com/puppeteer/puppeteer/) | ||
``` | ||
- Refreshing `eol=lf` for snapshot of test (Windows) | ||
```sh | ||
git add . -u | ||
git commit -m "Saving files before refreshing line endings" | ||
npm run eol | ||
``` | ||
### VSCode Extension | ||
@@ -1071,0 +1086,0 @@ - [Coverage Gutters](https://github.com/ryanluker/vscode-coverage-gutters) - Display test coverage generated by lcov or xml in VSCode editor. |
@@ -42,2 +42,3 @@ # Monocart Coverage Reports | ||
- [Playwright](#playwright) | ||
- [c8](#c8) | ||
- [CodeceptJS](#codeceptjs) | ||
@@ -922,3 +923,2 @@ - [Jest](#jest) | ||
- [monocart-reporter](https://github.com/cenfun/monocart-reporter) - Playwright custom reporter, supports generating [Code coverage report](https://github.com/cenfun/monocart-reporter?#code-coverage-report) | ||
- [merge-code-coverage](https://github.com/cenfun/merge-code-coverage) - Example for merging code coverage (unit + e2e shard) | ||
- Coverage for component testing with `monocart-reporter`: | ||
@@ -933,10 +933,18 @@ - [playwright-ct-vue](https://github.com/cenfun/playwright-ct-vue) | ||
### [c8](https://github.com/bcoe/c8) | ||
- c8 has integrated `MCR` as an experimental feature since [v10.1.0](https://github.com/bcoe/c8/releases/tag/v10.1.0) | ||
```sh | ||
c8 --experimental-monocart --reporter=v8 --reporter=console-details node foo.js | ||
``` | ||
### [CodeceptJS](https://github.com/codeceptjs/CodeceptJS) | ||
- CodeceptJS is a [BDD](https://codecept.io/bdd/) + [AI](https://codecept.io/ai/) testing framework for e2e testing, it has integrated `MCR` since [v3.5.15](https://github.com/codeceptjs/CodeceptJS/releases/tag/3.5.15), see [plugins/coverage](https://codecept.io/plugins/#coverage). There's no need to use ~~[codeceptjs-monocart-coverage](https://github.com/cenfun/codeceptjs-monocart-coverage)~~ anymore. | ||
- CodeceptJS is a [BDD](https://codecept.io/bdd/) + [AI](https://codecept.io/ai/) testing framework for e2e testing, it has integrated `MCR` since [v3.5.15](https://github.com/codeceptjs/CodeceptJS/releases/tag/3.5.15), see [plugins/coverage](https://codecept.io/plugins/#coverage) | ||
### [Jest](https://github.com/jestjs/jest/) | ||
- [jest-monocart-coverage](https://github.com/cenfun/jest-monocart-coverage) - Jest custom reporter for coverage reports | ||
- [merge-code-coverage](https://github.com/cenfun/merge-code-coverage) - Example for merging code coverage (Jest unit + Playwright e2e sharding) | ||
### [Vitest](https://github.com/vitest-dev/vitest) | ||
- [vitest-monocart-coverage](https://github.com/cenfun/vitest-monocart-coverage) - Vitest custom provider module for coverage reports | ||
- [merge-code-coverage-vitest](https://github.com/cenfun/merge-code-coverage-vitest) - Example for merging code coverage (Vitest unit + Playwright e2e sharding) | ||
@@ -1072,3 +1080,10 @@ ### [Puppeteer](https://github.com/puppeteer/puppeteer/) | ||
``` | ||
- Refreshing `eol=lf` for snapshot of test (Windows) | ||
```sh | ||
git add . -u | ||
git commit -m "Saving files before refreshing line endings" | ||
npm run eol | ||
``` | ||
### VSCode Extension | ||
@@ -1075,0 +1090,0 @@ - [Coverage Gutters](https://github.com/ryanluker/vscode-coverage-gutters) - Display test coverage generated by lcov or xml in VSCode editor. |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
908986
9227
1085
Updatedmonocart-code-viewer@^1.1.4
Updatedturbogrid@^3.1.0