@shopify/cli-kit 3.3.3 → 3.6.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/CHANGELOG.md +31 -0
- package/dist/analytics.d.ts +11 -5
- package/dist/analytics.js +62 -72
- package/dist/analytics.js.map +1 -1
- package/dist/api/admin.js +20 -34
- package/dist/api/admin.js.map +1 -1
- package/dist/api/common.d.ts +11 -1
- package/dist/api/common.js +50 -6
- package/dist/api/common.js.map +1 -1
- package/dist/api/identity.js +3 -4
- package/dist/api/identity.js.map +1 -1
- package/dist/api/partners.d.ts +0 -5
- package/dist/api/partners.js +22 -43
- package/dist/api/partners.js.map +1 -1
- package/dist/array.d.ts +1 -0
- package/dist/array.js +4 -0
- package/dist/array.js.map +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -2
- package/dist/constants.js.map +1 -1
- package/dist/environment/local.d.ts +1 -0
- package/dist/environment/local.js +3 -0
- package/dist/environment/local.js.map +1 -1
- package/dist/environment/service.d.ts +2 -1
- package/dist/environment/service.js +16 -0
- package/dist/environment/service.js.map +1 -1
- package/dist/error.d.ts +5 -0
- package/dist/error.js +10 -4
- package/dist/error.js.map +1 -1
- package/dist/file.d.ts +3 -1
- package/dist/file.js +14 -2
- package/dist/file.js.map +1 -1
- package/dist/git.js +12 -5
- package/dist/git.js.map +1 -1
- package/dist/haiku.d.ts +6 -1
- package/dist/haiku.js +67 -6
- package/dist/haiku.js.map +1 -1
- package/dist/http/fetch.d.ts +9 -2
- package/dist/http/fetch.js +11 -2
- package/dist/http/fetch.js.map +1 -1
- package/dist/http/graphql.d.ts +15 -0
- package/dist/http/graphql.js +12 -0
- package/dist/http/graphql.js.map +1 -0
- package/dist/http.d.ts +24 -0
- package/dist/http.js +27 -0
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +6 -0
- package/dist/json.js +2 -0
- package/dist/json.js.map +1 -0
- package/dist/metadata.d.ts +51 -0
- package/dist/metadata.js +29 -0
- package/dist/metadata.js.map +1 -0
- package/dist/monorail.d.ts +38 -0
- package/dist/monorail.js +38 -0
- package/dist/monorail.js.map +1 -0
- package/dist/network/service.d.ts +1 -1
- package/dist/network/service.js.map +1 -1
- package/dist/node/archiver.d.ts +4 -1
- package/dist/node/archiver.js +22 -13
- package/dist/node/archiver.js.map +1 -1
- package/dist/node/base-command.d.ts +1 -0
- package/dist/node/base-command.js +11 -2
- package/dist/node/base-command.js.map +1 -1
- package/dist/node/cli.d.ts +0 -2
- package/dist/node/cli.js +0 -4
- package/dist/node/cli.js.map +1 -1
- package/dist/node/error-handler.d.ts +23 -1
- package/dist/node/error-handler.js +64 -8
- package/dist/node/error-handler.js.map +1 -1
- package/dist/node/hooks/init.d.ts +2 -0
- package/dist/node/hooks/init.js +7 -0
- package/dist/node/hooks/init.js.map +1 -0
- package/dist/node/hooks/postrun.js +5 -2
- package/dist/node/hooks/postrun.js.map +1 -1
- package/dist/node/hooks/prerun.js +2 -0
- package/dist/node/hooks/prerun.js.map +1 -1
- package/dist/node/ruby.d.ts +7 -2
- package/dist/node/ruby.js +22 -7
- package/dist/node/ruby.js.map +1 -1
- package/dist/output.d.ts +18 -11
- package/dist/output.js +96 -28
- package/dist/output.js.map +1 -1
- package/dist/path.d.ts +3 -3
- package/dist/path.js +2 -4
- package/dist/path.js.map +1 -1
- package/dist/plugins.d.ts +38 -2
- package/dist/plugins.js +11 -0
- package/dist/plugins.js.map +1 -1
- package/dist/session/authorize.js +16 -4
- package/dist/session/authorize.js.map +1 -1
- package/dist/session/exchange.js +2 -8
- package/dist/session/exchange.js.map +1 -1
- package/dist/session/validate.js +3 -0
- package/dist/session/validate.js.map +1 -1
- package/dist/session.js +7 -1
- package/dist/session.js.map +1 -1
- package/dist/store.js +0 -2
- package/dist/store.js.map +1 -1
- package/dist/string.d.ts +4 -0
- package/dist/string.js +13 -0
- package/dist/string.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing/overloaded-parameters.d.ts +6 -0
- package/dist/typing/overloaded-parameters.js +2 -0
- package/dist/typing/overloaded-parameters.js.map +1 -0
- package/dist/typing/simple-definitions.d.ts +4 -0
- package/dist/typing/simple-definitions.js +2 -0
- package/dist/typing/simple-definitions.js.map +1 -0
- package/dist/ui.d.ts +12 -0
- package/dist/ui.js +57 -5
- package/dist/ui.js.map +1 -1
- package/package.json +28 -22
package/dist/output.js
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import { Bug } from './error.js';
|
|
2
|
+
import { Bug, cleanSingleStackTracePath } from './error.js';
|
|
3
3
|
import { isUnitTest, isVerbose } from './environment/local.js';
|
|
4
4
|
import constants from './constants.js';
|
|
5
|
-
import {
|
|
5
|
+
import { generateRandomUUID } from './id.js';
|
|
6
|
+
import { mkdirSync as fileMkdirSync, readSync as fileReadSync, sizeSync as fileSizeSync, writeSync as fileWriteSync, touchSync as fileTouchSync, } from './file.js';
|
|
6
7
|
import { join as pathJoin, relativize as relativizePath } from './path.js';
|
|
7
8
|
import { page } from './system.js';
|
|
8
9
|
import { colors } from './node/colors.js';
|
|
9
10
|
import terminalLink from 'terminal-link';
|
|
10
11
|
import StackTracey from 'stacktracey';
|
|
11
12
|
import { AbortController } from 'abort-controller';
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
13
|
-
// @ts-ignore
|
|
14
13
|
import cjs from 'color-json';
|
|
15
14
|
import stripAnsi from 'strip-ansi';
|
|
16
15
|
import { Writable } from 'node:stream';
|
|
17
|
-
|
|
18
|
-
export
|
|
16
|
+
import { createWriteStream } from 'node:fs';
|
|
17
|
+
export { default as logUpdate } from 'log-update';
|
|
18
|
+
const logFileName = 'shopify.cli.log';
|
|
19
|
+
let logFileStream;
|
|
20
|
+
let commandUuid;
|
|
21
|
+
export function initiateLogging(options = {}) {
|
|
22
|
+
if (isUnitTest())
|
|
23
|
+
return;
|
|
24
|
+
const logDir = options.logDir || constants.paths.directories.cache.path();
|
|
25
|
+
commandUuid = generateRandomUUID();
|
|
19
26
|
fileMkdirSync(logDir);
|
|
20
|
-
logFile = pathJoin(logDir,
|
|
27
|
+
const logFile = pathJoin(logDir, logFileName);
|
|
21
28
|
fileTouchSync(logFile);
|
|
22
|
-
truncateLogs();
|
|
29
|
+
truncateLogs(logFile);
|
|
30
|
+
logFileStream = createWriteStream(logFile, { flags: 'a' });
|
|
23
31
|
}
|
|
24
32
|
// Shaves off the first 10,000 log lines (circa 1MB) if logs are over 5MB long.
|
|
25
33
|
// Rescues in case the file hasn't been created yet.
|
|
26
|
-
function truncateLogs() {
|
|
34
|
+
function truncateLogs(logFile) {
|
|
27
35
|
try {
|
|
28
36
|
if (fileSizeSync(logFile) > 5 * 1024 * 1024) {
|
|
29
37
|
const contents = fileReadSync(logFile);
|
|
@@ -259,61 +267,69 @@ export const clearCollectedLogs = () => {
|
|
|
259
267
|
collectedLogs = {};
|
|
260
268
|
};
|
|
261
269
|
/**
|
|
262
|
-
* Ouputs information to the user.
|
|
270
|
+
* Ouputs information to the user.
|
|
263
271
|
* Info messages don't get additional formatting.
|
|
264
272
|
* Note: Info messages are sent through the standard output.
|
|
265
273
|
* @param content {string} The content to be output to the user.
|
|
274
|
+
* @param logger {Function} The logging function to use to output to the user.
|
|
266
275
|
*/
|
|
267
|
-
export const info = (content) => {
|
|
276
|
+
export const info = (content, logger = consoleLog) => {
|
|
277
|
+
const message = stringifyMessage(content);
|
|
268
278
|
if (isUnitTest())
|
|
269
279
|
collectLog('info', content);
|
|
270
|
-
|
|
280
|
+
outputWhereAppropriate('info', logger, message);
|
|
271
281
|
};
|
|
272
282
|
/**
|
|
273
283
|
* Outputs a success message to the user.
|
|
274
|
-
* Success
|
|
284
|
+
* Success messages receive a special formatting to make them stand out in the console.
|
|
275
285
|
* Note: Success messages are sent through the standard output.
|
|
276
286
|
* @param content {string} The content to be output to the user.
|
|
287
|
+
* @param logger {Function} The logging function to use to output to the user.
|
|
277
288
|
*/
|
|
278
|
-
export const success = (content) => {
|
|
289
|
+
export const success = (content, logger = consoleLog) => {
|
|
279
290
|
const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`);
|
|
280
291
|
if (isUnitTest())
|
|
281
292
|
collectLog('success', content);
|
|
282
|
-
outputWhereAppropriate('info',
|
|
293
|
+
outputWhereAppropriate('info', logger, message);
|
|
283
294
|
};
|
|
284
295
|
/**
|
|
285
296
|
* Outputs a completed message to the user.
|
|
286
297
|
* Completed message receive a special formatting to make them stand out in the console.
|
|
287
298
|
* Note: Completed messages are sent through the standard output.
|
|
288
299
|
* @param content {string} The content to be output to the user.
|
|
300
|
+
* @param logger {Function} The logging function to use to output to the user.
|
|
289
301
|
*/
|
|
290
|
-
export const completed = (content) => {
|
|
302
|
+
export const completed = (content, logger = consoleLog) => {
|
|
291
303
|
const message = `${colors.green('✔')} ${stringifyMessage(content)}`;
|
|
292
304
|
if (isUnitTest())
|
|
293
305
|
collectLog('completed', content);
|
|
294
|
-
outputWhereAppropriate('info',
|
|
306
|
+
outputWhereAppropriate('info', logger, message);
|
|
295
307
|
};
|
|
296
308
|
/**
|
|
297
309
|
* Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.
|
|
298
310
|
* Debug messages don't get additional formatting.
|
|
299
311
|
* Note: Debug messages are sent through the standard output.
|
|
300
312
|
* @param content {string} The content to be output to the user.
|
|
313
|
+
* @param logger {Function} The logging function to use to output to the user.
|
|
301
314
|
*/
|
|
302
|
-
export const debug = (content) => {
|
|
315
|
+
export const debug = (content, logger = consoleLog) => {
|
|
303
316
|
if (isUnitTest())
|
|
304
317
|
collectLog('debug', content);
|
|
305
|
-
message
|
|
318
|
+
const message = colors.gray(stringifyMessage(content));
|
|
319
|
+
outputWhereAppropriate('debug', logger, message);
|
|
306
320
|
};
|
|
307
321
|
/**
|
|
308
322
|
* Outputs a warning message to the user.
|
|
309
323
|
* Warning messages receive a special formatting to make them stand out in the console.
|
|
310
324
|
* Note: Warning messages are sent through the standard output.
|
|
311
325
|
* @param content {string} The content to be output to the user.
|
|
326
|
+
* @param logger {Function} The logging function to use to output to the user.
|
|
312
327
|
*/
|
|
313
|
-
export const warn = (content) => {
|
|
328
|
+
export const warn = (content, logger = consoleWarn) => {
|
|
314
329
|
if (isUnitTest())
|
|
315
330
|
collectLog('warn', content);
|
|
316
|
-
|
|
331
|
+
const message = colors.yellow(stringifyMessage(content));
|
|
332
|
+
outputWhereAppropriate('warn', logger, message);
|
|
317
333
|
};
|
|
318
334
|
/**
|
|
319
335
|
* Prints a new line in the terminal.
|
|
@@ -349,7 +365,11 @@ export const error = async (content) => {
|
|
|
349
365
|
outputString += `${padding}${line}\n`;
|
|
350
366
|
}
|
|
351
367
|
}
|
|
352
|
-
let stack =
|
|
368
|
+
let stack = new StackTracey(content);
|
|
369
|
+
stack.items.forEach((item) => {
|
|
370
|
+
item.file = cleanSingleStackTracePath(item.file);
|
|
371
|
+
});
|
|
372
|
+
stack = await stack.withSourcesAsync();
|
|
353
373
|
stack = stack
|
|
354
374
|
.filter((entry) => {
|
|
355
375
|
return !entry.file.includes('@oclif/core');
|
|
@@ -465,14 +485,14 @@ function consoleError(message) {
|
|
|
465
485
|
function consoleWarn(message) {
|
|
466
486
|
console.warn(withOrWithoutStyle(message));
|
|
467
487
|
}
|
|
468
|
-
function outputWhereAppropriate(logLevel,
|
|
488
|
+
function outputWhereAppropriate(logLevel, logger, message) {
|
|
469
489
|
if (shouldOutput(logLevel)) {
|
|
470
|
-
|
|
490
|
+
logger(message);
|
|
471
491
|
}
|
|
472
492
|
logToFile(message, logLevel.toUpperCase());
|
|
473
493
|
}
|
|
474
494
|
export function logFileExists() {
|
|
475
|
-
return Boolean(
|
|
495
|
+
return Boolean(logFileStream);
|
|
476
496
|
}
|
|
477
497
|
// DO NOT USE THIS FUNCTION DIRECTLY under normal circumstances.
|
|
478
498
|
// It is exported purely for use in cases where output is already being logged
|
|
@@ -482,7 +502,8 @@ export function logToFile(message, logLevel) {
|
|
|
482
502
|
if (!logFileExists())
|
|
483
503
|
return;
|
|
484
504
|
const timestamp = new Date().toISOString();
|
|
485
|
-
|
|
505
|
+
const logContents = `[${timestamp} ${commandUuid} ${logLevel}]: ${message}\n`;
|
|
506
|
+
logFileStream.write(logContents);
|
|
486
507
|
}
|
|
487
508
|
function withOrWithoutStyle(message) {
|
|
488
509
|
if (shouldDisplayColors()) {
|
|
@@ -498,8 +519,55 @@ export function unstyled(message) {
|
|
|
498
519
|
export function shouldDisplayColors() {
|
|
499
520
|
return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR);
|
|
500
521
|
}
|
|
501
|
-
export async function pageLogs() {
|
|
502
|
-
|
|
522
|
+
export async function pageLogs({ lastCommand }) {
|
|
523
|
+
const logDir = constants.paths.directories.cache.path();
|
|
524
|
+
const logFile = pathJoin(logDir, logFileName);
|
|
525
|
+
// Ensure file exists in case they deleted it or something
|
|
526
|
+
fileTouchSync(logFile);
|
|
527
|
+
if (lastCommand) {
|
|
528
|
+
printLastCommand(logFile);
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
await page(logFile);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
function printLastCommand(logFile) {
|
|
535
|
+
const contents = fileReadSync(logFile).split('\n');
|
|
536
|
+
const uuids = contents
|
|
537
|
+
.map(logfileLineUUID)
|
|
538
|
+
.filter((uuid) => uuid)
|
|
539
|
+
.reverse();
|
|
540
|
+
// 2nd unique UUID, because the currently running command will be the 1st
|
|
541
|
+
const relevantUuid = Array.from(new Set(uuids))[1];
|
|
542
|
+
if (relevantUuid) {
|
|
543
|
+
consoleLog(relevantLines(contents, relevantUuid).join('\n'));
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function relevantLines(contents, relevantUuid) {
|
|
547
|
+
// We run through the file line by line, keeping track of the most recently
|
|
548
|
+
// encountered UUID.
|
|
549
|
+
//
|
|
550
|
+
// If the current line has a UUID, it's a new logged unit and should be
|
|
551
|
+
// considered. Otherwise, the line is related to the most recent UUID.
|
|
552
|
+
let mostRecentUuid = '';
|
|
553
|
+
return contents.filter((line) => {
|
|
554
|
+
const currentUuid = logfileLineUUID(line) || mostRecentUuid;
|
|
555
|
+
mostRecentUuid = currentUuid;
|
|
556
|
+
return currentUuid === relevantUuid;
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
function logfileLineUUID(line) {
|
|
560
|
+
// Log lines look like:
|
|
561
|
+
//
|
|
562
|
+
// timestamp UUID contents
|
|
563
|
+
// ===========================================================================================
|
|
564
|
+
// [2022-07-20T08:51:40.296Z 5288e1da-a06a-4f96-b1a6-e34fcdd7b416 DEBUG]: Running command logs
|
|
565
|
+
// ===========================================================================================
|
|
566
|
+
//
|
|
567
|
+
// There may be subsequent lines if the contents section is multi-line.
|
|
568
|
+
//
|
|
569
|
+
const match = line.match(/^\[\S+ ([0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}) [A-Z]+\]/);
|
|
570
|
+
return match && match[1];
|
|
503
571
|
}
|
|
504
572
|
/**
|
|
505
573
|
*
|
package/dist/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAQ,GAAG,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC5D,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAEtC,OAAO,EACL,MAAM,IAAI,UAAU,EACpB,SAAS,IAAI,aAAa,EAC1B,QAAQ,IAAI,YAAY,EACxB,QAAQ,IAAI,YAAY,EACxB,SAAS,IAAI,aAAa,EAC1B,SAAS,IAAI,aAAa,GAC3B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAE,UA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,OAAO,CAAA,cAAc,OAAO,mBAAmB,aAAa,EAAE,CAAC,KAAK,CAAA;AAC7E,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {Fatal, Bug} from './error.js'\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport constants from './constants.js'\nimport {PackageManager} from './node/node-package-manager.js'\nimport {\n append as fileAppend,\n mkdirSync as fileMkdirSync,\n readSync as fileReadSync,\n sizeSync as fileSizeSync,\n writeSync as fileWriteSync,\n touchSync as fileTouchSync,\n} from './file.js'\nimport {join as pathJoin, relativize as relativizePath} from './path.js'\nimport {page} from './system.js'\nimport {colors} from './node/colors.js'\nimport terminalLink from 'terminal-link'\nimport StackTracey from 'stacktracey'\nimport {AbortController, AbortSignal} from 'abort-controller'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport cjs from 'color-json'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'node:stream'\n\nlet logFile: string\n\nexport function initiateLogging({\n logDir = constants.paths.directories.cache.path(),\n filename = 'shopify.log',\n}: {\n logDir?: string\n filename?: string\n}) {\n fileMkdirSync(logDir)\n logFile = pathJoin(logDir, filename)\n fileTouchSync(logFile)\n truncateLogs()\n}\n\n// Shaves off the first 10,000 log lines (circa 1MB) if logs are over 5MB long.\n// Rescues in case the file hasn't been created yet.\nfunction truncateLogs() {\n try {\n if (fileSizeSync(logFile) > 5 * 1024 * 1024) {\n const contents = fileReadSync(logFile)\n const splitContents = contents.split('\\n')\n const newContents = splitContents.slice(10000, splitContents.length).join('\\n')\n fileWriteSync(logFile, newContents)\n }\n // eslint-disable-next-line no-empty, no-catch-all/no-catch-all\n } catch {}\n}\n\nenum ContentTokenType {\n Raw,\n Command,\n Json,\n Path,\n Link,\n Heading,\n SubHeading,\n Italic,\n ErrorText,\n Yellow,\n Cyan,\n Magenta,\n Green,\n}\n\ninterface ContentMetadata {\n link?: string\n}\n\nclass ContentToken {\n type: ContentTokenType\n value: Message\n metadata: ContentMetadata\n\n constructor(value: Message, metadata: ContentMetadata = {}, type: ContentTokenType) {\n this.type = type\n this.value = value\n this.metadata = metadata\n }\n}\n\nexport const token = {\n raw: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Raw)\n },\n genericShellCommand: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Command)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new ContentToken(value, {}, ContentTokenType.Json)\n },\n path: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Path)\n },\n link: (value: Message, link: string) => {\n return new ContentToken(value, {link}, ContentTokenType.Link)\n },\n heading: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Heading)\n },\n subheading: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.SubHeading)\n },\n italic: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Italic)\n },\n errorText: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.ErrorText)\n },\n cyan: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Cyan)\n },\n yellow: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Yellow)\n },\n magenta: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Magenta)\n },\n green: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Green)\n },\n packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => {\n return new ContentToken(\n formatPackageManagerCommand(packageManager, scriptName, scriptArgs),\n {},\n ContentTokenType.Command,\n )\n },\n successIcon: () => {\n return new ContentToken('✔', {}, ContentTokenType.Green)\n },\n failIcon: () => {\n return new ContentToken('✖', {}, ContentTokenType.ErrorText)\n },\n}\n\nfunction formatPackageManagerCommand(packageManager: PackageManager, scriptName: string, scriptArgs: string[]): string {\n switch (packageManager) {\n case 'yarn': {\n const pieces = ['yarn', scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'pnpm':\n case 'npm': {\n const pieces = [packageManager, 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type Message = string | TokenizedString\n\nexport function content(strings: TemplateStringsArray, ...keys: (ContentToken | string)[]): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumToken = token as ContentToken\n switch (enumToken.type) {\n case ContentTokenType.Raw:\n output += enumToken.value\n break\n case ContentTokenType.Command:\n output += colors.bold(colors.yellow(stringifyMessage(enumToken.value)))\n break\n case ContentTokenType.Path:\n output += relativizePath(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Json:\n try {\n output += cjs(stringifyMessage(enumToken.value) ?? {})\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_) {\n output += JSON.stringify(stringifyMessage(enumToken.value) ?? {}, null, 2)\n }\n break\n case ContentTokenType.Link:\n output += terminalLink(colors.green(stringifyMessage(enumToken.value)), enumToken.metadata.link ?? '')\n break\n case ContentTokenType.Heading:\n output += colors.bold.underline(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.SubHeading:\n output += colors.underline(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Italic:\n output += colors.italic(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.ErrorText:\n output += colors.bold.redBright(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Yellow:\n output += colors.yellow(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Cyan:\n output += colors.cyan(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Magenta:\n output += colors.magenta(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Green:\n output += colors.green(stringifyMessage(enumToken.value))\n break\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n * @param level {LogLevel} The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nconst logLevelValue = (level: LogLevel): number => {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n *\n * @returns {LogLevel} It returns the log level set by the user.\n */\nexport const currentLogLevel = (): LogLevel => {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\nexport const shouldOutput = (logLevel: LogLevel): boolean => {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n * @param key {string} The key of the log.\n * @param content {string} The content of the log.\n */\nconst collectLog = (key: string, content: Message) => {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = () => {\n collectedLogs = {}\n}\n\n/**\n * Ouputs information to the user. This is akin to \"console.log\"\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n */\nexport const info = (content: Message) => {\n if (isUnitTest()) collectLog('info', content)\n message(content, 'info')\n}\n\n/**\n * Outputs a success message to the user.\n * Success message receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n */\nexport const success = (content: Message) => {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', consoleLog, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n */\nexport const completed = (content: Message) => {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', consoleLog, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n */\nexport const debug = (content: Message) => {\n if (isUnitTest()) collectLog('debug', content)\n message(colors.gray(stringifyMessage(content)), 'debug')\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n */\nexport const warn = (content: Message) => {\n if (isUnitTest()) collectLog('warn', content)\n consoleWarn(colors.yellow(stringifyMessage(content)))\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport const newline = () => {\n console.log()\n}\n\n/**\n * Formats and outputs a fatal error.\n * Note: This API is not intended to be used internally. If you want to\n * abort the execution due to an error, raise a fatal error and let the\n * error handler handle and format it.\n * @param content {Fatal} The fatal error to be output.\n */\nexport const error = async (content: Fatal) => {\n if (!content.message) {\n return\n }\n let outputString = ''\n const message = content.message\n const padding = ' '\n const header = colors.redBright(`\\n━━━━━━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n`)\n const footer = colors.redBright('\\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n')\n outputString += header\n const lines = message.split('\\n')\n for (const line of lines) {\n outputString += `${padding}${line}\\n`\n }\n if (content.tryMessage) {\n outputString += `\\n${padding}${colors.bold('What to try:')}\\n`\n const lines = content.tryMessage.split('\\n')\n for (const line of lines) {\n outputString += `${padding}${line}\\n`\n }\n }\n\n let stack = await new StackTracey(content).withSourcesAsync()\n stack = stack\n .filter((entry) => {\n return !entry.file.includes('@oclif/core')\n })\n .map((item) => {\n item.calleeShort = colors.yellow(item.calleeShort)\n /** We make the paths relative to the packages/ directory */\n const fileShortComponents = item.fileShort.split('packages/')\n item.fileShort = fileShortComponents.length === 2 ? fileShortComponents[1] : fileShortComponents[0]\n return item\n })\n if (content instanceof Bug) {\n if (stack.items.length !== 0) {\n outputString += `\\n${padding}${colors.bold('Stack trace:')}\\n`\n const stackLines = stack.asTable({}).split('\\n')\n for (const stackLine of stackLines) {\n outputString += `${padding}${stackLine}\\n`\n }\n }\n }\n outputString += footer\n outputWhereAppropriate('error', consoleError, outputString)\n}\n\nexport function stringifyMessage(message: Message): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nconst message = (content: Message, level: LogLevel = 'info') => {\n const stringifiedMessage = stringifyMessage(content)\n outputWhereAppropriate(level, consoleLog, stringifiedMessage)\n}\n\nexport interface OutputProcess {\n /** The prefix to include in the logs\n * [vite] Output coming from Vite\n */\n prefix: string\n /**\n * A callback to invoke the process. stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\n/**\n * Use this function when you have multiple concurrent processes that send data events\n * and we need to output them ensuring that they can visually differenciated by the user.\n *\n * @param processes {OutputProcess[]} A list of processes to run concurrently.\n */\nexport async function concurrent(\n processes: OutputProcess[],\n callback: ((signal: AbortSignal) => void) | undefined = undefined,\n) {\n const abortController = new AbortController()\n\n // eslint-disable-next-line node/callback-return\n if (callback) callback(abortController.signal)\n\n const concurrentColors = [token.yellow, token.cyan, token.magenta, token.green]\n const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length))\n\n function linePrefix(prefix: string, index: number) {\n const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length\n const color = concurrentColors[colorIndex]\n return color(`${prefix}${' '.repeat(prefixColumnSize - prefix.length)} ${colors.bold('|')} `)\n }\n\n try {\n await Promise.all(\n processes.map(async (process, index) => {\n const stdout = new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\\n/)\n for (const line of lines) {\n info(content`${linePrefix(process.prefix, index)}${line}`)\n }\n next()\n },\n })\n const stderr = new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\\n/)\n for (const line of lines) {\n message(content`${linePrefix(process.prefix, index)}${colors.bold(line)}`, 'error')\n }\n next()\n },\n })\n await process.action(stdout, stderr, abortController.signal)\n }),\n )\n } catch (_error) {\n // We abort any running process\n abortController.abort()\n throw _error\n }\n}\n\n/**\n * This regex can be used to find the erase cursor Ansii characters\n * to strip them from the string.\n * https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#erase-functions\n */\nconst eraseCursorAnsiRegex = [\n // Erase the entire line\n '2K',\n // Clear vertical tab stop at current line\n '1G',\n]\n .map((element) => `[\\\\u001B\\\\u009B][[\\\\]()#;?]*${element}`)\n .join('|')\n\n/**\n * The data sent through the standard pipelines of the sub-processes that we execute\n * might contain ansii escape characters to move the cursor. That causes any additional\n * formatting to break. This function takes a string and strips escape characters that\n * manage the cursor in the terminal.\n * @param value {string} String whose erase cursor escape characters will be stripped.\n * @returns {string} Stripped string.\n */\nfunction stripAnsiEraseCursorEscapeCharacters(value: string): string {\n return value.replace(/(\\n)$/, '').replace(new RegExp(eraseCursorAnsiRegex, 'g'), '')\n}\n\nfunction consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nfunction consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nfunction consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nfunction outputWhereAppropriate(logLevel: LogLevel, logFunc: (message: string) => void, message: string): void {\n if (shouldOutput(logLevel)) {\n logFunc(message)\n }\n logToFile(message, logLevel.toUpperCase())\n}\n\nexport function logFileExists(): boolean {\n return Boolean(logFile)\n}\n\n// DO NOT USE THIS FUNCTION DIRECTLY under normal circumstances.\n// It is exported purely for use in cases where output is already being logged\n// to the terminal but is not reflected in the logfile, e.g. Listr output.\nexport function logToFile(message: string, logLevel: string): void {\n // If file logging hasn't been initiated, skip it\n if (!logFileExists()) return\n const timestamp = new Date().toISOString()\n fileAppend(logFile, `[${timestamp} ${logLevel}]: ${message}\\n`)\n}\n\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\nexport function unstyled(message: string): string {\n return colors.unstyle(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\nexport async function pageLogs() {\n await page(logFile)\n}\n\n/**\n *\n * @param packageManager {PackageManager} The package manager that is being used.\n * @param version {string} The version to update to\n * @returns {te}\n */\nexport function getOutputUpdateCLIReminder(packageManager: PackageManager, version: string): string {\n const updateCommand = token.packagejsonScript(packageManager, 'shopify', 'upgrade')\n return content`💡 Version ${version} available! Run ${updateCommand}`.value\n}\n\n/* eslint-enable no-console */\n"]}
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAQ,GAAG,EAAE,yBAAyB,EAAC,MAAM,YAAY,CAAA;AAChE,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC5D,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAEtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAC1C,OAAO,EACL,SAAS,IAAI,aAAa,EAC1B,QAAQ,IAAI,YAAY,EACxB,QAAQ,IAAI,YAAY,EACxB,SAAS,IAAI,aAAa,EAC1B,SA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,CAAA;IACnF,OAAO,OAAO,CAAA,cAAc,OAAO,mBAAmB,aAAa,EAAE,CAAC,KAAK,CAAA;AAC7E,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {Fatal, Bug, cleanSingleStackTracePath} from './error.js'\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport constants from './constants.js'\nimport {PackageManager} from './node/node-package-manager.js'\nimport {generateRandomUUID} from './id.js'\nimport {\n mkdirSync as fileMkdirSync,\n readSync as fileReadSync,\n sizeSync as fileSizeSync,\n writeSync as fileWriteSync,\n touchSync as fileTouchSync,\n} from './file.js'\nimport {join as pathJoin, relativize as relativizePath} from './path.js'\nimport {page} from './system.js'\nimport {colors} from './node/colors.js'\nimport terminalLink from 'terminal-link'\nimport StackTracey from 'stacktracey'\nimport {AbortController, AbortSignal} from 'abort-controller'\nimport cjs from 'color-json'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'node:stream'\nimport {WriteStream, createWriteStream} from 'node:fs'\n\nexport {default as logUpdate} from 'log-update'\n\nconst logFileName = 'shopify.cli.log'\nlet logFileStream: WriteStream\nlet commandUuid: string\n\nexport function initiateLogging(options: {logDir?: string} = {}) {\n if (isUnitTest()) return\n const logDir = options.logDir || constants.paths.directories.cache.path()\n commandUuid = generateRandomUUID()\n fileMkdirSync(logDir)\n const logFile = pathJoin(logDir, logFileName)\n fileTouchSync(logFile)\n truncateLogs(logFile)\n logFileStream = createWriteStream(logFile, {flags: 'a'})\n}\n\n// Shaves off the first 10,000 log lines (circa 1MB) if logs are over 5MB long.\n// Rescues in case the file hasn't been created yet.\nfunction truncateLogs(logFile: string): void {\n try {\n if (fileSizeSync(logFile) > 5 * 1024 * 1024) {\n const contents = fileReadSync(logFile)\n const splitContents = contents.split('\\n')\n const newContents = splitContents.slice(10000, splitContents.length).join('\\n')\n fileWriteSync(logFile, newContents)\n }\n // eslint-disable-next-line no-empty, no-catch-all/no-catch-all\n } catch {}\n}\n\nenum ContentTokenType {\n Raw,\n Command,\n Json,\n Path,\n Link,\n Heading,\n SubHeading,\n Italic,\n ErrorText,\n Yellow,\n Cyan,\n Magenta,\n Green,\n}\n\ninterface ContentMetadata {\n link?: string\n}\n\nexport type Logger = (message: string) => void\n\nclass ContentToken {\n type: ContentTokenType\n value: Message\n metadata: ContentMetadata\n\n constructor(value: Message, metadata: ContentMetadata = {}, type: ContentTokenType) {\n this.type = type\n this.value = value\n this.metadata = metadata\n }\n}\n\nexport const token = {\n raw: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Raw)\n },\n genericShellCommand: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Command)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new ContentToken(value, {}, ContentTokenType.Json)\n },\n path: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Path)\n },\n link: (value: Message, link: string) => {\n return new ContentToken(value, {link}, ContentTokenType.Link)\n },\n heading: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Heading)\n },\n subheading: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.SubHeading)\n },\n italic: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Italic)\n },\n errorText: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.ErrorText)\n },\n cyan: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Cyan)\n },\n yellow: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Yellow)\n },\n magenta: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Magenta)\n },\n green: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Green)\n },\n packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => {\n return new ContentToken(\n formatPackageManagerCommand(packageManager, scriptName, scriptArgs),\n {},\n ContentTokenType.Command,\n )\n },\n successIcon: () => {\n return new ContentToken('✔', {}, ContentTokenType.Green)\n },\n failIcon: () => {\n return new ContentToken('✖', {}, ContentTokenType.ErrorText)\n },\n}\n\nfunction formatPackageManagerCommand(packageManager: PackageManager, scriptName: string, scriptArgs: string[]): string {\n switch (packageManager) {\n case 'yarn': {\n const pieces = ['yarn', scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'pnpm':\n case 'npm': {\n const pieces = [packageManager, 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type Message = string | TokenizedString\n\nexport function content(strings: TemplateStringsArray, ...keys: (ContentToken | string)[]): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumToken = token as ContentToken\n switch (enumToken.type) {\n case ContentTokenType.Raw:\n output += enumToken.value\n break\n case ContentTokenType.Command:\n output += colors.bold(colors.yellow(stringifyMessage(enumToken.value)))\n break\n case ContentTokenType.Path:\n output += relativizePath(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Json:\n try {\n output += cjs(stringifyMessage(enumToken.value) ?? {})\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_) {\n output += JSON.stringify(stringifyMessage(enumToken.value) ?? {}, null, 2)\n }\n break\n case ContentTokenType.Link:\n output += terminalLink(colors.green(stringifyMessage(enumToken.value)), enumToken.metadata.link ?? '')\n break\n case ContentTokenType.Heading:\n output += colors.bold.underline(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.SubHeading:\n output += colors.underline(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Italic:\n output += colors.italic(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.ErrorText:\n output += colors.bold.redBright(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Yellow:\n output += colors.yellow(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Cyan:\n output += colors.cyan(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Magenta:\n output += colors.magenta(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Green:\n output += colors.green(stringifyMessage(enumToken.value))\n break\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n * @param level {LogLevel} The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nconst logLevelValue = (level: LogLevel): number => {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n *\n * @returns {LogLevel} It returns the log level set by the user.\n */\nexport const currentLogLevel = (): LogLevel => {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\nexport const shouldOutput = (logLevel: LogLevel): boolean => {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n * @param key {string} The key of the log.\n * @param content {string} The content of the log.\n */\nconst collectLog = (key: string, content: Message) => {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = () => {\n collectedLogs = {}\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n * @param logger {Function} The logging function to use to output to the user.\n */\nexport const info = (content: Message, logger: Logger = consoleLog) => {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n * @param logger {Function} The logging function to use to output to the user.\n */\nexport const success = (content: Message, logger: Logger = consoleLog) => {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n * @param logger {Function} The logging function to use to output to the user.\n */\nexport const completed = (content: Message, logger: Logger = consoleLog) => {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n * @param logger {Function} The logging function to use to output to the user.\n */\nexport const debug = (content: Message, logger: Logger = consoleLog) => {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, message)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n * @param logger {Function} The logging function to use to output to the user.\n */\nexport const warn = (content: Message, logger: Logger = consoleWarn) => {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport const newline = () => {\n console.log()\n}\n\n/**\n * Formats and outputs a fatal error.\n * Note: This API is not intended to be used internally. If you want to\n * abort the execution due to an error, raise a fatal error and let the\n * error handler handle and format it.\n * @param content {Fatal} The fatal error to be output.\n */\nexport const error = async (content: Fatal) => {\n if (!content.message) {\n return\n }\n let outputString = ''\n const message = content.message\n const padding = ' '\n const header = colors.redBright(`\\n━━━━━━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n`)\n const footer = colors.redBright('\\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n')\n outputString += header\n const lines = message.split('\\n')\n for (const line of lines) {\n outputString += `${padding}${line}\\n`\n }\n if (content.tryMessage) {\n outputString += `\\n${padding}${colors.bold('What to try:')}\\n`\n const lines = content.tryMessage.split('\\n')\n for (const line of lines) {\n outputString += `${padding}${line}\\n`\n }\n }\n\n let stack = new StackTracey(content)\n stack.items.forEach((item) => {\n item.file = cleanSingleStackTracePath(item.file)\n })\n\n stack = await stack.withSourcesAsync()\n stack = stack\n .filter((entry) => {\n return !entry.file.includes('@oclif/core')\n })\n .map((item) => {\n item.calleeShort = colors.yellow(item.calleeShort)\n /** We make the paths relative to the packages/ directory */\n const fileShortComponents = item.fileShort.split('packages/')\n item.fileShort = fileShortComponents.length === 2 ? fileShortComponents[1] : fileShortComponents[0]\n return item\n })\n if (content instanceof Bug) {\n if (stack.items.length !== 0) {\n outputString += `\\n${padding}${colors.bold('Stack trace:')}\\n`\n const stackLines = stack.asTable({}).split('\\n')\n for (const stackLine of stackLines) {\n outputString += `${padding}${stackLine}\\n`\n }\n }\n }\n outputString += footer\n outputWhereAppropriate('error', consoleError, outputString)\n}\n\nexport function stringifyMessage(message: Message): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nconst message = (content: Message, level: LogLevel = 'info') => {\n const stringifiedMessage = stringifyMessage(content)\n outputWhereAppropriate(level, consoleLog, stringifiedMessage)\n}\n\nexport interface OutputProcess {\n /** The prefix to include in the logs\n * [vite] Output coming from Vite\n */\n prefix: string\n /**\n * A callback to invoke the process. stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\n/**\n * Use this function when you have multiple concurrent processes that send data events\n * and we need to output them ensuring that they can visually differenciated by the user.\n *\n * @param processes {OutputProcess[]} A list of processes to run concurrently.\n */\nexport async function concurrent(\n processes: OutputProcess[],\n callback: ((signal: AbortSignal) => void) | undefined = undefined,\n) {\n const abortController = new AbortController()\n\n // eslint-disable-next-line node/callback-return\n if (callback) callback(abortController.signal)\n\n const concurrentColors = [token.yellow, token.cyan, token.magenta, token.green]\n const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length))\n\n function linePrefix(prefix: string, index: number) {\n const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length\n const color = concurrentColors[colorIndex]\n return color(`${prefix}${' '.repeat(prefixColumnSize - prefix.length)} ${colors.bold('|')} `)\n }\n\n try {\n await Promise.all(\n processes.map(async (process, index) => {\n const stdout = new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\\n/)\n for (const line of lines) {\n info(content`${linePrefix(process.prefix, index)}${line}`)\n }\n next()\n },\n })\n const stderr = new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\\n/)\n for (const line of lines) {\n message(content`${linePrefix(process.prefix, index)}${colors.bold(line)}`, 'error')\n }\n next()\n },\n })\n await process.action(stdout, stderr, abortController.signal)\n }),\n )\n } catch (_error) {\n // We abort any running process\n abortController.abort()\n throw _error\n }\n}\n\n/**\n * This regex can be used to find the erase cursor Ansii characters\n * to strip them from the string.\n * https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#erase-functions\n */\nconst eraseCursorAnsiRegex = [\n // Erase the entire line\n '2K',\n // Clear vertical tab stop at current line\n '1G',\n]\n .map((element) => `[\\\\u001B\\\\u009B][[\\\\]()#;?]*${element}`)\n .join('|')\n\n/**\n * The data sent through the standard pipelines of the sub-processes that we execute\n * might contain ansii escape characters to move the cursor. That causes any additional\n * formatting to break. This function takes a string and strips escape characters that\n * manage the cursor in the terminal.\n * @param value {string} String whose erase cursor escape characters will be stripped.\n * @returns {string} Stripped string.\n */\nfunction stripAnsiEraseCursorEscapeCharacters(value: string): string {\n return value.replace(/(\\n)$/, '').replace(new RegExp(eraseCursorAnsiRegex, 'g'), '')\n}\n\nfunction consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nfunction consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nfunction consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nfunction outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n logger(message)\n }\n logToFile(message, logLevel.toUpperCase())\n}\n\nexport function logFileExists(): boolean {\n return Boolean(logFileStream)\n}\n\n// DO NOT USE THIS FUNCTION DIRECTLY under normal circumstances.\n// It is exported purely for use in cases where output is already being logged\n// to the terminal but is not reflected in the logfile, e.g. Listr output.\nexport function logToFile(message: string, logLevel: string): void {\n // If file logging hasn't been initiated, skip it\n if (!logFileExists()) return\n const timestamp = new Date().toISOString()\n const logContents = `[${timestamp} ${commandUuid} ${logLevel}]: ${message}\\n`\n logFileStream.write(logContents)\n}\n\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\nexport function unstyled(message: string): string {\n return colors.unstyle(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\nexport async function pageLogs({lastCommand}: {lastCommand: boolean}) {\n const logDir = constants.paths.directories.cache.path()\n const logFile = pathJoin(logDir, logFileName)\n // Ensure file exists in case they deleted it or something\n fileTouchSync(logFile)\n if (lastCommand) {\n printLastCommand(logFile)\n } else {\n await page(logFile)\n }\n}\n\nfunction printLastCommand(logFile: string): void {\n const contents = fileReadSync(logFile).split('\\n')\n const uuids = contents\n .map(logfileLineUUID)\n .filter((uuid) => uuid)\n .reverse()\n // 2nd unique UUID, because the currently running command will be the 1st\n const relevantUuid = Array.from(new Set(uuids))[1]\n if (relevantUuid) {\n consoleLog(relevantLines(contents, relevantUuid).join('\\n'))\n }\n}\n\nfunction relevantLines(contents: string[], relevantUuid: string): string[] {\n // We run through the file line by line, keeping track of the most recently\n // encountered UUID.\n //\n // If the current line has a UUID, it's a new logged unit and should be\n // considered. Otherwise, the line is related to the most recent UUID.\n let mostRecentUuid = ''\n return contents.filter((line: string) => {\n const currentUuid = logfileLineUUID(line) || mostRecentUuid\n mostRecentUuid = currentUuid\n return currentUuid === relevantUuid\n })\n}\n\nfunction logfileLineUUID(line: string): string | null {\n // Log lines look like:\n //\n // timestamp UUID contents\n // ===========================================================================================\n // [2022-07-20T08:51:40.296Z 5288e1da-a06a-4f96-b1a6-e34fcdd7b416 DEBUG]: Running command logs\n // ===========================================================================================\n //\n // There may be subsequent lines if the contents section is multi-line.\n //\n const match = line.match(/^\\[\\S+ ([0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}) [A-Z]+\\]/)\n return match && match[1]\n}\n\n/**\n *\n * @param packageManager {PackageManager} The package manager that is being used.\n * @param version {string} The version to update to\n * @returns {te}\n */\nexport function getOutputUpdateCLIReminder(packageManager: PackageManager, version: string): string {\n const updateCommand = token.packagejsonScript(packageManager, 'shopify', 'upgrade')\n return content`💡 Version ${version} available! Run ${updateCommand}`.value\n}\n\n/* eslint-enable no-console */\n"]}
|
package/dist/path.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { OverloadParameters } from './typing/overloaded-parameters.js';
|
|
1
2
|
import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute } from 'pathe';
|
|
2
|
-
import { findUp as internalFindUp
|
|
3
|
+
import { findUp as internalFindUp } from 'find-up';
|
|
3
4
|
export { join, relative, dirname, normalize, resolve, basename, extname, isAbsolute };
|
|
4
5
|
export { default as glob } from 'fast-glob';
|
|
5
6
|
export { pathToFileURL } from 'node:url';
|
|
6
|
-
declare
|
|
7
|
-
export declare function findUp(matcher: string | ReadonlyArray<string> | FindUpMatcher, options: Parameters<typeof internalFindUp>[1]): ReturnType<typeof internalFindUp>;
|
|
7
|
+
export declare function findUp(matcher: OverloadParameters<typeof internalFindUp>[0], options: OverloadParameters<typeof internalFindUp>[1]): ReturnType<typeof internalFindUp>;
|
|
8
8
|
/**
|
|
9
9
|
* Given an absolute filesystem path, it makes it relative to
|
|
10
10
|
* the current working directory. This is useful when logging paths
|
package/dist/path.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
-
// @ts-ignore
|
|
3
1
|
import commondir from 'commondir';
|
|
4
2
|
import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute } from 'pathe';
|
|
5
3
|
import { findUp as internalFindUp } from 'find-up';
|
|
@@ -8,8 +6,8 @@ export { join, relative, dirname, normalize, resolve, basename, extname, isAbsol
|
|
|
8
6
|
export { default as glob } from 'fast-glob';
|
|
9
7
|
export { pathToFileURL } from 'node:url';
|
|
10
8
|
export async function findUp(matcher, options) {
|
|
11
|
-
//
|
|
12
|
-
// @
|
|
9
|
+
// findUp has odd typing
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
11
|
const got = await internalFindUp(matcher, options);
|
|
14
12
|
return got ? normalize(got) : undefined;
|
|
15
13
|
}
|
package/dist/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAA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AO,IAAI,CAAA;KACZ;SAAM;QACL,OAAO,YAAY,CAAA;KACpB;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB;IACrD,OAAO,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {OverloadParameters} from './typing/overloaded-parameters.js'\nimport commondir from 'commondir'\nimport {relative, dirname, join, normalize, resolve, basename, extname, isAbsolute} from 'pathe'\nimport {findUp as internalFindUp, Match as FindUpMatch} from 'find-up'\nimport {fileURLToPath} from 'url'\n\nexport {join, relative, dirname, normalize, resolve, basename, extname, isAbsolute}\n\nexport {default as glob} from 'fast-glob'\nexport {pathToFileURL} from 'node:url'\n\ntype FindUpMatcher = (directory: string) => FindUpMatch | Promise<FindUpMatch>\n\nexport async function findUp(\n matcher: OverloadParameters<typeof internalFindUp>[0],\n options: OverloadParameters<typeof internalFindUp>[1],\n): ReturnType<typeof internalFindUp> {\n // findUp has odd typing\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const got = await internalFindUp(matcher as any, options)\n return got ? normalize(got) : undefined\n}\n\n/**\n * Given an absolute filesystem path, it makes it relative to\n * the current working directory. This is useful when logging paths\n * to allow the users to click on the file and let the OS open it\n * in the editor of choice.\n * @param path {string} Path to relativize\n * @returns {string} Relativized path.\n */\nexport function relativize(path: string): string {\n const result = commondir([path, process.cwd()])\n const relativePath = relative(process.cwd(), path)\n const relativeComponents = relativePath.split('/').filter((component) => component === '..').length\n if (result === '/' || relativePath === '' || relativeComponents > 2) {\n return path\n } else {\n return relativePath\n }\n}\n\n/**\n * Given a module's import.meta.url it returns the directory containing the module.\n * @param moduleURL {string} The value of import.meta.url in the context of the caller module.\n * @returns {string} The path to the directory containing the caller module.\n */\nexport function moduleDirectory(moduleURL: string | URL): string {\n return dirname(fileURLToPath(moduleURL))\n}\n"]}
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,9 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schemas } from './monorail.js';
|
|
2
|
+
import { Interfaces } from '@oclif/core';
|
|
2
3
|
interface TunnelPlugin {
|
|
3
4
|
start: (options: TunnelStartOptions) => Promise<string>;
|
|
4
5
|
}
|
|
5
6
|
interface TunnelStartOptions {
|
|
6
7
|
port: number;
|
|
7
8
|
}
|
|
8
|
-
export declare function lookupTunnelPlugin(plugins: Plugin[]): Promise<TunnelPlugin | undefined>;
|
|
9
|
+
export declare function lookupTunnelPlugin(plugins: Interfaces.Plugin[]): Promise<TunnelPlugin | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.
|
|
12
|
+
*
|
|
13
|
+
* Responses are organised into a dictionary, keyed by plug-in name. Only plug-ins that have hooks registered for the given event, and the hooks were run successfully, are included.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fanoutHooks<TPluginMap extends HookReturnsPerPlugin, TEvent extends string & keyof TPluginMap>(config: Interfaces.Config, event: TEvent, options: TPluginMap[typeof event]['options'], timeout?: number): Promise<Partial<TPluginMap[typeof event]['pluginReturns']>>;
|
|
16
|
+
interface HookReturnsPerPlugin {
|
|
17
|
+
public_command_metadata: {
|
|
18
|
+
options: {
|
|
19
|
+
[key: string]: never;
|
|
20
|
+
};
|
|
21
|
+
pluginReturns: {
|
|
22
|
+
'@shopify/app': Partial<Pick<Schemas['app_cli3_command/1.0']['public'], 'project_type' | 'api_key' | 'partner_id'> & {
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
[pluginName: string]: {
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
[hookName: string]: {
|
|
31
|
+
options: {
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
};
|
|
34
|
+
pluginReturns: {
|
|
35
|
+
[key: string]: {
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
declare type PluginReturnsForHook<TEvent extends keyof TPluginMap, TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'], TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin> = TPluginMap[TEvent]['pluginReturns'][TPluginName];
|
|
42
|
+
export declare type FanoutHookFunction<TEvent extends keyof TPluginMap = string, TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'] = string, TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin> = (this: Interfaces.Hook.Context, options: TPluginMap[TEvent]['options'] & {
|
|
43
|
+
config: Interfaces.Config;
|
|
44
|
+
}) => Promise<Partial<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>>;
|
|
9
45
|
export {};
|
package/dist/plugins.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1
2
|
import { join, pathToFileURL } from './path.js';
|
|
2
3
|
import { debug, content } from './output.js';
|
|
3
4
|
const TUNNEL_PLUGINS = ['@shopify/plugin-ngrok'];
|
|
@@ -9,4 +10,14 @@ export async function lookupTunnelPlugin(plugins) {
|
|
|
9
10
|
const tunnelPath = pathToFileURL(join(tunnelPlugin.root, 'dist/tunnel.js')).toString();
|
|
10
11
|
return import(tunnelPath).catch(() => undefined);
|
|
11
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.
|
|
15
|
+
*
|
|
16
|
+
* Responses are organised into a dictionary, keyed by plug-in name. Only plug-ins that have hooks registered for the given event, and the hooks were run successfully, are included.
|
|
17
|
+
*/
|
|
18
|
+
export async function fanoutHooks(config, event, options, timeout) {
|
|
19
|
+
const res = await config.runHook(event, options, timeout);
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
return Object.fromEntries(res.successes.map(({ result, plugin }) => [plugin.name, result]));
|
|
22
|
+
}
|
|
12
23
|
//# sourceMappingURL=plugins.js.map
|
package/dist/plugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,aAAa,EAAC,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAC,IAAI,EAAE,aAAa,EAAC,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,MAAM,aAAa,CAAA;AAI1C,MAAM,cAAc,GAAG,CAAC,uBAAuB,CAAC,CAAA;AAUhD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA4B;IACnE,KAAK,CAAC,OAAO,CAAA,uCAAuC,CAAC,CAAA;IACrD,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IACnF,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAA;IACnC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IACtF,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAyB,EACzB,KAAa,EACb,OAA4C,EAC5C,OAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACzD,8DAA8D;IAC9D,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAC,MAAM,EAAE,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAQ,CAAA;AAClG,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport {join, pathToFileURL} from './path.js'\nimport {debug, content} from './output.js'\nimport {Schemas} from './monorail.js'\nimport {Interfaces} from '@oclif/core'\n\nconst TUNNEL_PLUGINS = ['@shopify/plugin-ngrok']\n\ninterface TunnelPlugin {\n start: (options: TunnelStartOptions) => Promise<string>\n}\n\ninterface TunnelStartOptions {\n port: number\n}\n\nexport async function lookupTunnelPlugin(plugins: Interfaces.Plugin[]): Promise<TunnelPlugin | undefined> {\n debug(content`Looking up the Ngrok tunnel plugin...`)\n const tunnelPlugin = plugins.find((plugin) => TUNNEL_PLUGINS.includes(plugin.name))\n if (!tunnelPlugin) return undefined\n const tunnelPath = pathToFileURL(join(tunnelPlugin.root, 'dist/tunnel.js')).toString()\n return import(tunnelPath).catch(() => undefined)\n}\n\n/**\n * Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.\n *\n * Responses are organised into a dictionary, keyed by plug-in name. Only plug-ins that have hooks registered for the given event, and the hooks were run successfully, are included.\n */\nexport async function fanoutHooks<TPluginMap extends HookReturnsPerPlugin, TEvent extends string & keyof TPluginMap>(\n config: Interfaces.Config,\n event: TEvent,\n options: TPluginMap[typeof event]['options'],\n timeout?: number,\n): Promise<Partial<TPluginMap[typeof event]['pluginReturns']>> {\n const res = await config.runHook(event, options, timeout)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Object.fromEntries(res.successes.map(({result, plugin}) => [plugin.name, result])) as any\n}\n\ninterface HookReturnsPerPlugin {\n public_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<\n Pick<Schemas['app_cli3_command/1.0']['public'], 'project_type' | 'api_key' | 'partner_id'> & {\n [key: string]: unknown\n }\n >\n [pluginName: string]: {[key: string]: unknown}\n }\n }\n [hookName: string]: {\n options: {[key: string]: unknown}\n pluginReturns: {[key: string]: {[key: string]: unknown}}\n }\n}\n\ntype PluginReturnsForHook<\n TEvent extends keyof TPluginMap,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'],\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = TPluginMap[TEvent]['pluginReturns'][TPluginName]\n\nexport type FanoutHookFunction<\n TEvent extends keyof TPluginMap = string,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'] = string,\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = (\n this: Interfaces.Hook.Context,\n options: TPluginMap[TEvent]['options'] & {config: Interfaces.Config},\n) => Promise<Partial<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>>\n"]}
|
|
@@ -2,10 +2,12 @@ import { listenRedirect } from './redirect-listener.js';
|
|
|
2
2
|
import { clientId } from './identity.js';
|
|
3
3
|
import { generateRandomChallengePair, randomHex } from '../string.js';
|
|
4
4
|
import { open } from '../system.js';
|
|
5
|
-
import { Abort } from '../error.js';
|
|
5
|
+
import { Abort, CancelExecution } from '../error.js';
|
|
6
6
|
import { identity as identityFqdn } from '../environment/fqdn.js';
|
|
7
7
|
import * as output from '../output.js';
|
|
8
|
-
import { keypress } from '../ui.js';
|
|
8
|
+
import { keypress, terminateBlockingPortProcessPrompt } from '../ui.js';
|
|
9
|
+
import { checkPort as isPortAvailable } from 'get-port-please';
|
|
10
|
+
import { killPortProcess } from 'kill-port-process';
|
|
9
11
|
export const MismatchStateError = new Abort("The state received from the authentication doesn't match the one that initiated the authentication process.");
|
|
10
12
|
export async function authorize(scopes, state = randomHex(30)) {
|
|
11
13
|
const port = 3456;
|
|
@@ -13,9 +15,9 @@ export async function authorize(scopes, state = randomHex(30)) {
|
|
|
13
15
|
const redirectUri = `http://${host}:${port}`;
|
|
14
16
|
const fqdn = await identityFqdn();
|
|
15
17
|
const identityClientId = await clientId();
|
|
18
|
+
await validateRedirectionPortAvailability(port);
|
|
16
19
|
let url = `http://${fqdn}/oauth/authorize`;
|
|
17
20
|
const { codeVerifier, codeChallenge } = generateRandomChallengePair();
|
|
18
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
19
21
|
const params = {
|
|
20
22
|
client_id: identityClientId,
|
|
21
23
|
scope: scopes.join(' '),
|
|
@@ -25,7 +27,6 @@ export async function authorize(scopes, state = randomHex(30)) {
|
|
|
25
27
|
code_challenge_method: 'S256',
|
|
26
28
|
code_challenge: codeChallenge,
|
|
27
29
|
};
|
|
28
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
29
30
|
output.info('\nTo run this command, log in to Shopify Partners.');
|
|
30
31
|
output.info('👉 Press any key to open the login page on your browser');
|
|
31
32
|
await keypress();
|
|
@@ -37,4 +38,15 @@ export async function authorize(scopes, state = randomHex(30)) {
|
|
|
37
38
|
}
|
|
38
39
|
return { code: result.code, codeVerifier };
|
|
39
40
|
}
|
|
41
|
+
async function validateRedirectionPortAvailability(port) {
|
|
42
|
+
if (await isPortAvailable(port)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (await terminateBlockingPortProcessPrompt(port, 'Authentication')) {
|
|
46
|
+
await killPortProcess(port);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw new CancelExecution();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
40
52
|
//# sourceMappingURL=authorize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../src/session/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,2BAA2B,EAAE,SAAS,EAAC,MAAM,c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,CAAA;IAE1C,MAAM,EAAC,YAAY,EAAE,aAAa,EAAC,GAAG,2BAA2B,EAAE,CAAA;IAEnE,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,gBAAgB;QAC3B,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QACvB,YAAY,EAAE,WAAW;QACzB,KAAK;QACL,aAAa,EAAE,MAAM;QACrB,qBAAqB,EAAE,MAAM;QAC7B,cAAc,EAAE,aAAa;KAC9B,CAAA;IAED,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;IACjE,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAA;IACtE,MAAM,QAAQ,EAAE,CAAA;IAEhB,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAA;IACxD,IAAI,CAAC,GAAG,CAAC,CAAA;IAET,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAEpD,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;QAC1B,MAAM,kBAAkB,CAAA;KACzB;IAED,OAAO,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,YAAY,EAAC,CAAA;AAC1C,CAAC;AAED,KAAK,UAAU,mCAAmC,CAAC,IAAY;IAC7D,IAAI,MAAM,eAAe,CAAC,IAAI,CAAC,EAAE;QAC/B,OAAM;KACP;IAED,IAAI,MAAM,kCAAkC,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE;QACpE,MAAM,eAAe,CAAC,IAAI,CAAC,CAAA;KAC5B;SAAM;QACL,MAAM,IAAI,eAAe,EAAE,CAAA;KAC5B;AACH,CAAC","sourcesContent":["import {listenRedirect} from './redirect-listener.js'\nimport {clientId} from './identity.js'\nimport {generateRandomChallengePair, randomHex} from '../string.js'\nimport {open} from '../system.js'\nimport {Abort, CancelExecution} from '../error.js'\nimport {identity as identityFqdn} from '../environment/fqdn.js'\nimport * as output from '../output.js'\nimport {keypress, terminateBlockingPortProcessPrompt} from '../ui.js'\nimport {checkPort as isPortAvailable} from 'get-port-please'\nimport {killPortProcess} from 'kill-port-process'\n\nexport const MismatchStateError = new Abort(\n \"The state received from the authentication doesn't match the one that initiated the authentication process.\",\n)\n\nexport interface CodeAuthResult {\n code: string\n codeVerifier: string\n}\n\nexport async function authorize(scopes: string[], state: string = randomHex(30)): Promise<CodeAuthResult> {\n const port = 3456\n const host = '127.0.0.1'\n const redirectUri = `http://${host}:${port}`\n const fqdn = await identityFqdn()\n const identityClientId = await clientId()\n\n await validateRedirectionPortAvailability(port)\n\n let url = `http://${fqdn}/oauth/authorize`\n\n const {codeVerifier, codeChallenge} = generateRandomChallengePair()\n\n const params = {\n client_id: identityClientId,\n scope: scopes.join(' '),\n redirect_uri: redirectUri,\n state,\n response_type: 'code',\n code_challenge_method: 'S256',\n code_challenge: codeChallenge,\n }\n\n output.info('\\nTo run this command, log in to Shopify Partners.')\n output.info('👉 Press any key to open the login page on your browser')\n await keypress()\n\n url = `${url}?${new URLSearchParams(params).toString()}`\n open(url)\n\n const result = await listenRedirect(host, port, url)\n\n if (result.state !== state) {\n throw MismatchStateError\n }\n\n return {code: result.code, codeVerifier}\n}\n\nasync function validateRedirectionPortAvailability(port: number) {\n if (await isPortAvailable(port)) {\n return\n }\n\n if (await terminateBlockingPortProcessPrompt(port, 'Authentication')) {\n await killPortProcess(port)\n } else {\n throw new CancelExecution()\n }\n}\n"]}
|