@lahat-group/cli 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,42 +1,42 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
3
- var Lt=Object.create;var Ee=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var Mt=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,Wt=Object.prototype.hasOwnProperty;var q=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Jt=(n,e)=>()=>(n&&(e=n(n=0)),e);var P=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var zt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Mt(e))!Wt.call(n,i)&&i!==t&&Ee(n,i,{get:()=>e[i],enumerable:!(r=Ut(e,i))||r.enumerable});return n};var Gt=(n,e,t)=>(t=n!=null?Lt(Bt(n)):{},zt(e||!n||!n.__esModule?Ee(t,"default",{value:n,enumerable:!0}):t,n));import Wr from"path";import{fileURLToPath as zr}from"url";var u=Jt(()=>{"use strict"});var H=P(Q=>{"use strict";u();var U=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},X=class extends U{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Q.CommanderError=U;Q.InvalidArgumentError=X});var M=P(ee=>{"use strict";u();var{InvalidArgumentError:Kt}=H(),Z=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,r)=>{if(!this.argChoices.includes(t))throw new Kt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Yt(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}ee.Argument=Z;ee.humanReadableArgName=Yt});var re=P(Se=>{"use strict";u();var{humanReadableArgName:Xt}=M(),te=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let r=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),r=e._getHelpOption();if(r&&!r.hidden){let i=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!i&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!i&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let i=r.options.filter(s=>!s.hidden);t.push(...i)}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(r=>Xt(r)).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((r,i)=>Math.max(r,t.subcommandTerm(i).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,i)=>Math.max(r,t.optionTerm(i).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,i)=>Math.max(r,t.optionTerm(i).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,i)=>Math.max(r,t.argumentTerm(i).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let i=e.parent;i;i=i.parent)r=i.name()+" "+r;return r+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(r=>JSON.stringify(r)).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(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),i=t.helpWidth||80,s=2,o=2;function c(b,v){if(v){let Y=`${b.padEnd(r+o)}${v}`;return t.wrap(Y,i-s,r+o)}return b}function a(b){return b.join(`
4
- `).replace(/^/gm," ".repeat(s))}let l=[`Usage: ${t.commandUsage(e)}`,""],h=t.commandDescription(e);h.length>0&&(l=l.concat([t.wrap(h,i,0),""]));let f=t.visibleArguments(e).map(b=>c(t.argumentTerm(b),t.argumentDescription(b)));f.length>0&&(l=l.concat(["Arguments:",a(f),""]));let _=t.visibleOptions(e).map(b=>c(t.optionTerm(b),t.optionDescription(b)));if(_.length>0&&(l=l.concat(["Options:",a(_),""])),this.showGlobalOptions){let b=t.visibleGlobalOptions(e).map(v=>c(t.optionTerm(v),t.optionDescription(v)));b.length>0&&(l=l.concat(["Global Options:",a(b),""]))}let S=t.visibleCommands(e).map(b=>c(t.subcommandTerm(b),t.subcommandDescription(b)));return S.length>0&&(l=l.concat(["Commands:",a(S),""])),l.join(`
3
+ var Mt=Object.create;var Se=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var Jt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty;var q=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Gt=(n,e)=>()=>(n&&(e=n(n=0)),e);var P=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Kt=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Wt(e))!zt.call(n,i)&&i!==t&&Se(n,i,{get:()=>e[i],enumerable:!(r=Bt(e,i))||r.enumerable});return n};var Yt=(n,e,t)=>(t=n!=null?Mt(Jt(n)):{},Kt(e||!n||!n.__esModule?Se(t,"default",{value:n,enumerable:!0}):t,n));import Jr from"path";import{fileURLToPath as Gr}from"url";var u=Gt(()=>{"use strict"});var H=P(Q=>{"use strict";u();var U=class extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},X=class extends U{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};Q.CommanderError=U;Q.InvalidArgumentError=X});var M=P(ee=>{"use strict";u();var{InvalidArgumentError:Xt}=H(),Z=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,r)=>{if(!this.argChoices.includes(t))throw new Xt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Qt(n){let e=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+e+">":"["+e+"]"}ee.Argument=Z;ee.humanReadableArgName=Qt});var re=P(Pe=>{"use strict";u();var{humanReadableArgName:Zt}=M(),te=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),r=e._getHelpCommand();return r&&!r._hidden&&t.push(r),this.sortSubcommands&&t.sort((i,s)=>i.name().localeCompare(s.name())),t}compareOptions(e,t){let r=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),r=e._getHelpOption();if(r&&!r.hidden){let i=r.short&&e._findOption(r.short),s=r.long&&e._findOption(r.long);!i&&!s?t.push(r):r.long&&!s?t.push(e.createOption(r.long,r.description)):r.short&&!i&&t.push(e.createOption(r.short,r.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let r=e.parent;r;r=r.parent){let i=r.options.filter(s=>!s.hidden);t.push(...i)}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(r=>Zt(r)).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((r,i)=>Math.max(r,t.subcommandTerm(i).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((r,i)=>Math.max(r,t.optionTerm(i).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((r,i)=>Math.max(r,t.optionTerm(i).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((r,i)=>Math.max(r,t.argumentTerm(i).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let i=e.parent;i;i=i.parent)r=i.name()+" "+r;return r+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(r=>JSON.stringify(r)).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(r=>JSON.stringify(r)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){let r=t.padWidth(e,t),i=t.helpWidth||80,s=2,o=2;function c(b,A){if(A){let Y=`${b.padEnd(r+o)}${A}`;return t.wrap(Y,i-s,r+o)}return b}function a(b){return b.join(`
4
+ `).replace(/^/gm," ".repeat(s))}let l=[`Usage: ${t.commandUsage(e)}`,""],h=t.commandDescription(e);h.length>0&&(l=l.concat([t.wrap(h,i,0),""]));let f=t.visibleArguments(e).map(b=>c(t.argumentTerm(b),t.argumentDescription(b)));f.length>0&&(l=l.concat(["Arguments:",a(f),""]));let _=t.visibleOptions(e).map(b=>c(t.optionTerm(b),t.optionDescription(b)));if(_.length>0&&(l=l.concat(["Options:",a(_),""])),this.showGlobalOptions){let b=t.visibleGlobalOptions(e).map(A=>c(t.optionTerm(A),t.optionDescription(A)));b.length>0&&(l=l.concat(["Global Options:",a(b),""]))}let S=t.visibleCommands(e).map(b=>c(t.subcommandTerm(b),t.subcommandDescription(b)));return S.length>0&&(l=l.concat(["Commands:",a(S),""])),l.join(`
5
5
  `)}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,r,i=40){let s=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",o=new RegExp(`[\\n][${s}]+`);if(e.match(o))return e;let c=t-r;if(c<i)return e;let a=e.slice(0,r),l=e.slice(r).replace(`\r
6
6
  `,`
7
7
  `),h=" ".repeat(r),_="\\s\u200B",S=new RegExp(`
8
- |.{1,${c-1}}([${_}]|$)|[^${_}]+?([${_}]|$)`,"g"),b=l.match(S)||[];return a+b.map((v,Y)=>v===`
9
- `?"":(Y>0?h:"")+v.trimEnd()).join(`
10
- `)}};Se.Help=te});var oe=P(se=>{"use strict";u();var{InvalidArgumentError:Qt}=H(),ne=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 r=er(e);this.short=r.shortFlag,this.long=r.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,r)=>{if(!this.argChoices.includes(t))throw new Qt(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return Zt(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},ie=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,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let i=this.negativeOptions.get(r).presetArg,s=i!==void 0?i:!1;return t.negate===(s===e)}};function Zt(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function er(n){let e,t,r=n.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),t=r.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}se.Option=ne;se.DualOptions=ie});var ke=P(Pe=>{"use strict";u();function tr(n,e){if(Math.abs(n.length-e.length)>3)return Math.max(n.length,e.length);let t=[];for(let r=0;r<=n.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let i=1;i<=n.length;i++){let s=1;n[i-1]===e[r-1]?s=0:s=1,t[i][r]=Math.min(t[i-1][r]+1,t[i][r-1]+1,t[i-1][r-1]+s),i>1&&r>1&&n[i-1]===e[r-2]&&n[i-2]===e[r-1]&&(t[i][r]=Math.min(t[i][r],t[i-2][r-2]+1))}return t[n.length][e.length]}function rr(n,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=n.startsWith("--");t&&(n=n.slice(2),e=e.map(o=>o.slice(2)));let r=[],i=3,s=.4;return e.forEach(o=>{if(o.length<=1)return;let c=tr(n,o),a=Math.max(n.length,o.length);(a-c)/a>s&&(c<i?(i=c,r=[o]):c===i&&r.push(o))}),r.sort((o,c)=>o.localeCompare(c)),t&&(r=r.map(o=>`--${o}`)),r.length>1?`
8
+ |.{1,${c-1}}([${_}]|$)|[^${_}]+?([${_}]|$)`,"g"),b=l.match(S)||[];return a+b.map((A,Y)=>A===`
9
+ `?"":(Y>0?h:"")+A.trimEnd()).join(`
10
+ `)}};Pe.Help=te});var oe=P(se=>{"use strict";u();var{InvalidArgumentError:er}=H(),ne=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 r=rr(e);this.short=r.shortFlag,this.long=r.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,r)=>{if(!this.argChoices.includes(t))throw new er(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return tr(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},ie=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,r)=>{this.positiveOptions.has(r)&&this.dualOptions.add(r)})}valueFromOption(e,t){let r=t.attributeName();if(!this.dualOptions.has(r))return!0;let i=this.negativeOptions.get(r).presetArg,s=i!==void 0?i:!1;return t.negate===(s===e)}};function tr(n){return n.split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}function rr(n){let e,t,r=n.split(/[ |,]+/);return r.length>1&&!/^[[<]/.test(r[1])&&(e=r.shift()),t=r.shift(),!e&&/^-[^-]$/.test(t)&&(e=t,t=void 0),{shortFlag:e,longFlag:t}}se.Option=ne;se.DualOptions=ie});var Re=P(ke=>{"use strict";u();function nr(n,e){if(Math.abs(n.length-e.length)>3)return Math.max(n.length,e.length);let t=[];for(let r=0;r<=n.length;r++)t[r]=[r];for(let r=0;r<=e.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let i=1;i<=n.length;i++){let s=1;n[i-1]===e[r-1]?s=0:s=1,t[i][r]=Math.min(t[i-1][r]+1,t[i][r-1]+1,t[i-1][r-1]+s),i>1&&r>1&&n[i-1]===e[r-2]&&n[i-2]===e[r-1]&&(t[i][r]=Math.min(t[i][r],t[i-2][r-2]+1))}return t[n.length][e.length]}function ir(n,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let t=n.startsWith("--");t&&(n=n.slice(2),e=e.map(o=>o.slice(2)));let r=[],i=3,s=.4;return e.forEach(o=>{if(o.length<=1)return;let c=nr(n,o),a=Math.max(n.length,o.length);(a-c)/a>s&&(c<i?(i=c,r=[o]):c===i&&r.push(o))}),r.sort((o,c)=>o.localeCompare(c)),t&&(r=r.map(o=>`--${o}`)),r.length>1?`
11
11
  (Did you mean one of ${r.join(", ")}?)`:r.length===1?`
12
- (Did you mean ${r[0]}?)`:""}Pe.suggestSimilar=rr});var He=P(qe=>{"use strict";u();var nr=q("events").EventEmitter,ae=q("child_process"),A=q("path"),ce=q("fs"),g=q("process"),{Argument:ir,humanReadableArgName:sr}=M(),{CommanderError:ue}=H(),{Help:or}=re(),{Option:Re,DualOptions:ar}=oe(),{suggestSimilar:Te}=ke(),le=class n extends nr{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=>g.stdout.write(t),writeErr:t=>g.stderr.write(t),getOutHelpWidth:()=>g.stdout.isTTY?g.stdout.columns:void 0,getErrHelpWidth:()=>g.stderr.isTTY?g.stderr.columns:void 0,outputError:(t,r)=>r(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,r){let i=t,s=r;typeof i=="object"&&i!==null&&(s=i,i=null),s=s||{};let[,o,c]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(o);return i&&(a.description(i),a._executableHandler=!0),s.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(s.noHelp||s.hidden),a._executableFile=s.executableFile||null,c&&a.arguments(c),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),i?this:a}createCommand(e){return new n(e)}createHelp(){return Object.assign(new or,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
13
- - 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 ir(e,t)}argument(e,t,r,i){let s=this.createArgument(e,t);return typeof r=="function"?s.default(i).argParser(r):s.default(r),this.addArgument(s),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[,r,i]=e.match(/([^ ]+) *(.*)/),s=t??"display help for command",o=this.createCommand(r);return o.helpOption(!1),i&&o.arguments(i),s&&o.description(s),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 r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
14
- Expecting one of '${r.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,r){this._exitCallback&&this._exitCallback(new ue(e,t,r)),g.exit(e)}action(e){let t=r=>{let i=this.registeredArguments.length,s=r.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new Re(e,t)}_callParseArg(e,t,r,i){try{return e.parseArg(t,r)}catch(s){if(s.code==="commander.invalidArgument"){let o=`${i} ${s.message}`;this.error(o,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let r=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 '${r}'
15
- - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),r=t(e).find(i=>this._findCommand(i));if(r){let i=t(this._findCommand(r)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${i}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let i=(s,o,c)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let a=this.getOptionValue(r);s!==null&&e.parseArg?s=this._callParseArg(e,s,a,o):s!==null&&e.variadic&&(s=e._concatValue(s,a)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(r,s,c)};return this.on("option:"+t,s=>{let o=`error: option '${e.flags}' argument '${s}' is invalid.`;i(s,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let o=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;i(s,o,"env")}),this}_optionEx(e,t,r,i,s){if(typeof t=="object"&&t instanceof Re)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,r);if(o.makeOptionMandatory(!!e.mandatory),typeof i=="function")o.default(s).argParser(i);else if(i instanceof RegExp){let c=i;i=(a,l)=>{let h=c.exec(a);return h?h[0]:l},o.default(s).argParser(i)}else o.default(i);return this.addOption(o)}option(e,t,r,i){return this._optionEx({},e,t,r,i)}requiredOption(e,t,r,i){return this._optionEx({mandatory:!0},e,t,r,i)}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,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){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){g.versions?.electron&&(t.from="electron");let i=g.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=g.argv),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":g.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=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",r}parse(e,t){let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_executeSubCommand(e,t){t=t.slice();let r=!1,i=[".js",".ts",".tsx",".mjs",".cjs"];function s(h,f){let _=A.resolve(h,f);if(ce.existsSync(_))return _;if(i.includes(A.extname(f)))return;let S=i.find(b=>ce.existsSync(`${_}${b}`));if(S)return`${_}${S}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,c=this._executableDir||"";if(this._scriptPath){let h;try{h=ce.realpathSync(this._scriptPath)}catch{h=this._scriptPath}c=A.resolve(A.dirname(h),c)}if(c){let h=s(c,o);if(!h&&!e._executableFile&&this._scriptPath){let f=A.basename(this._scriptPath,A.extname(this._scriptPath));f!==this._name&&(h=s(c,`${f}-${e._name}`))}o=h||o}r=i.includes(A.extname(o));let a;g.platform!=="win32"?r?(t.unshift(o),t=Ne(g.execArgv).concat(t),a=ae.spawn(g.argv[0],t,{stdio:"inherit"})):a=ae.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=Ne(g.execArgv).concat(t),a=ae.spawn(g.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{g.on(f,()=>{a.killed===!1&&a.exitCode===null&&a.kill(f)})});let l=this._exitCallback;a.on("close",h=>{h=h??1,l?l(new ue(h,"commander.executeSubCommandAsync","(close)")):g.exit(h)}),a.on("error",h=>{if(h.code==="ENOENT"){let f=c?`searched for local subcommand relative to directory '${c}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",_=`'${o}' does not exist
12
+ (Did you mean ${r[0]}?)`:""}ke.suggestSimilar=ir});var Ie=P(He=>{"use strict";u();var sr=q("events").EventEmitter,ae=q("child_process"),$=q("path"),ce=q("fs"),g=q("process"),{Argument:or,humanReadableArgName:ar}=M(),{CommanderError:ue}=H(),{Help:cr}=re(),{Option:Te,DualOptions:ur}=oe(),{suggestSimilar:Ne}=Re(),le=class n extends sr{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=>g.stdout.write(t),writeErr:t=>g.stderr.write(t),getOutHelpWidth:()=>g.stdout.isTTY?g.stdout.columns:void 0,getErrHelpWidth:()=>g.stderr.isTTY?g.stderr.columns:void 0,outputError:(t,r)=>r(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,r){let i=t,s=r;typeof i=="object"&&i!==null&&(s=i,i=null),s=s||{};let[,o,c]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(o);return i&&(a.description(i),a._executableHandler=!0),s.isDefault&&(this._defaultCommandName=a._name),a._hidden=!!(s.noHelp||s.hidden),a._executableFile=s.executableFile||null,c&&a.arguments(c),this._registerCommand(a),a.parent=this,a.copyInheritedSettings(this),i?this:a}createCommand(e){return new n(e)}createHelp(){return Object.assign(new cr,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
13
+ - 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 or(e,t)}argument(e,t,r,i){let s=this.createArgument(e,t);return typeof r=="function"?s.default(i).argParser(r):s.default(r),this.addArgument(s),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[,r,i]=e.match(/([^ ]+) *(.*)/),s=t??"display help for command",o=this.createCommand(r);return o.helpOption(!1),i&&o.arguments(i),s&&o.description(s),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 r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
14
+ Expecting one of '${r.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,r){this._exitCallback&&this._exitCallback(new ue(e,t,r)),g.exit(e)}action(e){let t=r=>{let i=this.registeredArguments.length,s=r.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=t,this}createOption(e,t){return new Te(e,t)}_callParseArg(e,t,r,i){try{return e.parseArg(t,r)}catch(s){if(s.code==="commander.invalidArgument"){let o=`${i} ${s.message}`;this.error(o,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){let r=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 '${r}'
15
+ - already used by option '${t.flags}'`)}this.options.push(e)}_registerCommand(e){let t=i=>[i.name()].concat(i.aliases()),r=t(e).find(i=>this._findCommand(i));if(r){let i=t(this._findCommand(r)).join("|"),s=t(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${i}'`)}this.commands.push(e)}addOption(e){this._registerOption(e);let t=e.name(),r=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(r,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(r,e.defaultValue,"default");let i=(s,o,c)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let a=this.getOptionValue(r);s!==null&&e.parseArg?s=this._callParseArg(e,s,a,o):s!==null&&e.variadic&&(s=e._concatValue(s,a)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(r,s,c)};return this.on("option:"+t,s=>{let o=`error: option '${e.flags}' argument '${s}' is invalid.`;i(s,o,"cli")}),e.envVar&&this.on("optionEnv:"+t,s=>{let o=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;i(s,o,"env")}),this}_optionEx(e,t,r,i,s){if(typeof t=="object"&&t instanceof Te)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(t,r);if(o.makeOptionMandatory(!!e.mandatory),typeof i=="function")o.default(s).argParser(i);else if(i instanceof RegExp){let c=i;i=(a,l)=>{let h=c.exec(a);return h?h[0]:l},o.default(s).argParser(i)}else o.default(i);return this.addOption(o)}option(e,t,r,i){return this._optionEx({},e,t,r,i)}requiredOption(e,t,r,i){return this._optionEx({mandatory:!0},e,t,r,i)}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,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{r.getOptionValueSource(e)!==void 0&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){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){g.versions?.electron&&(t.from="electron");let i=g.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(t.from="eval")}e===void 0&&(e=g.argv),this.rawArgs=e.slice();let r;switch(t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":g.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;case"eval":r=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",r}parse(e,t){let r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){let r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_executeSubCommand(e,t){t=t.slice();let r=!1,i=[".js",".ts",".tsx",".mjs",".cjs"];function s(h,f){let _=$.resolve(h,f);if(ce.existsSync(_))return _;if(i.includes($.extname(f)))return;let S=i.find(b=>ce.existsSync(`${_}${b}`));if(S)return`${_}${S}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,c=this._executableDir||"";if(this._scriptPath){let h;try{h=ce.realpathSync(this._scriptPath)}catch{h=this._scriptPath}c=$.resolve($.dirname(h),c)}if(c){let h=s(c,o);if(!h&&!e._executableFile&&this._scriptPath){let f=$.basename(this._scriptPath,$.extname(this._scriptPath));f!==this._name&&(h=s(c,`${f}-${e._name}`))}o=h||o}r=i.includes($.extname(o));let a;g.platform!=="win32"?r?(t.unshift(o),t=qe(g.execArgv).concat(t),a=ae.spawn(g.argv[0],t,{stdio:"inherit"})):a=ae.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=qe(g.execArgv).concat(t),a=ae.spawn(g.execPath,t,{stdio:"inherit"})),a.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{g.on(f,()=>{a.killed===!1&&a.exitCode===null&&a.kill(f)})});let l=this._exitCallback;a.on("close",h=>{h=h??1,l?l(new ue(h,"commander.executeSubCommandAsync","(close)")):g.exit(h)}),a.on("error",h=>{if(h.code==="ENOENT"){let f=c?`searched for local subcommand relative to directory '${c}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",_=`'${o}' does not exist
16
16
  - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
17
17
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
18
18
  - ${f}`;throw new Error(_)}else if(h.code==="EACCES")throw new Error(`'${o}' not executable`);if(!l)g.exit(1);else{let f=new ue(1,"commander.executeSubCommandAsync","(error)");f.nestedError=h,l(f)}}),this.runningCommand=a}_dispatchSubcommand(e,t,r){let i=this._findCommand(e);i||this.help({error:!0});let s;return s=this._chainOrCallSubCommandHook(s,i,"preSubcommand"),s=this._chainOrCall(s,()=>{if(i._executableHandler)this._executeSubCommand(i,t.concat(r));else return i._parseCommand(t,r)}),s}_dispatchHelpCommand(e){e||this.help();let t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.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=(r,i,s)=>{let o=i;if(i!==null&&r.parseArg){let c=`error: command-argument value '${i}' is invalid for argument '${r.name()}'.`;o=this._callParseArg(r,i,s,c)}return o};this._checkNumberOfArguments();let t=[];this.registeredArguments.forEach((r,i)=>{let s=r.defaultValue;r.variadic?i<this.args.length?(s=this.args.slice(i),r.parseArg&&(s=s.reduce((o,c)=>e(r,c,o),r.defaultValue))):s===void 0&&(s=[]):i<this.args.length&&(s=this.args[i],r.parseArg&&(s=e(r,s,r.defaultValue))),t[i]=s}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&typeof e.then=="function"?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e,i=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[t]!==void 0).forEach(s=>{s._lifeCycleHooks[t].forEach(o=>{i.push({hookedCommand:s,callback:o})})}),t==="postAction"&&i.reverse(),i.forEach(s=>{r=this._chainOrCall(r,()=>s.callback(s.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let i=e;return this._lifeCycleHooks[r]!==void 0&&this._lifeCycleHooks[r].forEach(s=>{i=this._chainOrCall(i,()=>s(this,t))}),i}_parseCommand(e,t){let r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.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(r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){i(),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(s,e,t)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(s))i(),this._processArguments(),this.parent.emit(s,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():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),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(r=>{let i=r.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(r=>r.conflictsWith.length>0).forEach(r=>{let i=e.find(s=>r.conflictsWith.includes(s.attributeName()));i&&this._conflictingOption(r,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let t=[],r=[],i=t,s=e.slice();function o(a){return a.length>1&&a[0]==="-"}let c=null;for(;s.length;){let a=s.shift();if(a==="--"){i===r&&i.push(a),i.push(...s);break}if(c&&!o(a)){this.emit(`option:${c.name()}`,a);continue}if(c=null,o(a)){let l=this._findOption(a);if(l){if(l.required){let h=s.shift();h===void 0&&this.optionMissingArgument(l),this.emit(`option:${l.name()}`,h)}else if(l.optional){let h=null;s.length>0&&!o(s[0])&&(h=s.shift()),this.emit(`option:${l.name()}`,h)}else this.emit(`option:${l.name()}`);c=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()}`),s.unshift(`-${a.slice(2)}`));continue}}if(/^--[^=]+=/.test(a)){let l=a.indexOf("="),h=this._findOption(a.slice(0,l));if(h&&(h.required||h.optional)){this.emit(`option:${h.name()}`,a.slice(l+1));continue}}if(o(a)&&(i=r),(this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&r.length===0){if(this._findCommand(a)){t.push(a),s.length>0&&r.push(...s);break}else if(this._getHelpCommand()&&a===this._getHelpCommand().name()){t.push(a),s.length>0&&t.push(...s);break}else if(this._defaultCommandName){r.push(a),s.length>0&&r.push(...s);break}}if(this._passThroughOptions){i.push(a),s.length>0&&i.push(...s);break}i.push(a)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){let e={},t=this.options.length;for(let r=0;r<t;r++){let i=this.options[r].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}
19
19
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
20
20
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
21
- `),this.outputHelp({error:!0}));let r=t||{},i=r.exitCode||1,s=r.code||"commander.error";this._exit(i,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in g.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()}`,g.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new ar(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,r.implied[i],"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 r=o=>{let c=o.attributeName(),a=this.getOptionValue(c),l=this.options.find(f=>f.negate&&c===f.attributeName()),h=this.options.find(f=>!f.negate&&c===f.attributeName());return l&&(l.presetArg===void 0&&a===!1||l.presetArg!==void 0&&a===l.presetArg)?l:h||o},i=o=>{let c=r(o),a=c.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${c.envVar}'`:`option '${c.flags}'`},s=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter(c=>c.long).map(c=>c.long);i=i.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);t=Te(e,i)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(s=>{i.push(s.name()),s.alias()&&i.push(s.alias())}),t=Te(e,i)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let i=this.createOption(t,r);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
22
- `),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){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 r=this.parent?._findCommand(e);if(r){let i=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}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(r=>sr(r));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=A.basename(e,A.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},r;return t.error?r=i=>this._outputConfiguration.writeErr(i):r=i=>this._outputConfiguration.writeOut(i),t.write=e.write||r,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let i=this.helpInformation(r);if(t&&(i=t(i),typeof i!="string"&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",r))}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=g.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
21
+ `),this.outputHelp({error:!0}));let r=t||{},i=r.exitCode||1,s=r.code||"commander.error";this._exit(i,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in g.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()}`,g.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new ur(this.options),t=r=>this.getOptionValue(r)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(r));this.options.filter(r=>r.implied!==void 0&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(r=>{Object.keys(r.implied).filter(i=>!t(i)).forEach(i=>{this.setOptionValueWithSource(i,r.implied[i],"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 r=o=>{let c=o.attributeName(),a=this.getOptionValue(c),l=this.options.find(f=>f.negate&&c===f.attributeName()),h=this.options.find(f=>!f.negate&&c===f.attributeName());return l&&(l.presetArg===void 0&&a===!1||l.presetArg!==void 0&&a===l.presetArg)?l:h||o},i=o=>{let c=r(o),a=c.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${c.envVar}'`:`option '${c.flags}'`},s=`error: ${i(e)} cannot be used with ${i(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter(c=>c.long).map(c=>c.long);i=i.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);t=Ne(e,i)}let r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,r=t===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(s=>{i.push(s.name()),s.alias()&&i.push(s.alias())}),t=Ne(e,i)}let r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";let i=this.createOption(t,r);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
22
+ `),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){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 r=this.parent?._findCommand(e);if(r){let i=[r.name()].concat(r.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}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(r=>ar(r));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=$.basename(e,$.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},r;return t.error?r=i=>this._outputConfiguration.writeErr(i):r=i=>this._outputConfiguration.writeOut(i),t.write=e.write||r,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let r=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let i=this.helpInformation(r);if(t&&(i=t(i),typeof i!="string"&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",r))}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=g.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.
23
23
  Expecting one of '${r.join("', '")}'`);let i=`${e}Help`;return this.on(i,s=>{let o;typeof t=="function"?o=t({error:s.error,command:s.command}):o=t,o&&s.write(`${o}
24
- `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Ne(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",i="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?i=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],r=s[3],i=s[4]),t&&i!=="0"?`${t}=${r}:${parseInt(i)+1}`:e})}qe.Command=le});var Fe=P(O=>{"use strict";u();var{Argument:Ie}=M(),{Command:he}=He(),{CommanderError:cr,InvalidArgumentError:Ve}=H(),{Help:ur}=re(),{Option:De}=oe();O.program=new he;O.createCommand=n=>new he(n);O.createOption=(n,e)=>new De(n,e);O.createArgument=(n,e)=>new Ie(n,e);O.Command=he;O.Option=De;O.Argument=Ie;O.Help=ur;O.CommanderError=cr;O.InvalidArgumentError=Ve;O.InvalidOptionArgumentError=Ve});u();u();var Le=Gt(Fe(),1),{program:y,createCommand:ln,createArgument:hn,createOption:dn,CommanderError:mn,InvalidArgumentError:pn,InvalidOptionArgumentError:fn,Command:gn,Argument:bn,Option:yn,Help:wn}=Le.default;u();import{existsSync as $r}from"fs";u();u();u();u();var j=class extends Error{response;request;options;constructor(e,t,r){let i=e.status||e.status===0?e.status:"",s=e.statusText??"",o=`${i} ${s}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${t.method} ${t.url}`),this.name="HTTPError",this.response=e,this.request=t,this.options=r}};u();var T=class extends Error{name="NonError";value;constructor(e){let t="Non-error value was thrown";try{typeof e=="string"?t=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(t=e.message)}catch{}super(t),this.value=e}};u();var N=class extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){let t=e?.cause?e.cause instanceof Error?e.cause:new T(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",t?{cause:t}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}};u();u();var de=(()=>{let n=!1,e=!1,t=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(t&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return n&&!e})(),Ue=typeof globalThis.AbortController=="function",B=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Me=typeof globalThis.ReadableStream=="function",Be=typeof globalThis.FormData=="function",W=["get","post","put","patch","head","delete"],lr=()=>{};lr();var We={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},J=2147483647,Je=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,z=Symbol("stop"),I=class{options;constructor(e){this.options=e}},ze=n=>new I(n),Ge={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},Ke={next:!0},Ye={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0};var hr=n=>{if(!n)return 0;if(n instanceof FormData){let e=0;for(let[t,r]of n)e+=Je,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${t}"`).length,e+=typeof r=="string"?new TextEncoder().encode(r).length:r.size;return e}if(n instanceof Blob)return n.size;if(n instanceof ArrayBuffer)return n.byteLength;if(typeof n=="string")return new TextEncoder().encode(n).length;if(n instanceof URLSearchParams)return new TextEncoder().encode(n.toString()).length;if("byteLength"in n)return n.byteLength;if(typeof n=="object"&&n!==null)try{let e=JSON.stringify(n);return new TextEncoder().encode(e).length}catch{return 0}return 0},Xe=(n,e,t)=>{let r,i=0;return n.pipeThrough(new TransformStream({transform(s,o){if(o.enqueue(s),r){i+=r.byteLength;let c=e===0?0:i/e;c>=1&&(c=1-Number.EPSILON),t?.({percent:c,totalBytes:Math.max(e,i),transferredBytes:i},r)}r=s},flush(){r&&(i+=r.byteLength,t?.({percent:1,totalBytes:Math.max(e,i),transferredBytes:i},r))}}))},Qe=(n,e)=>{if(!n.body)return n;if(n.status===204)return new Response(null,{status:n.status,statusText:n.statusText,headers:n.headers});let t=Math.max(0,Number(n.headers.get("content-length"))||0);return new Response(Xe(n.body,t,e),{status:n.status,statusText:n.statusText,headers:n.headers})},Ze=(n,e,t)=>{if(!n.body)return n;let r=hr(t??n.body);return new Request(n,{duplex:"half",body:Xe(n.body,r,e)})};u();u();var E=n=>n!==null&&typeof n=="object";var V=(...n)=>{for(let e of n)if((!E(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return fe({},...n)},me=(n={},e={})=>{let t=new globalThis.Headers(n),r=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(let[s,o]of i.entries())r&&o==="undefined"||o===void 0?t.delete(s):t.set(s,o);return t};function G(n,e,t){return Object.hasOwn(e,t)&&e[t]===void 0?[]:fe(n[t]??[],e[t]??[])}var pe=(n={},e={})=>({beforeRequest:G(n,e,"beforeRequest"),beforeRetry:G(n,e,"beforeRetry"),afterResponse:G(n,e,"afterResponse"),beforeError:G(n,e,"beforeError")}),dr=(n,e)=>{let t=new URLSearchParams;for(let r of[n,e])if(r!==void 0)if(r instanceof URLSearchParams)for(let[i,s]of r.entries())t.append(i,s);else if(Array.isArray(r))for(let i of r){if(!Array.isArray(i)||i.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");t.append(String(i[0]),String(i[1]))}else if(E(r))for(let[i,s]of Object.entries(r))s!==void 0&&t.append(i,String(s));else{let i=new URLSearchParams(r);for(let[s,o]of i.entries())t.append(s,o)}return t},fe=(...n)=>{let e={},t={},r={},i,s=[];for(let o of n)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(E(o)){for(let[c,a]of Object.entries(o)){if(c==="signal"&&a instanceof globalThis.AbortSignal){s.push(a);continue}if(c==="context"){if(a!=null&&(!E(a)||Array.isArray(a)))throw new TypeError("The `context` option must be an object");e={...e,context:a==null?{}:{...e.context,...a}};continue}if(c==="searchParams"){a==null?i=void 0:i=i===void 0?a:dr(i,a);continue}E(a)&&c in e&&(a=fe(e[c],a)),e={...e,[c]:a}}E(o.hooks)&&(r=pe(r,o.hooks),e.hooks=r),E(o.headers)&&(t=me(t,o.headers),e.headers=t)}return i!==void 0&&(e.searchParams=i),s.length>0&&(s.length===1?e.signal=s[0]:B?e.signal=AbortSignal.any(s):e.signal=s.at(-1)),e};u();var tt=n=>W.includes(n)?n.toUpperCase():n,mr=["get","put","head","delete","options","trace"],pr=[408,413,429,500,502,503,504],fr=[413,429,503],et={limit:2,methods:mr,statusCodes:pr,afterStatusCodes:fr,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:n=>.3*2**(n-1)*1e3,jitter:void 0,retryOnTimeout:!1},rt=(n={})=>{if(typeof n=="number")return{...et,limit:n};if(n.methods&&!Array.isArray(n.methods))throw new Error("retry.methods must be an array");if(n.methods&&=n.methods.map(t=>t.toLowerCase()),n.statusCodes&&!Array.isArray(n.statusCodes))throw new Error("retry.statusCodes must be an array");let e=Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0));return{...et,...e}};u();u();var k=class extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}};async function ge(n,e,t,r){return new Promise((i,s)=>{let o=setTimeout(()=>{t&&t.abort(),s(new k(n))},r.timeout);r.fetch(n,e).then(i).catch(s).then(()=>{clearTimeout(o)})})}u();async function be(n,{signal:e}){return new Promise((t,r)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(s),r(e.reason)}let s=setTimeout(()=>{e?.removeEventListener("abort",i),t()},n)})}u();var nt=(n,e)=>{let t={};for(let r in e)Object.hasOwn(e,r)&&!(r in Ye)&&!(r in Ge)&&(!(r in n)||r in Ke)&&(t[r]=e[r]);return t},it=n=>n===void 0?!1:Array.isArray(n)?n.length>0:n instanceof URLSearchParams?n.size>0:typeof n=="object"?Object.keys(n).length>0:typeof n=="string"?n.trim().length>0:!!n;u();function st(n){return n instanceof j||n?.name===j.name}function ot(n){return n instanceof k||n?.name===k.name}var D=class n{static create(e,t){let r=new n(e,t),i=async()=>{if(typeof r.#e.timeout=="number"&&r.#e.timeout>J)throw new RangeError(`The \`timeout\` option cannot be greater than ${J}`);await Promise.resolve();let o=await r.#b();for(let c of r.#e.hooks.afterResponse){let a=r.#d(o.clone()),l;try{l=await c(r.request,r.#c(),a,{retryCount:r.#r})}catch(f){throw r.#s(a),r.#s(o),f}if(l instanceof I)throw r.#s(a),r.#s(o),new N(l.options);let h=l instanceof globalThis.Response?l:o;a!==h&&r.#s(a),o!==h&&r.#s(o),o=h}if(r.#d(o),!o.ok&&(typeof r.#e.throwHttpErrors=="function"?r.#e.throwHttpErrors(o.status):r.#e.throwHttpErrors)){let c=new j(o,r.request,r.#c());for(let a of r.#e.hooks.beforeError)c=await a(c,{retryCount:r.#r});throw c}if(r.#e.onDownloadProgress){if(typeof r.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Me)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");let c=o.clone();return r.#s(o),Qe(c,r.#e.onDownloadProgress)}return o},s=r.#m(i).finally(()=>{let o=r.#o;r.#l(o?.body??void 0),r.#l(r.request.body??void 0)});for(let[o,c]of Object.entries(We))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(s[o]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||c);let a=await s;if(o==="json"){if(a.status===204)return"";let l=await a.text();return l===""?"":t.parseJson?t.parseJson(l):JSON.parse(l)}return a[o]()});return s}static#f(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)):e}request;#n;#r=0;#t;#e;#o;#i;#a;constructor(e,t={}){if(this.#t=e,this.#e={...t,headers:me(this.#t.headers,t.headers),hooks:pe({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},t.hooks),method:tt(t.method??this.#t.method??"GET"),prefixUrl:String(t.prefixUrl||""),retry:rt(t.retry),throwHttpErrors:t.throwHttpErrors??!0,timeout:t.timeout??1e4,fetch:t.fetch??globalThis.fetch.bind(globalThis),context:t.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}Ue&&B&&(this.#i=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal),de&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));let r=t.headers&&new globalThis.Headers(t.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(Be&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!r&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),it(this.#e.searchParams)){let s="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(n.#f(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,s);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!de)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#p(this.request,this.#e.body??void 0)}}#u(){let e=this.#e.retry.delay(this.#r),t=e;this.#e.retry.jitter===!0?t=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(t=this.#e.retry.jitter(e),(!Number.isFinite(t)||t<0)&&(t=e));let r=this.#e.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(r,t)}async#g(e){if(this.#r++,this.#r>this.#e.retry.limit)throw e;let t=e instanceof Error?e:new T(e);if(t instanceof N)return t.customDelay??this.#u();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){let r=await this.#e.retry.shouldRetry({error:t,retryCount:this.#r});if(r===!1)throw e;if(r===!0)return this.#u()}if(ot(e)&&!this.#e.retry.retryOnTimeout)throw e;if(st(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;let r=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(r&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let i=Number(r)*1e3;Number.isNaN(i)?i=Date.parse(r)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let s=this.#e.retry.maxRetryAfter??i;return i<s?i:s}if(e.response.status===413)throw e}return this.#u()}#d(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}#l(e){e&&e.cancel().catch(()=>{})}#s(e){this.#l(e.body??void 0)}async#m(e){try{return await e()}catch(t){let r=Math.min(await this.#g(t),J);if(this.#r<1)throw t;if(await be(r,this.#i?{signal:this.#i}:{}),t instanceof N&&t.customRequest){let i=this.#e.signal?new globalThis.Request(t.customRequest,{signal:this.#e.signal}):new globalThis.Request(t.customRequest);this.#h(i)}for(let i of this.#e.hooks.beforeRetry){let s=await i({request:this.request,options:this.#c(),error:t,retryCount:this.#r});if(s instanceof globalThis.Request){this.#h(s);break}if(s instanceof globalThis.Response)return s;if(s===z)return}return this.#m(e)}}async#b(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(let t of this.#e.hooks.beforeRequest){let r=await t(this.request,this.#c(),{retryCount:this.#r});if(r instanceof Response)return r;if(r instanceof globalThis.Request){this.#h(r);break}}let e=nt(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,e):ge(this.#o,e,this.#n,this.#e)}#c(){if(!this.#a){let{hooks:e,...t}=this.#e;this.#a=Object.freeze(t)}return this.#a}#h(e){this.#a=void 0,this.request=this.#p(e)}#p(e,t){return!this.#e.onUploadProgress||!e.body?e:Ze(e,this.#e.onUploadProgress,t??this.#e.body??void 0)}};var ye=n=>{let e=(t,r)=>D.create(t,V(n,r));for(let t of W)e[t]=(r,i)=>D.create(r,V(n,i,{method:t}));return e.create=t=>ye(V(t)),e.extend=t=>(typeof t=="function"&&(t=t(n??{})),ye(V(n,t))),e.stop=z,e.retry=ze,e},gr=ye(),F=gr;var br="https://pro.lahat.group/api";function we(){return process.env.WARDROBE_API_URL??br}function C(n){if(!n)throw new Error("Not authenticated. Run `wardrobe login` first.");return F.create({prefixUrl:we(),headers:{Authorization:`Bearer ${n}`},retry:0})}u();import{readFileSync as yr,writeFileSync as wr,mkdirSync as _r,rmSync as jr,existsSync as Or}from"fs";import{homedir as xr}from"os";import{join as at}from"path";function ct(){return process.env.WARDROBE_CONFIG_DIR??at(xr(),".config","wardrobe")}function _e(){return at(ct(),"config.json")}function x(){let n=_e();if(!Or(n))return null;try{return JSON.parse(yr(n,"utf8"))}catch{return null}}function ut(n){_r(ct(),{recursive:!0,mode:448}),wr(_e(),JSON.stringify(n,null,2),{mode:384})}function lt(){jr(_e(),{force:!0})}u();import{readFileSync as Cr}from"fs";function Ar(){return new Promise((n,e)=>{let t="";process.stdin.setEncoding("utf8"),process.stdin.on("data",r=>t+=r),process.stdin.on("end",()=>n(t)),process.stdin.on("error",e)})}async function $(n){let e=n==="-"?await Ar():Cr(n,"utf8");try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON input: ${t.message}`)}}function p(n,e,t){e?process.stdout.write(JSON.stringify(n,null,2)+`
25
- `):t()}function je(){return C(x()?.accessToken??null)}async function ht(n={}){let e={};for(let r of["width","height","depth"])n[r]!==void 0&&(e[r]=n[r]);let t=await je().get("configs/init",{searchParams:e}).json();process.stdout.write(JSON.stringify(t.config,null,2)+`
26
- `)}async function dt(n,e={}){let t=await $(n),r=await je().post("configs/validate",{json:{config:t}}).json();p(r,!!e.json,()=>{if(r.valid)process.stdout.write(`valid
24
+ `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(i=>t.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function qe(n){return n.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r="127.0.0.1",i="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?t=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=s[1],/^\d+$/.test(s[3])?i=s[3]:r=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=s[1],r=s[3],i=s[4]),t&&i!=="0"?`${t}=${r}:${parseInt(i)+1}`:e})}He.Command=le});var Le=P(O=>{"use strict";u();var{Argument:Ve}=M(),{Command:he}=Ie(),{CommanderError:lr,InvalidArgumentError:De}=H(),{Help:hr}=re(),{Option:Fe}=oe();O.program=new he;O.createCommand=n=>new he(n);O.createOption=(n,e)=>new Fe(n,e);O.createArgument=(n,e)=>new Ve(n,e);O.Command=he;O.Option=Fe;O.Argument=Ve;O.Help=hr;O.CommanderError=lr;O.InvalidArgumentError=De;O.InvalidOptionArgumentError=De});u();u();var Ue=Yt(Le(),1),{program:y,createCommand:hn,createArgument:dn,createOption:mn,CommanderError:pn,InvalidArgumentError:fn,InvalidOptionArgumentError:gn,Command:bn,Argument:yn,Option:wn,Help:_n}=Ue.default;u();import{existsSync as Er}from"fs";u();u();u();u();var j=class extends Error{response;request;options;constructor(e,t,r){let i=e.status||e.status===0?e.status:"",s=e.statusText??"",o=`${i} ${s}`.trim(),c=o?`status code ${o}`:"an unknown error";super(`Request failed with ${c}: ${t.method} ${t.url}`),this.name="HTTPError",this.response=e,this.request=t,this.options=r}};u();var T=class extends Error{name="NonError";value;constructor(e){let t="Non-error value was thrown";try{typeof e=="string"?t=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(t=e.message)}catch{}super(t),this.value=e}};u();var N=class extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){let t=e?.cause?e.cause instanceof Error?e.cause:new T(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",t?{cause:t}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}};u();u();var de=(()=>{let n=!1,e=!1,t=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(t&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return n=!0,"half"}}).headers.has("Content-Type")}catch(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return n&&!e})(),Me=typeof globalThis.AbortController=="function",B=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Be=typeof globalThis.ReadableStream=="function",We=typeof globalThis.FormData=="function",W=["get","post","put","patch","head","delete"],dr=()=>{};dr();var Je={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},J=2147483647,ze=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,z=Symbol("stop"),I=class{options;constructor(e){this.options=e}},Ge=n=>new I(n),Ke={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},Ye={next:!0},Xe={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0};var mr=n=>{if(!n)return 0;if(n instanceof FormData){let e=0;for(let[t,r]of n)e+=ze,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${t}"`).length,e+=typeof r=="string"?new TextEncoder().encode(r).length:r.size;return e}if(n instanceof Blob)return n.size;if(n instanceof ArrayBuffer)return n.byteLength;if(typeof n=="string")return new TextEncoder().encode(n).length;if(n instanceof URLSearchParams)return new TextEncoder().encode(n.toString()).length;if("byteLength"in n)return n.byteLength;if(typeof n=="object"&&n!==null)try{let e=JSON.stringify(n);return new TextEncoder().encode(e).length}catch{return 0}return 0},Qe=(n,e,t)=>{let r,i=0;return n.pipeThrough(new TransformStream({transform(s,o){if(o.enqueue(s),r){i+=r.byteLength;let c=e===0?0:i/e;c>=1&&(c=1-Number.EPSILON),t?.({percent:c,totalBytes:Math.max(e,i),transferredBytes:i},r)}r=s},flush(){r&&(i+=r.byteLength,t?.({percent:1,totalBytes:Math.max(e,i),transferredBytes:i},r))}}))},Ze=(n,e)=>{if(!n.body)return n;if(n.status===204)return new Response(null,{status:n.status,statusText:n.statusText,headers:n.headers});let t=Math.max(0,Number(n.headers.get("content-length"))||0);return new Response(Qe(n.body,t,e),{status:n.status,statusText:n.statusText,headers:n.headers})},et=(n,e,t)=>{if(!n.body)return n;let r=mr(t??n.body);return new Request(n,{duplex:"half",body:Qe(n.body,r,e)})};u();u();var E=n=>n!==null&&typeof n=="object";var V=(...n)=>{for(let e of n)if((!E(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return fe({},...n)},me=(n={},e={})=>{let t=new globalThis.Headers(n),r=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(let[s,o]of i.entries())r&&o==="undefined"||o===void 0?t.delete(s):t.set(s,o);return t};function G(n,e,t){return Object.hasOwn(e,t)&&e[t]===void 0?[]:fe(n[t]??[],e[t]??[])}var pe=(n={},e={})=>({beforeRequest:G(n,e,"beforeRequest"),beforeRetry:G(n,e,"beforeRetry"),afterResponse:G(n,e,"afterResponse"),beforeError:G(n,e,"beforeError")}),pr=(n,e)=>{let t=new URLSearchParams;for(let r of[n,e])if(r!==void 0)if(r instanceof URLSearchParams)for(let[i,s]of r.entries())t.append(i,s);else if(Array.isArray(r))for(let i of r){if(!Array.isArray(i)||i.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");t.append(String(i[0]),String(i[1]))}else if(E(r))for(let[i,s]of Object.entries(r))s!==void 0&&t.append(i,String(s));else{let i=new URLSearchParams(r);for(let[s,o]of i.entries())t.append(s,o)}return t},fe=(...n)=>{let e={},t={},r={},i,s=[];for(let o of n)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(E(o)){for(let[c,a]of Object.entries(o)){if(c==="signal"&&a instanceof globalThis.AbortSignal){s.push(a);continue}if(c==="context"){if(a!=null&&(!E(a)||Array.isArray(a)))throw new TypeError("The `context` option must be an object");e={...e,context:a==null?{}:{...e.context,...a}};continue}if(c==="searchParams"){a==null?i=void 0:i=i===void 0?a:pr(i,a);continue}E(a)&&c in e&&(a=fe(e[c],a)),e={...e,[c]:a}}E(o.hooks)&&(r=pe(r,o.hooks),e.hooks=r),E(o.headers)&&(t=me(t,o.headers),e.headers=t)}return i!==void 0&&(e.searchParams=i),s.length>0&&(s.length===1?e.signal=s[0]:B?e.signal=AbortSignal.any(s):e.signal=s.at(-1)),e};u();var rt=n=>W.includes(n)?n.toUpperCase():n,fr=["get","put","head","delete","options","trace"],gr=[408,413,429,500,502,503,504],br=[413,429,503],tt={limit:2,methods:fr,statusCodes:gr,afterStatusCodes:br,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:n=>.3*2**(n-1)*1e3,jitter:void 0,retryOnTimeout:!1},nt=(n={})=>{if(typeof n=="number")return{...tt,limit:n};if(n.methods&&!Array.isArray(n.methods))throw new Error("retry.methods must be an array");if(n.methods&&=n.methods.map(t=>t.toLowerCase()),n.statusCodes&&!Array.isArray(n.statusCodes))throw new Error("retry.statusCodes must be an array");let e=Object.fromEntries(Object.entries(n).filter(([,t])=>t!==void 0));return{...tt,...e}};u();u();var k=class extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}};async function ge(n,e,t,r){return new Promise((i,s)=>{let o=setTimeout(()=>{t&&t.abort(),s(new k(n))},r.timeout);r.fetch(n,e).then(i).catch(s).then(()=>{clearTimeout(o)})})}u();async function be(n,{signal:e}){return new Promise((t,r)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(s),r(e.reason)}let s=setTimeout(()=>{e?.removeEventListener("abort",i),t()},n)})}u();var it=(n,e)=>{let t={};for(let r in e)Object.hasOwn(e,r)&&!(r in Xe)&&!(r in Ke)&&(!(r in n)||r in Ye)&&(t[r]=e[r]);return t},st=n=>n===void 0?!1:Array.isArray(n)?n.length>0:n instanceof URLSearchParams?n.size>0:typeof n=="object"?Object.keys(n).length>0:typeof n=="string"?n.trim().length>0:!!n;u();function ot(n){return n instanceof j||n?.name===j.name}function at(n){return n instanceof k||n?.name===k.name}var D=class n{static create(e,t){let r=new n(e,t),i=async()=>{if(typeof r.#e.timeout=="number"&&r.#e.timeout>J)throw new RangeError(`The \`timeout\` option cannot be greater than ${J}`);await Promise.resolve();let o=await r.#b();for(let c of r.#e.hooks.afterResponse){let a=r.#d(o.clone()),l;try{l=await c(r.request,r.#c(),a,{retryCount:r.#r})}catch(f){throw r.#s(a),r.#s(o),f}if(l instanceof I)throw r.#s(a),r.#s(o),new N(l.options);let h=l instanceof globalThis.Response?l:o;a!==h&&r.#s(a),o!==h&&r.#s(o),o=h}if(r.#d(o),!o.ok&&(typeof r.#e.throwHttpErrors=="function"?r.#e.throwHttpErrors(o.status):r.#e.throwHttpErrors)){let c=new j(o,r.request,r.#c());for(let a of r.#e.hooks.beforeError)c=await a(c,{retryCount:r.#r});throw c}if(r.#e.onDownloadProgress){if(typeof r.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Be)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");let c=o.clone();return r.#s(o),Ze(c,r.#e.onDownloadProgress)}return o},s=r.#m(i).finally(()=>{let o=r.#o;r.#l(o?.body??void 0),r.#l(r.request.body??void 0)});for(let[o,c]of Object.entries(Je))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(s[o]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||c);let a=await s;if(o==="json"){if(a.status===204)return"";let l=await a.text();return l===""?"":t.parseJson?t.parseJson(l):JSON.parse(l)}return a[o]()});return s}static#f(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)):e}request;#n;#r=0;#t;#e;#o;#i;#a;constructor(e,t={}){if(this.#t=e,this.#e={...t,headers:me(this.#t.headers,t.headers),hooks:pe({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},t.hooks),method:rt(t.method??this.#t.method??"GET"),prefixUrl:String(t.prefixUrl||""),retry:nt(t.retry),throwHttpErrors:t.throwHttpErrors??!0,timeout:t.timeout??1e4,fetch:t.fetch??globalThis.fetch.bind(globalThis),context:t.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}Me&&B&&(this.#i=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal),de&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));let r=t.headers&&new globalThis.Headers(t.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(We&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!r&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),st(this.#e.searchParams)){let s="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(n.#f(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,s);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!de)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#p(this.request,this.#e.body??void 0)}}#u(){let e=this.#e.retry.delay(this.#r),t=e;this.#e.retry.jitter===!0?t=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(t=this.#e.retry.jitter(e),(!Number.isFinite(t)||t<0)&&(t=e));let r=this.#e.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(r,t)}async#g(e){if(this.#r++,this.#r>this.#e.retry.limit)throw e;let t=e instanceof Error?e:new T(e);if(t instanceof N)return t.customDelay??this.#u();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){let r=await this.#e.retry.shouldRetry({error:t,retryCount:this.#r});if(r===!1)throw e;if(r===!0)return this.#u()}if(at(e)&&!this.#e.retry.retryOnTimeout)throw e;if(ot(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;let r=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(r&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let i=Number(r)*1e3;Number.isNaN(i)?i=Date.parse(r)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());let s=this.#e.retry.maxRetryAfter??i;return i<s?i:s}if(e.response.status===413)throw e}return this.#u()}#d(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}#l(e){e&&e.cancel().catch(()=>{})}#s(e){this.#l(e.body??void 0)}async#m(e){try{return await e()}catch(t){let r=Math.min(await this.#g(t),J);if(this.#r<1)throw t;if(await be(r,this.#i?{signal:this.#i}:{}),t instanceof N&&t.customRequest){let i=this.#e.signal?new globalThis.Request(t.customRequest,{signal:this.#e.signal}):new globalThis.Request(t.customRequest);this.#h(i)}for(let i of this.#e.hooks.beforeRetry){let s=await i({request:this.request,options:this.#c(),error:t,retryCount:this.#r});if(s instanceof globalThis.Request){this.#h(s);break}if(s instanceof globalThis.Response)return s;if(s===z)return}return this.#m(e)}}async#b(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(let t of this.#e.hooks.beforeRequest){let r=await t(this.request,this.#c(),{retryCount:this.#r});if(r instanceof Response)return r;if(r instanceof globalThis.Request){this.#h(r);break}}let e=it(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,e):ge(this.#o,e,this.#n,this.#e)}#c(){if(!this.#a){let{hooks:e,...t}=this.#e;this.#a=Object.freeze(t)}return this.#a}#h(e){this.#a=void 0,this.request=this.#p(e)}#p(e,t){return!this.#e.onUploadProgress||!e.body?e:et(e,this.#e.onUploadProgress,t??this.#e.body??void 0)}};var ye=n=>{let e=(t,r)=>D.create(t,V(n,r));for(let t of W)e[t]=(r,i)=>D.create(r,V(n,i,{method:t}));return e.create=t=>ye(V(t)),e.extend=t=>(typeof t=="function"&&(t=t(n??{})),ye(V(n,t))),e.stop=z,e.retry=Ge,e},yr=ye(),F=yr;var wr="https://pro.lahat.group/api";function we(){return process.env.WARDROBE_API_URL??wr}function C(n){if(!n)throw new Error("Not authenticated. Run `wardrobe login` first.");return F.create({prefixUrl:we(),headers:{Authorization:`Bearer ${n}`},retry:0})}u();import{readFileSync as _r,writeFileSync as jr,mkdirSync as Or,rmSync as xr,existsSync as Cr}from"fs";import{homedir as $r}from"os";import{join as ct}from"path";function ut(){return process.env.WARDROBE_CONFIG_DIR??ct($r(),".config","wardrobe")}function _e(){return ct(ut(),"config.json")}function x(){let n=_e();if(!Cr(n))return null;try{return JSON.parse(_r(n,"utf8"))}catch{return null}}function lt(n){Or(ut(),{recursive:!0,mode:448}),jr(_e(),JSON.stringify(n,null,2),{mode:384})}function ht(){xr(_e(),{force:!0})}u();import{readFileSync as vr}from"fs";function Ar(){return new Promise((n,e)=>{let t="";process.stdin.setEncoding("utf8"),process.stdin.on("data",r=>t+=r),process.stdin.on("end",()=>n(t)),process.stdin.on("error",e)})}async function v(n){let e=n==="-"?await Ar():vr(n,"utf8");try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON input: ${t.message}`)}}function p(n,e,t){e?process.stdout.write(JSON.stringify(n,null,2)+`
25
+ `):t()}function je(){return C(x()?.accessToken??null)}async function dt(n={}){let e={};for(let r of["width","height","depth"])n[r]!==void 0&&(e[r]=n[r]);let t=await je().get("configs/init",{searchParams:e}).json();process.stdout.write(JSON.stringify(t.config,null,2)+`
26
+ `)}async function mt(n,e={}){let t=await v(n),r=await je().post("configs/validate",{json:{config:t}}).json();p(r,!!e.json,()=>{if(r.valid)process.stdout.write(`valid
27
27
  `);else for(let i of r.errors)process.stdout.write(`${i.severity}: ${i.path} \u2014 ${i.message}
28
- `)}),r.valid||(process.exitCode=1)}async function mt(n,e={}){let t=je(),r=n==="-"||$r(n)?await $(n):(await t.get(`designs/${n}`).json()).config,i=await t.post("configs/describe",{json:{config:r,locale:e.locale??"en"}}).json();p(i.lines,!!e.json,()=>process.stdout.write(i.lines.join(`
28
+ `)}),r.valid||(process.exitCode=1)}async function pt(n,e={}){let t=je(),r=n==="-"||Er(n)?await v(n):(await t.get(`designs/${n}`).json()).config,i=await t.post("configs/describe",{json:{config:r,locale:e.locale??"en"}}).json();p(i.lines,!!e.json,()=>process.stdout.write(i.lines.join(`
29
29
  `)+`
30
- `))}u();import{spawn as vr}from"child_process";import{setTimeout as Er}from"timers/promises";function Sr(n){let e=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";try{vr(e,[n],{stdio:"ignore",detached:!0}).unref()}catch{}}async function pt(n={}){let e=we(),t=await F.post(`${e}/auth/device/code`,{retry:0}).json(),r=`${t.verification_uri}?code=${encodeURIComponent(t.user_code)}`;n.json||(process.stdout.write(`
30
+ `))}u();import{spawn as Sr}from"child_process";import{setTimeout as Pr}from"timers/promises";function kr(n){let e=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";try{Sr(e,[n],{stdio:"ignore",detached:!0}).unref()}catch{}}async function ft(n={}){let e=we(),t=await F.post(`${e}/auth/device/code`,{retry:0}).json(),r=`${t.verification_uri}?code=${encodeURIComponent(t.user_code)}`;n.json||(process.stdout.write(`
31
31
  To authorize this CLI, visit:
32
32
  ${t.verification_uri}
33
33
  `),process.stdout.write(`and enter code: ${t.user_code}
34
34
 
35
- `),Sr(r));let i=t.interval,s=Date.now()+t.expires_in*1e3;for(;Date.now()<s;){await Er(i*1e3);try{let o=await F.post(`${e}/auth/device/token`,{json:{device_code:t.device_code},retry:0}).json();ut({...x(),accessToken:o.access_token,apiUrl:e}),p({status:"authorized",scopes:o.scopes},!!n.json,()=>process.stdout.write(`Authorized. Agent key saved.
36
- `));return}catch(o){let a=(o instanceof j?await o.response.json().catch(()=>({})):{}).error;if(a==="authorization_pending")continue;if(a==="slow_down"||o instanceof j&&o.response.status===429){i+=5;continue}throw new Error(`Login failed: ${a??o.message}`)}}throw new Error("Login timed out. Run `wardrobe login` again.")}u();async function ft(n={}){let t=await C(x()?.accessToken??null).get("auth/me").json();p(t,!!n.json,()=>{process.stdout.write(`${t.displayName} <${t.email}> \u2014 account role: ${t.role}
35
+ `),kr(r));let i=t.interval,s=Date.now()+t.expires_in*1e3;for(;Date.now()<s;){await Pr(i*1e3);try{let o=await F.post(`${e}/auth/device/token`,{json:{device_code:t.device_code},retry:0}).json();lt({...x(),accessToken:o.access_token,apiUrl:e}),p({status:"authorized",scopes:o.scopes},!!n.json,()=>process.stdout.write(`Authorized. Agent key saved.
36
+ `));return}catch(o){let a=(o instanceof j?await o.response.json().catch(()=>({})):{}).error;if(a==="authorization_pending")continue;if(a==="slow_down"||o instanceof j&&o.response.status===429){i+=5;continue}throw new Error(`Login failed: ${a??o.message}`)}}throw new Error("Login timed out. Run `wardrobe login` again.")}u();async function gt(n={}){let t=await C(x()?.accessToken??null).get("auth/me").json();p(t,!!n.json,()=>{process.stdout.write(`${t.displayName} <${t.email}> \u2014 account role: ${t.role}
37
37
  `),t.agent&&process.stdout.write(`Agent key scopes: ${t.agent.scopes.join(", ")}
38
- `)})}function gt(n={}){lt(),p({status:"logged_out"},!!n.json,()=>process.stdout.write(`Logged out.
39
- `))}u();u();import{writeFileSync as bt}from"fs";function w(){return C(x()?.accessToken??null)}function Oe(n){let e=(n??"").replace(/\D/g,"");return e.startsWith("972")?`0${e.slice(3)}`:e}async function yt(n,e={}){let t=await w().get(`projects/${n}`).json();p(t,!!e.json,()=>{process.stdout.write(`${t.id} ${t.name}
38
+ `)})}function bt(n={}){ht(),p({status:"logged_out"},!!n.json,()=>process.stdout.write(`Logged out.
39
+ `))}u();u();import{writeFileSync as Oe}from"fs";function w(){return C(x()?.accessToken??null)}function xe(n){let e=(n??"").replace(/\D/g,"");return e.startsWith("00")&&(e=e.slice(2)),e.startsWith("972")&&(e=e.slice(3)),e.replace(/^0+/,"")}async function yt(n,e={}){let t=await w().get(`projects/${n}`).json();p(t,!!e.json,()=>{process.stdout.write(`${t.id} ${t.name}
40
40
  `),t.customer&&process.stdout.write(`customer: ${t.customer.customerName??"\u2014"} ${t.customer.phoneNumber??""}
41
41
  `),t.createdBy&&process.stdout.write(`designer: ${t.createdBy.displayName??"\u2014"} (${t.createdBy.id??""})
42
42
  `)})}async function wt(n,e={}){let t=await w().get(`projects/${n}/members`).json();p(t.members,!!e.json,()=>{for(let r of t.members)process.stdout.write(`${r.userId} ${r.role} ${r.displayName??r.email??""}
@@ -50,26 +50,27 @@ To authorize this CLI, visit:
50
50
  `),process.stdout.write(`customer: ${t.customerName??""} ${t.phoneNumber??""}
51
51
  `);for(let o of t.items??[])process.stdout.write(`design: ${o.designId} ${o.designName}
52
52
  `);let i=t.statusHistory??[],s=i[i.length-1];s&&process.stdout.write(`last transition: -> ${s.to} ${s.at}
53
- `)})}async function At(n,e={}){let t=e.out??`order-${n}.pdf`,r=Buffer.from(await w().get(`orders/${n}/pdf`).arrayBuffer());bt(t,r),p({path:t,bytes:r.length},!!e.json,()=>process.stdout.write(`${t} ${r.length} bytes
54
- `))}async function $t(n,e={}){let t=e.out??`design-${n}.jpg`,r=Buffer.from(await w().get(`designs/${n}/thumbnail`).arrayBuffer());bt(t,r),p({path:t,bytes:r.length},!!e.json,()=>process.stdout.write(`${t} ${r.length} bytes
55
- `))}async function vt(n={}){let e={};n.limit!==void 0&&(e.limit=n.limit),n.since!==void 0&&(e.createdSince=n.since);let t=await w().get("users",{searchParams:e}).json();p(t.users,!!n.json,()=>{if(t.users.length===0){process.stdout.write(`no users
56
- `);return}for(let r of t.users)process.stdout.write(`${r.id??""} ${r.email??""} ${r.displayName??""} ${r.role??""} ${r.createdAt??""}
57
- `)})}async function Et(n,e={}){if(!n)throw new Error("phone is required.");let t=await w().get("users/by-phone",{searchParams:{phone:n}}).json();p(t.users,!!e.json,()=>{if(t.users.length===0){process.stdout.write(`no matching user
58
- `);return}for(let r of t.users)process.stdout.write(`${r.id??""} ${r.email??""} ${r.displayName??""} ${r.role??""}
59
- `)})}async function St(n={}){let e=await w().get("help-texts").json();p(e,!!n.json,()=>process.stdout.write(`${Object.keys(e).length} help text(s)
60
- `))}function L(){return C(x()?.accessToken??null)}async function Pt(n,e={}){let t=await $(n),r=await L().post("price",{json:{config:t}}).json();p(r,!!e.json,()=>process.stdout.write(`${r.total} ${r.currency}
61
- `))}async function kt(n={}){let e={};n.project?e.projectId=n.project:(n.limit!==void 0&&(e.limit=n.limit),n.since!==void 0&&(e.updatedSince=n.since));let t=await L().get("designs",{searchParams:e}).json();p(t.designs,!!n.json,()=>{if(t.designs.length===0){process.stdout.write(`no designs
53
+ `)})}async function $t(n,e={}){let t=e.out??`order-${n}.pdf`,r=Buffer.from(await w().get(`orders/${n}/pdf`).arrayBuffer());Oe(t,r),p({path:t,bytes:r.length},!!e.json,()=>process.stdout.write(`${t} ${r.length} bytes
54
+ `))}async function vt(n,e={}){let t=e.revision;t===void 0&&(t=(await w().get(`quotations/project/${n}`).json()).revisionNumber);let r=e.out??`quotation-${n}-rev${t}.pdf`,i=Buffer.from(await w().get(`quotations/project/${n}/revisions/${t}/pdf`).arrayBuffer());Oe(r,i),p({path:r,bytes:i.length},!!e.json,()=>process.stdout.write(`${r} ${i.length} bytes
55
+ `))}async function At(n,e={}){let t=e.out??`design-${n}.jpg`,r=Buffer.from(await w().get(`designs/${n}/thumbnail`).arrayBuffer());Oe(t,r),p({path:t,bytes:r.length},!!e.json,()=>process.stdout.write(`${t} ${r.length} bytes
56
+ `))}async function Et(n={}){let e={};n.limit!==void 0&&(e.limit=n.limit),n.since!==void 0&&(e.createdSince=n.since);let t=await w().get("users",{searchParams:e}).json();p(t.users,!!n.json,()=>{if(t.users.length===0){process.stdout.write(`no users
57
+ `);return}for(let r of t.users)process.stdout.write(`${r.id??""} ${r.email??""} ${r.displayName??""} ${r.role??""} ${r.createdAt??""} ${r.phone??""}
58
+ `)})}async function St(n,e={}){if(!n)throw new Error("phone is required.");let t=await w().get("users/by-phone",{searchParams:{phone:n}}).json();p(t.users,!!e.json,()=>{if(t.users.length===0){process.stdout.write(`no matching user
59
+ `);return}for(let r of t.users)process.stdout.write(`${r.id??""} ${r.email??""} ${r.displayName??""} ${r.role??""} ${r.phone??""}
60
+ `)})}async function Pt(n={}){let e=await w().get("help-texts").json();p(e,!!n.json,()=>process.stdout.write(`${Object.keys(e).length} help text(s)
61
+ `))}function L(){return C(x()?.accessToken??null)}async function kt(n,e={}){let t=await v(n),r=await L().post("price",{json:{config:t}}).json();p(r,!!e.json,()=>process.stdout.write(`${r.total} ${r.currency}
62
+ `))}async function Rt(n={}){let e={};n.project?e.projectId=n.project:(n.limit!==void 0&&(e.limit=n.limit),n.since!==void 0&&(e.updatedSince=n.since));let t=await L().get("designs",{searchParams:e}).json();p(t.designs,!!n.json,()=>{if(t.designs.length===0){process.stdout.write(`no designs
62
63
  `);return}for(let r of t.designs){let i=n.project?"":` ${r.projectId??""}`;process.stdout.write(`${r.id} ${r.name}${i}
63
- `)}})}async function Rt(n={}){if(n.project){let r=await L().get(`quotations/project/${n.project}`).json();p(r,!!n.json,()=>{process.stdout.write(`quote #${r.quoteNumber}, ${r.revisionNumber} revision(s)
64
+ `)}})}async function Tt(n={}){if(n.project){let r=await L().get(`quotations/project/${n.project}`).json();p(r,!!n.json,()=>{process.stdout.write(`quote #${r.quoteNumber}, ${r.revisionNumber} revision(s)
64
65
  `);for(let i of r.revisions)process.stdout.write(`rev${i.revisionNumber} ${i.totalPrice+i.serviceTotal} ${i.currency} ${i.at}
65
66
  `)});return}let e={};n.limit!==void 0&&(e.limit=n.limit),n.since!==void 0&&(e.updatedSince=n.since);let t=await L().get("quotations",{searchParams:e}).json();p(t.quotations,!!n.json,()=>{if(t.quotations.length===0){process.stdout.write(`no quotations
66
67
  `);return}for(let r of t.quotations){let i=r.totalPrice!==null?`${r.totalPrice+(r.serviceTotal??0)} ${r.currency??"NIS"}`:"";process.stdout.write(`${r.projectId} quote #${r.quoteNumber} rev${r.revisionNumber} ${i} ${r.generatedAt??""}
67
- `)}})}async function Tt(n={}){let t=(await L().get("projects").json()).projects;if(n.phone){let r=Oe(n.phone);t=t.filter(i=>Oe(i.customer?.phoneNumber)===r)}if(n.designer){let r=n.designer.toLowerCase();t=t.filter(i=>i.createdBy?.id===n.designer||(i.createdBy?.displayName??"").toLowerCase().includes(r))}p(t,!!n.json,()=>{for(let r of t){let i=r.createdBy?.displayName?` ${r.createdBy.displayName}`:"",s=r.customer?.customerName?` ${r.customer.customerName}`:"";process.stdout.write(`${r.id} ${r.name}${s}${i}
68
- `)}})}u();function xe(){return C(x()?.accessToken??null)}async function Nt(n,e={}){let t=await $(n),r=await xe().post("price",{json:{config:t},searchParams:{preview:"bom"}}).json();p(r,!!e.json,()=>{process.stdout.write(`${r.total} ${r.currency}
68
+ `)}})}async function Nt(n={}){let t=(await L().get("projects").json()).projects;if(n.phone){let r=xe(n.phone);t=t.filter(i=>xe(i.customer?.phoneNumber)===r)}if(n.designer){let r=n.designer.toLowerCase();t=t.filter(i=>i.createdBy?.id===n.designer||(i.createdBy?.displayName??"").toLowerCase().includes(r))}p(t,!!n.json,()=>{for(let r of t){let i=r.createdBy?.displayName?` ${r.createdBy.displayName}`:"",s=r.customer?.customerName?` ${r.customer.customerName}`:"";process.stdout.write(`${r.id} ${r.name}${s}${i}
69
+ `)}})}u();function Ce(){return C(x()?.accessToken??null)}async function qt(n,e={}){let t=await v(n),r=await Ce().post("price",{json:{config:t},searchParams:{preview:"bom"}}).json();p(r,!!e.json,()=>{process.stdout.write(`${r.total} ${r.currency}
69
70
  `);for(let i of r.bomPreview?.lines??[])process.stdout.write(` ${i.qty}\xD7 ${i.part} (${i.sku}) ${i.widthMm}\xD7${i.heightMm}mm
70
- `)})}async function Ce(n,e={}){if(!e.project)throw new Error("--project <id> is required.");let t=await $(n),r=await xe().post("designs",{json:{projectId:e.project,name:e.name??"CLI design",config:t}}).json();p(r,!!e.json,()=>process.stdout.write(`${r.id}
71
- `))}async function qt(n,e={}){if(!e.file&&!e.name)throw new Error("Nothing to update \u2014 pass --file <config> and/or --name <name>.");let t=xe(),r=await t.get(`designs/${n}`).json(),i={};e.file&&(i.config=await $(e.file)),e.name&&(i.name=e.name),r.version!==void 0&&(i.version=r.version);let s=await t.put(`designs/${n}`,{json:i}).json();p(s,!!e.json,()=>process.stdout.write(`${s.id} v${s.version??"?"}
72
- `))}u();import{fileURLToPath as Pr}from"url";import{dirname as Ht,join as R}from"path";import{homedir as kr}from"os";import{existsSync as Rr,mkdirSync as Tr,readdirSync as Nr,copyFileSync as qr,statSync as Hr}from"fs";function Ir(){let n=Ht(Pr(import.meta.url));for(let e=0;e<6;e++){let t=R(n,"skill");if(Rr(R(t,"SKILL.md")))return t;n=Ht(n)}throw new Error("Bundled SKILL.md not found next to the CLI package")}function Vr(n){let e=n?R(process.cwd(),".claude"):R(kr(),".claude");return R(e,"skills","wardrobe-configurator")}function Dr(n={}){let e=n.sourceDir??Ir(),t=n.targetDir??Vr(!!n.project);Tr(t,{recursive:!0});let r=[];for(let i of Nr(e)){let s=R(e,i);Hr(s).isFile()&&(qr(s,R(t,i)),r.push(i))}return{target:t,files:r}}function It(n){let e=Dr({project:n.project});p(e,!!n.json,()=>{process.stdout.write(`Installed ${e.files.length} file(s) to ${e.target}
71
+ `)})}async function $e(n,e={}){if(!e.project)throw new Error("--project <id> is required.");let t=await v(n),r=await Ce().post("designs",{json:{projectId:e.project,name:e.name??"CLI design",config:t}}).json();p(r,!!e.json,()=>process.stdout.write(`${r.id}
72
+ `))}async function Ht(n,e={}){if(!e.file&&!e.name)throw new Error("Nothing to update \u2014 pass --file <config> and/or --name <name>.");let t=Ce(),r=await t.get(`designs/${n}`).json(),i={};e.file&&(i.config=await v(e.file)),e.name&&(i.name=e.name),r.version!==void 0&&(i.version=r.version);let s=await t.put(`designs/${n}`,{json:i}).json();p(s,!!e.json,()=>process.stdout.write(`${s.id} v${s.version??"?"}
73
+ `))}u();import{fileURLToPath as Rr}from"url";import{dirname as It,join as R}from"path";import{homedir as Tr}from"os";import{existsSync as Nr,mkdirSync as qr,readdirSync as Hr,copyFileSync as Ir,statSync as Vr}from"fs";function Dr(){let n=It(Rr(import.meta.url));for(let e=0;e<6;e++){let t=R(n,"skill");if(Nr(R(t,"SKILL.md")))return t;n=It(n)}throw new Error("Bundled SKILL.md not found next to the CLI package")}function Fr(n){let e=n?R(process.cwd(),".claude"):R(Tr(),".claude");return R(e,"skills","wardrobe-configurator")}function Lr(n={}){let e=n.sourceDir??Dr(),t=n.targetDir??Fr(!!n.project);qr(t,{recursive:!0});let r=[];for(let i of Hr(e)){let s=R(e,i);Vr(s).isFile()&&(Ir(s,R(t,i)),r.push(i))}return{target:t,files:r}}function Vt(n){let e=Lr({project:n.project});p(e,!!n.json,()=>{process.stdout.write(`Installed ${e.files.length} file(s) to ${e.target}
73
74
  `),process.stdout.write(`Restart Claude Code, then invoke /wardrobe-configurator
74
- `)})}u();async function Fr(n){if(!(n instanceof j))return null;try{return await n.response.json()}catch{return null}}async function Vt(n,e){let t=await Fr(n);if(e)return JSON.stringify(t?{error:t.error??"request_failed",...t}:{error:n.message},null,2);if(!t)return`Error: ${n.message}`;let r=[t.error??"Request failed"];return t.detail&&r.push(t.detail),t.fix_hint&&r.push(`fix: ${t.fix_hint}`),t.issues&&r.push(JSON.stringify(t.issues)),`Error: ${r.join(" \u2014 ")}`}u();var Dt="2.0.2";y.name("wardrobe").description("Wardrobe configurator CLI").version(Dt);y.command("login").description("Authenticate via the OAuth device flow").option("--json","machine-readable output").action(n=>pt(n));y.command("whoami").description("Show the authenticated user").option("--json","machine-readable output").action(n=>ft(n));y.command("logout").description("Remove the stored agent key").option("--json","machine-readable output").action(n=>gt(n));y.command("init").description("Emit a fresh, valid WardrobeConfig JSON (via the API)").option("--width <cm>","total width in cm",n=>Number(n)).option("--height <cm>","height in cm",n=>Number(n)).option("--depth <cm>","depth in cm",n=>Number(n)).action(n=>ht(n));y.command("validate <file>").description("Validate a config against the live rules (file or - for stdin)").option("--json","machine-readable output").action((n,e)=>dt(n,e));y.command("describe <idOrFile>").description("Describe a config (local file/-) or saved design (id), via the API").option("--locale <locale>","en or he","en").option("--json","machine-readable output").action((n,e)=>mt(n,e));y.command("price <file>").description("Price a config via the API (file or - for stdin)").option("--json","machine-readable output").action((n,e)=>Pt(n,e));y.command("plan <file>").description("Dry-run: price a config + BOM preview (mutates nothing)").option("--json","machine-readable output").action((n,e)=>Nt(n,e));y.command("apply <file>").description("Save a config as a design (file or - for stdin)").requiredOption("--project <id>","project id").option("--name <name>","design name").option("--json","machine-readable output").action((n,e)=>Ce(n,e));var K=y.command("designs").description("Manage saved designs");K.command("list").description("List designs in a project, or the newest across every project with --project omitted").option("--project <id>","project id").option("--limit <n>","cross-project mode only: max rows (default 20, max 100)",n=>Number(n)).option("--since <iso>","cross-project mode only: only designs updated at/after this ISO 8601 timestamp").option("--json","machine-readable output").action(n=>kt(n));K.command("create <file>").description("Save a config as a new design in a project (same as `apply`)").requiredOption("--project <id>","project id").option("--name <name>","design name").option("--json","machine-readable output").action((n,e)=>Ce(n,e));K.command("update <id>").description("Revise a saved design (config and/or name)").option("--file <file>","new config JSON (file or - for stdin)").option("--name <name>","new design name").option("--json","machine-readable output").action((n,e)=>qt(n,e));K.command("thumbnail <id>").description("Download a design's thumbnail image").option("--out <file>","destination path").option("--json","machine-readable output").action((n,e)=>$t(n,e));var Ae=y.command("projects").description("Manage projects");Ae.command("list").description("List accessible projects").option("--phone <number>","filter by the customer's phone number").option("--designer <idOrName>","filter by the designer who owns the project").option("--json","machine-readable output").action(n=>Tt(n));Ae.command("get <id>").description("Show one project").option("--json","machine-readable output").action((n,e)=>yt(n,e));Ae.command("members <id>").description("List a project's owner and members").option("--json","machine-readable output").action((n,e)=>wt(n,e));var $e=y.command("customers").description("Read customers");$e.command("list").description("List your customers").option("--json","machine-readable output").action(n=>_t(n));$e.command("get <id>").description("Show one customer").option("--json","machine-readable output").action((n,e)=>jt(n,e));$e.command("projects <id>").description("List a customer's projects").option("--json","machine-readable output").action((n,e)=>Ot(n,e));var ve=y.command("orders").description("Read orders");ve.command("list").description("List a project's orders, or the newest-updated across every project with --project omitted").option("--project <id>","project id").option("--open","only the project's active (non-cancelled) order (requires --project)").option("--limit <n>","cross-project mode only: max rows (default 20, max 100)",n=>Number(n)).option("--since <iso>","cross-project mode only: only orders updated at/after this ISO 8601 timestamp").option("--json","machine-readable output").action(n=>xt(n));ve.command("get <id>").description("Show one order, with its designs embedded").option("--json","machine-readable output").action((n,e)=>Ct(n,e));ve.command("pdf <id>").description("Download an order PDF").option("--out <file>","destination path").option("--json","machine-readable output").action((n,e)=>At(n,e));var Lr=y.command("quotations").description("Read quotations (requires quotations:read)");Lr.command("list").description("Show a project's quote history, or the newest-generated across every project with --project omitted").option("--project <id>","project id").option("--limit <n>","cross-project mode only: max rows (default 20, max 100)",n=>Number(n)).option("--since <iso>","cross-project mode only: only quotations generated at/after this ISO 8601 timestamp").option("--json","machine-readable output").action(n=>Rt(n));var Ft=y.command("users").description("Read registered accounts (requires staff:read)");Ft.command("list").description("List registered users, newest-registered first").option("--limit <n>","max rows (default 20, max 100)",n=>Number(n)).option("--since <iso>","only users registered at/after this ISO 8601 timestamp").option("--json","machine-readable output").action(n=>vt(n));Ft.command("by-phone <phone>").description("Find the account(s) tied to a phone number (the linked client, plus any designer who owns a project for that customer)").option("--json","machine-readable output").action((n,e)=>Et(n,e));y.command("help-texts").description("Read the help-text table").option("--json","machine-readable output").action(n=>St(n));var Ur=y.command("skill").description("Manage the bundled Claude Skill");Ur.command("install").description("Install the wardrobe-configurator Skill for Claude Code").option("--project","install into ./.claude/skills instead of ~/.claude/skills").option("--json","machine-readable output").action(n=>It(n));y.parseAsync().catch(async n=>{let e=await Vt(n,process.argv.includes("--json"));process.stderr.write(`${e}
75
+ `)})}u();async function Ur(n){if(!(n instanceof j))return null;try{return await n.response.json()}catch{return null}}async function Dt(n,e){let t=await Ur(n);if(e)return JSON.stringify(t?{error:t.error??"request_failed",...t}:{error:n.message},null,2);if(!t)return`Error: ${n.message}`;let r=[t.error??"Request failed"];return t.detail&&r.push(t.detail),t.fix_hint&&r.push(`fix: ${t.fix_hint}`),t.issues&&r.push(JSON.stringify(t.issues)),`Error: ${r.join(" \u2014 ")}`}u();var Ft="2.0.4";y.name("wardrobe").description("Wardrobe configurator CLI").version(Ft);y.command("login").description("Authenticate via the OAuth device flow").option("--json","machine-readable output").action(n=>ft(n));y.command("whoami").description("Show the authenticated user").option("--json","machine-readable output").action(n=>gt(n));y.command("logout").description("Remove the stored agent key").option("--json","machine-readable output").action(n=>bt(n));y.command("init").description("Emit a fresh, valid WardrobeConfig JSON (via the API)").option("--width <cm>","total width in cm",n=>Number(n)).option("--height <cm>","height in cm",n=>Number(n)).option("--depth <cm>","depth in cm",n=>Number(n)).action(n=>dt(n));y.command("validate <file>").description("Validate a config against the live rules (file or - for stdin)").option("--json","machine-readable output").action((n,e)=>mt(n,e));y.command("describe <idOrFile>").description("Describe a config (local file/-) or saved design (id), via the API").option("--locale <locale>","en or he","en").option("--json","machine-readable output").action((n,e)=>pt(n,e));y.command("price <file>").description("Price a config via the API (file or - for stdin)").option("--json","machine-readable output").action((n,e)=>kt(n,e));y.command("plan <file>").description("Dry-run: price a config + BOM preview (mutates nothing)").option("--json","machine-readable output").action((n,e)=>qt(n,e));y.command("apply <file>").description("Save a config as a design (file or - for stdin)").requiredOption("--project <id>","project id").option("--name <name>","design name").option("--json","machine-readable output").action((n,e)=>$e(n,e));var K=y.command("designs").description("Manage saved designs");K.command("list").description("List designs in a project, or the newest across every project with --project omitted").option("--project <id>","project id").option("--limit <n>","cross-project mode only: max rows (default 20, max 100)",n=>Number(n)).option("--since <iso>","cross-project mode only: only designs updated at/after this ISO 8601 timestamp").option("--json","machine-readable output").action(n=>Rt(n));K.command("create <file>").description("Save a config as a new design in a project (same as `apply`)").requiredOption("--project <id>","project id").option("--name <name>","design name").option("--json","machine-readable output").action((n,e)=>$e(n,e));K.command("update <id>").description("Revise a saved design (config and/or name)").option("--file <file>","new config JSON (file or - for stdin)").option("--name <name>","new design name").option("--json","machine-readable output").action((n,e)=>Ht(n,e));K.command("thumbnail <id>").description("Download a design's thumbnail image").option("--out <file>","destination path").option("--json","machine-readable output").action((n,e)=>At(n,e));var ve=y.command("projects").description("Manage projects");ve.command("list").description("List accessible projects").option("--phone <number>","filter by the customer's phone number").option("--designer <idOrName>","filter by the designer who owns the project").option("--json","machine-readable output").action(n=>Nt(n));ve.command("get <id>").description("Show one project").option("--json","machine-readable output").action((n,e)=>yt(n,e));ve.command("members <id>").description("List a project's owner and members").option("--json","machine-readable output").action((n,e)=>wt(n,e));var Ae=y.command("customers").description("Read customers");Ae.command("list").description("List your customers").option("--json","machine-readable output").action(n=>_t(n));Ae.command("get <id>").description("Show one customer").option("--json","machine-readable output").action((n,e)=>jt(n,e));Ae.command("projects <id>").description("List a customer's projects").option("--json","machine-readable output").action((n,e)=>Ot(n,e));var Ee=y.command("orders").description("Read orders");Ee.command("list").description("List a project's orders, or the newest-updated across every project with --project omitted").option("--project <id>","project id").option("--open","only the project's active (non-cancelled) order (requires --project)").option("--limit <n>","cross-project mode only: max rows (default 20, max 100)",n=>Number(n)).option("--since <iso>","cross-project mode only: only orders updated at/after this ISO 8601 timestamp").option("--json","machine-readable output").action(n=>xt(n));Ee.command("get <id>").description("Show one order, with its designs embedded").option("--json","machine-readable output").action((n,e)=>Ct(n,e));Ee.command("pdf <id>").description("Download an order PDF").option("--out <file>","destination path").option("--json","machine-readable output").action((n,e)=>$t(n,e));var Lt=y.command("quotations").description("Read quotations (requires quotations:read)");Lt.command("list").description("Show a project's quote history, or the newest-generated across every project with --project omitted").option("--project <id>","project id").option("--limit <n>","cross-project mode only: max rows (default 20, max 100)",n=>Number(n)).option("--since <iso>","cross-project mode only: only quotations generated at/after this ISO 8601 timestamp").option("--json","machine-readable output").action(n=>Tt(n));Lt.command("pdf <projectId>").description("Download a quotation PDF (default: the project's current revision) \u2014 never mints a new one").option("--revision <n>","a specific historical revision instead of the current one",n=>Number(n)).option("--out <file>","destination path").option("--json","machine-readable output").action((n,e)=>vt(n,e));var Ut=y.command("users").description("Read registered accounts (requires staff:read)");Ut.command("list").description("List registered users, newest-registered first").option("--limit <n>","max rows (default 20, max 100)",n=>Number(n)).option("--since <iso>","only users registered at/after this ISO 8601 timestamp").option("--json","machine-readable output").action(n=>Et(n));Ut.command("by-phone <phone>").description("Find the account(s) whose own phone is this number (+972\u2026 and 05\u2026 forms match)").option("--json","machine-readable output").action((n,e)=>St(n,e));y.command("help-texts").description("Read the help-text table").option("--json","machine-readable output").action(n=>Pt(n));var Mr=y.command("skill").description("Manage the bundled Claude Skill");Mr.command("install").description("Install the wardrobe-configurator Skill for Claude Code").option("--project","install into ./.claude/skills instead of ~/.claude/skills").option("--json","machine-readable output").action(n=>Vt(n));y.parseAsync().catch(async n=>{let e=await Dt(n,process.argv.includes("--json"));process.stderr.write(`${e}
75
76
  `),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lahat-group/cli",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "CLI + Claude Skill to build, validate, price, and save wardrobe designs.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/skill/SKILL.md CHANGED
@@ -98,9 +98,11 @@ answer `403 insufficient_scope` whoever signed in).
98
98
  | `wardrobe quotations list --project <id>` | That project's quote number + full revision history |
99
99
  | `wardrobe quotations list` | Every quotation you can see, **newest-generated first** — this is "latest quotes generation" |
100
100
  | `wardrobe quotations list --limit <n>` `--since <ISO>` | Same, paged (`--since` filters by `updatedAt >=`, i.e. last generated at/after) |
101
+ | `wardrobe quotations pdf <projectId> --out f.pdf` | The project's **current** quotation revision's PDF — fetches only, never mints one |
102
+ | `wardrobe quotations pdf <projectId> --revision <n> --out f.pdf` | A specific historical revision's PDF instead |
101
103
  | `wardrobe users list` | Registered accounts, **newest-registered first** — staff only, see below |
102
104
  | `wardrobe users list --limit <n>` `--since <ISO>` | Same, paged (`--since` filters by `createdAt >=`) — `--limit 5` with no `--since` is "the latest registered users"; omit both, paging with `--since` off the last row's timestamp, for "every user in the system" |
103
- | `wardrobe users by-phone <number>` | The account(s) tied to that phone number: the linked client account plus every designer who owns a project for a customer with it — staff only |
105
+ | `wardrobe users by-phone <number>` | The account(s) whose **own** phone is that number (`+972…`, `05…`, `052-…` all match) — staff only |
104
106
  | `wardrobe help-texts` | The help-text table |
105
107
 
106
108
  `projects list` already returns each project's **customer and owning designer inline** —
@@ -141,13 +143,14 @@ your key isn't staff at all), `404` means it is gone.
141
143
 
142
144
  `users list` / `users by-phone` read the `User` **account** table — designers, admins,
143
145
  support and self-serve clients who can sign in — not the per-project `Customer` contact
144
- card `wardrobe customers` reads. A phone number usually resolves to a **designer**
145
- (whoever owns the project for the customer with that number), occasionally to a
146
- **client** account too (if that customer accepted a project invitation and has their own
147
- login). It is normal for `users by-phone` to return more than one account, or to return
148
- zero when the number belongs to a customer nobody has invited to sign in — that is not
149
- an error, and it does not mean the phone number is unknown; check `wardrobe projects list
150
- --phone <number>` for the project/customer side of the same question.
146
+ card `wardrobe customers` reads. Each row carries the account's own `phone` (empty until
147
+ that user passes the onboarding phone step; staff never do). `users by-phone` matches
148
+ **only** that field: a customer's number never resolves to the designer who serves them,
149
+ so its answer is "who is this person", safe to act on as the caller's identity. Numbers
150
+ match as the national number, so `+972526665153` and `0526665153` are the same. More than
151
+ one row means the number is ambiguous (the field is self-declared, not unique) — say so
152
+ rather than picking one. Zero rows is normal and not an error; for the customer side of
153
+ the same number use `wardrobe projects list --phone <number>`.
151
154
 
152
155
  ### Not available here
153
156
 
@@ -183,9 +186,12 @@ Prefer generating the skeleton with `wardrobe init` rather than hand-writing it
183
186
  `projects:read`, `customers:read`, `designs:read`, `designs:write`, `orders:read`,
184
187
  `price:read`, `quotations:read` (+ `staff:read` and `staff:write` for staff) —
185
188
  **every write beyond designs is absent**, and so is every admin scope. `wardrobe
186
- orders list`, `orders pdf` and `quotations list` work; creating or changing an order,
187
- a customer or a quotation answers `403 insufficient_scope`. Don't attempt it, and
188
- don't attempt admin/catalog operations.
189
+ orders list`, `orders pdf`, `quotations list` and `quotations pdf` work; creating or
190
+ changing an order, a customer or a quotation answers `403 insufficient_scope`. A
191
+ project that has never been quoted on the web app has no revision to fetch —
192
+ `quotations pdf`/`quotations list --project` answer `404 quotation_not_found`, not an
193
+ empty document. Don't attempt to generate one yourself, and don't attempt
194
+ admin/catalog operations.
189
195
  - To turn a saved design into an order, direct the **human** to the web app: they
190
196
  open the project, review the design, and complete the **verify-details** flow —
191
197
  which computes the final price, freezes the PDF, and advances the order. Only a