@shopify/cli-kit 3.48.6 → 3.49.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 (87) hide show
  1. package/README.md +3 -1
  2. package/assets/cli-ruby/lib/project_types/theme/commands/console.rb +9 -3
  3. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy_param_builder.rb +2 -0
  4. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server.rb +1 -1
  5. package/assets/cli-ruby/lib/shopify_cli/theme/repl/api.rb +7 -7
  6. package/assets/cli-ruby/lib/shopify_cli/theme/repl/auth_dev_server.rb +18 -3
  7. package/assets/cli-ruby/lib/shopify_cli/theme/repl/auth_middleware.rb +27 -6
  8. package/assets/cli-ruby/lib/shopify_cli/theme/repl/remote_evaluator.rb +158 -0
  9. package/assets/cli-ruby/lib/shopify_cli/theme/repl/resources/success.html +0 -1
  10. package/assets/cli-ruby/lib/shopify_cli/theme/repl/snippet.rb +81 -0
  11. package/assets/cli-ruby/lib/shopify_cli/theme/repl.rb +31 -89
  12. package/dist/private/node/analytics.js +2 -2
  13. package/dist/private/node/analytics.js.map +1 -1
  14. package/dist/private/node/api/graphql.d.ts +2 -2
  15. package/dist/private/node/api/graphql.js +12 -6
  16. package/dist/private/node/api/graphql.js.map +1 -1
  17. package/dist/private/node/api.d.ts +1 -1
  18. package/dist/private/node/api.js +1 -1
  19. package/dist/private/node/api.js.map +1 -1
  20. package/dist/private/node/context/utilities.d.ts +2 -0
  21. package/dist/private/node/context/utilities.js +3 -2
  22. package/dist/private/node/context/utilities.js.map +1 -1
  23. package/dist/private/node/demo-recorder.d.ts +0 -3
  24. package/dist/private/node/demo-recorder.js +3 -5
  25. package/dist/private/node/demo-recorder.js.map +1 -1
  26. package/dist/private/node/session/exchange.js +1 -0
  27. package/dist/private/node/session/exchange.js.map +1 -1
  28. package/dist/private/node/testing/ui.d.ts +6 -1
  29. package/dist/private/node/testing/ui.js +25 -1
  30. package/dist/private/node/testing/ui.js.map +1 -1
  31. package/dist/private/node/ui/components/AutocompletePrompt.test.js +2 -0
  32. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
  33. package/dist/private/node/ui/components/Command.js +1 -1
  34. package/dist/private/node/ui/components/Command.js.map +1 -1
  35. package/dist/private/node/ui/components/Command.test.js +1 -1
  36. package/dist/private/node/ui/components/Command.test.js.map +1 -1
  37. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +2 -23
  38. package/dist/private/node/ui/components/ConcurrentOutput.js +39 -103
  39. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  40. package/dist/private/node/ui/components/ConcurrentOutput.test.js +22 -208
  41. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  42. package/dist/private/node/ui/components/SelectPrompt.test.js +2 -0
  43. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  44. package/dist/private/node/ui/components/Tasks.test.js +2 -0
  45. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  46. package/dist/private/node/ui/components/TextPrompt.test.js +2 -0
  47. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  48. package/dist/private/node/ui/hooks/use-abort-signal.d.ts +1 -1
  49. package/dist/private/node/ui/hooks/use-abort-signal.js +8 -3
  50. package/dist/private/node/ui/hooks/use-abort-signal.js.map +1 -1
  51. package/dist/private/node/ui/utilities.d.ts +1 -1
  52. package/dist/private/node/ui.js +1 -1
  53. package/dist/private/node/ui.js.map +1 -1
  54. package/dist/public/common/version.d.ts +1 -1
  55. package/dist/public/common/version.js +1 -1
  56. package/dist/public/common/version.js.map +1 -1
  57. package/dist/public/node/base-command.d.ts +2 -4
  58. package/dist/public/node/base-command.js +18 -4
  59. package/dist/public/node/base-command.js.map +1 -1
  60. package/dist/public/node/dot-env.d.ts +0 -7
  61. package/dist/public/node/dot-env.js +1 -9
  62. package/dist/public/node/dot-env.js.map +1 -1
  63. package/dist/public/node/node-package-manager.d.ts +16 -5
  64. package/dist/public/node/node-package-manager.js +28 -13
  65. package/dist/public/node/node-package-manager.js.map +1 -1
  66. package/dist/public/node/output.d.ts +1 -1
  67. package/dist/public/node/output.js +4 -0
  68. package/dist/public/node/output.js.map +1 -1
  69. package/dist/public/node/system.js +3 -6
  70. package/dist/public/node/system.js.map +1 -1
  71. package/dist/public/node/testing/ui.d.ts +1 -0
  72. package/dist/public/node/testing/ui.js +2 -0
  73. package/dist/public/node/testing/ui.js.map +1 -0
  74. package/dist/public/node/tree-kill.d.ts +7 -2
  75. package/dist/public/node/tree-kill.js +165 -4
  76. package/dist/public/node/tree-kill.js.map +1 -1
  77. package/dist/public/node/ui/components.d.ts +1 -0
  78. package/dist/public/node/ui/components.js +2 -0
  79. package/dist/public/node/ui/components.js.map +1 -0
  80. package/dist/public/node/ui/hooks.d.ts +1 -0
  81. package/dist/public/node/ui/hooks.js +2 -0
  82. package/dist/public/node/ui/hooks.js.map +1 -0
  83. package/dist/public/node/ui.d.ts +3 -10
  84. package/dist/public/node/ui.js +5 -14
  85. package/dist/public/node/ui.js.map +1 -1
  86. package/dist/tsconfig.tsbuildinfo +1 -1
  87. package/package.json +11 -15
@@ -1,12 +1,173 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+ /* eslint-disable jsdoc/require-throws */
3
+ /* eslint-disable jsdoc/require-returns */
4
+ /* eslint-disable no-restricted-imports */
5
+ import { outputDebug } from './output.js';
1
6
  import { printEventsJson } from '../../private/node/demo-recorder.js';
2
- import originalTreeKill from 'tree-kill';
7
+ import { exec, spawn } from 'child_process';
3
8
  /**
4
9
  * Kills the process that calls the method and all its children.
5
10
  *
6
- * @param signal - Type of kill signal to be used.
11
+ * @param pid - Pid of the process to kill.
12
+ * @param killSignal - Type of kill signal to be used.
13
+ * @param killRoot - Whether to kill the root process.
14
+ * @param callback - Optional callback to run after killing the processes.
7
15
  */
8
- export function treeKill(signal) {
16
+ export function treeKill(pid = process.pid, killSignal = 'SIGTERM', killRoot = true, callback) {
17
+ const after = callback ??
18
+ ((error) => {
19
+ if (error)
20
+ outputDebug(`Failed to kill process ${pid}: ${error}`);
21
+ });
9
22
  printEventsJson();
10
- originalTreeKill(process.pid, signal);
23
+ adaptedTreeKill(pid, killSignal, killRoot, after);
24
+ }
25
+ /**
26
+ * Adapted from https://github.com/pkrumins/node-tree-kill.
27
+ *
28
+ * Our implementation allows to skip killing the root process. This is useful for example when
29
+ * gracefully exiting the 'dev' process, as the default tree-kill implementation will cause it
30
+ * to exit with a non-zero code. Instead, we want to treat it as a graceful termination.
31
+ * In addition, we also add debug logging for better visibility in what tree-kill is doing.
32
+ *
33
+ * @param pid - Pid of the process to kill.
34
+ * @param killSignal - Type of kill signal to be used.
35
+ * @param killRoot - Whether to kill the root process.
36
+ * @param callback - Optional callback to run after killing the processes.
37
+ */
38
+ function adaptedTreeKill(pid, killSignal, killRoot, callback) {
39
+ const rootPid = typeof pid === 'number' ? pid.toString() : pid;
40
+ if (Number.isNaN(rootPid)) {
41
+ if (callback) {
42
+ return callback(new Error('pid must be a number'));
43
+ }
44
+ else {
45
+ throw new Error('pid must be a number');
46
+ }
47
+ }
48
+ // A map from parent pid to an array of children pids
49
+ const tree = {};
50
+ tree[rootPid] = [];
51
+ // A set of pids to visit. We use it to recursively find all the children pids
52
+ const pidsToProcess = new Set();
53
+ pidsToProcess.add(rootPid);
54
+ switch (process.platform) {
55
+ case 'win32':
56
+ // @ts-ignore
57
+ exec(`taskkill /pid ${pid} /T /F`, callback);
58
+ break;
59
+ case 'darwin':
60
+ buildProcessTree(rootPid, tree, pidsToProcess, function (parentPid) {
61
+ return spawn('pgrep', ['-lfP', parentPid]);
62
+ }, function () {
63
+ killAll(tree, killSignal, rootPid, killRoot, callback);
64
+ });
65
+ break;
66
+ // Linux
67
+ default:
68
+ buildProcessTree(rootPid, tree, pidsToProcess, function (parentPid) {
69
+ return spawn('ps', ['-o', 'pid command', '--no-headers', '--ppid', parentPid]);
70
+ }, function () {
71
+ killAll(tree, killSignal, rootPid, killRoot, callback);
72
+ });
73
+ break;
74
+ }
75
+ }
76
+ /**
77
+ * Kills all processes in the process tree.
78
+ *
79
+ * @param tree - Process tree.
80
+ * @param killSignal - Type of kill signal to be used.
81
+ * @param rootPid - Pid of the root process.
82
+ * @param killRoot - Whether to kill the root process.
83
+ * @param callback - Optional callback to run after killing the processes.
84
+ */
85
+ function killAll(tree, killSignal, rootPid, killRoot, callback) {
86
+ const killed = new Set();
87
+ try {
88
+ Object.keys(tree).forEach(function (pid) {
89
+ tree[pid].forEach(function (pidpid) {
90
+ if (!killed.has(pidpid)) {
91
+ killPid(pidpid, killSignal);
92
+ killed.add(pidpid);
93
+ }
94
+ });
95
+ if (pid === rootPid && killRoot && !killed.has(pid)) {
96
+ killPid(pid, killSignal);
97
+ killed.add(pid);
98
+ }
99
+ });
100
+ }
101
+ catch (err) {
102
+ if (callback) {
103
+ // @ts-ignore
104
+ return callback(err);
105
+ }
106
+ else {
107
+ throw err;
108
+ }
109
+ }
110
+ if (callback) {
111
+ return callback();
112
+ }
113
+ }
114
+ /**
115
+ * Kills a process.
116
+ *
117
+ * @param pid - Pid of the process to kill.
118
+ * @param killSignal - Type of kill signal to be used.
119
+ */
120
+ function killPid(pid, killSignal) {
121
+ try {
122
+ process.kill(parseInt(pid, 10), killSignal);
123
+ }
124
+ catch (err) {
125
+ // @ts-ignore
126
+ if (err.code !== 'ESRCH')
127
+ throw err;
128
+ }
129
+ }
130
+ /**
131
+ * Builds a process tree.
132
+ *
133
+ * @param parentPid - Pid of the parent process.
134
+ * @param tree - Process tree.
135
+ * @param pidsToProcess - Pids to process.
136
+ * @param spawnChildProcessesList - Function to spawn child processes.
137
+ * @param cb - Callback to run after building the process tree.
138
+ */
139
+ function buildProcessTree(parentPid, tree, pidsToProcess, spawnChildProcessesList, cb) {
140
+ const ps = spawnChildProcessesList(parentPid);
141
+ let allData = '';
142
+ ps.stdout?.on('data', function (data) {
143
+ const dataStr = data.toString('ascii');
144
+ allData += dataStr;
145
+ });
146
+ const onClose = (code) => {
147
+ pidsToProcess.delete(parentPid);
148
+ if (code !== 0) {
149
+ // no more parent processes
150
+ if (pidsToProcess.size === 0) {
151
+ return cb();
152
+ }
153
+ return;
154
+ }
155
+ allData
156
+ .trim()
157
+ .split('\n')
158
+ .forEach(function (line) {
159
+ const match = line.match(/^(\d+)\s(.*)$/);
160
+ if (match) {
161
+ const pid = match[1];
162
+ const cmd = match[2];
163
+ tree[parentPid].push(pid);
164
+ tree[pid] = [];
165
+ outputDebug(`Killing process ${pid}: ${cmd}`);
166
+ pidsToProcess.add(pid);
167
+ buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb);
168
+ }
169
+ });
170
+ };
171
+ ps.on('close', onClose);
11
172
  }
12
173
  //# sourceMappingURL=tree-kill.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree-kill.js","sourceRoot":"","sources":["../../../src/public/node/tree-kill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,qCAAqC,CAAA;AACnE,OAAO,gBAAgB,MAAM,WAAW,CAAA;AAExC;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,eAAe,EAAE,CAAA;IACjB,gBAAgB,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AACvC,CAAC","sourcesContent":["import {printEventsJson} from '../../private/node/demo-recorder.js'\nimport originalTreeKill from 'tree-kill'\n\n/**\n * Kills the process that calls the method and all its children.\n *\n * @param signal - Type of kill signal to be used.\n */\nexport function treeKill(signal: string): void {\n printEventsJson()\n originalTreeKill(process.pid, signal)\n}\n"]}
1
+ {"version":3,"file":"tree-kill.js","sourceRoot":"","sources":["../../../src/public/node/tree-kill.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,yCAAyC;AACzC,0CAA0C;AAC1C,0CAA0C;AAE1C,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,EAAC,eAAe,EAAC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ACd,2BAA2B;YAC3B,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;gBAC5B,OAAO,EAAE,EAAE,CAAA;aACZ;YACD,OAAM;SACP;QAED,OAAO;aACJ,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,OAAO,CAAC,UAAU,IAAI;YACrB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;YACzC,IAAI,KAAK,EAAE;gBACT,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;gBACrB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;gBACrB,IAAI,CAAC,SAAS,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;gBACd,WAAW,CAAC,mBAAmB,GAAG,KAAK,GAAG,EAAE,CAAC,CAAA;gBAC7C,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;gBACtB,gBAAgB,CAAC,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAA;aACxE;QACH,CAAC,CAAC,CAAA;IACN,CAAC,CAAA;IAED,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n/* eslint-disable jsdoc/require-throws */\n/* eslint-disable jsdoc/require-returns */\n/* eslint-disable no-restricted-imports */\n\nimport {outputDebug} from './output.js'\nimport {printEventsJson} from '../../private/node/demo-recorder.js'\nimport {exec, spawn} from 'child_process'\n\ninterface ProcessTree {\n [key: string]: string[]\n}\n\ntype AfterKillCallback = (error?: Error) => void\n\n/**\n * Kills the process that calls the method and all its children.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nexport function treeKill(\n pid: number | string = process.pid,\n killSignal = 'SIGTERM',\n killRoot = true,\n callback?: AfterKillCallback,\n): void {\n const after =\n callback ??\n ((error?: Error) => {\n if (error) outputDebug(`Failed to kill process ${pid}: ${error}`)\n })\n printEventsJson()\n adaptedTreeKill(pid, killSignal, killRoot, after)\n}\n\n/**\n * Adapted from https://github.com/pkrumins/node-tree-kill.\n *\n * Our implementation allows to skip killing the root process. This is useful for example when\n * gracefully exiting the 'dev' process, as the default tree-kill implementation will cause it\n * to exit with a non-zero code. Instead, we want to treat it as a graceful termination.\n * In addition, we also add debug logging for better visibility in what tree-kill is doing.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nfunction adaptedTreeKill(\n pid: number | string,\n killSignal: string,\n killRoot: boolean,\n callback: (error?: Error) => void,\n): void {\n const rootPid = typeof pid === 'number' ? pid.toString() : pid\n\n if (Number.isNaN(rootPid)) {\n if (callback) {\n return callback(new Error('pid must be a number'))\n } else {\n throw new Error('pid must be a number')\n }\n }\n\n // A map from parent pid to an array of children pids\n const tree: ProcessTree = {}\n tree[rootPid] = []\n\n // A set of pids to visit. We use it to recursively find all the children pids\n const pidsToProcess: Set<string> = new Set()\n pidsToProcess.add(rootPid)\n\n switch (process.platform) {\n case 'win32':\n // @ts-ignore\n exec(`taskkill /pid ${pid} /T /F`, callback)\n break\n case 'darwin':\n buildProcessTree(\n rootPid,\n tree,\n pidsToProcess,\n function (parentPid: string) {\n return spawn('pgrep', ['-lfP', parentPid])\n },\n function () {\n killAll(tree, killSignal, rootPid, killRoot, callback)\n },\n )\n break\n // Linux\n default:\n buildProcessTree(\n rootPid,\n tree,\n pidsToProcess,\n function (parentPid: string) {\n return spawn('ps', ['-o', 'pid command', '--no-headers', '--ppid', parentPid])\n },\n function () {\n killAll(tree, killSignal, rootPid, killRoot, callback)\n },\n )\n break\n }\n}\n\n/**\n * Kills all processes in the process tree.\n *\n * @param tree - Process tree.\n * @param killSignal - Type of kill signal to be used.\n * @param rootPid - Pid of the root process.\n * @param killRoot - Whether to kill the root process.\n * @param callback - Optional callback to run after killing the processes.\n */\nfunction killAll(\n tree: ProcessTree,\n killSignal: string,\n rootPid: string,\n killRoot: boolean,\n callback: AfterKillCallback,\n): void {\n const killed: Set<string> = new Set()\n try {\n Object.keys(tree).forEach(function (pid) {\n tree[pid]!.forEach(function (pidpid) {\n if (!killed.has(pidpid)) {\n killPid(pidpid, killSignal)\n killed.add(pidpid)\n }\n })\n if (pid === rootPid && killRoot && !killed.has(pid)) {\n killPid(pid, killSignal)\n killed.add(pid)\n }\n })\n } catch (err: unknown) {\n if (callback) {\n // @ts-ignore\n return callback(err)\n } else {\n throw err\n }\n }\n if (callback) {\n return callback()\n }\n}\n\n/**\n * Kills a process.\n *\n * @param pid - Pid of the process to kill.\n * @param killSignal - Type of kill signal to be used.\n */\nfunction killPid(pid: string, killSignal: string) {\n try {\n process.kill(parseInt(pid, 10), killSignal)\n } catch (err) {\n // @ts-ignore\n if (err.code !== 'ESRCH') throw err\n }\n}\n\n/**\n * Builds a process tree.\n *\n * @param parentPid - Pid of the parent process.\n * @param tree - Process tree.\n * @param pidsToProcess - Pids to process.\n * @param spawnChildProcessesList - Function to spawn child processes.\n * @param cb - Callback to run after building the process tree.\n */\nfunction buildProcessTree(\n parentPid: string,\n tree: ProcessTree,\n pidsToProcess: Set<string>,\n spawnChildProcessesList: (parentPid: string) => ReturnType<typeof spawn>,\n cb: () => void,\n) {\n const ps = spawnChildProcessesList(parentPid)\n let allData = ''\n ps.stdout?.on('data', function (data: Buffer) {\n const dataStr = data.toString('ascii')\n allData += dataStr\n })\n\n const onClose = (code: number) => {\n pidsToProcess.delete(parentPid)\n\n if (code !== 0) {\n // no more parent processes\n if (pidsToProcess.size === 0) {\n return cb()\n }\n return\n }\n\n allData\n .trim()\n .split('\\n')\n .forEach(function (line) {\n const match = line.match(/^(\\d+)\\s(.*)$/)\n if (match) {\n const pid = match[1]!\n const cmd = match[2]!\n tree[parentPid]!.push(pid)\n tree[pid] = []\n outputDebug(`Killing process ${pid}: ${cmd}`)\n pidsToProcess.add(pid)\n buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb)\n }\n })\n }\n\n ps.on('close', onClose)\n}\n"]}
@@ -0,0 +1 @@
1
+ export { ConcurrentOutput } from '../../../private/node/ui/components/ConcurrentOutput.js';
@@ -0,0 +1,2 @@
1
+ export { ConcurrentOutput } from '../../../private/node/ui/components/ConcurrentOutput.js';
2
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../../../../src/public/node/ui/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,yDAAyD,CAAA","sourcesContent":["export {ConcurrentOutput} from '../../../private/node/ui/components/ConcurrentOutput.js'\n"]}
@@ -0,0 +1 @@
1
+ export { default as useAbortSignal } from '../../../private/node/ui/hooks/use-abort-signal.js';
@@ -0,0 +1,2 @@
1
+ export { default as useAbortSignal } from '../../../private/node/ui/hooks/use-abort-signal.js';
2
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../src/public/node/ui/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,oDAAoD,CAAA","sourcesContent":["export {default as useAbortSignal} from '../../../private/node/ui/hooks/use-abort-signal.js'\n"]}
@@ -1,6 +1,7 @@
1
1
  import { FatalError as Fatal } from './error.js';
2
2
  import { Logger, LogLevel } from './output.js';
3
3
  import { ConcurrentOutputProps } from '../../private/node/ui/components/ConcurrentOutput.js';
4
+ import { handleCtrlC, render } from '../../private/node/ui.js';
4
5
  import { AlertOptions } from '../../private/node/ui/alert.js';
5
6
  import { CustomSection } from '../../private/node/ui/components/Alert.js';
6
7
  import ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js';
@@ -15,10 +16,9 @@ import { InfoTableSection } from '../../private/node/ui/components/Prompts/InfoT
15
16
  import { InfoMessageProps } from '../../private/node/ui/components/Prompts/InfoMessage.js';
16
17
  import { Key as InkKey, RenderOptions } from 'ink';
17
18
  type PartialBy<T, TKey extends keyof T> = Omit<T, TKey> & Partial<Pick<T, TKey>>;
18
- export interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps, 'abortController'> {
19
+ export interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps, 'abortSignal'> {
19
20
  renderOptions?: RenderOptions;
20
21
  }
21
- export { FooterContext } from '../../private/node/ui/components/ConcurrentOutput.js';
22
22
  /**
23
23
  * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.
24
24
  * @example
@@ -29,13 +29,6 @@ export { FooterContext } from '../../private/node/ui/components/ConcurrentOutput
29
29
  * 00:00:00 │ frontend │ second frontend message
30
30
  * 00:00:00 │ frontend │ third frontend message
31
31
  *
32
- * ────────────────────────────────────────────────────────────
33
- *
34
- * › Press p │ preview in your browser
35
- * › Press q │ quit.
36
- *
37
- * Preview URL: https://shopify.com
38
- *
39
32
  */
40
33
  export declare function renderConcurrent({ renderOptions, ...props }: RenderConcurrentOptions): Promise<void | void[]>;
41
34
  export type AlertCustomSection = CustomSection;
@@ -377,4 +370,4 @@ export declare function renderText({ text, logLevel, logger }: RenderTextOptions
377
370
  export declare const keypress: () => Promise<unknown>;
378
371
  export type Key = InkKey;
379
372
  export type InfoMessage = InfoMessageProps['message'];
380
- export { Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken };
373
+ export { Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken, render, handleCtrlC };
@@ -5,7 +5,7 @@ import { isUnitTest } from './context/local.js';
5
5
  import { terminalSupportsRawMode } from './system.js';
6
6
  import { AbortController } from './abort.js';
7
7
  import { ConcurrentOutput } from '../../private/node/ui/components/ConcurrentOutput.js';
8
- import { render, renderOnce } from '../../private/node/ui.js';
8
+ import { handleCtrlC, render, renderOnce } from '../../private/node/ui.js';
9
9
  import { alert } from '../../private/node/ui/alert.js';
10
10
  import { FatalError } from '../../private/node/ui/components/FatalError.js';
11
11
  import { Table } from '../../private/node/ui/components/Table/Table.js';
@@ -27,25 +27,15 @@ import React from 'react';
27
27
  * 00:00:00 │ frontend │ second frontend message
28
28
  * 00:00:00 │ frontend │ third frontend message
29
29
  *
30
- * ────────────────────────────────────────────────────────────
31
- *
32
- * › Press p │ preview in your browser
33
- * › Press q │ quit.
34
- *
35
- * Preview URL: https://shopify.com
36
- *
37
30
  */
38
31
  export async function renderConcurrent({ renderOptions, ...props }) {
39
- const abortController = props.abortController ?? new AbortController();
32
+ const abortSignal = props.abortSignal ?? new AbortController().signal;
40
33
  if (terminalSupportsRawMode(renderOptions?.stdin)) {
41
- return render(React.createElement(ConcurrentOutput, { ...props, abortController: abortController }), {
42
- ...renderOptions,
43
- exitOnCtrlC: typeof props.onInput === 'undefined' && typeof props.onInputAsync === 'undefined',
44
- });
34
+ return render(React.createElement(ConcurrentOutput, { ...props, abortSignal: abortSignal }), renderOptions);
45
35
  }
46
36
  else {
47
37
  return Promise.all(props.processes.map(async (concurrentProcess) => {
48
- await concurrentProcess.action(process.stdout, process.stderr, abortController.signal);
38
+ await concurrentProcess.action(process.stdout, process.stderr, abortSignal);
49
39
  }));
50
40
  }
51
41
  }
@@ -515,4 +505,5 @@ ${outputContent `${outputToken.cyan(promptText)}`.value}
515
505
  This usually happens when running a command non-interactively, for example in a CI environment, or when piping input from another process.`;
516
506
  throw new AbortError(errorMessage, 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.');
517
507
  }
508
+ export { render, handleCtrlC };
518
509
  //# sourceMappingURL=ui.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,EAAC,UAA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-disable tsdoc/syntax */\nimport {AbortError, AbortSilentError, FatalError as Fatal, FatalErrorType} from './error.js'\nimport {\n collectLog,\n consoleError,\n consoleLog,\n Logger,\n LogLevel,\n outputContent,\n outputDebug,\n outputToken,\n outputWhereAppropriate,\n} from './output.js'\nimport {isUnitTest} from './context/local.js'\nimport {terminalSupportsRawMode} from './system.js'\nimport {AbortController} from './abort.js'\nimport {ConcurrentOutput, ConcurrentOutputProps} from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {render, renderOnce} from '../../private/node/ui.js'\nimport {alert, AlertOptions} from '../../private/node/ui/alert.js'\nimport {CustomSection} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js'\nimport {Table, TableColumn, TableProps} from '../../private/node/ui/components/Table/Table.js'\nimport {\n tokenItemToString,\n InlineToken,\n LinkToken,\n ListToken,\n TokenItem,\n} from '../../private/node/ui/components/TokenizedText.js'\nimport {\n DangerousConfirmationPrompt,\n DangerousConfirmationPromptProps,\n} from '../../private/node/ui/components/DangerousConfirmationPrompt.js'\nimport {SelectPrompt, SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {TextPrompt, TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport {AutocompletePromptProps, AutocompletePrompt} from '../../private/node/ui/components/AutocompletePrompt.js'\nimport {InfoTableSection} from '../../private/node/ui/components/Prompts/InfoTable.js'\nimport {recordUIEvent, resetRecordedSleep} from '../../private/node/demo-recorder.js'\nimport {InfoMessageProps} from '../../private/node/ui/components/Prompts/InfoMessage.js'\nimport React from 'react'\nimport {Key as InkKey, RenderOptions} from 'ink'\n\ntype PartialBy<T, TKey extends keyof T> = Omit<T, TKey> & Partial<Pick<T, TKey>>\n\nexport interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps, 'abortController'> {\n renderOptions?: RenderOptions\n}\n\nexport {FooterContext} from '../../private/node/ui/components/ConcurrentOutput.js'\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n * @example\n * 00:00:00 │ backend │ first backend message\n * 00:00:00 │ backend │ second backend message\n * 00:00:00 │ backend │ third backend message\n * 00:00:00 │ frontend │ first frontend message\n * 00:00:00 │ frontend │ second frontend message\n * 00:00:00 │ frontend │ third frontend message\n *\n * ────────────────────────────────────────────────────────────\n *\n * › Press p │ preview in your browser\n * › Press q │ quit.\n *\n * Preview URL: https://shopify.com\n *\n */\nexport async function renderConcurrent({renderOptions, ...props}: RenderConcurrentOptions) {\n const abortController = props.abortController ?? new AbortController()\n\n if (terminalSupportsRawMode(renderOptions?.stdin)) {\n return render(<ConcurrentOutput {...props} abortController={abortController} />, {\n ...renderOptions,\n exitOnCtrlC: typeof props.onInput === 'undefined' && typeof props.onInputAsync === 'undefined',\n })\n } else {\n return Promise.all(\n props.processes.map(async (concurrentProcess) => {\n await concurrentProcess.action(process.stdout, process.stderr, abortController.signal)\n }),\n )\n }\n}\n\nexport type AlertCustomSection = CustomSection\nexport type RenderAlertOptions = Omit<AlertOptions, 'type'>\n\n/**\n * Renders an information banner to the console.\n * @example Basic\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ CLI update available. │\n * │ │\n * │ Run `npm run shopify upgrade`. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ my-app initialized and ready to build. │\n * │ │\n * │ Next steps │\n * │ • Run `cd verification-app` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Dev docs [1] │\n * │ │\n * │ Custom section │\n * │ • Item 1 [2] │\n * │ • Item 2 │\n * │ • Item 3 [3] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://shopify.dev\n * [2] https://www.google.com/search?q=jh56t9l34kpo35tw8s28hn7s\n * 9s2xvzla01d8cn6j7yq&rlz=1C1GCEU_enUS832US832&oq=jh56t9l34kpo\n * 35tw8s28hn7s9s2xvzla01d8cn6j7yq&aqs=chrome.0.35i39l2j0l4j46j\n * 69i60.2711j0j7&sourceid=chrome&ie=UTF-8\n * [3] https://shopify.com\n *\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n * @example Basic\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ CLI updated. │\n * │ │\n * │ You are now running version 3.47. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Deployment successful. │\n * │ │\n * │ Your extensions have been uploaded to your Shopify │\n * │ Partners Dashboard. │\n * │ │\n * │ Next steps │\n * │ • See your deployment and set it live [1] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://partners.shopify.com/1797046/apps/4523695/deploy\n * ments\n *\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n * @example Basic\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ You have reached your limit of checkout extensions for │\n * │ this app. │\n * │ │\n * │ You can free up space for a new one by deleting an │\n * │ existing one. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Required access scope update. │\n * │ │\n * │ The deadline for re-selecting your app scopes is May │\n * │ 1, 2022. │\n * │ │\n * │ Reference │\n * │ • Dev docs [1] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://shopify.dev/app/scopes\n *\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\n/**\n * Renders an error banner to the console.\n * @example\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Version couldn't be released. │\n * │ │\n * │ This version needs to be submitted for review and │\n * │ approved by Shopify before it can be released. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n */\nexport function renderError(options: RenderAlertOptions) {\n return alert({...options, type: 'error'})\n}\n\ninterface RenderFatalErrorOptions {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n * @example Basic\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Something went wrong. │\n * │ │\n * │ To investigate the issue, examine this stack trace: │\n * │ at _compile (internal/modules/cjs/loader.js:1137) │\n * │ at js (internal/modules/cjs/loader.js:1157) │\n * │ at load (internal/modules/cjs/loader.js:985) │\n * │ at _load (internal/modules/cjs/loader.js:878) │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ No Organization found │\n * │ │\n * │ Next steps │\n * │ • Have you created a Shopify Partners organization │\n * │ [1]? │\n * │ • Have you confirmed your accounts from the emails │\n * │ you received? │\n * │ • Need to connect to a different App or │\n * │ organization? Run the command again with `--reset` │\n * │ │\n * │ amortizable-marketplace-ext │\n * │ • Some other error │\n * │ Validation errors │\n * │ • Missing expected key(s). │\n * │ │\n * │ amortizable-marketplace-ext-2 │\n * │ • Something was not found │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://partners.shopify.com/signup\n *\n */\n// eslint-disable-next-line max-params\nexport function renderFatalError(error: Fatal, {renderOptions}: RenderFatalErrorOptions = {}) {\n recordUIEvent({\n type: 'fatalError',\n properties: {...error, errorType: error.type === FatalErrorType.Bug ? 'bug' : 'abort'},\n })\n\n return renderOnce(<FatalError error={error} />, {logLevel: 'error', logger: consoleError, renderOptions})\n}\n\nexport interface RenderSelectPromptOptions<T> extends Omit<SelectPromptProps<T>, 'onSubmit'> {\n isConfirmationPrompt?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a select prompt to the console.\n * @example\n * ? Associate your project with the org Castile Ventures?\n *\n * ┃ Add\n * ┃ • new-ext\n * ┃\n * ┃ Remove\n * ┃ • integrated-demand-ext\n * ┃ • order-discount\n *\n * Automations\n * > fifth\n * sixth\n *\n * Merchant Admin\n * eighth\n * ninth\n *\n * Other\n * first\n * second\n * third (limit reached)\n * fourth\n * seventh\n * tenth\n *\n * Press ↑↓ arrows to select, enter to confirm.\n *\n */\nexport async function renderSelectPrompt<T>({\n renderOptions,\n isConfirmationPrompt,\n ...props\n}: RenderSelectPromptOptions<T>): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n if (!isConfirmationPrompt) {\n recordUIEvent({type: 'selectPrompt', properties: {renderOptions, ...props}})\n }\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<SelectPrompt {...props} onSubmit={(value: T) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\nexport interface RenderConfirmationPromptOptions\n extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable' | 'infoMessage' | 'gitDiff' | 'abortSignal'> {\n confirmationMessage?: string\n cancellationMessage?: string\n renderOptions?: RenderOptions\n defaultValue?: boolean\n}\n\n/**\n * Renders a confirmation prompt to the console.\n * @example\n * ? Delete the following themes from the store?\n *\n * ┃ Info message title\n * ┃\n * ┃ Info message body\n * ┃\n * ┃ • first theme (#1)\n * ┃ • second theme (#2)\n *\n * > (y) Yes, confirm changes\n * (n) Cancel\n *\n * Press ↑↓ arrows to select, enter or a shortcut to\n * confirm.\n *\n */\nexport async function renderConfirmationPrompt({\n message,\n infoTable,\n gitDiff,\n confirmationMessage = 'Yes, confirm',\n cancellationMessage = 'No, cancel',\n renderOptions,\n defaultValue = true,\n abortSignal,\n infoMessage,\n}: RenderConfirmationPromptOptions): Promise<boolean> {\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'confirmationPrompt', properties: arguments[0]})\n\n const choices = [\n {\n label: confirmationMessage,\n value: true,\n key: 'y',\n },\n {\n label: cancellationMessage,\n value: false,\n key: 'n',\n },\n ]\n\n return renderSelectPrompt({\n choices,\n message,\n infoTable,\n gitDiff,\n renderOptions,\n defaultValue,\n isConfirmationPrompt: true,\n abortSignal,\n infoMessage,\n })\n}\n\nexport interface RenderAutocompleteOptions<T>\n extends PartialBy<Omit<AutocompletePromptProps<T>, 'onSubmit'>, 'search'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders an autocomplete prompt to the console.\n * @example\n * ? Select a template: Type to search...\n *\n * ┃ Info message title\n * ┃\n * ┃ Info message body\n *\n * > first\n * second\n * third\n * fourth\n * fifth\n * sixth\n * seventh\n * eighth\n * ninth\n * tenth\n * eleventh\n * twelfth\n * thirteenth\n * fourteenth\n * fifteenth\n * sixteenth\n * seventeenth\n * eighteenth\n * nineteenth (disabled)\n * twentieth\n * twenty-first\n * twenty-second\n * twenty-third\n * twenty-fourth\n * twenty-fifth\n *\n * Press ↑↓ arrows to select, enter to confirm.\n *\n */\nexport async function renderAutocompletePrompt<T>({renderOptions, ...props}: RenderAutocompleteOptions<T>): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'autocompletePrompt', properties: arguments[0]})\n\n const newProps = {\n search(term: string) {\n const lowerTerm = term.toLowerCase()\n return Promise.resolve({\n data: props.choices.filter((item) => {\n return (\n item.label.toLowerCase().includes(lowerTerm) || (item.group && item.group.toLowerCase().includes(lowerTerm))\n )\n }),\n })\n },\n ...props,\n }\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<AutocompletePrompt {...newProps} onSubmit={(value: T) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\ninterface RenderTableOptions<T extends ScalarDict> extends TableProps<T> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a table to the console.\n * @example\n * ID Name email\n * ── ────────── ─────────────\n * 1 John Doe jon@doe.com\n * 2 Jane Doe jane@doe.com\n * 3 John Smith jon@smith.com\n */\nexport function renderTable<T extends ScalarDict>({renderOptions, ...props}: RenderTableOptions<T>) {\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'table', properties: arguments[0]})\n\n return renderOnce(<Table {...props} />, {renderOptions})\n}\n\ninterface RenderTasksOptions {\n renderOptions?: RenderOptions\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n * @example\n * ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀\n * Installing dependencies ...\n */\n// eslint-disable-next-line max-params\nexport async function renderTasks<TContext>(tasks: Task<TContext>[], {renderOptions}: RenderTasksOptions = {}) {\n recordUIEvent({\n type: 'taskbar',\n properties: {\n // Rather than timing exactly, pretend each step takes 2 seconds. This\n // should be easy to tweak manually.\n steps: tasks.map((task) => {\n return {title: task.title, duration: 2}\n }),\n },\n })\n\n // eslint-disable-next-line max-params\n return new Promise<TContext>((resolve, reject) => {\n render(<Tasks tasks={tasks} onComplete={resolve} />, renderOptions)\n .then(() => resetRecordedSleep())\n .catch(reject)\n })\n}\n\nexport interface RenderTextPromptOptions extends Omit<TextPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a text prompt to the console.\n * @example\n * ? App project name (can be changed later):\n * > expansive commerce app\n * ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n *\n */\nexport async function renderTextPrompt({renderOptions, ...props}: RenderTextPromptOptions): Promise<string> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'textPrompt', properties: arguments[0]})\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<TextPrompt {...props} onSubmit={(value: string) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\nexport interface RenderDangerousConfirmationPromptOptions extends Omit<DangerousConfirmationPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a dangerous confirmation prompt to the console, forcing the user to\n * type a confirmation string to proceed.\n * @example\n * ? Release a new version of nightly-app-2023-06-19?\n *\n * ┃ Includes:\n * ┃ + web-px (new)\n * ┃ + sub-ui-ext\n * ┃ + theme-app-ext\n * ┃ + paymentify (from Partner Dashboard)\n * ┃\n * ┃ Removes:\n * ┃ - prod-discount-fun\n * ┃\n * ┃ This can permanently delete app user data.\n *\n * Type nightly-app-2023-06-19 to confirm, or press Escape\n * to cancel.\n * > █\n * ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n *\n */\nexport async function renderDangerousConfirmationPrompt({\n renderOptions,\n ...props\n}: RenderDangerousConfirmationPromptOptions): Promise<boolean> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'dangerousConfirmationPrompt', properties: arguments[0]})\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<DangerousConfirmationPrompt {...props} onSubmit={(value: boolean) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\ninterface RenderTextOptions {\n text: string\n logLevel?: LogLevel\n logger?: Logger\n}\n\n/** Renders a text string to the console.\n * Using this function makes sure that correct spacing is applied among the various components.\n * @example\n * Hello world!\n *\n */\nexport function renderText({text, logLevel = 'info', logger = consoleLog}: RenderTextOptions) {\n let textWithLineReturn = text\n if (!text.endsWith('\\n')) textWithLineReturn += '\\n'\n\n if (isUnitTest()) collectLog(logLevel, textWithLineReturn)\n outputWhereAppropriate(logLevel, logger, textWithLineReturn)\n return textWithLineReturn\n}\n\n/** Waits for any key to be pressed except Ctrl+C which will terminate the process. */\nexport const keypress = async () => {\n throwInNonTTY({message: 'Press any key'})\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n process.stdin.setRawMode(false)\n process.stdin.pause()\n\n const bytes = Array.from(buffer)\n\n if (bytes.length && bytes[0] === 3) {\n outputDebug('Canceled keypress, User pressed CTRL+C')\n reject(new AbortSilentError())\n }\n process.nextTick(resolve)\n }\n\n process.stdin.resume()\n process.stdin.setRawMode(true)\n process.stdin.once('data', handler)\n })\n}\n\ninterface ThrowInNonTTYOptions {\n message: TokenItem\n stdin?: NodeJS.ReadStream\n}\n\nfunction throwInNonTTY({message, stdin = undefined}: ThrowInNonTTYOptions) {\n if (stdin || terminalSupportsRawMode()) return\n\n const promptText = tokenItemToString(message)\n const errorMessage = `Failed to prompt:\n\n${outputContent`${outputToken.cyan(promptText)}`.value}\n\nThis usually happens when running a command non-interactively, for example in a CI environment, or when piping input from another process.`\n throw new AbortError(\n errorMessage,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n}\n\nexport type Key = InkKey\nexport type InfoMessage = InfoMessageProps['message']\nexport {Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAuB,cAAc,EAAC,MAAM,YAAY,CAAA;AAC5F,OAAO,EACL,UAAU,EACV,YAAY,E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jC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;YAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;YAErB,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAEhC,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;gBAClC,WAAW,CAAC,wCAAwC,CAAC,CAAA;gBACrD,MAAM,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAA;aAC/B;YACD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC3B,CAAC,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,CAAA;QACtB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAOD,SAAS,aAAa,CAAC,EAAC,OAAO,EAAE,KAAK,GAAG,SAAS,EAAuB;IACvE,IAAI,KAAK,IAAI,uBAAuB,EAAE;QAAE,OAAM;IAE9C,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAC7C,MAAM,YAAY,GAAG;;EAErB,aAAa,CAAA,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK;;2IAEqF,CAAA;IACzI,MAAM,IAAI,UAAU,CAClB,YAAY,EACZ,mIAAmI,CACpI,CAAA;AACH,CAAC;AAID,OAAO,EAAoF,MAAM,EAAE,WAAW,EAAC,CAAA","sourcesContent":["/* eslint-disable tsdoc/syntax */\nimport {AbortError, AbortSilentError, FatalError as Fatal, FatalErrorType} from './error.js'\nimport {\n collectLog,\n consoleError,\n consoleLog,\n Logger,\n LogLevel,\n outputContent,\n outputDebug,\n outputToken,\n outputWhereAppropriate,\n} from './output.js'\nimport {isUnitTest} from './context/local.js'\nimport {terminalSupportsRawMode} from './system.js'\nimport {AbortController} from './abort.js'\nimport {ConcurrentOutput, ConcurrentOutputProps} from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {handleCtrlC, render, renderOnce} from '../../private/node/ui.js'\nimport {alert, AlertOptions} from '../../private/node/ui/alert.js'\nimport {CustomSection} from '../../private/node/ui/components/Alert.js'\nimport {FatalError} from '../../private/node/ui/components/FatalError.js'\nimport ScalarDict from '../../private/node/ui/components/Table/ScalarDict.js'\nimport {Table, TableColumn, TableProps} from '../../private/node/ui/components/Table/Table.js'\nimport {\n tokenItemToString,\n InlineToken,\n LinkToken,\n ListToken,\n TokenItem,\n} from '../../private/node/ui/components/TokenizedText.js'\nimport {\n DangerousConfirmationPrompt,\n DangerousConfirmationPromptProps,\n} from '../../private/node/ui/components/DangerousConfirmationPrompt.js'\nimport {SelectPrompt, SelectPromptProps} from '../../private/node/ui/components/SelectPrompt.js'\nimport {Tasks, Task} from '../../private/node/ui/components/Tasks.js'\nimport {TextPrompt, TextPromptProps} from '../../private/node/ui/components/TextPrompt.js'\nimport {AutocompletePromptProps, AutocompletePrompt} from '../../private/node/ui/components/AutocompletePrompt.js'\nimport {InfoTableSection} from '../../private/node/ui/components/Prompts/InfoTable.js'\nimport {recordUIEvent, resetRecordedSleep} from '../../private/node/demo-recorder.js'\nimport {InfoMessageProps} from '../../private/node/ui/components/Prompts/InfoMessage.js'\nimport React from 'react'\nimport {Key as InkKey, RenderOptions} from 'ink'\n\ntype PartialBy<T, TKey extends keyof T> = Omit<T, TKey> & Partial<Pick<T, TKey>>\n\nexport interface RenderConcurrentOptions extends PartialBy<ConcurrentOutputProps, 'abortSignal'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n * @example\n * 00:00:00 │ backend │ first backend message\n * 00:00:00 │ backend │ second backend message\n * 00:00:00 │ backend │ third backend message\n * 00:00:00 │ frontend │ first frontend message\n * 00:00:00 │ frontend │ second frontend message\n * 00:00:00 │ frontend │ third frontend message\n *\n */\nexport async function renderConcurrent({renderOptions, ...props}: RenderConcurrentOptions) {\n const abortSignal = props.abortSignal ?? new AbortController().signal\n\n if (terminalSupportsRawMode(renderOptions?.stdin)) {\n return render(<ConcurrentOutput {...props} abortSignal={abortSignal} />, renderOptions)\n } else {\n return Promise.all(\n props.processes.map(async (concurrentProcess) => {\n await concurrentProcess.action(process.stdout, process.stderr, abortSignal)\n }),\n )\n }\n}\n\nexport type AlertCustomSection = CustomSection\nexport type RenderAlertOptions = Omit<AlertOptions, 'type'>\n\n/**\n * Renders an information banner to the console.\n * @example Basic\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ CLI update available. │\n * │ │\n * │ Run `npm run shopify upgrade`. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ my-app initialized and ready to build. │\n * │ │\n * │ Next steps │\n * │ • Run `cd verification-app` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Dev docs [1] │\n * │ │\n * │ Custom section │\n * │ • Item 1 [2] │\n * │ • Item 2 │\n * │ • Item 3 [3] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://shopify.dev\n * [2] https://www.google.com/search?q=jh56t9l34kpo35tw8s28hn7s\n * 9s2xvzla01d8cn6j7yq&rlz=1C1GCEU_enUS832US832&oq=jh56t9l34kpo\n * 35tw8s28hn7s9s2xvzla01d8cn6j7yq&aqs=chrome.0.35i39l2j0l4j46j\n * 69i60.2711j0j7&sourceid=chrome&ie=UTF-8\n * [3] https://shopify.com\n *\n */\nexport function renderInfo(options: RenderAlertOptions) {\n return alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n * @example Basic\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ CLI updated. │\n * │ │\n * │ You are now running version 3.47. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Deployment successful. │\n * │ │\n * │ Your extensions have been uploaded to your Shopify │\n * │ Partners Dashboard. │\n * │ │\n * │ Next steps │\n * │ • See your deployment and set it live [1] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://partners.shopify.com/1797046/apps/4523695/deploy\n * ments\n *\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n return alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n * @example Basic\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ You have reached your limit of checkout extensions for │\n * │ this app. │\n * │ │\n * │ You can free up space for a new one by deleting an │\n * │ existing one. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Required access scope update. │\n * │ │\n * │ The deadline for re-selecting your app scopes is May │\n * │ 1, 2022. │\n * │ │\n * │ Reference │\n * │ • Dev docs [1] │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://shopify.dev/app/scopes\n *\n */\nexport function renderWarning(options: RenderAlertOptions) {\n return alert({...options, type: 'warning'})\n}\n\n/**\n * Renders an error banner to the console.\n * @example\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Version couldn't be released. │\n * │ │\n * │ This version needs to be submitted for review and │\n * │ approved by Shopify before it can be released. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n */\nexport function renderError(options: RenderAlertOptions) {\n return alert({...options, type: 'error'})\n}\n\ninterface RenderFatalErrorOptions {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n * @example Basic\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Something went wrong. │\n * │ │\n * │ To investigate the issue, examine this stack trace: │\n * │ at _compile (internal/modules/cjs/loader.js:1137) │\n * │ at js (internal/modules/cjs/loader.js:1157) │\n * │ at load (internal/modules/cjs/loader.js:985) │\n * │ at _load (internal/modules/cjs/loader.js:878) │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n *\n * @example Complete\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ No Organization found │\n * │ │\n * │ Next steps │\n * │ • Have you created a Shopify Partners organization │\n * │ [1]? │\n * │ • Have you confirmed your accounts from the emails │\n * │ you received? │\n * │ • Need to connect to a different App or │\n * │ organization? Run the command again with `--reset` │\n * │ │\n * │ amortizable-marketplace-ext │\n * │ • Some other error │\n * │ Validation errors │\n * │ • Missing expected key(s). │\n * │ │\n * │ amortizable-marketplace-ext-2 │\n * │ • Something was not found │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * [1] https://partners.shopify.com/signup\n *\n */\n// eslint-disable-next-line max-params\nexport function renderFatalError(error: Fatal, {renderOptions}: RenderFatalErrorOptions = {}) {\n recordUIEvent({\n type: 'fatalError',\n properties: {...error, errorType: error.type === FatalErrorType.Bug ? 'bug' : 'abort'},\n })\n\n return renderOnce(<FatalError error={error} />, {logLevel: 'error', logger: consoleError, renderOptions})\n}\n\nexport interface RenderSelectPromptOptions<T> extends Omit<SelectPromptProps<T>, 'onSubmit'> {\n isConfirmationPrompt?: boolean\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a select prompt to the console.\n * @example\n * ? Associate your project with the org Castile Ventures?\n *\n * ┃ Add\n * ┃ • new-ext\n * ┃\n * ┃ Remove\n * ┃ • integrated-demand-ext\n * ┃ • order-discount\n *\n * Automations\n * > fifth\n * sixth\n *\n * Merchant Admin\n * eighth\n * ninth\n *\n * Other\n * first\n * second\n * third (limit reached)\n * fourth\n * seventh\n * tenth\n *\n * Press ↑↓ arrows to select, enter to confirm.\n *\n */\nexport async function renderSelectPrompt<T>({\n renderOptions,\n isConfirmationPrompt,\n ...props\n}: RenderSelectPromptOptions<T>): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n if (!isConfirmationPrompt) {\n recordUIEvent({type: 'selectPrompt', properties: {renderOptions, ...props}})\n }\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<SelectPrompt {...props} onSubmit={(value: T) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\nexport interface RenderConfirmationPromptOptions\n extends Pick<SelectPromptProps<boolean>, 'message' | 'infoTable' | 'infoMessage' | 'gitDiff' | 'abortSignal'> {\n confirmationMessage?: string\n cancellationMessage?: string\n renderOptions?: RenderOptions\n defaultValue?: boolean\n}\n\n/**\n * Renders a confirmation prompt to the console.\n * @example\n * ? Delete the following themes from the store?\n *\n * ┃ Info message title\n * ┃\n * ┃ Info message body\n * ┃\n * ┃ • first theme (#1)\n * ┃ • second theme (#2)\n *\n * > (y) Yes, confirm changes\n * (n) Cancel\n *\n * Press ↑↓ arrows to select, enter or a shortcut to\n * confirm.\n *\n */\nexport async function renderConfirmationPrompt({\n message,\n infoTable,\n gitDiff,\n confirmationMessage = 'Yes, confirm',\n cancellationMessage = 'No, cancel',\n renderOptions,\n defaultValue = true,\n abortSignal,\n infoMessage,\n}: RenderConfirmationPromptOptions): Promise<boolean> {\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'confirmationPrompt', properties: arguments[0]})\n\n const choices = [\n {\n label: confirmationMessage,\n value: true,\n key: 'y',\n },\n {\n label: cancellationMessage,\n value: false,\n key: 'n',\n },\n ]\n\n return renderSelectPrompt({\n choices,\n message,\n infoTable,\n gitDiff,\n renderOptions,\n defaultValue,\n isConfirmationPrompt: true,\n abortSignal,\n infoMessage,\n })\n}\n\nexport interface RenderAutocompleteOptions<T>\n extends PartialBy<Omit<AutocompletePromptProps<T>, 'onSubmit'>, 'search'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders an autocomplete prompt to the console.\n * @example\n * ? Select a template: Type to search...\n *\n * ┃ Info message title\n * ┃\n * ┃ Info message body\n *\n * > first\n * second\n * third\n * fourth\n * fifth\n * sixth\n * seventh\n * eighth\n * ninth\n * tenth\n * eleventh\n * twelfth\n * thirteenth\n * fourteenth\n * fifteenth\n * sixteenth\n * seventeenth\n * eighteenth\n * nineteenth (disabled)\n * twentieth\n * twenty-first\n * twenty-second\n * twenty-third\n * twenty-fourth\n * twenty-fifth\n *\n * Press ↑↓ arrows to select, enter to confirm.\n *\n */\nexport async function renderAutocompletePrompt<T>({renderOptions, ...props}: RenderAutocompleteOptions<T>): Promise<T> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'autocompletePrompt', properties: arguments[0]})\n\n const newProps = {\n search(term: string) {\n const lowerTerm = term.toLowerCase()\n return Promise.resolve({\n data: props.choices.filter((item) => {\n return (\n item.label.toLowerCase().includes(lowerTerm) || (item.group && item.group.toLowerCase().includes(lowerTerm))\n )\n }),\n })\n },\n ...props,\n }\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<AutocompletePrompt {...newProps} onSubmit={(value: T) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\ninterface RenderTableOptions<T extends ScalarDict> extends TableProps<T> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a table to the console.\n * @example\n * ID Name email\n * ── ────────── ─────────────\n * 1 John Doe jon@doe.com\n * 2 Jane Doe jane@doe.com\n * 3 John Smith jon@smith.com\n */\nexport function renderTable<T extends ScalarDict>({renderOptions, ...props}: RenderTableOptions<T>) {\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'table', properties: arguments[0]})\n\n return renderOnce(<Table {...props} />, {renderOptions})\n}\n\ninterface RenderTasksOptions {\n renderOptions?: RenderOptions\n}\n\n/**\n * Runs async tasks and displays their progress to the console.\n * @example\n * ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀\n * Installing dependencies ...\n */\n// eslint-disable-next-line max-params\nexport async function renderTasks<TContext>(tasks: Task<TContext>[], {renderOptions}: RenderTasksOptions = {}) {\n recordUIEvent({\n type: 'taskbar',\n properties: {\n // Rather than timing exactly, pretend each step takes 2 seconds. This\n // should be easy to tweak manually.\n steps: tasks.map((task) => {\n return {title: task.title, duration: 2}\n }),\n },\n })\n\n // eslint-disable-next-line max-params\n return new Promise<TContext>((resolve, reject) => {\n render(<Tasks tasks={tasks} onComplete={resolve} />, renderOptions)\n .then(() => resetRecordedSleep())\n .catch(reject)\n })\n}\n\nexport interface RenderTextPromptOptions extends Omit<TextPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a text prompt to the console.\n * @example\n * ? App project name (can be changed later):\n * > expansive commerce app\n * ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n *\n */\nexport async function renderTextPrompt({renderOptions, ...props}: RenderTextPromptOptions): Promise<string> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'textPrompt', properties: arguments[0]})\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<TextPrompt {...props} onSubmit={(value: string) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\nexport interface RenderDangerousConfirmationPromptOptions extends Omit<DangerousConfirmationPromptProps, 'onSubmit'> {\n renderOptions?: RenderOptions\n}\n\n/**\n * Renders a dangerous confirmation prompt to the console, forcing the user to\n * type a confirmation string to proceed.\n * @example\n * ? Release a new version of nightly-app-2023-06-19?\n *\n * ┃ Includes:\n * ┃ + web-px (new)\n * ┃ + sub-ui-ext\n * ┃ + theme-app-ext\n * ┃ + paymentify (from Partner Dashboard)\n * ┃\n * ┃ Removes:\n * ┃ - prod-discount-fun\n * ┃\n * ┃ This can permanently delete app user data.\n *\n * Type nightly-app-2023-06-19 to confirm, or press Escape\n * to cancel.\n * > █\n * ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n *\n */\nexport async function renderDangerousConfirmationPrompt({\n renderOptions,\n ...props\n}: RenderDangerousConfirmationPromptOptions): Promise<boolean> {\n throwInNonTTY({message: props.message, stdin: renderOptions?.stdin})\n\n // eslint-disable-next-line prefer-rest-params\n recordUIEvent({type: 'dangerousConfirmationPrompt', properties: arguments[0]})\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n render(<DangerousConfirmationPrompt {...props} onSubmit={(value: boolean) => resolve(value)} />, {\n ...renderOptions,\n exitOnCtrlC: false,\n })\n .catch(reject)\n .finally(resetRecordedSleep)\n })\n}\n\ninterface RenderTextOptions {\n text: string\n logLevel?: LogLevel\n logger?: Logger\n}\n\n/** Renders a text string to the console.\n * Using this function makes sure that correct spacing is applied among the various components.\n * @example\n * Hello world!\n *\n */\nexport function renderText({text, logLevel = 'info', logger = consoleLog}: RenderTextOptions) {\n let textWithLineReturn = text\n if (!text.endsWith('\\n')) textWithLineReturn += '\\n'\n\n if (isUnitTest()) collectLog(logLevel, textWithLineReturn)\n outputWhereAppropriate(logLevel, logger, textWithLineReturn)\n return textWithLineReturn\n}\n\n/** Waits for any key to be pressed except Ctrl+C which will terminate the process. */\nexport const keypress = async () => {\n throwInNonTTY({message: 'Press any key'})\n\n // eslint-disable-next-line max-params\n return new Promise((resolve, reject) => {\n const handler = (buffer: Buffer) => {\n process.stdin.setRawMode(false)\n process.stdin.pause()\n\n const bytes = Array.from(buffer)\n\n if (bytes.length && bytes[0] === 3) {\n outputDebug('Canceled keypress, User pressed CTRL+C')\n reject(new AbortSilentError())\n }\n process.nextTick(resolve)\n }\n\n process.stdin.resume()\n process.stdin.setRawMode(true)\n process.stdin.once('data', handler)\n })\n}\n\ninterface ThrowInNonTTYOptions {\n message: TokenItem\n stdin?: NodeJS.ReadStream\n}\n\nfunction throwInNonTTY({message, stdin = undefined}: ThrowInNonTTYOptions) {\n if (stdin || terminalSupportsRawMode()) return\n\n const promptText = tokenItemToString(message)\n const errorMessage = `Failed to prompt:\n\n${outputContent`${outputToken.cyan(promptText)}`.value}\n\nThis usually happens when running a command non-interactively, for example in a CI environment, or when piping input from another process.`\n throw new AbortError(\n errorMessage,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n}\n\nexport type Key = InkKey\nexport type InfoMessage = InfoMessageProps['message']\nexport {Task, TokenItem, InlineToken, LinkToken, TableColumn, InfoTableSection, ListToken, render, handleCtrlC}\n"]}