@shopify/cli-kit 3.37.0 → 3.39.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 (191) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +0 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/private/common/json.d.ts +2 -2
  5. package/dist/private/common/lodash.d.ts +4 -4
  6. package/dist/private/common/ts/overloaded-parameters.d.ts +5 -5
  7. package/dist/private/node/api/graphql.js +7 -7
  8. package/dist/private/node/api/graphql.js.map +1 -1
  9. package/dist/private/node/api/headers.d.ts +1 -1
  10. package/dist/private/node/api.d.ts +2 -0
  11. package/dist/{network → private/node}/api.js +0 -0
  12. package/dist/private/node/api.js.map +1 -0
  13. package/dist/private/node/conf-store.js +4 -4
  14. package/dist/private/node/conf-store.js.map +1 -1
  15. package/dist/private/node/constants.d.ts +2 -2
  16. package/dist/{content-tokens.d.ts → private/node/content-tokens.d.ts} +11 -11
  17. package/dist/{content-tokens.js → private/node/content-tokens.js} +3 -3
  18. package/dist/private/node/content-tokens.js.map +1 -0
  19. package/dist/private/node/environment/service.d.ts +1 -1
  20. package/dist/private/node/error-handler.d.ts +2 -0
  21. package/dist/private/node/error-handler.js +5 -0
  22. package/dist/private/node/error-handler.js.map +1 -0
  23. package/dist/private/node/secure-store.js +4 -4
  24. package/dist/private/node/secure-store.js.map +1 -1
  25. package/dist/private/node/session/authorize.js +3 -3
  26. package/dist/private/node/session/authorize.js.map +1 -1
  27. package/dist/private/node/session/device-authorization.js +6 -6
  28. package/dist/private/node/session/device-authorization.js.map +1 -1
  29. package/dist/private/node/session/exchange.d.ts +1 -1
  30. package/dist/private/node/session/exchange.js.map +1 -1
  31. package/dist/private/node/session/identity-token-validation.js +5 -5
  32. package/dist/private/node/session/identity-token-validation.js.map +1 -1
  33. package/dist/private/node/session/identity.d.ts +1 -1
  34. package/dist/private/node/session/identity.js.map +1 -1
  35. package/dist/private/node/session/redirect-listener.d.ts +1 -1
  36. package/dist/private/node/session/redirect-listener.js +7 -7
  37. package/dist/private/node/session/redirect-listener.js.map +1 -1
  38. package/dist/private/node/session/schema.d.ts +3 -3
  39. package/dist/private/node/session/scopes.d.ts +1 -1
  40. package/dist/private/node/session/scopes.js +1 -1
  41. package/dist/private/node/session/scopes.js.map +1 -1
  42. package/dist/private/node/session/store.js +4 -4
  43. package/dist/private/node/session/store.js.map +1 -1
  44. package/dist/private/node/session/validate.d.ts +1 -1
  45. package/dist/private/node/session/validate.js +2 -2
  46. package/dist/private/node/session/validate.js.map +1 -1
  47. package/dist/private/node/session.d.ts +4 -4
  48. package/dist/private/node/session.js +19 -19
  49. package/dist/private/node/session.js.map +1 -1
  50. package/dist/private/node/ui/alert.js +1 -1
  51. package/dist/private/node/ui/alert.js.map +1 -1
  52. package/dist/private/node/ui/components/Alert.test.js +1 -1
  53. package/dist/private/node/ui/components/Alert.test.js.map +1 -1
  54. package/dist/private/node/ui/components/AutocompletePrompt.d.ts +9 -2
  55. package/dist/private/node/ui/components/AutocompletePrompt.js +8 -4
  56. package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
  57. package/dist/private/node/ui/components/AutocompletePrompt.test.js +62 -8
  58. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
  59. package/dist/private/node/ui/components/Banner.d.ts +1 -1
  60. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +3 -3
  61. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  62. package/dist/private/node/ui/components/ConcurrentOutput.test.js +1 -1
  63. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  64. package/dist/private/node/ui/components/FatalError.test.js +1 -1
  65. package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
  66. package/dist/private/node/ui/components/List.test.js +1 -1
  67. package/dist/private/node/ui/components/List.test.js.map +1 -1
  68. package/dist/private/node/ui/components/SelectInput.d.ts +3 -1
  69. package/dist/private/node/ui/components/SelectInput.js +8 -2
  70. package/dist/private/node/ui/components/SelectInput.js.map +1 -1
  71. package/dist/private/node/ui/components/SelectInput.test.js +26 -0
  72. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
  73. package/dist/private/node/ui/components/SelectPrompt.test.js +1 -1
  74. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  75. package/dist/private/node/ui/components/Table/Row.d.ts +1 -1
  76. package/dist/private/node/ui/components/Table/ScalarDict.d.ts +1 -1
  77. package/dist/private/node/ui/components/Table/Table.d.ts +1 -1
  78. package/dist/private/node/ui/components/Tasks.d.ts +5 -1
  79. package/dist/private/node/ui/components/Tasks.js +31 -6
  80. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  81. package/dist/private/node/ui/components/Tasks.test.js +260 -20
  82. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  83. package/dist/private/node/ui/components/TextPrompt.test.js +1 -1
  84. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  85. package/dist/private/node/ui/components/TokenizedText.d.ts +2 -2
  86. package/dist/private/node/ui/components/TokenizedText.test.js +1 -1
  87. package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
  88. package/dist/private/node/ui.d.ts +2 -2
  89. package/dist/private/node/ui.js +1 -1
  90. package/dist/private/node/ui.js.map +1 -1
  91. package/dist/public/common/string.d.ts +1 -1
  92. package/dist/public/common/string.js +1 -1
  93. package/dist/public/common/string.js.map +1 -1
  94. package/dist/{private → public}/common/ts/deep-required.d.ts +2 -1
  95. package/dist/{private → public}/common/ts/deep-required.js +0 -0
  96. package/dist/public/common/ts/deep-required.js.map +1 -0
  97. package/dist/public/common/ts/pick-by-prefix.d.ts +2 -1
  98. package/dist/public/common/ts/pick-by-prefix.js.map +1 -1
  99. package/dist/public/common/version.d.ts +1 -1
  100. package/dist/public/common/version.js +1 -1
  101. package/dist/public/common/version.js.map +1 -1
  102. package/dist/public/node/analytics.js +5 -5
  103. package/dist/public/node/analytics.js.map +1 -1
  104. package/dist/public/node/api/admin.js +2 -2
  105. package/dist/public/node/api/admin.js.map +1 -1
  106. package/dist/public/node/api/http.d.ts +1 -0
  107. package/dist/public/node/api/http.js +1 -1
  108. package/dist/public/node/archiver.d.ts +20 -6
  109. package/dist/public/node/archiver.js +16 -15
  110. package/dist/public/node/archiver.js.map +1 -1
  111. package/dist/public/node/base-command.js +4 -4
  112. package/dist/public/node/base-command.js.map +1 -1
  113. package/dist/public/node/crypto.d.ts +1 -1
  114. package/dist/public/node/dot-env.js +4 -2
  115. package/dist/public/node/dot-env.js.map +1 -1
  116. package/dist/public/node/environment/local.d.ts +1 -1
  117. package/dist/public/node/environment/spin.d.ts +1 -1
  118. package/dist/public/node/environment/spin.js +2 -2
  119. package/dist/public/node/environment/spin.js.map +1 -1
  120. package/dist/public/node/error-handler.d.ts +1 -2
  121. package/dist/public/node/error-handler.js +15 -5
  122. package/dist/public/node/error-handler.js.map +1 -1
  123. package/dist/public/node/error.d.ts +5 -5
  124. package/dist/public/node/error.js +1 -1
  125. package/dist/public/node/error.js.map +1 -1
  126. package/dist/public/node/fs.d.ts +24 -4
  127. package/dist/public/node/fs.js +50 -21
  128. package/dist/public/node/fs.js.map +1 -1
  129. package/dist/public/node/git.d.ts +9 -1
  130. package/dist/public/node/git.js +39 -9
  131. package/dist/public/node/git.js.map +1 -1
  132. package/dist/public/node/github.js +2 -2
  133. package/dist/public/node/github.js.map +1 -1
  134. package/dist/public/node/hooks/postrun.js +2 -2
  135. package/dist/public/node/hooks/postrun.js.map +1 -1
  136. package/dist/public/node/hooks/prerun.js +2 -2
  137. package/dist/public/node/hooks/prerun.js.map +1 -1
  138. package/dist/public/node/http.d.ts +9 -1
  139. package/dist/public/node/http.js +37 -3
  140. package/dist/public/node/http.js.map +1 -1
  141. package/dist/public/node/liquid.js +2 -2
  142. package/dist/public/node/liquid.js.map +1 -1
  143. package/dist/public/node/metadata.d.ts +7 -7
  144. package/dist/public/node/monorail.d.ts +6 -6
  145. package/dist/public/node/monorail.js +4 -4
  146. package/dist/public/node/monorail.js.map +1 -1
  147. package/dist/public/node/node-package-manager.d.ts +5 -5
  148. package/dist/public/node/node-package-manager.js +9 -9
  149. package/dist/public/node/node-package-manager.js.map +1 -1
  150. package/dist/public/node/os.d.ts +2 -2
  151. package/dist/public/node/os.js +2 -2
  152. package/dist/public/node/os.js.map +1 -1
  153. package/dist/public/node/output.d.ts +188 -0
  154. package/dist/{output.js → public/node/output.js} +129 -50
  155. package/dist/public/node/output.js.map +1 -0
  156. package/dist/public/node/path.d.ts +1 -1
  157. package/dist/public/node/plugins/tunnel.d.ts +5 -5
  158. package/dist/public/node/plugins.d.ts +4 -4
  159. package/dist/public/node/result.d.ts +1 -1
  160. package/dist/public/node/ruby.d.ts +1 -1
  161. package/dist/public/node/ruby.js +7 -5
  162. package/dist/public/node/ruby.js.map +1 -1
  163. package/dist/public/node/session.d.ts +1 -1
  164. package/dist/public/node/session.js +9 -9
  165. package/dist/public/node/session.js.map +1 -1
  166. package/dist/public/node/system.d.ts +1 -1
  167. package/dist/public/node/system.js +2 -2
  168. package/dist/public/node/system.js.map +1 -1
  169. package/dist/public/node/tcp.js +4 -4
  170. package/dist/public/node/tcp.js.map +1 -1
  171. package/dist/public/node/testing/output.js +10 -9
  172. package/dist/public/node/testing/output.js.map +1 -1
  173. package/dist/public/node/ui.d.ts +11 -6
  174. package/dist/public/node/ui.js +5 -4
  175. package/dist/public/node/ui.js.map +1 -1
  176. package/dist/public/node/vscode.js +4 -4
  177. package/dist/public/node/vscode.js.map +1 -1
  178. package/dist/tsconfig.tsbuildinfo +1 -1
  179. package/dist/ui.d.ts +6 -20
  180. package/dist/ui.js +8 -28
  181. package/dist/ui.js.map +1 -1
  182. package/package.json +6 -7
  183. package/dist/content-tokens.js.map +0 -1
  184. package/dist/network/api.d.ts +0 -2
  185. package/dist/network/api.js.map +0 -1
  186. package/dist/output.d.ts +0 -129
  187. package/dist/output.js.map +0 -1
  188. package/dist/private/common/ts/deep-required.js.map +0 -1
  189. package/dist/private/node/simple-definitions.d.ts +0 -4
  190. package/dist/private/node/simple-definitions.js +0 -2
  191. package/dist/private/node/simple-definitions.js.map +0 -1
@@ -0,0 +1,188 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { PackageManager } from './node-package-manager.js';
3
+ import { ColorContentToken, CommandContentToken, ContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken } from '../../private/node/content-tokens.js';
4
+ import { AbortSignal } from '@shopify/cli-kit/node/abort';
5
+ import { Writable } from 'stream';
6
+ import type { Change } from 'diff';
7
+ export { default as logUpdate } from 'log-update';
8
+ export type Logger = Writable | ((message: string) => void);
9
+ export declare class TokenizedString {
10
+ value: string;
11
+ constructor(value: string);
12
+ }
13
+ export type OutputMessage = string | TokenizedString;
14
+ export declare const outputToken: {
15
+ raw(value: string): RawContentToken;
16
+ genericShellCommand(value: OutputMessage): CommandContentToken;
17
+ json(value: unknown): JsonContentToken;
18
+ path(value: OutputMessage): PathContentToken;
19
+ link(value: OutputMessage, link: string): LinkContentToken;
20
+ heading(value: OutputMessage): HeadingContentToken;
21
+ subheading(value: OutputMessage): SubHeadingContentToken;
22
+ italic(value: OutputMessage): ItalicContentToken;
23
+ errorText(value: OutputMessage): ErrorContentToken;
24
+ cyan(value: OutputMessage): ColorContentToken;
25
+ yellow(value: OutputMessage): ColorContentToken;
26
+ magenta(value: OutputMessage): ColorContentToken;
27
+ green(value: OutputMessage): ColorContentToken;
28
+ packagejsonScript(packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]): CommandContentToken;
29
+ successIcon(): ColorContentToken;
30
+ failIcon(): ErrorContentToken;
31
+ linesDiff(value: Change[]): LinesDiffContentToken;
32
+ };
33
+ /**
34
+ * Given a command and its arguments, it formats it depending on the package manager.
35
+ *
36
+ * @param packageManager - The package manager to use (pnpm, npm, yarn).
37
+ * @param scriptName - The name of the script to run.
38
+ * @param scriptArgs - The arguments to pass to the script.
39
+ * @returns The formatted command.
40
+ */
41
+ export declare function formatPackageManagerCommand(packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]): string;
42
+ /**
43
+ * Creates a tokenized string from an array of strings and tokens.
44
+ *
45
+ * @param strings - The strings to join.
46
+ * @param keys - Array of tokens or strings to join.
47
+ * @returns The tokenized string.
48
+ */
49
+ export declare function outputContent(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | string)[]): TokenizedString;
50
+ /** Log levels. */
51
+ export type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
52
+ export declare let collectedLogs: {
53
+ [key: string]: string[];
54
+ };
55
+ /**
56
+ * This is only used during UnitTesting.
57
+ * If we are in a testing context, instead of printing the logs to the console,
58
+ * we will store them in a variable that can be accessed from the tests.
59
+ *
60
+ * @param key - The key of the log.
61
+ * @param content - The content of the log.
62
+ */
63
+ export declare function collectLog(key: string, content: OutputMessage): void;
64
+ export declare const clearCollectedLogs: () => void;
65
+ /**
66
+ * Ouputs information to the user.
67
+ * Info messages don't get additional formatting.
68
+ * Note: Info messages are sent through the standard output.
69
+ *
70
+ * @param content - The content to be output to the user.
71
+ * @param logger - The logging function to use to output to the user.
72
+ */
73
+ export declare function outputInfo(content: OutputMessage, logger?: Logger): void;
74
+ /**
75
+ * Outputs a success message to the user.
76
+ * Success messages receive a special formatting to make them stand out in the console.
77
+ * Note: Success messages are sent through the standard output.
78
+ *
79
+ * @param content - The content to be output to the user.
80
+ * @param logger - The logging function to use to output to the user.
81
+ */
82
+ export declare function outputSuccess(content: OutputMessage, logger?: Logger): void;
83
+ /**
84
+ * Outputs a completed message to the user.
85
+ * Completed message receive a special formatting to make them stand out in the console.
86
+ * Note: Completed messages are sent through the standard output.
87
+ *
88
+ * @param content - The content to be output to the user.
89
+ * @param logger - The logging function to use to output to the user.
90
+ */
91
+ export declare function outputCompleted(content: OutputMessage, logger?: Logger): void;
92
+ /**
93
+ * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.
94
+ * Debug messages don't get additional formatting.
95
+ * Note: Debug messages are sent through the standard output.
96
+ *
97
+ * @param content - The content to be output to the user.
98
+ * @param logger - The logging function to use to output to the user.
99
+ */
100
+ export declare function outputDebug(content: OutputMessage, logger?: Logger): void;
101
+ /**
102
+ * Outputs a warning message to the user.
103
+ * Warning messages receive a special formatting to make them stand out in the console.
104
+ * Note: Warning messages are sent through the standard output.
105
+ *
106
+ * @param content - The content to be output to the user.
107
+ * @param logger - The logging function to use to output to the user.
108
+ */
109
+ export declare function outputWarn(content: OutputMessage, logger?: Logger): void;
110
+ /**
111
+ * Prints a new line in the terminal.
112
+ */
113
+ export declare function outputNewline(): void;
114
+ /**
115
+ * Converts a Message to string.
116
+ *
117
+ * @param message - The message to convert to string.
118
+ * @returns The string representation of the message.
119
+ */
120
+ export declare function stringifyMessage(message: OutputMessage): string;
121
+ export interface OutputProcess {
122
+ /**
123
+ * The prefix to include in the logs
124
+ * [vite] Output coming from Vite.
125
+ */
126
+ prefix: string;
127
+ /**
128
+ * A callback to invoke the process. Stdout and stderr should be used
129
+ * to send standard output and error data that gets formatted with the
130
+ * right prefix.
131
+ */
132
+ action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>;
133
+ }
134
+ /**
135
+ * Prints a log message in the console.
136
+ *
137
+ * @param message - The message to print.
138
+ */
139
+ export declare function consoleLog(message: string): void;
140
+ /**
141
+ * Prints an error message in the console.
142
+ *
143
+ * @param message - The message to print.
144
+ */
145
+ export declare function consoleError(message: string): void;
146
+ /**
147
+ * Prints a warning message in the console.
148
+ *
149
+ * @param message - The message to print.
150
+ */
151
+ export declare function consoleWarn(message: string): void;
152
+ /**
153
+ * Writes a message to the appropiated logger.
154
+ *
155
+ * @param logLevel - The log level to use to determine if the message should be output.
156
+ * @param logger - The logger to use to output the message.
157
+ * @param message - The message to output.
158
+ */
159
+ export declare function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void;
160
+ /**
161
+ * Returns a message without styles (colors or any ANSI escape codes).
162
+ *
163
+ * @param message - The message to remove styles from.
164
+ * @returns The message without styles.
165
+ */
166
+ export declare function unstyled(message: string): string;
167
+ /**
168
+ * Checks if the console outputs should display colors or not.
169
+ *
170
+ * @returns True if the console outputs should display colors, false otherwise.
171
+ */
172
+ export declare function shouldDisplayColors(): boolean;
173
+ /**
174
+ * Generates a message to remind the user to update the CLI.
175
+ *
176
+ * @param packageManager - The package manager that is being used.
177
+ * @param version - The version to update to.
178
+ * @returns The message to remind the user to update the CLI.
179
+ */
180
+ export declare function getOutputUpdateCLIReminder(packageManager: PackageManager | 'unknown' | undefined, version: string): string;
181
+ /**
182
+ * Parse title and body to be a single formatted string.
183
+ *
184
+ * @param title - The title of the message. Will be formatted as a heading.
185
+ * @param body - The body of the message. Will respect the original formatting.
186
+ * @returns The formatted message.
187
+ */
188
+ export declare function formatSection(title: string, body: string): string;
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-console */
2
- import { isUnitTest, isVerbose } from './public/node/environment/local.js';
3
- import colors from './public/node/colors.js';
4
- import { ColorContentToken, CommandContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken, } from './content-tokens.js';
2
+ import { isUnitTest, isVerbose } from './environment/local.js';
3
+ import colors from './colors.js';
4
+ import { ColorContentToken, CommandContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken, } from '../../private/node/content-tokens.js';
5
5
  import stripAnsi from 'strip-ansi';
6
6
  import { Writable } from 'stream';
7
7
  export { default as logUpdate } from 'log-update';
@@ -10,60 +10,67 @@ export class TokenizedString {
10
10
  this.value = value;
11
11
  }
12
12
  }
13
- export const token = {
14
- raw: (value) => {
13
+ export const outputToken = {
14
+ raw(value) {
15
15
  return new RawContentToken(value);
16
16
  },
17
- genericShellCommand: (value) => {
17
+ genericShellCommand(value) {
18
18
  return new CommandContentToken(value);
19
19
  },
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- json: (value) => {
20
+ json(value) {
22
21
  return new JsonContentToken(value);
23
22
  },
24
- path: (value) => {
23
+ path(value) {
25
24
  return new PathContentToken(value);
26
25
  },
27
- link: (value, link) => {
26
+ link(value, link) {
28
27
  return new LinkContentToken(value, link);
29
28
  },
30
- heading: (value) => {
29
+ heading(value) {
31
30
  return new HeadingContentToken(value);
32
31
  },
33
- subheading: (value) => {
32
+ subheading(value) {
34
33
  return new SubHeadingContentToken(value);
35
34
  },
36
- italic: (value) => {
35
+ italic(value) {
37
36
  return new ItalicContentToken(value);
38
37
  },
39
- errorText: (value) => {
38
+ errorText(value) {
40
39
  return new ErrorContentToken(value);
41
40
  },
42
- cyan: (value) => {
41
+ cyan(value) {
43
42
  return new ColorContentToken(value, colors.cyan);
44
43
  },
45
- yellow: (value) => {
44
+ yellow(value) {
46
45
  return new ColorContentToken(value, colors.yellow);
47
46
  },
48
- magenta: (value) => {
47
+ magenta(value) {
49
48
  return new ColorContentToken(value, colors.magenta);
50
49
  },
51
- green: (value) => {
50
+ green(value) {
52
51
  return new ColorContentToken(value, colors.green);
53
52
  },
54
- packagejsonScript: (packageManager, scriptName, ...scriptArgs) => {
53
+ packagejsonScript(packageManager, scriptName, ...scriptArgs) {
55
54
  return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs));
56
55
  },
57
- successIcon: () => {
56
+ successIcon() {
58
57
  return new ColorContentToken('✔', colors.green);
59
58
  },
60
- failIcon: () => {
59
+ failIcon() {
61
60
  return new ErrorContentToken('✖');
62
61
  },
63
- linesDiff: (value) => {
62
+ linesDiff(value) {
64
63
  return new LinesDiffContentToken(value);
65
64
  },
66
65
  };
66
+ /**
67
+ * Given a command and its arguments, it formats it depending on the package manager.
68
+ *
69
+ * @param packageManager - The package manager to use (pnpm, npm, yarn).
70
+ * @param scriptName - The name of the script to run.
71
+ * @param scriptArgs - The arguments to pass to the script.
72
+ * @returns The formatted command.
73
+ */
67
74
  export function formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs) {
68
75
  switch (packageManager) {
69
76
  case 'pnpm':
@@ -81,7 +88,14 @@ export function formatPackageManagerCommand(packageManager, scriptName, ...scrip
81
88
  }
82
89
  }
83
90
  }
84
- export function content(strings, ...keys) {
91
+ /**
92
+ * Creates a tokenized string from an array of strings and tokens.
93
+ *
94
+ * @param strings - The strings to join.
95
+ * @param keys - Array of tokens or strings to join.
96
+ * @returns The tokenized string.
97
+ */
98
+ export function outputContent(strings, ...keys) {
85
99
  let output = ``;
86
100
  strings.forEach((string, i) => {
87
101
  output += string;
@@ -108,10 +122,11 @@ export function content(strings, ...keys) {
108
122
  }
109
123
  /**
110
124
  * It maps a level to a numeric value.
125
+ *
111
126
  * @param level - The level for which we'll return its numeric value.
112
127
  * @returns The numeric value of the level.
113
128
  */
114
- const logLevelValue = (level) => {
129
+ function logLevelValue(level) {
115
130
  switch (level) {
116
131
  case 'trace':
117
132
  return 10;
@@ -128,118 +143,139 @@ const logLevelValue = (level) => {
128
143
  default:
129
144
  return 30;
130
145
  }
131
- };
146
+ }
132
147
  /**
148
+ * It returns the current log level (debug or info).
133
149
  *
134
- * @returns It returns the log level set by the user.
150
+ * @returns The log level set by the user.
135
151
  */
136
- export const currentLogLevel = () => {
152
+ function currentLogLevel() {
137
153
  if (isVerbose()) {
138
154
  return 'debug';
139
155
  }
140
156
  else {
141
157
  return 'info';
142
158
  }
143
- };
144
- export const shouldOutput = (logLevel) => {
159
+ }
160
+ /**
161
+ * It checks if the message should be outputted or not.
162
+ *
163
+ * @param logLevel - The desired log level for the message.
164
+ * @returns True if the message should be outputted, false otherwise.
165
+ */
166
+ function shouldOutput(logLevel) {
145
167
  if (isUnitTest()) {
146
168
  return false;
147
169
  }
148
170
  const currentLogLevelValue = logLevelValue(currentLogLevel());
149
171
  const messageLogLevelValue = logLevelValue(logLevel);
150
172
  return messageLogLevelValue >= currentLogLevelValue;
151
- };
173
+ }
152
174
  // eslint-disable-next-line import/no-mutable-exports
153
175
  export let collectedLogs = {};
154
176
  /**
155
177
  * This is only used during UnitTesting.
156
178
  * If we are in a testing context, instead of printing the logs to the console,
157
179
  * we will store them in a variable that can be accessed from the tests.
180
+ *
158
181
  * @param key - The key of the log.
159
182
  * @param content - The content of the log.
160
183
  */
161
- export const collectLog = (key, content) => {
184
+ export function collectLog(key, content) {
162
185
  const output = collectedLogs.output ?? [];
163
186
  const data = collectedLogs[key] ?? [];
164
187
  data.push(stripAnsi(stringifyMessage(content) ?? ''));
165
188
  output.push(stripAnsi(stringifyMessage(content) ?? ''));
166
189
  collectedLogs[key] = data;
167
190
  collectedLogs.output = output;
168
- };
191
+ }
169
192
  export const clearCollectedLogs = () => {
193
+ // console.log('clearCollectLogs')
170
194
  collectedLogs = {};
195
+ // console.log(collectedLogs)
171
196
  };
172
197
  /**
173
198
  * Ouputs information to the user.
174
199
  * Info messages don't get additional formatting.
175
200
  * Note: Info messages are sent through the standard output.
201
+ *
176
202
  * @param content - The content to be output to the user.
177
203
  * @param logger - The logging function to use to output to the user.
178
204
  */
179
- export const info = (content, logger = consoleLog) => {
205
+ export function outputInfo(content, logger = consoleLog) {
180
206
  const message = stringifyMessage(content);
181
207
  if (isUnitTest())
182
208
  collectLog('info', content);
183
209
  outputWhereAppropriate('info', logger, message);
184
- };
210
+ }
185
211
  /**
186
212
  * Outputs a success message to the user.
187
213
  * Success messages receive a special formatting to make them stand out in the console.
188
214
  * Note: Success messages are sent through the standard output.
215
+ *
189
216
  * @param content - The content to be output to the user.
190
217
  * @param logger - The logging function to use to output to the user.
191
218
  */
192
- export const success = (content, logger = consoleLog) => {
219
+ export function outputSuccess(content, logger = consoleLog) {
193
220
  const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`);
194
221
  if (isUnitTest())
195
222
  collectLog('success', content);
196
223
  outputWhereAppropriate('info', logger, message);
197
- };
224
+ }
198
225
  /**
199
226
  * Outputs a completed message to the user.
200
227
  * Completed message receive a special formatting to make them stand out in the console.
201
228
  * Note: Completed messages are sent through the standard output.
229
+ *
202
230
  * @param content - The content to be output to the user.
203
231
  * @param logger - The logging function to use to output to the user.
204
232
  */
205
- export const completed = (content, logger = consoleLog) => {
233
+ export function outputCompleted(content, logger = consoleLog) {
206
234
  const message = `${colors.green('✔')} ${stringifyMessage(content)}`;
207
235
  if (isUnitTest())
208
236
  collectLog('completed', content);
209
237
  outputWhereAppropriate('info', logger, message);
210
- };
238
+ }
211
239
  /**
212
240
  * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.
213
241
  * Debug messages don't get additional formatting.
214
242
  * Note: Debug messages are sent through the standard output.
243
+ *
215
244
  * @param content - The content to be output to the user.
216
245
  * @param logger - The logging function to use to output to the user.
217
246
  */
218
- export const debug = (content, logger = consoleLog) => {
247
+ export function outputDebug(content, logger = consoleLog) {
219
248
  if (isUnitTest())
220
249
  collectLog('debug', content);
221
250
  const message = colors.gray(stringifyMessage(content));
222
251
  outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`);
223
- };
252
+ }
224
253
  /**
225
254
  * Outputs a warning message to the user.
226
255
  * Warning messages receive a special formatting to make them stand out in the console.
227
256
  * Note: Warning messages are sent through the standard output.
257
+ *
228
258
  * @param content - The content to be output to the user.
229
259
  * @param logger - The logging function to use to output to the user.
230
260
  */
231
- export const warn = (content, logger = consoleWarn) => {
261
+ export function outputWarn(content, logger = consoleWarn) {
232
262
  if (isUnitTest())
233
263
  collectLog('warn', content);
234
264
  const message = colors.yellow(stringifyMessage(content));
235
265
  outputWhereAppropriate('warn', logger, message);
236
- };
266
+ }
237
267
  /**
238
268
  * Prints a new line in the terminal.
239
269
  */
240
- export const newline = () => {
270
+ export function outputNewline() {
241
271
  console.log();
242
- };
272
+ }
273
+ /**
274
+ * Converts a Message to string.
275
+ *
276
+ * @param message - The message to convert to string.
277
+ * @returns The string representation of the message.
278
+ */
243
279
  export function stringifyMessage(message) {
244
280
  if (message instanceof TokenizedString) {
245
281
  return message.value;
@@ -248,15 +284,37 @@ export function stringifyMessage(message) {
248
284
  return message;
249
285
  }
250
286
  }
287
+ /**
288
+ * Prints a log message in the console.
289
+ *
290
+ * @param message - The message to print.
291
+ */
251
292
  export function consoleLog(message) {
252
293
  console.log(withOrWithoutStyle(message));
253
294
  }
295
+ /**
296
+ * Prints an error message in the console.
297
+ *
298
+ * @param message - The message to print.
299
+ */
254
300
  export function consoleError(message) {
255
301
  console.error(withOrWithoutStyle(message));
256
302
  }
303
+ /**
304
+ * Prints a warning message in the console.
305
+ *
306
+ * @param message - The message to print.
307
+ */
257
308
  export function consoleWarn(message) {
258
309
  console.warn(withOrWithoutStyle(message));
259
310
  }
311
+ /**
312
+ * Writes a message to the appropiated logger.
313
+ *
314
+ * @param logLevel - The log level to use to determine if the message should be output.
315
+ * @param logger - The logger to use to output the message.
316
+ * @param message - The message to output.
317
+ */
260
318
  export function outputWhereAppropriate(logLevel, logger, message) {
261
319
  if (shouldOutput(logLevel)) {
262
320
  if (logger instanceof Writable) {
@@ -267,6 +325,12 @@ export function outputWhereAppropriate(logLevel, logger, message) {
267
325
  }
268
326
  }
269
327
  }
328
+ /**
329
+ * Returns a colored or uncolored version of a message, depending on the environment.
330
+ *
331
+ * @param message - The message to color or not.
332
+ * @returns The message with or without colors.
333
+ */
270
334
  function withOrWithoutStyle(message) {
271
335
  if (shouldDisplayColors()) {
272
336
  return message;
@@ -275,32 +339,47 @@ function withOrWithoutStyle(message) {
275
339
  return unstyled(message);
276
340
  }
277
341
  }
342
+ /**
343
+ * Returns a message without styles (colors or any ANSI escape codes).
344
+ *
345
+ * @param message - The message to remove styles from.
346
+ * @returns The message without styles.
347
+ */
278
348
  export function unstyled(message) {
279
349
  return stripAnsi(message);
280
350
  }
351
+ /**
352
+ * Checks if the console outputs should display colors or not.
353
+ *
354
+ * @returns True if the console outputs should display colors, false otherwise.
355
+ */
281
356
  export function shouldDisplayColors() {
282
357
  return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR);
283
358
  }
284
359
  /**
360
+ * Generates a message to remind the user to update the CLI.
361
+ *
285
362
  * @param packageManager - The package manager that is being used.
286
- * @param version - The version to update to
363
+ * @param version - The version to update to.
364
+ * @returns The message to remind the user to update the CLI.
287
365
  */
288
366
  export function getOutputUpdateCLIReminder(packageManager, version) {
289
367
  const versionMessage = `💡 Version ${version} available!`;
290
368
  if (!packageManager || packageManager === 'unknown')
291
369
  return versionMessage;
292
- const updateCommand = token.packagejsonScript(packageManager, 'shopify upgrade');
293
- return content `${versionMessage} Run ${updateCommand}`.value;
370
+ const updateCommand = outputToken.packagejsonScript(packageManager, 'shopify upgrade');
371
+ return outputContent `${versionMessage} Run ${updateCommand}`.value;
294
372
  }
295
373
  /**
296
- * Parse title and body to be a single formatted string
374
+ * Parse title and body to be a single formatted string.
375
+ *
297
376
  * @param title - The title of the message. Will be formatted as a heading.
298
377
  * @param body - The body of the message. Will respect the original formatting.
299
378
  * @returns The formatted message.
300
379
  */
301
- export function section(title, body) {
380
+ export function formatSection(title, body) {
302
381
  const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`;
303
- return content `${token.heading(formattedTitle)}\n${body}`.value;
382
+ return outputContent `${outputToken.heading(formattedTitle)}\n${body}`.value;
304
383
  }
305
384
  /* eslint-enable no-console */
306
385
  //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../../../src/public/node/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAE5D,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EAEnB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB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AC,OAAO,CAAC,CAAA;SAChB;KACF;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,OAAe;IACzC,IAAI,mBAAmB,EAAE,EAAE;QACzB,OAAO,OAAO,CAAA;KACf;SAAM;QACL,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAA;KACzB;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAA;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AACjE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAAsD,EACtD,OAAe;IAEf,MAAM,cAAc,GAAG,cAAc,OAAO,aAAa,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,cAAc,CAAA;IAE1E,MAAM,aAAa,GAAG,WAAW,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IACtF,OAAO,aAAa,CAAA,GAAG,cAAc,QAAQ,aAAa,EAAE,CAAC,KAAK,CAAA;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,IAAY;IACvD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,aAAa,CAAA,GAAG,WAAW,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AAC7E,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport {PackageManager} from './node-package-manager.js'\nimport colors from './colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from '../../private/node/content-tokens.js'\nimport stripAnsi from 'strip-ansi'\nimport {AbortSignal} from '@shopify/cli-kit/node/abort'\nimport {Writable} from 'stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = Writable | ((message: string) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type OutputMessage = string | TokenizedString\n\nexport const outputToken = {\n raw(value: string): RawContentToken {\n return new RawContentToken(value)\n },\n genericShellCommand(value: OutputMessage): CommandContentToken {\n return new CommandContentToken(value)\n },\n json(value: unknown): JsonContentToken {\n return new JsonContentToken(value)\n },\n path(value: OutputMessage): PathContentToken {\n return new PathContentToken(value)\n },\n link(value: OutputMessage, link: string): LinkContentToken {\n return new LinkContentToken(value, link)\n },\n heading(value: OutputMessage): HeadingContentToken {\n return new HeadingContentToken(value)\n },\n subheading(value: OutputMessage): SubHeadingContentToken {\n return new SubHeadingContentToken(value)\n },\n italic(value: OutputMessage): ItalicContentToken {\n return new ItalicContentToken(value)\n },\n errorText(value: OutputMessage): ErrorContentToken {\n return new ErrorContentToken(value)\n },\n cyan(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.magenta)\n },\n green(value: OutputMessage): ColorContentToken {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript(packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]): CommandContentToken {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon(): ColorContentToken {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon(): ErrorContentToken {\n return new ErrorContentToken('✖')\n },\n linesDiff(value: Change[]): LinesDiffContentToken {\n return new LinesDiffContentToken(value)\n },\n}\n\n/**\n * Given a command and its arguments, it formats it depending on the package manager.\n *\n * @param packageManager - The package manager to use (pnpm, npm, yarn).\n * @param scriptName - The name of the script to run.\n * @param scriptArgs - The arguments to pass to the script.\n * @returns The formatted command.\n */\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n switch (packageManager) {\n case 'pnpm':\n case 'yarn': {\n const pieces = [packageManager, scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'npm': {\n const pieces = ['npm', 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\n/**\n * Creates a tokenized string from an array of strings and tokens.\n *\n * @param strings - The strings to join.\n * @param keys - Array of tokens or strings to join.\n * @returns The tokenized string.\n */\nexport function outputContent(\n strings: TemplateStringsArray,\n ...keys: (ContentToken<unknown> | string)[]\n): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels. */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n *\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nfunction logLevelValue(level: LogLevel): number {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n * It returns the current log level (debug or info).\n *\n * @returns The log level set by the user.\n */\nfunction currentLogLevel(): LogLevel {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\n/**\n * It checks if the message should be outputted or not.\n *\n * @param logLevel - The desired log level for the message.\n * @returns True if the message should be outputted, false otherwise.\n */\nfunction shouldOutput(logLevel: LogLevel): boolean {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n *\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport function collectLog(key: string, content: OutputMessage): void {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = (): void => {\n // console.log('clearCollectLogs')\n collectedLogs = {}\n // console.log(collectedLogs)\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputInfo(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputSuccess(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputCompleted(content: OutputMessage, logger: Logger = consoleLog): void {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputDebug(content: OutputMessage, logger: Logger = consoleLog): void {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n *\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport function outputWarn(content: OutputMessage, logger: Logger = consoleWarn): void {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport function outputNewline(): void {\n console.log()\n}\n\n/**\n * Converts a Message to string.\n *\n * @param message - The message to convert to string.\n * @returns The string representation of the message.\n */\nexport function stringifyMessage(message: OutputMessage): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nexport interface OutputProcess {\n /**\n * The prefix to include in the logs\n * [vite] Output coming from Vite.\n */\n prefix: string\n /**\n * A callback to invoke the process. Stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\n/**\n * Prints a log message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\n/**\n * Prints an error message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\n/**\n * Prints a warning message in the console.\n *\n * @param message - The message to print.\n */\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\n/**\n * Writes a message to the appropiated logger.\n *\n * @param logLevel - The log level to use to determine if the message should be output.\n * @param logger - The logger to use to output the message.\n * @param message - The message to output.\n */\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message)\n }\n }\n}\n\n/**\n * Returns a colored or uncolored version of a message, depending on the environment.\n *\n * @param message - The message to color or not.\n * @returns The message with or without colors.\n */\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\n/**\n * Returns a message without styles (colors or any ANSI escape codes).\n *\n * @param message - The message to remove styles from.\n * @returns The message without styles.\n */\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\n/**\n * Checks if the console outputs should display colors or not.\n *\n * @returns True if the console outputs should display colors, false otherwise.\n */\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * Generates a message to remind the user to update the CLI.\n *\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to.\n * @returns The message to remind the user to update the CLI.\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = outputToken.packagejsonScript(packageManager, 'shopify upgrade')\n return outputContent`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string.\n *\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function formatSection(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return outputContent`${outputToken.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
@@ -1,4 +1,4 @@
1
- /// <reference types="node" />
1
+ /// <reference types="node" resolution-mode="require"/>
2
2
  import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute } from 'pathe';
3
3
  import type { URL } from 'url';
4
4
  export { join as joinPath, relative as relativePath, normalize as normalizePath, resolve as resolvePath, isAbsolute as isAbsolutePath, dirname, basename, extname, };
@@ -1,7 +1,7 @@
1
1
  import { Result } from '../result.js';
2
2
  import { ExtendableError } from '../error.js';
3
3
  import { FanoutHookFunction, PluginReturnsForHook } from '../plugins.js';
4
- export declare type TunnelErrorType = 'invalid-provider' | 'tunnel-already-running' | 'wrong-credentials' | 'unknown';
4
+ export type TunnelErrorType = 'invalid-provider' | 'tunnel-already-running' | 'wrong-credentials' | 'unknown';
5
5
  export declare class TunnelError extends ExtendableError {
6
6
  type: TunnelErrorType;
7
7
  constructor(type: TunnelErrorType, message?: string);
@@ -34,10 +34,10 @@ export interface HookReturnPerTunnelPlugin {
34
34
  };
35
35
  };
36
36
  }
37
- export declare type TunnelProviderFunction = FanoutHookFunction<'tunnel_provider', ''>;
38
- export declare type TunnelStartFunction = FanoutHookFunction<'tunnel_start', ''>;
39
- export declare type TunnelStartReturn = PluginReturnsForHook<'tunnel_start', ''>;
40
- export declare type TunnelStartAction = (port: number) => Promise<TunnelStartReturn>;
37
+ export type TunnelProviderFunction = FanoutHookFunction<'tunnel_provider', ''>;
38
+ export type TunnelStartFunction = FanoutHookFunction<'tunnel_start', ''>;
39
+ export type TunnelStartReturn = PluginReturnsForHook<'tunnel_start', ''>;
40
+ export type TunnelStartAction = (port: number) => Promise<TunnelStartReturn>;
41
41
  export declare const defineProvider: (input: {
42
42
  name: string;
43
43
  }) => TunnelProviderFunction;