@shopify/cli-kit 3.0.23 → 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 (287) hide show
  1. package/CHANGELOG.md +28 -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 -2115
  159. package/dist/index.js +38 -46
  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/node/archiver.d.ts +6 -0
  168. package/dist/node/archiver.js +24 -0
  169. package/dist/node/archiver.js.map +1 -0
  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 +32 -21
  283. package/dist/index-160b2bd2.js +0 -175294
  284. package/dist/index-160b2bd2.js.map +0 -1
  285. package/dist/index.d.ts.map +0 -1
  286. package/dist/multipart-parser-7ce1f707.js +0 -477
  287. package/dist/multipart-parser-7ce1f707.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ import enquirer from 'enquirer';
2
+ export declare class Select extends enquirer.Select {
3
+ constructor(options: any);
4
+ pointer(_choice: unknown, i: number): any;
5
+ prefix(_state: unknown): any;
6
+ }
@@ -0,0 +1,30 @@
1
+ // Enquirer types are totally broken so we need to disable typescript checks for this file
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
+ // @ts-nocheck
4
+ import { colors } from '../colors.js';
5
+ import enquirer from 'enquirer';
6
+ export class Select extends enquirer.Select {
7
+ constructor(options) {
8
+ const originalResult = options.result;
9
+ options.result = (value) => {
10
+ const answer = this.focused.value || this.focused.name || value;
11
+ if (originalResult) {
12
+ return originalResult(answer);
13
+ }
14
+ return answer;
15
+ };
16
+ super(options);
17
+ this.styles.primary = colors.magenta;
18
+ this.styles.em = colors.magenta;
19
+ }
20
+ pointer(_choice, i) {
21
+ const color = this.styles.primary;
22
+ const showPointer = !this.state.multiple && this.state.index === i;
23
+ return showPointer ? color('>') : ' ';
24
+ }
25
+ prefix(_state) {
26
+ const color = this.styles.primary.bold;
27
+ return this.state.status === 'submitted' ? color('✔') : color('?');
28
+ }
29
+ }
30
+ //# sourceMappingURL=select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/ui/select.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,6DAA6D;AAC7D,cAAc;AACd,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AACnC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,MAAM,OAAO,MAAO,SAAQ,QAAQ,CAAC,MAAM;IACzC,YAAY,OAAO;QACjB,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAA;QACrC,OAAO,CAAC,MAAM,GAAG,CAAC,KAAK,EAAE,EAAE;YACzB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,KAAK,CAAA;YAE/D,IAAI,cAAc,EAAE;gBAClB,OAAO,cAAc,CAAC,MAAM,CAAC,CAAA;aAC9B;YAED,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;QACD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QACpC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,CAAA;IACjC,CAAC;IAED,OAAO,CAAC,OAAgB,EAAE,CAAS;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAA;QACjC,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,CAAA;QAClE,OAAO,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACvC,CAAC;IAED,MAAM,CAAC,MAAe;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAA;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACpE,CAAC;CACF","sourcesContent":["// Enquirer types are totally broken so we need to disable typescript checks for this file\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck\nimport {colors} from '../colors.js'\nimport enquirer from 'enquirer'\n\nexport class Select extends enquirer.Select {\n constructor(options) {\n const originalResult = options.result\n options.result = (value) => {\n const answer = this.focused.value || this.focused.name || value\n\n if (originalResult) {\n return originalResult(answer)\n }\n\n return answer\n }\n super(options)\n this.styles.primary = colors.magenta\n this.styles.em = colors.magenta\n }\n\n pointer(_choice: unknown, i: number) {\n const color = this.styles.primary\n const showPointer = !this.state.multiple && this.state.index === i\n return showPointer ? color('>') : ' '\n }\n\n prefix(_state: unknown) {\n const color = this.styles.primary.bold\n return this.state.status === 'submitted' ? color('✔') : color('?')\n }\n}\n"]}
package/dist/ui.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ import { Listr as OriginalListr, ListrTask } from 'listr2';
2
+ export declare function newListr(tasks: ListrTask[], options?: object): OriginalListr<any, any, "verbose">;
3
+ export declare type ListrTasks = ConstructorParameters<typeof OriginalListr>[0];
4
+ export type { ListrTaskWrapper, ListrDefaultRenderer, ListrTask } from 'listr2';
5
+ interface BaseQuestion<TName extends string> {
6
+ name: TName;
7
+ message: string;
8
+ preface?: string;
9
+ validate?: (value: string) => string | true;
10
+ default?: string;
11
+ result?: (value: string) => string | boolean;
12
+ }
13
+ export declare type InputQuestion<TName extends string> = BaseQuestion<TName> & {
14
+ type: 'input';
15
+ };
16
+ export declare type SelectQuestion<TName extends string> = BaseQuestion<TName> & {
17
+ type: 'select';
18
+ choices: string[] | {
19
+ name: string;
20
+ value: string;
21
+ }[];
22
+ };
23
+ export declare type AutocompleteQuestion<TName extends string> = BaseQuestion<TName> & {
24
+ type: 'autocomplete';
25
+ choices: string[] | {
26
+ name: string;
27
+ value: string;
28
+ }[];
29
+ };
30
+ export declare type PasswordQuestion<TName extends string> = BaseQuestion<TName> & {
31
+ type: 'password';
32
+ };
33
+ export declare type Question<TName extends string = string> = InputQuestion<TName> | SelectQuestion<TName> | AutocompleteQuestion<TName> | PasswordQuestion<TName>;
34
+ export declare const prompt: <TName extends string & keyof TAnswers, TAnswers extends { [key in TName]: string; } = { [key_1 in TName]: string; }>(questions: readonly Question<TName>[], debugForceInquirer?: boolean) => Promise<TAnswers>;
35
+ export declare function nonEmptyDirectoryPrompt(directory: string): Promise<void>;
36
+ export declare const keypress: () => Promise<void>;
package/dist/ui.js ADDED
@@ -0,0 +1,124 @@
1
+ import { AutoComplete } from './ui/autocomplete.js';
2
+ import { Input } from './ui/input.js';
3
+ import { Select } from './ui/select.js';
4
+ import { Bug, AbortSilent } from './error.js';
5
+ import { remove, exists } from './file.js';
6
+ import { info, content, token, logToFile } from './output.js';
7
+ import { relative } from './path.js';
8
+ import { isTerminalInteractive } from './environment/local.js';
9
+ import { isTruthy } from './environment/utilities.js';
10
+ import inquirer from 'inquirer';
11
+ import { Listr as OriginalListr, ListrTaskState } from 'listr2';
12
+ export function newListr(tasks, options) {
13
+ const listr = new OriginalListr(tasks, options);
14
+ listr.tasks.forEach((task) => {
15
+ const loggedSubtaskTitles = [];
16
+ task.subscribe((event) => {
17
+ if (event.type === 'TITLE' && typeof event.data === 'string') {
18
+ logToFile(event.data, 'INFO');
19
+ }
20
+ });
21
+ task.renderHook$.subscribe(() => {
22
+ if (task.hasSubtasks()) {
23
+ const activeSubtasks = task.subtasks.filter((subtask) => {
24
+ return [ListrTaskState.PENDING, ListrTaskState.COMPLETED].includes(subtask.state);
25
+ });
26
+ activeSubtasks.forEach((subtask) => {
27
+ if (subtask.title && !loggedSubtaskTitles.includes(subtask.title)) {
28
+ loggedSubtaskTitles.push(subtask.title);
29
+ logToFile(subtask.title, 'INFO');
30
+ }
31
+ });
32
+ }
33
+ });
34
+ });
35
+ return listr;
36
+ }
37
+ export const prompt = async (questions, debugForceInquirer = false) => {
38
+ if (!isTerminalInteractive() && questions.length !== 0) {
39
+ throw new Bug(content `
40
+ The CLI prompted in a non-interactive terminal with the following questions:
41
+ ${token.json(questions)}
42
+ `);
43
+ }
44
+ if (debugForceInquirer || isTruthy(process.env.SHOPIFY_USE_INQUIRER)) {
45
+ const results = [];
46
+ for (const question of questions) {
47
+ if (question.preface) {
48
+ info(question.preface);
49
+ }
50
+ const questionName = question.name;
51
+ // eslint-disable-next-line no-await-in-loop
52
+ const answer = (await inquirer.prompt([convertQuestionForInquirer(question)]))[questionName];
53
+ results.push([questionName, answer]);
54
+ }
55
+ return Object.fromEntries(results);
56
+ }
57
+ else {
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ const mappedQuestions = questions.map(mapper);
60
+ const value = {};
61
+ for (const question of mappedQuestions) {
62
+ if (question.preface) {
63
+ info(question.preface);
64
+ }
65
+ // eslint-disable-next-line no-await-in-loop
66
+ value[question.name] = await question.run();
67
+ }
68
+ return value;
69
+ }
70
+ };
71
+ export async function nonEmptyDirectoryPrompt(directory) {
72
+ if (await exists(directory)) {
73
+ const options = [
74
+ { name: 'No, don’t delete the files', value: 'abort' },
75
+ { name: 'Yes, delete the files', value: 'overwrite' },
76
+ ];
77
+ const relativeDirectory = relative(process.cwd(), directory);
78
+ const questions = {
79
+ type: 'select',
80
+ name: 'value',
81
+ message: `${relativeDirectory} is not an empty directory. Do you want to delete the existing files and continue?`,
82
+ choices: options,
83
+ };
84
+ const choice = await prompt([questions]);
85
+ if (choice.value === 'abort') {
86
+ throw new AbortSilent();
87
+ }
88
+ remove(directory);
89
+ }
90
+ }
91
+ export const keypress = async () => {
92
+ process.stdin.setRawMode(true);
93
+ return new Promise((resolve) => process.stdin.once('data', () => {
94
+ process.stdin.setRawMode(false);
95
+ resolve();
96
+ }));
97
+ };
98
+ function convertQuestionForInquirer(question) {
99
+ switch (question.type) {
100
+ case 'input':
101
+ case 'password':
102
+ return question;
103
+ case 'select':
104
+ case 'autocomplete':
105
+ return {
106
+ ...question,
107
+ type: 'list',
108
+ };
109
+ }
110
+ }
111
+ function mapper(question) {
112
+ switch (question.type) {
113
+ case 'input':
114
+ case 'password':
115
+ return new Input(question);
116
+ case 'select':
117
+ return new Select(question);
118
+ case 'autocomplete':
119
+ return new AutoComplete(question);
120
+ default:
121
+ return undefined;
122
+ }
123
+ }
124
+ //# sourceMappingURL=ui.js.map
package/dist/ui.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAA;AACnC,OAAO,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAA;AACrC,OAAO,EAAC,GAAG,EAAE,WAAW,EAAC,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAC,MAAM,EAAE,MAAM,EAAC,MAAM,WAAW,CAAA;AACxC,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,aAAa,CAAA;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAClC,OAAO,EAAC,qBAAqB,EAAC,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAA;AACnD,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,KAAK,IAAI,aAAa,EAAyB,cAAc,EAAC,MAAM,QAAQ,CAAA;AAEpF,MAAM,UAAU,QAAQ,CAAC,KAAkB,EAAE,OAAgB;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B,OAAO;gBACL,GAAG,QAAQ;gBACX,IAAI,EAAE,MAAM;aACb,CAAA;KACJ;AACH,CAAC;AAED,SAAS,MAAM,CAAC,QAAkB;IAChC,QAAQ,QAAQ,CAAC,IAAI,EAAE;QACrB,KAAK,OAAO,CAAC;QACb,KAAK,UAAU;YACb,OAAO,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAA;QAC5B,KAAK,QAAQ;YACX,OAAO,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC7B,KAAK,cAAc;YACjB,OAAO,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAA;QACnC;YACE,OAAO,SAAS,CAAA;KACnB;AACH,CAAC","sourcesContent":["import {AutoComplete} from './ui/autocomplete.js'\nimport {Input} from './ui/input.js'\nimport {Select} from './ui/select.js'\nimport {Bug, AbortSilent} from './error.js'\nimport {remove, exists} from './file.js'\nimport {info, content, token, logToFile} from './output.js'\nimport {relative} from './path.js'\nimport {isTerminalInteractive} from './environment/local.js'\nimport {isTruthy} from './environment/utilities.js'\nimport inquirer from 'inquirer'\nimport {Listr as OriginalListr, ListrTask, ListrEvent, ListrTaskState} from 'listr2'\n\nexport function newListr(tasks: ListrTask[], options?: object) {\n const listr = new OriginalListr(tasks, options)\n listr.tasks.forEach((task) => {\n const loggedSubtaskTitles: string[] = []\n task.subscribe((event: ListrEvent) => {\n if (event.type === 'TITLE' && typeof event.data === 'string') {\n logToFile(event.data, 'INFO')\n }\n })\n task.renderHook$.subscribe(() => {\n if (task.hasSubtasks()) {\n const activeSubtasks = task.subtasks.filter((subtask) => {\n return [ListrTaskState.PENDING, ListrTaskState.COMPLETED].includes(subtask.state as ListrTaskState)\n })\n activeSubtasks.forEach((subtask) => {\n if (subtask.title && !loggedSubtaskTitles.includes(subtask.title)) {\n loggedSubtaskTitles.push(subtask.title)\n logToFile(subtask.title, 'INFO')\n }\n })\n }\n })\n })\n return listr\n}\n\nexport type ListrTasks = ConstructorParameters<typeof OriginalListr>[0]\nexport type {ListrTaskWrapper, ListrDefaultRenderer, ListrTask} from 'listr2'\n\ninterface BaseQuestion<TName extends string> {\n name: TName\n message: string\n preface?: string\n validate?: (value: string) => string | true\n default?: string\n result?: (value: string) => string | boolean\n}\n\nexport type InputQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'input'\n}\n\nexport type SelectQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'select'\n choices: string[] | {name: string; value: string}[]\n}\n\nexport type AutocompleteQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'autocomplete'\n choices: string[] | {name: string; value: string}[]\n}\n\nexport type PasswordQuestion<TName extends string> = BaseQuestion<TName> & {\n type: 'password'\n}\n\nexport type Question<TName extends string = string> =\n | InputQuestion<TName>\n | SelectQuestion<TName>\n | AutocompleteQuestion<TName>\n | PasswordQuestion<TName>\n\nexport const prompt = async <\n TName extends string & keyof TAnswers,\n TAnswers extends {[key in TName]: string} = {[key in TName]: string},\n>(\n questions: ReadonlyArray<Question<TName>>,\n debugForceInquirer = false,\n): Promise<TAnswers> => {\n if (!isTerminalInteractive() && questions.length !== 0) {\n throw new Bug(content`\nThe CLI prompted in a non-interactive terminal with the following questions:\n${token.json(questions)}\n `)\n }\n\n if (debugForceInquirer || isTruthy(process.env.SHOPIFY_USE_INQUIRER)) {\n const results = []\n for (const question of questions) {\n if (question.preface) {\n info(question.preface)\n }\n\n const questionName = question.name\n // eslint-disable-next-line no-await-in-loop\n const answer = (await inquirer.prompt([convertQuestionForInquirer(question)]))[questionName]\n results.push([questionName, answer])\n }\n\n return Object.fromEntries(results) as TAnswers\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const mappedQuestions: any[] = questions.map(mapper)\n const value = {} as TAnswers\n for (const question of mappedQuestions) {\n if (question.preface) {\n info(question.preface)\n }\n // eslint-disable-next-line no-await-in-loop\n value[question.name as keyof TAnswers] = await question.run()\n }\n return value\n }\n}\n\nexport async function nonEmptyDirectoryPrompt(directory: string) {\n if (await exists(directory)) {\n const options = [\n {name: 'No, don’t delete the files', value: 'abort'},\n {name: 'Yes, delete the files', value: 'overwrite'},\n ]\n\n const relativeDirectory = relative(process.cwd(), directory)\n\n const questions: Question<'value'> = {\n type: 'select',\n name: 'value',\n message: `${relativeDirectory} is not an empty directory. Do you want to delete the existing files and continue?`,\n choices: options,\n }\n\n const choice = await prompt([questions])\n\n if (choice.value === 'abort') {\n throw new AbortSilent()\n }\n\n remove(directory)\n }\n}\n\nexport const keypress = async () => {\n process.stdin.setRawMode(true)\n return new Promise<void>((resolve) =>\n process.stdin.once('data', () => {\n process.stdin.setRawMode(false)\n resolve()\n }),\n )\n}\n\nfunction convertQuestionForInquirer<\n TName extends string & keyof TAnswers,\n TAnswers extends {[key in TName]: string} = {[key in TName]: string},\n>(question: Question<TName>): inquirer.DistinctQuestion<TAnswers> {\n switch (question.type) {\n case 'input':\n case 'password':\n return question\n case 'select':\n case 'autocomplete':\n return {\n ...question,\n type: 'list',\n }\n }\n}\n\nfunction mapper(question: Question): unknown {\n switch (question.type) {\n case 'input':\n case 'password':\n return new Input(question)\n case 'select':\n return new Select(question)\n case 'autocomplete':\n return new AutoComplete(question)\n default:\n return undefined\n }\n}\n"]}
@@ -0,0 +1,19 @@
1
+ import { Bug } from './error.js';
2
+ export declare const PackageJsonVersionNotFoundError: (packageJsonPath: string) => Bug;
3
+ /**
4
+ * Returns the latest available version of an NPM package.
5
+ * @param name {string} The name of the NPM package.
6
+ * @returns A promise to get the latest available version of a package.
7
+ */
8
+ export declare function latestNpmPackageVersion(name: string): Promise<string>;
9
+ interface FindPackageVersionUpOptions {
10
+ fromModuleURL: URL | string;
11
+ }
12
+ /**
13
+ * Given a module URL, it traverses the directory hierarchy up until it finds a package.json
14
+ * and then it returns the version in it.
15
+ * @param options {FindPackageVersionUpOptions} Options
16
+ * @returns {Promise<string>} The version if it can find the package.json and it exists. An error otherwise.
17
+ */
18
+ export declare function findPackageVersionUp(options: FindPackageVersionUpOptions): Promise<string>;
19
+ export {};
@@ -0,0 +1,34 @@
1
+ import { content, token, debug } from './output.js';
2
+ import { moduleDirectory } from './path.js';
3
+ import { Bug } from './error.js';
4
+ import { findUpAndReadPackageJson } from './dependency.js';
5
+ import latestVersion from 'latest-version';
6
+ export const PackageJsonVersionNotFoundError = (packageJsonPath) => {
7
+ return new Bug(content `The package.json at path ${token.path(packageJsonPath)} doesn't contain a version`);
8
+ };
9
+ /**
10
+ * Returns the latest available version of an NPM package.
11
+ * @param name {string} The name of the NPM package.
12
+ * @returns A promise to get the latest available version of a package.
13
+ */
14
+ export async function latestNpmPackageVersion(name) {
15
+ debug(content `Getting the latest version of NPM package: ${token.raw(name)}`);
16
+ return latestVersion(name);
17
+ }
18
+ /**
19
+ * Given a module URL, it traverses the directory hierarchy up until it finds a package.json
20
+ * and then it returns the version in it.
21
+ * @param options {FindPackageVersionUpOptions} Options
22
+ * @returns {Promise<string>} The version if it can find the package.json and it exists. An error otherwise.
23
+ */
24
+ export async function findPackageVersionUp(options) {
25
+ const fromDirectory = moduleDirectory(options.fromModuleURL);
26
+ const packageJson = await findUpAndReadPackageJson(fromDirectory);
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ const version = packageJson.content.version;
29
+ if (!version) {
30
+ throw PackageJsonVersionNotFoundError(packageJson.path);
31
+ }
32
+ return version;
33
+ }
34
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,WAAW,CAAA;AACzC,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAC,wBAAwB,EAAC,MAAM,iBAAiB,CAAA;AACxD,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAE1C,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,eAAuB,EAAE,EAAE;IACzE,OAAO,IAAI,GAAG,CAAC,OAAO,CAAA,4BAA4B,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,4BAA4B,CAAC,CAAA;AAC5G,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,IAAY;IACxD,KAAK,CAAC,OAAO,CAAA,8CAA8C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC7E,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AAMD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAoC;IAC7E,MAAM,aAAa,GAAG,eAAe,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IAC5D,MAAM,WAAW,GAAG,MAAM,wBAAwB,CAAC,aAAa,CAAC,CAAA;IACjE,8DAA8D;IAC9D,MAAM,OAAO,GAAI,WAAW,CAAC,OAAe,CAAC,OAAO,CAAA;IACpD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,+BAA+B,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;KACxD;IACD,OAAO,OAAO,CAAA;AAChB,CAAC","sourcesContent":["import {content, token, debug} from './output.js'\nimport {moduleDirectory} from './path.js'\nimport {Bug} from './error.js'\nimport {findUpAndReadPackageJson} from './dependency.js'\nimport latestVersion from 'latest-version'\n\nexport const PackageJsonVersionNotFoundError = (packageJsonPath: string) => {\n return new Bug(content`The package.json at path ${token.path(packageJsonPath)} doesn't contain a version`)\n}\n\n/**\n * Returns the latest available version of an NPM package.\n * @param name {string} The name of the NPM package.\n * @returns A promise to get the latest available version of a package.\n */\nexport async function latestNpmPackageVersion(name: string) {\n debug(content`Getting the latest version of NPM package: ${token.raw(name)}`)\n return latestVersion(name)\n}\n\ninterface FindPackageVersionUpOptions {\n fromModuleURL: URL | string\n}\n\n/**\n * Given a module URL, it traverses the directory hierarchy up until it finds a package.json\n * and then it returns the version in it.\n * @param options {FindPackageVersionUpOptions} Options\n * @returns {Promise<string>} The version if it can find the package.json and it exists. An error otherwise.\n */\nexport async function findPackageVersionUp(options: FindPackageVersionUpOptions): Promise<string> {\n const fromDirectory = moduleDirectory(options.fromModuleURL)\n const packageJson = await findUpAndReadPackageJson(fromDirectory)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const version = (packageJson.content as any).version\n if (!version) {\n throw PackageJsonVersionNotFoundError(packageJson.path)\n }\n return version\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Check if user editor is VS Code
3
+ */
4
+ export declare const isVSCode: (root?: string) => Promise<boolean>;
5
+ /**
6
+ * Add VSCode extension recommendations
7
+ */
8
+ export declare function addRecommendedExtensions(directory: string, recommendations: string[]): Promise<void>;
package/dist/vscode.js ADDED
@@ -0,0 +1,36 @@
1
+ import { exists, write, read } from './file.js';
2
+ import { findUp, join } from './path.js';
3
+ import { content, token, debug } from './output.js';
4
+ /**
5
+ * Check if user editor is VS Code
6
+ */
7
+ export const isVSCode = async (root = process.cwd()) => {
8
+ debug(content `Checking if the directory ${token.path(root)} or any of its parents has a .vscode directory... `);
9
+ const config = await findUp(join(root, '.vscode'), { type: 'directory' });
10
+ if (!config) {
11
+ return false;
12
+ }
13
+ return exists(config);
14
+ };
15
+ /**
16
+ * Add VSCode extension recommendations
17
+ */
18
+ export async function addRecommendedExtensions(directory, recommendations) {
19
+ debug(content `Adding VSCode recommended extensions at ${token.path(directory)}:
20
+ ${token.json(recommendations)}
21
+ `);
22
+ const extensionsPath = join(directory, '.vscode/extensions.json');
23
+ if (await isVSCode(directory)) {
24
+ let originalExtensionsJson = { recommendations: [] };
25
+ if (await exists(extensionsPath)) {
26
+ const originalExtensionsFile = await read(extensionsPath);
27
+ originalExtensionsJson = JSON.parse(originalExtensionsFile);
28
+ }
29
+ const newExtensionsJson = {
30
+ ...originalExtensionsJson,
31
+ recommendations: [...originalExtensionsJson.recommendations, ...recommendations],
32
+ };
33
+ await write(extensionsPath, JSON.stringify(newExtensionsJson, null, 2));
34
+ }
35
+ }
36
+ //# sourceMappingURL=vscode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vscode.js","sourceRoot":"","sources":["../src/vscode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AACtC,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE;IACrD,KAAK,CAAC,OAAO,CAAA,6BAA6B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;IAC/G,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAC,IAAI,EAAE,WAAW,EAAC,CAAC,CAAA;IAEvE,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,KAAK,CAAA;KACb;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,CAAA;AACvB,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,SAAiB,EAAE,eAAyB;IACzF,KAAK,CAAC,OAAO,CAAA,2CAA2C,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;EAC7E,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC;GAC1B,CAAC,CAAA;IACF,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,yBAAyB,CAAC,CAAA;IAEjE,IAAI,MAAM,QAAQ,CAAC,SAAS,CAAC,EAAE;QAC7B,IAAI,sBAAsB,GAAG,EAAC,eAAe,EAAE,EAAE,EAAC,CAAA;QAClD,IAAI,MAAM,MAAM,CAAC,cAAc,CAAC,EAAE;YAChC,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,CAAA;YACzD,sBAAsB,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;SAC5D;QACD,MAAM,iBAAiB,GAAG;YACxB,GAAG,sBAAsB;YACzB,eAAe,EAAE,CAAC,GAAG,sBAAsB,CAAC,eAAe,EAAE,GAAG,eAAe,CAAC;SACjF,CAAA;QACD,MAAM,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;KACxE;AACH,CAAC","sourcesContent":["import {exists, write, read} from './file.js'\nimport {findUp, join} from './path.js'\nimport {content, token, debug} from './output.js'\n\n/**\n * Check if user editor is VS Code\n */\nexport const isVSCode = async (root = process.cwd()) => {\n debug(content`Checking if the directory ${token.path(root)} or any of its parents has a .vscode directory... `)\n const config = await findUp(join(root, '.vscode'), {type: 'directory'})\n\n if (!config) {\n return false\n }\n\n return exists(config)\n}\n\n/**\n * Add VSCode extension recommendations\n */\nexport async function addRecommendedExtensions(directory: string, recommendations: string[]) {\n debug(content`Adding VSCode recommended extensions at ${token.path(directory)}:\n${token.json(recommendations)}\n `)\n const extensionsPath = join(directory, '.vscode/extensions.json')\n\n if (await isVSCode(directory)) {\n let originalExtensionsJson = {recommendations: []}\n if (await exists(extensionsPath)) {\n const originalExtensionsFile = await read(extensionsPath)\n originalExtensionsJson = JSON.parse(originalExtensionsFile)\n }\n const newExtensionsJson = {\n ...originalExtensionsJson,\n recommendations: [...originalExtensionsJson.recommendations, ...recommendations],\n }\n await write(extensionsPath, JSON.stringify(newExtensionsJson, null, 2))\n }\n}\n"]}
package/dist/yaml.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function decode(input: string): unknown;
2
+ export declare function encode(content: unknown): string;
package/dist/yaml.js ADDED
@@ -0,0 +1,8 @@
1
+ import * as yaml from 'js-yaml';
2
+ export function decode(input) {
3
+ return yaml.load(input);
4
+ }
5
+ export function encode(content) {
6
+ return yaml.dump(content);
7
+ }
8
+ //# sourceMappingURL=yaml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml.js","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA;AAE/B,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACzB,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAgB;IACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC3B,CAAC","sourcesContent":["import * as yaml from 'js-yaml'\n\nexport function decode(input: string): unknown {\n return yaml.load(input)\n}\n\nexport function encode(content: unknown): string {\n return yaml.dump(content)\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopify/cli-kit",
3
- "version": "3.0.23",
3
+ "version": "3.0.26",
4
4
  "private": false,
5
5
  "description": "A set of utilities, interfaces, and models that are common across all the platform features",
6
6
  "keywords": [
@@ -16,6 +16,14 @@
16
16
  ".": {
17
17
  "import": "./dist/index.js",
18
18
  "types": "./dist/index.d.ts"
19
+ },
20
+ "./node/*": {
21
+ "node": "./dist/node/*.js",
22
+ "types": "./dist/node/*.d.ts"
23
+ },
24
+ "./testing/*": {
25
+ "node": "./dist/testing/*.js",
26
+ "types": "./dist/testing/*.d.ts"
19
27
  }
20
28
  },
21
29
  "files": [
@@ -28,9 +36,9 @@
28
36
  },
29
37
  "scripts": {
30
38
  "clean": "shx rm -rf dist",
31
- "build": "rimraf dist/ && rollup -c",
39
+ "build": "rimraf dist/ && tsc -b ./tsconfig.build.json",
32
40
  "prepack": "cross-env NODE_ENV=production yarn run build",
33
- "lint": "prettier -c src/** && eslint 'src/**/*.ts'",
41
+ "lint": "prettier -c src/** && eslint \"src/**/*.ts\"",
34
42
  "lint:fix": "eslint 'src/**/*.ts' --fix",
35
43
  "test": "vitest run",
36
44
  "test:watch": "vitest watch",
@@ -59,16 +67,14 @@
59
67
  "open": "^8.4.0",
60
68
  "prettier": "^2.6.2",
61
69
  "source-map-support": "^0.5.21",
62
- "stacktracey": "^2.1.8"
63
- },
64
- "devDependencies": {
65
- "@iarna/toml": "^2.2.5",
66
- "@types/cross-zip": "^4.0.0",
67
- "@types/inquirer": "^8.2.1",
68
- "@types/js-yaml": "^4.0.5",
69
- "@types/semver": "^7.3.9",
70
+ "stacktracey": "^2.1.8",
71
+ "pathe": "0.2.0",
70
72
  "abort-controller": "^3.0.0",
71
- "ansi-colors": "^4.1.1",
73
+ "ts-error": "^1.0.6",
74
+ "find-up": "^6.2.0",
75
+ "execa": "^6.0.0",
76
+ "listr2": "^4.0.5",
77
+ "@iarna/toml": "^2.2.5",
72
78
  "change-case": "^4.1.2",
73
79
  "color-json": "^2.0.1",
74
80
  "commondir": "^1.0.1",
@@ -77,9 +83,7 @@
77
83
  "del": "^6.0.0",
78
84
  "enquirer": "^2.3.6",
79
85
  "env-paths": "^3.0.0",
80
- "execa": "^6.0.0",
81
86
  "fast-glob": "^3.2.11",
82
- "find-up": "^6.2.0",
83
87
  "find-versions": "^5.0.0",
84
88
  "form-data": "^4.0.0",
85
89
  "fs-extra": "^10.0.0",
@@ -91,17 +95,24 @@
91
95
  "js-yaml": "^4.1.0",
92
96
  "latest-version": "^6.0.0",
93
97
  "liquidjs": "^9.36.0",
94
- "listr2": "^4.0.5",
95
98
  "md5-file": "^5.0.0",
96
99
  "node-fetch": "^3.2.4",
97
- "pathe": "^0.2.0",
98
- "semver": "^7.3.6",
99
100
  "simple-git": "^3.5.0",
100
- "tempy": "^2.0.0",
101
+ "tempy": "^3.0.0",
101
102
  "term-size": "^3.0.1",
102
103
  "terminal-link": "^3.0.0",
103
- "ts-error": "^1.0.6",
104
- "vitest": "^0.15.1",
105
- "zod": "^3.17.3"
104
+ "zod": "^3.17.3",
105
+ "semver": "^7.3.6",
106
+ "ansi-colors": "^4.1.1",
107
+ "unique-string": "^3.0.0",
108
+ "strip-ansi": "^7.0.1",
109
+ "@bugsnag/js": "^7.16.7"
110
+ },
111
+ "devDependencies": {
112
+ "@types/cross-zip": "^4.0.0",
113
+ "@types/inquirer": "^8.2.1",
114
+ "@types/js-yaml": "^4.0.5",
115
+ "@types/semver": "^7.3.9",
116
+ "vitest": "^0.15.1"
106
117
  }
107
118
  }