@shopify/cli-kit 3.23.0 → 3.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +1 -1
  3. package/dist/api/graphql/functions/app_function_set.d.ts +1 -0
  4. package/dist/api/graphql/functions/app_function_set.js +2 -0
  5. package/dist/api/graphql/functions/app_function_set.js.map +1 -1
  6. package/dist/error.d.ts +9 -7
  7. package/dist/error.js +5 -4
  8. package/dist/error.js.map +1 -1
  9. package/dist/index.d.ts +0 -1
  10. package/dist/index.js +0 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/output.d.ts +1 -0
  13. package/dist/output.js +2 -15
  14. package/dist/output.js.map +1 -1
  15. package/dist/path.d.ts +0 -1
  16. package/dist/plugins.d.ts +3 -3
  17. package/dist/plugins.js +1 -1
  18. package/dist/plugins.js.map +1 -1
  19. package/dist/private/node/ui/components/Alert.d.ts +5 -5
  20. package/dist/private/node/ui/components/Alert.js +3 -3
  21. package/dist/private/node/ui/components/Alert.js.map +1 -1
  22. package/dist/private/node/ui/components/Alert.test.d.ts +1 -0
  23. package/dist/private/node/ui/components/Alert.test.js +95 -0
  24. package/dist/private/node/ui/components/Alert.test.js.map +1 -0
  25. package/dist/private/node/ui/components/Banner.d.ts +1 -0
  26. package/dist/private/node/ui/components/Banner.js +12 -13
  27. package/dist/private/node/ui/components/Banner.js.map +1 -1
  28. package/dist/private/node/ui/components/Banner.test.d.ts +1 -0
  29. package/dist/private/node/ui/components/Banner.test.js +52 -0
  30. package/dist/private/node/ui/components/Banner.test.js.map +1 -0
  31. package/dist/private/node/ui/components/Command.test.d.ts +1 -0
  32. package/dist/private/node/ui/components/Command.test.js +11 -0
  33. package/dist/private/node/ui/components/Command.test.js.map +1 -0
  34. package/dist/private/node/ui/components/ConcurrentOutput.js +11 -17
  35. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  36. package/dist/private/node/ui/components/FatalError.js +5 -2
  37. package/dist/private/node/ui/components/FatalError.js.map +1 -1
  38. package/dist/private/node/ui/components/FatalError.test.d.ts +1 -0
  39. package/dist/private/node/ui/components/FatalError.test.js +119 -0
  40. package/dist/private/node/ui/components/FatalError.test.js.map +1 -0
  41. package/dist/private/node/ui/components/FilePath.d.ts +9 -0
  42. package/dist/private/node/ui/components/FilePath.js +13 -0
  43. package/dist/private/node/ui/components/FilePath.js.map +1 -0
  44. package/dist/private/node/ui/components/FilePath.test.d.ts +1 -0
  45. package/dist/private/node/ui/components/FilePath.test.js +11 -0
  46. package/dist/private/node/ui/components/FilePath.test.js.map +1 -0
  47. package/dist/private/node/ui/components/Link.js +6 -5
  48. package/dist/private/node/ui/components/Link.js.map +1 -1
  49. package/dist/private/node/ui/components/Link.test.d.ts +1 -0
  50. package/dist/private/node/ui/components/Link.test.js +22 -0
  51. package/dist/private/node/ui/components/Link.test.js.map +1 -0
  52. package/dist/private/node/ui/components/List.d.ts +3 -3
  53. package/dist/private/node/ui/components/List.js +2 -2
  54. package/dist/private/node/ui/components/List.js.map +1 -1
  55. package/dist/private/node/ui/components/List.test.d.ts +1 -0
  56. package/dist/private/node/ui/components/List.test.js +34 -0
  57. package/dist/private/node/ui/components/List.test.js.map +1 -0
  58. package/dist/private/node/ui/components/TokenizedText.d.ts +18 -3
  59. package/dist/private/node/ui/components/TokenizedText.js +49 -5
  60. package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
  61. package/dist/private/node/ui/components/TokenizedText.test.d.ts +1 -0
  62. package/dist/private/node/ui/components/TokenizedText.test.js +44 -0
  63. package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -0
  64. package/dist/private/node/ui/components/UserInput.d.ts +10 -0
  65. package/dist/private/node/ui/components/UserInput.js +11 -0
  66. package/dist/private/node/ui/components/UserInput.js.map +1 -0
  67. package/dist/private/node/ui/components/UserInput.test.d.ts +1 -0
  68. package/dist/private/node/ui/components/UserInput.test.js +11 -0
  69. package/dist/private/node/ui/components/UserInput.test.js.map +1 -0
  70. package/dist/private/node/ui/error.d.ts +0 -2
  71. package/dist/private/node/ui/error.js +0 -4
  72. package/dist/private/node/ui/error.js.map +1 -1
  73. package/dist/private/node/ui.d.ts +2 -1
  74. package/dist/private/node/ui.js +3 -2
  75. package/dist/private/node/ui.js.map +1 -1
  76. package/dist/public/common/string.d.ts +4 -2
  77. package/dist/public/common/string.js +54 -5
  78. package/dist/public/common/string.js.map +1 -1
  79. package/dist/public/node/fs.d.ts +3 -0
  80. package/dist/public/node/fs.js +2 -2
  81. package/dist/public/node/fs.js.map +1 -1
  82. package/dist/public/node/github.d.ts +50 -0
  83. package/dist/{github.js → public/node/github.js} +29 -14
  84. package/dist/public/node/github.js.map +1 -0
  85. package/dist/public/node/node-package-manager.d.ts +4 -1
  86. package/dist/public/node/node-package-manager.js +3 -1
  87. package/dist/public/node/node-package-manager.js.map +1 -1
  88. package/dist/public/node/plugins/tunnel.d.ts +1 -1
  89. package/dist/public/node/plugins/tunnel.js +1 -1
  90. package/dist/public/node/plugins/tunnel.js.map +1 -1
  91. package/dist/public/{common → node}/result.d.ts +12 -6
  92. package/dist/public/{common → node}/result.js +28 -5
  93. package/dist/public/node/result.js.map +1 -0
  94. package/dist/public/node/ui.d.ts +3 -16
  95. package/dist/public/node/ui.js +3 -20
  96. package/dist/public/node/ui.js.map +1 -1
  97. package/dist/session/exchange.d.ts +1 -1
  98. package/dist/session/exchange.js +4 -4
  99. package/dist/session/exchange.js.map +1 -1
  100. package/dist/tsconfig.tsbuildinfo +1 -1
  101. package/dist/ui.d.ts +13 -2
  102. package/dist/ui.js.map +1 -1
  103. package/dist/version.d.ts +0 -1
  104. package/package.json +56 -55
  105. package/dist/github.d.ts +0 -33
  106. package/dist/github.js.map +0 -1
  107. package/dist/private/node/ui/components/Error.d.ts +0 -8
  108. package/dist/private/node/ui/components/Error.js +0 -13
  109. package/dist/private/node/ui/components/Error.js.map +0 -1
  110. package/dist/public/common/result.js.map +0 -1
@@ -0,0 +1,22 @@
1
+ import { Link } from './Link.js';
2
+ import { renderString } from '../../ui.js';
3
+ import { describe, expect, test } from 'vitest';
4
+ import React from 'react';
5
+ describe('Link', async () => {
6
+ test("renders correctly with a fallback for terminals that don't support hyperlinks", async () => {
7
+ const link = {
8
+ url: 'https://example.com',
9
+ label: 'Example',
10
+ };
11
+ const { output } = renderString(React.createElement(Link, { ...link }));
12
+ expect(output).toMatchInlineSnapshot('"Example (https://example.com)"');
13
+ });
14
+ test("it doesn't render a fallback if only url is passed", async () => {
15
+ const link = {
16
+ url: 'https://example.com',
17
+ };
18
+ const { output } = renderString(React.createElement(Link, { ...link }));
19
+ expect(output).toMatchInlineSnapshot('"https://example.com"');
20
+ });
21
+ });
22
+ //# sourceMappingURL=Link.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Link.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAA;AACxC,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,QAAQ,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;IAC1B,IAAI,CAAC,+EAA+E,EAAE,KAAK,IAAI,EAAE;QAC/F,MAAM,IAAI,GAAG;YACX,GAAG,EAAE,qBAAqB;YAC1B,KAAK,EAAE,SAAS;SACjB,CAAA;QAED,MAAM,EAAC,MAAM,EAAC,GAAG,YAAY,CAAC,oBAAC,IAAI,OAAK,IAAI,GAAI,CAAC,CAAA;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,0CAA0C,CAAC,CAAA;IAClF,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;QACpE,MAAM,IAAI,GAAG;YACX,GAAG,EAAE,qBAAqB;SAC3B,CAAA;QAED,MAAM,EAAC,MAAM,EAAC,GAAG,YAAY,CAAC,oBAAC,IAAI,OAAK,IAAI,GAAI,CAAC,CAAA;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,uBAAuB,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {Link} from './Link.js'\nimport {renderString} from '../../ui.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\n\ndescribe('Link', async () => {\n test(\"renders correctly with a fallback for terminals that don't support hyperlinks\", async () => {\n const link = {\n url: 'https://example.com',\n label: 'Example',\n }\n\n const {output} = renderString(<Link {...link} />)\n\n expect(output).toMatchInlineSnapshot('\"Example \u001b[2m(https://example.com)\u001b[22m\"')\n })\n\n test(\"it doesn't render a fallback if only url is passed\", async () => {\n const link = {\n url: 'https://example.com',\n }\n\n const {output} = renderString(<Link {...link} />)\n\n expect(output).toMatchInlineSnapshot('\"https://example.com\"')\n })\n})\n"]}
@@ -1,8 +1,8 @@
1
- import { TextTokenItem } from './TokenizedText.js';
1
+ import { TokenItem } from './TokenizedText.js';
2
2
  import React from 'react';
3
3
  interface Props {
4
- title: string;
5
- items: TextTokenItem[];
4
+ title?: string;
5
+ items: TokenItem[];
6
6
  ordered?: boolean;
7
7
  }
8
8
  /**
@@ -8,10 +8,10 @@ const DOT = '•';
8
8
  */
9
9
  const List = ({ title, items, ordered = false }) => {
10
10
  return (React.createElement(Box, { flexDirection: "column" },
11
- React.createElement(Text, { dimColor: true }, title),
11
+ title && React.createElement(Text, { bold: true }, title),
12
12
  items.map((item, index) => (React.createElement(Box, { key: index },
13
13
  React.createElement(Box, null,
14
- React.createElement(Text, { dimColor: true }, ` ${ordered ? `${index + 1}.` : DOT}`)),
14
+ React.createElement(Text, null, ` ${ordered ? `${index + 1}.` : DOT}`)),
15
15
  React.createElement(Box, { flexGrow: 1, marginLeft: 1 },
16
16
  React.createElement(TokenizedText, { item: item })))))));
17
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/List.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,MAAM,GAAG,GAAG,GAAG,CAAA;AAEf;;;GAGG;AACH,MAAM,IAAI,GAAoB,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,EAAiC,EAAe,EAAE;IAC7G,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ;QACzB,oBAAC,IAAI,IAAC,QAAQ,UAAE,KAAK,CAAQ;QAC5B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1B,oBAAC,GAAG,IAAC,GAAG,EAAE,KAAK;YACb,oBAAC,GAAG;gBACF,oBAAC,IAAI,IAAC,QAAQ,UAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAQ,CAC1D;YAEN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;gBAC7B,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CACzB,CACF,CACP,CAAC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,IAAI,EAAC,CAAA","sourcesContent":["import {TextTokenItem, TokenizedText} from './TokenizedText.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\ninterface Props {\n title: string\n items: TextTokenItem[]\n ordered?: boolean\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: React.FC<Props> = ({title, items, ordered = false}: React.PropsWithChildren<Props>): JSX.Element => {\n return (\n <Box flexDirection=\"column\">\n <Text dimColor>{title}</Text>\n {items.map((item, index) => (\n <Box key={index}>\n <Box>\n <Text dimColor>{` ${ordered ? `${index + 1}.` : DOT}`}</Text>\n </Box>\n\n <Box flexGrow={1} marginLeft={1}>\n <TokenizedText item={item} />\n </Box>\n </Box>\n ))}\n </Box>\n )\n}\n\nexport {List}\n"]}
1
+ {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/List.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,MAAM,GAAG,GAAG,GAAG,CAAA;AAEf;;;GAGG;AACH,MAAM,IAAI,GAAoB,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,EAAC,EAAe,EAAE;IAC7E,OAAO,CACL,oBAAC,GAAG,IAAC,aAAa,EAAC,QAAQ;QACxB,KAAK,IAAI,oBAAC,IAAI,IAAC,IAAI,UAAE,KAAK,CAAQ;QAClC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1B,oBAAC,GAAG,IAAC,GAAG,EAAE,KAAK;YACb,oBAAC,GAAG;gBACF,oBAAC,IAAI,QAAE,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAQ,CACjD;YAEN,oBAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;gBAC7B,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CACzB,CACF,CACP,CAAC,CACE,CACP,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAC,IAAI,EAAC,CAAA","sourcesContent":["import {TokenItem, TokenizedText} from './TokenizedText.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\ninterface Props {\n title?: string\n items: TokenItem[]\n ordered?: boolean\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: React.FC<Props> = ({title, items, ordered = false}): JSX.Element => {\n return (\n <Box flexDirection=\"column\">\n {title && <Text bold>{title}</Text>}\n {items.map((item, index) => (\n <Box key={index}>\n <Box>\n <Text>{` ${ordered ? `${index + 1}.` : DOT}`}</Text>\n </Box>\n\n <Box flexGrow={1} marginLeft={1}>\n <TokenizedText item={item} />\n </Box>\n </Box>\n ))}\n </Box>\n )\n}\n\nexport {List}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import { List } from './List.js';
2
+ import { renderString } from '../../ui.js';
3
+ import { unstyled } from '../../../../output.js';
4
+ import { describe, expect, test } from 'vitest';
5
+ import React from 'react';
6
+ describe('List', async () => {
7
+ test('renders unordered items', async () => {
8
+ const options = {
9
+ title: 'List title',
10
+ items: ['Item 1', 'Item 2', 'Item 3'],
11
+ ordered: false,
12
+ };
13
+ const { output } = renderString(React.createElement(List, { ...options }));
14
+ expect(unstyled(output)).toMatchInlineSnapshot(`
15
+ "List title
16
+ • Item 1
17
+ • Item 2
18
+ • Item 3"
19
+ `);
20
+ });
21
+ test('renders ordered items', async () => {
22
+ const options = {
23
+ items: ['Item 1', 'Item 2', 'Item 3'],
24
+ ordered: true,
25
+ };
26
+ const { output } = renderString(React.createElement(List, { ...options }));
27
+ expect(unstyled(output)).toMatchInlineSnapshot(`
28
+ " 1. Item 1
29
+ 2. Item 2
30
+ 3. Item 3"
31
+ `);
32
+ });
33
+ });
34
+ //# sourceMappingURL=List.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"List.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/List.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAA;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,QAAQ,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;IAC1B,IAAI,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,OAAO,GAAG;YACd,KAAK,EAAE,YAAY;YACnB,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;YACrC,OAAO,EAAE,KAAK;SACf,CAAA;QAED,MAAM,EAAC,MAAM,EAAC,GAAG,YAAY,CAAC,oBAAC,IAAI,OAAK,OAAO,GAAI,CAAC,CAAA;QAEpD,MAAM,CAAC,QAAQ,CAAC,MAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;KAK/C,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,uBAAuB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,OAAO,GAAG;YACd,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;YACrC,OAAO,EAAE,IAAI;SACd,CAAA;QAED,MAAM,EAAC,MAAM,EAAC,GAAG,YAAY,CAAC,oBAAC,IAAI,OAAK,OAAO,GAAI,CAAC,CAAA;QAEpD,MAAM,CAAC,QAAQ,CAAC,MAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;KAI/C,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {List} from './List.js'\nimport {renderString} from '../../ui.js'\nimport {unstyled} from '../../../../output.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\n\ndescribe('List', async () => {\n test('renders unordered items', async () => {\n const options = {\n title: 'List title',\n items: ['Item 1', 'Item 2', 'Item 3'],\n ordered: false,\n }\n\n const {output} = renderString(<List {...options} />)\n\n expect(unstyled(output!)).toMatchInlineSnapshot(`\n \"List title\n • Item 1\n • Item 2\n • Item 3\"\n `)\n })\n\n test('renders ordered items', async () => {\n const options = {\n items: ['Item 1', 'Item 2', 'Item 3'],\n ordered: true,\n }\n\n const {output} = renderString(<List {...options} />)\n\n expect(unstyled(output!)).toMatchInlineSnapshot(`\n \" 1. Item 1\n 2. Item 2\n 3. Item 3\"\n `)\n })\n})\n"]}
@@ -8,10 +8,25 @@ interface LinkToken {
8
8
  url: string;
9
9
  };
10
10
  }
11
- export declare type TextToken = string | CommandToken | LinkToken;
12
- export declare type TextTokenItem = TextToken | TextToken[];
11
+ interface CharToken {
12
+ char: string;
13
+ }
14
+ interface UserInputToken {
15
+ userInput: string;
16
+ }
17
+ interface FilePathToken {
18
+ filePath: string;
19
+ }
20
+ interface ListToken {
21
+ list: {
22
+ items: TokenItem[];
23
+ ordered?: boolean;
24
+ };
25
+ }
26
+ declare type Token = string | CommandToken | LinkToken | CharToken | UserInputToken | FilePathToken | ListToken;
27
+ export declare type TokenItem = Token | Token[];
13
28
  interface Props {
14
- item: TextToken | TextToken[];
29
+ item: TokenItem;
15
30
  }
16
31
  /**
17
32
  * `TokenizedText` renders a text string with tokens that can be either strings,
@@ -1,14 +1,38 @@
1
1
  import { Command } from './Command.js';
2
2
  import { Link } from './Link.js';
3
- import { Text } from 'ink';
3
+ import { List } from './List.js';
4
+ import { UserInput } from './UserInput.js';
5
+ import { FilePath } from './FilePath.js';
6
+ import { Box, Text } from 'ink';
4
7
  import React from 'react';
8
+ function tokenToBlock(token) {
9
+ return {
10
+ display: typeof token !== 'string' && 'list' in token ? 'block' : 'inline',
11
+ value: token,
12
+ };
13
+ }
14
+ function splitByDisplayType(acc, item) {
15
+ if (item.display === 'block') {
16
+ acc.push([item]);
17
+ }
18
+ else {
19
+ const last = acc[acc.length - 1];
20
+ if (last && last[0].display === 'inline') {
21
+ last.push(item);
22
+ }
23
+ else {
24
+ acc.push([item]);
25
+ }
26
+ }
27
+ return acc;
28
+ }
5
29
  /**
6
30
  * `TokenizedText` renders a text string with tokens that can be either strings,
7
31
  * links, and commands.
8
32
  */
9
33
  const TokenizedText = ({ item }) => {
10
34
  if (typeof item === 'string') {
11
- return React.createElement(Text, { dimColor: true }, item);
35
+ return React.createElement(Text, null, item);
12
36
  }
13
37
  else if ('command' in item) {
14
38
  return React.createElement(Command, { command: item.command });
@@ -16,10 +40,30 @@ const TokenizedText = ({ item }) => {
16
40
  else if ('link' in item) {
17
41
  return React.createElement(Link, { ...item.link });
18
42
  }
43
+ else if ('char' in item) {
44
+ return React.createElement(Text, null, item.char[0]);
45
+ }
46
+ else if ('userInput' in item) {
47
+ return React.createElement(UserInput, { userInput: item.userInput });
48
+ }
49
+ else if ('filePath' in item) {
50
+ return React.createElement(FilePath, { filePath: item.filePath });
51
+ }
52
+ else if ('list' in item) {
53
+ return React.createElement(List, { ...item.list });
54
+ }
19
55
  else {
20
- return (React.createElement(Text, null, item.map((listItem, index) => (React.createElement(Text, { key: index },
21
- React.createElement(TokenizedText, { item: listItem }),
22
- index < item.length - 1 && React.createElement(Text, null, " "))))));
56
+ const groupedItems = item.map(tokenToBlock).reduce(splitByDisplayType, []);
57
+ return (React.createElement(Box, { flexDirection: "column" }, groupedItems.map((items, groupIndex) => {
58
+ if (items[0].display === 'inline') {
59
+ return (React.createElement(Text, { key: groupIndex }, items.map((item, itemIndex) => (React.createElement(Text, { key: itemIndex },
60
+ itemIndex !== 0 && !(typeof item.value !== 'string' && 'char' in item.value) && React.createElement(Text, null, " "),
61
+ React.createElement(TokenizedText, { item: item.value }))))));
62
+ }
63
+ else {
64
+ return React.createElement(List, { key: groupIndex, items: items[0].value.list.items });
65
+ }
66
+ })));
23
67
  }
24
68
  };
25
69
  export { TokenizedText };
@@ -1 +1 @@
1
- {"version":3,"file":"TokenizedText.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TokenizedText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AACpC,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAoBzB;;;GAGG;AACH,MAAM,aAAa,GAAoB,CAAC,EAAC,IAAI,EAAC,EAAE,EAAE;IAChD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,OAAO,oBAAC,IAAI,IAAC,QAAQ,UAAE,IAAI,CAAQ,CAAA;KACpC;SAAM,IAAI,SAAS,IAAI,IAAI,EAAE;QAC5B,OAAO,oBAAC,OAAO,IAAC,OAAO,EAAE,IAAI,CAAC,OAAO,GAAI,CAAA;KAC1C;SAAM,IAAI,MAAM,IAAI,IAAI,EAAE;QACzB,OAAO,oBAAC,IAAI,OAAK,IAAI,CAAC,IAAI,GAAI,CAAA;KAC/B;SAAM;QACL,OAAO,CACL,oBAAC,IAAI,QACF,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CAC7B,oBAAC,IAAI,IAAC,GAAG,EAAE,KAAK;YACd,oBAAC,aAAa,IAAC,IAAI,EAAE,QAAQ,GAAI;YAChC,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,oBAAC,IAAI,YAAS,CACrC,CACR,CAAC,CACG,CACR,CAAA;KACF;AACH,CAAC,CAAA;AAED,OAAO,EAAC,aAAa,EAAC,CAAA","sourcesContent":["import {Command} from './Command.js'\nimport {Link} from './Link.js'\nimport {Text} from 'ink'\nimport React from 'react'\n\ninterface CommandToken {\n command: string\n}\n\ninterface LinkToken {\n link: {\n label?: string\n url: string\n }\n}\n\nexport type TextToken = string | CommandToken | LinkToken\nexport type TextTokenItem = TextToken | TextToken[]\n\ninterface Props {\n item: TextToken | TextToken[]\n}\n\n/**\n * `TokenizedText` renders a text string with tokens that can be either strings,\n * links, and commands.\n */\nconst TokenizedText: React.FC<Props> = ({item}) => {\n if (typeof item === 'string') {\n return <Text dimColor>{item}</Text>\n } else if ('command' in item) {\n return <Command command={item.command} />\n } else if ('link' in item) {\n return <Link {...item.link} />\n } else {\n return (\n <Text>\n {item.map((listItem, index) => (\n <Text key={index}>\n <TokenizedText item={listItem} />\n {index < item.length - 1 && <Text> </Text>}\n </Text>\n ))}\n </Text>\n )\n }\n}\n\nexport {TokenizedText}\n"]}
1
+ {"version":3,"file":"TokenizedText.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TokenizedText.tsx"],"names":[],"mappings":"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","sourcesContent":["import {Command} from './Command.js'\nimport {Link} from './Link.js'\nimport {List} from './List.js'\nimport {UserInput} from './UserInput.js'\nimport {FilePath} from './FilePath.js'\nimport {Box, Text} from 'ink'\nimport React from 'react'\n\ninterface CommandToken {\n command: string\n}\n\ninterface LinkToken {\n link: {\n label?: string\n url: string\n }\n}\n\ninterface CharToken {\n char: string\n}\n\ninterface UserInputToken {\n userInput: string\n}\n\ninterface FilePathToken {\n filePath: string\n}\n\ninterface ListToken {\n list: {\n items: TokenItem[]\n ordered?: boolean\n }\n}\n\ntype Token = string | CommandToken | LinkToken | CharToken | UserInputToken | FilePathToken | ListToken\nexport type TokenItem = Token | Token[]\n\ntype DisplayType = 'block' | 'inline'\ninterface Block {\n display: DisplayType\n value: Token\n}\n\nfunction tokenToBlock(token: Token): Block {\n return {\n display: typeof token !== 'string' && 'list' in token ? 'block' : 'inline',\n value: token,\n }\n}\n\nfunction splitByDisplayType(acc: Block[][], item: Block) {\n if (item.display === 'block') {\n acc.push([item])\n } else {\n const last = acc[acc.length - 1]\n if (last && last[0]!.display === 'inline') {\n last.push(item)\n } else {\n acc.push([item])\n }\n }\n return acc\n}\n\ninterface Props {\n item: TokenItem\n}\n\n/**\n * `TokenizedText` renders a text string with tokens that can be either strings,\n * links, and commands.\n */\nconst TokenizedText: React.FC<Props> = ({item}) => {\n if (typeof item === 'string') {\n return <Text>{item}</Text>\n } else if ('command' in item) {\n return <Command command={item.command} />\n } else if ('link' in item) {\n return <Link {...item.link} />\n } else if ('char' in item) {\n return <Text>{item.char[0]}</Text>\n } else if ('userInput' in item) {\n return <UserInput userInput={item.userInput} />\n } else if ('filePath' in item) {\n return <FilePath filePath={item.filePath} />\n } else if ('list' in item) {\n return <List {...item.list} />\n } else {\n const groupedItems = item.map(tokenToBlock).reduce(splitByDisplayType, [])\n\n return (\n <Box flexDirection=\"column\">\n {groupedItems.map((items, groupIndex) => {\n if (items[0]!.display === 'inline') {\n return (\n <Text key={groupIndex}>\n {items.map((item, itemIndex) => (\n <Text key={itemIndex}>\n {itemIndex !== 0 && !(typeof item.value !== 'string' && 'char' in item.value) && <Text> </Text>}\n <TokenizedText item={item.value} />\n </Text>\n ))}\n </Text>\n )\n } else {\n return <List key={groupIndex} items={(items[0]!.value as ListToken).list.items} />\n }\n })}\n </Box>\n )\n }\n}\n\nexport {TokenizedText}\n"]}
@@ -0,0 +1,44 @@
1
+ import { TokenizedText } from './TokenizedText.js';
2
+ import { renderString } from '../../ui.js';
3
+ import { unstyled } from '../../../../output.js';
4
+ import { describe, expect, test } from 'vitest';
5
+ import React from 'react';
6
+ describe('TokenizedText', async () => {
7
+ test('renders arrays of items separated by spaces', async () => {
8
+ const item = [
9
+ 'Run',
10
+ {
11
+ command: 'cd verification-app',
12
+ },
13
+ {
14
+ link: {
15
+ url: 'https://example.com',
16
+ label: 'Example',
17
+ },
18
+ },
19
+ {
20
+ char: '!',
21
+ },
22
+ {
23
+ userInput: 'my-app',
24
+ },
25
+ {
26
+ list: {
27
+ items: ['Item 1', 'Item 2', 'Item 3'],
28
+ },
29
+ },
30
+ {
31
+ filePath: 'src/this/is/a/test.js',
32
+ },
33
+ ];
34
+ const { output } = renderString(React.createElement(TokenizedText, { item: item }));
35
+ expect(unstyled(output)).toMatchInlineSnapshot(`
36
+ "Run \`cd verification-app\` Example (https://example.com)! my-app
37
+ • Item 1
38
+ • Item 2
39
+ • Item 3
40
+ \\"src/this/is/a/test.js\\""
41
+ `);
42
+ });
43
+ });
44
+ //# sourceMappingURL=TokenizedText.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TokenizedText.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/TokenizedText.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAA;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,QAAQ,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;IACnC,IAAI,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;QAC7D,MAAM,IAAI,GAAG;YACX,KAAK;YACL;gBACE,OAAO,EAAE,qBAAqB;aAC/B;YACD;gBACE,IAAI,EAAE;oBACJ,GAAG,EAAE,qBAAqB;oBAC1B,KAAK,EAAE,SAAS;iBACjB;aACF;YACD;gBACE,IAAI,EAAE,GAAG;aACV;YACD;gBACE,SAAS,EAAE,QAAQ;aACpB;YACD;gBACE,IAAI,EAAE;oBACJ,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;iBACtC;aACF;YACD;gBACE,QAAQ,EAAE,uBAAuB;aAClC;SACF,CAAA;QAED,MAAM,EAAC,MAAM,EAAC,GAAG,YAAY,CAAC,oBAAC,aAAa,IAAC,IAAI,EAAE,IAAI,GAAI,CAAC,CAAA;QAE5D,MAAM,CAAC,QAAQ,CAAC,MAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC;;;;;;KAM/C,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {TokenizedText} from './TokenizedText.js'\nimport {renderString} from '../../ui.js'\nimport {unstyled} from '../../../../output.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\n\ndescribe('TokenizedText', async () => {\n test('renders arrays of items separated by spaces', async () => {\n const item = [\n 'Run',\n {\n command: 'cd verification-app',\n },\n {\n link: {\n url: 'https://example.com',\n label: 'Example',\n },\n },\n {\n char: '!',\n },\n {\n userInput: 'my-app',\n },\n {\n list: {\n items: ['Item 1', 'Item 2', 'Item 3'],\n },\n },\n {\n filePath: 'src/this/is/a/test.js',\n },\n ]\n\n const {output} = renderString(<TokenizedText item={item} />)\n\n expect(unstyled(output!)).toMatchInlineSnapshot(`\n \"Run \\`cd verification-app\\` Example (https://example.com)! my-app\n • Item 1\n • Item 2\n • Item 3\n \\\\\"src/this/is/a/test.js\\\\\"\"\n `)\n })\n})\n"]}
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface Props {
3
+ userInput: string;
4
+ }
5
+ /**
6
+ * `UserInput` displays some text that represents input from the user.
7
+ * For example an answer to a selection prompt.
8
+ */
9
+ declare const UserInput: React.FC<Props>;
10
+ export { UserInput };
@@ -0,0 +1,11 @@
1
+ import { Text } from 'ink';
2
+ import React from 'react';
3
+ /**
4
+ * `UserInput` displays some text that represents input from the user.
5
+ * For example an answer to a selection prompt.
6
+ */
7
+ const UserInput = ({ userInput }) => {
8
+ return React.createElement(Text, { color: "cyan" }, userInput);
9
+ };
10
+ export { UserInput };
11
+ //# sourceMappingURL=UserInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserInput.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/UserInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB;;;GAGG;AACH,MAAM,SAAS,GAAoB,CAAC,EAAC,SAAS,EAAiC,EAAe,EAAE;IAC9F,OAAO,oBAAC,IAAI,IAAC,KAAK,EAAC,MAAM,IAAE,SAAS,CAAQ,CAAA;AAC9C,CAAC,CAAA;AAED,OAAO,EAAC,SAAS,EAAC,CAAA","sourcesContent":["import {Text} from 'ink'\nimport React from 'react'\n\ninterface Props {\n userInput: string\n}\n\n/**\n * `UserInput` displays some text that represents input from the user.\n * For example an answer to a selection prompt.\n */\nconst UserInput: React.FC<Props> = ({userInput}: React.PropsWithChildren<Props>): JSX.Element => {\n return <Text color=\"cyan\">{userInput}</Text>\n}\n\nexport {UserInput}\n"]}
@@ -0,0 +1,11 @@
1
+ import { UserInput } from './UserInput.js';
2
+ import { renderString } from '../../ui.js';
3
+ import { describe, expect, test } from 'vitest';
4
+ import React from 'react';
5
+ describe('UserInput', async () => {
6
+ test('renders correctly', async () => {
7
+ const { output } = renderString(React.createElement(UserInput, { userInput: "my-app" }));
8
+ expect(output).toMatchInlineSnapshot('"my-app"');
9
+ });
10
+ });
11
+ //# sourceMappingURL=UserInput.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserInput.test.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/UserInput.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAA;AACxC,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,QAAQ,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE;IAC/B,IAAI,CAAC,mBAAmB,EAAE,KAAK,IAAI,EAAE;QACnC,MAAM,EAAC,MAAM,EAAC,GAAG,YAAY,CAAC,oBAAC,SAAS,IAAC,SAAS,EAAC,QAAQ,GAAG,CAAC,CAAA;QAE/D,MAAM,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,oBAAoB,CAAC,CAAA;IAC5D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import {UserInput} from './UserInput.js'\nimport {renderString} from '../../ui.js'\nimport {describe, expect, test} from 'vitest'\nimport React from 'react'\n\ndescribe('UserInput', async () => {\n test('renders correctly', async () => {\n const {output} = renderString(<UserInput userInput=\"my-app\" />)\n\n expect(output).toMatchInlineSnapshot('\"\u001b[36mmy-app\u001b[39m\"')\n })\n})\n"]}
@@ -1,4 +1,2 @@
1
- import { ErrorProps } from './components/Error.js';
2
1
  import { Fatal } from '../../../error.js';
3
2
  export declare function fatalError(error: Fatal): void;
4
- export declare function error({ headline, tryMessage }: ErrorProps): void;
@@ -1,4 +1,3 @@
1
- import { Error } from './components/Error.js';
2
1
  import { FatalError } from './components/FatalError.js';
3
2
  import { renderOnce } from '../ui.js';
4
3
  import { consoleError } from '../../../output.js';
@@ -6,7 +5,4 @@ import React from 'react';
6
5
  export function fatalError(error) {
7
6
  renderOnce(React.createElement(FatalError, { error: error }), 'error', consoleError);
8
7
  }
9
- export function error({ headline, tryMessage }) {
10
- renderOnce(React.createElement(Error, { headline: headline, tryMessage: tryMessage }), 'error', consoleError);
11
- }
12
8
  //# sourceMappingURL=error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/private/node/ui/error.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,EAAC,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AAErD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,UAAU,UAAU,CAAC,KAAY;IACrC,UAAU,CAAC,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAA;AACjE,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAa;IACtD,UAAU,CAAC,oBAAC,KAAK,IAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,GAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAA;AAC1F,CAAC","sourcesContent":["import {ErrorProps, Error} from './components/Error.js'\nimport {FatalError} from './components/FatalError.js'\nimport {Fatal} from '../../../error.js'\nimport {renderOnce} from '../ui.js'\nimport {consoleError} from '../../../output.js'\nimport React from 'react'\n\nexport function fatalError(error: Fatal) {\n renderOnce(<FatalError error={error} />, 'error', consoleError)\n}\n\nexport function error({headline, tryMessage}: ErrorProps) {\n renderOnce(<Error headline={headline} tryMessage={tryMessage} />, 'error', consoleError)\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/private/node/ui/error.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AAErD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,UAAU,UAAU,CAAC,KAAY;IACrC,UAAU,CAAC,oBAAC,UAAU,IAAC,KAAK,EAAE,KAAK,GAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAA;AACjE,CAAC","sourcesContent":["import {FatalError} from './components/FatalError.js'\nimport {Fatal} from '../../../error.js'\nimport {renderOnce} from '../ui.js'\nimport {consoleError} from '../../../output.js'\nimport React from 'react'\n\nexport function fatalError(error: Fatal) {\n renderOnce(<FatalError error={error} />, 'error', consoleError)\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  import { Logger, LogLevel } from '../../output.js';
2
2
  import { ReactElement } from 'react';
3
+ import { RenderOptions } from 'ink';
3
4
  export declare function renderOnce(element: JSX.Element, logLevel?: LogLevel, logger?: Logger): void;
4
- export declare function render(element: JSX.Element): import("ink").Instance;
5
+ export declare function render(element: JSX.Element, options?: RenderOptions): Promise<void>;
5
6
  interface Instance {
6
7
  output: string | undefined;
7
8
  unmount: () => void;
@@ -11,8 +11,9 @@ export function renderOnce(element, logLevel = 'info', logger = consoleLog) {
11
11
  }
12
12
  unmount();
13
13
  }
14
- export function render(element) {
15
- return inkRender(element);
14
+ export function render(element, options) {
15
+ const { waitUntilExit } = inkRender(element, options);
16
+ return waitUntilExit();
16
17
  }
17
18
  const TEST_TERMINAL_WIDTH = 80;
18
19
  class OutputStream extends EventEmitter {
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/private/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAC,UAAU,EAAE,UAAU,EAAoB,sBAAsB,EAAC,MAAM,iBAAiB,CAAA;AAEhG,OAAO,EAAC,MAAM,IAAI,SAAS,EAAC,MAAM,KAAK,CAAA;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAA;AAEnC,MAAM,UAAU,UAAU,CAAC,OAAoB,EAAE,WAAqB,MAAM,EAAE,SAAiB,UAAU;IACvG,MAAM,EAAC,MAAM,EAAE,OAAO,EAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IAE/C,IAAI,MAAM,EAAE;QACV,IAAI,UAAU,EAAE;YAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC9C,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KACjD;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAoB;IACzC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAA;AAC3B,CAAC;AAOD,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAC9B,MAAM,YAAa,SAAQ,YAAY;IAIrC,YAAY,OAA0B;QACpC,KAAK,EAAE,CAAA;QAIT,UAAK,GAAG,CAAC,KAAa,EAAE,EAAE;YACxB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACzB,CAAC,CAAA;QAED,cAAS,GAAG,GAAG,EAAE;YACf,OAAO,IAAI,CAAC,UAAU,CAAA;QACxB,CAAC,CAAA;QATC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IAChC,CAAC;CASF;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAqB,EAAY,EAAE;IAC9D,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,EAAC,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IACvG,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,EAAC,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IAEvG,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE;QAClC,8DAA8D;QAC9D,MAAM,EAAE,MAAa;QACrB,8DAA8D;QAC9D,MAAM,EAAE,MAAa;QACrB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAA;IAEF,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE;QAC1B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {isUnitTest} from '../../environment/local.js'\nimport {collectLog, consoleLog, Logger, LogLevel, outputWhereAppropriate} from '../../output.js'\nimport {ReactElement} from 'react'\nimport {render as inkRender} from 'ink'\nimport {EventEmitter} from 'events'\n\nexport function renderOnce(element: JSX.Element, logLevel: LogLevel = 'info', logger: Logger = consoleLog) {\n const {output, unmount} = renderString(element)\n\n if (output) {\n if (isUnitTest()) collectLog(logLevel, output)\n outputWhereAppropriate(logLevel, logger, output)\n }\n\n unmount()\n}\n\nexport function render(element: JSX.Element) {\n return inkRender(element)\n}\n\ninterface Instance {\n output: string | undefined\n unmount: () => void\n}\n\nconst TEST_TERMINAL_WIDTH = 80\nclass OutputStream extends EventEmitter {\n columns: number\n private _lastFrame?: string\n\n constructor(options: {columns: number}) {\n super()\n this.columns = options.columns\n }\n\n write = (frame: string) => {\n this._lastFrame = frame\n }\n\n lastFrame = () => {\n return this._lastFrame\n }\n}\n\nexport const renderString = (element: ReactElement): Instance => {\n const stdout = new OutputStream({columns: isUnitTest() ? TEST_TERMINAL_WIDTH : process.stdout.columns})\n const stderr = new OutputStream({columns: isUnitTest() ? TEST_TERMINAL_WIDTH : process.stderr.columns})\n\n const instance = inkRender(element, {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stdout: stdout as any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stderr: stderr as any,\n debug: true,\n exitOnCtrlC: false,\n patchConsole: false,\n })\n\n return {\n output: stdout.lastFrame(),\n unmount: instance.unmount,\n }\n}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/private/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAC,UAAU,EAAE,UAAU,EAAoB,sBAAsB,EAAC,MAAM,iBAAiB,CAAA;AAEhG,OAAO,EAAC,MAAM,IAAI,SAAS,EAAgB,MAAM,KAAK,CAAA;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAA;AAEnC,MAAM,UAAU,UAAU,CAAC,OAAoB,EAAE,WAAqB,MAAM,EAAE,SAAiB,UAAU;IACvG,MAAM,EAAC,MAAM,EAAE,OAAO,EAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IAE/C,IAAI,MAAM,EAAE;QACV,IAAI,UAAU,EAAE;YAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC9C,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KACjD;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAoB,EAAE,OAAuB;IAClE,MAAM,EAAC,aAAa,EAAC,GAAG,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACnD,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAOD,MAAM,mBAAmB,GAAG,EAAE,CAAA;AAC9B,MAAM,YAAa,SAAQ,YAAY;IAIrC,YAAY,OAA0B;QACpC,KAAK,EAAE,CAAA;QAIT,UAAK,GAAG,CAAC,KAAa,EAAE,EAAE;YACxB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACzB,CAAC,CAAA;QAED,cAAS,GAAG,GAAG,EAAE;YACf,OAAO,IAAI,CAAC,UAAU,CAAA;QACxB,CAAC,CAAA;QATC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IAChC,CAAC;CASF;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAqB,EAAY,EAAE;IAC9D,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,EAAC,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IACvG,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,EAAC,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IAEvG,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE;QAClC,8DAA8D;QAC9D,MAAM,EAAE,MAAa;QACrB,8DAA8D;QAC9D,MAAM,EAAE,MAAa;QACrB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAA;IAEF,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE;QAC1B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {isUnitTest} from '../../environment/local.js'\nimport {collectLog, consoleLog, Logger, LogLevel, outputWhereAppropriate} from '../../output.js'\nimport {ReactElement} from 'react'\nimport {render as inkRender, RenderOptions} from 'ink'\nimport {EventEmitter} from 'events'\n\nexport function renderOnce(element: JSX.Element, logLevel: LogLevel = 'info', logger: Logger = consoleLog) {\n const {output, unmount} = renderString(element)\n\n if (output) {\n if (isUnitTest()) collectLog(logLevel, output)\n outputWhereAppropriate(logLevel, logger, output)\n }\n\n unmount()\n}\n\nexport function render(element: JSX.Element, options?: RenderOptions) {\n const {waitUntilExit} = inkRender(element, options)\n return waitUntilExit()\n}\n\ninterface Instance {\n output: string | undefined\n unmount: () => void\n}\n\nconst TEST_TERMINAL_WIDTH = 80\nclass OutputStream extends EventEmitter {\n columns: number\n private _lastFrame?: string\n\n constructor(options: {columns: number}) {\n super()\n this.columns = options.columns\n }\n\n write = (frame: string) => {\n this._lastFrame = frame\n }\n\n lastFrame = () => {\n return this._lastFrame\n }\n}\n\nexport const renderString = (element: ReactElement): Instance => {\n const stdout = new OutputStream({columns: isUnitTest() ? TEST_TERMINAL_WIDTH : process.stdout.columns})\n const stderr = new OutputStream({columns: isUnitTest() ? TEST_TERMINAL_WIDTH : process.stderr.columns})\n\n const instance = inkRender(element, {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stdout: stdout as any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stderr: stderr as any,\n debug: true,\n exitOnCtrlC: false,\n patchConsole: false,\n })\n\n return {\n output: stdout.lastFrame(),\n unmount: instance.unmount,\n }\n}\n"]}
@@ -1,4 +1,6 @@
1
+ export declare type RandomNameFamily = 'business' | 'creative';
1
2
  /**
2
- * Returns a randon name generated by combining a random adjetive and noun.
3
+ * @param family - Theme to use for the random name
4
+ * @returns A random name generated by combining an adjective and noun.
3
5
  */
4
- export declare function getRandomName(): string;
6
+ export declare function getRandomName(family?: RandomNameFamily): string;
@@ -1,5 +1,5 @@
1
1
  import { takeRandomFromArray } from './array.js';
2
- const SAFE_RANDOM_ADJECTIVES = [
2
+ const SAFE_RANDOM_BUSINESS_ADJECTIVES = [
3
3
  'commercial',
4
4
  'profitable',
5
5
  'amortizable',
@@ -22,7 +22,29 @@ const SAFE_RANDOM_ADJECTIVES = [
22
22
  'lucrative',
23
23
  'modern',
24
24
  ];
25
- const SAFE_RANDOM_NOUNS = [
25
+ const SAFE_RANDOM_CREATIVE_ADJECTIVES = [
26
+ 'bright',
27
+ 'impactful',
28
+ 'stylish',
29
+ 'colorful',
30
+ 'modern',
31
+ 'minimal',
32
+ 'trendy',
33
+ 'creative',
34
+ 'artistic',
35
+ 'spectacular',
36
+ 'glamorous',
37
+ 'luxury',
38
+ 'retro',
39
+ 'nostalgic',
40
+ 'comfy',
41
+ 'polished',
42
+ 'fabulous',
43
+ 'balanced',
44
+ 'monochrome',
45
+ 'glitched',
46
+ ];
47
+ const SAFE_RANDOM_BUSINESS_NOUNS = [
26
48
  'account',
27
49
  'consumer',
28
50
  'customer',
@@ -51,10 +73,37 @@ const SAFE_RANDOM_NOUNS = [
51
73
  'transaction',
52
74
  'sale',
53
75
  ];
76
+ const SAFE_RANDOM_CREATIVE_NOUNS = [
77
+ 'vibe',
78
+ 'style',
79
+ 'moment',
80
+ 'mood',
81
+ 'flavor',
82
+ 'look',
83
+ 'appearance',
84
+ 'perspective',
85
+ 'aspect',
86
+ 'ambience',
87
+ 'quality',
88
+ 'backdrop',
89
+ 'focus',
90
+ 'tone',
91
+ ];
54
92
  /**
55
- * Returns a randon name generated by combining a random adjetive and noun.
93
+ * @param family - Theme to use for the random name
94
+ * @returns A random name generated by combining an adjective and noun.
56
95
  */
57
- export function getRandomName() {
58
- return `${takeRandomFromArray(SAFE_RANDOM_ADJECTIVES)}-${takeRandomFromArray(SAFE_RANDOM_NOUNS)}`;
96
+ export function getRandomName(family = 'business') {
97
+ const mapping = {
98
+ business: {
99
+ adjectives: SAFE_RANDOM_BUSINESS_ADJECTIVES,
100
+ nouns: SAFE_RANDOM_BUSINESS_NOUNS,
101
+ },
102
+ creative: {
103
+ adjectives: SAFE_RANDOM_CREATIVE_ADJECTIVES,
104
+ nouns: SAFE_RANDOM_CREATIVE_NOUNS,
105
+ },
106
+ };
107
+ return `${takeRandomFromArray(mapping[family].adjectives)}-${takeRandomFromArray(mapping[family].nouns)}`;
59
108
  }
60
109
  //# sourceMappingURL=string.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/public/common/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAA;AAE9C,MAAM,sBAAsB,GAAG;IAC7B,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,SAAS;IACT,YAAY;IACZ,aAAa;IACb,cAAc;IACd,aAAa;IACb,MAAM;IACN,OAAO;IACP,SAAS;IACT,QAAQ;IACR,UAAU;IACV,WAAW;IACX,WAAW;IACX,eAAe;IACf,YAAY;IACZ,UAAU;IACV,WAAW;IACX,WAAW;IACX,QAAQ;CACT,CAAA;AAED,MAAM,iBAAiB,GAAG;IACxB,SAAS;IACT,UAAU;IACV,UAAU;IACV,YAAY;IACZ,UAAU;IACV,SAAS;IACT,aAAa;IACb,SAAS;IACT,UAAU;IACV,WAAW;IACX,aAAa;IACb,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,QAAQ;IACR,OAAO;IACP,MAAM;IACN,aAAa;IACb,aAAa;IACb,MAAM;CACP,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,GAAG,mBAAmB,CAAC,sBAAsB,CAAC,IAAI,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,CAAA;AACnG,CAAC","sourcesContent":["import {takeRandomFromArray} from './array.js'\n\nconst SAFE_RANDOM_ADJECTIVES = [\n 'commercial',\n 'profitable',\n 'amortizable',\n 'branded',\n 'integrated',\n 'synergistic',\n 'consolidated',\n 'diversified',\n 'lean',\n 'niche',\n 'premium',\n 'luxury',\n 'scalable',\n 'optimized',\n 'empowered',\n 'international',\n 'beneficial',\n 'fruitful',\n 'extensive',\n 'lucrative',\n 'modern',\n]\n\nconst SAFE_RANDOM_NOUNS = [\n 'account',\n 'consumer',\n 'customer',\n 'enterprise',\n 'business',\n 'venture',\n 'marketplace',\n 'revenue',\n 'vertical',\n 'portfolio',\n 'negotiation',\n 'shipping',\n 'demand',\n 'supply',\n 'growth',\n 'merchant',\n 'investment',\n 'shareholder',\n 'conversion',\n 'capital',\n 'projection',\n 'upside',\n 'trade',\n 'deal',\n 'merchandise',\n 'transaction',\n 'sale',\n]\n\n/**\n * Returns a randon name generated by combining a random adjetive and noun.\n */\nexport function getRandomName(): string {\n return `${takeRandomFromArray(SAFE_RANDOM_ADJECTIVES)}-${takeRandomFromArray(SAFE_RANDOM_NOUNS)}`\n}\n"]}
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/public/common/string.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAA;AAE9C,MAAM,+BAA+B,GAAG;IACtC,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,SAAS;IACT,YAAY;IACZ,aAAa;IACb,cAAc;IACd,aAAa;IACb,MAAM;IACN,OAAO;IACP,SAAS;IACT,QAAQ;IACR,UAAU;IACV,WAAW;IACX,WAAW;IACX,eAAe;IACf,YAAY;IACZ,UAAU;IACV,WAAW;IACX,WAAW;IACX,QAAQ;CACT,CAAA;AAED,MAAM,+BAA+B,GAAG;IACtC,QAAQ;IACR,WAAW;IACX,SAAS;IACT,UAAU;IACV,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,UAAU;IACV,UAAU;IACV,aAAa;IACb,WAAW;IACX,QAAQ;IACR,OAAO;IACP,WAAW;IACX,OAAO;IACP,UAAU;IACV,UAAU;IACV,UAAU;IACV,YAAY;IACZ,UAAU;CACX,CAAA;AAED,MAAM,0BAA0B,GAAG;IACjC,SAAS;IACT,UAAU;IACV,UAAU;IACV,YAAY;IACZ,UAAU;IACV,SAAS;IACT,aAAa;IACb,SAAS;IACT,UAAU;IACV,WAAW;IACX,aAAa;IACb,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,QAAQ;IACR,OAAO;IACP,MAAM;IACN,aAAa;IACb,aAAa;IACb,MAAM;CACP,CAAA;AAED,MAAM,0BAA0B,GAAG;IACjC,MAAM;IACN,OAAO;IACP,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,MAAM;IACN,YAAY;IACZ,aAAa;IACb,QAAQ;IACR,UAAU;IACV,SAAS;IACT,UAAU;IACV,OAAO;IACP,MAAM;CACP,CAAA;AAID;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,SAA2B,UAAU;IACjE,MAAM,OAAO,GAAG;QACd,QAAQ,EAAE;YACR,UAAU,EAAE,+BAA+B;YAC3C,KAAK,EAAE,0BAA0B;SAClC;QACD,QAAQ,EAAE;YACR,UAAU,EAAE,+BAA+B;YAC3C,KAAK,EAAE,0BAA0B;SAClC;KACF,CAAA;IACD,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,IAAI,mBAAmB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,CAAA;AAC3G,CAAC","sourcesContent":["import {takeRandomFromArray} from './array.js'\n\nconst SAFE_RANDOM_BUSINESS_ADJECTIVES = [\n 'commercial',\n 'profitable',\n 'amortizable',\n 'branded',\n 'integrated',\n 'synergistic',\n 'consolidated',\n 'diversified',\n 'lean',\n 'niche',\n 'premium',\n 'luxury',\n 'scalable',\n 'optimized',\n 'empowered',\n 'international',\n 'beneficial',\n 'fruitful',\n 'extensive',\n 'lucrative',\n 'modern',\n]\n\nconst SAFE_RANDOM_CREATIVE_ADJECTIVES = [\n 'bright',\n 'impactful',\n 'stylish',\n 'colorful',\n 'modern',\n 'minimal',\n 'trendy',\n 'creative',\n 'artistic',\n 'spectacular',\n 'glamorous',\n 'luxury',\n 'retro',\n 'nostalgic',\n 'comfy',\n 'polished',\n 'fabulous',\n 'balanced',\n 'monochrome',\n 'glitched',\n]\n\nconst SAFE_RANDOM_BUSINESS_NOUNS = [\n 'account',\n 'consumer',\n 'customer',\n 'enterprise',\n 'business',\n 'venture',\n 'marketplace',\n 'revenue',\n 'vertical',\n 'portfolio',\n 'negotiation',\n 'shipping',\n 'demand',\n 'supply',\n 'growth',\n 'merchant',\n 'investment',\n 'shareholder',\n 'conversion',\n 'capital',\n 'projection',\n 'upside',\n 'trade',\n 'deal',\n 'merchandise',\n 'transaction',\n 'sale',\n]\n\nconst SAFE_RANDOM_CREATIVE_NOUNS = [\n 'vibe',\n 'style',\n 'moment',\n 'mood',\n 'flavor',\n 'look',\n 'appearance',\n 'perspective',\n 'aspect',\n 'ambience',\n 'quality',\n 'backdrop',\n 'focus',\n 'tone',\n]\n\nexport type RandomNameFamily = 'business' | 'creative'\n\n/**\n * @param family - Theme to use for the random name\n * @returns A random name generated by combining an adjective and noun.\n */\nexport function getRandomName(family: RandomNameFamily = 'business'): string {\n const mapping = {\n business: {\n adjectives: SAFE_RANDOM_BUSINESS_ADJECTIVES,\n nouns: SAFE_RANDOM_BUSINESS_NOUNS,\n },\n creative: {\n adjectives: SAFE_RANDOM_CREATIVE_ADJECTIVES,\n nouns: SAFE_RANDOM_CREATIVE_NOUNS,\n },\n }\n return `${takeRandomFromArray(mapping[family].adjectives)}-${takeRandomFromArray(mapping[family].nouns)}`\n}\n"]}
@@ -1,8 +1,11 @@
1
+ import type { RandomNameFamily } from '../common/string.js';
1
2
  interface GenerateRandomDirectoryOptions {
2
3
  /** Suffix to include in the randomly generated directory name */
3
4
  suffix: string;
4
5
  /** Absolute path to the directory where the random directory will be created. */
5
6
  directory: string;
7
+ /** Type of word to use for random name */
8
+ family?: RandomNameFamily;
6
9
  }
7
10
  /**
8
11
  * It generates a random directory directory name for a sub-directory.
@@ -8,11 +8,11 @@ import { getRandomName } from '../common/string.js';
8
8
  * @returns It returns the name of the directory.
9
9
  */
10
10
  export async function generateRandomNameForSubdirectory(options) {
11
- const generated = `${getRandomName()}-${options.suffix}`;
11
+ const generated = `${getRandomName(options.family ?? 'business')}-${options.suffix}`;
12
12
  const randomDirectoryPath = joinPath(options.directory, generated);
13
13
  const isAppDirectoryTaken = await fileExists(randomDirectoryPath);
14
14
  if (isAppDirectoryTaken) {
15
- return generateRandomNameForSubdirectory({ suffix: options.suffix, directory: options.directory });
15
+ return generateRandomNameForSubdirectory(options);
16
16
  }
17
17
  else {
18
18
  return generated;
@@ -1 +1 @@
1
- {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/public/node/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,eAAe,CAAA;AAClD,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAA;AAUjD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,OAAuC;IAC7F,MAAM,SAAS,GAAG,GAAG,aAAa,EAAE,IAAI,OAAO,CAAC,MAAM,EAAE,CAAA;IACxD,MAAM,mBAAmB,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IAClE,MAAM,mBAAmB,GAAG,MAAM,UAAU,CAAC,mBAAmB,CAAC,CAAA;IAEjE,IAAI,mBAAmB,EAAE;QACvB,OAAO,iCAAiC,CAAC,EAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAC,CAAC,CAAA;KACjG;SAAM;QACL,OAAO,SAAS,CAAA;KACjB;AACH,CAAC","sourcesContent":["import {exists as fileExists} from '../../file.js'\nimport {join as joinPath} from '../../path.js'\nimport {getRandomName} from '../common/string.js'\n\ninterface GenerateRandomDirectoryOptions {\n /** Suffix to include in the randomly generated directory name */\n suffix: string\n\n /** Absolute path to the directory where the random directory will be created. */\n directory: string\n}\n\n/**\n * It generates a random directory directory name for a sub-directory.\n * It ensures that the returned directory name doesn't exist.\n *\n * @returns It returns the name of the directory.\n */\nexport async function generateRandomNameForSubdirectory(options: GenerateRandomDirectoryOptions): Promise<string> {\n const generated = `${getRandomName()}-${options.suffix}`\n const randomDirectoryPath = joinPath(options.directory, generated)\n const isAppDirectoryTaken = await fileExists(randomDirectoryPath)\n\n if (isAppDirectoryTaken) {\n return generateRandomNameForSubdirectory({suffix: options.suffix, directory: options.directory})\n } else {\n return generated\n }\n}\n"]}
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/public/node/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,eAAe,CAAA;AAClD,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAA;AAcjD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,OAAuC;IAC7F,MAAM,SAAS,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAA;IACpF,MAAM,mBAAmB,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IAClE,MAAM,mBAAmB,GAAG,MAAM,UAAU,CAAC,mBAAmB,CAAC,CAAA;IAEjE,IAAI,mBAAmB,EAAE;QACvB,OAAO,iCAAiC,CAAC,OAAO,CAAC,CAAA;KAClD;SAAM;QACL,OAAO,SAAS,CAAA;KACjB;AACH,CAAC","sourcesContent":["import {exists as fileExists} from '../../file.js'\nimport {join as joinPath} from '../../path.js'\nimport {getRandomName} from '../common/string.js'\nimport type {RandomNameFamily} from '../common/string.js'\n\ninterface GenerateRandomDirectoryOptions {\n /** Suffix to include in the randomly generated directory name */\n suffix: string\n\n /** Absolute path to the directory where the random directory will be created. */\n directory: string\n\n /** Type of word to use for random name */\n family?: RandomNameFamily\n}\n\n/**\n * It generates a random directory directory name for a sub-directory.\n * It ensures that the returned directory name doesn't exist.\n *\n * @returns It returns the name of the directory.\n */\nexport async function generateRandomNameForSubdirectory(options: GenerateRandomDirectoryOptions): Promise<string> {\n const generated = `${getRandomName(options.family ?? 'business')}-${options.suffix}`\n const randomDirectoryPath = joinPath(options.directory, generated)\n const isAppDirectoryTaken = await fileExists(randomDirectoryPath)\n\n if (isAppDirectoryTaken) {\n return generateRandomNameForSubdirectory(options)\n } else {\n return generated\n }\n}\n"]}
@@ -0,0 +1,50 @@
1
+ import { Result } from './result.js';
2
+ export interface GithubRelease {
3
+ id: number;
4
+ url: string;
5
+ tag_name: string;
6
+ name: string;
7
+ body: string;
8
+ draft: boolean;
9
+ prerelease: boolean;
10
+ created_at: string;
11
+ published_at: string;
12
+ tarball_url: string;
13
+ }
14
+ interface GetLatestGitHubReleaseOptions {
15
+ filter: (release: GithubRelease) => boolean;
16
+ }
17
+ /**
18
+ * Given a GitHub repository it obtains the latest release.
19
+ * @param owner - Repository owner (e.g., shopify)
20
+ * @param repo - Repository name (e.g., cli)
21
+ * @param options - Options
22
+ */
23
+ export declare function getLatestGitHubRelease(owner: string, repo: string, options?: GetLatestGitHubReleaseOptions): Promise<GithubRelease>;
24
+ interface ParseRepositoryURLOutput {
25
+ full: string;
26
+ site: string;
27
+ user: string;
28
+ name: string;
29
+ ref: string;
30
+ subDirectory: string;
31
+ ssh: string;
32
+ http: string;
33
+ }
34
+ /**
35
+ * Given a GitHub repository URL, it parses it and returns its coomponents.
36
+ * @param url - The GitHub repository URL
37
+ */
38
+ export declare function parseGitHubRepositoryURL(url: string): Result<ParseRepositoryURLOutput, Error>;
39
+ export interface GithubRepositoryReference {
40
+ baseURL: string;
41
+ branch?: string;
42
+ filePath?: string;
43
+ }
44
+ /**
45
+ * Given a GitHub repository URL it parses it and extracts the branch, file path,
46
+ * and base URL components
47
+ * @param reference - A GitHub repository URL (e.g. https://github.com/Shopify/cli/blob/main/package.json)
48
+ */
49
+ export declare function parseGitHubRepositoryReference(reference: string): GithubRepositoryReference;
50
+ export {};