jja 2.3.21 → 2.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) <2025> <earthnut.dev>
3
+ Copyright (c) <2025> <Mr.MudBean>
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
6
6
  purpose with or without fee is hereby granted, provided that the above
@@ -16,7 +16,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
16
 
17
17
  # MIT 许可证
18
18
 
19
- 版权所有 (c) [2025] [花生亻]
19
+ 版权所有 (c) [2025] [泥豆君]
20
20
 
21
21
  特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
22
22
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # jolly job aid (开心工作助手)
2
2
 
3
- [![version](<https://img.shields.io/npm/v/jja.svg?logo=npm&logoColor=rgb(0,0,0)&label=版本号&labelColor=rgb(73,73,228)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/jja) [![issues 提交](<https://img.shields.io/badge/issues-提交-rgb(255,0,63)?logo=github>)](https://github.com/earthnutDev/jja/issues)
3
+ [![version](<https://img.shields.io/npm/v/jja.svg?logo=npm&logoColor=rgb(0,0,0)&label=版本号&labelColor=rgb(73,73,228)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/jja) [![issues 提交](<https://img.shields.io/badge/issues-提交-rgb(255,0,63)?logo=github>)](https://github.com/MrMudBean/jja/issues)
4
4
 
5
5
  ---
6
6
 
@@ -0,0 +1,254 @@
1
+ THIRD-PARTY LICENSE
2
+ ==================================================
3
+
4
+ a-type-of-js (2.0.0)
5
+ ------------------------------
6
+ # MIT License
7
+
8
+ Copyright (c) <2025> <Mr.MudBean>
9
+
10
+ Permission to use, copy, modify, and/or distribute this software for any
11
+ purpose with or without fee is hereby granted, provided that the above
12
+ copyright notice and this permission notice appear in all copies.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21
+
22
+ # MIT 许可证
23
+
24
+ 版权所有 (c) [2025] [花生亻]
25
+
26
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
27
+
28
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
29
+
30
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
31
+
32
+ a-js-tools (2.0.1)
33
+ ------------------------------
34
+ # MIT License
35
+
36
+ Copyright (c) <2024> <Mr.MudBean>
37
+
38
+ Permission to use, copy, modify, and/or distribute this software for any
39
+ purpose with or without fee is hereby granted, provided that the above
40
+ copyright notice and this permission notice appear in all copies.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
43
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
44
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
45
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
46
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
47
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
48
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49
+
50
+ # MIT 许可证
51
+
52
+ 版权所有 (c) [2024] [泥豆君]
53
+
54
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
55
+
56
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
57
+
58
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
59
+
60
+ a-node-tools (4.4.1)
61
+ ------------------------------
62
+ # MIT License
63
+
64
+ Copyright (c) <2024> <Mr.MudBean>
65
+
66
+ Permission to use, copy, modify, and/or distribute this software for any
67
+ purpose with or without fee is hereby granted, provided that the above
68
+ copyright notice and this permission notice appear in all copies.
69
+
70
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
71
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
72
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
73
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
74
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
75
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
76
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
77
+
78
+ # MIT 许可证
79
+
80
+ 版权所有 (c) [2024] [泥豆君]
81
+
82
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
83
+
84
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
85
+
86
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
87
+
88
+ @qqi/log (1.0.0)
89
+ ------------------------------
90
+ # MIT License
91
+
92
+ Copyright (c) <2025> <Mr.MudBean>
93
+
94
+ Permission to use, copy, modify, and/or distribute this software for any
95
+ purpose with or without fee is hereby granted, provided that the above
96
+ copyright notice and this permission notice appear in all copies.
97
+
98
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
99
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
100
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
101
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
102
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
103
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
104
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
105
+
106
+ # MIT 许可证
107
+
108
+ 版权所有 (c) [2025] [泥豆君]
109
+
110
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
111
+
112
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
113
+
114
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
115
+
116
+ @color-pen/static (1.1.1)
117
+ ------------------------------
118
+ # MIT License
119
+
120
+ Copyright (c) <2025> <Mr.MudBean>
121
+
122
+ Permission to use, copy, modify, and/or distribute this software for any
123
+ purpose with or without fee is hereby granted, provided that the above
124
+ copyright notice and this permission notice appear in all copies.
125
+
126
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
127
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
128
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
129
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
130
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
131
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
132
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
133
+
134
+ # MIT 许可证
135
+
136
+ 版权所有 (c) [2025] [泥豆君]
137
+
138
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
139
+
140
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
141
+
142
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
143
+
144
+ color-pen (3.0.0)
145
+ ------------------------------
146
+ # MIT License
147
+
148
+ Copyright (c) <2025> <Mr.MudBean>
149
+
150
+ Permission to use, copy, modify, and/or distribute this software for any
151
+ purpose with or without fee is hereby granted, provided that the above
152
+ copyright notice and this permission notice appear in all copies.
153
+
154
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
155
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
156
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
157
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
158
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
159
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
160
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
161
+
162
+ # MIT 许可证
163
+
164
+ 版权所有 (c) [2025] [泥豆君]
165
+
166
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
167
+
168
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
169
+
170
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
171
+
172
+ a-command (3.0.0)
173
+ ------------------------------
174
+ # MIT License
175
+
176
+ Copyright (c) <2024> <MrMudBean>
177
+
178
+ Permission to use, copy, modify, and/or distribute this software for any
179
+ purpose with or without fee is hereby granted, provided that the above
180
+ copyright notice and this permission notice appear in all copies.
181
+
182
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
183
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
184
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
185
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
186
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
187
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
188
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
189
+
190
+ # MIT 许可证
191
+
192
+ 版权所有 (c) [2024] [泥豆君]
193
+
194
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
195
+
196
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
197
+
198
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
199
+
200
+ @qqi/copy-text (1.1.0)
201
+ ------------------------------
202
+ # MIT License
203
+
204
+ Copyright (c) <2025> <Mr.MudBean>
205
+
206
+ Permission to use, copy, modify, and/or distribute this software for any
207
+ purpose with or without fee is hereby granted, provided that the above
208
+ copyright notice and this permission notice appear in all copies.
209
+
210
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
211
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
212
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
213
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
214
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
215
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
216
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
217
+
218
+ # MIT 许可证
219
+
220
+ 版权所有 (c) [2025] [泥豆君]
221
+
222
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
223
+
224
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
225
+
226
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
227
+
228
+ colored-table (0.2.0)
229
+ ------------------------------
230
+ # MIT License
231
+
232
+ Copyright (c) <2025> <Mr.MudBean>
233
+
234
+ Permission to use, copy, modify, and/or distribute this software for any
235
+ purpose with or without fee is hereby granted, provided that the above
236
+ copyright notice and this permission notice appear in all copies.
237
+
238
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
239
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
240
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
241
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
242
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
243
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
244
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
245
+
246
+ # MIT 许可证
247
+
248
+ 版权所有 (c) [2025] [泥豆君]
249
+
250
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
251
+
252
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
253
+
254
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
package/bin.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{arch as e}from"node:os";import{dirname as t,normalize as n,join as r,resolve as o}from"node:path";import{fileURLToPath as i}from"node:url";import{statSync as s,readFileSync as a,readdirSync as c}from"node:fs";import"node:fs/promises";import{execSync as l,spawn as u}from"node:child_process";import{emitKeypressEvents as f}from"node:readline";import{resolve as d}from"node:path/posix";import h,{Resolver as p}from"node:dns";import g from"node:net";import m from"node:https";function b(e){const t=typeof e;if("object"!==t&&"function"!==t)return t;const n=Reflect.apply(Object.prototype.toString,e,[]).replace(/^.*\s(.*)]$/,"$1").toLowerCase();return"error"!==n?n:e instanceof SyntaxError?"syntaxerror":e instanceof TypeError?"typeerror":e instanceof URIError?"urierror":e instanceof ReferenceError?"referenceerror":e instanceof AggregateError?"aggregateerror":e instanceof RangeError?"rangeerror":e instanceof EvalError?"evalerror":"error"}function w(e){return"string"===b(e)}function y(e){return"regexp"===b(e)}function $(e){return w(e)&&""===e.valueOf()}function v(e){return w(e)&&""===e.valueOf().trim()}function x(e){return"number"===b(e)}function k(e){return Number.isNaN(e)}function C(e){return 0===e}function E(e){return"boolean"===b(e)}function I(e){return!0===e}function j(e){return!1===e}function S(e){return null===e}function O(e){return void 0===e}function T(e){return"function"===b(e)}function R(e){return Array.isArray(e)}function D(e){if(R(e))return 0===e.length;throw new TypeError("参数必须为数组")}function N(e){return"object"===b(e)}function L(e){return N(e)&&0===Reflect.ownKeys(e).length}function P(e){return"symbol"===b(e)}function M(e,t){return void 0===t||("function"==typeof t?t(e):t)}function A(e){return e.prototype.apply=Function.apply,e.prototype.bind=Function.bind,e.prototype.call=Function.call,e.prototype.length=Function.length,e.prototype.name=Function.name,e.prototype.toString=Function.toString,e}function B(e,t){return Object.keys(t).forEach(n=>e[n]=t[n]),e}function F(e=1,t=0){if(!isFinite(e)||!isFinite(t)||k(e)||k(t)||!x(e)||!x(t))throw new TypeError("getRandomInt: max or min is NaN or is not a number");let n=Math.ceil(Number(t)),r=Math.floor(Number(e));return r===n?r:(n>r&&([r,n]=[n,r]),Math.round(Math.random()*(r-n)+n))}function W(e){if(!N(e)&&!x(e)||x(e)&&k(e)||x(e)&&!isFinite(e)||x(e)&&!Number.isInteger(e)||x(e)&&Number.isInteger(e)&&e<1||x(e)&&e<1||N(e)&&(!x(e.length)||e.length<1||!Number.isInteger(e.length)))throw new TypeError("参数类型错误 ❌ (getRandomString)");const t={length:32,chars:"abcdefghijklmnopqrstuvwxyz",chars2:"0123456789",chars3:"!@#$%^&*()_+~`|}{[]:;?><,./-=",type:"string",includeUppercaseLetters:!1,includeNumbers:!1,includeSpecial:!1};if("uuid"===t.type)return crypto.randomUUID();x(e)&&Number.isInteger(e)&&e>0&&B(t,{length:e}),N(e)&&(B(t,e),t.length=t.length<1?32:t.length);const n=t.chars.split("");t.includeUppercaseLetters&&s(n,t.chars.toUpperCase()),t.includeNumbers&&s(n,t.chars2),t.includeSpecial&&s(n,t.chars3);let r="";const o=n.join(""),i=o.length;if(globalThis&&globalThis.crypto&&globalThis.crypto.getRandomValues){globalThis.crypto.getRandomValues(new Uint8Array(t.length)).forEach(e=>r+=o[e%i])}else for(let e=0;e<t.length;e++)r+=o[F(i-1)];function s(e,t){const n=e.length,r=t.length,o=Math.max(n,r);for(let i=0;i<o;i++)i<n&&!O(t[i])?e[i]+=t[i]:i<r&&(e[i]=t[i])}if(!/[a-zA-Z]/.test(r))return String.fromCharCode(F(97,122)).concat(r.slice(1));for(;!/^[a-zA-Z]$/.test(r[0]);)r=r.slice(1)+r[0];return r}function V(e,t=200){if(!T(e))throw new TypeError("callback must be a function");let n;x(t)&&(t={delay:t,this:null}),(O(t.delay)||!isFinite(t.delay)||t.delay<0)&&(t.delay=200);const r=()=>{n&&(clearTimeout(n),n=void 0)},o=(...o)=>{r(),n=setTimeout(()=>{try{const n=t&&t.this?t.this:null;e.apply(n,o)}catch(e){console.log("Debounce callback throw an error",e)}},Math.max(t.delay||5,5))};return o.cancel=()=>r(),o}function q(){return!O(globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node||void 0)}async function z(e=1e3){if(!isFinite(e)||e<0)throw new TypeError("delay 应该是一个正常的数值");return C(e)?Promise.resolve():new Promise(t=>setTimeout(t,e))}const _=q()&&"win32"===process.platform||!q()&&window.navigator.userAgent.includes("Windows"),G=[!1,!0,"all","info","error","warn"];function J(e){return!!G.includes(e)&&e}function H(...e){}function U(){this.error=this.info=this.warn=H}const K=q()?"node":"browser",Y="",X=`${Y}[`;function Z(){return new RegExp(`(\\x1b\\[(${["([1-4]?[0-9])(;([1-4]?[0-9]+))*m","[m]","\\?(25|7)[hl]","\\d*;?\\d*[HFr]","6n","\\d{0,4}[A-DTS]","[0-3]?[JKg]","[0-6]?W"].map(e=>`(${e})`).join("|")}))`.concat("|(\\x1b[78DMc])"),"g")}const Q=`${X}0m`;function ee(e,t=!0){if(I(t)){if(!w(e))throw new TypeError("`color` must be a string or number but not number[] when isHex is true");if(e.startsWith("0x"))e=e.replace(/0x/,"#");else if(!e.startsWith("#"))throw new TypeError("`color` must be a string or number but not number[] when isHex is true")}else{if(!j(t))throw new TypeError("The second variable `isHex` must be boolean");if(R(e)){if(e.some(e=>!isFinite(e))||3!==e.length)throw new TypeError("If the `color` is an array, it must be 3 in length and be of numeric type");e=`rgb(${e.join(",")})`}else{if(x(e))throw new TypeError("If the `color` is not number when isHex is false");if(w(e)){if(!e.startsWith("rgb(")||!e.endsWith(")"))throw new TypeError("If the `color` is a string, it must be rgb(r, g, b)");{const t=e.replace(/.*\((.*)\).*/,"$1").split(",");if(3!==t.length||t.some(e=>!isFinite(Number(e))||Number(e)<0||Number(e)>255))throw new TypeError("If the `color` is a string, it must be rgb(r, g, b)")}}}}let n=0,r=0,o=0;if(e.startsWith("#"))if(6==(e=e.slice(1)).length)n=te(parseInt(e.slice(0,2),16)),r=te(parseInt(e.slice(2,4),16)),o=te(parseInt(e.slice(4,6),16));else{if(3!=e.length)return F(255);n=te(parseInt(e.slice(0,1).repeat(2),16)),r=te(parseInt(e.slice(1,2).repeat(2),16)),o=te(parseInt(e.slice(2,3).repeat(2),16))}else if(e.startsWith("rgb")){const t=e.replace(/.*\((.*)\).*/,"$1").split(",");n=te(Number(t[0])),r=te(Number(t[1])),o=te(Number(t[2]))}return 16+36*n+6*r+o}function te(e){const t=isFinite(e)?Math.floor(6*e/256):F(6);return Math.min(5,Math.max(0,t))}function ne(e,t,n,r=!0){const o=r?"38":"48";if(x(e)&&x(t)&&x(n))return`${o};5;${ee([e,t,n],!1)}`;if(w(e)&&O(t)&&O(n)){if(e.startsWith("rgb"))return`${o};5;${ee(e,!1)}`;if(e.startsWith("#")||e.startsWith("0x"))return`${o};5;${ee(e,!0)}`;re()}else{if(x(e)&&O(t)&&O(n))return`${o};5;${ee(e,!0)}`;re()}}function re(){throw new TypeError(' 使用 color() 或 bgColor() 时,可使用三整数 `r , g , b` 或单字符串 `"rgb(r , g, b)"` 或十六进制数值 `0xrgb`、`0xrrggbb` 或十六进制字符串表达 `"#rgb"`、`"#rrggbb"` ,不接受其他格式的参数')}function oe(e,t,n,r=!0){try{return ne(e,t,n,r)}catch(e){throw console.error(e),new TypeError('使用 rgb() 或 bgRgb() 时,参数可以为单字符串 `"rgb(r, g, b)"` 或三个数值 `r , g ,b`。不接受其他格式')}}function ie(e,t=!0){try{return ne(e,void 0,void 0,t)}catch(e){throw console.error(e),new TypeError('使用 hex() 或 bgHex() 时,参数可以为单字符串 `"0xnnnnnn"`、`"#rgb"` 、`"#rrggbb"` 或一个数值 `0xrrggbb`。不接受其他格式')}}function se(e,t=!1){return e<0&&(e=0),e>255&&(e=255),e=isFinite(e)?Math.round(e):F(255),`${[48,38][Number(t)]};5;${e}`}const ae={black:"38;5;0",red:"38;5;1",green:"38;5;2",yellow:"38;5;3",blue:"38;5;4",magenta:"38;5;5",cyan:"38;5;6",white:"38;5;7",brightBlack:"38;5;8",brightRed:"38;5;9",brightGreen:"38;5;10",brightYellow:"38;5;11",brightBlue:"38;5;12",brightMagenta:"38;5;13",brightCyan:"38;5;14",brightWhite:"38;5;15",bgBlack:"48;5;0",bgRed:"48;5;1",bgGreen:"48;5;2",bgYellow:"48;5;3",bgBlue:"48;5;4",bgMagenta:"48;5;5",bgCyan:"48;5;6",bgWhite:"48;5;7",bgBrightBlack:"48;5;8",bgBrightRed:"48;5;9",bgBrightGreen:"48;5;10",bgBrightYellow:"48;5;11",bgBrightBlue:"48;5;12",bgBrightMagenta:"48;5;13",bgBrightCyan:"48;5;14",bgBrightWhite:"48;5;15",bold:"1",dim:"2",italic:"3",underline:"4",blink:"5",reversed:"7",hide:"8",random:"random",bgRandom:"bgRandom",rgb:(e,t,n)=>oe(e,t,n),hex:e=>ie(e),color:(e,t,n)=>ne(e,t,n),number:e=>se(e,!0),bgRgb:(e,t,n)=>oe(e,t,n,!1),bgHex:e=>ie(e,!1),bgColor:(e,t,n)=>ne(e,t,n,!1),bgNumber:e=>se(e)};Object.freeze(ae);const ce=["#000000","#c23621","#25bc24","#adad29","#492ee1","#dd38dd","#33bbc8","#cbcccd","#818383","#fc391f","#31e722","#eaec23","#5833ff","#f93578","#14f0f0","#ebeded"];function le(e){let t=Number(e);if(!isFinite(t))throw new TypeError("色值反向解析出错");if(t<16){return ce[t]}const n=e=>Math.floor(256*e/6+F(42)).toString(16).padStart(2,"0");t-=16;const r=t%36;return`#${n(Math.floor(t/36))}${n(Math.floor(r/6))}${n(r%6)}`}class ue{constructor(e){this.parse(e),this.build()}build(){this.hide&&(this.color="transparent"),this.reversed&&([this.color,this.bgColor]=[this.bgColor,this.color]),O(this.color)||(this.str+=`color: ${this.color};`),O(this.bgColor)||(this.str+=`background: ${this.bgColor};`),0!==this.bold&&(this.str+=`font-weight: ${1===this.bold?800:200};`),this.italic&&(this.str+="font-style: italic;"),this.underline&&(this.str+="border-bottom: 1px #666 solid;")}color=void 0;bgColor=void 0;bold=0;italic=!1;underline=!1;reversed=!1;hide=!1;str="";parse(e){e.replace(/38;5;(\d+)/g,"c-$1").replace(/48;5;(\d+)/g,"b-$1").split(";").reverse().forEach(e=>{0===this.bold&&e===ae.bold?this.bold=1:0===this.bold&&e===ae.dim?this.bold=-1:e===ae.italic?this.italic=!0:e===ae.underline?this.underline=!0:e===ae.reversed?this.reversed=!0:e===ae.hide?this.hide=!0:O(this.color)&&e.startsWith("c")?this.color=le(e.split("-")[1]):O(this.bgColor)&&e.startsWith("b")&&(this.bgColor=le(e.split("-")[1]))})}}function fe(e){return q()?[e]:function(e){e=e.replace(new RegExp("\\\\[0m","g"),"");const t=Z(),n=[""];let r,o=0,i="";const s=()=>{const t=e.substring(o,r?.index??e.length);n[0]+="%c".concat(t),n.push(i)};for(;!S(r=t.exec(e));)s(),i=O(r[7])?new ue(r[3].slice(0,-1)).str:"",o=t.lastIndex;return s(),n}(e)}function de(e,t){if($(e=S(e)||O(e)?"":e.toString()))return"";if(D(t))return e;const n=e.indexOf(X),r=e.indexOf(`${X}0m`);return t=function(e){return e.map(e=>"random"===e?`38;5;${F(255)}`:"bgRandom"===e?`48;5;${F(255)}`:e)}(t),n>-1&&r>-1?de(e.substring(0,n),t).concat(e.substring(n,r+4)).concat(de(e.substring(r+4),t)):e.endsWith("\r\n")?(e=e.substring(0,e.length-2),`${X}${t.join(";")}m${e}${X}0m\r\n`):e.endsWith("\n")?(e=e.substring(0,e.length-1),`${X}${t.join(";")}m${e}${X}0m\n`):`${X}${t.join(";")}m${e}${X}0m`}function he(e,t){const n=parseInt(t);if(n>10){const r=I(38===n)?"38;5;":"48;5;",o=e.findIndex(e=>e.startsWith(r));return o>-1?e.toSpliced(o,1,t):[...e,t]}return e.includes(t)?[...e]:[...e,t]}const pe=A(function(e=[]){const t=(t,...n)=>{if(M(t,()=>R(t)&&t.every(e=>w(e)))){let r="";for(let o=0;o<t.length;o++)r+=de(t[o],e),o<n.length&&(r+=de(n[o],e));return r}if(D(n))return de(t,e);throw new Error("pen: 缺少参数")},n=Object.keys(ae).map(t=>[t,{get:()=>function(e,t){let n=[];if(M(e,w(ae[e])))return n=he(t,ae[e]),new pe(n);if("hex"===e||"bgHex"===e)return r=>(n=he(t,ae[e](r)),new pe(n));if("rgb"===e||"bgRgb"===e)return(r,o,i)=>{if(w(r)&&O(o)&&O(i))n=he(t,ae[e](r));else{if(!(x(r)&&x(o)&&x(i)))throw new Error(`${e} 的参数类型不正确,请使用 'rgb' 或 'hex' 函数`);n=he(t,ae[e](r,o,i))}return new pe(n)};if("color"===e||"bgColor"===e)return(r,o,i)=>{if(w(r)&&O(o)&&O(i))n=he(t,ae[e](r));else{if(!(x(r)&&x(o)&&x(i)))throw new Error(`${e} 的参数类型不正确,请使用 'rgb' 或 'hex' 函数`);n=he(t,ae[e](r,o,i))}return new pe(n)};if("number"===e||"bgNumber"===e)return r=>{if(x(r))return n=he(t,ae[e](r)),new pe(n);throw new TypeError(`${e} 的参数应为有效正整数数值,范围 0 - 255`)};throw new Error(`${e} 函数不存在`)}(t,e)}]),r=Object.fromEntries(n);return Object.defineProperties(t,r),t});const ge=new pe([]),me=new pe([ae.red]),be=new pe([ae.green]),we=new pe([ae.yellow]);new pe([ae.blue]);const ye=new pe([ae.magenta]),$e=new pe([ae.cyan]);new pe([ae.white]),new pe([ae.brightBlack]);const ve=new pe([ae.brightRed]),xe=new pe([ae.brightGreen]),ke=new pe([ae.brightYellow]);new pe([ae.brightBlue]);const Ce=new pe([ae.brightMagenta]),Ee=new pe([ae.brightCyan]);new pe([ae.brightWhite]),new pe([ae.bgBlack]),new pe([ae.bgRed]),new pe([ae.bgGreen]),new pe([ae.bgYellow]),new pe([ae.bgBlue]),new pe([ae.bgMagenta]),new pe([ae.bgCyan]),new pe([ae.bgWhite]),new pe([ae.bgBrightBlack]),new pe([ae.bgBrightRed]),new pe([ae.bgBrightGreen]),new pe([ae.bgBrightYellow]),new pe([ae.bgBrightBlue]);const Ie=new pe([ae.bgBrightMagenta]);new pe([ae.bgBrightCyan]),new pe([ae.bgBrightWhite]);const je=new pe([ae.bold]),Se=new pe([ae.italic]),Oe=new pe([ae.underline]),Te=new pe([ae.hide]);new pe([ae.dim]),new pe([ae.blink]);const Re=new pe([ae.reversed]);ge.rgb;const De=ge.hex,Ne=ge.color;ge.bgRgb;const Le=ge.bgHex;ge.bgColor;const Pe=ge.random;function Me(e){const t=Z(),n=e.replace(t,"");let r=0;for(let e=0,t=n.length;e<t;e++)r+=1+Number(Ae(n[e]));return r}function Ae(e){const t=e.codePointAt(0)||0;return t>=19968&&t<=40959||t>=13312&&t<=19903||t>=131072&&t<=191471||t>=63744&&t<=64255||t>=65280&&t<=65519||t>=65381&&t<=65439||t>=127744&&t<=129750||t>=128512&&t<=128591||t>=128640&&t<=128767||t>=9728&&t<=9983||t>=9984&&t<=10175||t>=44032&&t<=55215||t>=12288&&t<=12351}function Be(e,t,n=!0){const r=t,o=e;if(0===r)return"";let i=!1;const s=Me(o);if(s<=r)return o.concat(" ".repeat(r-s));const a=r>0,c=Z();c.lastIndex=0;const l=[...o.replaceAll(c,"")],u=a?l:l.reverse(),f=u.length,d=Math.abs(r);let h=Math.floor(d/2),p=u.slice(0,h).join(""),g=Me(p);for(;h<f;){if(g+=Me(u[h]),g===d){p+=u[h];break}if(g===d+1){n&&(i=!0);break}if(g>d+1)break;p+=u[h],h++}if(a&&o.startsWith(p)||!a&&o.endsWith(p=[...p].reverse().join("")))return i?p+" ":p;if(a){let e;for(c.lastIndex=0;null!==(e=c.exec(o));){const t=p;if(p=t.slice(0,e.index).concat(e[0]).concat(t.slice(e.index)),o.startsWith(p))break}p+=Q}else{const e=[...p];let t=e.length-1;p="";const n=[...o].reverse();for(let r=0,o=n.length;r<o;r++){const o=n[r];if(o===e[t])--t;else if(t<0)break;p=o+p}p=Q+p}return i?p+" ":p}function Fe(e){return`${X}?7l${e.toString()}${X}?7h`}function We(e){try{throw new Error}catch(t){const n=(t.stack?.split("\n")||[]).map(e=>{const t=/at\s(.*)\s\((.*):(\d*):(\d*)\)/.exec(e);return t?{name:t[1],path:t[2],line:t[3],column:t[4]}:{name:""}}),r=n.filter(e=>""!==e.name&&void 0!==e.path),o=r[3]??r[2]??r[1]??r[0],i=` ${"info"===e?"💡":"error"===e?"❌":"⚠️ "} ${(new Date).toLocaleString()} `,s=("info"===e?ge.bgCyan.brightWhite:"error"===e?ge.bgBlack.red:ge.bgBrightYellow.brightGreen)(i);console.log(`${s} ${o?.name??""} ${o?.line?.concat(" 行")} ${o?.column?.concat(" 列")}`)}}function Ve(...e){We("error"),console.error(...e)}function qe(...e){We("warn"),console.warn(...e)}function ze(...e){We("info"),console.info(...e)}function _e(e,t,n){if("node"===K){const r=globalThis?.process.env[n.toUpperCase().concat("_DEV")]||globalThis?.process.env[n.toLowerCase().concat("_dev")];if(!1===e||O(r)||"false"===r)return Reflect.apply(U,t,[]);[...G,"true","false"].includes(r)&&(e="true"===r?"all":r),t.info=["all","info",!0].includes(e)?ze:H,t.error=["all","error",!0].includes(e)?Ve:H,t.warn=["all","warn",!0].includes(e)?qe:H}else{if(!1===e)return Reflect.apply(U,t,[]);t.info=["all","info",!0].includes(e)?ze:H,t.error=["all","error",!0].includes(e)?Ve:H,t.warn=["all","warn",!0].includes(e)?qe:H}}function Ge(e){O(e)&&(e={name:W(10),type:!1}),E(e)&&(e={name:W(10),type:e}),w(e)&&(e={name:e,type:!1});let{name:t="",type:n=!1}=e;t=t.trim().replace(/\s+/g,"_");const r="node"===K&&(globalThis?.process.env[t.toUpperCase().concat("_DEV")]??globalThis?.process.env[t.toLowerCase().concat("_dev")])||!1;n="node"!==K||J(("false"!==r&&("true"===r||r))??n);const o={error:H,warn:H,info:H};_e(n,o,t);const i=(...e)=>{Reflect.apply(o.info,this,e)};return Object.setPrototypeOf(i,this),Object.defineProperties(this,{type:{get:()=>n||!1,set(e){const r=J(e);r!==n&&(n=r,_e(n,o,t))}},error:{value:(...e)=>Reflect.apply(o.error,this,e),configurable:!1,enumerable:!1,writable:!1},warn:{value:(...e)=>Reflect.apply(o.warn,this,e),configurable:!1,enumerable:!1,writable:!1}}),i}ge.bgRandom,ge.number,ge.bgNumber,Ge.prototype.clear=()=>{"browser"===K?console.clear():console.log(Y.concat("c"))};const Je=A(Ge),He=new Je({type:"error",name:"a node tools"});function Ue(...e){return n(r(...e))}function Ke(e){return s(e,{throwIfNoEntry:!1})}function Ye(e,n="file",...r){r=r.filter(e=>w(e));let i=o(...r);const s=Ke(i);if(He("当前工作目录",i),!s)return He("🎯 工作目录不存在"),"";if(s.isFile())i=t(i);else if(!s.isDirectory())return;let a=20;const c=()=>{const t=Ke(Ue(i,e));if(t&&("file"==n&&t.isFile()||"directory"==n&&t.isDirectory()))return i;if(C(a))return;a--,He("♻️ 查找中...",i);const r=Ue(i,"..");return r!==i?(i=r,c()):void 0};return c()}function Xe(e){if(!/.json^/.test(e)&&!s(e,{throwIfNoEntry:!1}))return null;try{const t=a(e,{encoding:"utf-8"});return JSON.parse(t||"null")}catch(e){return He.error(e),null}}function Ze(e=1){const t=function(e){const t=1,n=void 0;if(O(e))return{depth:t,path:n};const r=e=>x(e)?(e=Math.floor(e))<1||e>20?1:e:1;if(x(e))return{depth:r(e),path:void 0};if(w(e))return{depth:1,path:e};return{depth:r(e.depth)||1,path:e.path||void 0}}(e),n=t.depth;let r=1;if(r>n||n>20)return He("不满足条件退出了查找",r,n),null;let o="";const i="package.json";let s,a=t.path;do{if(He("当前执行的路径",a),a=Ye(i,"file",a),O(a)){He("未获取 package.json 的路径");break}if(o=Ue(a,i),r===n){try{s=Xe(o)}catch(e){return He.error("获取 package.json 文件报错",e),null}He("已获取到文件内容");break}r++,a=Ue(a,"..")}while(r<=n);return He("经过了 while 循环",r,n,s),void 0===s?null:{content:s,depth:n,path:o}}const Qe=()=>q()&&process&&process.stdout&&process.stdout.isTTY||!1;function et(e){const t=new RegExp(e);let n;try{throw new Error}catch(e){n=e}const r=(n.stack?.replace(/\\/gm,"/").split("\n")).reverse(),o=r.findIndex((e,n,r)=>!t.test(e)&&t.test(r[n+1]));if(-1==o)return{name:"",line:0,row:0,originArr:r};let i=r[o];return/\(.*\)/.test(i)&&(i=i.replace(/^.*\((.*)\).*/,"$1")),/file:\/*/.test(i)&&(i=i.replace(/^.*file:\/*(.*)/,"$1")),_||i.startsWith("/")||(i="/"+i),{name:i.replace(/^(.*):\d+:\d+$/,"$1"),line:Number(i.replace(/^.*:(\d+):\d+$/,"$")),row:Number(i.replace(/^.*:\d+:(\d+)$/,"$1")),originArr:r}}function tt(){let e;try{new Function('import("")'),e=i(import.meta.url)}catch(t){He.error(t),e=__filename}_&&(e=e.replace(/\\/gm,"/")),e=et(e).name;return[e,t(e)]}function nt(){it()}function rt(e,t){const n=at[at.list[0]],{callback:r,resolve:o}=n;He("当前执行的回调是",{...n,rl:"原始值为 readline 的 Interface 对象"}),T(r)?I(Reflect.apply(r,null,[e,t]))&&(He("回调遇见了想待的键,执行了退出操作,keyValue: < ",e,"> key: <",t,">"),at.remove(),o(!0)):(at.remove(),o(!1))}const{stdin:ot}=process;function it(){ot.removeListener("keypress",rt),process.removeListener("beforeExit",it),process.stdin.removeListener("end",nt),Qe&&ot?.setRawMode(!1),ot.pause()}const{stdin:st}=process,at={list:[],listened:!1,on(e,t,n){j(this.listened)&&(this.listened=!0,f(process.stdin),Qe()&&process.stdin.setRawMode(!0),process.stdin.resume(),st.on("keypress",rt),process.on("beforeExit",it),process.stdin.on("end",nt));const r=this.list,o={key:e,callback:t,resolve:n};return D(r)&&He("当前执行的栈中没有数据",o),r.push(e),this[e]=o,o},remove(){const e=this.list,t=e.shift();return this.del(t),He("执行完毕一项,还有:",e),!(e.length>0)&&(this.listened=!1,it(),He("监听已移除"),!0)},del(e){He("开始移除",e);const t=this.list[0]===e&&!O(this[e]);if(He("当前 key 是否为当前执行项",t),t)return this.remove(),!0;{const t=this.list.includes(e),n=!O(this[e]);return t&&n?(this.list.splice(this.list.indexOf(e),1),this[e].resolve(!0),delete this[e],!0):t?(this.list.splice(this.list.indexOf(e),1),!0):!!n&&(this.list.splice(this.list.indexOf(e),1),this[e].resolve(!0),!0)}}};const ct=(e,t)=>async function(e,t){if(!q())throw new RangeError("当前环境不支持 readInput");const n=t??Symbol(W(3));return new Promise(t=>{at.on(n,e,t)})}(e,t);function lt(e="",t=!0){let n="";const r=b(e);if(!E(t))throw He.error(""),new TypeError("lineFeed 的类型必须是 boolean ");if("bigint"===r){const r=e.toString().concat("n");n=t?`${r}\n`:`${r}`}else if(["string","number","boolean","function","null"].includes(r))n=t?`${e}\n`:`${e}`;else{const r=JSON.stringify(e,(e,t)=>T(t)?`${t}`:null==t?"undefined":t,2);n=t?`${r}\n`:`${r}`}q()?process.stdout.write(n):console.log(...fe(n.replace(/\n$/,"")))}function ut(e,t){e=(e=e?.toString?e:"").toString();const n=process.stdout.columns,r=[..."-".repeat(n)].map(e=>Pe(e)).join("");if(v(e))e=r;else{t&&(e=I(t)?[...e].map(e=>Pe(e)).join(""):Ne(t)(e));const o=Me(e=Be(e,n-4).trim());e=Be(e+r,n-Math.floor((n-o)/2)),e=Be(r+e,-n)}lt(),lt(e)}function ft(e){const t=e[e.length-1];w(t)&&!t.endsWith("\n")&&e.push("\n"),e.forEach(e=>lt(e,!1))}function dt(e,t){const{show:n,info:r,prefix:o,interval:i,canCtrlCExit:s,canCtrlDExit:a,beforeDestroyed:c}=t??{show:!0,info:"请等待",prefix:0,interval:20,canCtrlCExit:!1,canCtrlDExit:!1,beforeDestroyed:()=>{}},l=E(e)?{show:e,info:r,prefix:o,interval:i,canCtrlCExit:s,canCtrlDExit:a,beforeDestroyed:c}:w(e)?{show:n,info:e,prefix:o,interval:i,canCtrlCExit:s,canCtrlDExit:a,beforeDestroyed:c}:O(e)?{show:n,info:r,prefix:o,interval:i,canCtrlCExit:s,canCtrlDExit:a,beforeDestroyed:c}:x(e)?{show:!0,info:"请等待",prefix:isNaN(e)?o:Math.min(Math.max(0,e),2),interval:i,canCtrlCExit:s,canCtrlDExit:a,beforeDestroyed:c}:{show:n,info:r,prefix:o,interval:i,canCtrlCExit:s,canCtrlDExit:a,beforeDestroyed:c,...e};return l.interval=isFinite(l.interval)?Math.max(20,Math.min(2e3,l.interval)):i,l.info=l.info.replace(/\n/g,"\\n"),l}function ht(e,t=!0){lt(`${t?X:Y}${e}`,!1)}function pt(){ht("?25l")}function gt(){ht("?25h")}function mt(e=!1){e&&wt(1/0),ht("0J")}function bt(e=1,t=!1){ht(`${$t(e,"vertical")}A`),t&&wt(1/0)}function wt(e=1){ht(`${$t(e)}D`)}function yt(e=1){ht(`${$t(e)}C`)}function $t(e,t="horizontal"){(!x(e=Number(e))||isNaN(e)||e<1||!1===Number.isInteger(e)&&e!==1/0)&&(e=1);const n=q()?"horizontal"===t?process.stdout.columns:process.stdout.rows:80;return(1/0===e||e>n)&&(e=n),e}function vt(){gt()}function xt(){gt()}Object.defineProperties(ct,{remove:{value:e=>at.del(e)}});const kt=[".","..","...","....","...",".."],Ct=[["⋯","⋱","⋮","⋰","⋯","⋱","⋮","⋰"],["🕐","🕑","🕒","🕓","🕔","🕕","🕖","🕗","🕘","🕙","🕚","🕛"],["🕜","🕝","🕞","🕟","🕠","🕡","🕢","🕣","🕤","🕥","🕦","🕧"],["👈","👆","👉","👇","🤘","🤟","🫳","🫴","👊"],["🌞","🌕","🌖","🌗","🌜","🌘","🌑","🌒","🌓","🌛","🌔","🌔","🌔","🌝"]];class Et{#e;#t=void 0;#n=Symbol("waiting-tips");#r=[];#o=(...e)=>ft(e);state="destroyed";#i=0;#s=4e4;#a=!1;async destroyed(){"destroyed"!==this.state&&(this.state="destroyed",this.#i=0,O(this.#t)||clearInterval(this.#t),ct.remove(this.#n),wt(1/0),mt(),process.removeListener("exit",vt),process.removeListener("SIGINT",xt),gt(),this.#r.forEach(e=>this.#o(...e)),this.#r.length=0,this.log=this.#o,!function(e){return"promise"===b(e)}(this.#e.beforeDestroyed)?this.#e.beforeDestroyed(this.#a):await this.#e.beforeDestroyed(this.#a),this.#a=!1)}log=this.#o;run(e){"run"===this.state&&this.destroyed(),this.#a=!1,this.state="run",this.#i=Date.now(),this.#e=O(e)?this.#e:dt(e,this.#e);const{prefix:t,info:n,interval:r,canCtrlCExit:o,canCtrlDExit:i}=this.#e;this.log=(...e)=>this.#r.push(e);const s=kt.length,a=Ct[Math.min(Ct.length-1,Math.max(t,0))],c=a.length,l=a.reduce((e,t)=>Math.max(e,Me(t)),0);let u=0;pt(),process.on("exit",vt),process.on("SIGINT",xt),this.#t=setInterval(()=>{mt(!0),this.#r.forEach(e=>ft(e)),this.#r.length=0,lt("\n".repeat(2)),bt(3),ht(7,!1);const e=Be(a[++u%c],l);Date.now()-this.#i<this.#s?lt(Fe(`${e} ${n.replace(/\n/,"\\n")}${kt[Math.floor(u/10)%s]}`),!1):lt(Fe(`${e} ${n} ${ye`当前已执行 ${Math.ceil((Date.now()-this.#i)/1e3)} 秒`}\n \n\r${$e`可使用双击 esc 键退出(确保执行完成,若执行仍在期望时间内,请忽略)`}`),!1),ht(8,!1)},r),ct((e,t)=>!!(t?.meta&&t?.sequence===Y.repeat(2)||I(t?.ctrl)&&(o&&"c"===t?.name||i&&"d"===t?.name))&&(this.#a=!0,this.destroyed(),!0),this.#n)}set timeout(e){this.#i=Date.now(),this.#s=!isFinite(e)||e<0?4e4:e<600?1e3*e:e}get timeout(){return this.#s}constructor(e){this.#e=dt(e),I(this.#e.show)&&this.run()}}function It(e){return new Et(e)}function jt(e,t){if(j(q()))throw new RangeError("当前环境不支持 node 环境");const{env:n}=t;w(e)&&(n.code=e,e={code:e,waiting:!1});const r=process.cwd();let o=d(r,e.cwd||"");-1===function(e){try{const t=Ke(e);if(t&&t.isDirectory())return 0==c(e,{withFileTypes:!0}).length?1:0}catch(e){return He.error("is ",e),-1}return-1}(o)&&(He(`执行目录 ${me(o)} 不存在,使用命令执行目录 ${$e(r)}`),o=r);const i=e.code.replace(/\s{2,}/g," ").trim().split(" ");Object.assign(t.env,{shell:!0,hideWaiting:!0,waitingMessage:"请稍等",printLog:!1,...e,cmd:i,cwd:o})}function St(e,t,n){let r=e.toString().trim();return/\n$/.test(r)||(r=r.concat(_?"\r\n":"\n")),r=r.replace(/\n+/g,"\n"),mt(),t&&n.log(r),r}function Ot(e){const t={result:{success:!1,data:"",error:"",status:1,isSIGINT:!1},env:{cmd:[],code:"",cwd:"",printLog:!1,shell:!0,callBack:()=>{},waiting:{show:!1,info:"",prefix:0,interval:10,canCtrlDExit:!1,canCtrlCExit:!1,beforeDestroyed(){}}}},{env:n,result:r}=t;He("runOtherCode 方法 开始执行 "),jt(e,t),He("执行参数",t);const{cmd:o,waiting:i,cwd:s,shell:a,code:c}=n,[l,f]=(()=>{if(i instanceof Et)return[i,"run"===i.state];const e=dt(i);return[It(e),e.show]})();try{return new Promise(e=>{const n=I(a)?u(c,[],{cwd:s,shell:a}):u(o[0],o.slice(1),{cwd:s,shell:a});f&&l.run({beforeDestroyed:e=>{if(e){if(He("执行退出前"),_){try{n.killed||n.kill(-1)}catch(e){He.error("使用 child.kill(child.pid, -1 ) 关闭子进程失败",e),u("taskkill",["/pid",n.pid?.toString(),"/T","/F"],{stdio:"pipe"})}He("终结在 windows 下的子进程")}else n.kill("SIGTERM"),He("终结在非 windows 下的子进程");t.result.isSIGINT=!0}}}),n.on("spawn",()=>function(e){const{result:t}=e;He("子线程已启动,运行状态良好"),t.success=!0,t.status=1}(t)),n.stdout.on("data",e=>function(e,t,n){const{env:r,result:o}=t,i=St(e,r.printLog,n);He(Ie`stdout on data`,i),o.data+=i}(e,t,l)),n.on("exit",(e,t)=>function(e,t){He("子进程已退出了,退出码为 <",e,">"),S(t)||He.error("子进程被其他信号中断执行,执行的退出信号为:",t)}(e,t)),n.stderr.on("data",e=>function(e,t,n){const{env:r,result:o}=t,i=St(e,r.printLog,n);He(Ie`stderr on data`,i),o.error+=i}(e,t,l)),n.on("error",e=>function(e,t,n){const{env:r,result:o}=t;{const t=St(e,r.printLog,n);He(Ie`error`,t),He.error("error",t),o.success=!1,o.status=""!==o.data?2:3,o.error+=t}}(e,t,l)),n.on("close",(n,r)=>function(e,t,n,r,o){const{env:i,result:s}=r,{callBack:a}=i;He("进行正常关闭",e),setTimeout(async()=>{a&&T(a)&&Reflect.apply(a,null,[]),await o.destroyed(),0!==e&&"SIGINT"!==t&&"SIGTERM"!==t?(s.success=!1,s.status=3):"SIGINT"!==t&&"SIGTERM"!==t||(s.success=!1,s.status=4,s.isSIGINT=!0),n(s)})}(n,r,e,t,l))})}catch(e){const t=e.toString();return He.error("创建(但是确是非 node 无法创建子进程,而是更上游的 node 创建的错误)子进程出错",e),new Promise(e=>{(async()=>{await l.destroyed()})(),r.error=t,r.success=!1,r.status=0,e(r)})}}const Tt=e=>Ot(e);async function Rt(e,t="官方",n=5e3){const r={"淘宝":"registry.npmmirror.com","官方":"registry.npmjs.org","腾讯":"mirrors.tencent.com","中科大":"npmreg.proxy.ustclug.org",yarn:"registry.yarnpkg.com"},o=r[t]||r["官方"];return He("get npm pkg info 开始执行"),new Promise(r=>{(()=>{let i="";const s=function(e){if(!e||!w(e))return null;if(e.includes("@")){const t=e.replace(/\/+/g,"/").replace(/@+/g,"@").replace(/\/$/,"").split("@").map(e=>e.trim().replace(/^\/*/,"")),n=t.length;return""===t[0]?3===n||2===n&&""!==t[1]?`@${t[1]}`:null:2===n?`${t[0]}`:null}return e}(e)||"a-node-tools";He("解析后的 pkg 名称",s);const a=("腾讯"===t?"/npm":"").concat(`/${s}`),c={hostname:o,path:a,port:443,method:"GET",timeout:n,headers:{"sec-fetch-dest":"empty","X-Spiferacl":"1"}};He("请求参数",c);const l=m.get(c,e=>{e.on("data",e=>{O(e)||(i+=e.toString())}),e.on("end",()=>{if(200==e.statusCode)try{const e=JSON.parse(i);e.version=e["dist-tags"].latest,r({data:e,success:!0,status:"success",error:null})}catch(e){He.error("转化错误",e),r({data:null,success:!0,status:"parseJsonError",error:e,message:i})}else 404==e.statusCode?r({data:null,success:!0,status:"notFound",error:null,message:"npm 中没有该包"}):r({data:null,success:!0,status:"otherCode",error:null,message:`请求的返回请求码: ${e.statusCode}`})})});l.on("error",e=>{He.error("请求错误",e),r({data:null,success:!1,status:"error",error:e})}),l.on("timeout",()=>{He.error("请求超时"),l.destroy(),r({data:null,success:!1,status:"timeout",error:null})}),l.end(),He("结束方法")})()})}async function Dt(e,t=10){if(!w(e))throw new TypeError("str 需是一个字符串");if(!isFinite(t)||t<0||t>1e4)throw new RangeError("delay 需是一个 0 到 10000 之间(不包括两端)的数值");const n=Array.from(e);if(0!==n.length){for(const r of n)await z(t),He(`当前字符 ${je(r)} 长度为:`,r.length),He(`当前字符 ${ge.reversed(r)} 在 charCodeAt`,r.charCodeAt(0),r.charCodeAt(1),r.charCodeAt(2)),1===r.length&&k(r.charCodeAt(1))?lt(r,!1):2===e.length&&e.charCodeAt(0)>=55296&&e.charCodeAt(0)<=56319&&e.charCodeAt(1)>=56320&&e.charCodeAt(1)<=57343?(lt(r,!1),lt(" ",!1)):2===e.length&&65039===e.charCodeAt(1)?(lt(r,!1),lt(" ",!1)):(lt(r,!1),lt(" ",!1));lt()}else lt()}const Nt=process.argv.slice(2);Object.freeze(Nt);class Lt{originalArg=Nt.slice();name="";__filename="";get state(){return this._state}set state(e){this._state=[void 0,{code:1,text:"start"},{code:2,text:"bind over"},{code:3,text:"run over"},{code:4,text:"over",overCode:e}][x(e)?e:4]}_state={code:1,text:"start"};args=new Pt;abbr={};helpInfo="";hasShowVersion=!1;originalBind={};values=[]}class Pt extends Array{get $nomatch(){return[]}get $map(){return{}}get $arrMap(){return[]}get $only(){return[]}get $original(){return[]}get $isVoid(){return!1}}const Mt={},At=new Je({name:"a command"}),Bt=j(At.type);function Ft(e){return[e.replace(/^(.*?)\s.*/gm,"$1")||"",/<.+>/.test(e)&&e.replace(/.*<(.+)>.*/,"$1")||"",e.replace(/.*?\((.*)\).*?/,"$1")||""]}function Wt(e,t){switch(t.state.code){case 3:return void At.warn("执行绑定","但是已经执行过 `run`");case 4:return void At.warn("执行绑定,但是 command 已完成全部应做动作");default:t.state=2}if(w(e)){const[n,r,o]=Ft(e);return Wt({name:n,abbr:r,info:o},t)}if(R(e))return e.forEach(e=>Wt(e,t));if(!O(e)&&!e.name&&!e.info)return function(e,t){const n={name:"",info:"",abbr:"",options:[]},r=Object.keys(e),o=Object.keys(n);return r.forEach(n=>{if(!o.includes(n)){const[r,o,i]=Ft(n);return Wt({name:r,info:i,abbr:o,options:e[n]},t)}})}(e,t);const n=e;n.abbr&&(t.abbr[n.abbr]=n.name),n.options?n.options=function(e,t,n){R(e)||(e=[e]);const r={};return e.forEach(e=>{let o={name:"",abbr:"",info:""};w(e)?[o.name,o.abbr,o.info]=Ft(e):o=Object.assign(o,e),o.abbr&&(n.abbr[`${t}^${o.abbr}`]=o.name),r[o.name]=o}),r}(n.options,n.name,t):n.options={},t.originalBind[n.name]={abbr:"",...n}}function Vt(){return new Proxy(new Lt,{get(e,t,n){if("args"===t){const t=JSON.parse(JSON.stringify(e[Symbol.for("_args")]||[]));return new Proxy(t,{get(n,r,o){return"$nomatch"===r?e.values.slice():"$map"===r?function(e){if(D(e))return{};const t=new Object;return e.forEach(e=>{const n=t[e.name]||{};n.value=[...n.value||[],...e.value||[]],e.options&&e.options.forEach(e=>{n[e.name]=[...n[e.name]||[],...e.value||[]]}),t[e.name]=n}),t}(t):"$arrMap"===r?D(i=t)?[]:i.map(e=>{const t={},n=t[e.name]||{};return e.value&&!D(e.value)&&(n.value=e.value),O(e)||O(e.options)||D(e.options)||(n.options=[],e.options.forEach(e=>{n.options?.push(Object.fromEntries([[e.name,e.value]]))})),t[e.name]=n,t}):"$only"===r?[...new Set(t.map(e=>e.name))]:"$original"===r?Nt.slice():"$isVoid"===r?0==Nt.slice().length:Reflect.get(n,r,o);var i},set:(e,t,n,r)=>(Reflect.set(e,t,n,r),!0)})}return Reflect.get(e,t,n)},set:(e,t,n,r)=>("args"===t?e[Symbol.for("_args")]=n:Reflect.set(e,t,n,r),!0)})}const qt=" ".repeat(4);function zt(e){return e.state="help",w(e.helpInfo)&&"help"!==e.helpInfo?function(e,t){const n=e.originalBind[t];if(lt(`${qt}${n.name}${qt}${ye(n.info)}\n`),n.options&&!L(n.options)){lt(`${we(`${qt}使用:`)} ${e.name} ${t} [subOptions/subAbbr [value]]\n`),lt(`${$e(`${qt}subOptions:`)} \n`),_t(n.options||{})}else{lt(`${be(`${qt}使用:`)} ${e.name} ${t} [value]\n`)}}(e,e.helpInfo):R(e.helpInfo)&&2==e.helpInfo.length?function(e){const t=e.name,n=e.helpInfo.join(" "),r=e.originalBind[e.helpInfo[0]].options[e.helpInfo[1]].info;lt(`${$e(" 可使用:")} ${t} ${n} [value]\n${be(" 描述:")} ${r}`)}(e):function(e){lt(`${ve(" 可使用:")} ${e.name} options/abbr [subOptions/subAbbr [value]]\n\n选项:\n`);const t=_t(e.originalBind);!function(e){["version -v 版本描述","help -h 帮助查看"].forEach(t=>{const[n,r,o]=t.split(" ");lt(Gt({len:e,name:n,info:o,abbr:r})),lt("")})}(t)}(e)}function _t(e){const t=Object.keys(e).sort();let n=8;t.forEach(e=>n=Math.max(n,e.length));const r=Math.min(15,n+1);return lt(Gt({len:r,name:"子命令",info:"描述",abbr:"缩写",color:!1})),lt(""),t.forEach(t=>{const{name:n,abbr:o,info:i}=e[t];let s=!1;"options"in e[t]&&!L(e[t].options)&&(s=!0),lt(Gt({len:r,name:n,info:i,abbr:o,textDecoration:s})),lt("")}),r}function Gt(e){const t=Object.assign({name:"",info:"",abbr:"",len:15,color:!0,textDecoration:!1},e);let n=ge[t.color?"green":"black"](qt);return n+=ge[t.textDecoration?"blue":"black"](t.name.slice(0,t.len)),n+=" ".repeat(t.len+1-Jt(t.name,t.len)),n+=ge[t.color?"yellow":"black"]`${t.abbr?.slice(0,6)||""}${" ".repeat(7-Jt(t.abbr||"",6))}`,n+=t.color?ye(t.info):t.info,n}function Jt(e,t){return Math.min(e.replace(/[^\x00-\x7f]/,"11").length,t)}const Ht="";function Ut(e){const{name:t,object:n,item:r,result:o}=e;v(t)||(r.name&&n.options?.push(r),o.push(JSON.parse(JSON.stringify(n))))}function Kt(e,t){"true"==e?e=!0:"false"==e?e=!1:e==Number(e)&&(e=Number(e)),v(t.name)?t.values.push(e):t[t.item.name?"item":"object"].value.push(e)}function Yt(e,t){const n=[];let r="";const o=(e,t)=>O(t)||v(t)?n.push(e):n.push(e,t);function i(e,s){if(!v(r)){if(t.originalBind[r].options[e])return o(e,s);const n=t.abbr[`${r}^${e}`];if(!O(n))return o(n,s)}if(t.originalBind[e])return r=e,o(e,s);if(t.abbr[e])return e=t.abbr[e],r=e,o(e,s);if(e.includes("=")){const t=e.indexOf("=");if(0===t||t===e.length-1)return n.push(e);const[r,o]=[e.slice(0,t),e.slice(t+1)||"true"];return i(r,o)}return O(s)||v(s)?n.push(e):n.push(`${e}=${s}`)}return e.forEach(e=>i(e)),n}function Xt(e,t,n){n.init(),e=Yt(e.filter(e=>""!==e),t),e.forEach(e=>{const{name:r}=n;return e=e.trim(),/^([a-z]|[A-Z]|-|\$|_)/.test(e)?!v(r)&&t.originalBind[r].options&&t.originalBind[r].options[e]?function(e,t){const{item:n,object:r}=t;n.name&&r.options.push(n),t.resetItem(e)}(e,n):t.originalBind[e]?function(e,t){v(t.name)||(Ut(t),t.resetItem("")),t.resetObject(e)}(e,n):Kt(e,n):Kt(e,n)}),Ut(n)}function Zt(e){switch(e.state.code){case 3:return void lt("已经执行过 `run`");case 4:return void lt("已完成全部");default:e.state=3}!function(e){if(2==process.argv.length)return;const t=e.originalArg,n=`${Ht}${t.join(Ht)}${Ht}`,r=t.findIndex(e=>/^(-h|help)$/.test(e));if(new RegExp(`${Ht}(-v|version)${Ht}`,"i").test(n))return void(e.hasShowVersion=!0);if(C(r))return void(e.helpInfo="help");let o=[];const i={result:[],values:[],name:"",object:{name:"",value:[],options:[]},item:{name:"",value:[]},resetObject(e){this.name=e,this.object={name:e,value:[],options:[]}},resetItem(e){this.item={name:e,value:[]}},init(){this.result=[],this.values=[],this.resetItem(""),this.resetObject("")}};r>0?(Xt(t.slice(0,r+1),e,i),e.values=i.values,e.args=i.result,o=e.args,D(o)?e.helpInfo="help":[O,D].some(e=>e(o[0].options))?e.helpInfo=o[0].name:e.helpInfo=[o[0].name,o[0].options[0].name]):(Xt(t,e,i),e.values=i.values,e.args=i.result)}(e),function(e){["name","originBind","abbr"].forEach(t=>{const n=t;e[n]&&(Object.freeze(e[n]),Object.defineProperty(e,t,{value:e[n],writable:!1,enumerable:!0,configurable:!1}))})}(e)}function Qt(t){t.state="version";const n=Ye("package.json","file",et(t.__filename).name);if(O(n))return en();const r=Ue(n,"package.json");if(!Ke(r))return en();const o=Xe(r);if(S(o))return en();const{platform:i}=process,s=ge.brightCyan(o.name),a=o.version,c="win32"==i?"Windows":"darwin"==i?"mac":i,l=ge.brightMagenta(e());lt(`${s} 版本 ${ge.brightRed(a)} (${c} ${l})`)}function en(){lt("抱歉,未找到版本定义说明")}class tn{#c;#l;constructor(e=""){if(w(e)||(e=`${e}`),this.#c=Symbol(e),Mt[this.#c])throw new Error(`${e} 已经存在,请更换初始化命令名称,若仍想在原命令上操作,请抽离为单独的文件做数据共享`);this.#l=Mt[this.#c]=Vt(),[this.#l.__filename]=tt(),this.#l.name=e||w(process.argv[1])&&process.argv.slice(1,2)[0].replace(/.*\/.*?$/,"$1")||"",Object.defineProperty(this,"#uniKey",{value:this.#c,writable:!1,enumerable:!1,configurable:!1})}get name(){return this.#l.name}get state(){return this.#l.state}isEnd(e=!1){const t=4===this.#l.state.code;return t&&I(e)&&this.end(),t}end(){return this.#l.state="end",process.exit()}error(){return this.#l.state="error",process.exit(1)}bind(e){return Wt(e,this.#l),this}run(){const e=this.#l;return Zt(e),v(e.helpInfo)||zt(e),e.hasShowVersion&&Qt(e),this}get args(){return this.#l.args}get values(){return this.#l.values.slice()}help(e,t){const n=this.#l;w(e)&&n.originalBind[e]?w(t)&&n.originalBind[e].options&&n.originalBind[e].options[t]?n.helpInfo=[e,t]:n.helpInfo=e:n.helpInfo="help",zt(this.#l)}version(){Qt(this.#l)}}const nn=De("#333"),rn=De("#666"),on=De("#aaa"),sn=Le("#666"),an=rn(".".repeat(3)),cn=(e="✦")=>Ee(e),ln=(e="❖")=>xe(e),un=(e="▶︎")=>ke(e),fn=(e="◼︎")=>Ce(e),dn=(e="⚉")=>ve(e),hn=(e="◦")=>rn(e),pn=(e="●")=>xe.blink(e),gn=(e="□")=>rn(e),mn=(e="□")=>xe.blink(e),bn=(e="■")=>rn(e),wn=(e="■")=>xe.blink(e);function yn(e,t){lt(`${fn(t)} ${e}`)}function $n(e,t){lt(`${un(t)} ${e}`)}function vn(e,t){lt(`${cn(t)} ${e}`)}function xn(e,t="⚉"){lt(`${dn(t)} ${De("#612").italic(e)}`)}function kn(e,t="❖"){lt(`${ln(t)} ${e}`)}const Cn={callList:[],on(e,t){const n=this.callList;D(n)&&(At("当前执行列表为空,直接执行任务",e),Reflect.apply(t,void 0,[])),n.push([e,t])},remove(e){const t=this.callList,n=t.findIndex(([t])=>t===e);return t.splice(n,1),D(t)?(At("当前执行列表为空,返回 true 结束执行"),!0):(Reflect.apply(t[0][1],null,[]),!1)}},En={data:"",kind:0,multi:!1,progressCount:0,indexOfCursor:0,init:function(e){this.data=e,this.multi=R(e)}},In={get kind(){return En.kind},set kind(e){(!isFinite(e)||0!=e&&1!=e)&&(e=0),En.kind=e},get multi(){return En.multi},enterText:[],get progressCount(){return En.progressCount},set progressCount(e){En.progressCount=e,e<0&&Reflect.apply(jn,this,[])},get indexOfCursor(){return En.indexOfCursor},set indexOfCursor(e){En.indexOfCursor=e},currentIssue:{text:"请更换为你自己的问题",tip:"",type:"text",private:!0,errorText:"",resultText:"",required:!0,defaultValue:"",mustInfo:!1,canCtrlCExit:!1,canCtrlDExit:!1,isWrapLine:!1,usableLength:0,mustInfoLen:0,row:0,cum:0,maxLen:0,minLen:0,len:0,verify:[]},results:[],assign(e){Object.keys(e).forEach(t=>{if(!Object.hasOwn(this,t)||O(e[t]))throw lt(`${t} is not exist`),new Error(`${t} is not exist`);this[t]=e[t]})},beforeStart(){this.results.length=this.enterText.length=this.indexOfCursor=0,this.progressCount=En.multi?-En.data.length:-1}};function jn(){const{multi:e,progressCount:t}=this,n=e&&R(En.data)?En.data[En.data.length+t]:En.data,r={text:"请更换为你自己的问题",tip:"",type:"text",private:!0,errorText:"",resultText:"",required:!0,defaultValue:"",mustInfo:!1,canCtrlCExit:!1,canCtrlDExit:!1,isWrapLine:!1,usableLength:0,mustInfoLen:0,row:0,cum:0,maxLen:0,minLen:0,len:0,verify:[]};Object.assign(r,w(n)||x(n)?{text:n}:n);const o=R(r.tip)?1:0;let i;1==o?i=[r.tip[0]]:(i=[],[r.tip,r.defaultValue].every(e=>$(e))&&(r.required=!0),!v(r.defaultValue)&&$(r.tip)&&(r.tip=r.defaultValue)),r.text=v(r.text.toString())?"请使用你自己的问题":r.text,this.assign({indexOfCursor:0,kind:o,enterText:i,currentIssue:r})}const Sn=V(()=>{const{kind:e,currentIssue:t,enterText:n}=In,{mustInfo:r,text:o,required:i,tip:s,verify:a}=t;pt();let c="",l=!1;if(C(t.row)||(c+=`${X}${t.row}A`,t.row=0),c+=`\r${X}0J${Q}`,r)c=On(c),l=!0;else if(!D(n)){const e=n.join("");for(const n of a)if(y(n.reg)&&w(n.info)&&[O,E].some(e=>e(n.inverse))){n.reg.lastIndex=0;const r=n.reg.test(e);if(I(n.inverse)&&I(r)||I(!n.inverse)&&j(r)){t.mustInfo=n.warn?ke(n.info):n.info,c=On(c),l=!0;break}}}const u=0===e&&i?ve.blink("*"):"";c+=`${un()} ${u}${o}${u}: `,t.row+=Number(t.isWrapLine),c+="\n".repeat(Number(t.isWrapLine)),C(e)?D(n)&&w(s)?$(s)?c+=Se.dim.blink("I"):c+=" ".concat(sn.italic.dim(s[0])).concat(Se.dim(s.slice(1))):(c+=" ",c=function(e){const{type:t,usableLength:n}=In.currentIssue;e="text"===t?function(e,t){const{enterText:n,indexOfCursor:r}=In,o=Me(n.join(""))>t;r===n.length?(o?e=function(e,t){const{enterText:n}=In;return e+=an.concat([...Be(n.toReversed().join(""),t-3,!1)].reverse().join("")),e}(e,t):e+=n.join(""),e+=sn.hide(" ")):o?e=function(e,t){const{indexOfCursor:n,enterText:r}=In,o=r.join(""),i=r.length,s=Math.floor(t/2),a=Be(o,s),c=a.length-1,l=a[c]===o[c]?c:c-1,u=Be(o,-s),f=u.length-1,d=u[f]===o[i-1-f]?i-1-f:i-f,h=r.map((e,t)=>t===n?sn(e):e).join("");if(n>=d)e+=an,e+=Be(h,3-t,!1);else if(n<l)e+=Be(h,t-3,!1),e+=an;else{const t=s-Me(r[n])-3;e+=an,e+=Be(o.slice(0,n),-t,!1),e+=sn(r[n]),e+=Be(o.slice(n+1),t,!1),e+=an}return e}(e,t):e+=`${n.map((e,t)=>t===r?sn(e):e).join("")}`;return e}(e,n):function(e){const{enterText:t,indexOfCursor:n}=In;n===t.length?(e+=` ${t.map(()=>"*").join("")}`,e+=sn.hide("1")):e+=` ${t.map((e,t)=>t===n?sn("*"):"*").join("")}`;return e}(e);return e}(c)):c=function(e){const{currentIssue:t,enterText:n}=In;return e+t.tip.map(e=>e===n[0]?Oe.bold.blink.cyan(e):ye(e)).join(" ")}(c),At("计算完成的文本为",c),lt(Fe(c)),t.row++,function(e){const{currentIssue:t,indexOfCursor:n,enterText:r}=In,{text:o,required:i,mustInfoLen:s}=t;if(e)return yt(s);const a=r.slice(0,n).join(""),c=o.toString().concat(a),l=Me(c),u=l+7+2*Number(i),f=u%process.stdout.columns;At("用户输入",r.join("")),At("光标所在的位置",n),At("实际参与计算的用户输入的文本为",a),At("计算总文本",c),At("计算文本长度",l),At("计算可用长度",u),At("屏幕宽",process.stdout.columns),At("光标偏移量",u%process.stdout.columns),yt(f)}(l),l||lt(Te("I"),!1),ht("8m")},66);function On(e){const{currentIssue:t}=In;e+="\n\r",t.row++;let n="";if(E(t.mustInfo)){const e=t.required?" ":"";n+=" ".repeat(2).concat(e).concat(me(t.text)).concat(e).concat(" ".repeat(3)),n+=me.blink`👆`}else n+=ye(t.mustInfo);let r=Me(n);const o=process.stderr.columns-4;return o<r&&(r=o,n=Be(n,o)),t.mustInfoLen=r,e+=n,e+=`\r${X}1A`,t.row--,t.mustInfo=!1,e}function Tn(){const{currentIssue:e}=In;!function(){const{currentIssue:e}=In,t=process.stdout.columns;let n=t-Me(e.text.toString())-2*Number(e.required)-4-7;const r=n<5;r&&(n=t-4);e.isWrapLine=r,e.usableLength=n}();const{isWrapLine:t}=e,n=2+Number(t);lt("\n".repeat(n),!1),e.row+=n,bt(n),e.row-=n}async function Rn(){try{await ct((e=this,(t,n)=>{const{kind:r,currentIssue:o,enterText:i,results:s}=e,{tip:a,text:c,canCtrlCExit:l,canCtrlDExit:u}=o;let f=[],d=0,h=0,p=!0;switch(C(r)||(f=a,d=f.length-1,h=f.indexOf(i[0])),At("\n 用户使用了",t,n),n.name){case"return":if(function(){const{enterText:e,currentIssue:t,results:n}=In,r=t.text;let o=e.join("").trim();if($(o)&&t.required)return t.mustInfo=!0,!1;const{len:i,minLen:s,maxLen:a,verify:c}=t,l=o.length;if(C(In.kind)){if(c.length>0)for(const e of c)if([O,j].some(t=>t(e.warn))&&y(e.reg)&&w(e.info)&&[O,E].some(t=>t(e.inverse))){e.reg.lastIndex=0;const t=e.reg.test(o);if(I(e.inverse)&&t||!e.inverse&&!t)return!1}if(!C(i)&&l!==i)return t.mustInfo=`您输入的长度 ${be(l)} 不符合要求值 ${$e(i)}`,!1;if(!C(s)&&l<s)return t.mustInfo=`您输入的长度 ${be(l)} 小于最低要求${$e(s)}`,!1;if(a>s&&l>a)return t.mustInfo=`您输入的长度 ${be(l)} 大于最低要求${$e(a)}`,!1}return $(o)&&j(t.required)&&(o=t.defaultValue||t.tip||""),n.push({q:r,r:o}),!0}())return p=!1,!0;break;case"left":!function(e,t,n){const{kind:r,enterText:o}=In;C(r)?In.indexOfCursor=0===In.indexOfCursor?o.length:In.indexOfCursor-1:o[0]=e[0===t?n:t-1]}(f,h,d);break;case"right":!function(e,t,n){const{kind:r,enterText:o}=In;C(r)?In.indexOfCursor=In.indexOfCursor==In.enterText.length?0:In.indexOfCursor+1:o[0]=e[t==n?0:t+1]}(f,h,d);break;case"delete":case"backspace":!function(){const{enterText:e,kind:t}=In;C(t)&&!C(In.indexOfCursor)&&(e.splice(In.indexOfCursor-1,1),In.indexOfCursor--)}();break;case"escape":if(n?.sequence===Y.repeat(2))return s.push({q:c,r:void 0}),p=!1,!0;break;default:if(At("当前触发为含 ctrl 键的功能键",t,n),j(n?.ctrl))!function(e){const{enterText:t,kind:n}=In;O(e)||0!==n||(In.indexOfCursor==t.length?t.push(e):t.splice(In.indexOfCursor,0,e),In.indexOfCursor+=1)}(t);else if(p=!1,ht("m"),I(l)&&"c"===n?.name||I(u)&&"d"===n?.name)return s.push({q:c,r:void 0}),!0}return p&&Sn(),!1}))}catch(e){At.error("接收用户输入出错",e),lt(e)}var e}function Dn(e,t){const n=Symbol("question");try{return new Promise((r,o)=>{Cn.on(n,async()=>{try{const o=await async function(e,t){process.stdout.removeListener("resize",Nn),process.stdout.on("resize",Nn),At("初始化问题"),En.init(e),At("初始化当前问题"),In.beforeStart(),At("开始绘制问题");do{Tn(),Sn();try{await Reflect.apply(Rn,In,[])}catch(e){At.error(e)}const{currentIssue:e,results:t}=In;C(e.row)||(bt(e.row,!0),e.row=0),ht("m"),gt(),mt(!0);const n=e.resultText||e.text,r=t[t.length-1].r;e.private||(O(r)?xn(e.errorText||n):kn(`${rn(n)}: ${"text"===e.type?r:r.replace(/./gm,"*")}`)),++In.progressCount}while(In.progressCount<0);return process.stdout.removeListener("resize",Nn),ht("m"),gt(),mt(!0),In.multi?I(t)&&R(e)?In.results.map(e=>e.r):In.results:In.results[0].r}(e,t);Cn.remove(n),r(o)}catch(e){At.error("\n\n\n\n\n执行出现错误",e),Cn.remove(n),o(e)}})})}catch(e){return At.error("系统故障",e),lt("系统故障",!1),lt(e),new Promise((t,n)=>{n(e)})}}const Nn=V(()=>{const{currentIssue:e}=In;C(e.row)||(bt(e.row,!0),e.row=0),lt(Q,!1),mt(!0),Tn(),Sn()}),Ln=async function(e,t){return Dn(e,t)};function Pn(e=!0){return process.stdout.rows-4*(1+Number(e))}function Mn(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];if(M(r,e=>[w,x].some(t=>t(e))))t.push({value:r,label:r,checked:!1,tip:"",disable:!1});else{if(!M(r,e=>[w,w].some(t=>t(e.label))&&[w,x,P].some(t=>t(e.value))))throw new TypeError(`${r} 的类型非法(有可能是返回值类型更改后未在解析中兼容)`);{let e=r.checked;!O(e)&&E(e)||(e=!1);let n=r.tip;!O(n)&&w(n)||(n="");const o=r.value;if(O(o)||S(o))throw new TypeError("value 值类型非法");const i=r.label,s=I(r.disable);t.push({checked:e,tip:n,value:o,label:i,disable:s})}}}return t}const An="请使用键盘选择,请使用 Enter 键进行选择",Bn=!1,Fn="radio",Wn={drawData:[],info:An,focus:0,renderInfo:{rows:0,renderRows:0,otherInfoRows:0,allowBelow:!1,size:{width:0,height:0}},resultText:"",errorText:"",private:Bn,required:Bn,kind:Fn,canCtrlCExit:Bn,canCtrlDExit:Bn,mustInfo:Bn,maxRows:Pn(),data:[],initData(e){At("初始化数据"),this.reset(),R(e)?this.data=Mn(e):Object.keys(e).forEach(t=>{const n=e[t];switch(t){case"data":this.data=R(n)?Mn(n):[];break;case"info":this.info=w(n)?n:An;break;case"resultText":this.resultText=w(n)?n:this.info||"";break;case"errorText":this.errorText=w(n)?n:this.resultText||this.info||"";break;case"private":this.private=E(n)?n:Bn;break;case"required":this.required=E(n)?n:Bn;break;case"kind":this.kind="check"===n?"check":Fn;break;case"canCtrlCExit":this.canCtrlCExit=E(n)?n:Bn;break;case"canCtrlDExit":this.canCtrlDExit=E(n)?n:Bn;break;case"maxRows":this.maxRows=isFinite(n)&&Number.isInteger(n)&&n>0?n+4:Pn()}});const t=this.data;for(const e in t){if(!t[e].disable)return this.focus=Number(e),!1}return!0},reset(){this.drawData.length=this.data.length=this.focus=0,this.maxRows=Pn(),this.renderInfo={rows:0,renderRows:0,otherInfoRows:0,allowBelow:!1,size:{width:0,height:0}},this.info=An,this.kind=Fn,this.resultText=this.errorText="",this.private=!0,this.required=this.canCtrlCExit=this.canCtrlDExit=this.mustInfo=Bn}};function Vn(e){const{data:t}=Wn,n=process.stdout.columns-7,r=n-3,o=t[e].label.toString();return Me(o)<=n?o:Be(o,r,!1).concat(an)}const qn=()=>{!function(){const{focus:e,drawData:t,data:n,kind:r}=Wn;for(let o=0,i=n.length;o<i;o++){const i=n[o];if(O(t[o])){const n=Me(i.label.toString());t[o]={index:o,text:Vn(o),length:n,checked:"radio"!==r&&i.checked,focus:o===e,changed:!0,show:!0,disable:i.disable}}else o===e?(t[o].changed=!0,t[o].focus=!0):o!==e&&I(t[o].focus)&&(t[o].changed=!0,t[o].focus=!1)}}(),function(){const{drawData:e,renderInfo:t,focus:n}=Wn,{renderRows:r}=t,o=e.length;if(o===r)return void e.forEach(e=>e.show=!0);const i=o-1,s=Math.floor((r-1)/2);let a=1&r?n-s:n-s-1;a=a<0?0:a;let c=r+a-1;c>i&&(c=i,a=c-r+1);e.forEach(e=>{const{index:t}=e;t>c||t<a?e.show=!1:t===c&&t!==i||t===a&&0!==t?(e.show=!0,e.text=an):e.text===an?(e.show=!0,e.text=Vn(t)):e.show=!0})}();const{info:e,mustInfo:t,renderInfo:n,focus:r,data:o}=Wn,{rows:i,allowBelow:s,size:a}=n,{width:c}=a;let l=`${X}${c}D`;l+="\n".repeat(i),l+=`${X}${i}A`,l+=`${X}J`,l+=Fe(`${un()} ${e} \n\n`),l+=function(){const{drawData:e,kind:t}=Wn;let n="";for(let r=0,o=e.length;r<o;r++){const o=e[r];o.show&&(o.focus?(n+=Fe(` ${"radio"===t?pn():o.checked?wn():mn()} ${o.text}`),n+="\n"):o.text===an?(n+=` ${an}`,n+="\n"):o.disable?(n+=Fe(` ${"radio"===t?on`⊗`:o.checked?on`▣`:on`☒`} ${on(o.text)}`),n+="\n"):(n+=Fe(` ${"radio"===t?hn():o.checked?bn():gn()} ${nn(o.text||"")}`),n+="\n"))}return n}(),l+=`${X}J`,s&&(t?l+=function(){const e=process.stdout.columns-7;Wn.mustInfo=!1;const t="抱歉,该项至少选择一项!!!请使用空格键或是左右键切换选择状态",n=Me(t)<e?t:Be(t,e);return"\n".concat(me(n))}():o[r].tip?(l+="\n",l+=Fe(`${$e(o[r].tip)}`)):l+="\n",l+="\n"),Bt&&(l+=`${X}${c}D${X}${i}A`),lt(l,!1)},zn=V(qn,66),_n=V(qn,600);function Gn(){const{data:e,renderInfo:t,maxRows:n}=Wn,[r,o]=[process.stdout.columns,process.stdout.rows],i=e.length;t.size={width:r,height:o};const s=t.rows=Math.max(Math.min(i+4,Pn(!1),n),5),a=t.allowBelow=Pn()>e.length||s>6,c=t.otherInfoRows=a?4:2;t.renderRows=s-c}async function Jn(){const{data:e,required:t,kind:n,drawData:r,canCtrlCExit:o,canCtrlDExit:i}=Wn,s={exit:!1};return await ct((a,c)=>{const{focus:l}=Wn;switch(c.name){case"return":return At("用户已选择,返回真值告诉等待程序可终结当前输入"),"check"!==n||!t||!D(r.filter(e=>e.checked))||(Wn.mustInfo=!0,zn(),!1);case"up":At("用户使用了键盘键的 up 键"),Un(!1),zn();break;case"down":At("用户使用了键盘键的 down 键"),Un(),zn();break;case"right":At("用户使用了键盘键的右键");case"left":At("用户使用了键盘键的左键");case"space":At("用户使用了键盘键的空格键"),"check"===n&&(e[l].checked=r[l].checked=!r[l].checked,zn());break;case"escape":if(c?.sequence===Y.repeat(2))return s.exit=!0,!0;break;default:if(At("用户使用了键盘键的非方向键 <",a,">, <",c,">"),I(c?.ctrl)&&("check"===Wn.kind&&("a"===c?.name&&(Hn(),zn()),"z"===c?.name&&(Hn(!1),zn()),"r"===c?.name&&(Wn.data.forEach(e=>{e.disable||(e.checked=!e.checked)}),Wn.drawData.forEach(e=>{e.disable||(e.checked=!e.checked)}),zn())),I(o)&&"c"===c?.name||I(i)&&"d"===c?.name))return s.exit=!0,!0}return!1}),s.exit}function Hn(e=!0){Wn.data.forEach(t=>{t.disable||(t.checked=e)}),Wn.drawData.forEach(t=>{t.disable||(t.checked=e)})}function Un(e=!0){const{focus:t,drawData:n}=Wn,r=n.length-1,o=e?t===r?n:[...n.slice(t+1),...n.slice(0,t+1)]:0===t?n.toReversed():[...n.slice(t),...n.slice(0,t)].toReversed();for(const e of o)if(!e.disable)return void(Wn.focus=e.index)}async function Kn(e,t){const n=Symbol("selection");return new Promise((r,o)=>{Cn.on(n,async()=>{try{const o=await async function(e,t){if(process.stdout.removeListener("resize",Yn),process.stdout.on("resize",Yn),Wn.initData(e))return;pt(),At("初始绘制问题选项"),Gn(),zn(),At("绘制完成,等待用户操作");const n=await Jn();lt(Q,!1),process.stdout.removeListener("resize",Yn);const{resultText:r,info:o,focus:i,kind:s,drawData:a,errorText:c}=Wn;if(gt(),mt(!0),n)return void(Wn.private||xn(c||r||o));const l=a.filter(e=>e.checked);if(!Wn.private){const e="radio"===s?[a[i].text]:l.map(e=>e.text);kn(`${rn.italic.dim(r||o)}: ${rn(e.join("、"))}`)}const u="radio"===s?Wn.data[i].value:l.map(e=>Wn.data[e.index].value),f="radio"===s?i:l.map(e=>e.index),d="string"==t||O(t)?u:f;return d}(e,t);Cn.remove(n),r(o)}catch(e){At.error(e),Cn.remove(n),o()}})})}const Yn=V(()=>{const{drawData:e,renderInfo:t}=Wn,n=t.size.height;e.length=0,lt(Q,!1),mt(),Gn(),process.stdout.rows!==n?_n():zn()},33);function Xn(e,t){return Kn(e,t)}const Zn=new Je({name:"jja",type:!1}),Qn=j(Zn.type),er=new class extends tn{constructor(e=""){super(e),Object.defineProperties(this,{selection:{value:Xn,writable:!1,enumerable:!1,configurable:!1},question:{value:Ln,writable:!1,enumerable:!1,configurable:!1}})}selection=Xn;question=Ln;INFO=vn;SUCCESS=kn;CURRENT=$n;WARN=yn;ERROR=xn}("jja");function tr(e){if(!q())throw new TypeError("该函数不支持当前环境");const t=process.platform,n=e.replace(/\s+$/,"");if("darwin"===t)l("pbcopy",{input:n});else if("win32"===t)l("clip",{input:n,stdio:"pipe"});else try{l("which xclip",{stdio:"ignore"}),l("xclip -selection clipboard",{input:n})}catch(e){try{l("which xsel",{stdio:"ignore"}),l("xsel --clipboard --input",{input:n})}catch(e){return""}}return e}er.bind({"package <pkg> (包管理)":["--diff <-d> (分析当下包的差异)","--upDependencies <-u> (更新依赖,强制更新到 'latest',使用需谨慎)"],"remove <rm> (做一个简单的兼容的移除文件或文件夹的命令)":["--ignore <-i> (不打印日志(默认打印的))","--subdirectories <-s> (这是一个危险的命令,用于 windows 下递归删除执行命令下所有的给定文件名称)"],"update <up> (做一个简单的 npm 升级程序,对,简单的)":["--ignore <-i> (不建议你这么用,你会发现你像个傻子一样在那等结果)",`--dependencies <-d> (更新依赖,跟 ${Pe("npm update")} 一样)`],"clearScreen <cls> (清理终端显示屏幕,同 clearTerminal )":"","clearTerminal <clear> (清理终端显示屏幕,同 clearScreen )":"","git (一些关于 git 的操作)":[`commit (git 提交代码,是 ${me("commit")} 提交啊,不是 ${De("#666")("push")} 推送)`,"merge (合并两个分支)","tag (给提交打上 tag)"],"dns (使用 dns 获取 ip 地址)":["--domain <-d> (获取给定域名获取 ip 地址,默认 github.com )","--port <-p> (配置要校验的 port 端口号,默认为 443)"],"runOtherCode <run> (执行其他的代码,使用 )":[]}).run(),Zn("参数已绑定,且已解析用户参数",er.args),Zn.warn("当前的执行状态",er.state),er.isEnd(!0);const nr=It({show:!1,info:"请稍等",beforeDestroyed:e=>e&&er.end()}),rr=je.green,or=De("0x993311"),ir=De("0x339999"),sr=De("0x666666"),ar=["A","AAAA","ANY","CAA","CNAME","MX","NAPTR","NS","PTR","SOA","SRV","TLSA","TXT"],cr={domain:"github.com",port:443,dnsServers:["1.1.1.1","8.8.8.8","8.8.4.4","208.67.222.222","114.114.115.115","223.5.5.5","180.76.76.76"],ips:{},rrtype:["A"],reset(e){this.ips={},this.domain="github.com",this.port=443,this.rrtype=[],O(e)||e.forEach(e=>{const t=e["--domain"];!O(t)&&t.length>0&&(this.domain=t[0].toString());const n=e["--port"];!O(n)&&n.length>0&&(this.port=Number(n[0]));const r=e["--rrtype"];if(!O(r)&&r.length>0){const e=function(e,t){if(!R(e)||!R(t))throw new TypeError("参数必须是数组类型数据");if(D(e)||D(t))return[];const[n,r]=e.length<=t.length?[e,t]:[t,e],o=new Set(n);return r.filter(e=>o.has(e))}(ar,r);e.length>0&&(this.rrtype=e)}})},noCopy:!0};async function lr(e){return Promise.all(e.map(e=>async function(e,t=3e3){const{ips:n,port:r}=cr;if(E(n[e]))return Qn||nr.log(`${e} 联通性已校验过 ${n[e]?"🔥":"⛓️‍💥"}`),Promise.resolve(null);n[e]=!1,Qn||nr.log(`校验 ${e} 的联通性`);return new Promise(o=>{const i=new g.Socket,s=(t=!1)=>{n[e]=t,i.destroy(),o(null)};i.setTimeout(t),i.on("connect",()=>s(!0)),i.on("timeout",()=>s()),i.on("error",()=>s()),Qn||nr.log("测试的接口为:",r),i.connect(r,e)})}(e)))}async function ur(e="1.1.1.1"){const{domain:t}=cr;try{const n=await async function(e,t){return new Promise(n=>{const r=new p;nr.run(`使用 ${t} 获取 ${e} 的 ip`),r.setServers([t]),r.resolve4(e,(r,o)=>{if(r)return Qn||nr.run(`使用 ${t} 获取 ${e} 的 ip 出错`),n(null);Qn||nr.log(`使用 ${t} 获取 ${e} 的 ip 值为 ${o.join(" --- ")}`),n(o)})})}(t,e);if(S(n))return Qn||nr.log(`${e} 获取 ${t} 的 ip 失败`),0;const r=(await lr(n)).filter(e=>!S(e));return D(r)?0:(nr.destroyed(),lt(),lt(Re`DNS: ${e}`),lt(),r.forEach(({ip:e,isAlive:t})=>{lt(Fe(t?`${be(e)} ${or`->`} ✅`:`${sr(e)} ${me`⛓️‍💥`} ❌`))}),3+r.length)}catch(e){return Qn||nr.log("'获取 ip 错误'",e),0}}async function fr(e){cr.reset(e.options),await async function(){const{domain:e,ips:t}=cr;nr.run(`正在获取本地的 ${e} 的 ip 地址`);try{const n=await async function(e){return new Promise(t=>{h.lookup(e,{all:!0,family:4},(n,r)=>{if(n)return Zn.error(`获取本地 ${e} 的 ip 出错`,n),void t(null);Qn||nr.log(`获取本地 ${e} 的 ip 值为 ${r.join(" --- ")}`),t(r.map(e=>e.address))})})}(e);if(S(n))return;await lr(n),L(t)||function(e){const{ips:t}=cr;lt(or`本地配置 ${e} 的 ip 地址及联通性为:\n`),Object.keys(t).forEach(e=>{const n=t[e];n&&(cr.noCopy=!1),lt($e`- ${e}`,!1),lt(n?or` -> ✅`:sr` -> ❌`)}),lt()}(e)}catch(e){Zn.error(e)}}(),await async function(){const{domain:e,dnsServers:t}=cr;nr.log(`${e} ip 列表:`);const n=t.map(e=>ur(e)),r=await Promise.all(n);Qn&&(bt(r.reduce((e,t)=>e+t,0)+1),mt(!0))}(),nr.destroyed();const{ips:t}=cr;Object.keys(t).length>0?await async function(){const{domain:e,ips:t,port:n}=cr;await Dt(`${Ce`${e}`} 域名解析结果:`),lt();let r=cr.noCopy;for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const o=t[n];lt(o?`${be`- ${n.padEnd(16)}`} ${or`->`} ✅${r?$e`(已复制)`:""}`:`${sr`- ${n.padEnd(16)}`} ${me`⛓️‍💥`} ❌`),o&&r&&(tr(`${n} ${e}`),r=!1)}lt(),await Dt(me.italic.dim`${e} 联通性接口判断为 ${n.toString()}`),lt()}():await async function(){const{domain:e,port:t}=cr;await Dt(`\n找不到 ${me(e)} 的服务器 IP 地址 ${sr`测试使用 ${t.toString()} 端口`}\n`)}()}async function dr(e){const t=Ye("package.json","file",process.cwd());if(null==t)return!0;const n=Xe(Ue(t,"package.json"));if(S(n)||!n.version)return!0;const r=n.version;await Tt({code:`git tag -a v${r} -m '${e}'`,cwd:t}),await Tt({code:"git push origin --tag",cwd:t})}async function hr(e){e.commit?await async function(e="版本维护",t=!1){const n=Ye(".git","directory");if(null==n)return lt(De("#ff0")("not a git repository(当前目录非 git 储存库)"));const r=await Tt({code:"git add .",cwd:n});if(!r.success)return null!=console.log(r.error);const o=await Tt({code:"git status",cwd:n});if(!/nothing to commit, working tree clean/.test(o.data||"")){const r=await Tt({code:"git add .",cwd:n});if(!r.success)return null!=console.log(r.error);""==e.trim()&&(e=await er.question({text:"请输入提交信息"})??"");const o=await Tt({code:`git commit -m "${e}"`,cwd:n});return o.success?(o.error&&console.log(o.error),await Tt({code:"git push",cwd:n}),t&&await dr(e),!0):null!=console.log(o.error)}return!1}(e.commit.join(" ")):e.merge?await async function(e){if(v(e)){const t=await Tt("git branch -a");console.log(t.data),e=await er.question({text:"请输入要合并分支的名称"})??""}if(v(e))return er.ERROR("没有获取到要合并的分支");const t=await er.selection({data:[{label:"正常快进合并",value:""},{label:"非快进合并 (--no-ff)",value:"--no-ff"},{label:"多提交记录合并为一条 (--squash)",value:"--squash",tip:"适用于将众多小的提交合并成一个提交"}]});O(t)?er.ERROR("您选择退出合并"):await Tt(`git merge ${e} ${t}`)}(e.merge.join("")):e.tag?await async function(){const e=await er.question({text:"请输入待标记的信息"});O(e)||await dr(e)}():er.help("git")}const pr={local:null,online:null,dependenceList:{},updateDependence:[],latestDependence:[],binning:function(e,t=!1){if(O(e)||L(e)||S(this.local))return;const{overrides:n}=this.local;for(const r in e){if(w(n?.[r])){er.WARN(`${r} 被锁定在 ${n[r]}`);continue}const o=e[r];this.dependenceList[r]={type:t?"devDependencies":"dependencies",version:o,localVersion:"",latestVersion:"",onlineVersion:"",tag:"",time:""}}},preReleaseDependence:[],timeoutDependence:[],registry:void 0},gr=A(function(e){return this.data=[],Object.setPrototypeOf(this,e),this});function mr(e,t){if(t.align&&(e.align=t.align),t.bgColor&&(e.bgColor=t.bgColor),t.color&&(e.color=t.color),t.italic&&(e.italic=t.italic),t.underline&&(e.underline=t.underline),t.border)if(M(t.border,e=>w(e))){const n=t.border;e.border={left:{color:void 0,style:n},right:{color:void 0,style:n},top:{color:void 0,style:n},bottom:{color:void 0,style:n}}}else if(M(t.border,e=>["color","style"].some(t=>!O(e[t])))){const n=t.border,r=n.style,o=n.color||void 0;e.border=JSON.parse(JSON.stringify({left:{color:o,style:r},right:{color:o,style:r},top:{color:o,style:r},bottom:{color:o,style:r}},(e,t)=>""===t?void 0:t))}else M(t.border,e=>["left","right","top","bottom"].some(t=>!O(e[t])))&&(e.border=t.border)}class br{}function wr(e,t){R(e)&&(e={data:e});const n=new br;mr(n,e);const r=new gr(n);return Object.setPrototypeOf(n,t),e.data?.forEach(e=>{e&&r.data.push(function(e,t){if(O(e))return;M(e,e=>!N(e))&&(e={content:e});const n={content:e.content};return mr(n,e),Object.setPrototypeOf(n,t),n}(e,n))}),r}class yr extends br{border={left:{style:"bold",color:void 0},right:{style:"bold",color:void 0},top:{style:"bold",color:void 0},bottom:{style:"bold",color:void 0}}}function $r(e){const t=new yr;return Object.setPrototypeOf(t,e),t}const vr=!q(),xr={emojiLength:2.08,emojiRegex:/[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F900}-\u{1F9FF}]/gu,chineseLength:1.8,chineseRegex:/[\u4E00-\u9FFF]/g};const kr=new class{align="left";color="";bgColor="";bold=!1;underline=!1;italic=!1;border={left:{color:void 0,style:"simple"},right:{color:void 0,style:"simple"},top:{color:void 0,style:"simple"},bottom:{color:void 0,style:"simple"}}},Cr=A(function(e){return this.body=[],this.header=void 0,Object.setPrototypeOf(this,e),this});class Er{}function Ir(e){let t=ge;return M(e)&&(e.bold&&(t=t.bold),v(e.bgColor)||O(e.bgColor)||(t=t.bgColor(e.bgColor)),v(e.color)||O(e.color)||(t=t.color(e.color)),e.italic&&(t=t.italic),e.underline&&(t=t.underline)),t}const jr={fine:{lt:"┌",ct:"┬",rt:"┐",lc:"├",c:"┼",rc:"┤",lb:"└",cb:"┴",rb:"┘",l:"─",v:"│"}};function Sr(e){let t=0;return[...e].forEach(e=>{xr.emojiRegex.lastIndex=0,xr.chineseRegex.lastIndex=0,e.match(xr.emojiRegex)?t+=xr.emojiLength:e.match(xr.chineseRegex)?t+=xr.chineseLength:t++}),Math.ceil(t)}function Or(e,t){const n=function(e){const t=[];return e.header&&e.header.data.forEach((e,n)=>{const r=e?.content?.toString()??"";t[n]=Math.max(t[n]??0,vr?Sr(r):Me(r))}),e.body&&e.body.forEach(e=>{e.data.forEach((e,n)=>{const r=e?.content?.toString()??"";t[n]=Math.max(t[n]??0,vr?Sr(r):Me(r))})}),t}(e);let r=!1,o="";e.header&&(r=!0,o+=function(e,t){let n="";const r=t.length-1,{fine:o}=jr,i=Ir(e);return t.forEach((e,t)=>{0===t&&(n+=o.lt),n+=Q,n+=o.l.repeat(e+2),t===r?(n+=Q,n+=o.rt):(n+=Q,n+=o.ct)}),n+="\n",t.forEach((t,s)=>{n+=Q,n+=o.v;const a=e.data[s];if(O(a)||S(a))n+=Q,n+=i(" ".repeat(t+2));else{const e=Ir(a);let r=a.content?.toString()??"";r=r.replace(/[\n]/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"),n+=Q,n+=e`\u2002${Be(r,t)}\u2002`}s===r&&(n+=o.v)}),n+="\n",n}(e.header,n)),o+=function(e,t,n){let r="";const o=t.length-1,{fine:i}=jr;return t.forEach((e,t)=>{0===t&&(r+=Q,r+=n?i.lc:i.lt),r+=Q,r+=i.l.repeat(e+2),t===o?(r+=Q,r+=n?i.rc:i.rt):(r+=Q,r+=n?i.c:i.ct)}),r+="\n",e.forEach((n,s)=>{const a=Ir(n);t.forEach((e,t)=>{r+=Q,r+=i.v;const s=n.data[t];if(O(s)||S(s))r+=a`${" ".repeat(e+2)}`;else{const t=Ir(s);let n=s.content?.toString()||"";n=n.replace(/[\n]/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"),r+=Q,r+=t`\u2002${Be(n,e)}\u2002`}t===o&&(r+=Q,r+=i.v)}),r+="\n";const c=e.length-1===s;t.forEach((e,t)=>{0===t&&(r+=Q,r+=c?i.lb:i.lc),r+=Q,r+=i.l.repeat(e+2),t===o?(r+=Q,r+=c?i.rb:i.rc):(r+=Q,r+=c?i.cb:i.c)}),r+="\n"}),r}(e.body,n,r);const i=fe(o);if(vr){const e=i[0].split("%c"),n=i.map((n,r)=>{if(r>0){const o=[...e[r]].reduce((e,t)=>Me(t)>1?(xr.emojiRegex.lastIndex=0,t.match(xr.emojiRegex)?e-(xr.emojiLength-2):e+(2-xr.chineseLength)):e,0);return n+"font-family: Consolas,Monaco,Courier,'Courier New','等宽字体',monospace; font-size:"+t+"px;word-spacing:normal;padding:0;margin:0;padding-right:"+o*t+"px"}return n});console.log(...n)}else console.log(...i)}const Tr=A(function(e){const[t,n]=function(e){O(e)&&(e={}),R(e)&&(e={body:e});const t=new Er;mr(t,e),Object.setPrototypeOf(t,kr);const n=new Cr(t);return e.header&&(n.header=wr(e.header,$r(t))),e.body?.forEach(e=>n.body.push(wr(e,t))),[n,t]}(e);let r=12;const o=()=>Or(t,r);return Object.setPrototypeOf(o,this),Object.defineProperties(o,{addRow:{value:e=>(t.body.push(wr(e,n)),o),configurable:!1,writable:!1,enumerable:!1},setHeader:{value:e=>(t.header=wr(e,$r(n)),o),configurable:!1,writable:!1,enumerable:!1},setFontSize:{value:e=>(r=e,o)}}),o}),Rr=_?"cmd"===function(){if(!Qe())return null;const e="C:\\Windows\\System32\\cmd.exe"===process.env.ComSpec,t=!!process.env.PSModulePath;if(e)return"cmd";if(t)return"powershell";try{return l('powershell -NoProfile -Command "$PSVersionTable"',{stdio:"ignore"}),"powershell"}catch(e){He("判定是否为 powershell 出错",e)}try{return l("ver",{stdio:"ignore"}),"cmd"}catch(e){He("判定是否为 cmd 时出错",e)}const n=process.env.SHELL??process.env.shell;if(n&&(n.includes("bash")||n.includes("zsh")))return n.includes("bash")?"bash":"zsh";try{return l("bash --version",{stdio:"ignore"}),"bash"}catch(e){He("判定是否为 bash 、zsh 时出错",e)}try{return l("zsh --version",{stdio:"ignore"}),"zsh"}catch(e){He("判定为 zsh 时出错",e)}try{return l("fish -v",{stdio:"ignore"}),"fish"}catch(e){He("判定为 fish 时错误",e)}try{return l("sh --version",{stdio:"ignore"}),"sh"}catch(e){He("判定为 sh 时出错",e)}return"unknown"}()?"^":"`":"\\";const Dr=(()=>{const e=function(e=!1){if(j(e)){const e=e=>Boolean(Ye(e,"file"));if(e("pnpm-lock.yaml"))return"pnpm";if(e("yarn.lock"))return"yarn";if(e("package-lock.json"))return"npm"}const t=process.env.npm_config_user_agent||"";return t.includes("pnpm")?"pnpm":t.includes("yarn")?"yarn":t.includes("npm")?"npm":process.env.PNPM_HOME?"pnpm":process.env.YARN_IGNORE_PATH?"yarn":"npm"}(),n=function(e){const n=Ze();if(null===n)return!1;const{content:r,path:o}=n,i=t(o);if("pnpm"===e){const e=Ue(i,"pnpm-workspace.yaml");if(!Ke(e))return!1;if(a(e,{encoding:"utf-8"}).split("\n").some(e=>e.startsWith("packages:")))return!0}if(r.workspaces){if("yarn"===e){if(Ke(Ue(i,".yarnrc.yml")))return!0}if("npm"===e)return!0}return!1}(e);return"npm"===e?"npm install --save".concat(n?" --include-workspace-root ":""):"yarn"===e?"yarn add".concat(n?" -W ":""):"pnpm add".concat(n?" -w ":"")})();async function Nr(){const e={"淘宝":"registry.npmmirror.com","官方":"registry.npmjs.org","腾讯":"mirrors.tencent.com/npm","中科大":"npmreg.proxy.ustclug.org",yarn:"registry.yarnpkg.com"},t=()=>Object.keys(e).map(t=>function(e){const t=Date.now();return new Promise(n=>{const r=`https://${e}/nry`,o=m.request(r,{method:"HEAD",timeout:3500},r=>{n((r?.statusCode??0)>=200&&(r?.statusCode??0)<300?{url:e,time:Date.now()-t,success:!0}:{url:e,time:Date.now()-t,success:!1})});o.on("error",()=>n({url:e,time:Date.now()-t,success:!1})),o.on("timeout",()=>{o.destroy(),n({url:e,time:Date.now()-t,success:!1})}),o.end()})}(e[t])),n={};for(let e=0;e<3;e++){nr.run(`请稍等,正在进行第${["一","二","三","四","五"][e]}次安装源延迟测试`);(await Promise.all(t())).forEach(e=>{j(e.success)||(n[e.url]?n[e.url]=(n[e.url]+e.time)/2:n[e.url]=e.time)})}return nr.destroyed(),Object.keys(e).reduce((t,r)=>n[e[r]]<(n[e[t]]??1/0)?r:t,"")}async function Lr(){const{dependenceList:e,timeoutDependence:t}=pr,n=Object.keys(e);n.length>18&&(O(pr.registry)||!["官方","淘宝","腾讯","中科大","yarn"].some(e=>e===pr.registry))&&(pr.registry=await Nr(),lt(`由于您未设置或者设置有误,现使用 ${$e(pr.registry)} npm 源`));const r=n.map(n=>new Promise(r=>{(async()=>{const o=e[n],i=e[n].version;nr.run(`${un()}获取 ${n} 的本地安装信息`);const s=function(e){const t=Xe(Ue("node_modules/",e,"package.json"));let n="";n=S(t)?"":t.version||"";return pr.dependenceList[e].localVersion=n,Zn(e,"本地安装的版本为:",n),n}(n);if(nr.run(`${ln()} ${n} 的本地安装版本:${o.localVersion}`),await async function(e){const t=await Rt(e,pr.registry,9867);if("timeout"===t.status)return void Zn.warn("请求超时");if(S(t.data))return void Zn.warn("获取包信息失败");const n=Date.now();Zn("获取数据",e,"包信息");const r=pr.dependenceList[e],{"dist-tags":o,time:i,version:s}=t.data;let a=s,c="latest";r.onlineVersion=a,r.tag=c;const l=Object.keys(o);Zn("共需比对",l.length);for(let e=0,t=l.length;e<t;e++){const t=l[e],n=o[t];i[n]>i[a]&&(a=n,c=t)}Zn("比对",e,"完成"),Zn("耗时",Date.now()-n),"latest"!==c&&(Zn(e,"最新版本为:",a,"tag为:",c),r.tag=c,r.latestVersion=a);const u=new Date(i[a]).toLocaleString();r.time=u,Zn(`${e} 的最后发布时间为:${u}`)}(n),""===o.onlineVersion&&""===o.latestVersion)return t.push(n),nr.log(`${dn()} ${n} 本地 ${o.localVersion} 请求错误`),r(!0);if(s===o.onlineVersion){const e=`${n} 的本地${i} 安装版本为 ${s} 最新是 ${o.onlineVersion} `;return""===o.latestVersion?(nr.run(cn()+e),r(!0)):(pr.preReleaseDependence.push(n),nr.log(`${cn()} ${e};最新预发布版本为 ${be(o.latestVersion)}`),r(!0))}if(s===o.latestVersion)return nr.log(`${cn()} ${n} 的本地版本${i} 安装版本为 ${s}`),r(!0);const a=`${n} 的本地 ${be(i)} 安装版本为 ${be(s)} 最新是 ${ir(o.onlineVersion)} `;pr.latestDependence.push(n),""===o.latestVersion?(nr.log(cn()+a),r(!0)):(pr.preReleaseDependence.push(n),nr.log(`${cn()} ${a};最新预发布版本为 ${be(o.latestVersion)}`),r(!0))})()}));return Promise.all(r).then(()=>{nr.destroyed()})}async function Pr(){const{local:e,preReleaseDependence:t,latestDependence:n,dependenceList:r,timeoutDependence:o}=pr;if(S(e))return;const{dependencies:i,devDependencies:s}=e;if(pr.binning(i),pr.binning(s,!0),await Lr(),0===t.length&&0===n.length&&0===o.length)return lt(sr`看起来似乎没有依赖版本差异`);if(0===t.length&&0===n.length)return lt(me`看起来网络不太好讷,所有的包线上版本的请求都出错了。或者是还没有执行 npm install 呐`);lt(ge.brightGreen`\n版本差异的依赖为:\n`);const a=[...n,...t];new Tr({header:[$e("包名"),{content:"发布时间",color:"#f26"},be`最新版本`],body:[...a.map(e=>{const{type:t,latestVersion:n,time:o,onlineVersion:i}=r[e];return["dependencies"===t?je(e):Se(e),Pe(o),n||Se(i)]})]})(),lt(ge.brightRed(`\n目前仅关注版本号是否为最新 ${ge.brightMagenta("latest")}`)),lt(`使用 ${Dr} 命令安装更新\n`),o.length>0&&(lt(Fe(me`有一些包没有返回结果,请注意:`)),new Tr([...o.map(e=>[e])])());const c=[...n.filter(e=>!1===t.includes(e)).map(e=>ge.bold(e).concat("@latest")),...t.map(e=>Mr(e,r[e].tag))],l=n.map(e=>Ar(e)),u=[...n.map(e=>Ar(e)),...t.filter(e=>!1===n.includes(e)).map(e=>Mr(e,r[e].tag))],f=c.length<t.length+n.length,d=t.length>0,h=n.length>0;d&&(f&&await Br({msg:"‼️ 预发布版本优先:",list:c,type:"brightRed"}),await Br({msg:"⚠️ latest 版本优先:",list:u,type:"brightMagenta",copy:!h})),h&&await Br({msg:"🎉 最佳安装:",list:l,type:"brightGreen",copy:!0})}function Mr(e,t){return`${Se(e)}@${Se.random(t)}`}function Ar(e){return`${je(e)}@${rr`latest`}`}async function Br(e){const{msg:t,list:n,type:r,copy:o}=e,i=ge[r];lt(),lt(i.reversed(t),!1),lt(o?sr.reversed`已复制到剪切板 📋`:""),lt(),lt(`${i(Dr)} ${Te(Rr)}\n${function(e){if(!R(e)||e.some(e=>!w(e)))throw new TypeError("参数必须为字符串数组");return e.map((t,n)=>n%3==2&&n!==e.length-1?`${t} ${Te(Rr)}\n`:t.concat(" ")).join("")}(n)}`),lt(),o&&tr(`${Dr} ${n.join(" ")}`.replace(Z(),""))}async function Fr(e){pr.registry=e[0]?.toString()||void 0,await async function(){const e=Ye("package.json","file");if(O(e))return void Zn.warn("未找到当前包的 package.json 文件的位置");const t=Xe(Ue(e,"package.json"));if(S(t))return void Zn.error("未找到当前包的 package.json 文件,该事件发生的概率极低");const n=t.name||"",r=await Rt(n,pr.registry,9800);pr.local=t,pr.online=r.data}();const{local:t,online:n}=pr,r=t?.version||"",o=n?.version||"";if(S(t))return Zn("未找到包 package.json 文件退出"),lt(or("未找到当前包 package.json"));const i=or(`当前包本地版本为: ${r}`);if(n){lt(i);const e=" ".repeat(6);lt(ir(`${e}线上版本为:${o}@latest`));const t=new Date(n&&n.time.modified||"").toLocaleString();er.INFO(`最后的发布时间为: ${t.toString()}`),ut()}await Pr()}async function Wr(e=!0){const t=Ye("package.json","file");if(null==t)return lt("当前目录下不存在 package.json 文件");const n=Xe(Ue(t,"package.json"))?.dependencies||{};if(e&&lt(be("初始化完成,等待下一步命令")),Object.keys(n).length>0){let e="npm install --save";for(let t=Object.keys(n),r=t.length,o=0;o<r;o++){e+=` ${t[o]}@latest `}await Tt(e)}var r;e&&lt($e("正在更新 dev 依赖")),await Tt("npm update --save"),e&&(r="开发依赖更新完毕",bt(),mt(),lt(r))}async function Vr(e){e["--upDependencies"]?await Wr(!0):e["--diff"]?await Fr(e["--diff"]):er.help("package")}const qr={log:!1,subdirectories:!1};function zr(e,t){lt(`清理 ${e} 文件${t?"完成":"失败"}`)}async function _r(e,t){qr.log||lt(De("#aaa")(` ${e} 文件/夹存在,准备删除`));let n={error:null};return _?t.isDirectory()?(n=await Tt(`rd /q /s ${e.replace(/\//,"\\")}`),zr(e,n.success)):t.isFile()&&(n=await Tt(`del ${qr.subdirectories?"/s":""} /q ${e.replace(/\//,"\\")}`),zr(e,n.success)):(n=await Tt(`rm -rf ${e.replace(/\\/,"/")}`),zr(e,n.success)),!!n.success||(console.log(n.error),!1)}async function Gr(e,t,n=5){return!await Reflect.apply(e,void 0,t)&&n--?(lt(be("执行失败,现在重试中")),Zn.warn(t,"执行失败,第",5-n,"次执行"),await Gr(e,t,n)):await Reflect.apply(e,void 0,t)}async function Jr(e){qr.log||lt(De("#336")(`当前清理文件为 ${e}`));const t=Ke(e);qr.log||lt(De("#666")(`正在检测 ${e} 文件/夹是否存在`)),Zn(`文件${e} 数据为 ${t}`),O(t)?qr.log||lt(we(`${e} 文件不存在`)):await Gr(_r,[e,t])}const Hr={log:!0};async function Ur(e){Boolean(e["--dependencies"])&&await Wr(Hr.log)}const Kr=er.args.$arrMap;Zn(Kr),Zn(er.args.$original),er.args.$isVoid?(Zn("没有匹配到子命令,打印帮助信息并退出"),er.help(),er.end()):D(er.args.$only)&&(console.log(`${er.args.$nomatch.map(e=>Pe(e)).join("、")} 不是有效的参数`),er.end());try{await async function e(){if(0===Kr.length)return;const t=Kr.shift();if(O(t))return await e();t.remove?(Zn("执行文件移除"),await async function(e){const t=e.value||[],n=e.options;for(n?.forEach(e=>{const n=e["--ignore"];n&&(qr.log=!0,t.concat(n));const r=e["--subdirectories"];r&&(qr.subdirectories=!0,t.concat(r))}),qr.log||lt(ge.brightCyan`当前系统为: ${_?"windows":"linux/mac"}`),0==t.length&&(Zn.warn("待删除列表",t),lt(ge.random`没有待清理的文件/文件夹`));t.length;){let e=t.pop();e=void 0===e?"undefined":e.toString(),await Jr(e)}}(t.remove)):t.clearScreen||t.clearTerminal?(Zn("执行清屏"),await async function(){Qe()?(Zn("执行第一遍清理"),await Tt({code:_?"cls":"clear",printLog:!1}),Zn("执行第二遍清理"),ht("3J"),ht("c",!1),bt(1/0),mt(!0)):(Zn.warn("当前系统不支持 TTY"),lt("当前环境不支持 "))}()):t.git?(Zn("执行 git 相关命令"),await async function(e){if(N(e)&&(e={value:[]}),O(e.options)||0===e.options.length)return Zn.warn("没有配置项,直接返回的帮助文档"),er.help("git");const t=e.options;for(let e=0,n=t.length;e<n;e++)Zn("本次执行",t[e]),await hr(t[e])}(t.git)):t.package?(Zn("执行 package 相关命令"),await async function(e){if(O(e.options)||0==e.options.length)return Zn.warn("没有参数输入"),er.help("package");const t=e.options;for(let e=0,n=t.length;e<n;e++)await Vr(t[e])}(t.package)):t.update?(Zn("执行 update 相关命令"),await async function(e){if(O(e.options)||0==e.options.length)return Zn.warn("没有匹配到选项,自动抛出帮助文档"),er.help("update");const t=e.options;Hr.log=!t.some(e=>e["--ignore"]);for(let e=0,n=t.length;e<n;e++)await Ur(t[e])}(t.update)):t.dns?(Zn("执行 dns 相关的命令"),await fr(t.dns)):t.runOtherCode&&(Zn("执行运行其他命令"),await async function(e){const{value:t}=e;if(O(t)||C(t.length))return;for(const e in t){const n=t[e].toString(),r=n.indexOf("=");if(-1===r)break;if(0===r){er.ERROR(`未识别 "${n}" 且已移除该项 ❌`),t[e]="";continue}const[o,i]=[n.slice(0,r),n.slice(r+1)||"true"];process.env[o]=i,er.SUCCESS(`设置环境变量 ${o}=${i} ✅`),t[e]=""}const n=t.join(" ").trim();Zn("执行代码",n);const r=u(n,[],{stdio:"inherit",env:process.env,shell:!0});r.on("close",e=>e),r.on("error",e=>e),r.on("exit",e=>e)}(t.runOtherCode));try{await e()}catch(e){Zn.error("执行 run 报错",e)}}(),ut(" 终结分割线 ",!0)}catch(e){Zn.error("执行 run 报错",e)}
package/package.json CHANGED
@@ -1,45 +1,49 @@
1
1
  {
2
2
  "name": "jja",
3
3
  "type": "module",
4
- "version": "2.3.21",
5
- "description": "一些在终端的执行动作 🥜",
6
- "license": "MIT",
7
- "dependencies": {
8
- "@color-pen/static": "^1.0.1",
9
- "@qqi/copy-text": "^1.0.7",
10
- "@qqi/log": "^0.1.1",
11
- "a-command": "^2.3.16",
12
- "a-js-tools": "^1.0.12",
13
- "a-node-tools": "^4.2.20",
14
- "a-type-of-js": "^1.0.7",
15
- "color-pen": "^2.0.13",
16
- "colored-table": "^0.1.0"
17
- },
4
+ "version": "2.4.0",
18
5
  "author": {
19
- "name": "🥜",
20
- "email": "earthnut.dev@outlook.com",
6
+ "name": "泥豆君",
7
+ "email": "Mr.MudBean@outlook.com",
21
8
  "url": "https://earthnut.dev"
22
9
  },
10
+ "description": "一些在终端的执行动作 🥜",
11
+ "license": "MIT",
23
12
  "files": [
24
- "bin.mjs"
13
+ "bin.js",
14
+ "LICENSE",
15
+ "README.md",
16
+ "THIRD-PARTY-LICENSES.txt"
25
17
  ],
26
18
  "keywords": [
27
- "jja"
19
+ "jja",
20
+ "remove file",
21
+ "Remove file across platforms",
22
+ "Environmental parameters start",
23
+ "Check dependency for the latest version",
24
+ "Check domain resolution and connectivity",
25
+ "跨端移除文件",
26
+ "参数启动",
27
+ "检测依赖最新版本",
28
+ "检测域名解析及联通性"
28
29
  ],
29
- "repository": {
30
- "type": "git",
31
- "url": "git+https://github.com/earthnutDev/jja.git"
32
- },
33
30
  "homepage": "https://earthnut.dev/npm/jja",
34
31
  "bugs": {
35
- "url": "https://github.com/earthnutDev/jja/issues",
36
- "email": "earthnut.dev@outlook.com"
32
+ "url": "https://github.com/MrMudBean/jja/issues",
33
+ "email": "Mr.MudBean@outlook.com"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/MrMudBean/jja.git"
37
38
  },
38
39
  "publishConfig": {
39
40
  "access": "public",
40
41
  "registry": "https://registry.npmjs.org/"
41
42
  },
42
43
  "bin": {
43
- "jja": "bin.mjs"
44
+ "jja": "bin.js"
45
+ },
46
+ "engines": {
47
+ "node": ">=18.0.0"
44
48
  }
45
49
  }
package/bin.mjs DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{Dog as e}from"@qqi/log";import{isFalse as n,isUndefined as t,isArray as o,isString as i,isEmptyObject as r,isNull as s,isBusinessEmptyString as a,isPlainObject as c,isBoolean as l,isEmptyArray as p,isZero as u}from"a-type-of-js";import{Command as d,enPrefixList as g}from"a-command";import{redPen as m,hexPen as f,randomPen as $,greenPen as w,yellowPen as y,pen as h,strInOneLineOnTerminal as v,hidePen as b,cyanPen as j,boldPen as k,italicPen as D,reversedPen as S}from"color-pen";import{_p as V,isWindows as R,runOtherCode as O,fileExist as A,detectShell as E,detectPackageManager as P,cursorMoveUp as C,cursorAfterClear as q,getDirectoryBy as T,readFileToJsonSync as x,pathJoin as L,getNpmPkgInfo as N,waitingTips as M,colorLine as F,isTTY as G,__p as I,typewrite as U}from"a-node-tools";import X from"node:https";import{copyTextToClipboard as Y}from"@qqi/copy-text";import{terminalRegExp as _}from"@color-pen/static";import{Table as B}from"colored-table";import{intersection as H}from"a-js-tools";import J,{Resolver as W}from"node:dns";import z from"node:net";import{spawn as K}from"node:child_process";const Q=new e({name:"jja",type:!1}),Z=n(Q.type),ee=new d("jja");ee.bind({"package <pkg> (包管理)":["--diff <-d> (分析当下包的差异)","--upDependencies <-u> (更新依赖,强制更新到 'latest',使用需谨慎)"],"remove <rm> (做一个简单的兼容的移除文件或文件夹的命令)":["--ignore <-i> (不打印日志(默认打印的))","--subdirectories <-s> (这是一个危险的命令,用于 windows 下递归删除执行命令下所有的给定文件名称)"],"update <up> (做一个简单的 npm 升级程序,对,简单的)":["--ignore <-i> (不建议你这么用,你会发现你像个傻子一样在那等结果)",`--dependencies <-d> (更新依赖,跟 ${$("npm update")} 一样)`],"clearScreen <cls> (清理终端显示屏幕,同 clearTerminal )":"","clearTerminal <clear> (清理终端显示屏幕,同 clearScreen )":"","git (一些关于 git 的操作)":[`commit (git 提交代码,是 ${m("commit")} 提交啊,不是 ${f("#666")("push")} 推送)`,"merge (合并两个分支)","tag (给提交打上 tag)"],"dns (使用 dns 获取 ip 地址)":["--domain <-d> (获取给定域名获取 ip 地址,默认 github.com )","--port <-p> (配置要校验的 port 端口号,默认为 443)"],"runOtherCode <run> (执行其他的代码,使用 )":[]}).run(),Q("参数已绑定,且已解析用户参数",ee.args),Q.warn("当前的执行状态",ee.state),ee.isEnd(!0);const ne={log:!1,subdirectories:!1};async function te(e,n,t=5){return!await Reflect.apply(e,void 0,n)&&t--?(V(w("执行失败,现在重试中")),Q.warn(n,"执行失败,第",5-t,"次执行"),await te(e,n,t)):await Reflect.apply(e,void 0,n)}function oe(e,n){V(`清理 ${e} 文件${n?"完成":"失败"}`)}async function ie(e,n){ne.log||V(f("#aaa")(` ${e} 文件/夹存在,准备删除`));let t={error:null};return R?n.isDirectory()?(t=await O(`rd /q /s ${e.replace(/\//,"\\")}`),oe(e,t.success)):n.isFile()&&(t=await O(`del ${ne.subdirectories?"/s":""} /q ${e.replace(/\//,"\\")}`),oe(e,t.success)):(t=await O(`rm -rf ${e.replace(/\\/,"/")}`),oe(e,t.success)),!!t.success||(console.log(t.error),!1)}async function re(e){ne.log||V(f("#336")(`当前清理文件为 ${e}`));const n=A(e);ne.log||V(f("#666")(`正在检测 ${e} 文件/夹是否存在`)),Q(`文件${e} 数据为 ${n}`),t(n)?ne.log||V(y(`${e} 文件不存在`)):await te(ie,[e,n])}const se=R?"cmd"===E()?"^":"`":"\\";const ae=(()=>{const e=P();return"npm"===e?"npm install --save":"yarn"===e?"yarn add":"pnpm add"})();async function ce(e=!0){const n=T("package.json","file");if(null==n)return V("当前目录下不存在 package.json 文件");const t=x(L(n,"package.json"))?.dependencies||{};if(e&&V(w("初始化完成,等待下一步命令")),Object.keys(t).length>0){let e="npm install --save";for(let n=Object.keys(t),o=n.length,i=0;i<o;i++){e+=` ${n[i]}@latest `}await O(e)}var o;e&&V(j("正在更新 dev 依赖")),await O("npm update --save"),e&&(o="开发依赖更新完毕",C(),q(),V(o))}const le={log:!0};async function pe(e){Boolean(e["--dependencies"])&&await ce(le.log)}const ue={local:null,online:null,dependenceList:{},updateDependence:[],latestDependence:[],binning:function(e,n=!1){if(t(e)||r(e)||s(this.local))return;const{overrides:o}=this.local;for(const t in e){if(i(o?.[t])){ee.WARN(`${t} 被锁定在 ${o[t]}`);continue}const r=e[t];this.dependenceList[t]={type:n?"devDependencies":"dependencies",version:r,localVersion:"",latestVersion:"",onlineVersion:"",tag:"",time:""}}},preReleaseDependence:[],timeoutDependence:[],registry:void 0};const de=k.green,ge=f("0x993311"),me=f("0x339999"),fe=f("0x666666");const $e=M({show:!1,info:"请稍等",beforeDestroyed:e=>e&&ee.end()});async function we(){const e={"淘宝":"registry.npmmirror.com","官方":"registry.npmjs.org","腾讯":"mirrors.tencent.com/npm","中科大":"npmreg.proxy.ustclug.org",yarn:"registry.yarnpkg.com"},t=()=>Object.keys(e).map(n=>function(e){const n=Date.now();return new Promise(t=>{const o=`https://${e}/nry`,i=X.request(o,{method:"HEAD",timeout:3500},o=>{t((o?.statusCode??0)>=200&&(o?.statusCode??0)<300?{url:e,time:Date.now()-n,success:!0}:{url:e,time:Date.now()-n,success:!1})});i.on("error",()=>t({url:e,time:Date.now()-n,success:!1})),i.on("timeout",()=>{i.destroy(),t({url:e,time:Date.now()-n,success:!1})}),i.end()})}(e[n])),o={};for(let e=0;e<3;e++){$e.run(`请稍等,正在进行第${["一","二","三","四","五"][e]}次安装源延迟测试`);(await Promise.all(t())).forEach(e=>{n(e.success)||(o[e.url]?o[e.url]=(o[e.url]+e.time)/2:o[e.url]=e.time)})}return $e.destroyed(),Object.keys(e).reduce((n,t)=>o[e[t]]<(o[e[n]]??1/0)?t:n,"")}async function ye(){const{dependenceList:e,timeoutDependence:n}=ue,o=Object.keys(e);o.length>18&&(t(ue.registry)||!["官方","淘宝","腾讯","中科大","yarn"].some(e=>e===ue.registry))&&(ue.registry=await we(),V(`由于您未设置或者设置有误,现使用 ${j(ue.registry)} npm 源`));const i=o.map(t=>new Promise(o=>{(async()=>{const i=e[t],r=e[t].version;$e.run(`${g.current()}获取 ${t} 的本地安装信息`);const a=function(e){const n=x(L("node_modules/",e,"package.json"));let t="";return t=s(n)?"":n.version||"",ue.dependenceList[e].localVersion=t,Q(e,"本地安装的版本为:",t),t}(t);if($e.run(`${g.success()} ${t} 的本地安装版本:${i.localVersion}`),await async function(e){const n=await N(e,ue.registry,9867);if("timeout"===n.status)return void Q.warn("请求超时");if(s(n.data))return void Q.warn("获取包信息失败");const t=Date.now();Q("获取数据",e,"包信息");const o=ue.dependenceList[e],{"dist-tags":i,time:r,version:a}=n.data;let c=a,l="latest";o.onlineVersion=c,o.tag=l;const p=Object.keys(i);Q("共需比对",p.length);for(let e=0,n=p.length;e<n;e++){const n=p[e],t=i[n];r[t]>r[c]&&(c=t,l=n)}Q("比对",e,"完成"),Q("耗时",Date.now()-t),"latest"!==l&&(Q(e,"最新版本为:",c,"tag为:",l),o.tag=l,o.latestVersion=c);const u=new Date(r[c]).toLocaleString();o.time=u,Q(`${e} 的最后发布时间为:${u}`)}(t),""===i.onlineVersion&&""===i.latestVersion)return n.push(t),$e.log(`${g.error()} ${t} 本地 ${i.localVersion} 请求错误`),o(!0);if(a===i.onlineVersion){const e=`${t} 的本地${r} 安装版本为 ${a} 最新是 ${i.onlineVersion} `;return""===i.latestVersion?($e.run(g.info()+e),o(!0)):(ue.preReleaseDependence.push(t),$e.log(`${g.info()} ${e};最新预发布版本为 ${w(i.latestVersion)}`),o(!0))}if(a===i.latestVersion)return $e.log(`${g.info()} ${t} 的本地版本${r} 安装版本为 ${a}`),o(!0);const c=`${t} 的本地 ${w(r)} 安装版本为 ${w(a)} 最新是 ${me(i.onlineVersion)} `;ue.latestDependence.push(t),""===i.latestVersion?($e.log(g.info()+c),o(!0)):(ue.preReleaseDependence.push(t),$e.log(`${g.info()} ${c};最新预发布版本为 ${w(i.latestVersion)}`),o(!0))})()}));return Promise.all(i).then(()=>{$e.destroyed()})}async function he(e){const{msg:n,list:t,type:r,copy:s}=e,a=h[r];V(),V(a.reversed(n),!1),V(s?fe.reversed`已复制到剪切板 📋`:""),V(),V(`${a(ae)} ${b(se)}\n${function(e){if(!o(e)||e.some(e=>!i(e)))throw new TypeError("参数必须为字符串数组");return e.map((n,t)=>t%3==2&&t!==e.length-1?`${n} ${b(se)}\n`:n.concat(" ")).join("")}(t)}`),V(),s&&Y(`${ae} ${t.join(" ")}`.replace(_(),""))}function ve(e){return`${k(e)}@${de`latest`}`}function be(e,n){return`${D(e)}@${D.random(n)}`}async function je(){const{local:e,preReleaseDependence:n,latestDependence:t,dependenceList:o,timeoutDependence:i}=ue;if(s(e))return;const{dependencies:r,devDependencies:a}=e;if(ue.binning(r),ue.binning(a,!0),await ye(),0===n.length&&0===t.length&&0===i.length)return V(fe`看起来似乎没有依赖版本差异`);if(0===n.length&&0===t.length)return V(m`看起来网络不太好讷,所有的包线上版本的请求都出错了。或者是还没有执行 npm install 呐`);V(h.brightGreen`\n版本差异的依赖为:\n`);const c=[...t,...n];var l;new B({header:[j("包名"),{content:"发布时间",color:"#f26"},w`最新版本`],body:[...c.map(e=>{const{type:n,latestVersion:t,time:i,onlineVersion:r}=o[e];return["dependencies"===n?k(e):D(e),$(i),t||D(r)]})]})(),V(h.brightRed(`\n目前仅关注版本号是否为最新 ${h.brightMagenta("latest")}`)),V(`使用 ${ae} 命令安装更新\n`),i.length>0&&(l=m`有一些包没有返回结果,请注意:`,V(v(l)),new B([...i.map(e=>[e])])());const p=[...t.filter(e=>!1===n.includes(e)).map(e=>h.bold(e).concat("@latest")),...n.map(e=>be(e,o[e].tag))],u=t.map(e=>ve(e)),d=[...t.map(e=>ve(e)),...n.filter(e=>!1===t.includes(e)).map(e=>be(e,o[e].tag))],g=p.length<n.length+t.length,f=n.length>0,y=t.length>0;f&&(g&&await he({msg:"‼️ 预发布版本优先:",list:p,type:"brightRed"}),await he({msg:"⚠️ latest 版本优先:",list:d,type:"brightMagenta",copy:!y})),y&&await he({msg:"🎉 最佳安装:",list:u,type:"brightGreen",copy:!0})}async function ke(e){ue.registry=e[0]?.toString()||void 0,await async function(){const e=T("package.json","file");if(t(e))return void Q.warn("未找到当前包的 package.json 文件的位置");const n=x(L(e,"package.json"));if(s(n))return void Q.error("未找到当前包的 package.json 文件,该事件发生的概率极低");const o=n.name||"",i=await N(o,ue.registry,9800);ue.local=n,ue.online=i.data}();const{local:n,online:o}=ue,i=n?.version||"",r=o?.version||"";if(s(n))return Q("未找到包 package.json 文件退出"),V(ge("未找到当前包 package.json"));const a=ge(`当前包本地版本为: ${i}`);if(o){V(a);const e=" ".repeat(6);V(me(`${e}线上版本为:${r}@latest`));const n=new Date(o&&o.time.modified||"").toLocaleString();ee.INFO(`最后的发布时间为: ${n.toString()}`),F()}await je()}async function De(e){e["--upDependencies"]?await ce(!0):e["--diff"]?await ke(e["--diff"]):ee.help("package")}async function Se(e){const n=T("package.json","file",process.cwd());if(null==n)return!0;const t=x(L(n,"package.json"));if(s(t)||!t.version)return!0;const o=t.version;await O({code:`git tag -a v${o} -m '${e}'`,cwd:n}),await O({code:"git push origin --tag",cwd:n})}async function Ve(e){e.commit?await async function(e="版本维护",n=!1){const t=T(".git","directory");if(null==t)return V(f("#ff0")("not a git repository(当前目录非 git 储存库)"));const o=await O({code:"git add .",cwd:t});if(!o.success)return null!=console.log(o.error);const i=await O({code:"git status",cwd:t});if(!/nothing to commit, working tree clean/.test(i.data||"")){const o=await O({code:"git add .",cwd:t});if(!o.success)return null!=console.log(o.error);""==e.trim()&&(e=await ee.question({text:"请输入提交信息"})??"");const i=await O({code:`git commit -m "${e}"`,cwd:t});return i.success?(i.error&&console.log(i.error),await O({code:"git push",cwd:t}),n&&await Se(e),!0):null!=console.log(i.error)}return!1}(e.commit.join(" ")):e.merge?await async function(e){if(a(e)){const n=await O("git branch -a");console.log(n.data),e=await ee.question({text:"请输入要合并分支的名称"})??""}if(a(e))return ee.ERROR("没有获取到要合并的分支");const n=await ee.selection({data:[{label:"正常快进合并",value:""},{label:"非快进合并 (--no-ff)",value:"--no-ff"},{label:"多提交记录合并为一条 (--squash)",value:"--squash",tip:"适用于将众多小的提交合并成一个提交"}]});t(n)?ee.ERROR("您选择退出合并"):await O(`git merge ${e} ${n}`)}(e.merge.join("")):e.tag?await async function(){const e=await ee.question({text:"请输入待标记的信息"});t(e)||await Se(e)}():ee.help("git")}const Re=["A","AAAA","ANY","CAA","CNAME","MX","NAPTR","NS","PTR","SOA","SRV","TLSA","TXT"],Oe={domain:"github.com",port:443,dnsServers:["1.1.1.1","8.8.8.8","8.8.4.4","208.67.222.222","114.114.115.115","223.5.5.5","180.76.76.76"],ips:{},rrtype:["A"],reset(e){this.ips={},this.domain="github.com",this.port=443,this.rrtype=[],t(e)||e.forEach(e=>{const n=e["--domain"];!t(n)&&n.length>0&&(this.domain=n[0].toString());const o=e["--port"];!t(o)&&o.length>0&&(this.port=Number(o[0]));const i=e["--rrtype"];if(!t(i)&&i.length>0){const e=H(Re,i);e.length>0&&(this.rrtype=e)}})},noCopy:!0};async function Ae(e){return Promise.all(e.map(e=>async function(e,n=3e3){const{ips:t,port:o}=Oe;if(l(t[e]))return Z||$e.log(`${e} 联通性已校验过 ${t[e]?"🔥":"⛓️‍💥"}`),Promise.resolve(null);t[e]=!1,Z||$e.log(`校验 ${e} 的联通性`);return new Promise(i=>{const r=new z.Socket,s=(n=!1)=>{t[e]=n,r.destroy(),i(null)};r.setTimeout(n),r.on("connect",()=>s(!0)),r.on("timeout",()=>s()),r.on("error",()=>s()),Z||$e.log("测试的接口为:",o),r.connect(o,e)})}(e)))}async function Ee(e="1.1.1.1"){const{domain:n}=Oe;try{const t=await async function(e,n){return new Promise(t=>{const o=new W;$e.run(`使用 ${n} 获取 ${e} 的 ip`),o.setServers([n]),o.resolve4(e,(o,i)=>{if(o)return Z||$e.run(`使用 ${n} 获取 ${e} 的 ip 出错`),t(null);Z||$e.log(`使用 ${n} 获取 ${e} 的 ip 值为 ${i.join(" --- ")}`),t(i)})})}(n,e);if(s(t))return Z||$e.log(`${e} 获取 ${n} 的 ip 失败`),0;const o=(await Ae(t)).filter(e=>!s(e));return p(o)?0:($e.destroyed(),V(),V(S`DNS: ${e}`),V(),o.forEach(({ip:e,isAlive:n})=>{const t=n?`${w(e)} ${ge`->`} ✅`:`${fe(e)} ${m`⛓️‍💥`} ❌`;V(v(t))}),3+o.length)}catch(e){return Z||$e.log("'获取 ip 错误'",e),0}}async function Pe(){const{domain:e,ips:n}=Oe;$e.run(`正在获取本地的 ${e} 的 ip 地址`);try{const t=await async function(e){return new Promise(n=>{J.lookup(e,{all:!0,family:4},(t,o)=>{if(t)return Q.error(`获取本地 ${e} 的 ip 出错`,t),void n(null);Z||$e.log(`获取本地 ${e} 的 ip 值为 ${o.join(" --- ")}`),n(o.map(e=>e.address))})})}(e);if(s(t))return;await Ae(t),r(n)||function(e){const{ips:n}=Oe;V(ge`本地配置 ${e} 的 ip 地址及联通性为:\n`),Object.keys(n).forEach(e=>{const t=n[e];t&&(Oe.noCopy=!1),V(j`- ${e}`,!1),V(t?ge` -> ✅`:fe` -> ❌`)}),V()}(e)}catch(e){Q.error(e)}}async function Ce(e){Oe.reset(e.options),await Pe(),await async function(){const{domain:e,dnsServers:n}=Oe;$e.log(`${e} ip 列表:`);const t=n.map(e=>Ee(e)),o=await Promise.all(t);Z&&(C(o.reduce((e,n)=>e+n,0)+1),q(!0))}(),$e.destroyed();const{ips:n}=Oe;Object.keys(n).length>0?await async function(){const{domain:e,ips:n,port:t}=Oe;await U(`${h.brightMagenta`${e}`} 域名解析结果:`),V();let o=Oe.noCopy;for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)){const i=n[t],r=i?`${w`- ${t.padEnd(16)}`} ${ge`->`} ✅${o?j`(已复制)`:""}`:`${fe`- ${t.padEnd(16)}`} ${m`⛓️‍💥`} ❌`;V(r),i&&o&&(Y(`${t} ${e}`),o=!1)}V(),await U(m.italic.dim`${e} 联通性接口判断为 ${t.toString()}`),V()}():await async function(){const{domain:e,port:n}=Oe;await U(`\n找不到 ${m(e)} 的服务器 IP 地址 ${fe`测试使用 ${n.toString()} 端口`}\n`)}()}const qe=ee.args.$arrMap;Q(qe),Q(ee.args.$original),ee.args.$isVoid?(Q("没有匹配到子命令,打印帮助信息并退出"),ee.help(),ee.end()):p(ee.args.$only)&&(console.log(`${ee.args.$nomatch.map(e=>$(e)).join("、")} 不是有效的参数`),ee.end());try{await async function e(){if(0===qe.length)return;const n=qe.shift();if(t(n))return await e();n.remove?(Q("执行文件移除"),await async function(e){const n=e.value||[],t=e.options;for(t?.forEach(e=>{const t=e["--ignore"];t&&(ne.log=!0,n.concat(t));const o=e["--subdirectories"];o&&(ne.subdirectories=!0,n.concat(o))}),ne.log||V(h.brightCyan`当前系统为: ${R?"windows":"linux/mac"}`),0==n.length&&(Q.warn("待删除列表",n),V(h.random`没有待清理的文件/文件夹`));n.length;){let e=n.pop();e=void 0===e?"undefined":e.toString(),await re(e)}}(n.remove)):n.clearScreen||n.clearTerminal?(Q("执行清屏"),await async function(){G()?(Q("执行第一遍清理"),await O({code:R?"cls":"clear",printLog:!1}),Q("执行第二遍清理"),I("3J"),I("c",!1),C(1/0),q(!0)):(Q.warn("当前系统不支持 TTY"),V("当前环境不支持 "))}()):n.git?(Q("执行 git 相关命令"),await async function(e){if(c(e)&&(e={value:[]}),t(e.options)||0===e.options.length)return Q.warn("没有配置项,直接返回的帮助文档"),ee.help("git");const n=e.options;for(let e=0,t=n.length;e<t;e++)Q("本次执行",n[e]),await Ve(n[e])}(n.git)):n.package?(Q("执行 package 相关命令"),await async function(e){if(t(e.options)||0==e.options.length)return Q.warn("没有参数输入"),ee.help("package");const n=e.options;for(let e=0,t=n.length;e<t;e++)await De(n[e])}(n.package)):n.update?(Q("执行 update 相关命令"),await async function(e){if(t(e.options)||0==e.options.length)return Q.warn("没有匹配到选项,自动抛出帮助文档"),ee.help("update");const n=e.options;le.log=!n.some(e=>e["--ignore"]);for(let e=0,t=n.length;e<t;e++)await pe(n[e])}(n.update)):n.dns?(Q("执行 dns 相关的命令"),await Ce(n.dns)):n.runOtherCode&&(Q("执行运行其他命令"),await async function(e){const{value:n}=e;if(t(n)||u(n.length))return;for(const e in n){const t=n[e].toString(),o=t.indexOf("=");if(-1===o)break;if(0===o){ee.ERROR(`未识别 "${t}" 且已移除该项 ❌`),n[e]="";continue}const[i,r]=[t.slice(0,o),t.slice(o+1)||"true"];process.env[i]=r,ee.SUCCESS(`设置环境变量 ${i}=${r} ✅`),n[e]=""}const o=n.join(" ").trim();Q("执行代码",o);const i=K(o,[],{stdio:"inherit",env:process.env,shell:!0});i.on("close",e=>e),i.on("error",e=>e),i.on("exit",e=>e)}(n.runOtherCode));try{await e()}catch(e){Q.error("执行 run 报错",e)}}(),F(" 终结分割线 ",!0)}catch(e){Q.error("执行 run 报错",e)}