stackkit 0.3.5 → 0.3.6
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/README.md +50 -42
- package/dist/cli/add.js +122 -56
- package/dist/cli/create.d.ts +2 -0
- package/dist/cli/create.js +271 -95
- package/dist/cli/doctor.js +1 -0
- package/dist/cli/list.d.ts +1 -1
- package/dist/cli/list.js +6 -4
- package/dist/index.js +234 -191
- package/dist/lib/constants.d.ts +4 -0
- package/dist/lib/constants.js +4 -0
- package/dist/lib/discovery/module-discovery.d.ts +4 -0
- package/dist/lib/discovery/module-discovery.js +56 -0
- package/dist/lib/generation/code-generator.d.ts +11 -2
- package/dist/lib/generation/code-generator.js +42 -3
- package/dist/lib/generation/generator-utils.js +3 -1
- package/dist/lib/pm/package-manager.js +16 -13
- package/dist/lib/ui/logger.js +3 -2
- package/dist/lib/utils/path-resolver.d.ts +2 -0
- package/dist/lib/utils/path-resolver.js +8 -0
- package/dist/meta.json +8312 -0
- package/modules/auth/better-auth/files/{shared → express}/config/env.ts +48 -50
- package/modules/auth/better-auth/files/express/middlewares/authorize.ts +20 -1
- package/modules/auth/better-auth/files/express/modules/auth.controller.ts +349 -0
- package/modules/auth/better-auth/files/express/modules/{auth/auth.route.ts → auth.route.ts} +9 -4
- package/modules/auth/better-auth/files/express/modules/auth.service.ts +664 -0
- package/modules/auth/better-auth/files/express/modules/{auth/auth.type.ts → auth.type.ts} +22 -9
- package/modules/auth/better-auth/files/{shared/mongoose/auth/helper.ts → express/mongo-modules/auth.helper.ts} +11 -1
- package/modules/auth/better-auth/files/express/types/express.d.ts +11 -0
- package/modules/auth/better-auth/files/nextjs/api-route.ts +74 -0
- package/modules/auth/better-auth/files/nextjs/dashboard/pages/(user)/page.tsx +6 -0
- package/modules/auth/better-auth/files/nextjs/dashboard/pages/admin/page.tsx +6 -0
- package/modules/auth/better-auth/files/nextjs/dashboard/pages/layout.tsx +48 -0
- package/modules/auth/better-auth/files/nextjs/dashboard/pages/my-profile/page.tsx +5 -0
- package/modules/auth/better-auth/files/nextjs/features/services/auth.service.ts +102 -0
- package/modules/auth/better-auth/files/nextjs/layout/layout.tsx +13 -0
- package/modules/auth/better-auth/files/nextjs/lib/axios/http.ts +158 -0
- package/modules/auth/better-auth/files/nextjs/lib/env.ts +35 -0
- package/modules/auth/better-auth/files/nextjs/lib/utils/auth.ts +75 -0
- package/modules/auth/better-auth/files/nextjs/lib/utils/cookie.ts +29 -0
- package/modules/auth/better-auth/files/nextjs/lib/utils/jwt.ts +28 -0
- package/modules/auth/better-auth/files/nextjs/lib/utils/token.ts +49 -0
- package/modules/auth/better-auth/files/nextjs/pages/forgot-password/page.tsx +5 -0
- package/modules/auth/better-auth/files/nextjs/pages/layout.tsx +11 -0
- package/modules/auth/better-auth/files/nextjs/pages/login/page.tsx +9 -0
- package/modules/auth/better-auth/files/nextjs/pages/register/page.tsx +5 -0
- package/modules/auth/better-auth/files/nextjs/pages/reset-password/page.tsx +10 -0
- package/modules/auth/better-auth/files/nextjs/pages/verify-email/page.tsx +10 -0
- package/modules/auth/better-auth/files/nextjs/proxy.ts +154 -42
- package/modules/auth/better-auth/files/nextjs/theme/providers/theme-provider.tsx +11 -0
- package/modules/auth/better-auth/files/nextjs/types/api.types.ts +18 -0
- package/modules/auth/better-auth/files/react/components/protected-route.tsx +39 -0
- package/modules/auth/better-auth/files/react/components/route-guards.tsx +13 -0
- package/modules/auth/better-auth/files/react/dashboard/admin/pages/overview.tsx +3 -0
- package/modules/auth/better-auth/files/react/dashboard/pages/overview.tsx +3 -0
- package/modules/auth/better-auth/files/react/features/pages/forgot-password.tsx +5 -0
- package/modules/auth/better-auth/files/react/features/pages/login.tsx +5 -0
- package/modules/auth/better-auth/files/react/features/pages/my-profile.tsx +5 -0
- package/modules/auth/better-auth/files/react/features/pages/oauth-callback.tsx +59 -0
- package/modules/auth/better-auth/files/react/features/pages/register.tsx +5 -0
- package/modules/auth/better-auth/files/react/features/pages/reset-password.tsx +10 -0
- package/modules/auth/better-auth/files/react/features/pages/verify-email.tsx +10 -0
- package/modules/auth/better-auth/files/react/layout/dashboard-layout.tsx +54 -0
- package/modules/auth/better-auth/files/react/lib/axios/http.ts +68 -0
- package/modules/auth/better-auth/files/react/lib/env.ts +25 -0
- package/modules/auth/better-auth/files/react/router.tsx +73 -0
- package/modules/auth/better-auth/files/react/theme/components/providers/theme-provider-context.ts +13 -0
- package/modules/auth/better-auth/files/react/theme/components/providers/theme-provider.tsx +51 -0
- package/modules/auth/better-auth/files/react/theme/hooks/use-theme.ts +8 -0
- package/modules/auth/better-auth/files/shared/features/components/change-password-dialog.tsx +113 -0
- package/modules/auth/better-auth/files/shared/features/components/forgot-password-form.tsx +84 -0
- package/modules/auth/better-auth/files/shared/features/components/login-form.tsx +134 -0
- package/modules/auth/better-auth/files/shared/features/components/my-profile.tsx +147 -0
- package/modules/auth/better-auth/files/shared/features/components/profile-form.tsx +205 -0
- package/modules/auth/better-auth/files/shared/features/components/register-form.tsx +100 -0
- package/modules/auth/better-auth/files/shared/features/components/reset-password-form.tsx +111 -0
- package/modules/auth/better-auth/files/shared/features/components/social-login-buttons.tsx +47 -0
- package/modules/auth/better-auth/files/shared/features/components/user-profile-menu.tsx +106 -0
- package/modules/auth/better-auth/files/shared/features/components/verify-email-form.tsx +110 -0
- package/modules/auth/better-auth/files/shared/features/queries/auth.mutations.tsx +312 -0
- package/modules/auth/better-auth/files/shared/features/queries/auth.querie.ts +19 -0
- package/modules/auth/better-auth/files/shared/features/services/auth.api.ts +81 -0
- package/modules/auth/better-auth/files/shared/features/types/auth.type.ts +47 -0
- package/modules/auth/better-auth/files/shared/features/validators/change-password.validator.ts +18 -0
- package/modules/auth/better-auth/files/shared/features/validators/forgot.validator.ts +7 -0
- package/modules/auth/better-auth/files/shared/features/validators/login.validator.ts +14 -0
- package/modules/auth/better-auth/files/shared/features/validators/profile.validator.ts +8 -0
- package/modules/auth/better-auth/files/shared/features/validators/register.validator.ts +9 -0
- package/modules/auth/better-auth/files/shared/features/validators/reset.validator.ts +9 -0
- package/modules/auth/better-auth/files/shared/features/validators/verify.validator.ts +8 -0
- package/modules/auth/better-auth/files/shared/lib/auth-client.ts +2 -1
- package/modules/auth/better-auth/files/shared/lib/auth.ts +5 -19
- package/modules/auth/better-auth/files/shared/lib/constant/dashboard.ts +90 -0
- package/modules/auth/better-auth/files/shared/theme/mode-toggle.tsx +30 -0
- package/modules/auth/better-auth/files/shared/ui/shadcn/components/dashboard/dashboard-header.tsx +94 -0
- package/modules/auth/better-auth/files/shared/ui/shadcn/components/dashboard/dashboard-sidebar.tsx +255 -0
- package/modules/auth/better-auth/files/shared/ui/shadcn/components/footer.tsx +35 -0
- package/modules/auth/better-auth/files/shared/ui/shadcn/components/navbar.tsx +145 -0
- package/modules/auth/better-auth/files/shared/ui/shadcn/form-field/input-field.tsx +440 -0
- package/modules/auth/better-auth/files/shared/utils/email.ts +2 -17
- package/modules/auth/better-auth/generator.json +172 -51
- package/modules/auth/better-auth/module.json +2 -2
- package/modules/components/files/shared/hooks/use-file-upload.ts +412 -0
- package/modules/components/files/shared/lib/utils/url-helpers.ts +110 -0
- package/modules/components/files/shared/shadcn/dashboard/data-table-column-selector.tsx +52 -0
- package/modules/components/files/shared/shadcn/dashboard/data-table-footer.tsx +156 -0
- package/modules/components/files/shared/shadcn/dashboard/data-table.tsx +405 -0
- package/modules/components/files/shared/shadcn/global/form-field/input-field.tsx +440 -0
- package/modules/components/files/shared/shadcn/global/form-field/media-uploader-field.tsx +745 -0
- package/modules/components/files/shared/shadcn/global/form-field/multi-select-field.tsx +207 -0
- package/modules/components/files/shared/shadcn/global/form-field/select-field.tsx +247 -0
- package/modules/components/files/shared/shadcn/global/form-field/textarea-field.tsx +277 -0
- package/modules/components/files/shared/shadcn/global/form-field/tiptap-editor-field.tsx +35 -0
- package/modules/components/files/shared/shadcn/global/no-results.tsx +41 -0
- package/modules/components/files/shared/shadcn/tiptap-editor/editor-menu-bar.tsx +217 -0
- package/modules/components/files/shared/shadcn/tiptap-editor/tiptap-editor.tsx +104 -0
- package/modules/components/files/shared/url/load-more.tsx +93 -0
- package/modules/components/files/shared/url/search-bar.tsx +131 -0
- package/modules/components/files/shared/url/sort-select.tsx +118 -0
- package/modules/components/files/shared/url/url-tabs.tsx +77 -0
- package/modules/components/generator.json +109 -0
- package/modules/components/module.json +11 -0
- package/modules/database/mongoose/generator.json +3 -14
- package/modules/database/mongoose/module.json +2 -2
- package/modules/database/prisma/generator.json +6 -12
- package/modules/database/prisma/module.json +2 -2
- package/modules/storage/cloudinary/files/express/config/env.ts +65 -0
- package/modules/storage/cloudinary/files/express/config/media.ts +103 -0
- package/modules/storage/cloudinary/files/express/modules/media/media.controller.ts +59 -0
- package/modules/storage/cloudinary/files/express/modules/media/media.route.ts +29 -0
- package/modules/storage/cloudinary/files/express/modules/media/media.service.ts +113 -0
- package/modules/storage/cloudinary/files/express/modules/media/media.type.ts +32 -0
- package/modules/storage/cloudinary/generator.json +34 -0
- package/modules/storage/cloudinary/module.json +11 -0
- package/modules/ui/shadcn/generator.json +21 -0
- package/modules/ui/shadcn/module.json +11 -0
- package/package.json +24 -26
- package/templates/express/README.md +11 -16
- package/templates/express/src/config/env.ts +7 -5
- package/templates/nextjs/README.md +13 -18
- package/templates/nextjs/app/favicon.ico +0 -0
- package/templates/nextjs/app/layout.tsx +6 -4
- package/templates/nextjs/components/providers/query-provider.tsx +3 -0
- package/templates/nextjs/env.example +3 -1
- package/templates/nextjs/lib/axios/http.ts +23 -0
- package/templates/nextjs/lib/env.ts +7 -5
- package/templates/nextjs/package.json +2 -1
- package/templates/nextjs/template.json +1 -2
- package/templates/react/README.md +9 -14
- package/templates/react/index.html +1 -1
- package/templates/react/package.json +1 -1
- package/templates/react/src/assets/favicon.ico +0 -0
- package/templates/react/src/components/providers/query-provider.tsx +38 -0
- package/templates/react/src/{shared/components → components}/seo.tsx +4 -8
- package/templates/react/src/lib/axios/http.ts +24 -0
- package/templates/react/src/main.tsx +8 -11
- package/templates/react/src/{features/about/pages → pages}/about.tsx +1 -1
- package/templates/react/src/{features/home/pages → pages}/home.tsx +1 -1
- package/templates/react/src/router.tsx +6 -6
- package/templates/react/src/vite-env.d.ts +2 -1
- package/templates/react/template.json +0 -1
- package/templates/react/tsconfig.app.json +6 -0
- package/templates/react/tsconfig.json +7 -1
- package/templates/react/vite.config.ts +12 -0
- package/modules/auth/authjs/files/nextjs/api/auth/[...nextauth]/route.ts +0 -3
- package/modules/auth/authjs/files/nextjs/proxy.ts +0 -1
- package/modules/auth/authjs/files/shared/lib/auth.ts +0 -119
- package/modules/auth/authjs/files/shared/prisma/schema.prisma +0 -61
- package/modules/auth/authjs/generator.json +0 -64
- package/modules/auth/authjs/module.json +0 -13
- package/modules/auth/better-auth/files/express/modules/auth/auth.controller.ts +0 -264
- package/modules/auth/better-auth/files/express/modules/auth/auth.service.ts +0 -549
- package/modules/auth/better-auth/files/express/templates/google-redirect.ejs +0 -24
- package/modules/auth/better-auth/files/nextjs/api/auth/[...all]/route.ts +0 -4
- package/modules/auth/better-auth/files/nextjs/lib/auth/auth-guards.ts +0 -31
- package/modules/auth/better-auth/files/nextjs/templates/email-otp.tsx +0 -74
- package/templates/nextjs/lib/api/http.ts +0 -40
- package/templates/react/public/vite.svg +0 -1
- package/templates/react/src/app/layouts/dashboard-layout.tsx +0 -8
- package/templates/react/src/app/layouts/public-layout.tsx +0 -5
- package/templates/react/src/app/providers.tsx +0 -20
- package/templates/react/src/app/router.tsx +0 -21
- package/templates/react/src/assets/react.svg +0 -1
- package/templates/react/src/shared/api/http.ts +0 -39
- package/templates/react/src/shared/components/loading.tsx +0 -8
- package/templates/react/src/shared/lib/query-client.ts +0 -12
- package/templates/react/src/utils/storage.ts +0 -35
- package/templates/react/src/utils/utils.ts +0 -3
- /package/modules/auth/better-auth/files/{shared/mongoose/auth/constants.ts → express/mongo-modules/auth.constants.ts} +0 -0
- /package/templates/nextjs/app/{page.tsx → (public)/(root)/page.tsx} +0 -0
- /package/templates/react/src/{shared/components → components}/error-boundary.tsx +0 -0
- /package/templates/react/src/{shared/components → components}/layout.tsx +0 -0
- /package/templates/react/src/{shared/pages → pages}/not-found.tsx +0 -0
package/dist/index.js
CHANGED
|
@@ -1,192 +1,235 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
}) :
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return function (mod) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.
|
|
122
|
-
.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
.option("--no-git", "Skip git initialization")
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
try {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
process.exit(1);
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
});
|
|
192
|
-
|
|
2
|
+
"use strict";var xO=Object.create;var Ao=Object.defineProperty;var vO=Object.getOwnPropertyDescriptor;var EO=Object.getOwnPropertyNames;var OO=Object.getPrototypeOf,TO=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),CO=(t,e)=>{for(var r in e)Ao(t,r,{get:e[r],enumerable:!0})},AO=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of EO(e))!TO.call(t,i)&&i!==r&&Ao(t,i,{get:()=>e[i],enumerable:!(n=vO(e,i))||n.enumerable});return t};var C=(t,e,r)=>(r=t!=null?xO(OO(t)):{},AO(e||!t||!t.__esModule?Ao(r,"default",{value:t,enumerable:!0}):r,t));var Zr=w(_o=>{var Qn=class extends Error{constructor(e,r,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=e,this.nestedError=void 0}},Po=class extends Qn{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};_o.CommanderError=Qn;_o.InvalidArgumentError=Po});var ei=w(Io=>{var{InvalidArgumentError:PO}=Zr(),ko=class{constructor(e,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,r){return r===this.defaultValue||!Array.isArray(r)?[e]:(r.push(e),r)}default(e,r){return this.defaultValue=e,this.defaultValueDescription=r,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new PO(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,n):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function _O(t){let e=t.name()+(t.variadic===!0?"...":"");return t.required?"<"+e+">":"["+e+"]"}Io.Argument=ko;Io.humanReadableArgName=_O});var Ro=w(Do=>{var{humanReadableArgName:kO}=ei(),Mo=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let r=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&r.push(n),this.sortSubcommands&&r.sort((i,s)=>i.name().localeCompare(s.name())),r}compareOptions(e,r){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(r))}visibleOptions(e){let r=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),s=n.long&&e._findOption(n.long);!i&&!s?r.push(n):n.long&&!s?r.push(e.createOption(n.long,n.description)):n.short&&!i&&r.push(e.createOption(n.short,n.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let r=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(s=>!s.hidden);r.push(...i)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(r=>{r.description=r.description||e._argsDescription[r.name()]||""}),e.registeredArguments.find(r=>r.description)?e.registeredArguments:[]}subcommandTerm(e){let r=e.registeredArguments.map(n=>kO(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,r){return r.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(i)))),0)}longestOptionTermLength(e,r){return r.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,r){return r.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(i)))),0)}longestArgumentTermLength(e,r){return r.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(i)))),0)}commandUsage(e){let r=e._name;e._aliases[0]&&(r=r+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+r+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let r=[];if(e.argChoices&&r.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&r.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&r.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&r.push(`env: ${e.envVar}`),r.length>0){let n=`(${r.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let r=[];if(e.argChoices&&r.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&r.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),r.length>0){let n=`(${r.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,r,n){return r.length===0?[]:[n.styleTitle(e),...r,""]}groupItems(e,r,n){let i=new Map;return e.forEach(s=>{let o=n(s);i.has(o)||i.set(o,[])}),r.forEach(s=>{let o=n(s);i.has(o)||i.set(o,[]),i.get(o).push(s)}),i}formatHelp(e,r){let n=r.padWidth(e,r),i=r.helpWidth??80;function s(d,f){return r.formatItem(d,n,f,r)}let o=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(e))}`,""],a=r.commandDescription(e);a.length>0&&(o=o.concat([r.boxWrap(r.styleCommandDescription(a),i),""]));let l=r.visibleArguments(e).map(d=>s(r.styleArgumentTerm(r.argumentTerm(d)),r.styleArgumentDescription(r.argumentDescription(d))));if(o=o.concat(this.formatItemList("Arguments:",l,r)),this.groupItems(e.options,r.visibleOptions(e),d=>d.helpGroupHeading??"Options:").forEach((d,f)=>{let h=d.map(p=>s(r.styleOptionTerm(r.optionTerm(p)),r.styleOptionDescription(r.optionDescription(p))));o=o.concat(this.formatItemList(f,h,r))}),r.showGlobalOptions){let d=r.visibleGlobalOptions(e).map(f=>s(r.styleOptionTerm(r.optionTerm(f)),r.styleOptionDescription(r.optionDescription(f))));o=o.concat(this.formatItemList("Global Options:",d,r))}return this.groupItems(e.commands,r.visibleCommands(e),d=>d.helpGroup()||"Commands:").forEach((d,f)=>{let h=d.map(p=>s(r.styleSubcommandTerm(r.subcommandTerm(p)),r.styleSubcommandDescription(r.subcommandDescription(p))));o=o.concat(this.formatItemList(f,h,r))}),o.join(`
|
|
3
|
+
`)}displayWidth(e){return Uu(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r==="[command]"?this.styleSubcommandText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleCommandText(r)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,r){return Math.max(r.longestOptionTermLength(e,r),r.longestGlobalOptionTermLength(e,r),r.longestSubcommandTermLength(e,r),r.longestArgumentTermLength(e,r))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,r,n,i){let o=" ".repeat(2);if(!n)return o+e;let a=e.padEnd(r+e.length-i.displayWidth(e)),l=2,c=(this.helpWidth??80)-r-l-2,d;return c<this.minWidthToWrap||i.preformatted(n)?d=n:d=i.boxWrap(n,c).replace(/\n/g,`
|
|
4
|
+
`+" ".repeat(r+l)),o+a+" ".repeat(l)+d.replace(/\n/g,`
|
|
5
|
+
${o}`)}boxWrap(e,r){if(r<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,s=[];return n.forEach(o=>{let a=o.match(i);if(a===null){s.push("");return}let l=[a.shift()],u=this.displayWidth(l[0]);a.forEach(c=>{let d=this.displayWidth(c);if(u+d<=r){l.push(c),u+=d;return}s.push(l.join(""));let f=c.trimStart();l=[f],u=this.displayWidth(f)}),s.push(l.join(""))}),s.join(`
|
|
6
|
+
`)}};function Uu(t){let e=/\x1b\[\d*(;\d*)*m/g;return t.replace(e,"")}Do.Help=Mo;Do.stripColor=Uu});var $o=w(No=>{var{InvalidArgumentError:IO}=Zr(),jo=class{constructor(e,r){this.flags=e,this.description=r||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let n=MO(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,r){return this.defaultValue=e,this.defaultValueDescription=r,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let r=e;return typeof e=="string"&&(r={[e]:!0}),this.implied=Object.assign(this.implied||{},r),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_collectValue(e,r){return r===this.defaultValue||!Array.isArray(r)?[e]:(r.push(e),r)}choices(e){return this.argChoices=e.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new IO(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,n):r},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?Vu(this.name().replace(/^no-/,"")):Vu(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Fo=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(r=>{r.negate?this.negativeOptions.set(r.attributeName(),r):this.positiveOptions.set(r.attributeName(),r)}),this.negativeOptions.forEach((r,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(e,r){let n=r.attributeName();if(!this.dualOptions.has(n))return!0;let i=this.negativeOptions.get(n).presetArg,s=i!==void 0?i:!1;return r.negate===(s===e)}};function Vu(t){return t.split("-").reduce((e,r)=>e+r[0].toUpperCase()+r.slice(1))}function MO(t){let e,r,n=/^-[^-]$/,i=/^--[^-]/,s=t.split(/[ |,]+/).concat("guard");if(n.test(s[0])&&(e=s.shift()),i.test(s[0])&&(r=s.shift()),!e&&n.test(s[0])&&(e=s.shift()),!e&&i.test(s[0])&&(e=r,r=s.shift()),s[0].startsWith("-")){let o=s[0],a=`option creation failed due to '${o}' in option flags '${t}'`;throw/^-[^-][^-]/.test(o)?new Error(`${a}
|
|
7
|
+
- a short flag is a single dash and a single character
|
|
8
|
+
- either use a single dash and a single character (for a short flag)
|
|
9
|
+
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`):n.test(o)?new Error(`${a}
|
|
10
|
+
- too many short flags`):i.test(o)?new Error(`${a}
|
|
11
|
+
- too many long flags`):new Error(`${a}
|
|
12
|
+
- unrecognised flag format`)}if(e===void 0&&r===void 0)throw new Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:e,longFlag:r}}No.Option=jo;No.DualOptions=Fo});var Hu=w(Wu=>{function DO(t,e){if(Math.abs(t.length-e.length)>3)return Math.max(t.length,e.length);let r=[];for(let n=0;n<=t.length;n++)r[n]=[n];for(let n=0;n<=e.length;n++)r[0][n]=n;for(let n=1;n<=e.length;n++)for(let i=1;i<=t.length;i++){let s=1;t[i-1]===e[n-1]?s=0:s=1,r[i][n]=Math.min(r[i-1][n]+1,r[i][n-1]+1,r[i-1][n-1]+s),i>1&&n>1&&t[i-1]===e[n-2]&&t[i-2]===e[n-1]&&(r[i][n]=Math.min(r[i][n],r[i-2][n-2]+1))}return r[t.length][e.length]}function RO(t,e){if(!e||e.length===0)return"";e=Array.from(new Set(e));let r=t.startsWith("--");r&&(t=t.slice(2),e=e.map(o=>o.slice(2)));let n=[],i=3,s=.4;return e.forEach(o=>{if(o.length<=1)return;let a=DO(t,o),l=Math.max(t.length,o.length);(l-a)/l>s&&(a<i?(i=a,n=[o]):a===i&&n.push(o))}),n.sort((o,a)=>o.localeCompare(a)),r&&(n=n.map(o=>`--${o}`)),n.length>1?`
|
|
13
|
+
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
|
|
14
|
+
(Did you mean ${n[0]}?)`:""}Wu.suggestSimilar=RO});var Ku=w(Uo=>{var jO=require("node:events").EventEmitter,Lo=require("node:child_process"),lt=require("node:path"),ti=require("node:fs"),B=require("node:process"),{Argument:FO,humanReadableArgName:NO}=ei(),{CommanderError:Go}=Zr(),{Help:$O,stripColor:LO}=Ro(),{Option:Ju,DualOptions:GO}=$o(),{suggestSimilar:Yu}=Hu(),qo=class t extends jO{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:r=>B.stdout.write(r),writeErr:r=>B.stderr.write(r),outputError:(r,n)=>n(r),getOutHelpWidth:()=>B.stdout.isTTY?B.stdout.columns:void 0,getErrHelpWidth:()=>B.stderr.isTTY?B.stderr.columns:void 0,getOutHasColors:()=>Bo()??(B.stdout.isTTY&&B.stdout.hasColors?.()),getErrHasColors:()=>Bo()??(B.stderr.isTTY&&B.stderr.hasColors?.()),stripColor:r=>LO(r)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let r=this;r;r=r.parent)e.push(r);return e}command(e,r,n){let i=r,s=n;typeof i=="object"&&i!==null&&(s=i,i=null),s=s||{};let[,o,a]=e.match(/([^ ]+) *(.*)/),l=this.createCommand(o);return i&&(l.description(i),l._executableHandler=!0),s.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(s.noHelp||s.hidden),l._executableFile=s.executableFile||null,a&&l.arguments(a),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),i?this:l}createCommand(e){return new t(e)}createHelp(){return Object.assign(new $O,this.configureHelp())}configureHelp(e){return e===void 0?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return e===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...e},this)}showHelpAfterError(e=!0){return typeof e!="string"&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,r){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name
|
|
15
|
+
- specify the name in Command constructor or using .name()`);return r=r||{},r.isDefault&&(this._defaultCommandName=e._name),(r.noHelp||r.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,r){return new FO(e,r)}argument(e,r,n,i){let s=this.createArgument(e,r);return typeof n=="function"?s.default(i).argParser(n):s.default(n),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(r=>{this.argument(r)}),this}addArgument(e){let r=this.registeredArguments.slice(-1)[0];if(r?.variadic)throw new Error(`only the last argument can be variadic '${r.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,r){if(typeof e=="boolean")return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=e??"help [command]",[,i,s]=n.match(/([^ ]+) *(.*)/),o=r??"display help for command",a=this.createCommand(i);return a.helpOption(!1),s&&a.arguments(s),o&&a.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=a,(e||r)&&this._initCommandGroup(a),this}addHelpCommand(e,r){return typeof e!="object"?(this.helpCommand(e,r),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,r){let n=["preSubcommand","preAction","postAction"];if(!n.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.
|
|
16
|
+
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(r):this._lifeCycleHooks[e]=[r],this}exitOverride(e){return e?this._exitCallback=e:this._exitCallback=r=>{if(r.code!=="commander.executeSubCommandAsync")throw r},this}_exit(e,r,n){this._exitCallback&&this._exitCallback(new Go(e,r,n)),B.exit(e)}action(e){let r=n=>{let i=this.registeredArguments.length,s=n.slice(0,i);return this._storeOptionsAsProperties?s[i]=this:s[i]=this.opts(),s.push(this),e.apply(this,s)};return this._actionHandler=r,this}createOption(e,r){return new Ju(e,r)}_callParseArg(e,r,n,i){try{return e.parseArg(r,n)}catch(s){if(s.code==="commander.invalidArgument"){let o=`${i} ${s.message}`;this.error(o,{exitCode:s.exitCode,code:s.code})}throw s}}_registerOption(e){let r=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(r){let n=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
|
|
17
|
+
- already used by option '${r.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let r=i=>[i.name()].concat(i.aliases()),n=r(e).find(i=>this._findCommand(i));if(n){let i=r(this._findCommand(n)).join("|"),s=r(e).join("|");throw new Error(`cannot add command '${s}' as already have command '${i}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let r=e.name(),n=e.attributeName();if(e.negate){let s=e.long.replace(/^--no-/,"--");this._findOption(s)||this.setOptionValueWithSource(n,e.defaultValue===void 0?!0:e.defaultValue,"default")}else e.defaultValue!==void 0&&this.setOptionValueWithSource(n,e.defaultValue,"default");let i=(s,o,a)=>{s==null&&e.presetArg!==void 0&&(s=e.presetArg);let l=this.getOptionValue(n);s!==null&&e.parseArg?s=this._callParseArg(e,s,l,o):s!==null&&e.variadic&&(s=e._collectValue(s,l)),s==null&&(e.negate?s=!1:e.isBoolean()||e.optional?s=!0:s=""),this.setOptionValueWithSource(n,s,a)};return this.on("option:"+r,s=>{let o=`error: option '${e.flags}' argument '${s}' is invalid.`;i(s,o,"cli")}),e.envVar&&this.on("optionEnv:"+r,s=>{let o=`error: option '${e.flags}' value '${s}' from env '${e.envVar}' is invalid.`;i(s,o,"env")}),this}_optionEx(e,r,n,i,s){if(typeof r=="object"&&r instanceof Ju)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(r,n);if(o.makeOptionMandatory(!!e.mandatory),typeof i=="function")o.default(s).argParser(i);else if(i instanceof RegExp){let a=i;i=(l,u)=>{let c=a.exec(l);return c?c[0]:u},o.default(s).argParser(i)}else o.default(i);return this.addOption(o)}option(e,r,n,i){return this._optionEx({},e,r,n,i)}requiredOption(e,r,n,i){return this._optionEx({mandatory:!0},e,r,n,i)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,r){return this.setOptionValueWithSource(e,r,void 0)}setOptionValueWithSource(e,r,n){return this._storeOptionsAsProperties?this[e]=r:this._optionValues[e]=r,this._optionValueSources[e]=n,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let r;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(e)!==void 0&&(r=n.getOptionValueSource(e))}),r}_prepareUserArgs(e,r){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(r=r||{},e===void 0&&r.from===void 0){B.versions?.electron&&(r.from="electron");let i=B.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(r.from="eval")}e===void 0&&(e=B.argv),this.rawArgs=e.slice();let n;switch(r.from){case void 0:case"node":this._scriptPath=e[1],n=e.slice(2);break;case"electron":B.defaultApp?(this._scriptPath=e[1],n=e.slice(2)):n=e.slice(1);break;case"user":n=e.slice(0);break;case"eval":n=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(e,r){this._prepareForParse();let n=this._prepareUserArgs(e,r);return this._parseCommand([],n),this}async parseAsync(e,r){this._prepareForParse();let n=this._prepareUserArgs(e,r);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
18
|
+
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,r,n){if(ti.existsSync(e))return;let i=r?`searched for local subcommand relative to directory '${r}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",s=`'${e}' does not exist
|
|
19
|
+
- if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
20
|
+
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
21
|
+
- ${i}`;throw new Error(s)}_executeSubCommand(e,r){r=r.slice();let n=!1,i=[".js",".ts",".tsx",".mjs",".cjs"];function s(c,d){let f=lt.resolve(c,d);if(ti.existsSync(f))return f;if(i.includes(lt.extname(d)))return;let h=i.find(p=>ti.existsSync(`${f}${p}`));if(h)return`${f}${h}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let c;try{c=ti.realpathSync(this._scriptPath)}catch{c=this._scriptPath}a=lt.resolve(lt.dirname(c),a)}if(a){let c=s(a,o);if(!c&&!e._executableFile&&this._scriptPath){let d=lt.basename(this._scriptPath,lt.extname(this._scriptPath));d!==this._name&&(c=s(a,`${d}-${e._name}`))}o=c||o}n=i.includes(lt.extname(o));let l;B.platform!=="win32"?n?(r.unshift(o),r=zu(B.execArgv).concat(r),l=Lo.spawn(B.argv[0],r,{stdio:"inherit"})):l=Lo.spawn(o,r,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,e._name),r.unshift(o),r=zu(B.execArgv).concat(r),l=Lo.spawn(B.execPath,r,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(d=>{B.on(d,()=>{l.killed===!1&&l.exitCode===null&&l.kill(d)})});let u=this._exitCallback;l.on("close",c=>{c=c??1,u?u(new Go(c,"commander.executeSubCommandAsync","(close)")):B.exit(c)}),l.on("error",c=>{if(c.code==="ENOENT")this._checkForMissingExecutable(o,a,e._name);else if(c.code==="EACCES")throw new Error(`'${o}' not executable`);if(!u)B.exit(1);else{let d=new Go(1,"commander.executeSubCommandAsync","(error)");d.nestedError=c,u(d)}}),this.runningCommand=l}_dispatchSubcommand(e,r,n){let i=this._findCommand(e);i||this.help({error:!0}),i._prepareForParse();let s;return s=this._chainOrCallSubCommandHook(s,i,"preSubcommand"),s=this._chainOrCall(s,()=>{if(i._executableHandler)this._executeSubCommand(i,r.concat(n));else return i._parseCommand(r,n)}),s}_dispatchHelpCommand(e){e||this.help();let r=this._findCommand(e);return r&&!r._executableHandler&&r.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,r)=>{e.required&&this.args[r]==null&&this.missingArgument(e.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let e=(n,i,s)=>{let o=i;if(i!==null&&n.parseArg){let a=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;o=this._callParseArg(n,i,s,a)}return o};this._checkNumberOfArguments();let r=[];this.registeredArguments.forEach((n,i)=>{let s=n.defaultValue;n.variadic?i<this.args.length?(s=this.args.slice(i),n.parseArg&&(s=s.reduce((o,a)=>e(n,a,o),n.defaultValue))):s===void 0&&(s=[]):i<this.args.length&&(s=this.args[i],n.parseArg&&(s=e(n,s,n.defaultValue))),r[i]=s}),this.processedArgs=r}_chainOrCall(e,r){return e?.then&&typeof e.then=="function"?e.then(()=>r()):r()}_chainOrCallHooks(e,r){let n=e,i=[];return this._getCommandAndAncestors().reverse().filter(s=>s._lifeCycleHooks[r]!==void 0).forEach(s=>{s._lifeCycleHooks[r].forEach(o=>{i.push({hookedCommand:s,callback:o})})}),r==="postAction"&&i.reverse(),i.forEach(s=>{n=this._chainOrCall(n,()=>s.callback(s.hookedCommand,this))}),n}_chainOrCallSubCommandHook(e,r,n){let i=e;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(s=>{i=this._chainOrCall(i,()=>s(this,r))}),i}_parseCommand(e,r){let n=this.parseOptions(r);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(n.operands),r=n.unknown,this.args=e.concat(r),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),r);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(r),this._dispatchSubcommand(this._defaultCommandName,e,r);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(s,e,r)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(s))i(),this._processArguments(),this.parent.emit(s,e,r);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,r);this.listenerCount("command:*")?this.emit("command:*",e,r):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(r=>r._name===e||r._aliases.includes(e))}_findOption(e){return this.options.find(r=>r.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(r=>{r.mandatory&&e.getOptionValue(r.attributeName())===void 0&&e.missingMandatoryOptionValue(r)})})}_checkForConflictingLocalOptions(){let e=this.options.filter(n=>{let i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});e.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=e.find(s=>n.conflictsWith.includes(s.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let r=[],n=[],i=r;function s(c){return c.length>1&&c[0]==="-"}let o=c=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(c)?!this._getCommandAndAncestors().some(d=>d.options.map(f=>f.short).some(f=>/^-\d$/.test(f))):!1,a=null,l=null,u=0;for(;u<e.length||l;){let c=l??e[u++];if(l=null,c==="--"){i===n&&i.push(c),i.push(...e.slice(u));break}if(a&&(!s(c)||o(c))){this.emit(`option:${a.name()}`,c);continue}if(a=null,s(c)){let d=this._findOption(c);if(d){if(d.required){let f=e[u++];f===void 0&&this.optionMissingArgument(d),this.emit(`option:${d.name()}`,f)}else if(d.optional){let f=null;u<e.length&&(!s(e[u])||o(e[u]))&&(f=e[u++]),this.emit(`option:${d.name()}`,f)}else this.emit(`option:${d.name()}`);a=d.variadic?d:null;continue}}if(c.length>2&&c[0]==="-"&&c[1]!=="-"){let d=this._findOption(`-${c[1]}`);if(d){d.required||d.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${d.name()}`,c.slice(2)):(this.emit(`option:${d.name()}`),l=`-${c.slice(2)}`);continue}}if(/^--[^=]+=/.test(c)){let d=c.indexOf("="),f=this._findOption(c.slice(0,d));if(f&&(f.required||f.optional)){this.emit(`option:${f.name()}`,c.slice(d+1));continue}}if(i===r&&s(c)&&!(this.commands.length===0&&o(c))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&n.length===0){if(this._findCommand(c)){r.push(c),n.push(...e.slice(u));break}else if(this._getHelpCommand()&&c===this._getHelpCommand().name()){r.push(c,...e.slice(u));break}else if(this._defaultCommandName){n.push(c,...e.slice(u));break}}if(this._passThroughOptions){i.push(c,...e.slice(u));break}i.push(c)}return{operands:r,unknown:n}}opts(){if(this._storeOptionsAsProperties){let e={},r=this.options.length;for(let n=0;n<r;n++){let i=this.options[n].attributeName();e[i]=i===this._versionOptionName?this._version:this[i]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,r)=>Object.assign(e,r.opts()),{})}error(e,r){this._outputConfiguration.outputError(`${e}
|
|
22
|
+
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
23
|
+
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
|
|
24
|
+
`),this.outputHelp({error:!0}));let n=r||{},i=n.exitCode||1,s=n.code||"commander.error";this._exit(i,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in B.env){let r=e.attributeName();(this.getOptionValue(r)===void 0||["default","config","env"].includes(this.getOptionValueSource(r)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,B.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new GO(this.options),r=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&r(n.attributeName())&&e.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!r(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(e){let r=`error: missing required argument '${e}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(e){let r=`error: option '${e.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let r=`error: required option '${e.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,r){let n=o=>{let a=o.attributeName(),l=this.getOptionValue(a),u=this.options.find(d=>d.negate&&a===d.attributeName()),c=this.options.find(d=>!d.negate&&a===d.attributeName());return u&&(u.presetArg===void 0&&l===!1||u.presetArg!==void 0&&l===u.presetArg)?u:c||o},i=o=>{let a=n(o),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},s=`error: ${i(e)} cannot be used with ${i(r)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let r="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],s=this;do{let o=s.createHelp().visibleOptions(s).filter(a=>a.long).map(a=>a.long);i=i.concat(o),s=s.parent}while(s&&!s._enablePositionalOptions);r=Yu(e,i)}let n=`error: unknown option '${e}'${r}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let r=this.registeredArguments.length,n=r===1?"":"s",s=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${r} argument${n} but got ${e.length}.`;this.error(s,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],r="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(s=>{i.push(s.name()),s.alias()&&i.push(s.alias())}),r=Yu(e,i)}let n=`error: unknown command '${e}'${r}`;this.error(n,{code:"commander.unknownCommand"})}version(e,r,n){if(e===void 0)return this._version;this._version=e,r=r||"-V, --version",n=n||"output the version number";let i=this.createOption(r,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
25
|
+
`),this._exit(0,"commander.version",e)}),this}description(e,r){return e===void 0&&r===void 0?this._description:(this._description=e,r&&(this._argsDescription=r),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(r=this.commands[this.commands.length-1]),e===r._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(e);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${i}'`)}return r._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(r=>this.alias(r)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let r=this.registeredArguments.map(n=>NO(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?r:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}helpGroup(e){return e===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return e===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return e===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=lt.basename(e,lt.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let r=this.createHelp(),n=this._getOutputContext(e);r.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let i=r.formatHelp(this,r);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(e){e=e||{};let r=!!e.error,n,i,s;return r?(n=a=>this._outputConfiguration.writeErr(a),i=this._outputConfiguration.getErrHasColors(),s=this._outputConfiguration.getErrHelpWidth()):(n=a=>this._outputConfiguration.writeOut(a),i=this._outputConfiguration.getOutHasColors(),s=this._outputConfiguration.getOutHelpWidth()),{error:r,write:a=>(i||(a=this._outputConfiguration.stripColor(a)),n(a)),hasColors:i,helpWidth:s}}outputHelp(e){let r;typeof e=="function"&&(r=e,e=void 0);let n=this._getOutputContext(e),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let s=this.helpInformation({error:n.error});if(r&&(s=r(s),typeof s!="string"&&!Buffer.isBuffer(s)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(s),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(e,r){return typeof e=="boolean"?(e?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",r??"display help for command"),(e||r)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let r=Number(B.exitCode??0);r===0&&e&&typeof e!="function"&&e.error&&(r=1),this._exit(r,"commander.help","(outputHelp)")}addHelpText(e,r){let n=["beforeAll","before","after","afterAll"];if(!n.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
26
|
+
Expecting one of '${n.join("', '")}'`);let i=`${e}Help`;return this.on(i,s=>{let o;typeof r=="function"?o=r({error:s.error,command:s.command}):o=r,o&&s.write(`${o}
|
|
27
|
+
`)}),this}_outputHelpIfRequested(e){let r=this._getHelpOption();r&&e.find(i=>r.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function zu(t){return t.map(e=>{if(!e.startsWith("--inspect"))return e;let r,n="127.0.0.1",i="9229",s;return(s=e.match(/^(--inspect(-brk)?)$/))!==null?r=s[1]:(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=s[1],/^\d+$/.test(s[3])?i=s[3]:n=s[3]):(s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=s[1],n=s[3],i=s[4]),r&&i!=="0"?`${r}=${n}:${parseInt(i)+1}`:e})}function Bo(){if(B.env.NO_COLOR||B.env.FORCE_COLOR==="0"||B.env.FORCE_COLOR==="false")return!1;if(B.env.FORCE_COLOR||B.env.CLICOLOR_FORCE!==void 0)return!0}Uo.Command=qo;Uo.useColor=Bo});var ed=w(Ie=>{var{Argument:Xu}=ei(),{Command:Vo}=Ku(),{CommanderError:qO,InvalidArgumentError:Zu}=Zr(),{Help:BO}=Ro(),{Option:Qu}=$o();Ie.program=new Vo;Ie.createCommand=t=>new Vo(t);Ie.createOption=(t,e)=>new Qu(t,e);Ie.createArgument=(t,e)=>new Xu(t,e);Ie.Command=Vo;Ie.Option=Qu;Ie.Argument=Xu;Ie.Help=BO;Ie.CommanderError=qO;Ie.InvalidArgumentError=Zu;Ie.InvalidOptionArgumentError=Zu});var ue=w(zo=>{"use strict";zo.fromCallback=function(t){return Object.defineProperty(function(...e){if(typeof e[e.length-1]=="function")t.apply(this,e);else return new Promise((r,n)=>{e.push((i,s)=>i!=null?n(i):r(s)),t.apply(this,e)})},"name",{value:t.name})};zo.fromPromise=function(t){return Object.defineProperty(function(...e){let r=e[e.length-1];if(typeof r!="function")return t.apply(this,e);e.pop(),t.apply(this,e).then(n=>r(null,n),r)},"name",{value:t.name})}});var md=w((KN,pd)=>{var At=require("constants"),n0=process.cwd,si=null,i0=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return si||(si=n0.call(process)),si};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Ko=process.chdir,process.chdir=function(t){si=null,Ko.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Ko));var Ko;pd.exports=s0;function s0(t){At.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||r(t),t.chown=s(t.chown),t.fchown=s(t.fchown),t.lchown=s(t.lchown),t.chmod=n(t.chmod),t.fchmod=n(t.fchmod),t.lchmod=n(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=i(t.chmodSync),t.fchmodSync=i(t.fchmodSync),t.lchmodSync=i(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=l(t.statSync),t.fstatSync=l(t.fstatSync),t.lstatSync=l(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(c,d,f){f&&process.nextTick(f)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(c,d,f,h){h&&process.nextTick(h)},t.lchownSync=function(){}),i0==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:(function(c){function d(f,h,p){var y=Date.now(),x=0;c(f,h,function b(S){if(S&&(S.code==="EACCES"||S.code==="EPERM"||S.code==="EBUSY")&&Date.now()-y<6e4){setTimeout(function(){t.stat(h,function(g,v){g&&g.code==="ENOENT"?c(f,h,b):p(S)})},x),x<100&&(x+=10);return}p&&p(S)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,c),d})(t.rename)),t.read=typeof t.read!="function"?t.read:(function(c){function d(f,h,p,y,x,b){var S;if(b&&typeof b=="function"){var g=0;S=function(v,E,T){if(v&&v.code==="EAGAIN"&&g<10)return g++,c.call(t,f,h,p,y,x,S);b.apply(this,arguments)}}return c.call(t,f,h,p,y,x,S)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,c),d})(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:(function(c){return function(d,f,h,p,y){for(var x=0;;)try{return c.call(t,d,f,h,p,y)}catch(b){if(b.code==="EAGAIN"&&x<10){x++;continue}throw b}}})(t.readSync);function e(c){c.lchmod=function(d,f,h){c.open(d,At.O_WRONLY|At.O_SYMLINK,f,function(p,y){if(p){h&&h(p);return}c.fchmod(y,f,function(x){c.close(y,function(b){h&&h(x||b)})})})},c.lchmodSync=function(d,f){var h=c.openSync(d,At.O_WRONLY|At.O_SYMLINK,f),p=!0,y;try{y=c.fchmodSync(h,f),p=!1}finally{if(p)try{c.closeSync(h)}catch{}else c.closeSync(h)}return y}}function r(c){At.hasOwnProperty("O_SYMLINK")&&c.futimes?(c.lutimes=function(d,f,h,p){c.open(d,At.O_SYMLINK,function(y,x){if(y){p&&p(y);return}c.futimes(x,f,h,function(b){c.close(x,function(S){p&&p(b||S)})})})},c.lutimesSync=function(d,f,h){var p=c.openSync(d,At.O_SYMLINK),y,x=!0;try{y=c.futimesSync(p,f,h),x=!1}finally{if(x)try{c.closeSync(p)}catch{}else c.closeSync(p)}return y}):c.futimes&&(c.lutimes=function(d,f,h,p){p&&process.nextTick(p)},c.lutimesSync=function(){})}function n(c){return c&&function(d,f,h){return c.call(t,d,f,function(p){u(p)&&(p=null),h&&h.apply(this,arguments)})}}function i(c){return c&&function(d,f){try{return c.call(t,d,f)}catch(h){if(!u(h))throw h}}}function s(c){return c&&function(d,f,h,p){return c.call(t,d,f,h,function(y){u(y)&&(y=null),p&&p.apply(this,arguments)})}}function o(c){return c&&function(d,f,h){try{return c.call(t,d,f,h)}catch(p){if(!u(p))throw p}}}function a(c){return c&&function(d,f,h){typeof f=="function"&&(h=f,f=null);function p(y,x){x&&(x.uid<0&&(x.uid+=4294967296),x.gid<0&&(x.gid+=4294967296)),h&&h.apply(this,arguments)}return f?c.call(t,d,f,p):c.call(t,d,p)}}function l(c){return c&&function(d,f){var h=f?c.call(t,d,f):c.call(t,d);return h&&(h.uid<0&&(h.uid+=4294967296),h.gid<0&&(h.gid+=4294967296)),h}}function u(c){if(!c||c.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(c.code==="EINVAL"||c.code==="EPERM"))}}});var wd=w((XN,yd)=>{var gd=require("stream").Stream;yd.exports=o0;function o0(t){return{ReadStream:e,WriteStream:r};function e(n,i){if(!(this instanceof e))return new e(n,i);gd.call(this);var s=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var o=Object.keys(i),a=0,l=o.length;a<l;a++){var u=o[a];this[u]=i[u]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){s._read()});return}t.open(this.path,this.flags,this.mode,function(c,d){if(c){s.emit("error",c),s.readable=!1;return}s.fd=d,s.emit("open",d),s._read()})}function r(n,i){if(!(this instanceof r))return new r(n,i);gd.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var s=Object.keys(i),o=0,a=s.length;o<a;o++){var l=s[o];this[l]=i[l]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Sd=w((ZN,bd)=>{"use strict";bd.exports=c0;var a0=Object.getPrototypeOf||function(t){return t.__proto__};function c0(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:a0(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}});var fr=w((QN,Qo)=>{var ne=require("fs"),l0=md(),u0=wd(),d0=Sd(),oi=require("util"),ge,ci;typeof Symbol=="function"&&typeof Symbol.for=="function"?(ge=Symbol.for("graceful-fs.queue"),ci=Symbol.for("graceful-fs.previous")):(ge="___graceful-fs.queue",ci="___graceful-fs.previous");function f0(){}function Ed(t,e){Object.defineProperty(t,ge,{get:function(){return e}})}var Jt=f0;oi.debuglog?Jt=oi.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Jt=function(){var t=oi.format.apply(oi,arguments);t="GFS4: "+t.split(/\n/).join(`
|
|
28
|
+
GFS4: `),console.error(t)});ne[ge]||(xd=global[ge]||[],Ed(ne,xd),ne.close=(function(t){function e(r,n){return t.call(ne,r,function(i){i||vd(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(e,ci,{value:t}),e})(ne.close),ne.closeSync=(function(t){function e(r){t.apply(ne,arguments),vd()}return Object.defineProperty(e,ci,{value:t}),e})(ne.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Jt(ne[ge]),require("assert").equal(ne[ge].length,0)}));var xd;global[ge]||Ed(global,ne[ge]);Qo.exports=Xo(d0(ne));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!ne.__patched&&(Qo.exports=Xo(ne),ne.__patched=!0);function Xo(t){l0(t),t.gracefulify=Xo,t.createReadStream=E,t.createWriteStream=T;var e=t.readFile;t.readFile=r;function r(A,D,k){return typeof D=="function"&&(k=D,D=null),X(A,D,k);function X(G,H,I,N){return e(G,H,function(F){F&&(F.code==="EMFILE"||F.code==="ENFILE")?dr([X,[G,H,I],F,N||Date.now(),Date.now()]):typeof I=="function"&&I.apply(this,arguments)})}}var n=t.writeFile;t.writeFile=i;function i(A,D,k,X){return typeof k=="function"&&(X=k,k=null),G(A,D,k,X);function G(H,I,N,F,re){return n(H,I,N,function(U){U&&(U.code==="EMFILE"||U.code==="ENFILE")?dr([G,[H,I,N,F],U,re||Date.now(),Date.now()]):typeof F=="function"&&F.apply(this,arguments)})}}var s=t.appendFile;s&&(t.appendFile=o);function o(A,D,k,X){return typeof k=="function"&&(X=k,k=null),G(A,D,k,X);function G(H,I,N,F,re){return s(H,I,N,function(U){U&&(U.code==="EMFILE"||U.code==="ENFILE")?dr([G,[H,I,N,F],U,re||Date.now(),Date.now()]):typeof F=="function"&&F.apply(this,arguments)})}}var a=t.copyFile;a&&(t.copyFile=l);function l(A,D,k,X){return typeof k=="function"&&(X=k,k=0),G(A,D,k,X);function G(H,I,N,F,re){return a(H,I,N,function(U){U&&(U.code==="EMFILE"||U.code==="ENFILE")?dr([G,[H,I,N,F],U,re||Date.now(),Date.now()]):typeof F=="function"&&F.apply(this,arguments)})}}var u=t.readdir;t.readdir=d;var c=/^v[0-5]\./;function d(A,D,k){typeof D=="function"&&(k=D,D=null);var X=c.test(process.version)?function(I,N,F,re){return u(I,G(I,N,F,re))}:function(I,N,F,re){return u(I,N,G(I,N,F,re))};return X(A,D,k);function G(H,I,N,F){return function(re,U){re&&(re.code==="EMFILE"||re.code==="ENFILE")?dr([X,[H,I,N],re,F||Date.now(),Date.now()]):(U&&U.sort&&U.sort(),typeof N=="function"&&N.call(this,re,U))}}}if(process.version.substr(0,4)==="v0.8"){var f=u0(t);b=f.ReadStream,g=f.WriteStream}var h=t.ReadStream;h&&(b.prototype=Object.create(h.prototype),b.prototype.open=S);var p=t.WriteStream;p&&(g.prototype=Object.create(p.prototype),g.prototype.open=v),Object.defineProperty(t,"ReadStream",{get:function(){return b},set:function(A){b=A},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return g},set:function(A){g=A},enumerable:!0,configurable:!0});var y=b;Object.defineProperty(t,"FileReadStream",{get:function(){return y},set:function(A){y=A},enumerable:!0,configurable:!0});var x=g;Object.defineProperty(t,"FileWriteStream",{get:function(){return x},set:function(A){x=A},enumerable:!0,configurable:!0});function b(A,D){return this instanceof b?(h.apply(this,arguments),this):b.apply(Object.create(b.prototype),arguments)}function S(){var A=this;$(A.path,A.flags,A.mode,function(D,k){D?(A.autoClose&&A.destroy(),A.emit("error",D)):(A.fd=k,A.emit("open",k),A.read())})}function g(A,D){return this instanceof g?(p.apply(this,arguments),this):g.apply(Object.create(g.prototype),arguments)}function v(){var A=this;$(A.path,A.flags,A.mode,function(D,k){D?(A.destroy(),A.emit("error",D)):(A.fd=k,A.emit("open",k))})}function E(A,D){return new t.ReadStream(A,D)}function T(A,D){return new t.WriteStream(A,D)}var j=t.open;t.open=$;function $(A,D,k,X){return typeof k=="function"&&(X=k,k=null),G(A,D,k,X);function G(H,I,N,F,re){return j(H,I,N,function(U,Bu){U&&(U.code==="EMFILE"||U.code==="ENFILE")?dr([G,[H,I,N,F],U,re||Date.now(),Date.now()]):typeof F=="function"&&F.apply(this,arguments)})}}return t}function dr(t){Jt("ENQUEUE",t[0].name,t[1]),ne[ge].push(t),Zo()}var ai;function vd(){for(var t=Date.now(),e=0;e<ne[ge].length;++e)ne[ge][e].length>2&&(ne[ge][e][3]=t,ne[ge][e][4]=t);Zo()}function Zo(){if(clearTimeout(ai),ai=void 0,ne[ge].length!==0){var t=ne[ge].shift(),e=t[0],r=t[1],n=t[2],i=t[3],s=t[4];if(i===void 0)Jt("RETRY",e.name,r),e.apply(null,r);else if(Date.now()-i>=6e4){Jt("TIMEOUT",e.name,r);var o=r.pop();typeof o=="function"&&o.call(null,n)}else{var a=Date.now()-s,l=Math.max(s-i,1),u=Math.min(l*1.2,100);a>=u?(Jt("RETRY",e.name,r),e.apply(null,r.concat([i]))):ne[ge].push(t)}ai===void 0&&(ai=setTimeout(Zo,0))}}});var ve=w(ut=>{"use strict";var Od=ue().fromCallback,xe=fr(),h0=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(t=>typeof xe[t]=="function");Object.assign(ut,xe);h0.forEach(t=>{ut[t]=Od(xe[t])});ut.exists=function(t,e){return typeof e=="function"?xe.exists(t,e):new Promise(r=>xe.exists(t,r))};ut.read=function(t,e,r,n,i,s){return typeof s=="function"?xe.read(t,e,r,n,i,s):new Promise((o,a)=>{xe.read(t,e,r,n,i,(l,u,c)=>{if(l)return a(l);o({bytesRead:u,buffer:c})})})};ut.write=function(t,e,...r){return typeof r[r.length-1]=="function"?xe.write(t,e,...r):new Promise((n,i)=>{xe.write(t,e,...r,(s,o,a)=>{if(s)return i(s);n({bytesWritten:o,buffer:a})})})};ut.readv=function(t,e,...r){return typeof r[r.length-1]=="function"?xe.readv(t,e,...r):new Promise((n,i)=>{xe.readv(t,e,...r,(s,o,a)=>{if(s)return i(s);n({bytesRead:o,buffers:a})})})};ut.writev=function(t,e,...r){return typeof r[r.length-1]=="function"?xe.writev(t,e,...r):new Promise((n,i)=>{xe.writev(t,e,...r,(s,o,a)=>{if(s)return i(s);n({bytesWritten:o,buffers:a})})})};typeof xe.realpath.native=="function"?ut.realpath.native=Od(xe.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")});var Cd=w((t$,Td)=>{"use strict";var p0=require("path");Td.exports.checkPath=function(e){if(process.platform==="win32"&&/[<>:"|?*]/.test(e.replace(p0.parse(e).root,""))){let n=new Error(`Path contains invalid characters: ${e}`);throw n.code="EINVAL",n}}});var kd=w((r$,ea)=>{"use strict";var Ad=ve(),{checkPath:Pd}=Cd(),_d=t=>{let e={mode:511};return typeof t=="number"?t:{...e,...t}.mode};ea.exports.makeDir=async(t,e)=>(Pd(t),Ad.mkdir(t,{mode:_d(e),recursive:!0}));ea.exports.makeDirSync=(t,e)=>(Pd(t),Ad.mkdirSync(t,{mode:_d(e),recursive:!0}))});var Ne=w((n$,Id)=>{"use strict";var m0=ue().fromPromise,{makeDir:g0,makeDirSync:ta}=kd(),ra=m0(g0);Id.exports={mkdirs:ra,mkdirsSync:ta,mkdirp:ra,mkdirpSync:ta,ensureDir:ra,ensureDirSync:ta}});var Pt=w((i$,Dd)=>{"use strict";var y0=ue().fromPromise,Md=ve();function w0(t){return Md.access(t).then(()=>!0).catch(()=>!1)}Dd.exports={pathExists:y0(w0),pathExistsSync:Md.existsSync}});var na=w((s$,Rd)=>{"use strict";var hr=ve(),b0=ue().fromPromise;async function S0(t,e,r){let n=await hr.open(t,"r+"),i=null;try{await hr.futimes(n,e,r)}finally{try{await hr.close(n)}catch(s){i=s}}if(i)throw i}function x0(t,e,r){let n=hr.openSync(t,"r+");return hr.futimesSync(n,e,r),hr.closeSync(n)}Rd.exports={utimesMillis:b0(S0),utimesMillisSync:x0}});var Yt=w((o$,$d)=>{"use strict";var pr=ve(),de=require("path"),jd=ue().fromPromise;function v0(t,e,r){let n=r.dereference?i=>pr.stat(i,{bigint:!0}):i=>pr.lstat(i,{bigint:!0});return Promise.all([n(t),n(e).catch(i=>{if(i.code==="ENOENT")return null;throw i})]).then(([i,s])=>({srcStat:i,destStat:s}))}function E0(t,e,r){let n,i=r.dereference?o=>pr.statSync(o,{bigint:!0}):o=>pr.lstatSync(o,{bigint:!0}),s=i(t);try{n=i(e)}catch(o){if(o.code==="ENOENT")return{srcStat:s,destStat:null};throw o}return{srcStat:s,destStat:n}}async function O0(t,e,r,n){let{srcStat:i,destStat:s}=await v0(t,e,n);if(s){if(tn(i,s)){let o=de.basename(t),a=de.basename(e);if(r==="move"&&o!==a&&o.toLowerCase()===a.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`)}if(i.isDirectory()&&ia(t,e))throw new Error(li(t,e,r));return{srcStat:i,destStat:s}}function T0(t,e,r,n){let{srcStat:i,destStat:s}=E0(t,e,n);if(s){if(tn(i,s)){let o=de.basename(t),a=de.basename(e);if(r==="move"&&o!==a&&o.toLowerCase()===a.toLowerCase())return{srcStat:i,destStat:s,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(i.isDirectory()&&!s.isDirectory())throw new Error(`Cannot overwrite non-directory '${e}' with directory '${t}'.`);if(!i.isDirectory()&&s.isDirectory())throw new Error(`Cannot overwrite directory '${e}' with non-directory '${t}'.`)}if(i.isDirectory()&&ia(t,e))throw new Error(li(t,e,r));return{srcStat:i,destStat:s}}async function Fd(t,e,r,n){let i=de.resolve(de.dirname(t)),s=de.resolve(de.dirname(r));if(s===i||s===de.parse(s).root)return;let o;try{o=await pr.stat(s,{bigint:!0})}catch(a){if(a.code==="ENOENT")return;throw a}if(tn(e,o))throw new Error(li(t,r,n));return Fd(t,e,s,n)}function Nd(t,e,r,n){let i=de.resolve(de.dirname(t)),s=de.resolve(de.dirname(r));if(s===i||s===de.parse(s).root)return;let o;try{o=pr.statSync(s,{bigint:!0})}catch(a){if(a.code==="ENOENT")return;throw a}if(tn(e,o))throw new Error(li(t,r,n));return Nd(t,e,s,n)}function tn(t,e){return e.ino!==void 0&&e.dev!==void 0&&e.ino===t.ino&&e.dev===t.dev}function ia(t,e){let r=de.resolve(t).split(de.sep).filter(i=>i),n=de.resolve(e).split(de.sep).filter(i=>i);return r.every((i,s)=>n[s]===i)}function li(t,e,r){return`Cannot ${r} '${t}' to a subdirectory of itself, '${e}'.`}$d.exports={checkPaths:jd(O0),checkPathsSync:T0,checkParentPaths:jd(Fd),checkParentPathsSync:Nd,isSrcSubdir:ia,areIdentical:tn}});var Gd=w((a$,Ld)=>{"use strict";async function C0(t,e){let r=[];for await(let n of t)r.push(e(n).then(()=>null,i=>i??new Error("unknown error")));await Promise.all(r.map(n=>n.then(i=>{if(i!==null)throw i})))}Ld.exports={asyncIteratorConcurrentProcess:C0}});var Wd=w((c$,Vd)=>{"use strict";var be=ve(),rn=require("path"),{mkdirs:A0}=Ne(),{pathExists:P0}=Pt(),{utimesMillis:_0}=na(),nn=Yt(),{asyncIteratorConcurrentProcess:k0}=Gd();async function I0(t,e,r={}){typeof r=="function"&&(r={filter:r}),r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
29
|
+
|
|
30
|
+
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0001");let{srcStat:n,destStat:i}=await nn.checkPaths(t,e,"copy",r);if(await nn.checkParentPaths(t,n,e,"copy"),!await Bd(t,e,r))return;let o=rn.dirname(e);await P0(o)||await A0(o),await Ud(i,t,e,r)}async function Bd(t,e,r){return r.filter?r.filter(t,e):!0}async function Ud(t,e,r,n){let s=await(n.dereference?be.stat:be.lstat)(e);if(s.isDirectory())return j0(s,t,e,r,n);if(s.isFile()||s.isCharacterDevice()||s.isBlockDevice())return M0(s,t,e,r,n);if(s.isSymbolicLink())return F0(t,e,r,n);throw s.isSocket()?new Error(`Cannot copy a socket file: ${e}`):s.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${e}`):new Error(`Unknown file: ${e}`)}async function M0(t,e,r,n,i){if(!e)return qd(t,r,n,i);if(i.overwrite)return await be.unlink(n),qd(t,r,n,i);if(i.errorOnExist)throw new Error(`'${n}' already exists`)}async function qd(t,e,r,n){if(await be.copyFile(e,r),n.preserveTimestamps){D0(t.mode)&&await R0(r,t.mode);let i=await be.stat(e);await _0(r,i.atime,i.mtime)}return be.chmod(r,t.mode)}function D0(t){return(t&128)===0}function R0(t,e){return be.chmod(t,e|128)}async function j0(t,e,r,n,i){e||await be.mkdir(n),await k0(await be.opendir(r),async s=>{let o=rn.join(r,s.name),a=rn.join(n,s.name);if(await Bd(o,a,i)){let{destStat:u}=await nn.checkPaths(o,a,"copy",i);await Ud(u,o,a,i)}}),e||await be.chmod(n,t.mode)}async function F0(t,e,r,n){let i=await be.readlink(e);if(n.dereference&&(i=rn.resolve(process.cwd(),i)),!t)return be.symlink(i,r);let s=null;try{s=await be.readlink(r)}catch(o){if(o.code==="EINVAL"||o.code==="UNKNOWN")return be.symlink(i,r);throw o}if(n.dereference&&(s=rn.resolve(process.cwd(),s)),i!==s){if(nn.isSrcSubdir(i,s))throw new Error(`Cannot copy '${i}' to a subdirectory of itself, '${s}'.`);if(nn.isSrcSubdir(s,i))throw new Error(`Cannot overwrite '${s}' with '${i}'.`)}return await be.unlink(r),be.symlink(i,r)}Vd.exports=I0});var Kd=w((l$,zd)=>{"use strict";var Ee=fr(),sn=require("path"),N0=Ne().mkdirsSync,$0=na().utimesMillisSync,on=Yt();function L0(t,e,r){typeof r=="function"&&(r={filter:r}),r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&process.emitWarning(`Using the preserveTimestamps option in 32-bit node is not recommended;
|
|
31
|
+
|
|
32
|
+
see https://github.com/jprichardson/node-fs-extra/issues/269`,"Warning","fs-extra-WARN0002");let{srcStat:n,destStat:i}=on.checkPathsSync(t,e,"copy",r);if(on.checkParentPathsSync(t,n,e,"copy"),r.filter&&!r.filter(t,e))return;let s=sn.dirname(e);return Ee.existsSync(s)||N0(s),Hd(i,t,e,r)}function Hd(t,e,r,n){let s=(n.dereference?Ee.statSync:Ee.lstatSync)(e);if(s.isDirectory())return H0(s,t,e,r,n);if(s.isFile()||s.isCharacterDevice()||s.isBlockDevice())return G0(s,t,e,r,n);if(s.isSymbolicLink())return z0(t,e,r,n);throw s.isSocket()?new Error(`Cannot copy a socket file: ${e}`):s.isFIFO()?new Error(`Cannot copy a FIFO pipe: ${e}`):new Error(`Unknown file: ${e}`)}function G0(t,e,r,n,i){return e?q0(t,r,n,i):Jd(t,r,n,i)}function q0(t,e,r,n){if(n.overwrite)return Ee.unlinkSync(r),Jd(t,e,r,n);if(n.errorOnExist)throw new Error(`'${r}' already exists`)}function Jd(t,e,r,n){return Ee.copyFileSync(e,r),n.preserveTimestamps&&B0(t.mode,e,r),sa(r,t.mode)}function B0(t,e,r){return U0(t)&&V0(r,t),W0(e,r)}function U0(t){return(t&128)===0}function V0(t,e){return sa(t,e|128)}function sa(t,e){return Ee.chmodSync(t,e)}function W0(t,e){let r=Ee.statSync(t);return $0(e,r.atime,r.mtime)}function H0(t,e,r,n,i){return e?Yd(r,n,i):J0(t.mode,r,n,i)}function J0(t,e,r,n){return Ee.mkdirSync(r),Yd(e,r,n),sa(r,t)}function Yd(t,e,r){let n=Ee.opendirSync(t);try{let i;for(;(i=n.readSync())!==null;)Y0(i.name,t,e,r)}finally{n.closeSync()}}function Y0(t,e,r,n){let i=sn.join(e,t),s=sn.join(r,t);if(n.filter&&!n.filter(i,s))return;let{destStat:o}=on.checkPathsSync(i,s,"copy",n);return Hd(o,i,s,n)}function z0(t,e,r,n){let i=Ee.readlinkSync(e);if(n.dereference&&(i=sn.resolve(process.cwd(),i)),t){let s;try{s=Ee.readlinkSync(r)}catch(o){if(o.code==="EINVAL"||o.code==="UNKNOWN")return Ee.symlinkSync(i,r);throw o}if(n.dereference&&(s=sn.resolve(process.cwd(),s)),i!==s){if(on.isSrcSubdir(i,s))throw new Error(`Cannot copy '${i}' to a subdirectory of itself, '${s}'.`);if(on.isSrcSubdir(s,i))throw new Error(`Cannot overwrite '${s}' with '${i}'.`)}return K0(i,r)}else return Ee.symlinkSync(i,r)}function K0(t,e){return Ee.unlinkSync(e),Ee.symlinkSync(t,e)}zd.exports=L0});var ui=w((u$,Xd)=>{"use strict";var X0=ue().fromPromise;Xd.exports={copy:X0(Wd()),copySync:Kd()}});var an=w((d$,Qd)=>{"use strict";var Zd=fr(),Z0=ue().fromCallback;function Q0(t,e){Zd.rm(t,{recursive:!0,force:!0},e)}function eT(t){Zd.rmSync(t,{recursive:!0,force:!0})}Qd.exports={remove:Z0(Q0),removeSync:eT}});var cf=w((f$,af)=>{"use strict";var tT=ue().fromPromise,rf=ve(),nf=require("path"),sf=Ne(),of=an(),ef=tT(async function(e){let r;try{r=await rf.readdir(e)}catch{return sf.mkdirs(e)}return Promise.all(r.map(n=>of.remove(nf.join(e,n))))});function tf(t){let e;try{e=rf.readdirSync(t)}catch{return sf.mkdirsSync(t)}e.forEach(r=>{r=nf.join(t,r),of.removeSync(r)})}af.exports={emptyDirSync:tf,emptydirSync:tf,emptyDir:ef,emptydir:ef}});var ff=w((h$,df)=>{"use strict";var rT=ue().fromPromise,lf=require("path"),dt=ve(),uf=Ne();async function nT(t){let e;try{e=await dt.stat(t)}catch{}if(e&&e.isFile())return;let r=lf.dirname(t),n=null;try{n=await dt.stat(r)}catch(i){if(i.code==="ENOENT"){await uf.mkdirs(r),await dt.writeFile(t,"");return}else throw i}n.isDirectory()?await dt.writeFile(t,""):await dt.readdir(r)}function iT(t){let e;try{e=dt.statSync(t)}catch{}if(e&&e.isFile())return;let r=lf.dirname(t);try{dt.statSync(r).isDirectory()||dt.readdirSync(r)}catch(n){if(n&&n.code==="ENOENT")uf.mkdirsSync(r);else throw n}dt.writeFileSync(t,"")}df.exports={createFile:rT(nT),createFileSync:iT}});var yf=w((p$,gf)=>{"use strict";var sT=ue().fromPromise,hf=require("path"),_t=ve(),pf=Ne(),{pathExists:oT}=Pt(),{areIdentical:mf}=Yt();async function aT(t,e){let r;try{r=await _t.lstat(e)}catch{}let n;try{n=await _t.lstat(t)}catch(o){throw o.message=o.message.replace("lstat","ensureLink"),o}if(r&&mf(n,r))return;let i=hf.dirname(e);await oT(i)||await pf.mkdirs(i),await _t.link(t,e)}function cT(t,e){let r;try{r=_t.lstatSync(e)}catch{}try{let s=_t.lstatSync(t);if(r&&mf(s,r))return}catch(s){throw s.message=s.message.replace("lstat","ensureLink"),s}let n=hf.dirname(e);return _t.existsSync(n)||pf.mkdirsSync(n),_t.linkSync(t,e)}gf.exports={createLink:sT(aT),createLinkSync:cT}});var bf=w((m$,wf)=>{"use strict";var kt=require("path"),cn=ve(),{pathExists:lT}=Pt(),uT=ue().fromPromise;async function dT(t,e){if(kt.isAbsolute(t)){try{await cn.lstat(t)}catch(s){throw s.message=s.message.replace("lstat","ensureSymlink"),s}return{toCwd:t,toDst:t}}let r=kt.dirname(e),n=kt.join(r,t);if(await lT(n))return{toCwd:n,toDst:t};try{await cn.lstat(t)}catch(s){throw s.message=s.message.replace("lstat","ensureSymlink"),s}return{toCwd:t,toDst:kt.relative(r,t)}}function fT(t,e){if(kt.isAbsolute(t)){if(!cn.existsSync(t))throw new Error("absolute srcpath does not exist");return{toCwd:t,toDst:t}}let r=kt.dirname(e),n=kt.join(r,t);if(cn.existsSync(n))return{toCwd:n,toDst:t};if(!cn.existsSync(t))throw new Error("relative srcpath does not exist");return{toCwd:t,toDst:kt.relative(r,t)}}wf.exports={symlinkPaths:uT(dT),symlinkPathsSync:fT}});var vf=w((g$,xf)=>{"use strict";var Sf=ve(),hT=ue().fromPromise;async function pT(t,e){if(e)return e;let r;try{r=await Sf.lstat(t)}catch{return"file"}return r&&r.isDirectory()?"dir":"file"}function mT(t,e){if(e)return e;let r;try{r=Sf.lstatSync(t)}catch{return"file"}return r&&r.isDirectory()?"dir":"file"}xf.exports={symlinkType:hT(pT),symlinkTypeSync:mT}});var Tf=w((y$,Of)=>{"use strict";var gT=ue().fromPromise,It=require("path"),Ce=ve(),{mkdirs:yT,mkdirsSync:wT}=Ne(),{symlinkPaths:bT,symlinkPathsSync:ST}=bf(),{symlinkType:xT,symlinkTypeSync:vT}=vf(),{pathExists:ET}=Pt(),{areIdentical:Ef}=Yt();async function OT(t,e,r){let n;try{n=await Ce.lstat(e)}catch{}if(n&&n.isSymbolicLink()){let a;if(It.isAbsolute(t))a=await Ce.stat(t);else{let u=It.dirname(e),c=It.join(u,t);try{a=await Ce.stat(c)}catch{a=await Ce.stat(t)}}let l=await Ce.stat(e);if(Ef(a,l))return}let i=await bT(t,e);t=i.toDst;let s=await xT(i.toCwd,r),o=It.dirname(e);return await ET(o)||await yT(o),Ce.symlink(t,e,s)}function TT(t,e,r){let n;try{n=Ce.lstatSync(e)}catch{}if(n&&n.isSymbolicLink()){let a;if(It.isAbsolute(t))a=Ce.statSync(t);else{let u=It.dirname(e),c=It.join(u,t);try{a=Ce.statSync(c)}catch{a=Ce.statSync(t)}}let l=Ce.statSync(e);if(Ef(a,l))return}let i=ST(t,e);t=i.toDst,r=vT(i.toCwd,r);let s=It.dirname(e);return Ce.existsSync(s)||wT(s),Ce.symlinkSync(t,e,r)}Of.exports={createSymlink:gT(OT),createSymlinkSync:TT}});var Df=w((w$,Mf)=>{"use strict";var{createFile:Cf,createFileSync:Af}=ff(),{createLink:Pf,createLinkSync:_f}=yf(),{createSymlink:kf,createSymlinkSync:If}=Tf();Mf.exports={createFile:Cf,createFileSync:Af,ensureFile:Cf,ensureFileSync:Af,createLink:Pf,createLinkSync:_f,ensureLink:Pf,ensureLinkSync:_f,createSymlink:kf,createSymlinkSync:If,ensureSymlink:kf,ensureSymlinkSync:If}});var di=w((b$,Rf)=>{function CT(t,{EOL:e=`
|
|
33
|
+
`,finalEOL:r=!0,replacer:n=null,spaces:i}={}){let s=r?e:"";return JSON.stringify(t,n,i).replace(/\n/g,e)+s}function AT(t){return Buffer.isBuffer(t)&&(t=t.toString("utf8")),t.replace(/^\uFEFF/,"")}Rf.exports={stringify:CT,stripBom:AT}});var $f=w((S$,Nf)=>{var mr;try{mr=fr()}catch{mr=require("fs")}var fi=ue(),{stringify:jf,stripBom:Ff}=di();async function PT(t,e={}){typeof e=="string"&&(e={encoding:e});let r=e.fs||mr,n="throws"in e?e.throws:!0,i=await fi.fromCallback(r.readFile)(t,e);i=Ff(i);let s;try{s=JSON.parse(i,e?e.reviver:null)}catch(o){if(n)throw o.message=`${t}: ${o.message}`,o;return null}return s}var _T=fi.fromPromise(PT);function kT(t,e={}){typeof e=="string"&&(e={encoding:e});let r=e.fs||mr,n="throws"in e?e.throws:!0;try{let i=r.readFileSync(t,e);return i=Ff(i),JSON.parse(i,e.reviver)}catch(i){if(n)throw i.message=`${t}: ${i.message}`,i;return null}}async function IT(t,e,r={}){let n=r.fs||mr,i=jf(e,r);await fi.fromCallback(n.writeFile)(t,i,r)}var MT=fi.fromPromise(IT);function DT(t,e,r={}){let n=r.fs||mr,i=jf(e,r);return n.writeFileSync(t,i,r)}Nf.exports={readFile:_T,readFileSync:kT,writeFile:MT,writeFileSync:DT}});var Gf=w((x$,Lf)=>{"use strict";var hi=$f();Lf.exports={readJson:hi.readFile,readJsonSync:hi.readFileSync,writeJson:hi.writeFile,writeJsonSync:hi.writeFileSync}});var pi=w((v$,Uf)=>{"use strict";var RT=ue().fromPromise,oa=ve(),qf=require("path"),Bf=Ne(),jT=Pt().pathExists;async function FT(t,e,r="utf-8"){let n=qf.dirname(t);return await jT(n)||await Bf.mkdirs(n),oa.writeFile(t,e,r)}function NT(t,...e){let r=qf.dirname(t);oa.existsSync(r)||Bf.mkdirsSync(r),oa.writeFileSync(t,...e)}Uf.exports={outputFile:RT(FT),outputFileSync:NT}});var Wf=w((E$,Vf)=>{"use strict";var{stringify:$T}=di(),{outputFile:LT}=pi();async function GT(t,e,r={}){let n=$T(e,r);await LT(t,n,r)}Vf.exports=GT});var Jf=w((O$,Hf)=>{"use strict";var{stringify:qT}=di(),{outputFileSync:BT}=pi();function UT(t,e,r){let n=qT(e,r);BT(t,n,r)}Hf.exports=UT});var zf=w((T$,Yf)=>{"use strict";var VT=ue().fromPromise,Oe=Gf();Oe.outputJson=VT(Wf());Oe.outputJsonSync=Jf();Oe.outputJSON=Oe.outputJson;Oe.outputJSONSync=Oe.outputJsonSync;Oe.writeJSON=Oe.writeJson;Oe.writeJSONSync=Oe.writeJsonSync;Oe.readJSON=Oe.readJson;Oe.readJSONSync=Oe.readJsonSync;Yf.exports=Oe});var eh=w((C$,Qf)=>{"use strict";var WT=ve(),Kf=require("path"),{copy:HT}=ui(),{remove:Zf}=an(),{mkdirp:JT}=Ne(),{pathExists:YT}=Pt(),Xf=Yt();async function zT(t,e,r={}){let n=r.overwrite||r.clobber||!1,{srcStat:i,isChangingCase:s=!1}=await Xf.checkPaths(t,e,"move",r);await Xf.checkParentPaths(t,i,e,"move");let o=Kf.dirname(e);return Kf.parse(o).root!==o&&await JT(o),KT(t,e,n,s)}async function KT(t,e,r,n){if(!n){if(r)await Zf(e);else if(await YT(e))throw new Error("dest already exists.")}try{await WT.rename(t,e)}catch(i){if(i.code!=="EXDEV")throw i;await XT(t,e,r)}}async function XT(t,e,r){return await HT(t,e,{overwrite:r,errorOnExist:!0,preserveTimestamps:!0}),Zf(t)}Qf.exports=zT});var sh=w((A$,ih)=>{"use strict";var rh=fr(),ca=require("path"),ZT=ui().copySync,nh=an().removeSync,QT=Ne().mkdirpSync,th=Yt();function eC(t,e,r){r=r||{};let n=r.overwrite||r.clobber||!1,{srcStat:i,isChangingCase:s=!1}=th.checkPathsSync(t,e,"move",r);return th.checkParentPathsSync(t,i,e,"move"),tC(e)||QT(ca.dirname(e)),rC(t,e,n,s)}function tC(t){let e=ca.dirname(t);return ca.parse(e).root===e}function rC(t,e,r,n){if(n)return aa(t,e,r);if(r)return nh(e),aa(t,e,r);if(rh.existsSync(e))throw new Error("dest already exists.");return aa(t,e,r)}function aa(t,e,r){try{rh.renameSync(t,e)}catch(n){if(n.code!=="EXDEV")throw n;return nC(t,e,r)}}function nC(t,e,r){return ZT(t,e,{overwrite:r,errorOnExist:!0,preserveTimestamps:!0}),nh(t)}ih.exports=eC});var ah=w((P$,oh)=>{"use strict";var iC=ue().fromPromise;oh.exports={move:iC(eh()),moveSync:sh()}});var fe=w((_$,ch)=>{"use strict";ch.exports={...ve(),...ui(),...cf(),...Df(),...zf(),...Ne(),...ah(),...pi(),...Pt(),...an()}});var ie=w((k$,uh)=>{"use strict";var{FORCE_COLOR:sC,NODE_DISABLE_COLORS:oC,TERM:aC}=process.env,V={enabled:!oC&&aC!=="dumb"&&sC!=="0",reset:J(0,0),bold:J(1,22),dim:J(2,22),italic:J(3,23),underline:J(4,24),inverse:J(7,27),hidden:J(8,28),strikethrough:J(9,29),black:J(30,39),red:J(31,39),green:J(32,39),yellow:J(33,39),blue:J(34,39),magenta:J(35,39),cyan:J(36,39),white:J(37,39),gray:J(90,39),grey:J(90,39),bgBlack:J(40,49),bgRed:J(41,49),bgGreen:J(42,49),bgYellow:J(43,49),bgBlue:J(44,49),bgMagenta:J(45,49),bgCyan:J(46,49),bgWhite:J(47,49)};function lh(t,e){let r=0,n,i="",s="";for(;r<t.length;r++)n=t[r],i+=n.open,s+=n.close,e.includes(n.close)&&(e=e.replace(n.rgx,n.close+n.open));return i+e+s}function cC(t,e){let r={has:t,keys:e};return r.reset=V.reset.bind(r),r.bold=V.bold.bind(r),r.dim=V.dim.bind(r),r.italic=V.italic.bind(r),r.underline=V.underline.bind(r),r.inverse=V.inverse.bind(r),r.hidden=V.hidden.bind(r),r.strikethrough=V.strikethrough.bind(r),r.black=V.black.bind(r),r.red=V.red.bind(r),r.green=V.green.bind(r),r.yellow=V.yellow.bind(r),r.blue=V.blue.bind(r),r.magenta=V.magenta.bind(r),r.cyan=V.cyan.bind(r),r.white=V.white.bind(r),r.gray=V.gray.bind(r),r.grey=V.grey.bind(r),r.bgBlack=V.bgBlack.bind(r),r.bgRed=V.bgRed.bind(r),r.bgGreen=V.bgGreen.bind(r),r.bgYellow=V.bgYellow.bind(r),r.bgBlue=V.bgBlue.bind(r),r.bgMagenta=V.bgMagenta.bind(r),r.bgCyan=V.bgCyan.bind(r),r.bgWhite=V.bgWhite.bind(r),r}function J(t,e){let r={open:`\x1B[${t}m`,close:`\x1B[${e}m`,rgx:new RegExp(`\\x1b\\[${e}m`,"g")};return function(n){return this!==void 0&&this.has!==void 0?(this.has.includes(t)||(this.has.push(t),this.keys.push(r)),n===void 0?this:V.enabled?lh(this.keys,n+""):n+""):n===void 0?cC([t],[r]):V.enabled?lh([r],n+""):n+""}}uh.exports=V});var fh=w((I$,dh)=>{"use strict";dh.exports=(t,e)=>{if(!(t.meta&&t.name!=="escape")){if(t.ctrl){if(t.name==="a")return"first";if(t.name==="c"||t.name==="d")return"abort";if(t.name==="e")return"last";if(t.name==="g")return"reset"}if(e){if(t.name==="j")return"down";if(t.name==="k")return"up"}return t.name==="return"||t.name==="enter"?"submit":t.name==="backspace"?"delete":t.name==="delete"?"deleteForward":t.name==="abort"?"abort":t.name==="escape"?"exit":t.name==="tab"?"next":t.name==="pagedown"?"nextPage":t.name==="pageup"?"prevPage":t.name==="home"?"home":t.name==="end"?"end":t.name==="up"?"up":t.name==="down"?"down":t.name==="right"?"right":t.name==="left"?"left":!1}}});var mi=w((M$,hh)=>{"use strict";hh.exports=t=>{let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),r=new RegExp(e,"g");return typeof t=="string"?t.replace(r,""):t}});var se=w((D$,ph)=>{"use strict";var la={to(t,e){return e?`\x1B[${e+1};${t+1}H`:`\x1B[${t+1}G`},move(t,e){let r="";return t<0?r+=`\x1B[${-t}D`:t>0&&(r+=`\x1B[${t}C`),e<0?r+=`\x1B[${-e}A`:e>0&&(r+=`\x1B[${e}B`),r},up:(t=1)=>`\x1B[${t}A`,down:(t=1)=>`\x1B[${t}B`,forward:(t=1)=>`\x1B[${t}C`,backward:(t=1)=>`\x1B[${t}D`,nextLine:(t=1)=>"\x1B[E".repeat(t),prevLine:(t=1)=>"\x1B[F".repeat(t),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},lC={up:(t=1)=>"\x1B[S".repeat(t),down:(t=1)=>"\x1B[T".repeat(t)},uC={screen:"\x1B[2J",up:(t=1)=>"\x1B[1J".repeat(t),down:(t=1)=>"\x1B[J".repeat(t),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(t){let e="";for(let r=0;r<t;r++)e+=this.line+(r<t-1?la.up():"");return t&&(e+=la.left),e}};ph.exports={cursor:la,scroll:lC,erase:uC,beep:"\x07"}});var bh=w((R$,wh)=>{"use strict";function dC(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=fC(t))||e&&t&&typeof t.length=="number"){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
34
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){r=r.call(t)},n:function(){var u=r.next();return s=u.done,u},e:function(u){o=!0,a=u},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw a}}}}function fC(t,e){if(t){if(typeof t=="string")return mh(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return mh(t,e)}}function mh(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var hC=mi(),yh=se(),gh=yh.erase,pC=yh.cursor,mC=t=>[...hC(t)].length;wh.exports=function(t,e){if(!e)return gh.line+pC.to(0);let r=0,n=t.split(/\r?\n/);var i=dC(n),s;try{for(i.s();!(s=i.n()).done;){let o=s.value;r+=1+Math.floor(Math.max(mC(o)-1,0)/e)}}catch(o){i.e(o)}finally{i.f()}return gh.lines(r)}});var ua=w((j$,Sh)=>{"use strict";var ln={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},gC={arrowUp:ln.arrowUp,arrowDown:ln.arrowDown,arrowLeft:ln.arrowLeft,arrowRight:ln.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},yC=process.platform==="win32"?gC:ln;Sh.exports=yC});var vh=w((F$,xh)=>{"use strict";var gr=ie(),zt=ua(),da=Object.freeze({password:{scale:1,render:t=>"*".repeat(t.length)},emoji:{scale:2,render:t=>"\u{1F603}".repeat(t.length)},invisible:{scale:0,render:t=>""},default:{scale:1,render:t=>`${t}`}}),wC=t=>da[t]||da.default,un=Object.freeze({aborted:gr.red(zt.cross),done:gr.green(zt.tick),exited:gr.yellow(zt.cross),default:gr.cyan("?")}),bC=(t,e,r)=>e?un.aborted:r?un.exited:t?un.done:un.default,SC=t=>gr.gray(t?zt.ellipsis:zt.pointerSmall),xC=(t,e)=>gr.gray(t?e?zt.pointerSmall:"+":zt.line);xh.exports={styles:da,render:wC,symbols:un,symbol:bC,delimiter:SC,item:xC}});var Oh=w((N$,Eh)=>{"use strict";var vC=mi();Eh.exports=function(t,e){let r=String(vC(t)||"").split(/\r?\n/);return e?r.map(n=>Math.ceil(n.length/e)).reduce((n,i)=>n+i):r.length}});var Ch=w(($$,Th)=>{"use strict";Th.exports=(t,e={})=>{let r=Number.isSafeInteger(parseInt(e.margin))?new Array(parseInt(e.margin)).fill(" ").join(""):e.margin||"",n=e.width;return(t||"").split(/\r?\n/g).map(i=>i.split(/\s+/g).reduce((s,o)=>(o.length+r.length>=n||s[s.length-1].length+o.length+1<n?s[s.length-1]+=` ${o}`:s.push(`${r}${o}`),s),[r]).join(`
|
|
35
|
+
`)).join(`
|
|
36
|
+
`)}});var Ph=w((L$,Ah)=>{"use strict";Ah.exports=(t,e,r)=>{r=r||e;let n=Math.min(e-r,t-Math.floor(r/2));n<0&&(n=0);let i=Math.min(n+r,e);return{startIndex:n,endIndex:i}}});var $e=w((G$,_h)=>{"use strict";_h.exports={action:fh(),clear:bh(),style:vh(),strip:mi(),figures:ua(),lines:Oh(),wrap:Ch(),entriesToDisplay:Ph()}});var ft=w((q$,Mh)=>{"use strict";var kh=require("readline"),EC=$e(),OC=EC.action,TC=require("events"),Ih=se(),CC=Ih.beep,AC=Ih.cursor,PC=ie(),fa=class extends TC{constructor(e={}){super(),this.firstRender=!0,this.in=e.stdin||process.stdin,this.out=e.stdout||process.stdout,this.onRender=(e.onRender||(()=>{})).bind(this);let r=kh.createInterface({input:this.in,escapeCodeTimeout:50});kh.emitKeypressEvents(this.in,r),this.in.isTTY&&this.in.setRawMode(!0);let n=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,i=(s,o)=>{let a=OC(o,n);a===!1?this._&&this._(s,o):typeof this[a]=="function"?this[a](o):this.bell()};this.close=()=>{this.out.write(AC.show),this.in.removeListener("keypress",i),this.in.isTTY&&this.in.setRawMode(!1),r.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",i)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(CC)}render(){this.onRender(PC),this.firstRender&&(this.firstRender=!1)}};Mh.exports=fa});var Nh=w((B$,Fh)=>{"use strict";function Dh(t,e,r,n,i,s,o){try{var a=t[s](o),l=a.value}catch(u){r(u);return}a.done?e(l):Promise.resolve(l).then(n,i)}function Rh(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function o(l){Dh(s,n,i,o,a,"next",l)}function a(l){Dh(s,n,i,o,a,"throw",l)}o(void 0)})}}var gi=ie(),_C=ft(),jh=se(),kC=jh.erase,dn=jh.cursor,yi=$e(),ha=yi.style,pa=yi.clear,IC=yi.lines,MC=yi.figures,ma=class extends _C{constructor(e={}){super(e),this.transform=ha.render(e.style),this.scale=this.transform.scale,this.msg=e.message,this.initial=e.initial||"",this.validator=e.validate||(()=>!0),this.value="",this.errorMsg=e.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=pa("",this.out.columns),this.render()}set value(e){!e&&this.initial?(this.placeholder=!0,this.rendered=gi.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(e)),this._value=e,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=+!!this.initial,this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
|
|
37
|
+
`),this.close()}validate(){var e=this;return Rh(function*(){let r=yield e.validator(e.value);typeof r=="string"&&(e.errorMsg=r,r=!1),e.error=!r})()}submit(){var e=this;return Rh(function*(){if(e.value=e.value||e.initial,e.cursorOffset=0,e.cursor=e.rendered.length,yield e.validate(),e.error){e.red=!0,e.fire(),e.render();return}e.done=!0,e.aborted=!1,e.fire(),e.render(),e.out.write(`
|
|
38
|
+
`),e.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(e){this.placeholder||(this.cursor=this.cursor+e,this.cursorOffset+=e)}_(e,r){let n=this.value.slice(0,this.cursor),i=this.value.slice(this.cursor);this.value=`${n}${e}${i}`,this.red=!1,this.cursor=this.placeholder?0:n.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let e=this.value.slice(0,this.cursor-1),r=this.value.slice(this.cursor);this.value=`${e}${r}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let e=this.value.slice(0,this.cursor),r=this.value.slice(this.cursor+1);this.value=`${e}${r}`,this.red=!1,this.isCursorAtEnd()?this.cursorOffset=0:this.cursorOffset++,this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(dn.down(IC(this.outputError,this.out.columns)-1)+pa(this.outputError,this.out.columns)),this.out.write(pa(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[ha.symbol(this.done,this.aborted),gi.bold(this.msg),ha.delimiter(this.done),this.red?gi.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
39
|
+
`).reduce((e,r,n)=>e+`
|
|
40
|
+
${n?" ":MC.pointerSmall} ${gi.red().italic(r)}`,"")),this.out.write(kC.line+dn.to(0)+this.outputText+dn.save+this.outputError+dn.restore+dn.move(this.cursorOffset,0)))}};Fh.exports=ma});var qh=w((U$,Gh)=>{"use strict";var ht=ie(),DC=ft(),fn=$e(),$h=fn.style,Lh=fn.clear,wi=fn.figures,RC=fn.wrap,jC=fn.entriesToDisplay,FC=se(),NC=FC.cursor,ga=class extends DC{constructor(e={}){super(e),this.msg=e.message,this.hint=e.hint||"- Use arrow-keys. Return to submit.",this.warn=e.warn||"- This option is disabled",this.cursor=e.initial||0,this.choices=e.choices.map((r,n)=>(typeof r=="string"&&(r={title:r,value:n}),{title:r&&(r.title||r.value||r),value:r&&(r.value===void 0?n:r.value),description:r&&r.description,selected:r&&r.selected,disabled:r&&r.disabled})),this.optionsPerPage=e.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=Lh("",this.out.columns),this.render()}moveCursor(e){this.cursor=e,this.value=this.choices[e].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
41
|
+
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
42
|
+
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(e,r){if(e===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(NC.hide):this.out.write(Lh(this.outputText,this.out.columns)),super.render();let e=jC(this.cursor,this.choices.length,this.optionsPerPage),r=e.startIndex,n=e.endIndex;if(this.outputText=[$h.symbol(this.done,this.aborted),ht.bold(this.msg),$h.delimiter(!1),this.done?this.selection.title:this.selection.disabled?ht.yellow(this.warn):ht.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
43
|
+
`;for(let i=r;i<n;i++){let s,o,a="",l=this.choices[i];i===r&&r>0?o=wi.arrowUp:i===n-1&&n<this.choices.length?o=wi.arrowDown:o=" ",l.disabled?(s=this.cursor===i?ht.gray().underline(l.title):ht.strikethrough().gray(l.title),o=(this.cursor===i?ht.bold().gray(wi.pointer)+" ":" ")+o):(s=this.cursor===i?ht.cyan().underline(l.title):l.title,o=(this.cursor===i?ht.cyan(wi.pointer)+" ":" ")+o,l.description&&this.cursor===i&&(a=` - ${l.description}`,(o.length+s.length+a.length>=this.out.columns||l.description.split(/\r?\n/).length>1)&&(a=`
|
|
44
|
+
`+RC(l.description,{margin:3,width:this.out.columns})))),this.outputText+=`${o} ${s}${ht.gray(a)}
|
|
45
|
+
`}}this.out.write(this.outputText)}};Gh.exports=ga});var Jh=w((V$,Hh)=>{"use strict";var bi=ie(),$C=ft(),Vh=$e(),Bh=Vh.style,LC=Vh.clear,Wh=se(),Uh=Wh.cursor,GC=Wh.erase,ya=class extends $C{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active||"on",this.inactive=e.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
46
|
+
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
47
|
+
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,r){if(e===" ")this.value=!this.value;else if(e==="1")this.value=!0;else if(e==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(Uh.hide):this.out.write(LC(this.outputText,this.out.columns)),super.render(),this.outputText=[Bh.symbol(this.done,this.aborted),bi.bold(this.msg),Bh.delimiter(this.done),this.value?this.inactive:bi.cyan().underline(this.inactive),bi.gray("/"),this.value?bi.cyan().underline(this.active):this.active].join(" "),this.out.write(GC.line+Uh.to(0)+this.outputText))}};Hh.exports=ya});var Je=w((W$,Yh)=>{"use strict";var wa=class t{constructor({token:e,date:r,parts:n,locales:i}){this.token=e,this.date=r||new Date,this.parts=n||[this],this.locales=i||{}}up(){}down(){}next(){let e=this.parts.indexOf(this);return this.parts.find((r,n)=>n>e&&r instanceof t)}setTo(e){}prev(){let e=[].concat(this.parts).reverse(),r=e.indexOf(this);return e.find((n,i)=>i>r&&n instanceof t)}toString(){return String(this.date)}};Yh.exports=wa});var Kh=w((H$,zh)=>{"use strict";var qC=Je(),ba=class extends qC{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?e.toUpperCase():e}};zh.exports=ba});var Zh=w((J$,Xh)=>{"use strict";var BC=Je(),UC=t=>(t=t%10,t===1?"st":t===2?"nd":t===3?"rd":"th"),Sa=class extends BC{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),r=this.date.getDay();return this.token==="DD"?String(e).padStart(2,"0"):this.token==="Do"?e+UC(e):this.token==="d"?r+1:this.token==="ddd"?this.locales.weekdaysShort[r]:this.token==="dddd"?this.locales.weekdays[r]:e}};Xh.exports=Sa});var ep=w((Y$,Qh)=>{"use strict";var VC=Je(),xa=class extends VC{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,"0"):e}};Qh.exports=xa});var rp=w((z$,tp)=>{"use strict";var WC=Je(),va=class extends WC{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};tp.exports=va});var ip=w((K$,np)=>{"use strict";var HC=Je(),Ea=class extends HC{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,"0"):e}};np.exports=Ea});var op=w((X$,sp)=>{"use strict";var JC=Je(),Oa=class extends JC{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),r=this.token.length;return r===2?String(e+1).padStart(2,"0"):r===3?this.locales.monthsShort[e]:r===4?this.locales.months[e]:String(e+1)}};sp.exports=Oa});var cp=w((Z$,ap)=>{"use strict";var YC=Je(),Ta=class extends YC{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,"0"):e}};ap.exports=Ta});var up=w((Q$,lp)=>{"use strict";var zC=Je(),Ca=class extends zC{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?e.substr(-2):e}};lp.exports=Ca});var fp=w((e2,dp)=>{"use strict";dp.exports={DatePart:Je(),Meridiem:Kh(),Day:Zh(),Hours:ep(),Milliseconds:rp(),Minutes:ip(),Month:op(),Seconds:cp(),Year:up()}});var vp=w((t2,xp)=>{"use strict";function hp(t,e,r,n,i,s,o){try{var a=t[s](o),l=a.value}catch(u){r(u);return}a.done?e(l):Promise.resolve(l).then(n,i)}function pp(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function o(l){hp(s,n,i,o,a,"next",l)}function a(l){hp(s,n,i,o,a,"throw",l)}o(void 0)})}}var Aa=ie(),KC=ft(),_a=$e(),mp=_a.style,gp=_a.clear,XC=_a.figures,Sp=se(),ZC=Sp.erase,yp=Sp.cursor,pt=fp(),wp=pt.DatePart,QC=pt.Meridiem,eA=pt.Day,tA=pt.Hours,rA=pt.Milliseconds,nA=pt.Minutes,iA=pt.Month,sA=pt.Seconds,oA=pt.Year,aA=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,bp={1:({token:t})=>t.replace(/\\(.)/g,"$1"),2:t=>new eA(t),3:t=>new iA(t),4:t=>new oA(t),5:t=>new QC(t),6:t=>new tA(t),7:t=>new nA(t),8:t=>new sA(t),9:t=>new rA(t)},cA={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")},Pa=class extends KC{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed="",this.locales=Object.assign(cA,e.locales),this._date=e.initial||new Date,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.mask=e.mask||"YYYY-MM-DD HH:mm:ss",this.clear=gp("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(e){e&&this._date.setTime(e.getTime())}set mask(e){let r;for(this.parts=[];r=aA.exec(e);){let i=r.shift(),s=r.findIndex(o=>o!=null);this.parts.push(s in bp?bp[s]({token:r[s]||i,date:this.date,parts:this.parts,locales:this.locales}):r[s]||i)}let n=this.parts.reduce((i,s)=>(typeof s=="string"&&typeof i[i.length-1]=="string"?i[i.length-1]+=s:i.push(s),i),[]);this.parts.splice(0),this.parts.push(...n),this.reset()}moveCursor(e){this.typed="",this.cursor=e,this.fire()}reset(){this.moveCursor(this.parts.findIndex(e=>e instanceof wp)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
48
|
+
`),this.close()}validate(){var e=this;return pp(function*(){let r=yield e.validator(e.value);typeof r=="string"&&(e.errorMsg=r,r=!1),e.error=!r})()}submit(){var e=this;return pp(function*(){if(yield e.validate(),e.error){e.color="red",e.fire(),e.render();return}e.done=!0,e.aborted=!1,e.fire(),e.render(),e.out.write(`
|
|
49
|
+
`),e.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(r=>r instanceof wp)),this.render()}_(e){/\d/.test(e)&&(this.typed+=e,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(yp.hide):this.out.write(gp(this.outputText,this.out.columns)),super.render(),this.outputText=[mp.symbol(this.done,this.aborted),Aa.bold(this.msg),mp.delimiter(!1),this.parts.reduce((e,r,n)=>e.concat(n===this.cursor&&!this.done?Aa.cyan().underline(r.toString()):r),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
50
|
+
`).reduce((e,r,n)=>e+`
|
|
51
|
+
${n?" ":XC.pointerSmall} ${Aa.red().italic(r)}`,"")),this.out.write(ZC.line+yp.to(0)+this.outputText))}};xp.exports=Pa});var _p=w((r2,Pp)=>{"use strict";function Ep(t,e,r,n,i,s,o){try{var a=t[s](o),l=a.value}catch(u){r(u);return}a.done?e(l):Promise.resolve(l).then(n,i)}function Op(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function o(l){Ep(s,n,i,o,a,"next",l)}function a(l){Ep(s,n,i,o,a,"throw",l)}o(void 0)})}}var Si=ie(),lA=ft(),Ap=se(),xi=Ap.cursor,uA=Ap.erase,vi=$e(),ka=vi.style,dA=vi.figures,Tp=vi.clear,fA=vi.lines,hA=/[0-9]/,Ia=t=>t!==void 0,Cp=(t,e)=>{let r=Math.pow(10,e);return Math.round(t*r)/r},Ma=class extends lA{constructor(e={}){super(e),this.transform=ka.render(e.style),this.msg=e.message,this.initial=Ia(e.initial)?e.initial:"",this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=Ia(e.min)?e.min:-1/0,this.max=Ia(e.max)?e.max:1/0,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(e){!e&&e!==0?(this.placeholder=!0,this.rendered=Si.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${Cp(e,this.round)}`),this._value=Cp(e,this.round)),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return e==="-"||e==="."&&this.float||hA.test(e)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let e=this.value;this.value=e!==""?e:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
52
|
+
`),this.close()}validate(){var e=this;return Op(function*(){let r=yield e.validator(e.value);typeof r=="string"&&(e.errorMsg=r,r=!1),e.error=!r})()}submit(){var e=this;return Op(function*(){if(yield e.validate(),e.error){e.color="red",e.fire(),e.render();return}let r=e.value;e.value=r!==""?r:e.initial,e.done=!0,e.aborted=!1,e.error=!1,e.fire(),e.render(),e.out.write(`
|
|
53
|
+
`),e.close()})()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,r){if(!this.valid(e))return this.bell();let n=Date.now();if(n-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=n,this.color="cyan",e===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(xi.down(fA(this.outputError,this.out.columns)-1)+Tp(this.outputError,this.out.columns)),this.out.write(Tp(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[ka.symbol(this.done,this.aborted),Si.bold(this.msg),ka.delimiter(this.done),!this.done||!this.done&&!this.placeholder?Si[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
54
|
+
`).reduce((e,r,n)=>e+`
|
|
55
|
+
${n?" ":dA.pointerSmall} ${Si.red().italic(r)}`,"")),this.out.write(uA.line+xi.to(0)+this.outputText+xi.save+this.outputError+xi.restore))}};Pp.exports=Ma});var Ra=w((n2,Mp)=>{"use strict";var Ye=ie(),pA=se(),mA=pA.cursor,gA=ft(),hn=$e(),kp=hn.clear,Mt=hn.figures,Ip=hn.style,yA=hn.wrap,wA=hn.entriesToDisplay,Da=class extends gA{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.scrollIndex=e.cursor||0,this.hint=e.hint||"",this.warn=e.warn||"- This option is disabled -",this.minSelected=e.min,this.showMinError=!1,this.maxChoices=e.max,this.instructions=e.instructions,this.optionsPerPage=e.optionsPerPage||10,this.value=e.choices.map((r,n)=>(typeof r=="string"&&(r={title:r,value:n}),{title:r&&(r.title||r.value||r),description:r&&r.description,value:r&&(r.value===void 0?n:r.value),selected:r&&r.selected,disabled:r&&r.disabled})),this.clear=kp("",this.out.columns),e.overrideRender||this.render()}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
56
|
+
`),this.close()}submit(){let e=this.value.filter(r=>r.selected);this.minSelected&&e.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
57
|
+
`),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let e=this.value[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(r=>r.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let e=!this.value[this.cursor].selected;this.value.filter(r=>!r.disabled).forEach(r=>r.selected=e),this.render()}_(e,r){if(e===" ")this.handleSpaceToggle();else if(e==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
58
|
+
Instructions:
|
|
59
|
+
${Mt.arrowUp}/${Mt.arrowDown}: Highlight option
|
|
60
|
+
${Mt.arrowLeft}/${Mt.arrowRight}/[space]: Toggle selection
|
|
61
|
+
`+(this.maxChoices===void 0?` a: Toggle all
|
|
62
|
+
`:"")+" enter/return: Complete answer":""}renderOption(e,r,n,i){let s=(r.selected?Ye.green(Mt.radioOn):Mt.radioOff)+" "+i+" ",o,a;return r.disabled?o=e===n?Ye.gray().underline(r.title):Ye.strikethrough().gray(r.title):(o=e===n?Ye.cyan().underline(r.title):r.title,e===n&&r.description&&(a=` - ${r.description}`,(s.length+o.length+a.length>=this.out.columns||r.description.split(/\r?\n/).length>1)&&(a=`
|
|
63
|
+
`+yA(r.description,{margin:s.length,width:this.out.columns})))),s+o+Ye.gray(a||"")}paginateOptions(e){if(e.length===0)return Ye.red("No matches for this query.");let r=wA(this.cursor,e.length,this.optionsPerPage),n=r.startIndex,i=r.endIndex,s,o=[];for(let a=n;a<i;a++)a===n&&n>0?s=Mt.arrowUp:a===i-1&&i<e.length?s=Mt.arrowDown:s=" ",o.push(this.renderOption(this.cursor,e[a],a,s));return`
|
|
64
|
+
`+o.join(`
|
|
65
|
+
`)}renderOptions(e){return this.done?"":this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[Ye.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(Ye.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(mA.hide),super.render();let e=[Ip.symbol(this.done,this.aborted),Ye.bold(this.msg),Ip.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=Ye.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=kp(e,this.out.columns)}};Mp.exports=Da});var Lp=w((i2,$p)=>{"use strict";function Dp(t,e,r,n,i,s,o){try{var a=t[s](o),l=a.value}catch(u){r(u);return}a.done?e(l):Promise.resolve(l).then(n,i)}function bA(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function o(l){Dp(s,n,i,o,a,"next",l)}function a(l){Dp(s,n,i,o,a,"throw",l)}o(void 0)})}}var pn=ie(),SA=ft(),Np=se(),xA=Np.erase,Rp=Np.cursor,mn=$e(),ja=mn.style,jp=mn.clear,Fa=mn.figures,vA=mn.wrap,EA=mn.entriesToDisplay,Fp=(t,e)=>t[e]&&(t[e].value||t[e].title||t[e]),OA=(t,e)=>t[e]&&(t[e].title||t[e].value||t[e]),TA=(t,e)=>{let r=t.findIndex(n=>n.value===e||n.title===e);return r>-1?r:void 0},Na=class extends SA{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=typeof e.initial=="number"?e.initial:TA(e.choices,e.initial),this.select=this.initial||e.cursor||0,this.i18n={noMatches:e.noMatches||"no matches found"},this.fallback=e.fallback||this.initial,this.clearFirst=e.clearFirst||!1,this.suggestions=[],this.input="",this.limit=e.limit||10,this.cursor=0,this.transform=ja.render(e.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=jp("",this.out.columns),this.complete(this.render),this.render()}set fallback(e){this._fb=Number.isSafeInteger(parseInt(e))?parseInt(e):e}get fallback(){let e;return typeof this._fb=="number"?e=this.choices[this._fb]:typeof this._fb=="string"&&(e={title:this._fb}),e||this._fb||{title:this.i18n.noMatches}}moveSelect(e){this.select=e,this.suggestions.length>0?this.value=Fp(this.suggestions,e):this.value=this.fallback.value,this.fire()}complete(e){var r=this;return bA(function*(){let n=r.completing=r.suggest(r.input,r.choices),i=yield n;if(r.completing!==n)return;r.suggestions=i.map((o,a,l)=>({title:OA(l,a),value:Fp(l,a),description:o.description})),r.completing=!1;let s=Math.max(i.length-1,0);r.moveSelect(Math.min(s,r.select)),e&&e()})()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
66
|
+
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
67
|
+
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
68
|
+
`),this.close()}_(e,r){let n=this.input.slice(0,this.cursor),i=this.input.slice(this.cursor);this.input=`${n}${e}${i}`,this.cursor=n.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let e=this.input.slice(0,this.cursor-1),r=this.input.slice(this.cursor);this.input=`${e}${r}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let e=this.input.slice(0,this.cursor),r=this.input.slice(this.cursor+1);this.input=`${e}${r}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(e,r,n,i){let s,o=n?Fa.arrowUp:i?Fa.arrowDown:" ",a=r?pn.cyan().underline(e.title):e.title;return o=(r?pn.cyan(Fa.pointer)+" ":" ")+o,e.description&&(s=` - ${e.description}`,(o.length+a.length+s.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(s=`
|
|
69
|
+
`+vA(e.description,{margin:3,width:this.out.columns}))),o+" "+a+pn.gray(s||"")}render(){if(this.closed)return;this.firstRender?this.out.write(Rp.hide):this.out.write(jp(this.outputText,this.out.columns)),super.render();let e=EA(this.select,this.choices.length,this.limit),r=e.startIndex,n=e.endIndex;if(this.outputText=[ja.symbol(this.done,this.aborted,this.exited),pn.bold(this.msg),ja.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let i=this.suggestions.slice(r,n).map((s,o)=>this.renderOption(s,this.select===o+r,o===0&&r>0,o+r===n-1&&n<this.choices.length)).join(`
|
|
70
|
+
`);this.outputText+=`
|
|
71
|
+
`+(i||pn.gray(this.fallback.title))}this.out.write(xA.line+Rp.to(0)+this.outputText)}};$p.exports=Na});var Up=w((s2,Bp)=>{"use strict";var mt=ie(),CA=se(),AA=CA.cursor,PA=Ra(),La=$e(),Gp=La.clear,qp=La.style,yr=La.figures,$a=class extends PA{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue="",this.clear=Gp("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){let e=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(n=>this.inputValue?!!(typeof n.title=="string"&&n.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof n.value=="string"&&n.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);let r=this.filteredOptions.findIndex(n=>n===e);this.cursor=r<0?0:r,this.render()}handleSpaceToggle(){let e=this.filteredOptions[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(r=>r.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}handleInputChange(e){this.inputValue=this.inputValue+e,this.updateFilteredOptions()}_(e,r){e===" "?this.handleSpaceToggle():this.handleInputChange(e)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
72
|
+
Instructions:
|
|
73
|
+
${yr.arrowUp}/${yr.arrowDown}: Highlight option
|
|
74
|
+
${yr.arrowLeft}/${yr.arrowRight}/[space]: Toggle selection
|
|
75
|
+
[a,b,c]/delete: Filter choices
|
|
76
|
+
enter/return: Complete answer
|
|
77
|
+
`:""}renderCurrentInput(){return`
|
|
78
|
+
Filtered results for: ${this.inputValue?this.inputValue:mt.gray("Enter something to filter")}
|
|
79
|
+
`}renderOption(e,r,n){let i;return r.disabled?i=e===n?mt.gray().underline(r.title):mt.strikethrough().gray(r.title):i=e===n?mt.cyan().underline(r.title):r.title,(r.selected?mt.green(yr.radioOn):yr.radioOff)+" "+i}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[mt.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(mt.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(AA.hide),super.render();let e=[qp.symbol(this.done,this.aborted),mt.bold(this.msg),qp.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=mt.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=Gp(e,this.out.columns)}};Bp.exports=$a});var Kp=w((o2,zp)=>{"use strict";var Vp=ie(),_A=ft(),Jp=$e(),Wp=Jp.style,kA=Jp.clear,Yp=se(),IA=Yp.erase,Hp=Yp.cursor,Ga=class extends _A{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.yesMsg=e.yes||"yes",this.yesOption=e.yesOption||"(Y/n)",this.noMsg=e.no||"no",this.noOption=e.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
80
|
+
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
81
|
+
`),this.close()}_(e,r){return e.toLowerCase()==="y"?(this.value=!0,this.submit()):e.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(Hp.hide):this.out.write(kA(this.outputText,this.out.columns)),super.render(),this.outputText=[Wp.symbol(this.done,this.aborted),Vp.bold(this.msg),Wp.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Vp.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(IA.line+Hp.to(0)+this.outputText))}};zp.exports=Ga});var Zp=w((a2,Xp)=>{"use strict";Xp.exports={TextPrompt:Nh(),SelectPrompt:qh(),TogglePrompt:Jh(),DatePrompt:vp(),NumberPrompt:_p(),MultiselectPrompt:Ra(),AutocompletePrompt:Lp(),AutocompleteMultiselectPrompt:Up(),ConfirmPrompt:Kp()}});var em=w(Qp=>{"use strict";var Ae=Qp,MA=Zp(),Ei=t=>t;function ze(t,e,r={}){return new Promise((n,i)=>{let s=new MA[t](e),o=r.onAbort||Ei,a=r.onSubmit||Ei,l=r.onExit||Ei;s.on("state",e.onState||Ei),s.on("submit",u=>n(a(u))),s.on("exit",u=>n(l(u))),s.on("abort",u=>i(o(u)))})}Ae.text=t=>ze("TextPrompt",t);Ae.password=t=>(t.style="password",Ae.text(t));Ae.invisible=t=>(t.style="invisible",Ae.text(t));Ae.number=t=>ze("NumberPrompt",t);Ae.date=t=>ze("DatePrompt",t);Ae.confirm=t=>ze("ConfirmPrompt",t);Ae.list=t=>{let e=t.separator||",";return ze("TextPrompt",t,{onSubmit:r=>r.split(e).map(n=>n.trim())})};Ae.toggle=t=>ze("TogglePrompt",t);Ae.select=t=>ze("SelectPrompt",t);Ae.multiselect=t=>{t.choices=[].concat(t.choices||[]);let e=r=>r.filter(n=>n.selected).map(n=>n.value);return ze("MultiselectPrompt",t,{onAbort:e,onSubmit:e})};Ae.autocompleteMultiselect=t=>{t.choices=[].concat(t.choices||[]);let e=r=>r.filter(n=>n.selected).map(n=>n.value);return ze("AutocompleteMultiselectPrompt",t,{onAbort:e,onSubmit:e})};var DA=(t,e)=>Promise.resolve(e.filter(r=>r.title.slice(0,t.length).toLowerCase()===t.toLowerCase()));Ae.autocomplete=t=>(t.suggest=t.suggest||DA,t.choices=[].concat(t.choices||[]),ze("AutocompletePrompt",t))});var cm=w((l2,am)=>{"use strict";function tm(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function rm(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?tm(Object(r),!0).forEach(function(n){RA(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):tm(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function RA(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jA(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=FA(t))||e&&t&&typeof t.length=="number"){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
82
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){r=r.call(t)},n:function(){var u=r.next();return s=u.done,u},e:function(u){o=!0,a=u},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw a}}}}function FA(t,e){if(t){if(typeof t=="string")return nm(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return nm(t,e)}}function nm(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function im(t,e,r,n,i,s,o){try{var a=t[s](o),l=a.value}catch(u){r(u);return}a.done?e(l):Promise.resolve(l).then(n,i)}function sm(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var s=t.apply(e,r);function o(l){im(s,n,i,o,a,"next",l)}function a(l){im(s,n,i,o,a,"throw",l)}o(void 0)})}}var qa=em(),NA=["suggest","format","onState","validate","onRender","type"],om=()=>{};function Dt(){return Ba.apply(this,arguments)}function Ba(){return Ba=sm(function*(t=[],{onSubmit:e=om,onCancel:r=om}={}){let n={},i=Dt._override||{};t=[].concat(t);let s,o,a,l,u,c,d=(function(){var x=sm(function*(b,S,g=!1){if(!(!g&&b.validate&&b.validate(S)!==!0))return b.format?yield b.format(S,n):S});return function(S,g){return x.apply(this,arguments)}})();var f=jA(t),h;try{for(f.s();!(h=f.n()).done;){o=h.value;var p=o;if(l=p.name,u=p.type,typeof u=="function"&&(u=yield u(s,rm({},n),o),o.type=u),!!u){for(let x in o){if(NA.includes(x))continue;let b=o[x];o[x]=typeof b=="function"?yield b(s,rm({},n),c):b}if(c=o,typeof o.message!="string")throw new Error("prompt message is required");var y=o;if(l=y.name,u=y.type,qa[u]===void 0)throw new Error(`prompt type (${u}) is not defined`);if(i[o.name]!==void 0&&(s=yield d(o,i[o.name]),s!==void 0)){n[l]=s;continue}try{s=Dt._injected?$A(Dt._injected,o.initial):yield qa[u](o),n[l]=s=yield d(o,s,!0),a=yield e(o,s,n)}catch{a=!(yield r(o,n))}if(a)return n}}}catch(x){f.e(x)}finally{f.f()}return n}),Ba.apply(this,arguments)}function $A(t,e){let r=t.shift();if(r instanceof Error)throw r;return r===void 0?e:r}function LA(t){Dt._injected=(Dt._injected||[]).concat(t)}function GA(t){Dt._override=Object.assign({},t)}am.exports=Object.assign(Dt,{prompt:Dt,prompts:qa,inject:LA,override:GA})});var um=w((u2,lm)=>{"use strict";lm.exports=(t,e)=>{if(!(t.meta&&t.name!=="escape")){if(t.ctrl){if(t.name==="a")return"first";if(t.name==="c"||t.name==="d")return"abort";if(t.name==="e")return"last";if(t.name==="g")return"reset"}if(e){if(t.name==="j")return"down";if(t.name==="k")return"up"}return t.name==="return"||t.name==="enter"?"submit":t.name==="backspace"?"delete":t.name==="delete"?"deleteForward":t.name==="abort"?"abort":t.name==="escape"?"exit":t.name==="tab"?"next":t.name==="pagedown"?"nextPage":t.name==="pageup"?"prevPage":t.name==="home"?"home":t.name==="end"?"end":t.name==="up"?"up":t.name==="down"?"down":t.name==="right"?"right":t.name==="left"?"left":!1}}});var Oi=w((d2,dm)=>{"use strict";dm.exports=t=>{let e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),r=new RegExp(e,"g");return typeof t=="string"?t.replace(r,""):t}});var pm=w((f2,hm)=>{"use strict";var qA=Oi(),{erase:fm,cursor:BA}=se(),UA=t=>[...qA(t)].length;hm.exports=function(t,e){if(!e)return fm.line+BA.to(0);let r=0,n=t.split(/\r?\n/);for(let i of n)r+=1+Math.floor(Math.max(UA(i)-1,0)/e);return fm.lines(r)}});var Ua=w((h2,mm)=>{"use strict";var gn={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},VA={arrowUp:gn.arrowUp,arrowDown:gn.arrowDown,arrowLeft:gn.arrowLeft,arrowRight:gn.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},WA=process.platform==="win32"?VA:gn;mm.exports=WA});var ym=w((p2,gm)=>{"use strict";var wr=ie(),Kt=Ua(),Va=Object.freeze({password:{scale:1,render:t=>"*".repeat(t.length)},emoji:{scale:2,render:t=>"\u{1F603}".repeat(t.length)},invisible:{scale:0,render:t=>""},default:{scale:1,render:t=>`${t}`}}),HA=t=>Va[t]||Va.default,yn=Object.freeze({aborted:wr.red(Kt.cross),done:wr.green(Kt.tick),exited:wr.yellow(Kt.cross),default:wr.cyan("?")}),JA=(t,e,r)=>e?yn.aborted:r?yn.exited:t?yn.done:yn.default,YA=t=>wr.gray(t?Kt.ellipsis:Kt.pointerSmall),zA=(t,e)=>wr.gray(t?e?Kt.pointerSmall:"+":Kt.line);gm.exports={styles:Va,render:HA,symbols:yn,symbol:JA,delimiter:YA,item:zA}});var bm=w((m2,wm)=>{"use strict";var KA=Oi();wm.exports=function(t,e){let r=String(KA(t)||"").split(/\r?\n/);return e?r.map(n=>Math.ceil(n.length/e)).reduce((n,i)=>n+i):r.length}});var xm=w((g2,Sm)=>{"use strict";Sm.exports=(t,e={})=>{let r=Number.isSafeInteger(parseInt(e.margin))?new Array(parseInt(e.margin)).fill(" ").join(""):e.margin||"",n=e.width;return(t||"").split(/\r?\n/g).map(i=>i.split(/\s+/g).reduce((s,o)=>(o.length+r.length>=n||s[s.length-1].length+o.length+1<n?s[s.length-1]+=` ${o}`:s.push(`${r}${o}`),s),[r]).join(`
|
|
83
|
+
`)).join(`
|
|
84
|
+
`)}});var Em=w((y2,vm)=>{"use strict";vm.exports=(t,e,r)=>{r=r||e;let n=Math.min(e-r,t-Math.floor(r/2));n<0&&(n=0);let i=Math.min(n+r,e);return{startIndex:n,endIndex:i}}});var Le=w((w2,Om)=>{"use strict";Om.exports={action:um(),clear:pm(),style:ym(),strip:Oi(),figures:Ua(),lines:bm(),wrap:xm(),entriesToDisplay:Em()}});var gt=w((b2,Cm)=>{"use strict";var Tm=require("readline"),{action:XA}=Le(),ZA=require("events"),{beep:QA,cursor:eP}=se(),tP=ie(),Wa=class extends ZA{constructor(e={}){super(),this.firstRender=!0,this.in=e.stdin||process.stdin,this.out=e.stdout||process.stdout,this.onRender=(e.onRender||(()=>{})).bind(this);let r=Tm.createInterface({input:this.in,escapeCodeTimeout:50});Tm.emitKeypressEvents(this.in,r),this.in.isTTY&&this.in.setRawMode(!0);let n=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,i=(s,o)=>{let a=XA(o,n);a===!1?this._&&this._(s,o):typeof this[a]=="function"?this[a](o):this.bell()};this.close=()=>{this.out.write(eP.show),this.in.removeListener("keypress",i),this.in.isTTY&&this.in.setRawMode(!1),r.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",i)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(QA)}render(){this.onRender(tP),this.firstRender&&(this.firstRender=!1)}};Cm.exports=Wa});var Pm=w((S2,Am)=>{var Ti=ie(),rP=gt(),{erase:nP,cursor:wn}=se(),{style:Ha,clear:Ja,lines:iP,figures:sP}=Le(),Ya=class extends rP{constructor(e={}){super(e),this.transform=Ha.render(e.style),this.scale=this.transform.scale,this.msg=e.message,this.initial=e.initial||"",this.validator=e.validate||(()=>!0),this.value="",this.errorMsg=e.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=Ja("",this.out.columns),this.render()}set value(e){!e&&this.initial?(this.placeholder=!0,this.rendered=Ti.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(e)),this._value=e,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=+!!this.initial,this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
|
|
85
|
+
`),this.close()}async validate(){let e=await this.validator(this.value);typeof e=="string"&&(this.errorMsg=e,e=!1),this.error=!e}async submit(){if(this.value=this.value||this.initial,this.cursorOffset=0,this.cursor=this.rendered.length,await this.validate(),this.error){this.red=!0,this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
86
|
+
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(e){this.placeholder||(this.cursor=this.cursor+e,this.cursorOffset+=e)}_(e,r){let n=this.value.slice(0,this.cursor),i=this.value.slice(this.cursor);this.value=`${n}${e}${i}`,this.red=!1,this.cursor=this.placeholder?0:n.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let e=this.value.slice(0,this.cursor-1),r=this.value.slice(this.cursor);this.value=`${e}${r}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let e=this.value.slice(0,this.cursor),r=this.value.slice(this.cursor+1);this.value=`${e}${r}`,this.red=!1,this.isCursorAtEnd()?this.cursorOffset=0:this.cursorOffset++,this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(wn.down(iP(this.outputError,this.out.columns)-1)+Ja(this.outputError,this.out.columns)),this.out.write(Ja(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[Ha.symbol(this.done,this.aborted),Ti.bold(this.msg),Ha.delimiter(this.done),this.red?Ti.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
87
|
+
`).reduce((e,r,n)=>e+`
|
|
88
|
+
${n?" ":sP.pointerSmall} ${Ti.red().italic(r)}`,"")),this.out.write(nP.line+wn.to(0)+this.outputText+wn.save+this.outputError+wn.restore+wn.move(this.cursorOffset,0)))}};Am.exports=Ya});var Mm=w((x2,Im)=>{"use strict";var yt=ie(),oP=gt(),{style:_m,clear:km,figures:Ci,wrap:aP,entriesToDisplay:cP}=Le(),{cursor:lP}=se(),za=class extends oP{constructor(e={}){super(e),this.msg=e.message,this.hint=e.hint||"- Use arrow-keys. Return to submit.",this.warn=e.warn||"- This option is disabled",this.cursor=e.initial||0,this.choices=e.choices.map((r,n)=>(typeof r=="string"&&(r={title:r,value:n}),{title:r&&(r.title||r.value||r),value:r&&(r.value===void 0?n:r.value),description:r&&r.description,selected:r&&r.selected,disabled:r&&r.disabled})),this.optionsPerPage=e.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=km("",this.out.columns),this.render()}moveCursor(e){this.cursor=e,this.value=this.choices[e].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
89
|
+
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
90
|
+
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(e,r){if(e===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(lP.hide):this.out.write(km(this.outputText,this.out.columns)),super.render();let{startIndex:e,endIndex:r}=cP(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[_m.symbol(this.done,this.aborted),yt.bold(this.msg),_m.delimiter(!1),this.done?this.selection.title:this.selection.disabled?yt.yellow(this.warn):yt.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
91
|
+
`;for(let n=e;n<r;n++){let i,s,o="",a=this.choices[n];n===e&&e>0?s=Ci.arrowUp:n===r-1&&r<this.choices.length?s=Ci.arrowDown:s=" ",a.disabled?(i=this.cursor===n?yt.gray().underline(a.title):yt.strikethrough().gray(a.title),s=(this.cursor===n?yt.bold().gray(Ci.pointer)+" ":" ")+s):(i=this.cursor===n?yt.cyan().underline(a.title):a.title,s=(this.cursor===n?yt.cyan(Ci.pointer)+" ":" ")+s,a.description&&this.cursor===n&&(o=` - ${a.description}`,(s.length+i.length+o.length>=this.out.columns||a.description.split(/\r?\n/).length>1)&&(o=`
|
|
92
|
+
`+aP(a.description,{margin:3,width:this.out.columns})))),this.outputText+=`${s} ${i}${yt.gray(o)}
|
|
93
|
+
`}}this.out.write(this.outputText)}};Im.exports=za});var Fm=w((v2,jm)=>{var Ai=ie(),uP=gt(),{style:Dm,clear:dP}=Le(),{cursor:Rm,erase:fP}=se(),Ka=class extends uP{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active||"on",this.inactive=e.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
94
|
+
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
95
|
+
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,r){if(e===" ")this.value=!this.value;else if(e==="1")this.value=!0;else if(e==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(Rm.hide):this.out.write(dP(this.outputText,this.out.columns)),super.render(),this.outputText=[Dm.symbol(this.done,this.aborted),Ai.bold(this.msg),Dm.delimiter(this.done),this.value?this.inactive:Ai.cyan().underline(this.inactive),Ai.gray("/"),this.value?Ai.cyan().underline(this.active):this.active].join(" "),this.out.write(fP.line+Rm.to(0)+this.outputText))}};jm.exports=Ka});var Ke=w((E2,Nm)=>{"use strict";var Xa=class t{constructor({token:e,date:r,parts:n,locales:i}){this.token=e,this.date=r||new Date,this.parts=n||[this],this.locales=i||{}}up(){}down(){}next(){let e=this.parts.indexOf(this);return this.parts.find((r,n)=>n>e&&r instanceof t)}setTo(e){}prev(){let e=[].concat(this.parts).reverse(),r=e.indexOf(this);return e.find((n,i)=>i>r&&n instanceof t)}toString(){return String(this.date)}};Nm.exports=Xa});var Lm=w((O2,$m)=>{"use strict";var hP=Ke(),Za=class extends hP{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?e.toUpperCase():e}};$m.exports=Za});var qm=w((T2,Gm)=>{"use strict";var pP=Ke(),mP=t=>(t=t%10,t===1?"st":t===2?"nd":t===3?"rd":"th"),Qa=class extends pP{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),r=this.date.getDay();return this.token==="DD"?String(e).padStart(2,"0"):this.token==="Do"?e+mP(e):this.token==="d"?r+1:this.token==="ddd"?this.locales.weekdaysShort[r]:this.token==="dddd"?this.locales.weekdays[r]:e}};Gm.exports=Qa});var Um=w((C2,Bm)=>{"use strict";var gP=Ke(),ec=class extends gP{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,"0"):e}};Bm.exports=ec});var Wm=w((A2,Vm)=>{"use strict";var yP=Ke(),tc=class extends yP{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}};Vm.exports=tc});var Jm=w((P2,Hm)=>{"use strict";var wP=Ke(),rc=class extends wP{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,"0"):e}};Hm.exports=rc});var zm=w((_2,Ym)=>{"use strict";var bP=Ke(),nc=class extends bP{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),r=this.token.length;return r===2?String(e+1).padStart(2,"0"):r===3?this.locales.monthsShort[e]:r===4?this.locales.months[e]:String(e+1)}};Ym.exports=nc});var Xm=w((k2,Km)=>{"use strict";var SP=Ke(),ic=class extends SP{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,"0"):e}};Km.exports=ic});var Qm=w((I2,Zm)=>{"use strict";var xP=Ke(),sc=class extends xP{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?e.substr(-2):e}};Zm.exports=sc});var tg=w((M2,eg)=>{"use strict";eg.exports={DatePart:Ke(),Meridiem:Lm(),Day:qm(),Hours:Um(),Milliseconds:Wm(),Minutes:Jm(),Month:zm(),Seconds:Xm(),Year:Qm()}});var cg=w((D2,ag)=>{"use strict";var oc=ie(),vP=gt(),{style:rg,clear:ng,figures:EP}=Le(),{erase:OP,cursor:ig}=se(),{DatePart:sg,Meridiem:TP,Day:CP,Hours:AP,Milliseconds:PP,Minutes:_P,Month:kP,Seconds:IP,Year:MP}=tg(),DP=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,og={1:({token:t})=>t.replace(/\\(.)/g,"$1"),2:t=>new CP(t),3:t=>new kP(t),4:t=>new MP(t),5:t=>new TP(t),6:t=>new AP(t),7:t=>new _P(t),8:t=>new IP(t),9:t=>new PP(t)},RP={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")},ac=class extends vP{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed="",this.locales=Object.assign(RP,e.locales),this._date=e.initial||new Date,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.mask=e.mask||"YYYY-MM-DD HH:mm:ss",this.clear=ng("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(e){e&&this._date.setTime(e.getTime())}set mask(e){let r;for(this.parts=[];r=DP.exec(e);){let i=r.shift(),s=r.findIndex(o=>o!=null);this.parts.push(s in og?og[s]({token:r[s]||i,date:this.date,parts:this.parts,locales:this.locales}):r[s]||i)}let n=this.parts.reduce((i,s)=>(typeof s=="string"&&typeof i[i.length-1]=="string"?i[i.length-1]+=s:i.push(s),i),[]);this.parts.splice(0),this.parts.push(...n),this.reset()}moveCursor(e){this.typed="",this.cursor=e,this.fire()}reset(){this.moveCursor(this.parts.findIndex(e=>e instanceof sg)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
96
|
+
`),this.close()}async validate(){let e=await this.validator(this.value);typeof e=="string"&&(this.errorMsg=e,e=!1),this.error=!e}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
97
|
+
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(r=>r instanceof sg)),this.render()}_(e){/\d/.test(e)&&(this.typed+=e,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(ig.hide):this.out.write(ng(this.outputText,this.out.columns)),super.render(),this.outputText=[rg.symbol(this.done,this.aborted),oc.bold(this.msg),rg.delimiter(!1),this.parts.reduce((e,r,n)=>e.concat(n===this.cursor&&!this.done?oc.cyan().underline(r.toString()):r),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
98
|
+
`).reduce((e,r,n)=>e+`
|
|
99
|
+
${n?" ":EP.pointerSmall} ${oc.red().italic(r)}`,"")),this.out.write(OP.line+ig.to(0)+this.outputText))}};ag.exports=ac});var fg=w((R2,dg)=>{var Pi=ie(),jP=gt(),{cursor:_i,erase:FP}=se(),{style:cc,figures:NP,clear:lg,lines:$P}=Le(),LP=/[0-9]/,lc=t=>t!==void 0,ug=(t,e)=>{let r=Math.pow(10,e);return Math.round(t*r)/r},uc=class extends jP{constructor(e={}){super(e),this.transform=cc.render(e.style),this.msg=e.message,this.initial=lc(e.initial)?e.initial:"",this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=lc(e.min)?e.min:-1/0,this.max=lc(e.max)?e.max:1/0,this.errorMsg=e.error||"Please Enter A Valid Value",this.validator=e.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(e){!e&&e!==0?(this.placeholder=!0,this.rendered=Pi.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${ug(e,this.round)}`),this._value=ug(e,this.round)),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return e==="-"||e==="."&&this.float||LP.test(e)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let e=this.value;this.value=e!==""?e:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
100
|
+
`),this.close()}async validate(){let e=await this.validator(this.value);typeof e=="string"&&(this.errorMsg=e,e=!1),this.error=!e}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let e=this.value;this.value=e!==""?e:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
101
|
+
`),this.close()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(e,r){if(!this.valid(e))return this.bell();let n=Date.now();if(n-this.lastHit>1e3&&(this.typed=""),this.typed+=e,this.lastHit=n,this.color="cyan",e===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(_i.down($P(this.outputError,this.out.columns)-1)+lg(this.outputError,this.out.columns)),this.out.write(lg(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[cc.symbol(this.done,this.aborted),Pi.bold(this.msg),cc.delimiter(this.done),!this.done||!this.done&&!this.placeholder?Pi[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
102
|
+
`).reduce((e,r,n)=>e+`
|
|
103
|
+
${n?" ":NP.pointerSmall} ${Pi.red().italic(r)}`,"")),this.out.write(FP.line+_i.to(0)+this.outputText+_i.save+this.outputError+_i.restore))}};dg.exports=uc});var fc=w((j2,mg)=>{"use strict";var Xe=ie(),{cursor:GP}=se(),qP=gt(),{clear:hg,figures:Rt,style:pg,wrap:BP,entriesToDisplay:UP}=Le(),dc=class extends qP{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.scrollIndex=e.cursor||0,this.hint=e.hint||"",this.warn=e.warn||"- This option is disabled -",this.minSelected=e.min,this.showMinError=!1,this.maxChoices=e.max,this.instructions=e.instructions,this.optionsPerPage=e.optionsPerPage||10,this.value=e.choices.map((r,n)=>(typeof r=="string"&&(r={title:r,value:n}),{title:r&&(r.title||r.value||r),description:r&&r.description,value:r&&(r.value===void 0?n:r.value),selected:r&&r.selected,disabled:r&&r.disabled})),this.clear=hg("",this.out.columns),e.overrideRender||this.render()}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
104
|
+
`),this.close()}submit(){let e=this.value.filter(r=>r.selected);this.minSelected&&e.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
105
|
+
`),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let e=this.value[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(r=>r.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let e=!this.value[this.cursor].selected;this.value.filter(r=>!r.disabled).forEach(r=>r.selected=e),this.render()}_(e,r){if(e===" ")this.handleSpaceToggle();else if(e==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
106
|
+
Instructions:
|
|
107
|
+
${Rt.arrowUp}/${Rt.arrowDown}: Highlight option
|
|
108
|
+
${Rt.arrowLeft}/${Rt.arrowRight}/[space]: Toggle selection
|
|
109
|
+
`+(this.maxChoices===void 0?` a: Toggle all
|
|
110
|
+
`:"")+" enter/return: Complete answer":""}renderOption(e,r,n,i){let s=(r.selected?Xe.green(Rt.radioOn):Rt.radioOff)+" "+i+" ",o,a;return r.disabled?o=e===n?Xe.gray().underline(r.title):Xe.strikethrough().gray(r.title):(o=e===n?Xe.cyan().underline(r.title):r.title,e===n&&r.description&&(a=` - ${r.description}`,(s.length+o.length+a.length>=this.out.columns||r.description.split(/\r?\n/).length>1)&&(a=`
|
|
111
|
+
`+BP(r.description,{margin:s.length,width:this.out.columns})))),s+o+Xe.gray(a||"")}paginateOptions(e){if(e.length===0)return Xe.red("No matches for this query.");let{startIndex:r,endIndex:n}=UP(this.cursor,e.length,this.optionsPerPage),i,s=[];for(let o=r;o<n;o++)o===r&&r>0?i=Rt.arrowUp:o===n-1&&n<e.length?i=Rt.arrowDown:i=" ",s.push(this.renderOption(this.cursor,e[o],o,i));return`
|
|
112
|
+
`+s.join(`
|
|
113
|
+
`)}renderOptions(e){return this.done?"":this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[Xe.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(Xe.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(GP.hide),super.render();let e=[pg.symbol(this.done,this.aborted),Xe.bold(this.msg),pg.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=Xe.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=hg(e,this.out.columns)}};mg.exports=dc});var Sg=w((F2,bg)=>{"use strict";var bn=ie(),VP=gt(),{erase:WP,cursor:gg}=se(),{style:hc,clear:yg,figures:pc,wrap:HP,entriesToDisplay:JP}=Le(),wg=(t,e)=>t[e]&&(t[e].value||t[e].title||t[e]),YP=(t,e)=>t[e]&&(t[e].title||t[e].value||t[e]),zP=(t,e)=>{let r=t.findIndex(n=>n.value===e||n.title===e);return r>-1?r:void 0},mc=class extends VP{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=typeof e.initial=="number"?e.initial:zP(e.choices,e.initial),this.select=this.initial||e.cursor||0,this.i18n={noMatches:e.noMatches||"no matches found"},this.fallback=e.fallback||this.initial,this.clearFirst=e.clearFirst||!1,this.suggestions=[],this.input="",this.limit=e.limit||10,this.cursor=0,this.transform=hc.render(e.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=yg("",this.out.columns),this.complete(this.render),this.render()}set fallback(e){this._fb=Number.isSafeInteger(parseInt(e))?parseInt(e):e}get fallback(){let e;return typeof this._fb=="number"?e=this.choices[this._fb]:typeof this._fb=="string"&&(e={title:this._fb}),e||this._fb||{title:this.i18n.noMatches}}moveSelect(e){this.select=e,this.suggestions.length>0?this.value=wg(this.suggestions,e):this.value=this.fallback.value,this.fire()}async complete(e){let r=this.completing=this.suggest(this.input,this.choices),n=await r;if(this.completing!==r)return;this.suggestions=n.map((s,o,a)=>({title:YP(a,o),value:wg(a,o),description:s.description})),this.completing=!1;let i=Math.max(n.length-1,0);this.moveSelect(Math.min(i,this.select)),e&&e()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
114
|
+
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
115
|
+
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
116
|
+
`),this.close()}_(e,r){let n=this.input.slice(0,this.cursor),i=this.input.slice(this.cursor);this.input=`${n}${e}${i}`,this.cursor=n.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let e=this.input.slice(0,this.cursor-1),r=this.input.slice(this.cursor);this.input=`${e}${r}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let e=this.input.slice(0,this.cursor),r=this.input.slice(this.cursor+1);this.input=`${e}${r}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(e,r,n,i){let s,o=n?pc.arrowUp:i?pc.arrowDown:" ",a=r?bn.cyan().underline(e.title):e.title;return o=(r?bn.cyan(pc.pointer)+" ":" ")+o,e.description&&(s=` - ${e.description}`,(o.length+a.length+s.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(s=`
|
|
117
|
+
`+HP(e.description,{margin:3,width:this.out.columns}))),o+" "+a+bn.gray(s||"")}render(){if(this.closed)return;this.firstRender?this.out.write(gg.hide):this.out.write(yg(this.outputText,this.out.columns)),super.render();let{startIndex:e,endIndex:r}=JP(this.select,this.choices.length,this.limit);if(this.outputText=[hc.symbol(this.done,this.aborted,this.exited),bn.bold(this.msg),hc.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let n=this.suggestions.slice(e,r).map((i,s)=>this.renderOption(i,this.select===s+e,s===0&&e>0,s+e===r-1&&r<this.choices.length)).join(`
|
|
118
|
+
`);this.outputText+=`
|
|
119
|
+
`+(n||bn.gray(this.fallback.title))}this.out.write(WP.line+gg.to(0)+this.outputText)}};bg.exports=mc});var Og=w((N2,Eg)=>{"use strict";var wt=ie(),{cursor:KP}=se(),XP=fc(),{clear:xg,style:vg,figures:br}=Le(),gc=class extends XP{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue="",this.clear=xg("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){let e=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(n=>this.inputValue?!!(typeof n.title=="string"&&n.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof n.value=="string"&&n.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);let r=this.filteredOptions.findIndex(n=>n===e);this.cursor=r<0?0:r,this.render()}handleSpaceToggle(){let e=this.filteredOptions[this.cursor];if(e.selected)e.selected=!1,this.render();else{if(e.disabled||this.value.filter(r=>r.selected).length>=this.maxChoices)return this.bell();e.selected=!0,this.render()}}handleInputChange(e){this.inputValue=this.inputValue+e,this.updateFilteredOptions()}_(e,r){e===" "?this.handleSpaceToggle():this.handleInputChange(e)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
120
|
+
Instructions:
|
|
121
|
+
${br.arrowUp}/${br.arrowDown}: Highlight option
|
|
122
|
+
${br.arrowLeft}/${br.arrowRight}/[space]: Toggle selection
|
|
123
|
+
[a,b,c]/delete: Filter choices
|
|
124
|
+
enter/return: Complete answer
|
|
125
|
+
`:""}renderCurrentInput(){return`
|
|
126
|
+
Filtered results for: ${this.inputValue?this.inputValue:wt.gray("Enter something to filter")}
|
|
127
|
+
`}renderOption(e,r,n){let i;return r.disabled?i=e===n?wt.gray().underline(r.title):wt.strikethrough().gray(r.title):i=e===n?wt.cyan().underline(r.title):r.title,(r.selected?wt.green(br.radioOn):br.radioOff)+" "+i}renderDoneOrInstructions(){if(this.done)return this.value.filter(r=>r.selected).map(r=>r.title).join(", ");let e=[wt.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(wt.yellow(this.warn)),e.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(KP.hide),super.render();let e=[vg.symbol(this.done,this.aborted),wt.bold(this.msg),vg.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(e+=wt.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=xg(e,this.out.columns)}};Eg.exports=gc});var _g=w(($2,Pg)=>{var Tg=ie(),ZP=gt(),{style:Cg,clear:QP}=Le(),{erase:e1,cursor:Ag}=se(),yc=class extends ZP{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.yesMsg=e.yes||"yes",this.yesOption=e.yesOption||"(Y/n)",this.noMsg=e.no||"no",this.noOption=e.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
128
|
+
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
129
|
+
`),this.close()}_(e,r){return e.toLowerCase()==="y"?(this.value=!0,this.submit()):e.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(Ag.hide):this.out.write(QP(this.outputText,this.out.columns)),super.render(),this.outputText=[Cg.symbol(this.done,this.aborted),Tg.bold(this.msg),Cg.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Tg.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(e1.line+Ag.to(0)+this.outputText))}};Pg.exports=yc});var Ig=w((L2,kg)=>{"use strict";kg.exports={TextPrompt:Pm(),SelectPrompt:Mm(),TogglePrompt:Fm(),DatePrompt:cg(),NumberPrompt:fg(),MultiselectPrompt:fc(),AutocompletePrompt:Sg(),AutocompleteMultiselectPrompt:Og(),ConfirmPrompt:_g()}});var Dg=w(Mg=>{"use strict";var Pe=Mg,t1=Ig(),ki=t=>t;function Ze(t,e,r={}){return new Promise((n,i)=>{let s=new t1[t](e),o=r.onAbort||ki,a=r.onSubmit||ki,l=r.onExit||ki;s.on("state",e.onState||ki),s.on("submit",u=>n(a(u))),s.on("exit",u=>n(l(u))),s.on("abort",u=>i(o(u)))})}Pe.text=t=>Ze("TextPrompt",t);Pe.password=t=>(t.style="password",Pe.text(t));Pe.invisible=t=>(t.style="invisible",Pe.text(t));Pe.number=t=>Ze("NumberPrompt",t);Pe.date=t=>Ze("DatePrompt",t);Pe.confirm=t=>Ze("ConfirmPrompt",t);Pe.list=t=>{let e=t.separator||",";return Ze("TextPrompt",t,{onSubmit:r=>r.split(e).map(n=>n.trim())})};Pe.toggle=t=>Ze("TogglePrompt",t);Pe.select=t=>Ze("SelectPrompt",t);Pe.multiselect=t=>{t.choices=[].concat(t.choices||[]);let e=r=>r.filter(n=>n.selected).map(n=>n.value);return Ze("MultiselectPrompt",t,{onAbort:e,onSubmit:e})};Pe.autocompleteMultiselect=t=>{t.choices=[].concat(t.choices||[]);let e=r=>r.filter(n=>n.selected).map(n=>n.value);return Ze("AutocompleteMultiselectPrompt",t,{onAbort:e,onSubmit:e})};var r1=(t,e)=>Promise.resolve(e.filter(r=>r.title.slice(0,t.length).toLowerCase()===t.toLowerCase()));Pe.autocomplete=t=>(t.suggest=t.suggest||r1,t.choices=[].concat(t.choices||[]),Ze("AutocompletePrompt",t))});var Fg=w((q2,jg)=>{"use strict";var wc=Dg(),n1=["suggest","format","onState","validate","onRender","type"],Rg=()=>{};async function jt(t=[],{onSubmit:e=Rg,onCancel:r=Rg}={}){let n={},i=jt._override||{};t=[].concat(t);let s,o,a,l,u,c,d=async(f,h,p=!1)=>{if(!(!p&&f.validate&&f.validate(h)!==!0))return f.format?await f.format(h,n):h};for(o of t)if({name:l,type:u}=o,typeof u=="function"&&(u=await u(s,{...n},o),o.type=u),!!u){for(let f in o){if(n1.includes(f))continue;let h=o[f];o[f]=typeof h=="function"?await h(s,{...n},c):h}if(c=o,typeof o.message!="string")throw new Error("prompt message is required");if({name:l,type:u}=o,wc[u]===void 0)throw new Error(`prompt type (${u}) is not defined`);if(i[o.name]!==void 0&&(s=await d(o,i[o.name]),s!==void 0)){n[l]=s;continue}try{s=jt._injected?i1(jt._injected,o.initial):await wc[u](o),n[l]=s=await d(o,s,!0),a=await e(o,s,n)}catch{a=!await r(o,n)}if(a)return n}return n}function i1(t,e){let r=t.shift();if(r instanceof Error)throw r;return r===void 0?e:r}function s1(t){jt._injected=(jt._injected||[]).concat(t)}function o1(t){jt._override=Object.assign({},t)}jg.exports=Object.assign(jt,{prompt:jt,prompts:wc,inject:s1,override:o1})});var bc=w((B2,Ng)=>{function a1(t){t=(Array.isArray(t)?t:t.split(".")).map(Number);let e=0,r=process.versions.node.split(".").map(Number);for(;e<t.length;e++){if(r[e]>t[e])return!1;if(t[e]>r[e])return!0}return!1}Ng.exports=a1("8.6.0")?cm():Fg()});var Ic=w((hL,Yg)=>{Yg.exports={dots:{frames:[".","..","..."],interval:80}}});var wy=w((U8,yy)=>{yy.exports=gy;gy.sync=i_;var py=require("fs");function n_(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var i=r[n].toLowerCase();if(i&&t.substr(-i.length).toLowerCase()===i)return!0}return!1}function my(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:n_(e,r)}function gy(t,e,r){py.stat(t,function(n,i){r(n,n?!1:my(i,t,e))})}function i_(t,e){return my(py.statSync(t),t,e)}});var Ey=w((V8,vy)=>{vy.exports=Sy;Sy.sync=s_;var by=require("fs");function Sy(t,e,r){by.stat(t,function(n,i){r(n,n?!1:xy(i,e))})}function s_(t,e){return xy(by.statSync(t),e)}function xy(t,e){return t.isFile()&&o_(t,e)}function o_(t,e){var r=t.mode,n=t.uid,i=t.gid,s=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),o=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),l=parseInt("010",8),u=parseInt("001",8),c=a|l,d=r&u||r&l&&i===o||r&a&&n===s||r&c&&s===0;return d}});var Ty=w((H8,Oy)=>{var W8=require("fs"),zi;process.platform==="win32"||global.TESTING_WINDOWS?zi=wy():zi=Ey();Oy.exports=Jc;Jc.sync=a_;function Jc(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,i){Jc(t,e||{},function(s,o){s?i(s):n(o)})})}zi(t,e||{},function(n,i){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,i=!1),r(n,i)})}function a_(t,e){try{return zi.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var My=w((J8,Iy)=>{var Tr=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Cy=require("path"),c_=Tr?";":":",Ay=Ty(),Py=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),_y=(t,e)=>{let r=e.colon||c_,n=t.match(/\//)||Tr&&t.match(/\\/)?[""]:[...Tr?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],i=Tr?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",s=Tr?i.split(r):[""];return Tr&&t.indexOf(".")!==-1&&s[0]!==""&&s.unshift(""),{pathEnv:n,pathExt:s,pathExtExe:i}},ky=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:n,pathExt:i,pathExtExe:s}=_y(t,e),o=[],a=u=>new Promise((c,d)=>{if(u===n.length)return e.all&&o.length?c(o):d(Py(t));let f=n[u],h=/^".*"$/.test(f)?f.slice(1,-1):f,p=Cy.join(h,t),y=!h&&/^\.[\\\/]/.test(t)?t.slice(0,2)+p:p;c(l(y,u,0))}),l=(u,c,d)=>new Promise((f,h)=>{if(d===i.length)return f(a(c+1));let p=i[d];Ay(u+p,{pathExt:s},(y,x)=>{if(!y&&x)if(e.all)o.push(u+p);else return f(u+p);return f(l(u,c,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},l_=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:n,pathExtExe:i}=_y(t,e),s=[];for(let o=0;o<r.length;o++){let a=r[o],l=/^".*"$/.test(a)?a.slice(1,-1):a,u=Cy.join(l,t),c=!l&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;for(let d=0;d<n.length;d++){let f=c+n[d];try{if(Ay.sync(f,{pathExt:i}))if(e.all)s.push(f);else return f}catch{}}}if(e.all&&s.length)return s;if(e.nothrow)return null;throw Py(t)};Iy.exports=ky;ky.sync=l_});var zc=w((Y8,Yc)=>{"use strict";var Dy=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Yc.exports=Dy;Yc.exports.default=Dy});var Ny=w((z8,Fy)=>{"use strict";var Ry=require("path"),u_=My(),d_=zc();function jy(t,e){let r=t.options.env||process.env,n=process.cwd(),i=t.options.cwd!=null,s=i&&process.chdir!==void 0&&!process.chdir.disabled;if(s)try{process.chdir(t.options.cwd)}catch{}let o;try{o=u_.sync(t.command,{path:r[d_({env:r})],pathExt:e?Ry.delimiter:void 0})}catch{}finally{s&&process.chdir(n)}return o&&(o=Ry.resolve(i?t.options.cwd:"",o)),o}function f_(t){return jy(t)||jy(t,!0)}Fy.exports=f_});var $y=w((K8,Xc)=>{"use strict";var Kc=/([()\][%!^"`<>&|;, *?])/g;function h_(t){return t=t.replace(Kc,"^$1"),t}function p_(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(Kc,"^$1"),e&&(t=t.replace(Kc,"^$1")),t}Xc.exports.command=h_;Xc.exports.argument=p_});var Gy=w((X8,Ly)=>{"use strict";Ly.exports=/^#!(.*)/});var By=w((Z8,qy)=>{"use strict";var m_=Gy();qy.exports=(t="")=>{let e=t.match(m_);if(!e)return null;let[r,n]=e[0].replace(/#! ?/,"").split(" "),i=r.split("/").pop();return i==="env"?n:n?`${i} ${n}`:i}});var Vy=w((Q8,Uy)=>{"use strict";var Zc=require("fs"),g_=By();function y_(t){let r=Buffer.alloc(150),n;try{n=Zc.openSync(t,"r"),Zc.readSync(n,r,0,150,0),Zc.closeSync(n)}catch{}return g_(r.toString())}Uy.exports=y_});var Yy=w((eG,Jy)=>{"use strict";var w_=require("path"),Wy=Ny(),Hy=$y(),b_=Vy(),S_=process.platform==="win32",x_=/\.(?:com|exe)$/i,v_=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function E_(t){t.file=Wy(t);let e=t.file&&b_(t.file);return e?(t.args.unshift(t.file),t.command=e,Wy(t)):t.file}function O_(t){if(!S_)return t;let e=E_(t),r=!x_.test(e);if(t.options.forceShell||r){let n=v_.test(e);t.command=w_.normalize(t.command),t.command=Hy.command(t.command),t.args=t.args.map(s=>Hy.argument(s,n));let i=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${i}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function T_(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let n={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?n:O_(n)}Jy.exports=T_});var Xy=w((tG,Ky)=>{"use strict";var Qc=process.platform==="win32";function el(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function C_(t,e){if(!Qc)return;let r=t.emit;t.emit=function(n,i){if(n==="exit"){let s=zy(i,e);if(s)return r.call(t,"error",s)}return r.apply(t,arguments)}}function zy(t,e){return Qc&&t===1&&!e.file?el(e.original,"spawn"):null}function A_(t,e){return Qc&&t===1&&!e.file?el(e.original,"spawnSync"):null}Ky.exports={hookChildProcess:C_,verifyENOENT:zy,verifyENOENTSync:A_,notFoundError:el}});var nl=w((rG,Cr)=>{"use strict";var Zy=require("child_process"),tl=Yy(),rl=Xy();function Qy(t,e,r){let n=tl(t,e,r),i=Zy.spawn(n.command,n.args,n.options);return rl.hookChildProcess(i,n),i}function P_(t,e,r){let n=tl(t,e,r),i=Zy.spawnSync(n.command,n.args,n.options);return i.error=i.error||rl.verifyENOENTSync(i.status,n),i}Cr.exports=Qy;Cr.exports.spawn=Qy;Cr.exports.sync=P_;Cr.exports._parse=tl;Cr.exports._enoent=rl});var tw=w((nG,ew)=>{"use strict";ew.exports=t=>{let e=typeof t=="string"?`
|
|
130
|
+
`:10,r=typeof t=="string"?"\r":13;return t[t.length-1]===e&&(t=t.slice(0,t.length-1)),t[t.length-1]===r&&(t=t.slice(0,t.length-1)),t}});var iw=w((iG,An)=>{"use strict";var Cn=require("path"),rw=zc(),nw=t=>{t={cwd:process.cwd(),path:process.env[rw()],execPath:process.execPath,...t};let e,r=Cn.resolve(t.cwd),n=[];for(;e!==r;)n.push(Cn.join(r,"node_modules/.bin")),e=r,r=Cn.resolve(r,"..");let i=Cn.resolve(t.cwd,t.execPath,"..");return n.push(i),n.concat(t.path).join(Cn.delimiter)};An.exports=nw;An.exports.default=nw;An.exports.env=t=>{t={env:process.env,...t};let e={...t.env},r=rw({env:e});return t.path=e[r],e[r]=An.exports(t),e}});var ow=w((sG,il)=>{"use strict";var sw=(t,e)=>{for(let r of Reflect.ownKeys(e))Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r));return t};il.exports=sw;il.exports.default=sw});var cw=w((oG,Xi)=>{"use strict";var __=ow(),Ki=new WeakMap,aw=(t,e={})=>{if(typeof t!="function")throw new TypeError("Expected a function");let r,n=0,i=t.displayName||t.name||"<anonymous>",s=function(...o){if(Ki.set(s,++n),n===1)r=t.apply(this,o),t=null;else if(e.throw===!0)throw new Error(`Function \`${i}\` can only be called once`);return r};return __(s,t),Ki.set(s,n),s};Xi.exports=aw;Xi.exports.default=aw;Xi.exports.callCount=t=>{if(!Ki.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return Ki.get(t)}});var lw=w(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});Zi.SIGNALS=void 0;var k_=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];Zi.SIGNALS=k_});var sl=w(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.SIGRTMAX=Ar.getRealtimeSignals=void 0;var I_=function(){let t=dw-uw+1;return Array.from({length:t},M_)};Ar.getRealtimeSignals=I_;var M_=function(t,e){return{name:`SIGRT${e+1}`,number:uw+e,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},uw=34,dw=64;Ar.SIGRTMAX=dw});var fw=w(Qi=>{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});Qi.getSignals=void 0;var D_=require("os"),R_=lw(),j_=sl(),F_=function(){let t=(0,j_.getRealtimeSignals)();return[...R_.SIGNALS,...t].map(N_)};Qi.getSignals=F_;var N_=function({name:t,number:e,description:r,action:n,forced:i=!1,standard:s}){let{signals:{[t]:o}}=D_.constants,a=o!==void 0;return{name:t,number:a?o:e,description:r,supported:a,action:n,forced:i,standard:s}}});var pw=w(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.signalsByNumber=Pr.signalsByName=void 0;var $_=require("os"),hw=fw(),L_=sl(),G_=function(){return(0,hw.getSignals)().reduce(q_,{})},q_=function(t,{name:e,number:r,description:n,supported:i,action:s,forced:o,standard:a}){return{...t,[e]:{name:e,number:r,description:n,supported:i,action:s,forced:o,standard:a}}},B_=G_();Pr.signalsByName=B_;var U_=function(){let t=(0,hw.getSignals)(),e=L_.SIGRTMAX+1,r=Array.from({length:e},(n,i)=>V_(i,t));return Object.assign({},...r)},V_=function(t,e){let r=W_(t,e);if(r===void 0)return{};let{name:n,description:i,supported:s,action:o,forced:a,standard:l}=r;return{[t]:{name:n,number:t,description:i,supported:s,action:o,forced:a,standard:l}}},W_=function(t,e){let r=e.find(({name:n})=>$_.constants.signals[n]===t);return r!==void 0?r:e.find(n=>n.number===t)},H_=U_();Pr.signalsByNumber=H_});var gw=w((dG,mw)=>{"use strict";var{signalsByName:J_}=pw(),Y_=({timedOut:t,timeout:e,errorCode:r,signal:n,signalDescription:i,exitCode:s,isCanceled:o})=>t?`timed out after ${e} milliseconds`:o?"was canceled":r!==void 0?`failed with ${r}`:n!==void 0?`was killed with ${n} (${i})`:s!==void 0?`failed with exit code ${s}`:"failed",z_=({stdout:t,stderr:e,all:r,error:n,signal:i,exitCode:s,command:o,escapedCommand:a,timedOut:l,isCanceled:u,killed:c,parsed:{options:{timeout:d}}})=>{s=s===null?void 0:s,i=i===null?void 0:i;let f=i===void 0?void 0:J_[i].description,h=n&&n.code,y=`Command ${Y_({timedOut:l,timeout:d,errorCode:h,signal:i,signalDescription:f,exitCode:s,isCanceled:u})}: ${o}`,x=Object.prototype.toString.call(n)==="[object Error]",b=x?`${y}
|
|
131
|
+
${n.message}`:y,S=[b,e,t].filter(Boolean).join(`
|
|
132
|
+
`);return x?(n.originalMessage=n.message,n.message=S):n=new Error(S),n.shortMessage=b,n.command=o,n.escapedCommand=a,n.exitCode=s,n.signal=i,n.signalDescription=f,n.stdout=t,n.stderr=e,r!==void 0&&(n.all=r),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!l,n.isCanceled=u,n.killed=c&&!l,n};mw.exports=z_});var ww=w((fG,ol)=>{"use strict";var es=["stdin","stdout","stderr"],K_=t=>es.some(e=>t[e]!==void 0),yw=t=>{if(!t)return;let{stdio:e}=t;if(e===void 0)return es.map(n=>t[n]);if(K_(t))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${es.map(n=>`\`${n}\``).join(", ")}`);if(typeof e=="string")return e;if(!Array.isArray(e))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof e}\``);let r=Math.max(e.length,es.length);return Array.from({length:r},(n,i)=>e[i])};ol.exports=yw;ol.exports.node=t=>{let e=yw(t);return e==="ipc"?"ipc":e===void 0||typeof e=="string"?[e,e,e,"ipc"]:e.includes("ipc")?e:[...e,"ipc"]}});var bw=w((hG,ts)=>{ts.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&ts.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ts.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var Ow=w((pG,Ir)=>{var ee=global.process,rr=function(t){return t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function"};rr(ee)?(Sw=require("assert"),_r=bw(),xw=/^win/i.test(ee.platform),Pn=require("events"),typeof Pn!="function"&&(Pn=Pn.EventEmitter),ee.__signal_exit_emitter__?pe=ee.__signal_exit_emitter__:(pe=ee.__signal_exit_emitter__=new Pn,pe.count=0,pe.emitted={}),pe.infinite||(pe.setMaxListeners(1/0),pe.infinite=!0),Ir.exports=function(t,e){if(!rr(global.process))return function(){};Sw.equal(typeof t,"function","a callback must be provided for exit handler"),kr===!1&&al();var r="exit";e&&e.alwaysLast&&(r="afterexit");var n=function(){pe.removeListener(r,t),pe.listeners("exit").length===0&&pe.listeners("afterexit").length===0&&rs()};return pe.on(r,t),n},rs=function(){!kr||!rr(global.process)||(kr=!1,_r.forEach(function(e){try{ee.removeListener(e,ns[e])}catch{}}),ee.emit=is,ee.reallyExit=cl,pe.count-=1)},Ir.exports.unload=rs,nr=function(e,r,n){pe.emitted[e]||(pe.emitted[e]=!0,pe.emit(e,r,n))},ns={},_r.forEach(function(t){ns[t]=function(){if(rr(global.process)){var r=ee.listeners(t);r.length===pe.count&&(rs(),nr("exit",null,t),nr("afterexit",null,t),xw&&t==="SIGHUP"&&(t="SIGINT"),ee.kill(ee.pid,t))}}}),Ir.exports.signals=function(){return _r},kr=!1,al=function(){kr||!rr(global.process)||(kr=!0,pe.count+=1,_r=_r.filter(function(e){try{return ee.on(e,ns[e]),!0}catch{return!1}}),ee.emit=Ew,ee.reallyExit=vw)},Ir.exports.load=al,cl=ee.reallyExit,vw=function(e){rr(global.process)&&(ee.exitCode=e||0,nr("exit",ee.exitCode,null),nr("afterexit",ee.exitCode,null),cl.call(ee,ee.exitCode))},is=ee.emit,Ew=function(e,r){if(e==="exit"&&rr(global.process)){r!==void 0&&(ee.exitCode=r);var n=is.apply(this,arguments);return nr("exit",ee.exitCode,null),nr("afterexit",ee.exitCode,null),n}else return is.apply(this,arguments)}):Ir.exports=function(){return function(){}};var Sw,_r,xw,Pn,pe,rs,nr,ns,kr,al,cl,vw,is,Ew});var Cw=w((mG,Tw)=>{"use strict";var X_=require("os"),Z_=Ow(),Q_=1e3*5,ek=(t,e="SIGTERM",r={})=>{let n=t(e);return tk(t,e,r,n),n},tk=(t,e,r,n)=>{if(!rk(e,r,n))return;let i=ik(r),s=setTimeout(()=>{t("SIGKILL")},i);s.unref&&s.unref()},rk=(t,{forceKillAfterTimeout:e},r)=>nk(t)&&e!==!1&&r,nk=t=>t===X_.constants.signals.SIGTERM||typeof t=="string"&&t.toUpperCase()==="SIGTERM",ik=({forceKillAfterTimeout:t=!0})=>{if(t===!0)return Q_;if(!Number.isFinite(t)||t<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`);return t},sk=(t,e)=>{t.kill()&&(e.isCanceled=!0)},ok=(t,e,r)=>{t.kill(e),r(Object.assign(new Error("Timed out"),{timedOut:!0,signal:e}))},ak=(t,{timeout:e,killSignal:r="SIGTERM"},n)=>{if(e===0||e===void 0)return n;let i,s=new Promise((a,l)=>{i=setTimeout(()=>{ok(t,r,l)},e)}),o=n.finally(()=>{clearTimeout(i)});return Promise.race([s,o])},ck=({timeout:t})=>{if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`)},lk=async(t,{cleanup:e,detached:r},n)=>{if(!e||r)return n;let i=Z_(()=>{t.kill()});return n.finally(()=>{i()})};Tw.exports={spawnedKill:ek,spawnedCancel:sk,setupTimeout:ak,validateTimeout:ck,setExitHandler:lk}});var Pw=w((gG,Aw)=>{"use strict";var tt=t=>t!==null&&typeof t=="object"&&typeof t.pipe=="function";tt.writable=t=>tt(t)&&t.writable!==!1&&typeof t._write=="function"&&typeof t._writableState=="object";tt.readable=t=>tt(t)&&t.readable!==!1&&typeof t._read=="function"&&typeof t._readableState=="object";tt.duplex=t=>tt.writable(t)&&tt.readable(t);tt.transform=t=>tt.duplex(t)&&typeof t._transform=="function";Aw.exports=tt});var kw=w((yG,_w)=>{"use strict";var{PassThrough:uk}=require("stream");_w.exports=t=>{t={...t};let{array:e}=t,{encoding:r}=t,n=r==="buffer",i=!1;e?i=!(r||n):r=r||"utf8",n&&(r=null);let s=new uk({objectMode:i});r&&s.setEncoding(r);let o=0,a=[];return s.on("data",l=>{a.push(l),i?o=a.length:o+=l.length}),s.getBufferedValue=()=>e?a:n?Buffer.concat(a,o):a.join(""),s.getBufferedLength=()=>o,s}});var Iw=w((wG,_n)=>{"use strict";var{constants:dk}=require("buffer"),fk=require("stream"),{promisify:hk}=require("util"),pk=kw(),mk=hk(fk.pipeline),ss=class extends Error{constructor(){super("maxBuffer exceeded"),this.name="MaxBufferError"}};async function ll(t,e){if(!t)throw new Error("Expected a stream");e={maxBuffer:1/0,...e};let{maxBuffer:r}=e,n=pk(e);return await new Promise((i,s)=>{let o=a=>{a&&n.getBufferedLength()<=dk.MAX_LENGTH&&(a.bufferedData=n.getBufferedValue()),s(a)};(async()=>{try{await mk(t,n),i()}catch(a){o(a)}})(),n.on("data",()=>{n.getBufferedLength()>r&&o(new ss)})}),n.getBufferedValue()}_n.exports=ll;_n.exports.buffer=(t,e)=>ll(t,{...e,encoding:"buffer"});_n.exports.array=(t,e)=>ll(t,{...e,array:!0});_n.exports.MaxBufferError=ss});var Dw=w((bG,Mw)=>{"use strict";var{PassThrough:gk}=require("stream");Mw.exports=function(){var t=[],e=new gk({objectMode:!0});return e.setMaxListeners(0),e.add=r,e.isEmpty=n,e.on("unpipe",i),Array.prototype.slice.call(arguments).forEach(r),e;function r(s){return Array.isArray(s)?(s.forEach(r),this):(t.push(s),s.once("end",i.bind(null,s)),s.once("error",e.emit.bind(e,"error")),s.pipe(e,{end:!1}),this)}function n(){return t.length==0}function i(s){t=t.filter(function(o){return o!==s}),!t.length&&e.readable&&e.end()}}});var Nw=w((SG,Fw)=>{"use strict";var jw=Pw(),Rw=Iw(),yk=Dw(),wk=(t,e)=>{e===void 0||t.stdin===void 0||(jw(e)?e.pipe(t.stdin):t.stdin.end(e))},bk=(t,{all:e})=>{if(!e||!t.stdout&&!t.stderr)return;let r=yk();return t.stdout&&r.add(t.stdout),t.stderr&&r.add(t.stderr),r},ul=async(t,e)=>{if(t){t.destroy();try{return await e}catch(r){return r.bufferedData}}},dl=(t,{encoding:e,buffer:r,maxBuffer:n})=>{if(!(!t||!r))return e?Rw(t,{encoding:e,maxBuffer:n}):Rw.buffer(t,{maxBuffer:n})},Sk=async({stdout:t,stderr:e,all:r},{encoding:n,buffer:i,maxBuffer:s},o)=>{let a=dl(t,{encoding:n,buffer:i,maxBuffer:s}),l=dl(e,{encoding:n,buffer:i,maxBuffer:s}),u=dl(r,{encoding:n,buffer:i,maxBuffer:s*2});try{return await Promise.all([o,a,l,u])}catch(c){return Promise.all([{error:c,signal:c.signal,timedOut:c.timedOut},ul(t,a),ul(e,l),ul(r,u)])}},xk=({input:t})=>{if(jw(t))throw new TypeError("The `input` option cannot be a stream in sync mode")};Fw.exports={handleInput:wk,makeAllStream:bk,getSpawnedResult:Sk,validateInputSync:xk}});var Lw=w((xG,$w)=>{"use strict";var vk=(async()=>{})().constructor.prototype,Ek=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(vk,t)]),Ok=(t,e)=>{for(let[r,n]of Ek){let i=typeof e=="function"?(...s)=>Reflect.apply(n.value,e(),s):n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}return t},Tk=t=>new Promise((e,r)=>{t.on("exit",(n,i)=>{e({exitCode:n,signal:i})}),t.on("error",n=>{r(n)}),t.stdin&&t.stdin.on("error",n=>{r(n)})});$w.exports={mergePromise:Ok,getSpawnedPromise:Tk}});var Bw=w((vG,qw)=>{"use strict";var Gw=(t,e=[])=>Array.isArray(e)?[t,...e]:[t],Ck=/^[\w.-]+$/,Ak=/"/g,Pk=t=>typeof t!="string"||Ck.test(t)?t:`"${t.replace(Ak,'\\"')}"`,_k=(t,e)=>Gw(t,e).join(" "),kk=(t,e)=>Gw(t,e).map(r=>Pk(r)).join(" "),Ik=/ +/g,Mk=t=>{let e=[];for(let r of t.trim().split(Ik)){let n=e[e.length-1];n&&n.endsWith("\\")?e[e.length-1]=`${n.slice(0,-1)} ${r}`:e.push(r)}return e};qw.exports={joinCommand:_k,getEscapedCommand:kk,parseCommand:Mk}});var zw=w((EG,Mr)=>{"use strict";var Dk=require("path"),fl=require("child_process"),Rk=nl(),jk=tw(),Fk=iw(),Nk=cw(),os=gw(),Vw=ww(),{spawnedKill:$k,spawnedCancel:Lk,setupTimeout:Gk,validateTimeout:qk,setExitHandler:Bk}=Cw(),{handleInput:Uk,getSpawnedResult:Vk,makeAllStream:Wk,validateInputSync:Hk}=Nw(),{mergePromise:Uw,getSpawnedPromise:Jk}=Lw(),{joinCommand:Ww,parseCommand:Hw,getEscapedCommand:Jw}=Bw(),Yk=1e3*1e3*100,zk=({env:t,extendEnv:e,preferLocal:r,localDir:n,execPath:i})=>{let s=e?{...process.env,...t}:t;return r?Fk.env({env:s,cwd:n,execPath:i}):s},Yw=(t,e,r={})=>{let n=Rk._parse(t,e,r);return t=n.command,e=n.args,r=n.options,r={maxBuffer:Yk,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:r.cwd||process.cwd(),execPath:process.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...r},r.env=zk(r),r.stdio=Vw(r),process.platform==="win32"&&Dk.basename(t,".exe")==="cmd"&&e.unshift("/q"),{file:t,args:e,options:r,parsed:n}},kn=(t,e,r)=>typeof e!="string"&&!Buffer.isBuffer(e)?r===void 0?void 0:"":t.stripFinalNewline?jk(e):e,as=(t,e,r)=>{let n=Yw(t,e,r),i=Ww(t,e),s=Jw(t,e);qk(n.options);let o;try{o=fl.spawn(n.file,n.args,n.options)}catch(h){let p=new fl.ChildProcess,y=Promise.reject(os({error:h,stdout:"",stderr:"",all:"",command:i,escapedCommand:s,parsed:n,timedOut:!1,isCanceled:!1,killed:!1}));return Uw(p,y)}let a=Jk(o),l=Gk(o,n.options,a),u=Bk(o,n.options,l),c={isCanceled:!1};o.kill=$k.bind(null,o.kill.bind(o)),o.cancel=Lk.bind(null,o,c);let f=Nk(async()=>{let[{error:h,exitCode:p,signal:y,timedOut:x},b,S,g]=await Vk(o,n.options,u),v=kn(n.options,b),E=kn(n.options,S),T=kn(n.options,g);if(h||p!==0||y!==null){let j=os({error:h,exitCode:p,signal:y,stdout:v,stderr:E,all:T,command:i,escapedCommand:s,parsed:n,timedOut:x,isCanceled:c.isCanceled,killed:o.killed});if(!n.options.reject)return j;throw j}return{command:i,escapedCommand:s,exitCode:0,stdout:v,stderr:E,all:T,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}});return Uk(o,n.options.input),o.all=Wk(o,n.options),Uw(o,f)};Mr.exports=as;Mr.exports.sync=(t,e,r)=>{let n=Yw(t,e,r),i=Ww(t,e),s=Jw(t,e);Hk(n.options);let o;try{o=fl.spawnSync(n.file,n.args,n.options)}catch(u){throw os({error:u,stdout:"",stderr:"",all:"",command:i,escapedCommand:s,parsed:n,timedOut:!1,isCanceled:!1,killed:!1})}let a=kn(n.options,o.stdout,o.error),l=kn(n.options,o.stderr,o.error);if(o.error||o.status!==0||o.signal!==null){let u=os({stdout:a,stderr:l,error:o.error,signal:o.signal,exitCode:o.status,command:i,escapedCommand:s,parsed:n,timedOut:o.error&&o.error.code==="ETIMEDOUT",isCanceled:!1,killed:o.signal!==null});if(!n.options.reject)return u;throw u}return{command:i,escapedCommand:s,exitCode:0,stdout:a,stderr:l,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}};Mr.exports.command=(t,e)=>{let[r,...n]=Hw(t);return as(r,n,e)};Mr.exports.commandSync=(t,e)=>{let[r,...n]=Hw(t);return as.sync(r,n,e)};Mr.exports.node=(t,e,r={})=>{e&&!Array.isArray(e)&&typeof e=="object"&&(r=e,e=[]);let n=Vw.node(r),i=process.execArgv.filter(a=>!a.startsWith("--inspect")),{nodePath:s=process.execPath,nodeOptions:o=i}=r;return as(s,[...o,t,...Array.isArray(e)?e:[]],{...r,stdin:void 0,stdout:void 0,stderr:void 0,stdio:n,shell:!1})}});var QE=w((E6,FF)=>{FF.exports=["_http_agent","_http_client","_http_common","_http_incoming","_http_outgoing","_http_server","_stream_duplex","_stream_passthrough","_stream_readable","_stream_transform","_stream_wrap","_stream_writable","_tls_common","_tls_wrap","assert","assert/strict","async_hooks","buffer","child_process","cluster","console","constants","crypto","dgram","diagnostics_channel","dns","dns/promises","domain","events","fs","fs/promises","http","http2","https","inspector","inspector/promises","module","net","os","path","path/posix","path/win32","perf_hooks","process","punycode","querystring","readline","readline/promises","repl","stream","stream/consumers","stream/promises","stream/web","string_decoder","sys","timers","timers/promises","tls","trace_events","tty","url","util","util/types","v8","vm","wasi","worker_threads","zlib","node:sea","node:sqlite","node:test","node:test/reporters"]});var tO=w((O6,eO)=>{"use strict";var NF=QE(),$F=new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$"),LF=["node_modules","favicon.ico"];function GF(t){var e=[],r=[];if(t===null)return r.push("name cannot be null"),Kn(e,r);if(t===void 0)return r.push("name cannot be undefined"),Kn(e,r);if(typeof t!="string")return r.push("name must be a string"),Kn(e,r);if(t.length||r.push("name length must be greater than zero"),t.startsWith(".")&&r.push("name cannot start with a period"),t.startsWith("-")&&r.push("name cannot start with a hyphen"),t.match(/^_/)&&r.push("name cannot start with an underscore"),t.trim()!==t&&r.push("name cannot contain leading or trailing spaces"),LF.forEach(function(o){t.toLowerCase()===o&&r.push(o+" is not a valid package name")}),NF.includes(t.toLowerCase())&&e.push(t+" is a core module name"),t.length>214&&e.push("name can no longer contain more than 214 characters"),t.toLowerCase()!==t&&e.push("name can no longer contain capital letters"),/[~'!()*]/.test(t.split("/").slice(-1)[0])&&e.push(`name can no longer contain special characters ("~'!()*")`),encodeURIComponent(t)!==t){var n=t.match($F);if(n){var i=n[1],s=n[2];if(s.startsWith(".")&&r.push("name cannot start with a period"),encodeURIComponent(i)===i&&encodeURIComponent(s)===s)return Kn(e,r)}r.push("name can only contain URL-friendly characters")}return Kn(e,r)}var Kn=function(t,e){var r={validForNewPackages:e.length===0&&t.length===0,validForOldPackages:e.length===0,warnings:t,errors:e};return r.warnings.length||delete r.warnings,r.errors.length||delete r.errors,r};eO.exports=GF});var td=C(ed(),1),{program:PN,createCommand:_N,createArgument:kN,createOption:IN,CommanderError:MN,InvalidArgumentError:DN,InvalidOptionArgumentError:RN,Command:rd,Argument:jN,Option:FN,Help:NN}=td.default;var _e=C(require("fs")),To=require("path");var nd=(t=0)=>e=>`\x1B[${e+t}m`,id=(t=0)=>e=>`\x1B[${38+t};5;${e}m`,sd=(t=0)=>(e,r,n)=>`\x1B[${38+t};2;${e};${r};${n}m`,Z={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},LN=Object.keys(Z.modifier),UO=Object.keys(Z.color),VO=Object.keys(Z.bgColor),GN=[...UO,...VO];function WO(){let t=new Map;for(let[e,r]of Object.entries(Z)){for(let[n,i]of Object.entries(r))Z[n]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},r[n]=Z[n],t.set(i[0],i[1]);Object.defineProperty(Z,e,{value:r,enumerable:!1})}return Object.defineProperty(Z,"codes",{value:t,enumerable:!1}),Z.color.close="\x1B[39m",Z.bgColor.close="\x1B[49m",Z.color.ansi=nd(),Z.color.ansi256=id(),Z.color.ansi16m=sd(),Z.bgColor.ansi=nd(10),Z.bgColor.ansi256=id(10),Z.bgColor.ansi16m=sd(10),Object.defineProperties(Z,{rgbToAnsi256:{value(e,r,n){return e===r&&r===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!r)return[0,0,0];let[n]=r;n.length===3&&(n=[...n].map(s=>s+s).join(""));let i=Number.parseInt(n,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:e=>Z.rgbToAnsi256(...Z.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let r,n,i;if(e>=232)r=((e-232)*10+8)/255,n=r,i=r;else{e-=16;let a=e%36;r=Math.floor(e/36)/5,n=Math.floor(a/6)/5,i=a%6/5}let s=Math.max(r,n,i)*2;if(s===0)return 30;let o=30+(Math.round(i)<<2|Math.round(n)<<1|Math.round(r));return s===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(e,r,n)=>Z.ansi256ToAnsi(Z.rgbToAnsi256(e,r,n)),enumerable:!1},hexToAnsi:{value:e=>Z.ansi256ToAnsi(Z.hexToAnsi256(e)),enumerable:!1}}),Z}var HO=WO(),Fe=HO;var ni=C(require("node:process"),1),ad=C(require("node:os"),1),Wo=C(require("node:tty"),1);function Me(t,e=globalThis.Deno?globalThis.Deno.args:ni.default.argv){let r=t.startsWith("-")?"":t.length===1?"-":"--",n=e.indexOf(r+t),i=e.indexOf("--");return n!==-1&&(i===-1||n<i)}var{env:Q}=ni.default,ri;Me("no-color")||Me("no-colors")||Me("color=false")||Me("color=never")?ri=0:(Me("color")||Me("colors")||Me("color=true")||Me("color=always"))&&(ri=1);function JO(){if("FORCE_COLOR"in Q)return Q.FORCE_COLOR==="true"?1:Q.FORCE_COLOR==="false"?0:Q.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Q.FORCE_COLOR,10),3)}function YO(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function zO(t,{streamIsTTY:e,sniffFlags:r=!0}={}){let n=JO();n!==void 0&&(ri=n);let i=r?ri:n;if(i===0)return 0;if(r){if(Me("color=16m")||Me("color=full")||Me("color=truecolor"))return 3;if(Me("color=256"))return 2}if("TF_BUILD"in Q&&"AGENT_NAME"in Q)return 1;if(t&&!e&&i===void 0)return 0;let s=i||0;if(Q.TERM==="dumb")return s;if(ni.default.platform==="win32"){let o=ad.default.release().split(".");return Number(o[0])>=10&&Number(o[2])>=10586?Number(o[2])>=14931?3:2:1}if("CI"in Q)return["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some(o=>o in Q)?3:["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(o=>o in Q)||Q.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in Q)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Q.TEAMCITY_VERSION)?1:0;if(Q.COLORTERM==="truecolor"||Q.TERM==="xterm-kitty"||Q.TERM==="xterm-ghostty"||Q.TERM==="wezterm")return 3;if("TERM_PROGRAM"in Q){let o=Number.parseInt((Q.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Q.TERM_PROGRAM){case"iTerm.app":return o>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Q.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Q.TERM)||"COLORTERM"in Q?1:s}function od(t,e={}){let r=zO(t,{streamIsTTY:t&&t.isTTY,...e});return YO(r)}var KO={stdout:od({isTTY:Wo.default.isatty(1)}),stderr:od({isTTY:Wo.default.isatty(2)})},cd=KO;function ld(t,e,r){let n=t.indexOf(e);if(n===-1)return t;let i=e.length,s=0,o="";do o+=t.slice(s,n)+e+r,s=n+i,n=t.indexOf(e,s);while(n!==-1);return o+=t.slice(s),o}function ud(t,e,r,n){let i=0,s="";do{let o=t[n-1]==="\r";s+=t.slice(i,o?n-1:n)+e+(o?`\r
|
|
133
|
+
`:`
|
|
134
|
+
`)+r,i=n+1,n=t.indexOf(`
|
|
135
|
+
`,i)}while(n!==-1);return s+=t.slice(i),s}var{stdout:dd,stderr:fd}=cd,Ho=Symbol("GENERATOR"),lr=Symbol("STYLER"),Qr=Symbol("IS_EMPTY"),hd=["ansi","ansi","ansi256","ansi16m"],ur=Object.create(null),XO=(t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let r=dd?dd.level:0;t.level=e.level===void 0?r:e.level};var ZO=t=>{let e=(...r)=>r.join(" ");return XO(e,t),Object.setPrototypeOf(e,en.prototype),e};function en(t){return ZO(t)}Object.setPrototypeOf(en.prototype,Function.prototype);for(let[t,e]of Object.entries(Fe))ur[t]={get(){let r=ii(this,Yo(e.open,e.close,this[lr]),this[Qr]);return Object.defineProperty(this,t,{value:r}),r}};ur.visible={get(){let t=ii(this,this[lr],!0);return Object.defineProperty(this,"visible",{value:t}),t}};var Jo=(t,e,r,...n)=>t==="rgb"?e==="ansi16m"?Fe[r].ansi16m(...n):e==="ansi256"?Fe[r].ansi256(Fe.rgbToAnsi256(...n)):Fe[r].ansi(Fe.rgbToAnsi(...n)):t==="hex"?Jo("rgb",e,r,...Fe.hexToRgb(...n)):Fe[r][t](...n),QO=["rgb","hex","ansi256"];for(let t of QO){ur[t]={get(){let{level:r}=this;return function(...n){let i=Yo(Jo(t,hd[r],"color",...n),Fe.color.close,this[lr]);return ii(this,i,this[Qr])}}};let e="bg"+t[0].toUpperCase()+t.slice(1);ur[e]={get(){let{level:r}=this;return function(...n){let i=Yo(Jo(t,hd[r],"bgColor",...n),Fe.bgColor.close,this[lr]);return ii(this,i,this[Qr])}}}}var e0=Object.defineProperties(()=>{},{...ur,level:{enumerable:!0,get(){return this[Ho].level},set(t){this[Ho].level=t}}}),Yo=(t,e,r)=>{let n,i;return r===void 0?(n=t,i=e):(n=r.openAll+t,i=e+r.closeAll),{open:t,close:e,openAll:n,closeAll:i,parent:r}},ii=(t,e,r)=>{let n=(...i)=>t0(n,i.length===1?""+i[0]:i.join(" "));return Object.setPrototypeOf(n,e0),n[Ho]=t,n[lr]=e,n[Qr]=r,n},t0=(t,e)=>{if(t.level<=0||!e)return t[Qr]?"":e;let r=t[lr];if(r===void 0)return e;let{openAll:n,closeAll:i}=r;if(e.includes("\x1B"))for(;r!==void 0;)e=ld(e,r.close,r.open),r=r.parent;let s=e.indexOf(`
|
|
136
|
+
`);return s!==-1&&(e=ud(e,i,n,s)),n+e+i};Object.defineProperties(en.prototype,ur);var r0=en(),JN=en({level:fd?fd.level:0});var P=r0;var Nu=require("child_process"),Y=C(fe()),te=C(require("path")),Wt=C(bc());var ae=C(fe()),he=C(require("path"));var bt=C(require("fs")),et=C(require("path"));var Qe={PNPM:"pnpm",NPM:"npm",YARN:"yarn",BUN:"bun"},Ft={[Qe.PNPM]:"pnpm-lock.yaml",[Qe.YARN]:"yarn.lock",[Qe.BUN]:"bun.lockb",[Qe.NPM]:"package-lock.json"},c1=[{file:Ft.pnpm,pm:Qe.PNPM},{file:Ft.yarn,pm:Qe.YARN},{file:Ft.bun,pm:Qe.BUN},{file:Ft.npm,pm:Qe.NPM}],l1={TYPESCRIPT:"typescript",JAVASCRIPT:"javascript"},Te={DATABASE:"database",AUTH:"auth",FRAMEWORK:"framework",UI:"ui",STORAGE:"storage"},Ii={MODULES:"modules",TEMPLATES:"templates",NODE_MODULES:"node_modules",GIT:".git",PRISMA:"prisma",FILES:"files",SRC:"src",DIST:"dist",BIN:"bin"},ye={PACKAGE_JSON:"package.json",TSCONFIG_JSON:"tsconfig.json",MODULE_JSON:"module.json",GENERATOR_JSON:"generator.json",TEMPLATE_JSON:"template.json",CONFIG_JSON:"config.json",ENV:".env",ENV_LOCAL:".env.local",ENV_EXAMPLE:".env.example",GITIGNORE:".gitignore",README:"README.md",SCHEMA_PRISMA:"schema.prisma"},u1=[ye.ENV,ye.ENV_LOCAL],d1=[ye.TEMPLATE_JSON,ye.CONFIG_JSON,Ii.NODE_MODULES,Ii.GIT],Mi={PACKAGE_INSTALL:3e5,GIT_INIT:3e4,RETRY_DELAY_BASE:1e3},$g={MAX_ATTEMPTS:2,PACKAGE_ROOT_MAX_ATTEMPTS:10},Sc={KEY:/^[A-Z_][A-Z0-9_]*$/,COMMENT:/^\s*#/},xc={APP:"app",PAGES:"pages"},U2={[Te.DATABASE]:"Database",[Te.AUTH]:"Auth",[Te.FRAMEWORK]:"Framework",[Te.UI]:"UI",[Te.STORAGE]:"Storage"},Lg={NO_PACKAGE_JSON:"No package.json found in current directory or any parent directory.",INVALID_DIRECTORY:"Target directory already exists and is not empty.",INVALID_PROJECT_NAME:"Invalid project name. Please use a valid npm package name.",UNKNOWN_MODULE_TYPE:t=>`Unknown module type "${t}". Use "${Te.DATABASE}" or "${Te.AUTH}", or specify a provider directly.`,MODULE_NOT_FOUND:t=>`Module "${t}" not found.`,TEMPLATE_NOT_FOUND:t=>`Base template not found for framework: ${t}`,GIT_INIT_FAILED:"Failed to initialize git repository",PACKAGE_INSTALL_FAILED:"Failed to install dependencies"};var V2=Qe.NPM,W2=l1.TYPESCRIPT;function M(){try{let e=require.resolve("stackkit/package.json"),r=et.dirname(e);if(bt.existsSync(r)&&bt.existsSync(et.join(r,ye.PACKAGE_JSON)))return r}catch{}try{let e=__dirname,r=0,n=$g.PACKAGE_ROOT_MAX_ATTEMPTS;for(;r<n;){let i=et.join(e,ye.PACKAGE_JSON);if(bt.existsSync(i))try{if(JSON.parse(bt.readFileSync(i,"utf-8")).name==="stackkit")return e}catch{}let s=et.dirname(e);if(s===e)break;e=s,r++}}catch{}try{let e=et.resolve(__dirname,"..","..",".."),r=et.join(e,ye.PACKAGE_JSON);if(bt.existsSync(r))try{if(JSON.parse(bt.readFileSync(r,"utf-8")).name==="stackkit")return e}catch{}}catch{}let t=et.resolve(__dirname,"..","..","..");if(!bt.existsSync(t))throw new Error(`Unable to determine stackkit package root. Please ensure stackkit is properly installed and run from a valid location. Attempted path: ${t}`);return t}var Gg=C(fe()),qg=C(require("path"));function Xt(t){return t?t==="none"?{database:"none"}:t.startsWith("prisma-")?{database:"prisma",provider:t.split("-")[1]}:t==="prisma"?{database:"prisma"}:{database:t}:{database:"none"}}function De(t){let e=t||M(),r=qg.default.join(e,"modules","database","prisma","generator.json");try{let n=Gg.default.readJsonSync(r,{throws:!1}),i=new Set,s=n&&typeof n=="object"?n.operations:void 0;if(Array.isArray(s))for(let o of s){let a=o&&typeof o=="object"?o.condition:void 0;a&&typeof a.prismaProvider=="string"&&i.add(String(a.prismaProvider))}return Array.from(i)}catch{return[]}}async function Sr(t){try{return await ae.default.readJson(t)}catch{return null}}async function Di(t){let e={frameworks:[],databases:[],auth:[]},r=[];t&&r.push(t),r.push(he.default.join(M(),"modules"));let n;for(let c of r)if(await ae.default.pathExists(c)){n=c;break}if(!n)return e;t=n;let i=he.default.join(t,"..","templates");if(await ae.default.pathExists(i)){let c=await ae.default.readdir(i);for(let d of c){let f=he.default.join(i,d,"template.json");if(await ae.default.pathExists(f)){let h=await Sr(f);h&&e.frameworks.push({...h,name:d,category:"framework"})}}}let s=he.default.join(t,"database");if(await ae.default.pathExists(s)){let c=await ae.default.readdir(s);c.sort((d,f)=>d==="prisma"?-1:f==="prisma"?1:d.localeCompare(f));for(let d of c){let f=he.default.join(s,d),h=he.default.join(f,"module.json");if(await ae.default.pathExists(h)){let p=await Sr(h);p&&(p.name||(p.name=d),p.displayName||(p.displayName=d),e.databases.push(p))}}}let o=he.default.join(t,"auth");if(await ae.default.pathExists(o)){let c=await ae.default.readdir(o);for(let d of c){let f=he.default.join(o,d),h=he.default.join(f,"module.json");if(await ae.default.pathExists(h)){let p=await Sr(h);p&&(p.name||(p.name=d),p.displayName||(p.displayName=d),e.auth.push(p))}}}let a=he.default.join(t,"ui");if(await ae.default.pathExists(a)){e.ui=[];let c=await ae.default.readdir(a);for(let d of c){let f=he.default.join(a,d),h=he.default.join(f,"module.json");if(await ae.default.pathExists(h)){let p=await Sr(h);p&&(p.name||(p.name=d),p.displayName||(p.displayName=d),e.ui.push(p))}}}let l=he.default.join(t,"storage");if(await ae.default.pathExists(l)){e.storage=[];let c=await ae.default.readdir(l);for(let d of c){let f=he.default.join(l,d),h=he.default.join(f,"module.json");if(await ae.default.pathExists(h)){let p=await Sr(h);p&&(p.name||(p.name=d),p.displayName||(p.displayName=d),e.storage.push(p))}}}let u=he.default.join(t,"components");if(await ae.default.pathExists(u)){let c=he.default.join(u,"module.json");if(await ae.default.pathExists(c)){let d=await Sr(c);d&&(d.name||(d.name="components"),d.displayName||(d.displayName="Components"),e.components=[d])}}return e}function Bg(t){let e=["none"];for(let r of t)if(r.name==="prisma"){let n=De();if(n.length>0)for(let i of n)e.push(`prisma-${i}`);else e.push("prisma")}else e.push(r.name);return e}function Ug(t){let e=["none"];for(let r of t)e.push(r.name);return e}function Sn(t,e,r,n){let i=[];for(let s of t){if(s.supportedFrameworks&&!s.supportedFrameworks.includes(e))continue;let o=Xt(r||"").database,a=!0;s.compatibility&&s.compatibility.databases&&(a=s.compatibility.databases.includes(o));let l=!1;if(n&&Array.isArray(n)){let u=n.find(c=>c.name===e);if(u&&u.compatibility){let c=u.compatibility.auth;Array.isArray(c)&&c.includes(s.name)&&(l=!0)}}!a&&!l||i.push({name:s.displayName,value:s.name,description:s.description||""})}return i.push({name:"None",value:"none"}),i}function xn(t,e){let r=[];for(let n of t)if(!(n.supportedFrameworks&&!n.supportedFrameworks.includes(e)))if(n.name==="prisma"){let i=De();if(i.length>0)for(let s of i)r.push({name:`Prisma (${s.charAt(0).toUpperCase()+s.slice(1)})`,value:`prisma-${s}`});else r.push({name:"Prisma",value:"prisma"})}else r.push({name:n.displayName||n.name,value:n.name});return r.push({name:"None",value:"none"}),r}var Ge=C(fe()),Wi=C(require("path"));var vr=C(require("node:process"),1),ay=require("node:util");var _c=C(require("node:process"),1);var vn=C(require("node:process"),1);var f1=(t,e,r,n)=>{if(r==="length"||r==="prototype"||r==="arguments"||r==="caller")return;let i=Object.getOwnPropertyDescriptor(t,r),s=Object.getOwnPropertyDescriptor(e,r);!h1(i,s)&&n||Object.defineProperty(t,r,s)},h1=function(t,e){return t===void 0||t.configurable||t.writable===e.writable&&t.enumerable===e.enumerable&&t.configurable===e.configurable&&(t.writable||t.value===e.value)},p1=(t,e)=>{let r=Object.getPrototypeOf(e);r!==Object.getPrototypeOf(t)&&Object.setPrototypeOf(t,r)},m1=(t,e)=>`/* Wrapped ${t}*/
|
|
137
|
+
${e}`,g1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),y1=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),w1=(t,e,r)=>{let n=r===""?"":`with ${r.trim()}() `,i=m1.bind(null,n,e.toString());Object.defineProperty(i,"name",y1);let{writable:s,enumerable:o,configurable:a}=g1;Object.defineProperty(t,"toString",{value:i,writable:s,enumerable:o,configurable:a})};function vc(t,e,{ignoreNonConfigurable:r=!1}={}){let{name:n}=t;for(let i of Reflect.ownKeys(e))f1(t,e,i,r);return p1(t,e),w1(t,e,n),t}var Ri=new WeakMap,Vg=(t,e={})=>{if(typeof t!="function")throw new TypeError("Expected a function");let r,n=0,i=t.displayName||t.name||"<anonymous>",s=function(...o){if(Ri.set(s,++n),n===1)r=t.apply(this,o),t=void 0;else if(e.throw===!0)throw new Error(`Function \`${i}\` can only be called once`);return r};return vc(s,t),Ri.set(s,n),s};Vg.callCount=t=>{if(!Ri.has(t))throw new Error(`The given function \`${t.name}\` is not wrapped by the \`onetime\` package`);return Ri.get(t)};var Wg=Vg;var Zt=[];Zt.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&Zt.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Zt.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ji=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",Ec=Symbol.for("signal-exit emitter"),Oc=globalThis,b1=Object.defineProperty.bind(Object),Tc=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Oc[Ec])return Oc[Ec];b1(Oc,Ec,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},Fi=class{},S1=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Cc=class extends Fi{onExit(){return()=>{}}load(){}unload(){}},Ac=class extends Fi{#i=Pc.platform==="win32"?"SIGINT":"SIGHUP";#n=new Tc;#t;#e;#s;#r={};#o=!1;constructor(e){super(),this.#t=e,this.#r={};for(let r of Zt)this.#r[r]=()=>{let n=this.#t.listeners(r),{count:i}=this.#n,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#n.emit("exit",null,r),a=r==="SIGHUP"?this.#i:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#e=e.emit}onExit(e,r){if(!ji(this.#t))return()=>{};this.#o===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#n.on(n,e),()=>{this.#n.removeListener(n,e),this.#n.listeners.exit.length===0&&this.#n.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#o){this.#o=!0,this.#n.count+=1;for(let e of Zt)try{let r=this.#r[e];r&&this.#t.on(e,r)}catch{}this.#t.emit=(e,...r)=>this.#d(e,...r),this.#t.reallyExit=e=>this.#c(e)}}unload(){this.#o&&(this.#o=!1,Zt.forEach(e=>{let r=this.#r[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#t.removeListener(e,r)}catch{}}),this.#t.emit=this.#e,this.#t.reallyExit=this.#s,this.#n.count-=1)}#c(e){return ji(this.#t)?(this.#t.exitCode=e||0,this.#n.emit("exit",this.#t.exitCode,null),this.#s.call(this.#t,this.#t.exitCode)):0}#d(e,...r){let n=this.#e;if(e==="exit"&&ji(this.#t)){typeof r[0]=="number"&&(this.#t.exitCode=r[0]);let i=n.call(this.#t,e,...r);return this.#n.emit("exit",this.#t.exitCode,null),i}else return n.call(this.#t,e,...r)}},Pc=globalThis.process,{onExit:Ni,load:sL,unload:oL}=S1(ji(Pc)?new Ac(Pc):new Cc);var Hg=vn.default.stderr.isTTY?vn.default.stderr:vn.default.stdout.isTTY?vn.default.stdout:void 0,x1=Hg?Wg(()=>{Ni(()=>{Hg.write("\x1B[?25h")},{alwaysLast:!0})}):()=>{},Jg=x1;var $i=!1,xr={};xr.show=(t=_c.default.stderr)=>{t.isTTY&&($i=!1,t.write("\x1B[?25h"))};xr.hide=(t=_c.default.stderr)=>{t.isTTY&&(Jg(),$i=!0,t.write("\x1B[?25l"))};xr.toggle=(t,e)=>{t!==void 0&&($i=t),$i?xr.show(e):xr.hide(e)};var kc=xr;var On=C(Ic(),1);var er={};CO(er,{error:()=>C1,info:()=>E1,success:()=>O1,warning:()=>T1});var zg=C(require("node:tty"),1),v1=zg.default?.WriteStream?.prototype?.hasColors?.()??!1,R=(t,e)=>{if(!v1)return i=>i;let r=`\x1B[${t}m`,n=`\x1B[${e}m`;return i=>{let s=i+"",o=s.indexOf(n);if(o===-1)return r+s+n;let a=r,l=0,c=(e===22?n:"")+r;for(;o!==-1;)a+=s.slice(l,o)+c,l=o+n.length,o=s.indexOf(n,l);return a+=s.slice(l)+n,a}},pL=R(0,0),Kg=R(1,22),mL=R(2,22),gL=R(3,23),yL=R(4,24),wL=R(53,55),bL=R(7,27),SL=R(8,28),xL=R(9,29),vL=R(30,39),Xg=R(31,39),Zg=R(32,39),Qg=R(33,39),ey=R(34,39),EL=R(35,39),OL=R(36,39),TL=R(37,39),Li=R(90,39),CL=R(40,49),AL=R(41,49),PL=R(42,49),_L=R(43,49),kL=R(44,49),IL=R(45,49),ML=R(46,49),DL=R(47,49),RL=R(100,49),ty=R(91,39),jL=R(92,39),ry=R(93,39),FL=R(94,39),NL=R(95,39),$L=R(96,39),LL=R(97,39),GL=R(101,49),qL=R(102,49),BL=R(103,49),UL=R(104,49),VL=R(105,49),WL=R(106,49),HL=R(107,49);var Mc=C(require("node:process"),1);function Qt(){let{env:t}=Mc.default,{TERM:e,TERM_PROGRAM:r}=t;return Mc.default.platform!=="win32"?e!=="linux":!!t.WT_SESSION||!!t.TERMINUS_SUBLIME||t.ConEmuTask==="{cmd::Cmder}"||r==="Terminus-Sublime"||r==="vscode"||e==="xterm-256color"||e==="alacritty"||e==="rxvt-unicode"||e==="rxvt-unicode-256color"||t.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Gi=Qt(),E1=ey(Gi?"\u2139":"i"),O1=Zg(Gi?"\u2714":"\u221A"),T1=Qg(Gi?"\u26A0":"\u203C"),C1=Xg(Gi?"\u2716":"\xD7");function Dc({onlyFirst:t=!1}={}){let i="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(i,t?void 0:"g")}var A1=Dc();function Rc(t){if(typeof t!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);return!t.includes("\x1B")&&!t.includes("\x9B")?t:t.replace(A1,"")}var qi=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Bi=[12288,12288,65281,65376,65504,65510],jc=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],Fc=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],En=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Ui=(t,e)=>{let r=0,n=Math.floor(t.length/2)-1;for(;r<=n;){let i=Math.floor((r+n)/2),s=i*2;if(e<t[s])n=i-1;else if(e>t[s+1])r=i+1;else return!0}return!1};var P1=qi[0],_1=qi.at(-1),k1=Bi[0],I1=Bi.at(-1),s8=jc[0],o8=jc.at(-1),a8=Fc[0],c8=Fc.at(-1),M1=En[0],D1=En.at(-1),ny=19968,[R1,j1]=F1(En);function F1(t){let e=t[0],r=t[1];for(let n=0;n<t.length;n+=2){let i=t[n],s=t[n+1];if(ny>=i&&ny<=s)return[i,s];s-i>r-e&&(e=i,r=s)}return[e,r]}var iy=t=>t<P1||t>_1?!1:Ui(qi,t),sy=t=>t<k1||t>I1?!1:Ui(Bi,t);var oy=t=>t>=R1&&t<=j1?!0:t<M1||t>D1?!1:Ui(En,t);function N1(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function Nc(t,{ambiguousAsWide:e=!1}={}){return N1(t),sy(t)||oy(t)||e&&iy(t)?2:1}var $1=new Intl.Segmenter,L1=new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Mark}|\\p{Surrogate})+$","v"),G1=new RegExp("^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+","v"),q1=new RegExp("^\\p{RGI_Emoji}$","v"),B1=/^[\d#*]\u20E3$/,U1=new RegExp("\\p{Extended_Pictographic}","gu");function V1(t){if(t.length>50)return!1;if(B1.test(t))return!0;if(t.includes("\u200D")){let e=t.match(U1);return e!==null&&e.length>=2}return!1}function W1(t){return t.replace(G1,"")}function H1(t){return L1.test(t)}function J1(t,e){let r=0;if(t.length>1)for(let n of t.slice(1))n>="\uFF00"&&n<="\uFFEF"&&(r+=Nc(n.codePointAt(0),e));return r}function $c(t,e={}){if(typeof t!="string"||t.length===0)return 0;let{ambiguousIsNarrow:r=!0,countAnsiEscapeCodes:n=!1}=e,i=t;if(!n&&(i.includes("\x1B")||i.includes("\x9B"))&&(i=Rc(i)),i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let s=0,o={ambiguousAsWide:!r};for(let{segment:a}of $1.segment(i)){if(H1(a))continue;if(q1.test(a)||V1(a)){s+=2;continue}let l=W1(a).codePointAt(0);s+=Nc(l,o),s+=J1(a,o)}return s}function Lc({stream:t=process.stdout}={}){return!!(t&&t.isTTY&&process.env.TERM!=="dumb"&&!("CI"in process.env))}var tr=C(require("node:process"),1),Y1=3,Gc=class{#i=0;#n;#t=!1;#e=!1;#s=e=>{if(!e?.length)return;(typeof e=="string"?e.codePointAt(0):e[0])===Y1&&(tr.default.listenerCount("SIGINT")>0?tr.default.emit("SIGINT"):tr.default.kill(tr.default.pid,"SIGINT"))};start(){this.#i++,this.#i===1&&this.#r()}stop(){this.#i!==0&&--this.#i===0&&this.#o()}#r(){let{stdin:e}=tr.default;if(tr.default.platform==="win32"||!e?.isTTY||typeof e.setRawMode!="function"){this.#n=void 0;return}this.#n=e,this.#t=e.isPaused(),this.#e=!!e.isRaw,e.setRawMode(!0),e.prependListener("data",this.#s),this.#t&&e.resume()}#o(){if(!this.#n)return;let e=this.#n;e.off("data",this.#s),e.isTTY&&e.setRawMode?.(this.#e),this.#t&&e.pause(),this.#n=void 0,this.#t=!1,this.#e=!1}},z1=new Gc,qc=Object.freeze(z1);var Q1=C(Ic(),1),K1=200,X1="\x1B[?2026h",Z1="\x1B[?2026l",Vi=new Map,Bc=class{#i=0;#n=-1;#t=0;#e;#s;#r;#o;#c=new Map;#d=!1;#l;#a;#f=!1;color;#u(e){this.#d=!0;try{return e()}finally{this.#d=!1}}#p(){this.isSpinning&&this.render()}#S(e,r){if(e==null)return"";if(typeof e=="string")return e;if(Buffer.isBuffer(e)||ArrayBuffer.isView(e)){let n=typeof r=="string"&&r&&r!=="buffer"?r:"utf8";return Buffer.from(e).toString(n)}return String(e)}#x(e){if(!e)return!1;let r=e.at(-1);return r===`
|
|
138
|
+
`||r==="\r"}#v(){this.#a||(this.#a=setTimeout(()=>{this.#a=void 0,this.isSpinning&&this.#p()},K1),typeof this.#a?.unref=="function"&&this.#a.unref())}#m(){this.#a&&(clearTimeout(this.#a),this.#a=void 0)}#g(e,r,n,i){let s=this.#w(n," "),a=typeof r=="string"?(e?" ":"")+r:"",l=this.#b(i," ");return s+e+a+l}constructor(e){typeof e=="string"&&(e={text:e}),this.#e={color:"cyan",stream:vr.default.stderr,discardStdin:!0,hideCursor:!0,...e},this.color=this.#e.color,this.#r=this.#e.stream,typeof this.#e.isEnabled!="boolean"&&(this.#e.isEnabled=Lc({stream:this.#r})),typeof this.#e.isSilent!="boolean"&&(this.#e.isSilent=!1);let r=this.#e.interval;this.spinner=this.#e.spinner,this.#e.interval=r,this.text=this.#e.text,this.prefixText=this.#e.prefixText,this.suffixText=this.#e.suffixText,this.indent=this.#e.indent,vr.default.env.NODE_ENV==="test"&&(this._stream=this.#r,this._isEnabled=this.#e.isEnabled,Object.defineProperty(this,"_linesToClear",{get(){return this.#i},set(n){this.#i=n}}),Object.defineProperty(this,"_frameIndex",{get(){return this.#n}}),Object.defineProperty(this,"_lineCount",{get(){let n=this.#r.columns??80,i=typeof this.#e.prefixText=="function"?"":this.#e.prefixText,s=typeof this.#e.suffixText=="function"?"":this.#e.suffixText,o=typeof i=="string"&&i!==""?i+" ":"",a=typeof s=="string"&&s!==""?" "+s:"",u=" ".repeat(this.#e.indent)+o+"-"+(typeof this.#e.text=="string"?" "+this.#e.text:"")+a;return this.#h(u,n)}}))}get indent(){return this.#e.indent}set indent(e=0){if(!(e>=0&&Number.isInteger(e)))throw new Error("The `indent` option must be an integer from 0 and up");this.#e.indent=e}get interval(){return this.#e.interval??this.#s.interval??100}get spinner(){return this.#s}set spinner(e){if(this.#n=-1,this.#e.interval=void 0,typeof e=="object"){if(!Array.isArray(e.frames)||e.frames.length===0||e.frames.some(r=>typeof r!="string"))throw new Error("The given spinner must have a non-empty `frames` array of strings");if(e.interval!==void 0&&!(Number.isInteger(e.interval)&&e.interval>0))throw new Error("`spinner.interval` must be a positive integer if provided");this.#s=e}else if(!Qt())this.#s=On.default.line;else if(e===void 0)this.#s=On.default.dots;else if(e!=="default"&&On.default[e])this.#s=On.default[e];else throw new Error(`There is no built-in spinner named '${e}'. See https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json for a full list.`)}get text(){return this.#e.text}set text(e=""){this.#e.text=e}get prefixText(){return this.#e.prefixText}set prefixText(e=""){this.#e.prefixText=e}get suffixText(){return this.#e.suffixText}set suffixText(e=""){this.#e.suffixText=e}get isSpinning(){return this.#o!==void 0}#y(e,r,n=!1){let i=typeof e=="function"?e():e;return typeof i=="string"&&i!==""?n?r+i:i+r:""}#w(e=this.#e.prefixText,r=" "){return this.#y(e,r,!1)}#b(e=this.#e.suffixText,r=" "){return this.#y(e,r,!0)}#h(e,r){let n=0;for(let i of(0,ay.stripVTControlCharacters)(e).split(`
|
|
139
|
+
`))n+=Math.max(1,Math.ceil($c(i)/r));return n}get isEnabled(){return this.#e.isEnabled&&!this.#e.isSilent}set isEnabled(e){if(typeof e!="boolean")throw new TypeError("The `isEnabled` option must be a boolean");this.#e.isEnabled=e}get isSilent(){return this.#e.isSilent}set isSilent(e){if(typeof e!="boolean")throw new TypeError("The `isSilent` option must be a boolean");this.#e.isSilent=e}frame(){let e=Date.now();(this.#n===-1||e-this.#t>=this.interval)&&(this.#n=(this.#n+1)%this.#s.frames.length,this.#t=e);let{frames:r}=this.#s,n=r[this.#n];this.color&&(n=P[this.color](n));let i=this.#w(this.#e.prefixText," "),s=typeof this.text=="string"?" "+this.text:"",o=this.#b(this.#e.suffixText," ");return i+n+s+o}clear(){return!this.isEnabled||!this.#r.isTTY?this:(this.#u(()=>{this.#r.cursorTo(0);for(let e=0;e<this.#i;e++)e>0&&this.#r.moveCursor(0,-1),this.#r.clearLine(1);this.#e.indent&&this.#r.cursorTo(this.#e.indent)}),this.#i=0,this)}#E(e){if(!e||this.#c.has(e)||!e.isTTY||typeof e.write!="function")return;Vi.has(e)&&console.warn("[ora] Multiple concurrent spinners detected. This may cause visual corruption. Use one spinner at a time.");let r=e.write;this.#c.set(e,r),Vi.set(e,this),e.write=(n,i,s)=>this.#C(e,r,n,i,s)}#O(){if(!this.isEnabled||this.#c.size>0)return;let e=new Set([this.#r,vr.default.stdout,vr.default.stderr]);for(let r of e)this.#E(r)}#T(){for(let[e,r]of this.#c)e.write=r,Vi.get(e)===this&&Vi.delete(e);this.#c.clear()}#C(e,r,n,i,s){if(typeof i=="function"&&(s=i,i=void 0),this.#d)return r.call(e,n,i,s);this.clear();let o=this.#S(n,i),a=this.#x(o),l=r.call(e,n,i,s);return a?this.#m():o.length>0&&this.#v(),this.isSpinning&&!this.#a&&this.render(),l}render(){if(!this.isEnabled||this.#l||this.#a)return this;let e=this.#r.isTTY,r=!1;try{e&&(this.#u(()=>this.#r.write(X1)),r=!0),this.clear();let n=this.frame(),i=this.#r.columns??80,s=this.#h(n,i),o=this.#r.rows;if(o&&o>1&&s>o){let l=n.split(`
|
|
140
|
+
`),u=o-1;n=[...l.slice(0,u),"... (content truncated to fit terminal)"].join(`
|
|
141
|
+
`)}this.#u(()=>this.#r.write(n))===!1&&this.#r.isTTY&&(this.#l=()=>{this.#l=void 0,this.#p()},this.#r.once("drain",this.#l)),this.#i=this.#h(n,i)}finally{r&&this.#u(()=>this.#r.write(Z1))}return this}start(e){if(e&&(this.text=e),this.isSilent)return this;if(!this.isEnabled){let r=this.text?"-":"",n=" ".repeat(this.#e.indent)+this.#g(r,this.text,this.#e.prefixText,this.#e.suffixText);return n.trim()!==""&&this.#u(()=>this.#r.write(n+`
|
|
142
|
+
`)),this}return this.isSpinning?this:(this.#e.hideCursor&&kc.hide(this.#r),this.#e.discardStdin&&vr.default.stdin.isTTY&&(qc.start(),this.#f=!0),this.#O(),this.render(),this.#o=setInterval(this.render.bind(this),this.interval),this)}stop(){return clearInterval(this.#o),this.#o=void 0,this.#n=-1,this.#t=0,this.#m(),this.#T(),this.#l&&(this.#r.removeListener("drain",this.#l),this.#l=void 0),this.isEnabled&&(this.clear(),this.#e.hideCursor&&kc.show(this.#r)),this.#f&&(this.#f=!1,qc.stop()),this}succeed(e){return this.stopAndPersist({symbol:er.success,text:e})}fail(e){return this.stopAndPersist({symbol:er.error,text:e})}warn(e){return this.stopAndPersist({symbol:er.warning,text:e})}info(e){return this.stopAndPersist({symbol:er.info,text:e})}stopAndPersist(e={}){if(this.isSilent)return this;let r=e.symbol??" ",n=e.text??this.text,i=e.prefixText??this.#e.prefixText,s=e.suffixText??this.#e.suffixText,o=this.#g(r,n,i,s)+`
|
|
143
|
+
`;return this.stop(),this.#u(()=>this.#r.write(o)),this}};function Uc(t){return new Bc(t)}var Vc=class{constructor(){this.spinner=null;this.debugMode=!1;this.silentMode=!1}setDebugMode(e){this.debugMode=e}setSilentMode(e){this.silentMode=e}info(e){this.silentMode||process.stdout.write(P.blue("\u2139")+" "+e+`
|
|
144
|
+
`)}success(e){this.silentMode||process.stdout.write(P.green("\u2714")+" "+e+`
|
|
145
|
+
`)}error(e,r){if(process.stderr.write(P.red("\u2716")+" "+e+`
|
|
146
|
+
`),r){let n=r.stack||r.message;process.stderr.write(P.gray("[STACK]")+" "+n+`
|
|
147
|
+
`)}}warn(e){this.silentMode||process.stdout.write(P.yellow("\u26A0")+" "+e+`
|
|
148
|
+
`)}debug(e){this.debugMode&&process.stdout.write(P.gray("[DEBUG] ")+P.dim(e)+`
|
|
149
|
+
`)}log(e){this.silentMode||process.stdout.write(e+`
|
|
150
|
+
`)}newLine(){this.silentMode||process.stdout.write(`
|
|
151
|
+
`)}startSpinner(e){return this.silentMode?{succeed:()=>{},fail:()=>{},text:e}:(this.spinner=Uc(e).start(),this.spinner)}stopSpinner(e=!0,r){this.spinner&&!this.silentMode&&(e?this.spinner.succeed(r):this.spinner.fail(r),this.spinner=null)}updateSpinner(e){this.spinner&&!this.silentMode&&(this.spinner.text=e)}header(e){this.silentMode||process.stdout.write(P.bold.cyan(e)+`
|
|
152
|
+
`)}footer(){this.silentMode||process.stdout.write(`
|
|
153
|
+
`)}box(e,r="cyan"){if(this.silentMode)return;let n=e.split(`
|
|
154
|
+
`),i=Math.max(...n.map(a=>a.length)),s="\u2500".repeat(i+2),o=P[r];process.stdout.write(o("\u250C"+s+"\u2510")+`
|
|
155
|
+
`),n.forEach(a=>{let l=" ".repeat(i-a.length);process.stdout.write(o("\u2502 ")+a+l+o(" \u2502")+`
|
|
156
|
+
`)}),process.stdout.write(o("\u2514"+s+"\u2518")+`
|
|
157
|
+
`)}logWithPrefix(e,r,n="blue"){if(this.silentMode)return;let i=P[n];process.stdout.write(i(e)+" "+r+`
|
|
158
|
+
`)}},m=new Vc;async function Hi(t,e,r={}){e_(e);let n=Wi.default.join(t,ye.ENV_EXAMPLE),i=Wi.default.join(t,ye.ENV);await cy(n,e,r),(await Ge.default.pathExists(i)||r.force)&&await cy(i,e,r),m.success("Environment variables added")}function e_(t){for(let e of t)if(!Sc.KEY.test(e.key))throw new Error(`Invalid environment variable key: ${e.key}. Must match pattern: ${Sc.KEY}`)}async function cy(t,e,r={}){let n="";if(await Ge.default.pathExists(t)&&(n=await Ge.default.readFile(t,"utf-8")),r.force){let o=e.map(a=>a.key);await t_(t,o),n=await Ge.default.pathExists(t)?await Ge.default.readFile(t,"utf-8"):""}let i=r_(n),s=e.filter(o=>!i.has(o.key));if(s.length!==0){n&&!n.endsWith(`
|
|
159
|
+
`)&&(n+=`
|
|
160
|
+
`);for(let o of s)n+=`${o.key}=${o.value||""}
|
|
161
|
+
`;await Ge.default.ensureDir(Wi.default.dirname(t)),await Ge.default.writeFile(t,n,"utf-8")}}async function t_(t,e){if(await Ge.default.pathExists(t))try{let n=(await Ge.default.readFile(t,"utf-8")).split(`
|
|
162
|
+
`),i=[];for(let s of n){let o=s.match(/^([A-Z_][A-Z0-9_]*)=/);(!o||!e.includes(o[1]))&&i.push(s)}for(;i.length>0&&i[i.length-1].trim()==="";)i.pop();await Ge.default.writeFile(t,i.join(`
|
|
163
|
+
`)+(i.length>0?`
|
|
164
|
+
`:""),"utf-8")}catch(r){throw m.error(`Failed to remove env variables from ${t}`),r}}function r_(t){let e=new Set,r=t.split(`
|
|
165
|
+
`);for(let n of r){let i=n.match(/^([A-Z_][A-Z0-9_]*)=/);i&&e.add(i[1])}return e}var St=C(fe()),Er=C(require("path")),Wc=new Map;async function ly(t){if(!await St.pathExists(t))return[];let e=[],r=await St.readdir(t);for(let n of r){let i=Er.join(t,n,"module.json");if(await St.pathExists(i))try{let s=await St.readJson(i);s.name&&e.push(s.name)}catch{continue}}return e}var Ji={async loadFrameworkConfig(t,e){let r=Er.join(e,t,"template.json");if(await St.pathExists(r)){let i=await St.readJson(r);return Wc.set(t,i),i}let n={name:t,displayName:t.charAt(0).toUpperCase()+t.slice(1),compatibility:{databases:[],auth:[]}};try{let i=Er.join(e,"..","modules");n.compatibility.databases=await ly(Er.join(i,"database")),n.compatibility.auth=await ly(Er.join(i,"auth"))}catch{n.compatibility.databases=[],n.compatibility.auth=[]}return Wc.set(t,n),n},isCompatible(t,e,r){let n=Wc.get(t);return n?!(e&&!n.compatibility.databases.includes(e)||r&&!n.compatibility.auth.includes(r)):!0}};var Tn=C(fe()),uy=C(require("path"));async function dy(t,e,r={}){if(await Tn.default.pathExists(t)&&!r.force){m.warn(`File already exists: ${t} (use --force to overwrite)`);return}await Tn.default.ensureDir(uy.default.dirname(t)),await Tn.default.writeFile(t,e,"utf-8")}async function fy(t){return Tn.default.pathExists(t)}var O=C(fe()),_=C(require("path"));var Yi=C(fe()),Nt=C(require("path"));async function Hc(t,e){let r=Nt.join(e,"module.json");if(await Yi.pathExists(r))try{let n=await Yi.readJson(r);n.postInstall&&Array.isArray(n.postInstall)&&(t.postInstall=n.postInstall),n.dependencies&&typeof n.dependencies=="object"&&(t.dependencies={...t.dependencies||{},...n.dependencies}),n.devDependencies&&typeof n.devDependencies=="object"&&(t.devDependencies={...t.devDependencies||{},...n.devDependencies}),n.scripts&&typeof n.scripts=="object"&&(t.scripts={...t.scripts||{},...n.scripts}),n.envVars&&typeof n.envVars=="object"&&(t.envVars={...t.envVars||{},...n.envVars})}catch{return t}return t}function hy(t,e,r){let n=M(),i=Nt.join(n,"modules"),s=Nt.join(n,"templates"),o=t==="framework"?Nt.join(s,e):t===e?Nt.join(i,t):Nt.join(i,t,e);return Nt.join(o,"files",r)}var Or=class{constructor(e){this.generators=new Map;this.postInstallCommands=[];this.createdFiles=[];this.frameworkConfig=e}initializeContext(e,r){let n={...e,features:r,combo:`${e.database||""}:${e.framework||""}`};if(e.database==="prisma"&&!n.prismaProvider){let i=De(M());i.length>0&&(n.prismaProvider=i[0])}return n}isGeneratorSelected(e,r,n){return e==="framework"&&r===n.framework||e==="database"&&r===n.database||e==="auth"&&r===n.auth||e==="ui"&&r===n.ui||e==="storage"&&r===n.storageProvider||e==="components"&&n.components===!0}async loadGenerators(e){let r=["auth","database","ui","storage","components"];for(let n of r){let i=_.join(e,n);if(await O.pathExists(i)){let s=_.join(i,"generator.json");if(await O.pathExists(s)){try{let a=await O.readJson(s);await Hc(a,i),this.generators.set(`${n}:${n}`,a)}catch{}continue}let o=await O.readdir(i);for(let a of o){let l=_.join(i,a,"generator.json");if(await O.pathExists(l))try{let u=await O.readJson(l),c=_.join(i,a);await Hc(u,c),this.generators.set(`${n}:${a}`,u)}catch{continue}}}}}evaluateCondition(e,r){if(!e)return!0;for(let[n,i]of Object.entries(e))if(n==="features"){let s=i,o=r.features||[];if(!s.every(a=>o.includes(a)))return!1}else if(Array.isArray(i)){if(!i.includes(r[n]))return!1}else if(r[n]!==i)return!1;return!0}processTemplate(e,r){let n={...r};return e=this.processVariableDefinitions(e,n),e=this.processTemplateRecursive(e,n),e=e.replace(/^\n+/,""),e=e.replace(/\n{3,}/g,`
|
|
166
|
+
|
|
167
|
+
`),e}renderHeadingFromExpr(e,r){let n=e.substring(8).trim(),i=r[n],s=parseInt(String(i||"1"),10)||1,o=Math.max(1,Math.min(s,6));return"#".repeat(o)}processVariableDefinitions(e,r){let n=e,i=0;for(;;){let s=n.indexOf("{{#var ",i);if(s===-1)break;let o=n.indexOf("=",s);if(o===-1)break;let a=n.substring(s+7,o).trim();if(!a)break;let l=1,u=o+1,c=u;for(let p=u;p<n.length;p++)if(n[p]==="{"&&n[p+1]==="{")l++,p++;else if(n[p]==="}"&&n[p+1]==="}"){if(l--,l===0){c=p;break}p++}if(c===u)break;let d=n.substring(u,c).trim(),f=n.substring(s,c+2),h=this.processTemplateRecursive(d,r);r[a]=h,n=n.replace(f,""),i=s}return n}processTemplateRecursive(e,r){return e=e.replace(/\{\{#if\s+([^}\s]+)\s+([^}\s]+)\s+([^}]+)\}\}([\s\S]*?)(?:\{\{else\}\}([\s\S]*?))?\{\{\/if\}\}/g,(n,i,s,o,a,l)=>{let u=r[i.trim()],c=o.trim().replace(/['"]/g,""),d=!1;switch(s){case"==":case"===":d=u===c;break;case"!=":case"!==":d=u!==c;break;case"includes":d=Array.isArray(u)&&u.includes(c);break;case"startsWith":d=typeof u=="string"&&u.startsWith(c);break;case"endsWith":d=typeof u=="string"&&u.endsWith(c);break}let f=d?a:l||"";return this.processTemplateRecursive(f,r).replace(/^\n+/,"").replace(/\n+$/,"")}),e=e.replace(/\{\{#if\s+([^}]+)\}\}([\s\S]*?)(?:\{\{else\}\}([\s\S]*?))?\{\{\/if\}\}/g,(n,i,s,o)=>{let a=i.split("==");if(a.length===2){let[c,d]=a.map(h=>h.trim().replace(/['"]/g,"")),f=r[c]===d?s:o||"";return this.processTemplateRecursive(f,r).replace(/^\n+/,"").replace(/\n+$/,"")}let l=i.split(".");if(l.length===2&&l[1]==="includes"){let[c,d]=l[0].split("("),f=d.replace(")","").replace(/['"]/g,""),h=r[c]||[],p=Array.isArray(h)&&h.includes(f)?s:o||"";return this.processTemplateRecursive(p,r).replace(/^\n+/,"").replace(/\n+$/,"")}let u=i.trim();if(u){if(u.startsWith("!")){let p=u.slice(1).trim().replace(/['"]/g,""),y=r[p],b=!!y&&!(Array.isArray(y)&&y.length===0)?o||"":s;return this.processTemplateRecursive(b,r).replace(/^\n+/,"").replace(/\n+$/,"")}let c=u.replace(/['"]/g,""),d=r[c],h=!!d&&!(Array.isArray(d)&&d.length===0)?s:o||"";return this.processTemplateRecursive(h,r).replace(/^\n+/,"").replace(/\n+$/,"")}return""}),e=e.replace(/\{\{#switch\s+([^}]+)\}\}([\s\S]*?)\{\{\/switch\}\}/g,(n,i,s)=>{let o=r[i.trim()],a=/\{\{#case\s+([^}]+)\}\}([\s\S]*?)(?=\{\{#case|\{\{\/case\}|\{\{\/switch\})/g,l="",u="",c;for(;(c=a.exec(s))!==null;){let[,f,h]=c,p=f.trim().replace(/['"]/g,"");if(p==="default")u=h.trim();else if(o===p){l=h.trim();break}}let d=(l||u||"").trim();return this.processTemplateRecursive(d,r)}),e=e.replace(/\{\{([^}]+)\}\}/g,(n,i)=>{let s=i.trim(),o=s.match(/^(.+?)\s*\?\s*(.+?)\s*:\s*(.+?)$/);if(o){let[,c,d,f]=o,h=c.match(/^(.+?)==(.+)$/);if(h){let[,p,y]=h,x=p.trim(),b=y.trim().replace(/['"]/g,"");return(r[x]===b?d.trim():f.trim()).replace(/['"]/g,"")}}let a=s.match(/^switch\s+([^}\s]+)\s+(.+)$/);if(a){let[,c,d]=a,f=r[c.trim()],h=d.split(",").map(p=>p.trim());for(let p of h){let[y,x]=p.split(":").map(S=>S.trim()),b=y.replace(/['"]/g,"");if(b===f||b==="default")return this.processTemplateRecursive(x.replace(/['"]/g,""),r)}return""}if(s.startsWith("heading:"))return this.renderHeadingFromExpr(s,r);if(s.startsWith("feature:")){let c=s.substring(8).trim();return(Array.isArray(r.features)?r.features:[]).includes(c)?"true":"false"}let l=s.match(/^if\s+(.+?)\s+then:([^,]+),\s*else:(.+)$/);if(l){let[,c,d,f]=l,h=c.match(/^(.+?)==(.+)$/);if(h){let[,p,y]=h,x=p.trim(),b=y.trim().replace(/['"]/g,"");return(r[x]===b?d.trim():f.trim()).replace(/['"]/g,"")}}let u=r[s];return u!==void 0?String(u):n}),e}async generate(e,r,n){await this.copyTemplate(e.framework,n);let i=this.initializeContext(e,r),s=[];for(let[o,a]of this.generators){let[l,u]=o.split(":");if(!this.isGeneratorSelected(l,u,e))continue;a.postInstall&&Array.isArray(a.postInstall)&&this.postInstallCommands.push(...a.postInstall);let c=a.operations||[];for(let d of c)this.evaluateCondition(d.condition,i)&&s.push({...d,generator:u,generatorType:l,priority:a.priority})}s.sort((o,a)=>{let l=o.priority||0,u=a.priority||0;return l-u});for(let o of s)await this.executeOperation(o,i,n);return await this.generatePackageJson(e,n),this.postInstallCommands}getCreatedFiles(){return this.createdFiles.slice()}async executeOperation(e,r,n){let i=this.processOperationTemplates(e,r);switch(i.type){case"create-file":await this.executeCreateFile(i,r,n);break;case"patch-file":await this.executePatchFile(i,r,n);break;case"add-dependency":await this.executeAddDependency(i,n);break;case"add-script":await this.executeAddScript(i,n);break;case"add-env":await this.executeAddEnv(i,r,n);break;case"run-command":this.executeRunCommand(i,r);break;default:return}}async copyTemplate(e,r){let n=M(),i=_.join(n,"templates",e);if(await O.pathExists(i)){await O.copy(i,r,{filter:s=>{let o=_.relative(i,s);return o!=="template.json"&&o!=="node_modules"&&!o.startsWith("node_modules/")}});try{let s=[".gitignore","gitignore","_gitignore"];for(let o of s){let a=_.join(i,o);if(await O.pathExists(a)){let l=_.join(r,".gitignore");await O.pathExists(l)||await O.copy(a,l);break}}}catch(s){}try{let s=_.join(i,"template.json");if(await O.pathExists(s)){let o=await O.readJson(s);if(o&&Array.isArray(o.files)){for(let a of o.files)if(typeof a=="string"&&a.startsWith(".")){let l=_.join(r,a);if(await O.pathExists(l))continue;if(a===".gitignore"){let c=a.slice(1),d=[a,c,`_${c}`];for(let f of d){let h=_.join(i,f);if(await O.pathExists(h)){await O.copy(h,l);break}}continue}let u=_.join(i,a);await O.pathExists(u)&&await O.copy(u,l)}}}}catch(s){}try{let s=_.join(i,"template.json");if(await O.pathExists(s)){let o=await O.readJson(s);if(o&&Array.isArray(o.files)){for(let a of o.files)if(typeof a=="string"&&a.startsWith(".")){let l=_.join(r,a),u=a.slice(1),c=_.join(r,u),d=_.join(r,`_${u}`);if(await O.pathExists(l)){await O.pathExists(c)&&await O.remove(c),await O.pathExists(d)&&await O.remove(d);continue}await O.pathExists(c)?await O.move(c,l,{overwrite:!0}):await O.pathExists(d)&&await O.move(d,l,{overwrite:!0})}}}}catch(s){}try{let s=_.join(r,".env.example"),o=_.join(r,".env");await O.pathExists(s)&&!await O.pathExists(o)&&await O.copy(s,o)}catch(s){}}}processOperationTemplates(e,r){let n={...e};return n.source&&(n.source=this.processTemplate(n.source,r)),n.destination&&(n.destination=this.processTemplate(n.destination,r)),n.content&&(n.content=this.processTemplate(n.content,r)),n.operations&&(n.operations=n.operations.map(i=>{let s={...i};return s.imports&&(s.imports=s.imports.map(o=>this.processTemplate(o,r))),s.code&&(Array.isArray(s.code)?s.code=s.code.map(o=>this.processTemplate(o,r)).join(`
|
|
168
|
+
`):s.code=this.processTemplate(s.code,r)),s.after&&(s.after=this.processTemplate(s.after,r)),s.before&&(s.before=this.processTemplate(s.before,r)),s.replace&&(s.replace=this.processTemplate(s.replace,r)),s.content&&(s.content=this.processTemplate(s.content,r)),s.source&&(s.source=this.processTemplate(s.source,r)),s})),n}async executeCreateFile(e,r,n){if(!e.destination)return;let i=this.processTemplate(e.destination,r),{basePath:s,mode:o}=this.parsePathPattern(i);if(e.content){let y=_.join(n,i);await O.ensureDir(_.dirname(y));let x=this.processTemplate(e.content,r);await O.writeFile(y,x,"utf-8");try{let b=_.relative(n,y);b&&!this.createdFiles.includes(b)&&this.createdFiles.push(b)}catch(b){}return}if(!e.source)throw new Error("Create file operation must have either 'content' or 'source' field");let a=this.processTemplate(e.source,r),{basePath:l,mode:u}=this.parsePathPattern(a),c=hy(e.generatorType,e.generator,l);if(!c||!await O.pathExists(c))throw new Error(`Source file not found: ${c}`);let d=await O.stat(c);if(d.isDirectory()||u!=="single"){if(!d.isDirectory())throw new Error(`Source path must be a directory for wildcard copy: ${a}`);let y=[];if(u==="flat"){let x=await O.readdir(c);for(let b of x){let S=_.join(c,b);(await O.stat(S)).isFile()&&y.push(S)}}else y=await this.collectFilesRecursively(c);for(let x of y){let b;o==="recursive"?b=_.relative(c,x):o==="flat"?b=_.basename(x):b=u==="flat"?_.basename(x):_.relative(c,x);let S=_.join(n,s,b);await O.ensureDir(_.dirname(S));let g=await O.readFile(x,"utf-8");g=this.processTemplate(g,r),await O.writeFile(S,g,"utf-8");try{let v=_.relative(n,S);v&&!this.createdFiles.includes(v)&&this.createdFiles.push(v)}catch(v){}}return}let h=o==="single"?_.join(n,i):_.join(n,s,_.basename(c));await O.ensureDir(_.dirname(h));let p=await O.readFile(c,"utf-8");p=this.processTemplate(p,r),await O.writeFile(h,p,"utf-8");try{let y=_.relative(n,h);y&&!this.createdFiles.includes(y)&&this.createdFiles.push(y)}catch(y){}}parsePathPattern(e){let r=e.replace(/\\/g,"/");return r.endsWith("/**")?{basePath:r.slice(0,-3),mode:"recursive"}:r.endsWith("/*")?{basePath:r.slice(0,-2),mode:"flat"}:{basePath:r,mode:"single"}}async collectFilesRecursively(e){let r=[],n=await O.readdir(e);for(let i of n){let s=_.join(e,i),o=await O.stat(s);o.isDirectory()?r.push(...await this.collectFilesRecursively(s)):o.isFile()&&r.push(s)}return r}async executePatchFile(e,r,n){if(!e.destination)return;let i=_.join(n,this.processTemplate(e.destination,r)),s=await O.readFile(i,"utf-8");if(e.content)s+=this.processTemplate(e.content,r).trim();else if(e.operations){for(let o of e.operations)if(this.evaluateCondition(o.condition,r))switch(o.type){case"add-import":if(o.imports){let a=o.imports.map(h=>this.processTemplate(h,r)).join(`
|
|
169
|
+
`).replace(/^\n+/,"").replace(/\n+$/,""),l=s.split(`
|
|
170
|
+
`),u=-1;for(let h=0;h<l.length;h++)l[h].trim().startsWith("import")&&(u=h);let c=u===-1?0:u+1,f=a.split(`
|
|
171
|
+
`).map(h=>h.trim()).filter(Boolean).filter(h=>!l.some(p=>p.trim()===h));if(f.length>0){c<l.length&&l[c].trim()===""?l.splice(c,1,...f):l.splice(c,0,...f);let h=-1;for(let y=0;y<l.length;y++)l[y].trim().startsWith("import")&&(h=y);let p=h+1;if(h!==-1){let y=p;for(;y<l.length&&l[y].trim()==="";)y++;p<l.length&&l.splice(p,y-p,"")}}s=l.join(`
|
|
172
|
+
`)}break;case"add-code":if(o.code){let a=o.code;Array.isArray(a)&&(a=a.join(`
|
|
173
|
+
`));let l=this.processTemplate(a,r),u=l.trim();if(u&&s.includes(u))break;if(o.after){let c=this.processTemplate(o.after,r),d=s.indexOf(c);if(d!==-1){let f=s.slice(0,d+c.length),h=s.slice(d+c.length),p=l.replace(/^\n+|\n+$/g,"")+`
|
|
174
|
+
`;h.startsWith(`
|
|
175
|
+
`)&&p.endsWith(`
|
|
176
|
+
`)&&(p=p.replace(/\n+$/,""));let x=!f.endsWith(`
|
|
177
|
+
`);s=f+(x?`
|
|
178
|
+
`:"")+p+h}}if(o.before){let c=this.processTemplate(o.before,r),d=s.indexOf(c);if(d!==-1){let f=s.slice(0,d),h=s.slice(d),p=l.replace(/^\n+|\n+$/g,"")+`
|
|
179
|
+
`;h.startsWith(`
|
|
180
|
+
`)&&p.endsWith(`
|
|
181
|
+
`)&&(p=p.replace(/\n+$/,""));let x=!f.endsWith(`
|
|
182
|
+
`);s=f+(x?`
|
|
183
|
+
`:"")+p+h}}}break;case"replace-code":if(o.code&&o.replace){let a=o.code;Array.isArray(a)&&(a=a.join(`
|
|
184
|
+
`));let l=this.processTemplate(a,r),u=this.processTemplate(o.replace,r);s=s.replace(u,l)}break;case"add-to-top":{let a="";if(o.content)a=this.processTemplate(o.content,r).trim();else if(o.source){let l=_.join(M(),"modules"),u=_.join(l,e.generatorType,e.generator,"files",o.source);await O.pathExists(u)&&(a=await O.readFile(u,"utf-8"),a=this.processTemplate(a,r).trim())}a&&(s=a+`
|
|
185
|
+
`+s);break}case"add-to-bottom":{let a="";if(o.content)a=this.processTemplate(o.content,r).trim();else if(o.source){let l=_.join(M(),"modules"),u=_.join(l,e.generatorType,e.generator,"files",o.source);await O.pathExists(u)&&(a=await O.readFile(u,"utf-8"),a=this.processTemplate(a,r).trim())}a&&(s=s+`
|
|
186
|
+
`+a);break}}}s=s.replace(/\n{3,}/g,`
|
|
187
|
+
|
|
188
|
+
`),await O.writeFile(i,s,"utf-8")}async executeAddDependency(e,r){let n=_.join(r,"package.json"),i={};await O.pathExists(n)&&(i=await O.readJson(n)),e.dependencies&&(i.dependencies={...i.dependencies||{},...e.dependencies}),e.devDependencies&&(i.devDependencies={...i.devDependencies||{},...e.devDependencies}),await O.writeJson(n,i,{spaces:2})}async executeAddScript(e,r){let n=_.join(r,"package.json"),i={};await O.pathExists(n)&&(i=await O.readJson(n)),e.scripts&&(i.scripts={...i.scripts||{},...e.scripts}),await O.writeJson(n,i,{spaces:2})}async executeAddEnv(e,r,n){let i=_.join(n,".env"),s="";if(await O.pathExists(i)&&(s=await O.readFile(i,"utf-8")),e.envVars){let o=Object.entries(e.envVars).map(([a,l])=>{let u=this.processTemplate(l,r);return`${a}=${u}`});s+=`
|
|
189
|
+
`+o.join(`
|
|
190
|
+
`)}await O.writeFile(i,s.trim(),"utf-8")}executeRunCommand(e,r){if(e.command){let n=this.processTemplate(e.command,r);this.postInstallCommands.push(n)}}async generatePackageJson(e,r){let n=_.join(r,"package.json"),i={};await O.pathExists(n)&&(i=await O.readJson(n));let s={},o={},a={};for(let[l,u]of this.generators){let[c,d]=l.split(":");this.isGeneratorSelected(c,d,e)&&(Object.assign(s,u.dependencies),Object.assign(o,u.devDependencies),Object.assign(a,u.scripts))}i.dependencies={...i.dependencies||{},...s},i.devDependencies={...i.devDependencies||{},...o},i.scripts={...i.scripts||{},...a},await O.writeJson(n,i,{spaces:2})}async applyToProject(e,r,n){let i=this.initializeContext(e,r),s=[];for(let[o,a]of this.generators){let[l,u]=o.split(":");if(!this.isGeneratorSelected(l,u,e))continue;a.postInstall&&Array.isArray(a.postInstall)&&this.postInstallCommands.push(...a.postInstall);let c=a.operations||[];for(let d of c)this.evaluateCondition(d.condition,i)&&s.push({...d,generator:u,generatorType:l,priority:a.priority})}s.sort((o,a)=>(o.priority||0)-(a.priority||0));for(let o of s)await this.executeOperation(o,i,n);return await this.generatePackageJson(e,n),this.postInstallCommands}getAvailableGenerators(){let e=[],r=[],n=[],i=[];for(let[s]of this.generators){let[o,a]=s.split(":");switch(o){case"framework":e.push(a);break;case"database":r.push(a);break;case"auth":n.push(a);break;case"components":i.push(a);break}}return{frameworks:e,databases:r,auths:n,components:i}}registerGenerator(e,r,n){this.generators.set(`${e}:${r}`,n)}};var Kk=C(zw(),1);function oe(t){if(typeof t!="object"||t===null)return!1;let e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}var Kw=require("node:url"),Dr=(t,e)=>{let r=pl(Xk(t));if(typeof r!="string")throw new TypeError(`${e} must be a string or a file URL: ${r}.`);return r},Xk=t=>hl(t)?t.toString():t,hl=t=>typeof t!="string"&&t&&Object.getPrototypeOf(t)===String.prototype,pl=t=>t instanceof URL?(0,Kw.fileURLToPath)(t):t;var cs=(t,e=[],r={})=>{let n=Dr(t,"First argument"),[i,s]=oe(e)?[[],e]:[e,r];if(!Array.isArray(i))throw new TypeError(`Second argument must be either an array of arguments or an options object: ${i}`);if(i.some(l=>typeof l=="object"&&l!==null))throw new TypeError(`Second argument must be an array of strings: ${i}`);let o=i.map(String),a=o.find(l=>l.includes("\0"));if(a!==void 0)throw new TypeError(`Arguments cannot contain null bytes ("\\0"): ${a}`);if(!oe(s))throw new TypeError(`Last argument must be an options object: ${s}`);return[n,o,s]};var sb=require("node:child_process");var Xw=require("node:string_decoder"),{toString:Zw}=Object.prototype,Qw=t=>Zw.call(t)==="[object ArrayBuffer]",ce=t=>Zw.call(t)==="[object Uint8Array]",xt=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),Zk=new TextEncoder,eb=t=>Zk.encode(t),Qk=new TextDecoder,ls=t=>Qk.decode(t),tb=(t,e)=>eI(t,e).join(""),eI=(t,e)=>{if(e==="utf8"&&t.every(s=>typeof s=="string"))return t;let r=new Xw.StringDecoder(e),n=t.map(s=>typeof s=="string"?eb(s):s).map(s=>r.write(s)),i=r.end();return i===""?n:[...n,i]},In=t=>t.length===1&&ce(t[0])?t[0]:ml(tI(t)),tI=t=>t.map(e=>typeof e=="string"?eb(e):e),ml=t=>{let e=new Uint8Array(rI(t)),r=0;for(let n of t)e.set(n,r),r+=n.length;return e},rI=t=>{let e=0;for(let r of t)e+=r.length;return e};var ob=t=>Array.isArray(t)&&Array.isArray(t.raw),ab=(t,e)=>{let r=[];for(let[s,o]of t.entries())r=nI({templates:t,expressions:e,tokens:r,index:s,template:o});if(r.length===0)throw new TypeError("Template script must not be empty");let[n,...i]=r;return[n,i,{}]},nI=({templates:t,expressions:e,tokens:r,index:n,template:i})=>{if(i===void 0)throw new TypeError(`Invalid backslash sequence: ${t.raw[n]}`);let{nextTokens:s,leadingWhitespaces:o,trailingWhitespaces:a}=iI(i,t.raw[n]),l=nb(r,s,o);if(n===e.length)return l;let u=e[n],c=Array.isArray(u)?u.map(d=>ib(d)):[ib(u)];return nb(l,c,a)},iI=(t,e)=>{if(e.length===0)return{nextTokens:[],leadingWhitespaces:!1,trailingWhitespaces:!1};let r=[],n=0,i=rb.has(e[0]);for(let o=0,a=0;o<t.length;o+=1,a+=1){let l=e[a];if(rb.has(l))n!==o&&r.push(t.slice(n,o)),n=o+1;else if(l==="\\"){let u=e[a+1];u===`
|
|
191
|
+
`?(o-=1,a+=1):u==="u"&&e[a+2]==="{"?a=e.indexOf("}",a+3):a+=sI[u]??1}}let s=n===t.length;return s||r.push(t.slice(n)),{nextTokens:r,leadingWhitespaces:i,trailingWhitespaces:s}},rb=new Set([" "," ","\r",`
|
|
192
|
+
`]),sI={x:3,u:5},nb=(t,e,r)=>r||t.length===0||e.length===0?[...t,...e]:[...t.slice(0,-1),`${t.at(-1)}${e[0]}`,...e.slice(1)],ib=t=>{let e=typeof t;if(e==="string")return t;if(e==="number")return String(t);if(oe(t)&&("stdout"in t||"isMaxBuffer"in t))return oI(t);throw t instanceof sb.ChildProcess||Object.prototype.toString.call(t)==="[object Promise]"?new TypeError("Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}."):new TypeError(`Unexpected "${e}" in template expression`)},oI=({stdout:t})=>{if(typeof t=="string")return t;if(ce(t))return ls(t);throw t===void 0?new TypeError(`Missing result.stdout in template expression. This is probably due to the previous subprocess' "stdout" option.`):new TypeError(`Unexpected "${typeof t}" stdout in template expression`)};var Tv=require("node:child_process");var lb=require("node:util");var us=C(require("node:process"),1),qe=t=>ds.includes(t),ds=[us.default.stdin,us.default.stdout,us.default.stderr],Re=["stdin","stdout","stderr"],fs=t=>Re[t]??`stdio[${t}]`;var ub=t=>{let e={...t};for(let r of wl)e[r]=gl(t,r);return e},gl=(t,e)=>{let r=Array.from({length:aI(t)+1}),n=cI(t[e],r,e);return hI(n,e)},aI=({stdio:t})=>Array.isArray(t)?Math.max(t.length,Re.length):Re.length,cI=(t,e,r)=>oe(t)?lI(t,e,r):e.fill(t),lI=(t,e,r)=>{for(let n of Object.keys(t).sort(uI))for(let i of dI(n,r,e))e[i]=t[n];return e},uI=(t,e)=>cb(t)<cb(e)?1:-1,cb=t=>t==="stdout"||t==="stderr"?0:t==="all"?2:1,dI=(t,e,r)=>{if(t==="ipc")return[r.length-1];let n=yl(t);if(n===void 0||n===0)throw new TypeError(`"${e}.${t}" is invalid.
|
|
193
|
+
It must be "${e}.stdout", "${e}.stderr", "${e}.all", "${e}.ipc", or "${e}.fd3", "${e}.fd4" (and so on).`);if(n>=r.length)throw new TypeError(`"${e}.${t}" is invalid: that file descriptor does not exist.
|
|
194
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);return n==="all"?[1,2]:[n]},yl=t=>{if(t==="all")return t;if(Re.includes(t))return Re.indexOf(t);let e=fI.exec(t);if(e!==null)return Number(e[1])},fI=/^fd(\d+)$/,hI=(t,e)=>t.map(r=>r===void 0?mI[e]:r),pI=(0,lb.debuglog)("execa").enabled?"full":"none",mI={lines:!1,buffer:!0,maxBuffer:1e3*1e3*100,verbose:pI,stripFinalNewline:!0},wl=["lines","buffer","maxBuffer","verbose","stripFinalNewline"],vt=(t,e)=>e==="ipc"?t.at(-1):t[e];var Rr=({verbose:t},e)=>bl(t,e)!=="none",jr=({verbose:t},e)=>!["none","short"].includes(bl(t,e)),db=({verbose:t},e)=>{let r=bl(t,e);return hs(r)?r:void 0},bl=(t,e)=>e===void 0?gI(t):vt(t,e),gI=t=>t.find(e=>hs(e))??ps.findLast(e=>t.includes(e)),hs=t=>typeof t=="function",ps=["none","short","full"];var vb=require("node:util");var fb=require("node:process"),hb=require("node:util"),pb=(t,e)=>{let r=[t,...e],n=r.join(" "),i=r.map(s=>vI(mb(s))).join(" ");return{command:n,escapedCommand:i}},Mn=t=>(0,hb.stripVTControlCharacters)(t).split(`
|
|
195
|
+
`).map(e=>mb(e)).join(`
|
|
196
|
+
`),mb=t=>t.replaceAll(bI,e=>yI(e)),yI=t=>{let e=SI[t];if(e!==void 0)return e;let r=t.codePointAt(0),n=r.toString(16);return r<=xI?`\\u${n.padStart(4,"0")}`:`\\U${n}`},wI=()=>{try{return new RegExp("\\p{Separator}|\\p{Other}","gu")}catch{return/[\s\u0000-\u001F\u007F-\u009F\u00AD]/g}},bI=wI(),SI={" ":" ","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t"},xI=65535,vI=t=>EI.test(t)?t:fb.platform==="win32"?`"${t.replaceAll('"','""')}"`:`'${t.replaceAll("'","'\\''")}'`,EI=/^[\w./-]+$/;var gb={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},yb={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},OI={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},TI={...gb,...yb},CI={...gb,...OI},AI=Qt(),PI=AI?TI:CI,ms=PI,BG=Object.entries(yb);var Sb=({type:t,message:e,timestamp:r,piped:n,commandId:i,result:{failed:s=!1}={},options:{reject:o=!0}})=>{let a=_I(r),l=kI[t]({failed:s,reject:o,piped:n}),u=II[t]({reject:o});return`${Li(`[${a}]`)} ${Li(`[${i}]`)} ${u(l)} ${u(e)}`},_I=t=>`${gs(t.getHours(),2)}:${gs(t.getMinutes(),2)}:${gs(t.getSeconds(),2)}.${gs(t.getMilliseconds(),3)}`,gs=(t,e)=>String(t).padStart(e,"0"),wb=({failed:t,reject:e})=>t?e?ms.cross:ms.warning:ms.tick,kI={command:({piped:t})=>t?"|":"$",output:()=>" ",ipc:()=>"*",error:wb,duration:wb},bb=t=>t,II={command:()=>Kg,output:()=>bb,ipc:()=>bb,error:({reject:t})=>t?ty:ry,duration:()=>Li};var xb=(t,e,r)=>{let n=db(e,r);return t.map(({verboseLine:i,verboseObject:s})=>MI(i,s,n)).filter(i=>i!==void 0).map(i=>DI(i)).join("")},MI=(t,e,r)=>{if(r===void 0)return t;let n=r(t,e);if(typeof n=="string")return n},DI=t=>t.endsWith(`
|
|
197
|
+
`)?t:`${t}
|
|
198
|
+
`;var rt=({type:t,verboseMessage:e,fdNumber:r,verboseInfo:n,result:i})=>{let s=RI({type:t,result:i,verboseInfo:n}),o=jI(e,s),a=xb(o,n,r);a!==""&&console.warn(a.slice(0,-1))},RI=({type:t,result:e,verboseInfo:{escapedCommand:r,commandId:n,rawOptions:{piped:i=!1,...s}}})=>({type:t,escapedCommand:r,commandId:`${n}`,timestamp:new Date,piped:i,result:e,options:s}),jI=(t,e)=>t.split(`
|
|
199
|
+
`).map(r=>FI({...e,message:r})),FI=t=>({verboseLine:Sb(t),verboseObject:t}),ys=t=>{let e=typeof t=="string"?t:(0,vb.inspect)(t);return Mn(e).replaceAll(" "," ".repeat(NI))},NI=2;var Eb=(t,e)=>{Rr(e)&&rt({type:"command",verboseMessage:t,verboseInfo:e})};var Ob=(t,e,r)=>{GI(t);let n=$I(t);return{verbose:t,escapedCommand:e,commandId:n,rawOptions:r}},$I=t=>Rr({verbose:t})?LI++:void 0,LI=0n,GI=t=>{for(let e of t){if(e===!1)throw new TypeError(`The "verbose: false" option was renamed to "verbose: 'none'".`);if(e===!0)throw new TypeError(`The "verbose: true" option was renamed to "verbose: 'short'".`);if(!ps.includes(e)&&!hs(e)){let r=ps.map(n=>`'${n}'`).join(", ");throw new TypeError(`The "verbose" option must not be ${e}. Allowed values are: ${r} or a function.`)}}};var Sl=require("node:process"),ws=()=>Sl.hrtime.bigint(),xl=t=>Number(Sl.hrtime.bigint()-t)/1e6;var bs=(t,e,r)=>{let n=ws(),{command:i,escapedCommand:s}=pb(t,e),o=gl(r,"verbose"),a=Ob(o,s,{...r});return Eb(s,a),{command:i,escapedCommand:s,startTime:n,verboseInfo:a}};var KS=C(require("node:path"),1),Fl=C(require("node:process"),1),XS=C(nl(),1);var Dn=C(require("node:process"),1),$t=C(require("node:path"),1);function Ss(t={}){let{env:e=process.env,platform:r=process.platform}=t;return r!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"}var Tb=require("node:util"),El=require("node:child_process"),vl=C(require("node:path"),1),Cb=require("node:url"),f9=(0,Tb.promisify)(El.execFile);function xs(t){return t instanceof URL?(0,Cb.fileURLToPath)(t):t}function Ab(t){return{*[Symbol.iterator](){let e=vl.default.resolve(xs(t)),r;for(;r!==e;)yield e,r=e,e=vl.default.resolve(e,"..")}}}var h9=10*1024*1024;var qI=({cwd:t=Dn.default.cwd(),path:e=Dn.default.env[Ss()],preferLocal:r=!0,execPath:n=Dn.default.execPath,addExecPath:i=!0}={})=>{let s=$t.default.resolve(xs(t)),o=[],a=e.split($t.default.delimiter);return r&&BI(o,a,s),i&&UI(o,a,n,s),e===""||e===$t.default.delimiter?`${o.join($t.default.delimiter)}${e}`:[...o,e].join($t.default.delimiter)},BI=(t,e,r)=>{for(let n of Ab(r)){let i=$t.default.join(n,"node_modules/.bin");e.includes(i)||t.push(i)}},UI=(t,e,r,n)=>{let i=$t.default.resolve(n,xs(r),"..");e.includes(i)||t.push(i)},Pb=({env:t=Dn.default.env,...e}={})=>{t={...t};let r=Ss({env:t});return e.path=t[r],t[r]=qI(e),t};var Vb=require("node:timers/promises");var _b=(t,e,r)=>{let n=r?jn:Rn,i=t instanceof Be?{}:{cause:t};return new n(e,i)},Be=class extends Error{},kb=(t,e)=>{Object.defineProperty(t.prototype,"name",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,Mb,{value:!0,writable:!1,enumerable:!1,configurable:!1})},Ib=t=>vs(t)&&Mb in t,Mb=Symbol("isExecaError"),vs=t=>Object.prototype.toString.call(t)==="[object Error]",Rn=class extends Error{};kb(Rn,Rn.name);var jn=class extends Error{};kb(jn,jn.name);var Fr=require("node:os");var $b=require("node:os");var Db=()=>{let t=jb-Rb+1;return Array.from({length:t},VI)},VI=(t,e)=>({name:`SIGRT${e+1}`,number:Rb+e,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),Rb=34,jb=64;var Nb=require("node:os");var Fb=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var Ol=()=>{let t=Db();return[...Fb,...t].map(WI)},WI=({name:t,number:e,description:r,action:n,forced:i=!1,standard:s})=>{let{signals:{[t]:o}}=Nb.constants,a=o!==void 0;return{name:t,number:a?o:e,description:r,supported:a,action:n,forced:i,standard:s}};var HI=()=>{let t=Ol();return Object.fromEntries(t.map(JI))},JI=({name:t,number:e,description:r,supported:n,action:i,forced:s,standard:o})=>[t,{name:t,number:e,description:r,supported:n,action:i,forced:s,standard:o}],Lb=HI(),YI=()=>{let t=Ol(),e=65,r=Array.from({length:e},(n,i)=>zI(i,t));return Object.assign({},...r)},zI=(t,e)=>{let r=KI(t,e);if(r===void 0)return{};let{name:n,description:i,supported:s,action:o,forced:a,standard:l}=r;return{[t]:{name:n,number:t,description:i,supported:s,action:o,forced:a,standard:l}}},KI=(t,e)=>{let r=e.find(({name:n})=>$b.constants.signals[n]===t);return r!==void 0?r:e.find(n=>n.number===t)},C9=YI();var qb=t=>{let e="option `killSignal`";if(t===0)throw new TypeError(`Invalid ${e}: 0 cannot be used.`);return Ub(t,e)},Bb=t=>t===0?t:Ub(t,"`subprocess.kill()`'s argument"),Ub=(t,e)=>{if(Number.isInteger(t))return XI(t,e);if(typeof t=="string")return QI(t,e);throw new TypeError(`Invalid ${e} ${String(t)}: it must be a string or an integer.
|
|
200
|
+
${Tl()}`)},XI=(t,e)=>{if(Gb.has(t))return Gb.get(t);throw new TypeError(`Invalid ${e} ${t}: this signal integer does not exist.
|
|
201
|
+
${Tl()}`)},ZI=()=>new Map(Object.entries(Fr.constants.signals).reverse().map(([t,e])=>[e,t])),Gb=ZI(),QI=(t,e)=>{if(t in Fr.constants.signals)return t;throw t.toUpperCase()in Fr.constants.signals?new TypeError(`Invalid ${e} '${t}': please rename it to '${t.toUpperCase()}'.`):new TypeError(`Invalid ${e} '${t}': this signal name does not exist.
|
|
202
|
+
${Tl()}`)},Tl=()=>`Available signal names: ${eM()}.
|
|
203
|
+
Available signal numbers: ${tM()}.`,eM=()=>Object.keys(Fr.constants.signals).sort().map(t=>`'${t}'`).join(", "),tM=()=>[...new Set(Object.values(Fr.constants.signals).sort((t,e)=>t-e))].join(", "),Es=t=>Lb[t].description;var Wb=t=>{if(t===!1)return t;if(t===!0)return rM;if(!Number.isFinite(t)||t<0)throw new TypeError(`Expected the \`forceKillAfterDelay\` option to be a non-negative integer, got \`${t}\` (${typeof t})`);return t},rM=1e3*5,Hb=({kill:t,options:{forceKillAfterDelay:e,killSignal:r},onInternalError:n,context:i,controller:s},o,a)=>{let{signal:l,error:u}=nM(o,a,r);iM(u,n);let c=t(l);return sM({kill:t,signal:l,forceKillAfterDelay:e,killSignal:r,killResult:c,context:i,controller:s}),c},nM=(t,e,r)=>{let[n=r,i]=vs(t)?[void 0,t]:[t,e];if(typeof n!="string"&&!Number.isInteger(n))throw new TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(n)}`);if(i!==void 0&&!vs(i))throw new TypeError(`The second argument is optional. If specified, it must be an error instance: ${i}`);return{signal:Bb(n),error:i}},iM=(t,e)=>{t!==void 0&&e.reject(t)},sM=async({kill:t,signal:e,forceKillAfterDelay:r,killSignal:n,killResult:i,context:s,controller:o})=>{e===n&&i&&Cl({kill:t,forceKillAfterDelay:r,context:s,controllerSignal:o.signal})},Cl=async({kill:t,forceKillAfterDelay:e,context:r,controllerSignal:n})=>{if(e!==!1)try{await(0,Vb.setTimeout)(e,void 0,{signal:n}),t("SIGKILL")&&(r.isForcefullyTerminated??=!0)}catch{}};var Jb=require("node:events"),Os=async(t,e)=>{t.aborted||await(0,Jb.once)(t,"abort",{signal:e})};var Yb=({cancelSignal:t})=>{if(t!==void 0&&Object.prototype.toString.call(t)!=="[object AbortSignal]")throw new Error(`The \`cancelSignal\` option must be an AbortSignal: ${String(t)}`)},zb=({subprocess:t,cancelSignal:e,gracefulCancel:r,context:n,controller:i})=>e===void 0||r?[]:[oM(t,e,n,i)],oM=async(t,e,r,{signal:n})=>{throw await Os(e,n),r.terminationReason??="cancel",t.kill(),e.reason};var PS=require("node:timers/promises");var CS=require("node:util");var Nr=({methodName:t,isSubprocess:e,ipc:r,isConnected:n})=>{aM(t,e,r),Al(t,e,n)},aM=(t,e,r)=>{if(!r)throw new Error(`${Ue(t,e)} can only be used if the \`ipc\` option is \`true\`.`)},Al=(t,e,r)=>{if(!r)throw new Error(`${Ue(t,e)} cannot be used: the ${Lt(e)} has already exited or disconnected.`)},Kb=t=>{throw new Error(`${Ue("getOneMessage",t)} could not complete: the ${Lt(t)} exited or disconnected.`)},Xb=t=>{throw new Error(`${Ue("sendMessage",t)} failed: the ${Lt(t)} is sending a message too, instead of listening to incoming messages.
|
|
204
|
+
This can be fixed by both sending a message and listening to incoming messages at the same time:
|
|
205
|
+
|
|
206
|
+
const [receivedMessage] = await Promise.all([
|
|
207
|
+
${Ue("getOneMessage",t)},
|
|
208
|
+
${Ue("sendMessage",t,"message, {strict: true}")},
|
|
209
|
+
]);`)},Ts=(t,e)=>new Error(`${Ue("sendMessage",e)} failed when sending an acknowledgment response to the ${Lt(e)}.`,{cause:t}),Zb=t=>{throw new Error(`${Ue("sendMessage",t)} failed: the ${Lt(t)} is not listening to incoming messages.`)},Qb=t=>{throw new Error(`${Ue("sendMessage",t)} failed: the ${Lt(t)} exited without listening to incoming messages.`)},eS=()=>new Error(`\`cancelSignal\` aborted: the ${Lt(!0)} disconnected.`),tS=()=>{throw new Error("`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.")},rS=({error:t,methodName:e,isSubprocess:r})=>{if(t.code==="EPIPE")throw new Error(`${Ue(e,r)} cannot be used: the ${Lt(r)} is disconnecting.`,{cause:t})},nS=({error:t,methodName:e,isSubprocess:r,message:n})=>{if(cM(t))throw new Error(`${Ue(e,r)}'s argument type is invalid: the message cannot be serialized: ${String(n)}.`,{cause:t})},cM=({code:t,message:e})=>lM.has(t)||uM.some(r=>e.includes(r)),lM=new Set(["ERR_MISSING_ARGS","ERR_INVALID_ARG_TYPE"]),uM=["could not be cloned","circular structure","call stack size exceeded"],Ue=(t,e,r="")=>t==="cancelSignal"?"`cancelSignal`'s `controller.abort()`":`${dM(e)}${t}(${r})`,dM=t=>t?"":"subprocess.",Lt=t=>t?"parent process":"subprocess",$r=t=>{t.connected&&t.disconnect()};var nt=()=>{let t={},e=new Promise((r,n)=>{Object.assign(t,{resolve:r,reject:n})});return Object.assign(e,t)};var As=(t,e="stdin")=>{let{options:n,fileDescriptors:i}=it.get(t),s=iS(i,e,!0),o=t.stdio[s];if(o===null)throw new TypeError(sS(s,e,n,!0));return o},Lr=(t,e="stdout")=>{let{options:n,fileDescriptors:i}=it.get(t),s=iS(i,e,!1),o=s==="all"?t.all:t.stdio[s];if(o==null)throw new TypeError(sS(s,e,n,!1));return o},it=new WeakMap,iS=(t,e,r)=>{let n=fM(e,r);return hM(n,e,r,t),n},fM=(t,e)=>{let r=yl(t);if(r!==void 0)return r;let{validOptions:n,defaultValue:i}=e?{validOptions:'"stdin"',defaultValue:"stdin"}:{validOptions:'"stdout", "stderr", "all"',defaultValue:"stdout"};throw new TypeError(`"${Fn(e)}" must not be "${t}".
|
|
210
|
+
It must be ${n} or "fd3", "fd4" (and so on).
|
|
211
|
+
It is optional and defaults to "${i}".`)},hM=(t,e,r,n)=>{let i=n[oS(t)];if(i===void 0)throw new TypeError(`"${Fn(r)}" must not be ${e}. That file descriptor does not exist.
|
|
212
|
+
Please set the "stdio" option to ensure that file descriptor exists.`);if(i.direction==="input"&&!r)throw new TypeError(`"${Fn(r)}" must not be ${e}. It must be a readable stream, not writable.`);if(i.direction!=="input"&&r)throw new TypeError(`"${Fn(r)}" must not be ${e}. It must be a writable stream, not readable.`)},sS=(t,e,r,n)=>{if(t==="all"&&!r.all)return`The "all" option must be true to use "from: 'all'".`;let{optionName:i,optionValue:s}=pM(t,r);return`The "${i}: ${Cs(s)}" option is incompatible with using "${Fn(n)}: ${Cs(e)}".
|
|
213
|
+
Please set this option with "pipe" instead.`},pM=(t,{stdin:e,stdout:r,stderr:n,stdio:i})=>{let s=oS(t);return s===0&&e!==void 0?{optionName:"stdin",optionValue:e}:s===1&&r!==void 0?{optionName:"stdout",optionValue:r}:s===2&&n!==void 0?{optionName:"stderr",optionValue:n}:{optionName:`stdio[${s}]`,optionValue:i[s]}},oS=t=>t==="all"?1:t,Fn=t=>t?"to":"from",Cs=t=>typeof t=="string"?`'${t}'`:typeof t=="number"?`${t}`:"Stream";var bS=require("node:events");var aS=require("node:events"),ir=(t,e,r)=>{let n=t.getMaxListeners();n===0||n===Number.POSITIVE_INFINITY||(t.setMaxListeners(n+e),(0,aS.addAbortListener)(r,()=>{t.setMaxListeners(t.getMaxListeners()-e)}))};var wS=require("node:events");var uS=require("node:events"),dS=require("node:timers/promises");var Ps=(t,e)=>{e&&Pl(t)},Pl=t=>{t.refCounted()},_s=(t,e)=>{e&&_l(t)},_l=t=>{t.unrefCounted()},cS=(t,e)=>{e&&(_l(t),_l(t))},lS=(t,e)=>{e&&(Pl(t),Pl(t))};var fS=async({anyProcess:t,channel:e,isSubprocess:r,ipcEmitter:n},i)=>{if(mS(i)||yS(i))return;ks.has(t)||ks.set(t,[]);let s=ks.get(t);if(s.push(i),!(s.length>1))for(;s.length>0;){await gS(t,n,i),await dS.scheduler.yield();let o=await pS({wrappedMessage:s[0],anyProcess:t,channel:e,isSubprocess:r,ipcEmitter:n});s.shift(),n.emit("message",o),n.emit("message:done")}},hS=async({anyProcess:t,channel:e,isSubprocess:r,ipcEmitter:n,boundOnMessage:i})=>{kl();let s=ks.get(t);for(;s?.length>0;)await(0,uS.once)(n,"message:done");t.removeListener("message",i),lS(e,r),n.connected=!1,n.emit("disconnect")},ks=new WeakMap;var Gt=(t,e,r)=>{if(Is.has(t))return Is.get(t);let n=new wS.EventEmitter;return n.connected=!0,Is.set(t,n),mM({ipcEmitter:n,anyProcess:t,channel:e,isSubprocess:r}),n},Is=new WeakMap,mM=({ipcEmitter:t,anyProcess:e,channel:r,isSubprocess:n})=>{let i=fS.bind(void 0,{anyProcess:e,channel:r,isSubprocess:n,ipcEmitter:t});e.on("message",i),e.once("disconnect",hS.bind(void 0,{anyProcess:e,channel:r,isSubprocess:n,ipcEmitter:t,boundOnMessage:i})),cS(r,n)},Ms=t=>{let e=Is.get(t);return e===void 0?t.channel!==null:e.connected};var SS=({anyProcess:t,channel:e,isSubprocess:r,message:n,strict:i})=>{if(!i)return n;let s=Gt(t,e,r),o=js(t,s);return{id:gM++,type:Rs,message:n,hasListeners:o}},gM=0n,xS=(t,e)=>{if(!(e?.type!==Rs||e.hasListeners))for(let{id:r}of t)r!==void 0&&Ds[r].resolve({isDeadlock:!0,hasListeners:!1})},pS=async({wrappedMessage:t,anyProcess:e,channel:r,isSubprocess:n,ipcEmitter:i})=>{if(t?.type!==Rs||!e.connected)return t;let{id:s,message:o}=t,a={id:s,type:ES,message:js(e,i)};try{await Fs({anyProcess:e,channel:r,isSubprocess:n,ipc:!0},a)}catch(l){i.emit("strict:error",l)}return o},mS=t=>{if(t?.type!==ES)return!1;let{id:e,message:r}=t;return Ds[e]?.resolve({isDeadlock:!1,hasListeners:r}),!0},vS=async(t,e,r)=>{if(t?.type!==Rs)return;let n=nt();Ds[t.id]=n;let i=new AbortController;try{let{isDeadlock:s,hasListeners:o}=await Promise.race([n,yM(e,r,i)]);s&&Xb(r),o||Zb(r)}finally{i.abort(),delete Ds[t.id]}},Ds={},yM=async(t,e,{signal:r})=>{ir(t,1,r),await(0,bS.once)(t,"disconnect",{signal:r}),Qb(e)},Rs="execa:ipc:request",ES="execa:ipc:response";var OS=(t,e,r)=>{Nn.has(t)||Nn.set(t,new Set);let n=Nn.get(t),i=nt(),s=r?e.id:void 0,o={onMessageSent:i,id:s};return n.add(o),{outgoingMessages:n,outgoingMessage:o}},TS=({outgoingMessages:t,outgoingMessage:e})=>{t.delete(e),e.onMessageSent.resolve()},gS=async(t,e,r)=>{for(;!js(t,e)&&Nn.get(t)?.size>0;){let n=[...Nn.get(t)];xS(n,r),await Promise.all(n.map(({onMessageSent:i})=>i))}},Nn=new WeakMap,js=(t,e)=>e.listenerCount("message")>wM(t),wM=t=>it.has(t)&&!vt(it.get(t).options.buffer,"ipc")?1:0;var Fs=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},i,{strict:s=!1}={})=>{let o="sendMessage";return Nr({methodName:o,isSubprocess:r,ipc:n,isConnected:t.connected}),bM({anyProcess:t,channel:e,methodName:o,isSubprocess:r,message:i,strict:s})},bM=async({anyProcess:t,channel:e,methodName:r,isSubprocess:n,message:i,strict:s})=>{let o=SS({anyProcess:t,channel:e,isSubprocess:n,message:i,strict:s}),a=OS(t,o,s);try{await Ml({anyProcess:t,methodName:r,isSubprocess:n,wrappedMessage:o,message:i})}catch(l){throw $r(t),l}finally{TS(a)}},Ml=async({anyProcess:t,methodName:e,isSubprocess:r,wrappedMessage:n,message:i})=>{let s=SM(t);try{await Promise.all([vS(n,t,r),s(n)])}catch(o){throw rS({error:o,methodName:e,isSubprocess:r}),nS({error:o,methodName:e,isSubprocess:r,message:i}),o}},SM=t=>{if(Il.has(t))return Il.get(t);let e=(0,CS.promisify)(t.send.bind(t));return Il.set(t,e),e},Il=new WeakMap;var _S=(t,e)=>{let r="cancelSignal";return Al(r,!1,t.connected),Ml({anyProcess:t,methodName:r,isSubprocess:!1,wrappedMessage:{type:IS,message:e},message:e})},kS=async({anyProcess:t,channel:e,isSubprocess:r,ipc:n})=>(await xM({anyProcess:t,channel:e,isSubprocess:r,ipc:n}),Dl.signal),xM=async({anyProcess:t,channel:e,isSubprocess:r,ipc:n})=>{if(!AS){if(AS=!0,!n){tS();return}if(e===null){kl();return}Gt(t,e,r),await PS.scheduler.yield()}},AS=!1,yS=t=>t?.type!==IS?!1:(Dl.abort(t.message),!0),IS="execa:ipc:cancel",kl=()=>{Dl.abort(eS())},Dl=new AbortController;var MS=({gracefulCancel:t,cancelSignal:e,ipc:r,serialization:n})=>{if(t){if(e===void 0)throw new Error("The `cancelSignal` option must be defined when setting the `gracefulCancel` option.");if(!r)throw new Error("The `ipc` option cannot be false when setting the `gracefulCancel` option.");if(n==="json")throw new Error("The `serialization` option cannot be 'json' when setting the `gracefulCancel` option.")}},DS=({subprocess:t,cancelSignal:e,gracefulCancel:r,forceKillAfterDelay:n,context:i,controller:s})=>r?[vM({subprocess:t,cancelSignal:e,forceKillAfterDelay:n,context:i,controller:s})]:[],vM=async({subprocess:t,cancelSignal:e,forceKillAfterDelay:r,context:n,controller:{signal:i}})=>{await Os(e,i);let s=EM(e);throw await _S(t,s),Cl({kill:t.kill,forceKillAfterDelay:r,context:n,controllerSignal:i}),n.terminationReason??="gracefulCancel",e.reason},EM=({reason:t})=>{if(!(t instanceof DOMException))return t;let e=new Error(t.message);return Object.defineProperty(e,"stack",{value:t.stack,enumerable:!1,configurable:!0,writable:!0}),e};var RS=require("node:timers/promises");var jS=({timeout:t})=>{if(t!==void 0&&(!Number.isFinite(t)||t<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${t}\` (${typeof t})`)},FS=(t,e,r,n)=>e===0||e===void 0?[]:[OM(t,e,r,n)],OM=async(t,e,r,{signal:n})=>{throw await(0,RS.setTimeout)(e,void 0,{signal:n}),r.terminationReason??="timeout",t.kill(),new Be};var Ns=require("node:process"),Rl=C(require("node:path"),1);var NS=({options:t})=>{if(t.node===!1)throw new TypeError('The "node" option cannot be false with `execaNode()`.');return{options:{...t,node:!0}}},$S=(t,e,{node:r=!1,nodePath:n=Ns.execPath,nodeOptions:i=Ns.execArgv.filter(l=>!l.startsWith("--inspect")),cwd:s,execPath:o,...a})=>{if(o!==void 0)throw new TypeError('The "execPath" option has been removed. Please use the "nodePath" option instead.');let l=Dr(n,'The "nodePath" option'),u=Rl.default.resolve(s,l),c={...a,nodePath:u,node:r,cwd:s};if(!r)return[t,e,c];if(Rl.default.basename(t,".exe")==="node")throw new TypeError('When the "node" option is true, the first argument does not need to be "node".');return[u,[...i,t,...e],{ipc:!0,...c,shell:!1}]};var LS=require("node:v8"),GS=({ipcInput:t,ipc:e,serialization:r})=>{if(t!==void 0){if(!e)throw new Error("The `ipcInput` option cannot be set unless the `ipc` option is `true`.");AM[r](t)}},TM=t=>{try{(0,LS.serialize)(t)}catch(e){throw new Error("The `ipcInput` option is not serializable with a structured clone.",{cause:e})}},CM=t=>{try{JSON.stringify(t)}catch(e){throw new Error("The `ipcInput` option is not serializable with JSON.",{cause:e})}},AM={advanced:TM,json:CM},qS=async(t,e)=>{e!==void 0&&await t.sendMessage(e)};var US=({encoding:t})=>{if(jl.has(t))return;let e=_M(t);if(e!==void 0)throw new TypeError(`Invalid option \`encoding: ${$s(t)}\`.
|
|
214
|
+
Please rename it to ${$s(e)}.`);let r=[...jl].map(n=>$s(n)).join(", ");throw new TypeError(`Invalid option \`encoding: ${$s(t)}\`.
|
|
215
|
+
Please rename it to one of: ${r}.`)},PM=new Set(["utf8","utf16le"]),ke=new Set(["buffer","hex","base64","base64url","latin1","ascii"]),jl=new Set([...PM,...ke]),_M=t=>{if(t===null)return"buffer";if(typeof t!="string")return;let e=t.toLowerCase();if(e in BS)return BS[e];if(jl.has(e))return e},BS={"utf-8":"utf8","utf-16le":"utf16le","ucs-2":"utf16le",ucs2:"utf16le",binary:"latin1"},$s=t=>typeof t=="string"?`"${t}"`:String(t);var VS=require("node:fs"),WS=C(require("node:path"),1),HS=C(require("node:process"),1);var JS=(t=YS())=>{let e=Dr(t,'The "cwd" option');return WS.default.resolve(e)},YS=()=>{try{return HS.default.cwd()}catch(t){throw t.message=`The current directory does not exist.
|
|
216
|
+
${t.message}`,t}},zS=(t,e)=>{if(e===YS())return t;let r;try{r=(0,VS.statSync)(e)}catch(n){return`The "cwd" option is invalid: ${e}.
|
|
217
|
+
${n.message}
|
|
218
|
+
${t}`}return r.isDirectory()?t:`The "cwd" option is not a directory: ${e}.
|
|
219
|
+
${t}`};var Ls=(t,e,r)=>{r.cwd=JS(r.cwd);let[n,i,s]=$S(t,e,r),{command:o,args:a,options:l}=XS.default._parse(n,i,s),u=ub(l),c=kM(u);return jS(c),US(c),GS(c),Yb(c),MS(c),c.shell=pl(c.shell),c.env=IM(c),c.killSignal=qb(c.killSignal),c.forceKillAfterDelay=Wb(c.forceKillAfterDelay),c.lines=c.lines.map((d,f)=>d&&!ke.has(c.encoding)&&c.buffer[f]),Fl.default.platform==="win32"&&KS.default.basename(o,".exe")==="cmd"&&a.unshift("/q"),{file:o,commandArguments:a,options:c}},kM=({extendEnv:t=!0,preferLocal:e=!1,cwd:r,localDir:n=r,encoding:i="utf8",reject:s=!0,cleanup:o=!0,all:a=!1,windowsHide:l=!0,killSignal:u="SIGTERM",forceKillAfterDelay:c=!0,gracefulCancel:d=!1,ipcInput:f,ipc:h=f!==void 0||d,serialization:p="advanced",...y})=>({...y,extendEnv:t,preferLocal:e,cwd:r,localDirectory:n,encoding:i,reject:s,cleanup:o,all:a,windowsHide:l,killSignal:u,forceKillAfterDelay:c,gracefulCancel:d,ipcInput:f,ipc:h,serialization:p}),IM=({env:t,extendEnv:e,preferLocal:r,node:n,localDirectory:i,nodePath:s})=>{let o=e?{...Fl.default.env,...t}:t;return r||n?Pb({env:o,cwd:i,execPath:s,preferLocal:r,addExecPath:n}):o};var Gs=(t,e,r)=>r.shell&&e.length>0?[[t,...e].join(" "),[],r]:[t,e,r];var bx=require("node:util");function Gr(t){if(typeof t=="string")return MM(t);if(!(ArrayBuffer.isView(t)&&t.BYTES_PER_ELEMENT===1))throw new Error("Input must be a string or a Uint8Array");return DM(t)}var MM=t=>t.at(-1)===ZS?t.slice(0,t.at(-2)===QS?-2:-1):t,DM=t=>t.at(-1)===RM?t.subarray(0,t.at(-2)===jM?-2:-1):t,ZS=`
|
|
220
|
+
`,RM=ZS.codePointAt(0),QS="\r",jM=QS.codePointAt(0);var dx=require("node:events"),fx=require("node:stream/promises");function Ve(t,{checkOpen:e=!0}={}){return t!==null&&typeof t=="object"&&(t.writable||t.readable||!e||t.writable===void 0&&t.readable===void 0)&&typeof t.pipe=="function"}function Nl(t,{checkOpen:e=!0}={}){return Ve(t,{checkOpen:e})&&(t.writable||!e)&&typeof t.write=="function"&&typeof t.end=="function"&&typeof t.writable=="boolean"&&typeof t.writableObjectMode=="boolean"&&typeof t.destroy=="function"&&typeof t.destroyed=="boolean"}function sr(t,{checkOpen:e=!0}={}){return Ve(t,{checkOpen:e})&&(t.readable||!e)&&typeof t.read=="function"&&typeof t.readable=="boolean"&&typeof t.readableObjectMode=="boolean"&&typeof t.destroy=="function"&&typeof t.destroyed=="boolean"}function $l(t,e){return Nl(t,e)&&sr(t,e)}var FM=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),Ll=class{#i;#n;#t=!1;#e=void 0;constructor(e,r){this.#i=e,this.#n=r}next(){let e=()=>this.#s();return this.#e=this.#e?this.#e.then(e,e):e(),this.#e}return(e){let r=()=>this.#r(e);return this.#e?this.#e.then(r,r):r()}async#s(){if(this.#t)return{done:!0,value:void 0};let e;try{e=await this.#i.read()}catch(r){throw this.#e=void 0,this.#t=!0,this.#i.releaseLock(),r}return e.done&&(this.#e=void 0,this.#t=!0,this.#i.releaseLock()),e}async#r(e){if(this.#t)return{done:!0,value:e};if(this.#t=!0,!this.#n){let r=this.#i.cancel(e);return this.#i.releaseLock(),await r,{done:!0,value:e}}return this.#i.releaseLock(),{done:!0,value:e}}},Gl=Symbol();function ex(){return this[Gl].next()}Object.defineProperty(ex,"name",{value:"next"});function tx(t){return this[Gl].return(t)}Object.defineProperty(tx,"name",{value:"return"});var NM=Object.create(FM,{next:{enumerable:!0,configurable:!0,writable:!0,value:ex},return:{enumerable:!0,configurable:!0,writable:!0,value:tx}});function ql({preventCancel:t=!1}={}){let e=this.getReader(),r=new Ll(e,t),n=Object.create(NM);return n[Gl]=r,n}var rx=t=>{if(sr(t,{checkOpen:!1})&&$n.on!==void 0)return LM(t);if(typeof t?.[Symbol.asyncIterator]=="function")return t;if($M.call(t)==="[object ReadableStream]")return ql.call(t);throw new TypeError("The first argument must be a Readable, a ReadableStream, or an async iterable.")},{toString:$M}=Object.prototype,LM=async function*(t){let e=new AbortController,r={};GM(t,e,r);try{for await(let[n]of $n.on(t,"data",{signal:e.signal}))yield n}catch(n){if(r.error!==void 0)throw r.error;if(!e.signal.aborted)throw n}finally{t.destroy()}},GM=async(t,e,r)=>{try{await $n.finished(t,{cleanup:!0,readable:!0,writable:!1,error:!1})}catch(n){r.error=n}finally{e.abort()}},$n={};var qr=async(t,{init:e,convertChunk:r,getSize:n,truncateChunk:i,addChunk:s,getFinalChunk:o,finalize:a},{maxBuffer:l=Number.POSITIVE_INFINITY}={})=>{let u=rx(t),c=e();c.length=0;try{for await(let d of u){let f=BM(d),h=r[f](d,c);sx({convertedChunk:h,state:c,getSize:n,truncateChunk:i,addChunk:s,maxBuffer:l})}return qM({state:c,convertChunk:r,getSize:n,truncateChunk:i,addChunk:s,getFinalChunk:o,maxBuffer:l}),a(c)}catch(d){let f=typeof d=="object"&&d!==null?d:new Error(d);throw f.bufferedData=a(c),f}},qM=({state:t,getSize:e,truncateChunk:r,addChunk:n,getFinalChunk:i,maxBuffer:s})=>{let o=i(t);o!==void 0&&sx({convertedChunk:o,state:t,getSize:e,truncateChunk:r,addChunk:n,maxBuffer:s})},sx=({convertedChunk:t,state:e,getSize:r,truncateChunk:n,addChunk:i,maxBuffer:s})=>{let o=r(t),a=e.length+o;if(a<=s){nx(t,e,i,a);return}let l=n(t,s-e.length);throw l!==void 0&&nx(l,e,i,s),new st},nx=(t,e,r,n)=>{e.contents=r(t,e,n),e.length=n},BM=t=>{let e=typeof t;if(e==="string")return"string";if(e!=="object"||t===null)return"others";if(globalThis.Buffer?.isBuffer(t))return"buffer";let r=ix.call(t);return r==="[object ArrayBuffer]"?"arrayBuffer":r==="[object DataView]"?"dataView":Number.isInteger(t.byteLength)&&Number.isInteger(t.byteOffset)&&ix.call(t.buffer)==="[object ArrayBuffer]"?"typedArray":"others"},{toString:ix}=Object.prototype,st=class extends Error{name="MaxBufferError";constructor(){super("maxBuffer exceeded")}};var Et=t=>t,Ln=()=>{},qs=({contents:t})=>t,Bs=t=>{throw new Error(`Streams in object mode are not supported: ${String(t)}`)},Us=t=>t.length;async function Vs(t,e){return qr(t,HM,e)}var UM=()=>({contents:[]}),VM=()=>1,WM=(t,{contents:e})=>(e.push(t),e),HM={init:UM,convertChunk:{string:Et,buffer:Et,arrayBuffer:Et,dataView:Et,typedArray:Et,others:Et},getSize:VM,truncateChunk:Ln,addChunk:WM,getFinalChunk:Ln,finalize:qs};async function Ws(t,e){return qr(t,tD,e)}var JM=()=>({contents:new ArrayBuffer(0)}),YM=t=>zM.encode(t),zM=new TextEncoder,ox=t=>new Uint8Array(t),ax=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),KM=(t,e)=>t.slice(0,e),XM=(t,{contents:e,length:r},n)=>{let i=ux()?QM(e,n):ZM(e,n);return new Uint8Array(i).set(t,r),i},ZM=(t,e)=>{if(e<=t.byteLength)return t;let r=new ArrayBuffer(lx(e));return new Uint8Array(r).set(new Uint8Array(t),0),r},QM=(t,e)=>{if(e<=t.maxByteLength)return t.resize(e),t;let r=new ArrayBuffer(e,{maxByteLength:lx(e)});return new Uint8Array(r).set(new Uint8Array(t),0),r},lx=t=>cx**Math.ceil(Math.log(t)/Math.log(cx)),cx=2,eD=({contents:t,length:e})=>ux()?t:t.slice(0,e),ux=()=>"resize"in ArrayBuffer.prototype,tD={init:JM,convertChunk:{string:YM,buffer:ox,arrayBuffer:ox,dataView:ax,typedArray:ax,others:Bs},getSize:Us,truncateChunk:KM,addChunk:XM,getFinalChunk:Ln,finalize:eD};async function Js(t,e){return qr(t,oD,e)}var rD=()=>({contents:"",textDecoder:new TextDecoder}),Hs=(t,{textDecoder:e})=>e.decode(t,{stream:!0}),nD=(t,{contents:e})=>e+t,iD=(t,e)=>t.slice(0,e),sD=({textDecoder:t})=>{let e=t.decode();return e===""?void 0:e},oD={init:rD,convertChunk:{string:Et,buffer:Hs,arrayBuffer:Hs,dataView:Hs,typedArray:Hs,others:Bs},getSize:Us,truncateChunk:iD,addChunk:nD,getFinalChunk:sD,finalize:qs};Object.assign($n,{on:dx.on,finished:fx.finished});var hx=({error:t,stream:e,readableObjectMode:r,lines:n,encoding:i,fdNumber:s})=>{if(!(t instanceof st))throw t;if(s==="all")return t;let o=aD(r,n,i);throw t.maxBufferInfo={fdNumber:s,unit:o},e.destroy(),t},aD=(t,e,r)=>t?"objects":e?"lines":r==="buffer"?"bytes":"characters",px=(t,e,r)=>{if(e.length!==r)return;let n=new st;throw n.maxBufferInfo={fdNumber:"ipc"},n},mx=(t,e)=>{let{streamName:r,threshold:n,unit:i}=cD(t,e);return`Command's ${r} was larger than ${n} ${i}`},cD=(t,e)=>{if(t?.maxBufferInfo===void 0)return{streamName:"output",threshold:e[1],unit:"bytes"};let{maxBufferInfo:{fdNumber:r,unit:n}}=t;delete t.maxBufferInfo;let i=vt(e,r);return r==="ipc"?{streamName:"IPC output",threshold:i,unit:"messages"}:{streamName:fs(r),threshold:i,unit:n}},gx=(t,e,r)=>t?.code==="ENOBUFS"&&e!==null&&e.some(n=>n!==null&&n.length>Ys(r)),yx=(t,e,r)=>{if(!e)return t;let n=Ys(r);return t.length>n?t.slice(0,n):t},Ys=([,t])=>t;var Sx=({stdio:t,all:e,ipcOutput:r,originalError:n,signal:i,signalDescription:s,exitCode:o,escapedCommand:a,timedOut:l,isCanceled:u,isGracefullyCanceled:c,isMaxBuffer:d,isForcefullyTerminated:f,forceKillAfterDelay:h,killSignal:p,maxBuffer:y,timeout:x,cwd:b})=>{let S=n?.code,g=lD({originalError:n,timedOut:l,timeout:x,isMaxBuffer:d,maxBuffer:y,errorCode:S,signal:i,signalDescription:s,exitCode:o,isCanceled:u,isGracefullyCanceled:c,isForcefullyTerminated:f,forceKillAfterDelay:h,killSignal:p}),v=dD(n,b),E=v===void 0?"":`
|
|
221
|
+
${v}`,T=`${g}: ${a}${E}`,j=e===void 0?[t[2],t[1]]:[e],$=[T,...j,...t.slice(3),r.map(A=>fD(A)).join(`
|
|
222
|
+
`)].map(A=>Mn(Gr(hD(A)))).filter(Boolean).join(`
|
|
223
|
+
|
|
224
|
+
`);return{originalMessage:v,shortMessage:T,message:$}},lD=({originalError:t,timedOut:e,timeout:r,isMaxBuffer:n,maxBuffer:i,errorCode:s,signal:o,signalDescription:a,exitCode:l,isCanceled:u,isGracefullyCanceled:c,isForcefullyTerminated:d,forceKillAfterDelay:f,killSignal:h})=>{let p=uD(d,f);return e?`Command timed out after ${r} milliseconds${p}`:c?o===void 0?`Command was gracefully canceled with exit code ${l}`:d?`Command was gracefully canceled${p}`:`Command was gracefully canceled with ${o} (${a})`:u?`Command was canceled${p}`:n?`${mx(t,i)}${p}`:s!==void 0?`Command failed with ${s}${p}`:d?`Command was killed with ${h} (${Es(h)})${p}`:o!==void 0?`Command was killed with ${o} (${a})`:l!==void 0?`Command failed with exit code ${l}`:"Command failed"},uD=(t,e)=>t?` and was forcefully terminated after ${e} milliseconds`:"",dD=(t,e)=>{if(t instanceof Be)return;let r=Ib(t)?t.originalMessage:String(t?.message??t),n=Mn(zS(r,e));return n===""?void 0:n},fD=t=>typeof t=="string"?t:(0,bx.inspect)(t),hD=t=>Array.isArray(t)?t.map(e=>Gr(wx(e))).filter(Boolean).join(`
|
|
225
|
+
`):wx(t),wx=t=>typeof t=="string"?t:ce(t)?ls(t):"";var zs=({command:t,escapedCommand:e,stdio:r,all:n,ipcOutput:i,options:{cwd:s},startTime:o})=>xx({command:t,escapedCommand:e,cwd:s,durationMs:xl(o),failed:!1,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isTerminated:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,exitCode:0,stdout:r[1],stderr:r[2],all:n,stdio:r,ipcOutput:i,pipedFrom:[]}),Br=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:o})=>Gn({error:t,command:e,escapedCommand:r,startTime:s,timedOut:!1,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:!1,isForcefullyTerminated:!1,stdio:Array.from({length:n.length}),ipcOutput:[],options:i,isSync:o}),Gn=({error:t,command:e,escapedCommand:r,startTime:n,timedOut:i,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:u,signal:c,stdio:d,all:f,ipcOutput:h,options:{timeoutDuration:p,timeout:y=p,forceKillAfterDelay:x,killSignal:b,cwd:S,maxBuffer:g},isSync:v})=>{let{exitCode:E,signal:T,signalDescription:j}=mD(u,c),{originalMessage:$,shortMessage:A,message:D}=Sx({stdio:d,all:f,ipcOutput:h,originalError:t,signal:T,signalDescription:j,exitCode:E,escapedCommand:r,timedOut:i,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:l,forceKillAfterDelay:x,killSignal:b,maxBuffer:g,timeout:y,cwd:S}),k=_b(t,D,v);return Object.assign(k,pD({error:k,command:e,escapedCommand:r,startTime:n,timedOut:i,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:E,signal:T,signalDescription:j,stdio:d,all:f,ipcOutput:h,cwd:S,originalMessage:$,shortMessage:A})),k},pD=({error:t,command:e,escapedCommand:r,startTime:n,timedOut:i,isCanceled:s,isGracefullyCanceled:o,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:u,signal:c,signalDescription:d,stdio:f,all:h,ipcOutput:p,cwd:y,originalMessage:x,shortMessage:b})=>xx({shortMessage:b,originalMessage:x,command:e,escapedCommand:r,cwd:y,durationMs:xl(n),failed:!0,timedOut:i,isCanceled:s,isGracefullyCanceled:o,isTerminated:c!==void 0,isMaxBuffer:a,isForcefullyTerminated:l,exitCode:u,signal:c,signalDescription:d,code:t.cause?.code,stdout:f[1],stderr:f[2],all:h,stdio:f,ipcOutput:p,pipedFrom:[]}),xx=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0)),mD=(t,e)=>{let r=t===null?void 0:t,n=e===null?void 0:e,i=n===void 0?void 0:Es(e);return{exitCode:r,signal:n,signalDescription:i}};var vx=t=>Number.isFinite(t)?t:0;function gD(t){return{days:Math.trunc(t/864e5),hours:Math.trunc(t/36e5%24),minutes:Math.trunc(t/6e4%60),seconds:Math.trunc(t/1e3%60),milliseconds:Math.trunc(t%1e3),microseconds:Math.trunc(vx(t*1e3)%1e3),nanoseconds:Math.trunc(vx(t*1e6)%1e3)}}function yD(t){return{days:t/86400000n,hours:t/3600000n%24n,minutes:t/60000n%60n,seconds:t/1000n%60n,milliseconds:t%1000n,microseconds:0n,nanoseconds:0n}}function Bl(t){switch(typeof t){case"number":{if(Number.isFinite(t))return gD(t);break}case"bigint":return yD(t)}throw new TypeError("Expected a finite number or bigint")}var wD=t=>t===0||t===0n,bD=(t,e)=>e===1||e===1n?t:`${t}s`,SD=1e-7,xD=24n*60n*60n*1000n;function Ul(t,e){let r=typeof t=="bigint";if(!r&&!Number.isFinite(t))throw new TypeError("Expected a finite number or bigint");e={...e};let n=t<0?"-":"";t=t<0?-t:t,e.colonNotation&&(e.compact=!1,e.formatSubMilliseconds=!1,e.separateMilliseconds=!1,e.verbose=!1),e.compact&&(e.unitCount=1,e.secondsDecimalDigits=0,e.millisecondsDecimalDigits=0);let i=[],s=(c,d)=>{let f=Math.floor(c*10**d+SD);return(Math.round(f)/10**d).toFixed(d)},o=(c,d,f,h)=>{if(!((i.length===0||!e.colonNotation)&&wD(c)&&!(e.colonNotation&&f==="m"))){if(h??=String(c),e.colonNotation){let p=h.includes(".")?h.split(".")[0].length:h.length,y=i.length>0?2:1;h="0".repeat(Math.max(0,y-p))+h}else h+=e.verbose?" "+bD(d,c):f;i.push(h)}},a=Bl(t),l=BigInt(a.days);if(e.hideYearAndDays?o(BigInt(l)*24n+BigInt(a.hours),"hour","h"):(e.hideYear?o(l,"day","d"):(o(l/365n,"year","y"),o(l%365n,"day","d")),o(Number(a.hours),"hour","h")),o(Number(a.minutes),"minute","m"),!e.hideSeconds)if(e.separateMilliseconds||e.formatSubMilliseconds||!e.colonNotation&&t<1e3&&!e.subSecondsAsDecimals){let c=Number(a.seconds),d=Number(a.milliseconds),f=Number(a.microseconds),h=Number(a.nanoseconds);if(o(c,"second","s"),e.formatSubMilliseconds)o(d,"millisecond","ms"),o(f,"microsecond","\xB5s"),o(h,"nanosecond","ns");else{let p=d+f/1e3+h/1e6,y=typeof e.millisecondsDecimalDigits=="number"?e.millisecondsDecimalDigits:0,x=p>=1?Math.round(p):Math.ceil(p),b=y?p.toFixed(y):x;o(Number.parseFloat(b),"millisecond","ms",b)}}else{let c=(r?Number(t%xD):t)/1e3%60,d=typeof e.secondsDecimalDigits=="number"?e.secondsDecimalDigits:1,f=s(c,d),h=e.keepDecimalsOnWholeSeconds?f:f.replace(/\.0+$/,"");o(Number.parseFloat(h),"second","s",h)}if(i.length===0)return n+"0"+(e.verbose?" milliseconds":"ms");let u=e.colonNotation?":":" ";return typeof e.unitCount=="number"&&(i=i.slice(0,Math.max(e.unitCount,1))),n+i.join(u)}var Ex=(t,e)=>{t.failed&&rt({type:"error",verboseMessage:t.shortMessage,verboseInfo:e,result:t})};var Ox=(t,e)=>{Rr(e)&&(Ex(t,e),vD(t,e))},vD=(t,e)=>{let r=`(done in ${Ul(t.durationMs)})`;rt({type:"duration",verboseMessage:r,verboseInfo:e,result:t})};var Ur=(t,e,{reject:r})=>{if(Ox(t,e),t.failed&&r)throw t;return t};var Xl=require("node:fs");var Ax=(t,e)=>or(t)?"asyncGenerator":kx(t)?"generator":Ks(t)?"fileUrl":AD(t)?"filePath":kD(t)?"webStream":Ve(t,{checkOpen:!1})?"native":ce(t)?"uint8Array":ID(t)?"asyncIterable":MD(t)?"iterable":Hl(t)?Px({transform:t},e):CD(t)?ED(t,e):"native",ED=(t,e)=>$l(t.transform,{checkOpen:!1})?OD(t,e):Hl(t.transform)?Px(t,e):TD(t,e),OD=(t,e)=>(_x(t,e,"Duplex stream"),"duplex"),Px=(t,e)=>(_x(t,e,"web TransformStream"),"webTransform"),_x=({final:t,binary:e,objectMode:r},n,i)=>{Tx(t,`${n}.final`,i),Tx(e,`${n}.binary`,i),Vl(r,`${n}.objectMode`)},Tx=(t,e,r)=>{if(t!==void 0)throw new TypeError(`The \`${e}\` option can only be defined when using a generator, not a ${r}.`)},TD=({transform:t,final:e,binary:r,objectMode:n},i)=>{if(t!==void 0&&!Cx(t))throw new TypeError(`The \`${i}.transform\` option must be a generator, a Duplex stream or a web TransformStream.`);if($l(e,{checkOpen:!1}))throw new TypeError(`The \`${i}.final\` option must not be a Duplex stream.`);if(Hl(e))throw new TypeError(`The \`${i}.final\` option must not be a web TransformStream.`);if(e!==void 0&&!Cx(e))throw new TypeError(`The \`${i}.final\` option must be a generator.`);return Vl(r,`${i}.binary`),Vl(n,`${i}.objectMode`),or(t)||or(e)?"asyncGenerator":"generator"},Vl=(t,e)=>{if(t!==void 0&&typeof t!="boolean")throw new TypeError(`The \`${e}\` option must use a boolean.`)},Cx=t=>or(t)||kx(t),or=t=>Object.prototype.toString.call(t)==="[object AsyncGeneratorFunction]",kx=t=>Object.prototype.toString.call(t)==="[object GeneratorFunction]",CD=t=>oe(t)&&(t.transform!==void 0||t.final!==void 0),Ks=t=>Object.prototype.toString.call(t)==="[object URL]",Ix=t=>Ks(t)&&t.protocol!=="file:",AD=t=>oe(t)&&Object.keys(t).length>0&&Object.keys(t).every(e=>PD.has(e))&&Wl(t.file),PD=new Set(["file","append"]),Wl=t=>typeof t=="string",Mx=(t,e)=>t==="native"&&typeof e=="string"&&!_D.has(e),_D=new Set(["ipc","ignore","inherit","overlapped","pipe"]),Dx=t=>Object.prototype.toString.call(t)==="[object ReadableStream]",Xs=t=>Object.prototype.toString.call(t)==="[object WritableStream]",kD=t=>Dx(t)||Xs(t),Hl=t=>Dx(t?.readable)&&Xs(t?.writable),ID=t=>Rx(t)&&typeof t[Symbol.asyncIterator]=="function",MD=t=>Rx(t)&&typeof t[Symbol.iterator]=="function",Rx=t=>typeof t=="object"&&t!==null,je=new Set(["generator","asyncGenerator","duplex","webTransform"]),Zs=new Set(["fileUrl","filePath","fileNumber"]),Jl=new Set(["fileUrl","filePath"]),jx=new Set([...Jl,"webStream","nodeStream"]),Fx=new Set(["webTransform","duplex"]),qt={generator:"a generator",asyncGenerator:"an async generator",fileUrl:"a file URL",filePath:"a file path string",fileNumber:"a file descriptor number",webStream:"a web stream",nodeStream:"a Node.js stream",webTransform:"a web TransformStream",duplex:"a Duplex stream",native:"any value",iterable:"an iterable",asyncIterable:"an async iterable",string:"a string",uint8Array:"a Uint8Array"};var Yl=(t,e,r,n)=>n==="output"?DD(t,e,r):RD(t,e,r),DD=(t,e,r)=>{let n=e!==0&&r[e-1].value.readableObjectMode;return{writableObjectMode:n,readableObjectMode:t??n}},RD=(t,e,r)=>{let n=e===0?t===!0:r[e-1].value.readableObjectMode,i=e!==r.length-1&&(t??n);return{writableObjectMode:n,readableObjectMode:i}},Nx=(t,e)=>{let r=t.findLast(({type:n})=>je.has(n));return r===void 0?!1:e==="input"?r.value.writableObjectMode:r.value.readableObjectMode};var $x=(t,e,r,n)=>[...t.filter(({type:i})=>!je.has(i)),...jD(t,e,r,n)],jD=(t,e,r,{encoding:n})=>{let i=t.filter(({type:o})=>je.has(o)),s=Array.from({length:i.length});for(let[o,a]of Object.entries(i))s[o]=FD({stdioItem:a,index:Number(o),newTransforms:s,optionName:e,direction:r,encoding:n});return GD(s,r)},FD=({stdioItem:t,stdioItem:{type:e},index:r,newTransforms:n,optionName:i,direction:s,encoding:o})=>e==="duplex"?ND({stdioItem:t,optionName:i}):e==="webTransform"?$D({stdioItem:t,index:r,newTransforms:n,direction:s}):LD({stdioItem:t,index:r,newTransforms:n,direction:s,encoding:o}),ND=({stdioItem:t,stdioItem:{value:{transform:e,transform:{writableObjectMode:r,readableObjectMode:n},objectMode:i=n}},optionName:s})=>{if(i&&!n)throw new TypeError(`The \`${s}.objectMode\` option can only be \`true\` if \`new Duplex({objectMode: true})\` is used.`);if(!i&&n)throw new TypeError(`The \`${s}.objectMode\` option cannot be \`false\` if \`new Duplex({objectMode: true})\` is used.`);return{...t,value:{transform:e,writableObjectMode:r,readableObjectMode:n}}},$D=({stdioItem:t,stdioItem:{value:e},index:r,newTransforms:n,direction:i})=>{let{transform:s,objectMode:o}=oe(e)?e:{transform:e},{writableObjectMode:a,readableObjectMode:l}=Yl(o,r,n,i);return{...t,value:{transform:s,writableObjectMode:a,readableObjectMode:l}}},LD=({stdioItem:t,stdioItem:{value:e},index:r,newTransforms:n,direction:i,encoding:s})=>{let{transform:o,final:a,binary:l=!1,preserveNewlines:u=!1,objectMode:c}=oe(e)?e:{transform:e},d=l||ke.has(s),{writableObjectMode:f,readableObjectMode:h}=Yl(c,r,n,i);return{...t,value:{transform:o,final:a,binary:d,preserveNewlines:u,writableObjectMode:f,readableObjectMode:h}}},GD=(t,e)=>e==="input"?t.reverse():t;var Qs=C(require("node:process"),1);var Lx=(t,e,r)=>{let n=t.map(i=>qD(i,e));if(n.includes("input")&&n.includes("output"))throw new TypeError(`The \`${r}\` option must not be an array of both readable and writable values.`);return n.find(Boolean)??VD},qD=({type:t,value:e},r)=>BD[r]??Gx[t](e),BD=["input","output","output"],Vr=()=>{},zl=()=>"input",Gx={generator:Vr,asyncGenerator:Vr,fileUrl:Vr,filePath:Vr,iterable:zl,asyncIterable:zl,uint8Array:zl,webStream:t=>Xs(t)?"output":"input",nodeStream(t){return sr(t,{checkOpen:!1})?Nl(t,{checkOpen:!1})?void 0:"input":"output"},webTransform:Vr,duplex:Vr,native(t){let e=UD(t);if(e!==void 0)return e;if(Ve(t,{checkOpen:!1}))return Gx.nodeStream(t)}},UD=t=>{if([0,Qs.default.stdin].includes(t))return"input";if([1,2,Qs.default.stdout,Qs.default.stderr].includes(t))return"output"},VD="output";var qx=(t,e)=>e&&!t.includes("ipc")?[...t,"ipc"]:t;var Bx=({stdio:t,ipc:e,buffer:r,...n},i,s)=>{let o=WD(t,n).map((a,l)=>Ux(a,l));return s?JD(o,r,i):qx(o,e)},WD=(t,e)=>{if(t===void 0)return Re.map(n=>e[n]);if(HD(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Re.map(n=>`\`${n}\``).join(", ")}`);if(typeof t=="string")return[t,t,t];if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);let r=Math.max(t.length,Re.length);return Array.from({length:r},(n,i)=>t[i])},HD=t=>Re.some(e=>t[e]!==void 0),Ux=(t,e)=>Array.isArray(t)?t.map(r=>Ux(r,e)):t??(e>=Re.length?"ignore":"pipe"),JD=(t,e,r)=>t.map((n,i)=>!e[i]&&i!==0&&!jr(r,i)&&YD(n)?"ignore":n),YD=t=>t==="pipe"||Array.isArray(t)&&t.every(e=>e==="pipe");var Wx=require("node:fs"),Hx=C(require("node:tty"),1);var Jx=({stdioItem:t,stdioItem:{type:e},isStdioArray:r,fdNumber:n,direction:i,isSync:s})=>!r||e!=="native"?t:s?zD({stdioItem:t,fdNumber:n,direction:i}):ZD({stdioItem:t,fdNumber:n}),zD=({stdioItem:t,stdioItem:{value:e,optionName:r},fdNumber:n,direction:i})=>{let s=KD({value:e,optionName:r,fdNumber:n,direction:i});if(s!==void 0)return s;if(Ve(e,{checkOpen:!1}))throw new TypeError(`The \`${r}: Stream\` option cannot both be an array and include a stream with synchronous methods.`);return t},KD=({value:t,optionName:e,fdNumber:r,direction:n})=>{let i=XD(t,r);if(i!==void 0){if(n==="output")return{type:"fileNumber",value:i,optionName:e};if(Hx.default.isatty(i))throw new TypeError(`The \`${e}: ${Cs(t)}\` option is invalid: it cannot be a TTY with synchronous methods.`);return{type:"uint8Array",value:xt((0,Wx.readFileSync)(i)),optionName:e}}},XD=(t,e)=>{if(t==="inherit")return e;if(typeof t=="number")return t;let r=ds.indexOf(t);if(r!==-1)return r},ZD=({stdioItem:t,stdioItem:{value:e,optionName:r},fdNumber:n})=>e==="inherit"?{type:"nodeStream",value:Vx(n,e,r),optionName:r}:typeof e=="number"?{type:"nodeStream",value:Vx(e,e,r),optionName:r}:Ve(e,{checkOpen:!1})?{type:"nodeStream",value:e,optionName:r}:t,Vx=(t,e,r)=>{let n=ds[t];if(n===void 0)throw new TypeError(`The \`${r}: ${e}\` option is invalid: no such standard stream.`);return n};var Yx=({input:t,inputFile:e},r)=>r===0?[...QD(t),...tR(e)]:[],QD=t=>t===void 0?[]:[{type:eR(t),value:t,optionName:"input"}],eR=t=>{if(sr(t,{checkOpen:!1}))return"nodeStream";if(typeof t=="string")return"string";if(ce(t))return"uint8Array";throw new Error("The `input` option must be a string, a Uint8Array or a Node.js Readable stream.")},tR=t=>t===void 0?[]:[{...rR(t),optionName:"inputFile"}],rR=t=>{if(Ks(t))return{type:"fileUrl",value:t};if(Wl(t))return{type:"filePath",value:{file:t}};throw new Error("The `inputFile` option must be a file path string or a file URL.")};var zx=t=>t.filter((e,r)=>t.every((n,i)=>e.value!==n.value||r>=i||e.type==="generator"||e.type==="asyncGenerator")),Kx=({stdioItem:{type:t,value:e,optionName:r},direction:n,fileDescriptors:i,isSync:s})=>{let o=nR(i,t);if(o.length!==0){if(s){iR({otherStdioItems:o,type:t,value:e,optionName:r,direction:n});return}if(jx.has(t))return Xx({otherStdioItems:o,type:t,value:e,optionName:r,direction:n});Fx.has(t)&&oR({otherStdioItems:o,type:t,value:e,optionName:r})}},nR=(t,e)=>t.flatMap(({direction:r,stdioItems:n})=>n.filter(i=>i.type===e).map((i=>({...i,direction:r})))),iR=({otherStdioItems:t,type:e,value:r,optionName:n,direction:i})=>{Jl.has(e)&&Xx({otherStdioItems:t,type:e,value:r,optionName:n,direction:i})},Xx=({otherStdioItems:t,type:e,value:r,optionName:n,direction:i})=>{let s=t.filter(a=>sR(a,r));if(s.length===0)return;let o=s.find(a=>a.direction!==i);return Zx(o,n,e),i==="output"?s[0].stream:void 0},sR=({type:t,value:e},r)=>t==="filePath"?e.file===r.file:t==="fileUrl"?e.href===r.href:e===r,oR=({otherStdioItems:t,type:e,value:r,optionName:n})=>{let i=t.find(({value:{transform:s}})=>s===r.transform);Zx(i,n,e)},Zx=(t,e,r)=>{if(t!==void 0)throw new TypeError(`The \`${t.optionName}\` and \`${e}\` options must not target ${qt[r]} that is the same.`)};var eo=(t,e,r,n)=>{let s=Bx(e,r,n).map((a,l)=>aR({stdioOption:a,fdNumber:l,options:e,isSync:n})),o=mR({initialFileDescriptors:s,addProperties:t,options:e,isSync:n});return e.stdio=o.map(({stdioItems:a})=>wR(a)),o},aR=({stdioOption:t,fdNumber:e,options:r,isSync:n})=>{let i=fs(e),{stdioItems:s,isStdioArray:o}=cR({stdioOption:t,fdNumber:e,options:r,optionName:i}),a=Lx(s,e,i),l=s.map(d=>Jx({stdioItem:d,isStdioArray:o,fdNumber:e,direction:a,isSync:n})),u=$x(l,i,a,r),c=Nx(u,a);return pR(u,c),{direction:a,objectMode:c,stdioItems:u}},cR=({stdioOption:t,fdNumber:e,options:r,optionName:n})=>{let s=[...(Array.isArray(t)?t:[t]).map(l=>lR(l,n)),...Yx(r,e)],o=zx(s),a=o.length>1;return uR(o,a,n),fR(o),{stdioItems:o,isStdioArray:a}},lR=(t,e)=>({type:Ax(t,e),value:t,optionName:e}),uR=(t,e,r)=>{if(t.length===0)throw new TypeError(`The \`${r}\` option must not be an empty array.`);if(e){for(let{value:n,optionName:i}of t)if(dR.has(n))throw new Error(`The \`${i}\` option must not include \`${n}\`.`)}},dR=new Set(["ignore","ipc"]),fR=t=>{for(let e of t)hR(e)},hR=({type:t,value:e,optionName:r})=>{if(Ix(e))throw new TypeError(`The \`${r}: URL\` option must use the \`file:\` scheme.
|
|
226
|
+
For example, you can use the \`pathToFileURL()\` method of the \`url\` core module.`);if(Mx(t,e))throw new TypeError(`The \`${r}: { file: '...' }\` option must be used instead of \`${r}: '...'\`.`)},pR=(t,e)=>{if(!e)return;let r=t.find(({type:n})=>Zs.has(n));if(r!==void 0)throw new TypeError(`The \`${r.optionName}\` option cannot use both files and transforms in objectMode.`)},mR=({initialFileDescriptors:t,addProperties:e,options:r,isSync:n})=>{let i=[];try{for(let s of t)i.push(gR({fileDescriptor:s,fileDescriptors:i,addProperties:e,options:r,isSync:n}));return i}catch(s){throw Kl(i),s}},gR=({fileDescriptor:{direction:t,objectMode:e,stdioItems:r},fileDescriptors:n,addProperties:i,options:s,isSync:o})=>{let a=r.map(l=>yR({stdioItem:l,addProperties:i,direction:t,options:s,fileDescriptors:n,isSync:o}));return{direction:t,objectMode:e,stdioItems:a}},yR=({stdioItem:t,addProperties:e,direction:r,options:n,fileDescriptors:i,isSync:s})=>{let o=Kx({stdioItem:t,direction:r,fileDescriptors:i,isSync:s});return o!==void 0?{...t,stream:o}:{...t,...e[r][t.type](t,n)}},Kl=t=>{for(let{stdioItems:e}of t)for(let{stream:r}of e)r!==void 0&&!qe(r)&&r.destroy()},wR=t=>{if(t.length>1)return t.some(({value:n})=>n==="overlapped")?"overlapped":"pipe";let[{type:e,value:r}]=t;return e==="native"?r:"pipe"};var ev=(t,e)=>eo(SR,t,e,!0),ot=({type:t,optionName:e})=>{tv(e,qt[t])},bR=({optionName:t,value:e})=>((e==="ipc"||e==="overlapped")&&tv(t,`"${e}"`),{}),tv=(t,e)=>{throw new TypeError(`The \`${t}\` option cannot be ${e} with synchronous methods.`)},Qx={generator(){},asyncGenerator:ot,webStream:ot,nodeStream:ot,webTransform:ot,duplex:ot,asyncIterable:ot,native:bR},SR={input:{...Qx,fileUrl:({value:t})=>({contents:[xt((0,Xl.readFileSync)(t))]}),filePath:({value:{file:t}})=>({contents:[xt((0,Xl.readFileSync)(t))]}),fileNumber:ot,iterable:({value:t})=>({contents:[...t]}),string:({value:t})=>({contents:[t]}),uint8Array:({value:t})=>({contents:[t]})},output:{...Qx,fileUrl:({value:t})=>({path:t}),filePath:({value:{file:t,append:e}})=>({path:t,append:e}),fileNumber:({value:t})=>({path:t}),iterable:ot,string:ot,uint8Array:ot}};var Ot=(t,{stripFinalNewline:e},r)=>Zl(e,r)&&t!==void 0&&!Array.isArray(t)?Gr(t):t,Zl=(t,e)=>e==="all"?t[1]||t[2]:t[e];var Bn=require("node:stream");var to=(t,e,r,n)=>t||r?void 0:nv(e,n),eu=(t,e,r)=>r?t.flatMap(n=>rv(n,e)):rv(t,e),rv=(t,e)=>{let{transform:r,final:n}=nv(e,{});return[...r(t),...n()]},nv=(t,e)=>(e.previousChunks="",{transform:xR.bind(void 0,e,t),final:ER.bind(void 0,e)}),xR=function*(t,e,r){if(typeof r!="string"){yield r;return}let{previousChunks:n}=t,i=-1;for(let s=0;s<r.length;s+=1)if(r[s]===`
|
|
227
|
+
`){let o=vR(r,s,e,t),a=r.slice(i+1,s+1-o);n.length>0&&(a=Ql(n,a),n=""),yield a,i=s}i!==r.length-1&&(n=Ql(n,r.slice(i+1))),t.previousChunks=n},vR=(t,e,r,n)=>r?0:(n.isWindowsNewline=e!==0&&t[e-1]==="\r",n.isWindowsNewline?2:1),ER=function*({previousChunks:t}){t.length>0&&(yield t)},iv=({binary:t,preserveNewlines:e,readableObjectMode:r,state:n})=>t||e||r?void 0:{transform:OR.bind(void 0,n)},OR=function*({isWindowsNewline:t=!1},e){let{unixNewline:r,windowsNewline:n,LF:i,concatBytes:s}=typeof e=="string"?TR:AR;if(e.at(-1)===i){yield e;return}yield s(e,t?n:r)},Ql=(t,e)=>`${t}${e}`,TR={windowsNewline:`\r
|
|
228
|
+
`,unixNewline:`
|
|
229
|
+
`,LF:`
|
|
230
|
+
`,concatBytes:Ql},CR=(t,e)=>{let r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r},AR={windowsNewline:new Uint8Array([13,10]),unixNewline:new Uint8Array([10]),LF:10,concatBytes:CR};var sv=require("node:buffer");var ov=(t,e)=>t?void 0:PR.bind(void 0,e),PR=function*(t,e){if(typeof e!="string"&&!ce(e)&&!sv.Buffer.isBuffer(e))throw new TypeError(`The \`${t}\` option's transform must use "objectMode: true" to receive as input: ${typeof e}.`);yield e},av=(t,e)=>t?_R.bind(void 0,e):kR.bind(void 0,e),_R=function*(t,e){cv(t,e),yield e},kR=function*(t,e){if(cv(t,e),typeof e!="string"&&!ce(e))throw new TypeError(`The \`${t}\` option's function must yield a string or an Uint8Array, not ${typeof e}.`);yield e},cv=(t,e)=>{if(e==null)throw new TypeError(`The \`${t}\` option's function must not call \`yield ${e}\`.
|
|
231
|
+
Instead, \`yield\` should either be called with a value, or not be called at all. For example:
|
|
232
|
+
if (condition) { yield value; }`)};var lv=require("node:buffer"),uv=require("node:string_decoder");var ro=(t,e,r)=>{if(r)return;if(t)return{transform:IR.bind(void 0,new TextEncoder)};let n=new uv.StringDecoder(e);return{transform:MR.bind(void 0,n),final:DR.bind(void 0,n)}},IR=function*(t,e){lv.Buffer.isBuffer(e)?yield xt(e):typeof e=="string"?yield t.encode(e):yield e},MR=function*(t,e){yield ce(e)?t.write(e):e},DR=function*(t){let e=t.end();e!==""&&(yield e)};var tu=require("node:util"),ru=(0,tu.callbackify)(async(t,e,r,n)=>{e.currentIterable=t(...r);try{for await(let i of e.currentIterable)n.push(i)}finally{delete e.currentIterable}}),no=async function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=jR}=e[r];for await(let i of n(t))yield*no(i,e,r+1)},dv=async function*(t){for(let[e,{final:r}]of Object.entries(t))yield*RR(r,Number(e),t)},RR=async function*(t,e,r){if(t!==void 0)for await(let n of t())yield*no(n,r,e+1)},fv=(0,tu.callbackify)(async({currentIterable:t},e)=>{if(t!==void 0){await(e?t.throw(e):t.return());return}if(e)throw e}),jR=function*(t){yield t};var nu=(t,e,r,n)=>{try{for(let i of t(...e))r.push(i);n()}catch(i){n(i)}},hv=(t,e)=>[...e.flatMap(r=>[...ar(r,t,0)]),...qn(t)],ar=function*(t,e,r){if(r===e.length){yield t;return}let{transform:n=NR}=e[r];for(let i of n(t))yield*ar(i,e,r+1)},qn=function*(t){for(let[e,{final:r}]of Object.entries(t))yield*FR(r,Number(e),t)},FR=function*(t,e,r){if(t!==void 0)for(let n of t())yield*ar(n,r,e+1)},NR=function*(t){yield t};var iu=({value:t,value:{transform:e,final:r,writableObjectMode:n,readableObjectMode:i},optionName:s},{encoding:o})=>{let a={},l=pv(t,o,s),u=or(e),c=or(r),d=u?ru.bind(void 0,no,a):nu.bind(void 0,ar),f=u||c?ru.bind(void 0,dv,a):nu.bind(void 0,qn),h=u||c?fv.bind(void 0,a):void 0;return{stream:new Bn.Transform({writableObjectMode:n,writableHighWaterMark:(0,Bn.getDefaultHighWaterMark)(n),readableObjectMode:i,readableHighWaterMark:(0,Bn.getDefaultHighWaterMark)(i),transform(y,x,b){d([y,l,0],this,b)},flush(y){f([l],this,y)},destroy:h})}},io=(t,e,r,n)=>{let i=e.filter(({type:o})=>o==="generator"),s=n?i.reverse():i;for(let{value:o,optionName:a}of s){let l=pv(o,r,a);t=hv(l,t)}return t},pv=({transform:t,final:e,binary:r,writableObjectMode:n,readableObjectMode:i,preserveNewlines:s},o,a)=>{let l={};return[{transform:ov(n,a)},ro(r,o,n),to(r,s,n,l),{transform:t,final:e},{transform:av(i,a)},iv({binary:r,preserveNewlines:s,readableObjectMode:i,state:l})].filter(Boolean)};var mv=(t,e)=>{for(let r of $R(t))LR(t,r,e)},$R=t=>new Set(Object.entries(t).filter(([,{direction:e}])=>e==="input").map(([e])=>Number(e))),LR=(t,e,r)=>{let{stdioItems:n}=t[e],i=n.filter(({contents:a})=>a!==void 0);if(i.length===0)return;if(e!==0){let[{type:a,optionName:l}]=i;throw new TypeError(`Only the \`stdin\` option, not \`${l}\`, can be ${qt[a]} with synchronous methods.`)}let o=i.map(({contents:a})=>a).map(a=>GR(a,n));r.input=In(o)},GR=(t,e)=>{let r=io(t,e,"utf8",!0);return qR(r),In(r)},qR=t=>{let e=t.find(r=>typeof r!="string"&&!ce(r));if(e!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${e}.`)};var oo=require("node:fs");var so=({stdioItems:t,encoding:e,verboseInfo:r,fdNumber:n})=>n!=="all"&&jr(r,n)&&!ke.has(e)&&BR(n)&&(t.some(({type:i,value:s})=>i==="native"&&UR.has(s))||t.every(({type:i})=>je.has(i))),BR=t=>t===1||t===2,UR=new Set(["pipe","overlapped"]),gv=async(t,e,r,n)=>{for await(let i of t)VR(e)||wv(i,r,n)},yv=(t,e,r)=>{for(let n of t)wv(n,e,r)},VR=t=>t._readableState.pipes.length>0,wv=(t,e,r)=>{let n=ys(t);rt({type:"output",verboseMessage:n,fdNumber:e,verboseInfo:r})};var bv=({fileDescriptors:t,syncResult:{output:e},options:r,isMaxBuffer:n,verboseInfo:i})=>{if(e===null)return{output:Array.from({length:3})};let s={},o=new Set([]);return{output:e.map((l,u)=>WR({result:l,fileDescriptors:t,fdNumber:u,state:s,outputFiles:o,isMaxBuffer:n,verboseInfo:i},r)),...s}},WR=({result:t,fileDescriptors:e,fdNumber:r,state:n,outputFiles:i,isMaxBuffer:s,verboseInfo:o},{buffer:a,encoding:l,lines:u,stripFinalNewline:c,maxBuffer:d})=>{if(t===null)return;let f=yx(t,s,d),h=xt(f),{stdioItems:p,objectMode:y}=e[r],x=HR([h],p,l,n),{serializedResult:b,finalResult:S=b}=JR({chunks:x,objectMode:y,encoding:l,lines:u,stripFinalNewline:c,fdNumber:r});YR({serializedResult:b,fdNumber:r,state:n,verboseInfo:o,encoding:l,stdioItems:p,objectMode:y});let g=a[r]?S:void 0;try{return n.error===void 0&&zR(b,p,i),g}catch(v){return n.error=v,g}},HR=(t,e,r,n)=>{try{return io(t,e,r,!1)}catch(i){return n.error=i,t}},JR=({chunks:t,objectMode:e,encoding:r,lines:n,stripFinalNewline:i,fdNumber:s})=>{if(e)return{serializedResult:t};if(r==="buffer")return{serializedResult:In(t)};let o=tb(t,r);return n[s]?{serializedResult:o,finalResult:eu(o,!i[s],e)}:{serializedResult:o}},YR=({serializedResult:t,fdNumber:e,state:r,verboseInfo:n,encoding:i,stdioItems:s,objectMode:o})=>{if(!so({stdioItems:s,encoding:i,verboseInfo:n,fdNumber:e}))return;let a=eu(t,!1,o);try{yv(a,e,n)}catch(l){r.error??=l}},zR=(t,e,r)=>{for(let{path:n,append:i}of e.filter(({type:s})=>Zs.has(s))){let s=typeof n=="string"?n:n.toString();i||r.has(s)?(0,oo.appendFileSync)(n,t):(r.add(s),(0,oo.writeFileSync)(n,t))}};var Sv=([,t,e],r)=>{if(r.all)return t===void 0?e:e===void 0?t:Array.isArray(t)?Array.isArray(e)?[...t,...e]:[...t,Ot(e,r,"all")]:Array.isArray(e)?[Ot(t,r,"all"),...e]:ce(t)&&ce(e)?ml([t,e]):`${t}${e}`};var ao=require("node:events");var xv=async(t,e)=>{let[r,n]=await KR(t);return e.isForcefullyTerminated??=!1,[r,n]},KR=async t=>{let[e,r]=await Promise.allSettled([(0,ao.once)(t,"spawn"),(0,ao.once)(t,"exit")]);return e.status==="rejected"?[]:r.status==="rejected"?vv(t):r.value},vv=async t=>{try{return await(0,ao.once)(t,"exit")}catch{return vv(t)}},Ev=async t=>{let[e,r]=await t;if(!XR(e,r)&&su(e,r))throw new Be;return[e,r]},XR=(t,e)=>t===void 0&&e===void 0,su=(t,e)=>t!==0||e!==null;var Ov=({error:t,status:e,signal:r,output:n},{maxBuffer:i})=>{let s=ZR(t,e,r),o=s?.code==="ETIMEDOUT",a=gx(s,n,i);return{resultError:s,exitCode:e,signal:r,timedOut:o,isMaxBuffer:a}},ZR=(t,e,r)=>t!==void 0?t:su(e,r)?new Be:void 0;var Cv=(t,e,r)=>{let{file:n,commandArguments:i,command:s,escapedCommand:o,startTime:a,verboseInfo:l,options:u,fileDescriptors:c}=QR(t,e,r),d=rj({file:n,commandArguments:i,options:u,command:s,escapedCommand:o,verboseInfo:l,fileDescriptors:c,startTime:a});return Ur(d,l,u)},QR=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=bs(t,e,r),a=ej(r),{file:l,commandArguments:u,options:c}=Ls(t,e,a);tj(c);let d=ev(c,o);return{file:l,commandArguments:u,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:c,fileDescriptors:d}},ej=t=>t.node&&!t.ipc?{...t,ipc:!1}:t,tj=({ipc:t,ipcInput:e,detached:r,cancelSignal:n})=>{e&&co("ipcInput"),t&&co("ipc: true"),r&&co("detached: true"),n&&co("cancelSignal")},co=t=>{throw new TypeError(`The "${t}" option cannot be used with synchronous methods.`)},rj=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,verboseInfo:s,fileDescriptors:o,startTime:a})=>{let l=nj({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:o,startTime:a});if(l.failed)return l;let{resultError:u,exitCode:c,signal:d,timedOut:f,isMaxBuffer:h}=Ov(l,r),{output:p,error:y=u}=bv({fileDescriptors:o,syncResult:l,options:r,isMaxBuffer:h,verboseInfo:s}),x=p.map((S,g)=>Ot(S,r,g)),b=Ot(Sv(p,r),r,"all");return sj({error:y,exitCode:c,signal:d,timedOut:f,isMaxBuffer:h,stdio:x,all:b,options:r,command:n,escapedCommand:i,startTime:a})},nj=({file:t,commandArguments:e,options:r,command:n,escapedCommand:i,fileDescriptors:s,startTime:o})=>{try{mv(s,r);let a=ij(r);return(0,Tv.spawnSync)(...Gs(t,e,a))}catch(a){return Br({error:a,command:n,escapedCommand:i,fileDescriptors:s,options:r,startTime:o,isSync:!0})}},ij=({encoding:t,maxBuffer:e,...r})=>({...r,encoding:"buffer",maxBuffer:Ys(e)}),sj=({error:t,exitCode:e,signal:r,timedOut:n,isMaxBuffer:i,stdio:s,all:o,options:a,command:l,escapedCommand:u,startTime:c})=>t===void 0?zs({command:l,escapedCommand:u,stdio:s,all:o,ipcOutput:[],options:a,startTime:c}):Gn({error:t,command:l,escapedCommand:u,timedOut:n,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:i,isForcefullyTerminated:!1,exitCode:e,signal:r,stdio:s,all:o,ipcOutput:[],options:a,startTime:c,isSync:!0});var DE=require("node:events"),RE=require("node:child_process");var au=C(require("node:process"),1);var Wr=require("node:events");var Av=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0,filter:s}={})=>(Nr({methodName:"getOneMessage",isSubprocess:r,ipc:n,isConnected:Ms(t)}),oj({anyProcess:t,channel:e,isSubprocess:r,filter:s,reference:i})),oj=async({anyProcess:t,channel:e,isSubprocess:r,filter:n,reference:i})=>{Ps(e,i);let s=Gt(t,e,r),o=new AbortController;try{return await Promise.race([aj(s,n,o),cj(s,r,o),lj(s,r,o)])}catch(a){throw $r(t),a}finally{o.abort(),_s(e,i)}},aj=async(t,e,{signal:r})=>{if(e===void 0){let[n]=await(0,Wr.once)(t,"message",{signal:r});return n}for await(let[n]of(0,Wr.on)(t,"message",{signal:r}))if(e(n))return n},cj=async(t,e,{signal:r})=>{await(0,Wr.once)(t,"disconnect",{signal:r}),Kb(e)},lj=async(t,e,{signal:r})=>{let[n]=await(0,Wr.once)(t,"strict:error",{signal:r});throw Ts(n,e)};var Un=require("node:events");var _v=({anyProcess:t,channel:e,isSubprocess:r,ipc:n},{reference:i=!0}={})=>ou({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:!r,reference:i}),ou=({anyProcess:t,channel:e,isSubprocess:r,ipc:n,shouldAwait:i,reference:s})=>{Nr({methodName:"getEachMessage",isSubprocess:r,ipc:n,isConnected:Ms(t)}),Ps(e,s);let o=Gt(t,e,r),a=new AbortController,l={};return uj(t,o,a),dj({ipcEmitter:o,isSubprocess:r,controller:a,state:l}),fj({anyProcess:t,channel:e,ipcEmitter:o,isSubprocess:r,shouldAwait:i,controller:a,state:l,reference:s})},uj=async(t,e,r)=>{try{await(0,Un.once)(e,"disconnect",{signal:r.signal}),r.abort()}catch{}},dj=async({ipcEmitter:t,isSubprocess:e,controller:r,state:n})=>{try{let[i]=await(0,Un.once)(t,"strict:error",{signal:r.signal});n.error=Ts(i,e),r.abort()}catch{}},fj=async function*({anyProcess:t,channel:e,ipcEmitter:r,isSubprocess:n,shouldAwait:i,controller:s,state:o,reference:a}){try{for await(let[l]of(0,Un.on)(r,"message",{signal:s.signal}))Pv(o),yield l}catch{Pv(o)}finally{s.abort(),_s(e,a),n||$r(t),i&&await t}},Pv=({error:t})=>{if(t)throw t};var kv=(t,{ipc:e})=>{Object.assign(t,Mv(t,!1,e))},Iv=()=>{let t=au.default,e=!0,r=au.default.channel!==void 0;return{...Mv(t,e,r),getCancelSignal:kS.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})}},Mv=(t,e,r)=>({sendMessage:Fs.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getOneMessage:Av.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r}),getEachMessage:_v.bind(void 0,{anyProcess:t,channel:t.channel,isSubprocess:e,ipc:r})});var Dv=require("node:child_process"),Bt=require("node:stream");var Rv=({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,verboseInfo:o})=>{Kl(n);let a=new Dv.ChildProcess;hj(a,n),Object.assign(a,{readable:pj,writable:mj,duplex:gj});let l=Br({error:t,command:e,escapedCommand:r,fileDescriptors:n,options:i,startTime:s,isSync:!1}),u=yj(l,o,i);return{subprocess:a,promise:u}},hj=(t,e)=>{let r=Vn(),n=Vn(),i=Vn(),s=Array.from({length:e.length-3},Vn),o=Vn(),a=[r,n,i,...s];Object.assign(t,{stdin:r,stdout:n,stderr:i,all:o,stdio:a})},Vn=()=>{let t=new Bt.PassThrough;return t.end(),t},pj=()=>new Bt.Readable({read(){}}),mj=()=>new Bt.Writable({write(){}}),gj=()=>new Bt.Duplex({read(){},write(){}}),yj=async(t,e,r)=>Ur(t,e,r);var Hr=require("node:fs"),Fv=require("node:buffer"),at=require("node:stream");var Nv=(t,e)=>eo(wj,t,e,!1),Wn=({type:t,optionName:e})=>{throw new TypeError(`The \`${e}\` option cannot be ${qt[t]}.`)},jv={fileNumber:Wn,generator:iu,asyncGenerator:iu,nodeStream:({value:t})=>({stream:t}),webTransform({value:{transform:t,writableObjectMode:e,readableObjectMode:r}}){let n=e||r;return{stream:at.Duplex.fromWeb(t,{objectMode:n})}},duplex:({value:{transform:t}})=>({stream:t}),native(){}},wj={input:{...jv,fileUrl:({value:t})=>({stream:(0,Hr.createReadStream)(t)}),filePath:({value:{file:t}})=>({stream:(0,Hr.createReadStream)(t)}),webStream:({value:t})=>({stream:at.Readable.fromWeb(t)}),iterable:({value:t})=>({stream:at.Readable.from(t)}),asyncIterable:({value:t})=>({stream:at.Readable.from(t)}),string:({value:t})=>({stream:at.Readable.from(t)}),uint8Array:({value:t})=>({stream:at.Readable.from(Fv.Buffer.from(t))})},output:{...jv,fileUrl:({value:t})=>({stream:(0,Hr.createWriteStream)(t)}),filePath:({value:{file:t,append:e}})=>({stream:(0,Hr.createWriteStream)(t,e?{flags:"a"}:{})}),webStream:({value:t})=>({stream:at.Writable.fromWeb(t)}),iterable:Wn,asyncIterable:Wn,string:Wn,uint8Array:Wn}};var Hn=require("node:events"),uo=require("node:stream"),uu=require("node:stream/promises");function cr(t){if(!Array.isArray(t))throw new TypeError(`Expected an array, got \`${typeof t}\`.`);for(let i of t)lu(i);let e=t.some(({readableObjectMode:i})=>i),r=bj(t,e),n=new cu({objectMode:e,writableHighWaterMark:r,readableHighWaterMark:r});for(let i of t)n.add(i);return n}var bj=(t,e)=>{if(t.length===0)return(0,uo.getDefaultHighWaterMark)(e);let r=t.filter(({readableObjectMode:n})=>n===e).map(({readableHighWaterMark:n})=>n);return Math.max(...r)},cu=class extends uo.PassThrough{#i=new Set([]);#n=new Set([]);#t=new Set([]);#e;#s=Symbol("unpipe");#r=new WeakMap;add(e){if(lu(e),this.#i.has(e))return;this.#i.add(e),this.#e??=Sj(this,this.#i,this.#s);let r=Ej({passThroughStream:this,stream:e,streams:this.#i,ended:this.#n,aborted:this.#t,onFinished:this.#e,unpipeEvent:this.#s});this.#r.set(e,r),e.pipe(this,{end:!1})}async remove(e){if(lu(e),!this.#i.has(e))return!1;let r=this.#r.get(e);return r===void 0?!1:(this.#r.delete(e),e.unpipe(this),await r,!0)}},Sj=async(t,e,r)=>{lo(t,$v);let n=new AbortController;try{await Promise.race([xj(t,n),vj(t,e,r,n)])}finally{n.abort(),lo(t,-$v)}},xj=async(t,{signal:e})=>{try{await(0,uu.finished)(t,{signal:e,cleanup:!0})}catch(r){throw Gv(t,r),r}},vj=async(t,e,r,{signal:n})=>{for await(let[i]of(0,Hn.on)(t,"unpipe",{signal:n}))e.has(i)&&i.emit(r)},lu=t=>{if(typeof t?.pipe!="function")throw new TypeError(`Expected a readable stream, got: \`${typeof t}\`.`)},Ej=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,onFinished:s,unpipeEvent:o})=>{lo(t,Lv);let a=new AbortController;try{await Promise.race([Oj(s,e,a),Tj({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:a}),Cj({stream:e,streams:r,ended:n,aborted:i,unpipeEvent:o,controller:a})])}finally{a.abort(),lo(t,-Lv)}r.size>0&&r.size===n.size+i.size&&(n.size===0&&i.size>0?du(t):Aj(t))},Oj=async(t,e,{signal:r})=>{try{await t,r.aborted||du(e)}catch(n){r.aborted||Gv(e,n)}},Tj=async({passThroughStream:t,stream:e,streams:r,ended:n,aborted:i,controller:{signal:s}})=>{try{await(0,uu.finished)(e,{signal:s,cleanup:!0,readable:!0,writable:!1}),r.has(e)&&n.add(e)}catch(o){if(s.aborted||!r.has(e))return;qv(o)?i.add(e):Bv(t,o)}},Cj=async({stream:t,streams:e,ended:r,aborted:n,unpipeEvent:i,controller:{signal:s}})=>{if(await(0,Hn.once)(t,i,{signal:s}),!t.readable)return(0,Hn.once)(s,"abort",{signal:s});e.delete(t),r.delete(t),n.delete(t)},Aj=t=>{t.writable&&t.end()},Gv=(t,e)=>{qv(e)?du(t):Bv(t,e)},qv=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",du=t=>{(t.readable||t.writable)&&t.destroy()},Bv=(t,e)=>{t.destroyed||(t.once("error",Pj),t.destroy(e))},Pj=()=>{},lo=(t,e)=>{let r=t.getMaxListeners();r!==0&&r!==Number.POSITIVE_INFINITY&&t.setMaxListeners(r+e)},$v=2,Lv=1;var fu=require("node:stream/promises");var Jr=(t,e)=>{t.pipe(e),_j(t,e),kj(t,e)},_j=async(t,e)=>{if(!(qe(t)||qe(e))){try{await(0,fu.finished)(t,{cleanup:!0,readable:!0,writable:!1})}catch{}hu(e)}},hu=t=>{t.writable&&t.end()},kj=async(t,e)=>{if(!(qe(t)||qe(e))){try{await(0,fu.finished)(e,{cleanup:!0,readable:!1,writable:!0})}catch{}pu(t)}},pu=t=>{t.readable&&t.destroy()};var Uv=(t,e,r)=>{let n=new Map;for(let[i,{stdioItems:s,direction:o}]of Object.entries(e)){for(let{stream:a}of s.filter(({type:l})=>je.has(l)))Ij(t,a,o,i);for(let{stream:a}of s.filter(({type:l})=>!je.has(l)))Dj({subprocess:t,stream:a,direction:o,fdNumber:i,pipeGroups:n,controller:r})}for(let[i,s]of n.entries()){let o=s.length===1?s[0]:cr(s);Jr(o,i)}},Ij=(t,e,r,n)=>{r==="output"?Jr(t.stdio[n],e):Jr(e,t.stdio[n]);let i=Mj[n];i!==void 0&&(t[i]=e),t.stdio[n]=e},Mj=["stdin","stdout","stderr"],Dj=({subprocess:t,stream:e,direction:r,fdNumber:n,pipeGroups:i,controller:s})=>{if(e===void 0)return;Rj(e,s);let[o,a]=r==="output"?[e,t.stdio[n]]:[t.stdio[n],e],l=i.get(o)??[];i.set(o,[...l,a])},Rj=(t,{signal:e})=>{qe(t)&&ir(t,jj,e)},jj=2;var Vv=require("node:events");var Wv=(t,{cleanup:e,detached:r},{signal:n})=>{if(!e||r)return;let i=Ni(()=>{t.kill()});(0,Vv.addAbortListener)(n,()=>{i()})};var Jv=({source:t,sourcePromise:e,boundOptions:r,createNested:n},...i)=>{let s=ws(),{destination:o,destinationStream:a,destinationError:l,from:u,unpipeSignal:c}=Fj(r,n,i),{sourceStream:d,sourceError:f}=$j(t,u),{options:h,fileDescriptors:p}=it.get(t);return{sourcePromise:e,sourceStream:d,sourceOptions:h,sourceError:f,destination:o,destinationStream:a,destinationError:l,unpipeSignal:c,fileDescriptors:p,startTime:s}},Fj=(t,e,r)=>{try{let{destination:n,pipeOptions:{from:i,to:s,unpipeSignal:o}={}}=Nj(t,e,...r),a=As(n,s);return{destination:n,destinationStream:a,from:i,unpipeSignal:o}}catch(n){return{destinationError:n}}},Nj=(t,e,r,...n)=>{if(Array.isArray(r))return{destination:e(Hv,t)(r,...n),pipeOptions:t};if(typeof r=="string"||r instanceof URL||hl(r)){if(Object.keys(t).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[i,s,o]=cs(r,...n);return{destination:e(Hv)(i,s,o),pipeOptions:o}}if(it.has(r)){if(Object.keys(t).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:r,pipeOptions:n[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${r}`)},Hv=({options:t})=>({options:{...t,stdin:"pipe",piped:!0}}),$j=(t,e)=>{try{return{sourceStream:Lr(t,e)}}catch(r){return{sourceError:r}}};var zv=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n,fileDescriptors:i,sourceOptions:s,startTime:o})=>{let a=Lj({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n});if(a!==void 0)throw mu({error:a,fileDescriptors:i,sourceOptions:s,startTime:o})},Lj=({sourceStream:t,sourceError:e,destinationStream:r,destinationError:n})=>{if(e!==void 0&&n!==void 0)return n;if(n!==void 0)return pu(t),n;if(e!==void 0)return hu(r),e},mu=({error:t,fileDescriptors:e,sourceOptions:r,startTime:n})=>Br({error:t,command:Yv,escapedCommand:Yv,fileDescriptors:e,options:r,startTime:n,isSync:!1}),Yv="source.pipe(destination)";var Kv=async t=>{let[{status:e,reason:r,value:n=r},{status:i,reason:s,value:o=s}]=await t;if(o.pipedFrom.includes(n)||o.pipedFrom.push(n),i==="rejected")throw o;if(e==="rejected")throw n;return o};var Xv=require("node:stream/promises");var Zv=(t,e,r)=>{let n=fo.has(e)?qj(t,e):Gj(t,e);return ir(t,Uj,r.signal),ir(e,Vj,r.signal),Bj(e),n},Gj=(t,e)=>{let r=cr([t]);return Jr(r,e),fo.set(e,r),r},qj=(t,e)=>{let r=fo.get(e);return r.add(t),r},Bj=async t=>{try{await(0,Xv.finished)(t,{cleanup:!0,readable:!1,writable:!0})}catch{}fo.delete(t)},fo=new WeakMap,Uj=2,Vj=1;var Qv=require("node:util");var eE=(t,e)=>t===void 0?[]:[Wj(t,e)],Wj=async(t,{sourceStream:e,mergedStream:r,fileDescriptors:n,sourceOptions:i,startTime:s})=>{await(0,Qv.aborted)(t,e),await r.remove(e);let o=new Error("Pipe canceled by `unpipeSignal` option.");throw mu({error:o,fileDescriptors:n,sourceOptions:i,startTime:s})};var ho=(t,...e)=>{if(oe(e[0]))return ho.bind(void 0,{...t,boundOptions:{...t.boundOptions,...e[0]}});let{destination:r,...n}=Jv(t,...e),i=Hj({...n,destination:r});return i.pipe=ho.bind(void 0,{...t,source:r,sourcePromise:i,boundOptions:{}}),i},Hj=async({sourcePromise:t,sourceStream:e,sourceOptions:r,sourceError:n,destination:i,destinationStream:s,destinationError:o,unpipeSignal:a,fileDescriptors:l,startTime:u})=>{let c=Jj(t,i);zv({sourceStream:e,sourceError:n,destinationStream:s,destinationError:o,fileDescriptors:l,sourceOptions:r,startTime:u});let d=new AbortController;try{let f=Zv(e,s,d);return await Promise.race([Kv(c),...eE(a,{sourceStream:e,mergedStream:f,sourceOptions:r,fileDescriptors:l,startTime:u})])}finally{d.abort()}},Jj=(t,e)=>Promise.allSettled([t,e]);var sE=require("node:timers/promises");var rE=require("node:events"),nE=require("node:stream");var po=({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:n,encoding:i,preserveNewlines:s})=>{let o=new AbortController;return Yj(e,o),iE({stream:t,controller:o,binary:r,shouldEncode:!t.readableObjectMode&&n,encoding:i,shouldSplit:!t.readableObjectMode,preserveNewlines:s})},Yj=async(t,e)=>{try{await t}catch{}finally{e.abort()}},gu=({stream:t,onStreamEnd:e,lines:r,encoding:n,stripFinalNewline:i,allMixed:s})=>{let o=new AbortController;zj(e,o,t);let a=t.readableObjectMode&&!s;return iE({stream:t,controller:o,binary:n==="buffer",shouldEncode:!a,encoding:n,shouldSplit:!a&&r,preserveNewlines:!i})},zj=async(t,e,r)=>{try{await t}catch{r.destroy()}finally{e.abort()}},iE=({stream:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})=>{let a=(0,rE.on)(t,"data",{signal:e.signal,highWaterMark:tE,highWatermark:tE});return Kj({onStdoutChunk:a,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o})},yu=(0,nE.getDefaultHighWaterMark)(!0),tE=yu,Kj=async function*({onStdoutChunk:t,controller:e,binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o}){let a=Xj({binary:r,shouldEncode:n,encoding:i,shouldSplit:s,preserveNewlines:o});try{for await(let[l]of t)yield*ar(l,a,0)}catch(l){if(!e.signal.aborted)throw l}finally{yield*qn(a)}},Xj=({binary:t,shouldEncode:e,encoding:r,shouldSplit:n,preserveNewlines:i})=>[ro(t,r,!e),to(t,i,!n,{})].filter(Boolean);var oE=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,buffer:i,maxBuffer:s,lines:o,allMixed:a,stripFinalNewline:l,verboseInfo:u,streamInfo:c})=>{let d=Zj({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:a,verboseInfo:u,streamInfo:c});if(!i){await Promise.all([Qj(t),d]);return}let f=Zl(l,r),h=gu({stream:t,onStreamEnd:e,lines:o,encoding:n,stripFinalNewline:f,allMixed:a}),[p]=await Promise.all([eF({stream:t,iterable:h,fdNumber:r,encoding:n,maxBuffer:s,lines:o}),d]);return p},Zj=async({stream:t,onStreamEnd:e,fdNumber:r,encoding:n,allMixed:i,verboseInfo:s,streamInfo:{fileDescriptors:o}})=>{if(!so({stdioItems:o[r]?.stdioItems,encoding:n,verboseInfo:s,fdNumber:r}))return;let a=gu({stream:t,onStreamEnd:e,lines:!0,encoding:n,stripFinalNewline:!0,allMixed:i});await gv(a,t,r,s)},Qj=async t=>{await(0,sE.setImmediate)(),t.readableFlowing===null&&t.resume()},eF=async({stream:t,stream:{readableObjectMode:e},iterable:r,fdNumber:n,encoding:i,maxBuffer:s,lines:o})=>{try{return e||o?await Vs(r,{maxBuffer:s}):i==="buffer"?new Uint8Array(await Ws(r,{maxBuffer:s})):await Js(r,{maxBuffer:s})}catch(a){return aE(hx({error:a,stream:t,readableObjectMode:e,lines:o,encoding:i,fdNumber:n}))}},wu=async t=>{try{return await t}catch(e){return aE(e)}},aE=({bufferedData:t})=>Qw(t)?new Uint8Array(t):t;var lE=require("node:stream/promises"),Jn=async(t,e,r,{isSameDirection:n,stopOnExit:i=!1}={})=>{let s=tF(t,r),o=new AbortController;try{await Promise.race([...i?[r.exitPromise]:[],(0,lE.finished)(t,{cleanup:!0,signal:o.signal})])}catch(a){s.stdinCleanedUp||iF(a,e,r,n)}finally{o.abort()}},tF=(t,{originalStreams:[e],subprocess:r})=>{let n={stdinCleanedUp:!1};return t===e&&rF(t,r,n),n},rF=(t,e,r)=>{let{_destroy:n}=t;t._destroy=(...i)=>{nF(e,r),n.call(t,...i)}},nF=({exitCode:t,signalCode:e},r)=>{(t!==null||e!==null)&&(r.stdinCleanedUp=!0)},iF=(t,e,r,n)=>{if(!sF(t,e,r,n))throw t},sF=(t,e,r,n=!0)=>r.propagating?cE(t)||mo(t):(r.propagating=!0,bu(r,e)===n?cE(t):mo(t)),bu=({fileDescriptors:t},e)=>e!=="all"&&t[e].direction==="input",mo=t=>t?.code==="ERR_STREAM_PREMATURE_CLOSE",cE=t=>t?.code==="EPIPE";var uE=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>t.stdio.map((l,u)=>Su({stream:l,fdNumber:u,encoding:e,buffer:r[u],maxBuffer:n[u],lines:i[u],allMixed:!1,stripFinalNewline:s,verboseInfo:o,streamInfo:a})),Su=async({stream:t,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:l,streamInfo:u})=>{if(!t)return;let c=Jn(t,e,u);if(bu(u,e)){await c;return}let[d]=await Promise.all([oE({stream:t,onStreamEnd:c,fdNumber:e,encoding:r,buffer:n,maxBuffer:i,lines:s,allMixed:o,stripFinalNewline:a,verboseInfo:l,streamInfo:u}),c]);return d};var dE=({stdout:t,stderr:e},{all:r})=>r&&(t||e)?cr([t,e].filter(Boolean)):void 0,fE=({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:s,verboseInfo:o,streamInfo:a})=>Su({...oF(t,r),fdNumber:"all",encoding:e,maxBuffer:n[1]+n[2],lines:i[1]||i[2],allMixed:aF(t),stripFinalNewline:s,verboseInfo:o,streamInfo:a}),oF=({stdout:t,stderr:e,all:r},[,n,i])=>{let s=n||i;return s?n?i?{stream:r,buffer:s}:{stream:t,buffer:s}:{stream:e,buffer:s}:{stream:r,buffer:s}},aF=({all:t,stdout:e,stderr:r})=>t&&e&&r&&e.readableObjectMode!==r.readableObjectMode;var yE=require("node:events");var hE=t=>jr(t,"ipc"),pE=(t,e)=>{let r=ys(t);rt({type:"ipc",verboseMessage:r,fdNumber:"ipc",verboseInfo:e})};var mE=async({subprocess:t,buffer:e,maxBuffer:r,ipc:n,ipcOutput:i,verboseInfo:s})=>{if(!n)return i;let o=hE(s),a=vt(e,"ipc"),l=vt(r,"ipc");for await(let u of ou({anyProcess:t,channel:t.channel,isSubprocess:!1,ipc:n,shouldAwait:!1,reference:!0}))a&&(px(t,i,l),i.push(u)),o&&pE(u,s);return i},gE=async(t,e)=>(await Promise.allSettled([t]),e);var wE=async({subprocess:t,options:{encoding:e,buffer:r,maxBuffer:n,lines:i,timeoutDuration:s,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:l,stripFinalNewline:u,ipc:c,ipcInput:d},context:f,verboseInfo:h,fileDescriptors:p,originalStreams:y,onInternalError:x,controller:b})=>{let S=xv(t,f),g={originalStreams:y,fileDescriptors:p,subprocess:t,exitPromise:S,propagating:!1},v=uE({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:h,streamInfo:g}),E=fE({subprocess:t,encoding:e,buffer:r,maxBuffer:n,lines:i,stripFinalNewline:u,verboseInfo:h,streamInfo:g}),T=[],j=mE({subprocess:t,buffer:r,maxBuffer:n,ipc:c,ipcOutput:T,verboseInfo:h}),$=cF(y,t,g),A=lF(p,g);try{return await Promise.race([Promise.all([{},Ev(S),Promise.all(v),E,j,qS(t,d),...$,...A]),x,uF(t,b),...FS(t,s,f,b),...zb({subprocess:t,cancelSignal:o,gracefulCancel:a,context:f,controller:b}),...DS({subprocess:t,cancelSignal:o,gracefulCancel:a,forceKillAfterDelay:l,context:f,controller:b})])}catch(D){return f.terminationReason??="other",Promise.all([{error:D},S,Promise.all(v.map(k=>wu(k))),wu(E),gE(j,T),Promise.allSettled($),Promise.allSettled(A)])}},cF=(t,e,r)=>t.map((n,i)=>n===e.stdio[i]?void 0:Jn(n,i,r)),lF=(t,e)=>t.flatMap(({stdioItems:r},n)=>r.filter(({value:i,stream:s=i})=>Ve(s,{checkOpen:!1})&&!qe(s)).map(({type:i,value:s,stream:o=s})=>Jn(o,n,e,{isSameDirection:je.has(i),stopOnExit:i==="native"}))),uF=async(t,{signal:e})=>{let[r]=await(0,yE.once)(t,"error",{signal:e});throw r};var bE=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),Yn=(t,e,r)=>{let n=t[r];n.has(e)||n.set(e,[]);let i=n.get(e),s=nt();return i.push(s),{resolve:s.resolve.bind(s),promises:i}},Yr=async({resolve:t,promises:e},r)=>{t();let[n]=await Promise.race([Promise.allSettled([!0,r]),Promise.all([!1,...e])]);return!n};var xE=require("node:stream"),vE=require("node:util");var xu=require("node:stream/promises");var vu=async t=>{if(t!==void 0)try{await Eu(t)}catch{}},SE=async t=>{if(t!==void 0)try{await Ou(t)}catch{}},Eu=async t=>{await(0,xu.finished)(t,{cleanup:!0,readable:!1,writable:!0})},Ou=async t=>{await(0,xu.finished)(t,{cleanup:!0,readable:!0,writable:!1})},go=async(t,e)=>{if(await t,e)throw e},yo=(t,e,r)=>{r&&!mo(r)?t.destroy(r):e&&t.destroy()};var EE=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,binary:i=!0,preserveNewlines:s=!0}={})=>{let o=i||ke.has(r),{subprocessStdout:a,waitReadableDestroy:l}=Tu(t,n,e),{readableEncoding:u,readableObjectMode:c,readableHighWaterMark:d}=Cu(a,o),{read:f,onStdoutDataDone:h}=Au({subprocessStdout:a,subprocess:t,binary:o,encoding:r,preserveNewlines:s}),p=new xE.Readable({read:f,destroy:(0,vE.callbackify)(_u.bind(void 0,{subprocessStdout:a,subprocess:t,waitReadableDestroy:l})),highWaterMark:d,objectMode:c,encoding:u});return Pu({subprocessStdout:a,onStdoutDataDone:h,readable:p,subprocess:t}),p},Tu=(t,e,r)=>{let n=Lr(t,e),i=Yn(r,n,"readableDestroy");return{subprocessStdout:n,waitReadableDestroy:i}},Cu=({readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r},n)=>n?{readableEncoding:t,readableObjectMode:e,readableHighWaterMark:r}:{readableEncoding:t,readableObjectMode:!0,readableHighWaterMark:yu},Au=({subprocessStdout:t,subprocess:e,binary:r,encoding:n,preserveNewlines:i})=>{let s=nt(),o=po({subprocessStdout:t,subprocess:e,binary:r,shouldEncode:!r,encoding:n,preserveNewlines:i});return{read(){dF(this,o,s)},onStdoutDataDone:s}},dF=async(t,e,r)=>{try{let{value:n,done:i}=await e.next();i?r.resolve():t.push(n)}catch{}},Pu=async({subprocessStdout:t,onStdoutDataDone:e,readable:r,subprocess:n,subprocessStdin:i})=>{try{await Ou(t),await n,await vu(i),await e,r.readable&&r.push(null)}catch(s){await vu(i),OE(r,s)}},_u=async({subprocessStdout:t,subprocess:e,waitReadableDestroy:r},n)=>{await Yr(r,e)&&(OE(t,n),await go(e,n))},OE=(t,e)=>{yo(t,t.readable,e)};var TE=require("node:stream"),ku=require("node:util");var CE=({subprocess:t,concurrentStreams:e},{to:r}={})=>{let{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}=Iu(t,r,e),o=new TE.Writable({...Mu(n,t,i),destroy:(0,ku.callbackify)(Ru.bind(void 0,{subprocessStdin:n,subprocess:t,waitWritableFinal:i,waitWritableDestroy:s})),highWaterMark:n.writableHighWaterMark,objectMode:n.writableObjectMode});return Du(n,o),o},Iu=(t,e,r)=>{let n=As(t,e),i=Yn(r,n,"writableFinal"),s=Yn(r,n,"writableDestroy");return{subprocessStdin:n,waitWritableFinal:i,waitWritableDestroy:s}},Mu=(t,e,r)=>({write:fF.bind(void 0,t),final:(0,ku.callbackify)(hF.bind(void 0,t,e,r))}),fF=(t,e,r,n)=>{t.write(e,r)?n():t.once("drain",n)},hF=async(t,e,r)=>{await Yr(r,e)&&(t.writable&&t.end(),await e)},Du=async(t,e,r)=>{try{await Eu(t),e.writable&&e.end()}catch(n){await SE(r),AE(e,n)}},Ru=async({subprocessStdin:t,subprocess:e,waitWritableFinal:r,waitWritableDestroy:n},i)=>{await Yr(r,e),await Yr(n,e)&&(AE(t,i),await go(e,i))},AE=(t,e)=>{yo(t,t.writable,e)};var PE=require("node:stream"),_E=require("node:util");var kE=({subprocess:t,concurrentStreams:e,encoding:r},{from:n,to:i,binary:s=!0,preserveNewlines:o=!0}={})=>{let a=s||ke.has(r),{subprocessStdout:l,waitReadableDestroy:u}=Tu(t,n,e),{subprocessStdin:c,waitWritableFinal:d,waitWritableDestroy:f}=Iu(t,i,e),{readableEncoding:h,readableObjectMode:p,readableHighWaterMark:y}=Cu(l,a),{read:x,onStdoutDataDone:b}=Au({subprocessStdout:l,subprocess:t,binary:a,encoding:r,preserveNewlines:o}),S=new PE.Duplex({read:x,...Mu(c,t,d),destroy:(0,_E.callbackify)(pF.bind(void 0,{subprocessStdout:l,subprocessStdin:c,subprocess:t,waitReadableDestroy:u,waitWritableFinal:d,waitWritableDestroy:f})),readableHighWaterMark:y,writableHighWaterMark:c.writableHighWaterMark,readableObjectMode:p,writableObjectMode:c.writableObjectMode,encoding:h});return Pu({subprocessStdout:l,onStdoutDataDone:b,readable:S,subprocess:t,subprocessStdin:c}),Du(c,S,l),S},pF=async({subprocessStdout:t,subprocessStdin:e,subprocess:r,waitReadableDestroy:n,waitWritableFinal:i,waitWritableDestroy:s},o)=>{await Promise.all([_u({subprocessStdout:t,subprocess:r,waitReadableDestroy:n},o),Ru({subprocessStdin:e,subprocess:r,waitWritableFinal:i,waitWritableDestroy:s},o)])};var ju=(t,e,{from:r,binary:n=!1,preserveNewlines:i=!1}={})=>{let s=n||ke.has(e),o=Lr(t,r),a=po({subprocessStdout:o,subprocess:t,binary:s,shouldEncode:!0,encoding:e,preserveNewlines:i});return mF(a,o,t)},mF=async function*(t,e,r){try{yield*t}finally{e.readable&&e.destroy(),await r}};var IE=(t,{encoding:e})=>{let r=bE();t.readable=EE.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.writable=CE.bind(void 0,{subprocess:t,concurrentStreams:r}),t.duplex=kE.bind(void 0,{subprocess:t,concurrentStreams:r,encoding:e}),t.iterable=ju.bind(void 0,t,e),t[Symbol.asyncIterator]=ju.bind(void 0,t,e,{})};var ME=(t,e)=>{for(let[r,n]of yF){let i=n.value.bind(e);Reflect.defineProperty(t,r,{...n,value:i})}},gF=(async()=>{})().constructor.prototype,yF=["then","catch","finally"].map(t=>[t,Reflect.getOwnPropertyDescriptor(gF,t)]);var jE=(t,e,r,n)=>{let{file:i,commandArguments:s,command:o,escapedCommand:a,startTime:l,verboseInfo:u,options:c,fileDescriptors:d}=wF(t,e,r),{subprocess:f,promise:h}=SF({file:i,commandArguments:s,options:c,startTime:l,verboseInfo:u,command:o,escapedCommand:a,fileDescriptors:d});return f.pipe=ho.bind(void 0,{source:f,sourcePromise:h,boundOptions:{},createNested:n}),ME(f,h),it.set(f,{options:c,fileDescriptors:d}),f},wF=(t,e,r)=>{let{command:n,escapedCommand:i,startTime:s,verboseInfo:o}=bs(t,e,r),{file:a,commandArguments:l,options:u}=Ls(t,e,r),c=bF(u),d=Nv(c,o);return{file:a,commandArguments:l,command:n,escapedCommand:i,startTime:s,verboseInfo:o,options:c,fileDescriptors:d}},bF=({timeout:t,signal:e,...r})=>{if(e!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...r,timeoutDuration:t}},SF=({file:t,commandArguments:e,options:r,startTime:n,verboseInfo:i,command:s,escapedCommand:o,fileDescriptors:a})=>{let l;try{l=(0,RE.spawn)(...Gs(t,e,r))}catch(p){return Rv({error:p,command:s,escapedCommand:o,fileDescriptors:a,options:r,startTime:n,verboseInfo:i})}let u=new AbortController;(0,DE.setMaxListeners)(Number.POSITIVE_INFINITY,u.signal);let c=[...l.stdio];Uv(l,a,u),Wv(l,r,u);let d={},f=nt();l.kill=Hb.bind(void 0,{kill:l.kill.bind(l),options:r,onInternalError:f,context:d,controller:u}),l.all=dE(l,r),IE(l,r),kv(l,r);let h=xF({subprocess:l,options:r,startTime:n,verboseInfo:i,fileDescriptors:a,originalStreams:c,command:s,escapedCommand:o,context:d,onInternalError:f,controller:u});return{subprocess:l,promise:h}},xF=async({subprocess:t,options:e,startTime:r,verboseInfo:n,fileDescriptors:i,originalStreams:s,command:o,escapedCommand:a,context:l,onInternalError:u,controller:c})=>{let[d,[f,h],p,y,x]=await wE({subprocess:t,options:e,context:l,verboseInfo:n,fileDescriptors:i,originalStreams:s,onInternalError:u,controller:c});c.abort(),u.resolve();let b=p.map((v,E)=>Ot(v,e,E)),S=Ot(y,e,"all"),g=vF({errorInfo:d,exitCode:f,signal:h,stdio:b,all:S,ipcOutput:x,context:l,options:e,command:o,escapedCommand:a,startTime:r});return Ur(g,n,e)},vF=({errorInfo:t,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,context:o,options:a,command:l,escapedCommand:u,startTime:c})=>"error"in t?Gn({error:t.error,command:l,escapedCommand:u,timedOut:o.terminationReason==="timeout",isCanceled:o.terminationReason==="cancel"||o.terminationReason==="gracefulCancel",isGracefullyCanceled:o.terminationReason==="gracefulCancel",isMaxBuffer:t.error instanceof st,isForcefullyTerminated:o.isForcefullyTerminated,exitCode:e,signal:r,stdio:n,all:i,ipcOutput:s,options:a,startTime:c,isSync:!1}):zs({command:l,escapedCommand:u,stdio:n,all:i,ipcOutput:s,options:a,startTime:c});var wo=(t,e)=>{let r=Object.fromEntries(Object.entries(e).map(([n,i])=>[n,EF(n,t[n],i)]));return{...t,...r}},EF=(t,e,r)=>OF.has(t)&&oe(e)&&oe(r)?{...e,...r}:r,OF=new Set(["env",...wl]);var Ut=(t,e,r,n)=>{let i=(o,a,l)=>Ut(o,a,r,l),s=(...o)=>TF({mapArguments:t,deepOptions:r,boundOptions:e,setBoundExeca:n,createNested:i},...o);return n!==void 0&&n(s,i,e),s},TF=({mapArguments:t,deepOptions:e={},boundOptions:r={},setBoundExeca:n,createNested:i},s,...o)=>{if(oe(s))return i(t,wo(r,s),n);let{file:a,commandArguments:l,options:u,isSync:c}=CF({mapArguments:t,firstArgument:s,nextArguments:o,deepOptions:e,boundOptions:r});return c?Cv(a,l,u):jE(a,l,u,i)},CF=({mapArguments:t,firstArgument:e,nextArguments:r,deepOptions:n,boundOptions:i})=>{let s=ob(e)?ab(e,r):[e,...r],[o,a,l]=cs(...s),u=wo(wo(n,i),l),{file:c=o,commandArguments:d=a,options:f=u,isSync:h=!1}=t({file:o,commandArguments:a,options:u});return{file:c,commandArguments:d,options:f,isSync:h}};var FE=({file:t,commandArguments:e})=>$E(t,e),NE=({file:t,commandArguments:e})=>({...$E(t,e),isSync:!0}),$E=(t,e)=>{if(e.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${t} ${e}.`);let[r,...n]=AF(t);return{file:r,commandArguments:n}},AF=t=>{if(typeof t!="string")throw new TypeError(`The command must be a string: ${String(t)}.`);let e=t.trim();if(e==="")return[];let r=[];for(let n of e.split(PF)){let i=r.at(-1);i&&i.endsWith("\\")?r[r.length-1]=`${i.slice(0,-1)} ${n}`:r.push(n)}return r},PF=/ +/g;var LE=(t,e,r)=>{t.sync=e(_F,r),t.s=t.sync},GE=({options:t})=>qE(t),_F=({options:t})=>({...qE(t),isSync:!0}),qE=t=>({options:{...kF(t),...t}}),kF=({input:t,inputFile:e,stdio:r})=>t===void 0&&e===void 0&&r===void 0?{stdin:"inherit"}:{},BE={preferLocal:!0};var We=Ut(()=>({})),L7=Ut(()=>({isSync:!0})),G7=Ut(FE),q7=Ut(NE),B7=Ut(NS),U7=Ut(GE,{},BE,LE),{sendMessage:V7,getOneMessage:W7,getEachMessage:H7,getCancelSignal:J7}=Iv();var UE=C(fe()),VE=C(require("path"));async function bo(t,e,r=2){let n=["install"],i="pipe",s=Number(process.env.STACKKIT_INSTALL_TIMEOUT_MS)||Mi.PACKAGE_INSTALL,o=process.env.STACKKIT_FALLBACK_PMS?process.env.STACKKIT_FALLBACK_PMS.split(",").map(d=>d.trim()).filter(Boolean):[],a=["pnpm","npm","yarn","bun"],l=Array.from(new Set([e,...o,...a].map(d=>d))),u=null;async function c(d){try{return await We(d,["--version"],{cwd:t,stdio:"pipe",timeout:2e3}),!0}catch{return!1}}for(let d of l){if(!["pnpm","npm","yarn","bun"].includes(d))continue;if(!await c(d)){m.debug(`${d} not found on PATH, skipping`);continue}m.debug(`Attempting install with ${d}`);let h=!1;for(let p=0;p<=r;p++)try{p>0&&(m.debug(`Retry attempt ${p} for ${d}`),await new Promise(y=>setTimeout(y,Mi.RETRY_DELAY_BASE*p))),await We(d,n,{cwd:t,stdio:i,timeout:s}),h=!0;break}catch(y){u=y,m.debug(`Installation attempt ${p+1} with ${d} failed: ${u.message}`);let b=y.message||"";if(b.includes("ECONNRESET")||b.includes("ETIMEDOUT")||b.includes("ENOTFOUND"))continue;break}if(h)return;m.debug(`${d} failed after retries, trying next fallback`)}throw new Error(`Failed to install dependencies after trying fallback package managers: ${u?.message||"Unknown error"}`)}async function Fu(t,e,r,n=!1){if(r.length===0){m.debug("No packages to add, skipping");return}let i=r.filter(o=>!IF(o));if(i.length>0)throw new Error(`Invalid package names: ${i.join(", ")}`);let s=m.startSpinner(`Adding ${n?"dev ":""}dependencies: ${r.join(", ")}...`);try{let o="pipe",a=[];switch(e){case"npm":a=["install",...n?["--save-dev"]:[],...r];break;case"yarn":a=["add",...n?["--dev"]:[],...r];break;case"pnpm":a=["add",...n?["-D"]:[],...r];break;case"bun":a=["add",...n?["-d"]:[],...r];break;default:throw new Error(`Unsupported package manager: ${e}`)}m.debug(`Running: ${e} ${a.join(" ")}`),await We(e,a,{cwd:t,stdio:o,timeout:Mi.PACKAGE_INSTALL}),s.succeed("Dependencies added successfully")}catch(o){s.fail("Failed to add dependencies");let a=o instanceof Error?o.message:String(o);throw m.debug(`Full error: ${a}`),a.includes("ENOTFOUND")||a.includes("ETIMEDOUT")?new Error("Network error while adding dependencies. Please check your internet connection and try again."):a.includes("404")?new Error(`One or more packages not found. Please verify package names: ${r.join(", ")}`):new Error(`Failed to add dependencies: ${a}`)}}function IF(t){let e=t.split("@").filter(Boolean)[0]||t;return/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/i.test(e)}async function WE(t){let e=m.startSpinner("Initializing git repository...");try{await We("git",["--version"],{cwd:t,stdio:"pipe"})}catch{e.fail("Git is not installed"),m.warn("Skipping git initialization. Please install git to enable version control.");return}try{if(await UE.pathExists(VE.join(t,".git"))){e.succeed("Git repository already exists");return}}catch{return}let r=async n=>{await We("git",["init"],{cwd:t,stdio:n});try{await We("git",["branch","-M","main"],{cwd:t,stdio:n})}catch{}await We("git",["add","."],{cwd:t,stdio:n});try{await We("git",["config","user.name"],{cwd:t,stdio:"pipe"}),await We("git",["config","user.email"],{cwd:t,stdio:"pipe"}),await We("git",["commit","-m","Initial commit from StackKit"],{cwd:t,stdio:n})}catch{m.debug("Git config not found, skipping initial commit")}};try{await r("pipe"),e.succeed("Git repository initialized");return}catch(n){let i=n;if(m.debug(`Git init error: ${i.message}`),(o=>{if(!o||typeof o!="object")return!1;let a=o;return a.code==="ENOBUFS"||a.errno==="ENOBUFS"||String(a.message??"").includes("ENOBUFS")})(i)){e.warn("Skipped git initialization due to system resource limits"),m.info("You can manually initialize git later with: git init");return}try{await r("inherit"),e.succeed("Git repository initialized");return}catch(o){let a=o;m.debug(`Git init fallback error: ${a.message}`),e.warn("Git initialization skipped"),m.info("You can manually initialize git later with: git init");return}}}var le=C(fe()),Se=C(require("path"));var ct=C(fe()),Tt=C(require("path"));async function So(t){try{return await ct.default.readJson(t)}catch{return null}}async function HE(t){let e=[],r=Tt.default.join(t,"generator.json");if(await ct.default.pathExists(r)){let i=await So(r);if(i&&Array.isArray(i.operations)&&Array.isArray(i.operations))for(let s of i.operations)s.dependencies&&typeof s.dependencies=="object"&&e.push(...Object.keys(s.dependencies)),s.devDependencies&&typeof s.devDependencies=="object"&&e.push(...Object.keys(s.devDependencies))}let n=Tt.default.join(t,"module.json");if(await ct.default.pathExists(n)){let i=await So(n);if(i&&typeof i=="object"){let s=i.dependencies||{};typeof s=="object"&&e.push(...Object.keys(s));let o=i.devDependencies||{};typeof o=="object"&&e.push(...Object.keys(o))}}return Array.from(new Set(e))}async function xo(t){let e={...t.dependencies,...t.devDependencies},r=[];try{let n=Tt.default.join(M(),"modules","auth");if(await ct.default.pathExists(n)){let i=await ct.default.readdir(n);for(let s of i)try{let o=Tt.default.join(n,s),a=await HE(o),l=s,u=Tt.default.join(o,"module.json");if(await ct.default.pathExists(u)){let c=await So(u);c?.name&&(l=c.name)}for(let c of a)if(e[c]){r.push(l);break}}catch{continue}}}catch{return Array.from(new Set(r))}return Array.from(new Set(r))}async function vo(t){let e={...t.dependencies,...t.devDependencies},r=[];try{let n=Tt.default.join(M(),"modules","database");if(await ct.default.pathExists(n)){let i=await ct.default.readdir(n);for(let s of i)try{let o=Tt.default.join(n,s),a=await HE(o),l=s,u=Tt.default.join(o,"module.json");if(await ct.default.pathExists(u)){let c=await So(u);c?.name&&(l=c.name)}for(let c of a)if(e[c]){r.push(l);break}}catch{continue}}}catch{return Array.from(new Set(r))}return Array.from(new Set(r))}async function zn(t){let e=Se.default.join(t,ye.PACKAGE_JSON);if(!await le.default.pathExists(e))throw new Error(Lg.NO_PACKAGE_JSON);let r=await le.default.readJSON(e),n="unknown";try{let b=Se.default.join(M(),"templates");if(await le.default.pathExists(b)){let S=await le.default.readdir(b),g=null;for(let v of S){let E=Se.default.join(b,v,"template.json");if(await le.default.pathExists(E))try{let T=await le.default.readJSON(E),j=Array.isArray(T.files)?T.files:[],$=0;for(let A of j){let D=Se.default.join(t,A.replace(/\\/g,"/"));await le.default.pathExists(D)&&$++}(!g||$>g.score)&&(g={name:v,score:$})}catch{continue}}g&&g.score>0&&(n=g.name)}}catch{n="unknown"}if(n==="unknown"){let b=r.dependencies?.next||r.devDependencies?.next,S=r.dependencies?.express||r.devDependencies?.express,g=r.dependencies?.react||r.devDependencies?.react,v=r.dependencies?.vite||r.devDependencies?.vite;b?n="nextjs":S?n="express":(g&&v||g)&&(n="react")}if(n==="unknown")throw new Error("Unsupported project type or unable to detect framework from templates.");let i="unknown";if(n==="nextjs"){let b=await le.default.pathExists(Se.default.join(t,"app")),S=await le.default.pathExists(Se.default.join(t,"pages")),g=await le.default.pathExists(Se.default.join(t,"src","app")),v=await le.default.pathExists(Se.default.join(t,"src","pages"));b||g?i=xc.APP:(S||v)&&(i=xc.PAGES)}let s=await le.default.pathExists(Se.default.join(t,ye.TSCONFIG_JSON)),o=await le.default.pathExists(Se.default.join(t,"jsconfig.json")),a;s?a="ts":o?a="js":a="ts";let l=await le.default.pathExists(Se.default.join(t,Ft.yarn)),u=await le.default.pathExists(Se.default.join(t,Ft.pnpm)),c=await le.default.pathExists(Se.default.join(t,Ft.bun)),d="pnpm";u?d="pnpm":l?d="yarn":c&&(d="bun");let f=await xo(r),h=await vo(r),p=f.length>0,y=h.includes("prisma"),x=y||h.length>0;return{framework:n,router:i,language:a,packageManager:d,hasAuth:p,hasPrisma:y,hasDatabase:x,rootDir:t}}function JE(t){let e=le.default.existsSync(Se.default.join(t.rootDir,"src"));if(t.router==="app")return e?"src/app":"app";if(t.router==="pages")return e?"src/pages":"pages";throw new Error("Unknown router type")}function YE(t){return t.framework==="express"||le.default.existsSync(Se.default.join(t.rootDir,"src"))?"src/lib":"lib"}async function zE(t,e){try{let r=process.cwd(),n=m.startSpinner("Detecting project..."),i=await zn(r);n.succeed(`Detected ${i.framework} (${i.router} router, ${i.language})`);let s=await MF(t,e,i),o=await zn(r);if(await KE(r,o,s,e),m.newLine(),s.preAdded&&s.preAdded.length>0){let a=[...s.preAdded.map(l=>l.displayName),s.displayName].map(l=>P.bold(l));m.success(`Added ${a.join(" and ")}`)}else m.success(`Added ${P.bold(s.displayName)}`);m.newLine()}catch(r){m.error(`Failed to add module: ${r.message}`),r instanceof Error&&r.stack&&m.log(P.gray(r.stack)),process.exit(1)}}async function MF(t,e,r){let n=te.default.join(M(),"modules");if(!t)return await DF(n,r,e);if(t==="database"||t==="auth"){if(!e?.provider)throw t==="database"?new Error("Provider is required for database. Use: `npx stackkit@latest add database --provider <provider>`"):new Error("Provider is required for auth. Use: `npx stackkit@latest add auth --provider <provider>`");if(t==="database"){let i=Xt(e.provider||""),s=i.database,o=i.provider?`${i.database}-${i.provider}`:i.database,a=await Vt(n,s,s);if(!a)throw new Error(`Database provider "${s}" not found`);return{module:"database",provider:o,displayName:i.database==="prisma"&&i.provider?`${a.displayName||s} (${i.provider})`:a.displayName||s,metadata:a}}else if(t==="auth"){let i=e.provider,s=await Vt(n,i,i);if(!s)throw new Error(`Auth provider "${i}" not found`);if(r){if(s.supportedFrameworks&&!s.supportedFrameworks.includes(r.framework))throw new Error(`${s.displayName} is not supported on ${r.framework}`);let o=r.hasPrisma?"prisma":r.hasDatabase?"other":"none";if(s.compatibility&&s.compatibility.databases&&!s.compatibility.databases.includes(o))throw new Error(`${s.displayName} is not compatible with the project's database configuration`)}return{module:"auth",provider:i,displayName:s.displayName||i,metadata:s}}}throw new Error(`Unknown module type "${t}". Use "database" or "auth", or specify a provider directly.`)}async function DF(t,e,r){let n=process.cwd(),i=await Di(t),s=i.frameworks&&i.frameworks[0]?.name||e?.framework||"",o=Sn(i.auth||[],e?.framework||s,e?.hasPrisma?"prisma":"none",i.frameworks),a=[{name:"Database",value:"database"}];if(o.length>0&&a.push({name:"Auth",value:"auth"}),["react","nextjs"].includes(e?.framework||s)){let c=e?.framework||s;(i.components||[]).filter(f=>!f.supportedFrameworks||f.supportedFrameworks.includes(c)).length>0&&a.push({name:"Components",value:"components"})}let u=(await(0,Wt.default)({type:"select",name:"category",message:"What would you like to add?",choices:a.map(c=>({title:c.name,value:c.value}))})).category;if(u==="database"){let d=xn(i.databases||[],e?.framework||s).map(y=>({title:y.name||y.title||String(y.value??""),value:y.value??String(y.title??"")})),h=(await(0,Wt.default)({type:"select",name:"database",message:"Select database:",choices:d})).database;if(h.startsWith("prisma-")){let y=h.split("-")[1];return{module:"database",provider:`prisma-${y}`,displayName:`Prisma (${y})`,metadata:await Vt(t,"prisma","prisma")}}let p=await Vt(t,h,h);if(!p)throw new Error(`Database provider "${h}" not found`);return{module:"database",provider:h,displayName:p.displayName||h,metadata:p}}else if(u==="auth"){let c;if(!e?.hasDatabase){m.warn("No database detected in the project. Authentication requires a database.");let g=xn(i.databases||[],e?.framework||s).map(j=>({title:j.name||j.title||String(j.value??""),value:j.value??String(j.title??"")})),E=(await(0,Wt.default)({type:"select",name:"database",message:"Select a database to add before authentication:",choices:g})).database;(!E||E==="none")&&(m.info("Cancelled \u2014 authentication requires a database"),process.exit(0));let T;if(E.startsWith("prisma-")){let j=E.split("-")[1];T={module:"database",provider:`prisma-${j}`,displayName:`Prisma (${j})`,metadata:await Vt(t,"prisma","prisma")}}else{let j=await Vt(t,E,E);if(!j)throw new Error(`Database provider "${E}" not found`);T={module:"database",provider:E,displayName:j.displayName||E,metadata:j}}await KE(n,e||await zn(n),T,r),e=await zn(n),T.preAdded=T.preAdded||[],c=T}let d=e?.hasPrisma?"prisma":"none",h=Sn(i.auth||[],e?.framework||s,d).map(S=>({title:S.name?S.description?`${S.name} \u2014 ${S.description}`:S.name:String(S.value??""),value:S.value??String(S.name??"")})),y=(await(0,Wt.default)({type:"select",name:"auth",message:"Select authentication:",choices:h})).auth;y==="none"&&(m.info("Cancelled"),process.exit(0));let x=await Vt(t,y,y);if(!x)throw new Error(`Auth provider "${y}" not found`);if(e&&x.supportedFrameworks&&!x.supportedFrameworks.includes(e.framework))throw new Error(`Auth provider "${y}" does not support ${e.framework}`);let b={module:"auth",provider:y,displayName:x.displayName||y,metadata:x};return typeof c<"u"&&c&&(b.preAdded=[c]),b}else if(u==="components"){let c=e?.framework||s,d=(i.components||[]).find(p=>!p.supportedFrameworks||p.supportedFrameworks.includes(c));d||(m.info("No components available for this framework"),process.exit(0)),(await(0,Wt.default)({type:"confirm",name:"add",message:`Add ${d.displayName||d.name}?${d.description?` (${d.description})`:""}`,initial:!0})).add===!1&&(m.info("No components selected"),process.exit(0));let h=await Vt(t,"components","components");return h||(m.error("Failed to load components module metadata"),process.exit(1)),{module:"components",provider:"components",displayName:h.displayName||"Components",metadata:h}}throw new Error("Invalid selection")}async function KE(t,e,r,n){let i=r.metadata,s=r.provider;if(r.module==="auth"&&e.hasAuth&&!n?.force){m.warn("Auth library already detected in this project");let{proceed:c}=await(0,Wt.default)({type:"confirm",name:"proceed",message:"Continue anyway? (use --force to skip this prompt)",initial:!1});if(!c){m.info("Cancelled");return}}if(r.module==="database"&&e.hasDatabase&&!n?.force){m.warn("Database library already detected in this project");let{proceed:c}=await(0,Wt.default)({type:"confirm",name:"proceed",message:"Continue anyway? (use --force to skip this prompt)",initial:!1});if(!c){m.info("Cancelled");return}}n?.dryRun&&(m.warn("Dry run mode - no changes will be made"),m.newLine());let o=await XE(te.default.join(M(),"modules"),r.module,r.provider);if(o){let c=await Ji.loadFrameworkConfig(e.framework,te.default.join(M(),"templates")),d=new Or(c);await d.loadGenerators(te.default.join(M(),"modules"));let f=te.default.basename(o),h=d.getAvailableGenerators();if(!(r.module==="database"&&h.databases.includes(f)||r.module==="auth"&&h.auths.includes(f)||r.module==="components"&&h.components.length>0)){let b=[];if(Array.isArray(i.patches))for(let S of i.patches)S.type==="create-file"&&b.push({type:"create-file",source:S.source,destination:S.destination,condition:S.condition});b.length>0&&d.registerGenerator(r.module,f,{name:f,type:r.module,priority:0,operations:b,dependencies:{}})}let y={framework:e.framework};try{let b=await Y.default.readJson(te.default.join(t,"package.json")),S={...b.dependencies||{},...b.devDependencies||{}};if(e.hasPrisma){y.database="prisma";let g=te.default.join(t,"prisma","schema.prisma");if(await Y.default.pathExists(g)){let E=(await Y.default.readFile(g,"utf-8")).match(/datasource\s+\w+\s*\{([\s\S]*?)\}/i);if(E&&E[1]){let T=E[1].match(/provider\s*=\s*["']([^"']+)["']/i);T&&T[1]&&(y.prismaProvider=T[1])}}}else S.mongoose&&(y.database="mongoose")}catch(b){}if(r.module==="database"&&r.provider){let b=Xt(r.provider);y.database=b.database,b.database==="prisma"&&b.provider&&(y.prismaProvider=b.provider)}r.module==="auth"&&r.provider?y.auth=r.provider:r.module==="components"&&(y.components=!0);let x=await d.applyToProject(y,[],t);if(!n?.dryRun&&n?.install!==!1){let b=m.startSpinner("Installing dependencies...");try{await bo(t,e.packageManager),b.succeed("Dependencies installed")}catch(S){throw b.fail("Failed to install dependencies"),S}}if(x&&x.length>0&&!n?.dryRun)if((d.getCreatedFiles?d.getCreatedFiles():[]).length===0)m.warn("Skipping post-install commands \u2014 no files were created by generators to act upon.");else{let S=m.startSpinner("Running post-install commands...");try{for(let g of x)(0,Nu.execSync)(g,{cwd:t,stdio:"inherit"});S.succeed("Post-install commands completed")}catch(g){throw S.fail("Failed to run post-install commands"),g}}return}let a={},l={};try{let c=i.frameworkConfigs?.shared;c&&c.dependencies&&Object.assign(a,c.dependencies),c&&c.devDependencies&&Object.assign(l,c.devDependencies)}catch(c){}let u={};if(s&&(u.provider=s),i.envVars){let c=Array.isArray(i.envVars)?i.envVars:Object.entries(i.envVars).map(([d,f])=>({key:d,value:String(f)}));for(let d of c)d.key&&typeof d.value=="string"&&(u[d.key]=d.value);for(let d=0;d<5;d++){let f=!1;for(let h of c){if(!h.key||typeof h.value!="string")continue;let p=h.value.replace(/\{\{(\w+)\}\}/g,(y,x)=>u[x]??y);u[h.key]!==p&&(u[h.key]=p,f=!0)}if(!f)break}}if(await RF(t,e,i,te.default.join(M(),"modules"),r.module,n||{}),i.frameworkPatches&&!n?.dryRun&&await jF(t,i.frameworkPatches,e.framework),i.postInstall&&i.postInstall.length>0&&!n?.dryRun){let c=[];if(Array.isArray(i.patches)){for(let d of i.patches)if(d.type==="create-file"){let f=d.destination;if(typeof f=="string"){let h=te.default.join(t,f);await Y.default.pathExists(h)&&c.push(f)}}}if(c.length===0)m.warn("Skipping module post-install commands \u2014 no files were created by module patches to act upon.");else{let d=m.startSpinner("Running post-install commands...");try{for(let f of i.postInstall)(0,Nu.execSync)(f,{cwd:t,stdio:"inherit"});d.succeed("Post-install commands completed")}catch(f){throw d.fail("Failed to run post-install commands"),f}}}if(Object.keys(a).length>0&&n?.install!==!1){let c=Object.entries(a).map(([d,f])=>`${d}@${f}`);n?.dryRun?m.info(`Would add dependencies: ${c.join(", ")}`):await Fu(t,e.packageManager,c,!1)}if(Object.keys(l).length>0&&n?.install!==!1){let c=Object.entries(l).map(([d,f])=>`${d}@${f}`);n?.dryRun?m.info(`Would add dev dependencies: ${c.join(", ")}`):await Fu(t,e.packageManager,c,!0)}if(i.envVars){let c=[];if(Array.isArray(i.envVars)?c=i.envVars:typeof i.envVars=="object"&&(c=Object.entries(i.envVars).map(([d,f])=>({key:d,value:String(f)}))),c.length>0){let d=c.map(f=>({key:f.key||"",value:f.value?.replace(/\{\{(\w+)\}\}/g,(h,p)=>u[p]||h),required:!1}));if(n?.dryRun)m.log(` ${P.dim("~")} .env.example`);else{let f=d.map(h=>({key:h.key,value:h.value,required:!!h.required}));await Hi(t,f,{force:n?.force})}}}}async function Vt(t,e,r){if(!await Y.default.pathExists(t))return null;let n=await Y.default.readdir(t);for(let i of n){let s=te.default.join(t,i);if(!(await Y.default.stat(s)).isDirectory())continue;let a=await Y.default.readdir(s);for(let u of a){let c=te.default.join(s,u);if(!(await Y.default.stat(c)).isDirectory())continue;let f=te.default.join(c,"module.json");if(await Y.default.pathExists(f)){let h=await Y.default.readJSON(f);if(r&&u===r||!r&&(h.category===e||u===e))return h}}let l=te.default.join(s,"module.json");if(await Y.default.pathExists(l)){let u=await Y.default.readJSON(l);if(r&&i===r||!r&&(u.category===e||i===e))return u}}return null}async function RF(t,e,r,n,i,s){if(!r.patches||!Array.isArray(r.patches))return;let o=await XE(n,i,s.provider);if(!o)throw new Error("Module files not found");for(let a of r.patches)if(a.type==="create-file"){let l=a;if(l.condition&&(l.condition.router&&l.condition.router!==e.router||l.condition.language&&l.condition.language!==e.language))continue;let u=te.default.join(o,"files",l.source),c=te.default.join(t,l.destination);if(c=c.replace("{{router}}",JE(e)).replace("{{lib}}",YE(e)),s.dryRun){let d=te.default.relative(t,c);m.log(` ${P.dim("+")} ${d}`)}else if(await fy(u)){let d=await Y.default.readFile(u,"utf-8");await dy(c,d,{force:s.force});let f=te.default.relative(t,c);m.log(` ${P.green("+")} ${f}`)}else m.warn(`Source file not found: ${l.source}`)}}async function XE(t,e,r){let n=await Y.default.readdir(t);for(let i of n){let s=te.default.join(t,i);if(!(await Y.default.stat(s)).isDirectory())continue;let a=await Y.default.readdir(s);for(let u of a){let c=te.default.join(s,u);if(!(await Y.default.stat(c)).isDirectory())continue;let f=te.default.join(c,"module.json");if(await Y.default.pathExists(f)){let h=await Y.default.readJSON(f);if(r){let p=String(r).split("-")[0];if(u===r||u===p)return c}if(!r&&h.name===e)return c}}let l=te.default.join(s,"module.json");if(await Y.default.pathExists(l)){let u=await Y.default.readJSON(l);if(r&&i===r||!r&&u.name===e)return s}}return null}async function jF(t,e,r){let i=e[r];if(i)for(let[s,o]of Object.entries(i)){let a=te.default.join(t,s);if(await Y.default.pathExists(a)){let l=await Y.default.readJson(a);if(o.merge){let u=ZE(l,o.merge);await Y.default.writeJson(a,u,{spaces:2});let c=te.default.relative(t,a);m.log(` ${P.blue("~")} ${c}`)}}}}function ZE(t,e){let r={...t};for(let n in e)e[n]&&typeof e[n]=="object"&&!Array.isArray(e[n])?t[n]?r[n]=ZE(t[n],e[n]):r[n]=e[n]:Array.isArray(e[n])?r[n]=Array.from(new Set([...t[n]||[],...e[n]])):r[n]=e[n];return r}var iO=require("child_process"),z=C(fe()),we=C(require("path")),He=C(bc()),sO=C(tO());var L=C(fe()),rO=require("module"),me=C(require("path"));var Ct=(0,rO.createRequire)(__filename),qF={express:"./src",react:"./src",nextjs:"."};async function nO(t,e){let r=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","next-env.d.ts","vite-env.d.ts"];for(let S of r){let g=me.default.join(t,S);await L.default.pathExists(g)&&await L.default.remove(g)}let n=async S=>{let g=await L.default.readdir(S,{withFileTypes:!0});for(let v of g){let E=me.default.join(S,v.name);v.isDirectory()&&v.name!=="node_modules"?await n(E):v.isFile()&&v.name.endsWith(".d.ts")&&await L.default.remove(E)}};await n(t);let i=Ct("@babel/core"),s=S=>{try{return Ct.resolve(S),!0}catch{return!1}},o=s("recast"),a=s("@babel/parser"),l=s("@babel/plugin-transform-typescript");if(!o||!a||!l){let S=M(),g=[];o||g.push("recast"),a||g.push("@babel/parser"),l||g.push("@babel/plugin-transform-typescript"),m.warn(`Optional tooling missing: ${g.join(", ")}. Generated JavaScript may contain transformed JSX.`),(process.env.STACKKIT_VERBOSE==="1"||process.env.DEBUG)&&m.info(`To ensure generated JavaScript preserves JSX, add these to the CLI package dependencies or run 'pnpm install' in ${S}`)}let u=async S=>{let g=await L.default.readdir(S,{withFileTypes:!0});for(let v of g){let E=me.default.join(S,v.name);if(v.isDirectory()&&v.name!=="node_modules")await u(E);else if(v.isFile()&&(v.name.endsWith(".ts")||v.name.endsWith(".tsx"))){let T=await L.default.readFile(E,"utf8"),j=v.name.endsWith(".tsx"),$=E.replace(/\.tsx$/,".jsx").replace(/\.ts$/,".js"),A=[[Ct.resolve("@babel/preset-typescript"),{onlyRemoveTypeImports:!0,allowDeclareFields:!0,allowNamespaces:!0,optimizeForSpeed:!0,allExtensions:!0,isTSX:j}],[Ct.resolve("@babel/preset-env"),{targets:{node:"18"},modules:!1}]];try{let k=Ct("recast"),{transformFromAstSync:X}=Ct("@babel/core"),G=Ct("@babel/plugin-transform-typescript"),H=Ct("recast/parsers/_babel_options"),I=typeof H=="function"?H:H.default??(()=>({plugins:[]})),N=Ct("recast/parsers/babel").parser,F=k.parse(T,{parser:{parse:(bO,SO)=>{let Co=I(SO||{});return j?Co.plugins.push("typescript","jsx"):Co.plugins.push("typescript"),N.parse(bO,Co)}}}),re={cloneInputAst:!1,code:!1,ast:!0,plugins:[G],configFile:!1},{ast:U}=X(F,T,re),Bu=k.print(U).code;await L.default.writeFile($,Bu,"utf8"),await L.default.remove(E);continue}catch{}let D=await i.transformAsync(T,{filename:v.name,presets:A,comments:!0,retainLines:!0,compact:!1,babelrc:!1,configFile:!1});if(!D?.code)continue;await L.default.writeFile($,D.code,"utf8"),await L.default.remove(E)}}};await u(t);let c=qF[e];if(c){let S=async g=>{let v=await L.default.readdir(g,{withFileTypes:!0});for(let E of v){let T=me.default.join(g,E.name);if(E.isDirectory()&&E.name!=="node_modules")await S(T);else if(E.isFile()&&(E.name.endsWith(".js")||E.name.endsWith(".jsx"))){let j=await L.default.readFile(T,"utf-8");if(j.includes("@/")){let $=me.default.dirname(T),A=j.replace(/from ['"]@\/([^'"]*)['"]/g,(D,k)=>{let X=me.default.resolve(c,k),G=me.default.relative($,X);return G.startsWith(".")||(G="./"+G),`from '${G}'`});await L.default.writeFile(T,A,"utf-8")}}}};await S(t)}let d=me.default.join(M(),"templates"),f=e,h=[],p=null;if(f){let S=me.default.join(d,f,"template.json");if(await L.default.pathExists(S))try{let g=await L.default.readJson(S);Array.isArray(g.fileReplacements)&&(h=g.fileReplacements),g.jsScripts&&(p=g.jsScripts)}catch{h=[]}}for(let S of h){let g=me.default.join(t,S.file);if(await L.default.pathExists(g)){let v=await L.default.readFile(g,"utf8");S.from&&S.to&&(v=v.replace(S.from,S.to),await L.default.writeFile(g,v,"utf8"))}}if(p){let S=me.default.join(t,"package.json");if(await L.default.pathExists(S)){let g=await L.default.readJson(S);g.scripts={...g.scripts,...p},await L.default.writeJson(S,g,{spaces:2})}}let y=me.default.join(t,"jsconfig.json");if(!await L.default.pathExists(y)){for(let S of await L.default.readdir(d,{withFileTypes:!0}))if(S.isDirectory()){let g=me.default.join(d,S.name,"jsconfig.json");if(await L.default.pathExists(g)){await L.default.copy(g,y);break}}}let x=me.default.join(t,"src");if(await L.default.pathExists(x)){let S=await L.default.readdir(x);for(let g of S)(g.endsWith(".js")||g.endsWith(".jsx"))&&g.replace(/\.(js|jsx)$/,".ts")&&S.includes(g.replace(/\.(js|jsx)$/,".ts"))&&await L.default.remove(me.default.join(x,g.replace(/\.(js|jsx)$/,".ts"))),g.endsWith(".jsx")&&S.includes(g.replace(/\.jsx$/,".tsx"))&&await L.default.remove(me.default.join(x,g.replace(/\.jsx$/,".tsx")))}let b=me.default.join(t,"package.json");if(await L.default.pathExists(b)){let S=await L.default.readJson(b);S.devDependencies&&(delete S.devDependencies.typescript,delete S.devDependencies["@types/node"],delete S.devDependencies["@types/react"],delete S.devDependencies["@types/react-dom"]),await L.default.writeJson(b,S,{spaces:2})}}async function oO(t,e){m.newLine(),m.log(P.bold.cyan("\u{1F4E6} Create StackKit App")),m.newLine();let r=await BF(t,e),n=we.default.join(process.cwd(),r.projectName);await z.default.pathExists(n)&&(m.error(`Directory "${r.projectName}" already exists`),m.log(P.gray(`Please choose a different name or remove the existing directory.
|
|
233
|
+
`)),process.exit(1)),await UF(r,n,e),await WF(r,n),HF(r)}async function BF(t,e){let r=we.default.join(M(),"modules"),n=await Di(r),i=process.argv.slice(2),s=i.indexOf("create"),a=(s>=0?i.slice(s+1):[]).some(g=>g.startsWith("-"));if(a||!!(e&&(e.yes||e.y))){if(e&&(e.yes||e.y)&&!a){let I=n.frameworks&&n.frameworks.length>0?n.frameworks[0].name:"",N=n.databases&&n.databases.length>0?n.databases[0].name:"none",F=De(M()),re=F.length>0?F[0]:void 0,U=n.auth&&n.auth.length>0?n.auth[0].name:"none";return{projectName:t||"my-app",framework:I,database:N,prismaProvider:re,auth:U,language:"typescript",packageManager:"pnpm",ui:"none",storageProvider:"none",components:!1}}let g=e&&(e.framework||e.f)||void 0;if(n.frameworks&&n.frameworks.length>0){let I=n.frameworks.map(N=>N.name);if(g&&!I.includes(g))throw new Error(`Invalid framework: ${g}. Valid options: ${I.join(", ")}`)}let v=e&&(e.database||e.d)||void 0,E=[];if(n.databases&&n.databases.length>0){let I=Bg(n.databases),N=n.databases.map(F=>F.name);if(E=[...I,...N],v&&!E.includes(v))throw new Error(`Invalid database: ${v}. Valid options: ${E.filter((F,re,U)=>U.indexOf(F)===re).join(", ")}`)}let T=e&&(e.auth||e.a)||void 0;if(n.auth&&n.auth.length>0){let I=Ug(n.auth);if(T&&!I.includes(T))throw new Error(`Invalid auth: ${T}. Valid options: ${I.join(", ")}`)}let j=["typescript","javascript"],$=e&&(e.language||e.l)||void 0;if($&&!j.includes($))throw new Error(`Invalid language: ${$}. Valid options: ${j.join(", ")}`);let A=["pnpm","npm","yarn","bun"],D=e&&(e.packageManager||e.p)||void 0;if(D&&!A.includes(D))throw new Error(`Invalid package manager: ${D}. Valid options: ${A.join(", ")}`);let k="none",X;if(v&&v!=="none"){let I=Xt(v);k=I.database,X=I.provider}let G="none";T&&T!=="none"&&(G=T);let H=g||(n.frameworks[0]?.name??"");if(G&&G!=="none"&&n.auth){let I=n.auth.find(N=>N.name===G);if(I){if(I.supportedFrameworks&&!I.supportedFrameworks.includes(H))throw new Error(`${I.displayName||G} is not supported on ${H}`);let N=k==="prisma"?"prisma":k==="none"?"none":"other";if(I.compatibility&&I.compatibility.databases&&!I.compatibility.databases.includes(N))throw new Error(`${I.displayName||G} is not compatible with the selected database configuration`)}}return{projectName:t||"my-app",framework:H,database:k,prismaProvider:X,auth:G,language:$||"typescript",packageManager:D||"pnpm",components:!1}}let u=De(M()),c={},d=async(g,v,E,T)=>(await(0,He.default)({type:"select",name:g,message:v,choices:E,initial:T}))[g],f=()=>{if(n.databases&&n.databases.length>0)return xn(n.databases,c.framework||"").map(g=>({title:g.name||String(g.value),value:g.value}));try{let g=we.default.join(M(),"modules","database");if(z.default.existsSync(g)){let v=z.default.readdirSync(g).map(E=>({title:E.charAt(0).toUpperCase()+E.slice(1),value:E}));return v.push({title:"None",value:"none"}),v}}catch{}return[{title:"None",value:"none"}]};if(t)c.projectName=t;else{let g=await(0,He.default)({type:"text",name:"projectName",message:"Project name:",initial:t||"my-app",validate:v=>{let E=(0,sO.default)(v);return E.validForNewPackages?z.default.existsSync(we.default.join(process.cwd(),v))?"Directory already exists":!0:E.errors?.[0]||"Invalid package name"}});c.projectName=g.projectName||t||"my-app"}let h=n.frameworks&&n.frameworks.length>0?n.frameworks.map(g=>({title:g.displayName||g.name,value:g.name})):(()=>{try{let g=we.default.join(M(),"templates");if(z.default.existsSync(g))return z.default.readdirSync(g).filter(E=>E!=="node_modules").map(E=>({title:E.charAt(0).toUpperCase()+E.slice(1),value:E}))}catch{return[]}return[]})(),p=await(0,He.default)({type:"select",name:"framework",message:"Select framework:",choices:h});if(c.framework=p.framework||(n.frameworks?.[0]?.name??""),["react","nextjs"].includes(c.framework||""))c.database="none";else{let v=f().map(T=>({title:T.name||T.title||String(T.value??""),value:T.value??String(T.title??"")})),E=await d("database","Select database/ORM:",v);c.database=E||"none"}if(c.database==="prisma"&&u.length>0){let g=await(0,He.default)({type:"select",name:"prismaProvider",message:"Select database provider for Prisma:",choices:u.map(v=>({title:v.charAt(0).toUpperCase()+v.slice(1),value:v}))});c.prismaProvider=g.prismaProvider}if(c.framework==="react"||c.framework==="nextjs"){let g=(n.ui||[]).filter($=>!$.supportedFrameworks||$.supportedFrameworks.includes(c.framework||"")).map($=>({title:$.displayName||$.name,value:$.name}));g.length===0&&(g.push({title:"Shadcn (shadcn/ui)",value:"shadcn"}),g.push({title:"None",value:"none"}));let v=g.findIndex($=>$.value==="none"),j=(await(0,He.default)({type:"select",name:"ui",message:"Select UI system:",choices:g,initial:v===-1?0:v})).ui;typeof j=="string"?c.ui=j:c.ui="none"}else c.ui="none";if(c.framework==="express"){let g=(n.storage||[]).map(T=>({title:T.displayName||T.name,value:T.name}));g.length===0&&g.push({title:"Cloudinary",value:"cloudinary"}),g.push({title:"None",value:"none"});let E=(await(0,He.default)({type:"select",name:"storageProvider",message:"Select storage provider:",choices:g,initial:Math.max(0,g.findIndex(T=>T.value==="cloudinary"))})).storageProvider;typeof E=="string"?c.storageProvider=E:c.storageProvider="none"}else c.storageProvider="none";if(c.framework==="react"||c.framework==="nextjs"){let g=(n.components||[]).find(v=>!v.supportedFrameworks||v.supportedFrameworks.includes(c.framework||""));if(g){let v=await(0,He.default)({type:"confirm",name:"add",message:`Add ${g.displayName||g.name}?${g.description?` \u203A ${g.description}`:""}`,initial:!0});c.components=v.add!==!1}else c.components=!1}else c.components=!1;if(c.database!=="none"||c.framework==="react"||c.framework==="nextjs"){let v=(Sn(n.auth,c.framework||"",c.database||"none",n.frameworks)||[]).map(T=>({title:T.name?T.description?`${T.name} \u2014 ${T.description}`:T.name:String(T.value??""),value:T.value??String(T.name??"")})),E=await(0,He.default)({type:"select",name:"auth",message:"Select authentication:",choices:v});c.auth=E.auth||"none"}else c.auth="none";let y=await(0,He.default)({type:"select",name:"language",message:"Language:",choices:[{title:"TypeScript",value:"typescript"},{title:"JavaScript",value:"javascript"}],initial:0});c.language=y.language||"typescript";let x=await(0,He.default)({type:"select",name:"packageManager",message:"Package manager:",choices:[{title:"pnpm (recommended)",value:"pnpm"},{title:"npm",value:"npm"},{title:"yarn",value:"yarn"},{title:"bun",value:"bun"}],initial:0});c.packageManager=x.packageManager||"pnpm";let b=c.database,S=c.prismaProvider;if(typeof b=="string"&&b.startsWith("prisma-")){let g=b.split("-");g.length>=2&&(S=g[1],b="prisma")}return{projectName:t||c.projectName,framework:c.framework,database:b,prismaProvider:S,auth:c.auth||"none",language:c.language,packageManager:c.packageManager,ui:c.ui||"none",storageProvider:c.storageProvider||"none",components:c.components??!1}}async function UF(t,e,r){let n=m.startSpinner("Creating project files..."),i=[];try{i=await VF(t,e),n.succeed("Project files created")}catch(s){throw n.fail("Failed to create project files"),s}if(r?.install!==!1&&!(r?.["skip-install"]||r?.skipInstall)){let s=m.startSpinner("Installing dependencies...");try{await bo(e,t.packageManager),s.succeed("Dependencies installed")}catch(o){throw s.fail("Failed to install dependencies"),o}}if(i.length>0&&r?.install!==!1&&!(r?.["skip-install"]||r?.skipInstall)){let s=m.startSpinner("Running post-install commands...");try{for(let o of i)(0,iO.execSync)(o,{cwd:e,stdio:"inherit"});s.succeed("Post-install commands completed")}catch(o){throw s.fail("Failed to run post-install commands"),o}}if(r?.git!==!1&&!(r?.["no-git"]||r?.noGit))try{await WE(e)}catch(s){m.warn(`Failed to initialize git repository: ${s.message}`)}}async function VF(t,e){let r=M(),n=we.default.join(r,"templates"),i=we.default.join(r,"modules");await z.default.ensureDir(e);let s=await Ji.loadFrameworkConfig(t.framework,n),o=new Or(s);await o.loadGenerators(i);let a=[],l=await o.generate({framework:t.framework,database:t.database==="none"?void 0:t.database,auth:t.auth==="none"?void 0:t.auth,prismaProvider:t.prismaProvider,ui:t.ui,storageProvider:t.storageProvider,components:t.components===!0?!0:void 0,packageManager:t.packageManager},a,e),u=we.default.join(e,"package.json");if(await z.default.pathExists(u)){let c=await z.default.readJson(u);c.name=t.projectName,await z.default.writeJson(u,c,{spaces:2})}try{let c=we.default.join(e,".env.example"),d=we.default.join(e,".env");if(await z.default.pathExists(c)&&!await z.default.pathExists(d)){let f=await z.default.readFile(c,"utf-8");await z.default.writeFile(d,f)}}catch(c){}return t.language==="javascript"&&await nO(e,t.framework),l}async function WF(t,e){let r=we.default.join(M(),"modules"),n=[];if(t.database&&t.database!=="none"){let i=we.default.join(r,"database",t.database,"generator.json");if(await z.default.pathExists(i)){let s=await z.default.readJson(i);if(s.operations){for(let o of s.operations)if(o.type==="add-env"&&(!o.condition||Xn(o.condition,t)))for(let[a,l]of Object.entries(o.envVars))n.push({key:a,value:l,required:!0})}}}if(t.auth&&t.auth!=="none"){let i=we.default.join(r,"auth",t.auth,"generator.json");if(await z.default.pathExists(i)){let s=await z.default.readJson(i);if(s.operations){for(let o of s.operations)if(o.type==="add-env"&&(!o.condition||Xn(o.condition,t)))for(let[a,l]of Object.entries(o.envVars))n.push({key:a,value:l,required:!0})}}}if(t.ui&&t.ui!=="none"){let i=we.default.join(r,"ui",t.ui,"generator.json");if(await z.default.pathExists(i)){let s=await z.default.readJson(i);if(s.operations){for(let o of s.operations)if(o.type==="add-env"&&(!o.condition||Xn(o.condition,t)))for(let[a,l]of Object.entries(o.envVars))n.push({key:a,value:l,required:!0})}}}if(t.storageProvider&&t.storageProvider!=="none"){let i=we.default.join(r,"storage",t.storageProvider,"generator.json");if(await z.default.pathExists(i)){let s=await z.default.readJson(i);if(s.operations){for(let o of s.operations)if(o.type==="add-env"&&(!o.condition||Xn(o.condition,t)))for(let[a,l]of Object.entries(o.envVars))n.push({key:a,value:l,required:!0})}}}if(t.components===!0){let i=we.default.join(r,"components","generator.json");if(await z.default.pathExists(i)){let s=await z.default.readJson(i);if(s.operations){for(let o of s.operations)if(o.type==="add-env"&&(!o.condition||Xn(o.condition,t)))for(let[a,l]of Object.entries(o.envVars))n.push({key:a,value:l,required:!0})}}}n.length>0&&await Hi(e,n,{force:!0})}function Xn(t,e){for(let[r,n]of Object.entries(t))if(Array.isArray(n)){if(!n.includes(e[r]))return!1}else if(e[r]!==n)return!1;return!0}function HF(t){m.newLine(),m.success(`Created ${t.projectName}`),m.newLine(),m.log("Next steps:"),m.log(` cd ${t.projectName}`),m.log(` ${t.packageManager} run dev`),m.newLine()}var W=C(fe()),K=C(require("path"));var q={NO_PACKAGE_JSON:"No package.json found in current directory or any parent directory.",UNSUPPORTED_PROJECT:"Unsupported project type or unable to detect framework.",NODE_TOO_OLD:t=>`Node.js version ${t} is not supported. Minimum required: Node 18.`,NODE_WARNING:t=>`Node.js version ${t} is supported but Node 20+ is recommended.`,NODE_SUCCESS:t=>`Node.js version ${t} is supported.`,ENV_EXAMPLE_MISSING:".env.example file missing (recommended for documentation)",ENV_EXAMPLE_FOUND:".env.example file found",ENV_MISSING:"No .env or .env.local file found",ENV_FOUND:".env/.env.local file found",PRISMA_SCHEMA_MISSING:"Prisma schema missing (required for Prisma)",PRISMA_SCHEMA_FOUND:"Prisma schema found",AUTH_ROUTES_MISSING:"Auth routes not found (may need configuration)",AUTH_ROUTES_FOUND:"Auth routes configured",ENV_VARS_MISSING:t=>`Missing: ${t.join(", ")}`,ENV_VARS_PRESENT:t=>`Present: ${t.join(", ")}`,TSCONFIG_MISSING:"tsconfig.json missing (required for TypeScript)",TSCONFIG_FOUND:"tsconfig.json found",ESLINT_CONFIG_MISSING:"ESLint config missing (recommended for code quality)",ESLINT_CONFIG_FOUND:"ESLint config found",BUILD_SCRIPT_MISSING:"Build script missing in package.json",BUILD_SCRIPT_FOUND:"Build script found",DEPENDENCY_OUTDATED:t=>`Outdated dependencies: ${t.join(", ")}`,DEPENDENCY_UP_TO_DATE:"Dependencies are up to date",GIT_REPO_MISSING:"Not a git repository (recommended for version control)",GIT_REPO_FOUND:"Git repository initialized"};async function aO(t){try{let e=await JF();if(t.json){process.stdout.write(JSON.stringify(e,null,2)+`
|
|
234
|
+
`);return}oN(e,t.verbose||!1);let r=e.summary.errors>0,n=e.summary.warnings>0,i=t.strict||!1;r||i&&n?process.exit(1):process.exit(0)}catch(e){m.error(`Doctor check failed: ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}async function JF(){let t=[],e=await YF();t.push({status:"success",message:`Found project root: ${e}`});let r=await zF(e),n=await KF(e),i=XF(r);i==="unknown"?t.push({status:"error",message:q.UNSUPPORTED_PROJECT}):t.push({status:"success",message:`Detected project type: ${i}`});let s=ZF();t.push(s);let o=await xo(r),a=await vo(r),l=await QF(e,i,o,a);t.push(...l);let u=await eN(e,o,a);t.push(...u.checks);let c=await rN(e,i,r);t.push(...c);let d=await nN(r);t.push(d);let f=await iN(e);t.push(f);let h=tN(o,a);return h.forEach(y=>{t.push({status:"warning",message:y})}),{project:{type:i,root:e,packageManager:n},runtime:{nodeVersion:process.version,nodeVersionStatus:s.status},modules:{auth:o,database:a},files:{envExample:await W.default.pathExists(K.default.join(e,".env.example")),env:await W.default.pathExists(K.default.join(e,".env"))||await W.default.pathExists(K.default.join(e,".env.local")),prismaSchema:a.includes("prisma")?await W.default.pathExists(K.default.join(e,"prisma","schema.prisma")):void 0,authRoutes:o.length>0?await cO(e):void 0,tsconfig:await W.default.pathExists(K.default.join(e,"tsconfig.json")),eslintConfig:await lO(e),git:await W.default.pathExists(K.default.join(e,".git"))},env:u.envStatus,dependencies:{outdated:d.outdated},conflicts:h,checks:t,summary:{errors:t.filter(y=>y.status==="error").length,warnings:t.filter(y=>y.status==="warning").length,suggestions:sN(o,a)}}}async function YF(){let t=process.cwd();for(;t!==K.default.dirname(t);){let e=K.default.join(t,"package.json");if(await W.default.pathExists(e))return t;t=K.default.dirname(t)}throw new Error(q.NO_PACKAGE_JSON)}async function zF(t){let e=K.default.join(t,"package.json");return await W.default.readJSON(e)}async function KF(t){let e=[{file:"pnpm-lock.yaml",manager:"pnpm"},{file:"yarn.lock",manager:"yarn"},{file:"package-lock.json",manager:"npm"}];for(let r of e)if(await W.default.pathExists(K.default.join(t,r.file)))return r.manager;return"npm"}function XF(t){let e={...t.dependencies,...t.devDependencies};try{let r=K.default.join(M(),"templates");if(W.default.existsSync(r)){let n=W.default.readdirSync(r);for(let i of n){let s=K.default.join(r,i,"template.json");if(W.default.existsSync(s))try{let o=JSON.parse(W.default.readFileSync(s,"utf-8"));if(o&&o.framework&&e[o.framework])return o.framework}catch{continue}}}}catch(r){}return e.next?"nextjs":e.express?"express":e.vite&&e.react||e.react?"react":"unknown"}function ZF(){let t=process.version,e=parseInt(t.slice(1).split(".")[0]);return e<18?{status:"error",message:q.NODE_TOO_OLD(t)}:e<20?{status:"warning",message:q.NODE_WARNING(t)}:{status:"success",message:q.NODE_SUCCESS(t)}}async function QF(t,e,r,n){let i=[],s=await W.default.pathExists(K.default.join(t,".env.example"));if(i.push({status:s?"success":"warning",message:s?".env.example file found":".env.example file missing (recommended for documentation)"}),n.includes("prisma")){let o=await W.default.pathExists(K.default.join(t,"prisma","schema.prisma"));i.push({status:o?"success":"error",message:o?"Prisma schema found":"Prisma schema missing (required for Prisma)"})}if(r.length>0){let o=await cO(t);i.push({status:o?"success":"warning",message:o?"Auth routes configured":"Auth routes not found (may need configuration)"})}return i}async function cO(t){let e=new Set;try{let r=K.default.join(M(),"modules","auth");if(await W.default.pathExists(r)){let n=await W.default.readdir(r);for(let i of n){let s=K.default.join(r,i,"generator.json");if(await W.default.pathExists(s))try{let o=await W.default.readJson(s);if(Array.isArray(o.operations)){for(let a of o.operations)if(typeof a.destination=="string"&&e.add(a.destination),Array.isArray(a.operations))for(let l of a.operations)typeof l.destination=="string"&&e.add(l.destination)}}catch{continue}}}}catch(r){}if(e.size===0)return!1;for(let r of e)if(await W.default.pathExists(K.default.join(t,r)))return!0;return!1}async function eN(t,e,r){let n=[],i=[],s=[],o=[];try{let d=K.default.join(M(),"modules");async function f(h,p){let y=K.default.join(d,h,p,"generator.json");if(await W.default.pathExists(y))try{let x=await W.default.readJson(y);if(Array.isArray(x.operations))for(let b of x.operations){if(b.type==="add-env"&&b.envVars&&typeof b.envVars=="object")for(let S of Object.keys(b.envVars))i.includes(S)||i.push(S);if(Array.isArray(b.operations)){for(let S of b.operations)if(S.type==="add-env"&&S.envVars&&typeof S.envVars=="object")for(let g of Object.keys(S.envVars))i.includes(g)||i.push(g)}}}catch{return}}for(let h of r)await f("database",h);for(let h of e)await f("auth",h)}catch(d){}let a=[".env",".env.local"],l="";for(let d of a){let f=K.default.join(t,d);if(await W.default.pathExists(f)){l=await W.default.readFile(f,"utf-8");break}}if(!l)return n.push({status:"warning",message:"No .env or .env.local file found"}),{checks:n,envStatus:{missing:i,present:[]}};let u=l.split(`
|
|
235
|
+
`).map(d=>d.trim()).filter(d=>d&&!d.startsWith("#")),c=new Set(u.map(d=>d.split("=")[0]));for(let d of i)c.has(d)?o.push(d):s.push(d);return s.length>0?n.push({status:"error",message:`Missing required environment variables: ${s.join(", ")}`}):i.length>0&&n.push({status:"success",message:"All required environment variables are present"}),{checks:n,envStatus:{missing:s,present:o}}}function tN(t,e){let r=[];return t.length>1&&r.push(`Multiple auth providers detected: ${t.join(", ")}. Consider using only one.`),e.length>1&&r.push(`Multiple database providers detected: ${e.join(", ")}. Consider using only one.`),r}async function rN(t,e,r){let n=[],i=await W.default.pathExists(K.default.join(t,"tsconfig.json"));n.push({status:i?"success":"error",message:i?q.TSCONFIG_FOUND:q.TSCONFIG_MISSING});let s=await lO(t);n.push({status:s?"success":"warning",message:s?q.ESLINT_CONFIG_FOUND:q.ESLINT_CONFIG_MISSING});let o=r.scripts&&typeof r.scripts=="object"&&"build"in r.scripts;return n.push({status:o?"success":"warning",message:o?q.BUILD_SCRIPT_FOUND:q.BUILD_SCRIPT_MISSING}),n}async function nN(t){let e=[],r={...t.dependencies,...t.devDependencies};for(let[n,i]of Object.entries(r||{}))typeof i=="string"&&(i.startsWith("^")||i.startsWith("~"))||e.push(n);return{status:e.length>0?"warning":"success",message:e.length>0?q.DEPENDENCY_OUTDATED(e):q.DEPENDENCY_UP_TO_DATE,outdated:e}}async function iN(t){let e=await W.default.pathExists(K.default.join(t,".git"));return{status:e?"success":"warning",message:e?q.GIT_REPO_FOUND:q.GIT_REPO_MISSING}}async function lO(t){let e=[".eslintrc.js",".eslintrc.json",".eslintrc.yml",".eslintrc.yaml","eslint.config.js","eslint.config.cjs","eslint.config.mjs"];for(let r of e)if(await W.default.pathExists(K.default.join(t,r)))return!0;return!1}function sN(t,e){let r=[];return t.length===0&&r.push("stackkit add auth - Add authentication module"),e.length===0&&r.push("stackkit add database - Add database module"),r.push("stackkit list - View available modules"),r}function oN(t,e){m.header("\u{1F50D} StackKit Doctor Report"),m.newLine(),m.log(P.bold("Project")),m.log(` Type: ${t.project.type}`),m.log(` Root: ${t.project.root}`),m.log(` Package Manager: ${t.project.packageManager}`),m.newLine(),m.log(P.bold("Runtime")),t.runtime.nodeVersionStatus==="success"?m.success(`Node.js: ${t.runtime.nodeVersion}`):t.runtime.nodeVersionStatus==="warning"?m.warn(`Node.js: ${t.runtime.nodeVersion}`):m.error(`Node.js: ${t.runtime.nodeVersion}`),m.newLine(),m.log(P.bold("Modules")),t.modules.auth.length>0?m.log(` Auth: ${t.modules.auth.join(", ")}`):m.info("Auth: None"),t.modules.database.length>0?m.log(` Database: ${t.modules.database.join(", ")}`):m.info("Database: None"),m.newLine(),m.log(P.bold("Files")),t.files.envExample?m.success(q.ENV_EXAMPLE_FOUND):(m.warn(q.ENV_EXAMPLE_MISSING),m.log(" Hint: Helps other developers understand required environment variables")),t.files.env?m.success(q.ENV_FOUND):(m.warn(q.ENV_MISSING),m.log(" Hint: Required for local development and production deployment")),t.files.prismaSchema!==void 0&&(t.files.prismaSchema?m.success(q.PRISMA_SCHEMA_FOUND):(m.error(q.PRISMA_SCHEMA_MISSING),m.log(" Hint: Defines your database schema and is required for Prisma to work"))),t.files.authRoutes!==void 0&&(t.files.authRoutes?m.success(q.AUTH_ROUTES_FOUND):(m.warn(q.AUTH_ROUTES_MISSING),m.log(" Hint: Authentication routes handle login/logout flows"))),t.files.tsconfig!==void 0&&(t.files.tsconfig?m.success(q.TSCONFIG_FOUND):(m.error(q.TSCONFIG_MISSING),m.log(" Hint: Required for TypeScript compilation"))),t.files.eslintConfig!==void 0&&(t.files.eslintConfig?m.success(q.ESLINT_CONFIG_FOUND):(m.warn(q.ESLINT_CONFIG_MISSING),m.log(" Hint: Helps maintain code quality"))),t.files.git!==void 0&&(t.files.git?m.success(q.GIT_REPO_FOUND):(m.warn(q.GIT_REPO_MISSING),m.log(" Hint: Recommended for version control"))),m.newLine(),t.dependencies.outdated.length>0&&(m.log(P.bold("Dependencies")),m.warn(q.DEPENDENCY_OUTDATED(t.dependencies.outdated)),m.log(" Hint: Run package manager update command"),m.newLine()),(t.env.missing.length>0||t.env.present.length>0)&&(m.log(P.bold("Environment Variables")),t.env.present.length>0&&m.success(q.ENV_VARS_PRESENT(t.env.present)),t.env.missing.length>0&&m.error(q.ENV_VARS_MISSING(t.env.missing)),m.newLine()),t.conflicts.length>0&&(m.log(P.bold("Conflicts")),t.conflicts.forEach(r=>{m.warn(r)}),m.newLine()),e&&(m.log(P.bold("Detailed Checks")),t.checks.forEach(r=>{r.status==="success"?m.success(r.message):r.status==="warning"?m.warn(r.message):m.error(r.message),r.details&&m.log(` ${P.gray(r.details)}`)}),m.newLine()),m.log(P.bold("Summary")),m.log(` Errors: ${t.summary.errors}`),m.log(` Warnings: ${t.summary.warnings}`),m.newLine(),t.summary.suggestions.length>0&&(m.log(P.bold("Suggestions")),t.summary.suggestions.forEach(r=>{m.log(` \u2022 ${r}`)}))}var qu=C(fe()),yO=C(require("path"));var Gu=C(require("path"));var Eo=C(fe());async function $u(t){return Eo.default.pathExists(t)}async function Lu(t){return Eo.default.readdir(t)}async function uO(t){try{return(await Eo.default.stat(t)).isDirectory()}catch{return!1}}var dO=require("fs"),fO=C(fe());async function hO(t){try{return await fO.default.readJSON(t)}catch{return null}}function zr(t){try{return JSON.parse((0,dO.readFileSync)(t,"utf-8"))}catch{return null}}var Kr=C(require("path"));function Zn(){return Kr.default.join(M(),Ii.MODULES)}function aN(t,e){return Kr.default.join(Zn(),t,e)}function Xr(t,e){return Kr.default.join(aN(t,e),ye.MODULE_JSON)}function pO(){return Kr.default.join(Zn(),Te.DATABASE)}function mO(){return Kr.default.join(Zn(),Te.AUTH)}async function gO(){let t=Zn();if(!await $u(t))return[];let e=[],r=await Lu(t);for(let n of r){let i=Gu.default.join(t,n);if(!await uO(i))continue;let s=await Lu(i);for(let o of s){let a=Gu.default.join(i,o,"module.json");if(await $u(a)){let l=await hO(a);l&&e.push(l)}}}return e}async function wO(t={}){let e=!t.modules||t.frameworks,r=!t.frameworks||t.modules;try{m.header("StackKit Resources"),m.newLine();let n=!1;if(e){let i=[];i=await pN(),i.length>0&&(n=!0,cN(i))}if(r){let i=[];i=await mN(),i.length>0&&(n=!0,lN(i))}n||(m.log(P.dim("No resources available")),m.newLine()),m.log(P.dim("Use 'stackkit add <module>' to add modules to your project")),m.newLine()}catch(n){m.error(`Failed to list resources: ${n.message}`,n),process.exit(1)}}function cN(t){m.log(P.bold.blue("FRAMEWORKS")),t.forEach((e,r)=>{let i=r===t.length-1?"\u2514\u2500\u2500":"\u251C\u2500\u2500";m.log(` ${P.gray(i)} ${P.cyan(e.displayName)}`)}),m.newLine()}function lN(t){m.log(P.bold.magenta("MODULES"));let e=hN(t),r=Object.keys(e);r.forEach((n,i)=>{let s=e[n],o=i===r.length-1,a=o?"\u2514\u2500\u2500":"\u251C\u2500\u2500";m.log(` ${P.gray(a)} ${P.yellow(yN(n))} ${P.dim(`(${s.length})`)}`),s.forEach((l,u)=>{let c=u===s.length-1,d=dN(o,c);m.log(` ${P.gray(d)} ${P.green(l.displayName)}`),l.category==="database"&&l.name==="prisma"&&uN(o,c)})}),m.newLine()}function uN(t,e){let r=fN(t,e),n=De(M()),i=n.length?n.map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(", "):"None";m.log(` ${P.gray(r)} ${P.dim(`Providers: ${i}`)}`)}function dN(t,e){return t?e?" \u2514\u2500\u2500":" \u251C\u2500\u2500":e?"\u2502 \u2514\u2500\u2500":"\u2502 \u251C\u2500\u2500"}function fN(t,e){return t?e?" \u2514\u2500\u2500":" \u251C\u2500\u2500":e?"\u2502 \u2514\u2500\u2500":"\u2502 \u251C\u2500\u2500"}function hN(t){return t.reduce((e,r)=>{let n=r.category||"other";return e[n]||(e[n]=[]),e[n].push(r),e},{})}async function pN(){let t=yO.default.join(M(),"templates");return await qu.default.pathExists(t)?(await qu.default.readdir(t)).filter(r=>r!=="node_modules"&&r!==".git").map(r=>({name:r,displayName:gN(r)})):[]}async function mN(){return gO()}function gN(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function yN(t){return t.charAt(0).toUpperCase()+t.slice(1)}var wN=zr((0,To.join)(__dirname,"../package.json"));function bN(){try{let t=pO(),e=mO(),r=[],n=[];if(_e.existsSync(t))for(let l of _e.readdirSync(t)){let u=Xr(Te.DATABASE,l);if(_e.existsSync(u)){let c=zr(u);if(c&&c.name==="prisma"){let d=De(M());d.length>0?d.forEach(f=>r.push(`prisma-${f}`)):r.push("prisma")}else c&&c.name&&r.push(c.name)}}if(_e.existsSync(e))for(let l of _e.readdirSync(e)){let u=Xr(Te.AUTH,l);if(_e.existsSync(u)){let c=zr(u);c&&c.name&&n.push(c.name)}}let i=(0,To.join)(M(),"modules","ui"),s=(0,To.join)(M(),"modules","storage"),o=[],a=[];if(_e.existsSync(i))for(let l of _e.readdirSync(i)){let u=Xr(Te.UI,l);if(_e.existsSync(u)){let c=zr(u);c&&c.name&&o.push(c.name)}}if(_e.existsSync(s))for(let l of _e.readdirSync(s)){let u=Xr(Te.STORAGE,l);if(_e.existsSync(u)){let c=zr(u);c&&c.name&&a.push(c.name)}}return{databaseHint:r.length>0?r.join(", "):"none",authHint:n.length>0?n.join(", "):"none",uiHint:o.length>0?o.join(", "):"none",storageHint:a.length>0?a.join(", "):"none"}}catch{return{databaseHint:"none",authHint:"none",uiHint:"none",storageHint:"none"}}}var Oo=bN(),Ht=new rd;Ht.name("stackkit").description("CLI for creating and managing StackKit projects").version(wN?.version||"0.0.0").configureHelp({subcommandTerm:t=>{let e=t.name();return e==="create"?"create [project-name] [options]":e==="add"?"add <module> [options]":e==="doctor"?"doctor [options]":e==="list"?"list [options]":e==="help"?"help [command]":e+" [options]"}});Ht.command("create [project-name]").description("Create a new StackKit project").usage("[project-name] [options]").option("-f, --framework <framework>","Framework (discovered)").option("-d, --database <database>",`Database: ${Oo.databaseHint}`).option("--prisma-provider <provider>","Prisma provider").option("-a, --auth <auth>",`Auth: ${Oo.authHint}`).option("-u, --ui <ui>",`UI: ${Oo.uiHint}`).option("--storage-provider <provider>",`Storage: ${Oo.storageHint}`).option("-l, --language <language>","Language: typescript, javascript").option("-p, --package-manager <pm>","Package manager: pnpm, npm, yarn, bun").option("--skip-install","Skip dependency installation").option("--no-git","Skip git initialization").option("-y, --yes","Use default options").action(async(t,e)=>{try{await oO(t,e)}catch(r){m.error(`Error: ${r.message}`,r),process.exit(1)}});Ht.command("add [module]").description("Add a module or category to your existing project").usage("[module] [options]").option("--provider <provider>","Specific provider/variant to use").option("--force","Overwrite existing files").option("--dry-run","Show what would be changed without making changes").option("--no-install","Skip installing dependencies").option("-y, --yes","Use default options").action(async(t,e)=>{try{await zE(t,e)}catch(r){m.error(`Error: ${r.message}`,r),process.exit(1)}});Ht.command("doctor").description("Check project health and compatibility with StackKit modules").option("--json","Output results in JSON format").option("--verbose","Show detailed information").option("--strict","Treat warnings as errors").action(async t=>{try{await aO(t)}catch(e){m.error(`Error: ${e.message}`,e),process.exit(1)}});Ht.command("list").description("List available frameworks and modules").option("-f, --frameworks","List only frameworks").option("-m, --modules","List only modules").action(async t=>{try{await wO(t)}catch(e){m.error(`Error: ${e.message}`),process.exit(1)}});Ht.on("command:*",()=>{m.error(`Invalid command: ${Ht.args.join(" ")}`),m.log("Run stackkit --help for a list of available commands."),process.exit(1)});Ht.parse();
|