@shopify/cli-kit 0.33.1 → 0.33.2

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.d.ts CHANGED
@@ -1,45 +1,1422 @@
1
1
  /// <reference types="node" />
2
+ import { EventEmitter } from 'events';
3
+ import { Readable } from 'stream';
2
4
  import { Writable } from 'node:stream';
3
5
  import open from 'open';
4
6
  import path$1 from 'path';
5
7
  import * as fs from 'fs';
6
- import { EventEmitter } from 'events';
8
+ import { platform } from 'node:process';
7
9
  import { RequestOptions } from 'http';
8
10
 
11
+ /**
12
+ * Represents a disposable resource, such as the execution of an Observable. A
13
+ * Subscription has one important method, `unsubscribe`, that takes no argument
14
+ * and just disposes the resource held by the subscription.
15
+ *
16
+ * Additionally, subscriptions may be grouped together through the `add()`
17
+ * method, which will attach a child Subscription to the current Subscription.
18
+ * When a Subscription is unsubscribed, all its children (and its grandchildren)
19
+ * will be unsubscribed as well.
20
+ *
21
+ * @class Subscription
22
+ */
23
+ declare class Subscription implements SubscriptionLike {
24
+ private initialTeardown?;
25
+ /** @nocollapse */
26
+ static EMPTY: Subscription;
27
+ /**
28
+ * A flag to indicate whether this Subscription has already been unsubscribed.
29
+ */
30
+ closed: boolean;
31
+ private _parentage;
32
+ /**
33
+ * The list of registered teardowns to execute upon unsubscription. Adding and removing from this
34
+ * list occurs in the {@link #add} and {@link #remove} methods.
35
+ */
36
+ private _teardowns;
37
+ /**
38
+ * @param initialTeardown A function executed first as part of the teardown
39
+ * process that is kicked off when {@link #unsubscribe} is called.
40
+ */
41
+ constructor(initialTeardown?: (() => void) | undefined);
42
+ /**
43
+ * Disposes the resources held by the subscription. May, for instance, cancel
44
+ * an ongoing Observable execution or cancel any other type of work that
45
+ * started when the Subscription was created.
46
+ * @return {void}
47
+ */
48
+ unsubscribe(): void;
49
+ /**
50
+ * Adds a teardown to this subscription, so that teardown will be unsubscribed/called
51
+ * when this subscription is unsubscribed. If this subscription is already {@link #closed},
52
+ * because it has already been unsubscribed, then whatever teardown is passed to it
53
+ * will automatically be executed (unless the teardown itself is also a closed subscription).
54
+ *
55
+ * Closed Subscriptions cannot be added as teardowns to any subscription. Adding a closed
56
+ * subscription to a any subscription will result in no operation. (A noop).
57
+ *
58
+ * Adding a subscription to itself, or adding `null` or `undefined` will not perform any
59
+ * operation at all. (A noop).
60
+ *
61
+ * `Subscription` instances that are added to this instance will automatically remove themselves
62
+ * if they are unsubscribed. Functions and {@link Unsubscribable} objects that you wish to remove
63
+ * will need to be removed manually with {@link #remove}
64
+ *
65
+ * @param teardown The teardown logic to add to this subscription.
66
+ */
67
+ add(teardown: TeardownLogic): void;
68
+ /**
69
+ * Checks to see if a this subscription already has a particular parent.
70
+ * This will signal that this subscription has already been added to the parent in question.
71
+ * @param parent the parent to check for
72
+ */
73
+ private _hasParent;
74
+ /**
75
+ * Adds a parent to this subscription so it can be removed from the parent if it
76
+ * unsubscribes on it's own.
77
+ *
78
+ * NOTE: THIS ASSUMES THAT {@link _hasParent} HAS ALREADY BEEN CHECKED.
79
+ * @param parent The parent subscription to add
80
+ */
81
+ private _addParent;
82
+ /**
83
+ * Called on a child when it is removed via {@link #remove}.
84
+ * @param parent The parent to remove
85
+ */
86
+ private _removeParent;
87
+ /**
88
+ * Removes a teardown from this subscription that was previously added with the {@link #add} method.
89
+ *
90
+ * Note that `Subscription` instances, when unsubscribed, will automatically remove themselves
91
+ * from every other `Subscription` they have been added to. This means that using the `remove` method
92
+ * is not a common thing and should be used thoughtfully.
93
+ *
94
+ * If you add the same teardown instance of a function or an unsubscribable object to a `Subcription` instance
95
+ * more than once, you will need to call `remove` the same number of times to remove all instances.
96
+ *
97
+ * All teardown instances are removed to free up memory upon unsubscription.
98
+ *
99
+ * @param teardown The teardown to remove from this subscription
100
+ */
101
+ remove(teardown: Exclude<TeardownLogic, void>): void;
102
+ }
103
+
104
+ /// <reference lib="esnext.asynciterable" />
105
+
106
+ /**
107
+ * Note: This will add Symbol.observable globally for all TypeScript users,
108
+ * however, we are no longer polyfilling Symbol.observable
109
+ */
110
+ declare global {
111
+ interface SymbolConstructor {
112
+ readonly observable: symbol;
113
+ }
114
+ }
115
+ /** OPERATOR INTERFACES */
116
+ interface UnaryFunction<T, R> {
117
+ (source: T): R;
118
+ }
119
+ interface OperatorFunction<T, R> extends UnaryFunction<Observable<T>, Observable<R>> {
120
+ }
121
+ /** SUBSCRIPTION INTERFACES */
122
+ interface Unsubscribable {
123
+ unsubscribe(): void;
124
+ }
125
+ declare type TeardownLogic = Subscription | Unsubscribable | (() => void) | void;
126
+ interface SubscriptionLike extends Unsubscribable {
127
+ unsubscribe(): void;
128
+ readonly closed: boolean;
129
+ }
130
+ /** OBSERVABLE INTERFACES */
131
+ interface Subscribable<T> {
132
+ subscribe(observer: Partial<Observer<T>>): Unsubscribable;
133
+ }
134
+ interface Observer<T> {
135
+ next: (value: T) => void;
136
+ error: (err: any) => void;
137
+ complete: () => void;
138
+ }
139
+
140
+ /**
141
+ * Implements the {@link Observer} interface and extends the
142
+ * {@link Subscription} class. While the {@link Observer} is the public API for
143
+ * consuming the values of an {@link Observable}, all Observers get converted to
144
+ * a Subscriber, in order to provide Subscription-like capabilities such as
145
+ * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for
146
+ * implementing operators, but it is rarely used as a public API.
147
+ *
148
+ * @class Subscriber<T>
149
+ */
150
+ declare class Subscriber<T> extends Subscription implements Observer<T> {
151
+ /**
152
+ * A static factory for a Subscriber, given a (potentially partial) definition
153
+ * of an Observer.
154
+ * @param next The `next` callback of an Observer.
155
+ * @param error The `error` callback of an
156
+ * Observer.
157
+ * @param complete The `complete` callback of an
158
+ * Observer.
159
+ * @return A Subscriber wrapping the (partially defined)
160
+ * Observer represented by the given arguments.
161
+ * @nocollapse
162
+ * @deprecated Do not use. Will be removed in v8. There is no replacement for this
163
+ * method, and there is no reason to be creating instances of `Subscriber` directly.
164
+ * If you have a specific use case, please file an issue.
165
+ */
166
+ static create<T>(next?: (x?: T) => void, error?: (e?: any) => void, complete?: () => void): Subscriber<T>;
167
+ /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */
168
+ protected isStopped: boolean;
169
+ /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */
170
+ protected destination: Subscriber<any> | Observer<any>;
171
+ /**
172
+ * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.
173
+ * There is no reason to directly create an instance of Subscriber. This type is exported for typings reasons.
174
+ */
175
+ constructor(destination?: Subscriber<any> | Observer<any>);
176
+ /**
177
+ * The {@link Observer} callback to receive notifications of type `next` from
178
+ * the Observable, with a value. The Observable may call this method 0 or more
179
+ * times.
180
+ * @param {T} [value] The `next` value.
181
+ * @return {void}
182
+ */
183
+ next(value?: T): void;
184
+ /**
185
+ * The {@link Observer} callback to receive notifications of type `error` from
186
+ * the Observable, with an attached `Error`. Notifies the Observer that
187
+ * the Observable has experienced an error condition.
188
+ * @param {any} [err] The `error` exception.
189
+ * @return {void}
190
+ */
191
+ error(err?: any): void;
192
+ /**
193
+ * The {@link Observer} callback to receive a valueless notification of type
194
+ * `complete` from the Observable. Notifies the Observer that the Observable
195
+ * has finished sending push-based notifications.
196
+ * @return {void}
197
+ */
198
+ complete(): void;
199
+ unsubscribe(): void;
200
+ protected _next(value: T): void;
201
+ protected _error(err: any): void;
202
+ protected _complete(): void;
203
+ }
204
+
205
+ /***
206
+ * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.
207
+ */
208
+ interface Operator<T, R> {
209
+ call(subscriber: Subscriber<R>, source: any): TeardownLogic;
210
+ }
211
+
212
+ /**
213
+ * A representation of any set of values over any amount of time. This is the most basic building block
214
+ * of RxJS.
215
+ *
216
+ * @class Observable<T>
217
+ */
218
+ declare class Observable<T> implements Subscribable<T> {
219
+ /**
220
+ * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.
221
+ */
222
+ source: Observable<any> | undefined;
223
+ /**
224
+ * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.
225
+ */
226
+ operator: Operator<any, T> | undefined;
227
+ /**
228
+ * @constructor
229
+ * @param {Function} subscribe the function that is called when the Observable is
230
+ * initially subscribed to. This function is given a Subscriber, to which new values
231
+ * can be `next`ed, or an `error` method can be called to raise an error, or
232
+ * `complete` can be called to notify of a successful completion.
233
+ */
234
+ constructor(subscribe?: (this: Observable<T>, subscriber: Subscriber<T>) => TeardownLogic);
235
+ /**
236
+ * Creates a new Observable by calling the Observable constructor
237
+ * @owner Observable
238
+ * @method create
239
+ * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
240
+ * @return {Observable} a new observable
241
+ * @nocollapse
242
+ * @deprecated Use `new Observable()` instead. Will be removed in v8.
243
+ */
244
+ static create: (...args: any[]) => any;
245
+ /**
246
+ * Creates a new Observable, with this Observable instance as the source, and the passed
247
+ * operator defined as the new observable's operator.
248
+ * @method lift
249
+ * @param operator the operator defining the operation to take on the observable
250
+ * @return a new observable with the Operator applied
251
+ * @deprecated Internal implementation detail, do not use directly. Will be made internal in v8.
252
+ * If you have implemented an operator using `lift`, it is recommended that you create an
253
+ * operator by simply returning `new Observable()` directly. See "Creating new operators from
254
+ * scratch" section here: https://rxjs.dev/guide/operators
255
+ */
256
+ lift<R>(operator?: Operator<T, R>): Observable<R>;
257
+ subscribe(observer?: Partial<Observer<T>>): Subscription;
258
+ subscribe(next: (value: T) => void): Subscription;
259
+ /** @deprecated Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback arguments will be removed in v8. Details: https://rxjs.dev/deprecations/subscribe-arguments */
260
+ subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription;
261
+ /**
262
+ * Used as a NON-CANCELLABLE means of subscribing to an observable, for use with
263
+ * APIs that expect promises, like `async/await`. You cannot unsubscribe from this.
264
+ *
265
+ * **WARNING**: Only use this with observables you *know* will complete. If the source
266
+ * observable does not complete, you will end up with a promise that is hung up, and
267
+ * potentially all of the state of an async function hanging out in memory. To avoid
268
+ * this situation, look into adding something like {@link timeout}, {@link take},
269
+ * {@link takeWhile}, or {@link takeUntil} amongst others.
270
+ *
271
+ * ## Example
272
+ *
273
+ * ```ts
274
+ * import { interval, take } from 'rxjs';
275
+ *
276
+ * const source$ = interval(1000).pipe(take(4));
277
+ *
278
+ * async function getTotal() {
279
+ * let total = 0;
280
+ *
281
+ * await source$.forEach(value => {
282
+ * total += value;
283
+ * console.log('observable -> ' + value);
284
+ * });
285
+ *
286
+ * return total;
287
+ * }
288
+ *
289
+ * getTotal().then(
290
+ * total => console.log('Total: ' + total)
291
+ * );
292
+ *
293
+ * // Expected:
294
+ * // 'observable -> 0'
295
+ * // 'observable -> 1'
296
+ * // 'observable -> 2'
297
+ * // 'observable -> 3'
298
+ * // 'Total: 6'
299
+ * ```
300
+ *
301
+ * @param next a handler for each value emitted by the observable
302
+ * @return a promise that either resolves on observable completion or
303
+ * rejects with the handled error
304
+ */
305
+ forEach(next: (value: T) => void): Promise<void>;
306
+ /**
307
+ * @param next a handler for each value emitted by the observable
308
+ * @param promiseCtor a constructor function used to instantiate the Promise
309
+ * @return a promise that either resolves on observable completion or
310
+ * rejects with the handled error
311
+ * @deprecated Passing a Promise constructor will no longer be available
312
+ * in upcoming versions of RxJS. This is because it adds weight to the library, for very
313
+ * little benefit. If you need this functionality, it is recommended that you either
314
+ * polyfill Promise, or you create an adapter to convert the returned native promise
315
+ * to whatever promise implementation you wanted. Will be removed in v8.
316
+ */
317
+ forEach(next: (value: T) => void, promiseCtor: PromiseConstructorLike): Promise<void>;
318
+ pipe(): Observable<T>;
319
+ pipe<A>(op1: OperatorFunction<T, A>): Observable<A>;
320
+ pipe<A, B>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>): Observable<B>;
321
+ pipe<A, B, C>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>): Observable<C>;
322
+ pipe<A, B, C, D>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>): Observable<D>;
323
+ pipe<A, B, C, D, E>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>): Observable<E>;
324
+ pipe<A, B, C, D, E, F>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>): Observable<F>;
325
+ pipe<A, B, C, D, E, F, G>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>): Observable<G>;
326
+ pipe<A, B, C, D, E, F, G, H>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>): Observable<H>;
327
+ pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>): Observable<I>;
328
+ pipe<A, B, C, D, E, F, G, H, I>(op1: OperatorFunction<T, A>, op2: OperatorFunction<A, B>, op3: OperatorFunction<B, C>, op4: OperatorFunction<C, D>, op5: OperatorFunction<D, E>, op6: OperatorFunction<E, F>, op7: OperatorFunction<F, G>, op8: OperatorFunction<G, H>, op9: OperatorFunction<H, I>, ...operations: OperatorFunction<any, any>[]): Observable<unknown>;
329
+ /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */
330
+ toPromise(): Promise<T | undefined>;
331
+ /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */
332
+ toPromise(PromiseCtor: typeof Promise): Promise<T | undefined>;
333
+ /** @deprecated Replaced with {@link firstValueFrom} and {@link lastValueFrom}. Will be removed in v8. Details: https://rxjs.dev/deprecations/to-promise */
334
+ toPromise(PromiseCtor: PromiseConstructorLike): Promise<T | undefined>;
335
+ }
336
+
337
+ /**
338
+ * A Subject is a special type of Observable that allows values to be
339
+ * multicasted to many Observers. Subjects are like EventEmitters.
340
+ *
341
+ * Every Subject is an Observable and an Observer. You can subscribe to a
342
+ * Subject, and you can call next to feed values as well as error and complete.
343
+ */
344
+ declare class Subject<T> extends Observable<T> implements SubscriptionLike {
345
+ closed: boolean;
346
+ /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */
347
+ observers: Observer<T>[];
348
+ /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */
349
+ isStopped: boolean;
350
+ /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */
351
+ hasError: boolean;
352
+ /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */
353
+ thrownError: any;
354
+ /**
355
+ * Creates a "subject" by basically gluing an observer to an observable.
356
+ *
357
+ * @nocollapse
358
+ * @deprecated Recommended you do not use. Will be removed at some point in the future. Plans for replacement still under discussion.
359
+ */
360
+ static create: (...args: any[]) => any;
361
+ constructor();
362
+ /** @deprecated Internal implementation detail, do not use directly. Will be made internal in v8. */
363
+ lift<R>(operator: Operator<T, R>): Observable<R>;
364
+ next(value: T): void;
365
+ error(err: any): void;
366
+ complete(): void;
367
+ unsubscribe(): void;
368
+ get observed(): boolean;
369
+ /**
370
+ * Creates a new Observable with this Subject as the source. You can do this
371
+ * to create customize Observer-side logic of the Subject and conceal it from
372
+ * code that uses the Observable.
373
+ * @return {Observable} Observable that the Subject casts to
374
+ */
375
+ asObservable(): Observable<T>;
376
+ }
377
+
378
+ interface BasePromptOptions$1 {
379
+ name: string | (() => string)
380
+ type: string | (() => string)
381
+ message: string | (() => string) | (() => Promise<string>)
382
+ initial?: any
383
+ required?: boolean
384
+ format?(value: string): string | Promise<string>
385
+ result?(value: string): string | Promise<string>
386
+ skip?: ((state: object) => boolean | Promise<boolean>) | boolean
387
+ validate?(value: string): boolean | Promise<boolean> | string | Promise<string>
388
+ onSubmit?(name: string, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
389
+ onCancel?(name: string, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
390
+ stdin?: NodeJS.ReadStream
391
+ stdout?: NodeJS.WriteStream
392
+ }
393
+
394
+ interface Choice {
395
+ name: string
396
+ message?: string
397
+ value?: string
398
+ hint?: string
399
+ disabled?: boolean | string
400
+ }
401
+
402
+ interface ArrayPromptOptions$1 extends BasePromptOptions$1 {
403
+ type:
404
+ | 'autocomplete'
405
+ | 'editable'
406
+ | 'form'
407
+ | 'multiselect'
408
+ | 'select'
409
+ | 'survey'
410
+ | 'list'
411
+ | 'scale'
412
+ choices: string[] | Choice[]
413
+ maxChoices?: number
414
+ muliple?: boolean
415
+ initial?: number
416
+ delay?: number
417
+ separator?: boolean
418
+ sort?: boolean
419
+ linebreak?: boolean
420
+ edgeLength?: number
421
+ align?: 'left' | 'right'
422
+ scroll?: boolean
423
+ }
424
+
425
+ interface BooleanPromptOptions$1 extends BasePromptOptions$1 {
426
+ type: 'confirm'
427
+ initial?: boolean
428
+ }
429
+
430
+ interface StringPromptOptions$1 extends BasePromptOptions$1 {
431
+ type: 'input' | 'invisible' | 'list' | 'password' | 'text'
432
+ initial?: string
433
+ multiline?: boolean
434
+ }
435
+
436
+ interface NumberPromptOptions$1 extends BasePromptOptions$1 {
437
+ type: 'numeral'
438
+ min?: number
439
+ max?: number
440
+ delay?: number
441
+ float?: boolean
442
+ round?: boolean
443
+ major?: number
444
+ minor?: number
445
+ initial?: number
446
+ }
447
+
448
+ interface SnippetPromptOptions$1 extends BasePromptOptions$1 {
449
+ type: 'snippet'
450
+ newline?: string
451
+ template?: string
452
+ }
453
+
454
+ interface SortPromptOptions$1 extends BasePromptOptions$1 {
455
+ type: 'sort'
456
+ hint?: string
457
+ drag?: boolean
458
+ numbered?: boolean
459
+ }
460
+
461
+ type PromptOptions$1 =
462
+ | BasePromptOptions$1
463
+ | ArrayPromptOptions$1
464
+ | BooleanPromptOptions$1
465
+ | StringPromptOptions$1
466
+ | NumberPromptOptions$1
467
+ | SnippetPromptOptions$1
468
+ | SortPromptOptions$1
469
+
470
+ declare class BasePrompt extends EventEmitter {
471
+ constructor(options?: PromptOptions$1);
472
+
473
+ render(): void;
474
+
475
+ run(): Promise<any>;
476
+ }
477
+
478
+ declare class Enquirer<T = object> extends EventEmitter {
479
+ constructor(options?: object, answers?: T);
480
+
481
+ /**
482
+ * Register a custom prompt type.
483
+ *
484
+ * @param type
485
+ * @param fn `Prompt` class, or a function that returns a `Prompt` class.
486
+ */
487
+ register(type: string, fn: typeof BasePrompt | (() => typeof BasePrompt)): this;
488
+
489
+ /**
490
+ * Register a custom prompt type.
491
+ */
492
+ register(type: { [key: string]: typeof BasePrompt | (() => typeof BasePrompt) }): this;
493
+
494
+ /**
495
+ * Prompt function that takes a "question" object or array of question objects,
496
+ * and returns an object with responses from the user.
497
+ *
498
+ * @param questions Options objects for one or more prompts to run.
499
+ */
500
+ prompt(
501
+ questions:
502
+ | PromptOptions$1
503
+ | ((this: Enquirer) => PromptOptions$1)
504
+ | (PromptOptions$1 | ((this: Enquirer) => PromptOptions$1))[]
505
+ ): Promise<T>;
506
+
507
+ /**
508
+ * Use an enquirer plugin.
509
+ *
510
+ * @param plugin Plugin function that takes an instance of Enquirer.
511
+ */
512
+ use(plugin: (this: this, enquirer: this) => void): this;
513
+ }
514
+
515
+ declare namespace Enquirer {
516
+ function prompt<T = object>(
517
+ questions:
518
+ | PromptOptions$1
519
+ | ((this: Enquirer) => PromptOptions$1)
520
+ | (PromptOptions$1 | ((this: Enquirer) => PromptOptions$1))[]
521
+ ): Promise<T>;
522
+
523
+ class Prompt extends BasePrompt {}
524
+ }
525
+
526
+ /** Type of listr internal events. */
527
+ declare enum ListrEventType {
528
+ TITLE = "TITLE",
529
+ STATE = "STATE",
530
+ ENABLED = "ENABLED",
531
+ SUBTASK = "SUBTASK",
532
+ DATA = "DATA",
533
+ MESSAGE = "MESSAGE"
534
+ }
535
+
536
+ /** Listr Default Context */
537
+ declare type ListrContext = any | undefined;
538
+ /**
539
+ * ListrTask.
540
+ *
541
+ * Defines the task, conditions and options to run a specific task in the listr.
542
+ */
543
+ interface ListrTask<Ctx = ListrContext, Renderer extends ListrRendererFactory = any> {
544
+ /**
545
+ * Title of the task.
546
+ *
547
+ * Give this task a title if you want to track it by name in the current renderer.
548
+ *
549
+ * Tasks without a title will hide in the default renderer and are useful for running a background instance.
550
+ * On verbose renderer, state changes from these tasks will log as 'Task without a title.'
551
+ */
552
+ title?: string;
553
+ /**
554
+ * The task itself.
555
+ *
556
+ * Task can be a sync or async function, an Observable, or a Stream.
557
+ * Task will be executed, if the certain criteria of the state are met and whenever the time for that specific task has come.
558
+ */
559
+ task: (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>;
560
+ /**
561
+ * Skip this task depending on the context.
562
+ *
563
+ * The function that has been passed in will be evaluated at the runtime when the task tries to initially run.
564
+ */
565
+ skip?: boolean | string | ((ctx: Ctx) => boolean | string | Promise<boolean | string>);
566
+ /**
567
+ * Enable a task depending on the context.
568
+ *
569
+ * The function that has been passed in will be evaluated at the initial creation of the Listr class for rendering purposes,
570
+ * as well as re-evaluated when the time for that specific task has come.
571
+ */
572
+ enabled?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
573
+ /**
574
+ * Adds the given number of retry attempts to the task if the task fails.
575
+ */
576
+ retry?: number;
577
+ /**
578
+ * Runs a specific event if the current task or any of the subtasks has failed.
579
+ *
580
+ * Mostly useful for rollback purposes for subtasks.
581
+ * But can also be useful whenever a task is failed and some measures have to be taken to ensure the state is not changed.
582
+ */
583
+ rollback?: (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>;
584
+ /**
585
+ * Set exit on the error option from task-level instead of setting it for all the subtasks.
586
+ */
587
+ exitOnError?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
588
+ /**
589
+ * Per task options, that depends on the selected renderer.
590
+ *
591
+ * These options depend on the implementation of the selected renderer. If the selected renderer has no options it will
592
+ * be displayed as never.
593
+ */
594
+ options?: ListrGetRendererTaskOptions<Renderer>;
595
+ }
596
+ /**
597
+ * Options to set the behavior of this base task.
598
+ */
599
+ interface ListrOptions<Ctx = ListrContext> {
600
+ /**
601
+ * To inject a context through this options wrapper. Context can also be defined in run time.
602
+ *
603
+ * @default {}
604
+ */
605
+ ctx?: Ctx;
606
+ /**
607
+ * Concurrency sets how many tasks will be run at the same time in parallel.
608
+ *
609
+ * @default false > Default is to run everything synchronously.
610
+ *
611
+ * `true` will set it to `Infinity`, `false` will set it to synchronous.
612
+ *
613
+ * If you pass in a `number` it will limit it to that number.
614
+ */
615
+ concurrent?: boolean | number;
616
+ /**
617
+ * Determine the default behavior of exiting on errors.
618
+ *
619
+ * @default true > exit on any error coming from the tasks.
620
+ */
621
+ exitOnError?: boolean;
622
+ /**
623
+ * Determine the behavior of exiting after rollback actions.
624
+ *
625
+ * This is independent of exitOnError, since failure of a rollback can be a more critical operation comparing to
626
+ * failing a single task.
627
+ *
628
+ * @default true > exit after rolling back tasks
629
+ */
630
+ exitAfterRollback?: boolean;
631
+ /**
632
+ * Collects errors to `ListrInstance.errors`
633
+ *
634
+ * This can take up a lot of memory, so disabling it can fix out-of-memory errors
635
+ *
636
+ * - 'full' will clone the current context and task in to the error instance
637
+ * - 'minimal' will only collect the error message and the location
638
+ * - false will collect no errors
639
+ *
640
+ * @default 'minimal'
641
+ */
642
+ collectErrors?: false | 'minimal' | 'full';
643
+ /**
644
+ * By default, Listr2 will track SIGINIT signal to update the renderer one last time before completely failing.
645
+ *
646
+ * @default true
647
+ */
648
+ registerSignalListeners?: boolean;
649
+ /**
650
+ * Determine the certain condition required to use the non-TTY renderer.
651
+ *
652
+ * @default null > handled internally
653
+ */
654
+ rendererFallback?: boolean | (() => boolean);
655
+ /**
656
+ * Determine the certain condition required to use the silent renderer.
657
+ *
658
+ * @default null > handled internally
659
+ */
660
+ rendererSilent?: boolean | (() => boolean);
661
+ /**
662
+ * Disabling the color, useful for tests and such.
663
+ *
664
+ * @default false
665
+ */
666
+ disableColor?: boolean;
667
+ /**
668
+ * Inject data directly to TaskWrapper.
669
+ */
670
+ injectWrapper?: {
671
+ enquirer?: Enquirer<object>;
672
+ };
673
+ }
674
+ /**
675
+ * Task can be set of sync or async function, an Observable or a stream.
676
+ */
677
+ declare type ListrTaskResult<Ctx> = string | Promise<any> | Listr<Ctx, ListrRendererValue, any> | Readable | NodeJS.ReadableStream | Observable<any>;
678
+ /**
679
+ * Parent class options.
680
+ *
681
+ * Parent class has more options where you can also select the and set renderer and non-tty renderer.
682
+ *
683
+ * Any subtasks will respect those options so they will be stripped of that properties.
684
+ */
685
+ declare type ListrBaseClassOptions<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue, FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue> = ListrOptions<Ctx> & ListrDefaultRendererOptions<Renderer> & ListrDefaultNonTTYRendererOptions<FallbackRenderer>;
686
+ /**
687
+ * Sub class options.
688
+ *
689
+ * Subtasks has reduced set options where the missing ones are explicitly set by the base class.
690
+ */
691
+ declare type ListrSubClassOptions<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue> = ListrOptions<Ctx> & Omit<ListrDefaultRendererOptions<Renderer>, 'renderer'>;
692
+ /** The internal communication event. */
693
+ declare type ListrEvent = {
694
+ type: Exclude<ListrEventType, 'MESSAGE' | 'DATA'>;
695
+ data?: string | boolean;
696
+ } | {
697
+ type: ListrEventType.DATA;
698
+ data: string;
699
+ } | {
700
+ type: ListrEventType.MESSAGE;
701
+ data: Task$1<any, any>['message'];
702
+ };
703
+ /**
704
+ * Used to match event.type to ListrEvent permutations
705
+ */
706
+ declare type ListrEventFromType<T extends ListrEventType, E = ListrEvent> = E extends {
707
+ type: infer U;
708
+ } ? T extends U ? E : never : never;
709
+
710
+ interface BasePromptOptions {
711
+ message: string | (() => string) | (() => Promise<string>);
712
+ initial?: boolean | number | number[] | string | (() => string) | (() => Promise<string>);
713
+ required?: boolean;
714
+ stdin?: NodeJS.ReadStream;
715
+ stdout?: NodeJS.WriteStream;
716
+ header?: string;
717
+ footer?: string;
718
+ skip?: (value: any) => boolean | Promise<boolean>;
719
+ format?: (value: any) => any | Promise<any>;
720
+ result?: (value: any) => any | Promise<any>;
721
+ validate?: (value: any, state: any) => boolean | Promise<boolean> | string | Promise<string> | Promise<string | boolean>;
722
+ onSubmit?: (name: any, value: any, prompt: Enquirer.Prompt) => boolean | Promise<boolean>;
723
+ onCancel?: (name: any, value: any, prompt: Enquirer.Prompt) => boolean | Promise<boolean>;
724
+ }
725
+ interface BasePromptOptionsWithName extends BasePromptOptions {
726
+ name: string | (() => string);
727
+ }
728
+ interface ArrayPromptOptions extends BasePromptOptions {
729
+ choices: string[] | BasePromptOptionsWithName[];
730
+ maxChoices?: number;
731
+ multiple?: boolean;
732
+ initial?: number | number[];
733
+ delay?: number;
734
+ separator?: boolean;
735
+ sort?: boolean;
736
+ linebreak?: boolean;
737
+ edgeLength?: number;
738
+ align?: 'left' | 'right';
739
+ scroll?: boolean;
740
+ hint?: string;
741
+ }
742
+ interface BooleanPromptOptions extends BasePromptOptions {
743
+ initial?: boolean | (() => string) | (() => Promise<string>);
744
+ }
745
+ interface StringPromptOptions extends BasePromptOptions {
746
+ initial?: string;
747
+ multiline?: boolean;
748
+ }
749
+ interface ScalePromptOptions extends ArrayPromptOptions {
750
+ scale: StringPromptOptions[];
751
+ margin?: [number, number, number, number];
752
+ }
753
+ interface NumberPromptOptions extends BasePromptOptions {
754
+ min?: number;
755
+ max?: number;
756
+ delay?: number;
757
+ float?: boolean;
758
+ round?: boolean;
759
+ major?: number;
760
+ minor?: number;
761
+ initial?: number;
762
+ }
763
+ interface SnippetPromptOptions extends BasePromptOptions {
764
+ newline?: string;
765
+ fields: Partial<BasePromptOptionsWithName>[];
766
+ template: string;
767
+ }
768
+ interface SortPromptOptions extends BasePromptOptions {
769
+ hint?: string;
770
+ drag?: boolean;
771
+ numbered?: boolean;
772
+ }
773
+ interface SurveyPromptOptions extends ArrayPromptOptions {
774
+ scale: BasePromptOptionsWithName[];
775
+ margin: [number, number, number, number];
776
+ }
777
+ interface QuizPromptOptions extends ArrayPromptOptions {
778
+ correctChoice: number;
779
+ }
780
+ interface TogglePromptOptions extends BasePromptOptions {
781
+ enabled?: string;
782
+ disabled?: string;
783
+ }
784
+ /** Returns all the prompt options depending on the type selected. */
785
+ declare type PromptOptions<T extends boolean = false> = Unionize<{
786
+ [K in PromptTypes]-?: T extends true ? {
787
+ type: K;
788
+ } & PromptOptionsType<K> & {
789
+ name: string | (() => string);
790
+ } : {
791
+ type: K;
792
+ } & PromptOptionsType<K>;
793
+ }> | ({
794
+ type: string;
795
+ } & T extends true ? PromptOptionsType<string> & {
796
+ name: string | (() => string);
797
+ } : PromptOptionsType<string>);
798
+ declare type Unionize<T extends Record<PropertyKey, unknown>> = {
799
+ [P in keyof T]: T[P];
800
+ }[keyof T];
801
+ declare type PromptTypes = 'AutoComplete' | 'BasicAuth' | 'Confirm' | 'Editable' | 'Form' | 'Input' | 'Invisible' | 'List' | 'MultiSelect' | 'Numeral' | 'Password' | 'Quiz' | 'Scale' | 'Select' | 'Snippet' | 'Sort' | 'Survey' | 'Text' | 'Toggle';
802
+ declare type PromptOptionsType<T> = T extends keyof PromptOptionsMap ? PromptOptionsMap[T] : T extends string ? BasePromptOptions & Record<PropertyKey, unknown> : any;
803
+ declare class PromptOptionsMap implements Record<PromptTypes, Record<PropertyKey, any>> {
804
+ AutoComplete: ArrayPromptOptions;
805
+ BasicAuth: StringPromptOptions;
806
+ Confirm: BooleanPromptOptions;
807
+ Editable: ArrayPromptOptions;
808
+ Form: ArrayPromptOptions;
809
+ Input: StringPromptOptions;
810
+ Invisible: StringPromptOptions;
811
+ List: ArrayPromptOptions;
812
+ MultiSelect: ArrayPromptOptions;
813
+ Numeral: NumberPromptOptions;
814
+ Password: StringPromptOptions;
815
+ Quiz: QuizPromptOptions;
816
+ Scale: ScalePromptOptions;
817
+ Select: ArrayPromptOptions;
818
+ Snippet: SnippetPromptOptions;
819
+ Sort: SortPromptOptions;
820
+ Survey: SurveyPromptOptions;
821
+ Text: StringPromptOptions;
822
+ Toggle: TogglePromptOptions;
823
+ }
824
+ interface PromptInstance extends Omit<BasePromptOptions, 'onCancel' | 'onSubmit'> {
825
+ submit: () => void;
826
+ cancel: (err?: string) => void;
827
+ }
828
+
829
+ /**
830
+ * Extend the task to have more functionality while accesing from the outside.
831
+ */
832
+ declare class TaskWrapper<Ctx, Renderer extends ListrRendererFactory> {
833
+ task: Task$1<Ctx, ListrRendererFactory>;
834
+ errors: ListrError<Ctx>[];
835
+ private options;
836
+ constructor(task: Task$1<Ctx, ListrRendererFactory>, errors: ListrError<Ctx>[], options: ListrBaseClassOptions<Ctx, any, any>);
837
+ /** Get the title of the current task. */
838
+ get title(): string;
839
+ /** Change the title of the current task. */
840
+ set title(data: string);
841
+ /** Get the output from the output channel. */
842
+ get output(): string;
843
+ /** Send a output to the output channel. */
844
+ set output(data: string);
845
+ /** Create a new subtask with given renderer selection from the parent task. */
846
+ newListr<NewCtx = Ctx>(task: ListrTask<NewCtx, Renderer> | ListrTask<NewCtx, Renderer>[] | ((parent: Omit<this, 'skip' | 'enabled'>) => ListrTask<NewCtx, Renderer> | ListrTask<NewCtx, Renderer>[]), options?: ListrSubClassOptions<NewCtx, Renderer>): Listr<NewCtx, any, any>;
847
+ /** Report a error in process for error collection. */
848
+ report(error: Error, type: ListrErrorTypes): void;
849
+ /** Skip current task. */
850
+ skip(message?: string): void;
851
+ /** Get the number of retrying, else returns false */
852
+ isRetrying(): Task$1<Ctx, Renderer>['retry'];
853
+ /**
854
+ * Create a new Enquirer prompt using prompt options.
855
+ *
856
+ * Since process.stdout is controlled by Listr, this will passthrough all Enquirer data through internal stdout.
857
+ */
858
+ prompt<T = any>(options: PromptOptions | PromptOptions<true>[]): Promise<T>;
859
+ /** Cancels the current prompt attach to this task. */
860
+ cancelPrompt(throwError?: boolean): void;
861
+ /**
862
+ * Pass stream of data to internal stdout.
863
+ *
864
+ * Since Listr2 takes control of process.stdout utilizing the default renderer, any data outputted to process.stdout
865
+ * will corupt its looks.
866
+ *
867
+ * This returns a fake stream to pass any stream inside Listr as task data.
868
+ */
869
+ stdout(): NodeJS.WriteStream & NodeJS.WritableStream;
870
+ /** Run this task. */
871
+ run(ctx: Ctx): Promise<void>;
872
+ }
873
+
874
+ /** Available task states. */
875
+ declare enum ListrTaskState {
876
+ PENDING = "PENDING",
877
+ COMPLETED = "COMPLETED",
878
+ FAILED = "FAILED",
879
+ SKIPPED = "SKIPPED",
880
+ ROLLING_BACK = "ROLLING_BACK",
881
+ ROLLED_BACK = "ROLLED_BACK",
882
+ RETRY = "RETRY"
883
+ }
884
+
885
+ /**
886
+ * Create a task from the given set of variables and make it runnable.
887
+ */
888
+ declare class Task$1<Ctx, Renderer extends ListrRendererFactory> extends Subject<ListrEvent> {
889
+ listr: Listr<Ctx, any, any>;
890
+ tasks: ListrTask<Ctx, any>;
891
+ options: ListrOptions;
892
+ rendererOptions: ListrGetRendererOptions<Renderer>;
893
+ /** Unique id per task, randomly generated in the uuid v4 format */
894
+ id: string;
895
+ /** The current state of the task. */
896
+ state: string;
897
+ /** The task object itself, to further utilize it. */
898
+ task: (ctx: Ctx, task: TaskWrapper<Ctx, Renderer>) => void | ListrTaskResult<Ctx>;
899
+ /** Extend current task with multiple subtasks. */
900
+ subtasks: Task$1<Ctx, any>[];
901
+ /** Title of the task */
902
+ title?: string;
903
+ /** Untouched unchanged title of the task */
904
+ initialTitle?: string;
905
+ /** Output data from the task. */
906
+ output?: string;
907
+ /** Skip current task. */
908
+ skip: boolean | string | ((ctx: Ctx) => boolean | string | Promise<boolean | string>);
909
+ /** Current retry number of the task if retrying */
910
+ retry?: {
911
+ count: number;
912
+ withError?: any;
913
+ };
914
+ /**
915
+ * A channel for messages.
916
+ *
917
+ * This requires a separate channel for messages like error, skip or runtime messages to further utilize in the renderers.
918
+ */
919
+ message: {
920
+ /** Run time of the task, if it has been successfully resolved. */
921
+ duration?: number;
922
+ /** Error message of the task, if it has been failed. */
923
+ error?: string;
924
+ /** Skip message of the task, if it has been skipped. */
925
+ skip?: string;
926
+ /** Rollback message of the task, if the rollback finishes */
927
+ rollback?: string;
928
+ /** Retry messages */
929
+ retry?: {
930
+ count: number;
931
+ withError?: any;
932
+ };
933
+ };
934
+ /** Per task options for the current renderer of the task. */
935
+ rendererTaskOptions: ListrGetRendererTaskOptions<Renderer>;
936
+ /** This will be triggered each time a new render should happen. */
937
+ renderHook$: Subject<void>;
938
+ prompt: undefined | PromptInstance | PromptError;
939
+ private enabled;
940
+ private enabledFn;
941
+ constructor(listr: Listr<Ctx, any, any>, tasks: ListrTask<Ctx, any>, options: ListrOptions, rendererOptions: ListrGetRendererOptions<Renderer>);
942
+ set state$(state: ListrTaskState);
943
+ set output$(data: string);
944
+ set message$(data: Task$1<Ctx, Renderer>['message']);
945
+ set title$(title: string);
946
+ /**
947
+ * A function to check whether this task should run at all via enable.
948
+ */
949
+ check(ctx: Ctx): Promise<void>;
950
+ /** Returns whether this task has subtasks. */
951
+ hasSubtasks(): boolean;
952
+ /** Returns whether this task is in progress. */
953
+ isPending(): boolean;
954
+ /** Returns whether this task is skipped. */
955
+ isSkipped(): boolean;
956
+ /** Returns whether this task has been completed. */
957
+ isCompleted(): boolean;
958
+ /** Returns whether this task has been failed. */
959
+ hasFailed(): boolean;
960
+ /** Returns whether this task has an active rollback task going on. */
961
+ isRollingBack(): boolean;
962
+ /** Returns whether the rollback action was successful. */
963
+ hasRolledBack(): boolean;
964
+ /** Returns whether this task has an actively retrying task going on. */
965
+ isRetrying(): boolean;
966
+ /** Returns whether enabled function resolves to true. */
967
+ isEnabled(): boolean;
968
+ /** Returns whether this task actually has a title. */
969
+ hasTitle(): boolean;
970
+ /** Returns whether this task has a prompt inside. */
971
+ isPrompt(): boolean;
972
+ /** Run the current task. */
973
+ run(context: Ctx, wrapper: TaskWrapper<Ctx, Renderer>): Promise<void>;
974
+ }
975
+
976
+ /** Default updating renderer for Listr2 */
977
+ declare class DefaultRenderer implements ListrRenderer {
978
+ tasks: Task$1<any, typeof DefaultRenderer>[];
979
+ options: typeof DefaultRenderer['rendererOptions'];
980
+ renderHook$?: Task$1<any, any>['renderHook$'];
981
+ /** designates whether this renderer can output to a non-tty console */
982
+ static nonTTY: boolean;
983
+ /** renderer options for the defauult renderer */
984
+ static rendererOptions: {
985
+ /**
986
+ * indentation per level of subtask
987
+ *
988
+ * @default 2
989
+ */
990
+ indentation?: number;
991
+ /**
992
+ * clear all the output generated by the renderer when the task finishes its execution
993
+ *
994
+ * @default false
995
+ * @global global option that can not be temperated with subtasks
996
+ */
997
+ clearOutput?: boolean;
998
+ /**
999
+ * show the subtasks of the current task
1000
+ *
1001
+ * @default true
1002
+ */
1003
+ showSubtasks?: boolean;
1004
+ /**
1005
+ * collapse subtasks after current task completes its execution
1006
+ *
1007
+ * @default true
1008
+ */
1009
+ collapse?: boolean;
1010
+ /**
1011
+ * show skip messages or show the original title of the task, this will also disable collapseSkips mode
1012
+ *
1013
+ * You can disable showing the skip messages, even though you passed in a message by settings this option,
1014
+ * if you want to keep the original task title intact.
1015
+ *
1016
+ * @default true
1017
+ */
1018
+ showSkipMessage?: boolean;
1019
+ /**
1020
+ * collapse skip messages into a single message and overwrite the task title
1021
+ *
1022
+ * @default true
1023
+ */
1024
+ collapseSkips?: boolean;
1025
+ /**
1026
+ * suffix skip messages with [SKIPPED] when in collapseSkips mode
1027
+ *
1028
+ * @default true
1029
+ */
1030
+ suffixSkips?: boolean;
1031
+ /**
1032
+ * shows the thrown error message or show the original title of the task, this will also disable collapseErrors mode
1033
+ * You can disable showing the error messages, even though you passed in a message by settings this option,
1034
+ * if you want to keep the original task title intact.
1035
+ *
1036
+ * @default true
1037
+ */
1038
+ showErrorMessage?: boolean;
1039
+ /**
1040
+ * collapse error messages into a single message and overwrite the task title
1041
+ *
1042
+ * @default true
1043
+ */
1044
+ collapseErrors?: boolean;
1045
+ /**
1046
+ * suffix retry messages with [RETRY-${COUNT}] when retry is enabled for a task
1047
+ *
1048
+ * @default true
1049
+ */
1050
+ suffixRetries?: boolean;
1051
+ /**
1052
+ * only update through triggers from renderhook
1053
+ *
1054
+ * useful for tests and stuff. this will disable showing spinner and only update the screen if something else has
1055
+ * happened in the task worthy to show
1056
+ *
1057
+ * @default false
1058
+ * @global global option that can not be temperated with subtasks
1059
+ */
1060
+ lazy?: boolean;
1061
+ /**
1062
+ * show duration for all tasks
1063
+ *
1064
+ * @default false
1065
+ * @global global option that can not be temperated with subtasks
1066
+ */
1067
+ showTimer?: boolean;
1068
+ /**
1069
+ * removes empty lines from the data output
1070
+ *
1071
+ * @default true
1072
+ */
1073
+ removeEmptyLines?: boolean;
1074
+ /**
1075
+ * formats data output depending on your requirements.
1076
+ *
1077
+ * @default 'truncate'
1078
+ * @global global option that can not be temperated with subtasks
1079
+ */
1080
+ formatOutput?: 'truncate' | 'wrap';
1081
+ };
1082
+ /** per task options for the default renderer */
1083
+ static rendererTaskOptions: {
1084
+ /**
1085
+ * write task output to the bottom bar instead of the gap under the task title itself.
1086
+ * useful for a stream of data.
1087
+ * @default false
1088
+ *
1089
+ * `true` only keep 1 line of the latest data outputted by the task.
1090
+ * `false` only keep 1 line of the latest data outputted by the task.
1091
+ * `number` will keep designated data of the latest data outputted by the task.
1092
+ */
1093
+ bottomBar?: boolean | number;
1094
+ /**
1095
+ * keep output after task finishes
1096
+ * @default false
1097
+ *
1098
+ * works both for the bottom bar and the default behavior
1099
+ */
1100
+ persistentOutput?: boolean;
1101
+ /**
1102
+ * show the task time if it was successful
1103
+ */
1104
+ showTimer?: boolean;
1105
+ };
1106
+ private id?;
1107
+ private bottomBar;
1108
+ private promptBar;
1109
+ private readonly spinner;
1110
+ private spinnerPosition;
1111
+ constructor(tasks: Task$1<any, typeof DefaultRenderer>[], options: typeof DefaultRenderer['rendererOptions'], renderHook$?: Task$1<any, any>['renderHook$']);
1112
+ getTaskOptions(task: Task$1<any, typeof DefaultRenderer>): typeof DefaultRenderer['rendererTaskOptions'];
1113
+ isBottomBar(task: Task$1<any, typeof DefaultRenderer>): boolean;
1114
+ hasPersistentOutput(task: Task$1<any, typeof DefaultRenderer>): boolean;
1115
+ hasTimer(task: Task$1<any, typeof DefaultRenderer>): boolean;
1116
+ getSelfOrParentOption<T extends keyof typeof DefaultRenderer['rendererOptions']>(task: Task$1<any, typeof DefaultRenderer>, key: T): typeof DefaultRenderer['rendererOptions'][T];
1117
+ getTaskTime(task: Task$1<any, typeof DefaultRenderer>): string;
1118
+ createRender(options?: {
1119
+ tasks?: boolean;
1120
+ bottomBar?: boolean;
1121
+ prompt?: boolean;
1122
+ }): string;
1123
+ render(): void;
1124
+ end(): void;
1125
+ private multiLineRenderer;
1126
+ private renderBottomBar;
1127
+ private renderPrompt;
1128
+ private dumpData;
1129
+ private formatString;
1130
+ private indentMultilineOutput;
1131
+ private getSymbol;
1132
+ private addSuffixToMessage;
1133
+ }
1134
+
1135
+ declare class SilentRenderer implements ListrRenderer {
1136
+ tasks: Task$1<any, typeof SilentRenderer>[];
1137
+ options: typeof SilentRenderer['rendererOptions'];
1138
+ /** designates whether this renderer can output to a non-tty console */
1139
+ static nonTTY: boolean;
1140
+ /** renderer options for the silent renderer */
1141
+ static rendererOptions: never;
1142
+ /** per task options for the silent renderer */
1143
+ static rendererTaskOptions: never;
1144
+ constructor(tasks: Task$1<any, typeof SilentRenderer>[], options: typeof SilentRenderer['rendererOptions']);
1145
+ render(): void;
1146
+ end(): void;
1147
+ }
1148
+
1149
+ /**
1150
+ * This is the default renderer which is neither verbose or updating.
1151
+ * It provides short output like update renderer, but does not disturb
1152
+ * stdin during execution of listr tasks
1153
+ */
1154
+ declare class SimpleRenderer implements ListrRenderer {
1155
+ readonly tasks: Task$1<any, typeof SimpleRenderer>[];
1156
+ options: typeof SimpleRenderer['rendererOptions'];
1157
+ static nonTTY: boolean;
1158
+ static rendererOptions: {
1159
+ /**
1160
+ * if true this will add
1161
+ * timestamp at the begin of the rendered line
1162
+ *
1163
+ * @example
1164
+ *
1165
+ * ```bash
1166
+ * [12:33:44] ✔ Do something important
1167
+ * ```
1168
+ *
1169
+ * @default false
1170
+ */
1171
+ prefixWithTimestamp?: boolean;
1172
+ /**
1173
+ * choose between process.stdout and process.stderr
1174
+ *
1175
+ * @default stdout
1176
+ */
1177
+ output?: 'stdout' | 'stderr';
1178
+ };
1179
+ static rendererTaskOptions: never;
1180
+ /**
1181
+ * Event type renderer map contains functions to process different task events
1182
+ */
1183
+ eventTypeRendererMap: Partial<{
1184
+ [P in ListrEventType]: (t: Task$1<any, typeof SimpleRenderer>, event: ListrEventFromType<P>) => void;
1185
+ }>;
1186
+ constructor(tasks: Task$1<any, typeof SimpleRenderer>[], options: typeof SimpleRenderer['rendererOptions']);
1187
+ static now(): Date;
1188
+ static formatTitle(task?: Task$1<any, typeof SimpleRenderer>): string;
1189
+ log(output?: string): void;
1190
+ end(): void;
1191
+ render(tasks?: Task$1<any, typeof SimpleRenderer>[]): void;
1192
+ }
1193
+
1194
+ /** Default loglevels for the logger */
1195
+ declare enum LogLevels {
1196
+ SILENT = "SILENT",
1197
+ FAILED = "FAILED",
1198
+ SKIPPED = "SKIPPED",
1199
+ SUCCESS = "SUCCESS",
1200
+ DATA = "DATA",
1201
+ STARTED = "STARTED",
1202
+ TITLE = "TITLE",
1203
+ RETRY = "RETRY",
1204
+ ROLLBACK = "ROLLBACK"
1205
+ }
1206
+
1207
+ /**
1208
+ * Options for the logger
1209
+ */
1210
+ interface LoggerOptions {
1211
+ useIcons: boolean;
1212
+ }
1213
+
1214
+ /**
1215
+ * A internal logger for using in the verbose renderer mostly.
1216
+ */
1217
+ declare class Logger {
1218
+ private options?;
1219
+ constructor(options?: LoggerOptions);
1220
+ fail(message: string): void;
1221
+ skip(message: string): void;
1222
+ success(message: string): void;
1223
+ data(message: string): void;
1224
+ start(message: string): void;
1225
+ title(message: string): void;
1226
+ retry(message: string): void;
1227
+ rollback(message: string): void;
1228
+ protected parseMessage(level: LogLevels, message: string): string;
1229
+ protected logColoring({ level, message }: {
1230
+ level: LogLevels;
1231
+ message: string;
1232
+ }): string;
1233
+ private wrapInBrackets;
1234
+ }
1235
+
1236
+ declare class VerboseRenderer implements ListrRenderer {
1237
+ tasks: Task$1<any, typeof VerboseRenderer>[];
1238
+ options: typeof VerboseRenderer['rendererOptions'];
1239
+ /** designates whether this renderer can output to a non-tty console */
1240
+ static nonTTY: boolean;
1241
+ /** renderer options for the verbose renderer */
1242
+ static rendererOptions: ({
1243
+ /**
1244
+ * useIcons instead of text for log level
1245
+ * @default false
1246
+ */
1247
+ useIcons?: boolean;
1248
+ /**
1249
+ * log tasks with empty titles
1250
+ * @default true
1251
+ */
1252
+ logEmptyTitle?: boolean;
1253
+ /**
1254
+ * log title changes
1255
+ * @default true
1256
+ */
1257
+ logTitleChange?: boolean;
1258
+ /**
1259
+ * show duration for all tasks
1260
+ */
1261
+ showTimer?: boolean;
1262
+ } & {
1263
+ /**
1264
+ * inject a custom logger
1265
+ */
1266
+ logger?: new (...args: any) => Logger;
1267
+ /**
1268
+ * inject options to custom logger
1269
+ */
1270
+ options?: any;
1271
+ });
1272
+ /** per task options for the verbose renderer */
1273
+ static rendererTaskOptions: never;
1274
+ private logger;
1275
+ constructor(tasks: Task$1<any, typeof VerboseRenderer>[], options: typeof VerboseRenderer['rendererOptions']);
1276
+ render(): void;
1277
+ end(): void;
1278
+ private verboseRenderer;
1279
+ }
1280
+
1281
+ /** The default renderer value used in Listr2 applications */
1282
+ declare type ListrDefaultRendererValue = 'default';
1283
+ /** Type of default renderer */
1284
+ declare type ListrDefaultRenderer = typeof DefaultRenderer;
1285
+ /** Name of default fallback renderer */
1286
+ declare type ListrFallbackRendererValue = 'verbose';
1287
+ /** Type of default fallback renderer */
1288
+ declare type ListrFallbackRenderer = typeof VerboseRenderer;
1289
+ /** Silent rendere for internal usage */
1290
+ declare type ListrSilentRendererValue = 'silent';
1291
+ /** Typeof silent renderer */
1292
+ declare type ListrSilentRenderer = typeof SilentRenderer;
1293
+ /** Simple renderer that simplifies things */
1294
+ declare type ListrSimpleRendererValue = 'simple';
1295
+ /** Typeof simple renderer */
1296
+ declare type ListrSimpleRenderer = typeof SimpleRenderer;
1297
+ /**
1298
+ * Listr2 can process either the integrated renderers as string aliases,
1299
+ * or utilize a compatible style renderer that extends the ListrRenderer abstract class.
1300
+ */
1301
+ declare type ListrRendererValue = ListrSilentRendererValue | ListrDefaultRendererValue | ListrSimpleRendererValue | ListrFallbackRendererValue | ListrRendererFactory;
1302
+ /**
1303
+ * Returns the class type from friendly names of the renderers.
1304
+ */
1305
+ declare type ListrGetRendererClassFromValue<T extends ListrRendererValue> = T extends ListrDefaultRendererValue ? ListrDefaultRenderer : T extends ListrSimpleRendererValue ? ListrSimpleRenderer : T extends ListrFallbackRendererValue ? ListrFallbackRenderer : T extends ListrSilentRenderer ? ListrSilentRenderer : T extends ListrRendererFactory ? T : never;
1306
+ /**
1307
+ * Returns renderer global options depending on the renderer type.
1308
+ */
1309
+ declare type ListrGetRendererOptions<T extends ListrRendererValue> = T extends ListrDefaultRendererValue ? ListrDefaultRenderer['rendererOptions'] : T extends ListrSimpleRendererValue ? ListrSimpleRenderer['rendererOptions'] : T extends ListrFallbackRendererValue ? ListrFallbackRenderer['rendererOptions'] : T extends ListrSilentRenderer ? ListrSilentRenderer['rendererOptions'] : T extends ListrRendererFactory ? T['rendererOptions'] : never;
1310
+ /**
1311
+ * Returns renderer per task options depending on the renderer type.
1312
+ */
1313
+ declare type ListrGetRendererTaskOptions<T extends ListrRendererValue> = T extends ListrDefaultRendererValue ? ListrDefaultRenderer['rendererTaskOptions'] : T extends ListrSimpleRendererValue ? ListrSimpleRenderer : T extends ListrFallbackRendererValue ? ListrFallbackRenderer['rendererTaskOptions'] : T extends ListrSilentRenderer ? ListrSilentRenderer['rendererTaskOptions'] : T extends ListrRendererFactory ? T['rendererTaskOptions'] : never;
1314
+ /** Select renderer as default renderer */
1315
+ interface ListrDefaultRendererOptions<T extends ListrRendererValue> {
1316
+ /** the default renderer */
1317
+ renderer?: T;
1318
+ /** Renderer options depending on the current renderer */
1319
+ rendererOptions?: ListrGetRendererOptions<T>;
1320
+ }
1321
+ /** Select a fallback renderer to fallback to in non-tty conditions */
1322
+ interface ListrDefaultNonTTYRendererOptions<T extends ListrRendererValue> {
1323
+ /** the fallback renderer to fallback to on non-tty conditions */
1324
+ nonTTYRenderer?: T;
1325
+ /** Renderer options depending on the current renderer */
1326
+ nonTTYRendererOptions?: ListrGetRendererOptions<T>;
1327
+ }
1328
+ /** The bones of a listr renderer. */
1329
+ declare class ListrRenderer {
1330
+ /** designate renderer global options that is specific to the current renderer */
1331
+ static rendererOptions: Record<PropertyKey, any>;
1332
+ /** designate renderer per task options that is specific to the current renderer */
1333
+ static rendererTaskOptions: Record<PropertyKey, any>;
1334
+ /** designate whether this renderer can work in non-tty environments */
1335
+ static nonTTY: boolean;
1336
+ /** A function to what to do on render */
1337
+ render: () => void;
1338
+ /** A function to what to do on end of the render */
1339
+ end: (err?: Error) => void;
1340
+ /** create a new renderer */
1341
+ constructor(tasks: readonly Task$1<any, ListrRendererFactory>[], options: typeof ListrRenderer.rendererOptions, renderHook$?: Subject<void>);
1342
+ }
1343
+ /** A renderer factory from the current type */
1344
+ declare type ListrRendererFactory = typeof ListrRenderer;
1345
+
1346
+ /** The internal error handling mechanism.. */
1347
+ declare class ListrError<Ctx extends Record<PropertyKey, any> = Record<PropertyKey, any>> extends Error {
1348
+ error: Error;
1349
+ type: ListrErrorTypes;
1350
+ task: Task$1<Ctx, ListrRendererFactory>;
1351
+ path: string;
1352
+ ctx: Ctx;
1353
+ constructor(error: Error, type: ListrErrorTypes, task: Task$1<Ctx, ListrRendererFactory>);
1354
+ }
1355
+ /**
1356
+ * The actual error type that is collected and to help identify where the error is triggered from.
1357
+ */
1358
+ declare enum ListrErrorTypes {
1359
+ /** Task has failed and will try to retry. */
1360
+ WILL_RETRY = "WILL_RETRY",
1361
+ /** Task has failed and will try to rollback. */
1362
+ WILL_ROLLBACK = "WILL_ROLLBACK",
1363
+ /** Task has failed, ran the rollback action but the rollback action itself has failed. */
1364
+ HAS_FAILED_TO_ROLLBACK = "HAS_FAILED_TO_ROLLBACK",
1365
+ /** Task has failed. */
1366
+ HAS_FAILED = "HAS_FAILED",
1367
+ /** Task has failed, but exitOnError is set to false, so will ignore this error. */
1368
+ HAS_FAILED_WITHOUT_ERROR = "HAS_FAILED_WITHOUT_ERROR"
1369
+ }
1370
+ /** The internal error handling mechanism for prompts only. */
1371
+ declare class PromptError extends Error {
1372
+ constructor(message: string);
1373
+ }
1374
+
1375
+ /**
1376
+ * Creates a new set of Listr2 task list.
1377
+ */
1378
+ declare class Listr<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue, FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue> {
1379
+ task: ListrTask<Ctx, ListrGetRendererClassFromValue<Renderer>> | ListrTask<Ctx, ListrGetRendererClassFromValue<Renderer>>[];
1380
+ options?: ListrBaseClassOptions<Ctx, Renderer, FallbackRenderer>;
1381
+ parentTask?: Task$1<any, any>;
1382
+ tasks: Task$1<Ctx, ListrGetRendererClassFromValue<Renderer>>[];
1383
+ err: ListrError<Ctx>[];
1384
+ ctx: Ctx;
1385
+ rendererClass: ListrRendererFactory;
1386
+ rendererClassOptions: ListrGetRendererOptions<ListrRendererFactory>;
1387
+ renderHook$: Task$1<any, any>['renderHook$'];
1388
+ path: string[];
1389
+ private concurrency;
1390
+ private renderer;
1391
+ constructor(task: ListrTask<Ctx, ListrGetRendererClassFromValue<Renderer>> | ListrTask<Ctx, ListrGetRendererClassFromValue<Renderer>>[], options?: ListrBaseClassOptions<Ctx, Renderer, FallbackRenderer>, parentTask?: Task$1<any, any>);
1392
+ add(task: ListrTask<Ctx, ListrGetRendererClassFromValue<Renderer>> | ListrTask<Ctx, ListrGetRendererClassFromValue<Renderer>>[]): void;
1393
+ run(context?: Ctx): Promise<Ctx>;
1394
+ private checkAll;
1395
+ private runTask;
1396
+ }
1397
+
9
1398
  interface Question {
10
1399
  type: 'input' | 'select';
11
1400
  name: string;
12
1401
  message: string;
1402
+ validate?: (value: string) => string | boolean;
13
1403
  default?: string;
14
- choices?: string[];
1404
+ choices?: string[] | {
1405
+ name: string;
1406
+ value: string;
1407
+ }[];
15
1408
  }
16
1409
  declare const prompt: <T>(questions: Question[]) => Promise<T>;
17
- interface Task$1 {
18
- title: string;
19
- output: string;
20
- }
21
- interface Context {
22
- }
23
- interface ListTask {
24
- title: string;
25
- task: (ctx: Context, task: Task$1) => Promise<void>;
26
- }
27
- interface ListOptions {
28
- concurrent?: boolean;
29
- }
30
- declare const list: (tasks: ListTask[], options?: ListOptions | undefined) => Promise<void>;
31
1410
 
32
1411
  type ui_Question = Question;
33
1412
  declare const ui_prompt: typeof prompt;
34
- type ui_Context = Context;
35
- declare const ui_list: typeof list;
1413
+ type ui_Listr<Ctx = ListrContext, Renderer extends ListrRendererValue = ListrDefaultRendererValue, FallbackRenderer extends ListrRendererValue = ListrFallbackRendererValue> = Listr<Ctx, Renderer, FallbackRenderer>;
1414
+ declare const ui_Listr: typeof Listr;
36
1415
  declare namespace ui {
37
1416
  export {
38
1417
  ui_Question as Question,
39
1418
  ui_prompt as prompt,
40
- Task$1 as Task,
41
- ui_Context as Context,
42
- ui_list as list,
1419
+ ui_Listr as Listr,
43
1420
  };
44
1421
  }
45
1422
 
@@ -144,6 +1521,8 @@ declare function camelCase(input: string, options?: Options$4): string;
144
1521
 
145
1522
  declare function paramCase(input: string, options?: Options$4): string;
146
1523
 
1524
+ declare function snakeCase(input: string, options?: Options$4): string;
1525
+
147
1526
  /** Returns a random string */
148
1527
  declare function randomHex(size: number): string;
149
1528
  declare function generateRandomChallengePair(): {
@@ -159,6 +1538,7 @@ declare namespace string {
159
1538
  string_generateRandomChallengePair as generateRandomChallengePair,
160
1539
  camelCase as camelize,
161
1540
  paramCase as hyphenize,
1541
+ snakeCase as underscore,
162
1542
  };
163
1543
  }
164
1544
 
@@ -175,7 +1555,7 @@ declare const relative: typeof path$1.relative;
175
1555
  declare const dirname: typeof path$1.dirname;
176
1556
  declare const format: typeof path$1.format;
177
1557
  declare const basename: typeof path$1.basename;
178
- declare const parse$1: typeof path$1.parse;
1558
+ declare const parse: typeof path$1.parse;
179
1559
 
180
1560
  interface Options$3 {
181
1561
  /**
@@ -498,6 +1878,7 @@ declare const path_isAbsolute: typeof isAbsolute;
498
1878
  declare const path_join: typeof join;
499
1879
  declare const path_normalize: typeof normalize;
500
1880
  declare const path_normalizeString: typeof normalizeString;
1881
+ declare const path_parse: typeof parse;
501
1882
  declare const path_relative: typeof relative;
502
1883
  declare const path_resolve: typeof resolve;
503
1884
  declare const path_sep: typeof sep;
@@ -515,7 +1896,7 @@ declare namespace path {
515
1896
  path_join as join,
516
1897
  path_normalize as normalize,
517
1898
  path_normalizeString as normalizeString,
518
- parse$1 as parse,
1899
+ path_parse as parse,
519
1900
  path_relative as relative,
520
1901
  path_resolve as resolve,
521
1902
  path_sep as sep,
@@ -523,6 +1904,11 @@ declare namespace path {
523
1904
  };
524
1905
  }
525
1906
 
1907
+ /**
1908
+ * Creates a temporary directory and ties its lifecycle ot the lifecycle of the callback.
1909
+ * @param callback - The callback that receives the temporary directory.
1910
+ */
1911
+ declare function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T>;
526
1912
  /**
527
1913
  * It reads a file and returns its content as a string using the
528
1914
  * utf-8 encoding
@@ -537,29 +1923,65 @@ declare function read(path: string): Promise<string>;
537
1923
  */
538
1924
  declare function copy(from: string, to: string): Promise<void>;
539
1925
  declare function write(path: string, data: string): Promise<void>;
1926
+ declare function append(path: string, data: string): Promise<void>;
540
1927
  declare function mkdir(path: string): Promise<void>;
541
1928
  declare function rmdir(path: string): Promise<void>;
542
1929
  declare function mkTmpDir(): Promise<string>;
543
1930
  declare function isDirectory(path: string): Promise<boolean>;
1931
+ /**
1932
+ * Moves a file.
1933
+ * @param src {string} File to be moved.
1934
+ * @param dest {string} Path to be moved to.
1935
+ * @param options {object} Moving options.
1936
+ */
1937
+ declare function move(src: string, dest: string, options?: {
1938
+ overwrite?: boolean;
1939
+ }): Promise<void>;
1940
+ /**
1941
+ * Changes the permissions of a directory or file.
1942
+ * @param path {string} Path to the file or directory whose permissions will be modified.
1943
+ * @param mode {string | numbers} Permissions to set to the file or directory.
1944
+ */
1945
+ declare function chmod(path: string, mode: number | string): Promise<void>;
1946
+ /**
1947
+ * Checks if a file has executable permissions.
1948
+ * @param path {string} Path to the file whose permissions will be checked.
1949
+ */
1950
+ declare function hasExecutablePermissions(path: string): Promise<boolean>;
1951
+ /**
1952
+ * Returns true if a file or directory exists
1953
+ * @param path {string} Path to the directory or file.
1954
+ * @returns {boolean} True if it exists.
1955
+ */
544
1956
  declare function exists(path: string): Promise<boolean>;
545
1957
 
1958
+ declare const file_inTemporaryDirectory: typeof inTemporaryDirectory;
546
1959
  declare const file_read: typeof read;
547
1960
  declare const file_copy: typeof copy;
548
1961
  declare const file_write: typeof write;
1962
+ declare const file_append: typeof append;
549
1963
  declare const file_mkdir: typeof mkdir;
550
1964
  declare const file_rmdir: typeof rmdir;
551
1965
  declare const file_mkTmpDir: typeof mkTmpDir;
552
1966
  declare const file_isDirectory: typeof isDirectory;
1967
+ declare const file_move: typeof move;
1968
+ declare const file_chmod: typeof chmod;
1969
+ declare const file_hasExecutablePermissions: typeof hasExecutablePermissions;
553
1970
  declare const file_exists: typeof exists;
554
1971
  declare namespace file {
555
1972
  export {
1973
+ file_inTemporaryDirectory as inTemporaryDirectory,
556
1974
  file_read as read,
557
1975
  file_copy as copy,
558
1976
  file_write as write,
1977
+ file_append as append,
559
1978
  file_mkdir as mkdir,
560
1979
  file_rmdir as rmdir,
561
1980
  file_mkTmpDir as mkTmpDir,
562
1981
  file_isDirectory as isDirectory,
1982
+ file_move as move,
1983
+ file_chmod as chmod,
1984
+ file_hasExecutablePermissions as hasExecutablePermissions,
563
1985
  file_exists as exists,
564
1986
  };
565
1987
  }
@@ -589,25 +2011,82 @@ declare class TokenizedString {
589
2011
  }
590
2012
  declare type Message = string | TokenizedString;
591
2013
  declare function content(strings: TemplateStringsArray, ...keys: (ContentToken | string)[]): TokenizedString;
2014
+ /** Log levels */
2015
+ declare type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
2016
+ /**
2017
+ *
2018
+ * @returns {LogLevel} It returns the log level set by the user.
2019
+ */
2020
+ declare const currentLogLevel: () => LogLevel;
2021
+ declare const shouldOutput: (logLevel: LogLevel) => boolean;
2022
+ /**
2023
+ * Ouputs information to the user. This is akin to "console.log"
2024
+ * Info messages don't get additional formatting.
2025
+ * Note: Info messages are sent through the standard output.
2026
+ * @param content {string} The content to be output to the user.
2027
+ */
2028
+ declare const info: (content: Message) => void;
2029
+ /**
2030
+ * Outputs a success message to the user.
2031
+ * Success message receive a special formatting to make them stand out in the console.
2032
+ * Note: Success messages are sent through the standard output.
2033
+ * @param content {string} The content to be output to the user.
2034
+ */
592
2035
  declare const success: (content: Message) => void;
593
- declare const message: (content: Message) => void;
594
- declare const error: (content: Message) => void;
595
- declare const warning: (content: Message) => void;
2036
+ /**
2037
+ * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.
2038
+ * Debug messages don't get additional formatting.
2039
+ * Note: Debug messages are sent through the standard output.
2040
+ * @param content {string} The content to be output to the user.
2041
+ */
2042
+ declare const debug: (content: Message) => void;
2043
+ /**
2044
+ * Outputs a warning message to the user.
2045
+ * Warning messages receive a special formatting to make them stand out in the console.
2046
+ * Note: Warning messages are sent through the standard output.
2047
+ * @param content {string} The content to be output to the user.
2048
+ */
2049
+ declare const warn: (content: Message) => void;
2050
+ /**
2051
+ * Prints a new line in the terminal.
2052
+ */
2053
+ declare const newline: () => void;
2054
+ /**
2055
+ * Formats and outputs a fatal error.
2056
+ * Note: This API is not intended to be used internally. If you want to
2057
+ * abort the execution due to an error, raise a fatal error and let the
2058
+ * error handler handle and format it.
2059
+ * @param content {Fatal} The fatal error to be output.
2060
+ */
2061
+ declare const error: (content: Fatal) => void;
2062
+ declare function stringifyMessage(message: Message): string;
596
2063
 
597
2064
  declare const output$1_token: typeof token;
598
2065
  declare const output$1_content: typeof content;
2066
+ type output$1_LogLevel = LogLevel;
2067
+ declare const output$1_currentLogLevel: typeof currentLogLevel;
2068
+ declare const output$1_shouldOutput: typeof shouldOutput;
2069
+ declare const output$1_info: typeof info;
599
2070
  declare const output$1_success: typeof success;
600
- declare const output$1_message: typeof message;
2071
+ declare const output$1_debug: typeof debug;
2072
+ declare const output$1_warn: typeof warn;
2073
+ declare const output$1_newline: typeof newline;
601
2074
  declare const output$1_error: typeof error;
602
- declare const output$1_warning: typeof warning;
2075
+ declare const output$1_stringifyMessage: typeof stringifyMessage;
603
2076
  declare namespace output$1 {
604
2077
  export {
605
2078
  output$1_token as token,
606
2079
  output$1_content as content,
2080
+ output$1_LogLevel as LogLevel,
2081
+ output$1_currentLogLevel as currentLogLevel,
2082
+ output$1_shouldOutput as shouldOutput,
2083
+ output$1_info as info,
607
2084
  output$1_success as success,
608
- output$1_message as message,
2085
+ output$1_debug as debug,
2086
+ output$1_warn as warn,
2087
+ output$1_newline as newline,
609
2088
  output$1_error as error,
610
- output$1_warning as warning,
2089
+ output$1_stringifyMessage as stringifyMessage,
611
2090
  };
612
2091
  }
613
2092
 
@@ -659,12 +2138,22 @@ declare namespace version {
659
2138
  };
660
2139
  }
661
2140
 
662
- declare const username: () => Promise<string | null>;
2141
+ declare const username: (platform?: typeof platform) => Promise<string | null>;
2142
+ /**
2143
+ * Returns the platform and architecture.
2144
+ * @returns {{platform: string, arch: string}} Returns the current platform and architecture.
2145
+ */
2146
+ declare const platformAndArch: (platform?: typeof platform) => {
2147
+ platform: string;
2148
+ arch: string;
2149
+ };
663
2150
 
664
2151
  declare const os_username: typeof username;
2152
+ declare const os_platformAndArch: typeof platformAndArch;
665
2153
  declare namespace os {
666
2154
  export {
667
2155
  os_username as username,
2156
+ os_platformAndArch as platformAndArch,
668
2157
  };
669
2158
  }
670
2159
 
@@ -816,18 +2305,54 @@ interface OAuthApplications {
816
2305
  storefrontRendererApi?: StorefrontRendererAPIOAuthOptions;
817
2306
  partnersApi?: PartnersAPIOAuthOptions;
818
2307
  }
2308
+ interface OAuthSession {
2309
+ admin?: string;
2310
+ partners?: string;
2311
+ storefront?: string;
2312
+ }
2313
+ /**
2314
+ * Ensure that we have a valid session to access the Partners API.
2315
+ * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token
2316
+ * If SHOPIFY_CLI_PARTNERS_TOKEN exists, scopes will be ignored
2317
+ * @param scopes {string[]} Optional array of extra scopes to authenticate with.
2318
+ * @returns {Promise<string>} The access token for the Partners API.
2319
+ */
2320
+ declare function ensureAuthenticatedPartners(scopes?: string[], env?: NodeJS.ProcessEnv): Promise<string>;
2321
+ /**
2322
+ * Ensure that we have a valid session to access the Storefront API.
2323
+ * @param scopes {string[]} Optional array of extra scopes to authenticate with.
2324
+ * @returns {Promise<string>} The access token for the Storefront API.
2325
+ */
2326
+ declare function ensureAuthenticatedStorefront(scopes?: string[]): Promise<string>;
2327
+ /**
2328
+ * Ensure that we have a valid Admin session for the given store.
2329
+ * If the session is valid, the store will be saved as the `activeStore` for future usage.
2330
+ * If no store is passed we will try to use the `activeStore` if there is any.
2331
+ * @param store {string} Store fqdn to request auth for
2332
+ * @param scopes {string[]} Optional array of extra scopes to authenticate with.
2333
+ * @returns {Promise<string>} The access token for the Admin API
2334
+ */
2335
+ declare function ensureAuthenticatedAdmin(store?: string, scopes?: string[]): Promise<string>;
819
2336
  /**
820
2337
  * This method ensures that we have a valid session to authenticate against the given applications using the provided scopes.
821
- * @param options {OAuthApplications} An object containing the applications we need to be authenticated with.
2338
+ * @param applications {OAuthApplications} An object containing the applications we need to be authenticated with.
822
2339
  * @returns {OAuthSession} An instance with the access tokens organized by application.
823
2340
  */
824
- declare function ensureAuthenticated(applications: OAuthApplications): Promise<void>;
2341
+ declare function ensureAuthenticated(applications: OAuthApplications, env?: NodeJS.ProcessEnv): Promise<OAuthSession>;
825
2342
 
826
2343
  type session_OAuthApplications = OAuthApplications;
2344
+ type session_OAuthSession = OAuthSession;
2345
+ declare const session_ensureAuthenticatedPartners: typeof ensureAuthenticatedPartners;
2346
+ declare const session_ensureAuthenticatedStorefront: typeof ensureAuthenticatedStorefront;
2347
+ declare const session_ensureAuthenticatedAdmin: typeof ensureAuthenticatedAdmin;
827
2348
  declare const session_ensureAuthenticated: typeof ensureAuthenticated;
828
2349
  declare namespace session {
829
2350
  export {
830
2351
  session_OAuthApplications as OAuthApplications,
2352
+ session_OAuthSession as OAuthSession,
2353
+ session_ensureAuthenticatedPartners as ensureAuthenticatedPartners,
2354
+ session_ensureAuthenticatedStorefront as ensureAuthenticatedStorefront,
2355
+ session_ensureAuthenticatedAdmin as ensureAuthenticatedAdmin,
831
2356
  session_ensureAuthenticated as ensureAuthenticated,
832
2357
  };
833
2358
  }
@@ -2158,12 +3683,15 @@ declare namespace schema {
2158
3683
  };
2159
3684
  }
2160
3685
 
2161
- declare function parse(input: string): object;
3686
+ declare function decode(input: string): object;
3687
+ declare function encode(content: any): string;
2162
3688
 
2163
- declare const toml_parse: typeof parse;
3689
+ declare const toml_decode: typeof decode;
3690
+ declare const toml_encode: typeof encode;
2164
3691
  declare namespace toml {
2165
3692
  export {
2166
- toml_parse as parse,
3693
+ toml_decode as decode,
3694
+ toml_encode as encode,
2167
3695
  };
2168
3696
  }
2169
3697
 
@@ -3372,25 +4900,7 @@ declare namespace store {
3372
4900
  };
3373
4901
  }
3374
4902
 
3375
- /**
3376
- * The schema represents an application token.
3377
- */
3378
- declare const ApplicationTokenSchema: ZodObject<{
3379
- accessToken: ZodString;
3380
- expiresAt: ZodEffects<ZodDate, Date, Date>;
3381
- scopes: ZodArray<ZodString, "many">;
3382
- }, "strip", ZodTypeAny, {
3383
- accessToken: string;
3384
- expiresAt: Date;
3385
- scopes: string[];
3386
- }, {
3387
- accessToken: string;
3388
- expiresAt: Date;
3389
- scopes: string[];
3390
- }>;
3391
- declare type ApplicationToken = TypeOf<typeof ApplicationTokenSchema>;
3392
-
3393
- declare function request$1<T>(query: any, token: ApplicationToken, store: string, variables?: any): Promise<T>;
4903
+ declare function request$1<T>(query: any, token: string, store: string, variables?: any): Promise<T>;
3394
4904
 
3395
4905
  declare namespace admin {
3396
4906
  export {
@@ -3398,7 +4908,7 @@ declare namespace admin {
3398
4908
  };
3399
4909
  }
3400
4910
 
3401
- declare function request<T>(query: any, token: ApplicationToken, variables?: any): Promise<T>;
4911
+ declare function request<T>(query: any, token: string, variables?: any): Promise<T>;
3402
4912
 
3403
4913
  declare const partners_request: typeof request;
3404
4914
  declare namespace partners {
@@ -3407,15 +4917,111 @@ declare namespace partners {
3407
4917
  };
3408
4918
  }
3409
4919
 
4920
+ declare const FindOrganizationQuery: string;
4921
+ interface FindOrganizationQuerySchema {
4922
+ organizations: {
4923
+ nodes: {
4924
+ id: string;
4925
+ businessName: string;
4926
+ website: string;
4927
+ stores: {
4928
+ nodes: {
4929
+ shopId: string;
4930
+ link: string;
4931
+ shopDomain: string;
4932
+ shopName: string;
4933
+ transferDisabled: boolean;
4934
+ convertableToPartnerTest: boolean;
4935
+ }[];
4936
+ };
4937
+ apps: {
4938
+ nodes: {
4939
+ id: string;
4940
+ title: string;
4941
+ apiKey: string;
4942
+ apiSecretKeys: {
4943
+ secret: string;
4944
+ };
4945
+ appType: string;
4946
+ }[];
4947
+ };
4948
+ }[];
4949
+ };
4950
+ }
4951
+
4952
+ interface AllOrganizationsQuerySchema {
4953
+ organizations: {
4954
+ nodes: {
4955
+ id: string;
4956
+ businessName: string;
4957
+ website: string;
4958
+ }[];
4959
+ };
4960
+ }
4961
+ declare const AllOrganizationsQuery: string;
4962
+
4963
+ declare const CreateAppQuery: string;
4964
+ interface CreateAppQueryVariables {
4965
+ org: number;
4966
+ title: string;
4967
+ appUrl: string;
4968
+ redir: string[];
4969
+ type: string;
4970
+ }
4971
+ interface CreateAppQuerySchema {
4972
+ appCreate: {
4973
+ app: {
4974
+ id: string;
4975
+ apiKey: string;
4976
+ title: string;
4977
+ applicationUrl: string;
4978
+ redirectUrlWhitelist: string[];
4979
+ apiSecretKeys: {
4980
+ secret: string;
4981
+ };
4982
+ appType: string;
4983
+ };
4984
+ userErrors: {
4985
+ field: string[];
4986
+ message: string;
4987
+ }[];
4988
+ };
4989
+ }
4990
+
4991
+ declare const index_FindOrganizationQuery: typeof FindOrganizationQuery;
4992
+ type index_FindOrganizationQuerySchema = FindOrganizationQuerySchema;
4993
+ type index_AllOrganizationsQuerySchema = AllOrganizationsQuerySchema;
4994
+ declare const index_AllOrganizationsQuery: typeof AllOrganizationsQuery;
4995
+ declare const index_CreateAppQuery: typeof CreateAppQuery;
4996
+ type index_CreateAppQueryVariables = CreateAppQueryVariables;
4997
+ type index_CreateAppQuerySchema = CreateAppQuerySchema;
4998
+ declare namespace index {
4999
+ export {
5000
+ index_FindOrganizationQuery as FindOrganizationQuery,
5001
+ index_FindOrganizationQuerySchema as FindOrganizationQuerySchema,
5002
+ index_AllOrganizationsQuerySchema as AllOrganizationsQuerySchema,
5003
+ index_AllOrganizationsQuery as AllOrganizationsQuery,
5004
+ index_CreateAppQuery as CreateAppQuery,
5005
+ index_CreateAppQueryVariables as CreateAppQueryVariables,
5006
+ index_CreateAppQuerySchema as CreateAppQuerySchema,
5007
+ };
5008
+ }
5009
+
3410
5010
  declare const api_admin: typeof admin;
3411
5011
  declare const api_partners: typeof partners;
3412
5012
  declare namespace api {
3413
5013
  export {
3414
5014
  api_admin as admin,
3415
5015
  api_partners as partners,
5016
+ index as graphql,
3416
5017
  };
3417
5018
  }
3418
5019
 
5020
+ declare const FormData: {
5021
+ new (): FormData;
5022
+ prototype: FormData;
5023
+ };
5024
+
3419
5025
  /** @type {typeof globalThis.Blob} */
3420
5026
  declare const Blob: typeof globalThis.Blob;
3421
5027
 
@@ -3619,9 +5225,33 @@ declare namespace http {
3619
5225
  };
3620
5226
  }
3621
5227
 
5228
+ declare const InvalidChecksumError: ({ file, expected, got }: {
5229
+ file: string;
5230
+ expected: string;
5231
+ got: string;
5232
+ }) => Abort;
5233
+ /**
5234
+ * Given a local file and a URL pointing to a remote file representing the MD5 of a local file,
5235
+ * it validates the authenticity of the binary using an MD5 checksum.
5236
+ * @param options: The file to validate and the URL that points to the file containing the MD5.
5237
+ */
5238
+ declare function validateMD5({ file, md5FileURL }: {
5239
+ file: string;
5240
+ md5FileURL: string;
5241
+ }): Promise<void>;
5242
+
5243
+ declare const checksum_InvalidChecksumError: typeof InvalidChecksumError;
5244
+ declare const checksum_validateMD5: typeof validateMD5;
5245
+ declare namespace checksum {
5246
+ export {
5247
+ checksum_InvalidChecksumError as InvalidChecksumError,
5248
+ checksum_validateMD5 as validateMD5,
5249
+ };
5250
+ }
5251
+
3622
5252
  declare const constants: {
3623
5253
  environmentVariables: {
3624
- debug: string;
5254
+ shopifyConfig: string;
3625
5255
  runAsUser: string;
3626
5256
  partnersEnv: string;
3627
5257
  shopifyEnv: string;
@@ -3631,6 +5261,7 @@ declare const constants: {
3631
5261
  spinWorkspace: string;
3632
5262
  spinNamespace: string;
3633
5263
  spinHost: string;
5264
+ partnersToken: string;
3634
5265
  };
3635
5266
  paths: {
3636
5267
  executables: {
@@ -3658,5 +5289,5 @@ declare const constants: {
3658
5289
  };
3659
5290
  };
3660
5291
 
3661
- export { api, constants, dependency, environment, error$1 as error, file, http, os, output$1 as output, path, schema, session, store, string, system, template, toml, ui, version };
5292
+ export { api, checksum, constants, dependency, environment, error$1 as error, file, http, os, output$1 as output, path, schema, session, store, string, system, template, toml, ui, version };
3662
5293
  //# sourceMappingURL=index.d.ts.map