@willbooster/wb 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # wb
2
+
3
+ `wb` offers a collection of reusable npm scripts,
4
+ designed primarily for WillBooster Inc. but with potential utility for other projects as well.
5
+
6
+ ## Usage
7
+
8
+ ```
9
+ wb <command>
10
+
11
+ Commands:
12
+ wb setup Setup development environment
13
+ wb buildIfNeeded Build code if changes are detected
14
+ wb optimizeForDockerBuild Optimize configuration when building a Docker image
15
+ wb prisma Run prisma commands
16
+ wb start Start app
17
+ wb test Test project
18
+ wb typecheck Run type checking
19
+
20
+ Options:
21
+ --version Show version number [boolean]
22
+ -e, --env .env files to be loaded. [array]
23
+ -w, --working-dir A working directory [string]
24
+ --help Show help [boolean]
25
+ ```
package/bin/index.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ import '../dist/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ import t,{resolve as e,dirname as n,normalize as s,basename as i,extname as r,relative as o}from"node:path";import a from"dotenv";import{notStrictEqual as c,strictEqual as l}from"node:assert";import h,{statSync as d,readdirSync as u,readFileSync as f,writeFile as p}from"node:fs";import{format as g,inspect as m}from"node:util";import{fileURLToPath as y}from"node:url";import b,{spawn as w,execSync as v,spawnSync as O}from"node:child_process";import{createHash as k}from"node:crypto";import j from"node:fs/promises";import A from"chalk";import{PromisePool as E}from"minimal-promise-pool";import*as _ from"node:os";import x from"node:os";const C={right:function(t,e){t=t.trim();const n=P.stringWidth(t);if(n<e)return" ".repeat(e-n)+t;return t},center:function(t,e){t=t.trim();const n=P.stringWidth(t);if(n>=e)return t;return" ".repeat(e-n>>1)+t}};class S{constructor(t){var e;this.width=t.width,this.wrap=null===(e=t.wrap)||void 0===e||e,this.rows=[]}span(...t){this.div(...t).span=!0}resetOutput(){this.rows=[]}div(...t){if(0===t.length&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...t)&&"string"==typeof t[0])return this.applyLayoutDSL(t[0]);const e=t.map((t=>"string"==typeof t?this.colFromString(t):t));return this.rows.push(e),e}shouldApplyLayoutDSL(...t){return 1===t.length&&"string"==typeof t[0]&&/[\t\n]/.test(t[0])}applyLayoutDSL(t){const e=t.split("\n").map((t=>t.split("\t")));let n=0;return e.forEach((t=>{t.length>1&&P.stringWidth(t[0])>n&&(n=Math.min(Math.floor(.5*this.width),P.stringWidth(t[0])))})),e.forEach((t=>{this.div(...t.map(((e,s)=>({text:e.trim(),padding:this.measurePadding(e),width:0===s&&t.length>1?n:void 0}))))})),this.rows[this.rows.length-1]}colFromString(t){return{text:t,padding:this.measurePadding(t)}}measurePadding(t){const e=P.stripAnsi(t);return[0,e.match(/\s*$/)[0].length,0,e.match(/^\s*/)[0].length]}toString(){const t=[];return this.rows.forEach((e=>{this.rowToString(e,t)})),t.filter((t=>!t.hidden)).map((t=>t.text)).join("\n")}rowToString(t,e){return this.rasterize(t).forEach(((n,s)=>{let i="";n.forEach(((n,r)=>{const{width:o}=t[r],a=this.negatePadding(t[r]);let c=n;if(a>P.stringWidth(n)&&(c+=" ".repeat(a-P.stringWidth(n))),t[r].align&&"left"!==t[r].align&&this.wrap){c=(0,C[t[r].align])(c,a),P.stringWidth(c)<a&&(c+=" ".repeat((o||0)-P.stringWidth(c)-1))}const l=t[r].padding||[0,0,0,0];l[3]&&(i+=" ".repeat(l[3])),i+=$(t[r],c,"| "),i+=c,i+=$(t[r],c," |"),l[1]&&(i+=" ".repeat(l[1])),0===s&&e.length>0&&(i=this.renderInline(i,e[e.length-1]))})),e.push({text:i.replace(/ +$/,""),span:t.span})})),e}renderInline(t,e){const n=t.match(/^ */),s=n?n[0].length:0,i=e.text,r=P.stringWidth(i.trimRight());return e.span?this.wrap?s<r?t:(e.hidden=!0,i.trimRight()+" ".repeat(s-r)+t.trimLeft()):(e.hidden=!0,i+t):t}rasterize(t){const e=[],n=this.columnWidths(t);let s;return t.forEach(((t,i)=>{t.width=n[i],s=this.wrap?P.wrap(t.text,this.negatePadding(t),{hard:!0}).split("\n"):t.text.split("\n"),t.border&&(s.unshift("."+"-".repeat(this.negatePadding(t)+2)+"."),s.push("'"+"-".repeat(this.negatePadding(t)+2)+"'")),t.padding&&(s.unshift(...new Array(t.padding[0]||0).fill("")),s.push(...new Array(t.padding[2]||0).fill(""))),s.forEach(((t,n)=>{e[n]||e.push([]);const s=e[n];for(let t=0;t<i;t++)void 0===s[t]&&s.push("");s.push(t)}))})),e}negatePadding(t){let e=t.width||0;return t.padding&&(e-=(t.padding[3]||0)+(t.padding[1]||0)),t.border&&(e-=4),e}columnWidths(t){if(!this.wrap)return t.map((t=>t.width||P.stringWidth(t.text)));let e=t.length,n=this.width;const s=t.map((t=>{if(t.width)return e--,n-=t.width,t.width})),i=e?Math.floor(n/e):0;return s.map(((e,n)=>void 0===e?Math.max(i,function(t){const e=t.padding||[],n=1+(e[3]||0)+(e[1]||0);if(t.border)return n+4;return n}(t[n])):e))}}function $(t,e,n){return t.border?/[.']-+[.']/.test(e)?"":0!==e.trim().length?n:" ":""}let P;const M=new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)","g");function N(t){return t.replace(M,"")}function I(t,e){const[n,s]=t.match(M)||["",""];t=N(t);let i="";for(let n=0;n<t.length;n++)0!==n&&n%e==0&&(i+="\n"),i+=t.charAt(n);return n&&s&&(i=`${n}${i}${s}`),i}
2
+ /**
3
+ * @license
4
+ * Copyright (c) 2016, Contributors
5
+ * SPDX-License-Identifier: ISC
6
+ */
7
+ function D(t){if(t!==t.toLowerCase()&&t!==t.toUpperCase()||(t=t.toLowerCase()),-1===t.indexOf("-")&&-1===t.indexOf("_"))return t;{let e="",n=!1;const s=t.match(/^-+/);for(let i=s?s[0].length:0;i<t.length;i++){let s=t.charAt(i);n&&(n=!1,s=s.toUpperCase()),0===i||"-"!==s&&"_"!==s?"-"!==s&&"_"!==s&&(e+=s):n=!0}return e}}function W(t,e){const n=t.toLowerCase();e=e||"-";let s="";for(let i=0;i<t.length;i++){const r=n.charAt(i),o=t.charAt(i);s+=r!==o&&i>0?`${e}${n.charAt(i)}`:o}return s}function F(t){return null!=t&&("number"==typeof t||(!!/^0x[0-9a-f]+$/i.test(t)||!/^0[^.]/.test(t)&&/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(t)))}
8
+ /**
9
+ * @license
10
+ * Copyright (c) 2016, Contributors
11
+ * SPDX-License-Identifier: ISC
12
+ */
13
+ /**
14
+ * @license
15
+ * Copyright (c) 2016, Contributors
16
+ * SPDX-License-Identifier: ISC
17
+ */
18
+ var z;
19
+ /**
20
+ * @license
21
+ * Copyright (c) 2016, Contributors
22
+ * SPDX-License-Identifier: ISC
23
+ */
24
+ let R;!function(t){t.BOOLEAN="boolean",t.STRING="string",t.NUMBER="number",t.ARRAY="array"}(z||(z={}));function L(t){return void 0!==t?t+1:1}function U(t){return"__proto__"===t?"___proto___":t}
25
+ /**
26
+ * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
27
+ * CJS and ESM environments.
28
+ *
29
+ * @license
30
+ * Copyright (c) 2016, Contributors
31
+ * SPDX-License-Identifier: ISC
32
+ */
33
+ var H,T,B;const q=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,V=null!==(T=null===(H=null===process||void 0===process?void 0:process.versions)||void 0===H?void 0:H.node)&&void 0!==T?T:null===(B=null===process||void 0===process?void 0:process.version)||void 0===B?void 0:B.slice(1);if(V){if(Number(V.match(/^([^.]+)/)[1])<q)throw Error(`yargs parser supports a minimum Node.js version of ${q}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}const G=process?process.env:{},Y=new class{constructor(t){R=t}parse(t,e){const n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},e),s=function(t){if(Array.isArray(t))return t.map((t=>"string"!=typeof t?t+"":t));t=t.trim();let e=0,n=null,s=null,i=null;const r=[];for(let o=0;o<t.length;o++)n=s,s=t.charAt(o)," "!==s||i?(s===i?i=null:"'"!==s&&'"'!==s||i||(i=s),r[e]||(r[e]=""),r[e]+=s):" "!==n&&e++;return r}(t),i="string"==typeof t,r=function(t){const e=[],n=Object.create(null);let s=!0;Object.keys(t).forEach((function(n){e.push([].concat(t[n],n))}));for(;s;){s=!1;for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){if(e[t].filter((function(t){return-1!==e[n].indexOf(t)})).length){e[t]=e[t].concat(e[n]),e.splice(n,1),s=!0;break}}}return e.forEach((function(t){const e=(t=t.filter((function(t,e,n){return n.indexOf(t)===e}))).pop();void 0!==e&&"string"==typeof e&&(n[e]=t)})),n}(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),a=Object.assign(Object.create(null),n.default),c=n.configObjects||[],l=n.envPrefix,h=o["populate--"],d=h?"--":"_",u=Object.create(null),f=Object.create(null),p=n.__||R.format,g={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},m=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,y=new RegExp("^--"+o["negation-prefix"]+"(.+)");[].concat(n.array||[]).filter(Boolean).forEach((function(t){const e="object"==typeof t?t.key:t,n=Object.keys(t).map((function(t){return{boolean:"bools",string:"strings",number:"numbers"}[t]})).filter(Boolean).pop();n&&(g[n][e]=!0),g.arrays[e]=!0,g.keys.push(e)})),[].concat(n.boolean||[]).filter(Boolean).forEach((function(t){g.bools[t]=!0,g.keys.push(t)})),[].concat(n.string||[]).filter(Boolean).forEach((function(t){g.strings[t]=!0,g.keys.push(t)})),[].concat(n.number||[]).filter(Boolean).forEach((function(t){g.numbers[t]=!0,g.keys.push(t)})),[].concat(n.count||[]).filter(Boolean).forEach((function(t){g.counts[t]=!0,g.keys.push(t)})),[].concat(n.normalize||[]).filter(Boolean).forEach((function(t){g.normalize[t]=!0,g.keys.push(t)})),"object"==typeof n.narg&&Object.entries(n.narg).forEach((([t,e])=>{"number"==typeof e&&(g.nargs[t]=e,g.keys.push(t))})),"object"==typeof n.coerce&&Object.entries(n.coerce).forEach((([t,e])=>{"function"==typeof e&&(g.coercions[t]=e,g.keys.push(t))})),void 0!==n.config&&(Array.isArray(n.config)||"string"==typeof n.config?[].concat(n.config).filter(Boolean).forEach((function(t){g.configs[t]=!0})):"object"==typeof n.config&&Object.entries(n.config).forEach((([t,e])=>{"boolean"!=typeof e&&"function"!=typeof e||(g.configs[t]=e)}))),function(...t){t.forEach((function(t){Object.keys(t||{}).forEach((function(t){g.aliases[t]||(g.aliases[t]=[].concat(r[t]||[]),g.aliases[t].concat(t).forEach((function(e){if(/-/.test(e)&&o["camel-case-expansion"]){const n=D(e);n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].concat(t).forEach((function(e){if(e.length>1&&/[A-Z]/.test(e)&&o["camel-case-expansion"]){const n=W(e,"-");n!==t&&-1===g.aliases[t].indexOf(n)&&(g.aliases[t].push(n),u[n]=!0)}})),g.aliases[t].forEach((function(e){g.aliases[e]=[t].concat(g.aliases[t].filter((function(t){return e!==t})))})))}))}))}(n.key,r,n.default,g.arrays),Object.keys(a).forEach((function(t){(g.aliases[t]||[]).forEach((function(e){a[e]=a[t]}))}));let b=null;Object.keys(g.counts).find((t=>I(t,g.arrays)?(b=Error(p("Invalid configuration: %s, opts.count excludes opts.array.",t)),!0):!!I(t,g.nargs)&&(b=Error(p("Invalid configuration: %s, opts.count excludes opts.narg.",t)),!0)));let w=[];const v=Object.assign(Object.create(null),{_:[]}),O={};for(let t=0;t<s.length;t++){const e=s[t],n=e.replace(/^-{3,}/,"---");let i,r,a,c,l,h;if("--"!==e&&/^-/.test(e)&&T(e))k(e);else{if(n.match(/^---+(=|$)/)){k(e);continue}if(e.match(/^--.+=/)||!o["short-option-groups"]&&e.match(/^-.+=/))c=e.match(/^--?([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&(I(c[1],g.arrays)?t=A(t,c[1],s,c[2]):!1!==I(c[1],g.nargs)?t=j(t,c[1],s,c[2]):E(c[1],c[2],!0));else if(e.match(y)&&o["boolean-negation"])c=e.match(y),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],E(r,!!I(r,g.arrays)&&[!1]));else if(e.match(/^--.+/)||!o["short-option-groups"]&&e.match(/^-[^-]+/))c=e.match(/^--?(.+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],I(r,g.arrays)?t=A(t,r,s):!1!==I(r,g.nargs)?t=j(t,r,s):(l=s[t+1],void 0===l||l.match(/^-/)&&!l.match(m)||I(r,g.bools)||I(r,g.counts)?/^(true|false)$/.test(l)?(E(r,l),t++):E(r,B(r)):(E(r,l),t++)));else if(e.match(/^-.\..+=/))c=e.match(/^-([^=]+)=([\s\S]*)$/),null!==c&&Array.isArray(c)&&c.length>=3&&E(c[1],c[2]);else if(e.match(/^-.\..+/)&&!e.match(m))l=s[t+1],c=e.match(/^-(.\..+)/),null!==c&&Array.isArray(c)&&c.length>=2&&(r=c[1],void 0===l||l.match(/^-/)||I(r,g.bools)||I(r,g.counts)?E(r,B(r)):(E(r,l),t++));else if(e.match(/^-[^-]+/)&&!e.match(m)){a=e.slice(1,-1).split(""),i=!1;for(let n=0;n<a.length;n++){if(l=e.slice(n+2),a[n+1]&&"="===a[n+1]){h=e.slice(n+3),r=a[n],I(r,g.arrays)?t=A(t,r,s,h):!1!==I(r,g.nargs)?t=j(t,r,s,h):E(r,h),i=!0;break}if("-"!==l){if(/[A-Za-z]/.test(a[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&!1===I(l,g.bools)){E(a[n],l),i=!0;break}if(a[n+1]&&a[n+1].match(/\W/)){E(a[n],l),i=!0;break}E(a[n],B(a[n]))}else E(a[n],l)}r=e.slice(-1)[0],i||"-"===r||(I(r,g.arrays)?t=A(t,r,s):!1!==I(r,g.nargs)?t=j(t,r,s):(l=s[t+1],void 0===l||/^(-|--)[^-]/.test(l)&&!l.match(m)||I(r,g.bools)||I(r,g.counts)?/^(true|false)$/.test(l)?(E(r,l),t++):E(r,B(r)):(E(r,l),t++)))}else if(e.match(/^-[0-9]$/)&&e.match(m)&&I(e.slice(1),g.bools))r=e.slice(1),E(r,B(r));else{if("--"===e){w=s.slice(t+1);break}if(o["halt-at-non-option"]){w=s.slice(t);break}k(e)}}}function k(t){const e=C("_",t);"string"!=typeof e&&"number"!=typeof e||v._.push(e)}function j(t,e,n,s){let i,r=I(e,g.nargs);if(r="number"!=typeof r||isNaN(r)?1:r,0===r)return q(s)||(b=Error(p("Argument unexpected for: %s",e))),E(e,B(e)),t;let a=q(s)?0:1;if(o["nargs-eats-options"])n.length-(t+1)+a<r&&(b=Error(p("Not enough arguments following: %s",e))),a=r;else{for(i=t+1;i<n.length&&(!n[i].match(/^-[^0-9]/)||n[i].match(m)||T(n[i]));i++)a++;a<r&&(b=Error(p("Not enough arguments following: %s",e)))}let c=Math.min(a,r);for(!q(s)&&c>0&&(E(e,s),c--),i=t+1;i<c+t+1;i++)E(e,n[i]);return t+c}function A(t,e,n,s){let r=[],c=s||n[t+1];const l=I(e,g.nargs);if(I(e,g.bools)&&!/^(true|false)$/.test(c))r.push(!0);else if(q(c)||q(s)&&/^-/.test(c)&&!m.test(c)&&!T(c)){if(void 0!==a[e]){const t=a[e];r=Array.isArray(t)?t:[t]}}else{q(s)||r.push(x(e,s,!0));for(let s=t+1;s<n.length&&!(!o["greedy-arrays"]&&r.length>0||l&&"number"==typeof l&&r.length>=l)&&(c=n[s],!/^-/.test(c)||m.test(c)||T(c));s++)t=s,r.push(x(e,c,i))}return"number"==typeof l&&(l&&r.length<l||isNaN(l)&&0===r.length)&&(b=Error(p("Not enough arguments following: %s",e))),E(e,r),t}function E(t,e,n=i){if(/-/.test(t)&&o["camel-case-expansion"]){const e=t.split(".").map((function(t){return D(t)})).join(".");_(t,e)}const s=x(t,e,n),r=t.split(".");if(N(v,r,s),g.aliases[t]&&g.aliases[t].forEach((function(t){const e=t.split(".");N(v,e,s)})),r.length>1&&o["dot-notation"]&&(g.aliases[r[0]]||[]).forEach((function(e){let n=e.split(".");const i=[].concat(r);i.shift(),n=n.concat(i),(g.aliases[t]||[]).includes(n.join("."))||N(v,n,s)})),I(t,g.normalize)&&!I(t,g.arrays)){[t].concat(g.aliases[t]||[]).forEach((function(t){Object.defineProperty(O,t,{enumerable:!0,get:()=>e,set(t){e="string"==typeof t?R.normalize(t):t}})}))}}function _(t,e){g.aliases[t]&&g.aliases[t].length||(g.aliases[t]=[e],u[e]=!0),g.aliases[e]&&g.aliases[e].length||_(e,t)}function x(t,e,n){n&&(e=function(t){return"string"!=typeof t||"'"!==t[0]&&'"'!==t[0]||t[t.length-1]!==t[0]?t:t.substring(1,t.length-1)}(e)),(I(t,g.bools)||I(t,g.counts))&&"string"==typeof e&&(e="true"===e);let s=Array.isArray(e)?e.map((function(e){return C(t,e)})):C(t,e);return I(t,g.counts)&&(q(s)||"boolean"==typeof s)&&(s=L()),I(t,g.normalize)&&I(t,g.arrays)&&(s=Array.isArray(e)?e.map((t=>R.normalize(t))):R.normalize(e)),s}function C(t,e){if(!o["parse-positional-numbers"]&&"_"===t)return e;if(!I(t,g.strings)&&!I(t,g.bools)&&!Array.isArray(e)){(F(e)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${e}`)))||!q(e)&&I(t,g.numbers))&&(e=Number(e))}return e}function S(t,e){Object.keys(t).forEach((function(n){const s=t[n],i=e?e+"."+n:n;"object"==typeof s&&null!==s&&!Array.isArray(s)&&o["dot-notation"]?S(s,i):(!M(v,i.split("."))||I(i,g.arrays)&&o["combine-arrays"])&&E(i,s)}))}function $(t,e){if(void 0===l)return;const n="string"==typeof l?l:"",s=R.env();Object.keys(s).forEach((function(i){if(""===n||0===i.lastIndexOf(n,0)){const r=i.split("__").map((function(t,e){return 0===e&&(t=t.substring(n.length)),D(t)}));(e&&g.configs[r.join(".")]||!e)&&!M(t,r)&&E(r.join("."),s[i])}}))}function P(t,e,n,s=!1){Object.keys(n).forEach((function(i){M(t,i.split("."))||(N(t,i.split("."),n[i]),s&&(f[i]=!0),(e[i]||[]).forEach((function(e){M(t,e.split("."))||N(t,e.split("."),n[i])})))}))}function M(t,e){let n=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){n=n[t]||{}}));const s=e[e.length-1];return"object"==typeof n&&s in n}function N(t,e,n){let s=t;o["dot-notation"]||(e=[e.join(".")]),e.slice(0,-1).forEach((function(t){t=U(t),"object"==typeof s&&void 0===s[t]&&(s[t]={}),"object"!=typeof s[t]||Array.isArray(s[t])?(Array.isArray(s[t])?s[t].push({}):s[t]=[s[t],{}],s=s[t][s[t].length-1]):s=s[t]}));const i=U(e[e.length-1]),r=I(e.join("."),g.arrays),a=Array.isArray(n);let c=o["duplicate-arguments-array"];!c&&I(i,g.nargs)&&(c=!0,(!q(s[i])&&1===g.nargs[i]||Array.isArray(s[i])&&s[i].length===g.nargs[i])&&(s[i]=void 0)),n===L()?s[i]=L(s[i]):Array.isArray(s[i])?c&&r&&a?s[i]=o["flatten-duplicate-arrays"]?s[i].concat(n):(Array.isArray(s[i][0])?s[i]:[s[i]]).concat([n]):c||Boolean(r)!==Boolean(a)?s[i]=s[i].concat([n]):s[i]=n:void 0===s[i]&&r?s[i]=a?n:[n]:!c||void 0===s[i]||I(i,g.counts)||I(i,g.bools)?s[i]=n:s[i]=[s[i],n]}function I(t,e){const n=[].concat(g.aliases[t]||[],t),s=Object.keys(e),i=n.find((t=>s.includes(t)));return!!i&&e[i]}function H(t){const e=Object.keys(g);return[].concat(e.map((t=>g[t]))).some((function(e){return Array.isArray(e)?e.includes(t):e[t]}))}function T(t){return o["unknown-options-as-args"]&&function(t){if(t=t.replace(/^-{3,}/,"--"),t.match(m))return!1;if(function(t){if(t.match(m)||!t.match(/^-[^-]+/))return!1;let e,n=!0;const s=t.slice(1).split("");for(let i=0;i<s.length;i++){if(e=t.slice(i+2),!H(s[i])){n=!1;break}if(s[i+1]&&"="===s[i+1]||"-"===e||/[A-Za-z]/.test(s[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(e)||s[i+1]&&s[i+1].match(/\W/))break}return n}(t))return!1;return!function(t,...e){return[].concat(...e).some((function(e){const n=t.match(e);return n&&H(n[1])}))}(t,/^-+([^=]+?)=[\s\S]*$/,y,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}(t)}function B(t){return I(t,g.bools)||I(t,g.counts)||!(`${t}`in a)?(e=function(t){let e=z.BOOLEAN;return I(t,g.strings)?e=z.STRING:I(t,g.numbers)?e=z.NUMBER:I(t,g.bools)?e=z.BOOLEAN:I(t,g.arrays)&&(e=z.ARRAY),e}(t),{[z.BOOLEAN]:!0,[z.STRING]:"",[z.NUMBER]:void 0,[z.ARRAY]:[]}[e]):a[t];var e}function q(t){return void 0===t}return $(v,!0),$(v,!1),function(t){const e=Object.create(null);P(e,g.aliases,a),Object.keys(g.configs).forEach((function(n){const s=t[n]||e[n];if(s)try{let t=null;const e=R.resolve(R.cwd(),s),i=g.configs[n];if("function"==typeof i){try{t=i(e)}catch(e){t=e}if(t instanceof Error)return void(b=t)}else t=R.require(e);S(t)}catch(e){"PermissionDenied"===e.name?b=e:t[n]&&(b=Error(p("Invalid JSON config file: %s",s)))}}))}(v),void 0!==c&&c.forEach((function(t){S(t)})),P(v,g.aliases,a,!0),function(t){let e;const n=new Set;Object.keys(t).forEach((function(s){if(!n.has(s)&&(e=I(s,g.coercions),"function"==typeof e))try{const i=C(s,e(t[s]));[].concat(g.aliases[s]||[],s).forEach((e=>{n.add(e),t[e]=i}))}catch(t){b=t}}))}(v),o["set-placeholder-key"]&&function(t){g.keys.forEach((e=>{~e.indexOf(".")||void 0===t[e]&&(t[e]=void 0)}))}(v),Object.keys(g.counts).forEach((function(t){M(v,t.split("."))||E(t,0)})),h&&w.length&&(v[d]=[]),w.forEach((function(t){v[d].push(t)})),o["camel-case-expansion"]&&o["strip-dashed"]&&Object.keys(v).filter((t=>"--"!==t&&t.includes("-"))).forEach((t=>{delete v[t]})),o["strip-aliased"]&&[].concat(...Object.keys(r).map((t=>r[t]))).forEach((t=>{o["camel-case-expansion"]&&t.includes("-")&&delete v[t.split(".").map((t=>D(t))).join(".")],delete v[t]})),{aliases:Object.assign({},g.aliases),argv:Object.assign(O,v),configuration:o,defaulted:Object.assign({},f),error:b,newAliases:Object.assign({},u)}}}({cwd:process.cwd,env:()=>G,format:g,normalize:s,resolve:e,require:t=>{if("undefined"!=typeof require)return require(t);if(t.match(/\.json$/))return JSON.parse(f(t,"utf8"));throw Error("only .json config files are supported in ESM")}}),J=function(t,e){return Y.parse(t.slice(),e).argv};function K(){return process.versions.electron&&!process.defaultApp?0:1}J.detailed=function(t,e){return Y.parse(t.slice(),e)},J.camelCase=D,J.decamelize=W,J.looksLikeNumber=F;class Q extends Error{constructor(t){super(t||"yargs error"),this.name="YError",Error.captureStackTrace&&Error.captureStackTrace(this,Q)}}var Z={fs:{readFileSync:f,writeFile:p},format:g,resolve:e,exists:t=>{try{return d(t).isFile()}catch(t){return!1}}};let X;class tt{constructor(t){t=t||{},this.directory=t.directory||"./locales",this.updateFiles="boolean"!=typeof t.updateFiles||t.updateFiles,this.locale=t.locale||"en",this.fallbackToLanguage="boolean"!=typeof t.fallbackToLanguage||t.fallbackToLanguage,this.cache=Object.create(null),this.writeQueue=[]}__(...t){if("string"!=typeof arguments[0])return this._taggedLiteral(arguments[0],...arguments);const e=t.shift();let n=function(){};return"function"==typeof t[t.length-1]&&(n=t.pop()),n=n||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]=e,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),X.format.apply(X.format,[this.cache[this.locale][e]||e].concat(t))}__n(){const t=Array.prototype.slice.call(arguments),e=t.shift(),n=t.shift(),s=t.shift();let i=function(){};"function"==typeof t[t.length-1]&&(i=t.pop()),this.cache[this.locale]||this._readLocaleFile();let r=1===s?e:n;if(this.cache[this.locale][e]){r=this.cache[this.locale][e][1===s?"one":"other"]}!this.cache[this.locale][e]&&this.updateFiles?(this.cache[this.locale][e]={one:e,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();const o=[r];return~r.indexOf("%d")&&o.push(s),X.format.apply(X.format,o.concat(t))}setLocale(t){this.locale=t}getLocale(){return this.locale}updateLocale(t){this.cache[this.locale]||this._readLocaleFile();for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this.cache[this.locale][e]=t[e])}_taggedLiteral(t,...e){let n="";return t.forEach((function(t,s){const i=e[s+1];n+=t,void 0!==i&&(n+="%s")})),this.__.apply(this,[n].concat([].slice.call(e,1)))}_enqueueWrite(t){this.writeQueue.push(t),1===this.writeQueue.length&&this._processWriteQueue()}_processWriteQueue(){const t=this,e=this.writeQueue[0],n=e.directory,s=e.locale,i=e.cb,r=this._resolveLocaleFile(n,s),o=JSON.stringify(this.cache[s],null,2);X.fs.writeFile(r,o,"utf-8",(function(e){t.writeQueue.shift(),t.writeQueue.length>0&&t._processWriteQueue(),i(e)}))}_readLocaleFile(){let t={};const e=this._resolveLocaleFile(this.directory,this.locale);try{X.fs.readFileSync&&(t=JSON.parse(X.fs.readFileSync(e,"utf-8")))}catch(n){if(n instanceof SyntaxError&&(n.message="syntax error in "+e),"ENOENT"!==n.code)throw n;t={}}this.cache[this.locale]=t}_resolveLocaleFile(t,e){let n=X.resolve(t,"./",e+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~e.lastIndexOf("_")){const s=X.resolve(t,"./",e.split("_")[0]+".json");this._fileExistsSync(s)&&(n=s)}return n}_fileExistsSync(t){return X.exists(t)}}const et="loading a directory of commands is not supported yet for ESM";let nt;try{nt=y(import.meta.url)}catch(t){nt=process.cwd()}var st,it={assert:{notStrictEqual:c,strictEqual:l},cliui:function(t){return function(t,e){return P=e,new S({width:(null==t?void 0:t.width)||("object"==typeof process&&process.stdout&&process.stdout.columns?process.stdout.columns:80),wrap:null==t?void 0:t.wrap})}(t,{stringWidth:t=>[...t].length,stripAnsi:N,wrap:I})},findUp:function(t,s){let i,r=e(".",t);for(d(r).isDirectory()||(r=n(r));;){if(i=s(r,u(r)),i)return e(r,i);if(r=n(i=r),i===r)break}},getEnv:t=>process.env[t],inspect:m,getCallerFile:()=>{throw new Q(et)},getProcessArgvBin:function(){return process.argv[K()]},mainFilename:nt.substring(0,nt.lastIndexOf("node_modules"))||process.cwd(),Parser:J,path:{basename:i,dirname:n,extname:r,relative:o,resolve:e},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(t,e)=>process.emitWarning(t,e),execPath:()=>process.execPath,exit:process.exit,nextTick:process.nextTick,stdColumns:void 0!==process.stdout.columns?process.stdout.columns:null},readFileSync:f,require:()=>{throw new Q("require is not supported by ESM")},requireDirectory:()=>{throw new Q(et)},stringWidth:t=>[...t].length,y18n:(st={directory:e(nt,"../../../locales"),updateFiles:!1},function(t,e){X=e;const n=new tt(t);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}(st,Z))};function rt(t,e,n,s){n.assert.notStrictEqual(t,e,s)}function ot(t,e){e.assert.strictEqual(typeof t,"string")}function at(t){return Object.keys(t)}function ct(t){return!!t&&!!t.then&&"function"==typeof t.then}function lt(t){const e=t.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,s=e.shift();if(!s)throw new Error(`No command found in: ${t}`);const i={cmd:s.replace(n,""),demanded:[],optional:[]};return e.forEach(((t,s)=>{let r=!1;t=t.replace(/\s/g,""),/\.+[\]>]/.test(t)&&s===e.length-1&&(r=!0),/^\[/.test(t)?i.optional.push({cmd:t.replace(n,"").split("|"),variadic:r}):i.demanded.push({cmd:t.replace(n,"").split("|"),variadic:r})})),i}const ht=["first","second","third","fourth","fifth","sixth"];function dt(t,e,n){try{let s=0;const[i,r,o]="object"==typeof t?[{demanded:[],optional:[]},t,e]:[lt(`cmd ${t}`),e,n],a=[].slice.call(r);for(;a.length&&void 0===a[a.length-1];)a.pop();const c=o||a.length;if(c<i.demanded.length)throw new Q(`Not enough arguments provided. Expected ${i.demanded.length} but received ${a.length}.`);const l=i.demanded.length+i.optional.length;if(c>l)throw new Q(`Too many arguments provided. Expected max ${l} but received ${c}.`);i.demanded.forEach((t=>{const e=ut(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&ft(e,t.cmd,s),s+=1})),i.optional.forEach((t=>{if(0===a.length)return;const e=ut(a.shift());0===t.cmd.filter((t=>t===e||"*"===t)).length&&ft(e,t.cmd,s),s+=1}))}catch(t){console.warn(t.stack)}}function ut(t){return Array.isArray(t)?"array":null===t?"null":typeof t}function ft(t,e,n){throw new Q(`Invalid ${ht[n]||"manyith"} argument. Expected ${e.join(" or ")} but received ${t}.`)}class pt{constructor(t){this.globalMiddleware=[],this.frozens=[],this.yargs=t}addMiddleware(t,e,n=!0,s=!1){if(dt("<array|function> [boolean] [boolean] [boolean]",[t,e,n],arguments.length),Array.isArray(t)){for(let s=0;s<t.length;s++){if("function"!=typeof t[s])throw Error("middleware must be a function");const i=t[s];i.applyBeforeValidation=e,i.global=n}Array.prototype.push.apply(this.globalMiddleware,t)}else if("function"==typeof t){const i=t;i.applyBeforeValidation=e,i.global=n,i.mutates=s,this.globalMiddleware.push(t)}return this.yargs}addCoerceMiddleware(t,e){const n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((t=>{const s=[...n[e]||[],e];return!t.option||!s.includes(t.option)})),t.option=e,this.addMiddleware(t,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){const t=this.frozens.pop();void 0!==t&&(this.globalMiddleware=t)}reset(){this.globalMiddleware=this.globalMiddleware.filter((t=>t.global))}}function gt(t,e,n,s){return n.reduce(((t,n)=>{if(n.applyBeforeValidation!==s)return t;if(n.mutates){if(n.applied)return t;n.applied=!0}if(ct(t))return t.then((t=>Promise.all([t,n(t,e)]))).then((([t,e])=>Object.assign(t,e)));{const s=n(t,e);return ct(s)?s.then((e=>Object.assign(t,e))):Object.assign(t,s)}}),t)}function mt(t,e,n=(t=>{throw t})){try{const n="function"==typeof t?t():t;return ct(n)?n.then((t=>e(t))):e(n)}catch(t){return n(t)}}const yt=/(^\*)|(^\$0)/;class bt{constructor(t,e,n,s){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=s,this.usage=t,this.globalMiddleware=n,this.validation=e}addDirectory(t,e,n,s){"boolean"!=typeof(s=s||{}).recurse&&(s.recurse=!1),Array.isArray(s.extensions)||(s.extensions=["js"]);const i="function"==typeof s.visit?s.visit:t=>t;s.visit=(t,e,n)=>{const s=i(t,e,n);if(s){if(this.requireCache.has(e))return s;this.requireCache.add(e),this.addHandler(s)}return s},this.shim.requireDirectory({require:e,filename:n},t,s)}addHandler(t,e,n,s,i,r){let o=[];const a=function(t){return t?t.map((t=>(t.applyBeforeValidation=!1,t))):[]}(i);if(s=s||(()=>{}),Array.isArray(t))if(function(t){return t.every((t=>"string"==typeof t))}(t))[t,...o]=t;else for(const e of t)this.addHandler(e);else{if(function(t){return"object"==typeof t&&!Array.isArray(t)}(t)){let e=Array.isArray(t.command)||"string"==typeof t.command?t.command:this.moduleName(t);return t.aliases&&(e=[].concat(e).concat(t.aliases)),void this.addHandler(e,this.extractDesc(t),t.builder,t.handler,t.middlewares,t.deprecated)}if(wt(n))return void this.addHandler([t].concat(o),e,n.builder,n.handler,n.middlewares,n.deprecated)}if("string"==typeof t){const i=lt(t);o=o.map((t=>lt(t).cmd));let c=!1;const l=[i.cmd].concat(o).filter((t=>!yt.test(t)||(c=!0,!1)));0===l.length&&c&&l.push("$0"),c&&(i.cmd=l[0],o=l.slice(1),t=t.replace(yt,i.cmd)),o.forEach((t=>{this.aliasMap[t]=i.cmd})),!1!==e&&this.usage.command(t,e,c,o,r),this.handlers[i.cmd]={original:t,description:e,handler:s,builder:n||{},middlewares:a,deprecated:r,demanded:i.demanded,optional:i.optional},c&&(this.defaultCommand=this.handlers[i.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(t,e,n,s,i,r){const o=this.handlers[t]||this.handlers[this.aliasMap[t]]||this.defaultCommand,a=e.getInternalMethods().getContext(),c=a.commands.slice(),l=!t;t&&(a.commands.push(t),a.fullCommands.push(o.original));const h=this.applyBuilderUpdateUsageAndParse(l,o,e,n.aliases,c,s,i,r);return ct(h)?h.then((t=>this.applyMiddlewareAndGetResult(l,o,t.innerArgv,a,i,t.aliases,e))):this.applyMiddlewareAndGetResult(l,o,h.innerArgv,a,i,h.aliases,e)}applyBuilderUpdateUsageAndParse(t,e,n,s,i,r,o,a){const c=e.builder;let l=n;if(vt(c)){n.getInternalMethods().getUsageInstance().freeze();const h=c(n.getInternalMethods().reset(s),a);if(ct(h))return h.then((s=>{var a;return l=(a=s)&&"function"==typeof a.getInternalMethods?s:n,this.parseAndUpdateUsage(t,e,l,i,r,o)}))}else(function(t){return"object"==typeof t})(c)&&(n.getInternalMethods().getUsageInstance().freeze(),l=n.getInternalMethods().reset(s),Object.keys(e.builder).forEach((t=>{l.option(t,c[t])})));return this.parseAndUpdateUsage(t,e,l,i,r,o)}parseAndUpdateUsage(t,e,n,s,i,r){t&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(s,e),e.description);const o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,r);return ct(o)?o.then((t=>({aliases:n.parsed.aliases,innerArgv:t}))):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(t){return!t.getInternalMethods().getUsageInstance().getUsageDisabled()&&0===t.getInternalMethods().getUsageInstance().getUsage().length}usageFromParentCommandsCommandHandler(t,e){const n=yt.test(e.original)?e.original.replace(yt,"").trim():e.original,s=t.filter((t=>!yt.test(t)));return s.push(n),`$0 ${s.join(" ")}`}handleValidationAndGetResult(t,e,n,s,i,r,o,a){if(!r.getInternalMethods().getHasOutput()){const e=r.getInternalMethods().runValidation(i,a,r.parsed.error,t);n=mt(n,(t=>(e(t),t)))}if(e.handler&&!r.getInternalMethods().getHasOutput()){r.getInternalMethods().setHasOutput();const s=!!r.getOptions().configuration["populate--"];r.getInternalMethods().postProcess(n,s,!1,!1),n=mt(n=gt(n,r,o,!1),(t=>{const n=e.handler(t);return ct(n)?n.then((()=>t)):t})),t||r.getInternalMethods().getUsageInstance().cacheHelpMessage(),ct(n)&&!r.getInternalMethods().hasParseCallback()&&n.catch((t=>{try{r.getInternalMethods().getUsageInstance().fail(null,t)}catch(t){}}))}return t||(s.commands.pop(),s.fullCommands.pop()),n}applyMiddlewareAndGetResult(t,e,n,s,i,r,o){let a={};if(i)return n;o.getInternalMethods().getHasOutput()||(a=this.populatePositionals(e,n,s,o));const c=this.globalMiddleware.getMiddleware().slice(0).concat(e.middlewares),l=gt(n,o,c,!0);return ct(l)?l.then((n=>this.handleValidationAndGetResult(t,e,n,s,r,o,c,a))):this.handleValidationAndGetResult(t,e,l,s,r,o,c,a)}populatePositionals(t,e,n,s){e._=e._.slice(n.commands.length);const i=t.demanded.slice(0),r=t.optional.slice(0),o={};for(this.validation.positionalCount(i.length,e._.length);i.length;){const t=i.shift();this.populatePositional(t,e,o)}for(;r.length;){const t=r.shift();this.populatePositional(t,e,o)}return e._=n.commands.concat(e._.map((t=>""+t))),this.postProcessPositionals(e,o,this.cmdToParseOptions(t.original),s),o}populatePositional(t,e,n){const s=t.cmd[0];t.variadic?n[s]=e._.splice(0).map(String):e._.length&&(n[s]=[String(e._.shift())])}cmdToParseOptions(t){const e={array:[],default:{},alias:{},demand:{}},n=lt(t);return n.demanded.forEach((t=>{const[n,...s]=t.cmd;t.variadic&&(e.array.push(n),e.default[n]=[]),e.alias[n]=s,e.demand[n]=!0})),n.optional.forEach((t=>{const[n,...s]=t.cmd;t.variadic&&(e.array.push(n),e.default[n]=[]),e.alias[n]=s})),e}postProcessPositionals(t,e,n,s){const i=Object.assign({},s.getOptions());i.default=Object.assign(n.default,i.default);for(const t of Object.keys(n.alias))i.alias[t]=(i.alias[t]||[]).concat(n.alias[t]);i.array=i.array.concat(n.array),i.config={};const r=[];if(Object.keys(e).forEach((t=>{e[t].map((e=>{i.configuration["unknown-options-as-args"]&&(i.key[t]=!0),r.push(`--${t}`),r.push(e)}))})),!r.length)return;const o=Object.assign({},i.configuration,{"populate--":!1}),a=this.shim.Parser.detailed(r,Object.assign({},i,{configuration:o}));if(a.error)s.getInternalMethods().getUsageInstance().fail(a.error.message,a.error);else{const n=Object.keys(e);Object.keys(e).forEach((t=>{n.push(...a.aliases[t])})),Object.keys(a.argv).forEach((i=>{n.includes(i)&&(e[i]||(e[i]=a.argv[i]),!this.isInConfigs(s,i)&&!this.isDefaulted(s,i)&&Object.prototype.hasOwnProperty.call(t,i)&&Object.prototype.hasOwnProperty.call(a.argv,i)&&(Array.isArray(t[i])||Array.isArray(a.argv[i]))?t[i]=[].concat(t[i],a.argv[i]):t[i]=a.argv[i])}))}}isDefaulted(t,e){const{default:n}=t.getOptions();return Object.prototype.hasOwnProperty.call(n,e)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(e))}isInConfigs(t,e){const{configObjects:n}=t.getOptions();return n.some((t=>Object.prototype.hasOwnProperty.call(t,e)))||n.some((t=>Object.prototype.hasOwnProperty.call(t,this.shim.Parser.camelCase(e))))}runDefaultBuilderOn(t){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(t)){const e=yt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");t.getInternalMethods().getUsageInstance().usage(e,this.defaultCommand.description)}const e=this.defaultCommand.builder;if(vt(e))return e(t,!0);wt(e)||Object.keys(e).forEach((n=>{t.option(n,e[n])}))}moduleName(t){const e=function(t){if("undefined"==typeof require)return null;for(let e,n=0,s=Object.keys(require.cache);n<s.length;n++)if(e=require.cache[s[n]],e.exports===t)return e;return null}(t);if(!e)throw new Error(`No command name given for module: ${this.shim.inspect(t)}`);return this.commandFromFilename(e.filename)}commandFromFilename(t){return this.shim.path.basename(t,this.shim.path.extname(t))}extractDesc({describe:t,description:e,desc:n}){for(const s of[t,e,n]){if("string"==typeof s||!1===s)return s;rt(s,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){const t=this.frozens.pop();rt(t,void 0,this.shim),({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=t)}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function wt(t){return"object"==typeof t&&!!t.builder&&"function"==typeof t.handler}function vt(t){return"function"==typeof t}function Ot(t={},e=(()=>!0)){const n={};return at(t).forEach((s=>{e(s,t[s])&&(n[s]=t[s])})),n}function kt(t){"undefined"!=typeof process&&[process.stdout,process.stderr].forEach((e=>{const n=e;n._handle&&n.isTTY&&"function"==typeof n._handle.setBlocking&&n._handle.setBlocking(t)}))}function jt(t){return"boolean"==typeof t}function At(t,e){const n=e.y18n.__,s={},i=[];s.failFn=function(t){i.push(t)};let r=null,o=null,a=!0;s.showHelpOnFail=function(e=!0,n){const[i,c]="string"==typeof e?[!0,e]:[e,n];return t.getInternalMethods().isGlobalContext()&&(o=c),r=c,a=i,s};let c=!1;s.fail=function(e,n){const l=t.getInternalMethods().getLoggerInstance();if(!i.length){if(t.getExitProcess()&&kt(!0),!c){c=!0,a&&(t.showHelp("error"),l.error()),(e||n)&&l.error(e||n);const s=r||o;s&&((e||n)&&l.error(""),l.error(s))}if(n=n||new Q(e),t.getExitProcess())return t.exit(1);if(t.getInternalMethods().hasParseCallback())return t.exit(1,n);throw n}for(let t=i.length-1;t>=0;--t){const r=i[t];if(jt(r)){if(n)throw n;if(e)throw Error(e)}else r(e,n,s)}};let l=[],h=!1;s.usage=(t,e)=>null===t?(h=!0,l=[],s):(h=!1,l.push([t,e||""]),s),s.getUsage=()=>l,s.getUsageDisabled=()=>h,s.getPositionalGroupName=()=>n("Positionals:");let d=[];s.example=(t,e)=>{d.push([t,e||""])};let u=[];s.command=function(t,e,n,s,i=!1){n&&(u=u.map((t=>(t[2]=!1,t)))),u.push([t,e||"",n,s,i])},s.getCommands=()=>u;let f={};s.describe=function(t,e){Array.isArray(t)?t.forEach((t=>{s.describe(t,e)})):"object"==typeof t?Object.keys(t).forEach((e=>{s.describe(e,t[e])})):f[t]=e},s.getDescriptions=()=>f;let p=[];s.epilog=t=>{p.push(t)};let g,m=!1;s.wrap=t=>{m=!0,g=t},s.getWrap=()=>e.getEnv("YARGS_DISABLE_WRAP")?null:(m||(g=function(){const t=80;return e.process.stdColumns?Math.min(t,e.process.stdColumns):t}(),m=!0),g);const y="__yargsString__:";function b(t,n,s){let i=0;return Array.isArray(t)||(t=Object.values(t).map((t=>[t]))),t.forEach((t=>{i=Math.max(e.stringWidth(s?`${s} ${xt(t[0])}`:xt(t[0]))+_t(t[0]),i)})),n&&(i=Math.min(i,parseInt((.5*n).toString(),10))),i}let w;function v(e){return t.getOptions().hiddenOptions.indexOf(e)<0||t.parsed.argv[t.getOptions().showHiddenOpt]}function O(t,e){let s=`[${n("default:")} `;if(void 0===t&&!e)return null;if(e)s+=e;else switch(typeof t){case"string":s+=`"${t}"`;break;case"object":s+=JSON.stringify(t);break;default:s+=t}return`${s}]`}s.deferY18nLookup=t=>y+t,s.help=function(){if(w)return w;!function(){const e=t.getDemandedOptions(),n=t.getOptions();(Object.keys(n.alias)||[]).forEach((i=>{n.alias[i].forEach((r=>{f[r]&&s.describe(i,f[r]),r in e&&t.demandOption(i,e[r]),n.boolean.includes(r)&&t.boolean(i),n.count.includes(r)&&t.count(i),n.string.includes(r)&&t.string(i),n.normalize.includes(r)&&t.normalize(i),n.array.includes(r)&&t.array(i),n.number.includes(r)&&t.number(i)}))}))}();const i=t.customScriptName?t.$0:e.path.basename(t.$0),r=t.getDemandedOptions(),o=t.getDemandedCommands(),a=t.getDeprecatedOptions(),c=t.getGroups(),g=t.getOptions();let m=[];m=m.concat(Object.keys(f)),m=m.concat(Object.keys(r)),m=m.concat(Object.keys(o)),m=m.concat(Object.keys(g.default)),m=m.filter(v),m=Object.keys(m.reduce(((t,e)=>("_"!==e&&(t[e]=!0),t)),{}));const k=s.getWrap(),j=e.cliui({width:k,wrap:!!k});if(!h)if(l.length)l.forEach((t=>{j.div({text:`${t[0].replace(/\$0/g,i)}`}),t[1]&&j.div({text:`${t[1]}`,padding:[1,0,0,0]})})),j.div();else if(u.length){let t=null;t=o._?`${i} <${n("command")}>\n`:`${i} [${n("command")}]\n`,j.div(`${t}`)}if(u.length>1||1===u.length&&!u[0][2]){j.div(n("Commands:"));const e=t.getInternalMethods().getContext(),s=e.commands.length?`${e.commands.join(" ")} `:"";!0===t.getInternalMethods().getParserConfiguration()["sort-commands"]&&(u=u.sort(((t,e)=>t[0].localeCompare(e[0]))));const r=i?`${i} `:"";u.forEach((t=>{const e=`${r}${s}${t[0].replace(/^\$0 ?/,"")}`;j.span({text:e,padding:[0,2,0,2],width:b(u,k,`${i}${s}`)+4},{text:t[1]});const o=[];t[2]&&o.push(`[${n("default")}]`),t[3]&&t[3].length&&o.push(`[${n("aliases:")} ${t[3].join(", ")}]`),t[4]&&("string"==typeof t[4]?o.push(`[${n("deprecated: %s",t[4])}]`):o.push(`[${n("deprecated")}]`)),o.length?j.div({text:o.join(" "),padding:[0,0,0,2],align:"right"}):j.div()})),j.div()}const A=(Object.keys(g.alias)||[]).concat(Object.keys(t.parsed.newAliases)||[]);m=m.filter((e=>!t.parsed.newAliases[e]&&A.every((t=>-1===(g.alias[t]||[]).indexOf(e)))));const E=n("Options:");c[E]||(c[E]=[]),function(t,e,n,s){let i=[],r=null;Object.keys(n).forEach((t=>{i=i.concat(n[t])})),t.forEach((t=>{r=[t].concat(e[t]),r.some((t=>-1!==i.indexOf(t)))||n[s].push(t)}))}(m,g.alias,c,E);const _=t=>/^--/.test(xt(t)),x=Object.keys(c).filter((t=>c[t].length>0)).map((t=>({groupName:t,normalizedKeys:c[t].filter(v).map((t=>{if(A.includes(t))return t;for(let e,n=0;void 0!==(e=A[n]);n++)if((g.alias[e]||[]).includes(t))return e;return t}))}))).filter((({normalizedKeys:t})=>t.length>0)).map((({groupName:t,normalizedKeys:e})=>{const n=e.reduce(((e,n)=>(e[n]=[n].concat(g.alias[n]||[]).map((e=>t===s.getPositionalGroupName()?e:(/^[0-9]$/.test(e)?g.boolean.includes(n)?"-":"--":e.length>1?"--":"-")+e)).sort(((t,e)=>_(t)===_(e)?0:_(t)?1:-1)).join(", "),e)),{});return{groupName:t,normalizedKeys:e,switches:n}}));if(x.filter((({groupName:t})=>t!==s.getPositionalGroupName())).some((({normalizedKeys:t,switches:e})=>!t.every((t=>_(e[t])))))&&x.filter((({groupName:t})=>t!==s.getPositionalGroupName())).forEach((({normalizedKeys:t,switches:e})=>{t.forEach((t=>{var n,s;_(e[t])&&(e[t]=(n=e[t],s=4,Et(n)?{text:n.text,indentation:n.indentation+s}:{text:n,indentation:s}))}))})),x.forEach((({groupName:e,normalizedKeys:i,switches:o})=>{j.div(e),i.forEach((e=>{const i=o[e];let c=f[e]||"",l=null;c.includes(y)&&(c=n(c.substring(16))),g.boolean.includes(e)&&(l=`[${n("boolean")}]`),g.count.includes(e)&&(l=`[${n("count")}]`),g.string.includes(e)&&(l=`[${n("string")}]`),g.normalize.includes(e)&&(l=`[${n("string")}]`),g.array.includes(e)&&(l=`[${n("array")}]`),g.number.includes(e)&&(l=`[${n("number")}]`);const h=[e in a?(d=a[e],"string"==typeof d?`[${n("deprecated: %s",d)}]`:`[${n("deprecated")}]`):null,l,e in r?`[${n("required")}]`:null,g.choices&&g.choices[e]?`[${n("choices:")} ${s.stringifiedValues(g.choices[e])}]`:null,O(g.default[e],g.defaultDescription[e])].filter(Boolean).join(" ");var d;j.span({text:xt(i),padding:[0,2,0,2+_t(i)],width:b(o,k)+4},c);const u=!0===t.getInternalMethods().getUsageConfiguration()["hide-types"];h&&!u?j.div({text:h,padding:[0,0,0,2],align:"right"}):j.div()})),j.div()})),d.length&&(j.div(n("Examples:")),d.forEach((t=>{t[0]=t[0].replace(/\$0/g,i)})),d.forEach((t=>{""===t[1]?j.div({text:t[0],padding:[0,2,0,2]}):j.div({text:t[0],padding:[0,2,0,2],width:b(d,k)+4},{text:t[1]})})),j.div()),p.length>0){const t=p.map((t=>t.replace(/\$0/g,i))).join("\n");j.div(`${t}\n`)}return j.toString().replace(/\s*$/,"")},s.cacheHelpMessage=function(){w=this.help()},s.clearCachedHelpMessage=function(){w=void 0},s.hasCachedHelpMessage=function(){return!!w},s.showHelp=e=>{const n=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:n[e])(s.help())},s.functionDescription=t=>["(",t.name?e.Parser.decamelize(t.name,"-"):n("generated-value"),")"].join(""),s.stringifiedValues=function(t,e){let n="";const s=e||", ",i=[].concat(t);return t&&i.length?(i.forEach((t=>{n.length&&(n+=s),n+=JSON.stringify(t)})),n):n};let k=null;s.version=t=>{k=t},s.showVersion=e=>{const n=t.getInternalMethods().getLoggerInstance();e||(e="error");("function"==typeof e?e:n[e])(k)},s.reset=function(t){return r=null,c=!1,l=[],h=!1,p=[],d=[],u=[],f=Ot(f,(e=>!t[e])),s};const j=[];return s.freeze=function(){j.push({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f})},s.unfreeze=function(t=!1){const e=j.pop();e&&(t?(f={...e.descriptions,...f},u=[...e.commands,...u],l=[...e.usages,...l],d=[...e.examples,...d],p=[...e.epilogs,...p]):({failMessage:r,failureOutput:c,usages:l,usageDisabled:h,epilogs:p,examples:d,commands:u,descriptions:f}=e))},s}function Et(t){return"object"==typeof t}function _t(t){return Et(t)?t.indentation:0}function xt(t){return Et(t)?t.text:t}class Ct{constructor(t,e,n,s){var i,r,o;this.yargs=t,this.usage=e,this.command=n,this.shim=s,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=null!==(o=(null===(i=this.shim.getEnv("SHELL"))||void 0===i?void 0:i.includes("zsh"))||(null===(r=this.shim.getEnv("ZSH_NAME"))||void 0===r?void 0:r.includes("zsh")))&&void 0!==o&&o}defaultCompletion(t,e,n,s){const i=this.command.getCommandHandlers();for(let e=0,n=t.length;e<n;++e)if(i[t[e]]&&i[t[e]].builder){const n=i[t[e]].builder;if(vt(n)){this.indexAfterLastReset=e+1;const t=this.yargs.getInternalMethods().reset();return n(t,!0),t.argv}}const r=[];this.commandCompletions(r,t,n),this.optionCompletions(r,t,e,n),this.choicesFromOptionsCompletions(r,t,e,n),this.choicesFromPositionalsCompletions(r,t,e,n),s(null,r)}commandCompletions(t,e,n){const s=this.yargs.getInternalMethods().getContext().commands;n.match(/^-/)||s[s.length-1]===n||this.previousArgHasChoices(e)||this.usage.getCommands().forEach((n=>{const s=lt(n[0]).cmd;if(-1===e.indexOf(s))if(this.zshShell){const e=n[1]||"";t.push(s.replace(/:/g,"\\:")+":"+e)}else t.push(s)}))}optionCompletions(t,e,n,s){if((s.match(/^-/)||""===s&&0===t.length)&&!this.previousArgHasChoices(e)){const n=this.yargs.getOptions(),i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(n.key).forEach((r=>{const o=!!n.configuration["boolean-negation"]&&n.boolean.includes(r);i.includes(r)||n.hiddenOptions.includes(r)||this.argsContainKey(e,r,o)||this.completeOptionKey(r,t,s,o&&!!n.default[r])}))}}choicesFromOptionsCompletions(t,e,n,s){if(this.previousArgHasChoices(e)){const n=this.getPreviousArgChoices(e);n&&n.length>0&&t.push(...n.map((t=>t.replace(/:/g,"\\:"))))}}choicesFromPositionalsCompletions(t,e,n,s){if(""===s&&t.length>0&&this.previousArgHasChoices(e))return;const i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],r=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[n._.length-r-1];if(!o)return;const a=this.yargs.getOptions().choices[o]||[];for(const e of a)e.startsWith(s)&&t.push(e.replace(/:/g,"\\:"))}getPreviousArgChoices(t){if(t.length<1)return;let e=t[t.length-1],n="";if(!e.startsWith("-")&&t.length>1&&(n=e,e=t[t.length-2]),!e.startsWith("-"))return;const s=e.replace(/^-+/,""),i=this.yargs.getOptions(),r=[s,...this.yargs.getAliases()[s]||[]];let o;for(const t of r)if(Object.prototype.hasOwnProperty.call(i.key,t)&&Array.isArray(i.choices[t])){o=i.choices[t];break}return o?o.filter((t=>!n||t.startsWith(n))):void 0}previousArgHasChoices(t){const e=this.getPreviousArgChoices(t);return void 0!==e&&e.length>0}argsContainKey(t,e,n){const s=e=>-1!==t.indexOf((/^[^0-9]$/.test(e)?"-":"--")+e);if(s(e))return!0;if(n&&s(`no-${e}`))return!0;if(this.aliases)for(const t of this.aliases[e])if(s(t))return!0;return!1}completeOptionKey(t,e,n,s){var i,r,o,a;let c=t;if(this.zshShell){const e=this.usage.getDescriptions(),n=null===(r=null===(i=null==this?void 0:this.aliases)||void 0===i?void 0:i[t])||void 0===r?void 0:r.find((t=>{const n=e[t];return"string"==typeof n&&n.length>0})),s=n?e[n]:void 0,l=null!==(a=null!==(o=e[t])&&void 0!==o?o:s)&&void 0!==a?a:"";c=`${t.replace(/:/g,"\\:")}:${l.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}const l=!/^--/.test(n)&&(t=>/^[^0-9]$/.test(t))(t)?"-":"--";e.push(l+c),s&&e.push(l+"no-"+c)}customCompletion(t,e,n,s){if(rt(this.customCompletionFunction,null,this.shim),this.customCompletionFunction.length<3){const t=this.customCompletionFunction(n,e);return ct(t)?t.then((t=>{this.shim.process.nextTick((()=>{s(null,t)}))})).catch((t=>{this.shim.process.nextTick((()=>{s(t,void 0)}))})):s(null,t)}return function(t){return t.length>3}(this.customCompletionFunction)?this.customCompletionFunction(n,e,((i=s)=>this.defaultCompletion(t,e,n,i)),(t=>{s(null,t)})):this.customCompletionFunction(n,e,(t=>{s(null,t)}))}getCompletion(t,e){const n=t.length?t[t.length-1]:"",s=this.yargs.parse(t,!0),i=this.customCompletionFunction?s=>this.customCompletion(t,s,n,e):s=>this.defaultCompletion(t,s,n,e);return ct(s)?s.then(i):i(s)}generateCompletionScript(t,e){let n=this.zshShell?'#compdef {{app_name}}\n###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc\n# or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local reply\n local si=$IFS\n IFS=$\'\n\' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "${words[@]}"))\n IFS=$si\n _describe \'values\' reply\n}\ncompdef _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n':'###-begin-{{app_name}}-completions-###\n#\n# yargs command completion script\n#\n# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc\n# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.\n#\n_{{app_name}}_yargs_completions()\n{\n local cur_word args type_list\n\n cur_word="${COMP_WORDS[COMP_CWORD]}"\n args=("${COMP_WORDS[@]}")\n\n # ask yargs to generate completions.\n type_list=$({{app_path}} --get-yargs-completions "${args[@]}")\n\n COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )\n\n # if no match was found, fall back to filename completion\n if [ ${#COMPREPLY[@]} -eq 0 ]; then\n COMPREPLY=()\n fi\n\n return 0\n}\ncomplete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}\n###-end-{{app_name}}-completions-###\n';const s=this.shim.path.basename(t);return t.match(/\.js$/)&&(t=`./${t}`),n=n.replace(/{{app_name}}/g,s),n=n.replace(/{{completion_command}}/g,e),n.replace(/{{app_path}}/g,t)}registerFunction(t){this.customCompletionFunction=t}setParsed(t){this.aliases=t.aliases}}function St(t,e){if(0===t.length)return e.length;if(0===e.length)return t.length;const n=[];let s,i;for(s=0;s<=e.length;s++)n[s]=[s];for(i=0;i<=t.length;i++)n[0][i]=i;for(s=1;s<=e.length;s++)for(i=1;i<=t.length;i++)e.charAt(s-1)===t.charAt(i-1)?n[s][i]=n[s-1][i-1]:s>1&&i>1&&e.charAt(s-2)===t.charAt(i-1)&&e.charAt(s-1)===t.charAt(i-2)?n[s][i]=n[s-2][i-2]+1:n[s][i]=Math.min(n[s-1][i-1]+1,Math.min(n[s][i-1]+1,n[s-1][i]+1));return n[e.length][t.length]}const $t=["$0","--","_"];let Pt,Mt=[];function Nt(t,e,n,s){Pt=s;let i={};if(Object.prototype.hasOwnProperty.call(t,"extends")){if("string"!=typeof t.extends)return i;const s=/\.json|\..*rc$/.test(t.extends);let r=null;if(s)r=function(t,e){return Pt.path.resolve(t,e)}(e,t.extends);else try{r=require.resolve(t.extends)}catch(e){return t}!function(t){if(Mt.indexOf(t)>-1)throw new Q(`Circular extended configurations: '${t}'.`)}(r),Mt.push(r),i=s?JSON.parse(Pt.readFileSync(r,"utf8")):require(t.extends),delete t.extends,i=Nt(i,Pt.path.dirname(r),n,Pt)}return Mt=[],n?It(i,t):Object.assign({},i,t)}function It(t,e){const n={};function s(t){return t&&"object"==typeof t&&!Array.isArray(t)}Object.assign(n,t);for(const i of Object.keys(e))s(e[i])&&s(n[i])?n[i]=It(t[i],e[i]):n[i]=e[i];return n}var Dt,Wt,Ft,zt,Rt,Lt,Ut,Ht,Tt,Bt,qt,Vt,Gt,Yt,Jt,Kt,Qt,Zt,Xt,te,ee,ne,se,ie,re,oe,ae,ce,le,he,de,ue,fe,pe,ge,me=function(t,e,n,s,i){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?i.call(t,n):i?i.value=n:e.set(t,n),n},ye=function(t,e,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(t):s?s.value:e.get(t)};const be=Symbol("copyDoubleDash"),we=Symbol("copyDoubleDash"),ve=Symbol("deleteFromParserHintObject"),Oe=Symbol("emitWarning"),ke=Symbol("freeze"),je=Symbol("getDollarZero"),Ae=Symbol("getParserConfiguration"),Ee=Symbol("getUsageConfiguration"),_e=Symbol("guessLocale"),xe=Symbol("guessVersion"),Ce=Symbol("parsePositionalNumbers"),Se=Symbol("pkgUp"),$e=Symbol("populateParserHintArray"),Pe=Symbol("populateParserHintSingleValueDictionary"),Me=Symbol("populateParserHintArrayDictionary"),Ne=Symbol("populateParserHintDictionary"),Ie=Symbol("sanitizeKey"),De=Symbol("setKey"),We=Symbol("unfreeze"),Fe=Symbol("validateAsync"),ze=Symbol("getCommandInstance"),Re=Symbol("getContext"),Le=Symbol("getHasOutput"),Ue=Symbol("getLoggerInstance"),He=Symbol("getParseContext"),Te=Symbol("getUsageInstance"),Be=Symbol("getValidationInstance"),qe=Symbol("hasParseCallback"),Ve=Symbol("isGlobalContext"),Ge=Symbol("postProcess"),Ye=Symbol("rebase"),Je=Symbol("reset"),Ke=Symbol("runYargsParserAndExecuteCommands"),Qe=Symbol("runValidation"),Ze=Symbol("setHasOutput"),Xe=Symbol("kTrackManuallySetKeys");class tn{constructor(t=[],e,n,s){this.customScriptName=!1,this.parsed=!1,Dt.set(this,void 0),Wt.set(this,void 0),Ft.set(this,{commands:[],fullCommands:[]}),zt.set(this,null),Rt.set(this,null),Lt.set(this,"show-hidden"),Ut.set(this,null),Ht.set(this,!0),Tt.set(this,{}),Bt.set(this,!0),qt.set(this,[]),Vt.set(this,void 0),Gt.set(this,{}),Yt.set(this,!1),Jt.set(this,null),Kt.set(this,!0),Qt.set(this,void 0),Zt.set(this,""),Xt.set(this,void 0),te.set(this,void 0),ee.set(this,{}),ne.set(this,null),se.set(this,null),ie.set(this,{}),re.set(this,{}),oe.set(this,void 0),ae.set(this,!1),ce.set(this,void 0),le.set(this,!1),he.set(this,!1),de.set(this,!1),ue.set(this,void 0),fe.set(this,{}),pe.set(this,null),ge.set(this,void 0),me(this,ce,s,"f"),me(this,oe,t,"f"),me(this,Wt,e,"f"),me(this,te,n,"f"),me(this,Vt,new pt(this),"f"),this.$0=this[je](),this[Je](),me(this,Dt,ye(this,Dt,"f"),"f"),me(this,ue,ye(this,ue,"f"),"f"),me(this,ge,ye(this,ge,"f"),"f"),me(this,Xt,ye(this,Xt,"f"),"f"),ye(this,Xt,"f").showHiddenOpt=ye(this,Lt,"f"),me(this,Qt,this[we](),"f")}addHelpOpt(t,e){return dt("[string|boolean] [string]",[t,e],arguments.length),ye(this,Jt,"f")&&(this[ve](ye(this,Jt,"f")),me(this,Jt,null,"f")),!1===t&&void 0===e||(me(this,Jt,"string"==typeof t?t:"help","f"),this.boolean(ye(this,Jt,"f")),this.describe(ye(this,Jt,"f"),e||ye(this,ue,"f").deferY18nLookup("Show help"))),this}help(t,e){return this.addHelpOpt(t,e)}addShowHiddenOpt(t,e){if(dt("[string|boolean] [string]",[t,e],arguments.length),!1===t&&void 0===e)return this;const n="string"==typeof t?t:ye(this,Lt,"f");return this.boolean(n),this.describe(n,e||ye(this,ue,"f").deferY18nLookup("Show hidden options")),ye(this,Xt,"f").showHiddenOpt=n,this}showHidden(t,e){return this.addShowHiddenOpt(t,e)}alias(t,e){return dt("<object|string|array> [string|array]",[t,e],arguments.length),this[Me](this.alias.bind(this),"alias",t,e),this}array(t){return dt("<array|string>",[t],arguments.length),this[$e]("array",t),this[Xe](t),this}boolean(t){return dt("<array|string>",[t],arguments.length),this[$e]("boolean",t),this[Xe](t),this}check(t,e){return dt("<function> [boolean]",[t,e],arguments.length),this.middleware(((e,n)=>mt((()=>t(e,n.getOptions())),(n=>(n?("string"==typeof n||n instanceof Error)&&ye(this,ue,"f").fail(n.toString(),n):ye(this,ue,"f").fail(ye(this,ce,"f").y18n.__("Argument check failed: %s",t.toString())),e)),(t=>(ye(this,ue,"f").fail(t.message?t.message:t.toString(),t),e)))),!1,e),this}choices(t,e){return dt("<object|string|array> [string|array]",[t,e],arguments.length),this[Me](this.choices.bind(this),"choices",t,e),this}coerce(t,e){if(dt("<object|string|array> [function]",[t,e],arguments.length),Array.isArray(t)){if(!e)throw new Q("coerce callback must be provided");for(const n of t)this.coerce(n,e);return this}if("object"==typeof t){for(const e of Object.keys(t))this.coerce(e,t[e]);return this}if(!e)throw new Q("coerce callback must be provided");return ye(this,Xt,"f").key[t]=!0,ye(this,Vt,"f").addCoerceMiddleware(((n,s)=>{let i;return Object.prototype.hasOwnProperty.call(n,t)?mt((()=>(i=s.getAliases(),e(n[t]))),(e=>{n[t]=e;const r=s.getInternalMethods().getParserConfiguration()["strip-aliased"];if(i[t]&&!0!==r)for(const s of i[t])n[s]=e;return n}),(t=>{throw new Q(t.message)})):n}),t),this}conflicts(t,e){return dt("<string|object> [string|array]",[t,e],arguments.length),ye(this,ge,"f").conflicts(t,e),this}config(t="config",e,n){return dt("[object|string] [string|function] [function]",[t,e,n],arguments.length),"object"!=typeof t||Array.isArray(t)?("function"==typeof e&&(n=e,e=void 0),this.describe(t,e||ye(this,ue,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(t)?t:[t]).forEach((t=>{ye(this,Xt,"f").config[t]=n||!0})),this):(t=Nt(t,ye(this,Wt,"f"),this[Ae]()["deep-merge-config"]||!1,ye(this,ce,"f")),ye(this,Xt,"f").configObjects=(ye(this,Xt,"f").configObjects||[]).concat(t),this)}completion(t,e,n){return dt("[string] [string|boolean|function] [function]",[t,e,n],arguments.length),"function"==typeof e&&(n=e,e=void 0),me(this,Rt,t||ye(this,Rt,"f")||"completion","f"),e||!1===e||(e="generate completion script"),this.command(ye(this,Rt,"f"),e),n&&ye(this,zt,"f").registerFunction(n),this}command(t,e,n,s,i,r){return dt("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[t,e,n,s,i,r],arguments.length),ye(this,Dt,"f").addHandler(t,e,n,s,i,r),this}commands(t,e,n,s,i,r){return this.command(t,e,n,s,i,r)}commandDir(t,e){dt("<string> [object]",[t,e],arguments.length);const n=ye(this,te,"f")||ye(this,ce,"f").require;return ye(this,Dt,"f").addDirectory(t,n,ye(this,ce,"f").getCallerFile(),e),this}count(t){return dt("<array|string>",[t],arguments.length),this[$e]("count",t),this[Xe](t),this}default(t,e,n){return dt("<object|string|array> [*] [string]",[t,e,n],arguments.length),n&&(ot(t,ye(this,ce,"f")),ye(this,Xt,"f").defaultDescription[t]=n),"function"==typeof e&&(ot(t,ye(this,ce,"f")),ye(this,Xt,"f").defaultDescription[t]||(ye(this,Xt,"f").defaultDescription[t]=ye(this,ue,"f").functionDescription(e)),e=e.call()),this[Pe](this.default.bind(this),"default",t,e),this}defaults(t,e,n){return this.default(t,e,n)}demandCommand(t=1,e,n,s){return dt("[number] [number|string] [string|null|undefined] [string|null|undefined]",[t,e,n,s],arguments.length),"number"!=typeof e&&(n=e,e=1/0),this.global("_",!1),ye(this,Xt,"f").demandedCommands._={min:t,max:e,minMsg:n,maxMsg:s},this}demand(t,e,n){return Array.isArray(e)?(e.forEach((t=>{rt(n,!0,ye(this,ce,"f")),this.demandOption(t,n)})),e=1/0):"number"!=typeof e&&(n=e,e=1/0),"number"==typeof t?(rt(n,!0,ye(this,ce,"f")),this.demandCommand(t,e,n,n)):Array.isArray(t)?t.forEach((t=>{rt(n,!0,ye(this,ce,"f")),this.demandOption(t,n)})):"string"==typeof n?this.demandOption(t,n):!0!==n&&void 0!==n||this.demandOption(t),this}demandOption(t,e){return dt("<object|string|array> [string]",[t,e],arguments.length),this[Pe](this.demandOption.bind(this),"demandedOptions",t,e),this}deprecateOption(t,e){return dt("<string> [string|boolean]",[t,e],arguments.length),ye(this,Xt,"f").deprecatedOptions[t]=e,this}describe(t,e){return dt("<object|string|array> [string]",[t,e],arguments.length),this[De](t,!0),ye(this,ue,"f").describe(t,e),this}detectLocale(t){return dt("<boolean>",[t],arguments.length),me(this,Ht,t,"f"),this}env(t){return dt("[string|boolean]",[t],arguments.length),!1===t?delete ye(this,Xt,"f").envPrefix:ye(this,Xt,"f").envPrefix=t||"",this}epilogue(t){return dt("<string>",[t],arguments.length),ye(this,ue,"f").epilog(t),this}epilog(t){return this.epilogue(t)}example(t,e){return dt("<string|array> [string]",[t,e],arguments.length),Array.isArray(t)?t.forEach((t=>this.example(...t))):ye(this,ue,"f").example(t,e),this}exit(t,e){me(this,Yt,!0,"f"),me(this,Ut,e,"f"),ye(this,Bt,"f")&&ye(this,ce,"f").process.exit(t)}exitProcess(t=!0){return dt("[boolean]",[t],arguments.length),me(this,Bt,t,"f"),this}fail(t){if(dt("<function|boolean>",[t],arguments.length),"boolean"==typeof t&&!1!==t)throw new Q("Invalid first argument. Expected function or boolean 'false'");return ye(this,ue,"f").failFn(t),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(t,e){return dt("<array> [function]",[t,e],arguments.length),e?ye(this,zt,"f").getCompletion(t,e):new Promise(((e,n)=>{ye(this,zt,"f").getCompletion(t,((t,s)=>{t?n(t):e(s)}))}))}getDemandedOptions(){return dt([],0),ye(this,Xt,"f").demandedOptions}getDemandedCommands(){return dt([],0),ye(this,Xt,"f").demandedCommands}getDeprecatedOptions(){return dt([],0),ye(this,Xt,"f").deprecatedOptions}getDetectLocale(){return ye(this,Ht,"f")}getExitProcess(){return ye(this,Bt,"f")}getGroups(){return Object.assign({},ye(this,Gt,"f"),ye(this,re,"f"))}getHelp(){if(me(this,Yt,!0,"f"),!ye(this,ue,"f").hasCachedHelpMessage()){if(!this.parsed){const t=this[Ke](ye(this,oe,"f"),void 0,void 0,0,!0);if(ct(t))return t.then((()=>ye(this,ue,"f").help()))}const t=ye(this,Dt,"f").runDefaultBuilderOn(this);if(ct(t))return t.then((()=>ye(this,ue,"f").help()))}return Promise.resolve(ye(this,ue,"f").help())}getOptions(){return ye(this,Xt,"f")}getStrict(){return ye(this,le,"f")}getStrictCommands(){return ye(this,he,"f")}getStrictOptions(){return ye(this,de,"f")}global(t,e){return dt("<string|array> [boolean]",[t,e],arguments.length),t=[].concat(t),!1!==e?ye(this,Xt,"f").local=ye(this,Xt,"f").local.filter((e=>-1===t.indexOf(e))):t.forEach((t=>{ye(this,Xt,"f").local.includes(t)||ye(this,Xt,"f").local.push(t)})),this}group(t,e){dt("<string|array> <string>",[t,e],arguments.length);const n=ye(this,re,"f")[e]||ye(this,Gt,"f")[e];ye(this,re,"f")[e]&&delete ye(this,re,"f")[e];const s={};return ye(this,Gt,"f")[e]=(n||[]).concat(t).filter((t=>!s[t]&&(s[t]=!0))),this}hide(t){return dt("<string>",[t],arguments.length),ye(this,Xt,"f").hiddenOptions.push(t),this}implies(t,e){return dt("<string|object> [number|string|array]",[t,e],arguments.length),ye(this,ge,"f").implies(t,e),this}locale(t){return dt("[string]",[t],arguments.length),void 0===t?(this[_e](),ye(this,ce,"f").y18n.getLocale()):(me(this,Ht,!1,"f"),ye(this,ce,"f").y18n.setLocale(t),this)}middleware(t,e,n){return ye(this,Vt,"f").addMiddleware(t,!!e,n)}nargs(t,e){return dt("<string|object|array> [number]",[t,e],arguments.length),this[Pe](this.nargs.bind(this),"narg",t,e),this}normalize(t){return dt("<array|string>",[t],arguments.length),this[$e]("normalize",t),this}number(t){return dt("<array|string>",[t],arguments.length),this[$e]("number",t),this[Xe](t),this}option(t,e){if(dt("<string|object> [object]",[t,e],arguments.length),"object"==typeof t)Object.keys(t).forEach((e=>{this.options(e,t[e])}));else{"object"!=typeof e&&(e={}),this[Xe](t),!ye(this,pe,"f")||"version"!==t&&"version"!==(null==e?void 0:e.alias)||this[Oe](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join("\n"),void 0,"versionWarning"),ye(this,Xt,"f").key[t]=!0,e.alias&&this.alias(t,e.alias);const n=e.deprecate||e.deprecated;n&&this.deprecateOption(t,n);const s=e.demand||e.required||e.require;s&&this.demand(t,s),e.demandOption&&this.demandOption(t,"string"==typeof e.demandOption?e.demandOption:void 0),e.conflicts&&this.conflicts(t,e.conflicts),"default"in e&&this.default(t,e.default),void 0!==e.implies&&this.implies(t,e.implies),void 0!==e.nargs&&this.nargs(t,e.nargs),e.config&&this.config(t,e.configParser),e.normalize&&this.normalize(t),e.choices&&this.choices(t,e.choices),e.coerce&&this.coerce(t,e.coerce),e.group&&this.group(t,e.group),(e.boolean||"boolean"===e.type)&&(this.boolean(t),e.alias&&this.boolean(e.alias)),(e.array||"array"===e.type)&&(this.array(t),e.alias&&this.array(e.alias)),(e.number||"number"===e.type)&&(this.number(t),e.alias&&this.number(e.alias)),(e.string||"string"===e.type)&&(this.string(t),e.alias&&this.string(e.alias)),(e.count||"count"===e.type)&&this.count(t),"boolean"==typeof e.global&&this.global(t,e.global),e.defaultDescription&&(ye(this,Xt,"f").defaultDescription[t]=e.defaultDescription),e.skipValidation&&this.skipValidation(t);const i=e.describe||e.description||e.desc,r=ye(this,ue,"f").getDescriptions();Object.prototype.hasOwnProperty.call(r,t)&&"string"!=typeof i||this.describe(t,i),e.hidden&&this.hide(t),e.requiresArg&&this.requiresArg(t)}return this}options(t,e){return this.option(t,e)}parse(t,e,n){dt("[string|array] [function|boolean|object] [function]",[t,e,n],arguments.length),this[ke](),void 0===t&&(t=ye(this,oe,"f")),"object"==typeof e&&(me(this,se,e,"f"),e=n),"function"==typeof e&&(me(this,ne,e,"f"),e=!1),e||me(this,oe,t,"f"),ye(this,ne,"f")&&me(this,Bt,!1,"f");const s=this[Ke](t,!!e),i=this.parsed;return ye(this,zt,"f").setParsed(this.parsed),ct(s)?s.then((t=>(ye(this,ne,"f")&&ye(this,ne,"f").call(this,ye(this,Ut,"f"),t,ye(this,Zt,"f")),t))).catch((t=>{throw ye(this,ne,"f")&&ye(this,ne,"f")(t,this.parsed.argv,ye(this,Zt,"f")),t})).finally((()=>{this[We](),this.parsed=i})):(ye(this,ne,"f")&&ye(this,ne,"f").call(this,ye(this,Ut,"f"),s,ye(this,Zt,"f")),this[We](),this.parsed=i,s)}parseAsync(t,e,n){const s=this.parse(t,e,n);return ct(s)?s:Promise.resolve(s)}parseSync(t,e,n){const s=this.parse(t,e,n);if(ct(s))throw new Q(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return s}parserConfiguration(t){return dt("<object>",[t],arguments.length),me(this,ee,t,"f"),this}pkgConf(t,e){dt("<string> [string]",[t,e],arguments.length);let n=null;const s=this[Se](e||ye(this,Wt,"f"));return s[t]&&"object"==typeof s[t]&&(n=Nt(s[t],e||ye(this,Wt,"f"),this[Ae]()["deep-merge-config"]||!1,ye(this,ce,"f")),ye(this,Xt,"f").configObjects=(ye(this,Xt,"f").configObjects||[]).concat(n)),this}positional(t,e){dt("<string> <object>",[t,e],arguments.length);const n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];e=Ot(e,((t,e)=>!("type"===t&&!["string","number","boolean"].includes(e))&&n.includes(t)));const s=ye(this,Ft,"f").fullCommands[ye(this,Ft,"f").fullCommands.length-1],i=s?ye(this,Dt,"f").cmdToParseOptions(s):{array:[],alias:{},default:{},demand:{}};return at(i).forEach((n=>{const s=i[n];Array.isArray(s)?-1!==s.indexOf(t)&&(e[n]=!0):s[t]&&!(n in e)&&(e[n]=s[t])})),this.group(t,ye(this,ue,"f").getPositionalGroupName()),this.option(t,e)}recommendCommands(t=!0){return dt("[boolean]",[t],arguments.length),me(this,ae,t,"f"),this}required(t,e,n){return this.demand(t,e,n)}require(t,e,n){return this.demand(t,e,n)}requiresArg(t){return dt("<array|string|object> [number]",[t],arguments.length),"string"==typeof t&&ye(this,Xt,"f").narg[t]||this[Pe](this.requiresArg.bind(this),"narg",t,NaN),this}showCompletionScript(t,e){return dt("[string] [string]",[t,e],arguments.length),t=t||this.$0,ye(this,Qt,"f").log(ye(this,zt,"f").generateCompletionScript(t,e||ye(this,Rt,"f")||"completion")),this}showHelp(t){if(dt("[string|function]",[t],arguments.length),me(this,Yt,!0,"f"),!ye(this,ue,"f").hasCachedHelpMessage()){if(!this.parsed){const e=this[Ke](ye(this,oe,"f"),void 0,void 0,0,!0);if(ct(e))return e.then((()=>{ye(this,ue,"f").showHelp(t)})),this}const e=ye(this,Dt,"f").runDefaultBuilderOn(this);if(ct(e))return e.then((()=>{ye(this,ue,"f").showHelp(t)})),this}return ye(this,ue,"f").showHelp(t),this}scriptName(t){return this.customScriptName=!0,this.$0=t,this}showHelpOnFail(t,e){return dt("[boolean|string] [string]",[t,e],arguments.length),ye(this,ue,"f").showHelpOnFail(t,e),this}showVersion(t){return dt("[string|function]",[t],arguments.length),ye(this,ue,"f").showVersion(t),this}skipValidation(t){return dt("<array|string>",[t],arguments.length),this[$e]("skipValidation",t),this}strict(t){return dt("[boolean]",[t],arguments.length),me(this,le,!1!==t,"f"),this}strictCommands(t){return dt("[boolean]",[t],arguments.length),me(this,he,!1!==t,"f"),this}strictOptions(t){return dt("[boolean]",[t],arguments.length),me(this,de,!1!==t,"f"),this}string(t){return dt("<array|string>",[t],arguments.length),this[$e]("string",t),this[Xe](t),this}terminalWidth(){return dt([],0),ye(this,ce,"f").process.stdColumns}updateLocale(t){return this.updateStrings(t)}updateStrings(t){return dt("<object>",[t],arguments.length),me(this,Ht,!1,"f"),ye(this,ce,"f").y18n.updateLocale(t),this}usage(t,e,n,s){if(dt("<string|null|undefined> [string|boolean] [function|object] [function]",[t,e,n,s],arguments.length),void 0!==e){if(rt(t,null,ye(this,ce,"f")),(t||"").match(/^\$0( |$)/))return this.command(t,e,n,s);throw new Q(".usage() description must start with $0 if being used as alias for .command()")}return ye(this,ue,"f").usage(t),this}usageConfiguration(t){return dt("<object>",[t],arguments.length),me(this,fe,t,"f"),this}version(t,e,n){const s="version";if(dt("[boolean|string] [string] [string]",[t,e,n],arguments.length),ye(this,pe,"f")&&(this[ve](ye(this,pe,"f")),ye(this,ue,"f").version(void 0),me(this,pe,null,"f")),0===arguments.length)n=this[xe](),t=s;else if(1===arguments.length){if(!1===t)return this;n=t,t=s}else 2===arguments.length&&(n=e,e=void 0);return me(this,pe,"string"==typeof t?t:s,"f"),e=e||ye(this,ue,"f").deferY18nLookup("Show version number"),ye(this,ue,"f").version(n||void 0),this.boolean(ye(this,pe,"f")),this.describe(ye(this,pe,"f"),e),this}wrap(t){return dt("<number|null|undefined>",[t],arguments.length),ye(this,ue,"f").wrap(t),this}[(Dt=new WeakMap,Wt=new WeakMap,Ft=new WeakMap,zt=new WeakMap,Rt=new WeakMap,Lt=new WeakMap,Ut=new WeakMap,Ht=new WeakMap,Tt=new WeakMap,Bt=new WeakMap,qt=new WeakMap,Vt=new WeakMap,Gt=new WeakMap,Yt=new WeakMap,Jt=new WeakMap,Kt=new WeakMap,Qt=new WeakMap,Zt=new WeakMap,Xt=new WeakMap,te=new WeakMap,ee=new WeakMap,ne=new WeakMap,se=new WeakMap,ie=new WeakMap,re=new WeakMap,oe=new WeakMap,ae=new WeakMap,ce=new WeakMap,le=new WeakMap,he=new WeakMap,de=new WeakMap,ue=new WeakMap,fe=new WeakMap,pe=new WeakMap,ge=new WeakMap,be)](t){if(!t._||!t["--"])return t;t._.push.apply(t._,t["--"]);try{delete t["--"]}catch(t){}return t}[we](){return{log:(...t)=>{this[qe]()||console.log(...t),me(this,Yt,!0,"f"),ye(this,Zt,"f").length&&me(this,Zt,ye(this,Zt,"f")+"\n","f"),me(this,Zt,ye(this,Zt,"f")+t.join(" "),"f")},error:(...t)=>{this[qe]()||console.error(...t),me(this,Yt,!0,"f"),ye(this,Zt,"f").length&&me(this,Zt,ye(this,Zt,"f")+"\n","f"),me(this,Zt,ye(this,Zt,"f")+t.join(" "),"f")}}}[ve](t){at(ye(this,Xt,"f")).forEach((e=>{if("configObjects"===e)return;const n=ye(this,Xt,"f")[e];Array.isArray(n)?n.includes(t)&&n.splice(n.indexOf(t),1):"object"==typeof n&&delete n[t]})),delete ye(this,ue,"f").getDescriptions()[t]}[Oe](t,e,n){ye(this,Tt,"f")[n]||(ye(this,ce,"f").process.emitWarning(t,e),ye(this,Tt,"f")[n]=!0)}[ke](){ye(this,qt,"f").push({options:ye(this,Xt,"f"),configObjects:ye(this,Xt,"f").configObjects.slice(0),exitProcess:ye(this,Bt,"f"),groups:ye(this,Gt,"f"),strict:ye(this,le,"f"),strictCommands:ye(this,he,"f"),strictOptions:ye(this,de,"f"),completionCommand:ye(this,Rt,"f"),output:ye(this,Zt,"f"),exitError:ye(this,Ut,"f"),hasOutput:ye(this,Yt,"f"),parsed:this.parsed,parseFn:ye(this,ne,"f"),parseContext:ye(this,se,"f")}),ye(this,ue,"f").freeze(),ye(this,ge,"f").freeze(),ye(this,Dt,"f").freeze(),ye(this,Vt,"f").freeze()}[je](){let t,e="";return t=/\b(node|iojs|electron)(\.exe)?$/.test(ye(this,ce,"f").process.argv()[0])?ye(this,ce,"f").process.argv().slice(1,2):ye(this,ce,"f").process.argv().slice(0,1),e=t.map((t=>{const e=this[Ye](ye(this,Wt,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&e.length<t.length?e:t})).join(" ").trim(),ye(this,ce,"f").getEnv("_")&&ye(this,ce,"f").getProcessArgvBin()===ye(this,ce,"f").getEnv("_")&&(e=ye(this,ce,"f").getEnv("_").replace(`${ye(this,ce,"f").path.dirname(ye(this,ce,"f").process.execPath())}/`,"")),e}[Ae](){return ye(this,ee,"f")}[Ee](){return ye(this,fe,"f")}[_e](){if(!ye(this,Ht,"f"))return;const t=ye(this,ce,"f").getEnv("LC_ALL")||ye(this,ce,"f").getEnv("LC_MESSAGES")||ye(this,ce,"f").getEnv("LANG")||ye(this,ce,"f").getEnv("LANGUAGE")||"en_US";this.locale(t.replace(/[.:].*/,""))}[xe](){return this[Se]().version||"unknown"}[Ce](t){const e=t["--"]?t["--"]:t._;for(let t,n=0;void 0!==(t=e[n]);n++)ye(this,ce,"f").Parser.looksLikeNumber(t)&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))&&(e[n]=Number(t));return t}[Se](t){const e=t||"*";if(ye(this,ie,"f")[e])return ye(this,ie,"f")[e];let n={};try{let e=t||ye(this,ce,"f").mainFilename;!t&&ye(this,ce,"f").path.extname(e)&&(e=ye(this,ce,"f").path.dirname(e));const s=ye(this,ce,"f").findUp(e,((t,e)=>e.includes("package.json")?"package.json":void 0));rt(s,void 0,ye(this,ce,"f")),n=JSON.parse(ye(this,ce,"f").readFileSync(s,"utf8"))}catch(t){}return ye(this,ie,"f")[e]=n||{},ye(this,ie,"f")[e]}[$e](t,e){(e=[].concat(e)).forEach((e=>{e=this[Ie](e),ye(this,Xt,"f")[t].push(e)}))}[Pe](t,e,n,s){this[Ne](t,e,n,s,((t,e,n)=>{ye(this,Xt,"f")[t][e]=n}))}[Me](t,e,n,s){this[Ne](t,e,n,s,((t,e,n)=>{ye(this,Xt,"f")[t][e]=(ye(this,Xt,"f")[t][e]||[]).concat(n)}))}[Ne](t,e,n,s,i){if(Array.isArray(n))n.forEach((e=>{t(e,s)}));else if((t=>"object"==typeof t)(n))for(const e of at(n))t(e,n[e]);else i(e,this[Ie](n),s)}[Ie](t){return"__proto__"===t?"___proto___":t}[De](t,e){return this[Pe](this[De].bind(this),"key",t,e),this}[We](){var t,e,n,s,i,r,o,a,c,l,h,d;const u=ye(this,qt,"f").pop();let f;rt(u,void 0,ye(this,ce,"f")),t=this,e=this,n=this,s=this,i=this,r=this,o=this,a=this,c=this,l=this,h=this,d=this,({options:{set value(e){me(t,Xt,e,"f")}}.value,configObjects:f,exitProcess:{set value(t){me(e,Bt,t,"f")}}.value,groups:{set value(t){me(n,Gt,t,"f")}}.value,output:{set value(t){me(s,Zt,t,"f")}}.value,exitError:{set value(t){me(i,Ut,t,"f")}}.value,hasOutput:{set value(t){me(r,Yt,t,"f")}}.value,parsed:this.parsed,strict:{set value(t){me(o,le,t,"f")}}.value,strictCommands:{set value(t){me(a,he,t,"f")}}.value,strictOptions:{set value(t){me(c,de,t,"f")}}.value,completionCommand:{set value(t){me(l,Rt,t,"f")}}.value,parseFn:{set value(t){me(h,ne,t,"f")}}.value,parseContext:{set value(t){me(d,se,t,"f")}}.value}=u),ye(this,Xt,"f").configObjects=f,ye(this,ue,"f").unfreeze(),ye(this,ge,"f").unfreeze(),ye(this,Dt,"f").unfreeze(),ye(this,Vt,"f").unfreeze()}[Fe](t,e){return mt(e,(e=>(t(e),e)))}getInternalMethods(){return{getCommandInstance:this[ze].bind(this),getContext:this[Re].bind(this),getHasOutput:this[Le].bind(this),getLoggerInstance:this[Ue].bind(this),getParseContext:this[He].bind(this),getParserConfiguration:this[Ae].bind(this),getUsageConfiguration:this[Ee].bind(this),getUsageInstance:this[Te].bind(this),getValidationInstance:this[Be].bind(this),hasParseCallback:this[qe].bind(this),isGlobalContext:this[Ve].bind(this),postProcess:this[Ge].bind(this),reset:this[Je].bind(this),runValidation:this[Qe].bind(this),runYargsParserAndExecuteCommands:this[Ke].bind(this),setHasOutput:this[Ze].bind(this)}}[ze](){return ye(this,Dt,"f")}[Re](){return ye(this,Ft,"f")}[Le](){return ye(this,Yt,"f")}[Ue](){return ye(this,Qt,"f")}[He](){return ye(this,se,"f")||{}}[Te](){return ye(this,ue,"f")}[Be](){return ye(this,ge,"f")}[qe](){return!!ye(this,ne,"f")}[Ve](){return ye(this,Kt,"f")}[Ge](t,e,n,s){if(n)return t;if(ct(t))return t;e||(t=this[be](t));return(this[Ae]()["parse-positional-numbers"]||void 0===this[Ae]()["parse-positional-numbers"])&&(t=this[Ce](t)),s&&(t=gt(t,this,ye(this,Vt,"f").getMiddleware(),!1)),t}[Je](t={}){me(this,Xt,ye(this,Xt,"f")||{},"f");const e={};e.local=ye(this,Xt,"f").local||[],e.configObjects=ye(this,Xt,"f").configObjects||[];const n={};e.local.forEach((e=>{n[e]=!0,(t[e]||[]).forEach((t=>{n[t]=!0}))})),Object.assign(ye(this,re,"f"),Object.keys(ye(this,Gt,"f")).reduce(((t,e)=>{const s=ye(this,Gt,"f")[e].filter((t=>!(t in n)));return s.length>0&&(t[e]=s),t}),{})),me(this,Gt,{},"f");return["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"].forEach((t=>{e[t]=(ye(this,Xt,"f")[t]||[]).filter((t=>!n[t]))})),["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"].forEach((t=>{e[t]=Ot(ye(this,Xt,"f")[t],(t=>!n[t]))})),e.envPrefix=ye(this,Xt,"f").envPrefix,me(this,Xt,e,"f"),me(this,ue,ye(this,ue,"f")?ye(this,ue,"f").reset(n):At(this,ye(this,ce,"f")),"f"),me(this,ge,ye(this,ge,"f")?ye(this,ge,"f").reset(n):function(t,e,n){const s=n.y18n.__,i=n.y18n.__n,r={nonOptionCount:function(n){const s=t.getDemandedCommands(),r=n._.length+(n["--"]?n["--"].length:0)-t.getInternalMethods().getContext().commands.length;s._&&(r<s._.min||r>s._.max)&&(r<s._.min?void 0!==s._.minMsg?e.fail(s._.minMsg?s._.minMsg.replace(/\$0/g,r.toString()).replace(/\$1/,s._.min.toString()):null):e.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",r,r.toString(),s._.min.toString())):r>s._.max&&(void 0!==s._.maxMsg?e.fail(s._.maxMsg?s._.maxMsg.replace(/\$0/g,r.toString()).replace(/\$1/,s._.max.toString()):null):e.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",r,r.toString(),s._.max.toString()))))},positionalCount:function(t,n){n<t&&e.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",n,n+"",t+""))},requiredArguments:function(t,n){let s=null;for(const e of Object.keys(n))Object.prototype.hasOwnProperty.call(t,e)&&void 0!==t[e]||(s=s||{},s[e]=n[e]);if(s){const t=[];for(const e of Object.keys(s)){const n=s[e];n&&t.indexOf(n)<0&&t.push(n)}const n=t.length?`\n${t.join("\n")}`:"";e.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(s).length,Object.keys(s).join(", ")+n))}},unknownArguments:function(n,s,o,a,c=!0){var l;const h=t.getInternalMethods().getCommandInstance().getCommands(),d=[],u=t.getInternalMethods().getContext();if(Object.keys(n).forEach((e=>{$t.includes(e)||Object.prototype.hasOwnProperty.call(o,e)||Object.prototype.hasOwnProperty.call(t.getInternalMethods().getParseContext(),e)||r.isValidAndSomeAliasIsNotNew(e,s)||d.push(e)})),c&&(u.commands.length>0||h.length>0||a)&&n._.slice(u.commands.length).forEach((t=>{h.includes(""+t)||d.push(""+t)})),c){const e=(null===(l=t.getDemandedCommands()._)||void 0===l?void 0:l.max)||0,s=u.commands.length+e;s<n._.length&&n._.slice(s).forEach((t=>{t=String(t),u.commands.includes(t)||d.includes(t)||d.push(t)}))}d.length&&e.fail(i("Unknown argument: %s","Unknown arguments: %s",d.length,d.map((t=>t.trim()?t:`"${t}"`)).join(", ")))},unknownCommands:function(n){const s=t.getInternalMethods().getCommandInstance().getCommands(),r=[],o=t.getInternalMethods().getContext();return(o.commands.length>0||s.length>0)&&n._.slice(o.commands.length).forEach((t=>{s.includes(""+t)||r.push(""+t)})),r.length>0&&(e.fail(i("Unknown command: %s","Unknown commands: %s",r.length,r.join(", "))),!0)},isValidAndSomeAliasIsNotNew:function(e,n){if(!Object.prototype.hasOwnProperty.call(n,e))return!1;const s=t.parsed.newAliases;return[e,...n[e]].some((t=>!Object.prototype.hasOwnProperty.call(s,t)||!s[e]))},limitedChoices:function(n){const i=t.getOptions(),r={};if(!Object.keys(i.choices).length)return;Object.keys(n).forEach((t=>{-1===$t.indexOf(t)&&Object.prototype.hasOwnProperty.call(i.choices,t)&&[].concat(n[t]).forEach((e=>{-1===i.choices[t].indexOf(e)&&void 0!==e&&(r[t]=(r[t]||[]).concat(e))}))}));const o=Object.keys(r);if(!o.length)return;let a=s("Invalid values:");o.forEach((t=>{a+=`\n ${s("Argument: %s, Given: %s, Choices: %s",t,e.stringifiedValues(r[t]),e.stringifiedValues(i.choices[t]))}`})),e.fail(a)}};let o={};function a(t,e){const n=Number(e);return"number"==typeof(e=isNaN(n)?e:n)?e=t._.length>=e:e.match(/^--no-.+/)?(e=e.match(/^--no-(.+)/)[1],e=!Object.prototype.hasOwnProperty.call(t,e)):e=Object.prototype.hasOwnProperty.call(t,e),e}r.implies=function(e,s){dt("<string|object> [array|number|string]",[e,s],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.implies(t,e[t])})):(t.global(e),o[e]||(o[e]=[]),Array.isArray(s)?s.forEach((t=>r.implies(e,t))):(rt(s,void 0,n),o[e].push(s)))},r.getImplied=function(){return o},r.implications=function(t){const n=[];if(Object.keys(o).forEach((e=>{const s=e;(o[e]||[]).forEach((e=>{let i=s;const r=e;i=a(t,i),e=a(t,e),i&&!e&&n.push(` ${s} -> ${r}`)}))})),n.length){let t=`${s("Implications failed:")}\n`;n.forEach((e=>{t+=e})),e.fail(t)}};let c={};r.conflicts=function(e,n){dt("<string|object> [array|string]",[e,n],arguments.length),"object"==typeof e?Object.keys(e).forEach((t=>{r.conflicts(t,e[t])})):(t.global(e),c[e]||(c[e]=[]),Array.isArray(n)?n.forEach((t=>r.conflicts(e,t))):c[e].push(n))},r.getConflicting=()=>c,r.conflicting=function(i){Object.keys(i).forEach((t=>{c[t]&&c[t].forEach((n=>{n&&void 0!==i[t]&&void 0!==i[n]&&e.fail(s("Arguments %s and %s are mutually exclusive",t,n))}))})),t.getInternalMethods().getParserConfiguration()["strip-dashed"]&&Object.keys(c).forEach((t=>{c[t].forEach((r=>{r&&void 0!==i[n.Parser.camelCase(t)]&&void 0!==i[n.Parser.camelCase(r)]&&e.fail(s("Arguments %s and %s are mutually exclusive",t,r))}))}))},r.recommendCommands=function(t,n){n=n.sort(((t,e)=>e.length-t.length));let i=null,r=1/0;for(let e,s=0;void 0!==(e=n[s]);s++){const n=St(t,e);n<=3&&n<r&&(r=n,i=e)}i&&e.fail(s("Did you mean %s?",i))},r.reset=function(t){return o=Ot(o,(e=>!t[e])),c=Ot(c,(e=>!t[e])),r};const l=[];return r.freeze=function(){l.push({implied:o,conflicting:c})},r.unfreeze=function(){const t=l.pop();rt(t,void 0,n),({implied:o,conflicting:c}=t)},r}(this,ye(this,ue,"f"),ye(this,ce,"f")),"f"),me(this,Dt,ye(this,Dt,"f")?ye(this,Dt,"f").reset():function(t,e,n,s){return new bt(t,e,n,s)}(ye(this,ue,"f"),ye(this,ge,"f"),ye(this,Vt,"f"),ye(this,ce,"f")),"f"),ye(this,zt,"f")||me(this,zt,function(t,e,n,s){return new Ct(t,e,n,s)}(this,ye(this,ue,"f"),ye(this,Dt,"f"),ye(this,ce,"f")),"f"),ye(this,Vt,"f").reset(),me(this,Rt,null,"f"),me(this,Zt,"","f"),me(this,Ut,null,"f"),me(this,Yt,!1,"f"),this.parsed=!1,this}[Ye](t,e){return ye(this,ce,"f").path.relative(t,e)}[Ke](t,e,n,s=0,i=!1){let r=!!n||i;t=t||ye(this,oe,"f"),ye(this,Xt,"f").__=ye(this,ce,"f").y18n.__,ye(this,Xt,"f").configuration=this[Ae]();const o=!!ye(this,Xt,"f").configuration["populate--"],a=Object.assign({},ye(this,Xt,"f").configuration,{"populate--":!0}),c=ye(this,ce,"f").Parser.detailed(t,Object.assign({},ye(this,Xt,"f"),{configuration:{"parse-positional-numbers":!1,...a}})),l=Object.assign(c.argv,ye(this,se,"f"));let h;const d=c.aliases;let u=!1,f=!1;Object.keys(l).forEach((t=>{t===ye(this,Jt,"f")&&l[t]?u=!0:t===ye(this,pe,"f")&&l[t]&&(f=!0)})),l.$0=this.$0,this.parsed=c,0===s&&ye(this,ue,"f").clearCachedHelpMessage();try{if(this[_e](),e)return this[Ge](l,o,!!n,!1);if(ye(this,Jt,"f")){[ye(this,Jt,"f")].concat(d[ye(this,Jt,"f")]||[]).filter((t=>t.length>1)).includes(""+l._[l._.length-1])&&(l._.pop(),u=!0)}me(this,Kt,!1,"f");const a=ye(this,Dt,"f").getCommands(),p=ye(this,zt,"f").completionKey in l,g=u||p||i;if(l._.length){if(a.length){let t;for(let e,r=s||0;void 0!==l._[r];r++){if(e=String(l._[r]),a.includes(e)&&e!==ye(this,Rt,"f")){const t=ye(this,Dt,"f").runCommand(e,this,c,r+1,i,u||f||i);return this[Ge](t,o,!!n,!1)}if(!t&&e!==ye(this,Rt,"f")){t=e;break}}!ye(this,Dt,"f").hasDefaultCommand()&&ye(this,ae,"f")&&t&&!g&&ye(this,ge,"f").recommendCommands(t,a)}ye(this,Rt,"f")&&l._.includes(ye(this,Rt,"f"))&&!p&&(ye(this,Bt,"f")&&kt(!0),this.showCompletionScript(),this.exit(0))}if(ye(this,Dt,"f").hasDefaultCommand()&&!g){const t=ye(this,Dt,"f").runCommand(null,this,c,0,i,u||f||i);return this[Ge](t,o,!!n,!1)}if(p){ye(this,Bt,"f")&&kt(!0);const e=(t=[].concat(t)).slice(t.indexOf(`--${ye(this,zt,"f").completionKey}`)+1);return ye(this,zt,"f").getCompletion(e,((t,e)=>{if(t)throw new Q(t.message);(e||[]).forEach((t=>{ye(this,Qt,"f").log(t)})),this.exit(0)})),this[Ge](l,!o,!!n,!1)}if(ye(this,Yt,"f")||(u?(ye(this,Bt,"f")&&kt(!0),r=!0,this.showHelp("log"),this.exit(0)):f&&(ye(this,Bt,"f")&&kt(!0),r=!0,ye(this,ue,"f").showVersion("log"),this.exit(0))),!r&&ye(this,Xt,"f").skipValidation.length>0&&(r=Object.keys(l).some((t=>ye(this,Xt,"f").skipValidation.indexOf(t)>=0&&!0===l[t]))),!r){if(c.error)throw new Q(c.error.message);if(!p){const t=this[Qe](d,{},c.error);n||(h=gt(l,this,ye(this,Vt,"f").getMiddleware(),!0)),h=this[Fe](t,null!=h?h:l),ct(h)&&!n&&(h=h.then((()=>gt(l,this,ye(this,Vt,"f").getMiddleware(),!1))))}}}catch(t){if(!(t instanceof Q))throw t;ye(this,ue,"f").fail(t.message,t)}return this[Ge](null!=h?h:l,o,!!n,!0)}[Qe](t,e,n,s){const i={...this.getDemandedOptions()};return r=>{if(n)throw new Q(n.message);ye(this,ge,"f").nonOptionCount(r),ye(this,ge,"f").requiredArguments(r,i);let o=!1;ye(this,he,"f")&&(o=ye(this,ge,"f").unknownCommands(r)),ye(this,le,"f")&&!o?ye(this,ge,"f").unknownArguments(r,t,e,!!s):ye(this,de,"f")&&ye(this,ge,"f").unknownArguments(r,t,{},!1,!1),ye(this,ge,"f").limitedChoices(r),ye(this,ge,"f").implications(r),ye(this,ge,"f").conflicting(r)}}[Ze](){me(this,Yt,!0,"f")}[Xe](t){if("string"==typeof t)ye(this,Xt,"f").key[t]=!0;else for(const e of t)ye(this,Xt,"f").key[e]=!0}}const en=(nn=it,(t=[],e=nn.process.cwd(),n)=>{const s=new tn(t,e,n,nn);return Object.defineProperty(s,"argv",{get:()=>s.parse(),enumerable:!0}),s.help(),s.version(),s});var nn;function sn(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var s=n.call(t,e||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const rn=new class{constructor(){sn(this,"_dirPath",void 0),sn(this,"_dockerfile",void 0),sn(this,"_hasDockerfile",void 0),sn(this,"_name",void 0),sn(this,"_packageJson",void 0),this._dirPath=process.cwd()}get dirPath(){return this._dirPath}set dirPath(e){this._dirPath=t.resolve(e)}get dockerfile(){return this._dockerfile??=h.readFileSync(t.join(this.dirPath,"Dockerfile"),"utf8")}get hasDockerfile(){return this._hasDockerfile??=h.existsSync(t.join(this.dirPath,"Dockerfile"))}get name(){return this._name??=rn.packageJson.name||"unknown"}get packageJson(){return this._packageJson??=JSON.parse(h.readFileSync(t.join(this.dirPath,"package.json"),"utf8"))}},on={env:{description:".env files to be loaded.",type:"array",alias:"e"},"working-dir":{description:"A working directory",type:"string",alias:"w"}},an={dry:{description:"Indicates if dry-run mode is enabled or not.",type:"boolean",alias:"d"},verbose:{description:"Indicates if verbose mode is enabled or not.",type:"boolean",alias:"v"}},cn={command:"buildIfNeeded",describe:"Build code if changes are detected",builder:{...on,...an,command:{description:"A build command",type:"string",default:"yarn build",alias:"c"}},async handler(e){await async function(e){const[n,s,i]=await async function(){const e=t.resolve(rn.dirPath,"node_modules",".cache","build"),n=t.resolve(e,"last-build");await j.mkdir(e,{recursive:!0});const s=k("sha256"),i=b.execSync("git rev-parse HEAD",{cwd:rn.dirPath}).toString().trim();s.update(i);const r=JSON.stringify(Object.entries(process.env).sort((([t],[e])=>t.localeCompare(e))));s.update(r),await async function(t){return new Promise((e=>{const n=b.spawnSync("git",["diff","--name-only"],{cwd:rn.dirPath,stdio:"pipe",encoding:"utf8"}).stdout.trim().split("\n").map((t=>"test"===process.env.WB_ENV?t.replace(/packages\/scripts\/test-fixtures\/[^/]+\//,""):t)).filter((t=>(ln.some((e=>t.includes(e)))||hn.some((e=>t.endsWith(e))))&&!dn.some((e=>t.includes(e))))),s=b.spawn("git",["diff","--",...n],{cwd:rn.dirPath});s.stdout?.on("data",(e=>{t.update(e)})),s.on("close",(()=>{e()}))}))}(s);const o=s.digest("hex");try{if(await j.readFile(n,"utf8")===o)return console.info("Skip to build production code."),[!0,n,o]}catch{}return[!1,n,o]}();if(n)return!1;if(console.info("Start building production code."),!e.dry){const[t,...n]=(e.command??"").split(" "),s=b.spawnSync(t,n,{cwd:rn.dirPath,stdio:"inherit"});if(0!==s.status)return console.info("Failed to build production code."),process.exitCode=s.status??1,!1}console.info("Finished building production code."),e.dry||await j.writeFile(s,i,"utf8");return!0}(e)}};const ln=["src/","public/"],hn=[".js",".cjs",".mjs",".jsx",".ts",".cts",".mts",".tsx",".json",".browserslistrc","yarn.lock"],dn=["test/","tests/","__tests__/","test-fixtures/","package.json"];const un={command:"optimizeForDockerBuild",describe:"Optimize configuration when building a Docker image",builder:{...on,...an,outside:{description:"Whether the optimization is executed outside a docker container or not",type:"boolean",alias:"o"}},async handler(e){const n={stdio:"inherit"},s=rn.packageJson.dependencies||{};if(s["@moti-components/go-e-mon"]&&(s["@moti-components/go-e-mon"]="./@moti-components/go-e-mon"),s["online-judge-shared"]&&(s["online-judge-shared"]="./online-judge-shared"),s["program-executor"]&&(s["program-executor"]="./program-executor"),e.outside){const t=rn.packageJson.devDependencies||{},n=["concurrently","conventional-changelog-conventionalcommits","eslint","husky","jest","kill-port","lint-staged","open-cli","playwright","prettier","pinst","sort-package-json","wait-on","semantic-release","vitest"];for(const s of Object.keys(t))(n.some((t=>s.includes(t)))||!e.outside&&s.includes("willbooster")&&s.includes("config"))&&delete t[s]}else delete rn.packageJson.devDependencies;const i=["check","deploy","format","lint","start","test"],r=["pinst ","husky "],o=rn.packageJson.scripts||{};for(const[t,e]of Object.entries(o))(i.some((e=>t.includes(e)))||r.some((t=>e.includes(t))))&&delete o[t];e.dry||(e.outside&&await j.mkdir("dist",{recursive:!0}),await j.writeFile(e.outside?t.join("dist","package.json"):"package.json",JSON.stringify(rn.packageJson),"utf8"),e.outside||b.spawnSync("yarn",n))}};const fn=new class{litestream(){return'node -e \'\nconst { PrismaClient } = require("@prisma/client");\nnew PrismaClient().$queryRaw`PRAGMA journal_mode = WAL;`\n .catch((error) => { console.log("Failed due to:", error); process.exit(1); });\n\''}migrate(){return`PRISMA migrate deploy && PRISMA generate && ${this.seed()}`}migrateDev(){return"PRISMA migrate dev"}reset(t=""){return`rm -f db/**/*.sqlite* && ${t}PRISMA migrate reset --force --skip-seed && ${t}${this.seed()}`}seed(){return rn.packageJson.dependencies?.blitz?"YARN blitz db seed":'if [ -e "prisma/seeds.ts" ]; then YARN build-ts run prisma/seeds.ts; fi'}studio(){return"PRISMA studio"}};function pn(t){return new Promise((e=>{h.access(t,h.constants.F_OK,(t=>{e(!t)}))}))}async function gn(t,e,n){return new Promise(((s,i)=>{try{const r=w(t,e??[],n??{});let o="",a="";r.stdout?.on("data",(t=>{o+=t})),r.stderr?.on("data",(t=>{n?.mergeOutAndError?o+=t:a+=t}));const c=()=>{try{let t,e;"darwin"===_.platform()?(t=v(`pstree ${r.pid}`).toString(),e=/\d+/):(t=v(`pstree -p ${r.pid}`).toString(),e=/\d+/g);const s=t.split("\n").flatMap((t=>(t.match(e)??[]).map(Number))),i=[];for(const t of s)t>0&&(t===r.pid||i.length>0)&&i.push(t);const o=`kill ${i.join(" ")}`;n?.verbose&&(console.info(t),console.info(`$ ${o}`)),v(o)}catch{}};n?.killOnExit&&process.on("exit",c),r.on("error",(t=>{process.removeListener("exit",c),r.removeAllListeners("close"),i(t)})),r.on("close",((t,e)=>{process.removeListener("exit",c),void 0===r.pid?i(new Error("Process has no pid.")):s({pid:r.pid,stdout:o,stderr:a,status:t,signal:e})}))}catch(t){i(t)}}))}const mn=new E,yn={exitIfFailed:!0};async function bn(t,e,n=yn){const[s,i]=vn(t);if(On(s),e.dryRun)return kn(s,0,n),0;const r=await gn(i,void 0,{cwd:rn.dirPath,shell:!0,stdio:"inherit",timeout:n?.timeout,killOnExit:!0,verbose:!0});return kn(s,r.status,n),r.status??1}function wn(t,e,n=yn){return mn.run((async()=>{const[s,i]=vn(t);if(On(s,"Start (parallel)",!0),e.dryRun)return On(s,"Start (log)"),void kn(s,0,n);const r=await gn(i,void 0,{cwd:rn.dirPath,shell:!0,stdio:"pipe",timeout:n?.timeout,mergeOutAndError:!0,killOnExit:!0,verbose:!0});On(s,"Start (log)");const o=r.stdout.trim();o&&console.info(o),kn(s,r.status,n)}))}function vn(e){const n=function(){if(jn)return An;jn=!0;let e=rn.dirPath;for(;;){const n=t.join(e,"node_modules",".bin");if(h.existsSync(n)&&(process.env.PATH=`${n}:${process.env.PATH}`,An=!0),h.existsSync(t.join(e,".git")))break;const s=t.dirname(e);if(e===s)break;e=s}return An}(),s=e.replaceAll("\n","").replaceAll(/\s\s+/g," ").replaceAll("PRISMA ",rn.packageJson.dependencies?.blitz?"YARN blitz prisma ":"YARN prisma ").trim();return[s.replaceAll("YARN ","yarn "),s.replaceAll("YARN ",n?"":"yarn ")]}function On(t,e="Start",n=!1){console.info("\n"+(n?A.gray:A.cyan)(A.bold(`${e}:`),t))}function kn(t,e,n){0===e?console.info(A.green(A.bold("Finished:"),t)):(console.info(A.red(A.bold(`Failed (exit code ${e}): `),t)),!1!==n.exitIfFailed&&process.exit(e??1))}let jn=!1,An=!1;const En={...an},_n={command:"prisma",describe:"Run prisma commands",builder:t=>t.command(xn).command(Cn).command(Sn).command($n).command(Pn).command(Mn).demandCommand(),handler(){}},xn={command:"litestream",describe:"Setup DB for Litestream",builder:En,async handler(t){await bn(fn.litestream(),t)}},Cn={command:"migrate",describe:"Apply migration files to DB",builder:En,async handler(t){await bn(fn.migrate(),t)}},Sn={command:"migrate-dev",describe:"Create a migration file",builder:En,async handler(t){await bn(fn.migrateDev(),t)}},$n={command:"reset",describe:"Reset DB",builder:En,async handler(t){await bn(fn.reset(),t)}},Pn={command:"seed",describe:"Populate DB with seed data",builder:En,async handler(t){await bn(fn.seed(),t)}},Mn={command:"studio",describe:"Open Prisma Studio",builder:En,async handler(t){await bn(fn.studio(),t)}},Nn={command:"setup",describe:"Setup development environment",builder:{...on,...an},async handler(t){await async function(t){const e=await j.readdir(rn.dirPath,{withFileTypes:!0});e.some((t=>t.isFile()&&t.name.includes("-version")))&&await bn("asdf install",t);if(e.some((t=>t.isFile()&&"pyproject.toml"===t.name))){await wn("poetry config virtualenvs.in-project true",t),await wn("poetry config virtualenvs.prefer-active-python true",t);const[,e]=b.execSync("asdf current python").toString().trim().split(/\s+/);await wn(`poetry env use ${e}`,t),await mn.promiseAll(),await bn("poetry run pip install --upgrade pip",t),await bn("poetry install --ansi",t)}if("darwin"===x.platform()){const e=["pstree"];rn.hasDockerfile&&e.push("expect"),await wn(`brew install ${e.join(" ")}`,t)}const n=rn.packageJson.dependencies??{},s=rn.packageJson.scripts??{},i=[];rn.hasDockerfile&&i.push("retry-cli");n.blitz?i.push("concurrently","dotenv-cli","open-cli","vitest","wait-on"):n.express&&i.push("concurrently","vitest","wait-on");i.length>0&&await bn(`yarn add -D ${i.join(" ")}`,t);s["gen-code"]&&await bn("yarn gen-code",t)}(t)}};const In=new class{buildDevImage(t="local"){return`${rn.packageJson.scripts?.["docker/build/prepare"]?"yarn run docker/build/prepare && ":""}YARN wb optimizeForDockerBuild --outside\n && YARN retry -n 3 -- docker build -t ${rn.name}\n --build-arg ARCH=$([ $(uname -m) = 'arm64' ] && echo arm64 || echo amd64)\n --build-arg WB_ENV=${t}\n --build-arg WB_VERSION=dev .`}stopAndStart(t=!1,e=""){return`${this.stop()} && ${t?"unbuffer ":""}${this.start(e)}`}start(t=""){return process.on("exit",(()=>O(this.stop(),{shell:!0,stdio:"inherit"}))),`docker run --rm -it -p 8080:8080 ${t} --name ${rn.name} ${rn.name}`}stop(){return`true $(docker rm -f $(docker container ls -q -f name=${rn.name}) 2> /dev/null)`}stopAll(){return"true $(docker rm -f $(docker ps -q) 2> /dev/null)"}};const Dn=new class{buildDocker(t="local"){return In.buildDevImage(t)}start(){return`YARN concurrently --raw --kill-others-on-fail\n "blitz dev"\n "${Dn.waitAndOpenApp()}"`}startDocker(){return`${this.buildDocker()}\n && YARN concurrently --raw --kill-others-on-fail\n "${In.stopAndStart(!1)}"\n "${Dn.waitAndOpenApp(8080)}"`}startProduction(t=8080){return`${fn.reset("NODE_ENV=production ")} && yarn build && YARN blitz start -p \${PORT:-${t}}`}testE2E({playwrightArgs:t="test tests/e2e",startCommand:e=this.startProduction()}){return`APP_ENV=production WB_ENV=test YARN dotenv -e .env.production -- concurrently --kill-others --raw --success first\n "rm -Rf db/mount && ${e} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && playwright ${t}"`}testStart(){return`YARN concurrently --kill-others --raw --success first "blitz dev" "${this.waitApp()}"`}testUnit(){return"YARN vitest run tests/unit --color --passWithNoTests"}waitApp(t=3e3){return`wait-on -t 10000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 10000 -i 500 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 10000 -i 1000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 10000 -i 2000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 20000 -i 4000 http://127.0.0.1:${t} 2> /dev/null\n || wait-on -t 60000 -i 5000 http://127.0.0.1:${t}`}waitAndOpenApp(t=3e3){return`${this.waitApp(t)} && open-cli http://localhost:${t}`}};const Wn=new class{buildDocker(t="local"){return In.buildDevImage(t)}start(t){return"YARN build-ts run src/index.ts "+(t?"--watch":"")}startDocker(){return`${this.buildDocker()} && ${In.stopAndStart(!1)}`}startProduction(t=8080){return`NODE_ENV=production; yarn build && PORT=\${PORT:-${t}} node dist/index.js`}testE2E({startCommand:t=`if [ -e "prisma" ]; then prisma migrate reset --force --skip-generate; fi && (${this.startProduction()})`}){return`NODE_ENV=production WB_ENV=test YARN concurrently --kill-others --raw --success first\n "${t} && exit 1"\n "wait-on -t 600000 -i 2000 http://127.0.0.1:8080 && vitest run tests/e2e --color --passWithNoTests"`}testStart(){return`YARN concurrently --kill-others --raw --success first "${this.start()}" "${this.waitApp()}"`}testUnit(){return Dn.testUnit()}waitApp(t=3e3){return Dn.waitApp(t)}},Fn={command:"start",describe:"Start app",builder:{...an,watch:{description:"Whether to watch files",type:"boolean"},mode:{description:"Start mode: dev[elopment] (default) | prod[uction] | docker",type:"string",alias:"m"}},async handler(t){const e=rn.packageJson.dependencies||{};let n;if(e.blitz?n=Dn:(e.express&&!e["firebase-functions"]||/EXPOSE\s+8080/.test(rn.dockerfile))&&(n=Wn),n)switch(t.mode||"dev"){case"dev":case"development":await bn(n.start(t.watch),t);break;case"prod":case"production":await bn(n.startProduction(),t);break;case"docker":await bn(n.startDocker(),t);break;default:throw new Error(`Unknown start mode: ${t.mode}`)}else console.error(A.red("Unable to determine the method for starting the app."))}},zn={command:"test",describe:"Test project",builder:{...an,ci:{description:"Whether to run tests on CI",type:"boolean"},e2e:{description:"Whether to run e2e tests",type:"boolean",alias:"e"},"e2e-mode":{description:"e2e mode: headless (default) | docker | headed | debug | generate | trace",type:"string",alias:"m"},start:{description:"Whether to run start tests",type:"boolean",alias:"s"},unit:{description:"Whether to run unit tests",type:"boolean",alias:"u"},"unit-timeout":{description:"Timeout for unit tests",type:"number"}},async handler(e){await async function(e){const n=rn.packageJson.dependencies||{};let s;n.blitz?s=Dn:n.express&&!n["firebase-functions"]&&(s=Wn);if(!s)return void console.error(A.red("Unable to determine the method for testing the app."));const i=[];if(e.ci){const n=pn(t.join(rn.dirPath,"tests","unit")),i=pn(t.join(rn.dirPath,"tests","e2e"));if(await wn(In.stopAll(),e),!1!==e.unit&&await n&&await wn(s.testUnit(),e,{timeout:e.unitTimeout}),!1!==e.start&&await wn(s.testStart(),e),await mn.promiseAll(),!1!==e.e2e&&await i){rn.hasDockerfile&&await bn(`${s.buildDocker("test")}`,e);const t=rn.hasDockerfile?{startCommand:In.stopAndStart(!0)}:{};process.exitCode=await bn(s.testE2E(t),e,{exitIfFailed:!1}),await bn(In.stop(),e)}return}(e.unit||!e.start&&!e.e2e)&&i.push(bn(s.testUnit(),e,{timeout:e.unitTimeout}));e.start&&i.push(bn(s.testStart(),e));if(await Promise.all(i),e.e2e){switch(e.e2eMode||"headless"){case"headless":return void await bn(s.testE2E({}),e);case"docker":return await bn(`${s.buildDocker("test")}`,e),process.exitCode=await bn(s.testE2E({startCommand:In.stopAndStart(!0)}),e,{exitIfFailed:!1}),void await bn(In.stop(),e)}if(n.blitz)switch(e.e2eMode||"headless"){case"headed":return void await bn(Dn.testE2E({playwrightArgs:"test tests/e2e --headed"}),e);case"debug":return void await bn(`PWDEBUG=1 ${Dn.testE2E({})}`,e);case"generate":return void await bn(Dn.testE2E({playwrightArgs:"codegen http://localhost:8080"}),e);case"trace":return void await bn("playwright show-trace",e)}throw new Error(`Unknown e2e mode: ${e.mode}`)}}(e)}};const Rn={command:"typecheck",describe:"Run type checking",builder:{...an},async handler(t){if(process.exitCode=await bn("tsc --noEmit --Pretty",t),0!==process.exitCode){(JSON.parse(await j.readFile("package.json","utf8")).dependencies||{}).blitz&&console.info(A.yellow('Please try "yarn gen-code" if you face unknown type errors.'))}}},Ln={...Rn,command:"tc"};var Un;await en((Un=process.argv,Un.slice(K()+1))).scriptName("wb").options(on).middleware((e=>{const n=e["working-dir"];if(n){const e=t.resolve(n);process.chdir(e),rn.dirPath=e}for(const n of e.env??[])a.config({path:t.join(rn.dirPath,n.toString())})})).command(Nn).command(cn).command(un).command(_n).command(Fn).command(zn).command(Rn).command(Ln).demandCommand().strict().help().argv;for(const t of["SIGINT","SIGTERM","SIGQUIT"])process.on(t,(()=>process.exit()));
34
+ //# sourceMappingURL=index.js.map