@shopify/cli-kit 3.46.0-pre.2 → 3.46.0-pre.3

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.
@@ -1,5 +1,5 @@
1
1
  query {
2
- products(first: 1) {
2
+ products(first: 1, query:"published_status:published") {
3
3
  edges {
4
4
  node {
5
5
  id
@@ -5,6 +5,7 @@ module ShopifyCLI
5
5
  class DevServer
6
6
  class LocalAssets
7
7
  THEME_REGEX = %r{//cdn\.shopify\.com/s/.+?/(assets/.+?\.(?:css|js))}
8
+ VANITY_THEME_REGEX = %r{/cdn/shop/.+?/(assets/.+?\.(?:css|js))}
8
9
 
9
10
  class FileBody
10
11
  def initialize(path)
@@ -44,12 +45,11 @@ module ShopifyCLI
44
45
  private
45
46
 
46
47
  def replace_asset_urls(body)
47
- replaced_body = body.join.gsub(THEME_REGEX) do |match|
48
- path = Regexp.last_match[1]
49
- if @target.static_asset_paths.include?(path)
50
- "/#{path}"
51
- else
52
- match
48
+ replaced_body = body.join
49
+ [THEME_REGEX, VANITY_THEME_REGEX].each do |regex|
50
+ replaced_body = replaced_body.gsub(regex) do |match|
51
+ path = Regexp.last_match[1]
52
+ @target.static_asset_paths.include?(path) ? "/#{path}" : match
53
53
  end
54
54
  end
55
55
 
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" resolution-mode="require"/>
1
2
  /**
2
3
  * Returns whether an environment variable value represents a truthy value.
3
4
  */
@@ -6,3 +7,16 @@ export declare function isTruthy(variable: string | undefined): boolean;
6
7
  * Returns whether an environment variable has been set and is non-empty
7
8
  */
8
9
  export declare function isSet(variable: string | undefined): boolean;
10
+ /**
11
+ * Returns an object with environment variables from the specified CI environment.
12
+ */
13
+ export declare function getCIMetadata(envName: string, envs: NodeJS.ProcessEnv): Metadata;
14
+ export interface Metadata {
15
+ actor?: string;
16
+ branch?: string;
17
+ build?: string;
18
+ commitMessage?: string;
19
+ commitSha?: string;
20
+ run?: string;
21
+ url?: string;
22
+ }
@@ -16,4 +16,51 @@ export function isSet(variable) {
16
16
  }
17
17
  return true;
18
18
  }
19
+ /**
20
+ * Returns an object with environment variables from the specified CI environment.
21
+ */
22
+ export function getCIMetadata(envName, envs) {
23
+ switch (envName) {
24
+ case 'bitbucket':
25
+ return {
26
+ actor: envs.BITBUCKET_COMMIT_AUTHOR,
27
+ branch: envs.BITBUCKET_BRANCH,
28
+ build: envs.BITBUCKET_BUILD_NUMBER,
29
+ commitSha: envs.BITBUCKET_COMMIT,
30
+ run: envs.BITBUCKET_BUILD_NUMBER,
31
+ url: envs.BITBUCKET_BUILD_URL,
32
+ };
33
+ case 'circleci':
34
+ return {
35
+ actor: envs.CIRCLE_USERNAME,
36
+ branch: envs.CIRCLE_BRANCH,
37
+ build: envs.CIRCLE_BUILD_NUM,
38
+ commitSha: envs.CIRCLE_SHA1,
39
+ run: envs.CIRCLE_WORKFLOW_ID,
40
+ url: envs.CIRCLE_BUILD_URL,
41
+ };
42
+ case 'github':
43
+ return {
44
+ actor: envs.GITHUB_ACTOR,
45
+ branch: envs.GITHUB_REF_NAME,
46
+ build: envs.GITHUB_RUN_ID,
47
+ commitMessage: envs.GITHUB_COMMIT_MESSAGE,
48
+ commitSha: envs.GITHUB_SHA,
49
+ run: envs.GITHUB_RUN_ID,
50
+ url: `${envs.GITHUB_SERVER_URL}${envs.GITHUB_REPOSITORY}/actions/runs/${envs.GITHUB_RUN_ID}`,
51
+ };
52
+ case 'gitlab':
53
+ return {
54
+ actor: envs.GITLAB_USER_LOGIN,
55
+ branch: envs.CI_COMMIT_REF_NAME,
56
+ build: envs.CI_PIPELINE_ID,
57
+ commitSha: envs.CI_COMMIT_SHA,
58
+ commitMessage: envs.CI_COMMIT_MESSAGE,
59
+ run: envs.CI_RUNNER_ID,
60
+ url: envs.CI_PROJECT_URL,
61
+ };
62
+ default:
63
+ return {};
64
+ }
65
+ }
19
66
  //# sourceMappingURL=utilities.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/private/node/context/utilities.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA4B;IACnD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAA;KACb;IACD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,QAA4B;IAChD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACpD,OAAO,KAAK,CAAA;KACb;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["/**\n * Returns whether an environment variable value represents a truthy value.\n */\nexport function isTruthy(variable: string | undefined): boolean {\n if (!variable) {\n return false\n }\n return ['1', 'true', 'TRUE', 'yes', 'YES'].includes(variable)\n}\n\n/**\n * Returns whether an environment variable has been set and is non-empty\n */\nexport function isSet(variable: string | undefined): boolean {\n if (variable === undefined || variable.trim() === '') {\n return false\n }\n return true\n}\n"]}
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/private/node/context/utilities.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA4B;IACnD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAA;KACb;IACD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,QAA4B;IAChD,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACpD,OAAO,KAAK,CAAA;KACb;IACD,OAAO,IAAI,CAAA;AACb,C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CAAC,iBAAiB;gBACrC,GAAG,EAAE,IAAI,CAAC,YAAY;gBACtB,GAAG,EAAE,IAAI,CAAC,cAAc;aACzB,CAAA;QACH;YACE,OAAO,EAAE,CAAA;KACZ;AACH,CAAC","sourcesContent":["/**\n * Returns whether an environment variable value represents a truthy value.\n */\nexport function isTruthy(variable: string | undefined): boolean {\n if (!variable) {\n return false\n }\n return ['1', 'true', 'TRUE', 'yes', 'YES'].includes(variable)\n}\n\n/**\n * Returns whether an environment variable has been set and is non-empty\n */\nexport function isSet(variable: string | undefined): boolean {\n if (variable === undefined || variable.trim() === '') {\n return false\n }\n return true\n}\n\n/**\n * Returns an object with environment variables from the specified CI environment.\n */\nexport function getCIMetadata(envName: string, envs: NodeJS.ProcessEnv): Metadata {\n switch (envName) {\n case 'bitbucket':\n return {\n actor: envs.BITBUCKET_COMMIT_AUTHOR,\n branch: envs.BITBUCKET_BRANCH,\n build: envs.BITBUCKET_BUILD_NUMBER,\n commitSha: envs.BITBUCKET_COMMIT,\n run: envs.BITBUCKET_BUILD_NUMBER,\n url: envs.BITBUCKET_BUILD_URL,\n }\n case 'circleci':\n return {\n actor: envs.CIRCLE_USERNAME,\n branch: envs.CIRCLE_BRANCH,\n build: envs.CIRCLE_BUILD_NUM,\n commitSha: envs.CIRCLE_SHA1,\n run: envs.CIRCLE_WORKFLOW_ID,\n url: envs.CIRCLE_BUILD_URL,\n }\n case 'github':\n return {\n actor: envs.GITHUB_ACTOR,\n branch: envs.GITHUB_REF_NAME,\n build: envs.GITHUB_RUN_ID,\n commitMessage: envs.GITHUB_COMMIT_MESSAGE,\n commitSha: envs.GITHUB_SHA,\n run: envs.GITHUB_RUN_ID,\n url: `${envs.GITHUB_SERVER_URL}${envs.GITHUB_REPOSITORY}/actions/runs/${envs.GITHUB_RUN_ID}`,\n }\n case 'gitlab':\n return {\n actor: envs.GITLAB_USER_LOGIN,\n branch: envs.CI_COMMIT_REF_NAME,\n build: envs.CI_PIPELINE_ID,\n commitSha: envs.CI_COMMIT_SHA,\n commitMessage: envs.CI_COMMIT_MESSAGE,\n run: envs.CI_RUNNER_ID,\n url: envs.CI_PROJECT_URL,\n }\n default:\n return {}\n }\n}\n\nexport interface Metadata {\n actor?: string\n branch?: string\n build?: string\n commitMessage?: string\n commitSha?: string\n run?: string\n url?: string\n}\n"]}
@@ -6,6 +6,7 @@ export interface TextPromptProps {
6
6
  password?: boolean;
7
7
  validate?: (value: string) => string | undefined;
8
8
  allowEmpty?: boolean;
9
+ emptyDisplayedValue?: string;
9
10
  }
10
11
  declare const TextPrompt: FunctionComponent<TextPromptProps>;
11
12
  export { TextPrompt };
@@ -6,7 +6,7 @@ import { messageWithPunctuation } from '../utilities.js';
6
6
  import React, { useCallback, useState } from 'react';
7
7
  import { Box, useApp, useInput, Text } from 'ink';
8
8
  import figures from 'figures';
9
- const TextPrompt = ({ message, onSubmit, validate, defaultValue = '', password = false, allowEmpty = false, }) => {
9
+ const TextPrompt = ({ message, onSubmit, validate, defaultValue = '', password = false, allowEmpty = false, emptyDisplayedValue = '(empty)', }) => {
10
10
  if (password && defaultValue) {
11
11
  throw new Error("Can't use defaultValue with password");
12
12
  }
@@ -21,6 +21,8 @@ const TextPrompt = ({ message, onSubmit, validate, defaultValue = '', password =
21
21
  const { oneThird } = useLayout();
22
22
  const [answer, setAnswer] = useState('');
23
23
  const answerOrDefault = answer.length > 0 ? answer : defaultValue;
24
+ const displayEmptyValue = answerOrDefault === '';
25
+ const displayedAnswer = displayEmptyValue ? emptyDisplayedValue : answerOrDefault;
24
26
  const { exit: unmountInk } = useApp();
25
27
  const [submitted, setSubmitted] = useState(false);
26
28
  const [error, setError] = useState(undefined);
@@ -48,7 +50,7 @@ const TextPrompt = ({ message, onSubmit, validate, defaultValue = '', password =
48
50
  React.createElement(Box, { marginRight: 2 },
49
51
  React.createElement(Text, { color: "cyan" }, figures.tick)),
50
52
  React.createElement(Box, { flexGrow: 1 },
51
- React.createElement(Text, { color: "cyan" }, password ? '*'.repeat(answer.length) : answerOrDefault)))) : (React.createElement(Box, { flexDirection: "column" },
53
+ React.createElement(Text, { color: "cyan", dimColor: displayEmptyValue }, password ? '*'.repeat(answer.length) : displayedAnswer)))) : (React.createElement(Box, { flexDirection: "column" },
52
54
  React.createElement(Box, null,
53
55
  React.createElement(Box, { marginRight: 2 },
54
56
  React.createElement(Text, { color: color }, `>`)),
@@ -1 +1 @@
1
- {"version":3,"file":"TextPrompt.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TextPrompt.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAC,sBAAsB,EAAC,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,EAAoB,WAAW,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AACrE,OAAO,EAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC/C,OAAO,OAAO,MAAM,SAAS,CAAA;AAW7B,MAAM,UAAU,GAAuC,CAAC,EACtD,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,YAAY,GAAG,EAAE,EACjB,QAAQ,GAAG,KAAK,EAChB,UAAU,GAAG,KAAK,GACnB,EAAE,EAAE;IACH,IAAI,QAAQ,IAAI,YAAY,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;KACxD;IAED,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,KAAa,EAAsB,EAAE;QACpC,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAA;SACvB;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO,+BA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K,IAAG,SAAS,CAAQ,CAClC;YACL,eAAe,CAAC,CAAC,CAAC,CACjB,oBAAC,GAAG,IAAC,UAAU,EAAE,CAAC;gBAChB,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,IAAG,KAAK,CAAQ,CAC9B,CACP,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CACG,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,UAAU,EAAC,CAAA","sourcesContent":["import {TextInput} from './TextInput.js'\nimport {TokenizedText} from './TokenizedText.js'\nimport {handleCtrlC} from '../../ui.js'\nimport useLayout from '../hooks/use-layout.js'\nimport {messageWithPunctuation} from '../utilities.js'\nimport React, {FunctionComponent, useCallback, useState} from 'react'\nimport {Box, useApp, useInput, Text} from 'ink'\nimport figures from 'figures'\n\nexport interface TextPromptProps {\n message: string\n onSubmit: (value: string) => void\n defaultValue?: string\n password?: boolean\n validate?: (value: string) => string | undefined\n allowEmpty?: boolean\n}\n\nconst TextPrompt: FunctionComponent<TextPromptProps> = ({\n message,\n onSubmit,\n validate,\n defaultValue = '',\n password = false,\n allowEmpty = false,\n}) => {\n if (password && defaultValue) {\n throw new Error(\"Can't use defaultValue with password\")\n }\n\n const validateAnswer = useCallback(\n (value: string): string | undefined => {\n if (validate) {\n return validate(value)\n }\n\n if (value.length === 0 && !allowEmpty) return 'Type an answer to the prompt.'\n\n return undefined\n },\n [allowEmpty, validate],\n )\n\n const {oneThird} = useLayout()\n const [answer, setAnswer] = useState<string>('')\n const answerOrDefault = answer.length > 0 ? answer : defaultValue\n const {exit: unmountInk} = useApp()\n const [submitted, setSubmitted] = useState(false)\n const [error, setError] = useState<string | undefined>(undefined)\n const shouldShowError = submitted && error\n const color = shouldShowError ? 'red' : 'cyan'\n const underline = new Array(oneThird - 3).fill('▔')\n\n useInput((input, key) => {\n handleCtrlC(input, key)\n\n if (key.return) {\n setSubmitted(true)\n const error = validateAnswer(answerOrDefault)\n setError(error)\n\n if (!error) {\n onSubmit(answerOrDefault)\n unmountInk()\n }\n }\n })\n\n return (\n <Box flexDirection=\"column\" marginBottom={1} width={oneThird}>\n <Box>\n <Box marginRight={2}>\n <Text>?</Text>\n </Box>\n <TokenizedText item={messageWithPunctuation(message)} />\n </Box>\n {submitted && !error ? (\n <Box>\n <Box marginRight={2}>\n <Text color=\"cyan\">{figures.tick}</Text>\n </Box>\n\n <Box flexGrow={1}>\n <Text color=\"cyan\">{password ? '*'.repeat(answer.length) : answerOrDefault}</Text>\n </Box>\n </Box>\n ) : (\n <Box flexDirection=\"column\">\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 setSubmitted(false)\n }}\n defaultValue={defaultValue}\n color={color}\n password={password}\n />\n </Box>\n </Box>\n <Box marginLeft={3}>\n <Text color={color}>{underline}</Text>\n </Box>\n {shouldShowError ? (\n <Box marginLeft={3}>\n <Text color={color}>{error}</Text>\n </Box>\n ) : null}\n </Box>\n )}\n </Box>\n )\n}\n\nexport {TextPrompt}\n"]}
1
+ {"version":3,"file":"TextPrompt.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TextPrompt.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,SAAS,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAC,sBAAsB,EAAC,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,EAAoB,WAAW,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AACrE,OAAO,EAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC/C,OAAO,OAAO,MAAM,SAAS,CAAA;AAY7B,MAAM,UAA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CAAC,CAAC,CAAC,CAAC,eAAe,CAClD,CACH,CACF,CACP,CAAC,CAAC,CAAC,CACF,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ;YACzB,oBAAC,GAAG;gBACF,oBAAC,GAAG,IAAC,WAAW,EAAE,CAAC;oBACjB,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,IAAG,GAAG,CAAQ,CAC5B;gBACN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC;oBACd,oBAAC,SAAS,IACR,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;4BACnB,SAAS,CAAC,MAAM,CAAC,CAAA;4BACjB,YAAY,CAAC,KAAK,CAAC,CAAA;wBACrB,CAAC,EACD,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,GAClB,CACE,CACF;YACN,oBAAC,GAAG,IAAC,UAAU,EAAE,CAAC;gBAChB,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,IAAG,SAAS,CAAQ,CAClC;YACL,eAAe,CAAC,CAAC,CAAC,CACjB,oBAAC,GAAG,IAAC,UAAU,EAAE,CAAC;gBAChB,oBAAC,IAAI,IAAC,KAAK,EAAE,KAAK,IAAG,KAAK,CAAQ,CAC9B,CACP,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CACG,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,UAAU,EAAC,CAAA","sourcesContent":["import {TextInput} from './TextInput.js'\nimport {TokenizedText} from './TokenizedText.js'\nimport {handleCtrlC} from '../../ui.js'\nimport useLayout from '../hooks/use-layout.js'\nimport {messageWithPunctuation} from '../utilities.js'\nimport React, {FunctionComponent, useCallback, useState} from 'react'\nimport {Box, useApp, useInput, Text} from 'ink'\nimport figures from 'figures'\n\nexport interface TextPromptProps {\n message: string\n onSubmit: (value: string) => void\n defaultValue?: string\n password?: boolean\n validate?: (value: string) => string | undefined\n allowEmpty?: boolean\n emptyDisplayedValue?: string\n}\n\nconst TextPrompt: FunctionComponent<TextPromptProps> = ({\n message,\n onSubmit,\n validate,\n defaultValue = '',\n password = false,\n allowEmpty = false,\n emptyDisplayedValue = '(empty)',\n}) => {\n if (password && defaultValue) {\n throw new Error(\"Can't use defaultValue with password\")\n }\n\n const validateAnswer = useCallback(\n (value: string): string | undefined => {\n if (validate) {\n return validate(value)\n }\n\n if (value.length === 0 && !allowEmpty) return 'Type an answer to the prompt.'\n\n return undefined\n },\n [allowEmpty, validate],\n )\n\n const {oneThird} = useLayout()\n const [answer, setAnswer] = useState<string>('')\n const answerOrDefault = answer.length > 0 ? answer : defaultValue\n const displayEmptyValue = answerOrDefault === ''\n const displayedAnswer = displayEmptyValue ? emptyDisplayedValue : answerOrDefault\n const {exit: unmountInk} = useApp()\n const [submitted, setSubmitted] = useState(false)\n const [error, setError] = useState<string | undefined>(undefined)\n const shouldShowError = submitted && error\n const color = shouldShowError ? 'red' : 'cyan'\n const underline = new Array(oneThird - 3).fill('▔')\n\n useInput((input, key) => {\n handleCtrlC(input, key)\n\n if (key.return) {\n setSubmitted(true)\n const error = validateAnswer(answerOrDefault)\n setError(error)\n\n if (!error) {\n onSubmit(answerOrDefault)\n unmountInk()\n }\n }\n })\n\n return (\n <Box flexDirection=\"column\" marginBottom={1} width={oneThird}>\n <Box>\n <Box marginRight={2}>\n <Text>?</Text>\n </Box>\n <TokenizedText item={messageWithPunctuation(message)} />\n </Box>\n {submitted && !error ? (\n <Box>\n <Box marginRight={2}>\n <Text color=\"cyan\">{figures.tick}</Text>\n </Box>\n\n <Box flexGrow={1}>\n <Text color=\"cyan\" dimColor={displayEmptyValue}>\n {password ? '*'.repeat(answer.length) : displayedAnswer}\n </Text>\n </Box>\n </Box>\n ) : (\n <Box flexDirection=\"column\">\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 setSubmitted(false)\n }}\n defaultValue={defaultValue}\n color={color}\n password={password}\n />\n </Box>\n </Box>\n <Box marginLeft={3}>\n <Text color={color}>{underline}</Text>\n </Box>\n {shouldShowError ? (\n <Box marginLeft={3}>\n <Text color={color}>{error}</Text>\n </Box>\n ) : null}\n </Box>\n )}\n </Box>\n )\n}\n\nexport {TextPrompt}\n"]}
@@ -74,6 +74,30 @@ describe('TextPrompt', () => {
74
74
  "
75
75
  `);
76
76
  });
77
+ test('display the empty value when no input is entered and there is no default value', async () => {
78
+ const onSubmit = vi.fn();
79
+ const renderInstance = render(React.createElement(TextPrompt, { onSubmit: onSubmit, message: "Test question", allowEmpty: true, emptyDisplayedValue: "empty" }));
80
+ await waitForInputsToBeReady();
81
+ await sendInputAndWaitForChange(renderInstance, ENTER);
82
+ expect(onSubmit).toHaveBeenCalledWith('');
83
+ expect(unstyled(getLastFrameAfterUnmount(renderInstance))).toMatchInlineSnapshot(`
84
+ "? Test question:
85
+ ✔ empty
86
+ "
87
+ `);
88
+ });
89
+ test("display the default value when allow empty is enabled but the user don't modify it", async () => {
90
+ const onSubmit = vi.fn();
91
+ const renderInstance = render(React.createElement(TextPrompt, { onSubmit: onSubmit, message: "Test question", allowEmpty: true, emptyDisplayedValue: "empty", defaultValue: "A" }));
92
+ await waitForInputsToBeReady();
93
+ await sendInputAndWaitForChange(renderInstance, ENTER);
94
+ expect(onSubmit).toHaveBeenCalledWith('A');
95
+ expect(unstyled(getLastFrameAfterUnmount(renderInstance))).toMatchInlineSnapshot(`
96
+ "? Test question:
97
+ ✔ A
98
+ "
99
+ `);
100
+ });
77
101
  test('text wrapping', async () => {
78
102
  // component width is 80 characters wide in tests but because of the question mark and
79
103
  // spaces before the question, we only have 77 characters to work with
@@ -1 +1 @@
1
- {"version":3,"file":"TextPrompt.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TextPrompt.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CA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AAE,OAAO,EAAC,eAAe,EAAC,QAAQ,SAAG,CAAC,CAAA;QAElG,MAAM,sBAAsB,EAAE,CAAA;QAC9B,MAAM,yBAAyB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;QACtD,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;KAKxD,CAAC,CAAA;QAEF,MAAM,yBAAyB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;QACtD,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,CAAE,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;KAIjF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,uEAAuE,EAAE,KAAK,IAAI,EAAE;QACvF,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,OAAO,EAAC,gBAAgB,GAAG,CAAC,CAAA;QAEvF,MAAM,CAAC,SAAS,EAAG,CAAC,CAAC,qBAAqB,CAAC;;;;;KAK1C,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,kEAAkE,EAAE,KAAK,IAAI,EAAE;QAClF,MAAM,cAAc,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,OAAO,EAAC,eAAe,EAAC,QAAQ,QAAC,YAAY,EAAC,GAAG,GAAG,CAAC,CAAA;QAEnH,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,CAAE,CAAC,CAAC,CAAC,SAAS,CAAC,6CAA6C,CAAC,CAAA;IACtH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {TextPrompt} from './TextPrompt.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'\n\ndescribe('TextPrompt', () => {\n test('default state', () => {\n const {lastFrame} = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" defaultValue=\"Placeholder\" />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"? Test question:\n > Placeholder\n ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n \"\n `)\n })\n\n test('default validation error', async () => {\n const renderInstance = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" />)\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 \u001b[31m>\u001b[39m \u001b[31m\u001b[7m \u001b[27m\u001b[39m\n \u001b[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \u001b[31mType an answer to the prompt.\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 \u001b[36m>\u001b[39m \u001b[36mA\u001b[7m \u001b[27m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test('custom validation error', async () => {\n const renderInstance = render(\n <TextPrompt\n onSubmit={() => {}}\n message=\"Test question\"\n validate={(value) => (value.includes('shopify') ? \"App name can't include the word shopify\" : undefined)}\n />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, 'this-test-includes-shopify')\n await sendInputAndWaitForChange(renderInstance, ENTER)\n // testing with styles because the color changes to red\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n \u001b[31m>\u001b[39m \u001b[31mthis-test-includes-shopify\u001b[7m \u001b[27m\u001b[39m\n \u001b[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \u001b[31mApp name can't include the word shopify\u001b[39m\n \"\n `)\n })\n\n test('submitting the value', async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(<TextPrompt onSubmit={onSubmit} message=\"Test question\" />)\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, 'A')\n await sendInputAndWaitForChange(renderInstance, ENTER)\n expect(onSubmit).toHaveBeenCalledWith('A')\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✔ A\n \"\n `)\n })\n\n test('submitting the default value', async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(<TextPrompt onSubmit={onSubmit} message=\"Test question\" defaultValue=\"A\" />)\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, ENTER)\n expect(onSubmit).toHaveBeenCalledWith('A')\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✔ A\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(<TextPrompt onSubmit={() => {}} message=\"Test question\" />)\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 \u001b[36m>\u001b[39m \u001b[36mAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\u001b[39m\n \u001b[36mBBBBBB\u001b[7m \u001b[27m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test(\"masking the input if it's a password\", async () => {\n const renderInstance = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" password />)\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, 'ABC')\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n \u001b[36m>\u001b[39m \u001b[36m***\u001b[7m \u001b[27m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n\n await sendInputAndWaitForChange(renderInstance, ENTER)\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✔ ***\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(<TextPrompt onSubmit={() => {}} message=\"Test question?\" />)\n\n expect(lastFrame()!).toMatchInlineSnapshot(`\n \"? Test question?\n \u001b[36m>\u001b[39m \u001b[36m\u001b[7m \u001b[27m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test(\"doesn't allow to pass defaultValue and password at the same time\", async () => {\n const renderInstance = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" password defaultValue=\"A\" />)\n\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toContain(\"ERROR Can't use defaultValue with password\")\n })\n})\n"]}
1
+ {"version":3,"file":"TextPrompt.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TextPrompt.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAA;AAC1C,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;AAElB,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;QACzB,MAAM,EAAC,SAAS,EAAC,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,QAAQ,EAAE,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AAE,GAAE,CAAC,EAAE,OAAO,EAAC,gBAAgB,GAAG,CAAC,CAAA;QAEvF,MAAM,CAAC,SAAS,EAAG,CAAC,CAAC,qBAAqB,CAAC;;;;;KAK1C,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,kEAAkE,EAAE,KAAK,IAAI,EAAE;QAClF,MAAM,cAAc,GAAG,MAAM,CAAC,oBAAC,UAAU,IAAC,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,OAAO,EAAC,eAAe,EAAC,QAAQ,QAAC,YAAY,EAAC,GAAG,GAAG,CAAC,CAAA;QAEnH,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAAC,cAAc,CAAE,CAAC,CAAC,CAAC,SAAS,CAAC,6CAA6C,CAAC,CAAA;IACtH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {TextPrompt} from './TextPrompt.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'\n\ndescribe('TextPrompt', () => {\n test('default state', () => {\n const {lastFrame} = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" defaultValue=\"Placeholder\" />)\n\n expect(unstyled(lastFrame()!)).toMatchInlineSnapshot(`\n \"? Test question:\n > Placeholder\n ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n \"\n `)\n })\n\n test('default validation error', async () => {\n const renderInstance = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" />)\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 \u001b[31m>\u001b[39m \u001b[31m\u001b[7m \u001b[27m\u001b[39m\n \u001b[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \u001b[31mType an answer to the prompt.\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 \u001b[36m>\u001b[39m \u001b[36mA\u001b[7m \u001b[27m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test('custom validation error', async () => {\n const renderInstance = render(\n <TextPrompt\n onSubmit={() => {}}\n message=\"Test question\"\n validate={(value) => (value.includes('shopify') ? \"App name can't include the word shopify\" : undefined)}\n />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, 'this-test-includes-shopify')\n await sendInputAndWaitForChange(renderInstance, ENTER)\n // testing with styles because the color changes to red\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n \u001b[31m>\u001b[39m \u001b[31mthis-test-includes-shopify\u001b[7m \u001b[27m\u001b[39m\n \u001b[31m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \u001b[31mApp name can't include the word shopify\u001b[39m\n \"\n `)\n })\n\n test('submitting the value', async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(<TextPrompt onSubmit={onSubmit} message=\"Test question\" />)\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, 'A')\n await sendInputAndWaitForChange(renderInstance, ENTER)\n expect(onSubmit).toHaveBeenCalledWith('A')\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✔ A\n \"\n `)\n })\n\n test('submitting the default value', async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(<TextPrompt onSubmit={onSubmit} message=\"Test question\" defaultValue=\"A\" />)\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, ENTER)\n expect(onSubmit).toHaveBeenCalledWith('A')\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✔ A\n \"\n `)\n })\n\n test('display the empty value when no input is entered and there is no default value', async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(\n <TextPrompt onSubmit={onSubmit} message=\"Test question\" allowEmpty emptyDisplayedValue=\"empty\" />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, ENTER)\n expect(onSubmit).toHaveBeenCalledWith('')\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✔ empty\n \"\n `)\n })\n\n test(\"display the default value when allow empty is enabled but the user don't modify it\", async () => {\n const onSubmit = vi.fn()\n const renderInstance = render(\n <TextPrompt\n onSubmit={onSubmit}\n message=\"Test question\"\n allowEmpty\n emptyDisplayedValue=\"empty\"\n defaultValue=\"A\"\n />,\n )\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, ENTER)\n expect(onSubmit).toHaveBeenCalledWith('A')\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✔ A\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(<TextPrompt onSubmit={() => {}} message=\"Test question\" />)\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 \u001b[36m>\u001b[39m \u001b[36mAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\u001b[39m\n \u001b[36mBBBBBB\u001b[7m \u001b[27m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test(\"masking the input if it's a password\", async () => {\n const renderInstance = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" password />)\n\n await waitForInputsToBeReady()\n await sendInputAndWaitForChange(renderInstance, 'ABC')\n expect(renderInstance.lastFrame()).toMatchInlineSnapshot(`\n \"? Test question:\n \u001b[36m>\u001b[39m \u001b[36m***\u001b[7m \u001b[27m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n\n await sendInputAndWaitForChange(renderInstance, ENTER)\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toMatchInlineSnapshot(`\n \"? Test question:\n ✔ ***\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(<TextPrompt onSubmit={() => {}} message=\"Test question?\" />)\n\n expect(lastFrame()!).toMatchInlineSnapshot(`\n \"? Test question?\n \u001b[36m>\u001b[39m \u001b[36m\u001b[7m \u001b[27m\u001b[39m\n \u001b[36m▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\u001b[39m\n \"\n `)\n })\n\n test(\"doesn't allow to pass defaultValue and password at the same time\", async () => {\n const renderInstance = render(<TextPrompt onSubmit={() => {}} message=\"Test question\" password defaultValue=\"A\" />)\n\n expect(unstyled(getLastFrameAfterUnmount(renderInstance)!)).toContain(\"ERROR Can't use defaultValue with password\")\n })\n})\n"]}
@@ -1 +1 @@
1
- export declare const CLI_KIT_VERSION = "3.46.0-pre.2";
1
+ export declare const CLI_KIT_VERSION = "3.46.0-pre.3";
@@ -1,2 +1,2 @@
1
- export const CLI_KIT_VERSION = '3.46.0-pre.2';
1
+ export const CLI_KIT_VERSION = '3.46.0-pre.3';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.46.0-pre.2'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.46.0-pre.3'\n"]}
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
+ import { Metadata } from '../../../private/node/context/utilities.js';
2
3
  /**
3
4
  * It returns true if the terminal is interactive.
4
5
  *
@@ -126,9 +127,11 @@ export declare function hasGit(): Promise<boolean>;
126
127
  export declare function ciPlatform(env?: NodeJS.ProcessEnv): {
127
128
  isCI: true;
128
129
  name: string;
130
+ metadata: Metadata;
129
131
  } | {
130
132
  isCI: false;
131
133
  name?: undefined;
134
+ metadata?: undefined;
132
135
  };
133
136
  /**
134
137
  * Returns the first mac address found.
@@ -136,3 +139,4 @@ export declare function ciPlatform(env?: NodeJS.ProcessEnv): {
136
139
  * @returns Mac address.
137
140
  */
138
141
  export declare function macAddress(): Promise<string>;
142
+ export type CIMetadata = Metadata;
@@ -1,5 +1,5 @@
1
1
  import { isSpin } from './spin.js';
2
- import { isTruthy, isSet } from '../../../private/node/context/utilities.js';
2
+ import { getCIMetadata, isTruthy, isSet } from '../../../private/node/context/utilities.js';
3
3
  import { environmentVariables, pathConstants } from '../../../private/node/constants.js';
4
4
  import { fileExists } from '../fs.js';
5
5
  import { exec } from '../system.js';
@@ -185,7 +185,10 @@ export async function hasGit() {
185
185
  export function ciPlatform(env = process.env) {
186
186
  if (isTruthy(env.CI)) {
187
187
  let name = 'unknown';
188
- if (isTruthy(env.CIRCLECI)) {
188
+ if (isSet(env.BITBUCKET_BUILD_NUMBER)) {
189
+ name = 'bitbucket';
190
+ }
191
+ else if (isTruthy(env.CIRCLECI)) {
189
192
  name = 'circleci';
190
193
  }
191
194
  else if (isSet(env.GITHUB_ACTION)) {
@@ -197,6 +200,7 @@ export function ciPlatform(env = process.env) {
197
200
  return {
198
201
  isCI: true,
199
202
  name,
203
+ metadata: getCIMetadata(name, env),
200
204
  };
201
205
  }
202
206
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AA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CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC1C,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACpB,IAAI,IAAI,GAAG,SAAS,CAAA;QACpB,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC1B,IAAI,GAAG,UAAU,CAAA;SAClB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACnC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;SACL,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {isSpin} from './spin.js'\nimport {isTruthy, isSet} from '../../../private/node/context/utilities.js'\nimport {environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n *\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n *\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_ENV is development.\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use device auth.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.\n */\nexport function useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_NO_THEME_BUNDLING is truthy.\n */\nexport function useThemebundling(env = process.env): boolean {\n return isTruthy(env[environmentVariables.themeBundling])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\nexport function codespaceURL(env = process.env): string | undefined {\n return env[environmentVariables.codespaceName]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns True in case the CLI is run from a cloud environment.\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns Cloud platform information.\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'cloudShell' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSet(env[environmentVariables.cloudShell])) {\n return {platform: 'cloudShell', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n *\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\n */\nexport function ciPlatform(env = process.env): {isCI: true; name: string} | {isCI: false; name?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n }\n\n return {\n isCI: true,\n name,\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found.\n *\n * @returns Mac address.\n */\nexport function macAddress(): Promise<string> {\n return macaddress.one()\n}\n"]}
1
+ {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAW,MAAM,4CAA4C,CAAA;AACnG,OAAO,EAAC,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACtF,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,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AAA;QACpB,IAAI,KAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC,EAAE;YACrC,IAAI,GAAG,WAAW,CAAA;SACnB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YACjC,IAAI,GAAG,UAAU,CAAA;SAClB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACnC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;YACJ,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC;SACnC,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {isSpin} from './spin.js'\nimport {getCIMetadata, isTruthy, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n *\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n *\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_ENV is development.\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use device auth.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.\n */\nexport function useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_NO_THEME_BUNDLING is truthy.\n */\nexport function useThemebundling(env = process.env): boolean {\n return isTruthy(env[environmentVariables.themeBundling])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\nexport function codespaceURL(env = process.env): string | undefined {\n return env[environmentVariables.codespaceName]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns True in case the CLI is run from a cloud environment.\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns Cloud platform information.\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'cloudShell' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSet(env[environmentVariables.cloudShell])) {\n return {platform: 'cloudShell', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n *\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\n */\nexport function ciPlatform(\n env = process.env,\n): {isCI: true; name: string; metadata: Metadata} | {isCI: false; name?: undefined; metadata?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isSet(env.BITBUCKET_BUILD_NUMBER)) {\n name = 'bitbucket'\n } else if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n }\n\n return {\n isCI: true,\n name,\n metadata: getCIMetadata(name, env),\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found.\n *\n * @returns Mac address.\n */\nexport function macAddress(): Promise<string> {\n return macaddress.one()\n}\n\nexport type CIMetadata = Metadata\n"]}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Returns the MIME type for a filename.
3
+ *
4
+ * @param fileName - Filename.
5
+ * @returns The mime type.
6
+ */
7
+ export declare function lookupMimeType(fileName: string): string;
8
+ /**
9
+ * Adds MIME type(s) to the dictionary.
10
+ *
11
+ * @param newTypes - Object of key-values where key is extension and value is mime type.
12
+ */
13
+ export declare function setMimeTypes(newTypes: {
14
+ [key: string]: string;
15
+ }): void;
@@ -0,0 +1,22 @@
1
+ // import * as mimeTypes from 'mrmime'
2
+ import { lookup, mimes } from 'mrmime';
3
+ /**
4
+ * Returns the MIME type for a filename.
5
+ *
6
+ * @param fileName - Filename.
7
+ * @returns The mime type.
8
+ */
9
+ export function lookupMimeType(fileName) {
10
+ return lookup(fileName) || 'application/octet-stream';
11
+ }
12
+ /**
13
+ * Adds MIME type(s) to the dictionary.
14
+ *
15
+ * @param newTypes - Object of key-values where key is extension and value is mime type.
16
+ */
17
+ export function setMimeTypes(newTypes) {
18
+ Object.entries(newTypes).forEach(([extension, mimeType]) => {
19
+ mimes[extension] = mimeType;
20
+ });
21
+ }
22
+ //# sourceMappingURL=mimes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mimes.js","sourceRoot":"","sources":["../../../src/public/node/mimes.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,QAAQ,CAAA;AAEpC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,0BAA0B,CAAA;AACvD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,QAAiC;IAC5D,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE;QACzD,KAAK,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAA;IAC7B,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["// import * as mimeTypes from 'mrmime'\nimport {lookup, mimes} from 'mrmime'\n\n/**\n * Returns the MIME type for a filename.\n *\n * @param fileName - Filename.\n * @returns The mime type.\n */\nexport function lookupMimeType(fileName: string): string {\n return lookup(fileName) || 'application/octet-stream'\n}\n\n/**\n * Adds MIME type(s) to the dictionary.\n *\n * @param newTypes - Object of key-values where key is extension and value is mime type.\n */\nexport function setMimeTypes(newTypes: {[key: string]: string}): void {\n Object.entries(newTypes).forEach(([extension, mimeType]) => {\n mimes[extension] = mimeType\n })\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
2
3
  import { AbortSignal } from './abort.js';
4
+ import { ReadStream } from 'tty';
3
5
  import type { Writable, Readable } from 'stream';
4
6
  export interface ExecOptions {
5
7
  cwd?: string;
@@ -43,8 +45,10 @@ export declare function exec(command: string, args: string[], options?: ExecOpti
43
45
  */
44
46
  export declare function sleep(seconds: number): Promise<void>;
45
47
  /**
46
- * Check if the current proccess is running from a terminal that supports raw mode entry.
48
+ * In case an standard input stream is passed check if it supports raw mode. Otherwise default standard input stream
49
+ * will be used.
47
50
  *
48
- * @returns True if the current proccess support raw mode entry.
51
+ * @param stdin - The standard input stream to check.
52
+ * @returns True in the selected input stream support raw mode.
49
53
  */
50
- export declare function terminalSupportsRawMode(): boolean;
54
+ export declare function terminalSupportsRawMode(stdin?: ReadStream): boolean;
@@ -107,11 +107,15 @@ export async function sleep(seconds) {
107
107
  });
108
108
  }
109
109
  /**
110
- * Check if the current proccess is running from a terminal that supports raw mode entry.
110
+ * In case an standard input stream is passed check if it supports raw mode. Otherwise default standard input stream
111
+ * will be used.
111
112
  *
112
- * @returns True if the current proccess support raw mode entry.
113
+ * @param stdin - The standard input stream to check.
114
+ * @returns True in the selected input stream support raw mode.
113
115
  */
114
- export function terminalSupportsRawMode() {
115
- return process.stdout.isTTY;
116
+ export function terminalSupportsRawMode(stdin) {
117
+ if (stdin)
118
+ return Boolean(stdin.isTTY);
119
+ return process.stdin.isTTY;
116
120
  }
117
121
  //# sourceMappingURL=system.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.js","sourceRoot":"","sources":["../../../src/public/node/system.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,YAAY,CAAA;AACpD,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,mBAAmB,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAC5E,OAAO,EAAC,KAAK,EAAoB,MAAM,OAAO,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GAAG,IAAI,GAAG,EAAE;CAC7C,CAAC,CAAA;IACA,OAAO,cAAc,CAAA;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAe;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAA;AAC7B,CAAC","sourcesContent":["import {AbortSignal} from './abort.js'\nimport {AbortError, ExternalError} from './error.js'\nimport {cwd} from './path.js'\nimport {shouldDisplayColors, outputDebug} from '../../public/node/output.js'\nimport {execa, ExecaChildProcess} from 'execa'\nimport treeKill from 'tree-kill'\nimport type {Writable, Readable} from 'stream'\n\nexport interface ExecOptions {\n cwd?: string\n env?: {[key: string]: string | undefined}\n stdin?: Readable | 'inherit'\n stdout?: Writable | 'inherit'\n stderr?: Writable | 'inherit'\n stdio?: 'inherit'\n input?: string\n signal?: AbortSignal\n}\n\n/**\n * Opens a URL in the user's default browser.\n *\n * @param url - URL to open.\n */\nexport async function openURL(url: string): Promise<void> {\n const externalOpen = await import('open')\n await externalOpen.default(url)\n}\n\n/**\n * Runs a command asynchronously, aggregates the stdout data, and returns it.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n * @returns A promise that resolves with the aggregatted stdout of the command.\n */\nexport async function captureOutput(command: string, args: string[], options?: ExecOptions): Promise<string> {\n const result = await buildExec(command, args, options)\n return result.stdout\n}\n\n/**\n * Runs a command asynchronously.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n */\nexport async function exec(command: string, args: string[], options?: ExecOptions): Promise<void> {\n const commandProcess = buildExec(command, args, options)\n if (options?.stderr && options.stderr !== 'inherit') {\n commandProcess.stderr?.pipe(options.stderr)\n }\n if (options?.stdout && options.stdout !== 'inherit') {\n commandProcess.stdout?.pipe(options.stdout)\n }\n let aborted = false\n options?.signal?.addEventListener('abort', () => {\n const pid = commandProcess.pid\n if (pid) {\n aborted = true\n treeKill(pid, (err) => {\n if (err) throw new AbortError(`Failed to kill process ${pid}: ${err}`)\n })\n }\n })\n try {\n await commandProcess\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n // Windows will throw an error whenever the process is killed, no matter the reason.\n // The aborted flag tell use that we killed it, so we can ignore the error.\n if (aborted) return\n const abortError = new ExternalError(processError.message, command, args)\n abortError.stack = processError.stack\n throw abortError\n }\n}\n\n/**\n * Runs a command asynchronously.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n * @returns A promise for a result with stdout and stderr properties.\n */\nfunction buildExec(command: string, args: string[], options?: ExecOptions): ExecaChildProcess<string> {\n const env = options?.env ?? process.env\n if (shouldDisplayColors()) {\n env.FORCE_COLOR = '1'\n }\n const commandProcess = execa(command, args, {\n env,\n cwd: options?.cwd,\n input: options?.input,\n stdio: options?.stdio,\n stdin: options?.stdin,\n stdout: options?.stdout === 'inherit' ? 'inherit' : undefined,\n stderr: options?.stderr === 'inherit' ? 'inherit' : undefined,\n // Setting this to false makes it possible to kill the main process\n // and all its sub-processes with Ctrl+C on Windows\n windowsHide: false,\n })\n outputDebug(`\nRunning system process:\n · Command: ${command} ${args.join(' ')}\n · Working directory: ${options?.cwd ?? cwd()}\n`)\n return commandProcess\n}\n\n/**\n * Waits for a given number of seconds.\n *\n * @param seconds - Number of seconds to wait.\n */\nexport async function sleep(seconds: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, 1000 * seconds)\n })\n}\n\n/**\n * Check if the current proccess is running from a terminal that supports raw mode entry.\n *\n * @returns True if the current proccess support raw mode entry.\n */\nexport function terminalSupportsRawMode(): boolean {\n return process.stdout.isTTY\n}\n"]}
1
+ {"version":3,"file":"system.js","sourceRoot":"","sources":["../../../src/public/node/system.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,YAAY,CAAA;AACpD,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAC7B,OAAO,EAAC,mBAAmB,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAC5E,OAAO,EAAC,KAAK,EAAoB,MAAM,OAAO,CAAA;AAC9C,OAAO,QAAQ,MAAM,WAAW,CAAA;AAehC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAA;IACzC,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AACjC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe,EAAE,IAAc,EAAE,OAAqB;IACxF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACtD,OAAO,MAAM,CAAC,MAAM,CAAA;AACtB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAAe,EAAE,IAAc,EAAE,OAAqB;IAC/E,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IACxD,IAAI,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;QACnD,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;KAC5C;IACD,IAAI,OAAO,EAAE,MAAM,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;QACnD,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CA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K,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC7D,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC7D,mEAAmE;QACnE,mDAAmD;QACnD,WAAW,EAAE,KAAK;KACnB,CAAC,CAAA;IACF,WAAW,CAAC;;eAEC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;yBACf,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE;CAC7C,CAAC,CAAA;IACA,OAAO,cAAc,CAAA;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAe;IACzC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAkB;IACxD,IAAI,KAAK;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACtC,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAA;AAC5B,CAAC","sourcesContent":["import {AbortSignal} from './abort.js'\nimport {AbortError, ExternalError} from './error.js'\nimport {cwd} from './path.js'\nimport {shouldDisplayColors, outputDebug} from '../../public/node/output.js'\nimport {execa, ExecaChildProcess} from 'execa'\nimport treeKill from 'tree-kill'\nimport {ReadStream} from 'tty'\nimport type {Writable, Readable} from 'stream'\n\nexport interface ExecOptions {\n cwd?: string\n env?: {[key: string]: string | undefined}\n stdin?: Readable | 'inherit'\n stdout?: Writable | 'inherit'\n stderr?: Writable | 'inherit'\n stdio?: 'inherit'\n input?: string\n signal?: AbortSignal\n}\n\n/**\n * Opens a URL in the user's default browser.\n *\n * @param url - URL to open.\n */\nexport async function openURL(url: string): Promise<void> {\n const externalOpen = await import('open')\n await externalOpen.default(url)\n}\n\n/**\n * Runs a command asynchronously, aggregates the stdout data, and returns it.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n * @returns A promise that resolves with the aggregatted stdout of the command.\n */\nexport async function captureOutput(command: string, args: string[], options?: ExecOptions): Promise<string> {\n const result = await buildExec(command, args, options)\n return result.stdout\n}\n\n/**\n * Runs a command asynchronously.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n */\nexport async function exec(command: string, args: string[], options?: ExecOptions): Promise<void> {\n const commandProcess = buildExec(command, args, options)\n if (options?.stderr && options.stderr !== 'inherit') {\n commandProcess.stderr?.pipe(options.stderr)\n }\n if (options?.stdout && options.stdout !== 'inherit') {\n commandProcess.stdout?.pipe(options.stdout)\n }\n let aborted = false\n options?.signal?.addEventListener('abort', () => {\n const pid = commandProcess.pid\n if (pid) {\n aborted = true\n treeKill(pid, (err) => {\n if (err) throw new AbortError(`Failed to kill process ${pid}: ${err}`)\n })\n }\n })\n try {\n await commandProcess\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n // Windows will throw an error whenever the process is killed, no matter the reason.\n // The aborted flag tell use that we killed it, so we can ignore the error.\n if (aborted) return\n const abortError = new ExternalError(processError.message, command, args)\n abortError.stack = processError.stack\n throw abortError\n }\n}\n\n/**\n * Runs a command asynchronously.\n *\n * @param command - Command to be executed.\n * @param args - Arguments to pass to the command.\n * @param options - Optional settings for how to run the command.\n * @returns A promise for a result with stdout and stderr properties.\n */\nfunction buildExec(command: string, args: string[], options?: ExecOptions): ExecaChildProcess<string> {\n const env = options?.env ?? process.env\n if (shouldDisplayColors()) {\n env.FORCE_COLOR = '1'\n }\n const commandProcess = execa(command, args, {\n env,\n cwd: options?.cwd,\n input: options?.input,\n stdio: options?.stdio,\n stdin: options?.stdin,\n stdout: options?.stdout === 'inherit' ? 'inherit' : undefined,\n stderr: options?.stderr === 'inherit' ? 'inherit' : undefined,\n // Setting this to false makes it possible to kill the main process\n // and all its sub-processes with Ctrl+C on Windows\n windowsHide: false,\n })\n outputDebug(`\nRunning system process:\n · Command: ${command} ${args.join(' ')}\n · Working directory: ${options?.cwd ?? cwd()}\n`)\n return commandProcess\n}\n\n/**\n * Waits for a given number of seconds.\n *\n * @param seconds - Number of seconds to wait.\n */\nexport async function sleep(seconds: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, 1000 * seconds)\n })\n}\n\n/**\n * In case an standard input stream is passed check if it supports raw mode. Otherwise default standard input stream\n * will be used.\n *\n * @param stdin - The standard input stream to check.\n * @returns True in the selected input stream support raw mode.\n */\nexport function terminalSupportsRawMode(stdin?: ReadStream): boolean {\n if (stdin) return Boolean(stdin.isTTY)\n return process.stdin.isTTY\n}\n"]}
@@ -32,7 +32,7 @@ export interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps
32
32
  * Preview URL: https://shopify.com
33
33
  *
34
34
  */
35
- export declare function renderConcurrent({ renderOptions, ...props }: RenderConcurrentOptions): Promise<void>;
35
+ export declare function renderConcurrent({ renderOptions, ...props }: RenderConcurrentOptions): Promise<void | void[]>;
36
36
  export type AlertCustomSection = CustomSection;
37
37
  export type RenderAlertOptions = Omit<AlertOptions, 'type'>;
38
38
  /**
@@ -3,6 +3,7 @@ import { AbortSilentError } from './error.js';
3
3
  import { collectLog, consoleError, consoleLog, outputDebug, outputWhereAppropriate } from './output.js';
4
4
  import { isUnitTest } from './context/local.js';
5
5
  import { AbortController } from './abort.js';
6
+ import { terminalSupportsRawMode } from './system.js';
6
7
  import { ConcurrentOutput } from '../../private/node/ui/components/ConcurrentOutput.js';
7
8
  import { render, renderOnce } from '../../private/node/ui.js';
8
9
  import { alert } from '../../private/node/ui/alert.js';
@@ -34,10 +35,17 @@ export async function renderConcurrent({ renderOptions, ...props }) {
34
35
  abortController: new AbortController(),
35
36
  ...props,
36
37
  };
37
- return render(React.createElement(ConcurrentOutput, { ...newProps }), {
38
- ...renderOptions,
39
- exitOnCtrlC: typeof props.onInput === 'undefined',
40
- });
38
+ if (terminalSupportsRawMode(renderOptions?.stdin)) {
39
+ return render(React.createElement(ConcurrentOutput, { ...newProps }), {
40
+ ...renderOptions,
41
+ exitOnCtrlC: typeof props.onInput === 'undefined',
42
+ });
43
+ }
44
+ else {
45
+ return Promise.all(newProps.processes.map(async (concurrentProcess) => {
46
+ await concurrentProcess.action(process.stdout, process.stderr, newProps.abortController.signal);
47
+ }));
48
+ }
41
49
  }
42
50
  /**
43
51
  * Renders an information banner to the console.