@shopify/cli-kit 3.46.0-pre.3 → 3.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +1 -1
- package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/cdn_fonts.rb +6 -2
- package/assets/cli-ruby/lib/shopify_cli/version.rb +1 -1
- package/dist/private/node/api.d.ts +1 -0
- package/dist/private/node/api.js +1 -0
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/constants.d.ts +1 -1
- package/dist/private/node/constants.js +1 -1
- package/dist/private/node/constants.js.map +1 -1
- package/dist/private/node/content-tokens.js +1 -1
- package/dist/private/node/content-tokens.js.map +1 -1
- package/dist/private/node/demo-recorder.d.ts +20 -0
- package/dist/private/node/demo-recorder.js +122 -0
- package/dist/private/node/demo-recorder.js.map +1 -0
- package/dist/private/node/session/schema.d.ts +203 -41
- package/dist/private/node/tree-kill.d.ts +1 -0
- package/dist/private/node/tree-kill.js +7 -0
- package/dist/private/node/tree-kill.js.map +1 -0
- package/dist/private/node/ui/alert.js +4 -0
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/Alert.test.js +2 -2
- package/dist/private/node/ui/components/Alert.test.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.d.ts +3 -1
- package/dist/private/node/ui/components/AutocompletePrompt.js +8 -4
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +33 -7
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -2
- package/dist/private/node/ui/components/ConcurrentOutput.js +23 -6
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +122 -8
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.js +5 -3
- package/dist/private/node/ui/components/FatalError.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.test.js +113 -0
- package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
- package/dist/private/node/ui/components/List.d.ts +1 -1
- package/dist/private/node/ui/components/List.js +2 -1
- package/dist/private/node/ui/components/List.js.map +1 -1
- package/dist/private/node/ui/components/List.test.js +19 -0
- package/dist/private/node/ui/components/List.test.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.js +5 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.test.js +5 -4
- package/dist/private/node/ui/components/Prompts/InfoTable.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.d.ts +3 -1
- package/dist/private/node/ui/components/SelectPrompt.js +4 -2
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js +22 -0
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.d.ts +3 -1
- package/dist/private/node/ui/components/Tasks.js +7 -3
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.test.js +22 -1
- package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.d.ts +2 -0
- package/dist/private/node/ui/components/TextPrompt.js +4 -2
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.test.js +9 -0
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.d.ts +1 -1
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.test.js +10 -0
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
- package/dist/private/node/ui/hooks/use-abort-signal.d.ts +4 -0
- package/dist/private/node/ui/hooks/use-abort-signal.js +14 -0
- package/dist/private/node/ui/hooks/use-abort-signal.js.map +1 -0
- package/dist/private/node/ui/hooks/use-async-and-unmount.d.ts +1 -1
- package/dist/private/node/ui/hooks/use-async-and-unmount.js +1 -1
- package/dist/private/node/ui/hooks/use-async-and-unmount.js.map +1 -1
- package/dist/private/node/ui.js +3 -3
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/cli.js +2 -0
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/colors.js.map +1 -0
- package/dist/public/node/context/local.d.ts +1 -1
- package/dist/public/node/context/local.js +2 -2
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/error-handler.js +7 -2
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/error.d.ts +8 -3
- package/dist/public/node/error.js +12 -5
- package/dist/public/node/error.js.map +1 -1
- package/dist/public/node/fs.d.ts +1 -0
- package/dist/public/node/hooks/prerun.js +2 -0
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/public/node/node-package-manager.d.ts +11 -0
- package/dist/public/node/node-package-manager.js +8 -6
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/output.d.ts +6 -1
- package/dist/public/node/output.js +6 -2
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/plugins/tunnel.d.ts +19 -4
- package/dist/public/node/plugins/tunnel.js +1 -1
- package/dist/public/node/plugins/tunnel.js.map +1 -1
- package/dist/public/node/plugins.d.ts +1 -12
- package/dist/public/node/plugins.js +0 -23
- package/dist/public/node/plugins.js.map +1 -1
- package/dist/public/node/ruby.js +2 -0
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/system.d.ts +1 -0
- package/dist/public/node/system.js +8 -3
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/tcp.js +1 -1
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/ui.d.ts +17 -8
- package/dist/public/node/ui.js +75 -19
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -12
- package/dist/private/node/colors.js.map +0 -1
- /package/dist/{private → public}/node/colors.d.ts +0 -0
- /package/dist/{private → public}/node/colors.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConcurrentOutput.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.tsx"],"names":[],"mappings":"AACA,OAAO,kBAAkB,MAAM,mCAAmC,CAAA;AAElE,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,EAAoB,QAAQ,EAAC,MAAM,OAAO,CAAA;AACxD,OAAO,EAAC,GAAG,EAAO,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAa,QAAQ,EAAC,MAAM,KAAK,CAAA;AACzE,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAA;AAwB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,gBAAgB,GAA6C,CAAC,EAClE,SAAS,EACT,eAAe,EACf,cAAc,GAAG,IAAI,EACrB,OAAO,EACP,MAAM,GACP,EAAE,EAAE;IACH,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAU,EAAE,CAAC,CAAA;IAC/D,MAAM,gBAAgB,GAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IAC7F,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CA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,CAAQ,CAC1B,CACP,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CAAC,CAAC,CAAC,IAAI,CACP,CACJ,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,gBAAgB,EAAC,CAAA","sourcesContent":["import {OutputProcess} from '../../../../public/node/output.js'\nimport useAsyncAndUnmount from '../hooks/use-async-and-unmount.js'\nimport {AbortController} from '../../../../public/node/abort.js'\nimport {handleCtrlC} from '../../ui.js'\nimport React, {FunctionComponent, useState} from 'react'\nimport {Box, Key, Static, Text, useInput, TextProps, useStdin} from 'ink'\nimport stripAnsi from 'strip-ansi'\nimport treeKill from 'tree-kill'\nimport figures from 'figures'\nimport {Writable} from 'stream'\n\nexport type WritableStream = (process: OutputProcess, index: number) => Writable\n\ninterface Shortcut {\n key: string\n action: string\n}\nexport interface ConcurrentOutputProps {\n processes: OutputProcess[]\n abortController: AbortController\n showTimestamps?: boolean\n onInput?: (input: string, key: Key, exit: () => void) => void\n footer?: {\n shortcuts: Shortcut[]\n subTitle?: string\n }\n}\ninterface Chunk {\n color: TextProps['color']\n prefix: string\n lines: string[]\n}\n\n/**\n * Renders output from concurrent processes to the terminal.\n * Output will be divided in a three column layout\n * with the left column containing the timestamp,\n * the right column containing the output,\n * and the middle column containing the process prefix.\n * Every process will be rendered with a different color, up to 4 colors.\n *\n * For example running `shopify app dev`:\n *\n * ```shell\n * 2022-10-10 13:11:03 | backend | npm\n * 2022-10-10 13:11:03 | backend | WARN ignoring workspace config at ...\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | > shopify-app-template-node@0.1.0 dev\n * 2022-10-10 13:11:03 | backend | > cross-env NODE_ENV=development nodemon backend/index.js --watch ./backend\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend | > starter-react-frontend-app@0.1.0 dev\n * 2022-10-10 13:11:03 | frontend | > cross-env NODE_ENV=development node vite-server.js\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | [nodemon] to restart at any time, enter `rs`\n * 2022-10-10 13:11:03 | backend | [nodemon] watching path(s): backend/\n * 2022-10-10 13:11:03 | backend | [nodemon] watching extensions: js,mjs,json\n * 2022-10-10 13:11:03 | backend | [nodemon] starting `node backend/index.js`\n * 2022-10-10 13:11:03 | backend |\n *\n * ```\n */\nconst ConcurrentOutput: FunctionComponent<ConcurrentOutputProps> = ({\n processes,\n abortController,\n showTimestamps = true,\n onInput,\n footer,\n}) => {\n const [processOutput, setProcessOutput] = useState<Chunk[]>([])\n const concurrentColors: TextProps['color'][] = ['yellow', 'cyan', 'magenta', 'green', 'blue']\n const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length))\n const {isRawModeSupported} = useStdin()\n\n function lineColor(index: number) {\n const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length\n return concurrentColors[colorIndex]!\n }\n\n const writableStream = (process: OutputProcess, index: number) => {\n return new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsi(chunk.toString('utf8').replace(/(\\n)$/, '')).split(/\\n/)\n\n setProcessOutput((previousProcessOutput) => [\n ...previousProcessOutput,\n {\n color: lineColor(index),\n prefix: process.prefix,\n lines,\n },\n ])\n\n next()\n },\n })\n }\n\n const runProcesses = () => {\n return Promise.all(\n processes.map(async (process, index) => {\n const stdout = writableStream(process, index)\n const stderr = writableStream(process, index)\n\n await process.action(stdout, stderr, abortController.signal)\n }),\n )\n }\n\n useInput(\n (input, key) => {\n handleCtrlC(input, key)\n\n onInput!(input, key, () => treeKill(process.pid, 'SIGINT'))\n },\n // isRawModeSupported can be undefined even if the type doesn't say so\n // Ink is checking that isActive is actually === false, not falsey\n {isActive: typeof onInput !== 'undefined' && Boolean(isRawModeSupported)},\n )\n\n useAsyncAndUnmount(runProcesses, {onRejected: () => abortController.abort()})\n\n return (\n <>\n <Static items={processOutput}>\n {(chunk, index) => {\n return (\n <Box flexDirection=\"column\" key={index}>\n {chunk.lines.map((line, index) => (\n <Box key={index} flexDirection=\"row\">\n {showTimestamps ? (\n <Box>\n <Box marginRight={1}>\n <Text color={chunk.color}>\n {new Date().toISOString().replace(/T/, ' ').replace(/\\..+/, '')}\n </Text>\n </Box>\n\n <Text bold color={chunk.color}>\n {figures.lineVertical}\n </Text>\n </Box>\n ) : null}\n\n <Box width={prefixColumnSize} marginX={1}>\n <Text color={chunk.color}>{chunk.prefix}</Text>\n </Box>\n\n <Text bold color={chunk.color}>\n {figures.lineVertical}\n </Text>\n\n <Box flexGrow={1} paddingLeft={1}>\n <Text color={chunk.color}>{line}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n )\n }}\n </Static>\n {footer ? (\n <Box marginY={1} flexDirection=\"column\" flexGrow={1}>\n {isRawModeSupported ? (\n <Box flexDirection=\"column\">\n {footer.shortcuts.map((shortcut, index) => (\n <Text key={index}>\n {figures.pointerSmall} Press <Text bold>{shortcut.key}</Text> {figures.lineVertical} {shortcut.action}\n </Text>\n ))}\n </Box>\n ) : null}\n {footer.subTitle ? (\n <Box marginTop={isRawModeSupported ? 1 : 0}>\n <Text>{footer.subTitle}</Text>\n </Box>\n ) : null}\n </Box>\n ) : null}\n </>\n )\n}\n\nexport {ConcurrentOutput}\n"]}
|
|
1
|
+
{"version":3,"file":"ConcurrentOutput.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.tsx"],"names":[],"mappings":"AACA,OAAO,kBAAkB,MAAM,mCAAmC,CAAA;AAElE,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,EAAC,kCAAkC,EAAC,MAAM,wBAAwB,CAAA;AACzE,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAC3C,OAAO,cAAc,MAAM,8BAA8B,CAAA;AACzD,OAAO,KAAK,EAAE,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C,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxC,oBAAC,IAAI,QAAE,MAAM,CAAC,QAAQ,CAAQ,CAC1B,CACP,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CAAC,CAAC,CAAC,IAAI,CACP,CACJ,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,gBAAgB,EAAC,CAAA","sourcesContent":["import {OutputProcess} from '../../../../public/node/output.js'\nimport useAsyncAndUnmount from '../hooks/use-async-and-unmount.js'\nimport {AbortSignal} from '../../../../public/node/abort.js'\nimport {handleCtrlC} from '../../ui.js'\nimport {addOrUpdateConcurrentUIEventOutput} from '../../demo-recorder.js'\nimport {treeKill} from '../../tree-kill.js'\nimport useAbortSignal from '../hooks/use-abort-signal.js'\nimport React, {FunctionComponent, useState} from 'react'\nimport {Box, Key, Static, Text, useInput, TextProps, useStdin} from 'ink'\nimport stripAnsi from 'strip-ansi'\nimport figures from 'figures'\nimport {Writable} from 'stream'\n\nexport type WritableStream = (process: OutputProcess, index: number) => Writable\n\ninterface Shortcut {\n key: string\n action: string\n}\nexport interface ConcurrentOutputProps {\n processes: OutputProcess[]\n abortSignal: AbortSignal\n showTimestamps?: boolean\n onInput?: (input: string, key: Key, exit: () => void) => void\n footer?: {\n shortcuts: Shortcut[]\n subTitle?: string\n }\n}\ninterface Chunk {\n color: TextProps['color']\n prefix: string\n lines: string[]\n}\n\nenum ConcurrentOutputState {\n Running = 'running',\n Stopped = 'stopped',\n}\n\n/**\n * Renders output from concurrent processes to the terminal.\n * Output will be divided in a three column layout\n * with the left column containing the timestamp,\n * the right column containing the output,\n * and the middle column containing the process prefix.\n * Every process will be rendered with a different color, up to 4 colors.\n *\n * For example running `shopify app dev`:\n *\n * ```shell\n * 2022-10-10 13:11:03 | backend | npm\n * 2022-10-10 13:11:03 | backend | WARN ignoring workspace config at ...\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | > shopify-app-template-node@0.1.0 dev\n * 2022-10-10 13:11:03 | backend | > cross-env NODE_ENV=development nodemon backend/index.js --watch ./backend\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend | > starter-react-frontend-app@0.1.0 dev\n * 2022-10-10 13:11:03 | frontend | > cross-env NODE_ENV=development node vite-server.js\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | frontend |\n * 2022-10-10 13:11:03 | backend |\n * 2022-10-10 13:11:03 | backend | [nodemon] to restart at any time, enter `rs`\n * 2022-10-10 13:11:03 | backend | [nodemon] watching path(s): backend/\n * 2022-10-10 13:11:03 | backend | [nodemon] watching extensions: js,mjs,json\n * 2022-10-10 13:11:03 | backend | [nodemon] starting `node backend/index.js`\n * 2022-10-10 13:11:03 | backend |\n *\n * ```\n */\nconst ConcurrentOutput: FunctionComponent<ConcurrentOutputProps> = ({\n processes,\n abortSignal,\n showTimestamps = true,\n onInput,\n footer,\n}) => {\n const [processOutput, setProcessOutput] = useState<Chunk[]>([])\n const concurrentColors: TextProps['color'][] = ['yellow', 'cyan', 'magenta', 'green', 'blue']\n const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length))\n const {isRawModeSupported} = useStdin()\n const [state, setState] = useState<ConcurrentOutputState>(ConcurrentOutputState.Running)\n\n function lineColor(index: number) {\n const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length\n return concurrentColors[colorIndex]!\n }\n\n const writableStream = (process: OutputProcess, index: number) => {\n return new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsi(chunk.toString('utf8').replace(/(\\n)$/, '')).split(/\\n/)\n addOrUpdateConcurrentUIEventOutput({prefix: process.prefix, index, output: lines.join('\\n')}, {footer})\n\n setProcessOutput((previousProcessOutput) => [\n ...previousProcessOutput,\n {\n color: lineColor(index),\n prefix: process.prefix,\n lines,\n },\n ])\n\n next()\n },\n })\n }\n\n const runProcesses = () => {\n return Promise.all(\n processes.map(async (process, index) => {\n const stdout = writableStream(process, index)\n const stderr = writableStream(process, index)\n\n await process.action(stdout, stderr, abortSignal)\n }),\n )\n }\n\n useInput(\n (input, key) => {\n handleCtrlC(input, key)\n\n onInput!(input, key, () => treeKill('SIGINT'))\n },\n // isRawModeSupported can be undefined even if the type doesn't say so\n // Ink is checking that isActive is actually === false, not falsey\n {isActive: typeof onInput !== 'undefined' && Boolean(isRawModeSupported)},\n )\n\n useAsyncAndUnmount(runProcesses, {\n onFulfilled: () => {\n setState(ConcurrentOutputState.Stopped)\n },\n onRejected: () => {\n setState(ConcurrentOutputState.Stopped)\n },\n })\n\n const {isAborted} = useAbortSignal(abortSignal)\n\n return (\n <>\n <Static items={processOutput}>\n {(chunk, index) => {\n return (\n <Box flexDirection=\"column\" key={index}>\n {chunk.lines.map((line, index) => (\n <Box key={index} flexDirection=\"row\">\n {showTimestamps ? (\n <Box>\n <Box marginRight={1}>\n <Text color={chunk.color}>\n {new Date().toISOString().replace(/T/, ' ').replace(/\\..+/, '')}\n </Text>\n </Box>\n\n <Text bold color={chunk.color}>\n {figures.lineVertical}\n </Text>\n </Box>\n ) : null}\n\n <Box width={prefixColumnSize} marginX={1}>\n <Text color={chunk.color}>{chunk.prefix}</Text>\n </Box>\n\n <Text bold color={chunk.color}>\n {figures.lineVertical}\n </Text>\n\n <Box flexGrow={1} paddingLeft={1}>\n <Text color={chunk.color}>{line}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n )\n }}\n </Static>\n {state === ConcurrentOutputState.Running && !isAborted && footer ? (\n <Box marginY={1} flexDirection=\"column\" flexGrow={1}>\n {isRawModeSupported ? (\n <Box flexDirection=\"column\">\n {footer.shortcuts.map((shortcut, index) => (\n <Text key={index}>\n {figures.pointerSmall} Press <Text bold>{shortcut.key}</Text> {figures.lineVertical} {shortcut.action}\n </Text>\n ))}\n </Box>\n ) : null}\n {footer.subTitle ? (\n <Box marginTop={isRawModeSupported ? 1 : 0}>\n <Text>{footer.subTitle}</Text>\n </Box>\n ) : null}\n </Box>\n ) : null}\n </>\n )\n}\n\nexport {ConcurrentOutput}\n"]}
|
|
@@ -8,9 +8,13 @@ describe('ConcurrentOutput', () => {
|
|
|
8
8
|
test('renders a stream of concurrent outputs from sub-processes', async () => {
|
|
9
9
|
// Given
|
|
10
10
|
let backendPromiseResolve;
|
|
11
|
+
let frontendPromiseResolve;
|
|
11
12
|
const backendPromise = new Promise(function (resolve, _reject) {
|
|
12
13
|
backendPromiseResolve = resolve;
|
|
13
14
|
});
|
|
15
|
+
const frontendPromise = new Promise(function (resolve, _reject) {
|
|
16
|
+
frontendPromiseResolve = resolve;
|
|
17
|
+
});
|
|
14
18
|
const backendProcess = {
|
|
15
19
|
prefix: 'backend',
|
|
16
20
|
action: async (stdout, _stderr, _signal) => {
|
|
@@ -27,10 +31,13 @@ describe('ConcurrentOutput', () => {
|
|
|
27
31
|
stdout.write('first frontend message');
|
|
28
32
|
stdout.write('second frontend message');
|
|
29
33
|
stdout.write('third frontend message');
|
|
34
|
+
frontendPromiseResolve();
|
|
35
|
+
// await promise that never resolves
|
|
36
|
+
await new Promise(() => { });
|
|
30
37
|
},
|
|
31
38
|
};
|
|
32
39
|
// When
|
|
33
|
-
const renderInstance = render(React.createElement(ConcurrentOutput, { processes: [backendProcess, frontendProcess],
|
|
40
|
+
const renderInstance = render(React.createElement(ConcurrentOutput, { processes: [backendProcess, frontendProcess], abortSignal: new AbortController().signal, footer: {
|
|
34
41
|
shortcuts: [
|
|
35
42
|
{
|
|
36
43
|
key: 'p',
|
|
@@ -43,10 +50,9 @@ describe('ConcurrentOutput', () => {
|
|
|
43
50
|
],
|
|
44
51
|
subTitle: `Preview URL: https://shopify.com`,
|
|
45
52
|
} }));
|
|
46
|
-
|
|
47
|
-
await renderInstance.waitUntilExit();
|
|
53
|
+
await frontendPromise;
|
|
48
54
|
// Then
|
|
49
|
-
expect(unstyled(
|
|
55
|
+
expect(unstyled(renderInstance.lastFrame().replace(/\d/g, '0'))).toMatchInlineSnapshot(`
|
|
50
56
|
"0000-00-00 00:00:00 │ backend │ first backend message
|
|
51
57
|
0000-00-00 00:00:00 │ backend │ second backend message
|
|
52
58
|
0000-00-00 00:00:00 │ backend │ third backend message
|
|
@@ -64,9 +70,13 @@ describe('ConcurrentOutput', () => {
|
|
|
64
70
|
test("doesn't render shortcuts if the stdin is not a TTY", async () => {
|
|
65
71
|
// Given
|
|
66
72
|
let backendPromiseResolve;
|
|
73
|
+
let frontendPromiseResolve;
|
|
67
74
|
const backendPromise = new Promise(function (resolve, _reject) {
|
|
68
75
|
backendPromiseResolve = resolve;
|
|
69
76
|
});
|
|
77
|
+
const frontendPromise = new Promise(function (resolve, _reject) {
|
|
78
|
+
frontendPromiseResolve = resolve;
|
|
79
|
+
});
|
|
70
80
|
const backendProcess = {
|
|
71
81
|
prefix: 'backend',
|
|
72
82
|
action: async (stdout, _stderr, _signal) => {
|
|
@@ -83,10 +93,13 @@ describe('ConcurrentOutput', () => {
|
|
|
83
93
|
stdout.write('first frontend message');
|
|
84
94
|
stdout.write('second frontend message');
|
|
85
95
|
stdout.write('third frontend message');
|
|
96
|
+
frontendPromiseResolve();
|
|
97
|
+
// await promise that never resolves
|
|
98
|
+
await new Promise(() => { });
|
|
86
99
|
},
|
|
87
100
|
};
|
|
88
101
|
// When
|
|
89
|
-
const renderInstance = render(React.createElement(ConcurrentOutput, { processes: [backendProcess, frontendProcess],
|
|
102
|
+
const renderInstance = render(React.createElement(ConcurrentOutput, { processes: [backendProcess, frontendProcess], abortSignal: new AbortController().signal, footer: {
|
|
90
103
|
shortcuts: [
|
|
91
104
|
{
|
|
92
105
|
key: 'p',
|
|
@@ -99,8 +112,7 @@ describe('ConcurrentOutput', () => {
|
|
|
99
112
|
],
|
|
100
113
|
subTitle: `Preview URL: https://shopify.com`,
|
|
101
114
|
} }), { stdin: new Stdin({ isTTY: false }) });
|
|
102
|
-
|
|
103
|
-
await renderInstance.waitUntilExit();
|
|
115
|
+
await frontendPromise;
|
|
104
116
|
// Then
|
|
105
117
|
expect(unstyled(getLastFrameAfterUnmount(renderInstance).replace(/\d/g, '0'))).toMatchInlineSnapshot(`
|
|
106
118
|
"0000-00-00 00:00:00 │ backend │ first backend message
|
|
@@ -123,12 +135,114 @@ describe('ConcurrentOutput', () => {
|
|
|
123
135
|
},
|
|
124
136
|
};
|
|
125
137
|
const onInput = vi.fn();
|
|
126
|
-
const renderInstance = render(React.createElement(ConcurrentOutput, { processes: [neverEndingProcess],
|
|
138
|
+
const renderInstance = render(React.createElement(ConcurrentOutput, { processes: [neverEndingProcess], onInput: (input, key) => onInput(input, key), abortSignal: new AbortController().signal }));
|
|
127
139
|
await waitForInputsToBeReady();
|
|
128
140
|
expect(onInput).toHaveBeenCalledTimes(0);
|
|
129
141
|
renderInstance.stdin.write('a');
|
|
130
142
|
expect(onInput).toHaveBeenCalledTimes(1);
|
|
131
143
|
expect(onInput.mock.calls[0][0]).toBe('a');
|
|
132
144
|
});
|
|
145
|
+
test('abortController can be used to exit from outside and should preserve static output', async () => {
|
|
146
|
+
// Given
|
|
147
|
+
const abortController = new AbortController();
|
|
148
|
+
const backendProcess = {
|
|
149
|
+
prefix: 'backend',
|
|
150
|
+
action: async (stdout, _stderr, _signal) => {
|
|
151
|
+
stdout.write('first backend message');
|
|
152
|
+
stdout.write('second backend message');
|
|
153
|
+
stdout.write('third backend message');
|
|
154
|
+
// await promise that never resolves
|
|
155
|
+
await new Promise(() => { });
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
// When
|
|
159
|
+
const renderInstance = render(React.createElement(ConcurrentOutput, { processes: [backendProcess], abortSignal: abortController.signal, footer: {
|
|
160
|
+
shortcuts: [
|
|
161
|
+
{
|
|
162
|
+
key: 'p',
|
|
163
|
+
action: 'preview in your browser',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
key: 'q',
|
|
167
|
+
action: 'quit',
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
subTitle: `Preview URL: https://shopify.com`,
|
|
171
|
+
} }));
|
|
172
|
+
const promise = renderInstance.waitUntilExit();
|
|
173
|
+
abortController.abort();
|
|
174
|
+
expect(unstyled(getLastFrameAfterUnmount(renderInstance)).replace(/\d/g, '0')).toMatchInlineSnapshot(`
|
|
175
|
+
"0000-00-00 00:00:00 │ backend │ first backend message
|
|
176
|
+
0000-00-00 00:00:00 │ backend │ second backend message
|
|
177
|
+
0000-00-00 00:00:00 │ backend │ third backend message
|
|
178
|
+
"
|
|
179
|
+
`);
|
|
180
|
+
await expect(promise).resolves.toEqual(undefined);
|
|
181
|
+
});
|
|
182
|
+
test('rejects with the error thrown inside one of the processes', async () => {
|
|
183
|
+
// Given
|
|
184
|
+
const backendProcess = {
|
|
185
|
+
prefix: 'backend',
|
|
186
|
+
action: async (stdout, _stderr, _signal) => {
|
|
187
|
+
stdout.write('first backend message');
|
|
188
|
+
stdout.write('second backend message');
|
|
189
|
+
stdout.write('third backend message');
|
|
190
|
+
throw new Error('something went wrong');
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
// When
|
|
194
|
+
const renderInstance = render(React.createElement(ConcurrentOutput, { processes: [backendProcess], abortSignal: new AbortController().signal, footer: {
|
|
195
|
+
shortcuts: [
|
|
196
|
+
{
|
|
197
|
+
key: 'p',
|
|
198
|
+
action: 'preview in your browser',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
key: 'q',
|
|
202
|
+
action: 'quit',
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
subTitle: `Preview URL: https://shopify.com`,
|
|
206
|
+
} }));
|
|
207
|
+
await expect(renderInstance.waitUntilExit()).rejects.toThrowError('something went wrong');
|
|
208
|
+
expect(unstyled(getLastFrameAfterUnmount(renderInstance)).replace(/\d/g, '0')).toMatchInlineSnapshot(`
|
|
209
|
+
"0000-00-00 00:00:00 │ backend │ first backend message
|
|
210
|
+
0000-00-00 00:00:00 │ backend │ second backend message
|
|
211
|
+
0000-00-00 00:00:00 │ backend │ third backend message
|
|
212
|
+
"
|
|
213
|
+
`);
|
|
214
|
+
});
|
|
215
|
+
test("doesn't render the footer when the processes resolve", async () => {
|
|
216
|
+
// Given
|
|
217
|
+
const backendProcess = {
|
|
218
|
+
prefix: 'backend',
|
|
219
|
+
action: async (stdout, _stderr, _signal) => {
|
|
220
|
+
stdout.write('first backend message');
|
|
221
|
+
stdout.write('second backend message');
|
|
222
|
+
stdout.write('third backend message');
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
// When
|
|
226
|
+
const renderInstance = render(React.createElement(ConcurrentOutput, { processes: [backendProcess], abortSignal: new AbortController().signal, footer: {
|
|
227
|
+
shortcuts: [
|
|
228
|
+
{
|
|
229
|
+
key: 'p',
|
|
230
|
+
action: 'preview in your browser',
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
key: 'q',
|
|
234
|
+
action: 'quit',
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
subTitle: `Preview URL: https://shopify.com`,
|
|
238
|
+
} }));
|
|
239
|
+
await renderInstance.waitUntilExit();
|
|
240
|
+
expect(unstyled(getLastFrameAfterUnmount(renderInstance)).replace(/\d/g, '0')).toMatchInlineSnapshot(`
|
|
241
|
+
"0000-00-00 00:00:00 │ backend │ first backend message
|
|
242
|
+
0000-00-00 00:00:00 │ backend │ second backend message
|
|
243
|
+
0000-00-00 00:00:00 │ backend │ third backend message
|
|
244
|
+
"
|
|
245
|
+
`);
|
|
246
|
+
});
|
|
133
247
|
});
|
|
134
248
|
//# sourceMappingURL=ConcurrentOutput.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConcurrentOutput.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAC,wBAAwB,E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ED,MAAM,OAAO,GAAG,EAAE,CAAC,EAAE,EAAE,CAAA;QAEvB,MAAM,cAAc,GAAG,MAAM,CAC3B,oBAAC,gBAAgB,IACf,SAAS,EAAE,CAAC,kBAAkB,CAAC,EAC/B,eAAe,EAAE,IAAI,eAAe,EAAE,EACtC,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,GAC5C,CACH,CAAA;QAED,MAAM,sBAAsB,EAAE,CAAA;QAC9B,MAAM,CAAC,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;QAExC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC/B,MAAM,CAAC,OAAO,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;QACxC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {ConcurrentOutput} from './ConcurrentOutput.js'\nimport {getLastFrameAfterUnmount, waitForInputsToBeReady, render, Stdin} from '../../testing/ui.js'\nimport {AbortController, AbortSignal} from '../../../../public/node/abort.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport React from 'react'\nimport {describe, expect, test, vi} from 'vitest'\nimport {Writable} from 'stream'\n\ndescribe('ConcurrentOutput', () => {\n test('renders a stream of concurrent outputs from sub-processes', async () => {\n // Given\n let backendPromiseResolve: () => void\n\n const backendPromise = new Promise<void>(function (resolve, _reject) {\n backendPromiseResolve = resolve\n })\n\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n backendPromiseResolve()\n },\n }\n\n const frontendProcess = {\n prefix: 'frontend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n await backendPromise\n\n stdout.write('first frontend message')\n stdout.write('second frontend message')\n stdout.write('third frontend message')\n },\n }\n // When\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[backendProcess, frontendProcess]}\n abortController={new AbortController()}\n footer={{\n shortcuts: [\n {\n key: 'p',\n action: 'preview in your browser',\n },\n {\n key: 'q',\n action: 'quit',\n },\n ],\n subTitle: `Preview URL: https://shopify.com`,\n }}\n />,\n )\n\n // wait for all output to be rendered\n await renderInstance.waitUntilExit()\n\n // Then\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!.replace(/\\d/g, '0'))).toMatchInlineSnapshot(`\n \"0000-00-00 00:00:00 │ backend │ first backend message\n 0000-00-00 00:00:00 │ backend │ second backend message\n 0000-00-00 00:00:00 │ backend │ third backend message\n 0000-00-00 00:00:00 │ frontend │ first frontend message\n 0000-00-00 00:00:00 │ frontend │ second frontend message\n 0000-00-00 00:00:00 │ frontend │ third frontend message\n\n › Press p │ preview in your browser\n › Press q │ quit\n\n Preview URL: https://shopify.com\n \"\n `)\n })\n\n test(\"doesn't render shortcuts if the stdin is not a TTY\", async () => {\n // Given\n let backendPromiseResolve: () => void\n\n const backendPromise = new Promise<void>(function (resolve, _reject) {\n backendPromiseResolve = resolve\n })\n\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n backendPromiseResolve()\n },\n }\n\n const frontendProcess = {\n prefix: 'frontend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n await backendPromise\n\n stdout.write('first frontend message')\n stdout.write('second frontend message')\n stdout.write('third frontend message')\n },\n }\n // When\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[backendProcess, frontendProcess]}\n abortController={new AbortController()}\n footer={{\n shortcuts: [\n {\n key: 'p',\n action: 'preview in your browser',\n },\n {\n key: 'q',\n action: 'quit',\n },\n ],\n subTitle: `Preview URL: https://shopify.com`,\n }}\n />,\n {stdin: new Stdin({isTTY: false})},\n )\n\n // wait for all output to be rendered\n await renderInstance.waitUntilExit()\n\n // Then\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!.replace(/\\d/g, '0'))).toMatchInlineSnapshot(`\n \"0000-00-00 00:00:00 │ backend │ first backend message\n 0000-00-00 00:00:00 │ backend │ second backend message\n 0000-00-00 00:00:00 │ backend │ third backend message\n 0000-00-00 00:00:00 │ frontend │ first frontend message\n 0000-00-00 00:00:00 │ frontend │ second frontend message\n 0000-00-00 00:00:00 │ frontend │ third frontend message\n\n Preview URL: https://shopify.com\n \"\n `)\n })\n\n test('accepts a onInput function that fires when a key is pressed', async () => {\n const neverEndingPromise = new Promise<void>(function (_resolve, _reject) {})\n\n const neverEndingProcess = {\n prefix: 'never-ending-process',\n action: async () => {\n await neverEndingPromise\n },\n }\n\n const onInput = vi.fn()\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[neverEndingProcess]}\n abortController={new AbortController()}\n onInput={(input, key) => onInput(input, key)}\n />,\n )\n\n await waitForInputsToBeReady()\n expect(onInput).toHaveBeenCalledTimes(0)\n\n renderInstance.stdin.write('a')\n expect(onInput).toHaveBeenCalledTimes(1)\n expect(onInput.mock.calls[0]![0]).toBe('a')\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"ConcurrentOutput.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/ConcurrentOutput.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAC,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,EAAE,KAAK,EAAC,MAAM,qBAAqB,CAAA;AACnG,OAAO,EAAC,eAAe,EAAc,MAAM,kCAAkC,CAAA;AAC7E,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAA;AAC1D,OAAO,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IACf,SAAS,EAAE,CAAC,cAAc,CAAC,EAC3B,WAAW,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM,EACzC,MAAM,EAAE;gBACN,SAAS,EAAE;oBACT;wBACE,GAAG,EAAE,GAAG;wBACR,MAAM,EAAE,yBAAyB;qBAClC;oBACD;wBACE,GAAG,EAAE,GAAG;wBACR,MAAM,EAAE,MAAM;qBACf;iBACF;gBACD,QAAQ,EAAE,kCAAkC;aAC7C,GACD,CACH,CAAA;QAED,MAAM,cAAc,CAAC,aAAa,EAAE,CAAA;QAEpC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,CAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKrG,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {ConcurrentOutput} from './ConcurrentOutput.js'\nimport {getLastFrameAfterUnmount, waitForInputsToBeReady, render, Stdin} from '../../testing/ui.js'\nimport {AbortController, AbortSignal} from '../../../../public/node/abort.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport React from 'react'\nimport {describe, expect, test, vi} from 'vitest'\nimport {Writable} from 'stream'\n\ndescribe('ConcurrentOutput', () => {\n test('renders a stream of concurrent outputs from sub-processes', async () => {\n // Given\n let backendPromiseResolve: () => void\n let frontendPromiseResolve: () => void\n\n const backendPromise = new Promise<void>(function (resolve, _reject) {\n backendPromiseResolve = resolve\n })\n\n const frontendPromise = new Promise<void>(function (resolve, _reject) {\n frontendPromiseResolve = resolve\n })\n\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n backendPromiseResolve()\n },\n }\n\n const frontendProcess = {\n prefix: 'frontend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n await backendPromise\n\n stdout.write('first frontend message')\n stdout.write('second frontend message')\n stdout.write('third frontend message')\n\n frontendPromiseResolve()\n\n // await promise that never resolves\n await new Promise(() => {})\n },\n }\n // When\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[backendProcess, frontendProcess]}\n abortSignal={new AbortController().signal}\n footer={{\n shortcuts: [\n {\n key: 'p',\n action: 'preview in your browser',\n },\n {\n key: 'q',\n action: 'quit',\n },\n ],\n subTitle: `Preview URL: https://shopify.com`,\n }}\n />,\n )\n\n await frontendPromise\n\n // Then\n expect(unstyled(renderInstance.lastFrame()!.replace(/\\d/g, '0'))).toMatchInlineSnapshot(`\n \"0000-00-00 00:00:00 │ backend │ first backend message\n 0000-00-00 00:00:00 │ backend │ second backend message\n 0000-00-00 00:00:00 │ backend │ third backend message\n 0000-00-00 00:00:00 │ frontend │ first frontend message\n 0000-00-00 00:00:00 │ frontend │ second frontend message\n 0000-00-00 00:00:00 │ frontend │ third frontend message\n\n › Press p │ preview in your browser\n › Press q │ quit\n\n Preview URL: https://shopify.com\n \"\n `)\n })\n\n test(\"doesn't render shortcuts if the stdin is not a TTY\", async () => {\n // Given\n let backendPromiseResolve: () => void\n let frontendPromiseResolve: () => void\n\n const backendPromise = new Promise<void>(function (resolve, _reject) {\n backendPromiseResolve = resolve\n })\n\n const frontendPromise = new Promise<void>(function (resolve, _reject) {\n frontendPromiseResolve = resolve\n })\n\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n backendPromiseResolve()\n },\n }\n\n const frontendProcess = {\n prefix: 'frontend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n await backendPromise\n\n stdout.write('first frontend message')\n stdout.write('second frontend message')\n stdout.write('third frontend message')\n\n frontendPromiseResolve()\n\n // await promise that never resolves\n await new Promise(() => {})\n },\n }\n // When\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[backendProcess, frontendProcess]}\n abortSignal={new AbortController().signal}\n footer={{\n shortcuts: [\n {\n key: 'p',\n action: 'preview in your browser',\n },\n {\n key: 'q',\n action: 'quit',\n },\n ],\n subTitle: `Preview URL: https://shopify.com`,\n }}\n />,\n {stdin: new Stdin({isTTY: false})},\n )\n\n await frontendPromise\n\n // Then\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!.replace(/\\d/g, '0'))).toMatchInlineSnapshot(`\n \"0000-00-00 00:00:00 │ backend │ first backend message\n 0000-00-00 00:00:00 │ backend │ second backend message\n 0000-00-00 00:00:00 │ backend │ third backend message\n 0000-00-00 00:00:00 │ frontend │ first frontend message\n 0000-00-00 00:00:00 │ frontend │ second frontend message\n 0000-00-00 00:00:00 │ frontend │ third frontend message\n\n Preview URL: https://shopify.com\n \"\n `)\n })\n\n test('accepts a onInput function that fires when a key is pressed', async () => {\n const neverEndingPromise = new Promise<void>(function (_resolve, _reject) {})\n\n const neverEndingProcess = {\n prefix: 'never-ending-process',\n action: async () => {\n await neverEndingPromise\n },\n }\n\n const onInput = vi.fn()\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[neverEndingProcess]}\n onInput={(input, key) => onInput(input, key)}\n abortSignal={new AbortController().signal}\n />,\n )\n\n await waitForInputsToBeReady()\n expect(onInput).toHaveBeenCalledTimes(0)\n\n renderInstance.stdin.write('a')\n expect(onInput).toHaveBeenCalledTimes(1)\n expect(onInput.mock.calls[0]![0]).toBe('a')\n })\n\n test('abortController can be used to exit from outside and should preserve static output', async () => {\n // Given\n const abortController = new AbortController()\n\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n // await promise that never resolves\n await new Promise(() => {})\n },\n }\n\n // When\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[backendProcess]}\n abortSignal={abortController.signal}\n footer={{\n shortcuts: [\n {\n key: 'p',\n action: 'preview in your browser',\n },\n {\n key: 'q',\n action: 'quit',\n },\n ],\n subTitle: `Preview URL: https://shopify.com`,\n }}\n />,\n )\n\n const promise = renderInstance.waitUntilExit()\n\n abortController.abort()\n\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!).replace(/\\d/g, '0')).toMatchInlineSnapshot(`\n \"0000-00-00 00:00:00 │ backend │ first backend message\n 0000-00-00 00:00:00 │ backend │ second backend message\n 0000-00-00 00:00:00 │ backend │ third backend message\n \"\n `)\n\n await expect(promise).resolves.toEqual(undefined)\n })\n\n test('rejects with the error thrown inside one of the processes', async () => {\n // Given\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n\n throw new Error('something went wrong')\n },\n }\n\n // When\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[backendProcess]}\n abortSignal={new AbortController().signal}\n footer={{\n shortcuts: [\n {\n key: 'p',\n action: 'preview in your browser',\n },\n {\n key: 'q',\n action: 'quit',\n },\n ],\n subTitle: `Preview URL: https://shopify.com`,\n }}\n />,\n )\n\n await expect(renderInstance.waitUntilExit()).rejects.toThrowError('something went wrong')\n\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!).replace(/\\d/g, '0')).toMatchInlineSnapshot(`\n \"0000-00-00 00:00:00 │ backend │ first backend message\n 0000-00-00 00:00:00 │ backend │ second backend message\n 0000-00-00 00:00:00 │ backend │ third backend message\n \"\n `)\n })\n\n test(\"doesn't render the footer when the processes resolve\", async () => {\n // Given\n const backendProcess = {\n prefix: 'backend',\n action: async (stdout: Writable, _stderr: Writable, _signal: AbortSignal) => {\n stdout.write('first backend message')\n stdout.write('second backend message')\n stdout.write('third backend message')\n },\n }\n\n // When\n\n const renderInstance = render(\n <ConcurrentOutput\n processes={[backendProcess]}\n abortSignal={new AbortController().signal}\n footer={{\n shortcuts: [\n {\n key: 'p',\n action: 'preview in your browser',\n },\n {\n key: 'q',\n action: 'quit',\n },\n ],\n subTitle: `Preview URL: https://shopify.com`,\n }}\n />,\n )\n\n await renderInstance.waitUntilExit()\n\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!).replace(/\\d/g, '0')).toMatchInlineSnapshot(`\n \"0000-00-00 00:00:00 │ backend │ first backend message\n 0000-00-00 00:00:00 │ backend │ second backend message\n 0000-00-00 00:00:00 │ backend │ third backend message\n \"\n `)\n })\n})\n"]}
|
|
@@ -34,12 +34,14 @@ const FatalError = ({ error }) => {
|
|
|
34
34
|
React.createElement(Text, null,
|
|
35
35
|
"Error coming from ",
|
|
36
36
|
React.createElement(Command, { command: tool })))) : null,
|
|
37
|
-
React.createElement(Box, null,
|
|
38
|
-
React.createElement(Text, null, error.message)),
|
|
37
|
+
React.createElement(Box, null, error.formattedMessage ? React.createElement(TokenizedText, { item: error.formattedMessage }) : React.createElement(Text, null, error.message)),
|
|
39
38
|
error.tryMessage ? (React.createElement(Box, { marginTop: 1 },
|
|
40
39
|
React.createElement(TokenizedText, { item: error.tryMessage }))) : null,
|
|
41
|
-
error.nextSteps ? (React.createElement(Box, { marginTop: 1 },
|
|
40
|
+
error.nextSteps && error.nextSteps.length > 0 ? (React.createElement(Box, { marginTop: 1 },
|
|
42
41
|
React.createElement(List, { title: "Next steps", items: error.nextSteps }))) : null,
|
|
42
|
+
error.customSections && error.customSections.length > 0 ? (React.createElement(Box, { flexDirection: "column" }, error.customSections.map((section, index) => (React.createElement(Box, { key: index, flexDirection: "column", marginTop: 1 },
|
|
43
|
+
section.title ? React.createElement(Text, { bold: true }, section.title) : null,
|
|
44
|
+
React.createElement(TokenizedText, { item: section.body })))))) : null,
|
|
43
45
|
stack && stack.items.length !== 0 ? (React.createElement(Box, { marginTop: 1, flexDirection: "column" },
|
|
44
46
|
React.createElement(Text, null, "To investigate the issue, examine this stack trace:"),
|
|
45
47
|
stack.items.map((item, index) => (React.createElement(Box, { flexDirection: "column", key: index, paddingLeft: 2 },
|
|
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I;QAEP,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CACnC,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ;YACvC,oBAAC,IAAI,8DAA2D;YAC/D,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAChC,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;gBACpD,oBAAC,IAAI;;oBACA,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,oBAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,IAAE,IAAI,IAAI,CAAC,WAAW,EAAE,CAAQ,CAAC,CAAC,CAAC,IAAI;oBAChF,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CACvD;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,CAAC,CAAC,CAAC,IAAI,CACD,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 {List} from './List.js'\nimport {BugError, cleanSingleStackTracePath, ExternalError, FatalError as Fatal} from '../../../../public/node/error.js'\nimport {Box, Text} from 'ink'\nimport React, {FunctionComponent} from 'react'\nimport StackTracey from 'stacktracey'\n\nexport interface FatalErrorProps {\n error: Fatal\n}\n\nconst FatalError: FunctionComponent<FatalErrorProps> = ({error}) => {\n let stack\n let tool\n\n if (error instanceof BugError) {\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 ) : null}\n\n <Box>\n {error.formattedMessage ? <TokenizedText item={error.formattedMessage} /> : <Text>{error.message}</Text>}\n </Box>\n\n {error.tryMessage ? (\n <Box marginTop={1}>\n <TokenizedText item={error.tryMessage} />\n </Box>\n ) : null}\n\n {error.nextSteps && error.nextSteps.length > 0 ? (\n <Box marginTop={1}>\n <List title=\"Next steps\" items={error.nextSteps} />\n </Box>\n ) : null}\n\n {error.customSections && error.customSections.length > 0 ? (\n <Box flexDirection=\"column\">\n {error.customSections.map((section, index) => (\n <Box key={index} flexDirection=\"column\" marginTop={1}>\n {section.title ? <Text bold>{section.title}</Text> : null}\n <TokenizedText item={section.body} />\n </Box>\n ))}\n </Box>\n ) : null}\n\n {stack && stack.items.length !== 0 ? (\n <Box marginTop={1} flexDirection=\"column\">\n <Text>To investigate the issue, examine this stack trace:</Text>\n {stack.items.map((item, index) => (\n <Box flexDirection=\"column\" key={index} paddingLeft={2}>\n <Text>\n at{item.calleeShort ? <Text color=\"yellow\">{` ${item.calleeShort}`}</Text> : null}\n {item.fileShort ? ` (${item.fileShort}:${item.line})` : null}\n </Text>\n <Box paddingLeft={2}>\n <Text dimColor>{item.sourceLine?.trim()}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n ) : null}\n </Banner>\n )\n}\n\nexport {FatalError}\n"]}
|
|
@@ -19,6 +19,30 @@ describe('FatalError', async () => {
|
|
|
19
19
|
"
|
|
20
20
|
`);
|
|
21
21
|
});
|
|
22
|
+
test('renders correctly with a formatted message', async () => {
|
|
23
|
+
const error = new AbortError([
|
|
24
|
+
'There has been an error creating your deployment:',
|
|
25
|
+
{
|
|
26
|
+
list: {
|
|
27
|
+
items: [
|
|
28
|
+
'amortizable-marketplace-ext: Missing expected key(s).',
|
|
29
|
+
"sub-ui-ext: You don't have access to this feature.",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
]);
|
|
34
|
+
const { lastFrame } = render(React.createElement(FatalError, { error: error }));
|
|
35
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
36
|
+
"╭─ error ──────────────────────────────────────────────────────────────────────╮
|
|
37
|
+
│ │
|
|
38
|
+
│ There has been an error creating your deployment: │
|
|
39
|
+
│ • amortizable-marketplace-ext: Missing expected key(s). │
|
|
40
|
+
│ • sub-ui-ext: You don't have access to this feature. │
|
|
41
|
+
│ │
|
|
42
|
+
╰──────────────────────────────────────────────────────────────────────────────╯
|
|
43
|
+
"
|
|
44
|
+
`);
|
|
45
|
+
});
|
|
22
46
|
test('renders correctly with a message and a stack', async () => {
|
|
23
47
|
const error = new BugError('Unexpected error');
|
|
24
48
|
error.stack = `
|
|
@@ -97,6 +121,95 @@ describe('FatalError', async () => {
|
|
|
97
121
|
"
|
|
98
122
|
`);
|
|
99
123
|
});
|
|
124
|
+
test('renders correctly with a message, a stack, next steps, and custom sections', async () => {
|
|
125
|
+
const error = new BugError('Unexpected error');
|
|
126
|
+
error.stack = `
|
|
127
|
+
Error: Unexpected error
|
|
128
|
+
at Module._compile (internal/modules/cjs/loader.js:1137:30)
|
|
129
|
+
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
|
|
130
|
+
at Module.load (internal/modules/cjs/loader.js:985:32)
|
|
131
|
+
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
|
|
132
|
+
`;
|
|
133
|
+
error.nextSteps = [
|
|
134
|
+
[
|
|
135
|
+
'Have you',
|
|
136
|
+
{
|
|
137
|
+
link: {
|
|
138
|
+
label: 'created a Shopify Partners organization',
|
|
139
|
+
url: 'https://partners.shopify.com/signup',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
char: '?',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
'Have you confirmed your accounts from the emails you received?',
|
|
147
|
+
[
|
|
148
|
+
'Need to connect to a different App or organization? Run the command again with',
|
|
149
|
+
{
|
|
150
|
+
command: '--reset',
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
];
|
|
154
|
+
error.customSections = [
|
|
155
|
+
{
|
|
156
|
+
title: 'amortizable-marketplace-ext',
|
|
157
|
+
body: [
|
|
158
|
+
{
|
|
159
|
+
list: {
|
|
160
|
+
items: ['Some other error'],
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
list: {
|
|
165
|
+
title: 'Validation errors',
|
|
166
|
+
items: ['Missing expected key(s).'],
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
title: 'amortizable-marketplace-ext-2',
|
|
173
|
+
body: [
|
|
174
|
+
{
|
|
175
|
+
list: {
|
|
176
|
+
items: ['Something was not found'],
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
},
|
|
181
|
+
];
|
|
182
|
+
const { lastFrame } = render(React.createElement(FatalError, { error: error }));
|
|
183
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
184
|
+
"╭─ error ──────────────────────────────────────────────────────────────────────╮
|
|
185
|
+
│ │
|
|
186
|
+
│ Unexpected error │
|
|
187
|
+
│ │
|
|
188
|
+
│ Next steps │
|
|
189
|
+
│ • Have you created a Shopify Partners organization [1]? │
|
|
190
|
+
│ • Have you confirmed your accounts from the emails you received? │
|
|
191
|
+
│ • Need to connect to a different App or organization? Run the command │
|
|
192
|
+
│ again with \`--reset\` │
|
|
193
|
+
│ │
|
|
194
|
+
│ amortizable-marketplace-ext │
|
|
195
|
+
│ • Some other error │
|
|
196
|
+
│ Validation errors │
|
|
197
|
+
│ • Missing expected key(s). │
|
|
198
|
+
│ │
|
|
199
|
+
│ amortizable-marketplace-ext-2 │
|
|
200
|
+
│ • Something was not found │
|
|
201
|
+
│ │
|
|
202
|
+
│ To investigate the issue, examine this stack trace: │
|
|
203
|
+
│ at _compile (internal/modules/cjs/loader.js:1137) │
|
|
204
|
+
│ at js (internal/modules/cjs/loader.js:1157) │
|
|
205
|
+
│ at load (internal/modules/cjs/loader.js:985) │
|
|
206
|
+
│ at _load (internal/modules/cjs/loader.js:878) │
|
|
207
|
+
│ │
|
|
208
|
+
╰──────────────────────────────────────────────────────────────────────────────╯
|
|
209
|
+
[1] https://partners.shopify.com/signup
|
|
210
|
+
"
|
|
211
|
+
`);
|
|
212
|
+
});
|
|
100
213
|
test('renders correctly an external error', async () => {
|
|
101
214
|
const error = new ExternalError('Unexpected error', 'yarn', ['install']);
|
|
102
215
|
const { lastFrame } = render(React.createElement(FatalError, { error: error }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FatalError.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/FatalError.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAA;AAC1D,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,kCAAkC,CAAA;AACpF,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,QAAQ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AM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC,CAAA;QAExD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;KAoBpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;QAExE,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC,CAAA;QAExD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;KASpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {FatalError} from './FatalError.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport {AbortError, BugError, ExternalError} from '../../../../public/node/error.js'\nimport {render} from '../../testing/ui.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\n\ndescribe('FatalError', async () => {\n test('renders correctly with a just a message and tryMessage', async () => {\n const error = new AbortError('test', 'try this')\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ test │\n │ │\n │ try this │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('renders correctly with a message and a stack', async () => {\n const error = new BugError('Unexpected error')\n error.stack = `\n Error: Unexpected error\n at Module._compile (internal/modules/cjs/loader.js:1137:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)\n at Module.load (internal/modules/cjs/loader.js:985:32)\n at Function.Module._load (internal/modules/cjs/loader.js:878:14)\n `\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ Unexpected error │\n │ │\n │ To investigate the issue, examine this stack trace: │\n │ at _compile (internal/modules/cjs/loader.js:1137) │\n │ at js (internal/modules/cjs/loader.js:1157) │\n │ at load (internal/modules/cjs/loader.js:985) │\n │ at _load (internal/modules/cjs/loader.js:878) │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('renders correctly with a message, a stack, and next steps', async () => {\n const error = new BugError('Unexpected error')\n error.stack = `\n Error: Unexpected error\n at Module._compile (internal/modules/cjs/loader.js:1137:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)\n at Module.load (internal/modules/cjs/loader.js:985:32)\n at Function.Module._load (internal/modules/cjs/loader.js:878:14)\n `\n\n error.nextSteps = [\n [\n 'Have you',\n {\n link: {\n label: 'created a Shopify Partners organization',\n url: 'https://partners.shopify.com/signup',\n },\n },\n {\n char: '?',\n },\n ],\n 'Have you confirmed your accounts from the emails you received?',\n [\n 'Need to connect to a different App or organization? Run the command again with',\n {\n command: '--reset',\n },\n ],\n ]\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ Unexpected error │\n │ │\n │ Next steps │\n │ • Have you created a Shopify Partners organization [1]? │\n │ • Have you confirmed your accounts from the emails you received? │\n │ • Need to connect to a different App or organization? Run the command │\n │ again with \\`--reset\\` │\n │ │\n │ To investigate the issue, examine this stack trace: │\n │ at _compile (internal/modules/cjs/loader.js:1137) │\n │ at js (internal/modules/cjs/loader.js:1157) │\n │ at load (internal/modules/cjs/loader.js:985) │\n │ at _load (internal/modules/cjs/loader.js:878) │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n [1] https://partners.shopify.com/signup\n \"\n `)\n })\n\n test('renders correctly an external error', async () => {\n const error = new ExternalError('Unexpected error', 'yarn', ['install'])\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"── external error ──────────────────────────────────────────────────────────────\n\n Error coming from \\`yarn install\\`\n\n Unexpected error\n\n ────────────────────────────────────────────────────────────────────────────────\n \"\n `)\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"FatalError.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/FatalError.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAA;AAC1D,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,kCAAkC,CAAA;AACpF,OAAO,EAAC,MAAM,EAAC,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,QAAQ,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;IAChC,IAAI,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACxE,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;QAChD,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC,CAAA;QAExD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;KASpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC5D,MAAM,KAAK,GAAG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C,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;QAExE,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC,CAAA;QAExD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;KASpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {FatalError} from './FatalError.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport {AbortError, BugError, ExternalError} from '../../../../public/node/error.js'\nimport {render} from '../../testing/ui.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\n\ndescribe('FatalError', async () => {\n test('renders correctly with a just a message and tryMessage', async () => {\n const error = new AbortError('test', 'try this')\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ test │\n │ │\n │ try this │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('renders correctly with a formatted message', async () => {\n const error = new AbortError([\n 'There has been an error creating your deployment:',\n {\n list: {\n items: [\n 'amortizable-marketplace-ext: Missing expected key(s).',\n \"sub-ui-ext: You don't have access to this feature.\",\n ],\n },\n },\n ])\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ There has been an error creating your deployment: │\n │ • amortizable-marketplace-ext: Missing expected key(s). │\n │ • sub-ui-ext: You don't have access to this feature. │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('renders correctly with a message and a stack', async () => {\n const error = new BugError('Unexpected error')\n error.stack = `\n Error: Unexpected error\n at Module._compile (internal/modules/cjs/loader.js:1137:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)\n at Module.load (internal/modules/cjs/loader.js:985:32)\n at Function.Module._load (internal/modules/cjs/loader.js:878:14)\n `\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ Unexpected error │\n │ │\n │ To investigate the issue, examine this stack trace: │\n │ at _compile (internal/modules/cjs/loader.js:1137) │\n │ at js (internal/modules/cjs/loader.js:1157) │\n │ at load (internal/modules/cjs/loader.js:985) │\n │ at _load (internal/modules/cjs/loader.js:878) │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n \"\n `)\n })\n\n test('renders correctly with a message, a stack, and next steps', async () => {\n const error = new BugError('Unexpected error')\n error.stack = `\n Error: Unexpected error\n at Module._compile (internal/modules/cjs/loader.js:1137:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)\n at Module.load (internal/modules/cjs/loader.js:985:32)\n at Function.Module._load (internal/modules/cjs/loader.js:878:14)\n `\n\n error.nextSteps = [\n [\n 'Have you',\n {\n link: {\n label: 'created a Shopify Partners organization',\n url: 'https://partners.shopify.com/signup',\n },\n },\n {\n char: '?',\n },\n ],\n 'Have you confirmed your accounts from the emails you received?',\n [\n 'Need to connect to a different App or organization? Run the command again with',\n {\n command: '--reset',\n },\n ],\n ]\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ Unexpected error │\n │ │\n │ Next steps │\n │ • Have you created a Shopify Partners organization [1]? │\n │ • Have you confirmed your accounts from the emails you received? │\n │ • Need to connect to a different App or organization? Run the command │\n │ again with \\`--reset\\` │\n │ │\n │ To investigate the issue, examine this stack trace: │\n │ at _compile (internal/modules/cjs/loader.js:1137) │\n │ at js (internal/modules/cjs/loader.js:1157) │\n │ at load (internal/modules/cjs/loader.js:985) │\n │ at _load (internal/modules/cjs/loader.js:878) │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n [1] https://partners.shopify.com/signup\n \"\n `)\n })\n\n test('renders correctly with a message, a stack, next steps, and custom sections', async () => {\n const error = new BugError('Unexpected error')\n error.stack = `\n Error: Unexpected error\n at Module._compile (internal/modules/cjs/loader.js:1137:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)\n at Module.load (internal/modules/cjs/loader.js:985:32)\n at Function.Module._load (internal/modules/cjs/loader.js:878:14)\n `\n\n error.nextSteps = [\n [\n 'Have you',\n {\n link: {\n label: 'created a Shopify Partners organization',\n url: 'https://partners.shopify.com/signup',\n },\n },\n {\n char: '?',\n },\n ],\n 'Have you confirmed your accounts from the emails you received?',\n [\n 'Need to connect to a different App or organization? Run the command again with',\n {\n command: '--reset',\n },\n ],\n ]\n\n error.customSections = [\n {\n title: 'amortizable-marketplace-ext',\n body: [\n {\n list: {\n items: ['Some other error'],\n },\n },\n {\n list: {\n title: 'Validation errors',\n items: ['Missing expected key(s).'],\n },\n },\n ],\n },\n {\n title: 'amortizable-marketplace-ext-2',\n body: [\n {\n list: {\n items: ['Something was not found'],\n },\n },\n ],\n },\n ]\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"╭─ error ──────────────────────────────────────────────────────────────────────╮\n │ │\n │ Unexpected error │\n │ │\n │ Next steps │\n │ • Have you created a Shopify Partners organization [1]? │\n │ • Have you confirmed your accounts from the emails you received? │\n │ • Need to connect to a different App or organization? Run the command │\n │ again with \\`--reset\\` │\n │ │\n │ amortizable-marketplace-ext │\n │ • Some other error │\n │ Validation errors │\n │ • Missing expected key(s). │\n │ │\n │ amortizable-marketplace-ext-2 │\n │ • Something was not found │\n │ │\n │ To investigate the issue, examine this stack trace: │\n │ at _compile (internal/modules/cjs/loader.js:1137) │\n │ at js (internal/modules/cjs/loader.js:1157) │\n │ at load (internal/modules/cjs/loader.js:985) │\n │ at _load (internal/modules/cjs/loader.js:878) │\n │ │\n ╰──────────────────────────────────────────────────────────────────────────────╯\n [1] https://partners.shopify.com/signup\n \"\n `)\n })\n\n test('renders correctly an external error', async () => {\n const error = new ExternalError('Unexpected error', 'yarn', ['install'])\n\n const {lastFrame} = render(<FatalError error={error} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"── external error ──────────────────────────────────────────────────────────────\n\n Error coming from \\`yarn install\\`\n\n Unexpected error\n\n ────────────────────────────────────────────────────────────────────────────────\n \"\n `)\n })\n})\n"]}
|
|
@@ -2,7 +2,7 @@ import { InlineToken, TokenItem } from './TokenizedText.js';
|
|
|
2
2
|
import { TextProps } from 'ink';
|
|
3
3
|
import { FunctionComponent } from 'react';
|
|
4
4
|
interface ListProps {
|
|
5
|
-
title?:
|
|
5
|
+
title?: TokenItem<InlineToken>;
|
|
6
6
|
items: TokenItem<InlineToken>[];
|
|
7
7
|
ordered?: boolean;
|
|
8
8
|
margin?: boolean;
|
|
@@ -8,7 +8,8 @@ const DOT = '•';
|
|
|
8
8
|
*/
|
|
9
9
|
const List = ({ title, items, margin = true, ordered = false, color }) => {
|
|
10
10
|
return (React.createElement(Box, { flexDirection: "column" },
|
|
11
|
-
title ? (React.createElement(Text, {
|
|
11
|
+
title ? (React.createElement(Text, { color: color },
|
|
12
|
+
React.createElement(TokenizedText, { item: title }))) : null,
|
|
12
13
|
items.map((item, index) => (React.createElement(Box, { key: index },
|
|
13
14
|
React.createElement(Box, null,
|
|
14
15
|
margin ? React.createElement(Text, null, ' ') : null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/List.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAC,MAAM,oBAAoB,CAAA;AACxE,OAAO,EAAC,GAAG,EAAE,IAAI,EAAY,MAAM,KAAK,CAAA;AACxC,OAAO,KAA0B,MAAM,OAAO,CAAA;AAU9C,MAAM,GAAG,GAAG,GAAG,CAAA;AAEf;;;GAGG;AACH,MAAM,IAAI,GAAiC,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,GAAG,KAAK,EAAE,KAAK,EAAC,EAAe,EAAE;IAChH,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ;QACxB,KAAK,CAAC,CAAC,CAAC,CACP,oBAAC,IAAI,IAAC,
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/List.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAC,MAAM,oBAAoB,CAAA;AACxE,OAAO,EAAC,GAAG,EAAE,IAAI,EAAY,MAAM,KAAK,CAAA;AACxC,OAAO,KAA0B,MAAM,OAAO,CAAA;AAU9C,MAAM,GAAG,GAAG,GAAG,CAAA;AAEf;;;GAGG;AACH,MAAM,IAAI,GAAiC,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,GAAG,KAAK,EAAE,KAAK,EAAC,EAAe,EAAE;IAChH,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ;QACxB,KAAK,CAAC,CAAC,CAAC,CACP,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK;YAChB,oBAAC,aAAa,IAAC,IAAI,EAAE,KAAK,GAAI,CACzB,CACR,CAAC,CAAC,CAAC,IAAI;QACP,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1B,oBAAC,GAAG,IAAC,GAAG,EAAE,KAAK;YACb,oBAAC,GAAG;gBACD,MAAM,CAAC,CAAC,CAAC,oBAAC,IAAI,QAAE,IAAI,CAAQ,CAAC,CAAC,CAAC,IAAI;gBACpC,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,IAAG,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAQ,CAC7D;YAEN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;gBAC7B,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK;oBAChB,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CACxB,CACH,CACF,CACP,CAAC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,IAAI,EAAC,CAAA","sourcesContent":["import {InlineToken, TokenItem, TokenizedText} from './TokenizedText.js'\nimport {Box, Text, TextProps} from 'ink'\nimport React, {FunctionComponent} from 'react'\n\ninterface ListProps {\n title?: TokenItem<InlineToken>\n items: TokenItem<InlineToken>[]\n ordered?: boolean\n margin?: boolean\n color?: TextProps['color']\n}\n\nconst DOT = '•'\n\n/**\n * `List` displays an unordered or ordered list with text aligned with the bullet point\n * and wrapped to the container width.\n */\nconst List: FunctionComponent<ListProps> = ({title, items, margin = true, ordered = false, color}): JSX.Element => {\n return (\n <Box flexDirection=\"column\">\n {title ? (\n <Text color={color}>\n <TokenizedText item={title} />\n </Text>\n ) : null}\n {items.map((item, index) => (\n <Box key={index}>\n <Box>\n {margin ? <Text>{' '}</Text> : null}\n <Text color={color}>{`${ordered ? `${index + 1}.` : DOT}`}</Text>\n </Box>\n\n <Box flexGrow={1} marginLeft={1}>\n <Text color={color}>\n <TokenizedText item={item} />\n </Text>\n </Box>\n </Box>\n ))}\n </Box>\n )\n}\n\nexport {List}\n"]}
|