@shopify/cli-kit 3.46.0-pre.3 → 3.46.1

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.
Files changed (116) hide show
  1. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +1 -1
  2. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +6 -2
  3. package/assets/cli-ruby/lib/shopify_cli/version.rb +1 -1
  4. package/dist/private/node/api.d.ts +1 -0
  5. package/dist/private/node/api.js +1 -0
  6. package/dist/private/node/api.js.map +1 -1
  7. package/dist/private/node/constants.d.ts +1 -1
  8. package/dist/private/node/constants.js +1 -1
  9. package/dist/private/node/constants.js.map +1 -1
  10. package/dist/private/node/content-tokens.js +1 -1
  11. package/dist/private/node/content-tokens.js.map +1 -1
  12. package/dist/private/node/demo-recorder.d.ts +20 -0
  13. package/dist/private/node/demo-recorder.js +122 -0
  14. package/dist/private/node/demo-recorder.js.map +1 -0
  15. package/dist/private/node/session/schema.d.ts +203 -41
  16. package/dist/private/node/tree-kill.d.ts +1 -0
  17. package/dist/private/node/tree-kill.js +7 -0
  18. package/dist/private/node/tree-kill.js.map +1 -0
  19. package/dist/private/node/ui/alert.js +4 -0
  20. package/dist/private/node/ui/alert.js.map +1 -1
  21. package/dist/private/node/ui/components/Alert.test.js +2 -2
  22. package/dist/private/node/ui/components/Alert.test.js.map +1 -1
  23. package/dist/private/node/ui/components/AutocompletePrompt.d.ts +3 -1
  24. package/dist/private/node/ui/components/AutocompletePrompt.js +8 -4
  25. package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
  26. package/dist/private/node/ui/components/AutocompletePrompt.test.js +33 -7
  27. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
  28. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -2
  29. package/dist/private/node/ui/components/ConcurrentOutput.js +23 -6
  30. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  31. package/dist/private/node/ui/components/ConcurrentOutput.test.js +122 -8
  32. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  33. package/dist/private/node/ui/components/FatalError.js +5 -3
  34. package/dist/private/node/ui/components/FatalError.js.map +1 -1
  35. package/dist/private/node/ui/components/FatalError.test.js +113 -0
  36. package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
  37. package/dist/private/node/ui/components/List.d.ts +1 -1
  38. package/dist/private/node/ui/components/List.js +2 -1
  39. package/dist/private/node/ui/components/List.js.map +1 -1
  40. package/dist/private/node/ui/components/List.test.js +19 -0
  41. package/dist/private/node/ui/components/List.test.js.map +1 -1
  42. package/dist/private/node/ui/components/Prompts/InfoTable.js +5 -1
  43. package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
  44. package/dist/private/node/ui/components/Prompts/InfoTable.test.js +5 -4
  45. package/dist/private/node/ui/components/Prompts/InfoTable.test.js.map +1 -1
  46. package/dist/private/node/ui/components/SelectPrompt.d.ts +3 -1
  47. package/dist/private/node/ui/components/SelectPrompt.js +4 -2
  48. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  49. package/dist/private/node/ui/components/SelectPrompt.test.js +22 -0
  50. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  51. package/dist/private/node/ui/components/Tasks.d.ts +3 -1
  52. package/dist/private/node/ui/components/Tasks.js +7 -3
  53. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  54. package/dist/private/node/ui/components/Tasks.test.js +22 -1
  55. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  56. package/dist/private/node/ui/components/TextPrompt.d.ts +2 -0
  57. package/dist/private/node/ui/components/TextPrompt.js +4 -2
  58. package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
  59. package/dist/private/node/ui/components/TextPrompt.test.js +9 -0
  60. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  61. package/dist/private/node/ui/components/TokenizedText.d.ts +1 -1
  62. package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
  63. package/dist/private/node/ui/components/TokenizedText.test.js +10 -0
  64. package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
  65. package/dist/private/node/ui/hooks/use-abort-signal.d.ts +4 -0
  66. package/dist/private/node/ui/hooks/use-abort-signal.js +14 -0
  67. package/dist/private/node/ui/hooks/use-abort-signal.js.map +1 -0
  68. package/dist/private/node/ui/hooks/use-async-and-unmount.d.ts +1 -1
  69. package/dist/private/node/ui/hooks/use-async-and-unmount.js +1 -1
  70. package/dist/private/node/ui/hooks/use-async-and-unmount.js.map +1 -1
  71. package/dist/private/node/ui.js +3 -3
  72. package/dist/private/node/ui.js.map +1 -1
  73. package/dist/public/common/version.d.ts +1 -1
  74. package/dist/public/common/version.js +1 -1
  75. package/dist/public/common/version.js.map +1 -1
  76. package/dist/public/node/cli.js +2 -0
  77. package/dist/public/node/cli.js.map +1 -1
  78. package/dist/public/node/colors.js.map +1 -0
  79. package/dist/public/node/context/local.d.ts +1 -1
  80. package/dist/public/node/context/local.js +2 -2
  81. package/dist/public/node/context/local.js.map +1 -1
  82. package/dist/public/node/error-handler.js +7 -2
  83. package/dist/public/node/error-handler.js.map +1 -1
  84. package/dist/public/node/error.d.ts +8 -3
  85. package/dist/public/node/error.js +12 -5
  86. package/dist/public/node/error.js.map +1 -1
  87. package/dist/public/node/fs.d.ts +1 -0
  88. package/dist/public/node/hooks/prerun.js +2 -0
  89. package/dist/public/node/hooks/prerun.js.map +1 -1
  90. package/dist/public/node/node-package-manager.d.ts +11 -0
  91. package/dist/public/node/node-package-manager.js +8 -6
  92. package/dist/public/node/node-package-manager.js.map +1 -1
  93. package/dist/public/node/output.d.ts +6 -1
  94. package/dist/public/node/output.js +6 -2
  95. package/dist/public/node/output.js.map +1 -1
  96. package/dist/public/node/plugins/tunnel.d.ts +19 -4
  97. package/dist/public/node/plugins/tunnel.js +1 -1
  98. package/dist/public/node/plugins/tunnel.js.map +1 -1
  99. package/dist/public/node/plugins.d.ts +1 -12
  100. package/dist/public/node/plugins.js +0 -23
  101. package/dist/public/node/plugins.js.map +1 -1
  102. package/dist/public/node/ruby.js +2 -0
  103. package/dist/public/node/ruby.js.map +1 -1
  104. package/dist/public/node/system.d.ts +1 -0
  105. package/dist/public/node/system.js +8 -3
  106. package/dist/public/node/system.js.map +1 -1
  107. package/dist/public/node/tcp.js +1 -1
  108. package/dist/public/node/tcp.js.map +1 -1
  109. package/dist/public/node/ui.d.ts +17 -8
  110. package/dist/public/node/ui.js +75 -19
  111. package/dist/public/node/ui.js.map +1 -1
  112. package/dist/tsconfig.tsbuildinfo +1 -1
  113. package/package.json +13 -12
  114. package/dist/private/node/colors.js.map +0 -1
  115. /package/dist/{private → public}/node/colors.d.ts +0 -0
  116. /package/dist/{private → public}/node/colors.js +0 -0
@@ -5,15 +5,15 @@ import { AlertOptions } from '../../private/node/ui/alert.js';
5
5
  import { CustomSection } from '../../private/node/ui/components/Alert.js';
6
6
  import ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js';
7
7
  import { TableColumn, TableProps } from '../../private/node/ui/components/Table/Table.js';
8
+ import { InlineToken, LinkToken, ListToken, TokenItem } from '../../private/node/ui/components/TokenizedText.js';
8
9
  import { SelectPromptProps } from '../../private/node/ui/components/SelectPrompt.js';
9
10
  import { Task } from '../../private/node/ui/components/Tasks.js';
10
11
  import { TextPromptProps } from '../../private/node/ui/components/TextPrompt.js';
11
12
  import { AutocompletePromptProps } from '../../private/node/ui/components/AutocompletePrompt.js';
12
- import { InlineToken, LinkToken, TokenItem } from '../../private/node/ui/components/TokenizedText.js';
13
13
  import { InfoTableSection } from '../../private/node/ui/components/Prompts/InfoTable.js';
14
14
  import { Key as InkKey, RenderOptions } from 'ink';
15
15
  type PartialBy<T, TKey extends keyof T> = Omit<T, TKey> & Partial<Pick<T, TKey>>;
16
- export interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps, 'abortController'> {
16
+ export interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps, 'abortSignal'> {
17
17
  renderOptions?: RenderOptions;
18
18
  }
19
19
  /**
@@ -40,7 +40,7 @@ export type RenderAlertOptions = Omit<AlertOptions, 'type'>;
40
40
  * @example Basic
41
41
  * ╭─ info ───────────────────────────────────────────────────╮
42
42
  * │ │
43
- * │ CLI update available
43
+ * │ CLI update available.
44
44
  * │ │
45
45
  * │ Run `npm run shopify upgrade`. │
46
46
  * │ │
@@ -163,12 +163,21 @@ interface RenderFatalErrorOptions {
163
163
  * │ • Need to connect to a different App or │
164
164
  * │ organization? Run the command again with `--reset` │
165
165
  * │ │
166
+ * │ amortizable-marketplace-ext │
167
+ * │ • Some other error │
168
+ * │ Validation errors │
169
+ * │ • Missing expected key(s). │
170
+ * │ │
171
+ * │ amortizable-marketplace-ext-2 │
172
+ * │ • Something was not found │
173
+ * │ │
166
174
  * ╰──────────────────────────────────────────────────────────╯
167
175
  * [1] https://partners.shopify.com/signup
168
176
  *
169
177
  */
170
178
  export declare function renderFatalError(error: Fatal, { renderOptions }?: RenderFatalErrorOptions): string | undefined;
171
- export interface RenderSeletPromptOptions<T> extends Omit<SelectPromptProps<T>, 'onSubmit'> {
179
+ export interface RenderSelectPromptOptions<T> extends Omit<SelectPromptProps<T>, 'onSubmit'> {
180
+ isConfirmationPrompt?: boolean;
172
181
  renderOptions?: RenderOptions;
173
182
  }
174
183
  /**
@@ -200,8 +209,8 @@ export interface RenderSeletPromptOptions<T> extends Omit<SelectPromptProps<T>,
200
209
  * Press ↑↓ arrows to select, enter to confirm
201
210
  *
202
211
  */
203
- export declare function renderSelectPrompt<T>({ renderOptions, ...props }: RenderSeletPromptOptions<T>): Promise<T>;
204
- export interface RenderConfirmationPromptOptions extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable'> {
212
+ export declare function renderSelectPrompt<T>({ renderOptions, isConfirmationPrompt, ...props }: RenderSelectPromptOptions<T>): Promise<T>;
213
+ export interface RenderConfirmationPromptOptions extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable' | 'abortSignal'> {
205
214
  confirmationMessage?: string;
206
215
  cancellationMessage?: string;
207
216
  renderOptions?: RenderOptions;
@@ -221,7 +230,7 @@ export interface RenderConfirmationPromptOptions extends Pick<SelectPromptProps<
221
230
  * Press ↑↓ arrows to select, enter or a shortcut to confirm
222
231
  *
223
232
  */
224
- export declare function renderConfirmationPrompt({ message, infoTable, confirmationMessage, cancellationMessage, renderOptions, defaultValue, }: RenderConfirmationPromptOptions): Promise<boolean>;
233
+ export declare function renderConfirmationPrompt({ message, infoTable, confirmationMessage, cancellationMessage, renderOptions, defaultValue, abortSignal, }: RenderConfirmationPromptOptions): Promise<boolean>;
225
234
  export interface RenderAutocompleteOptions<T> extends PartialBy<Omit<AutocompletePromptProps<T>, 'onSubmit'>, 'search'> {
226
235
  renderOptions?: RenderOptions;
227
236
  }
@@ -310,4 +319,4 @@ export declare function renderText({ text, logLevel, logger }: RenderTextOptions
310
319
  /** Waits for any key to be pressed except Ctrl+C which will terminate the process. */
311
320
  export declare const keypress: () => Promise<unknown>;
312
321
  export type Key = InkKey;
313
- export { Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection };
322
+ export { Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken };
@@ -1,18 +1,20 @@
1
1
  /* eslint-disable tsdoc/syntax */
2
- import { AbortSilentError } from './error.js';
3
- import { collectLog, consoleError, consoleLog, outputDebug, outputWhereAppropriate } from './output.js';
2
+ import { AbortError, AbortSilentError, FatalErrorType } from './error.js';
3
+ import { collectLog, consoleError, consoleLog, outputContent, outputDebug, outputToken, outputWhereAppropriate, } from './output.js';
4
4
  import { isUnitTest } from './context/local.js';
5
- import { AbortController } from './abort.js';
6
5
  import { terminalSupportsRawMode } from './system.js';
6
+ import { AbortController } from './abort.js';
7
7
  import { ConcurrentOutput } from '../../private/node/ui/components/ConcurrentOutput.js';
8
8
  import { render, renderOnce } from '../../private/node/ui.js';
9
9
  import { alert } from '../../private/node/ui/alert.js';
10
10
  import { FatalError } from '../../private/node/ui/components/FatalError.js';
11
11
  import { Table } from '../../private/node/ui/components/Table/Table.js';
12
+ import { tokenItemToString, } from '../../private/node/ui/components/TokenizedText.js';
12
13
  import { SelectPrompt } from '../../private/node/ui/components/SelectPrompt.js';
13
14
  import { Tasks } from '../../private/node/ui/components/Tasks.js';
14
15
  import { TextPrompt } from '../../private/node/ui/components/TextPrompt.js';
15
16
  import { AutocompletePrompt } from '../../private/node/ui/components/AutocompletePrompt.js';
17
+ import { recordUIEvent, resetRecordedSleep } from '../../private/node/demo-recorder.js';
16
18
  import React from 'react';
17
19
  /**
18
20
  * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.
@@ -31,19 +33,16 @@ import React from 'react';
31
33
  *
32
34
  */
33
35
  export async function renderConcurrent({ renderOptions, ...props }) {
34
- const newProps = {
35
- abortController: new AbortController(),
36
- ...props,
37
- };
36
+ const abortSignal = props.abortSignal ?? new AbortController().signal;
38
37
  if (terminalSupportsRawMode(renderOptions?.stdin)) {
39
- return render(React.createElement(ConcurrentOutput, { ...newProps }), {
38
+ return render(React.createElement(ConcurrentOutput, { ...props, abortSignal: abortSignal }), {
40
39
  ...renderOptions,
41
40
  exitOnCtrlC: typeof props.onInput === 'undefined',
42
41
  });
43
42
  }
44
43
  else {
45
- return Promise.all(newProps.processes.map(async (concurrentProcess) => {
46
- await concurrentProcess.action(process.stdout, process.stderr, newProps.abortController.signal);
44
+ return Promise.all(props.processes.map(async (concurrentProcess) => {
45
+ await concurrentProcess.action(process.stdout, process.stderr, abortSignal);
47
46
  }));
48
47
  }
49
48
  }
@@ -52,7 +51,7 @@ export async function renderConcurrent({ renderOptions, ...props }) {
52
51
  * @example Basic
53
52
  * ╭─ info ───────────────────────────────────────────────────╮
54
53
  * │ │
55
- * │ CLI update available
54
+ * │ CLI update available.
56
55
  * │ │
57
56
  * │ Run `npm run shopify upgrade`. │
58
57
  * │ │
@@ -178,12 +177,24 @@ export function renderWarning(options) {
178
177
  * │ • Need to connect to a different App or │
179
178
  * │ organization? Run the command again with `--reset` │
180
179
  * │ │
180
+ * │ amortizable-marketplace-ext │
181
+ * │ • Some other error │
182
+ * │ Validation errors │
183
+ * │ • Missing expected key(s). │
184
+ * │ │
185
+ * │ amortizable-marketplace-ext-2 │
186
+ * │ • Something was not found │
187
+ * │ │
181
188
  * ╰──────────────────────────────────────────────────────────╯
182
189
  * [1] https://partners.shopify.com/signup
183
190
  *
184
191
  */
185
192
  // eslint-disable-next-line max-params
186
193
  export function renderFatalError(error, { renderOptions } = {}) {
194
+ recordUIEvent({
195
+ type: 'fatalError',
196
+ properties: { ...error, errorType: error.type === FatalErrorType.Bug ? 'bug' : 'abort' },
197
+ });
187
198
  return renderOnce(React.createElement(FatalError, { error: error }), { logLevel: 'error', logger: consoleError, renderOptions });
188
199
  }
189
200
  /**
@@ -215,13 +226,19 @@ export function renderFatalError(error, { renderOptions } = {}) {
215
226
  * Press ↑↓ arrows to select, enter to confirm
216
227
  *
217
228
  */
218
- export function renderSelectPrompt({ renderOptions, ...props }) {
229
+ export async function renderSelectPrompt({ renderOptions, isConfirmationPrompt, ...props }) {
230
+ throwInNonTTY({ message: props.message, stdin: renderOptions?.stdin });
231
+ if (!isConfirmationPrompt) {
232
+ recordUIEvent({ type: 'selectPrompt', properties: { renderOptions, ...props } });
233
+ }
219
234
  // eslint-disable-next-line max-params
220
235
  return new Promise((resolve, reject) => {
221
236
  render(React.createElement(SelectPrompt, { ...props, onSubmit: (value) => resolve(value) }), {
222
237
  ...renderOptions,
223
238
  exitOnCtrlC: false,
224
- }).catch(reject);
239
+ })
240
+ .catch(reject)
241
+ .finally(resetRecordedSleep);
225
242
  });
226
243
  }
227
244
  /**
@@ -238,7 +255,9 @@ export function renderSelectPrompt({ renderOptions, ...props }) {
238
255
  * Press ↑↓ arrows to select, enter or a shortcut to confirm
239
256
  *
240
257
  */
241
- export function renderConfirmationPrompt({ message, infoTable, confirmationMessage = 'Yes, confirm', cancellationMessage = 'No, cancel', renderOptions, defaultValue = true, }) {
258
+ export async function renderConfirmationPrompt({ message, infoTable, confirmationMessage = 'Yes, confirm', cancellationMessage = 'No, cancel', renderOptions, defaultValue = true, abortSignal, }) {
259
+ // eslint-disable-next-line prefer-rest-params
260
+ recordUIEvent({ type: 'confirmationPrompt', properties: arguments[0] });
242
261
  const choices = [
243
262
  {
244
263
  label: confirmationMessage,
@@ -258,6 +277,8 @@ export function renderConfirmationPrompt({ message, infoTable, confirmationMessa
258
277
  submitWithShortcuts: true,
259
278
  renderOptions,
260
279
  defaultValue,
280
+ isConfirmationPrompt: true,
281
+ abortSignal,
261
282
  });
262
283
  }
263
284
  /**
@@ -294,7 +315,10 @@ export function renderConfirmationPrompt({ message, infoTable, confirmationMessa
294
315
  * Press ↑↓ arrows to select, enter to confirm
295
316
  *
296
317
  */
297
- export function renderAutocompletePrompt({ renderOptions, ...props }) {
318
+ export async function renderAutocompletePrompt({ renderOptions, ...props }) {
319
+ throwInNonTTY({ message: props.message, stdin: renderOptions?.stdin });
320
+ // eslint-disable-next-line prefer-rest-params
321
+ recordUIEvent({ type: 'autocompletePrompt', properties: arguments[0] });
298
322
  const newProps = {
299
323
  search(term) {
300
324
  return Promise.resolve({
@@ -308,7 +332,9 @@ export function renderAutocompletePrompt({ renderOptions, ...props }) {
308
332
  render(React.createElement(AutocompletePrompt, { ...newProps, onSubmit: (value) => resolve(value) }), {
309
333
  ...renderOptions,
310
334
  exitOnCtrlC: false,
311
- }).catch(reject);
335
+ })
336
+ .catch(reject)
337
+ .finally(resetRecordedSleep);
312
338
  });
313
339
  }
314
340
  /**
@@ -321,6 +347,8 @@ export function renderAutocompletePrompt({ renderOptions, ...props }) {
321
347
  * 3 John Smith jon@smith.com
322
348
  */
323
349
  export function renderTable({ renderOptions, ...props }) {
350
+ // eslint-disable-next-line prefer-rest-params
351
+ recordUIEvent({ type: 'table', properties: arguments[0] });
324
352
  return renderOnce(React.createElement(Table, { ...props }), { renderOptions });
325
353
  }
326
354
  /**
@@ -331,12 +359,24 @@ export function renderTable({ renderOptions, ...props }) {
331
359
  */
332
360
  // eslint-disable-next-line max-params
333
361
  export async function renderTasks(tasks, { renderOptions } = {}) {
362
+ recordUIEvent({
363
+ type: 'taskbar',
364
+ properties: {
365
+ // Rather than timing exactly, pretend each step takes 2 seconds. This
366
+ // should be easy to tweak manually.
367
+ steps: tasks.map((task) => {
368
+ return { title: task.title, duration: 2 };
369
+ }),
370
+ },
371
+ });
334
372
  // eslint-disable-next-line max-params
335
373
  return new Promise((resolve, reject) => {
336
374
  render(React.createElement(Tasks, { tasks: tasks, onComplete: resolve }), {
337
375
  ...renderOptions,
338
376
  exitOnCtrlC: false,
339
- }).catch(reject);
377
+ })
378
+ .then(() => resetRecordedSleep())
379
+ .catch(reject);
340
380
  });
341
381
  }
342
382
  /**
@@ -347,13 +387,18 @@ export async function renderTasks(tasks, { renderOptions } = {}) {
347
387
  * ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
348
388
  *
349
389
  */
350
- export function renderTextPrompt({ renderOptions, ...props }) {
390
+ export async function renderTextPrompt({ renderOptions, ...props }) {
391
+ throwInNonTTY({ message: props.message, stdin: renderOptions?.stdin });
392
+ // eslint-disable-next-line prefer-rest-params
393
+ recordUIEvent({ type: 'textPrompt', properties: arguments[0] });
351
394
  // eslint-disable-next-line max-params
352
395
  return new Promise((resolve, reject) => {
353
396
  render(React.createElement(TextPrompt, { ...props, onSubmit: (value) => resolve(value) }), {
354
397
  ...renderOptions,
355
398
  exitOnCtrlC: false,
356
- }).catch(reject);
399
+ })
400
+ .catch(reject)
401
+ .finally(resetRecordedSleep);
357
402
  });
358
403
  }
359
404
  /** Renders a text string to the console.
@@ -390,4 +435,15 @@ export const keypress = async () => {
390
435
  process.stdin.once('data', handler);
391
436
  });
392
437
  };
438
+ function throwInNonTTY({ message, stdin }) {
439
+ if (stdin || terminalSupportsRawMode())
440
+ return;
441
+ const promptText = tokenItemToString(message);
442
+ const errorMessage = `Failed to prompt:
443
+
444
+ ${outputContent `${outputToken.cyan(promptText)}`.value}
445
+
446
+ This usually happens when running a command non-interactively, for example in a CI environment, or when piping input from another process.`;
447
+ throw new AbortError(errorMessage, 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.');
448
+ }
393
449
  //# sourceMappingURL=ui.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,EAAC,gBAAgB,EAAsB,MAAM,YAAY,CAAA;AAChE,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,UAAU,EAAoB,WAAW,EAAE,sBAAsB,EAAC,MAAM,aAAa,CAAA;AACvH,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAC,uBAAuB,EAAC,MAAM,aAAa,CAAA;AACnD,OAAO,EAAC,gBAAgB,EAAwB,MAAM,sDAAsD,CAAA;AAC5G,OAAO,EAAC,MAAM,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAC,KAAK,EAAe,MAAM,gCAAgC,CAAA;AAElE,OAAO,EAAC,UAAU,EAAC,MAAM,gDAAgD,CAAA;AAEzE,OAAO,EAAC,KAAK,EAA0B,MAAM,iDAAiD,CAAA;AAC9F,OAAO,EAAC,YAAY,EAAoB,MAAM,kDAAkD,CAAA;AAChG,OAAO,EAAC,KAAK,EAAO,MAAM,2CAA2C,CAAA;AACrE,OAAO,EAAC,UAAU,EAAkB,MAAM,gDAAgD,CAAA;AAC1F,OAAO,EAA0B,kBAAkB,EAAC,MAAM,wDAAwD,CAAA;AAGlH,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB;;;;;;;;;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,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;YAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;YAErB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAEhC,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;gBAClC,WAAW,CAAC,wCAAwC,CAAC,CAAA;gBACrD,MAAM,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAA;aAC/B;YACD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC3B,CAAC,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAA;QACtB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["/* eslint-disable tsdoc/syntax */\nimport {AbortSilentError, FatalError as Fatal} from './error.js'\nimport {collectLog, consoleError, consoleLog, Logger, LogLevel, outputDebug, outputWhereAppropriate} from './output.js'\nimport {isUnitTest} from './context/local.js'\nimport {AbortController} from './abort.js'\nimport {terminalSupportsRawMode} from './system.js'\nimport {ConcurrentOutput, ConcurrentOutputProps} from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {render, renderOnce} from '../../private/node/ui.js'\nimport {alert, AlertOptions} from '../../private/node/ui/alert.js'\nimport {CustomSection} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js'\nimport {Table, TableColumn, TableProps} from '../../private/node/ui/components/Table/Table.js'\nimport {SelectPrompt, SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {TextPrompt, TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport {AutocompletePromptProps, AutocompletePrompt} from '../../private/node/ui/components/AutocompletePrompt.js'\nimport {InlineToken, LinkToken, TokenItem} from '../../private/node/ui/components/TokenizedText.js'\nimport {InfoTableSection} from '../../private/node/ui/components/Prompts/InfoTable.js'\nimport React from 'react'\nimport {Key as InkKey, RenderOptions} from 'ink'\n\ntype PartialBy<T, TKey extends keyof T> = Omit<T, TKey> & Partial<Pick<T, TKey>>\n\nexport interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps, 'abortController'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n * @example\n * 0000-00-00 00:00:00 │ backend │ first backend message\n * 0000-00-00 00:00:00 │ backend │ second backend message\n * 0000-00-00 00:00:00 │ backend │ third backend message\n * 0000-00-00 00:00:00 │ frontend │ first frontend message\n * 0000-00-00 00:00:00 │ frontend │ second frontend message\n * 0000-00-00 00:00:00 │ frontend │ third frontend message\n *\n * › Press p │ preview in your browser\n * › Press q │ quit.\n *\n * Preview URL: https://shopify.com\n *\n */\nexport async function renderConcurrent({renderOptions, ...props}: RenderConcurrentOptions) {\n const newProps = {\n abortController: new AbortController(),\n ...props,\n }\n if (terminalSupportsRawMode(renderOptions?.stdin)) {\n return render(<ConcurrentOutput {...newProps} />, {\n ...renderOptions,\n exitOnCtrlC: typeof props.onInput === 'undefined',\n })\n } else {\n return Promise.all(\n newProps.processes.map(async (concurrentProcess) => {\n await concurrentProcess.action(process.stdout, process.stderr, newProps.abortController.signal)\n }),\n )\n }\n}\n\nexport type AlertCustomSection = CustomSection\nexport type RenderAlertOptions = Omit<AlertOptions, 'type'>\n\n/**\n * Renders an information banner to the console.\n * @example Basic\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ CLI update available │\n * │ │\n * │ Run `npm run shopify upgrade`. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ my-app initialized and ready to build. │\n * │ │\n * │ Next steps │\n * │ • Run `cd verification-app` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Dev docs [1] │\n * │ │\n * │ Custom section │\n * │ • Item 1 [2] │\n * │ • Item 2 │\n * │ • Item 3 [3] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://shopify.dev\n * [2] https://www.google.com/search?q=jh56t9l34kpo35tw8s28hn7s\n * 9s2xvzla01d8cn6j7yq&rlz=1C1GCEU_enUS832US832&oq=jh56t9l34kpo\n * 35tw8s28hn7s9s2xvzla01d8cn6j7yq&aqs=chrome.0.35i39l2j0l4j46j\n * 69i60.2711j0j7&sourceid=chrome&ie=UTF-8\n * [3] https://shopify.com\n *\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n * @example Basic\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ CLI updated. │\n * │ │\n * │ You are now running version 3.47. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Deployment successful. │\n * │ │\n * │ Your extensions have been uploaded to your Shopify │\n * │ Partners Dashboard. │\n * │ │\n * │ Next steps │\n * │ • See your deployment and set it live [1] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://partners.shopify.com/1797046/apps/4523695/deploy\n * ments\n *\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n * @example Basic\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ You have reached your limit of checkout extensions for │\n * │ this app. │\n * │ │\n * │ You can free up space for a new one by deleting an │\n * │ existing one. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Required access scope update. │\n * │ │\n * │ The deadline for re-selecting your app scopes is May │\n * │ 1, 2022. │\n * │ │\n * │ Reference │\n * │ • Dev docs [1] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://shopify.dev/app/scopes\n *\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\ninterface RenderFatalErrorOptions {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n * @example Basic\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Something went wrong. │\n * │ │\n * │ To investigate the issue, examine this stack trace: │\n * │ at _compile (internal/modules/cjs/loader.js:1137) │\n * │ at js (internal/modules/cjs/loader.js:1157) │\n * │ at load (internal/modules/cjs/loader.js:985) │\n * │ at _load (internal/modules/cjs/loader.js:878) │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ No Organization found │\n * │ │\n * │ Next steps │\n * │ • Have you created a Shopify Partners organization │\n * │ [1]? │\n * │ • Have you confirmed your accounts from the emails │\n * │ you received? │\n * │ • Need to connect to a different App or │\n * │ organization? Run the command again with `--reset` │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://partners.shopify.com/signup\n *\n */\n// eslint-disable-next-line max-params\nexport function renderFatalError(error: Fatal, {renderOptions}: RenderFatalErrorOptions = {}) {\n return renderOnce(<FatalError error={error} />, {logLevel: 'error', logger: consoleError, renderOptions})\n}\n\nexport interface RenderSeletPromptOptions<T> extends Omit<SelectPromptProps<T>, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a select prompt to the console.\n * @example\n * ? Associate your project with the org Castile Ventures?\n *\n * Add: • new-ext\n *\n * Remove: • integrated-demand-ext\n * • order-discount\n *\n * Automations\n * > (a) fifth\n * (2) sixth\n *\n * Merchant Admin\n * (3) eighth\n * (4) ninth\n *\n * Other\n * (f) first\n * (s) second\n * (7) third\n * (8) fourth\n * (9) seventh\n * (10) tenth\n *\n * Press ↑↓ arrows to select, enter to confirm\n *\n */\nexport function renderSelectPrompt<T>({renderOptions, ...props}: RenderSeletPromptOptions<T>): Promise<T> {\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<SelectPrompt {...props} onSubmit={(value: T) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\nexport interface RenderConfirmationPromptOptions extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable'> {\n confirmationMessage?: string\n cancellationMessage?: string\n renderOptions?: RenderOptions\n defaultValue?: boolean\n}\n\n/**\n * Renders a confirmation prompt to the console.\n * @example\n * ? Delete the following themes from the store?\n *\n * • first theme (#1)\n * • second theme (#2)\n *\n * > (y) Yes, confirm changes\n * (n) Cancel\n *\n * Press ↑↓ arrows to select, enter or a shortcut to confirm\n *\n */\nexport function renderConfirmationPrompt({\n message,\n infoTable,\n confirmationMessage = 'Yes, confirm',\n cancellationMessage = 'No, cancel',\n renderOptions,\n defaultValue = true,\n}: RenderConfirmationPromptOptions): Promise<boolean> {\n const choices = [\n {\n label: confirmationMessage,\n value: true,\n key: 'y',\n },\n {\n label: cancellationMessage,\n value: false,\n key: 'n',\n },\n ]\n\n return renderSelectPrompt({\n choices,\n message,\n infoTable,\n submitWithShortcuts: true,\n renderOptions,\n defaultValue,\n })\n}\n\nexport interface RenderAutocompleteOptions<T>\n extends PartialBy<Omit<AutocompletePromptProps<T>, 'onSubmit'>, 'search'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders an autocomplete prompt to the console.\n * @example\n * ? Select a template: Type to search...\n *\n * > first\n * second\n * third\n * fourth\n * fifth\n * sixth\n * seventh\n * eighth\n * ninth\n * tenth\n * eleventh\n * twelfth\n * thirteenth\n * fourteenth\n * fifteenth\n * sixteenth\n * seventeenth\n * eighteenth\n * nineteenth\n * twentieth\n * twenty-first\n * twenty-second\n * twenty-third\n * twenty-fourth\n * twenty-fifth\n *\n * Press ↑↓ arrows to select, enter to confirm\n *\n */\nexport function renderAutocompletePrompt<T>({renderOptions, ...props}: RenderAutocompleteOptions<T>): Promise<T> {\n const newProps = {\n search(term: string) {\n return Promise.resolve({\n data: props.choices.filter((item) => item.label.toLowerCase().includes(term.toLowerCase())),\n })\n },\n ...props,\n }\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<AutocompletePrompt {...newProps} onSubmit={(value: T) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\ninterface RenderTableOptions<T extends ScalarDict> extends TableProps<T> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a table to the console.\n * @example\n * ID Name email\n * ── ────────── ─────────────\n * 1 John Doe jon@doe.com\n * 2 Jane Doe jane@doe.com\n * 3 John Smith jon@smith.com\n */\nexport function renderTable<T extends ScalarDict>({renderOptions, ...props}: RenderTableOptions<T>) {\n return renderOnce(<Table {...props} />, {renderOptions})\n}\n\ninterface RenderTasksOptions {\n renderOptions?: RenderOptions\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n * @example\n * ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀\n * Installing dependencies ...\n */\n// eslint-disable-next-line max-params\nexport async function renderTasks<TContext>(tasks: Task<TContext>[], {renderOptions}: RenderTasksOptions = {}) {\n // eslint-disable-next-line max-params\n return new Promise<TContext>((resolve, reject) => {\n render(<Tasks tasks={tasks} onComplete={resolve} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\nexport interface RenderTextPromptOptions extends Omit<TextPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a text prompt to the console.\n * @example\n * ? App project name (can be changed later):\n * > expansive commerce app\n * ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n *\n */\nexport function renderTextPrompt({renderOptions, ...props}: RenderTextPromptOptions): Promise<string> {\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<TextPrompt {...props} onSubmit={(value: string) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n }).catch(reject)\n })\n}\n\ninterface RenderTextOptions {\n text: string\n logLevel?: LogLevel\n logger?: Logger\n}\n\n/** Renders a text string to the console.\n * Using this function makes sure that correct spacing is applied among the various components.\n * @example\n * Hello world!\n *\n */\nexport function renderText({text, logLevel = 'info', logger = consoleLog}: RenderTextOptions) {\n let textWithLineReturn = text\n if (!text.endsWith('\\n')) textWithLineReturn += '\\n'\n\n if (isUnitTest()) collectLog(logLevel, textWithLineReturn)\n outputWhereAppropriate(logLevel, logger, textWithLineReturn)\n return textWithLineReturn\n}\n\n/** Waits for any key to be pressed except Ctrl+C which will terminate the process. */\nexport const keypress = async () => {\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n process.stdin.setRawMode(false)\n process.stdin.pause()\n\n const bytes = Array.from(buffer)\n\n if (bytes.length && bytes[0] === 3) {\n outputDebug('Canceled keypress, User pressed CTRL+C')\n reject(new AbortSilentError())\n }\n process.nextTick(resolve)\n }\n\n process.stdin.resume()\n process.stdin.setRawMode(true)\n process.stdin.once('data', handler)\n })\n}\n\nexport type Key = InkKey\nexport {Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,iCAAiC;A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CAAA;AACH,CAAC","sourcesContent":["/* eslint-disable tsdoc/syntax */\nimport {AbortError, AbortSilentError, FatalError as Fatal, FatalErrorType} from './error.js'\nimport {\n collectLog,\n consoleError,\n consoleLog,\n Logger,\n LogLevel,\n outputContent,\n outputDebug,\n outputToken,\n outputWhereAppropriate,\n} from './output.js'\nimport {isUnitTest} from './context/local.js'\nimport {terminalSupportsRawMode} from './system.js'\nimport {AbortController} from './abort.js'\nimport {ConcurrentOutput, ConcurrentOutputProps} from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {render, renderOnce} from '../../private/node/ui.js'\nimport {alert, AlertOptions} from '../../private/node/ui/alert.js'\nimport {CustomSection} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js'\nimport {Table, TableColumn, TableProps} from '../../private/node/ui/components/Table/Table.js'\nimport {\n tokenItemToString,\n InlineToken,\n LinkToken,\n ListToken,\n TokenItem,\n} from '../../private/node/ui/components/TokenizedText.js'\nimport {SelectPrompt, SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {TextPrompt, TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport {AutocompletePromptProps, AutocompletePrompt} from '../../private/node/ui/components/AutocompletePrompt.js'\nimport {InfoTableSection} from '../../private/node/ui/components/Prompts/InfoTable.js'\nimport {recordUIEvent, resetRecordedSleep} from '../../private/node/demo-recorder.js'\nimport React from 'react'\nimport {Key as InkKey, RenderOptions} from 'ink'\n\ntype PartialBy<T, TKey extends keyof T> = Omit<T, TKey> & Partial<Pick<T, TKey>>\n\nexport interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps, 'abortSignal'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n * @example\n * 0000-00-00 00:00:00 │ backend │ first backend message\n * 0000-00-00 00:00:00 │ backend │ second backend message\n * 0000-00-00 00:00:00 │ backend │ third backend message\n * 0000-00-00 00:00:00 │ frontend │ first frontend message\n * 0000-00-00 00:00:00 │ frontend │ second frontend message\n * 0000-00-00 00:00:00 │ frontend │ third frontend message\n *\n * › Press p │ preview in your browser\n * › Press q │ quit.\n *\n * Preview URL: https://shopify.com\n *\n */\nexport async function renderConcurrent({renderOptions, ...props}: RenderConcurrentOptions) {\n const abortSignal = props.abortSignal ?? new AbortController().signal\n\n if (terminalSupportsRawMode(renderOptions?.stdin)) {\n return render(<ConcurrentOutput {...props} abortSignal={abortSignal} />, {\n ...renderOptions,\n exitOnCtrlC: typeof props.onInput === 'undefined',\n })\n } else {\n return Promise.all(\n props.processes.map(async (concurrentProcess) => {\n await concurrentProcess.action(process.stdout, process.stderr, abortSignal)\n }),\n )\n }\n}\n\nexport type AlertCustomSection = CustomSection\nexport type RenderAlertOptions = Omit<AlertOptions, 'type'>\n\n/**\n * Renders an information banner to the console.\n * @example Basic\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ CLI update available. │\n * │ │\n * │ Run `npm run shopify upgrade`. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ my-app initialized and ready to build. │\n * │ │\n * │ Next steps │\n * │ • Run `cd verification-app` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Dev docs [1] │\n * │ │\n * │ Custom section │\n * │ • Item 1 [2] │\n * │ • Item 2 │\n * │ • Item 3 [3] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://shopify.dev\n * [2] https://www.google.com/search?q=jh56t9l34kpo35tw8s28hn7s\n * 9s2xvzla01d8cn6j7yq&rlz=1C1GCEU_enUS832US832&oq=jh56t9l34kpo\n * 35tw8s28hn7s9s2xvzla01d8cn6j7yq&aqs=chrome.0.35i39l2j0l4j46j\n * 69i60.2711j0j7&sourceid=chrome&ie=UTF-8\n * [3] https://shopify.com\n *\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n * @example Basic\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ CLI updated. │\n * │ │\n * │ You are now running version 3.47. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Deployment successful. │\n * │ │\n * │ Your extensions have been uploaded to your Shopify │\n * │ Partners Dashboard. │\n * │ │\n * │ Next steps │\n * │ • See your deployment and set it live [1] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://partners.shopify.com/1797046/apps/4523695/deploy\n * ments\n *\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n * @example Basic\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ You have reached your limit of checkout extensions for │\n * │ this app. │\n * │ │\n * │ You can free up space for a new one by deleting an │\n * │ existing one. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Required access scope update. │\n * │ │\n * │ The deadline for re-selecting your app scopes is May │\n * │ 1, 2022. │\n * │ │\n * │ Reference │\n * │ • Dev docs [1] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://shopify.dev/app/scopes\n *\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\ninterface RenderFatalErrorOptions {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n * @example Basic\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Something went wrong. │\n * │ │\n * │ To investigate the issue, examine this stack trace: │\n * │ at _compile (internal/modules/cjs/loader.js:1137) │\n * │ at js (internal/modules/cjs/loader.js:1157) │\n * │ at load (internal/modules/cjs/loader.js:985) │\n * │ at _load (internal/modules/cjs/loader.js:878) │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ No Organization found │\n * │ │\n * │ Next steps │\n * │ • Have you created a Shopify Partners organization │\n * │ [1]? │\n * │ • Have you confirmed your accounts from the emails │\n * │ you received? │\n * │ • Need to connect to a different App or │\n * │ organization? Run the command again with `--reset` │\n * │ │\n * │ amortizable-marketplace-ext │\n * │ • Some other error │\n * │ Validation errors │\n * │ • Missing expected key(s). │\n * │ │\n * │ amortizable-marketplace-ext-2 │\n * │ • Something was not found │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://partners.shopify.com/signup\n *\n */\n// eslint-disable-next-line max-params\nexport function renderFatalError(error: Fatal, {renderOptions}: RenderFatalErrorOptions = {}) {\n recordUIEvent({\n type: 'fatalError',\n properties: {...error, errorType: error.type === FatalErrorType.Bug ? 'bug' : 'abort'},\n })\n\n return renderOnce(<FatalError error={error} />, {logLevel: 'error', logger: consoleError, renderOptions})\n}\n\nexport interface RenderSelectPromptOptions<T> extends Omit<SelectPromptProps<T>, 'onSubmit'> {\n isConfirmationPrompt?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a select prompt to the console.\n * @example\n * ? Associate your project with the org Castile Ventures?\n *\n * Add: • new-ext\n *\n * Remove: • integrated-demand-ext\n * • order-discount\n *\n * Automations\n * > (a) fifth\n * (2) sixth\n *\n * Merchant Admin\n * (3) eighth\n * (4) ninth\n *\n * Other\n * (f) first\n * (s) second\n * (7) third\n * (8) fourth\n * (9) seventh\n * (10) tenth\n *\n * Press ↑↓ arrows to select, enter to confirm\n *\n */\nexport async function renderSelectPrompt<T>({\n renderOptions,\n isConfirmationPrompt,\n ...props\n}: RenderSelectPromptOptions<T>): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n if (!isConfirmationPrompt) {\n recordUIEvent({type: 'selectPrompt', properties: {renderOptions, ...props}})\n }\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<SelectPrompt {...props} onSubmit={(value: T) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\nexport interface RenderConfirmationPromptOptions\n extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable' | 'abortSignal'> {\n confirmationMessage?: string\n cancellationMessage?: string\n renderOptions?: RenderOptions\n defaultValue?: boolean\n}\n\n/**\n * Renders a confirmation prompt to the console.\n * @example\n * ? Delete the following themes from the store?\n *\n * • first theme (#1)\n * • second theme (#2)\n *\n * > (y) Yes, confirm changes\n * (n) Cancel\n *\n * Press ↑↓ arrows to select, enter or a shortcut to confirm\n *\n */\nexport async function renderConfirmationPrompt({\n message,\n infoTable,\n confirmationMessage = 'Yes, confirm',\n cancellationMessage = 'No, cancel',\n renderOptions,\n defaultValue = true,\n abortSignal,\n}: RenderConfirmationPromptOptions): Promise<boolean> {\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'confirmationPrompt', properties: arguments[0]})\n\n const choices = [\n {\n label: confirmationMessage,\n value: true,\n key: 'y',\n },\n {\n label: cancellationMessage,\n value: false,\n key: 'n',\n },\n ]\n\n return renderSelectPrompt({\n choices,\n message,\n infoTable,\n submitWithShortcuts: true,\n renderOptions,\n defaultValue,\n isConfirmationPrompt: true,\n abortSignal,\n })\n}\n\nexport interface RenderAutocompleteOptions<T>\n extends PartialBy<Omit<AutocompletePromptProps<T>, 'onSubmit'>, 'search'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders an autocomplete prompt to the console.\n * @example\n * ? Select a template: Type to search...\n *\n * > first\n * second\n * third\n * fourth\n * fifth\n * sixth\n * seventh\n * eighth\n * ninth\n * tenth\n * eleventh\n * twelfth\n * thirteenth\n * fourteenth\n * fifteenth\n * sixteenth\n * seventeenth\n * eighteenth\n * nineteenth\n * twentieth\n * twenty-first\n * twenty-second\n * twenty-third\n * twenty-fourth\n * twenty-fifth\n *\n * Press ↑↓ arrows to select, enter to confirm\n *\n */\nexport async function renderAutocompletePrompt<T>({renderOptions, ...props}: RenderAutocompleteOptions<T>): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'autocompletePrompt', properties: arguments[0]})\n\n const newProps = {\n search(term: string) {\n return Promise.resolve({\n data: props.choices.filter((item) => item.label.toLowerCase().includes(term.toLowerCase())),\n })\n },\n ...props,\n }\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<AutocompletePrompt {...newProps} onSubmit={(value: T) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\ninterface RenderTableOptions<T extends ScalarDict> extends TableProps<T> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a table to the console.\n * @example\n * ID Name email\n * ── ────────── ─────────────\n * 1 John Doe jon@doe.com\n * 2 Jane Doe jane@doe.com\n * 3 John Smith jon@smith.com\n */\nexport function renderTable<T extends ScalarDict>({renderOptions, ...props}: RenderTableOptions<T>) {\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'table', properties: arguments[0]})\n\n return renderOnce(<Table {...props} />, {renderOptions})\n}\n\ninterface RenderTasksOptions {\n renderOptions?: RenderOptions\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n * @example\n * ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀\n * Installing dependencies ...\n */\n// eslint-disable-next-line max-params\nexport async function renderTasks<TContext>(tasks: Task<TContext>[], {renderOptions}: RenderTasksOptions = {}) {\n recordUIEvent({\n type: 'taskbar',\n properties: {\n // Rather than timing exactly, pretend each step takes 2 seconds. This\n // should be easy to tweak manually.\n steps: tasks.map((task) => {\n return {title: task.title, duration: 2}\n }),\n },\n })\n\n // eslint-disable-next-line max-params\n return new Promise<TContext>((resolve, reject) => {\n render(<Tasks tasks={tasks} onComplete={resolve} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .then(() => resetRecordedSleep())\n .catch(reject)\n })\n}\n\nexport interface RenderTextPromptOptions extends Omit<TextPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a text prompt to the console.\n * @example\n * ? App project name (can be changed later):\n * > expansive commerce app\n * ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n *\n */\nexport async function renderTextPrompt({renderOptions, ...props}: RenderTextPromptOptions): Promise<string> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'textPrompt', properties: arguments[0]})\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<TextPrompt {...props} onSubmit={(value: string) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\ninterface RenderTextOptions {\n text: string\n logLevel?: LogLevel\n logger?: Logger\n}\n\n/** Renders a text string to the console.\n * Using this function makes sure that correct spacing is applied among the various components.\n * @example\n * Hello world!\n *\n */\nexport function renderText({text, logLevel = 'info', logger = consoleLog}: RenderTextOptions) {\n let textWithLineReturn = text\n if (!text.endsWith('\\n')) textWithLineReturn += '\\n'\n\n if (isUnitTest()) collectLog(logLevel, textWithLineReturn)\n outputWhereAppropriate(logLevel, logger, textWithLineReturn)\n return textWithLineReturn\n}\n\n/** Waits for any key to be pressed except Ctrl+C which will terminate the process. */\nexport const keypress = async () => {\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n process.stdin.setRawMode(false)\n process.stdin.pause()\n\n const bytes = Array.from(buffer)\n\n if (bytes.length && bytes[0] === 3) {\n outputDebug('Canceled keypress, User pressed CTRL+C')\n reject(new AbortSilentError())\n }\n process.nextTick(resolve)\n }\n\n process.stdin.resume()\n process.stdin.setRawMode(true)\n process.stdin.once('data', handler)\n })\n}\n\ninterface ThrowInNonTTYOptions {\n message: TokenItem\n stdin?: NodeJS.ReadStream\n}\n\nfunction throwInNonTTY({message, stdin}: ThrowInNonTTYOptions) {\n if (stdin || terminalSupportsRawMode()) return\n\n const promptText = tokenItemToString(message)\n const errorMessage = `Failed to prompt:\n\n${outputContent`${outputToken.cyan(promptText)}`.value}\n\nThis usually happens when running a command non-interactively, for example in a CI environment, or when piping input from another process.`\n throw new AbortError(\n errorMessage,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n}\n\nexport type Key = InkKey\nexport {Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken}\n"]}