@shopify/cli-kit 3.0.25 → 3.0.26

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 (286) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/assets/auth-error.html +2 -4
  3. package/assets/empty-url.html +2 -4
  4. package/assets/missing-code.html +2 -4
  5. package/assets/missing-state.html +2 -4
  6. package/assets/style.css +5 -8
  7. package/assets/success.html +1 -1
  8. package/dist/abort.d.ts +1 -0
  9. package/dist/abort.js +2 -0
  10. package/dist/abort.js.map +1 -0
  11. package/dist/analytics.d.ts +11 -0
  12. package/dist/analytics.js +96 -0
  13. package/dist/analytics.js.map +1 -0
  14. package/dist/api/admin.d.ts +3 -0
  15. package/dist/api/admin.js +80 -0
  16. package/dist/api/admin.js.map +1 -0
  17. package/dist/api/common.d.ts +11 -0
  18. package/dist/api/common.js +40 -0
  19. package/dist/api/common.js.map +1 -0
  20. package/dist/api/graphql/all_app_extension_registrations.d.ts +14 -0
  21. package/dist/api/graphql/all_app_extension_registrations.js +14 -0
  22. package/dist/api/graphql/all_app_extension_registrations.js.map +1 -0
  23. package/dist/api/graphql/all_orgs.d.ts +12 -0
  24. package/dist/api/graphql/all_orgs.js +14 -0
  25. package/dist/api/graphql/all_orgs.js.map +1 -0
  26. package/dist/api/graphql/all_stores_by_org.d.ts +18 -0
  27. package/dist/api/graphql/all_stores_by_org.js +21 -0
  28. package/dist/api/graphql/all_stores_by_org.js.map +1 -0
  29. package/dist/api/graphql/convert_dev_to_test_store.d.ts +16 -0
  30. package/dist/api/graphql/convert_dev_to_test_store.js +13 -0
  31. package/dist/api/graphql/convert_dev_to_test_store.js.map +1 -0
  32. package/dist/api/graphql/create_app.d.ts +28 -0
  33. package/dist/api/graphql/create_app.js +32 -0
  34. package/dist/api/graphql/create_app.js.map +1 -0
  35. package/dist/api/graphql/create_deployment.d.ts +33 -0
  36. package/dist/api/graphql/create_deployment.js +25 -0
  37. package/dist/api/graphql/create_deployment.js.map +1 -0
  38. package/dist/api/graphql/extension_create.d.ts +30 -0
  39. package/dist/api/graphql/extension_create.js +26 -0
  40. package/dist/api/graphql/extension_create.js.map +1 -0
  41. package/dist/api/graphql/extension_specifications.d.ts +18 -0
  42. package/dist/api/graphql/extension_specifications.js +18 -0
  43. package/dist/api/graphql/extension_specifications.js.map +1 -0
  44. package/dist/api/graphql/find_app.d.ts +13 -0
  45. package/dist/api/graphql/find_app.js +16 -0
  46. package/dist/api/graphql/find_app.js.map +1 -0
  47. package/dist/api/graphql/find_org.d.ts +23 -0
  48. package/dist/api/graphql/find_org.js +26 -0
  49. package/dist/api/graphql/find_org.js.map +1 -0
  50. package/dist/api/graphql/find_org_basic.d.ts +11 -0
  51. package/dist/api/graphql/find_org_basic.js +14 -0
  52. package/dist/api/graphql/find_org_basic.js.map +1 -0
  53. package/dist/api/graphql/functions/app_function_set.d.ts +43 -0
  54. package/dist/api/graphql/functions/app_function_set.js +52 -0
  55. package/dist/api/graphql/functions/app_function_set.js.map +1 -0
  56. package/dist/api/graphql/functions/compile_module.d.ts +15 -0
  57. package/dist/api/graphql/functions/compile_module.js +13 -0
  58. package/dist/api/graphql/functions/compile_module.js.map +1 -0
  59. package/dist/api/graphql/functions/function_service_proxy.d.ts +4 -0
  60. package/dist/api/graphql/functions/function_service_proxy.js +7 -0
  61. package/dist/api/graphql/functions/function_service_proxy.js.map +1 -0
  62. package/dist/api/graphql/functions/get_app_functions.d.ts +1 -0
  63. package/dist/api/graphql/functions/get_app_functions.js +10 -0
  64. package/dist/api/graphql/functions/get_app_functions.js.map +1 -0
  65. package/dist/api/graphql/functions/module_compilation_status.d.ts +15 -0
  66. package/dist/api/graphql/functions/module_compilation_status.js +13 -0
  67. package/dist/api/graphql/functions/module_compilation_status.js.map +1 -0
  68. package/dist/api/graphql/functions/module_upload_url_generate.d.ts +18 -0
  69. package/dist/api/graphql/functions/module_upload_url_generate.js +17 -0
  70. package/dist/api/graphql/functions/module_upload_url_generate.js.map +1 -0
  71. package/dist/api/graphql/generate_signed_upload_url.d.ts +15 -0
  72. package/dist/api/graphql/generate_signed_upload_url.js +15 -0
  73. package/dist/api/graphql/generate_signed_upload_url.js.map +1 -0
  74. package/dist/api/graphql/get_variant_id.d.ts +17 -0
  75. package/dist/api/graphql/get_variant_id.js +20 -0
  76. package/dist/api/graphql/get_variant_id.js.map +1 -0
  77. package/dist/api/graphql/index.d.ts +21 -0
  78. package/dist/api/graphql/index.js +22 -0
  79. package/dist/api/graphql/index.js.map +1 -0
  80. package/dist/api/graphql/update_draft.d.ts +33 -0
  81. package/dist/api/graphql/update_draft.js +24 -0
  82. package/dist/api/graphql/update_draft.js.map +1 -0
  83. package/dist/api/graphql/update_urls.d.ts +14 -0
  84. package/dist/api/graphql/update_urls.js +12 -0
  85. package/dist/api/graphql/update_urls.js.map +1 -0
  86. package/dist/api/identity.d.ts +1 -0
  87. package/dist/api/identity.js +29 -0
  88. package/dist/api/identity.js.map +1 -0
  89. package/dist/api/partners.d.ts +25 -0
  90. package/dist/api/partners.js +100 -0
  91. package/dist/api/partners.js.map +1 -0
  92. package/dist/api.d.ts +5 -0
  93. package/dist/api.js +6 -0
  94. package/dist/api.js.map +1 -0
  95. package/dist/checksum.d.ts +15 -0
  96. package/dist/checksum.js +27 -0
  97. package/dist/checksum.js.map +1 -0
  98. package/dist/cli.d.ts +7 -0
  99. package/dist/cli.js +13 -0
  100. package/dist/cli.js.map +1 -0
  101. package/dist/colors.d.ts +1 -0
  102. package/dist/colors.js +8 -0
  103. package/dist/colors.js.map +1 -0
  104. package/dist/constants.d.ts +43 -0
  105. package/dist/constants.js +63 -0
  106. package/dist/constants.js.map +1 -0
  107. package/dist/dependency.d.ts +128 -0
  108. package/dist/dependency.js +302 -0
  109. package/dist/dependency.js.map +1 -0
  110. package/dist/dot-env.d.ts +28 -0
  111. package/dist/dot-env.js +31 -0
  112. package/dist/dot-env.js.map +1 -0
  113. package/dist/environment/fqdn.d.ts +23 -0
  114. package/dist/environment/fqdn.js +61 -0
  115. package/dist/environment/fqdn.js.map +1 -0
  116. package/dist/environment/local.d.ts +48 -0
  117. package/dist/environment/local.js +82 -0
  118. package/dist/environment/local.js.map +1 -0
  119. package/dist/environment/service.d.ts +17 -0
  120. package/dist/environment/service.js +41 -0
  121. package/dist/environment/service.js.map +1 -0
  122. package/dist/environment/spin.d.ts +47 -0
  123. package/dist/environment/spin.js +83 -0
  124. package/dist/environment/spin.js.map +1 -0
  125. package/dist/environment/utilities.d.ts +6 -0
  126. package/dist/environment/utilities.js +12 -0
  127. package/dist/environment/utilities.js.map +1 -0
  128. package/dist/environment.d.ts +5 -0
  129. package/dist/environment.js +6 -0
  130. package/dist/environment.js.map +1 -0
  131. package/dist/error.d.ts +44 -0
  132. package/dist/error.js +91 -0
  133. package/dist/error.js.map +1 -0
  134. package/dist/file.d.ts +67 -0
  135. package/dist/file.js +165 -0
  136. package/dist/file.js.map +1 -0
  137. package/dist/git.d.ts +15 -0
  138. package/dist/git.js +48 -0
  139. package/dist/git.js.map +1 -0
  140. package/dist/github.d.ts +33 -0
  141. package/dist/github.js +56 -0
  142. package/dist/github.js.map +1 -0
  143. package/dist/haiku.d.ts +1 -0
  144. package/dist/haiku.js +8 -0
  145. package/dist/haiku.js.map +1 -0
  146. package/dist/http/fetch.d.ts +16 -0
  147. package/dist/http/fetch.js +18 -0
  148. package/dist/http/fetch.js.map +1 -0
  149. package/dist/http/formdata.d.ts +3 -0
  150. package/dist/http/formdata.js +6 -0
  151. package/dist/http/formdata.js.map +1 -0
  152. package/dist/http.d.ts +2 -0
  153. package/dist/http.js +3 -0
  154. package/dist/http.js.map +1 -0
  155. package/dist/id.d.ts +6 -0
  156. package/dist/id.js +18 -0
  157. package/dist/id.js.map +1 -0
  158. package/dist/index.d.ts +37 -2179
  159. package/dist/index.js +38 -3264
  160. package/dist/index.js.map +1 -1
  161. package/dist/network/api.d.ts +2 -0
  162. package/dist/network/api.js +2 -0
  163. package/dist/network/api.js.map +1 -0
  164. package/dist/network/service.d.ts +16 -0
  165. package/dist/network/service.js +12 -0
  166. package/dist/network/service.js.map +1 -0
  167. package/dist/{archiver.d.ts → node/archiver.d.ts} +1 -4
  168. package/dist/node/archiver.js +22 -42
  169. package/dist/node/archiver.js.map +1 -1
  170. package/dist/node/cli.d.ts +18 -0
  171. package/dist/node/cli.js +91 -0
  172. package/dist/node/cli.js.map +1 -0
  173. package/dist/npm.d.ts +27 -0
  174. package/dist/npm.js +20 -0
  175. package/dist/npm.js.map +1 -0
  176. package/dist/os.d.ts +10 -0
  177. package/dist/os.js +70 -0
  178. package/dist/os.js.map +1 -0
  179. package/dist/output.d.ts +142 -0
  180. package/dist/output.js +505 -0
  181. package/dist/output.js.map +1 -0
  182. package/dist/path.d.ts +22 -0
  183. package/dist/path.js +43 -0
  184. package/dist/path.js.map +1 -0
  185. package/dist/plugins.d.ts +9 -0
  186. package/dist/plugins.js +12 -0
  187. package/dist/plugins.js.map +1 -0
  188. package/dist/port.d.ts +5 -0
  189. package/dist/port.js +13 -0
  190. package/dist/port.js.map +1 -0
  191. package/dist/ruby.d.ts +21 -0
  192. package/dist/ruby.js +192 -0
  193. package/dist/ruby.js.map +1 -0
  194. package/dist/schema.d.ts +1 -0
  195. package/dist/schema.js +2 -0
  196. package/dist/schema.js.map +1 -0
  197. package/dist/secure-store.d.ts +19 -0
  198. package/dist/secure-store.js +63 -0
  199. package/dist/secure-store.js.map +1 -0
  200. package/dist/semver.d.ts +3 -0
  201. package/dist/semver.js +6 -0
  202. package/dist/semver.js.map +1 -0
  203. package/dist/session/authorize.d.ts +7 -0
  204. package/dist/session/authorize.js +40 -0
  205. package/dist/session/authorize.js.map +1 -0
  206. package/dist/session/exchange.d.ts +42 -0
  207. package/dist/session/exchange.js +144 -0
  208. package/dist/session/exchange.js.map +1 -0
  209. package/dist/session/identity.d.ts +3 -0
  210. package/dist/session/identity.js +58 -0
  211. package/dist/session/identity.js.map +1 -0
  212. package/dist/session/post-auth.d.ts +13 -0
  213. package/dist/session/post-auth.js +56 -0
  214. package/dist/session/post-auth.js.map +1 -0
  215. package/dist/session/redirect-listener.d.ts +34 -0
  216. package/dist/session/redirect-listener.js +97 -0
  217. package/dist/session/redirect-listener.js.map +1 -0
  218. package/dist/session/schema.d.ts +174 -0
  219. package/dist/session/schema.js +59 -0
  220. package/dist/session/schema.js.map +1 -0
  221. package/dist/session/scopes.d.ts +16 -0
  222. package/dist/session/scopes.js +53 -0
  223. package/dist/session/scopes.js.map +1 -0
  224. package/dist/session/store.d.ts +24 -0
  225. package/dist/session/store.js +88 -0
  226. package/dist/session/store.js.map +1 -0
  227. package/dist/session/token.d.ts +40 -0
  228. package/dist/session/token.js +22 -0
  229. package/dist/session/token.js.map +1 -0
  230. package/dist/session/validate.d.ts +17 -0
  231. package/dist/session/validate.js +75 -0
  232. package/dist/session/validate.js.map +1 -0
  233. package/dist/session.d.ts +88 -0
  234. package/dist/session.js +251 -0
  235. package/dist/session.js.map +1 -0
  236. package/dist/store/schema.d.ts +3 -0
  237. package/dist/store/schema.js +27 -0
  238. package/dist/store/schema.js.map +1 -0
  239. package/dist/store.d.ts +32 -0
  240. package/dist/store.js +102 -0
  241. package/dist/store.js.map +1 -0
  242. package/dist/string.d.ts +22 -0
  243. package/dist/string.js +38 -0
  244. package/dist/string.js.map +1 -0
  245. package/dist/system.d.ts +53 -0
  246. package/dist/system.js +109 -0
  247. package/dist/system.js.map +1 -0
  248. package/dist/template.d.ts +11 -0
  249. package/dist/template.js +50 -0
  250. package/dist/template.js.map +1 -0
  251. package/dist/testing/output.d.ts +9 -0
  252. package/dist/testing/output.js +15 -0
  253. package/dist/testing/output.js.map +1 -0
  254. package/dist/testing/store.d.ts +7 -0
  255. package/dist/testing/store.js +26 -0
  256. package/dist/testing/store.js.map +1 -0
  257. package/dist/toml.d.ts +3 -0
  258. package/dist/toml.js +8 -0
  259. package/dist/toml.js.map +1 -0
  260. package/dist/tsconfig.tsbuildinfo +1 -0
  261. package/dist/ui/autocomplete.d.ts +7 -0
  262. package/dist/ui/autocomplete.js +43 -0
  263. package/dist/ui/autocomplete.js.map +1 -0
  264. package/dist/ui/input.d.ts +7 -0
  265. package/dist/ui/input.js +48 -0
  266. package/dist/ui/input.js.map +1 -0
  267. package/dist/ui/select.d.ts +6 -0
  268. package/dist/ui/select.js +30 -0
  269. package/dist/ui/select.js.map +1 -0
  270. package/dist/ui.d.ts +36 -0
  271. package/dist/ui.js +124 -0
  272. package/dist/ui.js.map +1 -0
  273. package/dist/version.d.ts +19 -0
  274. package/dist/version.js +34 -0
  275. package/dist/version.js.map +1 -0
  276. package/dist/vscode.d.ts +8 -0
  277. package/dist/vscode.js +36 -0
  278. package/dist/vscode.js.map +1 -0
  279. package/dist/yaml.d.ts +2 -0
  280. package/dist/yaml.js +8 -0
  281. package/dist/yaml.js.map +1 -0
  282. package/package.json +14 -7
  283. package/dist/archiver.d.ts.map +0 -1
  284. package/dist/index.d.ts.map +0 -1
  285. package/dist/local-d0094ffe.js +0 -1344
  286. package/dist/local-d0094ffe.js.map +0 -1
package/dist/output.js ADDED
@@ -0,0 +1,505 @@
1
+ /* eslint-disable no-console */
2
+ import { Bug } from './error.js';
3
+ import { isUnitTest, isVerbose } from './environment/local.js';
4
+ import constants from './constants.js';
5
+ import { append as fileAppend, mkdirSync as fileMkdirSync, readSync as fileReadSync, sizeSync as fileSizeSync, writeSync as fileWriteSync, touchSync as fileTouchSync, } from './file.js';
6
+ import { join as pathJoin, relativize as relativizePath } from './path.js';
7
+ import { page } from './system.js';
8
+ import { colors } from './colors.js';
9
+ import terminalLink from 'terminal-link';
10
+ import StackTracey from 'stacktracey';
11
+ import { AbortController } from 'abort-controller';
12
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
+ // @ts-ignore
14
+ import cjs from 'color-json';
15
+ import stripAnsi from 'strip-ansi';
16
+ import { Writable } from 'node:stream';
17
+ let logFile;
18
+ export function initiateLogging({ logDir = constants.paths.directories.cache.path(), filename = 'shopify.log', }) {
19
+ fileMkdirSync(logDir);
20
+ logFile = pathJoin(logDir, filename);
21
+ fileTouchSync(logFile);
22
+ truncateLogs();
23
+ }
24
+ // Shaves off the first 10,000 log lines (circa 1MB) if logs are over 5MB long.
25
+ // Rescues in case the file hasn't been created yet.
26
+ function truncateLogs() {
27
+ try {
28
+ if (fileSizeSync(logFile) > 5 * 1024 * 1024) {
29
+ const contents = fileReadSync(logFile);
30
+ const splitContents = contents.split('\n');
31
+ const newContents = splitContents.slice(10000, splitContents.length).join('\n');
32
+ fileWriteSync(logFile, newContents);
33
+ }
34
+ // eslint-disable-next-line no-empty, no-catch-all/no-catch-all
35
+ }
36
+ catch { }
37
+ }
38
+ var ContentTokenType;
39
+ (function (ContentTokenType) {
40
+ ContentTokenType[ContentTokenType["Raw"] = 0] = "Raw";
41
+ ContentTokenType[ContentTokenType["Command"] = 1] = "Command";
42
+ ContentTokenType[ContentTokenType["Json"] = 2] = "Json";
43
+ ContentTokenType[ContentTokenType["Path"] = 3] = "Path";
44
+ ContentTokenType[ContentTokenType["Link"] = 4] = "Link";
45
+ ContentTokenType[ContentTokenType["Heading"] = 5] = "Heading";
46
+ ContentTokenType[ContentTokenType["SubHeading"] = 6] = "SubHeading";
47
+ ContentTokenType[ContentTokenType["Italic"] = 7] = "Italic";
48
+ ContentTokenType[ContentTokenType["ErrorText"] = 8] = "ErrorText";
49
+ ContentTokenType[ContentTokenType["Yellow"] = 9] = "Yellow";
50
+ ContentTokenType[ContentTokenType["Cyan"] = 10] = "Cyan";
51
+ ContentTokenType[ContentTokenType["Magenta"] = 11] = "Magenta";
52
+ ContentTokenType[ContentTokenType["Green"] = 12] = "Green";
53
+ })(ContentTokenType || (ContentTokenType = {}));
54
+ class ContentToken {
55
+ constructor(value, metadata = {}, type) {
56
+ this.type = type;
57
+ this.value = value;
58
+ this.metadata = metadata;
59
+ }
60
+ }
61
+ export const token = {
62
+ raw: (value) => {
63
+ return new ContentToken(value, {}, ContentTokenType.Raw);
64
+ },
65
+ genericShellCommand: (value) => {
66
+ return new ContentToken(value, {}, ContentTokenType.Command);
67
+ },
68
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ json: (value) => {
70
+ return new ContentToken(value, {}, ContentTokenType.Json);
71
+ },
72
+ path: (value) => {
73
+ return new ContentToken(value, {}, ContentTokenType.Path);
74
+ },
75
+ link: (value, link) => {
76
+ return new ContentToken(value, { link }, ContentTokenType.Link);
77
+ },
78
+ heading: (value) => {
79
+ return new ContentToken(value, {}, ContentTokenType.Heading);
80
+ },
81
+ subheading: (value) => {
82
+ return new ContentToken(value, {}, ContentTokenType.SubHeading);
83
+ },
84
+ italic: (value) => {
85
+ return new ContentToken(value, {}, ContentTokenType.Italic);
86
+ },
87
+ errorText: (value) => {
88
+ return new ContentToken(value, {}, ContentTokenType.ErrorText);
89
+ },
90
+ cyan: (value) => {
91
+ return new ContentToken(value, {}, ContentTokenType.Cyan);
92
+ },
93
+ yellow: (value) => {
94
+ return new ContentToken(value, {}, ContentTokenType.Yellow);
95
+ },
96
+ magenta: (value) => {
97
+ return new ContentToken(value, {}, ContentTokenType.Magenta);
98
+ },
99
+ green: (value) => {
100
+ return new ContentToken(value, {}, ContentTokenType.Green);
101
+ },
102
+ packagejsonScript: (dependencyManager, scriptName, ...scriptArgs) => {
103
+ return new ContentToken(formatPackageManagerCommand(dependencyManager, scriptName, scriptArgs), {}, ContentTokenType.Command);
104
+ },
105
+ successIcon: () => {
106
+ return new ContentToken('✔', {}, ContentTokenType.Green);
107
+ },
108
+ failIcon: () => {
109
+ return new ContentToken('✖', {}, ContentTokenType.ErrorText);
110
+ },
111
+ };
112
+ function formatPackageManagerCommand(dependencyManager, scriptName, scriptArgs) {
113
+ switch (dependencyManager) {
114
+ case 'yarn': {
115
+ const pieces = ['yarn', scriptName, ...scriptArgs];
116
+ return pieces.join(' ');
117
+ }
118
+ case 'pnpm':
119
+ case 'npm': {
120
+ const pieces = [dependencyManager, 'run', scriptName];
121
+ if (scriptArgs.length > 0) {
122
+ pieces.push('--');
123
+ pieces.push(...scriptArgs);
124
+ }
125
+ return pieces.join(' ');
126
+ }
127
+ }
128
+ }
129
+ export class TokenizedString {
130
+ constructor(value) {
131
+ this.value = value;
132
+ }
133
+ }
134
+ export function content(strings, ...keys) {
135
+ let output = ``;
136
+ strings.forEach((string, i) => {
137
+ output += string;
138
+ if (i >= keys.length) {
139
+ return;
140
+ }
141
+ const token = keys[i];
142
+ if (typeof token === 'string') {
143
+ output += token;
144
+ }
145
+ else {
146
+ const enumToken = token;
147
+ switch (enumToken.type) {
148
+ case ContentTokenType.Raw:
149
+ output += enumToken.value;
150
+ break;
151
+ case ContentTokenType.Command:
152
+ output += colors.bold(colors.yellow(stringifyMessage(enumToken.value)));
153
+ break;
154
+ case ContentTokenType.Path:
155
+ output += relativizePath(stringifyMessage(enumToken.value));
156
+ break;
157
+ case ContentTokenType.Json:
158
+ try {
159
+ output += cjs(stringifyMessage(enumToken.value) ?? {});
160
+ // eslint-disable-next-line no-catch-all/no-catch-all
161
+ }
162
+ catch (_) {
163
+ output += JSON.stringify(stringifyMessage(enumToken.value) ?? {}, null, 2);
164
+ }
165
+ break;
166
+ case ContentTokenType.Link:
167
+ output += terminalLink(colors.green(stringifyMessage(enumToken.value)), enumToken.metadata.link ?? '');
168
+ break;
169
+ case ContentTokenType.Heading:
170
+ output += colors.bold.underline(stringifyMessage(enumToken.value));
171
+ break;
172
+ case ContentTokenType.SubHeading:
173
+ output += colors.underline(stringifyMessage(enumToken.value));
174
+ break;
175
+ case ContentTokenType.Italic:
176
+ output += colors.italic(stringifyMessage(enumToken.value));
177
+ break;
178
+ case ContentTokenType.ErrorText:
179
+ output += colors.bold.redBright(stringifyMessage(enumToken.value));
180
+ break;
181
+ case ContentTokenType.Yellow:
182
+ output += colors.yellow(stringifyMessage(enumToken.value));
183
+ break;
184
+ case ContentTokenType.Cyan:
185
+ output += colors.cyan(stringifyMessage(enumToken.value));
186
+ break;
187
+ case ContentTokenType.Magenta:
188
+ output += colors.magenta(stringifyMessage(enumToken.value));
189
+ break;
190
+ case ContentTokenType.Green:
191
+ output += colors.green(stringifyMessage(enumToken.value));
192
+ break;
193
+ }
194
+ }
195
+ });
196
+ return new TokenizedString(output);
197
+ }
198
+ /**
199
+ * It maps a level to a numeric value.
200
+ * @param level {LogLevel} The level for which we'll return its numeric value.
201
+ * @returns The numeric value of the level.
202
+ */
203
+ const logLevelValue = (level) => {
204
+ switch (level) {
205
+ case 'trace':
206
+ return 10;
207
+ case 'debug':
208
+ return 20;
209
+ case 'info':
210
+ return 30;
211
+ case 'warn':
212
+ return 40;
213
+ case 'error':
214
+ return 50;
215
+ case 'fatal':
216
+ return 60;
217
+ default:
218
+ return 30;
219
+ }
220
+ };
221
+ /**
222
+ *
223
+ * @returns {LogLevel} It returns the log level set by the user.
224
+ */
225
+ export const currentLogLevel = () => {
226
+ if (isVerbose()) {
227
+ return 'debug';
228
+ }
229
+ else {
230
+ return 'info';
231
+ }
232
+ };
233
+ export const shouldOutput = (logLevel) => {
234
+ if (isUnitTest()) {
235
+ return false;
236
+ }
237
+ const currentLogLevelValue = logLevelValue(currentLogLevel());
238
+ const messageLogLevelValue = logLevelValue(logLevel);
239
+ return messageLogLevelValue >= currentLogLevelValue;
240
+ };
241
+ // eslint-disable-next-line import/no-mutable-exports
242
+ export let collectedLogs = {};
243
+ /**
244
+ * This is only used during UnitTesting.
245
+ * If we are in a testing context, instead of printing the logs to the console,
246
+ * we will store them in a variable that can be accessed from the tests.
247
+ * @param key {string} The key of the log.
248
+ * @param content {string} The content of the log.
249
+ */
250
+ const collectLog = (key, content) => {
251
+ const output = collectedLogs.output ?? [];
252
+ const data = collectedLogs[key] ?? [];
253
+ data.push(stripAnsi(stringifyMessage(content) ?? ''));
254
+ output.push(stripAnsi(stringifyMessage(content) ?? ''));
255
+ collectedLogs[key] = data;
256
+ collectedLogs.output = output;
257
+ };
258
+ export const clearCollectedLogs = () => {
259
+ collectedLogs = {};
260
+ };
261
+ /**
262
+ * Ouputs information to the user. This is akin to "console.log"
263
+ * Info messages don't get additional formatting.
264
+ * Note: Info messages are sent through the standard output.
265
+ * @param content {string} The content to be output to the user.
266
+ */
267
+ export const info = (content) => {
268
+ if (isUnitTest())
269
+ collectLog('info', content);
270
+ message(content, 'info');
271
+ };
272
+ /**
273
+ * Outputs a success message to the user.
274
+ * Success message receive a special formatting to make them stand out in the console.
275
+ * Note: Success messages are sent through the standard output.
276
+ * @param content {string} The content to be output to the user.
277
+ */
278
+ export const success = (content) => {
279
+ const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`);
280
+ if (isUnitTest())
281
+ collectLog('success', content);
282
+ outputWhereAppropriate('info', consoleLog, message);
283
+ };
284
+ /**
285
+ * Outputs a completed message to the user.
286
+ * Completed message receive a special formatting to make them stand out in the console.
287
+ * Note: Completed messages are sent through the standard output.
288
+ * @param content {string} The content to be output to the user.
289
+ */
290
+ export const completed = (content) => {
291
+ const message = `${colors.green('✔')} ${stringifyMessage(content)}`;
292
+ if (isUnitTest())
293
+ collectLog('completed', content);
294
+ outputWhereAppropriate('info', consoleLog, message);
295
+ };
296
+ /**
297
+ * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.
298
+ * Debug messages don't get additional formatting.
299
+ * Note: Debug messages are sent through the standard output.
300
+ * @param content {string} The content to be output to the user.
301
+ */
302
+ export const debug = (content) => {
303
+ if (isUnitTest())
304
+ collectLog('debug', content);
305
+ message(colors.gray(stringifyMessage(content)), 'debug');
306
+ };
307
+ /**
308
+ * Outputs a warning message to the user.
309
+ * Warning messages receive a special formatting to make them stand out in the console.
310
+ * Note: Warning messages are sent through the standard output.
311
+ * @param content {string} The content to be output to the user.
312
+ */
313
+ export const warn = (content) => {
314
+ if (isUnitTest())
315
+ collectLog('warn', content);
316
+ consoleWarn(colors.yellow(stringifyMessage(content)));
317
+ };
318
+ /**
319
+ * Prints a new line in the terminal.
320
+ */
321
+ export const newline = () => {
322
+ console.log();
323
+ };
324
+ /**
325
+ * Formats and outputs a fatal error.
326
+ * Note: This API is not intended to be used internally. If you want to
327
+ * abort the execution due to an error, raise a fatal error and let the
328
+ * error handler handle and format it.
329
+ * @param content {Fatal} The fatal error to be output.
330
+ */
331
+ export const error = async (content) => {
332
+ if (!content.message) {
333
+ return;
334
+ }
335
+ let outputString = '';
336
+ const message = content.message;
337
+ const padding = ' ';
338
+ const header = colors.redBright(`\n━━━━━━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n`);
339
+ const footer = colors.redBright('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
340
+ outputString += header;
341
+ const lines = message.split('\n');
342
+ for (const line of lines) {
343
+ outputString += `${padding}${line}\n`;
344
+ }
345
+ if (content.tryMessage) {
346
+ outputString += `\n${padding}${colors.bold('What to try:')}\n`;
347
+ const lines = content.tryMessage.split('\n');
348
+ for (const line of lines) {
349
+ outputString += `${padding}${line}\n`;
350
+ }
351
+ }
352
+ let stack = await new StackTracey(content).withSourcesAsync();
353
+ stack = stack
354
+ .filter((entry) => {
355
+ return !entry.file.includes('@oclif/core');
356
+ })
357
+ .map((item) => {
358
+ item.calleeShort = colors.yellow(item.calleeShort);
359
+ /** We make the paths relative to the packages/ directory */
360
+ const fileShortComponents = item.fileShort.split('packages/');
361
+ item.fileShort = fileShortComponents.length === 2 ? fileShortComponents[1] : fileShortComponents[0];
362
+ return item;
363
+ });
364
+ if (content instanceof Bug) {
365
+ if (stack.items.length !== 0) {
366
+ outputString += `\n${padding}${colors.bold('Stack trace:')}`;
367
+ const stackLines = stack.asTable({}).split('\n');
368
+ for (const stackLine of stackLines) {
369
+ outputString += `${padding}${stackLine}\n`;
370
+ }
371
+ }
372
+ }
373
+ outputString += footer;
374
+ outputWhereAppropriate('error', consoleError, outputString);
375
+ };
376
+ export function stringifyMessage(message) {
377
+ if (message instanceof TokenizedString) {
378
+ return message.value;
379
+ }
380
+ else {
381
+ return message;
382
+ }
383
+ }
384
+ const message = (content, level = 'info') => {
385
+ const stringifiedMessage = stringifyMessage(content);
386
+ outputWhereAppropriate(level, consoleLog, stringifiedMessage);
387
+ };
388
+ /**
389
+ * Use this function when you have multiple concurrent processes that send data events
390
+ * and we need to output them ensuring that they can visually differenciated by the user.
391
+ *
392
+ * @param processes {OutputProcess[]} A list of processes to run concurrently.
393
+ */
394
+ export async function concurrent(processes, callback = undefined) {
395
+ const abortController = new AbortController();
396
+ // eslint-disable-next-line node/callback-return
397
+ if (callback)
398
+ callback(abortController.signal);
399
+ const concurrentColors = [token.yellow, token.cyan, token.magenta, token.green];
400
+ const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length));
401
+ function linePrefix(prefix, index) {
402
+ const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length;
403
+ const color = concurrentColors[colorIndex];
404
+ return color(`${prefix}${' '.repeat(prefixColumnSize - prefix.length)} ${colors.bold('|')} `);
405
+ }
406
+ try {
407
+ await Promise.all(processes.map(async (process, index) => {
408
+ const stdout = new Writable({
409
+ write(chunk, _encoding, next) {
410
+ const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\n/);
411
+ for (const line of lines) {
412
+ info(content `${linePrefix(process.prefix, index)}${line}`);
413
+ }
414
+ next();
415
+ },
416
+ });
417
+ const stderr = new Writable({
418
+ write(chunk, _encoding, next) {
419
+ const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\n/);
420
+ for (const line of lines) {
421
+ message(content `${linePrefix(process.prefix, index)}${colors.bold(line)}`, 'error');
422
+ }
423
+ next();
424
+ },
425
+ });
426
+ await process.action(stdout, stderr, abortController.signal);
427
+ }));
428
+ }
429
+ catch (_error) {
430
+ // We abort any running process
431
+ abortController.abort();
432
+ throw _error;
433
+ }
434
+ }
435
+ /**
436
+ * This regex can be used to find the erase cursor Ansii characters
437
+ * to strip them from the string.
438
+ * https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#erase-functions
439
+ */
440
+ const eraseCursorAnsiRegex = [
441
+ // Erase the entire line
442
+ '2K',
443
+ // Clear vertical tab stop at current line
444
+ '1G',
445
+ ]
446
+ .map((element) => `[\\u001B\\u009B][[\\]()#;?]*${element}`)
447
+ .join('|');
448
+ /**
449
+ * The data sent through the standard pipelines of the sub-processes that we execute
450
+ * might contain ansii escape characters to move the cursor. That causes any additional
451
+ * formatting to break. This function takes a string and strips escape characters that
452
+ * manage the cursor in the terminal.
453
+ * @param value {string} String whose erase cursor escape characters will be stripped.
454
+ * @returns {string} Stripped string.
455
+ */
456
+ function stripAnsiEraseCursorEscapeCharacters(value) {
457
+ return value.replace(/(\n)$/, '').replace(new RegExp(eraseCursorAnsiRegex, 'g'), '');
458
+ }
459
+ function consoleLog(message) {
460
+ console.log(withOrWithoutStyle(message));
461
+ }
462
+ function consoleError(message) {
463
+ console.error(withOrWithoutStyle(message));
464
+ }
465
+ function consoleWarn(message) {
466
+ console.warn(withOrWithoutStyle(message));
467
+ }
468
+ function outputWhereAppropriate(logLevel, logFunc, message) {
469
+ if (shouldOutput(logLevel)) {
470
+ logFunc(message);
471
+ }
472
+ logToFile(message, logLevel.toUpperCase());
473
+ }
474
+ export function logFileExists() {
475
+ return Boolean(logFile);
476
+ }
477
+ // DO NOT USE THIS FUNCTION DIRECTLY under normal circumstances.
478
+ // It is exported purely for use in cases where output is already being logged
479
+ // to the terminal but is not reflected in the logfile, e.g. Listr output.
480
+ export function logToFile(message, logLevel) {
481
+ // If file logging hasn't been initiated, skip it
482
+ if (!logFileExists())
483
+ return;
484
+ const timestamp = new Date().toISOString();
485
+ fileAppend(logFile, `[${timestamp} ${logLevel}]: ${message}\n`);
486
+ }
487
+ function withOrWithoutStyle(message) {
488
+ if (shouldDisplayColors()) {
489
+ return message;
490
+ }
491
+ else {
492
+ return unstyled(message);
493
+ }
494
+ }
495
+ export function unstyled(message) {
496
+ return colors.unstyle(message);
497
+ }
498
+ export function shouldDisplayColors() {
499
+ return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR);
500
+ }
501
+ export async function pageLogs() {
502
+ await page(logFile);
503
+ }
504
+ /* eslint-enable no-console */
505
+ //# sourceMappingURL=output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAQ,GAAG,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAC5D,OAAO,SAAS,MAAM,gBAAgB,CAAA;AAEtC,OAAO,EACL,MAAM,IAAI,UAAU,EACpB,SAAS,IAAI,aAAa,EAC1B,QAAQ,IAAI,YAAY,EACxB,QAAQ,IAAI,YAAY,EACxB,SAAS,IAAI,aAAa,EAC1B,SAAS,IAAI,aAAa,GAC3B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAE,UAAU,IAAI,cAAc,EAAC,MAAM,WAAW,CAAA;AACxE,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAChC,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,EAAC,eAAe,EAAc,MAAM,kBAAkB,CAAA;AAC7D,6DAA6D;AAC7D,aAAa;AACb,OAAO,GAAG,MAAM,YAAY,CAAA;AAC5B,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AAEpC,IAAI,OAAe,CAAA;AAEnB,MAAM,UAAU,eAAe,CAAC,EAC9B,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,EACjD,QAAQ,GAAG,aAAa,GAIzB;IACC,aAAa,CAAC,MAAM,CAAC,CAAA;IACrB,OAAO,GAAG,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EAAE,EAAE;QACzB,OAAO,OAAO,CAAA;KACf;SAAM;QACL,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAA;KACzB;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAe;IACtC,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;AACjE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,MAAM,IAAI,CAAC,OAAO,CAAC,CAAA;AACrB,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {Fatal, Bug} from './error.js'\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport constants from './constants.js'\nimport {DependencyManager} from './dependency.js'\nimport {\n append as fileAppend,\n mkdirSync as fileMkdirSync,\n readSync as fileReadSync,\n sizeSync as fileSizeSync,\n writeSync as fileWriteSync,\n touchSync as fileTouchSync,\n} from './file.js'\nimport {join as pathJoin, relativize as relativizePath} from './path.js'\nimport {page} from './system.js'\nimport {colors} from './colors.js'\nimport terminalLink from 'terminal-link'\nimport StackTracey from 'stacktracey'\nimport {AbortController, AbortSignal} from 'abort-controller'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport cjs from 'color-json'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'node:stream'\n\nlet logFile: string\n\nexport function initiateLogging({\n logDir = constants.paths.directories.cache.path(),\n filename = 'shopify.log',\n}: {\n logDir?: string\n filename?: string\n}) {\n fileMkdirSync(logDir)\n logFile = pathJoin(logDir, filename)\n fileTouchSync(logFile)\n truncateLogs()\n}\n\n// Shaves off the first 10,000 log lines (circa 1MB) if logs are over 5MB long.\n// Rescues in case the file hasn't been created yet.\nfunction truncateLogs() {\n try {\n if (fileSizeSync(logFile) > 5 * 1024 * 1024) {\n const contents = fileReadSync(logFile)\n const splitContents = contents.split('\\n')\n const newContents = splitContents.slice(10000, splitContents.length).join('\\n')\n fileWriteSync(logFile, newContents)\n }\n // eslint-disable-next-line no-empty, no-catch-all/no-catch-all\n } catch {}\n}\n\nenum ContentTokenType {\n Raw,\n Command,\n Json,\n Path,\n Link,\n Heading,\n SubHeading,\n Italic,\n ErrorText,\n Yellow,\n Cyan,\n Magenta,\n Green,\n}\n\ninterface ContentMetadata {\n link?: string\n}\n\nclass ContentToken {\n type: ContentTokenType\n value: Message\n metadata: ContentMetadata\n\n constructor(value: Message, metadata: ContentMetadata = {}, type: ContentTokenType) {\n this.type = type\n this.value = value\n this.metadata = metadata\n }\n}\n\nexport const token = {\n raw: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Raw)\n },\n genericShellCommand: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Command)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new ContentToken(value, {}, ContentTokenType.Json)\n },\n path: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Path)\n },\n link: (value: Message, link: string) => {\n return new ContentToken(value, {link}, ContentTokenType.Link)\n },\n heading: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Heading)\n },\n subheading: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.SubHeading)\n },\n italic: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Italic)\n },\n errorText: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.ErrorText)\n },\n cyan: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Cyan)\n },\n yellow: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Yellow)\n },\n magenta: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Magenta)\n },\n green: (value: Message) => {\n return new ContentToken(value, {}, ContentTokenType.Green)\n },\n packagejsonScript: (dependencyManager: DependencyManager, scriptName: string, ...scriptArgs: string[]) => {\n return new ContentToken(\n formatPackageManagerCommand(dependencyManager, scriptName, scriptArgs),\n {},\n ContentTokenType.Command,\n )\n },\n successIcon: () => {\n return new ContentToken('✔', {}, ContentTokenType.Green)\n },\n failIcon: () => {\n return new ContentToken('✖', {}, ContentTokenType.ErrorText)\n },\n}\n\nfunction formatPackageManagerCommand(\n dependencyManager: DependencyManager,\n scriptName: string,\n scriptArgs: string[],\n): string {\n switch (dependencyManager) {\n case 'yarn': {\n const pieces = ['yarn', scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'pnpm':\n case 'npm': {\n const pieces = [dependencyManager, 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type Message = string | TokenizedString\n\nexport function content(strings: TemplateStringsArray, ...keys: (ContentToken | string)[]): 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 enumToken = token as ContentToken\n switch (enumToken.type) {\n case ContentTokenType.Raw:\n output += enumToken.value\n break\n case ContentTokenType.Command:\n output += colors.bold(colors.yellow(stringifyMessage(enumToken.value)))\n break\n case ContentTokenType.Path:\n output += relativizePath(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Json:\n try {\n output += cjs(stringifyMessage(enumToken.value) ?? {})\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_) {\n output += JSON.stringify(stringifyMessage(enumToken.value) ?? {}, null, 2)\n }\n break\n case ContentTokenType.Link:\n output += terminalLink(colors.green(stringifyMessage(enumToken.value)), enumToken.metadata.link ?? '')\n break\n case ContentTokenType.Heading:\n output += colors.bold.underline(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.SubHeading:\n output += colors.underline(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Italic:\n output += colors.italic(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.ErrorText:\n output += colors.bold.redBright(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Yellow:\n output += colors.yellow(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Cyan:\n output += colors.cyan(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Magenta:\n output += colors.magenta(stringifyMessage(enumToken.value))\n break\n case ContentTokenType.Green:\n output += colors.green(stringifyMessage(enumToken.value))\n break\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 * @param level {LogLevel} The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nconst 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 *\n * @returns {LogLevel} It returns the log level set by the user.\n */\nexport const currentLogLevel = (): LogLevel => {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\nexport const 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 * @param key {string} The key of the log.\n * @param content {string} The content of the log.\n */\nconst collectLog = (key: string, content: Message) => {\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 = () => {\n collectedLogs = {}\n}\n\n/**\n * Ouputs information to the user. This is akin to \"console.log\"\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n */\nexport const info = (content: Message) => {\n if (isUnitTest()) collectLog('info', content)\n message(content, 'info')\n}\n\n/**\n * Outputs a success message to the user.\n * Success message receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n * @param content {string} The content to be output to the user.\n */\nexport const success = (content: Message) => {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', consoleLog, 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 * @param content {string} The content to be output to the user.\n */\nexport const completed = (content: Message) => {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', consoleLog, 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 * @param content {string} The content to be output to the user.\n */\nexport const debug = (content: Message) => {\n if (isUnitTest()) collectLog('debug', content)\n message(colors.gray(stringifyMessage(content)), 'debug')\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 * @param content {string} The content to be output to the user.\n */\nexport const warn = (content: Message) => {\n if (isUnitTest()) collectLog('warn', content)\n consoleWarn(colors.yellow(stringifyMessage(content)))\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport const newline = () => {\n console.log()\n}\n\n/**\n * Formats and outputs a fatal error.\n * Note: This API is not intended to be used internally. If you want to\n * abort the execution due to an error, raise a fatal error and let the\n * error handler handle and format it.\n * @param content {Fatal} The fatal error to be output.\n */\nexport const error = async (content: Fatal) => {\n if (!content.message) {\n return\n }\n let outputString = ''\n const message = content.message\n const padding = ' '\n const header = colors.redBright(`\\n━━━━━━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n`)\n const footer = colors.redBright('\\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n')\n outputString += header\n const lines = message.split('\\n')\n for (const line of lines) {\n outputString += `${padding}${line}\\n`\n }\n if (content.tryMessage) {\n outputString += `\\n${padding}${colors.bold('What to try:')}\\n`\n const lines = content.tryMessage.split('\\n')\n for (const line of lines) {\n outputString += `${padding}${line}\\n`\n }\n }\n\n let stack = await new StackTracey(content).withSourcesAsync()\n stack = stack\n .filter((entry) => {\n return !entry.file.includes('@oclif/core')\n })\n .map((item) => {\n item.calleeShort = colors.yellow(item.calleeShort)\n /** We make the paths relative to the packages/ directory */\n const fileShortComponents = item.fileShort.split('packages/')\n item.fileShort = fileShortComponents.length === 2 ? fileShortComponents[1] : fileShortComponents[0]\n return item\n })\n if (content instanceof Bug) {\n if (stack.items.length !== 0) {\n outputString += `\\n${padding}${colors.bold('Stack trace:')}`\n const stackLines = stack.asTable({}).split('\\n')\n for (const stackLine of stackLines) {\n outputString += `${padding}${stackLine}\\n`\n }\n }\n }\n outputString += footer\n outputWhereAppropriate('error', consoleError, outputString)\n}\n\nexport function stringifyMessage(message: Message): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nconst message = (content: Message, level: LogLevel = 'info') => {\n const stringifiedMessage = stringifyMessage(content)\n outputWhereAppropriate(level, consoleLog, stringifiedMessage)\n}\n\nexport interface OutputProcess {\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 * Use this function when you have multiple concurrent processes that send data events\n * and we need to output them ensuring that they can visually differenciated by the user.\n *\n * @param processes {OutputProcess[]} A list of processes to run concurrently.\n */\nexport async function concurrent(\n processes: OutputProcess[],\n callback: ((signal: AbortSignal) => void) | undefined = undefined,\n) {\n const abortController = new AbortController()\n\n // eslint-disable-next-line node/callback-return\n if (callback) callback(abortController.signal)\n\n const concurrentColors = [token.yellow, token.cyan, token.magenta, token.green]\n const prefixColumnSize = Math.max(...processes.map((process) => process.prefix.length))\n\n function linePrefix(prefix: string, index: number) {\n const colorIndex = index < concurrentColors.length ? index : index % concurrentColors.length\n const color = concurrentColors[colorIndex]\n return color(`${prefix}${' '.repeat(prefixColumnSize - prefix.length)} ${colors.bold('|')} `)\n }\n\n try {\n await Promise.all(\n processes.map(async (process, index) => {\n const stdout = new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\\n/)\n for (const line of lines) {\n info(content`${linePrefix(process.prefix, index)}${line}`)\n }\n next()\n },\n })\n const stderr = new Writable({\n write(chunk, _encoding, next) {\n const lines = stripAnsiEraseCursorEscapeCharacters(chunk.toString('ascii')).split(/\\n/)\n for (const line of lines) {\n message(content`${linePrefix(process.prefix, index)}${colors.bold(line)}`, 'error')\n }\n next()\n },\n })\n await process.action(stdout, stderr, abortController.signal)\n }),\n )\n } catch (_error) {\n // We abort any running process\n abortController.abort()\n throw _error\n }\n}\n\n/**\n * This regex can be used to find the erase cursor Ansii characters\n * to strip them from the string.\n * https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#erase-functions\n */\nconst eraseCursorAnsiRegex = [\n // Erase the entire line\n '2K',\n // Clear vertical tab stop at current line\n '1G',\n]\n .map((element) => `[\\\\u001B\\\\u009B][[\\\\]()#;?]*${element}`)\n .join('|')\n\n/**\n * The data sent through the standard pipelines of the sub-processes that we execute\n * might contain ansii escape characters to move the cursor. That causes any additional\n * formatting to break. This function takes a string and strips escape characters that\n * manage the cursor in the terminal.\n * @param value {string} String whose erase cursor escape characters will be stripped.\n * @returns {string} Stripped string.\n */\nfunction stripAnsiEraseCursorEscapeCharacters(value: string): string {\n return value.replace(/(\\n)$/, '').replace(new RegExp(eraseCursorAnsiRegex, 'g'), '')\n}\n\nfunction consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nfunction consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nfunction consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nfunction outputWhereAppropriate(logLevel: LogLevel, logFunc: (message: string) => void, message: string): void {\n if (shouldOutput(logLevel)) {\n logFunc(message)\n }\n logToFile(message, logLevel.toUpperCase())\n}\n\nexport function logFileExists(): boolean {\n return Boolean(logFile)\n}\n\n// DO NOT USE THIS FUNCTION DIRECTLY under normal circumstances.\n// It is exported purely for use in cases where output is already being logged\n// to the terminal but is not reflected in the logfile, e.g. Listr output.\nexport function logToFile(message: string, logLevel: string): void {\n // If file logging hasn't been initiated, skip it\n if (!logFileExists()) return\n const timestamp = new Date().toISOString()\n fileAppend(logFile, `[${timestamp} ${logLevel}]: ${message}\\n`)\n}\n\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\nexport function unstyled(message: string): string {\n return colors.unstyle(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\nexport async function pageLogs() {\n await page(logFile)\n}\n\n/* eslint-enable no-console */\n"]}
package/dist/path.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute } from 'pathe';
2
+ import { findUp as internalFindUp, Match as FindUpMatch } from 'find-up';
3
+ export { join, relative, dirname, normalize, resolve, basename, extname, isAbsolute };
4
+ export { default as glob } from 'fast-glob';
5
+ export { pathToFileURL } from 'node:url';
6
+ declare type FindUpMatcher = (directory: string) => FindUpMatch | Promise<FindUpMatch>;
7
+ export declare function findUp(matcher: string | ReadonlyArray<string> | FindUpMatcher, options: Parameters<typeof internalFindUp>[1]): ReturnType<typeof internalFindUp>;
8
+ /**
9
+ * Given an absolute filesystem path, it makes it relative to
10
+ * the current working directory. This is useful when logging paths
11
+ * to allow the users to click on the file and let the OS open it
12
+ * in the editor of choice.
13
+ * @param path {string} Path to relativize
14
+ * @returns {string} Relativized path.
15
+ */
16
+ export declare function relativize(path: string): string;
17
+ /**
18
+ * Given a module's import.meta.url it returns the directory containing the module.
19
+ * @param moduleURL {string} The value of import.meta.url in the context of the caller module.
20
+ * @returns {string} The path to the directory containing the caller module.
21
+ */
22
+ export declare function moduleDirectory(moduleURL: string | URL): string;
package/dist/path.js ADDED
@@ -0,0 +1,43 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore
3
+ import commondir from 'commondir';
4
+ import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute } from 'pathe';
5
+ import { findUp as internalFindUp } from 'find-up';
6
+ import { fileURLToPath } from 'url';
7
+ export { join, relative, dirname, normalize, resolve, basename, extname, isAbsolute };
8
+ export { default as glob } from 'fast-glob';
9
+ export { pathToFileURL } from 'node:url';
10
+ export async function findUp(matcher, options) {
11
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
+ // @ts-ignore
13
+ const got = await internalFindUp(matcher, options);
14
+ return got ? normalize(got) : undefined;
15
+ }
16
+ /**
17
+ * Given an absolute filesystem path, it makes it relative to
18
+ * the current working directory. This is useful when logging paths
19
+ * to allow the users to click on the file and let the OS open it
20
+ * in the editor of choice.
21
+ * @param path {string} Path to relativize
22
+ * @returns {string} Relativized path.
23
+ */
24
+ export function relativize(path) {
25
+ const result = commondir([path, process.cwd()]);
26
+ const relativePath = relative(process.cwd(), path);
27
+ const relativeComponents = relativePath.split('/').filter((component) => component === '..').length;
28
+ if (result === '/' || relativePath === '' || relativeComponents > 2) {
29
+ return path;
30
+ }
31
+ else {
32
+ return relativePath;
33
+ }
34
+ }
35
+ /**
36
+ * Given a module's import.meta.url it returns the directory containing the module.
37
+ * @param moduleURL {string} The value of import.meta.url in the context of the caller module.
38
+ * @returns {string} The path to the directory containing the caller module.
39
+ */
40
+ export function moduleDirectory(moduleURL) {
41
+ return dirname(fileURLToPath(moduleURL));
42
+ }
43
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,aAAa;AACb,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAC,MAAM,OAAO,CAAA;AAChG,OAAO,EAAC,MAAM,IAAI,cAAc,EAAuB,MAAM,SAAS,CAAA;AACtE,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAEjC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAC,CAAA;AAEnF,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,WAAW,CAAA;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;AAItC,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAuD,EACvD,OAA6C;IAE7C,6DAA6D;IAC7D,aAAa;IACb,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAClD,OAAO,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAA;IAClD,MAAM,kBAAkB,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,MAAM,CAAA;IACnG,IAAI,MAAM,KAAK,GAAG,IAAI,YAAY,KAAK,EAAE,IAAI,kBAAkB,GAAG,CAAC,EAAE;QACnE,OAAO,IAAI,CAAA;KACZ;SAAM;QACL,OAAO,YAAY,CAAA;KACpB;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB;IACrD,OAAO,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport commondir from 'commondir'\nimport {relative, dirname, join, normalize, resolve, basename, extname, isAbsolute} from 'pathe'\nimport {findUp as internalFindUp, Match as FindUpMatch} from 'find-up'\nimport {fileURLToPath} from 'url'\n\nexport {join, relative, dirname, normalize, resolve, basename, extname, isAbsolute}\n\nexport {default as glob} from 'fast-glob'\nexport {pathToFileURL} from 'node:url'\n\ntype FindUpMatcher = (directory: string) => FindUpMatch | Promise<FindUpMatch>\n\nexport async function findUp(\n matcher: string | ReadonlyArray<string> | FindUpMatcher,\n options: Parameters<typeof internalFindUp>[1],\n): ReturnType<typeof internalFindUp> {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const got = await internalFindUp(matcher, options)\n return got ? normalize(got) : undefined\n}\n\n/**\n * Given an absolute filesystem path, it makes it relative to\n * the current working directory. This is useful when logging paths\n * to allow the users to click on the file and let the OS open it\n * in the editor of choice.\n * @param path {string} Path to relativize\n * @returns {string} Relativized path.\n */\nexport function relativize(path: string): string {\n const result = commondir([path, process.cwd()])\n const relativePath = relative(process.cwd(), path)\n const relativeComponents = relativePath.split('/').filter((component) => component === '..').length\n if (result === '/' || relativePath === '' || relativeComponents > 2) {\n return path\n } else {\n return relativePath\n }\n}\n\n/**\n * Given a module's import.meta.url it returns the directory containing the module.\n * @param moduleURL {string} The value of import.meta.url in the context of the caller module.\n * @returns {string} The path to the directory containing the caller module.\n */\nexport function moduleDirectory(moduleURL: string | URL): string {\n return dirname(fileURLToPath(moduleURL))\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { Plugin } from '@oclif/core/lib/interfaces';
2
+ interface TunnelPlugin {
3
+ start: (options: TunnelStartOptions) => Promise<string>;
4
+ }
5
+ interface TunnelStartOptions {
6
+ port: number;
7
+ }
8
+ export declare function lookupTunnelPlugin(plugins: Plugin[]): Promise<TunnelPlugin | undefined>;
9
+ export {};