@shopify/cli-kit 3.46.0-pre.2 → 3.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/cli-ruby/lib/graphql/get_variant_id.graphql +1 -1
- 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/theme/dev_server/local_assets.rb +6 -6
- 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/context/utilities.d.ts +14 -0
- package/dist/private/node/context/utilities.js +47 -0
- package/dist/private/node/context/utilities.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 +3 -0
- package/dist/private/node/ui/components/TextPrompt.js +7 -3
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.test.js +33 -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 +5 -1
- package/dist/public/node/context/local.js +8 -4
- 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/mimes.d.ts +15 -0
- package/dist/public/node/mimes.js +22 -0
- package/dist/public/node/mimes.js.map +1 -0
- 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 +8 -3
- package/dist/public/node/system.js +16 -7
- 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 +18 -9
- package/dist/public/node/ui.js +83 -19
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -13
- 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.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,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAA;AAGjD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QAC3E,QAAQ;QACR,IAAI,qBAAiC,CAAA;QAErC,MAAM,cAAc,GAAG,IAAI,OAAO,CAAO,UAAU,OAAO,EAAE,OAAO;YACjE,qBAAqB,GAAG,OAAO,CAAA;QACjC,CAAC,CAAC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AAO,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,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAA;AAGjD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QAC3E,QAAQ;QACR,IAAI,qBAAiC,CAAA;QACrC,IAAI,sBAAkC,CAAA;QAEtC,MAAM,cAAc,GAAG,IAAI,OAAO,CAAO,UAAU,OAAO,EAAE,OAAO;YACjE,qBAAqB,GAAG,OAAO,CAAA;QACjC,CAAC,CAAC,CAAA;QAEF,MAAM,eAAe,GAAG,IAAI,OAAO,CAAO,UAAU,OAAO,EAAE,OAAO;YAClE,sBAAsB,GAAG,OAAO,CAAA;QAClC,CAAC,CAAC,CAAA;QAEF,MAAM,cAAc,GAAG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AA","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 },
|
|
@@ -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,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,QAAQ,EAAE,yBAAyB,EAAE,aAAa,EAAsB,MAAM,kCAAkC,CAAA;AACxH,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAA0B,MAAM,OAAO,CAAA;AAC9C,OAAO,WAAW,MAAM,aAAa,CAAA;AAMrC,MAAM,UAAU,GAA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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,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,8CAA8C,EAAE,KAAK,IAAI,EAAE;QAC9D,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,kBAAkB,CAAC,CAAA;QAC9C,KAAK,CAAC,KAAK,GAAG;;;;;;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C,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,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{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
|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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"]}
|
|
@@ -30,5 +30,24 @@ describe('List', async () => {
|
|
|
30
30
|
3. Item 3"
|
|
31
31
|
`);
|
|
32
32
|
});
|
|
33
|
+
test('title can be made of tokens', async () => {
|
|
34
|
+
const options = {
|
|
35
|
+
title: [
|
|
36
|
+
'List title',
|
|
37
|
+
{
|
|
38
|
+
bold: ' (bold)',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
items: ['Item 1', 'Item 2', 'Item 3'],
|
|
42
|
+
ordered: false,
|
|
43
|
+
};
|
|
44
|
+
const { lastFrame } = render(React.createElement(List, { ...options }));
|
|
45
|
+
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
46
|
+
"List title [1m (bold)[22m
|
|
47
|
+
• Item 1
|
|
48
|
+
• Item 2
|
|
49
|
+
• Item 3"
|
|
50
|
+
`);
|
|
51
|
+
});
|
|
33
52
|
});
|
|
34
53
|
//# sourceMappingURL=List.test.js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ACJ,CAAC,CAAC,CAAA","sourcesContent":["import {List} from './List.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport {render} from '../../testing/ui.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\n\ndescribe('List', async () => {\n test('renders unordered items', async () => {\n const options = {\n title: 'List title',\n items: ['Item 1', 'Item 2', 'Item 3'],\n ordered: false,\n }\n\n const {lastFrame} = render(<List {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"List title\n • Item 1\n • Item 2\n • Item 3\"\n `)\n })\n\n test('renders ordered items', async () => {\n const options = {\n items: ['Item 1', 'Item 2', 'Item 3'],\n ordered: true,\n }\n\n const {lastFrame} = render(<List {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \" 1. Item 1\n 2. Item 2\n 3. Item 3\"\n `)\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"List.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/List.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAA;AAC1D,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,MAAM,EAAE,KAAK,IAAI,EAAE;IAC1B,IAAI,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,OAAO,GAAG;YACd,KAAK,EAAE,YAAY;YACnB,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;YACrC,OAAO,EAAE,KAAK;SACf,CAAA;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,IAAI,OAAK,OAAO,GAAI,CAAC,CAAA;QAEjD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,OAAO,GAAG;YACd,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;YACrC,OAAO,EAAE,IAAI;SACd,CAAA;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,IAAI,OAAK,OAAO,GAAI,CAAC,CAAA;QAEjD,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;KAIpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,OAAO,GAAG;YACd,KAAK,EAAE;gBACL,YAAY;gBACZ;oBACE,IAAI,EAAE,SAAS;iBAChB;aACF;YACD,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;YACrC,OAAO,EAAE,KAAK;SACf,CAAA;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,IAAI,OAAK,OAAO,GAAI,CAAC,CAAA;QAEjD,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKzC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {List} from './List.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport {render} from '../../testing/ui.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\n\ndescribe('List', async () => {\n test('renders unordered items', async () => {\n const options = {\n title: 'List title',\n items: ['Item 1', 'Item 2', 'Item 3'],\n ordered: false,\n }\n\n const {lastFrame} = render(<List {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"List title\n • Item 1\n • Item 2\n • Item 3\"\n `)\n })\n\n test('renders ordered items', async () => {\n const options = {\n items: ['Item 1', 'Item 2', 'Item 3'],\n ordered: true,\n }\n\n const {lastFrame} = render(<List {...options} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \" 1. Item 1\n 2. Item 2\n 3. Item 3\"\n `)\n })\n\n test('title can be made of tokens', async () => {\n const options = {\n title: [\n 'List title',\n {\n bold: ' (bold)',\n },\n ],\n items: ['Item 1', 'Item 2', 'Item 3'],\n ordered: false,\n }\n\n const {lastFrame} = render(<List {...options} />)\n\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"List title \u001b[1m (bold)\u001b[22m\n • Item 1\n • Item 2\n • Item 3\"\n `)\n })\n})\n"]}
|
|
@@ -6,7 +6,11 @@ const InfoTable = ({ table }) => {
|
|
|
6
6
|
const sections = Array.isArray(table)
|
|
7
7
|
? table
|
|
8
8
|
: Object.keys(table).map((header) => ({ header, items: table[header], color: undefined, helperText: undefined }));
|
|
9
|
-
const headerColumnWidth = Math.max(...sections.map((section) =>
|
|
9
|
+
const headerColumnWidth = Math.max(...sections.map((section) => {
|
|
10
|
+
return Math.max(...section.header.split('\n').map((line) => {
|
|
11
|
+
return line.length;
|
|
12
|
+
}));
|
|
13
|
+
}));
|
|
10
14
|
return (React.createElement(Box, { flexDirection: "column" }, sections.map((section, index) => (React.createElement(Box, { key: index, marginBottom: index === sections.length - 1 ? 0 : 1 },
|
|
11
15
|
section.header.length > 0 && (React.createElement(Box, { width: headerColumnWidth + 1 },
|
|
12
16
|
React.createElement(Text, { color: section.color },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoTable.js","sourceRoot":"","sources":["../../../../../../src/private/node/ui/components/Prompts/InfoTable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAA;AAC/B,OAAO,EAAC,UAAU,EAA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AC,KAAK,IAAG,OAAO,CAAC,UAAU,CAAQ,CACnD,CACP,CAAC,CAAC,CAAC,IAAI,CACJ,CACF,CACP,CAAC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,SAAS,EAAC,CAAA","sourcesContent":["import {List} from '../List.js'\nimport {capitalize} from '../../../../../public/common/string.js'\nimport {InlineToken, TokenItem} from '../TokenizedText.js'\nimport {Box, Text, TextProps} from 'ink'\nimport React, {FunctionComponent} from 'react'\n\ntype Items = TokenItem<InlineToken>[]\n\nexport interface InfoTableSection {\n color?: TextProps['color']\n header: string\n helperText?: string\n items: Items\n}\n\nexport interface InfoTableProps {\n table:\n | {\n [header: string]: Items\n }\n | InfoTableSection[]\n}\n\nconst InfoTable: FunctionComponent<InfoTableProps> = ({table}) => {\n const sections = Array.isArray(table)\n ? table\n : Object.keys(table).map((header) => ({header, items: table[header]!, color: undefined, helperText: undefined}))\n\n const headerColumnWidth = Math.max(\n ...sections.map((section) => {\n return Math.max(\n ...section.header.split('\\n').map((line) => {\n return line.length\n }),\n )\n }),\n )\n\n return (\n <Box flexDirection=\"column\">\n {sections.map((section, index) => (\n <Box key={index} marginBottom={index === sections.length - 1 ? 0 : 1}>\n {section.header.length > 0 && (\n <Box width={headerColumnWidth + 1}>\n <Text color={section.color}>{capitalize(section.header)}:</Text>\n </Box>\n )}\n <Box marginLeft={section.header.length > 0 ? 2 : 0} flexGrow={1} flexDirection=\"column\">\n <List margin={false} items={section.items} color={section.color} />\n {section.helperText ? (\n <Box marginTop={1}>\n <Text color={section.color}>{section.helperText}</Text>\n </Box>\n ) : null}\n </Box>\n </Box>\n ))}\n </Box>\n )\n}\n\nexport {InfoTable}\n"]}
|
|
@@ -7,13 +7,14 @@ describe('InfoTable', async () => {
|
|
|
7
7
|
test('renders a horizontal table with bullet points', async () => {
|
|
8
8
|
const { lastFrame } = render(React.createElement(InfoTable, { table: {
|
|
9
9
|
'header 1': ['some', 'items'],
|
|
10
|
-
'header 2': [['one item', { link: { label: 'Shopify', url: 'https://shopify.com' } }]],
|
|
10
|
+
'header 2\nlonger text here': [['one item', { link: { label: 'Shopify', url: 'https://shopify.com' } }]],
|
|
11
11
|
} }));
|
|
12
12
|
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
13
|
-
"Header 1:
|
|
14
|
-
|
|
13
|
+
"Header 1: • some
|
|
14
|
+
• items
|
|
15
15
|
|
|
16
|
-
Header 2
|
|
16
|
+
Header 2 • one item Shopify ( https://shopify.com )
|
|
17
|
+
longer text here:"
|
|
17
18
|
`);
|
|
18
19
|
});
|
|
19
20
|
test('supports an empty header value', async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoTable.test.js","sourceRoot":"","sources":["../../../../../../src/private/node/ui/components/Prompts/InfoTable.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,sCAAsC,CAAA;AAC7D,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,QAAQ,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE;IAC/B,IAAI,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CACxB,oBAAC,SAAS,IACR,KAAK,EAAE;gBACL,UAAU,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;gBAC7B,
|
|
1
|
+
{"version":3,"file":"InfoTable.test.js","sourceRoot":"","sources":["../../../../../../src/private/node/ui/components/Prompts/InfoTable.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,sCAAsC,CAAA;AAC7D,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,QAAQ,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE;IAC/B,IAAI,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QAC/D,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CACxB,oBAAC,SAAS,IACR,KAAK,EAAE;gBACL,UAAU,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;gBAC7B,4BAA4B,EAAE,CAAC,CAAC,UAAU,EAAE,EAAC,IAAI,EAAE,EAAC,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,qBAAqB,EAAC,EAAC,CAAC,CAAC;aACrG,GACD,CACH,CAAA;QAED,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;KAMpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CACxB,oBAAC,SAAS,IACR,KAAK,EAAE;gBACL,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;aACtB,GACD,CACH,CAAA;QAED,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;KAGpD,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {InfoTable} from './InfoTable.js'\nimport {unstyled} from '../../../../../public/node/output.js'\nimport {render} from '../../../testing/ui.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\n\ndescribe('InfoTable', async () => {\n test('renders a horizontal table with bullet points', async () => {\n const {lastFrame} = render(\n <InfoTable\n table={{\n 'header 1': ['some', 'items'],\n 'header 2\\nlonger text here': [['one item', {link: {label: 'Shopify', url: 'https://shopify.com'}}]],\n }}\n />,\n )\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"Header 1: • some\n • items\n\n Header 2 • one item Shopify ( https://shopify.com )\n longer text here:\"\n `)\n })\n\n test('supports an empty header value', async () => {\n const {lastFrame} = render(\n <InfoTable\n table={{\n '': ['some', 'items'],\n }}\n />,\n )\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"• some\n • items\"\n `)\n })\n})\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SelectInputProps } from './SelectInput.js';
|
|
2
2
|
import { InfoTableProps } from './Prompts/InfoTable.js';
|
|
3
3
|
import { InlineToken, LinkToken, TokenItem } from './TokenizedText.js';
|
|
4
|
+
import { AbortSignal } from '../../../../public/node/abort.js';
|
|
4
5
|
import React, { ReactElement } from 'react';
|
|
5
6
|
export interface SelectPromptProps<T> {
|
|
6
7
|
message: TokenItem<Exclude<InlineToken, LinkToken>>;
|
|
@@ -9,6 +10,7 @@ export interface SelectPromptProps<T> {
|
|
|
9
10
|
infoTable?: InfoTableProps['table'];
|
|
10
11
|
defaultValue?: T;
|
|
11
12
|
submitWithShortcuts?: boolean;
|
|
13
|
+
abortSignal?: AbortSignal;
|
|
12
14
|
}
|
|
13
|
-
declare function SelectPrompt<T>({ message, choices, infoTable, onSubmit, defaultValue, submitWithShortcuts, }: React.PropsWithChildren<SelectPromptProps<T>>): ReactElement | null;
|
|
15
|
+
declare function SelectPrompt<T>({ message, choices, infoTable, onSubmit, defaultValue, submitWithShortcuts, abortSignal, }: React.PropsWithChildren<SelectPromptProps<T>>): ReactElement | null;
|
|
14
16
|
export { SelectPrompt };
|
|
@@ -4,12 +4,13 @@ import { TokenizedText } from './TokenizedText.js';
|
|
|
4
4
|
import { handleCtrlC } from '../../ui.js';
|
|
5
5
|
import { messageWithPunctuation } from '../utilities.js';
|
|
6
6
|
import { uniqBy } from '../../../../public/common/array.js';
|
|
7
|
+
import useAbortSignal from '../hooks/use-abort-signal.js';
|
|
7
8
|
import React, { useCallback, useLayoutEffect, useState } from 'react';
|
|
8
9
|
import { Box, measureElement, Text, useApp, useInput, useStdout } from 'ink';
|
|
9
10
|
import figures from 'figures';
|
|
10
11
|
import ansiEscapes from 'ansi-escapes';
|
|
11
12
|
// eslint-disable-next-line react/function-component-definition
|
|
12
|
-
function SelectPrompt({ message, choices, infoTable, onSubmit, defaultValue, submitWithShortcuts = false, }) {
|
|
13
|
+
function SelectPrompt({ message, choices, infoTable, onSubmit, defaultValue, submitWithShortcuts = false, abortSignal, }) {
|
|
13
14
|
if (choices.length === 0) {
|
|
14
15
|
throw new Error('SelectPrompt requires at least one choice');
|
|
15
16
|
}
|
|
@@ -58,13 +59,14 @@ function SelectPrompt({ message, choices, infoTable, onSubmit, defaultValue, sub
|
|
|
58
59
|
unmountInk();
|
|
59
60
|
onSubmit(answer.value);
|
|
60
61
|
}, [stdout, wrapperHeight, unmountInk, onSubmit]);
|
|
62
|
+
const { isAborted } = useAbortSignal(abortSignal);
|
|
61
63
|
useInput((input, key) => {
|
|
62
64
|
handleCtrlC(input, key);
|
|
63
65
|
if (key.return && answer) {
|
|
64
66
|
submitAnswer(answer);
|
|
65
67
|
}
|
|
66
68
|
});
|
|
67
|
-
return (React.createElement(Box, { flexDirection: "column", marginBottom: 1, ref: wrapperRef },
|
|
69
|
+
return isAborted ? null : (React.createElement(Box, { flexDirection: "column", marginBottom: 1, ref: wrapperRef },
|
|
68
70
|
React.createElement(Box, null,
|
|
69
71
|
React.createElement(Box, { marginRight: 2 },
|
|
70
72
|
React.createElement(Text, null, "?")),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectPrompt.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/SelectPrompt.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAuC,MAAM,kBAAkB,CAAA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B,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,IAAE,OAAO,CAAC,IAAI,CAAQ,CACpC;YAEN,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,IAAE,MAAO,CAAC,KAAK,CAAQ,CACrC,CACP,CAAC,CAAC,CAAC,CACF,oBAAC,GAAG,IAAC,SAAS,EAAE,CAAC;YACf,oBAAC,WAAW,IACV,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,OAAO,EACd,WAAW,EACT,mBAAmB;oBACjB,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,SAAS,mDAAmD;oBACjG,CAAC,CAAC,SAAS,EAEf,QAAQ,EAAE,CAAC,EAAC,IAAI,EAAE,YAAY,EAAC,EAAE,EAAE;oBACjC,SAAS,CAAC,IAAI,CAAC,CAAA;oBAEf,IAAI,mBAAmB,IAAI,YAAY,IAAI,IAAI,EAAE;wBAC/C,YAAY,CAAC,IAAI,CAAC,CAAA;qBACnB;gBACH,CAAC,EACD,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,QAAQ,GACb,CACE,CACP,CACG,CACP,CAAA;AACH,CAAC;AAED,OAAO,EAAC,YAAY,EAAC,CAAA","sourcesContent":["import {SelectInput, SelectInputProps, Item as SelectItem} from './SelectInput.js'\nimport {InfoTable, InfoTableProps} from './Prompts/InfoTable.js'\nimport {InlineToken, LinkToken, TokenItem, TokenizedText} from './TokenizedText.js'\nimport {handleCtrlC} from '../../ui.js'\nimport {messageWithPunctuation} from '../utilities.js'\nimport {uniqBy} from '../../../../public/common/array.js'\nimport {AbortSignal} from '../../../../public/node/abort.js'\nimport useAbortSignal from '../hooks/use-abort-signal.js'\nimport React, {ReactElement, useCallback, useLayoutEffect, useState} from 'react'\nimport {Box, measureElement, Text, useApp, useInput, useStdout} from 'ink'\nimport figures from 'figures'\nimport ansiEscapes from 'ansi-escapes'\n\nexport interface SelectPromptProps<T> {\n message: TokenItem<Exclude<InlineToken, LinkToken>>\n choices: SelectInputProps<T>['items']\n onSubmit: (value: T) => void\n infoTable?: InfoTableProps['table']\n defaultValue?: T\n submitWithShortcuts?: boolean\n abortSignal?: AbortSignal\n}\n\n// eslint-disable-next-line react/function-component-definition\nfunction SelectPrompt<T>({\n message,\n choices,\n infoTable,\n onSubmit,\n defaultValue,\n submitWithShortcuts = false,\n abortSignal,\n}: React.PropsWithChildren<SelectPromptProps<T>>): ReactElement | null {\n if (choices.length === 0) {\n throw new Error('SelectPrompt requires at least one choice')\n }\n const initialValue =\n typeof defaultValue === 'undefined' ? undefined : choices.find((choice) => choice.value === defaultValue)\n const [answer, setAnswer] = useState<SelectItem<T> | undefined>(undefined)\n const {exit: unmountInk} = useApp()\n const [submitted, setSubmitted] = useState(false)\n const {stdout} = useStdout()\n const [wrapperHeight, setWrapperHeight] = useState(0)\n const [selectInputHeight, setSelectInputHeight] = useState(0)\n const [limit, setLimit] = useState(choices.length)\n const numberOfGroups = uniqBy(\n choices.filter((choice) => choice.group),\n 'group',\n ).length\n\n const wrapperRef = useCallback((node) => {\n if (node !== null) {\n const {height} = measureElement(node)\n setWrapperHeight(height)\n }\n }, [])\n\n const inputRef = useCallback((node) => {\n if (node !== null) {\n const {height} = measureElement(node)\n setSelectInputHeight(height)\n }\n }, [])\n\n useLayoutEffect(() => {\n function onResize() {\n const availableSpace = stdout.rows - (wrapperHeight - selectInputHeight)\n // rough estimate of the limit needed based on the space available\n const newLimit = Math.max(2, availableSpace - numberOfGroups * 2 - 4)\n\n if (newLimit < limit) {\n stdout.write(ansiEscapes.clearTerminal)\n }\n\n setLimit(Math.min(newLimit, choices.length))\n }\n\n onResize()\n\n stdout.on('resize', onResize)\n return () => {\n stdout.off('resize', onResize)\n }\n }, [wrapperHeight, selectInputHeight, choices.length, numberOfGroups, stdout, limit])\n\n const submitAnswer = useCallback(\n (answer: SelectItem<T>) => {\n if (stdout && wrapperHeight >= stdout.rows) {\n stdout.write(ansiEscapes.clearTerminal)\n }\n setSubmitted(true)\n unmountInk()\n onSubmit(answer.value)\n },\n [stdout, wrapperHeight, unmountInk, onSubmit],\n )\n\n const {isAborted} = useAbortSignal(abortSignal)\n\n useInput((input, key) => {\n handleCtrlC(input, key)\n\n if (key.return && answer) {\n submitAnswer(answer)\n }\n })\n\n return isAborted ? null : (\n <Box flexDirection=\"column\" marginBottom={1} ref={wrapperRef}>\n <Box>\n <Box marginRight={2}>\n <Text>?</Text>\n </Box>\n <TokenizedText item={messageWithPunctuation(message)} />\n </Box>\n {infoTable && !submitted ? (\n <Box marginLeft={7} marginTop={1}>\n <InfoTable table={infoTable} />\n </Box>\n ) : null}\n {submitted ? (\n <Box>\n <Box marginRight={2}>\n <Text color=\"cyan\">{figures.tick}</Text>\n </Box>\n\n <Text color=\"cyan\">{answer!.label}</Text>\n </Box>\n ) : (\n <Box marginTop={1}>\n <SelectInput\n defaultValue={initialValue}\n items={choices}\n infoMessage={\n submitWithShortcuts\n ? `Press ${figures.arrowUp}${figures.arrowDown} arrows to select, enter or a shortcut to confirm`\n : undefined\n }\n onChange={({item, usedShortcut}) => {\n setAnswer(item)\n\n if (submitWithShortcuts && usedShortcut && item) {\n submitAnswer(item)\n }\n }}\n limit={limit}\n ref={inputRef}\n />\n </Box>\n )}\n </Box>\n )\n}\n\nexport {SelectPrompt}\n"]}
|
|
@@ -2,6 +2,7 @@ import { SelectPrompt } from './SelectPrompt.js';
|
|
|
2
2
|
import { getLastFrameAfterUnmount, sendInputAndWaitForChange, waitForInputsToBeReady, render } from '../../testing/ui.js';
|
|
3
3
|
import { unstyled } from '../../../../public/node/output.js';
|
|
4
4
|
import { Stdout } from '../../ui.js';
|
|
5
|
+
import { AbortController } from '../../../../public/node/abort.js';
|
|
5
6
|
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
6
7
|
import React from 'react';
|
|
7
8
|
import { useStdout } from 'ink';
|
|
@@ -251,5 +252,26 @@ describe('SelectPrompt', async () => {
|
|
|
251
252
|
"
|
|
252
253
|
`);
|
|
253
254
|
});
|
|
255
|
+
test('abortController can be used to exit the prompt from outside', async () => {
|
|
256
|
+
const items = [
|
|
257
|
+
{ label: 'a', value: 'a' },
|
|
258
|
+
{ label: 'b', value: 'b' },
|
|
259
|
+
];
|
|
260
|
+
const abortController = new AbortController();
|
|
261
|
+
const renderInstance = render(React.createElement(SelectPrompt, { choices: items, onSubmit: () => { }, message: "Test question?", abortSignal: abortController.signal }));
|
|
262
|
+
const promise = renderInstance.waitUntilExit();
|
|
263
|
+
expect(unstyled(renderInstance.lastFrame())).toMatchInlineSnapshot(`
|
|
264
|
+
"? Test question?
|
|
265
|
+
|
|
266
|
+
> (1) a
|
|
267
|
+
(2) b
|
|
268
|
+
|
|
269
|
+
Press ↑↓ arrows to select, enter to confirm
|
|
270
|
+
"
|
|
271
|
+
`);
|
|
272
|
+
abortController.abort();
|
|
273
|
+
expect(getLastFrameAfterUnmount(renderInstance)).toEqual('');
|
|
274
|
+
await expect(promise).resolves.toEqual(undefined);
|
|
275
|
+
});
|
|
254
276
|
});
|
|
255
277
|
//# sourceMappingURL=SelectPrompt.test.js.map
|