@super-protocol/sp-cli 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -44
- package/dist/commands/account/base.d.ts +1 -2
- package/dist/commands/account/base.js +8 -14
- package/dist/commands/account/forget.d.ts +1 -0
- package/dist/commands/account/forget.js +69 -3
- package/dist/commands/account/info.js +5 -5
- package/dist/commands/account/login.d.ts +6 -0
- package/dist/commands/account/login.js +122 -22
- package/dist/commands/account/switch.d.ts +3 -0
- package/dist/commands/account/switch.js +30 -10
- package/dist/commands/base.js +97 -12
- package/dist/commands/storage/base.js +11 -11
- package/dist/commands/storage/select.js +3 -3
- package/dist/commands/storage/update.js +10 -10
- package/dist/commands/workflows/extend-lease.d.ts +1 -1
- package/dist/commands/workflows/extend-lease.js +2 -3
- package/dist/hooks/prerun/auth.js +2 -1
- package/dist/managers/config-file-manager.d.ts +6 -12
- package/dist/managers/config-file-manager.js +58 -59
- package/dist/utils/progress.js +1 -0
- package/dist/utils/prompt-flags.d.ts +20 -0
- package/dist/utils/prompt-flags.js +121 -0
- package/dist/utils/prompt.service.d.ts +23 -0
- package/dist/utils/prompt.service.js +107 -0
- package/dist/utils/tty.d.ts +1 -0
- package/dist/utils/tty.js +3 -0
- package/oclif.manifest.json +281 -162
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ $ npm install -g @super-protocol/sp-cli
|
|
|
21
21
|
$ sp COMMAND
|
|
22
22
|
running command...
|
|
23
23
|
$ sp (--version)
|
|
24
|
-
@super-protocol/sp-cli/0.0.
|
|
24
|
+
@super-protocol/sp-cli/0.0.9 linux-x64 node-v22.22.0
|
|
25
25
|
$ sp --help [COMMAND]
|
|
26
26
|
USAGE
|
|
27
27
|
$ sp COMMAND
|
|
@@ -53,14 +53,15 @@ Purge all account details
|
|
|
53
53
|
|
|
54
54
|
```
|
|
55
55
|
USAGE
|
|
56
|
-
$ sp account forget [--json] [-f] [-n <value>]
|
|
56
|
+
$ sp account forget [--json] [--tty] [-f] [-n <value>]
|
|
57
57
|
|
|
58
58
|
FLAGS
|
|
59
|
-
-f, --force Force
|
|
60
|
-
-n, --name=<value>
|
|
59
|
+
-f, --force Force forget without confirmation
|
|
60
|
+
-n, --name=<value> Account name to forget
|
|
61
61
|
|
|
62
62
|
GLOBAL FLAGS
|
|
63
|
-
--json
|
|
63
|
+
--json Format output as json.
|
|
64
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
64
65
|
|
|
65
66
|
DESCRIPTION
|
|
66
67
|
Purge all account details
|
|
@@ -73,7 +74,7 @@ EXAMPLES
|
|
|
73
74
|
$ sp account forget --name "My Account" --force
|
|
74
75
|
```
|
|
75
76
|
|
|
76
|
-
_See code: [src/commands/account/forget.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
77
|
+
_See code: [src/commands/account/forget.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/account/forget.ts)_
|
|
77
78
|
|
|
78
79
|
## `sp account get-sppi`
|
|
79
80
|
|
|
@@ -81,10 +82,11 @@ Get SPPI (Super Protocol incentive tokens)
|
|
|
81
82
|
|
|
82
83
|
```
|
|
83
84
|
USAGE
|
|
84
|
-
$ sp account get-sppi [--json]
|
|
85
|
+
$ sp account get-sppi [--json] [--tty]
|
|
85
86
|
|
|
86
87
|
GLOBAL FLAGS
|
|
87
|
-
--json
|
|
88
|
+
--json Format output as json.
|
|
89
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
88
90
|
|
|
89
91
|
DESCRIPTION
|
|
90
92
|
Get SPPI (Super Protocol incentive tokens)
|
|
@@ -93,7 +95,7 @@ EXAMPLES
|
|
|
93
95
|
$ sp account get-sppi
|
|
94
96
|
```
|
|
95
97
|
|
|
96
|
-
_See code: [src/commands/account/get-sppi.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
98
|
+
_See code: [src/commands/account/get-sppi.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/account/get-sppi.ts)_
|
|
97
99
|
|
|
98
100
|
## `sp account info`
|
|
99
101
|
|
|
@@ -101,19 +103,20 @@ Information about current authorized user
|
|
|
101
103
|
|
|
102
104
|
```
|
|
103
105
|
USAGE
|
|
104
|
-
$ sp account info [--json] [--detail]
|
|
106
|
+
$ sp account info [--json] [--tty] [--detail]
|
|
105
107
|
|
|
106
108
|
FLAGS
|
|
107
109
|
--detail Detailed information about Account
|
|
108
110
|
|
|
109
111
|
GLOBAL FLAGS
|
|
110
|
-
--json
|
|
112
|
+
--json Format output as json.
|
|
113
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
111
114
|
|
|
112
115
|
DESCRIPTION
|
|
113
116
|
Information about current authorized user
|
|
114
117
|
```
|
|
115
118
|
|
|
116
|
-
_See code: [src/commands/account/info.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
119
|
+
_See code: [src/commands/account/info.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/account/info.ts)_
|
|
117
120
|
|
|
118
121
|
## `sp account list`
|
|
119
122
|
|
|
@@ -121,10 +124,11 @@ List all Accounts
|
|
|
121
124
|
|
|
122
125
|
```
|
|
123
126
|
USAGE
|
|
124
|
-
$ sp account list [--json]
|
|
127
|
+
$ sp account list [--json] [--tty]
|
|
125
128
|
|
|
126
129
|
GLOBAL FLAGS
|
|
127
|
-
--json
|
|
130
|
+
--json Format output as json.
|
|
131
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
128
132
|
|
|
129
133
|
DESCRIPTION
|
|
130
134
|
List all Accounts
|
|
@@ -133,7 +137,7 @@ EXAMPLES
|
|
|
133
137
|
$ sp account list
|
|
134
138
|
```
|
|
135
139
|
|
|
136
|
-
_See code: [src/commands/account/list.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
140
|
+
_See code: [src/commands/account/list.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/account/list.ts)_
|
|
137
141
|
|
|
138
142
|
## `sp account login`
|
|
139
143
|
|
|
@@ -141,15 +145,17 @@ Login to SuperProtocol (sign up or sign in).
|
|
|
141
145
|
|
|
142
146
|
```
|
|
143
147
|
USAGE
|
|
144
|
-
$ sp account login [--json] [--name <value>] [--privateKey <value>] [-y]
|
|
148
|
+
$ sp account login [--json] [--tty] [--name <value>] [--privateKey <value>] [--path <value>] [-y]
|
|
145
149
|
|
|
146
150
|
FLAGS
|
|
147
151
|
-y, --yes Skip questions (generate keys when needed).
|
|
148
152
|
--name=<value> Account readable name
|
|
153
|
+
--path=<value> Path to account(configuration) file to import
|
|
149
154
|
--privateKey=<value> Account private key used for authentication
|
|
150
155
|
|
|
151
156
|
GLOBAL FLAGS
|
|
152
|
-
--json
|
|
157
|
+
--json Format output as json.
|
|
158
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
153
159
|
|
|
154
160
|
DESCRIPTION
|
|
155
161
|
Login to SuperProtocol (sign up or sign in).
|
|
@@ -161,7 +167,7 @@ EXAMPLES
|
|
|
161
167
|
$ sp account login
|
|
162
168
|
```
|
|
163
169
|
|
|
164
|
-
_See code: [src/commands/account/login.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
170
|
+
_See code: [src/commands/account/login.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/account/login.ts)_
|
|
165
171
|
|
|
166
172
|
## `sp account switch`
|
|
167
173
|
|
|
@@ -169,10 +175,14 @@ Switch to a different account
|
|
|
169
175
|
|
|
170
176
|
```
|
|
171
177
|
USAGE
|
|
172
|
-
$ sp account switch [--json]
|
|
178
|
+
$ sp account switch [--json] [--tty] [-n <value>]
|
|
179
|
+
|
|
180
|
+
FLAGS
|
|
181
|
+
-n, --name=<value> Account name to switch
|
|
173
182
|
|
|
174
183
|
GLOBAL FLAGS
|
|
175
|
-
--json
|
|
184
|
+
--json Format output as json.
|
|
185
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
176
186
|
|
|
177
187
|
DESCRIPTION
|
|
178
188
|
Switch to a different account
|
|
@@ -181,7 +191,7 @@ EXAMPLES
|
|
|
181
191
|
$ sp account switch
|
|
182
192
|
```
|
|
183
193
|
|
|
184
|
-
_See code: [src/commands/account/switch.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
194
|
+
_See code: [src/commands/account/switch.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/account/switch.ts)_
|
|
185
195
|
|
|
186
196
|
## `sp autocomplete [SHELL]`
|
|
187
197
|
|
|
@@ -220,7 +230,7 @@ Download file or directory described in resource file
|
|
|
220
230
|
|
|
221
231
|
```
|
|
222
232
|
USAGE
|
|
223
|
-
$ sp files download RESOURCEFILE LOCALDIRECTORY [--json] [--maximum-concurrent <value>]
|
|
233
|
+
$ sp files download RESOURCEFILE LOCALDIRECTORY [--json] [--tty] [--maximum-concurrent <value>]
|
|
224
234
|
|
|
225
235
|
ARGUMENTS
|
|
226
236
|
RESOURCEFILE Path to a resource file
|
|
@@ -230,7 +240,8 @@ FLAGS
|
|
|
230
240
|
--maximum-concurrent=<value> [default: 1] Maximum concurrent pieces to download at once per transfer
|
|
231
241
|
|
|
232
242
|
GLOBAL FLAGS
|
|
233
|
-
--json
|
|
243
|
+
--json Format output as json.
|
|
244
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
234
245
|
|
|
235
246
|
DESCRIPTION
|
|
236
247
|
Download file or directory described in resource file
|
|
@@ -239,7 +250,7 @@ EXAMPLES
|
|
|
239
250
|
$ sp files download ./resource.json ./pathToDownload
|
|
240
251
|
```
|
|
241
252
|
|
|
242
|
-
_See code: [src/commands/files/download.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
253
|
+
_See code: [src/commands/files/download.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/files/download.ts)_
|
|
243
254
|
|
|
244
255
|
## `sp files upload PATH`
|
|
245
256
|
|
|
@@ -247,7 +258,7 @@ Upload file or directory to remote storage
|
|
|
247
258
|
|
|
248
259
|
```
|
|
249
260
|
USAGE
|
|
250
|
-
$ sp files upload PATH [--json] [--filename <value>] [--maximum-concurrent <value>] [--metadata <value>]
|
|
261
|
+
$ sp files upload PATH [--json] [--tty] [--filename <value>] [--maximum-concurrent <value>] [--metadata <value>]
|
|
251
262
|
[--output <value>] [--skip-encryption] [--sync]
|
|
252
263
|
|
|
253
264
|
ARGUMENTS
|
|
@@ -263,7 +274,8 @@ FLAGS
|
|
|
263
274
|
--sync Sync mode: delete files in target that don't exist in source
|
|
264
275
|
|
|
265
276
|
GLOBAL FLAGS
|
|
266
|
-
--json
|
|
277
|
+
--json Format output as json.
|
|
278
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
267
279
|
|
|
268
280
|
DESCRIPTION
|
|
269
281
|
Upload file or directory to remote storage
|
|
@@ -272,7 +284,7 @@ EXAMPLES
|
|
|
272
284
|
$ sp files upload ./file.txt
|
|
273
285
|
```
|
|
274
286
|
|
|
275
|
-
_See code: [src/commands/files/upload.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
287
|
+
_See code: [src/commands/files/upload.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/files/upload.ts)_
|
|
276
288
|
|
|
277
289
|
## `sp help [COMMAND]`
|
|
278
290
|
|
|
@@ -300,15 +312,17 @@ Login to SuperProtocol (sign up or sign in).
|
|
|
300
312
|
|
|
301
313
|
```
|
|
302
314
|
USAGE
|
|
303
|
-
$ sp login [--json] [--name <value>] [--privateKey <value>] [-y]
|
|
315
|
+
$ sp login [--json] [--tty] [--name <value>] [--privateKey <value>] [--path <value>] [-y]
|
|
304
316
|
|
|
305
317
|
FLAGS
|
|
306
318
|
-y, --yes Skip questions (generate keys when needed).
|
|
307
319
|
--name=<value> Account readable name
|
|
320
|
+
--path=<value> Path to account(configuration) file to import
|
|
308
321
|
--privateKey=<value> Account private key used for authentication
|
|
309
322
|
|
|
310
323
|
GLOBAL FLAGS
|
|
311
|
-
--json
|
|
324
|
+
--json Format output as json.
|
|
325
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
312
326
|
|
|
313
327
|
DESCRIPTION
|
|
314
328
|
Login to SuperProtocol (sign up or sign in).
|
|
@@ -326,14 +340,15 @@ Create a new storage entry from file or interactive prompts.
|
|
|
326
340
|
|
|
327
341
|
```
|
|
328
342
|
USAGE
|
|
329
|
-
$ sp storage create [--json] [-f <value>] [--notDefault]
|
|
343
|
+
$ sp storage create [--json] [--tty] [-f <value>] [--notDefault]
|
|
330
344
|
|
|
331
345
|
FLAGS
|
|
332
346
|
-f, --fromFile=<value> Path to a JSON file that contains AddStorageDto payload.
|
|
333
347
|
--notDefault Skip setting the created storage as default.
|
|
334
348
|
|
|
335
349
|
GLOBAL FLAGS
|
|
336
|
-
--json
|
|
350
|
+
--json Format output as json.
|
|
351
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
337
352
|
|
|
338
353
|
DESCRIPTION
|
|
339
354
|
Create a new storage entry from file or interactive prompts.
|
|
@@ -346,7 +361,7 @@ EXAMPLES
|
|
|
346
361
|
$ sp storage create --not-default
|
|
347
362
|
```
|
|
348
363
|
|
|
349
|
-
_See code: [src/commands/storage/create.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
364
|
+
_See code: [src/commands/storage/create.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/storage/create.ts)_
|
|
350
365
|
|
|
351
366
|
## `sp storage select`
|
|
352
367
|
|
|
@@ -354,10 +369,11 @@ Select a storage that will be used by subsequent commands.
|
|
|
354
369
|
|
|
355
370
|
```
|
|
356
371
|
USAGE
|
|
357
|
-
$ sp storage select [--json]
|
|
372
|
+
$ sp storage select [--json] [--tty]
|
|
358
373
|
|
|
359
374
|
GLOBAL FLAGS
|
|
360
|
-
--json
|
|
375
|
+
--json Format output as json.
|
|
376
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
361
377
|
|
|
362
378
|
DESCRIPTION
|
|
363
379
|
Select a storage that will be used by subsequent commands.
|
|
@@ -366,7 +382,7 @@ EXAMPLES
|
|
|
366
382
|
$ sp storage select
|
|
367
383
|
```
|
|
368
384
|
|
|
369
|
-
_See code: [src/commands/storage/select.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
385
|
+
_See code: [src/commands/storage/select.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/storage/select.ts)_
|
|
370
386
|
|
|
371
387
|
## `sp storage show`
|
|
372
388
|
|
|
@@ -374,10 +390,11 @@ Show current selected storage
|
|
|
374
390
|
|
|
375
391
|
```
|
|
376
392
|
USAGE
|
|
377
|
-
$ sp storage show [--json]
|
|
393
|
+
$ sp storage show [--json] [--tty]
|
|
378
394
|
|
|
379
395
|
GLOBAL FLAGS
|
|
380
|
-
--json
|
|
396
|
+
--json Format output as json.
|
|
397
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
381
398
|
|
|
382
399
|
DESCRIPTION
|
|
383
400
|
Show current selected storage
|
|
@@ -386,7 +403,7 @@ EXAMPLES
|
|
|
386
403
|
$ sp storage show
|
|
387
404
|
```
|
|
388
405
|
|
|
389
|
-
_See code: [src/commands/storage/show.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
406
|
+
_See code: [src/commands/storage/show.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/storage/show.ts)_
|
|
390
407
|
|
|
391
408
|
## `sp storage update`
|
|
392
409
|
|
|
@@ -394,14 +411,15 @@ Update the configuration of an existing storage.
|
|
|
394
411
|
|
|
395
412
|
```
|
|
396
413
|
USAGE
|
|
397
|
-
$ sp storage update [--json] [-f <value>] [-i <value>]
|
|
414
|
+
$ sp storage update [--json] [--tty] [-f <value>] [-i <value>]
|
|
398
415
|
|
|
399
416
|
FLAGS
|
|
400
417
|
-f, --fromFile=<value> Path to a JSON file that contains UpdateStorageDto payload.
|
|
401
418
|
-i, --id=<value> Storage ID to update
|
|
402
419
|
|
|
403
420
|
GLOBAL FLAGS
|
|
404
|
-
--json
|
|
421
|
+
--json Format output as json.
|
|
422
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
405
423
|
|
|
406
424
|
DESCRIPTION
|
|
407
425
|
Update the configuration of an existing storage.
|
|
@@ -412,7 +430,7 @@ EXAMPLES
|
|
|
412
430
|
$ sp storage update --id=2de3e3a4-0000-1111-2222-333344445555
|
|
413
431
|
```
|
|
414
432
|
|
|
415
|
-
_See code: [src/commands/storage/update.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
433
|
+
_See code: [src/commands/storage/update.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/storage/update.ts)_
|
|
416
434
|
|
|
417
435
|
## `sp workflows extend-lease ORDERID`
|
|
418
436
|
|
|
@@ -420,7 +438,7 @@ Replenish deposit for a workflow to extend its lease time
|
|
|
420
438
|
|
|
421
439
|
```
|
|
422
440
|
USAGE
|
|
423
|
-
$ sp workflows extend-lease ORDERID [--json] [--minutes <value>] [--sppi <value>] [-y]
|
|
441
|
+
$ sp workflows extend-lease ORDERID [--json] [--tty] [--minutes <value>] [--sppi <value>] [-y]
|
|
424
442
|
|
|
425
443
|
ARGUMENTS
|
|
426
444
|
ORDERID Order ID
|
|
@@ -431,7 +449,8 @@ FLAGS
|
|
|
431
449
|
--sppi=<value> SPPI token amount to add to the order
|
|
432
450
|
|
|
433
451
|
GLOBAL FLAGS
|
|
434
|
-
--json
|
|
452
|
+
--json Format output as json.
|
|
453
|
+
--[no-]tty Force or disable interactive mode (use --no-tty to disable).
|
|
435
454
|
|
|
436
455
|
DESCRIPTION
|
|
437
456
|
Replenish deposit for a workflow to extend its lease time
|
|
@@ -444,5 +463,5 @@ EXAMPLES
|
|
|
444
463
|
$ sp workflows extend-lease <orderId> --sppi 2 --yes
|
|
445
464
|
```
|
|
446
465
|
|
|
447
|
-
_See code: [src/commands/workflows/extend-lease.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.
|
|
466
|
+
_See code: [src/commands/workflows/extend-lease.ts](https://github.com/Super-Protocol/sp-cli/blob/v0.0.9/src/commands/workflows/extend-lease.ts)_
|
|
448
467
|
<!-- commandsstop -->
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { select } from '@clack/prompts';
|
|
2
1
|
import type { Command } from '@oclif/core';
|
|
3
2
|
import type { AccountManager } from '../../managers/index.js';
|
|
3
|
+
import { type SelectOptions } from '../../utils/prompt.service.js';
|
|
4
4
|
import { BaseCommand } from '../base.js';
|
|
5
|
-
type SelectOptions<T> = Parameters<typeof select<T>>[0];
|
|
6
5
|
type ProviderInitOptions = {
|
|
7
6
|
assumeYes?: boolean;
|
|
8
7
|
enableAuth?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { promptService } from '../../utils/prompt.service.js';
|
|
2
2
|
import { BaseCommand } from '../base.js';
|
|
3
3
|
export class BaseAccountCommand extends BaseCommand {
|
|
4
4
|
async initAccountContext(providerOptions = {}) {
|
|
@@ -14,23 +14,18 @@ export class BaseAccountCommand extends BaseCommand {
|
|
|
14
14
|
}
|
|
15
15
|
async interactWithUser(accountManager) {
|
|
16
16
|
this.warn("Account doesn't exist in current configuration");
|
|
17
|
-
const ask = await confirm({
|
|
18
|
-
message: 'Do you
|
|
17
|
+
const ask = await promptService.confirm({
|
|
18
|
+
message: 'Do you already have an account?',
|
|
19
19
|
});
|
|
20
|
-
if (
|
|
21
|
-
this.error('Operation cancelled.', { exit: 1 });
|
|
22
|
-
}
|
|
23
|
-
if (ask) {
|
|
20
|
+
if (!ask) {
|
|
24
21
|
const account = await accountManager.create();
|
|
25
22
|
this.log('Generated new keyPair for new account.');
|
|
26
23
|
return account;
|
|
27
24
|
}
|
|
28
|
-
const privateKeyInput = await password({
|
|
29
|
-
message: 'Please input your privateKey
|
|
25
|
+
const privateKeyInput = await promptService.password({
|
|
26
|
+
message: 'Please input your privateKey',
|
|
27
|
+
validate: (value) => value?.trim(),
|
|
30
28
|
});
|
|
31
|
-
if (isCancel(privateKeyInput)) {
|
|
32
|
-
this.error('Operation cancelled.', { exit: 1 });
|
|
33
|
-
}
|
|
34
29
|
const privateKey = privateKeyInput.trim();
|
|
35
30
|
try {
|
|
36
31
|
const account = await accountManager.createFromKey(privateKey);
|
|
@@ -43,7 +38,6 @@ export class BaseAccountCommand extends BaseCommand {
|
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
40
|
async selectPrompt(options) {
|
|
46
|
-
|
|
47
|
-
return this.ensurePromptValue(result);
|
|
41
|
+
return promptService.select(options);
|
|
48
42
|
}
|
|
49
43
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
+
import { AppContainer } from '../../lib/container.js';
|
|
3
|
+
import { promptService } from '../../utils/prompt.service.js';
|
|
2
4
|
import { BaseAccountCommand } from './base.js';
|
|
3
5
|
export default class AccountForget extends BaseAccountCommand {
|
|
4
6
|
static authenticate = false;
|
|
@@ -12,21 +14,85 @@ export default class AccountForget extends BaseAccountCommand {
|
|
|
12
14
|
force: Flags.boolean({
|
|
13
15
|
char: 'f',
|
|
14
16
|
default: false,
|
|
15
|
-
description: 'Force
|
|
17
|
+
description: 'Force forget without confirmation',
|
|
16
18
|
}),
|
|
17
19
|
name: Flags.string({
|
|
18
20
|
char: 'n',
|
|
19
|
-
description: '
|
|
21
|
+
description: 'Account name to forget',
|
|
20
22
|
}),
|
|
21
23
|
};
|
|
22
24
|
configFileManager;
|
|
23
25
|
async init() {
|
|
26
|
+
await this.updateNameFlagOptions();
|
|
24
27
|
await super.init();
|
|
25
28
|
await this.container.initConfigFileManager().build();
|
|
26
29
|
this.configFileManager = this.container.configFileManager;
|
|
27
30
|
}
|
|
28
31
|
async run() {
|
|
29
32
|
const { force, name } = this.flags;
|
|
30
|
-
|
|
33
|
+
const configs = this.configFileManager.getConfigsWithNames();
|
|
34
|
+
if (configs.length === 0) {
|
|
35
|
+
this.error('Not found any account', { exit: 1 });
|
|
36
|
+
}
|
|
37
|
+
let configToDelete;
|
|
38
|
+
let displayName;
|
|
39
|
+
if (name) {
|
|
40
|
+
const config = configs.find((item) => item.name === name || item.file === name);
|
|
41
|
+
if (!config) {
|
|
42
|
+
this.error(`Account with name: ${name} not found`);
|
|
43
|
+
}
|
|
44
|
+
configToDelete = config.file;
|
|
45
|
+
displayName = config.name || config.file;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const selection = await promptService.select({
|
|
49
|
+
message: 'Select account to forget:',
|
|
50
|
+
options: configs.map((config) => ({
|
|
51
|
+
label: config.name || config.file,
|
|
52
|
+
value: config.file,
|
|
53
|
+
})),
|
|
54
|
+
});
|
|
55
|
+
const config = configs.find((item) => item.file === selection);
|
|
56
|
+
configToDelete = selection;
|
|
57
|
+
displayName = config?.name || selection;
|
|
58
|
+
}
|
|
59
|
+
if (!force) {
|
|
60
|
+
const confirmed = await promptService.confirm({
|
|
61
|
+
initialValue: false,
|
|
62
|
+
message: `Are you sure you want to forget "${displayName}"?`,
|
|
63
|
+
});
|
|
64
|
+
if (!confirmed) {
|
|
65
|
+
this.log('Cancelled. Use --force to skip confirmation.');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
await this.configFileManager.deleteConfigByName(configToDelete);
|
|
71
|
+
this.log(`Successfully forgot account: ${displayName}`);
|
|
72
|
+
const newCurrent = this.configFileManager.getCurrentConfigFile();
|
|
73
|
+
if (newCurrent) {
|
|
74
|
+
const configsAfter = this.configFileManager.getConfigsWithNames();
|
|
75
|
+
const newCurrentConfig = configsAfter.find((c) => c.file === newCurrent);
|
|
76
|
+
this.log(`Current account is now: ${newCurrentConfig?.name || newCurrent}`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.log('No accounts remaining');
|
|
80
|
+
this.log('Create a new account with: sp account login --name "Account Name" or sp account login');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
85
|
+
this.error(`Failed to forget account: ${message}`, { exit: 1 });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async updateNameFlagOptions() {
|
|
89
|
+
const { configFileManager } = await AppContainer.container.initConfigFileManager().build();
|
|
90
|
+
const configs = configFileManager.getConfigsWithNames();
|
|
91
|
+
const options = configs.map((config) => config.name);
|
|
92
|
+
this.constructor.flags.name = Flags.option({
|
|
93
|
+
char: 'n',
|
|
94
|
+
description: 'Account name to forget',
|
|
95
|
+
options,
|
|
96
|
+
})();
|
|
31
97
|
}
|
|
32
98
|
}
|
|
@@ -55,11 +55,11 @@ export class InfoCommand extends BaseAccountCommand {
|
|
|
55
55
|
const currentConfig = configs.find((c) => c.file === current);
|
|
56
56
|
const displayName = currentConfig?.name || current;
|
|
57
57
|
const configData = configFileManager.getConfigData(current);
|
|
58
|
-
this.log(`Current
|
|
58
|
+
this.log(`Current account: ${displayName}`);
|
|
59
59
|
this.log(`Configuration file: ${current}`);
|
|
60
60
|
this.log(`Configuration directory: ${configDir}`);
|
|
61
61
|
if (configData) {
|
|
62
|
-
this.log('\
|
|
62
|
+
this.log('\nAccount details:');
|
|
63
63
|
if (configData.providerUrl) {
|
|
64
64
|
this.log(` Provider URL: ${configData.providerUrl}`);
|
|
65
65
|
}
|
|
@@ -81,9 +81,9 @@ export class InfoCommand extends BaseAccountCommand {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
84
|
-
this.log('No
|
|
85
|
-
this.log(`
|
|
86
|
-
this.log('Create a new
|
|
84
|
+
this.log('No account is currently set');
|
|
85
|
+
this.log(`Account directory: ${configDir}`);
|
|
86
|
+
this.log('Create a new account with: sp account login --privateKey "<PRIVATE_KEY>" --name "Account Name"');
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
return {
|
|
@@ -7,6 +7,7 @@ export default class AccountLoginCommand extends BaseAccountCommand<typeof Accou
|
|
|
7
7
|
static flags: {
|
|
8
8
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
privateKey: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
path: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
url: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
13
|
};
|
|
@@ -26,9 +27,14 @@ export default class AccountLoginCommand extends BaseAccountCommand<typeof Accou
|
|
|
26
27
|
private confirmPrompt;
|
|
27
28
|
private createAccountFromKey;
|
|
28
29
|
private createConfigIfMissing;
|
|
30
|
+
private updateConfigDisplayName;
|
|
29
31
|
private findConfigsByPrivateKey;
|
|
30
32
|
private getPrivateKeyOrGenerate;
|
|
31
33
|
private resolveByName;
|
|
34
|
+
private assertConfigHasAccount;
|
|
35
|
+
private loadConfigFromPath;
|
|
36
|
+
private resolveConfigFileName;
|
|
37
|
+
private resolveByPath;
|
|
32
38
|
private resolveByPrivateKey;
|
|
33
39
|
private resolveConfiguration;
|
|
34
40
|
private static maskPrivateKey;
|