@shopify/cli-kit 3.21.0 → 3.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/analytics.d.ts +2 -2
- package/dist/analytics.js +3 -3
- package/dist/analytics.js.map +1 -1
- package/dist/api/graphql/extension_specifications.d.ts +15 -12
- package/dist/api/graphql/extension_specifications.js +2 -0
- package/dist/api/graphql/extension_specifications.js.map +1 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -2
- package/dist/constants.js.map +1 -1
- package/dist/content-tokens.js +1 -1
- package/dist/content-tokens.js.map +1 -1
- package/dist/environment/local.d.ts +0 -2
- package/dist/environment/local.js +0 -6
- package/dist/environment/local.js.map +1 -1
- package/dist/error.d.ts +9 -0
- package/dist/error.js +11 -0
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/log.d.ts +11 -2
- package/dist/log.js +39 -16
- package/dist/log.js.map +1 -1
- package/dist/metadata.js +1 -1
- package/dist/metadata.js.map +1 -1
- package/dist/output.d.ts +1 -1
- package/dist/output.js +1 -1
- package/dist/output.js.map +1 -1
- package/dist/plugins.d.ts +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/private/node/ui/components/Alert.d.ts +1 -1
- package/dist/private/node/ui/components/Alert.js.map +1 -1
- package/dist/private/node/ui/components/Banner.d.ts +1 -1
- package/dist/private/node/ui/components/Banner.js +25 -2
- package/dist/private/node/ui/components/Banner.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.js +11 -2
- package/dist/private/node/ui/components/FatalError.js.map +1 -1
- package/dist/public/common/object.d.ts +10 -0
- package/dist/public/common/object.js +17 -0
- package/dist/public/common/object.js.map +1 -0
- package/dist/public/common/string.d.ts +4 -0
- package/dist/{haiku.js → public/common/string.js} +9 -18
- package/dist/public/common/string.js.map +1 -0
- package/dist/{node → public/node}/archiver.d.ts +0 -0
- package/dist/{node → public/node}/archiver.js +2 -2
- package/dist/public/node/archiver.js.map +1 -0
- package/dist/{node → public/node}/base-command.d.ts +0 -0
- package/dist/{node → public/node}/base-command.js +8 -6
- package/dist/public/node/base-command.js.map +1 -0
- package/dist/{node → public/node}/checksum.d.ts +2 -2
- package/dist/{node → public/node}/checksum.js +4 -4
- package/dist/public/node/checksum.js.map +1 -0
- package/dist/{node → public/node}/cli.d.ts +0 -0
- package/dist/{node → public/node}/cli.js +7 -7
- package/dist/public/node/cli.js.map +1 -0
- package/dist/public/node/colors.d.ts +2 -0
- package/dist/public/node/colors.js +3 -0
- package/dist/public/node/colors.js.map +1 -0
- package/dist/{node → public/node}/dot-env.d.ts +2 -2
- package/dist/{node → public/node}/dot-env.js +4 -4
- package/dist/public/node/dot-env.js.map +1 -0
- package/dist/{node → public/node}/error-handler.d.ts +0 -0
- package/dist/{node → public/node}/error-handler.js +7 -7
- package/dist/public/node/error-handler.js.map +1 -0
- package/dist/{node → public/node}/framework.d.ts +0 -0
- package/dist/{node → public/node}/framework.js +1 -1
- package/dist/public/node/framework.js.map +1 -0
- package/dist/public/node/fs.d.ts +14 -0
- package/dist/public/node/fs.js +21 -0
- package/dist/public/node/fs.js.map +1 -0
- package/dist/{node → public/node}/hooks/postrun.d.ts +0 -0
- package/dist/{node → public/node}/hooks/postrun.js +2 -2
- package/dist/public/node/hooks/postrun.js.map +1 -0
- package/dist/{node → public/node}/hooks/prerun.d.ts +0 -0
- package/dist/{node → public/node}/hooks/prerun.js +2 -2
- package/dist/public/node/hooks/prerun.js.map +1 -0
- package/dist/{node → public/node}/node-package-manager.d.ts +3 -3
- package/dist/{node → public/node}/node-package-manager.js +9 -9
- package/dist/public/node/node-package-manager.js.map +1 -0
- package/dist/{plugins → public/node/plugins}/tunnel.d.ts +3 -3
- package/dist/{plugins → public/node/plugins}/tunnel.js +2 -2
- package/dist/public/node/plugins/tunnel.js.map +1 -0
- package/dist/{node → public/node}/ruby.d.ts +1 -1
- package/dist/{node → public/node}/ruby.js +9 -9
- package/dist/public/node/ruby.js.map +1 -0
- package/dist/session/exchange.js +1 -1
- package/dist/session/exchange.js.map +1 -1
- package/dist/system.js +2 -2
- package/dist/system.js.map +1 -1
- package/dist/testing/fixtures/render-concurrent.js +1 -1
- package/dist/testing/fixtures/render-concurrent.js.map +1 -1
- package/dist/testing/ui.js +1 -1
- package/dist/testing/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/inquirer/autocomplete.js +1 -2
- package/dist/ui/inquirer/autocomplete.js.map +1 -1
- package/dist/ui/inquirer/input.js +1 -2
- package/dist/ui/inquirer/input.js.map +1 -1
- package/dist/ui/inquirer/select.js +0 -1
- package/dist/ui/inquirer/select.js.map +1 -1
- package/dist/ui.js +1 -1
- package/dist/ui.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +4 -34
- package/dist/common/object.d.ts +0 -8
- package/dist/common/object.js +0 -12
- package/dist/common/object.js.map +0 -1
- package/dist/haiku.d.ts +0 -6
- package/dist/haiku.js.map +0 -1
- package/dist/node/archiver.js.map +0 -1
- package/dist/node/base-command.js.map +0 -1
- package/dist/node/checksum.js.map +0 -1
- package/dist/node/cli.js.map +0 -1
- package/dist/node/colors.d.ts +0 -2
- package/dist/node/colors.js +0 -3
- package/dist/node/colors.js.map +0 -1
- package/dist/node/dot-env.js.map +0 -1
- package/dist/node/error-handler.js.map +0 -1
- package/dist/node/framework.js.map +0 -1
- package/dist/node/hooks/init.d.ts +0 -2
- package/dist/node/hooks/init.js +0 -5
- package/dist/node/hooks/init.js.map +0 -1
- package/dist/node/hooks/postrun.js.map +0 -1
- package/dist/node/hooks/prerun.js.map +0 -1
- package/dist/node/node-package-manager.js.map +0 -1
- package/dist/node/ruby.js.map +0 -1
- package/dist/plugins/tunnel.js.map +0 -1
- package/dist/yaml.d.ts +0 -2
- package/dist/yaml.js +0 -8
- package/dist/yaml.js.map +0 -1
package/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K,CAAC,6DAA6D,CAAC,CAAA;IACvF,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,CAAE,CAAA;AAC3B,CAAC","sourcesContent":["import {isUnitTest} from './environment/local.js'\nimport constants from './constants.js'\nimport {generateRandomUUID} from './id.js'\nimport {\n mkdirSync as fileMkdirSync,\n sizeSync as fileSizeSync,\n touchSync as fileTouchSync,\n readSync as fileReadSync,\n} from './file.js'\nimport {join as pathJoin} from './path.js'\nimport {consoleLog} from './output.js'\nimport {page} from './system.js'\nimport {promisify} from 'node:util'\nimport {Stream, Transform, TransformCallback, TransformOptions} from 'node:stream'\nimport {WriteStream, createWriteStream, createReadStream, unlinkSync} from 'node:fs'\nimport {EOL} from 'node:os'\n\nconst logFileName = 'shopify.cli.log'\nconst maxLogFileSize = 5 * 1024 * 1024\nlet logFileStream: WriteStream\nlet commandUuid: string\nlet logFilePath: string\nexport class LinesTruncatorTransformer extends Transform {\n linesToRetain: string[] = []\n lastLineCompleted = true\n\n constructor(readonly maxFileSize: number, opts?: TransformOptions) {\n super(opts)\n }\n\n _transform(chunk: unknown, encoding: BufferEncoding, callback: TransformCallback): void {\n const tokens = (chunk as string).toString().split(EOL)\n\n this.completeLastLine(tokens)\n // last splitted token will be an empty string when last character is a breakline\n this.lastLineCompleted = tokens[tokens.length - 1] === ''\n if (this.lastLineCompleted) {\n tokens.pop()\n }\n this.linesToRetain = this.linesToRetain.concat(tokens)\n\n const numLinesToRetain = this.calculateNumLinesToRetain()\n if (this.linesToRetain.length > numLinesToRetain) {\n this.linesToRetain = this.linesToRetain.splice(this.linesToRetain.length - numLinesToRetain)\n }\n callback()\n }\n\n _flush(callback: TransformCallback): void {\n this.push(this.linesToRetain.join(EOL))\n callback()\n }\n\n // Lines retained length average is used so the number of lines depends on the length of them\n calculateNumLinesToRetain() {\n return Math.floor(\n this.maxFileSize /\n (this.linesToRetain.map((line) => line.length).reduce((l1, l2) => l1 + l2, 0) / this.linesToRetain.length),\n )\n }\n\n completeLastLine(tokens: string[]) {\n if (this.lastLineCompleted) {\n return\n }\n\n const remainingToken = tokens.shift() ?? ''\n const incompleteToken = this.linesToRetain[this.linesToRetain.length - 1] ?? ''\n this.linesToRetain[this.linesToRetain.length - 1] = incompleteToken.concat(remainingToken)\n }\n}\n\nexport async function initiateLogging(options: {logDir?: string; override?: boolean} = {}) {\n if (isUnitTest()) return\n commandUuid = generateRandomUUID()\n logFilePath = getLogFilePath(options)\n await truncateLogs(logFilePath)\n logFileStream = createWriteStream(logFilePath, {flags: 'a'})\n}\n\nexport function closeLogging() {\n if (logFileExists()) {\n logFileStream.end()\n }\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\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 getLogFilePath(options: {logDir?: string; override?: boolean} = {}) {\n if (!logFilePath || options.override) {\n const logDir = options.logDir || constants.paths.directories.cache.path()\n fileMkdirSync(logDir)\n logFilePath = pathJoin(logDir, logFileName)\n fileTouchSync(logFilePath)\n }\n\n return logFilePath\n}\n\n// Shaves off older log lines if logs are over maxLogFileSize long.\nasync function truncateLogs(logFile: string) {\n if (fileSizeSync(logFile) < maxLogFileSize) {\n return\n }\n const tmpLogFile = logFile.concat('.tmp')\n const truncateLines = new LinesTruncatorTransformer(maxLogFileSize)\n const pipeline = promisify(Stream.pipeline)\n await pipeline(createReadStream(logFile), truncateLines, createWriteStream(tmpLogFile))\n await pipeline(createReadStream(tmpLogFile), createWriteStream(logFile))\n unlinkSync(tmpLogFile)\n}\n\nfunction logFileExists(): boolean {\n return Boolean(logFileStream)\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"]}
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AACjD,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAA;AAC1C,OAAO,EACL,SAAS,IAAI,aAAa,EAC1B,IAAI,IAAI,QAAQ,EAChB,SAAS,IAAI,aAAa,EAC1B,QAAQ,IAAI,YAAY,GACzB,MAAM,W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,EAAE;QAChB,UAAU,CAAC,aAAa,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;KAC7D;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAkB,EAAE,YAAoB;IAC7D,2EAA2E;IAC3E,oBAAoB;IACpB,EAAE;IACF,uEAAuE;IACvE,sEAAsE;IACtE,IAAI,cAAc,GAAG,EAAE,CAAA;IACvB,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAY,EAAE,EAAE;QACtC,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,cAAc,CAAA;QAC3D,cAAc,GAAG,WAAW,CAAA;QAC5B,OAAO,WAAW,KAAK,YAAY,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,uBAAuB;IACvB,EAAE;IACF,uFAAuF;IACvF,8FAA8F;IAC9F,8FAA8F;IAC9F,8FAA8F;IAC9F,EAAE;IACF,uEAAuE;IACvE,EAAE;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAA;IACvF,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,CAAE,CAAA;AAC3B,CAAC","sourcesContent":["import {isUnitTest} from './environment/local.js'\nimport constants from './constants.js'\nimport {generateRandomUUID} from './id.js'\nimport {\n mkdirSync as fileMkdirSync,\n size as fileSize,\n touchSync as fileTouchSync,\n readSync as fileReadSync,\n} from './file.js'\nimport {join as pathJoin} from './path.js'\nimport {consoleLog} from './output.js'\nimport {page} from './system.js'\nimport * as ui from './ui.js'\nimport {promisify} from 'node:util'\nimport {Stream, Transform, TransformCallback, TransformOptions} from 'node:stream'\nimport {WriteStream, createWriteStream, createReadStream, unlinkSync} from 'node:fs'\nimport {EOL} from 'node:os'\n\nconst logFileName = 'shopify.cli.log'\nconst maxLogFileSize = 5 * 1024 * 1024\nconst maxLogFileSizeToTruncate = 30 * 1024 * 1024\nlet logFileStream: WriteStream\nlet commandUuid: string\nlet logFilePath: string\n\ninterface LinesTruncatorTransformerOptions {\n fileSize: number\n maxFileSize?: number\n maxFileSizeToTruncate?: number\n}\nexport class LinesTruncatorTransformer extends Transform {\n linesToRetain: string[] = []\n lastLineCompleted = true\n contentSize = 0\n options: LinesTruncatorTransformerOptions\n\n constructor(truncatorOptions: LinesTruncatorTransformerOptions, opts?: TransformOptions) {\n super(opts)\n this.options = truncatorOptions\n }\n\n _transform(chunk: unknown, encoding: BufferEncoding, callback: TransformCallback): void {\n if (this.shouldTruncate(chunk)) {\n this.truncate(chunk)\n }\n callback()\n }\n\n _flush(callback: TransformCallback): void {\n this.push(this.linesToRetain.join(EOL))\n callback()\n }\n\n shouldTruncate(chunk: unknown): boolean {\n this.contentSize += (chunk as string).toString().length\n return this.options.fileSize - this.contentSize < (this.options.maxFileSizeToTruncate ?? maxLogFileSizeToTruncate)\n }\n\n truncate(chunk: unknown) {\n const tokens = (chunk as string).toString().split(EOL)\n\n this.completeLastLine(tokens)\n // last splitted token will be an empty string when last character is a breakline\n this.lastLineCompleted = tokens[tokens.length - 1] === ''\n if (this.lastLineCompleted) {\n tokens.pop()\n }\n this.linesToRetain = this.linesToRetain.concat(tokens)\n\n const numLinesToRetain = this.calculateNumLinesToRetain()\n if (this.linesToRetain.length > numLinesToRetain) {\n this.linesToRetain = this.linesToRetain.splice(this.linesToRetain.length - numLinesToRetain)\n }\n }\n\n // Lines retained length average is used so the number of lines depends on the length of them\n calculateNumLinesToRetain() {\n return Math.floor(\n (this.options.maxFileSize ?? maxLogFileSize) /\n (this.linesToRetain.map((line) => line.length).reduce((l1, l2) => l1 + l2, 0) / this.linesToRetain.length),\n )\n }\n\n completeLastLine(tokens: string[]) {\n if (this.lastLineCompleted) {\n return\n }\n\n const remainingToken = tokens.shift() ?? ''\n const incompleteToken = this.linesToRetain[this.linesToRetain.length - 1] ?? ''\n this.linesToRetain[this.linesToRetain.length - 1] = incompleteToken.concat(remainingToken)\n }\n}\n\nexport async function initiateLogging(options: {logDir?: string; override?: boolean} = {}) {\n if (isUnitTest()) return\n commandUuid = generateRandomUUID()\n logFilePath = getLogFilePath(options)\n await truncateLogs(logFilePath)\n logFileStream = createWriteStream(logFilePath, {flags: 'a'})\n}\n\nexport function closeLogging() {\n if (logFileExists()) {\n logFileStream.end()\n }\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\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 getLogFilePath(options: {logDir?: string; override?: boolean} = {}) {\n if (!logFilePath || options.override) {\n const logDir = options.logDir || constants.paths.directories.cache.path()\n fileMkdirSync(logDir)\n logFilePath = pathJoin(logDir, logFileName)\n fileTouchSync(logFilePath)\n }\n\n return logFilePath\n}\n\n// Shaves off older log lines if logs are over maxLogFileSize long.\nasync function truncateLogs(logFile: string) {\n const size = await fileSize(logFile)\n if (size < maxLogFileSize) {\n return\n }\n const list = ui.newListr([\n {\n title: 'Truncation of the log file',\n task: async (_, task) => {\n task.title = `Starting the truncation of the ${Math.floor(size / (1024 * 1024)).toLocaleString(\n 'en-US',\n )}MB log file`\n const tmpLogFile = logFile.concat('.tmp')\n const truncateLines = new LinesTruncatorTransformer({fileSize: size})\n const pipeline = promisify(Stream.pipeline)\n await pipeline(createReadStream(logFile), truncateLines, createWriteStream(tmpLogFile))\n await pipeline(createReadStream(tmpLogFile), createWriteStream(logFile))\n unlinkSync(tmpLogFile)\n task.title = 'Finished log truncation process'\n },\n },\n ])\n await list.run()\n}\n\nfunction logFileExists(): boolean {\n return Boolean(logFileStream)\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"]}
|
package/dist/metadata.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isUnitTest } from './environment/local.js';
|
|
2
|
-
import { sendErrorToBugsnag } from './node/error-handler.js';
|
|
2
|
+
import { sendErrorToBugsnag } from './public/node/error-handler.js';
|
|
3
3
|
function getMetadataErrorHandlingStrategy() {
|
|
4
4
|
if (isUnitTest()) {
|
|
5
5
|
return 'bubble';
|
package/dist/metadata.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AAGjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAA;AAGjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAA;AAajE,SAAS,gCAAgC;IACvC,IAAI,UAAU,EAAE,EAAE;QAChB,OAAO,QAAQ,CAAA;KAChB;IACD,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAgBD;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAI5C,MAAM,GAAG,GAA+D;QACtE,SAAS,EAAE,EAAE;QACb,MAAM,EAAE,EAAE;KACX,CAAA;IACD,MAAM,SAAS,GAAG,CAAC,IAAsB,EAAE,EAAE;QAC3C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACjC,CAAC,CAAA;IACD,MAAM,YAAY,GAAG,CAAC,IAAyB,EAAE,EAAE;QACjD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;IACpC,CAAC,CAAA;IAED,MAAM,WAAW,GAAG,KAAK,EACvB,KAAiC,EACjC,KAAyB,EACzB,OAA8B,EAC9B,EAAE;QACF,MAAM,aAAa,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;QACvF,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;YAC3B,MAAM,IAAI,GAAG,MAAM,KAAK,EAAE,CAAA;YAC1B,KAAK,CAAC,IAAI,CAAC,CAAA;QACb,CAAC,CAAA;QAED,IAAI,aAAa,KAAK,QAAQ,EAAE;YAC9B,MAAM,SAAS,EAAE,CAAA;SAClB;aAAM;YACL,IAAI;gBACF,MAAM,SAAS,EAAE,CAAA;gBACjB,yFAAyF;aAC1F;YAAC,OAAO,KAAU,EAAE;gBACnB,MAAM,kBAAkB,CAAC,KAAK,CAAC,CAAA;aAChC;SACF;IACH,CAAC,CAAA;IAED,OAAO;QACL,YAAY,EAAE,GAAG,EAAE;YACjB,OAAO,EAAC,GAAG,GAAG,CAAC,MAAM,EAAC,CAAA;QACxB,CAAC;QACD,eAAe,EAAE,GAAG,EAAE;YACpB,OAAO,EAAC,GAAG,GAAG,CAAC,SAAS,EAAC,CAAA;QAC3B,CAAC;QACD,SAAS,EAAE,KAAK,EAAE,OAAiC,EAAE,UAAiC,MAAM,EAAE,EAAE;YAC9F,OAAO,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACjD,CAAC;QACD,YAAY,EAAE,KAAK,EAAE,OAAoC,EAAE,UAAiC,MAAM,EAAE,EAAE;YACpG,OAAO,WAAW,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;KACF,CAAA;AACH,CAAC;AAOD,MAAM,QAAQ,GAAG,8BAA8B,EAU5C,CAAA;AAEH,MAAM,CAAC,MAAM,EAAC,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAC,GAAG,QAAQ,CAAA","sourcesContent":["import {isUnitTest} from './environment/local.js'\nimport {AnyJson} from './json.js'\nimport {MonorailEventPublic} from './monorail.js'\nimport {sendErrorToBugsnag} from './public/node/error-handler.js'\nimport {PickByPrefix} from './typing/pick-by-prefix.js'\n\ntype ProvideMetadata<T> = () => Partial<T> | Promise<Partial<T>>\n\ntype MetadataErrorHandling =\n // Mute & report errors in production, throw them whilst testing\n | 'auto'\n // Errors are not reported to the user and do not stop execution, but they are reported to Bugsnag\n | 'mute-and-report'\n // Errors are not caught and will bubble out as normal\n | 'bubble'\n\nfunction getMetadataErrorHandlingStrategy(): 'mute-and-report' | 'bubble' {\n if (isUnitTest()) {\n return 'bubble'\n }\n return 'mute-and-report'\n}\n\nexport interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {\n /** Add some public metadata -- this should not contain any PII */\n addPublic: (getData: ProvideMetadata<TPublic>, onError?: MetadataErrorHandling) => Promise<void>\n /** Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked (this is a good fit for command args for instance) */\n addSensitive: (getData: ProvideMetadata<TSensitive>, onError?: MetadataErrorHandling) => Promise<void>\n /** Get a snapshot of the tracked public data */\n getAllPublic: () => Partial<TPublic>\n /** Get a snapshot of the tracked sensitive data */\n getAllSensitive: () => Partial<TSensitive>\n}\n\nexport type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never\nexport type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never\n\n/**\n * Creates a container for metadata collected at runtime.\n *\n * The container provides async-safe functions for extracting the gathered metadata, and for setting it.\n *\n */\nexport function createRuntimeMetadataContainer<\n TPublic extends AnyJson,\n TSensitive extends AnyJson = {[key: string]: never},\n>(): RuntimeMetadataManager<TPublic, TSensitive> {\n const raw: {sensitive: Partial<TSensitive>; public: Partial<TPublic>} = {\n sensitive: {},\n public: {},\n }\n const addPublic = (data: Partial<TPublic>) => {\n Object.assign(raw.public, data)\n }\n const addSensitive = (data: Partial<TSensitive>) => {\n Object.assign(raw.sensitive, data)\n }\n\n const addMetadata = async <T>(\n addFn: (data: Partial<T>) => void,\n getFn: ProvideMetadata<T>,\n onError: MetadataErrorHandling,\n ) => {\n const errorHandling = onError === 'auto' ? getMetadataErrorHandlingStrategy() : onError\n const getAndSet = async () => {\n const data = await getFn()\n addFn(data)\n }\n\n if (errorHandling === 'bubble') {\n await getAndSet()\n } else {\n try {\n await getAndSet()\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (error: any) {\n await sendErrorToBugsnag(error)\n }\n }\n }\n\n return {\n getAllPublic: () => {\n return {...raw.public}\n },\n getAllSensitive: () => {\n return {...raw.sensitive}\n },\n addPublic: async (getData: ProvideMetadata<TPublic>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addPublic, getData, onError)\n },\n addSensitive: async (getData: ProvideMetadata<TSensitive>, onError: MetadataErrorHandling = 'auto') => {\n return addMetadata(addSensitive, getData, onError)\n },\n }\n}\n\n// We want to track anything that ends up getting sent to monorail as `cmd_all_*` and\n// `cmd_app_*`\ntype CmdFieldsFromMonorail = PickByPrefix<MonorailEventPublic, 'cmd_all_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_app_'>\n\nconst coreData = createRuntimeMetadataContainer<\n CmdFieldsFromMonorail,\n {\n commandStartOptions: {\n startTime: number\n startCommand: string\n startTopic?: string\n startArgs: string[]\n }\n }\n>()\n\nexport const {getAllPublic, getAllSensitive, addPublic, addSensitive} = coreData\n\nexport type Public = PublicSchema<typeof coreData>\nexport type Sensitive = SensitiveSchema<typeof coreData>\n"]}
|
package/dist/output.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { PackageManager } from './node/node-package-manager.js';
|
|
2
|
+
import { PackageManager } from './public/node/node-package-manager.js';
|
|
3
3
|
import { ColorContentToken, CommandContentToken, ContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken } from './content-tokens.js';
|
|
4
4
|
import { AbortSignal } from 'abort-controller';
|
|
5
5
|
import { Writable } from 'node:stream';
|
package/dist/output.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
2
|
import { isUnitTest, isVerbose } from './environment/local.js';
|
|
3
|
-
import
|
|
3
|
+
import colors from './public/node/colors.js';
|
|
4
4
|
import { ColorContentToken, CommandContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken, } from './content-tokens.js';
|
|
5
5
|
import { logToFile } from './log.js';
|
|
6
6
|
import stripAnsi from 'strip-ansi';
|
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,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAE5D,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EAEnB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAElC,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,YAAY,CAAA;AAI/C,MAAM,OAAO,eAAe;IAE1B,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAID,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,GAAG,EAAE,CAAC,KAAa,EAAE,EAAE;QACrB,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;IACD,mBAAmB,EAAE,CAAC,KAAc,EAAE,EAAE;QACtC,OAAO,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAA;IACvC,CAAC;IACD,8DAA8D;IAC9D,IAAI,EAAE,CAAC,KAAU,EAAE,EAAE;QACnB,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IACD,IAAI,EAAE,CAAC,KAAc,EAAE,EA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'\nimport {PackageManager} from './node/node-package-manager.js'\nimport {colors} from './node/colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from './content-tokens.js'\nimport {logToFile} from './log.js'\nimport {AbortSignal} from 'abort-controller'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'node:stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = (message: string) => void\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 const token = {\n raw: (value: string) => {\n return new RawContentToken(value)\n },\n genericShellCommand: (value: Message) => {\n return new CommandContentToken(value)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new JsonContentToken(value)\n },\n path: (value: Message) => {\n return new PathContentToken(value)\n },\n link: (value: Message, link: string) => {\n return new LinkContentToken(value, link)\n },\n heading: (value: Message) => {\n return new HeadingContentToken(value)\n },\n subheading: (value: Message) => {\n return new SubHeadingContentToken(value)\n },\n italic: (value: Message) => {\n return new ItalicContentToken(value)\n },\n errorText: (value: Message) => {\n return new ErrorContentToken(value)\n },\n cyan: (value: Message) => {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow: (value: Message) => {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta: (value: Message) => {\n return new ColorContentToken(value, colors.magenta)\n },\n green: (value: Message) => {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, scriptArgs))\n },\n successIcon: () => {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon: () => {\n return new ErrorContentToken('✖')\n },\n linesDiff: (value: Change[]) => {\n return new LinesDiffContentToken(value)\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 function content(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | 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 enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\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 - 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 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 - The key of the log.\n * @param content - The content of the log.\n */\nexport const 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 - The content to be output to the user.\n * @param logger - 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 - The content to be output to the user.\n * @param logger - 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 - The content to be output to the user.\n * @param logger - 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 - The content to be output to the user.\n * @param logger - 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 - The content to be output to the user.\n * @param logger - 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\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 * 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\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n logger(message)\n }\n logToFile(message, logLevel.toUpperCase())\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 stripAnsi(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = token.packagejsonScript(packageManager, 'shopify', 'upgrade')\n return content`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function section(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return content`${token.heading(formattedTitle)}\\n${body}`.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,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAE5D,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EAEnB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAA;AAElC,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,YAAY,CAAA;AAI/C,MAAM,OAAO,eAAe;IAE1B,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAA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,aAAa,EAAE,CAAC,KAAK,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,IAAY;IACjD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,OAAO,CAAA,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AACjE,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport {PackageManager} from './public/node/node-package-manager.js'\nimport colors from './public/node/colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from './content-tokens.js'\nimport {logToFile} from './log.js'\nimport {AbortSignal} from 'abort-controller'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'node:stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = (message: string) => void\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 const token = {\n raw: (value: string) => {\n return new RawContentToken(value)\n },\n genericShellCommand: (value: Message) => {\n return new CommandContentToken(value)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new JsonContentToken(value)\n },\n path: (value: Message) => {\n return new PathContentToken(value)\n },\n link: (value: Message, link: string) => {\n return new LinkContentToken(value, link)\n },\n heading: (value: Message) => {\n return new HeadingContentToken(value)\n },\n subheading: (value: Message) => {\n return new SubHeadingContentToken(value)\n },\n italic: (value: Message) => {\n return new ItalicContentToken(value)\n },\n errorText: (value: Message) => {\n return new ErrorContentToken(value)\n },\n cyan: (value: Message) => {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow: (value: Message) => {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta: (value: Message) => {\n return new ColorContentToken(value, colors.magenta)\n },\n green: (value: Message) => {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, scriptArgs))\n },\n successIcon: () => {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon: () => {\n return new ErrorContentToken('✖')\n },\n linesDiff: (value: Change[]) => {\n return new LinesDiffContentToken(value)\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 function content(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | 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 enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\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 - 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 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 - The key of the log.\n * @param content - The content of the log.\n */\nexport const 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 - The content to be output to the user.\n * @param logger - 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 - The content to be output to the user.\n * @param logger - 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 - The content to be output to the user.\n * @param logger - 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 - The content to be output to the user.\n * @param logger - 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 - The content to be output to the user.\n * @param logger - 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\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 * 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\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n logger(message)\n }\n logToFile(message, logLevel.toUpperCase())\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 stripAnsi(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = token.packagejsonScript(packageManager, 'shopify', 'upgrade')\n return content`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function section(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return content`${token.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JsonMap } from './json.js';
|
|
2
2
|
import { PickByPrefix } from './typing/pick-by-prefix.js';
|
|
3
3
|
import { MonorailEventPublic, MonorailEventSensitive } from './monorail.js';
|
|
4
|
-
import { HookReturnPerTunnelPlugin } from './plugins/tunnel.js';
|
|
4
|
+
import { HookReturnPerTunnelPlugin } from './public/node/plugins/tunnel.js';
|
|
5
5
|
import { Result } from './public/common/result.js';
|
|
6
6
|
import { Config, Interfaces } from '@oclif/core';
|
|
7
7
|
/**
|
package/dist/plugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,0BAA0B,EAAE,0BAA0B,EAAC,MAAM,0BAA0B,CAAA;AAC/F,OAAO,EAAC,GAAG,EAAS,MAAM,2BAA2B,CAAA;AAGrD;;;;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;AA4CD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAAc;IACzD,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAA;IAC9D,MAAM,KAAK,GAAG,0BAA0B,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;IACtF,IAAI,0BAA0B,CAAC,KAAK,CAAC;QAAE,OAAO,EAAC,OAAO,EAAE,KAAK,E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orailEventSensitive} from './monorail.js'\nimport {HookReturnPerTunnelPlugin} from './plugins/tunnel.js'\nimport {getArrayContainsDuplicates, getArrayRejectingUndefined} from './public/common/array.js'\nimport {err, Result} from './public/common/result.js'\nimport {Config, Interfaces} from '@oclif/core'\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\ntype AppSpecificMonorailFields = PickByPrefix<MonorailEventPublic, 'app_', 'project_type' | 'api_key' | 'partner_id'> &\n PickByPrefix<MonorailEventPublic, 'cmd_extensions_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_scaffold_'>\n\ntype AppSpecificSensitiveMonorailFields = PickByPrefix<MonorailEventSensitive, 'app_'>\n\ninterface HookReturnsPerPlugin extends HookReturnPerTunnelPlugin {\n public_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n sensitive_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificSensitiveMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n [hookName: string]: {\n options: {[key: string]: unknown}\n pluginReturns: {[key: string]: JsonMap | Result<JsonMap, Error>}\n }\n}\n\nexport type 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<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>\n\n/**\n * Execute the 'tunnel_provider' hook, and return the list of available tunnel providers.\n * Fail if there are multiple plugins for the same provider\n *\n * @param config - oclif config used to execute hooks\n * @returns list of available tunnel plugins\n */\nexport async function getListOfTunnelPlugins(config: Config): Promise<{plugins: string[]; error?: string}> {\n const hooks = await fanoutHooks(config, 'tunnel_provider', {})\n const names = getArrayRejectingUndefined(Object.values(hooks).map((key) => key?.name))\n if (getArrayContainsDuplicates(names)) return {plugins: names, error: 'multiple-plugins-for-provider'}\n return {plugins: names}\n}\n\nexport interface TunnelPluginError {\n provider: string\n type: 'multiple-urls' | 'handled-error' | 'unknown' | 'no-provider'\n message?: string\n}\n\n/**\n * Execute the 'tunnel_start' hook for the given provider.\n * Fails if there aren't plugins for that provider or if there are more than one.\n *\n * @param config - oclif config used to execute hooks\n * @param port - port where the tunnel will be started\n * @param provider - selected provider, must be unique\n * @returns tunnel URL from the selected provider\n */\nexport async function runTunnelPlugin(\n config: Config,\n port: number,\n provider: string,\n): Promise<Result<string, TunnelPluginError>> {\n const hooks = await fanoutHooks(config, 'tunnel_start', {port, provider})\n const urlResults = Object.values(hooks).filter(\n (tunnelResponse) => !tunnelResponse?.isErr() || tunnelResponse.error.type !== 'invalid-provider',\n )\n if (urlResults.length > 1) return err({provider, type: 'multiple-urls'})\n if (urlResults.length === 0 || !urlResults[0]) return err({provider, type: 'no-provider'})\n\n return urlResults[0]\n .map((data) => data.url)\n .mapError((error) =>\n error.type === 'unknown'\n ? {provider, type: 'unknown', message: error.message}\n : {provider, type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K,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAA;IACzE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAC5C,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB,CACjG,CAAA;IACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAC,CAAC,CAAA;IACxE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAC,CAAC,CAAA;IAE1F,OAAO,UAAU,CAAC,CAAC,CAAC;SACjB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;SACvB,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAClB,KAAK,CAAC,IAAI,KAAK,SAAS;QACtB,CAAC,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAC;QACrD,CAAC,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAC,CACtC,CAAA;AACL,CAAC","sourcesContent":["import {JsonMap} from './json.js'\nimport {PickByPrefix} from './typing/pick-by-prefix.js'\nimport {MonorailEventPublic, MonorailEventSensitive} from './monorail.js'\nimport {HookReturnPerTunnelPlugin} from './public/node/plugins/tunnel.js'\nimport {getArrayContainsDuplicates, getArrayRejectingUndefined} from './public/common/array.js'\nimport {err, Result} from './public/common/result.js'\nimport {Config, Interfaces} from '@oclif/core'\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\ntype AppSpecificMonorailFields = PickByPrefix<MonorailEventPublic, 'app_', 'project_type' | 'api_key' | 'partner_id'> &\n PickByPrefix<MonorailEventPublic, 'cmd_extensions_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_scaffold_'>\n\ntype AppSpecificSensitiveMonorailFields = PickByPrefix<MonorailEventSensitive, 'app_'>\n\ninterface HookReturnsPerPlugin extends HookReturnPerTunnelPlugin {\n public_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n sensitive_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificSensitiveMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n [hookName: string]: {\n options: {[key: string]: unknown}\n pluginReturns: {[key: string]: JsonMap | Result<JsonMap, Error>}\n }\n}\n\nexport type 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<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>\n\n/**\n * Execute the 'tunnel_provider' hook, and return the list of available tunnel providers.\n * Fail if there are multiple plugins for the same provider\n *\n * @param config - oclif config used to execute hooks\n * @returns list of available tunnel plugins\n */\nexport async function getListOfTunnelPlugins(config: Config): Promise<{plugins: string[]; error?: string}> {\n const hooks = await fanoutHooks(config, 'tunnel_provider', {})\n const names = getArrayRejectingUndefined(Object.values(hooks).map((key) => key?.name))\n if (getArrayContainsDuplicates(names)) return {plugins: names, error: 'multiple-plugins-for-provider'}\n return {plugins: names}\n}\n\nexport interface TunnelPluginError {\n provider: string\n type: 'multiple-urls' | 'handled-error' | 'unknown' | 'no-provider'\n message?: string\n}\n\n/**\n * Execute the 'tunnel_start' hook for the given provider.\n * Fails if there aren't plugins for that provider or if there are more than one.\n *\n * @param config - oclif config used to execute hooks\n * @param port - port where the tunnel will be started\n * @param provider - selected provider, must be unique\n * @returns tunnel URL from the selected provider\n */\nexport async function runTunnelPlugin(\n config: Config,\n port: number,\n provider: string,\n): Promise<Result<string, TunnelPluginError>> {\n const hooks = await fanoutHooks(config, 'tunnel_start', {port, provider})\n const urlResults = Object.values(hooks).filter(\n (tunnelResponse) => !tunnelResponse?.isErr() || tunnelResponse.error.type !== 'invalid-provider',\n )\n if (urlResults.length > 1) return err({provider, type: 'multiple-urls'})\n if (urlResults.length === 0 || !urlResults[0]) return err({provider, type: 'no-provider'})\n\n return urlResults[0]\n .map((data) => data.url)\n .mapError((error) =>\n error.type === 'unknown'\n ? {provider, type: 'unknown', message: error.message}\n : {provider, type: 'handled-error'},\n )\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { BannerType } from './Banner.js';
|
|
|
2
2
|
import { TextTokenItem } from './TokenizedText.js';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
export interface AlertProps {
|
|
5
|
-
type: Exclude<BannerType, 'error'>;
|
|
5
|
+
type: Exclude<BannerType, 'error' | 'external_error'>;
|
|
6
6
|
headline: string;
|
|
7
7
|
body?: TextTokenItem;
|
|
8
8
|
nextSteps?: TextTokenItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAa,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAgB,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AAezB,MAAM,KAAK,GAAyB,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,GAAG,KAAK,EAAC,EAAE,EAAE;IACnH,OAAO,CACL,oBAAC,MAAM,IAAC,IAAI,EAAE,IAAI;QAChB,oBAAC,GAAG;YACF,oBAAC,IAAI,QAAE,QAAQ,CAAQ,CACnB;QAEL,IAAI,IAAI,CACP,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CACzB,CACP;QAEA,SAAS,IAAI,CACZ,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,KAAK,EAAC,YAAY,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,GAAI,CACpE,CACP;QAEA,SAAS,IAAI,CACZ,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,KAAK,EAAC,WAAW,EAAC,KAAK,EAAE,SAAS,GAAI,CACxC,CACP;QAEA,IAAI,IAAI,CACP,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,GAAI,CACtC,CACP,CACM,CACV,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,KAAK,EAAC,CAAA","sourcesContent":["import {Banner, BannerType} from './Banner.js'\nimport {Link} from './Link.js'\nimport {List} from './List.js'\nimport {TextTokenItem, TokenizedText} from './TokenizedText.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\nexport interface AlertProps {\n type: Exclude<BannerType, 'error'>\n headline: string\n body?: TextTokenItem\n nextSteps?: TextTokenItem[]\n reference?: TextTokenItem[]\n link?: {\n label: string\n url: string\n }\n orderedNextSteps?: boolean\n}\n\nconst Alert: React.FC<AlertProps> = ({type, headline, body, nextSteps, reference, link, orderedNextSteps = false}) => {\n return (\n <Banner type={type}>\n <Box>\n <Text>{headline}</Text>\n </Box>\n\n {body && (\n <Box marginTop={1}>\n <TokenizedText item={body} />\n </Box>\n )}\n\n {nextSteps && (\n <Box marginTop={1}>\n <List title=\"Next steps\" items={nextSteps} ordered={orderedNextSteps} />\n </Box>\n )}\n\n {reference && (\n <Box marginTop={1}>\n <List title=\"Reference\" items={reference} />\n </Box>\n )}\n\n {link && (\n <Box marginTop={1}>\n <Link url={link.url} label={link.label} />\n </Box>\n )}\n </Banner>\n )\n}\n\nexport {Alert}\n"]}
|
|
1
|
+
{"version":3,"file":"Alert.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAa,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAgB,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AAezB,MAAM,KAAK,GAAyB,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,GAAG,KAAK,EAAC,EAAE,EAAE;IACnH,OAAO,CACL,oBAAC,MAAM,IAAC,IAAI,EAAE,IAAI;QAChB,oBAAC,GAAG;YACF,oBAAC,IAAI,QAAE,QAAQ,CAAQ,CACnB;QAEL,IAAI,IAAI,CACP,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CACzB,CACP;QAEA,SAAS,IAAI,CACZ,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,KAAK,EAAC,YAAY,EAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,GAAI,CACpE,CACP;QAEA,SAAS,IAAI,CACZ,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,KAAK,EAAC,WAAW,EAAC,KAAK,EAAE,SAAS,GAAI,CACxC,CACP;QAEA,IAAI,IAAI,CACP,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,IAAI,IAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,GAAI,CACtC,CACP,CACM,CACV,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,KAAK,EAAC,CAAA","sourcesContent":["import {Banner, BannerType} from './Banner.js'\nimport {Link} from './Link.js'\nimport {List} from './List.js'\nimport {TextTokenItem, TokenizedText} from './TokenizedText.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\nexport interface AlertProps {\n type: Exclude<BannerType, 'error' | 'external_error'>\n headline: string\n body?: TextTokenItem\n nextSteps?: TextTokenItem[]\n reference?: TextTokenItem[]\n link?: {\n label: string\n url: string\n }\n orderedNextSteps?: boolean\n}\n\nconst Alert: React.FC<AlertProps> = ({type, headline, body, nextSteps, reference, link, orderedNextSteps = false}) => {\n return (\n <Banner type={type}>\n <Box>\n <Text>{headline}</Text>\n </Box>\n\n {body && (\n <Box marginTop={1}>\n <TokenizedText item={body} />\n </Box>\n )}\n\n {nextSteps && (\n <Box marginTop={1}>\n <List title=\"Next steps\" items={nextSteps} ordered={orderedNextSteps} />\n </Box>\n )}\n\n {reference && (\n <Box marginTop={1}>\n <List title=\"Reference\" items={reference} />\n </Box>\n )}\n\n {link && (\n <Box marginTop={1}>\n <Link url={link.url} label={link.label} />\n </Box>\n )}\n </Banner>\n )\n}\n\nexport {Alert}\n"]}
|
|
@@ -6,6 +6,7 @@ function typeToColor(type) {
|
|
|
6
6
|
error: 'red',
|
|
7
7
|
warning: 'yellow',
|
|
8
8
|
info: 'dim',
|
|
9
|
+
external_error: 'red',
|
|
9
10
|
}[type];
|
|
10
11
|
}
|
|
11
12
|
const BANNER_MIN_WIDTH = 80;
|
|
@@ -24,12 +25,34 @@ function calculateWidth(stdout) {
|
|
|
24
25
|
}
|
|
25
26
|
return width;
|
|
26
27
|
}
|
|
27
|
-
const
|
|
28
|
+
const BoxWithBorder = ({ type, children }) => {
|
|
28
29
|
const { stdout } = useStdout();
|
|
29
30
|
return (React.createElement(Box, { width: calculateWidth(stdout), paddingY: 1, paddingX: 2, borderStyle: "round", flexDirection: "column", borderColor: typeToColor(type) },
|
|
30
31
|
React.createElement(Box, { marginTop: -2, marginBottom: 1, marginLeft: -1 },
|
|
31
|
-
React.createElement(Text, { dimColor: true, bold: true }, ` ${type} `)),
|
|
32
|
+
React.createElement(Text, { dimColor: true, bold: true }, ` ${type.replace(/_/g, ' ')} `)),
|
|
32
33
|
children));
|
|
33
34
|
};
|
|
35
|
+
const BoxWithTopLine = ({ type, children }) => {
|
|
36
|
+
const { stdout } = useStdout();
|
|
37
|
+
const width = calculateWidth(stdout);
|
|
38
|
+
return (React.createElement(Box, { marginY: 1, flexDirection: "column" },
|
|
39
|
+
React.createElement(Box, { marginBottom: 1 },
|
|
40
|
+
React.createElement(Text, null,
|
|
41
|
+
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(2)),
|
|
42
|
+
React.createElement(Text, { dimColor: true, bold: true }, ` ${type.replace(/_/g, ' ')} `),
|
|
43
|
+
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(width - 2 - type.length - 2)))),
|
|
44
|
+
children,
|
|
45
|
+
React.createElement(Box, { marginTop: 1 },
|
|
46
|
+
React.createElement(Text, { color: typeToColor(type) }, '─'.repeat(width)))));
|
|
47
|
+
};
|
|
48
|
+
const BannerBox = ({ type, children }) => {
|
|
49
|
+
if (type === 'external_error') {
|
|
50
|
+
return React.createElement(BoxWithTopLine, { type: type }, children);
|
|
51
|
+
}
|
|
52
|
+
return React.createElement(BoxWithBorder, { type: type }, children);
|
|
53
|
+
};
|
|
54
|
+
const Banner = ({ type, children }) => {
|
|
55
|
+
return React.createElement(BannerBox, { type: type }, children);
|
|
56
|
+
};
|
|
34
57
|
export { Banner };
|
|
35
58
|
//# sourceMappingURL=Banner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAC,MAAM,KAAK,CAAA;AACxC,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,SAAS,WAAW,CAAC,IAAmB;IACtC,OAAO;QACL,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"Banner.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Banner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EA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c,IAAC,IAAI,EAAE,IAAI,IAAG,QAAQ,CAAkB,CAAA;KAC/D;IAED,OAAO,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,IAAG,QAAQ,CAAiB,CAAA;AAC9D,CAAC,CAAA;AAED,MAAM,MAAM,GAAoB,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE;IACnD,OAAO,oBAAC,SAAS,IAAC,IAAI,EAAE,IAAI,IAAG,QAAQ,CAAa,CAAA;AACtD,CAAC,CAAA;AAED,OAAO,EAAC,MAAM,EAAC,CAAA","sourcesContent":["import {Box, Text, useStdout} from 'ink'\nimport React from 'react'\n\nexport type BannerType = 'success' | 'error' | 'warning' | 'info' | 'external_error'\n\ninterface Props {\n type: BannerType\n}\n\nfunction typeToColor(type: Props['type']) {\n return {\n success: 'green',\n error: 'red',\n warning: 'yellow',\n info: 'dim',\n external_error: 'red',\n }[type]\n}\n\nconst BANNER_MIN_WIDTH = 80\n\nfunction calculateWidth(stdout: NodeJS.WriteStream | undefined) {\n const fullWidth = stdout?.columns ?? BANNER_MIN_WIDTH\n const twoThirdsOfWidth = Math.floor((fullWidth / 3) * 2)\n let width\n\n if (fullWidth <= BANNER_MIN_WIDTH) {\n width = fullWidth\n } else if (twoThirdsOfWidth < BANNER_MIN_WIDTH) {\n width = BANNER_MIN_WIDTH\n } else {\n width = twoThirdsOfWidth\n }\n\n return width\n}\n\nconst BoxWithBorder: React.FC<Props> = ({type, children}) => {\n const {stdout} = useStdout()\n\n return (\n <Box\n width={calculateWidth(stdout)}\n paddingY={1}\n paddingX={2}\n borderStyle=\"round\"\n flexDirection=\"column\"\n borderColor={typeToColor(type)}\n >\n <Box marginTop={-2} marginBottom={1} marginLeft={-1}>\n <Text dimColor bold>{` ${type.replace(/_/g, ' ')} `}</Text>\n </Box>\n {children}\n </Box>\n )\n}\n\nconst BoxWithTopLine: React.FC<Props> = ({type, children}) => {\n const {stdout} = useStdout()\n const width = calculateWidth(stdout)\n\n return (\n <Box marginY={1} flexDirection=\"column\">\n <Box marginBottom={1}>\n <Text>\n <Text color={typeToColor(type)}>{'─'.repeat(2)}</Text>\n <Text dimColor bold>{` ${type.replace(/_/g, ' ')} `}</Text>\n {/* 2 initial dashes + 2 spaces surrounding the type */}\n <Text color={typeToColor(type)}>{'─'.repeat(width - 2 - type.length - 2)}</Text>\n </Text>\n </Box>\n\n {children}\n\n <Box marginTop={1}>\n <Text color={typeToColor(type)}>{'─'.repeat(width)}</Text>\n </Box>\n </Box>\n )\n}\n\nconst BannerBox: React.FC<Props> = ({type, children}) => {\n if (type === 'external_error') {\n return <BoxWithTopLine type={type}>{children}</BoxWithTopLine>\n }\n\n return <BoxWithBorder type={type}>{children}</BoxWithBorder>\n}\n\nconst Banner: React.FC<Props> = ({type, children}) => {\n return <BannerBox type={type}>{children}</BannerBox>\n}\n\nexport {Banner}\n"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Banner } from './Banner.js';
|
|
2
2
|
import { TokenizedText } from './TokenizedText.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Command } from './Command.js';
|
|
4
|
+
import { Bug, cleanSingleStackTracePath, ExternalError } from '../../../../error.js';
|
|
4
5
|
import { Box, Text } from 'ink';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
import StackTracey from 'stacktracey';
|
|
7
8
|
const FatalError = ({ error }) => {
|
|
8
9
|
let stack;
|
|
10
|
+
let tool;
|
|
9
11
|
if (error instanceof Bug) {
|
|
10
12
|
stack = new StackTracey(error);
|
|
11
13
|
stack.items.forEach((item) => {
|
|
@@ -23,7 +25,14 @@ const FatalError = ({ error }) => {
|
|
|
23
25
|
return item;
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
|
-
|
|
28
|
+
if (error instanceof ExternalError) {
|
|
29
|
+
tool = `${error.command} ${error.args.join(' ')}`;
|
|
30
|
+
}
|
|
31
|
+
return (React.createElement(Banner, { type: tool ? 'external_error' : 'error' },
|
|
32
|
+
tool && (React.createElement(Box, { marginBottom: 1 },
|
|
33
|
+
React.createElement(Text, null,
|
|
34
|
+
"Error coming from ",
|
|
35
|
+
React.createElement(Command, { command: tool })))),
|
|
27
36
|
React.createElement(Box, null,
|
|
28
37
|
React.createElement(Text, null, error.message)),
|
|
29
38
|
error.tryMessage && (React.createElement(Box, { marginTop: 1 },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FatalError.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/FatalError.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,GAAG,EAAE,yBAAyB,EAAQ,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"FatalError.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/FatalError.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,GAAG,EAAE,yBAAyB,EAAE,aAAa,EAAQ,MAAM,sBAAsB,CAAA;AACzF,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,WAAW,MAAM,aAAa,CAAA;AAMrC,MAAM,UAAU,GAA8B,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE;IACxD,IAAI,KAAK,CAAA;IACT,IAAI,IAAI,CAAA;IAER,IAAI,KAAK,YAAY,GAAG,EAAE;QACxB,KAAK,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAA;QAC9B,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,IAAI,CAAC,IAAI,GA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,CACrC,CACP;QACA,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CACpC,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ;YACvC,oBAAC,IAAI,IAAC,QAAQ,gEAA2D;YACxE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAChC,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,GAAG,EAAE,KAAK;gBACpC,oBAAC,IAAI;;oBACA,IAAI,CAAC,WAAW,IAAI,oBAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,IAAE,IAAI,IAAI,CAAC,WAAW,EAAE,CAAQ;oBAC1E,IAAI,CAAC,SAAS,IAAI,KAAK,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,GAAG,CACjD;gBACP,oBAAC,GAAG,IAAC,WAAW,EAAE,CAAC;oBACjB,oBAAC,IAAI,IAAC,QAAQ,UAAE,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,CAAQ,CAC3C,CACF,CACP,CAAC,CACE,CACP,CACM,CACV,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,UAAU,EAAC,CAAA","sourcesContent":["import {Banner} from './Banner.js'\nimport {TokenizedText} from './TokenizedText.js'\nimport {Command} from './Command.js'\nimport {Bug, cleanSingleStackTracePath, ExternalError, Fatal} from '../../../../error.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\nimport StackTracey from 'stacktracey'\n\nexport interface FatalErrorProps {\n error: Fatal\n}\n\nconst FatalError: React.FC<FatalErrorProps> = ({error}) => {\n let stack\n let tool\n\n if (error instanceof Bug) {\n stack = new StackTracey(error)\n stack.items.forEach((item) => {\n item.file = cleanSingleStackTracePath(item.file)\n })\n\n stack = stack.withSources()\n stack = stack\n .filter((entry) => {\n return !entry.file.includes('@oclif/core')\n })\n .map((item) => {\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 }\n\n if (error instanceof ExternalError) {\n tool = `${error.command} ${error.args.join(' ')}`\n }\n\n return (\n <Banner type={tool ? 'external_error' : 'error'}>\n {tool && (\n <Box marginBottom={1}>\n <Text>\n Error coming from <Command command={tool} />\n </Text>\n </Box>\n )}\n\n <Box>\n <Text>{error.message}</Text>\n </Box>\n\n {error.tryMessage && (\n <Box marginTop={1}>\n <TokenizedText item={error.tryMessage} />\n </Box>\n )}\n {stack && stack.items.length !== 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text dimColor>To investigate the issue, examine this stack trace:</Text>\n {stack.items.map((item, index) => (\n <Box flexDirection=\"column\" key={index}>\n <Text>\n at{item.calleeShort && <Text color=\"yellow\">{` ${item.calleeShort}`}</Text>}\n {item.fileShort && ` (${item.fileShort}:${item.line})`}\n </Text>\n <Box paddingLeft={1}>\n <Text dimColor>{item.sourceLine?.trim()}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n )}\n </Banner>\n )\n}\n\nexport {FatalError}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep merges the two objects and returns a new object with the merge result.
|
|
3
|
+
*
|
|
4
|
+
* @param lhs - One of the objects to be merged.
|
|
5
|
+
* @param rhs - Another object to be merged.
|
|
6
|
+
* @param arrayMergeStrategy - Strategy used to merge the array typed fields. Union strategy is used by default to avoid
|
|
7
|
+
* duplicated elements.
|
|
8
|
+
* @returns A Javascrip tobject with th emerged objects.
|
|
9
|
+
*/
|
|
10
|
+
export declare function deepMergeObjects<T1, T2>(lhs: Partial<T1>, rhs: Partial<T2>, arrayMergeStrategy?: (destinationArray: unknown[], sourceArray: unknown[]) => unknown[]): T1 & T2;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import deepMerge from 'deepmerge';
|
|
2
|
+
/**
|
|
3
|
+
* Deep merges the two objects and returns a new object with the merge result.
|
|
4
|
+
*
|
|
5
|
+
* @param lhs - One of the objects to be merged.
|
|
6
|
+
* @param rhs - Another object to be merged.
|
|
7
|
+
* @param arrayMergeStrategy - Strategy used to merge the array typed fields. Union strategy is used by default to avoid
|
|
8
|
+
* duplicated elements.
|
|
9
|
+
* @returns A Javascrip tobject with th emerged objects.
|
|
10
|
+
*/
|
|
11
|
+
export function deepMergeObjects(lhs, rhs, arrayMergeStrategy = unionArrayStrategy) {
|
|
12
|
+
return deepMerge(lhs, rhs, { arrayMerge: arrayMergeStrategy });
|
|
13
|
+
}
|
|
14
|
+
function unionArrayStrategy(destinationArray, sourceArray) {
|
|
15
|
+
return Array.from(new Set([...destinationArray, ...sourceArray]));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/public/common/object.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAgB,EAChB,GAAgB,EAChB,qBAAyF,kBAAkB;IAE3G,OAAO,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAC,UAAU,EAAE,kBAAkB,EAAC,CAAC,CAAA;AAC9D,CAAC;AAED,SAAS,kBAAkB,CAAC,gBAA2B,EAAE,WAAsB;IAC7E,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,gBAAgB,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;AACnE,CAAC","sourcesContent":["import deepMerge from 'deepmerge'\n\n/**\n * Deep merges the two objects and returns a new object with the merge result.\n *\n * @param lhs - One of the objects to be merged.\n * @param rhs - Another object to be merged.\n * @param arrayMergeStrategy - Strategy used to merge the array typed fields. Union strategy is used by default to avoid\n * duplicated elements.\n * @returns A Javascrip tobject with th emerged objects.\n */\nexport function deepMergeObjects<T1, T2>(\n lhs: Partial<T1>,\n rhs: Partial<T2>,\n arrayMergeStrategy: (destinationArray: unknown[], sourceArray: unknown[]) => unknown[] = unionArrayStrategy,\n): T1 & T2 {\n return deepMerge(lhs, rhs, {arrayMerge: arrayMergeStrategy})\n}\n\nfunction unionArrayStrategy(destinationArray: unknown[], sourceArray: unknown[]): unknown[] {\n return Array.from(new Set([...destinationArray, ...sourceArray]))\n}\n"]}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { takeRandomFromArray } from './
|
|
2
|
-
|
|
3
|
-
import { join } from './path.js';
|
|
4
|
-
export const SAFE_ADJECTIVES = [
|
|
1
|
+
import { takeRandomFromArray } from './array.js';
|
|
2
|
+
const SAFE_RANDOM_ADJECTIVES = [
|
|
5
3
|
'commercial',
|
|
6
4
|
'profitable',
|
|
7
5
|
'amortizable',
|
|
@@ -24,7 +22,7 @@ export const SAFE_ADJECTIVES = [
|
|
|
24
22
|
'lucrative',
|
|
25
23
|
'modern',
|
|
26
24
|
];
|
|
27
|
-
|
|
25
|
+
const SAFE_RANDOM_NOUNS = [
|
|
28
26
|
'account',
|
|
29
27
|
'consumer',
|
|
30
28
|
'customer',
|
|
@@ -53,17 +51,10 @@ export const SAFE_NOUNS = [
|
|
|
53
51
|
'transaction',
|
|
54
52
|
'sale',
|
|
55
53
|
];
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Returns a randon name generated by combining a random adjetive and noun.
|
|
56
|
+
*/
|
|
57
|
+
export function getRandomName() {
|
|
58
|
+
return `${takeRandomFromArray(SAFE_RANDOM_ADJECTIVES)}-${takeRandomFromArray(SAFE_RANDOM_NOUNS)}`;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
const generated = `${generateRandomName()}-${suffix}`;
|
|
61
|
-
const isAppDirectoryTaken = await exists(join(directory, generated));
|
|
62
|
-
if (isAppDirectoryTaken) {
|
|
63
|
-
return generate({ suffix, directory });
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
return generated;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=haiku.js.map
|
|
60
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/public/common/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAA;AAE9C,MAAM,sBAAsB,GAAG;IAC7B,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,SAAS;IACT,YAAY;IACZ,aAAa;IACb,cAAc;IACd,aAAa;IACb,MAAM;IACN,OAAO;IACP,SAAS;IACT,QAAQ;IACR,UAAU;IACV,WAAW;IACX,WAAW;IACX,eAAe;IACf,YAAY;IACZ,UAAU;IACV,WAAW;IACX,WAAW;IACX,QAAQ;CACT,CAAA;AAED,MAAM,iBAAiB,GAAG;IACxB,SAAS;IACT,UAAU;IACV,UAAU;IACV,YAAY;IACZ,UAAU;IACV,SAAS;IACT,aAAa;IACb,SAAS;IACT,UAAU;IACV,WAAW;IACX,aAAa;IACb,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,QAAQ;IACR,OAAO;IACP,MAAM;IACN,aAAa;IACb,aAAa;IACb,MAAM;CACP,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,IAAI,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,CAAA;AACnG,CAAC","sourcesContent":["import {takeRandomFromArray} from './array.js'\n\nconst SAFE_RANDOM_ADJECTIVES = [\n 'commercial',\n 'profitable',\n 'amortizable',\n 'branded',\n 'integrated',\n 'synergistic',\n 'consolidated',\n 'diversified',\n 'lean',\n 'niche',\n 'premium',\n 'luxury',\n 'scalable',\n 'optimized',\n 'empowered',\n 'international',\n 'beneficial',\n 'fruitful',\n 'extensive',\n 'lucrative',\n 'modern',\n]\n\nconst SAFE_RANDOM_NOUNS = [\n 'account',\n 'consumer',\n 'customer',\n 'enterprise',\n 'business',\n 'venture',\n 'marketplace',\n 'revenue',\n 'vertical',\n 'portfolio',\n 'negotiation',\n 'shipping',\n 'demand',\n 'supply',\n 'growth',\n 'merchant',\n 'investment',\n 'shareholder',\n 'conversion',\n 'capital',\n 'projection',\n 'upside',\n 'trade',\n 'deal',\n 'merchandise',\n 'transaction',\n 'sale',\n]\n\n/**\n * Returns a randon name generated by combining a random adjetive and noun.\n */\nexport function getRandomName(): string {\n return `${takeRandomFromArray(SAFE_RANDOM_ADJECTIVES)}-${takeRandomFromArray(SAFE_RANDOM_NOUNS)}`\n}\n"]}
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { debug, content, token } from '
|
|
2
|
-
import { glob, relative as relativePath } from '
|
|
1
|
+
import { debug, content, token } from '../../output.js';
|
|
2
|
+
import { glob, relative as relativePath } from '../../path.js';
|
|
3
3
|
import archiver from 'archiver';
|
|
4
4
|
import { createWriteStream } from 'node:fs';
|
|
5
5
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../../src/public/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAC,IAAI,EAAE,QAAQ,IAAI,YAAY,EAAC,MAAM,eAAe,CAAA;AAC5D,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAA;AACzC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,cAAsB,EAAE,aAAqB;IACrE,KAAK,CAAC,OAAO,CAAA,WAAW,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IACvF,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,EAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAC,CAAC,CAAA;IACnH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC/B,MAAM,MAAM,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAA;QAE/C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE;YACjB,OAAO,EAAE,CAAA;QACX,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK;YACjC,MAAM,CAAC,KAAK,CAAC,CAAA;QACf,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpB,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;YACjC,MAAM,gBAAgB,GAAG,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;YAC/D,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC,CAAA;SACjD;QAED,mEAAmE;QACnE,OAAO,CAAC,QAAQ,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {debug, content, token} from '../../output.js'\nimport {glob, relative as relativePath} from '../../path.js'\nimport archiver from 'archiver'\nimport {createWriteStream} from 'node:fs'\n/**\n * It zips a directory normalizing the paths to be forward-slash. Note that unzipping\n * the zip generated by this function from a Windows environment won't work because paths\n * need to be made backward-slash.\n *\n * @param inputDirectory - The absolute path to the directory to be zipped.\n * @param outputZipPath - The absolute path to the output zip file.\n */\nexport async function zip(inputDirectory: string, outputZipPath: string): Promise<void> {\n debug(content`Zipping ${token.path(inputDirectory)} into ${token.path(outputZipPath)}`)\n const pathsToZip = await glob('**/*', {cwd: inputDirectory, absolute: true, dot: true, followSymbolicLinks: false})\n return new Promise((resolve, reject) => {\n const archive = archiver('zip')\n const output = createWriteStream(outputZipPath)\n\n output.on('close', function () {\n resolve()\n })\n archive.on('error', function (error) {\n reject(error)\n })\n archive.pipe(output)\n\n for (const filePath of pathsToZip) {\n const fileRelativePath = relativePath(inputDirectory, filePath)\n archive.file(filePath, {name: fileRelativePath})\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n archive.finalize()\n })\n}\n"]}
|
|
File without changes
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { errorHandler, registerCleanBugsnagErrorsFromWithinPlugins } from './error-handler.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { loadPresetsFromDirectory } from './presets.js';
|
|
3
|
+
import { isDevelopment } from '../../environment/local.js';
|
|
4
|
+
import { Abort } from '../../error.js';
|
|
5
|
+
import { addPublic } from '../../metadata.js';
|
|
6
|
+
import { content, info, token } from '../../output.js';
|
|
7
|
+
import { hashString } from '../../string.js';
|
|
8
|
+
import { initiateLogging } from '../../log.js';
|
|
8
9
|
import { Command } from '@oclif/core';
|
|
9
10
|
class BaseCommand extends Command {
|
|
10
11
|
static analyticsNameOverride() {
|
|
@@ -19,6 +20,7 @@ class BaseCommand extends Command {
|
|
|
19
20
|
// This function runs just prior to `run`
|
|
20
21
|
await registerCleanBugsnagErrorsFromWithinPlugins(this.config);
|
|
21
22
|
}
|
|
23
|
+
await initiateLogging();
|
|
22
24
|
return super.init();
|
|
23
25
|
}
|
|
24
26
|
async parse(options, argv) {
|