@stackedhq/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +217 -0
- package/dist/index.js +102 -0
- package/package.json +47 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@stackedhq/cli` are documented here. The JSON/agent contract (`schemaVersion`, `error.code`, exit codes) follows the stability rules in `README.md`.
|
|
4
|
+
|
|
5
|
+
## [0.1.0] - 2026-06-19
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Platform operations: `redeploy`, `deployments list|get|cancel`, `logs`, `restart`, `stop`
|
|
10
|
+
- Environment variables: `env list|set|unset|pull`
|
|
11
|
+
- Read-only inventory: `machines list|get`, `databases list|get`, `domains list`, `projects list`
|
|
12
|
+
- SSE log streaming (`lib/stream.ts`); `DEPLOYMENT_IN_FLIGHT` error code
|
|
13
|
+
- Shared deployment watch loop for `deploy` / `redeploy`
|
|
14
|
+
|
|
15
|
+
### Notes
|
|
16
|
+
|
|
17
|
+
- First public npm release. Install: `npm i -g @stackedhq/cli`.
|
package/README.md
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# @stackedhq/cli
|
|
2
|
+
|
|
3
|
+
The Stacked CLI. Deploy, manage, and inspect your [Stacked](https://stacked.rest) services from the terminal — and drive them from agents and CI with first-class JSON output.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm i -g @stackedhq/cli
|
|
7
|
+
stacked --help
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
stacked login # browser-based device flow (default)
|
|
14
|
+
stacked status # one-shot view of auth, API, linked service
|
|
15
|
+
stacked services list # human table — or pipe with --json
|
|
16
|
+
stacked deploy <slug> # watches the deployment until it terminates
|
|
17
|
+
stacked redeploy <slug># re-run the latest deployment, faithful to its config
|
|
18
|
+
stacked logs <slug> # tail runtime logs (Ctrl-C to stop)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
|
|
23
|
+
### Auth & session
|
|
24
|
+
|
|
25
|
+
| Command | Description |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `stacked login` | Authenticate. Browser device flow by default; `--token <stk_…>` to paste. |
|
|
28
|
+
| `stacked logout` | Sign out. Revokes the token server-side unless `--keep-server`. |
|
|
29
|
+
| `stacked whoami` | Show the current user. |
|
|
30
|
+
| `stacked status` | Single-shot view of auth, API reachability, version, linked service. |
|
|
31
|
+
|
|
32
|
+
### Deploy & operate
|
|
33
|
+
|
|
34
|
+
| Command | Description |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `stacked deploy [service]` | Deploy a service from its current config. Defaults to the linked service. `--watch` (default in TTY) follows status; `--no-watch` returns the deployment id immediately; `--timeout <sec>` (default 600). |
|
|
37
|
+
| `stacked redeploy [service]` | Re-run the service's most recent deployment, faithful to the exact image/git ref it shipped. Same `--watch`/`--no-watch`/`--timeout` flags as `deploy`. |
|
|
38
|
+
| `stacked deployments list [service]` | List a service's deployment history, or recent deployments across all services. |
|
|
39
|
+
| `stacked deployments get <id>` | Show one deployment. |
|
|
40
|
+
| `stacked deployments cancel <id>` | Cancel an in-flight deployment. |
|
|
41
|
+
| `stacked logs [service]` | Tail runtime container logs. `--deployment <id>` streams a deployment's build logs instead; `--no-follow` captures current logs and exits. |
|
|
42
|
+
| `stacked restart [service]` | Restart a service. |
|
|
43
|
+
| `stacked stop [service]` | Stop a service. |
|
|
44
|
+
|
|
45
|
+
### Environment variables
|
|
46
|
+
|
|
47
|
+
| Command | Description |
|
|
48
|
+
|---|---|
|
|
49
|
+
| `stacked env list [--service <id>]` | List a service's env vars. |
|
|
50
|
+
| `stacked env set KEY=VALUE … [--service <id>]` | Upsert one or more vars (additive). |
|
|
51
|
+
| `stacked env unset KEY … [--service <id>]` | Remove vars by key. |
|
|
52
|
+
| `stacked env pull [--service <id>] [--file .env] [--force]` | Write env vars to a dotenv file. |
|
|
53
|
+
|
|
54
|
+
`env` subcommands take their target from `--service <id-or-slug>` or the linked service. (Positionals are reserved for `KEY=VALUE` pairs / keys.)
|
|
55
|
+
|
|
56
|
+
### Inventory (read-only)
|
|
57
|
+
|
|
58
|
+
| Command | Description |
|
|
59
|
+
|---|---|
|
|
60
|
+
| `stacked services list` / `stacked services get <id-or-slug>` | List / show services. |
|
|
61
|
+
| `stacked machines list` / `stacked machines get <id>` | List / show connected machines. |
|
|
62
|
+
| `stacked databases list` / `stacked databases get <id>` | List / show databases. |
|
|
63
|
+
| `stacked domains list` | List domains. |
|
|
64
|
+
| `stacked projects list` | List projects. |
|
|
65
|
+
|
|
66
|
+
### Project link & misc
|
|
67
|
+
|
|
68
|
+
| Command | Description |
|
|
69
|
+
|---|---|
|
|
70
|
+
| `stacked link <service>` | Link the current directory to a service (writes `.stacked`). |
|
|
71
|
+
| `stacked unlink` | Remove `.stacked`. |
|
|
72
|
+
| `stacked open [service]` | Open the dashboard in your browser. |
|
|
73
|
+
| `stacked update` | Print (or `--run`) the upgrade command for your install. |
|
|
74
|
+
| `stacked completion [zsh\|bash\|fish]` | Emit a shell completion script. |
|
|
75
|
+
| `stacked schema` | Emit a JSON description of every command, error code, exit code, and env var. |
|
|
76
|
+
|
|
77
|
+
## Authentication
|
|
78
|
+
|
|
79
|
+
Three ways to provide a token, in precedence order:
|
|
80
|
+
|
|
81
|
+
1. **`--token <stk_…>`** flag — overrides everything, never persisted.
|
|
82
|
+
2. **`STACKED_TOKEN` env var** — for CI and agent workflows. Stateless: nothing is written to disk.
|
|
83
|
+
3. **Saved config** — written by `stacked login` after a successful browser device flow.
|
|
84
|
+
|
|
85
|
+
Tokens are minted at:
|
|
86
|
+
|
|
87
|
+
- **`stacked login`** — opens the browser, you click *Authorize*, the CLI exchanges the code for a token. No copy-pasting.
|
|
88
|
+
- **Dashboard → Settings → API keys** — create a named key for non-interactive workflows. Plaintext shown exactly once. Same primitive the CLI uses; usable from `curl`, agents, MCP servers, CI, anywhere.
|
|
89
|
+
|
|
90
|
+
Revoke any key from the same dashboard page.
|
|
91
|
+
|
|
92
|
+
## Agent & scripting mode
|
|
93
|
+
|
|
94
|
+
Pass `--json` (or `--output ndjson`) to get a stable, versioned envelope on stdout:
|
|
95
|
+
|
|
96
|
+
```jsonc
|
|
97
|
+
{
|
|
98
|
+
"schemaVersion": 1,
|
|
99
|
+
"ok": true,
|
|
100
|
+
"command": "services.list",
|
|
101
|
+
"requestId": "f0d4314f-…",
|
|
102
|
+
"data": { /* command-specific */ },
|
|
103
|
+
"meta": {
|
|
104
|
+
"apiUrl": "https://stacked.rest",
|
|
105
|
+
"apiUrlSource": "default",
|
|
106
|
+
"authSource": "env",
|
|
107
|
+
"durationMs": 142,
|
|
108
|
+
"cliVersion": "0.0.1"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
On failure:
|
|
114
|
+
|
|
115
|
+
```jsonc
|
|
116
|
+
{
|
|
117
|
+
"schemaVersion": 1,
|
|
118
|
+
"ok": false,
|
|
119
|
+
"command": "deploy",
|
|
120
|
+
"error": {
|
|
121
|
+
"code": "NOT_AUTHENTICATED",
|
|
122
|
+
"message": "Run `stacked login` first.",
|
|
123
|
+
"httpStatus": 401,
|
|
124
|
+
"hint": { "action": "login" }
|
|
125
|
+
},
|
|
126
|
+
"meta": { /* … */ }
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`error.code` is a closed enum — adding new codes is non-breaking; renaming or removing one bumps `schemaVersion`. Run `stacked schema` to enumerate every code, exit code, and env var.
|
|
131
|
+
|
|
132
|
+
### Exit codes
|
|
133
|
+
|
|
134
|
+
| Code | Meaning |
|
|
135
|
+
|---|---|
|
|
136
|
+
| `0` | Success |
|
|
137
|
+
| `1` | Generic / unknown |
|
|
138
|
+
| `2` | `USER_INPUT_ERROR` / `VALIDATION_ERROR` |
|
|
139
|
+
| `3` | `NOT_AUTHENTICATED` |
|
|
140
|
+
| `4` | `FORBIDDEN` / `FORBIDDEN_PRELAUNCH` |
|
|
141
|
+
| `5` | `NOT_FOUND` |
|
|
142
|
+
| `6` | `CONFLICT` / `DEPLOYMENT_IN_FLIGHT` (a deployment is already running for the service) |
|
|
143
|
+
| `7` | `RATE_LIMITED` |
|
|
144
|
+
| `8` | `NETWORK_ERROR` |
|
|
145
|
+
| `9` | `SERVER_ERROR` |
|
|
146
|
+
| `10` | `DEPLOYMENT_FAILED` (deploy ended in `failed`/`cancelled`) |
|
|
147
|
+
| `11` | `TIMEOUT` (watched deploy didn't terminate before `--timeout`) |
|
|
148
|
+
|
|
149
|
+
### Progress events
|
|
150
|
+
|
|
151
|
+
In JSON / ndjson mode, the runtime stays silent on stderr by default. Pass `--verbose` (or set `STACKED_JSON_EVENTS=1`) to receive ndjson progress events on stderr — useful while watching a deployment.
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
stacked --json --verbose deploy myapp 2> events.ndjson
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Agent recipes
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Redeploy and block until it's live, parsing the result envelope.
|
|
161
|
+
stacked redeploy myapp --json --watch | jq -e '.ok and .data.status == "success"'
|
|
162
|
+
|
|
163
|
+
# Trigger a deploy without blocking, then poll on your own cadence.
|
|
164
|
+
ID=$(stacked deploy myapp --json --no-watch | jq -r .data.deploymentId)
|
|
165
|
+
stacked deployments get "$ID" --json
|
|
166
|
+
|
|
167
|
+
# Capture the current logs (no streaming) for a diagnosis prompt.
|
|
168
|
+
stacked logs myapp --json --no-follow | jq -r '.data.lines[]'
|
|
169
|
+
|
|
170
|
+
# Read/patch config non-interactively.
|
|
171
|
+
stacked env list --service myapp --json
|
|
172
|
+
stacked env set DATABASE_URL=postgres://… LOG_LEVEL=debug --service myapp --json
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Note: log **following** can't be expressed as the single-shot JSON envelope, so
|
|
176
|
+
`--json` requires `--no-follow` (it captures the currently-buffered lines and
|
|
177
|
+
returns them once). Human mode follows by default and prints lines as they
|
|
178
|
+
arrive. `stacked schema` enumerates every command, arg, error code, and exit
|
|
179
|
+
code for agents to introspect without parsing `--help`.
|
|
180
|
+
|
|
181
|
+
## Environment variables
|
|
182
|
+
|
|
183
|
+
| Var | Purpose |
|
|
184
|
+
|---|---|
|
|
185
|
+
| `STACKED_TOKEN` | Long-lived API key. Overrides saved config. |
|
|
186
|
+
| `STACKED_API_URL` | Override API base URL (e.g. for a Cloudflare Tunnel). |
|
|
187
|
+
| `STACKED_DEBUG` | `1` → dump raw HTTP traffic to stderr (secrets redacted). |
|
|
188
|
+
| `STACKED_JSON_EVENTS` | `1` → emit ndjson progress events to stderr in JSON modes. |
|
|
189
|
+
| `STACKED_NO_UPDATE_CHECK` | `1` → disable the daily npm registry update probe. |
|
|
190
|
+
|
|
191
|
+
## Development
|
|
192
|
+
|
|
193
|
+
From the repo root:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
pnpm install
|
|
197
|
+
pnpm --filter @stackedhq/cli dev # run from source with hot reload
|
|
198
|
+
pnpm --filter @stackedhq/cli build # build to dist/
|
|
199
|
+
pnpm --filter @stackedhq/cli type-check
|
|
200
|
+
pnpm --filter @stackedhq/cli test
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Point the CLI at a local API while developing:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
STACKED_API_URL=http://localhost:3000 pnpm --filter @stackedhq/cli dev whoami
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Publishing
|
|
210
|
+
|
|
211
|
+
Maintainers: full runbook in **`docs/cli-release.md`** (version bump, manual publish, GitHub Actions **Publish CLI** with `NPM_TOKEN`).
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
pnpm --filter @stackedhq/cli test
|
|
215
|
+
pnpm --filter @stackedhq/cli build
|
|
216
|
+
cd packages/cli && npm publish --access public
|
|
217
|
+
```
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var Zt=Object.defineProperty;var kt=(u,D)=>{for(var i in D)Zt(u,i,{get:D[i],enumerable:!0,configurable:!0,set:(e)=>D[i]=()=>e})};var Yt=(u,D)=>()=>(u&&(D=u(u=0)),D);var YD={};kt(YD,{prompt:()=>kD,kCancel:()=>ZD});import I,{stdin as li,stdout as hi}from"node:process";import $D from"node:readline";import{WriteStream as oi}from"node:tty";function ci(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}function mi(){if(bD)return Qu;bD=1;let u="\x1B",D=`${u}[`,i="\x07",e={to(t,s){if(!s)return`${D}${t+1}G`;return`${D}${s+1};${t+1}H`},move(t,s){let a="";if(t<0)a+=`${D}${-t}D`;else if(t>0)a+=`${D}${t}C`;if(s<0)a+=`${D}${-s}A`;else if(s>0)a+=`${D}${s}B`;return a},up:(t=1)=>`${D}${t}A`,down:(t=1)=>`${D}${t}B`,forward:(t=1)=>`${D}${t}C`,backward:(t=1)=>`${D}${t}D`,nextLine:(t=1)=>`${D}E`.repeat(t),prevLine:(t=1)=>`${D}F`.repeat(t),left:`${D}G`,hide:`${D}?25l`,show:`${D}?25h`,save:`${u}7`,restore:`${u}8`},n={up:(t=1)=>`${D}S`.repeat(t),down:(t=1)=>`${D}T`.repeat(t)},r={screen:`${D}2J`,up:(t=1)=>`${D}1J`.repeat(t),down:(t=1)=>`${D}J`.repeat(t),line:`${D}2K`,lineEnd:`${D}K`,lineStart:`${D}1K`,lines(t){let s="";for(let a=0;a<t;a++)s+=this.line+(a<t-1?e.up():"");if(t)s+=e.left;return s}};return Qu={cursor:e,scroll:n,erase:r,beep:i},Qu}function Ei(){if(dD)return eu.exports;dD=1;let u=process||{},D=u.argv||[],i=u.env||{},e=!(!!i.NO_COLOR||D.includes("--no-color"))&&(!!i.FORCE_COLOR||D.includes("--color")||u.platform==="win32"||(u.stdout||{}).isTTY&&i.TERM!=="dumb"||!!i.CI),n=(s,a,F=s)=>(C)=>{let c=""+C,B=c.indexOf(a,s.length);return~B?s+r(c,a,F,B)+a:s+c+a},r=(s,a,F,C)=>{let c="",B=0;do c+=s.substring(B,C)+F,B=C+a.length,C=s.indexOf(a,B);while(~C);return c+s.substring(B)},t=(s=e)=>{let a=s?n:()=>String;return{isColorSupported:s,reset:a("\x1B[0m","\x1B[0m"),bold:a("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:a("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:a("\x1B[3m","\x1B[23m"),underline:a("\x1B[4m","\x1B[24m"),inverse:a("\x1B[7m","\x1B[27m"),hidden:a("\x1B[8m","\x1B[28m"),strikethrough:a("\x1B[9m","\x1B[29m"),black:a("\x1B[30m","\x1B[39m"),red:a("\x1B[31m","\x1B[39m"),green:a("\x1B[32m","\x1B[39m"),yellow:a("\x1B[33m","\x1B[39m"),blue:a("\x1B[34m","\x1B[39m"),magenta:a("\x1B[35m","\x1B[39m"),cyan:a("\x1B[36m","\x1B[39m"),white:a("\x1B[37m","\x1B[39m"),gray:a("\x1B[90m","\x1B[39m"),bgBlack:a("\x1B[40m","\x1B[49m"),bgRed:a("\x1B[41m","\x1B[49m"),bgGreen:a("\x1B[42m","\x1B[49m"),bgYellow:a("\x1B[43m","\x1B[49m"),bgBlue:a("\x1B[44m","\x1B[49m"),bgMagenta:a("\x1B[45m","\x1B[49m"),bgCyan:a("\x1B[46m","\x1B[49m"),bgWhite:a("\x1B[47m","\x1B[49m"),blackBright:a("\x1B[90m","\x1B[39m"),redBright:a("\x1B[91m","\x1B[39m"),greenBright:a("\x1B[92m","\x1B[39m"),yellowBright:a("\x1B[93m","\x1B[39m"),blueBright:a("\x1B[94m","\x1B[39m"),magentaBright:a("\x1B[95m","\x1B[39m"),cyanBright:a("\x1B[96m","\x1B[39m"),whiteBright:a("\x1B[97m","\x1B[39m"),bgBlackBright:a("\x1B[100m","\x1B[49m"),bgRedBright:a("\x1B[101m","\x1B[49m"),bgGreenBright:a("\x1B[102m","\x1B[49m"),bgYellowBright:a("\x1B[103m","\x1B[49m"),bgBlueBright:a("\x1B[104m","\x1B[49m"),bgMagentaBright:a("\x1B[105m","\x1B[49m"),bgCyanBright:a("\x1B[106m","\x1B[49m"),bgWhiteBright:a("\x1B[107m","\x1B[49m")}};return eu.exports=t(),eu.exports.createColors=t,eu.exports}function Bi({onlyFirst:u=!1}={}){let D=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(D,u?void 0:"g")}function GD(u){if(typeof u!="string")throw TypeError(`Expected a \`string\`, got \`${typeof u}\``);return u.replace(gi,"")}function UD(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}function X(u,D={}){if(typeof u!="string"||u.length===0||(D={ambiguousIsNarrow:!0,...D},u=GD(u),u.length===0))return 0;u=u.replace(bi()," ");let i=D.ambiguousIsNarrow?1:2,e=0;for(let n of u){let r=n.codePointAt(0);if(r<=31||r>=127&&r<=159||r>=768&&r<=879)continue;switch(Ai.eastAsianWidth(n)){case"F":case"W":e+=2;break;case"A":e+=i;break;default:e+=1}}return e}function yi(){let u=new Map;for(let[D,i]of Object.entries($)){for(let[e,n]of Object.entries(i))$[e]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},i[e]=$[e],u.set(n[0],n[1]);Object.defineProperty($,D,{value:i,enumerable:!1})}return Object.defineProperty($,"codes",{value:u,enumerable:!1}),$.color.close="\x1B[39m",$.bgColor.close="\x1B[49m",$.color.ansi=wD(),$.color.ansi256=yD(),$.color.ansi16m=vD(),$.bgColor.ansi=wD(qu),$.bgColor.ansi256=yD(qu),$.bgColor.ansi16m=vD(qu),Object.defineProperties($,{rgbToAnsi256:{value:(D,i,e)=>D===i&&i===e?D<8?16:D>248?231:Math.round((D-8)/247*24)+232:16+36*Math.round(D/255*5)+6*Math.round(i/255*5)+Math.round(e/255*5),enumerable:!1},hexToRgb:{value:(D)=>{let i=/[a-f\d]{6}|[a-f\d]{3}/i.exec(D.toString(16));if(!i)return[0,0,0];let[e]=i;e.length===3&&(e=[...e].map((r)=>r+r).join(""));let n=Number.parseInt(e,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:(D)=>$.rgbToAnsi256(...$.hexToRgb(D)),enumerable:!1},ansi256ToAnsi:{value:(D)=>{if(D<8)return 30+D;if(D<16)return 90+(D-8);let i,e,n;if(D>=232)i=((D-232)*10+8)/255,e=i,n=i;else{D-=16;let s=D%36;i=Math.floor(D/36)/5,e=Math.floor(s/6)/5,n=s%6/5}let r=Math.max(i,e,n)*2;if(r===0)return 30;let t=30+(Math.round(n)<<2|Math.round(e)<<1|Math.round(i));return r===2&&(t+=60),t},enumerable:!1},rgbToAnsi:{value:(D,i,e)=>$.ansi256ToAnsi($.rgbToAnsi256(D,i,e)),enumerable:!1},hexToAnsi:{value:(D)=>$.ansi256ToAnsi($.hexToAnsi256(D)),enumerable:!1}}),$}function SD(u,D,i){return String(u).normalize().replace(/\r\n/g,`
|
|
3
|
+
`).split(`
|
|
4
|
+
`).map((e)=>Ti(e,D,i)).join(`
|
|
5
|
+
`)}function zD(u,D){if(typeof u=="string")return ru.aliases.get(u)===D;for(let i of u)if(i!==void 0&&zD(i,D))return!0;return!1}function _i(u,D){if(u===D)return;let i=u.split(`
|
|
6
|
+
`),e=D.split(`
|
|
7
|
+
`),n=[];for(let r=0;r<Math.max(i.length,e.length);r++)i[r]!==e[r]&&n.push(r);return n}function nu(u,D){let i=u;i.isTTY&&i.setRawMode(D)}class O{constructor(u,D=!0){V(this,"input"),V(this,"output"),V(this,"_abortSignal"),V(this,"rl"),V(this,"opts"),V(this,"_render"),V(this,"_track",!1),V(this,"_prevFrame",""),V(this,"_subscribers",new Map),V(this,"_cursor",0),V(this,"state","initial"),V(this,"error",""),V(this,"value");let{input:i=li,output:e=hi,render:n,signal:r,...t}=u;this.opts=t,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=n.bind(this),this._track=D,this._abortSignal=r,this.input=i,this.output=e}unsubscribe(){this._subscribers.clear()}setSubscriber(u,D){let i=this._subscribers.get(u)??[];i.push(D),this._subscribers.set(u,i)}on(u,D){this.setSubscriber(u,{cb:D})}once(u,D){this.setSubscriber(u,{cb:D,once:!0})}emit(u,...D){let i=this._subscribers.get(u)??[],e=[];for(let n of i)n.cb(...D),n.once&&e.push(()=>i.splice(i.indexOf(n),1));for(let n of e)n()}prompt(){return new Promise((u,D)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),u(VD);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}let i=new oi(0);i._write=(e,n,r)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,""),this._cursor=this.rl?.cursor??0,this.emit("value",this.value)),r()},this.input.pipe(i),this.rl=$D.createInterface({input:this.input,output:i,tabSize:2,prompt:"",escapeCodeTimeout:50}),$D.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on("keypress",this.onKeypress),nu(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(_.cursor.show),this.output.off("resize",this.render),nu(this.input,!1),u(this.value)}),this.once("cancel",()=>{this.output.write(_.cursor.show),this.output.off("resize",this.render),nu(this.input,!1),u(VD)})})}onKeypress(u,D){if(this.state==="error"&&(this.state="active"),D?.name&&(!this._track&&ru.aliases.has(D.name)&&this.emit("cursor",ru.aliases.get(D.name)),ru.actions.has(D.name)&&this.emit("cursor",D.name)),u&&(u.toLowerCase()==="y"||u.toLowerCase()==="n")&&this.emit("confirm",u.toLowerCase()==="y"),u==="\t"&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit("value",this.opts.placeholder))),u&&this.emit("key",u.toLowerCase()),D?.name==="return"){if(this.opts.validate){let i=this.opts.validate(this.value);i&&(this.error=i instanceof Error?i.message:i,this.state="error",this.rl?.write(this.value))}this.state!=="error"&&(this.state="submit")}zD([u,D?.name,D?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
|
|
8
|
+
`),nu(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let u=SD(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
9
|
+
`).length-1;this.output.write(_.cursor.move(-999,u*-1))}render(){let u=SD(this._render(this)??"",process.stdout.columns,{hard:!0});if(u!==this._prevFrame){if(this.state==="initial")this.output.write(_.cursor.hide);else{let D=_i(this._prevFrame,u);if(this.restoreCursor(),D&&D?.length===1){let i=D[0];this.output.write(_.cursor.move(0,i)),this.output.write(_.erase.lines(1));let e=u.split(`
|
|
10
|
+
`);this.output.write(e[i]),this._prevFrame=u,this.output.write(_.cursor.move(0,e.length-i-1));return}if(D&&D?.length>1){let i=D[0];this.output.write(_.cursor.move(0,i)),this.output.write(_.erase.down());let e=u.split(`
|
|
11
|
+
`).slice(i);this.output.write(e.join(`
|
|
12
|
+
`)),this._prevFrame=u;return}this.output.write(_.erase.down())}this.output.write(u),this.state==="initial"&&(this.state="active"),this._prevFrame=u}}}function Ki(){return I.platform!=="win32"?I.env.TERM!=="linux":!!I.env.CI||!!I.env.WT_SESSION||!!I.env.TERMINUS_SUBLIME||I.env.ConEmuTask==="{cmd::Cmder}"||I.env.TERM_PROGRAM==="Terminus-Sublime"||I.env.TERM_PROGRAM==="vscode"||I.env.TERM==="xterm-256color"||I.env.TERM==="alacritty"||I.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}async function kD(u,D={}){let i=(e)=>{if(typeof e!=="symbol"||e.toString()!=="Symbol(clack:cancel)")return e;switch(D.cancel){case"reject":{let n=Error("Prompt cancelled.");if(n.name="ConsolaPromptCancelledError",Error.captureStackTrace)Error.captureStackTrace(n,kD);throw n}case"undefined":return;case"null":return null;case"symbol":return ZD;default:case"default":return D.default??D.initial}};if(!D.type||D.type==="text")return await Xi({message:u,defaultValue:D.default,placeholder:D.placeholder,initialValue:D.initial}).then(i);if(D.type==="confirm")return await Oi({message:u,initialValue:D.initial}).then(i);if(D.type==="select")return await ji({message:u,options:D.options.map((e)=>typeof e==="string"?{value:e,label:e}:e),initialValue:D.initial}).then(i);if(D.type==="multiselect")return await xi({message:u,options:D.options.map((e)=>typeof e==="string"?{value:e,label:e}:e),required:D.required,initialValues:D.initial}).then(i);throw Error(`Unknown prompt type: ${D.type}`)}var Qu,bD,_,eu,dD,fi,l,gi,PD,pi,Ai,$i=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g},bi,qu=10,wD=(u=0)=>(D)=>`\x1B[${D+u}m`,yD=(u=0)=>(D)=>`\x1B[${38+u};5;${D}m`,vD=(u=0)=>(D,i,e)=>`\x1B[${38+u};2;${D};${i};${e}m`,$,di,wi,vi,su,Mi=39,xu="\x07",RD="[",Ni="]",WD="m",uD,MD=(u)=>`${su.values().next().value}${RD}${u}${WD}`,ND=(u)=>`${su.values().next().value}${uD}${u}${xu}`,Si=(u)=>u.split(" ").map((D)=>X(D)),Lu=(u,D,i)=>{let e=[...D],n=!1,r=!1,t=X(GD(u[u.length-1]));for(let[s,a]of e.entries()){let F=X(a);if(t+F<=i?u[u.length-1]+=a:(u.push(a),t=0),su.has(a)&&(n=!0,r=e.slice(s+1).join("").startsWith(uD)),n){r?a===xu&&(n=!1,r=!1):a===WD&&(n=!1);continue}t+=F,t===i&&s<e.length-1&&(u.push(""),t=0)}!t&&u[u.length-1].length>0&&u.length>1&&(u[u.length-2]+=u.pop())},Vi=(u)=>{let D=u.split(" "),i=D.length;for(;i>0&&!(X(D[i-1])>0);)i--;return i===D.length?u:D.slice(0,i).join(" ")+D.slice(i).join("")},Ti=(u,D,i={})=>{if(i.trim!==!1&&u.trim()==="")return"";let e="",n,r,t=Si(u),s=[""];for(let[F,C]of u.split(" ").entries()){i.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let c=X(s[s.length-1]);if(F!==0&&(c>=D&&(i.wordWrap===!1||i.trim===!1)&&(s.push(""),c=0),(c>0||i.trim===!1)&&(s[s.length-1]+=" ",c++)),i.hard&&t[F]>D){let B=D-c,m=1+Math.floor((t[F]-B-1)/D);Math.floor((t[F]-1)/D)<m&&s.push(""),Lu(s,C,D);continue}if(c+t[F]>D&&c>0&&t[F]>0){if(i.wordWrap===!1&&c<D){Lu(s,C,D);continue}s.push("")}if(c+t[F]>D&&i.wordWrap===!1){Lu(s,C,D);continue}s[s.length-1]+=C}i.trim!==!1&&(s=s.map((F)=>Vi(F)));let a=[...s.join(`
|
|
13
|
+
`)];for(let[F,C]of a.entries()){if(e+=C,su.has(C)){let{groups:B}=new RegExp(`(?:\\${RD}(?<code>\\d+)m|\\${uD}(?<uri>.*)${xu})`).exec(a.slice(F).join(""))||{groups:{}};if(B.code!==void 0){let m=Number.parseFloat(B.code);n=m===Mi?void 0:m}else B.uri!==void 0&&(r=B.uri.length===0?void 0:B.uri)}let c=vi.codes.get(Number(n));a[F+1]===`
|
|
14
|
+
`?(r&&(e+=ND("")),n&&c&&(e+=MD(c))):C===`
|
|
15
|
+
`&&(n&&c&&(e+=MD(n)),r&&(e+=ND(r)))}return e},Ii,ru,VD,Gi,Ui=(u,D,i)=>(D in u)?Gi(u,D,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[D]=i,V=(u,D,i)=>(Ui(u,typeof D!="symbol"?D+"":D,i),i),HD,Pi,Ri=(u,D,i)=>(D in u)?Pi(u,D,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[D]=i,TD=(u,D,i)=>(Ri(u,typeof D!="symbol"?D+"":D,i),i),Wi,zi,Hi=(u,D,i)=>(D in u)?zi(u,D,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[D]=i,ID=(u,D,i)=>(Hi(u,typeof D!="symbol"?D+"":D,i),i),KD,JD,Ji,G=(u,D)=>Ji?u:D,Zi,ki,Yi,Qi,A,q,Xu,Ou,qi,_D,Li,au=(u)=>{switch(u){case"initial":case"active":return l.cyan(Zi);case"cancel":return l.red(ki);case"error":return l.yellow(Yi);case"submit":return l.green(Qi)}},ju=(u)=>{let{cursor:D,options:i,style:e}=u,n=u.maxItems??Number.POSITIVE_INFINITY,r=Math.max(process.stdout.rows-4,0),t=Math.min(r,Math.max(n,5)),s=0;D>=s+t-3?s=Math.max(Math.min(D-t+3,i.length-t),0):D<s+2&&(s=Math.max(D-2,0));let a=t<i.length&&s>0,F=t<i.length&&s+t<i.length;return i.slice(s,s+t).map((C,c,B)=>{let m=c===0&&a,g=c===B.length-1&&F;return m||g?l.dim("..."):e(C,c+s===D)})},Xi=(u)=>new JD({validate:u.validate,placeholder:u.placeholder,defaultValue:u.defaultValue,initialValue:u.initialValue,render(){let D=`${l.gray(A)}
|
|
16
|
+
${au(this.state)} ${u.message}
|
|
17
|
+
`,i=u.placeholder?l.inverse(u.placeholder[0])+l.dim(u.placeholder.slice(1)):l.inverse(l.hidden("_")),e=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${D.trim()}
|
|
18
|
+
${l.yellow(A)} ${e}
|
|
19
|
+
${l.yellow(q)} ${l.yellow(this.error)}
|
|
20
|
+
`;case"submit":return`${D}${l.gray(A)} ${l.dim(this.value||u.placeholder)}`;case"cancel":return`${D}${l.gray(A)} ${l.strikethrough(l.dim(this.value??""))}${this.value?.trim()?`
|
|
21
|
+
${l.gray(A)}`:""}`;default:return`${D}${l.cyan(A)} ${e}
|
|
22
|
+
${l.cyan(q)}
|
|
23
|
+
`}}}).prompt(),Oi=(u)=>{let D=u.active??"Yes",i=u.inactive??"No";return new HD({active:D,inactive:i,initialValue:u.initialValue??!0,render(){let e=`${l.gray(A)}
|
|
24
|
+
${au(this.state)} ${u.message}
|
|
25
|
+
`,n=this.value?D:i;switch(this.state){case"submit":return`${e}${l.gray(A)} ${l.dim(n)}`;case"cancel":return`${e}${l.gray(A)} ${l.strikethrough(l.dim(n))}
|
|
26
|
+
${l.gray(A)}`;default:return`${e}${l.cyan(A)} ${this.value?`${l.green(Xu)} ${D}`:`${l.dim(Ou)} ${l.dim(D)}`} ${l.dim("/")} ${this.value?`${l.dim(Ou)} ${l.dim(i)}`:`${l.green(Xu)} ${i}`}
|
|
27
|
+
${l.cyan(q)}
|
|
28
|
+
`}}}).prompt()},ji=(u)=>{let D=(i,e)=>{let n=i.label??String(i.value);switch(e){case"selected":return`${l.dim(n)}`;case"active":return`${l.green(Xu)} ${n} ${i.hint?l.dim(`(${i.hint})`):""}`;case"cancelled":return`${l.strikethrough(l.dim(n))}`;default:return`${l.dim(Ou)} ${l.dim(n)}`}};return new KD({options:u.options,initialValue:u.initialValue,render(){let i=`${l.gray(A)}
|
|
29
|
+
${au(this.state)} ${u.message}
|
|
30
|
+
`;switch(this.state){case"submit":return`${i}${l.gray(A)} ${D(this.options[this.cursor],"selected")}`;case"cancel":return`${i}${l.gray(A)} ${D(this.options[this.cursor],"cancelled")}
|
|
31
|
+
${l.gray(A)}`;default:return`${i}${l.cyan(A)} ${ju({cursor:this.cursor,options:this.options,maxItems:u.maxItems,style:(e,n)=>D(e,n?"active":"inactive")}).join(`
|
|
32
|
+
${l.cyan(A)} `)}
|
|
33
|
+
${l.cyan(q)}
|
|
34
|
+
`}}}).prompt()},xi=(u)=>{let D=(i,e)=>{let n=i.label??String(i.value);return e==="active"?`${l.cyan(qi)} ${n} ${i.hint?l.dim(`(${i.hint})`):""}`:e==="selected"?`${l.green(_D)} ${l.dim(n)}`:e==="cancelled"?`${l.strikethrough(l.dim(n))}`:e==="active-selected"?`${l.green(_D)} ${n} ${i.hint?l.dim(`(${i.hint})`):""}`:e==="submitted"?`${l.dim(n)}`:`${l.dim(Li)} ${l.dim(n)}`};return new Wi({options:u.options,initialValues:u.initialValues,required:u.required??!0,cursorAt:u.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
|
|
35
|
+
${l.reset(l.dim(`Press ${l.gray(l.bgWhite(l.inverse(" space ")))} to select, ${l.gray(l.bgWhite(l.inverse(" enter ")))} to submit`))}`},render(){let i=`${l.gray(A)}
|
|
36
|
+
${au(this.state)} ${u.message}
|
|
37
|
+
`,e=(n,r)=>{let t=this.value.includes(n.value);return r&&t?D(n,"active-selected"):t?D(n,"selected"):D(n,r?"active":"inactive")};switch(this.state){case"submit":return`${i}${l.gray(A)} ${this.options.filter(({value:n})=>this.value.includes(n)).map((n)=>D(n,"submitted")).join(l.dim(", "))||l.dim("none")}`;case"cancel":{let n=this.options.filter(({value:r})=>this.value.includes(r)).map((r)=>D(r,"cancelled")).join(l.dim(", "));return`${i}${l.gray(A)} ${n.trim()?`${n}
|
|
38
|
+
${l.gray(A)}`:""}`}case"error":{let n=this.error.split(`
|
|
39
|
+
`).map((r,t)=>t===0?`${l.yellow(q)} ${l.yellow(r)}`:` ${r}`).join(`
|
|
40
|
+
`);return`${i+l.yellow(A)} ${ju({options:this.options,cursor:this.cursor,maxItems:u.maxItems,style:e}).join(`
|
|
41
|
+
${l.yellow(A)} `)}
|
|
42
|
+
${n}
|
|
43
|
+
`}default:return`${i}${l.cyan(A)} ${ju({options:this.options,cursor:this.cursor,maxItems:u.maxItems,style:e}).join(`
|
|
44
|
+
${l.cyan(A)} `)}
|
|
45
|
+
${l.cyan(q)}
|
|
46
|
+
`}}}).prompt()},ZD;var QD=Yt(()=>{_=mi(),eu={exports:{}};fi=Ei(),l=ci(fi);gi=Bi();PD={exports:{}};(function(u){var D={};u.exports=D,D.eastAsianWidth=function(e){var n=e.charCodeAt(0),r=e.length==2?e.charCodeAt(1):0,t=n;return 55296<=n&&n<=56319&&56320<=r&&r<=57343&&(n&=1023,r&=1023,t=n<<10|r,t+=65536),t==12288||65281<=t&&t<=65376||65504<=t&&t<=65510?"F":t==8361||65377<=t&&t<=65470||65474<=t&&t<=65479||65482<=t&&t<=65487||65490<=t&&t<=65495||65498<=t&&t<=65500||65512<=t&&t<=65518?"H":4352<=t&&t<=4447||4515<=t&&t<=4519||4602<=t&&t<=4607||9001<=t&&t<=9002||11904<=t&&t<=11929||11931<=t&&t<=12019||12032<=t&&t<=12245||12272<=t&&t<=12283||12289<=t&&t<=12350||12353<=t&&t<=12438||12441<=t&&t<=12543||12549<=t&&t<=12589||12593<=t&&t<=12686||12688<=t&&t<=12730||12736<=t&&t<=12771||12784<=t&&t<=12830||12832<=t&&t<=12871||12880<=t&&t<=13054||13056<=t&&t<=19903||19968<=t&&t<=42124||42128<=t&&t<=42182||43360<=t&&t<=43388||44032<=t&&t<=55203||55216<=t&&t<=55238||55243<=t&&t<=55291||63744<=t&&t<=64255||65040<=t&&t<=65049||65072<=t&&t<=65106||65108<=t&&t<=65126||65128<=t&&t<=65131||110592<=t&&t<=110593||127488<=t&&t<=127490||127504<=t&&t<=127546||127552<=t&&t<=127560||127568<=t&&t<=127569||131072<=t&&t<=194367||177984<=t&&t<=196605||196608<=t&&t<=262141?"W":32<=t&&t<=126||162<=t&&t<=163||165<=t&&t<=166||t==172||t==175||10214<=t&&t<=10221||10629<=t&&t<=10630?"Na":t==161||t==164||167<=t&&t<=168||t==170||173<=t&&t<=174||176<=t&&t<=180||182<=t&&t<=186||188<=t&&t<=191||t==198||t==208||215<=t&&t<=216||222<=t&&t<=225||t==230||232<=t&&t<=234||236<=t&&t<=237||t==240||242<=t&&t<=243||247<=t&&t<=250||t==252||t==254||t==257||t==273||t==275||t==283||294<=t&&t<=295||t==299||305<=t&&t<=307||t==312||319<=t&&t<=322||t==324||328<=t&&t<=331||t==333||338<=t&&t<=339||358<=t&&t<=359||t==363||t==462||t==464||t==466||t==468||t==470||t==472||t==474||t==476||t==593||t==609||t==708||t==711||713<=t&&t<=715||t==717||t==720||728<=t&&t<=731||t==733||t==735||768<=t&&t<=879||913<=t&&t<=929||931<=t&&t<=937||945<=t&&t<=961||963<=t&&t<=969||t==1025||1040<=t&&t<=1103||t==1105||t==8208||8211<=t&&t<=8214||8216<=t&&t<=8217||8220<=t&&t<=8221||8224<=t&&t<=8226||8228<=t&&t<=8231||t==8240||8242<=t&&t<=8243||t==8245||t==8251||t==8254||t==8308||t==8319||8321<=t&&t<=8324||t==8364||t==8451||t==8453||t==8457||t==8467||t==8470||8481<=t&&t<=8482||t==8486||t==8491||8531<=t&&t<=8532||8539<=t&&t<=8542||8544<=t&&t<=8555||8560<=t&&t<=8569||t==8585||8592<=t&&t<=8601||8632<=t&&t<=8633||t==8658||t==8660||t==8679||t==8704||8706<=t&&t<=8707||8711<=t&&t<=8712||t==8715||t==8719||t==8721||t==8725||t==8730||8733<=t&&t<=8736||t==8739||t==8741||8743<=t&&t<=8748||t==8750||8756<=t&&t<=8759||8764<=t&&t<=8765||t==8776||t==8780||t==8786||8800<=t&&t<=8801||8804<=t&&t<=8807||8810<=t&&t<=8811||8814<=t&&t<=8815||8834<=t&&t<=8835||8838<=t&&t<=8839||t==8853||t==8857||t==8869||t==8895||t==8978||9312<=t&&t<=9449||9451<=t&&t<=9547||9552<=t&&t<=9587||9600<=t&&t<=9615||9618<=t&&t<=9621||9632<=t&&t<=9633||9635<=t&&t<=9641||9650<=t&&t<=9651||9654<=t&&t<=9655||9660<=t&&t<=9661||9664<=t&&t<=9665||9670<=t&&t<=9672||t==9675||9678<=t&&t<=9681||9698<=t&&t<=9701||t==9711||9733<=t&&t<=9734||t==9737||9742<=t&&t<=9743||9748<=t&&t<=9749||t==9756||t==9758||t==9792||t==9794||9824<=t&&t<=9825||9827<=t&&t<=9829||9831<=t&&t<=9834||9836<=t&&t<=9837||t==9839||9886<=t&&t<=9887||9918<=t&&t<=9919||9924<=t&&t<=9933||9935<=t&&t<=9953||t==9955||9960<=t&&t<=9983||t==10045||t==10071||10102<=t&&t<=10111||11093<=t&&t<=11097||12872<=t&&t<=12879||57344<=t&&t<=63743||65024<=t&&t<=65039||t==65533||127232<=t&&t<=127242||127248<=t&&t<=127277||127280<=t&&t<=127337||127344<=t&&t<=127386||917760<=t&&t<=917999||983040<=t&&t<=1048573||1048576<=t&&t<=1114109?"A":"N"},D.characterLength=function(e){var n=this.eastAsianWidth(e);return n=="F"||n=="W"||n=="A"?2:1};function i(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}D.length=function(e){for(var n=i(e),r=0,t=0;t<n.length;t++)r=r+this.characterLength(n[t]);return r},D.slice=function(e,n,r){textLen=D.length(e),n=n||0,r=r||1,n<0&&(n=textLen+n),r<0&&(r=textLen+r);for(var t="",s=0,a=i(e),F=0;F<a.length;F++){var C=a[F],c=D.length(C);if(s>=n-(c==2?1:0))if(s+c<=r)t+=C;else break;s+=c}return t}})(PD);pi=PD.exports,Ai=UD(pi),bi=UD($i);$={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]}};Object.keys($.modifier);di=Object.keys($.color),wi=Object.keys($.bgColor);[...di,...wi];vi=yi(),su=new Set(["\x1B",""]),uD=`${Ni}8;;`;Ii=["up","down","left","right","space","enter","cancel"],ru={actions:new Set(Ii),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]])};globalThis.process.platform.startsWith("win");VD=Symbol("clack:cancel");Gi=Object.defineProperty;HD=class HD extends O{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(u){super(u,!1),this.value=!!u.initialValue,this.on("value",()=>{this.value=this._value}),this.on("confirm",(D)=>{this.output.write(_.cursor.move(0,-1)),this.value=D,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}};Pi=Object.defineProperty,Wi=class extends O{constructor(u){super(u,!1),TD(this,"options"),TD(this,"cursor",0),this.options=u.options,this.value=[...u.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:D})=>D===u.cursorAt),0),this.on("key",(D)=>{D==="a"&&this.toggleAll()}),this.on("cursor",(D)=>{switch(D){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case"space":this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){let u=this.value.length===this.options.length;this.value=u?[]:this.options.map((D)=>D.value)}toggleValue(){let u=this.value.includes(this._value);this.value=u?this.value.filter((D)=>D!==this._value):[...this.value,this._value]}},zi=Object.defineProperty;KD=class KD extends O{constructor(u){super(u,!1),ID(this,"options"),ID(this,"cursor",0),this.options=u.options,this.cursor=this.options.findIndex(({value:D})=>D===u.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on("cursor",(D)=>{switch(D){case"left":case"up":this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case"down":case"right":this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}};JD=class JD extends O{get valueWithCursor(){if(this.state==="submit")return this.value;if(this.cursor>=this.value.length)return`${this.value}█`;let u=this.value.slice(0,this.cursor),[D,...i]=this.value.slice(this.cursor);return`${u}${l.inverse(D)}${i.join("")}`}get cursor(){return this._cursor}constructor(u){super(u),this.on("finalize",()=>{this.value||(this.value=u.defaultValue)})}};Ji=Ki(),Zi=G("❯",">"),ki=G("■","x"),Yi=G("▲","x"),Qi=G("✔","√"),A=G(""),q=G(""),Xu=G("●",">"),Ou=G("○"," "),qi=G("◻","[•]"),_D=G("◼","[+]"),Li=G("◻","[ ]");`${l.gray(A)} `;ZD=Symbol.for("cancel")});var v={silent:Number.NEGATIVE_INFINITY,fatal:0,error:0,warn:1,log:2,info:3,success:3,fail:3,ready:3,start:3,box:3,debug:4,trace:5,verbose:Number.POSITIVE_INFINITY},Ku={silent:{level:-1},fatal:{level:v.fatal},error:{level:v.error},warn:{level:v.warn},log:{level:v.log},info:{level:v.info},success:{level:v.success},fail:{level:v.fail},ready:{level:v.info},start:{level:v.info},box:{level:v.info},debug:{level:v.debug},trace:{level:v.trace},verbose:{level:v.verbose}};function Wu(u){if(u===null||typeof u!=="object")return!1;let D=Object.getPrototypeOf(u);if(D!==null&&D!==Object.prototype&&Object.getPrototypeOf(D)!==null)return!1;if(Symbol.iterator in u)return!1;if(Symbol.toStringTag in u)return Object.prototype.toString.call(u)==="[object Module]";return!0}function Ju(u,D,i=".",e){if(!Wu(D))return Ju(u,{},i,e);let n=Object.assign({},D);for(let r in u){if(r==="__proto__"||r==="constructor")continue;let t=u[r];if(t===null||t===void 0)continue;if(e&&e(n,r,t,i))continue;if(Array.isArray(t)&&Array.isArray(n[r]))n[r]=[...t,...n[r]];else if(Wu(t)&&Wu(n[r]))n[r]=Ju(t,n[r],(i?`${i}.`:"")+r.toString(),e);else n[r]=t}return n}function Qt(u){return(...D)=>D.reduce((i,e)=>Ju(i,e,"",u),{})}var qt=Qt();function Lt(u){return Object.prototype.toString.call(u)==="[object Object]"}function Xt(u){if(!Lt(u))return!1;if(!u.message&&!u.args)return!1;if(u.stack)return!1;return!0}var zu=!1,oD=[];class w{options;_lastLog;_mockFn;constructor(u={}){let D=u.types||Ku;this.options=qt({...u,defaults:{...u.defaults},level:Hu(u.level,D),reporters:[...u.reporters||[]]},{types:Ku,throttle:1000,throttleMin:5,formatOptions:{date:!0,colors:!1,compact:!0}});for(let i in D){let e={type:i,...this.options.defaults,...D[i]};this[i]=this._wrapLogFn(e),this[i].raw=this._wrapLogFn(e,!0)}if(this.options.mockFn)this.mockTypes();this._lastLog={}}get level(){return this.options.level}set level(u){this.options.level=Hu(u,this.options.types,this.options.level)}prompt(u,D){if(!this.options.prompt)throw Error("prompt is not supported!");return this.options.prompt(u,D)}create(u){let D=new w({...this.options,...u});if(this._mockFn)D.mockTypes(this._mockFn);return D}withDefaults(u){return this.create({...this.options,defaults:{...this.options.defaults,...u}})}withTag(u){return this.withDefaults({tag:this.options.defaults.tag?this.options.defaults.tag+":"+u:u})}addReporter(u){return this.options.reporters.push(u),this}removeReporter(u){if(u){let D=this.options.reporters.indexOf(u);if(D!==-1)return this.options.reporters.splice(D,1)}else this.options.reporters.splice(0);return this}setReporters(u){return this.options.reporters=Array.isArray(u)?u:[u],this}wrapAll(){this.wrapConsole(),this.wrapStd()}restoreAll(){this.restoreConsole(),this.restoreStd()}wrapConsole(){for(let u in this.options.types){if(!console["__"+u])console["__"+u]=console[u];console[u]=this[u].raw}}restoreConsole(){for(let u in this.options.types)if(console["__"+u])console[u]=console["__"+u],delete console["__"+u]}wrapStd(){this._wrapStream(this.options.stdout,"log"),this._wrapStream(this.options.stderr,"log")}_wrapStream(u,D){if(!u)return;if(!u.__write)u.__write=u.write;u.write=(i)=>{this[D].raw(String(i).trim())}}restoreStd(){this._restoreStream(this.options.stdout),this._restoreStream(this.options.stderr)}_restoreStream(u){if(!u)return;if(u.__write)u.write=u.__write,delete u.__write}pauseLogs(){zu=!0}resumeLogs(){zu=!1;let u=oD.splice(0);for(let D of u)D[0]._logFn(D[1],D[2])}mockTypes(u){let D=u||this.options.mockFn;if(this._mockFn=D,typeof D!=="function")return;for(let i in this.options.types)this[i]=D(i,this.options.types[i])||this[i],this[i].raw=this[i]}_wrapLogFn(u,D){return(...i)=>{if(zu){oD.push([this,u,i,D]);return}return this._logFn(u,i,D)}}_logFn(u,D,i){if((u.level||0)>this.level)return!1;let e={date:new Date,args:[],...u,level:Hu(u.level,this.options.types)};if(!i&&D.length===1&&Xt(D[0]))Object.assign(e,D[0]);else e.args=[...D];if(e.message)e.args.unshift(e.message),delete e.message;if(e.additional){if(!Array.isArray(e.additional))e.additional=e.additional.split(`
|
|
47
|
+
`);e.args.push(`
|
|
48
|
+
`+e.additional.join(`
|
|
49
|
+
`)),delete e.additional}e.type=typeof e.type==="string"?e.type.toLowerCase():"log",e.tag=typeof e.tag==="string"?e.tag:"";let n=(t=!1)=>{let s=(this._lastLog.count||0)-this.options.throttleMin;if(this._lastLog.object&&s>0){let a=[...this._lastLog.object.args];if(s>1)a.push(`(repeated ${s} times)`);this._log({...this._lastLog.object,args:a}),this._lastLog.count=1}if(t)this._lastLog.object=e,this._log(e)};clearTimeout(this._lastLog.timeout);let r=this._lastLog.time&&e.date?e.date.getTime()-this._lastLog.time.getTime():0;if(this._lastLog.time=e.date,r<this.options.throttle)try{let t=JSON.stringify([e.type,e.tag,e.args]),s=this._lastLog.serialized===t;if(this._lastLog.serialized=t,s){if(this._lastLog.count=(this._lastLog.count||0)+1,this._lastLog.count>this.options.throttleMin){this._lastLog.timeout=setTimeout(n,this.options.throttle);return}}}catch{}n(!0)}_log(u){for(let D of this.options.reporters)D.log(u,{options:this.options})}}function Hu(u,D={},i=3){if(u===void 0)return i;if(typeof u==="number")return u;if(D[u]&&D[u].level!==void 0)return D[u].level;return i}w.prototype.add=w.prototype.addReporter;w.prototype.remove=w.prototype.removeReporter;w.prototype.clear=w.prototype.removeReporter;w.prototype.withScope=w.prototype.withTag;w.prototype.mock=w.prototype.mockTypes;w.prototype.pause=w.prototype.pauseLogs;w.prototype.resume=w.prototype.resumeLogs;function cD(u={}){return new w(u)}import{formatWithOptions as mD}from"node:util";import{sep as Ot}from"node:path";function ku(u,D){let i=process.cwd()+Ot;return u.split(`
|
|
50
|
+
`).splice(D.split(`
|
|
51
|
+
`).length).map((n)=>n.trim().replace("file://","").replace(i,""))}function jt(u,D){return(D.__write||D.write).call(D,u)}var Zu=(u)=>u?`[${u}]`:"";class tu{formatStack(u,D,i){let e=" ".repeat((i?.errorLevel||0)+1);return e+ku(u,D).join(`
|
|
52
|
+
${e}`)}formatError(u,D){let i=u.message??mD(D,u),e=u.stack?this.formatStack(u.stack,i,D):"",n=D?.errorLevel||0,r=n>0?`${" ".repeat(n)}[cause]: `:"",t=u.cause?`
|
|
53
|
+
|
|
54
|
+
`+this.formatError(u.cause,{...D,errorLevel:n+1}):"";return r+i+`
|
|
55
|
+
`+e+t}formatArgs(u,D){let i=u.map((e)=>{if(e&&typeof e.stack==="string")return this.formatError(e,D);return e});return mD(D,...i)}formatDate(u,D){return D.date?u.toLocaleTimeString():""}filterAndJoin(u){return u.filter(Boolean).join(" ")}formatLogObj(u,D){let i=this.formatArgs(u.args,D);if(u.type==="box")return`
|
|
56
|
+
`+[Zu(u.tag),u.title&&u.title,...i.split(`
|
|
57
|
+
`)].filter(Boolean).map((e)=>" > "+e).join(`
|
|
58
|
+
`)+`
|
|
59
|
+
`;return this.filterAndJoin([Zu(u.type),Zu(u.tag),i])}log(u,D){let i=this.formatLogObj(u,{columns:D.options.stdout.columns||0,...D.options.formatOptions});return jt(i+`
|
|
60
|
+
`,u.level<2?D.options.stderr||process.stderr:D.options.stdout||process.stdout)}}import qD from"node:process";import*as iu from"node:tty";var{env:z={},argv:BD=[],platform:xt=""}=typeof process>"u"?{}:process,ui="NO_COLOR"in z||BD.includes("--no-color"),Di="FORCE_COLOR"in z||BD.includes("--color"),ti=xt==="win32",gD=z.TERM==="dumb",ii=iu&&iu.isatty&&iu.isatty(1)&&z.TERM&&!gD,ei="CI"in z&&(("GITHUB_ACTIONS"in z)||("GITLAB_CI"in z)||("CIRCLECI"in z)),ni=!ui&&(Di||ti&&!gD||ii||ei);function pD(u,D,i,e,n=D.slice(0,Math.max(0,u))+e,r=D.slice(Math.max(0,u+i.length)),t=r.indexOf(i)){return n+(t<0?r:pD(t,r,i,e))}function ri(u,D,i,e,n){return u<0?i+D+e:i+pD(u,D,e,n)+e}function si(u,D,i=u,e=u.length+1){return(n)=>n||!(n===""||n===void 0)?ri((""+n).indexOf(D,e),n,u,D,i):""}function f(u,D,i){return si(`\x1B[${u}m`,`\x1B[${D}m`,i)}var ED={reset:f(0,0),bold:f(1,22,"\x1B[22m\x1B[1m"),dim:f(2,22,"\x1B[22m\x1B[2m"),italic:f(3,23),underline:f(4,24),inverse:f(7,27),hidden:f(8,28),strikethrough:f(9,29),black:f(30,39),red:f(31,39),green:f(32,39),yellow:f(33,39),blue:f(34,39),magenta:f(35,39),cyan:f(36,39),white:f(37,39),gray:f(90,39),bgBlack:f(40,49),bgRed:f(41,49),bgGreen:f(42,49),bgYellow:f(43,49),bgBlue:f(44,49),bgMagenta:f(45,49),bgCyan:f(46,49),bgWhite:f(47,49),blackBright:f(90,39),redBright:f(91,39),greenBright:f(92,39),yellowBright:f(93,39),blueBright:f(94,39),magentaBright:f(95,39),cyanBright:f(96,39),whiteBright:f(97,39),bgBlackBright:f(100,49),bgRedBright:f(101,49),bgGreenBright:f(102,49),bgYellowBright:f(103,49),bgBlueBright:f(104,49),bgMagentaBright:f(105,49),bgCyanBright:f(106,49),bgWhiteBright:f(107,49)};function ai(u=ni){return u?ED:Object.fromEntries(Object.keys(ED).map((D)=>[D,String]))}var p=ai();function AD(u,D="reset"){return p[u]||p[D]}var Fi=[String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`,String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");function W(u){return u.replace(new RegExp(Fi,"g"),"")}var fD={solid:{tl:"┌",tr:"┐",bl:"└",br:"┘",h:"─",v:"│"},double:{tl:"╔",tr:"╗",bl:"╚",br:"╝",h:"═",v:"║"},doubleSingle:{tl:"╓",tr:"╖",bl:"╙",br:"╜",h:"─",v:"║"},doubleSingleRounded:{tl:"╭",tr:"╮",bl:"╰",br:"╯",h:"─",v:"║"},singleThick:{tl:"┏",tr:"┓",bl:"┗",br:"┛",h:"━",v:"┃"},singleDouble:{tl:"╒",tr:"╕",bl:"╘",br:"╛",h:"═",v:"│"},singleDoubleRounded:{tl:"╭",tr:"╮",bl:"╰",br:"╯",h:"═",v:"│"},rounded:{tl:"╭",tr:"╮",bl:"╰",br:"╯",h:"─",v:"│"}},Ci={borderColor:"white",borderStyle:"rounded",valign:"center",padding:2,marginLeft:1,marginTop:1,marginBottom:1};function Yu(u,D={}){let i={...D,style:{...Ci,...D.style}},e=u.split(`
|
|
61
|
+
`),n=[],r=AD(i.style.borderColor),t={...typeof i.style.borderStyle==="string"?fD[i.style.borderStyle]||fD.solid:i.style.borderStyle};if(r)for(let m in t)t[m]=r(t[m]);let s=i.style.padding%2===0?i.style.padding:i.style.padding+1,a=e.length+s,F=Math.max(...e.map((m)=>W(m).length),i.title?W(i.title).length:0)+s,C=F+s,c=i.style.marginLeft>0?" ".repeat(i.style.marginLeft):"";if(i.style.marginTop>0)n.push("".repeat(i.style.marginTop));if(i.title){let m=r?r(i.title):i.title,g=t.h.repeat(Math.floor((F-W(i.title).length)/2)),M=t.h.repeat(F-W(i.title).length-W(g).length+s);n.push(`${c}${t.tl}${g}${m}${M}${t.tr}`)}else n.push(`${c}${t.tl}${t.h.repeat(C)}${t.tr}`);let B=i.style.valign==="center"?Math.floor((a-e.length)/2):i.style.valign==="top"?a-e.length-s:a-e.length;for(let m=0;m<a;m++)if(m<B||m>=B+e.length)n.push(`${c}${t.v}${" ".repeat(C)}${t.v}`);else{let g=e[m-B],M=" ".repeat(s),R=" ".repeat(F-W(g).length);n.push(`${c}${t.v}${M}${g}${R}${t.v}`)}if(n.push(`${c}${t.bl}${t.h.repeat(C)}${t.br}`),i.style.marginBottom>0)n.push("".repeat(i.style.marginBottom));return n.join(`
|
|
62
|
+
`)}var Cu=Object.create(null),j=(u)=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(u?Cu:globalThis),H=new Proxy(Cu,{get(u,D){return j()[D]??Cu[D]},has(u,D){let i=j();return D in i||D in Cu},set(u,D,i){let e=j(!0);return e[D]=i,!0},deleteProperty(u,D){if(!D)return!1;let i=j(!0);return delete i[D],!0},ownKeys(){let u=j(!0);return Object.keys(u)}}),ue=typeof process<"u"&&process.env&&"development"||"",De=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["CODESANDBOX","CODESANDBOX_HOST",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:!0}]];function te(){if(globalThis.process?.env)for(let u of De){let D=u[1]||u[0];if(globalThis.process?.env[D])return{name:u[0].toLowerCase(),...u[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}var jD=te();jD.name;function Z(u){return u?u!=="false":!1}var ie=globalThis.process?.platform||"",DD=Z(H.CI)||jD.ci!==!1,xD=Z(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),ee=Z(H.DEBUG),tD=ue==="test"||Z(H.TEST);Z(H.MINIMAL);var ne=/^win/i.test(ie);!Z(H.NO_COLOR)&&(Z(H.FORCE_COLOR)||(xD||ne)&&H.TERM);var re=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null;Number(re?.split(".")[0]);var se=globalThis.process||Object.create(null),LD={versions:{}};new Proxy(se,{get(u,D){if(D==="env")return H;if(D in u)return u[D];if(D in LD)return LD[D]}});var ae=globalThis.process?.release?.name==="node",Fe=!!globalThis.Bun||!!globalThis.process?.versions?.bun,Ce=!!globalThis.Deno,le=!!globalThis.fastly,he=!!globalThis.Netlify,oe=!!globalThis.EdgeRuntime,ce=globalThis.navigator?.userAgent==="Cloudflare-Workers",me=[[he,"netlify"],[oe,"edge-light"],[ce,"workerd"],[le,"fastly"],[Ce,"deno"],[Fe,"bun"],[ae,"node"]];function Ee(){let u=me.find((D)=>D[0]);if(u)return{name:u[1]}}var fe=Ee();fe?.name;function Be({onlyFirst:u=!1}={}){let i=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(i,u?void 0:"g")}var ge=Be();function pe(u){if(typeof u!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof u}\``);return u.replace(ge,"")}function Ae(u){return u===161||u===164||u===167||u===168||u===170||u===173||u===174||u>=176&&u<=180||u>=182&&u<=186||u>=188&&u<=191||u===198||u===208||u===215||u===216||u>=222&&u<=225||u===230||u>=232&&u<=234||u===236||u===237||u===240||u===242||u===243||u>=247&&u<=250||u===252||u===254||u===257||u===273||u===275||u===283||u===294||u===295||u===299||u>=305&&u<=307||u===312||u>=319&&u<=322||u===324||u>=328&&u<=331||u===333||u===338||u===339||u===358||u===359||u===363||u===462||u===464||u===466||u===468||u===470||u===472||u===474||u===476||u===593||u===609||u===708||u===711||u>=713&&u<=715||u===717||u===720||u>=728&&u<=731||u===733||u===735||u>=768&&u<=879||u>=913&&u<=929||u>=931&&u<=937||u>=945&&u<=961||u>=963&&u<=969||u===1025||u>=1040&&u<=1103||u===1105||u===8208||u>=8211&&u<=8214||u===8216||u===8217||u===8220||u===8221||u>=8224&&u<=8226||u>=8228&&u<=8231||u===8240||u===8242||u===8243||u===8245||u===8251||u===8254||u===8308||u===8319||u>=8321&&u<=8324||u===8364||u===8451||u===8453||u===8457||u===8467||u===8470||u===8481||u===8482||u===8486||u===8491||u===8531||u===8532||u>=8539&&u<=8542||u>=8544&&u<=8555||u>=8560&&u<=8569||u===8585||u>=8592&&u<=8601||u===8632||u===8633||u===8658||u===8660||u===8679||u===8704||u===8706||u===8707||u===8711||u===8712||u===8715||u===8719||u===8721||u===8725||u===8730||u>=8733&&u<=8736||u===8739||u===8741||u>=8743&&u<=8748||u===8750||u>=8756&&u<=8759||u===8764||u===8765||u===8776||u===8780||u===8786||u===8800||u===8801||u>=8804&&u<=8807||u===8810||u===8811||u===8814||u===8815||u===8834||u===8835||u===8838||u===8839||u===8853||u===8857||u===8869||u===8895||u===8978||u>=9312&&u<=9449||u>=9451&&u<=9547||u>=9552&&u<=9587||u>=9600&&u<=9615||u>=9618&&u<=9621||u===9632||u===9633||u>=9635&&u<=9641||u===9650||u===9651||u===9654||u===9655||u===9660||u===9661||u===9664||u===9665||u>=9670&&u<=9672||u===9675||u>=9678&&u<=9681||u>=9698&&u<=9701||u===9711||u===9733||u===9734||u===9737||u===9742||u===9743||u===9756||u===9758||u===9792||u===9794||u===9824||u===9825||u>=9827&&u<=9829||u>=9831&&u<=9834||u===9836||u===9837||u===9839||u===9886||u===9887||u===9919||u>=9926&&u<=9933||u>=9935&&u<=9939||u>=9941&&u<=9953||u===9955||u===9960||u===9961||u>=9963&&u<=9969||u===9972||u>=9974&&u<=9977||u===9979||u===9980||u===9982||u===9983||u===10045||u>=10102&&u<=10111||u>=11094&&u<=11097||u>=12872&&u<=12879||u>=57344&&u<=63743||u>=65024&&u<=65039||u===65533||u>=127232&&u<=127242||u>=127248&&u<=127277||u>=127280&&u<=127337||u>=127344&&u<=127373||u===127375||u===127376||u>=127387&&u<=127404||u>=917760&&u<=917999||u>=983040&&u<=1048573||u>=1048576&&u<=1114109}function $e(u){return u===12288||u>=65281&&u<=65376||u>=65504&&u<=65510}function be(u){return u>=4352&&u<=4447||u===8986||u===8987||u===9001||u===9002||u>=9193&&u<=9196||u===9200||u===9203||u===9725||u===9726||u===9748||u===9749||u>=9776&&u<=9783||u>=9800&&u<=9811||u===9855||u>=9866&&u<=9871||u===9875||u===9889||u===9898||u===9899||u===9917||u===9918||u===9924||u===9925||u===9934||u===9940||u===9962||u===9970||u===9971||u===9973||u===9978||u===9981||u===9989||u===9994||u===9995||u===10024||u===10060||u===10062||u>=10067&&u<=10069||u===10071||u>=10133&&u<=10135||u===10160||u===10175||u===11035||u===11036||u===11088||u===11093||u>=11904&&u<=11929||u>=11931&&u<=12019||u>=12032&&u<=12245||u>=12272&&u<=12287||u>=12289&&u<=12350||u>=12353&&u<=12438||u>=12441&&u<=12543||u>=12549&&u<=12591||u>=12593&&u<=12686||u>=12688&&u<=12773||u>=12783&&u<=12830||u>=12832&&u<=12871||u>=12880&&u<=42124||u>=42128&&u<=42182||u>=43360&&u<=43388||u>=44032&&u<=55203||u>=63744&&u<=64255||u>=65040&&u<=65049||u>=65072&&u<=65106||u>=65108&&u<=65126||u>=65128&&u<=65131||u>=94176&&u<=94180||u===94192||u===94193||u>=94208&&u<=100343||u>=100352&&u<=101589||u>=101631&&u<=101640||u>=110576&&u<=110579||u>=110581&&u<=110587||u===110589||u===110590||u>=110592&&u<=110882||u===110898||u>=110928&&u<=110930||u===110933||u>=110948&&u<=110951||u>=110960&&u<=111355||u>=119552&&u<=119638||u>=119648&&u<=119670||u===126980||u===127183||u===127374||u>=127377&&u<=127386||u>=127488&&u<=127490||u>=127504&&u<=127547||u>=127552&&u<=127560||u===127568||u===127569||u>=127584&&u<=127589||u>=127744&&u<=127776||u>=127789&&u<=127797||u>=127799&&u<=127868||u>=127870&&u<=127891||u>=127904&&u<=127946||u>=127951&&u<=127955||u>=127968&&u<=127984||u===127988||u>=127992&&u<=128062||u===128064||u>=128066&&u<=128252||u>=128255&&u<=128317||u>=128331&&u<=128334||u>=128336&&u<=128359||u===128378||u===128405||u===128406||u===128420||u>=128507&&u<=128591||u>=128640&&u<=128709||u===128716||u>=128720&&u<=128722||u>=128725&&u<=128727||u>=128732&&u<=128735||u===128747||u===128748||u>=128756&&u<=128764||u>=128992&&u<=129003||u===129008||u>=129292&&u<=129338||u>=129340&&u<=129349||u>=129351&&u<=129535||u>=129648&&u<=129660||u>=129664&&u<=129673||u>=129679&&u<=129734||u>=129742&&u<=129756||u>=129759&&u<=129769||u>=129776&&u<=129784||u>=131072&&u<=196605||u>=196608&&u<=262141}function de(u){if(!Number.isSafeInteger(u))throw TypeError(`Expected a code point, got \`${typeof u}\`.`)}function we(u,{ambiguousAsWide:D=!1}={}){if(de(u),$e(u)||be(u)||D&&Ae(u))return 2;return 1}var ye=()=>{return/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g},ve=globalThis.Intl?.Segmenter?new Intl.Segmenter:{segment:(u)=>u.split("")},Me=/^\p{Default_Ignorable_Code_Point}$/u;function Ne(u,D={}){if(typeof u!=="string"||u.length===0)return 0;let{ambiguousIsNarrow:i=!0,countAnsiEscapeCodes:e=!1}=D;if(!e)u=pe(u);if(u.length===0)return 0;let n=0,r={ambiguousAsWide:!i};for(let{segment:t}of ve.segment(u)){let s=t.codePointAt(0);if(s<=31||s>=127&&s<=159)continue;if(s>=8203&&s<=8207||s===65279)continue;if(s>=768&&s<=879||s>=6832&&s<=6911||s>=7616&&s<=7679||s>=8400&&s<=8447||s>=65056&&s<=65071)continue;if(s>=55296&&s<=57343)continue;if(s>=65024&&s<=65039)continue;if(Me.test(t))continue;if(ye().test(t)){n+=2;continue}n+=we(s,r)}return n}function Se(){let{env:u}=qD,{TERM:D,TERM_PROGRAM:i}=u;if(qD.platform!=="win32")return D!=="linux";return Boolean(u.WT_SESSION)||Boolean(u.TERMINUS_SUBLIME)||u.ConEmuTask==="{cmd::Cmder}"||i==="Terminus-Sublime"||i==="vscode"||D==="xterm-256color"||D==="alacritty"||D==="rxvt-unicode"||D==="rxvt-unicode-256color"||u.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Ve={info:"cyan",fail:"red",success:"green",ready:"green",start:"magenta"},Te={0:"red",1:"yellow"},Ie=Se(),P=(u,D)=>Ie?u:D,XD={error:P("✖","×"),fatal:P("✖","×"),ready:P("✔","√"),warn:P("⚠","‼"),info:P("ℹ","i"),success:P("✔","√"),debug:P("⚙","D"),trace:P("→","→"),fail:P("✖","×"),start:P("◐","o"),log:""};function OD(u){if(typeof Intl!=="object"||!Intl.Segmenter)return W(u).length;return Ne(u)}class ut extends tu{formatStack(u,D,i){let e=" ".repeat((i?.errorLevel||0)+1);return`
|
|
63
|
+
${e}`+ku(u,D).map((n)=>" "+n.replace(/^at +/,(r)=>p.gray(r)).replace(/\((.+)\)/,(r,t)=>`(${p.cyan(t)})`)).join(`
|
|
64
|
+
${e}`)}formatType(u,D,i){let e=Ve[u.type]||Te[u.level]||"gray";if(D)return Ge(e)(p.black(` ${u.type.toUpperCase()} `));let n=typeof XD[u.type]==="string"?XD[u.type]:u.icon||u.type;return n?_e(e)(n):""}formatLogObj(u,D){let[i,...e]=this.formatArgs(u.args,D).split(`
|
|
65
|
+
`);if(u.type==="box")return Yu(Fu(i+(e.length>0?`
|
|
66
|
+
`+e.join(`
|
|
67
|
+
`):"")),{title:u.title?Fu(u.title):void 0,style:u.style});let n=this.formatDate(u.date,D),r=n&&p.gray(n),t=u.badge??u.level<2,s=this.formatType(u,t,D),a=u.tag?p.gray(u.tag):"",F,C=this.filterAndJoin([s,Fu(i)]),c=this.filterAndJoin(D.columns?[a,r]:[a]),B=(D.columns||0)-OD(C)-OD(c)-2;if(F=B>0&&(D.columns||0)>=80?C+" ".repeat(B)+c:(c?`${p.gray(`[${c}]`)} `:"")+C,F+=Fu(e.length>0?`
|
|
68
|
+
`+e.join(`
|
|
69
|
+
`):""),u.type==="trace"){let m=Error("Trace: "+u.message);F+=this.formatStack(m.stack||"",m.message)}return t?`
|
|
70
|
+
`+F+`
|
|
71
|
+
`:F}}function Fu(u){return u.replace(/`([^`]+)`/gm,(D,i)=>p.cyan(i)).replace(/\s+_([^_]+)_\s+/gm,(D,i)=>` ${p.underline(i)} `)}function _e(u="white"){return p[u]||p.white}function Ge(u="bgWhite"){return p[`bg${u[0].toUpperCase()}${u.slice(1)}`]||p.bgWhite}function Ue(u={}){let D=Pe();if(process.env.CONSOLA_LEVEL)D=Number.parseInt(process.env.CONSOLA_LEVEL)??D;return cD({level:D,defaults:{level:D},stdout:process.stdout,stderr:process.stderr,prompt:(...e)=>Promise.resolve().then(() => (QD(),YD)).then((n)=>n.prompt(...e)),reporters:u.reporters||[u.fancy??!(DD||tD)?new ut:new tu],...u})}function Pe(){if(ee)return v.debug;if(tD)return v.warn;return v.info}var N=Ue();function Re(u){if(Array.isArray(u))return u;return u===void 0?[]:[u]}function iD(u,D=""){let i=[];for(let e of u)for(let[n,r]of e.entries())i[n]=Math.max(i[n]||0,r.length);return u.map((e)=>e.map((n,r)=>D+n[r===0?"padStart":"padEnd"](i[r])).join(" ")).join(`
|
|
72
|
+
`)}function U(u){return typeof u==="function"?u():u}class k extends Error{constructor(u,D){super(u);this.code=D,this.name="CLIError"}}var We=/\d/,ze=["-","_","/","."];function He(u=""){if(We.test(u))return;return u!==u.toLowerCase()}function Dt(u,D){let i=D??ze,e=[];if(!u||typeof u!=="string")return e;let n="",r,t;for(let s of u){let a=i.includes(s);if(a===!0){e.push(n),n="",r=void 0;continue}let F=He(s);if(t===!1){if(r===!1&&F===!0){e.push(n),n=s,r=F;continue}if(r===!0&&F===!1&&n.length>1){let C=n.at(-1);e.push(n.slice(0,Math.max(0,n.length-1))),n=C+s,r=F;continue}}n+=s,r=F,t=a}return e.push(n),e}function Ke(u){return u?u[0].toUpperCase()+u.slice(1):""}function Je(u){return u?u[0].toLowerCase()+u.slice(1):""}function Ze(u,D){return u?(Array.isArray(u)?u:Dt(u)).map((i)=>Ke(D?.normalize?i.toLowerCase():i)).join(""):""}function ke(u,D){return Je(Ze(u||"",D))}function Ye(u,D){return u?(Array.isArray(u)?u:Dt(u)).map((i)=>i.toLowerCase()).join(D??"-"):""}function eD(u){return u==null?[]:Array.isArray(u)?u:[u]}function Qe(u,D,i,e){let n,r=u[D],t=~e.string.indexOf(D)?i==null||i===!0?"":String(i):typeof i==="boolean"?i:~e.boolean.indexOf(D)?i==="false"?!1:i==="true"||(u._.push((n=+i,n*0===0)?n:i),!!i):(n=+i,n*0===0)?n:i;u[D]=r==null?t:Array.isArray(r)?r.concat(t):[r,t]}function qe(u=[],D={}){let i,e,n,r,t,s={_:[]},a=0,F=0,C=0,c=u.length,B=D.alias!==void 0,m=D.unknown!==void 0,g=D.default!==void 0;if(D.alias=D.alias||{},D.string=eD(D.string),D.boolean=eD(D.boolean),B)for(i in D.alias){e=D.alias[i]=eD(D.alias[i]);for(a=0;a<e.length;a++)(D.alias[e[a]]=e.concat(i)).splice(a,1)}for(a=D.boolean.length;a-- >0;){e=D.alias[D.boolean[a]]||[];for(F=e.length;F-- >0;)D.boolean.push(e[F])}for(a=D.string.length;a-- >0;){e=D.alias[D.string[a]]||[];for(F=e.length;F-- >0;)D.string.push(e[F])}if(g){for(i in D.default)if(r=typeof D.default[i],e=D.alias[i]=D.alias[i]||[],D[r]!==void 0){D[r].push(i);for(a=0;a<e.length;a++)D[r].push(e[a])}}let M=m?Object.keys(D.alias):[];for(a=0;a<c;a++){if(n=u[a],n==="--"){s._=s._.concat(u.slice(++a));break}for(F=0;F<n.length;F++)if(n.charCodeAt(F)!==45)break;if(F===0)s._.push(n);else if(n.substring(F,F+3)==="no-"){if(r=n.slice(Math.max(0,F+3)),m&&!~M.indexOf(r))return D.unknown(n);s[r]=!1}else{for(C=F+1;C<n.length;C++)if(n.charCodeAt(C)===61)break;r=n.substring(F,C),t=n.slice(Math.max(0,++C))||a+1===c||(""+u[a+1]).charCodeAt(0)===45||u[++a],e=F===2?[r]:r;for(C=0;C<e.length;C++){if(r=e[C],m&&!~M.indexOf(r))return D.unknown("-".repeat(F)+r);Qe(s,r,C+1<e.length||t,D)}}}if(g){for(i in D.default)if(s[i]===void 0)s[i]=D.default[i]}if(B)for(i in s){e=D.alias[i]||[];while(e.length>0)s[e.shift()]=s[i]}return s}function Le(u,D){let i={boolean:[],string:[],mixed:[],alias:{},default:{}},e=tt(D);for(let s of e){if(s.type==="positional")continue;if(s.type==="string")i.string.push(s.name);else if(s.type==="boolean")i.boolean.push(s.name);if(s.default!==void 0)i.default[s.name]=s.default;if(s.alias)i.alias[s.name]=s.alias}let n=qe(u,i),[...r]=n._,t=new Proxy(n,{get(s,a){return s[a]??s[ke(a)]??s[Ye(a)]}});for(let[,s]of e.entries())if(s.type==="positional"){let a=r.shift();if(a!==void 0)t[s.name]=a;else if(s.default===void 0&&s.required!==!1)throw new k(`Missing required positional argument: ${s.name.toUpperCase()}`,"EARG");else t[s.name]=s.default}else if(s.required&&t[s.name]===void 0)throw new k(`Missing required argument: --${s.name}`,"EARG");return t}function tt(u){let D=[];for(let[i,e]of Object.entries(u||{}))D.push({...e,name:i,alias:Re(e.alias)});return D}function b(u){return u}async function it(u,D){let i=await U(u.args||{}),e=Le(D.rawArgs,i),n={rawArgs:D.rawArgs,args:e,data:D.data,cmd:u};if(typeof u.setup==="function")await u.setup(n);let r;try{let t=await U(u.subCommands);if(t&&Object.keys(t).length>0){let s=D.rawArgs.findIndex((F)=>!F.startsWith("-")),a=D.rawArgs[s];if(a){if(!t[a])throw new k(`Unknown command \`${a}\``,"E_UNKNOWN_COMMAND");let F=await U(t[a]);if(F)await it(F,{rawArgs:D.rawArgs.slice(s+1)})}else if(!u.run)throw new k("No command specified.","E_NO_COMMAND")}if(typeof u.run==="function")r=await u.run(n)}finally{if(typeof u.cleanup==="function")await u.cleanup(n)}return{result:r}}async function nD(u,D,i){let e=await U(u.subCommands);if(e&&Object.keys(e).length>0){let n=D.findIndex((s)=>!s.startsWith("-")),r=D[n],t=await U(e[r]);if(t)return nD(t,D.slice(n+1),u)}return[u,i]}async function Xe(u,D){try{N.log(await Oe(u,D)+`
|
|
73
|
+
`)}catch(i){N.error(i)}}async function Oe(u,D){let i=await U(u.meta||{}),e=tt(await U(u.args||{})),n=await U(D?.meta||{}),r=`${n.name?`${n.name} `:""}`+(i.name||process.argv[1]),t=[],s=[],a=[],F=[];for(let m of e)if(m.type==="positional"){let g=m.name.toUpperCase(),M=m.required!==!1&&m.default===void 0,R=m.default?`="${m.default}"`:"";s.push(["`"+g+R+"`",m.description||"",m.valueHint?`<${m.valueHint}>`:""]),F.push(M?`<${g}>`:`[${g}]`)}else{let g=m.required===!0&&m.default===void 0,M=(m.type==="boolean"&&m.default===!0?[...(m.alias||[]).map((R)=>`--no-${R}`),`--no-${m.name}`].join(", "):[...(m.alias||[]).map((R)=>`-${R}`),`--${m.name}`].join(", "))+(m.type==="string"&&(m.valueHint||m.default)?`=${m.valueHint?`<${m.valueHint}>`:`"${m.default||""}"`}`:"");if(t.push(["`"+M+(g?" (required)":"")+"`",m.description||""]),g)F.push(M)}if(u.subCommands){let m=[],g=await U(u.subCommands);for(let[M,R]of Object.entries(g)){let Kt=await U(R),Jt=await U(Kt?.meta);a.push([`\`${M}\``,Jt?.description||""]),m.push(M)}F.push(m.join("|"))}let C=[],c=i.version||n.version;C.push(p.gray(`${i.description} (${r+(c?` v${c}`:"")})`),"");let B=t.length>0||s.length>0;if(C.push(`${p.underline(p.bold("USAGE"))} \`${r}${B?" [OPTIONS]":""} ${F.join(" ")}\``,""),s.length>0)C.push(p.underline(p.bold("ARGUMENTS")),""),C.push(iD(s," ")),C.push("");if(t.length>0)C.push(p.underline(p.bold("OPTIONS")),""),C.push(iD(t," ")),C.push("");if(a.length>0)C.push(p.underline(p.bold("COMMANDS")),""),C.push(iD(a," ")),C.push("",`Use \`${r} <command> --help\` for more information about a command.`);return C.filter((m)=>typeof m==="string").join(`
|
|
74
|
+
`)}async function et(u,D={}){let i=D.rawArgs||process.argv.slice(2),e=D.showUsage||Xe;try{if(i.includes("--help")||i.includes("-h"))await e(...await nD(u,i)),process.exit(0);else if(i.length===1&&i[0]==="--version"){let n=typeof u.meta==="function"?await u.meta():await u.meta;if(!n?.version)throw new k("No version specified","E_NO_VERSION");N.log(n.version)}else await it(u,{rawArgs:i})}catch(n){let r=n instanceof k;if(!r)N.error(n,`
|
|
75
|
+
`);if(r)await e(...await nD(u,i));N.error(n.message),process.exit(1)}}var T={name:"@stackedhq/cli",version:"0.1.0",description:"The Stacked CLI — deploy, manage, and inspect your Stacked services from the terminal.",author:"Perier",license:"UNLICENSED",private:!1,type:"module",bin:{stacked:"./dist/index.js"},files:["dist","README.md","CHANGELOG.md"],engines:{node:">=20"},repository:{type:"git",url:"https://github.com/stackedhq/stacked.git",directory:"packages/cli"},homepage:"https://stacked.rest",scripts:{dev:"bun run --watch src/index.ts",build:"bun build src/index.ts --target=node --outfile=dist/index.js --minify --banner='#!/usr/bin/env node' && chmod +x dist/index.js","type-check":"tsc --noEmit",start:"node dist/index.js",test:"vitest run",prepublishOnly:"bun run build"},dependencies:{citty:"^0.1.6",consola:"^3.4.2",valibot:"^1.0.0"},devDependencies:{"@types/node":"^22.10.0",typescript:"^5.7.0",vitest:"^2.1.0"},publishConfig:{access:"public"}};var lu=b({meta:{name:"completion",description:"Generate a shell completion script for your $SHELL."},args:{shell:{type:"positional",description:"Shell to target: zsh | bash | fish.",required:!1}},async run({args:u}){let D=u.shell??(process.env.SHELL?xe(process.env.SHELL):"bash");process.stdout.write(un(D))}});function xe(u){if(u.includes("zsh"))return"zsh";if(u.includes("fish"))return"fish";return"bash"}function un(u){let D=["login","logout","whoami","status","services","deploy","redeploy","deployments","logs","restart","stop","env","machines","databases","domains","projects","link","unlink","open","update","completion","schema"];if(u==="zsh")return["#compdef stacked","_stacked() {",` local -a cmds=(${D.map((i)=>`'${i}'`).join(" ")})`," _describe 'stacked' cmds","}","_stacked",""].join(`
|
|
76
|
+
`);if(u==="fish")return D.map((i)=>`complete -c stacked -n "__fish_use_subcommand" -a "${i}"`).join(`
|
|
77
|
+
`).concat(`
|
|
78
|
+
`);return["_stacked() {",' local cur="${COMP_WORDS[COMP_CWORD]}"',` COMPREPLY=( $(compgen -W "${D.join(" ")}" -- "$cur") )`,"}","complete -F _stacked stacked",""].join(`
|
|
79
|
+
`)}var h={NOT_AUTHENTICATED:"NOT_AUTHENTICATED",FORBIDDEN:"FORBIDDEN",FORBIDDEN_PRELAUNCH:"FORBIDDEN_PRELAUNCH",NOT_FOUND:"NOT_FOUND",CONFLICT:"CONFLICT",VALIDATION_ERROR:"VALIDATION_ERROR",RATE_LIMITED:"RATE_LIMITED",SERVER_ERROR:"SERVER_ERROR",NETWORK_ERROR:"NETWORK_ERROR",CONFIG_ERROR:"CONFIG_ERROR",USER_INPUT_ERROR:"USER_INPUT_ERROR",DEPLOYMENT_IN_FLIGHT:"DEPLOYMENT_IN_FLIGHT",DEPLOYMENT_FAILED:"DEPLOYMENT_FAILED",TIMEOUT:"TIMEOUT",UNKNOWN:"UNKNOWN"},rD={OK:0,UNKNOWN:1,USER_INPUT_ERROR:2,NOT_AUTHENTICATED:3,FORBIDDEN:4,FORBIDDEN_PRELAUNCH:4,NOT_FOUND:5,CONFLICT:6,RATE_LIMITED:7,NETWORK_ERROR:8,SERVER_ERROR:9,VALIDATION_ERROR:2,CONFIG_ERROR:1,DEPLOYMENT_IN_FLIGHT:6,DEPLOYMENT_FAILED:10,TIMEOUT:11};class o extends Error{code;httpStatus;hint;constructor(u,D,i={}){super(D);this.code=u,this.httpStatus=i.httpStatus,this.hint=i.hint}}function x(u){if(u===400)return h.VALIDATION_ERROR;if(u===401)return h.NOT_AUTHENTICATED;if(u===403)return h.FORBIDDEN;if(u===404)return h.NOT_FOUND;if(u===409)return h.CONFLICT;if(u===429)return h.RATE_LIMITED;if(u>=500)return h.SERVER_ERROR;return h.UNKNOWN}function nt(u){return rD[u]??1}function S(u,D,i){if(D.length===0){u.log("No results.");return}let e=D.map((t)=>i.map((s)=>s.get(t)??"")),n=i.map((t,s)=>Math.max(t.header.length,...e.map((a)=>a[s]?.length??0))),r=(t)=>t.map((s,a)=>{let F=n[a]??0;return i[a]?.align==="right"?s.padStart(F):s.padEnd(F)}).join(" ");u.log(r(i.map((t)=>t.header))),u.log(r(n.map((t)=>"─".repeat(t))));for(let t of e)u.log(r(t))}function K(u,D){let i=Math.max(...D.map(([e])=>e.length));for(let[e,n]of D)u.log(`${e.padEnd(i)} ${n??"—"}`)}var Dn=/stk_(live|test)_[A-Za-z0-9_-]+/g,tn=/(Bearer\s+)([A-Za-z0-9._~+/=-]+)/gi;function en(u){return u.replace(Dn,(D)=>`${D.slice(0,12)}****`).replace(tn,(D,i)=>`${i}****`)}function L(u){if(u==null)return u;if(typeof u==="string")return en(u);if(Array.isArray(u))return u.map(L);if(typeof u==="object"){let D={};for(let[i,e]of Object.entries(u))if(/^(authorization|x-api-key|cookie|set-cookie|token)$/i.test(i))D[i]="****";else D[i]=L(e);return D}return u}async function*rt(u){let D=u.apiUrl.replace(/\/+$/,""),i=new URLSearchParams;if(u.query){for(let[C,c]of Object.entries(u.query))if(c!==void 0&&c!==null&&c!=="")i.set(C,String(c))}let e=i.toString(),n=`${D}/api${u.path}${e?`?${e}`:""}`,r={accept:"text/event-stream","x-request-id":u.requestId,"user-agent":`stacked-cli/${process.env.STACKED_CLI_VERSION??"dev"}`};if(u.token)r.authorization=`Bearer ${u.token}`;let t;try{t=await fetch(n,{headers:r,signal:u.signal})}catch(C){if(u.signal.aborted)return;if(C instanceof Error&&C.name==="AbortError")return;throw new o(h.NETWORK_ERROR,C instanceof Error?C.message:"Network error")}if(!t.ok)throw new o(x(t.status),`Log stream failed (${t.status})`,{httpStatus:t.status});if(!t.body)return;let s=t.body.getReader(),a=new TextDecoder,F="";try{while(!0){let{done:C,value:c}=await s.read();if(C)break;F+=a.decode(c,{stream:!0});let B=F.indexOf(`
|
|
80
|
+
|
|
81
|
+
`);while(B!==-1){let m=F.slice(0,B);F=F.slice(B+2);let g=nn(m);if(g!==null&&g.length>0)yield g;B=F.indexOf(`
|
|
82
|
+
|
|
83
|
+
`)}}}catch(C){if(u.signal.aborted)return;if(C instanceof Error&&C.name==="AbortError")return;throw new o(h.NETWORK_ERROR,C instanceof Error?C.message:"Stream error")}finally{try{await s.cancel()}catch{}}}function nn(u){let D=[];for(let i of u.split(`
|
|
84
|
+
`))if(i.startsWith("data:"))D.push(i.slice(5).replace(/^ /,""));if(D.length===0)return null;return D.join(`
|
|
85
|
+
`)}var st=5000,hu=10485760;class ou{opts;constructor(u){this.opts=u}withToken(u){return new ou({...this.opts,token:u})}stream(u){return rt({apiUrl:this.opts.apiUrl,token:this.opts.token,requestId:this.opts.requestId,path:u.path,query:u.query,signal:u.signal})}async request(u){let D=this.buildUrl(u.path,u.query),i={accept:"application/json","x-request-id":this.opts.requestId,"user-agent":`stacked-cli/${process.env.STACKED_CLI_VERSION??"dev"}`,...u.headers};if(u.body!==void 0)i["content-type"]="application/json";if(!u.unauthenticated&&this.opts.token)i.authorization=`Bearer ${this.opts.token}`;let e=new AbortController,n=setTimeout(()=>e.abort(),u.timeoutMs??this.opts.timeoutMs??st);if(this.opts.debug)this.dumpRequest(u.method??"GET",D,i,u.body);let r;try{r=await fetch(D,{method:u.method??"GET",headers:i,body:u.body!==void 0?JSON.stringify(u.body):void 0,signal:e.signal})}catch(F){clearTimeout(n);let C=F instanceof Error&&F.name==="AbortError"?`Request timed out after ${u.timeoutMs??this.opts.timeoutMs??st}ms`:F instanceof Error?F.message:"Network error";throw new o(h.NETWORK_ERROR,C)}clearTimeout(n);let t=Number(r.headers.get("content-length")??0);if(t>hu)throw new o(h.SERVER_ERROR,`Response too large (${t} bytes; cap is ${hu}).`,{httpStatus:r.status});let s=await r.text();if(s.length>hu)throw new o(h.SERVER_ERROR,`Response too large (${s.length} bytes; cap is ${hu}).`,{httpStatus:r.status});let a=null;if(s.length>0)try{a=JSON.parse(s)}catch{if(!r.ok)throw new o(x(r.status),s||`Server returned ${r.status}`,{httpStatus:r.status});throw new o(h.SERVER_ERROR,"Server returned non-JSON response",{httpStatus:r.status})}if(this.opts.debug)this.dumpResponse(r.status,a);if(!r.ok){let F=rn(r.status,a),C=sn(a)??`Request failed (${r.status})`;throw new o(F,C,{httpStatus:r.status})}return a}buildUrl(u,D){let i=this.opts.apiUrl.replace(/\/+$/,""),e=new URLSearchParams;if(D){for(let[t,s]of Object.entries(D))if(s!==void 0&&s!==null&&s!=="")e.set(t,String(s))}let n=e.toString();return`${i}/api${u}${n?`?${n}`:""}`}dumpRequest(u,D,i,e){let n=L(i),r=L(e??null);process.stderr.write(`[stacked debug] → ${u} ${D}
|
|
86
|
+
${JSON.stringify({headers:n,body:r},null,2)}
|
|
87
|
+
`)}dumpResponse(u,D){let i=L(D);process.stderr.write(`[stacked debug] ← ${u}
|
|
88
|
+
${JSON.stringify(i,null,2)}
|
|
89
|
+
`)}}function rn(u,D){if(u===403&&typeof D==="object"&&D!==null&&typeof D.error==="string"&&(D.error.toLowerCase().includes("prelaunch")||D.error.toLowerCase().includes("waitlist")))return h.FORBIDDEN_PRELAUNCH;if(typeof D==="object"&&D!==null){let i=D.code;if(typeof i==="string"&&i in h)return i}return x(u)}function sn(u){if(typeof u==="object"&&u!==null){let D=u.error;if(typeof D==="string")return D;let i=u.message;if(typeof i==="string")return i}return null}import{existsSync as sD,mkdirSync as an,readFileSync as Fn,unlinkSync as Cn,writeFileSync as ln}from"node:fs";import{homedir as at,platform as hn}from"node:os";import{join as uu}from"node:path";var on="https://stacked.rest";function Ft(){if(hn()==="win32"){let D=process.env.APPDATA;if(D)return uu(D,"stacked");return uu(at(),"AppData","Roaming","stacked")}let u=process.env.XDG_CONFIG_HOME;if(u)return uu(u,"stacked");return uu(at(),".config","stacked")}function Y(){return uu(Ft(),"config.json")}function cu(){let u=Y();if(!sD(u))return{version:1};try{let D=Fn(u,"utf8"),i=JSON.parse(D);if(typeof i!=="object"||i===null)return{version:1};if(typeof i.version!=="number")i.version=1;return i}catch{return{version:1}}}function mu(u){let D=Ft();if(!sD(D))an(D,{recursive:!0,mode:448});let i=Y(),e={...u,version:1};if(!e.anonId)e.anonId=crypto.randomUUID();ln(i,`${JSON.stringify(e,null,2)}
|
|
90
|
+
`,{mode:384})}function Ct(){let u=Y();if(sD(u))try{Cn(u)}catch{}}function lt(u){if(u.flag)return{token:u.flag,source:"flag"};if(process.env.STACKED_TOKEN)return{token:process.env.STACKED_TOKEN,source:"env"};if(u.config?.token)return{token:u.config.token,source:"config"};return{token:null,source:"none"}}function ht(u){if(u.flag)return{apiUrl:u.flag,source:"flag"};if(process.env.STACKED_API_URL)return{apiUrl:process.env.STACKED_API_URL,source:"env"};if(u.config?.apiUrl)return{apiUrl:u.config.apiUrl,source:"config"};return{apiUrl:on,source:"default"}}function ot(u){if(u.mode==="json")return new aD(u,!1);if(u.mode==="ndjson")return new aD(u,!0);return new ct(u)}function cn(){return process.env.STACKED_CLI_VERSION??"dev"}class aD{init;mode;constructor(u,D){this.init=u;this.mode=D?"ndjson":"json"}event(u,D){if(!this.init.verbose)return;process.stderr.write(`${JSON.stringify({type:"event",name:u,...D,at:new Date().toISOString()})}
|
|
91
|
+
`)}success(u){let D={schemaVersion:1,ok:!0,command:this.init.commandPath,requestId:this.init.requestId,data:u,meta:this.buildMeta()};this.emit(D)}failure(u){let D={schemaVersion:1,ok:!1,command:this.init.commandPath,requestId:this.init.requestId,error:{code:u.code,message:u.message,httpStatus:u.httpStatus,hint:u.hint},meta:this.buildMeta()};this.emit(D)}human(){}prompt(){return Promise.reject(Error("Interactive prompts are disabled in JSON mode. Pass values via flags or env vars."))}emit(u){process.stdout.write(this.mode==="ndjson"?`${JSON.stringify(u)}
|
|
92
|
+
`:`${JSON.stringify(u,null,2)}
|
|
93
|
+
`)}buildMeta(){return{apiUrl:this.init.apiUrl,apiUrlSource:this.init.apiUrlSource,authSource:this.init.authSource,durationMs:Date.now()-this.init.startedAt,cliVersion:cn()}}}class ct{init;mode="human";constructor(u){this.init=u}event(u,D){if(!this.init.verbose)return;N.info(D)}success(u){if(u===void 0||u===null)return;if(typeof u==="string"){N.log(u);return}N.log(u)}failure(u){if(N.error(u.message),u.hint?.action)N.info(`Try: stacked ${u.hint.action}`);else if(u.hint?.env)N.info(`Set ${u.hint.env} and retry.`);else if(u.hint?.flag)N.info(`Pass ${u.hint.flag} and retry.`)}human(u){u(N)}async prompt(u){let D=await N.prompt(u,{type:"text"});if(typeof D!=="string")throw Error("Prompt cancelled.");return D}}var mn={json:{type:"boolean",description:"Emit a single JSON envelope on stdout (agent-friendly)."},output:{type:"string",description:"Output format: human | json | ndjson."},verbose:{type:"boolean",description:"Print progress events to stderr (ndjson when --json)."},"api-url":{type:"string",description:"Override the Stacked API URL."},token:{type:"string",description:"CLI token (overrides STACKED_TOKEN and saved config)."},debug:{type:"boolean",description:"Dump raw HTTP traffic to stderr (secrets redacted)."}};function E(u){return b({meta:{name:u.name,description:u.description},args:{...mn,...u.args??{}},async run(D){let i=D.args,e=await En(i,u.commandPath??u.name);try{let n=await u.run({ctx:e,args:i});e.renderer.success(n),process.exitCode=0}catch(n){let r=fn(n);e.renderer.failure(r),process.exitCode=nt(r.code)}}})}async function En(u,D){let i=cu(),{apiUrl:e,source:n}=ht({flag:u["api-url"],config:i}),{token:r,source:t}=lt({flag:u.token,config:i}),s=u.output?u.output:u.json?"json":"human",a=crypto.randomUUID(),F=u.debug||process.env.STACKED_DEBUG==="1",C=new ou({apiUrl:e,token:r,requestId:a,debug:F}),c=ot({mode:s,verbose:u.verbose===!0||process.env.STACKED_JSON_EVENTS==="1",apiUrl:e,apiUrlSource:n,authSource:t,commandPath:D,requestId:a,startedAt:Date.now()});return{apiUrl:e,apiUrlSource:n,token:r,authSource:t,config:i,api:C,renderer:c,requestId:a,startedAt:Date.now(),mode:s,debug:F}}function fn(u){if(u instanceof o)return u;if(u instanceof Error)return new o(h.UNKNOWN,u.message);return new o(h.UNKNOWN,"Unknown error")}var mt=E({name:"get",description:"Show a single database by id.",args:{id:{type:"positional",description:"Database id.",required:!0}},commandPath:"databases.get",async run({ctx:u,args:D}){let e=(await u.api.request({method:"GET",path:`/databases/${encodeURIComponent(D.id)}`}))?.data;if(!e)throw new o(h.NOT_FOUND,"Database not found.");return u.renderer.human((n)=>{K(n,[["ID",e.id],["Name",e.name],["Type",e.type??null],["Version",e.version??null],["Image",e.dockerImage??null],["Status",e.status??null],["Port",e.port==null?null:String(e.port)],["Access",e.accessMode??null],["Machine",e.machineId??null],["Project",e.projectId??null]])}),e}});var Et=E({name:"list",description:"List your databases.",args:{limit:{type:"string",description:"Page size (1–100, default 50)."},cursor:{type:"string",description:"Pagination cursor."}},commandPath:"databases.list",async run({ctx:u,args:D}){let i=await u.api.request({method:"GET",path:"/databases",query:{limit:D.limit?Number(D.limit):void 0,cursor:D.cursor}}),e=i?.data??[];return u.renderer.human((n)=>{S(n,e,[{header:"ID",get:(r)=>r.id},{header:"NAME",get:(r)=>r.name},{header:"TYPE",get:(r)=>r.type??"—"},{header:"VERSION",get:(r)=>r.version??"—"},{header:"STATUS",get:(r)=>r.status??"—"},{header:"PORT",get:(r)=>r.port==null?"—":String(r.port)}])}),{databases:e,nextCursor:i?.cursor??null}}});var Eu=b({meta:{name:"databases",description:"Inspect your databases."},subCommands:{list:Et,get:mt}});var ft=new Set(["success","failed","cancelled"]),Bn=2000;function fu(u,D){return{deploymentId:u.id,serviceId:D,status:u.status,watched:!1,startedAt:u.createdAt,finishedAt:u.finishedAt??null,durationMs:null}}async function Bu(u){let{api:D,renderer:i,apiUrl:e,serviceId:n,deployment:r,timeoutSec:t}=u,s=Date.now()+t*1000,a=r.status,F=r;while(Date.now()<s){await gn(Bn);let g=(await D.request({method:"GET",path:`/deployments/${encodeURIComponent(r.id)}`}))?.data;if(!g)continue;if(g.status!==a)i.event("deploy.status",{deploymentId:g.id,status:g.status}),i.human((M)=>M.info(`Status: ${g.status}`)),a=g.status;if(F=g,ft.has(g.status))break}if(!ft.has(F.status))throw new o(h.TIMEOUT,`Deployment ${F.id} did not complete within ${t}s (last status: ${F.status}).`,{hint:{url:`${e}/services/${n}`}});let C=Date.parse(F.createdAt),c=F.finishedAt?Date.parse(F.finishedAt):Date.now(),B={deploymentId:F.id,serviceId:n,status:F.status,watched:!0,startedAt:F.createdAt,finishedAt:F.finishedAt??null,durationMs:Number.isFinite(C)?c-C:null};if(F.status!=="success")throw new o(h.DEPLOYMENT_FAILED,`Deployment ${F.id} ended with status: ${F.status}.`,{hint:{url:`${e}/services/${n}`}});return B}function gn(u){return new Promise((D)=>setTimeout(D,u))}import{existsSync as Bt,readFileSync as pn,unlinkSync as An,writeFileSync as $n}from"node:fs";import{join as bn}from"node:path";var dn=".stacked";function Q(u=process.cwd()){return bn(u,dn)}function y(u=process.cwd()){let D=Q(u);if(!Bt(D))return null;try{let i=JSON.parse(pn(D,"utf8"));if(typeof i.serviceId!=="string")return null;return i}catch{return null}}function gt(u,D=process.cwd()){$n(Q(D),`${JSON.stringify({serviceId:u},null,2)}
|
|
94
|
+
`,{mode:420})}function pt(u=process.cwd()){let D=Q(u);if(!Bt(D))return!1;try{return An(D),!0}catch{return!1}}var wn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function d(u,D){if(wn.test(D))return D;let n=((await u.request({method:"GET",path:"/services",query:{limit:100}}))?.data??[]).find((r)=>r.slug===D||r.name===D);if(!n)throw new o(h.NOT_FOUND,`No service matched "${D}".`);return n.id}var gu=E({name:"deploy",description:"Deploy a service. Defaults to the linked service in the current directory.",args:{service:{type:"positional",description:"Service id or slug to deploy.",required:!1},watch:{type:"boolean",description:"Wait until the deployment terminates (default in TTY mode)."},"no-watch":{type:"boolean",description:"Return immediately with the deployment id."},timeout:{type:"string",description:"Watch timeout in seconds (default 600)."}},commandPath:"deploy",async run({ctx:u,args:D}){if(!u.token)throw new o(h.NOT_AUTHENTICATED,"Run `stacked login` first.",{hint:{action:"login"}});let i=D.service??y()?.serviceId;if(!i)throw new o(h.USER_INPUT_ERROR,"No service specified. Pass a positional, run `stacked link <id>`, or set one in `.stacked`.",{hint:{action:"link <serviceId>"}});let e=await d(u.api,i),n=D["no-watch"]?!1:D.watch!==void 0?D.watch===!0:u.mode==="human",t=(await u.api.request({method:"POST",path:`/deployments/service/${encodeURIComponent(e)}`,body:{}}))?.data;if(!t)throw new o(h.SERVER_ERROR,"Server did not return a deployment.");if(u.renderer.event("deploy.started",{deploymentId:t.id,serviceId:e,status:t.status}),u.renderer.human((s)=>s.info(`Deployment ${t.id} created (status: ${t.status}).`)),!n)return fu(t,e);return Bu({api:u.api,renderer:u.renderer,apiUrl:u.apiUrl,serviceId:e,deployment:t,timeoutSec:D.timeout?Number(D.timeout):600})}});var At=E({name:"cancel",description:"Cancel an in-flight deployment.",args:{id:{type:"positional",description:"Deployment id.",required:!0}},commandPath:"deployments.cancel",async run({ctx:u,args:D}){let e=(await u.api.request({method:"POST",path:`/deployments/${encodeURIComponent(D.id)}/cancel`,body:{}}))?.data?.status??"cancelled";return u.renderer.human((n)=>n.success(`Deployment ${D.id} ${e}.`)),{deploymentId:D.id,status:e}}});var $t=E({name:"get",description:"Show a single deployment by id.",args:{id:{type:"positional",description:"Deployment id.",required:!0}},commandPath:"deployments.get",async run({ctx:u,args:D}){let e=(await u.api.request({method:"GET",path:`/deployments/${encodeURIComponent(D.id)}`}))?.data;if(!e)throw new o(h.NOT_FOUND,"Deployment not found.");return u.renderer.human((n)=>{K(n,[["ID",e.id],["Service",e.serviceId],["Status",e.status],["Triggered by",e.triggeredBy??null],["Commit",e.commitSha??null],["Message",e.commitMessage??null],["Image digest",e.imageDigest??null],["Health probe",e.healthProbeOk==null?null:e.healthProbeOk?"ok":`failed${e.healthProbeError?`: ${e.healthProbeError}`:""}`],["Started",e.startedAt??null],["Finished",e.finishedAt??null],["Created",e.createdAt]])}),e}});var bt=E({name:"list",description:"List deployments for a service, or recent deployments across all services.",args:{service:{type:"positional",description:"Service id or slug. Defaults to the linked service; omit for all services.",required:!1},limit:{type:"string",description:"Page size (default 50 per-service, 10 global)."},cursor:{type:"string",description:"Pagination cursor (per-service listing only)."}},commandPath:"deployments.list",async run({ctx:u,args:D}){let i=D.service??y()?.serviceId,e=[],n=null;if(i){let r=await d(u.api,i),t=await u.api.request({method:"GET",path:`/deployments/service/${encodeURIComponent(r)}`,query:{limit:D.limit?Number(D.limit):void 0,cursor:D.cursor}});e=t?.data??[],n=t?.nextCursor??null}else e=(await u.api.request({method:"GET",path:"/deployments",query:{limit:D.limit?Number(D.limit):void 0}}))?.data??[];return u.renderer.human((r)=>{S(r,e,[{header:"ID",get:(t)=>t.id},{header:"SERVICE",get:(t)=>t.serviceId},{header:"STATUS",get:(t)=>t.status},{header:"TRIGGER",get:(t)=>t.triggeredBy??"—"},{header:"CREATED",get:(t)=>t.createdAt}])}),{deployments:e,nextCursor:n}}});var pu=b({meta:{name:"deployments",description:"List, inspect, and cancel deployments."},subCommands:{list:bt,get:$t,cancel:At}});var dt=E({name:"list",description:"List your domains.",args:{limit:{type:"string",description:"Page size (1–100, default 50)."},cursor:{type:"string",description:"Pagination cursor."}},commandPath:"domains.list",async run({ctx:u,args:D}){let i=await u.api.request({method:"GET",path:"/domains",query:{limit:D.limit?Number(D.limit):void 0,cursor:D.cursor}}),e=i?.data??[];return u.renderer.human((n)=>{S(n,e,[{header:"ID",get:(r)=>r.id},{header:"DOMAIN",get:(r)=>r.domain},{header:"PATH",get:(r)=>r.path??"/"},{header:"TARGET",get:(r)=>r.serviceId?`service:${r.serviceId}`:r.machineId?`${r.machineId}:${r.upstreamPort??"?"}`:"—"},{header:"STATUS",get:(r)=>r.status??"—"}])}),{domains:e,nextCursor:i?.cursor??null}}});var Au=b({meta:{name:"domains",description:"Inspect your domains."},subCommands:{list:dt}});async function J(u,D){if(!u.token)throw new o(h.NOT_AUTHENTICATED,"Run `stacked login` first.",{hint:{action:"login"}});let i=D??y()?.serviceId;if(!i)throw new o(h.USER_INPUT_ERROR,"No service specified. Pass --service <id> or run `stacked link <id>`.",{hint:{flag:"--service"}});return d(u.api,i)}function $u(u){let D=u._;return Array.isArray(D)?D.map((i)=>String(i)):[]}function wt(u){if(u.length===0)throw new o(h.USER_INPUT_ERROR,"Provide at least one KEY=VALUE pair.");return u.map((D)=>{let i=D.indexOf("=");if(i<=0)throw new o(h.USER_INPUT_ERROR,`Invalid pair "${D}". Expected KEY=VALUE.`);return{key:D.slice(0,i),value:D.slice(i+1)}})}var yt=E({name:"list",description:"List environment variables for a service.",args:{service:{type:"string",description:"Service id or slug. Defaults to the linked service."}},commandPath:"env.list",async run({ctx:u,args:D}){let i=await J(u,D.service),n=((await u.api.request({method:"GET",path:`/env-vars/service/${encodeURIComponent(i)}`}))?.data??[]).map((r)=>({key:r.key,value:r.value}));return u.renderer.human((r)=>{S(r,n,[{header:"KEY",get:(t)=>t.key},{header:"VALUE",get:(t)=>t.value}])}),{serviceId:i,vars:n}}});import{existsSync as yn,writeFileSync as vn}from"node:fs";var vt=E({name:"pull",description:"Write a service's environment variables to a .env file.",args:{service:{type:"string",description:"Service id or slug. Defaults to the linked service."},file:{type:"string",description:"Output file path (default: .env)."},force:{type:"boolean",description:"Overwrite the file if it already exists."}},commandPath:"env.pull",async run({ctx:u,args:D}){let i=await J(u,D.service),e=D.file??".env";if(yn(e)&&!D.force)throw new o(h.CONFLICT,`${e} already exists. Pass --force to overwrite.`,{hint:{flag:"--force"}});let r=(await u.api.request({method:"GET",path:`/env-vars/service/${encodeURIComponent(i)}`}))?.data??[],t=r.map((s)=>`${s.key}=${Mn(s.value)}`).join(`
|
|
95
|
+
`);return vn(e,t?`${t}
|
|
96
|
+
`:"",{mode:384}),u.renderer.human((s)=>s.success(`Wrote ${r.length} variable(s) to ${e}.`)),{serviceId:i,file:e,count:r.length}}});function Mn(u){if(u==="")return"";if(/^[A-Za-z0-9_./:@-]+$/.test(u))return u;return`"${u.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`}var Mt=E({name:"set",description:"Set environment variables (KEY=VALUE …) on a service.",args:{service:{type:"string",description:"Service id or slug. Defaults to the linked service."},pairs:{type:"positional",description:"One or more KEY=VALUE pairs.",required:!1}},commandPath:"env.set",async run({ctx:u,args:D}){let i=wt($u(D)),e=await J(u,D.service);await u.api.request({method:"PUT",path:`/env-vars/service/${encodeURIComponent(e)}`,body:{vars:i}});let n=i.map((r)=>r.key);return u.renderer.human((r)=>r.success(`Set ${n.length} variable(s): ${n.join(", ")}.`)),{serviceId:e,set:n}}});var Nt=E({name:"unset",description:"Remove environment variables by key from a service.",args:{service:{type:"string",description:"Service id or slug. Defaults to the linked service."},keys:{type:"positional",description:"One or more variable keys to remove.",required:!1}},commandPath:"env.unset",async run({ctx:u,args:D}){let i=$u(D);if(i.length===0)throw new o(h.USER_INPUT_ERROR,"Provide at least one variable key to remove.");let e=await J(u,D.service),r=(await u.api.request({method:"GET",path:`/env-vars/service/${encodeURIComponent(e)}`}))?.data??[],t=new Map(r.map((F)=>[F.key,F.id])),s=[],a=[];for(let F of i){let C=t.get(F);if(!C){a.push(F);continue}await u.api.request({method:"DELETE",path:`/env-vars/${encodeURIComponent(C)}`}),s.push(F)}return u.renderer.human((F)=>{if(s.length>0)F.success(`Removed: ${s.join(", ")}.`);if(a.length>0)F.warn(`Not set (skipped): ${a.join(", ")}.`)}),{serviceId:e,removed:s,notFound:a}}});var bu=b({meta:{name:"env",description:"Manage a service's environment variables."},subCommands:{list:yt,set:Mt,unset:Nt,pull:vt}});var du=E({name:"link",description:"Link the current directory to a Stacked service (writes .stacked).",args:{service:{type:"positional",description:"Service id or slug.",required:!0}},commandPath:"link",async run({ctx:u,args:D}){let i=await d(u.api,D.service);return gt(i),u.renderer.human((e)=>e.success(`Linked to service ${i} (.stacked written)`)),{serviceId:i,path:Q()}}});import{hostname as In}from"node:os";import{spawn as FD}from"node:child_process";import{platform as Nn}from"node:os";async function St(u,D,i){let e=await u.request({method:"POST",path:"/cli/device/code",body:{clientName:D},unauthenticated:!0,timeoutMs:5000});i.onPrompt({userCode:e.userCode,verificationUri:e.verificationUri,verificationUriComplete:e.verificationUriComplete,expiresIn:e.expiresIn}),Tn(e.verificationUriComplete);let n=Date.now()+e.expiresIn*1000,r=Math.max(e.interval,1)*1000,t=0;while(Date.now()<n){t+=1,i.onPoll?.(t),await Vn(r);try{let s=await u.request({method:"POST",path:"/cli/device/token",body:{deviceCode:e.deviceCode},unauthenticated:!0,timeoutMs:1e4});if(s.token)return{token:s.token}}catch(s){if(!(s instanceof o))throw s;switch(Sn(s)){case"authorization_pending":continue;case"slow_down":r+=3000;continue;case"expired_token":throw new o(h.USER_INPUT_ERROR,"Authorization request expired before approval. Run `stacked login` again.",{hint:{action:"login"}});case"access_denied":throw new o(h.FORBIDDEN,"Authorization request was denied.");case"token_already_issued":throw new o(h.CONFLICT,"This authorization has already been claimed. Run `stacked login` again.",{hint:{action:"login"}});default:throw s}}}throw new o(h.USER_INPUT_ERROR,"Authorization request expired before approval. Run `stacked login` again.",{hint:{action:"login"}})}function Sn(u){let D=["authorization_pending","slow_down","expired_token","access_denied","invalid_grant","token_already_issued"];for(let i of D)if(u.message===i)return i;return null}function Vn(u){return new Promise((D)=>setTimeout(D,u))}function Tn(u){try{let D=Nn();if(D==="darwin")FD("open",[u],{stdio:"ignore",detached:!0}).unref();else if(D==="win32")FD("cmd",["/c","start","",u],{stdio:"ignore",detached:!0,windowsHide:!0}).unref();else FD("xdg-open",[u],{stdio:"ignore",detached:!0}).unref()}catch{}}var wu=E({name:"login",description:"Authenticate with Stacked. Opens a browser by default; pass the global --token to paste an existing API key.",args:{name:{type:"string",description:"Label for the API key created by the browser flow (default: hostname)."}},commandPath:"login",async run({ctx:u,args:D}){if(u.authSource==="env"&&u.token){let r=await Vt(u.api);return{userId:r.userId,email:r.email,authSource:"env",flow:"env"}}let i=u.authSource==="flag"?u.token:null,e="device";if(i)e="paste";else if(u.mode!=="human")throw new o(h.USER_INPUT_ERROR,"stacked login in non-interactive mode requires --token or STACKED_TOKEN.",{hint:{flag:"--token",env:"STACKED_TOKEN"}});else{let r=D.name??In();i=(await St(u.api,r,{onPrompt:({userCode:s,verificationUri:a,verificationUriComplete:F,expiresIn:C})=>{u.renderer.human((c)=>{c.box(["Authorize this CLI in your browser:","",` ${F}`,"",`If the page doesn't open, visit ${a} and enter:`,"",` ${s}`,"",`(expires in ${Math.round(C/60)} minutes)`].join(`
|
|
97
|
+
`))}),u.renderer.event("login.prompt",{userCode:s,verificationUri:a,verificationUriComplete:F,expiresIn:C})},onPoll:(s)=>u.renderer.event("login.poll",{attempt:s})})).token}let n=await Vt(u.api.withToken(i));return mu({...u.config,apiUrl:u.apiUrl,token:i,userId:n.userId,email:n.email}),{userId:n.userId,email:n.email,authSource:"config",flow:e}}});async function Vt(u){let D=await u.request({method:"GET",path:"/auth/get-session"});if(!D?.user)throw new o(h.NOT_AUTHENTICATED,"Token did not resolve to a session.",{hint:{action:"login"}});return{userId:D.user.id,email:D.user.email}}var yu=E({name:"logout",description:"Sign out of Stacked. Revokes the local token unless --keep-server is set.",args:{"keep-server":{type:"boolean",description:"Don't try to revoke the token on the server."}},commandPath:"logout",async run({ctx:u,args:D}){let i=!1;if(!D["keep-server"]&&u.token?.startsWith("stk_live_"))try{i=(await u.api.request({method:"POST",path:"/keys/revoke-self"}))?.data?.revoked===!0}catch{}return Ct(),{revokedServer:i,configCleared:!0}}});var _n=1500,vu=E({name:"logs",description:"Stream service runtime logs (or a deployment's build logs with --deployment).",args:{service:{type:"positional",description:"Service id or slug. Defaults to the linked service.",required:!1},deployment:{type:"string",description:"Stream a deployment's build/deploy logs instead of runtime logs."},follow:{type:"boolean",description:"Follow the log stream (default in TTY/human mode)."},"no-follow":{type:"boolean",description:"Print the currently-buffered logs and exit (required in --json mode)."}},commandPath:"logs",async run({ctx:u,args:D}){if(!u.token)throw new o(h.NOT_AUTHENTICATED,"Run `stacked login` first.",{hint:{action:"login"}});let i=D["no-follow"]?!1:D.follow!==void 0?D.follow===!0:u.mode==="human";if(u.mode!=="human"&&i)throw new o(h.USER_INPUT_ERROR,"Following logs is not supported in --json mode. Pass --no-follow to capture the current logs.",{hint:{flag:"--no-follow"}});let e,n=null,r=null;if(D.deployment)r=D.deployment,e=`/deployments/${encodeURIComponent(r)}/logs/stream`;else{let c=D.service??y()?.serviceId;if(!c)throw new o(h.USER_INPUT_ERROR,"No service specified. Pass a positional, run `stacked link <id>`, or use --deployment <id>.",{hint:{action:"link <serviceId>"}});n=await d(u.api,c),e=`/logs/service/${encodeURIComponent(n)}/stream`}let t=new AbortController,s=[],a=()=>t.abort();if(i)process.once("SIGINT",a);let F,C=()=>{if(i)return;if(F)clearTimeout(F);F=setTimeout(()=>t.abort(),_n)};if(i)u.renderer.human((c)=>c.info(r?`Streaming logs for deployment ${r} (Ctrl-C to stop)…`:`Streaming logs for service ${n} (Ctrl-C to stop)…`));try{C();for await(let c of u.api.stream({path:e,signal:t.signal}))if(C(),u.mode==="human")process.stdout.write(`${c}
|
|
98
|
+
`);else s.push(c)}finally{if(F)clearTimeout(F);if(i)process.removeListener("SIGINT",a)}if(u.mode==="human")return;return{service:n,deployment:r,followed:!1,count:s.length,lines:s}}});var Tt=E({name:"get",description:"Show a single machine by id.",args:{id:{type:"positional",description:"Machine id.",required:!0}},commandPath:"machines.get",async run({ctx:u,args:D}){let e=(await u.api.request({method:"GET",path:`/machines/${encodeURIComponent(D.id)}`}))?.data;if(!e)throw new o(h.NOT_FOUND,"Machine not found.");return u.renderer.human((n)=>{K(n,[["ID",e.id],["Name",e.name],["IP",e.ipAddress??null],["Status",e.status??null],["Provider",e.provider??null],["Region",e.region??null],["OS / Arch",[e.os,e.arch].filter(Boolean).join(" / ")||null],["Agent",e.agentVersion??null],["CPU",e.cpuUsage==null?null:`${e.cpuUsage}%`],["Memory",e.memoryUsage==null?null:`${e.memoryUsage}%`],["Disk",e.diskUsage==null?null:`${e.diskUsage}%`]])}),e}});var It=E({name:"list",description:"List your connected machines.",args:{limit:{type:"string",description:"Page size (1–100, default 50)."},cursor:{type:"string",description:"Pagination cursor."}},commandPath:"machines.list",async run({ctx:u,args:D}){let i=await u.api.request({method:"GET",path:"/machines",query:{limit:D.limit?Number(D.limit):void 0,cursor:D.cursor}}),e=i?.data??[];return u.renderer.human((n)=>{S(n,e,[{header:"ID",get:(r)=>r.id},{header:"NAME",get:(r)=>r.name},{header:"IP",get:(r)=>r.ipAddress??"—"},{header:"STATUS",get:(r)=>r.status??"—"},{header:"PROVIDER",get:(r)=>r.provider??"—"},{header:"AGENT",get:(r)=>r.agentVersion??"—"}])}),{machines:e,nextCursor:i?.cursor??null}}});var Mu=b({meta:{name:"machines",description:"Inspect your connected machines."},subCommands:{list:It,get:Tt}});import{spawn as CD}from"node:child_process";import{platform as Gn}from"node:os";var Nu=E({name:"open",description:"Open the dashboard for a service in your browser.",args:{service:{type:"positional",description:"Service id or slug. Defaults to the linked service.",required:!1}},commandPath:"open",async run({ctx:u,args:D}){let i=D.service??y()?.serviceId;if(!i)throw new o(h.USER_INPUT_ERROR,"No service specified. Pass a positional or run `stacked link <id>`.");let e=await d(u.api,i),r=`${u.apiUrl.replace(/\/+$/,"")}/services/${e}`;try{let t=Gn();if(t==="darwin")CD("open",[r],{stdio:"ignore",detached:!0}).unref();else if(t==="win32")CD("cmd",["/c","start","",r],{stdio:"ignore",detached:!0,windowsHide:!0}).unref();else CD("xdg-open",[r],{stdio:"ignore",detached:!0}).unref()}catch{}return u.renderer.human((t)=>t.info(`Opening ${r}`)),{url:r}}});var _t=E({name:"list",description:"List your projects.",commandPath:"projects.list",async run({ctx:u}){let i=(await u.api.request({method:"GET",path:"/projects"}))?.data??[];return u.renderer.human((e)=>{S(e,i,[{header:"ID",get:(n)=>n.id},{header:"NAME",get:(n)=>n.name}])}),{projects:i}}});var Su=b({meta:{name:"projects",description:"Inspect your projects."},subCommands:{list:_t}});var Vu=E({name:"redeploy",description:"Redeploy a service's most recent deployment. Defaults to the linked service.",args:{service:{type:"positional",description:"Service id or slug to redeploy.",required:!1},watch:{type:"boolean",description:"Wait until the deployment terminates (default in TTY mode)."},"no-watch":{type:"boolean",description:"Return immediately with the deployment id."},timeout:{type:"string",description:"Watch timeout in seconds (default 600)."}},commandPath:"redeploy",async run({ctx:u,args:D}){if(!u.token)throw new o(h.NOT_AUTHENTICATED,"Run `stacked login` first.",{hint:{action:"login"}});let i=D.service??y()?.serviceId;if(!i)throw new o(h.USER_INPUT_ERROR,"No service specified. Pass a positional, run `stacked link <id>`, or set one in `.stacked`.",{hint:{action:"link <serviceId>"}});let e=await d(u.api,i),r=(await u.api.request({method:"GET",path:`/deployments/service/${encodeURIComponent(e)}`,query:{limit:1}}))?.data?.[0];if(!r)throw new o(h.NOT_FOUND,"No prior deployment to redeploy. Run `stacked deploy` first.",{hint:{action:`deploy ${i}`}});let t=D["no-watch"]?!1:D.watch!==void 0?D.watch===!0:u.mode==="human",a=(await u.api.request({method:"POST",path:`/deployments/${encodeURIComponent(r.id)}/redeploy`,body:{}}))?.data;if(!a)throw new o(h.SERVER_ERROR,"Server did not return a deployment.");if(u.renderer.event("deploy.started",{deploymentId:a.id,serviceId:e,status:a.status,redeployOf:r.id}),u.renderer.human((F)=>F.info(`Redeploy ${a.id} created from ${r.id} (status: ${a.status}).`)),!t)return fu(a,e);return Bu({api:u.api,renderer:u.renderer,apiUrl:u.apiUrl,serviceId:e,deployment:a,timeoutSec:D.timeout?Number(D.timeout):600})}});var Tu=E({name:"restart",description:"Restart a service. Defaults to the linked service.",args:{service:{type:"positional",description:"Service id or slug. Defaults to the linked service.",required:!1}},commandPath:"restart",async run({ctx:u,args:D}){if(!u.token)throw new o(h.NOT_AUTHENTICATED,"Run `stacked login` first.",{hint:{action:"login"}});let i=D.service??y()?.serviceId;if(!i)throw new o(h.USER_INPUT_ERROR,"No service specified. Pass a positional or run `stacked link <id>`.",{hint:{action:"link <serviceId>"}});let e=await d(u.api,i);return await u.api.request({method:"POST",path:`/services/${encodeURIComponent(e)}/restart`,body:{}}),u.renderer.human((n)=>n.success(`Restart queued for service ${e}.`)),{serviceId:e,queued:!0}}});var Un=[{name:"STACKED_TOKEN",description:"Long-lived CLI token (overrides saved config)."},{name:"STACKED_API_URL",description:"Override the API base URL (e.g. for a Cloudflare Tunnel)."},{name:"STACKED_DEBUG",description:"Set to 1 to dump raw HTTP traffic to stderr (secrets redacted)."},{name:"STACKED_JSON_EVENTS",description:"Set to 1 to emit ndjson progress events to stderr in JSON modes."},{name:"STACKED_NO_UPDATE_CHECK",description:"Set to 1 to disable the daily npm registry update probe."}];async function Gt(u,D,i){let e=[];for(let[n,r]of Object.entries(i)){let t=typeof r==="function"?await r():r;e.push(await Ut(n,t))}return{schemaVersion:1,cliVersion:D,rootCommand:u,errorCodes:Object.values(h),exitCodes:rD,envVars:Un,commands:e}}async function Ut(u,D){let i=await lD(D.meta)??{},e=await lD(D.args)??{},n=await lD(D.subCommands)??{},r=[];for(let[t,s]of Object.entries(n)){let a=typeof s==="function"?await s():s;r.push(await Ut(t,a))}return{name:i.name??u,description:i.description??"",args:Object.entries(e).map(([t,s])=>({name:t,type:s.type??"string",required:s.required===!0,positional:s.type==="positional",description:s.description??void 0})),subcommands:r}}async function lD(u){if(typeof u==="function")return await u();return u}var Pt=E({name:"get",description:"Show a single service by id or slug.",args:{idOrSlug:{type:"positional",description:"Service id (uuid) or slug.",required:!0}},commandPath:"services.get",async run({ctx:u,args:D}){let i=await d(u.api,D.idOrSlug),n=(await u.api.request({method:"GET",path:`/services/${encodeURIComponent(i)}`}))?.data;if(!n)throw new o(h.NOT_FOUND,"Service not found.");return u.renderer.human((r)=>{K(r,[["ID",n.id],["Name",n.name],["Slug",n.slug??null],["Status",n.status??null],["Project",n.projectId??null],["Created",n.createdAt]])}),n}});var Rt=E({name:"list",description:"List your services.",args:{cursor:{type:"string",description:"Opaque pagination cursor returned by a previous call."},limit:{type:"string",description:"Page size (1–100, default 50)."},project:{type:"string",description:"Filter by project id."}},commandPath:"services.list",async run({ctx:u,args:D}){let i=await u.api.request({method:"GET",path:"/services",query:{cursor:D.cursor,limit:D.limit?Number(D.limit):void 0}}),e=i.data??[];if(D.project)e=e.filter((n)=>n.projectId===D.project);return u.renderer.human((n)=>{S(n,e,[{header:"ID",get:(r)=>r.id},{header:"NAME",get:(r)=>r.name},{header:"SLUG",get:(r)=>r.slug??"—"},{header:"STATUS",get:(r)=>r.status??"—"}])}),{services:e,nextCursor:i.nextCursor??null}}});var Iu=b({meta:{name:"services",description:"Inspect your Stacked services."},subCommands:{list:Rt,get:Pt}});var _u=E({name:"status",description:"Single-shot view of the CLI's current auth, target API, and linked service.",commandPath:"status",async run({ctx:u}){let D=y(),i=!1,e=null;try{let s=await u.api.request({method:"GET",path:"/health",unauthenticated:!0,timeoutMs:3000});i=s?.status==="ok",e=s?.version??null}catch{i=!1}let n=null,r=!1;if(u.token)try{let s=await u.api.request({method:"GET",path:"/auth/get-session",timeoutMs:3000});if(s?.user)r=!0,n={id:s.user.id,email:s.user.email,role:s.user.role??null}}catch{r=!1}let t={cliVersion:T.version,nodeVersion:process.version,platform:`${process.platform}/${process.arch}`,apiUrl:u.apiUrl,apiUrlSource:u.apiUrlSource,apiReachable:i,apiVersion:e,authenticated:r,authSource:u.authSource,user:n,configPath:Y(),linkedService:D?.serviceId??null};return u.renderer.human((s)=>{if(s.log(`Stacked CLI ${t.cliVersion} (node ${t.nodeVersion}, ${t.platform})`),s.log(`API: ${t.apiUrl} (${t.apiUrlSource})`),s.log(`Reachable: ${t.apiReachable?"yes":"no"}${t.apiVersion?` · v${t.apiVersion}`:""}`),s.log(`Authenticated: ${t.authenticated?"yes":"no"} (source: ${t.authSource})`),t.user)s.log(`User: ${t.user.email} [${t.user.role??"user"}]`);s.log(`Config: ${t.configPath}`),s.log(`Linked: ${t.linkedService??"—"}`)}),t}});var Gu=E({name:"stop",description:"Stop a service. Defaults to the linked service.",args:{service:{type:"positional",description:"Service id or slug. Defaults to the linked service.",required:!1}},commandPath:"stop",async run({ctx:u,args:D}){if(!u.token)throw new o(h.NOT_AUTHENTICATED,"Run `stacked login` first.",{hint:{action:"login"}});let i=D.service??y()?.serviceId;if(!i)throw new o(h.USER_INPUT_ERROR,"No service specified. Pass a positional or run `stacked link <id>`.",{hint:{action:"link <serviceId>"}});let e=await d(u.api,i);return await u.api.request({method:"POST",path:`/services/${encodeURIComponent(e)}/stop`,body:{}}),u.renderer.human((n)=>n.success(`Stop queued for service ${e}.`)),{serviceId:e,queued:!0}}});var Uu=E({name:"unlink",description:"Remove the .stacked file in the current directory.",commandPath:"unlink",async run({ctx:u}){let D=pt();return u.renderer.human((i)=>D?i.success("Unlinked."):i.info("No .stacked file in current directory.")),{removed:D,path:Q()}}});import{exec as Pn}from"node:child_process";var Du="@stackedhq/cli",Pu=E({name:"update",description:"Print (or run with --run) the upgrade command for your install.",args:{run:{type:"boolean",description:"Actually run the upgrade command."}},commandPath:"update",async run({ctx:u,args:D}){let i=Rn(),e=i==="pnpm"?`pnpm add -g ${Du}@latest`:i==="yarn"?`yarn global add ${Du}@latest`:i==="bun"?`bun add -g ${Du}@latest`:`npm i -g ${Du}@latest`,n=await Wn(),r=!1;if(D.run)await new Promise((t,s)=>{Pn(e,(a,F,C)=>{if(F)process.stdout.write(F);if(C)process.stderr.write(C);if(a)s(a);else t()})}),r=!0;return u.renderer.human((t)=>{if(t.log(`Current: ${T.version}`),n)t.log(`Latest: ${n}`);if(t.log(`Run: ${e}`),!D.run)t.info("Pass --run to execute.")}),{currentVersion:T.version,latestVersion:n,upgradeCommand:e,ran:r}}});function Rn(){let u=process.env.npm_config_user_agent??"";if(u.startsWith("pnpm"))return"pnpm";if(u.startsWith("yarn"))return"yarn";if(u.startsWith("bun"))return"bun";return"npm"}async function Wn(){try{let u=new AbortController,D=setTimeout(()=>u.abort(),1500),i=await fetch(`https://registry.npmjs.org/${encodeURIComponent(Du)}/latest`,{signal:u.signal});if(clearTimeout(D),!i.ok)return null;return(await i.json()).version??null}catch{return null}}var Ru=E({name:"whoami",description:"Show the currently authenticated Stacked user.",commandPath:"whoami",async run({ctx:u}){if(!u.token)throw new o(h.NOT_AUTHENTICATED,"Not signed in.",{hint:{action:"login",env:"STACKED_TOKEN"}});let D=await u.api.request({method:"GET",path:"/auth/get-session"});if(!D?.user)throw new o(h.NOT_AUTHENTICATED,"Session not found. Your token may have been revoked.",{hint:{action:"login"}});let i={userId:D.user.id,email:D.user.email,name:D.user.name,role:D.user.role??null,authSource:u.authSource,apiUrl:u.apiUrl};return u.renderer.human((e)=>{e.log(`Signed in as ${i.email} (${i.userId})`),e.log(`API: ${i.apiUrl}`),e.log(`Auth source: ${i.authSource}`)}),i}});var hD=b({meta:{name:"schema",description:"Print a JSON description of every command, error code, exit code, and env var."},async run(){let u=await Gt("stacked",T.version,{login:wu,logout:yu,whoami:Ru,status:_u,services:Iu,deploy:gu,redeploy:Vu,deployments:pu,logs:vu,restart:Tu,stop:Gu,env:bu,machines:Mu,databases:Eu,domains:Au,projects:Su,link:du,unlink:Uu,open:Nu,update:Pu,completion:lu,schema:hD});process.stdout.write(`${JSON.stringify(u,null,2)}
|
|
99
|
+
`)}});import{existsSync as zn}from"node:fs";var Hn=86400000,Kn="https://registry.npmjs.org/@stackedhq/cli/latest";function zt(u){if(process.env.STACKED_NO_UPDATE_CHECK==="1")return!1;if(process.env.CI)return!1;if(u!=="human")return!1;return!0}async function Ht(u){let D=cu(),i=D.lastUpdateCheck?Date.parse(D.lastUpdateCheck):0;if(Number.isFinite(i)&&Date.now()-i<Hn&&D.latestVersion)return Wt(D.latestVersion,u)?D.latestVersion:null;let e=null;try{let n=new AbortController,r=setTimeout(()=>n.abort(),1500),t=await fetch(Kn,{signal:n.signal});if(clearTimeout(r),t.ok){let s=await t.json();if(typeof s.version==="string")e=s.version}}catch{e=null}if(zn(Y()))mu({...D,lastUpdateCheck:new Date().toISOString(),latestVersion:e??D.latestVersion});if(!e)return null;return Wt(e,u)?e:null}function Wt(u,D){let i=u.split(".").map((n)=>Number.parseInt(n,10)||0),e=D.split(".").map((n)=>Number.parseInt(n,10)||0);for(let n=0;n<Math.max(i.length,e.length);n++){let r=i[n]??0,t=e[n]??0;if(r>t)return!0;if(r<t)return!1}return!1}process.env.STACKED_CLI_VERSION=T.version;var Jn=b({meta:{name:"stacked",version:T.version,description:T.description},subCommands:{login:wu,logout:yu,whoami:Ru,status:_u,services:Iu,deploy:gu,redeploy:Vu,deployments:pu,logs:vu,restart:Tu,stop:Gu,env:bu,machines:Mu,databases:Eu,domains:Au,projects:Su,link:du,unlink:Uu,open:Nu,update:Pu,completion:lu,schema:hD}});await et(Jn);{let u=process.argv.slice(2),i=u.includes("--json")||u.includes("--output=json")||u.includes("--output=ndjson")?"json":"human";if(zt(i))try{let e=await Ht(T.version);if(e)process.stderr.write(`
|
|
100
|
+
A newer version of @stackedhq/cli is available: ${T.version} → ${e}
|
|
101
|
+
Run \`stacked update --run\` to upgrade.
|
|
102
|
+
`)}catch{}}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stackedhq/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Stacked CLI — deploy, manage, and inspect your Stacked services from the terminal.",
|
|
5
|
+
"author": "Perier",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"private": false,
|
|
8
|
+
"type": "module",
|
|
9
|
+
"bin": {
|
|
10
|
+
"stacked": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md",
|
|
15
|
+
"CHANGELOG.md"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/stackedhq/stacked.git",
|
|
23
|
+
"directory": "packages/cli"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://stacked.rest",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "bun run --watch src/index.ts",
|
|
28
|
+
"build": "bun build src/index.ts --target=node --outfile=dist/index.js --minify --banner='#!/usr/bin/env node' && chmod +x dist/index.js",
|
|
29
|
+
"type-check": "tsc --noEmit",
|
|
30
|
+
"start": "node dist/index.js",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"prepublishOnly": "bun run build"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"citty": "^0.1.6",
|
|
36
|
+
"consola": "^3.4.2",
|
|
37
|
+
"valibot": "^1.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^22.10.0",
|
|
41
|
+
"typescript": "^5.7.0",
|
|
42
|
+
"vitest": "^2.1.0"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
}
|
|
47
|
+
}
|