agent-relay 4.0.19 → 4.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1407 -537
- package/dist/src/cli/commands/messaging.d.ts +44 -0
- package/dist/src/cli/commands/messaging.d.ts.map +1 -1
- package/dist/src/cli/commands/messaging.js +195 -8
- package/dist/src/cli/commands/messaging.js.map +1 -1
- package/dist/src/cli/commands/setup.d.ts +30 -1
- package/dist/src/cli/commands/setup.d.ts.map +1 -1
- package/dist/src/cli/commands/setup.js +102 -85
- package/dist/src/cli/commands/setup.js.map +1 -1
- package/node_modules/@agent-relay/cloud/dist/auth.d.ts +2 -2
- package/node_modules/@agent-relay/cloud/dist/auth.d.ts.map +1 -1
- package/node_modules/@agent-relay/cloud/dist/auth.js +108 -62
- package/node_modules/@agent-relay/cloud/dist/auth.js.map +1 -1
- package/node_modules/@agent-relay/cloud/package.json +2 -2
- package/node_modules/@agent-relay/config/package.json +1 -1
- package/node_modules/@agent-relay/hooks/package.json +4 -4
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.d.ts +5 -35
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.d.ts.map +1 -1
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.js +158 -292
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.js.map +1 -1
- package/node_modules/@agent-relay/sdk/package.json +3 -2
- package/node_modules/@agent-relay/telemetry/package.json +1 -1
- package/node_modules/@agent-relay/trajectory/package.json +2 -2
- package/node_modules/@agent-relay/user-directory/package.json +2 -2
- package/node_modules/@agent-relay/utils/package.json +2 -2
- package/node_modules/@clack/core/CHANGELOG.md +200 -0
- package/node_modules/@clack/core/LICENSE +9 -0
- package/node_modules/@clack/core/README.md +22 -0
- package/node_modules/@clack/core/dist/index.cjs +15 -0
- package/node_modules/@clack/core/dist/index.cjs.map +1 -0
- package/node_modules/@clack/core/dist/index.d.cts +151 -0
- package/node_modules/@clack/core/dist/index.d.mts +151 -0
- package/node_modules/@clack/core/dist/index.d.ts +151 -0
- package/node_modules/@clack/core/dist/index.mjs +15 -0
- package/node_modules/@clack/core/dist/index.mjs.map +1 -0
- package/node_modules/@clack/core/package.json +62 -0
- package/node_modules/@clack/prompts/CHANGELOG.md +256 -0
- package/node_modules/@clack/prompts/LICENSE +23 -0
- package/node_modules/@clack/prompts/README.md +158 -0
- package/node_modules/@clack/prompts/dist/index.cjs +77 -0
- package/node_modules/@clack/prompts/dist/index.d.ts +106 -0
- package/node_modules/@clack/prompts/dist/index.mjs +77 -0
- package/node_modules/@clack/prompts/node_modules/is-unicode-supported/index.d.ts +12 -0
- package/node_modules/@clack/prompts/node_modules/is-unicode-supported/index.js +17 -0
- package/node_modules/@clack/prompts/node_modules/is-unicode-supported/license +9 -0
- package/node_modules/@clack/prompts/node_modules/is-unicode-supported/package.json +43 -0
- package/node_modules/@clack/prompts/node_modules/is-unicode-supported/readme.md +35 -0
- package/node_modules/@clack/prompts/package.json +65 -0
- package/node_modules/@smithy/config-resolver/package.json +2 -2
- package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
- package/node_modules/@smithy/util-endpoints/dist-cjs/index.js +154 -61
- package/node_modules/@smithy/util-endpoints/dist-es/bdd/BinaryDecisionDiagram.js +15 -0
- package/node_modules/@smithy/util-endpoints/dist-es/decideEndpoint.js +41 -0
- package/node_modules/@smithy/util-endpoints/dist-es/index.js +2 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/coalesce.js +8 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/index.js +3 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/ite.js +3 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/split.js +13 -0
- package/node_modules/@smithy/util-endpoints/dist-es/lib/substring.js +1 -1
- package/node_modules/@smithy/util-endpoints/dist-es/utils/endpointFunctions.js +4 -1
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateExpression.js +20 -5
- package/node_modules/@smithy/util-endpoints/dist-es/utils/evaluateTemplate.js +3 -6
- package/node_modules/@smithy/util-endpoints/dist-es/utils/getReferenceValue.js +1 -5
- package/node_modules/@smithy/util-endpoints/dist-types/bdd/BinaryDecisionDiagram.d.ts +22 -0
- package/node_modules/@smithy/util-endpoints/dist-types/decideEndpoint.d.ts +7 -0
- package/node_modules/@smithy/util-endpoints/dist-types/index.d.ts +2 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/coalesce.d.ts +7 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/index.d.ts +3 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/ite.d.ts +6 -0
- package/node_modules/@smithy/util-endpoints/dist-types/lib/split.d.ts +11 -0
- package/node_modules/@smithy/util-endpoints/dist-types/utils/endpointFunctions.d.ts +4 -0
- package/node_modules/@smithy/util-endpoints/dist-types/utils/getReferenceValue.d.ts +3 -1
- package/node_modules/@smithy/util-endpoints/package.json +1 -1
- package/node_modules/agent-trajectories/README.md +562 -0
- package/node_modules/agent-trajectories/dist/chunk-W222QB6V.js +2036 -0
- package/node_modules/agent-trajectories/dist/chunk-W222QB6V.js.map +1 -0
- package/node_modules/agent-trajectories/dist/cli/index.d.ts +2 -0
- package/node_modules/agent-trajectories/dist/cli/index.js +4592 -0
- package/node_modules/agent-trajectories/dist/cli/index.js.map +1 -0
- package/node_modules/agent-trajectories/dist/index-7tzw_CMS.d.ts +1777 -0
- package/node_modules/agent-trajectories/dist/index.d.ts +90 -0
- package/node_modules/agent-trajectories/dist/index.js +73 -0
- package/node_modules/agent-trajectories/dist/index.js.map +1 -0
- package/node_modules/agent-trajectories/dist/sdk/index.d.ts +2 -0
- package/node_modules/agent-trajectories/dist/sdk/index.js +39 -0
- package/node_modules/agent-trajectories/dist/sdk/index.js.map +1 -0
- package/node_modules/agent-trajectories/package.json +72 -0
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1157 -0
- package/node_modules/commander/esm.mjs +16 -0
- package/node_modules/commander/index.js +24 -0
- package/node_modules/commander/lib/argument.js +149 -0
- package/node_modules/commander/lib/command.js +2509 -0
- package/node_modules/commander/lib/error.js +39 -0
- package/node_modules/commander/lib/help.js +520 -0
- package/node_modules/commander/lib/option.js +330 -0
- package/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/node_modules/commander/package-support.json +16 -0
- package/node_modules/commander/package.json +84 -0
- package/node_modules/commander/typings/esm.d.mts +3 -0
- package/node_modules/commander/typings/index.d.ts +969 -0
- package/node_modules/picocolors/LICENSE +15 -0
- package/node_modules/picocolors/README.md +21 -0
- package/node_modules/picocolors/package.json +25 -0
- package/node_modules/picocolors/picocolors.browser.js +4 -0
- package/node_modules/picocolors/picocolors.d.ts +5 -0
- package/node_modules/picocolors/picocolors.js +75 -0
- package/node_modules/picocolors/types.d.ts +51 -0
- package/node_modules/sisteransi/license +21 -0
- package/node_modules/sisteransi/package.json +34 -0
- package/node_modules/sisteransi/readme.md +113 -0
- package/node_modules/sisteransi/src/index.js +58 -0
- package/node_modules/sisteransi/src/sisteransi.d.ts +35 -0
- package/package.json +10 -10
- package/packages/cloud/dist/auth.d.ts +2 -2
- package/packages/cloud/dist/auth.d.ts.map +1 -1
- package/packages/cloud/dist/auth.js +108 -62
- package/packages/cloud/dist/auth.js.map +1 -1
- package/packages/cloud/package.json +2 -2
- package/packages/config/package.json +1 -1
- package/packages/hooks/package.json +4 -4
- package/packages/sdk/dist/workflows/trajectory.d.ts +5 -35
- package/packages/sdk/dist/workflows/trajectory.d.ts.map +1 -1
- package/packages/sdk/dist/workflows/trajectory.js +158 -292
- package/packages/sdk/dist/workflows/trajectory.js.map +1 -1
- package/packages/sdk/package.json +3 -2
- package/packages/telemetry/package.json +1 -1
- package/packages/trajectory/package.json +2 -2
- package/packages/user-directory/package.json +2 -2
- package/packages/utils/package.json +2 -2
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# @clack/prompts
|
|
2
|
+
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b27a701: add maxItems option to select prompt
|
|
8
|
+
- 89371be: added a new method called `spinner.message(msg: string)`
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 52183c4: Fix `spinner` conflict with terminal on error between `spinner.start()` and `spinner.stop()`
|
|
13
|
+
- ab51d29: Fixes cases where the note title length was miscalculated due to ansi characters
|
|
14
|
+
- Updated dependencies [cd79076]
|
|
15
|
+
- @clack/core@0.3.3
|
|
16
|
+
|
|
17
|
+
## 0.6.3
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- c96eda5: Enable hard line-wrapping behavior for long words without spaces
|
|
22
|
+
- Updated dependencies [c96eda5]
|
|
23
|
+
- @clack/core@0.3.2
|
|
24
|
+
|
|
25
|
+
## 0.6.2
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 58a1df1: Fix line duplication bug by automatically wrapping prompts to `process.stdout.columns`
|
|
30
|
+
- Updated dependencies [58a1df1]
|
|
31
|
+
- @clack/core@0.3.1
|
|
32
|
+
|
|
33
|
+
## 0.6.1
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- ca08fb6: Support complex value types for `select`, `multiselect` and `groupMultiselect`.
|
|
38
|
+
|
|
39
|
+
## 0.6.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- 8a4a12f: add `groupMultiselect` prompt
|
|
44
|
+
- 165a1b3: Add `log` APIs. Supports `log.info`, `log.success`, `log.warn`, and `log.error`. For low-level control, `log.message` is also exposed.
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [8a4a12f]
|
|
49
|
+
- Updated dependencies [8a4a12f]
|
|
50
|
+
- @clack/core@0.3.0
|
|
51
|
+
|
|
52
|
+
## 0.5.1
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- cc11917: Update default `password` mask
|
|
57
|
+
- Updated dependencies [ec812b6]
|
|
58
|
+
- @clack/core@0.2.1
|
|
59
|
+
|
|
60
|
+
## 0.5.0
|
|
61
|
+
|
|
62
|
+
### Minor Changes
|
|
63
|
+
|
|
64
|
+
- d74dd05: Adds a `selectKey` prompt type
|
|
65
|
+
- 54c1bc3: **Breaking Change** `multiselect` has renamed `initialValue` to `initialValues`
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [d74dd05]
|
|
70
|
+
- Updated dependencies [54c1bc3]
|
|
71
|
+
- @clack/core@0.2.0
|
|
72
|
+
|
|
73
|
+
## 0.4.5
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- 1251132: Multiselect: return `Value[]` instead of `Option[]`.
|
|
78
|
+
- 8994382: Add a password prompt to `@clack/prompts`
|
|
79
|
+
- Updated dependencies [1251132]
|
|
80
|
+
- Updated dependencies [8994382]
|
|
81
|
+
- @clack/core@0.1.9
|
|
82
|
+
|
|
83
|
+
## 0.4.4
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- d96071c: Don't mutate `initialValue` in `multiselect`, fix parameter type for `validate()`.
|
|
88
|
+
|
|
89
|
+
Credits to @banjo for the bug report and initial PR!
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [d96071c]
|
|
92
|
+
- @clack/core@0.1.8
|
|
93
|
+
|
|
94
|
+
## 0.4.3
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- 83d890e: Fix text cancel display bug
|
|
99
|
+
|
|
100
|
+
## 0.4.2
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- Update README
|
|
105
|
+
|
|
106
|
+
## 0.4.1
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- 7fb5375: Adds a new `defaultValue` option to the text prompt, removes automatic usage of the placeholder value.
|
|
111
|
+
- Updated dependencies [7fb5375]
|
|
112
|
+
- @clack/core@0.1.6
|
|
113
|
+
|
|
114
|
+
## 0.4.0
|
|
115
|
+
|
|
116
|
+
### Minor Changes
|
|
117
|
+
|
|
118
|
+
- 61b88b6: Add `group` construct to group many prompts together
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- de1314e: Support `required` option for multi-select
|
|
123
|
+
- Updated dependencies [de1314e]
|
|
124
|
+
- @clack/core@0.1.5
|
|
125
|
+
|
|
126
|
+
## 0.3.0
|
|
127
|
+
|
|
128
|
+
### Minor Changes
|
|
129
|
+
|
|
130
|
+
- 493c592: Improve types for select/multiselect prompts. Numbers and booleans are now supported as the `value` option.
|
|
131
|
+
- 15558e3: Improved Windows/non-unicode support
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- ca77da1: Fix multiselect initial value logic
|
|
136
|
+
- Updated dependencies [ca77da1]
|
|
137
|
+
- Updated dependencies [8aed606]
|
|
138
|
+
- @clack/core@0.1.4
|
|
139
|
+
|
|
140
|
+
## 0.2.2
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- 94b24d9: Fix CJS `ansi-regex` interop
|
|
145
|
+
|
|
146
|
+
## 0.2.1
|
|
147
|
+
|
|
148
|
+
### Patch Changes
|
|
149
|
+
|
|
150
|
+
- a99c458: Support `initialValue` option for text prompt
|
|
151
|
+
- Updated dependencies [a99c458]
|
|
152
|
+
- @clack/core@0.1.3
|
|
153
|
+
|
|
154
|
+
## 0.2.0
|
|
155
|
+
|
|
156
|
+
### Minor Changes
|
|
157
|
+
|
|
158
|
+
- Improved type safety
|
|
159
|
+
- b1341d6: Updated styles, new note component
|
|
160
|
+
|
|
161
|
+
### Patch Changes
|
|
162
|
+
|
|
163
|
+
- Updated dependencies [7dcad8f]
|
|
164
|
+
- Updated dependencies [2242f13]
|
|
165
|
+
- Updated dependencies [b1341d6]
|
|
166
|
+
- @clack/core@0.1.2
|
|
167
|
+
|
|
168
|
+
## 0.1.1
|
|
169
|
+
|
|
170
|
+
### Patch Changes
|
|
171
|
+
|
|
172
|
+
- fa09bf5: Use circle for radio, square for checkbox
|
|
173
|
+
- Updated dependencies [4be7dbf]
|
|
174
|
+
- Updated dependencies [b480679]
|
|
175
|
+
- @clack/core@0.1.1
|
|
176
|
+
|
|
177
|
+
## 0.1.0
|
|
178
|
+
|
|
179
|
+
### Minor Changes
|
|
180
|
+
|
|
181
|
+
- 7015ec9: Create new prompt: multi-select
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- Updated dependencies [7015ec9]
|
|
186
|
+
- @clack/core@0.1.0
|
|
187
|
+
|
|
188
|
+
## 0.0.10
|
|
189
|
+
|
|
190
|
+
### Patch Changes
|
|
191
|
+
|
|
192
|
+
- e0b49e5: Update spinner so it actually spins
|
|
193
|
+
|
|
194
|
+
## 0.0.9
|
|
195
|
+
|
|
196
|
+
### Patch Changes
|
|
197
|
+
|
|
198
|
+
- Update README
|
|
199
|
+
|
|
200
|
+
## 0.0.8
|
|
201
|
+
|
|
202
|
+
### Patch Changes
|
|
203
|
+
|
|
204
|
+
- Updated dependencies [9d371c3]
|
|
205
|
+
- @clack/core@0.0.12
|
|
206
|
+
|
|
207
|
+
## 0.0.7
|
|
208
|
+
|
|
209
|
+
### Patch Changes
|
|
210
|
+
|
|
211
|
+
- Update README
|
|
212
|
+
|
|
213
|
+
## 0.0.6
|
|
214
|
+
|
|
215
|
+
### Patch Changes
|
|
216
|
+
|
|
217
|
+
- d20ef2a: Update keywords, URLs
|
|
218
|
+
- Updated dependencies [441d5b7]
|
|
219
|
+
- Updated dependencies [d20ef2a]
|
|
220
|
+
- Updated dependencies [fe13c2f]
|
|
221
|
+
- @clack/core@0.0.11
|
|
222
|
+
|
|
223
|
+
## 0.0.5
|
|
224
|
+
|
|
225
|
+
### Patch Changes
|
|
226
|
+
|
|
227
|
+
- Update README
|
|
228
|
+
|
|
229
|
+
## 0.0.4
|
|
230
|
+
|
|
231
|
+
### Patch Changes
|
|
232
|
+
|
|
233
|
+
- 80404ab: Update README
|
|
234
|
+
|
|
235
|
+
## 0.0.3
|
|
236
|
+
|
|
237
|
+
### Patch Changes
|
|
238
|
+
|
|
239
|
+
- a0cb382: Add `main` entrypoint
|
|
240
|
+
- Updated dependencies [a0cb382]
|
|
241
|
+
- @clack/core@0.0.10
|
|
242
|
+
|
|
243
|
+
## 0.0.2
|
|
244
|
+
|
|
245
|
+
### Patch Changes
|
|
246
|
+
|
|
247
|
+
- Updated dependencies
|
|
248
|
+
- @clack/core@0.0.9
|
|
249
|
+
|
|
250
|
+
## 0.0.1
|
|
251
|
+
|
|
252
|
+
### Patch Changes
|
|
253
|
+
|
|
254
|
+
- a4b5e13: Initial release
|
|
255
|
+
- Updated dependencies [a4b5e13]
|
|
256
|
+
- @clack/core@0.0.8
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Nate Moore
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
`ansi-regex` is adapted from https://github.com/chalk/ansi-regex
|
|
14
|
+
|
|
15
|
+
MIT License
|
|
16
|
+
|
|
17
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
18
|
+
|
|
19
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# `@clack/prompts`
|
|
2
|
+
|
|
3
|
+
Effortlessly build beautiful command-line apps 🪄 [Try the demo](https://stackblitz.com/edit/clack-prompts?file=index.js)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
`@clack/prompts` is an opinionated, pre-styled wrapper around [`@clack/core`](https://www.npmjs.com/package/@clack/core).
|
|
10
|
+
|
|
11
|
+
- 🤏 80% smaller than other options
|
|
12
|
+
- 💎 Beautiful, minimal UI
|
|
13
|
+
- ✅ Simple API
|
|
14
|
+
- 🧱 Comes with `text`, `confirm`, `select`, `multiselect`, and `spinner` components
|
|
15
|
+
|
|
16
|
+
## Basics
|
|
17
|
+
|
|
18
|
+
### Setup
|
|
19
|
+
|
|
20
|
+
The `intro` and `outro` functions will print a message to begin or end a prompt session, respectively.
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { intro, outro } from '@clack/prompts';
|
|
24
|
+
|
|
25
|
+
intro(`create-my-app`);
|
|
26
|
+
// Do stuff
|
|
27
|
+
outro(`You're all set!`);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Cancellation
|
|
31
|
+
|
|
32
|
+
The `isCancel` function is a guard that detects when a user cancels a question with `CTRL + C`. You should handle this situation for each prompt, optionally providing a nice cancellation message with the `cancel` utility.
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import { isCancel, cancel, text } from '@clack/prompts';
|
|
36
|
+
|
|
37
|
+
const value = await text(/* TODO */);
|
|
38
|
+
|
|
39
|
+
if (isCancel(value)) {
|
|
40
|
+
cancel('Operation cancelled.');
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Components
|
|
46
|
+
|
|
47
|
+
### Text
|
|
48
|
+
|
|
49
|
+
The text component accepts a single line of text.
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { text } from '@clack/prompts';
|
|
53
|
+
|
|
54
|
+
const meaning = await text({
|
|
55
|
+
message: 'What is the meaning of life?',
|
|
56
|
+
placeholder: 'Not sure',
|
|
57
|
+
initialValue: '42',
|
|
58
|
+
validate(value) {
|
|
59
|
+
if (value.length === 0) return `Value is required!`;
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Confirm
|
|
65
|
+
|
|
66
|
+
The confirm component accepts a yes or no answer. The result is a boolean value of `true` or `false`.
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
import { confirm } from '@clack/prompts';
|
|
70
|
+
|
|
71
|
+
const shouldContinue = await confirm({
|
|
72
|
+
message: 'Do you want to continue?',
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Select
|
|
77
|
+
|
|
78
|
+
The select component allows a user to choose one value from a list of options. The result is the `value` prop of a given option.
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
import { select } from '@clack/prompts';
|
|
82
|
+
|
|
83
|
+
const projectType = await select({
|
|
84
|
+
message: 'Pick a project type.',
|
|
85
|
+
options: [
|
|
86
|
+
{ value: 'ts', label: 'TypeScript' },
|
|
87
|
+
{ value: 'js', label: 'JavaScript' },
|
|
88
|
+
{ value: 'coffee', label: 'CoffeeScript', hint: 'oh no' },
|
|
89
|
+
],
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Multi-Select
|
|
94
|
+
|
|
95
|
+
The `multiselect` component allows a user to choose many values from a list of options. The result is an array with all selected `value` props.
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
import { multiselect } from '@clack/prompts';
|
|
99
|
+
|
|
100
|
+
const additionalTools = await multiselect({
|
|
101
|
+
message: 'Select additional tools.',
|
|
102
|
+
options: [
|
|
103
|
+
{ value: 'eslint', label: 'ESLint', hint: 'recommended' },
|
|
104
|
+
{ value: 'prettier', label: 'Prettier' },
|
|
105
|
+
{ value: 'gh-action', label: 'GitHub Action' },
|
|
106
|
+
],
|
|
107
|
+
required: false,
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Spinner
|
|
112
|
+
|
|
113
|
+
The spinner component surfaces a pending action, such as a long-running download or dependency installation.
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
import { spinner } from '@clack/prompts';
|
|
117
|
+
|
|
118
|
+
const s = spinner();
|
|
119
|
+
s.start('Installing via npm');
|
|
120
|
+
// Do installation
|
|
121
|
+
s.stop('Installed via npm');
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Utilities
|
|
125
|
+
|
|
126
|
+
### Grouping
|
|
127
|
+
|
|
128
|
+
Grouping prompts together is a great way to keep your code organized. This accepts a JSON object with a name that can be used to reference the group later. The second argument is an optional but has a `onCancel` callback that will be called if the user cancels one of the prompts in the group.
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
import * as p from '@clack/prompts';
|
|
132
|
+
|
|
133
|
+
const group = await p.group(
|
|
134
|
+
{
|
|
135
|
+
name: () => p.text({ message: 'What is your name?' }),
|
|
136
|
+
age: () => p.text({ message: 'What is your age?' }),
|
|
137
|
+
color: ({ results }) =>
|
|
138
|
+
p.multiselect({
|
|
139
|
+
message: `What is your favorite color ${results.name}?`,
|
|
140
|
+
options: [
|
|
141
|
+
{ value: 'red', label: 'Red' },
|
|
142
|
+
{ value: 'green', label: 'Green' },
|
|
143
|
+
{ value: 'blue', label: 'Blue' },
|
|
144
|
+
],
|
|
145
|
+
}),
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
// On Cancel callback that wraps the group
|
|
149
|
+
// So if the user cancels one of the prompts in the group this function will be called
|
|
150
|
+
onCancel: ({ results }) => {
|
|
151
|
+
p.cancel('Operation cancelled.');
|
|
152
|
+
process.exit(0);
|
|
153
|
+
},
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
console.log(group.name, group.age, group.color);
|
|
158
|
+
```
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";const core=require("@clack/core"),process$1=require("node:process"),color=require("picocolors"),sisteransi=require("sisteransi");function isUnicodeSupported(){return process$1.platform!=="win32"?process$1.env.TERM!=="linux":Boolean(process$1.env.CI)||Boolean(process$1.env.WT_SESSION)||Boolean(process$1.env.TERMINUS_SUBLIME)||process$1.env.ConEmuTask==="{cmd::Cmder}"||process$1.env.TERM_PROGRAM==="Terminus-Sublime"||process$1.env.TERM_PROGRAM==="vscode"||process$1.env.TERM==="xterm-256color"||process$1.env.TERM==="alacritty"||process$1.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}const unicode=isUnicodeSupported(),s=(t,n)=>unicode?t:n,S_STEP_ACTIVE=s("\u25C6","*"),S_STEP_CANCEL=s("\u25A0","x"),S_STEP_ERROR=s("\u25B2","x"),S_STEP_SUBMIT=s("\u25C7","o"),S_BAR_START=s("\u250C","T"),S_BAR=s("\u2502","|"),S_BAR_END=s("\u2514","\u2014"),S_RADIO_ACTIVE=s("\u25CF",">"),S_RADIO_INACTIVE=s("\u25CB"," "),S_CHECKBOX_ACTIVE=s("\u25FB","[\u2022]"),S_CHECKBOX_SELECTED=s("\u25FC","[+]"),S_CHECKBOX_INACTIVE=s("\u25FB","[ ]"),S_PASSWORD_MASK=s("\u25AA","\u2022"),S_BAR_H=s("\u2500","-"),S_CORNER_TOP_RIGHT=s("\u256E","+"),S_CONNECT_LEFT=s("\u251C","+"),S_CORNER_BOTTOM_RIGHT=s("\u256F","+"),S_INFO=s("\u25CF","\u2022"),S_SUCCESS=s("\u25C6","*"),S_WARN=s("\u25B2","!"),S_ERROR=s("\u25A0","x"),symbol=t=>{switch(t){case"initial":case"active":return color.cyan(S_STEP_ACTIVE);case"cancel":return color.red(S_STEP_CANCEL);case"error":return color.yellow(S_STEP_ERROR);case"submit":return color.green(S_STEP_SUBMIT)}},text=t=>new core.TextPrompt({validate:t.validate,placeholder:t.placeholder,defaultValue:t.defaultValue,initialValue:t.initialValue,render(){const n=`${color.gray(S_BAR)}
|
|
2
|
+
${symbol(this.state)} ${t.message}
|
|
3
|
+
`,i=t.placeholder?color.inverse(t.placeholder[0])+color.dim(t.placeholder.slice(1)):color.inverse(color.hidden("_")),e=this.value?this.valueWithCursor:i;switch(this.state){case"error":return`${n.trim()}
|
|
4
|
+
${color.yellow(S_BAR)} ${e}
|
|
5
|
+
${color.yellow(S_BAR_END)} ${color.yellow(this.error)}
|
|
6
|
+
`;case"submit":return`${n}${color.gray(S_BAR)} ${color.dim(this.value||t.placeholder)}`;case"cancel":return`${n}${color.gray(S_BAR)} ${color.strikethrough(color.dim(this.value??""))}${this.value?.trim()?`
|
|
7
|
+
`+color.gray(S_BAR):""}`;default:return`${n}${color.cyan(S_BAR)} ${e}
|
|
8
|
+
${color.cyan(S_BAR_END)}
|
|
9
|
+
`}}}).prompt(),password=t=>new core.PasswordPrompt({validate:t.validate,mask:t.mask??S_PASSWORD_MASK,render(){const n=`${color.gray(S_BAR)}
|
|
10
|
+
${symbol(this.state)} ${t.message}
|
|
11
|
+
`,i=this.valueWithCursor,e=this.masked;switch(this.state){case"error":return`${n.trim()}
|
|
12
|
+
${color.yellow(S_BAR)} ${e}
|
|
13
|
+
${color.yellow(S_BAR_END)} ${color.yellow(this.error)}
|
|
14
|
+
`;case"submit":return`${n}${color.gray(S_BAR)} ${color.dim(e)}`;case"cancel":return`${n}${color.gray(S_BAR)} ${color.strikethrough(color.dim(e??""))}${e?`
|
|
15
|
+
`+color.gray(S_BAR):""}`;default:return`${n}${color.cyan(S_BAR)} ${i}
|
|
16
|
+
${color.cyan(S_BAR_END)}
|
|
17
|
+
`}}}).prompt(),confirm=t=>{const n=t.active??"Yes",i=t.inactive??"No";return new core.ConfirmPrompt({active:n,inactive:i,initialValue:t.initialValue??!0,render(){const e=`${color.gray(S_BAR)}
|
|
18
|
+
${symbol(this.state)} ${t.message}
|
|
19
|
+
`,r=this.value?n:i;switch(this.state){case"submit":return`${e}${color.gray(S_BAR)} ${color.dim(r)}`;case"cancel":return`${e}${color.gray(S_BAR)} ${color.strikethrough(color.dim(r))}
|
|
20
|
+
${color.gray(S_BAR)}`;default:return`${e}${color.cyan(S_BAR)} ${this.value?`${color.green(S_RADIO_ACTIVE)} ${n}`:`${color.dim(S_RADIO_INACTIVE)} ${color.dim(n)}`} ${color.dim("/")} ${this.value?`${color.dim(S_RADIO_INACTIVE)} ${color.dim(i)}`:`${color.green(S_RADIO_ACTIVE)} ${i}`}
|
|
21
|
+
${color.cyan(S_BAR_END)}
|
|
22
|
+
`}}}).prompt()},select=t=>{const n=(e,r)=>{const c=e.label??String(e.value);return r==="active"?`${color.green(S_RADIO_ACTIVE)} ${c} ${e.hint?color.dim(`(${e.hint})`):""}`:r==="selected"?`${color.dim(c)}`:r==="cancelled"?`${color.strikethrough(color.dim(c))}`:`${color.dim(S_RADIO_INACTIVE)} ${color.dim(c)}`};let i=0;return new core.SelectPrompt({options:t.options,initialValue:t.initialValue,render(){const e=`${color.gray(S_BAR)}
|
|
23
|
+
${symbol(this.state)} ${t.message}
|
|
24
|
+
`;switch(this.state){case"submit":return`${e}${color.gray(S_BAR)} ${n(this.options[this.cursor],"selected")}`;case"cancel":return`${e}${color.gray(S_BAR)} ${n(this.options[this.cursor],"cancelled")}
|
|
25
|
+
${color.gray(S_BAR)}`;default:{const r=t.maxItems===void 0?1/0:Math.max(t.maxItems,5);this.cursor>=i+r-3?i=Math.max(Math.min(this.cursor-r+3,this.options.length-r),0):this.cursor<i+2&&(i=Math.max(this.cursor-2,0));const c=r<this.options.length&&i>0,a=r<this.options.length&&i+r<this.options.length;return`${e}${color.cyan(S_BAR)} ${this.options.slice(i,i+r).map((l,o,u)=>o===0&&c||o===u.length-1&&a?color.dim("..."):n(l,o+i===this.cursor?"active":"inactive")).join(`
|
|
26
|
+
${color.cyan(S_BAR)} `)}
|
|
27
|
+
${color.cyan(S_BAR_END)}
|
|
28
|
+
`}}}}).prompt()},selectKey=t=>{const n=(i,e="inactive")=>{const r=i.label??String(i.value);return e==="selected"?`${color.dim(r)}`:e==="cancelled"?`${color.strikethrough(color.dim(r))}`:e==="active"?`${color.bgCyan(color.gray(` ${i.value} `))} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`:`${color.gray(color.bgWhite(color.inverse(` ${i.value} `)))} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`};return new core.SelectKeyPrompt({options:t.options,initialValue:t.initialValue,render(){const i=`${color.gray(S_BAR)}
|
|
29
|
+
${symbol(this.state)} ${t.message}
|
|
30
|
+
`;switch(this.state){case"submit":return`${i}${color.gray(S_BAR)} ${n(this.options.find(e=>e.value===this.value),"selected")}`;case"cancel":return`${i}${color.gray(S_BAR)} ${n(this.options[0],"cancelled")}
|
|
31
|
+
${color.gray(S_BAR)}`;default:return`${i}${color.cyan(S_BAR)} ${this.options.map((e,r)=>n(e,r===this.cursor?"active":"inactive")).join(`
|
|
32
|
+
${color.cyan(S_BAR)} `)}
|
|
33
|
+
${color.cyan(S_BAR_END)}
|
|
34
|
+
`}}}).prompt()},multiselect=t=>{const n=(i,e)=>{const r=i.label??String(i.value);return e==="active"?`${color.cyan(S_CHECKBOX_ACTIVE)} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="selected"?`${color.green(S_CHECKBOX_SELECTED)} ${color.dim(r)}`:e==="cancelled"?`${color.strikethrough(color.dim(r))}`:e==="active-selected"?`${color.green(S_CHECKBOX_SELECTED)} ${r} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="submitted"?`${color.dim(r)}`:`${color.dim(S_CHECKBOX_INACTIVE)} ${color.dim(r)}`};return new core.MultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
|
|
35
|
+
${color.reset(color.dim(`Press ${color.gray(color.bgWhite(color.inverse(" space ")))} to select, ${color.gray(color.bgWhite(color.inverse(" enter ")))} to submit`))}`},render(){let i=`${color.gray(S_BAR)}
|
|
36
|
+
${symbol(this.state)} ${t.message}
|
|
37
|
+
`;switch(this.state){case"submit":return`${i}${color.gray(S_BAR)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>n(e,"submitted")).join(color.dim(", "))||color.dim("none")}`;case"cancel":{const e=this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"cancelled")).join(color.dim(", "));return`${i}${color.gray(S_BAR)} ${e.trim()?`${e}
|
|
38
|
+
${color.gray(S_BAR)}`:""}`}case"error":{const e=this.error.split(`
|
|
39
|
+
`).map((r,c)=>c===0?`${color.yellow(S_BAR_END)} ${color.yellow(r)}`:` ${r}`).join(`
|
|
40
|
+
`);return i+color.yellow(S_BAR)+" "+this.options.map((r,c)=>{const a=this.value.includes(r.value),l=c===this.cursor;return l&&a?n(r,"active-selected"):a?n(r,"selected"):n(r,l?"active":"inactive")}).join(`
|
|
41
|
+
${color.yellow(S_BAR)} `)+`
|
|
42
|
+
`+e+`
|
|
43
|
+
`}default:return`${i}${color.cyan(S_BAR)} ${this.options.map((e,r)=>{const c=this.value.includes(e.value),a=r===this.cursor;return a&&c?n(e,"active-selected"):c?n(e,"selected"):n(e,a?"active":"inactive")}).join(`
|
|
44
|
+
${color.cyan(S_BAR)} `)}
|
|
45
|
+
${color.cyan(S_BAR_END)}
|
|
46
|
+
`}}}).prompt()},groupMultiselect=t=>{const n=(i,e,r=[])=>{const c=i.label??String(i.value),a=typeof i.group=="string",l=a&&(r[r.indexOf(i)+1]??{group:!0}),o=a&&l.group===!0,u=a?`${o?S_BAR_END:S_BAR} `:"";return e==="active"?`${color.dim(u)}${color.cyan(S_CHECKBOX_ACTIVE)} ${c} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="group-active"?`${u}${color.cyan(S_CHECKBOX_ACTIVE)} ${color.dim(c)}`:e==="group-active-selected"?`${u}${color.green(S_CHECKBOX_SELECTED)} ${color.dim(c)}`:e==="selected"?`${color.dim(u)}${color.green(S_CHECKBOX_SELECTED)} ${color.dim(c)}`:e==="cancelled"?`${color.strikethrough(color.dim(c))}`:e==="active-selected"?`${color.dim(u)}${color.green(S_CHECKBOX_SELECTED)} ${c} ${i.hint?color.dim(`(${i.hint})`):""}`:e==="submitted"?`${color.dim(c)}`:`${color.dim(u)}${color.dim(S_CHECKBOX_INACTIVE)} ${color.dim(c)}`};return new core.GroupMultiSelectPrompt({options:t.options,initialValues:t.initialValues,required:t.required??!0,cursorAt:t.cursorAt,validate(i){if(this.required&&i.length===0)return`Please select at least one option.
|
|
47
|
+
${color.reset(color.dim(`Press ${color.gray(color.bgWhite(color.inverse(" space ")))} to select, ${color.gray(color.bgWhite(color.inverse(" enter ")))} to submit`))}`},render(){let i=`${color.gray(S_BAR)}
|
|
48
|
+
${symbol(this.state)} ${t.message}
|
|
49
|
+
`;switch(this.state){case"submit":return`${i}${color.gray(S_BAR)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>n(e,"submitted")).join(color.dim(", "))}`;case"cancel":{const e=this.options.filter(({value:r})=>this.value.includes(r)).map(r=>n(r,"cancelled")).join(color.dim(", "));return`${i}${color.gray(S_BAR)} ${e.trim()?`${e}
|
|
50
|
+
${color.gray(S_BAR)}`:""}`}case"error":{const e=this.error.split(`
|
|
51
|
+
`).map((r,c)=>c===0?`${color.yellow(S_BAR_END)} ${color.yellow(r)}`:` ${r}`).join(`
|
|
52
|
+
`);return`${i}${color.yellow(S_BAR)} ${this.options.map((r,c,a)=>{const l=this.value.includes(r.value)||r.group===!0&&this.isGroupSelected(`${r.value}`),o=c===this.cursor;return!o&&typeof r.group=="string"&&this.options[this.cursor].value===r.group?n(r,l?"group-active-selected":"group-active",a):o&&l?n(r,"active-selected",a):l?n(r,"selected",a):n(r,o?"active":"inactive",a)}).join(`
|
|
53
|
+
${color.yellow(S_BAR)} `)}
|
|
54
|
+
${e}
|
|
55
|
+
`}default:return`${i}${color.cyan(S_BAR)} ${this.options.map((e,r,c)=>{const a=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),l=r===this.cursor;return!l&&typeof e.group=="string"&&this.options[this.cursor].value===e.group?n(e,a?"group-active-selected":"group-active",c):l&&a?n(e,"active-selected",c):a?n(e,"selected",c):n(e,l?"active":"inactive",c)}).join(`
|
|
56
|
+
${color.cyan(S_BAR)} `)}
|
|
57
|
+
${color.cyan(S_BAR_END)}
|
|
58
|
+
`}}}).prompt()},strip=t=>t.replace(ansiRegex(),""),note=(t="",n="")=>{const i=`
|
|
59
|
+
${t}
|
|
60
|
+
`.split(`
|
|
61
|
+
`),e=strip(n).length,r=Math.max(i.reduce((a,l)=>(l=strip(l),l.length>a?l.length:a),0),e)+2,c=i.map(a=>`${color.gray(S_BAR)} ${color.dim(a)}${" ".repeat(r-strip(a).length)}${color.gray(S_BAR)}`).join(`
|
|
62
|
+
`);process.stdout.write(`${color.gray(S_BAR)}
|
|
63
|
+
${color.green(S_STEP_SUBMIT)} ${color.reset(n)} ${color.gray(S_BAR_H.repeat(Math.max(r-e-1,1))+S_CORNER_TOP_RIGHT)}
|
|
64
|
+
${c}
|
|
65
|
+
${color.gray(S_CONNECT_LEFT+S_BAR_H.repeat(r+2)+S_CORNER_BOTTOM_RIGHT)}
|
|
66
|
+
`)},cancel=(t="")=>{process.stdout.write(`${color.gray(S_BAR_END)} ${color.red(t)}
|
|
67
|
+
|
|
68
|
+
`)},intro=(t="")=>{process.stdout.write(`${color.gray(S_BAR_START)} ${t}
|
|
69
|
+
`)},outro=(t="")=>{process.stdout.write(`${color.gray(S_BAR)}
|
|
70
|
+
${color.gray(S_BAR_END)} ${t}
|
|
71
|
+
|
|
72
|
+
`)},log={message:(t="",{symbol:n=color.gray(S_BAR)}={})=>{const i=[`${color.gray(S_BAR)}`];if(t){const[e,...r]=t.split(`
|
|
73
|
+
`);i.push(`${n} ${e}`,...r.map(c=>`${color.gray(S_BAR)} ${c}`))}process.stdout.write(`${i.join(`
|
|
74
|
+
`)}
|
|
75
|
+
`)},info:t=>{log.message(t,{symbol:color.blue(S_INFO)})},success:t=>{log.message(t,{symbol:color.green(S_SUCCESS)})},step:t=>{log.message(t,{symbol:color.green(S_STEP_SUBMIT)})},warn:t=>{log.message(t,{symbol:color.yellow(S_WARN)})},warning:t=>{log.warn(t)},error:t=>{log.message(t,{symbol:color.red(S_ERROR)})}},spinner=()=>{const t=unicode?["\u25D2","\u25D0","\u25D3","\u25D1"]:["\u2022","o","O","0"],n=unicode?80:120;let i,e,r=!1,c="";const a=(d="")=>{r=!0,i=core.block(),c=d.replace(/\.+$/,""),process.stdout.write(`${color.gray(S_BAR)}
|
|
76
|
+
`);let $=0,m=0;e=setInterval(()=>{const h=color.magenta(t[$]),g=".".repeat(Math.floor(m)).slice(0,3);process.stdout.write(sisteransi.cursor.move(-999,0)),process.stdout.write(sisteransi.erase.down(1)),process.stdout.write(`${h} ${c}${g}`),$=$+1<t.length?$+1:0,m=m<t.length?m+.125:0},n)},l=(d="",$=0)=>{c=d??c,r=!1,clearInterval(e);const m=$===0?color.green(S_STEP_SUBMIT):$===1?color.red(S_STEP_CANCEL):color.red(S_STEP_ERROR);process.stdout.write(sisteransi.cursor.move(-999,0)),process.stdout.write(sisteransi.erase.down(1)),process.stdout.write(`${m} ${c}
|
|
77
|
+
`),i()},o=(d="")=>{c=d??c},u=d=>{const $=d>1?"Something went wrong":"Canceled";r&&l($,d)};return process.on("uncaughtExceptionMonitor",()=>u(2)),process.on("unhandledRejection",()=>u(2)),process.on("SIGINT",()=>u(1)),process.on("SIGTERM",()=>u(1)),process.on("exit",u),{start:a,stop:l,message:o}};function ansiRegex(){const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(t,"g")}const group=async(t,n)=>{const i={},e=Object.keys(t);for(const r of e){const c=t[r],a=await c({results:i})?.catch(l=>{throw l});if(typeof n?.onCancel=="function"&&core.isCancel(a)){i[r]="canceled",n.onCancel({results:i});continue}i[r]=a}return i};exports.isCancel=core.isCancel,exports.cancel=cancel,exports.confirm=confirm,exports.group=group,exports.groupMultiselect=groupMultiselect,exports.intro=intro,exports.log=log,exports.multiselect=multiselect,exports.note=note,exports.outro=outro,exports.password=password,exports.select=select,exports.selectKey=selectKey,exports.spinner=spinner,exports.text=text;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export { isCancel } from '@clack/core';
|
|
2
|
+
|
|
3
|
+
interface TextOptions {
|
|
4
|
+
message: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
initialValue?: string;
|
|
8
|
+
validate?: (value: string) => string | void;
|
|
9
|
+
}
|
|
10
|
+
declare const text: (opts: TextOptions) => Promise<string | symbol>;
|
|
11
|
+
interface PasswordOptions {
|
|
12
|
+
message: string;
|
|
13
|
+
mask?: string;
|
|
14
|
+
validate?: (value: string) => string | void;
|
|
15
|
+
}
|
|
16
|
+
declare const password: (opts: PasswordOptions) => Promise<string | symbol>;
|
|
17
|
+
interface ConfirmOptions {
|
|
18
|
+
message: string;
|
|
19
|
+
active?: string;
|
|
20
|
+
inactive?: string;
|
|
21
|
+
initialValue?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare const confirm: (opts: ConfirmOptions) => Promise<boolean | symbol>;
|
|
24
|
+
type Primitive = Readonly<string | boolean | number>;
|
|
25
|
+
type Option<Value> = Value extends Primitive ? {
|
|
26
|
+
value: Value;
|
|
27
|
+
label?: string;
|
|
28
|
+
hint?: string;
|
|
29
|
+
} : {
|
|
30
|
+
value: Value;
|
|
31
|
+
label: string;
|
|
32
|
+
hint?: string;
|
|
33
|
+
};
|
|
34
|
+
interface SelectOptions<Options extends Option<Value>[], Value> {
|
|
35
|
+
message: string;
|
|
36
|
+
options: Options;
|
|
37
|
+
initialValue?: Value;
|
|
38
|
+
maxItems?: number;
|
|
39
|
+
}
|
|
40
|
+
declare const select: <Options extends Option<Value>[], Value>(opts: SelectOptions<Options, Value>) => Promise<symbol | Value>;
|
|
41
|
+
declare const selectKey: <Options extends Option<Value>[], Value extends string>(opts: SelectOptions<Options, Value>) => Promise<symbol | Value>;
|
|
42
|
+
interface MultiSelectOptions<Options extends Option<Value>[], Value> {
|
|
43
|
+
message: string;
|
|
44
|
+
options: Options;
|
|
45
|
+
initialValues?: Value[];
|
|
46
|
+
required?: boolean;
|
|
47
|
+
cursorAt?: Value;
|
|
48
|
+
}
|
|
49
|
+
declare const multiselect: <Options extends Option<Value>[], Value>(opts: MultiSelectOptions<Options, Value>) => Promise<symbol | Value[]>;
|
|
50
|
+
interface GroupMultiSelectOptions<Options extends Option<Value>[], Value> {
|
|
51
|
+
message: string;
|
|
52
|
+
options: Record<string, Options>;
|
|
53
|
+
initialValues?: Value[];
|
|
54
|
+
required?: boolean;
|
|
55
|
+
cursorAt?: Value;
|
|
56
|
+
}
|
|
57
|
+
declare const groupMultiselect: <Options extends Option<Value>[], Value>(opts: GroupMultiSelectOptions<Options, Value>) => Promise<symbol | Value[]>;
|
|
58
|
+
declare const note: (message?: string, title?: string) => void;
|
|
59
|
+
declare const cancel: (message?: string) => void;
|
|
60
|
+
declare const intro: (title?: string) => void;
|
|
61
|
+
declare const outro: (message?: string) => void;
|
|
62
|
+
type LogMessageOptions = {
|
|
63
|
+
symbol?: string;
|
|
64
|
+
};
|
|
65
|
+
declare const log: {
|
|
66
|
+
message: (message?: string, { symbol }?: LogMessageOptions) => void;
|
|
67
|
+
info: (message: string) => void;
|
|
68
|
+
success: (message: string) => void;
|
|
69
|
+
step: (message: string) => void;
|
|
70
|
+
warn: (message: string) => void;
|
|
71
|
+
/** alias for `log.warn()`. */
|
|
72
|
+
warning: (message: string) => void;
|
|
73
|
+
error: (message: string) => void;
|
|
74
|
+
};
|
|
75
|
+
declare const spinner: () => {
|
|
76
|
+
start: (msg?: string) => void;
|
|
77
|
+
stop: (msg?: string, code?: number) => void;
|
|
78
|
+
message: (msg?: string) => void;
|
|
79
|
+
};
|
|
80
|
+
type PromptGroupAwaitedReturn<T> = {
|
|
81
|
+
[P in keyof T]: Exclude<Awaited<T[P]>, symbol>;
|
|
82
|
+
};
|
|
83
|
+
interface PromptGroupOptions<T> {
|
|
84
|
+
/**
|
|
85
|
+
* Control how the group can be canceled
|
|
86
|
+
* if one of the prompts is canceled.
|
|
87
|
+
*/
|
|
88
|
+
onCancel?: (opts: {
|
|
89
|
+
results: Prettify<Partial<PromptGroupAwaitedReturn<T>>>;
|
|
90
|
+
}) => void;
|
|
91
|
+
}
|
|
92
|
+
type Prettify<T> = {
|
|
93
|
+
[P in keyof T]: T[P];
|
|
94
|
+
} & {};
|
|
95
|
+
type PromptGroup<T> = {
|
|
96
|
+
[P in keyof T]: (opts: {
|
|
97
|
+
results: Prettify<Partial<PromptGroupAwaitedReturn<Omit<T, P>>>>;
|
|
98
|
+
}) => void | Promise<T[P] | void>;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Define a group of prompts to be displayed
|
|
102
|
+
* and return a results of objects within the group
|
|
103
|
+
*/
|
|
104
|
+
declare const group: <T>(prompts: PromptGroup<T>, opts?: PromptGroupOptions<T> | undefined) => Promise<PromptGroupAwaitedReturn<T> extends infer T_1 ? { [P in keyof T_1]: PromptGroupAwaitedReturn<T>[P]; } : never>;
|
|
105
|
+
|
|
106
|
+
export { ConfirmOptions, GroupMultiSelectOptions, LogMessageOptions, MultiSelectOptions, PasswordOptions, PromptGroup, PromptGroupAwaitedReturn, PromptGroupOptions, SelectOptions, TextOptions, cancel, confirm, group, groupMultiselect, intro, log, multiselect, note, outro, password, select, selectKey, spinner, text };
|