@shopify/cli-kit 3.70.0 → 3.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/api/graphql/admin/generated/theme_files_upsert.d.ts +21 -0
- package/dist/cli/api/graphql/admin/generated/theme_files_upsert.js +82 -0
- package/dist/cli/api/graphql/admin/generated/theme_files_upsert.js.map +1 -0
- package/dist/private/node/api.d.ts +1 -1
- package/dist/private/node/api.js +30 -2
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/constants.d.ts +2 -0
- package/dist/private/node/constants.js +2 -0
- package/dist/private/node/constants.js.map +1 -1
- package/dist/private/node/session/exchange.js +2 -2
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/session/scopes.js +3 -5
- package/dist/private/node/session/scopes.js.map +1 -1
- package/dist/private/node/session.js +2 -3
- package/dist/private/node/session.js.map +1 -1
- package/dist/private/node/ui/alert.js +1 -3
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.js +0 -2
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/Link.js +3 -0
- package/dist/private/node/ui/components/Link.js.map +1 -1
- package/dist/private/node/ui/components/Link.test.js +23 -0
- package/dist/private/node/ui/components/Link.test.js.map +1 -1
- package/dist/private/node/ui.js +1 -1
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/admin.js +11 -1
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/graphql.d.ts +2 -0
- package/dist/public/node/api/graphql.js +2 -2
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/api/webhooks.d.ts +13 -0
- package/dist/public/node/api/webhooks.js +34 -0
- package/dist/public/node/api/webhooks.js.map +1 -0
- package/dist/public/node/cli-launcher.d.ts +12 -0
- package/dist/public/node/cli-launcher.js +29 -0
- package/dist/public/node/cli-launcher.js.map +1 -0
- package/dist/public/node/cli.d.ts +12 -10
- package/dist/public/node/cli.js +38 -100
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/context/fqdn.js +11 -7
- package/dist/public/node/context/fqdn.js.map +1 -1
- package/dist/public/node/context/local.d.ts +7 -0
- package/dist/public/node/context/local.js +9 -0
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/environment.d.ts +7 -0
- package/dist/public/node/environment.js +11 -0
- package/dist/public/node/environment.js.map +1 -1
- package/dist/public/node/error-handler.js +1 -3
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/hooks/prerun.js +0 -2
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/public/node/json-schema.d.ts +2 -1
- package/dist/public/node/json-schema.js +8 -3
- package/dist/public/node/json-schema.js.map +1 -1
- package/dist/public/node/notifications-system.d.ts +3 -1
- package/dist/public/node/notifications-system.js +9 -1
- package/dist/public/node/notifications-system.js.map +1 -1
- package/dist/public/node/output.d.ts +1 -6
- package/dist/public/node/output.js +1 -5
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/path.d.ts +3 -3
- package/dist/public/node/path.js +4 -5
- package/dist/public/node/path.js.map +1 -1
- package/dist/public/node/system.js +14 -2
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/themes/api.js +67 -8
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/public/node/themes/factories.d.ts +1 -3
- package/dist/public/node/themes/factories.js +0 -16
- package/dist/public/node/themes/factories.js.map +1 -1
- package/dist/public/node/tree-kill.js +0 -2
- package/dist/public/node/tree-kill.js.map +1 -1
- package/dist/public/node/ui.js +30 -80
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/vendor/dev_server/DevServer.d.ts +19 -0
- package/dist/public/node/vendor/dev_server/DevServer.js +170 -0
- package/dist/public/node/vendor/dev_server/DevServer.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -4
- package/dist/private/node/demo-recorder.d.ts +0 -17
- package/dist/private/node/demo-recorder.js +0 -121
- package/dist/private/node/demo-recorder.js.map +0 -1
package/dist/public/node/ui.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
2
|
/* eslint-disable tsdoc/syntax */
|
|
3
|
-
import { AbortError, AbortSilentError
|
|
3
|
+
import { AbortError, AbortSilentError } from './error.js';
|
|
4
4
|
import { collectLog, consoleError, consoleLog, outputContent, outputDebug, outputToken, outputWhereAppropriate, } from './output.js';
|
|
5
5
|
import { isUnitTest } from './context/local.js';
|
|
6
6
|
import { terminalSupportsPrompting } from './system.js';
|
|
@@ -17,7 +17,6 @@ import { SelectPrompt } from '../../private/node/ui/components/SelectPrompt.js';
|
|
|
17
17
|
import { Tasks } from '../../private/node/ui/components/Tasks.js';
|
|
18
18
|
import { TextPrompt } from '../../private/node/ui/components/TextPrompt.js';
|
|
19
19
|
import { AutocompletePrompt } from '../../private/node/ui/components/AutocompletePrompt.js';
|
|
20
|
-
import { recordUIEvent, resetRecordedSleep } from '../../private/node/demo-recorder.js';
|
|
21
20
|
import React from 'react';
|
|
22
21
|
const defaultUIDebugOptions = {
|
|
23
22
|
skipTTYCheck: false,
|
|
@@ -198,10 +197,6 @@ export function renderError(options) {
|
|
|
198
197
|
*/
|
|
199
198
|
// eslint-disable-next-line max-params
|
|
200
199
|
export function renderFatalError(error, { renderOptions } = {}) {
|
|
201
|
-
recordUIEvent({
|
|
202
|
-
type: 'fatalError',
|
|
203
|
-
properties: { ...error, errorType: error.type === FatalErrorType.Bug ? 'bug' : 'abort' },
|
|
204
|
-
});
|
|
205
200
|
return renderOnce(React.createElement(FatalError, { error: error }), { logLevel: 'error', logger: consoleError, renderOptions });
|
|
206
201
|
}
|
|
207
202
|
/**
|
|
@@ -238,23 +233,15 @@ export function renderFatalError(error, { renderOptions } = {}) {
|
|
|
238
233
|
// eslint-disable-next-line max-params
|
|
239
234
|
export async function renderSelectPrompt({ renderOptions, isConfirmationPrompt, ...props }, uiDebugOptions = defaultUIDebugOptions) {
|
|
240
235
|
throwInNonTTY({ message: props.message, stdin: renderOptions?.stdin }, uiDebugOptions);
|
|
241
|
-
if (!isConfirmationPrompt) {
|
|
242
|
-
recordUIEvent({ type: 'selectPrompt', properties: { renderOptions, ...props } });
|
|
243
|
-
}
|
|
244
236
|
return runWithTimer('cmd_all_timing_prompts_ms')(async () => {
|
|
245
237
|
let selectedValue;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return selectedValue;
|
|
254
|
-
}
|
|
255
|
-
finally {
|
|
256
|
-
resetRecordedSleep();
|
|
257
|
-
}
|
|
238
|
+
await render(React.createElement(SelectPrompt, { ...props, onSubmit: (value) => {
|
|
239
|
+
selectedValue = value;
|
|
240
|
+
} }), {
|
|
241
|
+
...renderOptions,
|
|
242
|
+
exitOnCtrlC: false,
|
|
243
|
+
});
|
|
244
|
+
return selectedValue;
|
|
258
245
|
});
|
|
259
246
|
}
|
|
260
247
|
/**
|
|
@@ -277,8 +264,6 @@ export async function renderSelectPrompt({ renderOptions, isConfirmationPrompt,
|
|
|
277
264
|
*
|
|
278
265
|
*/
|
|
279
266
|
export async function renderConfirmationPrompt({ message, infoTable, confirmationMessage = 'Yes, confirm', cancellationMessage = 'No, cancel', renderOptions, defaultValue = true, abortSignal, infoMessage, }) {
|
|
280
|
-
// eslint-disable-next-line prefer-rest-params
|
|
281
|
-
recordUIEvent({ type: 'confirmationPrompt', properties: arguments[0] });
|
|
282
267
|
const choices = [
|
|
283
268
|
{
|
|
284
269
|
label: confirmationMessage,
|
|
@@ -343,8 +328,6 @@ export async function renderConfirmationPrompt({ message, infoTable, confirmatio
|
|
|
343
328
|
// eslint-disable-next-line max-params
|
|
344
329
|
export async function renderAutocompletePrompt({ renderOptions, ...props }, uiDebugOptions = defaultUIDebugOptions) {
|
|
345
330
|
throwInNonTTY({ message: props.message, stdin: renderOptions?.stdin }, uiDebugOptions);
|
|
346
|
-
// eslint-disable-next-line prefer-rest-params
|
|
347
|
-
recordUIEvent({ type: 'autocompletePrompt', properties: arguments[0] });
|
|
348
331
|
const newProps = {
|
|
349
332
|
search(term) {
|
|
350
333
|
const lowerTerm = term.toLowerCase();
|
|
@@ -358,18 +341,13 @@ export async function renderAutocompletePrompt({ renderOptions, ...props }, uiDe
|
|
|
358
341
|
};
|
|
359
342
|
return runWithTimer('cmd_all_timing_prompts_ms')(async () => {
|
|
360
343
|
let selectedValue;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
return selectedValue;
|
|
369
|
-
}
|
|
370
|
-
finally {
|
|
371
|
-
resetRecordedSleep();
|
|
372
|
-
}
|
|
344
|
+
await render(React.createElement(AutocompletePrompt, { ...newProps, onSubmit: (value) => {
|
|
345
|
+
selectedValue = value;
|
|
346
|
+
} }), {
|
|
347
|
+
...renderOptions,
|
|
348
|
+
exitOnCtrlC: false,
|
|
349
|
+
});
|
|
350
|
+
return selectedValue;
|
|
373
351
|
});
|
|
374
352
|
}
|
|
375
353
|
/**
|
|
@@ -382,8 +360,6 @@ export async function renderAutocompletePrompt({ renderOptions, ...props }, uiDe
|
|
|
382
360
|
* 3 John Smith jon@smith.com
|
|
383
361
|
*/
|
|
384
362
|
export function renderTable({ renderOptions, ...props }) {
|
|
385
|
-
// eslint-disable-next-line prefer-rest-params
|
|
386
|
-
recordUIEvent({ type: 'table', properties: arguments[0] });
|
|
387
363
|
return renderOnce(React.createElement(Table, { ...props }), { renderOptions });
|
|
388
364
|
}
|
|
389
365
|
/**
|
|
@@ -394,25 +370,13 @@ export function renderTable({ renderOptions, ...props }) {
|
|
|
394
370
|
*/
|
|
395
371
|
// eslint-disable-next-line max-params
|
|
396
372
|
export async function renderTasks(tasks, { renderOptions } = {}) {
|
|
397
|
-
recordUIEvent({
|
|
398
|
-
type: 'taskbar',
|
|
399
|
-
properties: {
|
|
400
|
-
// Rather than timing exactly, pretend each step takes 2 seconds. This
|
|
401
|
-
// should be easy to tweak manually.
|
|
402
|
-
steps: tasks.map((task) => {
|
|
403
|
-
return { title: task.title, duration: 2 };
|
|
404
|
-
}),
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
373
|
// eslint-disable-next-line max-params
|
|
408
374
|
return new Promise((resolve, reject) => {
|
|
409
375
|
render(React.createElement(Tasks, { tasks: tasks, onComplete: resolve }), {
|
|
410
376
|
...renderOptions,
|
|
411
377
|
exitOnCtrlC: false,
|
|
412
378
|
})
|
|
413
|
-
.then(() => {
|
|
414
|
-
resetRecordedSleep();
|
|
415
|
-
})
|
|
379
|
+
.then(() => { })
|
|
416
380
|
.catch(reject);
|
|
417
381
|
});
|
|
418
382
|
}
|
|
@@ -427,22 +391,15 @@ export async function renderTasks(tasks, { renderOptions } = {}) {
|
|
|
427
391
|
// eslint-disable-next-line max-params
|
|
428
392
|
export async function renderTextPrompt({ renderOptions, ...props }, uiDebugOptions = defaultUIDebugOptions) {
|
|
429
393
|
throwInNonTTY({ message: props.message, stdin: renderOptions?.stdin }, uiDebugOptions);
|
|
430
|
-
// eslint-disable-next-line prefer-rest-params
|
|
431
|
-
recordUIEvent({ type: 'textPrompt', properties: arguments[0] });
|
|
432
394
|
return runWithTimer('cmd_all_timing_prompts_ms')(async () => {
|
|
433
395
|
let enteredText = '';
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
return enteredText;
|
|
442
|
-
}
|
|
443
|
-
finally {
|
|
444
|
-
resetRecordedSleep();
|
|
445
|
-
}
|
|
396
|
+
await render(React.createElement(TextPrompt, { ...props, onSubmit: (value) => {
|
|
397
|
+
enteredText = value;
|
|
398
|
+
} }), {
|
|
399
|
+
...renderOptions,
|
|
400
|
+
exitOnCtrlC: false,
|
|
401
|
+
});
|
|
402
|
+
return enteredText;
|
|
446
403
|
});
|
|
447
404
|
}
|
|
448
405
|
/**
|
|
@@ -471,22 +428,15 @@ export async function renderTextPrompt({ renderOptions, ...props }, uiDebugOptio
|
|
|
471
428
|
// eslint-disable-next-line max-params
|
|
472
429
|
export async function renderDangerousConfirmationPrompt({ renderOptions, ...props }, uiDebugOptions = defaultUIDebugOptions) {
|
|
473
430
|
throwInNonTTY({ message: props.message, stdin: renderOptions?.stdin }, uiDebugOptions);
|
|
474
|
-
// eslint-disable-next-line prefer-rest-params
|
|
475
|
-
recordUIEvent({ type: 'dangerousConfirmationPrompt', properties: arguments[0] });
|
|
476
431
|
return runWithTimer('cmd_all_timing_prompts_ms')(async () => {
|
|
477
432
|
let confirmed;
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
return confirmed;
|
|
486
|
-
}
|
|
487
|
-
finally {
|
|
488
|
-
resetRecordedSleep();
|
|
489
|
-
}
|
|
433
|
+
await render(React.createElement(DangerousConfirmationPrompt, { ...props, onSubmit: (value) => {
|
|
434
|
+
confirmed = value;
|
|
435
|
+
} }), {
|
|
436
|
+
...renderOptions,
|
|
437
|
+
exitOnCtrlC: false,
|
|
438
|
+
});
|
|
439
|
+
return confirmed;
|
|
490
440
|
});
|
|
491
441
|
}
|
|
492
442
|
/** Renders a text string to the console.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AACjC,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAuB,cAAc,EAAC,MAAM,YAAY,CAAA;AAC5F,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EAGV,aAAa,EACb,WAAW,EACX,WAAW,EACX,sBAA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,EAAC,CAAC;QAAE,OAAM;IAE1C,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAC7C,MAAM,YAAY,GAAG;;EAErB,aAAa,CAAA,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK;;2IAEqF,CAAA;IACzI,MAAM,IAAI,UAAU,CAClB,YAAY,EACZ,mIAAmI,CACpI,CAAA;AACH,CAAC;AAID,OAAO,EAA2F,MAAM,EAAE,WAAW,EAAC,CAAA","sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/* 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 {terminalSupportsPrompting} from './system.js'\nimport {AbortController} from './abort.js'\nimport {runWithTimer} from './metadata.js'\nimport {ConcurrentOutput, ConcurrentOutputProps} from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {handleCtrlC, 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 Token,\n tokenItemToString,\n InlineToken,\n LinkToken,\n ListToken,\n TokenItem,\n} from '../../private/node/ui/components/TokenizedText.js'\nimport {\n DangerousConfirmationPrompt,\n DangerousConfirmationPromptProps,\n} from '../../private/node/ui/components/DangerousConfirmationPrompt.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 {InfoMessageProps} from '../../private/node/ui/components/Prompts/InfoMessage.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\ninterface UIDebugOptions {\n /** If true, don't check if the current terminal is interactive or not */\n skipTTYCheck?: boolean\n}\nconst defaultUIDebugOptions: UIDebugOptions = {\n skipTTYCheck: false,\n}\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 * 00:00:00 │ backend │ first backend message\n * 00:00:00 │ backend │ second backend message\n * 00:00:00 │ backend │ third backend message\n * 00:00:00 │ frontend │ first frontend message\n * 00:00:00 │ frontend │ second frontend message\n * 00:00:00 │ frontend │ third frontend message\n *\n */\nexport async function renderConcurrent({renderOptions, ...props}: RenderConcurrentOptions) {\n const abortSignal = props.abortSignal ?? new AbortController().signal\n\n return render(<ConcurrentOutput {...props} abortSignal={abortSignal} />, renderOptions)\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\n/**\n * Renders an error banner to the console.\n * @example\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Version couldn't be released. │\n * │ │\n * │ This version needs to be submitted for review and │\n * │ approved by Shopify before it can be released. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n */\nexport function renderError(options: RenderAlertOptions) {\n return alert({...options, type: 'error'})\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\n * ┃ • new-ext\n * ┃\n * ┃ Remove\n * ┃ • integrated-demand-ext\n * ┃ • order-discount\n *\n * Automations\n * > fifth\n * sixth\n *\n * Merchant Admin\n * eighth\n * ninth\n *\n * Other\n * first\n * second\n * third (limit reached)\n * fourth\n * seventh\n * tenth\n *\n * Press ↑↓ arrows to select, enter to confirm.\n *\n */\n// eslint-disable-next-line max-params\nexport async function renderSelectPrompt<T>(\n {renderOptions, isConfirmationPrompt, ...props}: RenderSelectPromptOptions<T>,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n if (!isConfirmationPrompt) {\n recordUIEvent({type: 'selectPrompt', properties: {renderOptions, ...props}})\n }\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let selectedValue: T\n try {\n await render(\n <SelectPrompt\n {...props}\n onSubmit={(value: T) => {\n selectedValue = value\n }}\n />,\n {\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return selectedValue!\n } finally {\n resetRecordedSleep()\n }\n })\n}\n\nexport interface RenderConfirmationPromptOptions\n extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable' | 'infoMessage' | '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 * ┃ Info message title\n * ┃\n * ┃ Info message body\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\n * 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 infoMessage,\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 renderOptions,\n defaultValue,\n isConfirmationPrompt: true,\n abortSignal,\n infoMessage,\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 * ┃ Info message title\n * ┃\n * ┃ Info message body\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 (disabled)\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 */\n// eslint-disable-next-line max-params\nexport async function renderAutocompletePrompt<T>(\n {renderOptions, ...props}: RenderAutocompleteOptions<T>,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\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 const lowerTerm = term.toLowerCase()\n return Promise.resolve({\n data: props.choices.filter((item) => {\n return item.label.toLowerCase().includes(lowerTerm) || item.group?.toLowerCase().includes(lowerTerm)\n }),\n })\n },\n ...props,\n }\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let selectedValue: T\n try {\n await render(\n <AutocompletePrompt\n {...newProps}\n onSubmit={(value: T) => {\n selectedValue = value\n }}\n />,\n {\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return selectedValue!\n } finally {\n resetRecordedSleep()\n }\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(() => {\n resetRecordedSleep()\n })\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 */\n// eslint-disable-next-line max-params\nexport async function renderTextPrompt(\n {renderOptions, ...props}: RenderTextPromptOptions,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<string> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'textPrompt', properties: arguments[0]})\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let enteredText = ''\n try {\n await render(\n <TextPrompt\n {...props}\n onSubmit={(value: string) => {\n enteredText = value\n }}\n />,\n {\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return enteredText\n } finally {\n resetRecordedSleep()\n }\n })\n}\n\nexport interface RenderDangerousConfirmationPromptOptions extends Omit<DangerousConfirmationPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a dangerous confirmation prompt to the console, forcing the user to\n * type a confirmation string to proceed.\n * @example\n * ? Release a new version of nightly-app-2023-06-19?\n *\n * ┃ Includes:\n * ┃ + web-px (new)\n * ┃ + sub-ui-ext\n * ┃ + theme-app-ext\n * ┃ + paymentify (from Partner Dashboard)\n * ┃\n * ┃ Removes:\n * ┃ - prod-discount-fun\n * ┃\n * ┃ This can permanently delete app user data.\n *\n * Type nightly-app-2023-06-19 to confirm, or press Escape\n * to cancel.\n * > █\n * ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n *\n */\n// eslint-disable-next-line max-params\nexport async function renderDangerousConfirmationPrompt(\n {renderOptions, ...props}: RenderDangerousConfirmationPromptOptions,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<boolean> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'dangerousConfirmationPrompt', properties: arguments[0]})\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let confirmed: boolean\n try {\n await render(\n <DangerousConfirmationPrompt\n {...props}\n onSubmit={(value: boolean) => {\n confirmed = value\n }}\n />,\n {\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return confirmed!\n } finally {\n resetRecordedSleep()\n }\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. */\n// eslint-disable-next-line max-params\nexport const keypress = async (stdin = process.stdin, uiDebugOptions: UIDebugOptions = defaultUIDebugOptions) => {\n throwInNonTTY({message: 'Press any key'}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(() => {\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n stdin.setRawMode(false)\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 stdin.unref()\n process.nextTick(resolve)\n }\n\n stdin.setRawMode(true)\n stdin.once('data', handler)\n\n // We want to indicate that we're still using stdin, so that the process\n // doesn't exit early.\n stdin.ref()\n })\n })\n}\n\ninterface IsTTYOptions {\n stdin?: NodeJS.ReadStream\n uiDebugOptions?: UIDebugOptions\n}\n\nexport function isTTY({stdin = undefined, uiDebugOptions = defaultUIDebugOptions}: IsTTYOptions = {}) {\n return Boolean(uiDebugOptions.skipTTYCheck || stdin || terminalSupportsPrompting())\n}\n\ninterface ThrowInNonTTYOptions {\n message: TokenItem\n stdin?: NodeJS.ReadStream\n}\n\n// eslint-disable-next-line max-params\nfunction throwInNonTTY({message, stdin = undefined}: ThrowInNonTTYOptions, uiDebugOptions: UIDebugOptions) {\n if (isTTY({stdin, uiDebugOptions})) 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 to or 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 type InfoMessage = InfoMessageProps['message']\nexport {Token, Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken, render, handleCtrlC}\n"]}
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,iCAAiC;AACjC,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAsB,MAAM,YAAY,CAAA;AAC5E,OAAO,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EAGV,aAAa,EACb,WAAW,EACX,WAAW,EACX,sBAAsB,GACvB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAA;AA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Error, FatalError as Fatal} 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 {terminalSupportsPrompting} from './system.js'\nimport {AbortController} from './abort.js'\nimport {runWithTimer} from './metadata.js'\nimport {ConcurrentOutput, ConcurrentOutputProps} from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {handleCtrlC, 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 Token,\n tokenItemToString,\n InlineToken,\n LinkToken,\n ListToken,\n TokenItem,\n} from '../../private/node/ui/components/TokenizedText.js'\nimport {\n DangerousConfirmationPrompt,\n DangerousConfirmationPromptProps,\n} from '../../private/node/ui/components/DangerousConfirmationPrompt.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 {InfoMessageProps} from '../../private/node/ui/components/Prompts/InfoMessage.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\ninterface UIDebugOptions {\n /** If true, don't check if the current terminal is interactive or not */\n skipTTYCheck?: boolean\n}\nconst defaultUIDebugOptions: UIDebugOptions = {\n skipTTYCheck: false,\n}\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 * 00:00:00 │ backend │ first backend message\n * 00:00:00 │ backend │ second backend message\n * 00:00:00 │ backend │ third backend message\n * 00:00:00 │ frontend │ first frontend message\n * 00:00:00 │ frontend │ second frontend message\n * 00:00:00 │ frontend │ third frontend message\n *\n */\nexport async function renderConcurrent({renderOptions, ...props}: RenderConcurrentOptions) {\n const abortSignal = props.abortSignal ?? new AbortController().signal\n\n return render(<ConcurrentOutput {...props} abortSignal={abortSignal} />, renderOptions)\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\n/**\n * Renders an error banner to the console.\n * @example\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Version couldn't be released. │\n * │ │\n * │ This version needs to be submitted for review and │\n * │ approved by Shopify before it can be released. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n */\nexport function renderError(options: RenderAlertOptions) {\n return alert({...options, type: 'error'})\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 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\n * ┃ • new-ext\n * ┃\n * ┃ Remove\n * ┃ • integrated-demand-ext\n * ┃ • order-discount\n *\n * Automations\n * > fifth\n * sixth\n *\n * Merchant Admin\n * eighth\n * ninth\n *\n * Other\n * first\n * second\n * third (limit reached)\n * fourth\n * seventh\n * tenth\n *\n * Press ↑↓ arrows to select, enter to confirm.\n *\n */\n// eslint-disable-next-line max-params\nexport async function renderSelectPrompt<T>(\n {renderOptions, isConfirmationPrompt, ...props}: RenderSelectPromptOptions<T>,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let selectedValue: T\n await render(\n <SelectPrompt\n {...props}\n onSubmit={(value: T) => {\n selectedValue = value\n }}\n />,\n {\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return selectedValue!\n })\n}\n\nexport interface RenderConfirmationPromptOptions\n extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable' | 'infoMessage' | '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 * ┃ Info message title\n * ┃\n * ┃ Info message body\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\n * 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 infoMessage,\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 renderOptions,\n defaultValue,\n isConfirmationPrompt: true,\n abortSignal,\n infoMessage,\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 * ┃ Info message title\n * ┃\n * ┃ Info message body\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 (disabled)\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 */\n// eslint-disable-next-line max-params\nexport async function renderAutocompletePrompt<T>(\n {renderOptions, ...props}: RenderAutocompleteOptions<T>,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n const newProps = {\n search(term: string) {\n const lowerTerm = term.toLowerCase()\n return Promise.resolve({\n data: props.choices.filter((item) => {\n return item.label.toLowerCase().includes(lowerTerm) || item.group?.toLowerCase().includes(lowerTerm)\n }),\n })\n },\n ...props,\n }\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let selectedValue: T\n await render(\n <AutocompletePrompt\n {...newProps}\n onSubmit={(value: T) => {\n selectedValue = value\n }}\n />,\n {\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return selectedValue!\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 })\n .then(() => {})\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 */\n// eslint-disable-next-line max-params\nexport async function renderTextPrompt(\n {renderOptions, ...props}: RenderTextPromptOptions,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<string> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let enteredText = ''\n await render(\n <TextPrompt\n {...props}\n onSubmit={(value: string) => {\n enteredText = value\n }}\n />,\n {\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return enteredText\n })\n}\n\nexport interface RenderDangerousConfirmationPromptOptions extends Omit<DangerousConfirmationPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a dangerous confirmation prompt to the console, forcing the user to\n * type a confirmation string to proceed.\n * @example\n * ? Release a new version of nightly-app-2023-06-19?\n *\n * ┃ Includes:\n * ┃ + web-px (new)\n * ┃ + sub-ui-ext\n * ┃ + theme-app-ext\n * ┃ + paymentify (from Partner Dashboard)\n * ┃\n * ┃ Removes:\n * ┃ - prod-discount-fun\n * ┃\n * ┃ This can permanently delete app user data.\n *\n * Type nightly-app-2023-06-19 to confirm, or press Escape\n * to cancel.\n * > █\n * ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n *\n */\n// eslint-disable-next-line max-params\nexport async function renderDangerousConfirmationPrompt(\n {renderOptions, ...props}: RenderDangerousConfirmationPromptOptions,\n uiDebugOptions: UIDebugOptions = defaultUIDebugOptions,\n): Promise<boolean> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(async () => {\n let confirmed: boolean\n await render(\n <DangerousConfirmationPrompt\n {...props}\n onSubmit={(value: boolean) => {\n confirmed = value\n }}\n />,\n {\n ...renderOptions,\n exitOnCtrlC: false,\n },\n )\n return confirmed!\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. */\n// eslint-disable-next-line max-params\nexport const keypress = async (stdin = process.stdin, uiDebugOptions: UIDebugOptions = defaultUIDebugOptions) => {\n throwInNonTTY({message: 'Press any key'}, uiDebugOptions)\n\n return runWithTimer('cmd_all_timing_prompts_ms')(() => {\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n stdin.setRawMode(false)\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 stdin.unref()\n process.nextTick(resolve)\n }\n\n stdin.setRawMode(true)\n stdin.once('data', handler)\n\n // We want to indicate that we're still using stdin, so that the process\n // doesn't exit early.\n stdin.ref()\n })\n })\n}\n\ninterface IsTTYOptions {\n stdin?: NodeJS.ReadStream\n uiDebugOptions?: UIDebugOptions\n}\n\nexport function isTTY({stdin = undefined, uiDebugOptions = defaultUIDebugOptions}: IsTTYOptions = {}) {\n return Boolean(uiDebugOptions.skipTTYCheck || stdin || terminalSupportsPrompting())\n}\n\ninterface ThrowInNonTTYOptions {\n message: TokenItem\n stdin?: NodeJS.ReadStream\n}\n\n// eslint-disable-next-line max-params\nfunction throwInNonTTY({message, stdin = undefined}: ThrowInNonTTYOptions, uiDebugOptions: UIDebugOptions) {\n if (isTTY({stdin, uiDebugOptions})) 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 to or 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 type InfoMessage = InfoMessageProps['message']\nexport {Token, Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken, render, handleCtrlC}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class DevServer {
|
|
2
|
+
protected name: string;
|
|
3
|
+
constructor(name: string);
|
|
4
|
+
url({ nonstandardHostPrefix, }?: {
|
|
5
|
+
nonstandardHostPrefix?: string;
|
|
6
|
+
}): string;
|
|
7
|
+
host({ nonstandardHostPrefix, }?: {
|
|
8
|
+
nonstandardHostPrefix?: string;
|
|
9
|
+
}): string;
|
|
10
|
+
protected assertRunningLocally2024(): void;
|
|
11
|
+
protected assertRunningLocally2016(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare class DevServerCore {
|
|
14
|
+
private readonly name;
|
|
15
|
+
url(prefix: string): string;
|
|
16
|
+
host(prefix: string): string;
|
|
17
|
+
private assertRunningLocally2024;
|
|
18
|
+
private assertRunningLocally2016;
|
|
19
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import * as os from 'os';
|
|
3
|
+
import * as ni from 'network-interfaces';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
class DevServerUtils {
|
|
6
|
+
static assertConnectable(name, addr, port) {
|
|
7
|
+
try {
|
|
8
|
+
execSync(`nc -z -v -w 1 ${addr} ${port}`, {
|
|
9
|
+
timeout: DevServerUtils.CONNECT_TIMEOUT,
|
|
10
|
+
stdio: 'ignore',
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
catch (err) {
|
|
14
|
+
throw new Error(`NET FAILED DevServer for '${name}' is not running on ${port} / ${addr}: \`dev up ${name}\` to start it.`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
static inferenceModeAndProjectIsEdition2016(name) {
|
|
18
|
+
try {
|
|
19
|
+
fs.accessSync(DevServerUtils.INFERENCE_MODE_SENTINEL);
|
|
20
|
+
try {
|
|
21
|
+
fs.accessSync(`/opt/nginx/etc/manifest/${name}/current/edition-2024`);
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
static getIpFromHosts(hostname) {
|
|
33
|
+
try {
|
|
34
|
+
const hostsContent = fs.readFileSync(DevServerUtils.HOSTS_FILE, 'utf8');
|
|
35
|
+
const lines = hostsContent.split(/\r?\n/);
|
|
36
|
+
for (const line of lines) {
|
|
37
|
+
const matches = /^\s*?([^#]+?)\s+([^#]+?)$/.exec(line);
|
|
38
|
+
if (matches && matches.length === 3 && matches[2] === hostname) {
|
|
39
|
+
return matches[1]; // Return the IP address
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error('Error reading hosts file:', error);
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`No IP found for hostname: ${hostname}`);
|
|
47
|
+
}
|
|
48
|
+
static getAddrPort2024(name) {
|
|
49
|
+
try {
|
|
50
|
+
const backendIp = DevServerUtils.resolveBackendHost(name);
|
|
51
|
+
const interfaceName = ni.fromIp(backendIp, {
|
|
52
|
+
internal: true,
|
|
53
|
+
ipVersion: 4,
|
|
54
|
+
});
|
|
55
|
+
return [backendIp, DevServerUtils.BACKEND_PORT];
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static getAddrPort2016(name) {
|
|
62
|
+
try {
|
|
63
|
+
const portContent = fs.readFileSync(`${os.homedir()}/.local/run/services/${name}/server/port`, 'utf-8');
|
|
64
|
+
return ['localhost', parseInt(portContent, 10)];
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
throw new Error(`DevServer for '${name}' is not running: \`dev up ${name}\` to start it.`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
static resolveBackendHost(name) {
|
|
71
|
+
let host;
|
|
72
|
+
try {
|
|
73
|
+
host = fs.readlinkSync(`/opt/nginx/etc/manifest/${name}/current`);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
host = `${name}.root.shopify.dev.internal`;
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
return DevServerUtils.getIpFromHosts(host);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return host;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
DevServerUtils.INFERENCE_MODE_SENTINEL = '/opt/dev/misc/dev-server-inference-mode';
|
|
87
|
+
DevServerUtils.BACKEND_PORT = 8080;
|
|
88
|
+
DevServerUtils.CONNECT_TIMEOUT = 100; // 100ms
|
|
89
|
+
DevServerUtils.HOSTS_FILE = '/etc/hosts';
|
|
90
|
+
export class DevServer {
|
|
91
|
+
constructor(name) {
|
|
92
|
+
if (!process.env.SPIN && !process.env.USING_DEV) {
|
|
93
|
+
throw new Error('DevServer is not supported in this environment');
|
|
94
|
+
}
|
|
95
|
+
if (name === 'shopify') {
|
|
96
|
+
throw new Error('Use DevServer.core for the \'shopify\' project');
|
|
97
|
+
}
|
|
98
|
+
this.name = name;
|
|
99
|
+
}
|
|
100
|
+
url({ nonstandardHostPrefix, } = {}) {
|
|
101
|
+
return `https://${this.host({ nonstandardHostPrefix })}`;
|
|
102
|
+
}
|
|
103
|
+
host({ nonstandardHostPrefix, } = {}) {
|
|
104
|
+
const prefix = nonstandardHostPrefix || this.name;
|
|
105
|
+
if (process.env.SPIN === '1') {
|
|
106
|
+
const services = fs.readdirSync('/run/ports2')
|
|
107
|
+
.filter(file => file.endsWith(`--${this.name}`));
|
|
108
|
+
if (services.length === 0) {
|
|
109
|
+
throw new Error(`DevServer for '${this.name}' not present in this spin environment`);
|
|
110
|
+
}
|
|
111
|
+
const match = new RegExp(`^(.+)${this.name}$`).exec(services[0]);
|
|
112
|
+
const organization = match ? match[1] : '';
|
|
113
|
+
const spinPrefix = organization !== 'shopify--' ? `${organization}` : '';
|
|
114
|
+
return `${spinPrefix}${this.name}.${process.env.SPIN_FQDN}`;
|
|
115
|
+
}
|
|
116
|
+
else if (DevServerUtils.inferenceModeAndProjectIsEdition2016(this.name)) {
|
|
117
|
+
this.assertRunningLocally2016();
|
|
118
|
+
return `${prefix}.myshopify.io`;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.assertRunningLocally2024();
|
|
122
|
+
return `${prefix}.shop.dev`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
assertRunningLocally2024() {
|
|
126
|
+
const [addr, port] = DevServerUtils.getAddrPort2024(this.name);
|
|
127
|
+
DevServerUtils.assertConnectable(this.name, addr, port);
|
|
128
|
+
}
|
|
129
|
+
assertRunningLocally2016() {
|
|
130
|
+
const [addr, port] = DevServerUtils.getAddrPort2016(this.name);
|
|
131
|
+
DevServerUtils.assertConnectable(this.name, addr, port);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export class DevServerCore {
|
|
135
|
+
constructor() {
|
|
136
|
+
this.name = 'shopify';
|
|
137
|
+
}
|
|
138
|
+
url(prefix) {
|
|
139
|
+
return `https://${this.host(prefix)}`;
|
|
140
|
+
}
|
|
141
|
+
host(prefix) {
|
|
142
|
+
if (process.env.SPIN === '1') {
|
|
143
|
+
const projectPortRoot = fs
|
|
144
|
+
.readdirSync('/run/ports2')
|
|
145
|
+
.find((file) => file.endsWith(`--${this.name}`));
|
|
146
|
+
if (!projectPortRoot) {
|
|
147
|
+
throw new Error(`DevServer for '${this.name}' not present in this spin environment`);
|
|
148
|
+
}
|
|
149
|
+
// Spin mostly doesn't do alternative hostname prefixing.
|
|
150
|
+
return `${prefix}.${this.name}.${process.env.SPIN_FQDN}`;
|
|
151
|
+
}
|
|
152
|
+
else if (DevServerUtils.inferenceModeAndProjectIsEdition2016('shopify')) {
|
|
153
|
+
this.assertRunningLocally2016();
|
|
154
|
+
return `${prefix}.myshopify.io`;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
this.assertRunningLocally2024();
|
|
158
|
+
return `${prefix}.my.shop.dev`;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
assertRunningLocally2024() {
|
|
162
|
+
const [addr, port] = DevServerUtils.getAddrPort2024('shopify');
|
|
163
|
+
DevServerUtils.assertConnectable('shopify', addr, port);
|
|
164
|
+
}
|
|
165
|
+
assertRunningLocally2016() {
|
|
166
|
+
const [addr, port] = DevServerUtils.getAddrPort2016('shopify');
|
|
167
|
+
DevServerUtils.assertConnectable('shopify', addr, port);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=DevServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevServer.js","sourceRoot":"","sources":["../../../../../src/public/node/vendor/dev_server/DevServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,cAAc;IAOlB,MAAM,CAAC,iBAAiB,CAAC,IAAY,EAAE,IAAY,EAAE,IAAY;QAC/D,IAAI;YACF,QAAQ,CAAC,iBAAiB,IAAI,IAAI,IAAI,EAAE,EAAE;gBACxC,OAAO,EAAE,cAAc,CAAC,eAAe;gBACvC,KAAK,EAAE,QAAQ;aAChB,CAAC,CAAC;SACJ;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,IAAI,KAAK,CACb,6BAA6B,IAAI,uBAAuB,IAAI,MAAM,IAAI,cAAc,IAAI,iBAAiB,CAC1G,CAAC;SACH;IACH,CAAC;IAED,MAAM,CAAC,oCAAoC,CAAC,IAAY;QACtD,IAAI;YACF,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;YACtD,IAAI;gBACF,EAAE,CAAC,UAAU,CAAC,2BAA2B,IAAI,uBAAuB,CAAC,CAAC;gBACtE,OAAO,KAAK,CAAC;aACd;YAAC,MAAM;gBACN,OAAO,IAAI,CAAC;aACb;SACF;QAAC,MAAM;YACN,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,QAAgB;QACpC,IAAI;YACF,MAAM,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;Y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C/D,cAAc,CAAC,iBAAiB,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAEO,wBAAwB;QAC9B,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAC/D,cAAc,CAAC,iBAAiB,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import fs from 'fs';\nimport * as os from 'os';\nimport * as ni from 'network-interfaces';\nimport { execSync } from 'child_process';\n\nclass DevServerUtils {\n static readonly INFERENCE_MODE_SENTINEL =\n '/opt/dev/misc/dev-server-inference-mode';\n static readonly BACKEND_PORT = 8080;\n static readonly CONNECT_TIMEOUT = 100; // 100ms\n static readonly HOSTS_FILE = '/etc/hosts';\n\n static assertConnectable(name: string, addr: string, port: number): void {\n try {\n execSync(`nc -z -v -w 1 ${addr} ${port}`, {\n timeout: DevServerUtils.CONNECT_TIMEOUT,\n stdio: 'ignore',\n });\n } catch (err) {\n throw new Error(\n `NET FAILED DevServer for '${name}' is not running on ${port} / ${addr}: \\`dev up ${name}\\` to start it.`\n );\n }\n }\n\n static inferenceModeAndProjectIsEdition2016(name: string): boolean {\n try {\n fs.accessSync(DevServerUtils.INFERENCE_MODE_SENTINEL);\n try {\n fs.accessSync(`/opt/nginx/etc/manifest/${name}/current/edition-2024`);\n return false;\n } catch {\n return true;\n }\n } catch {\n return false;\n }\n }\n\n static getIpFromHosts(hostname: string): string {\n try {\n const hostsContent = fs.readFileSync(DevServerUtils.HOSTS_FILE, 'utf8');\n const lines = hostsContent.split(/\\r?\\n/);\n for (const line of lines) {\n const matches = /^\\s*?([^#]+?)\\s+([^#]+?)$/.exec(line);\n if (matches && matches.length === 3 && matches[2] === hostname) {\n return matches[1]!; // Return the IP address\n }\n }\n } catch (error) {\n console.error('Error reading hosts file:', error);\n }\n\n throw new Error(`No IP found for hostname: ${hostname}`);\n }\n\n static getAddrPort2024(name: string): [string, number] {\n try {\n const backendIp = DevServerUtils.resolveBackendHost(name);\n const interfaceName = ni.fromIp(backendIp, {\n internal: true,\n ipVersion: 4,\n });\n return [backendIp, DevServerUtils.BACKEND_PORT];\n } catch (error) {\n throw new Error(\n `DevServer for '${name}' is not running: \\`dev up ${name}\\` to start it.`\n );\n }\n }\n\n static getAddrPort2016(name: string): [string, number] {\n try {\n const portContent = fs.readFileSync(\n `${os.homedir()}/.local/run/services/${name}/server/port`,\n 'utf-8'\n );\n return ['localhost', parseInt(portContent, 10)];\n } catch (error) {\n throw new Error(\n `DevServer for '${name}' is not running: \\`dev up ${name}\\` to start it.`\n );\n }\n }\n\n static resolveBackendHost(name: string): string {\n let host: string;\n try {\n host = fs.readlinkSync(`/opt/nginx/etc/manifest/${name}/current`);\n } catch (error) {\n host = `${name}.root.shopify.dev.internal`;\n }\n\n try {\n return DevServerUtils.getIpFromHosts(host);\n } catch {\n return host;\n }\n }\n}\n\nexport class DevServer {\n protected name: string;\n\n constructor(name: string) {\n if (!process.env.SPIN && !process.env.USING_DEV) {\n throw new Error('DevServer is not supported in this environment');\n }\n\n if (name === 'shopify') {\n throw new Error('Use DevServer.core for the \\'shopify\\' project');\n }\n this.name = name;\n }\n\n url({\n nonstandardHostPrefix,\n }: { nonstandardHostPrefix?: string } = {}): string {\n return `https://${this.host({nonstandardHostPrefix})}`;\n }\n\n host({\n nonstandardHostPrefix,\n }: { nonstandardHostPrefix?: string } = {}): string {\n const prefix = nonstandardHostPrefix || this.name;\n\n if (process.env.SPIN === '1') {\n const services = fs.readdirSync('/run/ports2')\n .filter(file => file.endsWith(`--${this.name}`));\n\n if (services.length === 0) {\n throw new Error(\n `DevServer for '${this.name}' not present in this spin environment`\n );\n }\n\n const match = new RegExp(`^(.+)${this.name}$`).exec(services[0]!);\n const organization = match ? match[1] : '';\n const spinPrefix = organization !== 'shopify--' ? `${organization}` : '';\n\n return `${spinPrefix}${this.name}.${process.env.SPIN_FQDN}`;\n } else if (DevServerUtils.inferenceModeAndProjectIsEdition2016(this.name)) {\n this.assertRunningLocally2016();\n return `${prefix}.myshopify.io`;\n } else {\n this.assertRunningLocally2024();\n return `${prefix}.shop.dev`;\n }\n }\n\n protected assertRunningLocally2024(): void {\n const [addr, port] = DevServerUtils.getAddrPort2024(this.name);\n DevServerUtils.assertConnectable(this.name, addr, port);\n }\n\n protected assertRunningLocally2016(): void {\n const [addr, port] = DevServerUtils.getAddrPort2016(this.name);\n DevServerUtils.assertConnectable(this.name, addr, port);\n }\n}\n\nexport class DevServerCore {\n private readonly name = 'shopify';\n\n url(prefix: string): string {\n return `https://${this.host(prefix)}`;\n }\n\n host(prefix: string): string {\n if (process.env.SPIN === '1') {\n const projectPortRoot = fs\n .readdirSync('/run/ports2')\n .find((file) => file.endsWith(`--${this.name}`));\n if (!projectPortRoot) {\n throw new Error(\n `DevServer for '${this.name}' not present in this spin environment`\n );\n }\n // Spin mostly doesn't do alternative hostname prefixing.\n return `${prefix}.${this.name}.${process.env.SPIN_FQDN}`;\n } else if (DevServerUtils.inferenceModeAndProjectIsEdition2016('shopify')) {\n this.assertRunningLocally2016();\n return `${prefix}.myshopify.io`;\n } else {\n this.assertRunningLocally2024();\n return `${prefix}.my.shop.dev`;\n }\n }\n\n private assertRunningLocally2024(): void {\n const [addr, port] = DevServerUtils.getAddrPort2024('shopify');\n DevServerUtils.assertConnectable('shopify', addr, port);\n }\n\n private assertRunningLocally2016(): void {\n const [addr, port] = DevServerUtils.getAddrPort2016('shopify');\n DevServerUtils.assertConnectable('shopify', addr, port);\n }\n}"]}
|