@shopify/cli-kit 3.47.5 → 3.48.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/messages/messages.rb +18 -1
- package/assets/cli-ruby/lib/shopify_cli/constants.rb +1 -0
- package/assets/cli-ruby/lib/shopify_cli/environment.rb +7 -0
- package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server.rb +8 -2
- package/dist/private/node/api/graphql.js +8 -1
- package/dist/private/node/api/graphql.js.map +1 -1
- package/dist/private/node/api/headers.js +1 -1
- package/dist/private/node/api/headers.js.map +1 -1
- package/dist/private/node/api/urls.d.ts +6 -0
- package/dist/private/node/api/urls.js +16 -0
- package/dist/private/node/api/urls.js.map +1 -0
- package/dist/private/node/api.js +2 -1
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/ui/alert.js +3 -1
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/Alert.d.ts +1 -1
- package/dist/private/node/ui/components/Alert.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.d.ts +7 -2
- package/dist/private/node/ui/components/AutocompletePrompt.js +28 -91
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +317 -257
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +1 -0
- package/dist/private/node/ui/components/ConcurrentOutput.js +59 -32
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +62 -22
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.d.ts +12 -0
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.js +77 -0
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.js.map +1 -0
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js +101 -0
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js.map +1 -0
- package/dist/private/node/ui/components/List.d.ts +1 -0
- package/dist/private/node/ui/components/List.js +2 -2
- package/dist/private/node/ui/components/List.js.map +1 -1
- package/dist/private/node/ui/components/{GitDiff.d.ts → Prompts/GitDiff.d.ts} +4 -2
- package/dist/private/node/ui/components/{GitDiff.js → Prompts/GitDiff.js} +3 -2
- package/dist/private/node/ui/components/Prompts/GitDiff.js.map +1 -0
- package/dist/private/node/ui/components/Prompts/GitDiff.test.d.ts +1 -0
- package/dist/private/node/ui/components/{GitDiff.test.js → Prompts/GitDiff.test.js} +50 -28
- package/dist/private/node/ui/components/Prompts/GitDiff.test.js.map +1 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.d.ts +14 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.js +11 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.js.map +1 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.test.d.ts +1 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.test.js +21 -0
- package/dist/private/node/ui/components/Prompts/InfoMessage.test.js.map +1 -0
- package/dist/private/node/ui/components/Prompts/InfoTable.d.ts +1 -0
- package/dist/private/node/ui/components/Prompts/InfoTable.js +11 -7
- package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.test.js +6 -4
- package/dist/private/node/ui/components/Prompts/InfoTable.test.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.d.ts +21 -0
- package/dist/private/node/ui/components/Prompts/PromptLayout.js +73 -0
- package/dist/private/node/ui/components/Prompts/PromptLayout.js.map +1 -0
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.d.ts +1 -0
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.js +129 -0
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.js.map +1 -0
- package/dist/private/node/ui/components/Scrollbar.d.ts +10 -0
- package/dist/private/node/ui/components/Scrollbar.js +44 -0
- package/dist/private/node/ui/components/Scrollbar.js.map +1 -0
- package/dist/private/node/ui/components/Scrollbar.test.d.ts +1 -0
- package/dist/private/node/ui/components/Scrollbar.test.js +96 -0
- package/dist/private/node/ui/components/Scrollbar.test.js.map +1 -0
- package/dist/private/node/ui/components/SelectInput.d.ts +3 -6
- package/dist/private/node/ui/components/SelectInput.js +57 -41
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.test.js +120 -192
- package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.d.ts +7 -6
- package/dist/private/node/ui/components/SelectPrompt.js +11 -68
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js +135 -65
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Table/Row.js +2 -1
- package/dist/private/node/ui/components/Table/Row.js.map +1 -1
- package/dist/private/node/ui/components/Table/Table.js +2 -1
- package/dist/private/node/ui/components/Table/Table.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.js +1 -8
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/TextInput.d.ts +1 -0
- package/dist/private/node/ui/components/TextInput.js +10 -4
- package/dist/private/node/ui/components/TextInput.js.map +1 -1
- package/dist/private/node/ui/components/TextInput.test.js +27 -18
- package/dist/private/node/ui/components/TextInput.test.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.d.ts +2 -3
- package/dist/private/node/ui/components/TextPrompt.js +18 -16
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.test.js +25 -11
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
- package/dist/private/node/ui/hooks/use-prompt.d.ts +18 -0
- package/dist/private/node/ui/hooks/use-prompt.js +20 -0
- package/dist/private/node/ui/hooks/use-prompt.js.map +1 -0
- package/dist/private/node/ui/hooks/use-select-state.d.ts +4 -4
- package/dist/private/node/ui/hooks/use-select-state.js +9 -9
- package/dist/private/node/ui/hooks/use-select-state.js.map +1 -1
- package/dist/public/common/object.d.ts +16 -0
- package/dist/public/common/object.js +26 -0
- package/dist/public/common/object.js.map +1 -1
- package/dist/public/common/string.d.ts +16 -0
- package/dist/public/common/string.js +30 -0
- package/dist/public/common/string.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/analytics.js +3 -1
- package/dist/public/node/analytics.js.map +1 -1
- package/dist/public/node/api/partners.js +11 -2
- package/dist/public/node/api/partners.js.map +1 -1
- package/dist/public/node/base-command.d.ts +1 -0
- package/dist/public/node/base-command.js +21 -1
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/figures.d.ts +2 -0
- package/dist/public/node/figures.js +3 -0
- package/dist/public/node/figures.js.map +1 -0
- package/dist/public/node/http.js +5 -2
- package/dist/public/node/http.js.map +1 -1
- package/dist/public/node/metadata.d.ts +2 -1
- package/dist/public/node/metadata.js +5 -2
- package/dist/public/node/metadata.js.map +1 -1
- package/dist/public/node/monorail.d.ts +22 -1
- package/dist/public/node/monorail.js +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/node-package-manager.d.ts +2 -0
- package/dist/public/node/node-package-manager.js +5 -2
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/output.d.ts +1 -1
- package/dist/public/node/output.js +1 -1
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/ruby.d.ts +1 -0
- package/dist/public/node/ruby.js +1 -0
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/system.js +2 -2
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/themes/models/theme.d.ts +2 -1
- package/dist/public/node/themes/models/theme.js +2 -1
- package/dist/public/node/themes/models/theme.js.map +1 -1
- package/dist/public/node/themes/theme-urls.d.ts +1 -0
- package/dist/public/node/themes/theme-urls.js +4 -0
- package/dist/public/node/themes/theme-urls.js.map +1 -1
- package/dist/public/node/themes/themes-api.d.ts +9 -1
- package/dist/public/node/themes/themes-api.js +14 -3
- package/dist/public/node/themes/themes-api.js.map +1 -1
- package/dist/public/node/toml.d.ts +3 -2
- package/dist/public/node/toml.js +5 -2
- package/dist/public/node/toml.js.map +1 -1
- package/dist/public/node/ui.d.ts +82 -27
- package/dist/public/node/ui.js +97 -32
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -14
- package/dist/private/node/ui/components/GitDiff.js.map +0 -1
- package/dist/private/node/ui/components/GitDiff.test.js.map +0 -1
- /package/dist/private/node/ui/components/{GitDiff.test.d.ts → DangerousConfirmationPrompt.test.d.ts} +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;QACrC,IAAI,sBAAkC,CAAA;QAEtC,MAAM,cAA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ACD,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;;;;;;;KAOrG,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 Preview URL: https://shopify.com\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 Preview URL: https://shopify.com\n \"\n `)\n })\n\n test(\"doesn't render the shortcuts 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 Preview URL: https://shopify.com\n \"\n `)\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;YACrB,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,KAAK,EAAE,MAAgB,EAAE,OAAiB,EAAE,OAAoB,EAAE,EAAE;gBAC1E,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;gBACrC,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAA;gBACtC,MAAM,CAAC,KAAK,CAAC,uBAAuB,C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AwB,CAAC,CAAA;gBACtC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAA;YACvC,CAAC;SACF,CAAA;QAED,OAAO;QACP,MAAM,cAAc,GAAG,MAAM,CAC3B,oBAAC,gBAAgB,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,EACD,OAAO,EAAE,OAAO,EAChB,gCAAgC,SAChC,CACH,CAAA;QAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;QAEzD,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,CAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;KAUrG,CAAC,CAAA;QAEF,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 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 \"00:00:00 │ backend │ first backend message\n 00:00:00 │ backend │ second backend message\n 00:00:00 │ backend │ third backend message\n 00:00:00 │ frontend │ first frontend message\n 00:00:00 │ frontend │ second frontend message\n 00:00:00 │ frontend │ third frontend message\n\n › 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 \"00:00:00 │ backend │ first backend message\n 00:00:00 │ backend │ second backend message\n 00:00:00 │ backend │ third backend message\n 00:00:00 │ frontend │ first frontend message\n 00:00:00 │ frontend │ second frontend message\n 00:00:00 │ frontend │ third frontend message\n\n 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 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 \"00:00:00 │ backend │ first backend message\n 00:00:00 │ backend │ second backend message\n 00:00:00 │ backend │ third backend message\n\n Preview URL: https://shopify.com\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 \"00:00:00 │ backend │ first backend message\n 00:00:00 │ backend │ second backend message\n 00:00:00 │ backend │ third backend message\n\n Preview URL: https://shopify.com\n \"\n `)\n })\n\n test(\"doesn't render the shortcuts 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 \"00:00:00 │ backend │ first backend message\n 00:00:00 │ backend │ second backend message\n 00:00:00 │ backend │ third backend message\n\n Preview URL: https://shopify.com\n \"\n `)\n })\n\n test('renders the shortcuts and accepts inputs when the processes resolve and keepRunningAfterProcessesResolve is true', async () => {\n const onInput = vi.fn()\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 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 onInput={onInput}\n keepRunningAfterProcessesResolve\n />,\n )\n\n await new Promise((resolve) => setTimeout(resolve, 1000))\n\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!).replace(/\\d/g, '0')).toMatchInlineSnapshot(`\n \"00:00:00 │ backend │ first backend message\n 00:00:00 │ backend │ second backend message\n 00:00:00 │ backend │ third backend message\n\n › Press p │ preview in your browser\n › Press q │ quit\n\n Preview URL: https://shopify.com\n \"\n `)\n\n renderInstance.stdin.write('a')\n expect(onInput).toHaveBeenCalledTimes(1)\n expect(onInput.mock.calls[0]![0]).toBe('a')\n })\n})\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InfoTableProps } from './Prompts/InfoTable.js';
|
|
2
|
+
import { AbortSignal } from '../../../../public/node/abort.js';
|
|
3
|
+
import { FunctionComponent } from 'react';
|
|
4
|
+
export interface DangerousConfirmationPromptProps {
|
|
5
|
+
message: string;
|
|
6
|
+
confirmation: string;
|
|
7
|
+
infoTable?: InfoTableProps['table'];
|
|
8
|
+
onSubmit: (value: boolean) => void;
|
|
9
|
+
abortSignal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
declare const DangerousConfirmationPrompt: FunctionComponent<DangerousConfirmationPromptProps>;
|
|
12
|
+
export { DangerousConfirmationPrompt };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { TextInput } from './TextInput.js';
|
|
2
|
+
import { TokenizedText } from './TokenizedText.js';
|
|
3
|
+
import { InfoTable } from './Prompts/InfoTable.js';
|
|
4
|
+
import { handleCtrlC } from '../../ui.js';
|
|
5
|
+
import useLayout from '../hooks/use-layout.js';
|
|
6
|
+
import { messageWithPunctuation } from '../utilities.js';
|
|
7
|
+
import useAbortSignal from '../hooks/use-abort-signal.js';
|
|
8
|
+
import usePrompt, { PromptState } from '../hooks/use-prompt.js';
|
|
9
|
+
import React, { useCallback, useState } from 'react';
|
|
10
|
+
import { Box, useApp, useInput, Text } from 'ink';
|
|
11
|
+
import figures from 'figures';
|
|
12
|
+
const DangerousConfirmationPrompt = ({ message, confirmation, infoTable, onSubmit, abortSignal, }) => {
|
|
13
|
+
const validateAnswer = useCallback((value) => {
|
|
14
|
+
return value === confirmation ? undefined : ['Value must be exactly', { userInput: confirmation }];
|
|
15
|
+
}, [confirmation]);
|
|
16
|
+
const { oneThird, twoThirds } = useLayout();
|
|
17
|
+
const { promptState, setPromptState, answer, setAnswer } = usePrompt({
|
|
18
|
+
initialAnswer: '',
|
|
19
|
+
});
|
|
20
|
+
const { exit: unmountInk } = useApp();
|
|
21
|
+
const [error, setError] = useState(undefined);
|
|
22
|
+
const color = promptState === PromptState.Error ? 'red' : 'cyan';
|
|
23
|
+
const underline = new Array(oneThird - 3).fill('▔');
|
|
24
|
+
const { isAborted } = useAbortSignal(abortSignal);
|
|
25
|
+
useInput((input, key) => {
|
|
26
|
+
handleCtrlC(input, key);
|
|
27
|
+
if (key.escape) {
|
|
28
|
+
setPromptState(PromptState.Cancelled);
|
|
29
|
+
setError(undefined);
|
|
30
|
+
onSubmit(false);
|
|
31
|
+
unmountInk();
|
|
32
|
+
}
|
|
33
|
+
if (key.return) {
|
|
34
|
+
const error = validateAnswer(answer);
|
|
35
|
+
if (error) {
|
|
36
|
+
setPromptState(PromptState.Error);
|
|
37
|
+
setError(error);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
setPromptState(PromptState.Submitted);
|
|
41
|
+
onSubmit(true);
|
|
42
|
+
unmountInk();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const completed = promptState === PromptState.Submitted || promptState === PromptState.Cancelled;
|
|
47
|
+
return isAborted ? null : (React.createElement(Box, { flexDirection: "column", marginBottom: 1, width: twoThirds },
|
|
48
|
+
React.createElement(Box, null,
|
|
49
|
+
React.createElement(Box, { marginRight: 2 },
|
|
50
|
+
React.createElement(Text, null, "?")),
|
|
51
|
+
React.createElement(TokenizedText, { item: messageWithPunctuation(message) })),
|
|
52
|
+
completed ? (React.createElement(CompletedPrompt, { ...{ cancelled: promptState === PromptState.Cancelled } })) : (React.createElement(React.Fragment, null,
|
|
53
|
+
React.createElement(Box, { flexDirection: "column", gap: 1, marginTop: 1, marginLeft: 3 },
|
|
54
|
+
infoTable ? (React.createElement(Box, { paddingLeft: 2, borderStyle: "bold", borderLeft: true, borderRight: false, borderTop: false, borderBottom: false, flexDirection: "column", gap: 1 },
|
|
55
|
+
React.createElement(InfoTable, { table: infoTable }))) : null,
|
|
56
|
+
React.createElement(Box, null,
|
|
57
|
+
React.createElement(TokenizedText, { item: ['Type', { userInput: confirmation }, 'to confirm, or press Escape to cancel.'] }))),
|
|
58
|
+
React.createElement(Box, { flexDirection: "column", width: oneThird },
|
|
59
|
+
React.createElement(Box, null,
|
|
60
|
+
React.createElement(Box, { marginRight: 2 },
|
|
61
|
+
React.createElement(Text, { color: color }, `>`)),
|
|
62
|
+
React.createElement(Box, { flexGrow: 1 },
|
|
63
|
+
React.createElement(TextInput, { value: answer, onChange: (answer) => {
|
|
64
|
+
setAnswer(answer);
|
|
65
|
+
setPromptState(PromptState.Idle);
|
|
66
|
+
}, defaultValue: "", color: color }))),
|
|
67
|
+
React.createElement(Box, { marginLeft: 3 },
|
|
68
|
+
React.createElement(Text, { color: color }, underline)),
|
|
69
|
+
promptState === PromptState.Error && error ? (React.createElement(Box, { marginLeft: 3 },
|
|
70
|
+
React.createElement(Text, { color: color },
|
|
71
|
+
React.createElement(TokenizedText, { item: error })))) : null)))));
|
|
72
|
+
};
|
|
73
|
+
const CompletedPrompt = ({ cancelled }) => (React.createElement(Box, null,
|
|
74
|
+
React.createElement(Box, { marginRight: 2 }, cancelled ? React.createElement(Text, { color: "red" }, figures.cross) : React.createElement(Text, { color: "cyan" }, figures.tick)),
|
|
75
|
+
React.createElement(Box, { flexGrow: 1 }, cancelled ? React.createElement(Text, { color: "red" }, "Cancelled") : React.createElement(Text, { color: "cyan" }, "Confirmed"))));
|
|
76
|
+
export { DangerousConfirmationPrompt };
|
|
77
|
+
//# sourceMappingURL=DangerousConfirmationPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DangerousConfirmationPrompt.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/DangerousConfirmationPrompt.tsx"],"names":[],"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,CAAC,MAAM,CAAC,CAAA;gCACjB,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;4BAClC,CAAC,EACD,YAAY,EAAC,EAAE,EACf,KAAK,EAAE,KAAK,GACZ,CACE,CACF;gBACN,oBAAC,GAAG,IAAC,UAAU,EAAE,CAAC;oBAChB,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,IAAG,SAAS,CAAQ,CAClC;gBACL,WAAW,KAAK,WAAW,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,CAC5C,oBAAC,GAAG,IAAC,UAAU,EAAE,CAAC;oBAChB,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK;wBAChB,oBAAC,aAAa,IAAC,IAAI,EAAE,KAAK,GAAI,CACzB,CACH,CACP,CAAC,CAAC,CAAC,IAAI,CACJ,CACL,CACJ,CACG,CACP,CAAA;AACH,CAAC,CAAA;AAMD,MAAM,eAAe,GAA4C,CAAC,EAAC,SAAS,EAAC,EAAE,EAAE,CAAC,CAChF,oBAAC,GAAG;IACF,oBAAC,GAAG,IAAC,WAAW,EAAE,CAAC,IAChB,SAAS,CAAC,CAAC,CAAC,oBAAC,IAAI,IAAC,KAAK,EAAC,KAAK,IAAE,OAAO,CAAC,KAAK,CAAQ,CAAC,CAAC,CAAC,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,IAAE,OAAO,CAAC,IAAI,CAAQ,CAC5F;IAEN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,IAAG,SAAS,CAAC,CAAC,CAAC,oBAAC,IAAI,IAAC,KAAK,EAAC,KAAK,gBAAiB,CAAC,CAAC,CAAC,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,gBAAiB,CAAO,CAC1G,CACP,CAAA;AAED,OAAO,EAAC,2BAA2B,EAAC,CAAA","sourcesContent":["import {TextInput} from './TextInput.js'\nimport {InlineToken, TokenItem, TokenizedText} from './TokenizedText.js'\nimport {InfoTable, InfoTableProps} from './Prompts/InfoTable.js'\nimport {handleCtrlC} from '../../ui.js'\nimport useLayout from '../hooks/use-layout.js'\nimport {messageWithPunctuation} from '../utilities.js'\nimport {AbortSignal} from '../../../../public/node/abort.js'\nimport useAbortSignal from '../hooks/use-abort-signal.js'\nimport usePrompt, {PromptState} from '../hooks/use-prompt.js'\nimport React, {FunctionComponent, useCallback, useState} from 'react'\nimport {Box, useApp, useInput, Text} from 'ink'\nimport figures from 'figures'\n\nexport interface DangerousConfirmationPromptProps {\n message: string\n confirmation: string\n infoTable?: InfoTableProps['table']\n onSubmit: (value: boolean) => void\n abortSignal?: AbortSignal\n}\n\nconst DangerousConfirmationPrompt: FunctionComponent<DangerousConfirmationPromptProps> = ({\n message,\n confirmation,\n infoTable,\n onSubmit,\n abortSignal,\n}) => {\n const validateAnswer = useCallback(\n (value: string): TokenItem<InlineToken> | undefined => {\n return value === confirmation ? undefined : ['Value must be exactly', {userInput: confirmation}]\n },\n [confirmation],\n )\n\n const {oneThird, twoThirds} = useLayout()\n const {promptState, setPromptState, answer, setAnswer} = usePrompt<string>({\n initialAnswer: '',\n })\n const {exit: unmountInk} = useApp()\n const [error, setError] = useState<TokenItem<InlineToken> | undefined>(undefined)\n const color = promptState === PromptState.Error ? 'red' : 'cyan'\n const underline = new Array(oneThird - 3).fill('▔')\n const {isAborted} = useAbortSignal(abortSignal)\n\n useInput((input, key) => {\n handleCtrlC(input, key)\n\n if (key.escape) {\n setPromptState(PromptState.Cancelled)\n setError(undefined)\n onSubmit(false)\n unmountInk()\n }\n\n if (key.return) {\n const error = validateAnswer(answer)\n\n if (error) {\n setPromptState(PromptState.Error)\n setError(error)\n } else {\n setPromptState(PromptState.Submitted)\n onSubmit(true)\n unmountInk()\n }\n }\n })\n\n const completed = promptState === PromptState.Submitted || promptState === PromptState.Cancelled\n\n return isAborted ? null : (\n <Box flexDirection=\"column\" marginBottom={1} width={twoThirds}>\n <Box>\n <Box marginRight={2}>\n <Text>?</Text>\n </Box>\n <TokenizedText item={messageWithPunctuation(message)} />\n </Box>\n {completed ? (\n <CompletedPrompt {...{cancelled: promptState === PromptState.Cancelled}} />\n ) : (\n <>\n <Box flexDirection=\"column\" gap={1} marginTop={1} marginLeft={3}>\n {infoTable ? (\n <Box\n paddingLeft={2}\n borderStyle=\"bold\"\n borderLeft\n borderRight={false}\n borderTop={false}\n borderBottom={false}\n flexDirection=\"column\"\n gap={1}\n >\n <InfoTable table={infoTable} />\n </Box>\n ) : null}\n <Box>\n <TokenizedText item={['Type', {userInput: confirmation}, 'to confirm, or press Escape to cancel.']} />\n </Box>\n </Box>\n <Box flexDirection=\"column\" width={oneThird}>\n <Box>\n <Box marginRight={2}>\n <Text color={color}>{`>`}</Text>\n </Box>\n <Box flexGrow={1}>\n <TextInput\n value={answer}\n onChange={(answer) => {\n setAnswer(answer)\n setPromptState(PromptState.Idle)\n }}\n defaultValue=\"\"\n color={color}\n />\n </Box>\n </Box>\n <Box marginLeft={3}>\n <Text color={color}>{underline}</Text>\n </Box>\n {promptState === PromptState.Error && error ? (\n <Box marginLeft={3}>\n <Text color={color}>\n <TokenizedText item={error} />\n </Text>\n </Box>\n ) : null}\n </Box>\n </>\n )}\n </Box>\n )\n}\n\ninterface CompletedPromptProps {\n cancelled: boolean\n}\n\nconst CompletedPrompt: FunctionComponent<CompletedPromptProps> = ({cancelled}) => (\n <Box>\n <Box marginRight={2}>\n {cancelled ? <Text color=\"red\">{figures.cross}</Text> : <Text color=\"cyan\">{figures.tick}</Text>}\n </Box>\n\n <Box flexGrow={1}>{cancelled ? <Text color=\"red\">Cancelled</Text> : <Text color=\"cyan\">Confirmed</Text>}</Box>\n </Box>\n)\n\nexport {DangerousConfirmationPrompt}\n"]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { DangerousConfirmationPrompt } from './DangerousConfirmationPrompt.js';
|
|
2
|
+
import { getLastFrameAfterUnmount, sendInputAndWaitForChange, waitForInputsToBeReady, render } from '../../testing/ui.js';
|
|
3
|
+
import { unstyled } from '../../../../public/node/output.js';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
6
|
+
const ENTER = '\r';
|
|
7
|
+
const ESC = '\x1b';
|
|
8
|
+
describe('DangerousConfirmationPrompt', () => {
|
|
9
|
+
test('default state', () => {
|
|
10
|
+
const { lastFrame } = render(React.createElement(DangerousConfirmationPrompt, { onSubmit: () => { }, message: "Test question", confirmation: "yes" }));
|
|
11
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
12
|
+
"? Test question:
|
|
13
|
+
|
|
14
|
+
Type yes to confirm, or press Escape to cancel.
|
|
15
|
+
> █
|
|
16
|
+
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
|
|
17
|
+
"
|
|
18
|
+
`);
|
|
19
|
+
});
|
|
20
|
+
test('default validation error', async () => {
|
|
21
|
+
const renderInstance = render(React.createElement(DangerousConfirmationPrompt, { onSubmit: () => { }, message: "Test question", confirmation: "yes" }));
|
|
22
|
+
await waitForInputsToBeReady();
|
|
23
|
+
await sendInputAndWaitForChange(renderInstance, ENTER);
|
|
24
|
+
// testing with styles because the color changes to red
|
|
25
|
+
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
26
|
+
"? Test question:
|
|
27
|
+
|
|
28
|
+
Type [36myes[39m to confirm, or press Escape to cancel.
|
|
29
|
+
[31m>[39m [31m[41m█[49m[39m
|
|
30
|
+
[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔[39m
|
|
31
|
+
[31mValue must be exactly [36myes[39m[31m[39m
|
|
32
|
+
"
|
|
33
|
+
`);
|
|
34
|
+
await sendInputAndWaitForChange(renderInstance, 'A');
|
|
35
|
+
// color changes back to valid color
|
|
36
|
+
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
37
|
+
"? Test question:
|
|
38
|
+
|
|
39
|
+
Type [36myes[39m to confirm, or press Escape to cancel.
|
|
40
|
+
[36m>[39m [36mA[46m█[49m[39m
|
|
41
|
+
[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔[39m
|
|
42
|
+
"
|
|
43
|
+
`);
|
|
44
|
+
});
|
|
45
|
+
test('submitting the value', async () => {
|
|
46
|
+
const onSubmit = vi.fn();
|
|
47
|
+
const renderInstance = render(React.createElement(DangerousConfirmationPrompt, { onSubmit: onSubmit, message: "Test question", confirmation: "yes" }));
|
|
48
|
+
await waitForInputsToBeReady();
|
|
49
|
+
await sendInputAndWaitForChange(renderInstance, 'yes');
|
|
50
|
+
await sendInputAndWaitForChange(renderInstance, ENTER);
|
|
51
|
+
expect(onSubmit).toHaveBeenCalledWith(true);
|
|
52
|
+
expect(unstyled(getLastFrameAfterUnmount(renderInstance))).toMatchInlineSnapshot(`
|
|
53
|
+
"? Test question:
|
|
54
|
+
✔ Confirmed
|
|
55
|
+
"
|
|
56
|
+
`);
|
|
57
|
+
});
|
|
58
|
+
test('text wrapping', async () => {
|
|
59
|
+
// component width is 80 characters wide in tests but because of the question mark and
|
|
60
|
+
// spaces before the question, we only have 77 characters to work with
|
|
61
|
+
const renderInstance = render(React.createElement(DangerousConfirmationPrompt, { onSubmit: () => { }, message: "Test question", confirmation: "yes" }));
|
|
62
|
+
await waitForInputsToBeReady();
|
|
63
|
+
await sendInputAndWaitForChange(renderInstance, 'A'.repeat(77));
|
|
64
|
+
await sendInputAndWaitForChange(renderInstance, 'B'.repeat(6));
|
|
65
|
+
expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`
|
|
66
|
+
"? Test question:
|
|
67
|
+
|
|
68
|
+
Type [36myes[39m to confirm, or press Escape to cancel.
|
|
69
|
+
[36m>[39m [36mAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA[39m
|
|
70
|
+
[36mBBBBBB[46m█[49m[39m
|
|
71
|
+
[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔[39m
|
|
72
|
+
"
|
|
73
|
+
`);
|
|
74
|
+
});
|
|
75
|
+
test("doesn't append a colon to the message if it ends with a question mark", async () => {
|
|
76
|
+
const { lastFrame } = render(React.createElement(DangerousConfirmationPrompt, { onSubmit: () => { }, message: "Test question?", confirmation: "yes" }));
|
|
77
|
+
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
78
|
+
"? Test question?
|
|
79
|
+
|
|
80
|
+
Type yes to confirm, or press Escape to cancel.
|
|
81
|
+
> █
|
|
82
|
+
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
|
|
83
|
+
"
|
|
84
|
+
`);
|
|
85
|
+
});
|
|
86
|
+
test('can use Escape key to exit the prompt gracefully', async () => {
|
|
87
|
+
const onSubmit = vi.fn();
|
|
88
|
+
const renderInstance = render(React.createElement(DangerousConfirmationPrompt, { onSubmit: onSubmit, message: "Test question", confirmation: "yes" }));
|
|
89
|
+
await waitForInputsToBeReady();
|
|
90
|
+
const promise = renderInstance.waitUntilExit();
|
|
91
|
+
await sendInputAndWaitForChange(renderInstance, ESC);
|
|
92
|
+
expect(unstyled(getLastFrameAfterUnmount(renderInstance))).toMatchInlineSnapshot(`
|
|
93
|
+
"? Test question:
|
|
94
|
+
✘ Cancelled
|
|
95
|
+
"
|
|
96
|
+
`);
|
|
97
|
+
await expect(promise).resolves.toEqual(undefined);
|
|
98
|
+
expect(onSubmit).toHaveBeenCalledWith(false);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=DangerousConfirmationPrompt.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DangerousConfirmationPrompt.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/DangerousConfirmationPrompt.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAA;AAC5E,OAAO,EAAC,wBAAwB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,EAAC,MAAM,qBAAqB,CAAA;AACvH,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;AAEjD,MAAM,KAAK,GAAG,IAAI,CAAA;AAClB,MAAM,GAAG,GAAG,MAAM,CAAA;AAElB,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;QACzB,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CACxB,oBAAC,2BAA2B,IAAC,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,OAAO,EAAC,eAAe,EAAC,YAAY,EAAC,KAAK,GAAG,C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O,EAAC,eAAe,EAAC,YAAY,EAAC,KAAK,GAAG,CAC/F,CAAA;QACD,MAAM,sBAAsB,EAAE,CAAA;QAC9B,MAAM,OAAO,GAAG,cAAc,CAAC,aAAa,EAAE,CAAA;QAC9C,MAAM,yBAAyB,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;QAEpD,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,CAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;KAIjF,CAAC,CAAA;QACF,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACjD,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {DangerousConfirmationPrompt} from './DangerousConfirmationPrompt.js'\nimport {getLastFrameAfterUnmount, sendInputAndWaitForChange, waitForInputsToBeReady, render} from '../../testing/ui.js'\nimport {unstyled} from '../../../../public/node/output.js'\nimport React from 'react'\nimport {describe, expect, test, vi} from 'vitest'\n\nconst ENTER = '\\r'\nconst ESC = '\\x1b'\n\ndescribe('DangerousConfirmationPrompt', () => {\n test('default state', () => {\n const {lastFrame} = render(\n <DangerousConfirmationPrompt onSubmit={() => {}} message=\"Test question\" confirmation=\"yes\" />,\n )\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"? Test question:\n\n Type yes to confirm, or press Escape to cancel.\n > █\n ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n \"\n `)\n })\n\n test('default validation error', async () => {\n const renderInstance = render(\n <DangerousConfirmationPrompt onSubmit={() => {}} message=\"Test question\" confirmation=\"yes\" />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, ENTER)\n // testing with styles because the color changes to red\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n\n Type \u001b[36myes\u001b[39m to confirm, or press Escape to cancel.\n \u001b[31m>\u001b[39m \u001b[31m\u001b[41m█\u001b[49m\u001b[39m\n \u001b[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \u001b[31mValue must be exactly \u001b[36myes\u001b[39m\u001b[31m\u001b[39m\n \"\n `)\n await sendInputAndWaitForChange(renderInstance, 'A')\n // color changes back to valid color\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n\n Type \u001b[36myes\u001b[39m to confirm, or press Escape to cancel.\n \u001b[36m>\u001b[39m \u001b[36mA\u001b[46m█\u001b[49m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test('submitting the value', async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(\n <DangerousConfirmationPrompt onSubmit={onSubmit} message=\"Test question\" confirmation=\"yes\" />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, 'yes')\n await sendInputAndWaitForChange(renderInstance, ENTER)\n expect(onSubmit).toHaveBeenCalledWith(true)\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✔ Confirmed\n \"\n `)\n })\n\n test('text wrapping', async () => {\n // component width is 80 characters wide in tests but because of the question mark and\n // spaces before the question, we only have 77 characters to work with\n const renderInstance = render(\n <DangerousConfirmationPrompt onSubmit={() => {}} message=\"Test question\" confirmation=\"yes\" />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, 'A'.repeat(77))\n await sendInputAndWaitForChange(renderInstance, 'B'.repeat(6))\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n\n Type \u001b[36myes\u001b[39m to confirm, or press Escape to cancel.\n \u001b[36m>\u001b[39m \u001b[36mAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\u001b[39m\n \u001b[36mBBBBBB\u001b[46m█\u001b[49m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test(\"doesn't append a colon to the message if it ends with a question mark\", async () => {\n const {lastFrame} = render(\n <DangerousConfirmationPrompt onSubmit={() => {}} message=\"Test question?\" confirmation=\"yes\" />,\n )\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"? Test question?\n\n Type yes to confirm, or press Escape to cancel.\n > █\n ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n \"\n `)\n })\n\n test('can use Escape key to exit the prompt gracefully', async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(\n <DangerousConfirmationPrompt onSubmit={onSubmit} message=\"Test question\" confirmation=\"yes\" />,\n )\n await waitForInputsToBeReady()\n const promise = renderInstance.waitUntilExit()\n await sendInputAndWaitForChange(renderInstance, ESC)\n\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✘ Cancelled\n \"\n `)\n await expect(promise).resolves.toEqual(undefined)\n expect(onSubmit).toHaveBeenCalledWith(false)\n })\n})\n"]}
|
|
@@ -6,12 +6,12 @@ const DOT = '•';
|
|
|
6
6
|
* `List` displays an unordered or ordered list with text aligned with the bullet point
|
|
7
7
|
* and wrapped to the container width.
|
|
8
8
|
*/
|
|
9
|
-
const List = ({ title, items, margin = true, ordered = false, color }) => {
|
|
9
|
+
const List = ({ title, items, margin = true, ordered = false, color, bullet = DOT, }) => {
|
|
10
10
|
return (React.createElement(Box, { flexDirection: "column" },
|
|
11
11
|
title ? (React.createElement(Text, { color: color },
|
|
12
12
|
React.createElement(TokenizedText, { item: title }))) : null,
|
|
13
13
|
items.map((item, index) => (React.createElement(Box, { key: index, marginLeft: margin ? 2 : 0 },
|
|
14
|
-
React.createElement(Text, { color: color }, `${ordered ? `${index + 1}.` :
|
|
14
|
+
React.createElement(Text, { color: color }, `${ordered ? `${index + 1}.` : bullet}`),
|
|
15
15
|
React.createElement(Box, { flexGrow: 1, marginLeft: 1 },
|
|
16
16
|
React.createElement(Text, { color: color },
|
|
17
17
|
React.createElement(TokenizedText, { item: item }))))))));
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"List.js","sourceRoot":"","sources":["../../../../../src/private/node/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'\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 bullet?: string\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> = ({\n title,\n items,\n margin = true,\n ordered = false,\n color,\n bullet = DOT,\n}): 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} marginLeft={margin ? 2 : 0}>\n <Text color={color}>{`${ordered ? `${index + 1}.` : bullet}`}</Text>\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"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
export interface GitDiffProps {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
gitDiff: {
|
|
4
|
+
baselineContent: string;
|
|
5
|
+
updatedContent: string;
|
|
6
|
+
};
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* `GitDiff` displays a git diff between two strings.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unstyled, shouldDisplayColors } from '
|
|
1
|
+
import { unstyled, shouldDisplayColors } from '../../../../../public/node/output.js';
|
|
2
2
|
import { Text } from 'ink';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { createRequire } from 'module';
|
|
@@ -12,11 +12,12 @@ const gitDiff = require('git-diff');
|
|
|
12
12
|
* unchanged line
|
|
13
13
|
* + added line
|
|
14
14
|
*/
|
|
15
|
-
const GitDiff = ({ baselineContent, updatedContent }) => {
|
|
15
|
+
const GitDiff = ({ gitDiff: { baselineContent, updatedContent } }) => {
|
|
16
16
|
const rawDiffContents = gitDiff(baselineContent, updatedContent, {
|
|
17
17
|
color: shouldDisplayColors(),
|
|
18
18
|
// Show minimal context to accommodate small terminals.
|
|
19
19
|
flags: '--unified=1 --inter-hunk-context=1',
|
|
20
|
+
noHeaders: true,
|
|
20
21
|
});
|
|
21
22
|
if (!rawDiffContents) {
|
|
22
23
|
return React.createElement(Text, null, "No changes.");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitDiff.js","sourceRoot":"","sources":["../../../../../../src/private/node/ui/components/Prompts/GitDiff.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,mBAAmB,EAAC,MAAM,sCAAsC,CAAA;AAClF,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAA0B,MAAM,OAAO,CAAA;AAC9C,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAEpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AASnC;;;;;;;GAOG;AACH,MAAM,OAAO,GAAoC,CAAC,EAAC,OAAO,EAAE,EAAC,eAAe,EAAE,cAAc,EAAC,EAAC,EAAe,EAAE;IAC7G,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,EAAE,cAAc,EAAE;QAC/D,KAAK,EAAE,mBAAmB,EAAE;QAC5B,uDAAuD;QACvD,KAAK,EAAE,oCAAoC;QAC3C,SAAS,EAAE,IAAI;KAChB,CAAC,CAAA;IACF,IAAI,CAAC,eAAe,EAAE;QACpB,OAAO,oBAAC,IAAI,sBAAmB,CAAA;KAChC;IACD,MAAM,YAAY,GAAG,eAAe;SACjC,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAY,EAAE,KAAa,EAAsB,EAAE;QACvD,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;QACnC,IAAI,YAAY,KAAK,8BAA8B,EAAE;YACnD,OAAO,SAAS,CAAA;SACjB;aAAM,IAAI,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;YACpC,MAAM,UAAU,GAAG,KAAK,KAAK,CAAC,CAAA;YAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;SAC3D;aAAM;YACL,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;gBACxC,OAAO,GAAG,KAAK,GAAG,CAAA;YACpB,CAAC,CAAC,CAAA;SACH;IACH,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAwB,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC;SACxD,IAAI,CAAC,IAAI,CAAC;SACV,OAAO,EAAE,CAAA;IACZ,OAAO,oBAAC,IAAI,QAAE,YAAY,CAAQ,CAAA;AACpC,CAAC,CAAA;AAED,OAAO,EAAC,OAAO,EAAC,CAAA","sourcesContent":["import {unstyled, shouldDisplayColors} from '../../../../../public/node/output.js'\nimport {Text} from 'ink'\nimport React, {FunctionComponent} from 'react'\nimport {createRequire} from 'module'\n\nconst require = createRequire(import.meta.url)\nconst gitDiff = require('git-diff')\n\nexport interface GitDiffProps {\n gitDiff: {\n baselineContent: string\n updatedContent: string\n }\n}\n\n/**\n * `GitDiff` displays a git diff between two strings.\n * @example\n * \\@\\@ -1,2 +1,2 \\@\\@\n * - deleted line\n * unchanged line\n * + added line\n */\nconst GitDiff: FunctionComponent<GitDiffProps> = ({gitDiff: {baselineContent, updatedContent}}): JSX.Element => {\n const rawDiffContents = gitDiff(baselineContent, updatedContent, {\n color: shouldDisplayColors(),\n // Show minimal context to accommodate small terminals.\n flags: '--unified=1 --inter-hunk-context=1',\n noHeaders: true,\n })\n if (!rawDiffContents) {\n return <Text>No changes.</Text>\n }\n const diffContents = rawDiffContents\n .split('\\n')\n .map((line: string, index: number): string | undefined => {\n const unstyledLine = unstyled(line)\n if (unstyledLine === '\\\') {\n return undefined\n } else if (unstyledLine.match(/^@@/)) {\n const addNewline = index !== 0\n return line.replace('@@', `${addNewline ? '\\n' : ''} @@`)\n } else {\n return line.replace(/([+\\- ])/, (match) => {\n return `${match} `\n })\n }\n })\n .filter((line: string | undefined) => line !== undefined)\n .join('\\n')\n .trimEnd()\n return <Text>{diffContents}</Text>\n}\n\nexport {GitDiff}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GitDiff } from './GitDiff.js';
|
|
2
|
-
import { render } from '
|
|
3
|
-
import { unstyled } from '
|
|
2
|
+
import { render } from '../../../testing/ui.js';
|
|
3
|
+
import { unstyled } from '../../../../../public/node/output.js';
|
|
4
4
|
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
afterEach(async () => {
|
|
@@ -8,56 +8,74 @@ afterEach(async () => {
|
|
|
8
8
|
});
|
|
9
9
|
describe('GitDiff', async () => {
|
|
10
10
|
test('renders correctly when no changes exist', async () => {
|
|
11
|
-
const
|
|
11
|
+
const gitDiff = {
|
|
12
|
+
baselineContent: 'hello',
|
|
13
|
+
updatedContent: 'hello',
|
|
14
|
+
};
|
|
15
|
+
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
12
16
|
expect(lastFrame()).toEqual('No changes.');
|
|
13
17
|
});
|
|
14
18
|
test('renders correctly when changes exist', async () => {
|
|
15
|
-
const
|
|
19
|
+
const gitDiff = {
|
|
20
|
+
baselineContent: 'hello\n',
|
|
21
|
+
updatedContent: 'world\n',
|
|
22
|
+
};
|
|
23
|
+
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
16
24
|
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
17
|
-
"
|
|
18
|
-
- hello
|
|
25
|
+
"- hello
|
|
19
26
|
+ world"
|
|
20
27
|
`);
|
|
21
28
|
});
|
|
22
29
|
test('renders correctly when changes exist and are several lines long', async () => {
|
|
23
|
-
const
|
|
30
|
+
const gitDiff = {
|
|
31
|
+
baselineContent: 'hello\nworld\n',
|
|
32
|
+
updatedContent: 'world\nhello\n',
|
|
33
|
+
};
|
|
34
|
+
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
24
35
|
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
25
|
-
"
|
|
26
|
-
- hello
|
|
36
|
+
"- hello
|
|
27
37
|
world
|
|
28
38
|
+ hello"
|
|
29
39
|
`);
|
|
30
40
|
});
|
|
31
41
|
test('displays color correctly', async () => {
|
|
32
|
-
const
|
|
42
|
+
const gitDiff = {
|
|
43
|
+
baselineContent: 'hello\nworld\n',
|
|
44
|
+
updatedContent: 'world\nhello\n',
|
|
45
|
+
};
|
|
46
|
+
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
33
47
|
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
\u001b[32m+ \u001b[m\u001b[32mhello\u001b[m"
|
|
48
|
+
"[31m- hello[m
|
|
49
|
+
world[m
|
|
50
|
+
[32m+ [m[32mhello[m"
|
|
38
51
|
`);
|
|
39
52
|
});
|
|
40
53
|
test('respects no-color mode', async () => {
|
|
41
54
|
vi.stubGlobal('process', { ...process, env: { ...process.env, FORCE_COLOR: '0' } });
|
|
42
|
-
const
|
|
55
|
+
const gitDiff = {
|
|
56
|
+
baselineContent: 'hello\nworld\n',
|
|
57
|
+
updatedContent: 'world\nhello\n',
|
|
58
|
+
};
|
|
59
|
+
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
43
60
|
expect(lastFrame()).toMatchInlineSnapshot(`
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
`);
|
|
61
|
+
"- hello
|
|
62
|
+
world
|
|
63
|
+
+ hello"
|
|
64
|
+
`);
|
|
49
65
|
});
|
|
50
66
|
test('ignores newline changes', async () => {
|
|
51
67
|
const expectedDiff = `
|
|
52
|
-
"
|
|
53
|
-
- hello
|
|
68
|
+
"- hello
|
|
54
69
|
world
|
|
55
70
|
+ hello"
|
|
56
71
|
`;
|
|
72
|
+
const gitDiff = {
|
|
73
|
+
baselineContent: 'hello\nworld\n',
|
|
74
|
+
updatedContent: 'world\nhello',
|
|
75
|
+
};
|
|
57
76
|
// Removing a newline
|
|
58
|
-
const { lastFrame } = render(React.createElement(GitDiff, {
|
|
77
|
+
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
59
78
|
expect(unstyled(lastFrame())).toMatchInlineSnapshot(expectedDiff);
|
|
60
|
-
const lastFrame2 = render(React.createElement(GitDiff, { baselineContent: "hello\\nworld\\n", updatedContent: "world\\nhello" })).lastFrame;
|
|
61
79
|
expect(unstyled(lastFrame())).toMatchInlineSnapshot(expectedDiff);
|
|
62
80
|
});
|
|
63
81
|
test('renders correctly when changes exist in multiple areas of a file', async () => {
|
|
@@ -80,10 +98,13 @@ sit
|
|
|
80
98
|
amet
|
|
81
99
|
foo
|
|
82
100
|
qux`;
|
|
83
|
-
const
|
|
101
|
+
const gitDiff = {
|
|
102
|
+
baselineContent,
|
|
103
|
+
updatedContent,
|
|
104
|
+
};
|
|
105
|
+
const { lastFrame } = render(React.createElement(GitDiff, { gitDiff: gitDiff }));
|
|
84
106
|
expect(unstyled(lastFrame())).toMatchInlineSnapshot(`
|
|
85
|
-
"
|
|
86
|
-
- hello
|
|
107
|
+
"- hello
|
|
87
108
|
world
|
|
88
109
|
+ hello
|
|
89
110
|
lorem
|
|
@@ -91,7 +112,8 @@ qux`;
|
|
|
91
112
|
@@ -8,2 +8,2 @@ amet
|
|
92
113
|
foo
|
|
93
114
|
- bar
|
|
94
|
-
+ qux"
|
|
115
|
+
+ qux"
|
|
116
|
+
`);
|
|
95
117
|
});
|
|
96
118
|
});
|
|
97
119
|
//# sourceMappingURL=GitDiff.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitDiff.test.js","sourceRoot":"","sources":["../../../../../../src/private/node/ui/components/Prompts/GitDiff.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,sCAAsC,CAAA;AAC7D,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAC,MAAM,QAAQ,CAAA;AAC5D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,SAAS,CAAC,KAAK,IAAI,EAAE;IACnB,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAA;AAC7B,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;IAC7B,IAAI,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;QACzD,MAAM,OAAO,GAAG;YACd,eAAe,EAAE,OAAO;YACxB,cAAc,EAAE,OAAO;SACxB,CAAA;QAED,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,OAAO,IAAC,OAAO,EAAE,OAAO,GAAI,CAAC,CAAA;QAEzD,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,OAAO,GAAG;YACd,eAAe,EAAE,SAAS;YAC1B,cAAc,EAAE,SAAS;SAC1B,CAAA;QAED,MAAM,EAAC,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output.js'\nimport {afterEach, describe, expect, test, vi} from 'vitest'\nimport React from 'react'\n\nafterEach(async () => {\n await vi.unstubAllGlobals()\n})\n\ndescribe('GitDiff', async () => {\n test('renders correctly when no changes exist', async () => {\n const gitDiff = {\n baselineContent: 'hello',\n updatedContent: 'hello',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(lastFrame()).toEqual('No changes.')\n })\n\n test('renders correctly when changes exist', async () => {\n const gitDiff = {\n baselineContent: 'hello\\n',\n updatedContent: 'world\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"- hello\n + world\"\n `)\n })\n\n test('renders correctly when changes exist and are several lines long', async () => {\n const gitDiff = {\n baselineContent: 'hello\\nworld\\n',\n updatedContent: 'world\\nhello\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"- hello\n world\n + hello\"\n `)\n })\n\n test('displays color correctly', async () => {\n const gitDiff = {\n baselineContent: 'hello\\nworld\\n',\n updatedContent: 'world\\nhello\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(lastFrame()).toMatchInlineSnapshot(`\n \"\u001b[31m- hello\u001b[m\n world\u001b[m\n \u001b[32m+ \u001b[m\u001b[32mhello\u001b[m\"\n `)\n })\n\n test('respects no-color mode', async () => {\n vi.stubGlobal('process', {...process, env: {...process.env, FORCE_COLOR: '0'}})\n const gitDiff = {\n baselineContent: 'hello\\nworld\\n',\n updatedContent: 'world\\nhello\\n',\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(lastFrame()!).toMatchInlineSnapshot(`\n \"- hello\n world\n + hello\"\n `)\n })\n\n test('ignores newline changes', async () => {\n const expectedDiff = `\n \"- hello\n world\n + hello\"\n `\n\n const gitDiff = {\n baselineContent: 'hello\\nworld\\n',\n updatedContent: 'world\\nhello',\n }\n\n // Removing a newline\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(expectedDiff)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(expectedDiff)\n })\n\n test('renders correctly when changes exist in multiple areas of a file', async () => {\n const baselineContent = `hello\nworld\nlorem\nipsum\ndolor\nsit\namet\nfoo\nbar\n`\n const updatedContent = `world\nhello\nlorem\nipsum\ndolor\nsit\namet\nfoo\nqux`\n\n const gitDiff = {\n baselineContent,\n updatedContent,\n }\n\n const {lastFrame} = render(<GitDiff gitDiff={gitDiff} />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"- hello\n world\n + hello\n lorem\n\n @@ -8,2 +8,2 @@ amet\n foo\n - bar\n + qux\"\n `)\n })\n})\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { InlineToken, LinkToken, TokenItem, UserInputToken } from '../TokenizedText.js';
|
|
2
|
+
import { TextProps } from 'ink';
|
|
3
|
+
import { FunctionComponent } from 'react';
|
|
4
|
+
export interface InfoMessageProps {
|
|
5
|
+
message: {
|
|
6
|
+
title: {
|
|
7
|
+
color?: TextProps['color'];
|
|
8
|
+
text: TokenItem<Exclude<InlineToken, UserInputToken | LinkToken>>;
|
|
9
|
+
};
|
|
10
|
+
body: TokenItem;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
declare const InfoMessage: FunctionComponent<InfoMessageProps>;
|
|
14
|
+
export { InfoMessage };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TokenizedText } from '../TokenizedText.js';
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
const InfoMessage = ({ message: { title: { color, text: title }, body, }, }) => {
|
|
5
|
+
return (React.createElement(Box, { flexDirection: "column", gap: 1 },
|
|
6
|
+
React.createElement(Text, { color: color },
|
|
7
|
+
React.createElement(TokenizedText, { item: title })),
|
|
8
|
+
React.createElement(TokenizedText, { item: body })));
|
|
9
|
+
};
|
|
10
|
+
export { InfoMessage };
|
|
11
|
+
//# sourceMappingURL=InfoMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoMessage.js","sourceRoot":"","sources":["../../../../../../src/private/node/ui/components/Prompts/InfoMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoC,aAAa,EAAiB,MAAM,qBAAqB,CAAA;AACpG,OAAO,EAAC,GAAG,EAAE,IAAI,EAAY,MAAM,KAAK,CAAA;AACxC,OAAO,KAA0B,MAAM,OAAO,CAAA;AAY9C,MAAM,WAAW,GAAwC,CAAC,EACxD,OAAO,EAAE,EACP,KAAK,EAAE,EAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAC,EAC3B,IAAI,GACL,GACF,EAAE,EAAE;IACH,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,GAAG,EAAE,CAAC;QAChC,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK;YAChB,oBAAC,aAAa,IAAC,IAAI,EAAE,KAAK,GAAI,CACzB;QACP,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CACzB,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,WAAW,EAAC,CAAA","sourcesContent":["import {InlineToken, LinkToken, TokenItem, TokenizedText, UserInputToken} from '../TokenizedText.js'\nimport {Box, Text, TextProps} from 'ink'\nimport React, {FunctionComponent} from 'react'\n\nexport interface InfoMessageProps {\n message: {\n title: {\n color?: TextProps['color']\n text: TokenItem<Exclude<InlineToken, UserInputToken | LinkToken>>\n }\n body: TokenItem\n }\n}\n\nconst InfoMessage: FunctionComponent<InfoMessageProps> = ({\n message: {\n title: {color, text: title},\n body,\n },\n}) => {\n return (\n <Box flexDirection=\"column\" gap={1}>\n <Text color={color}>\n <TokenizedText item={title} />\n </Text>\n <TokenizedText item={body} />\n </Box>\n )\n}\n\nexport {InfoMessage}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|