@shopify/cli-kit 0.0.0-nightly-20230110194301

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 (488) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +63 -0
  3. package/assets/auth-error.html +23 -0
  4. package/assets/empty-url.html +23 -0
  5. package/assets/favicon.svg +26 -0
  6. package/assets/missing-code.html +23 -0
  7. package/assets/missing-state.html +23 -0
  8. package/assets/style.css +58 -0
  9. package/assets/success.html +20 -0
  10. package/dist/api/admin.d.ts +3 -0
  11. package/dist/api/admin.js +56 -0
  12. package/dist/api/admin.js.map +1 -0
  13. package/dist/api/common.d.ts +21 -0
  14. package/dist/api/common.js +87 -0
  15. package/dist/api/common.js.map +1 -0
  16. package/dist/api/graphql/all_app_extension_registrations.d.ts +20 -0
  17. package/dist/api/graphql/all_app_extension_registrations.js +20 -0
  18. package/dist/api/graphql/all_app_extension_registrations.js.map +1 -0
  19. package/dist/api/graphql/all_dev_stores_by_org.d.ts +18 -0
  20. package/dist/api/graphql/all_dev_stores_by_org.js +21 -0
  21. package/dist/api/graphql/all_dev_stores_by_org.js.map +1 -0
  22. package/dist/api/graphql/all_orgs.d.ts +12 -0
  23. package/dist/api/graphql/all_orgs.js +14 -0
  24. package/dist/api/graphql/all_orgs.js.map +1 -0
  25. package/dist/api/graphql/convert_dev_to_test_store.d.ts +16 -0
  26. package/dist/api/graphql/convert_dev_to_test_store.js +13 -0
  27. package/dist/api/graphql/convert_dev_to_test_store.js.map +1 -0
  28. package/dist/api/graphql/create_app.d.ts +29 -0
  29. package/dist/api/graphql/create_app.js +33 -0
  30. package/dist/api/graphql/create_app.js.map +1 -0
  31. package/dist/api/graphql/create_deployment.d.ts +33 -0
  32. package/dist/api/graphql/create_deployment.js +25 -0
  33. package/dist/api/graphql/create_deployment.js.map +1 -0
  34. package/dist/api/graphql/extension_create.d.ts +30 -0
  35. package/dist/api/graphql/extension_create.js +26 -0
  36. package/dist/api/graphql/extension_create.js.map +1 -0
  37. package/dist/api/graphql/extension_specifications.d.ts +27 -0
  38. package/dist/api/graphql/extension_specifications.js +22 -0
  39. package/dist/api/graphql/extension_specifications.js.map +1 -0
  40. package/dist/api/graphql/find_app.d.ts +14 -0
  41. package/dist/api/graphql/find_app.js +17 -0
  42. package/dist/api/graphql/find_app.js.map +1 -0
  43. package/dist/api/graphql/find_org.d.ts +18 -0
  44. package/dist/api/graphql/find_org.js +21 -0
  45. package/dist/api/graphql/find_org.js.map +1 -0
  46. package/dist/api/graphql/find_org_basic.d.ts +11 -0
  47. package/dist/api/graphql/find_org_basic.js +14 -0
  48. package/dist/api/graphql/find_org_basic.js.map +1 -0
  49. package/dist/api/graphql/find_store_by_domain.d.ts +21 -0
  50. package/dist/api/graphql/find_store_by_domain.js +24 -0
  51. package/dist/api/graphql/find_store_by_domain.js.map +1 -0
  52. package/dist/api/graphql/functions/api_schema_definition.d.ts +9 -0
  53. package/dist/api/graphql/functions/api_schema_definition.js +7 -0
  54. package/dist/api/graphql/functions/api_schema_definition.js.map +1 -0
  55. package/dist/api/graphql/functions/app_function_set.d.ts +30 -0
  56. package/dist/api/graphql/functions/app_function_set.js +38 -0
  57. package/dist/api/graphql/functions/app_function_set.js.map +1 -0
  58. package/dist/api/graphql/functions/function_service_proxy.d.ts +4 -0
  59. package/dist/api/graphql/functions/function_service_proxy.js +7 -0
  60. package/dist/api/graphql/functions/function_service_proxy.js.map +1 -0
  61. package/dist/api/graphql/functions/upload_url_generate.d.ts +12 -0
  62. package/dist/api/graphql/functions/upload_url_generate.js +11 -0
  63. package/dist/api/graphql/functions/upload_url_generate.js.map +1 -0
  64. package/dist/api/graphql/generate_signed_upload_url.d.ts +15 -0
  65. package/dist/api/graphql/generate_signed_upload_url.js +15 -0
  66. package/dist/api/graphql/generate_signed_upload_url.js.map +1 -0
  67. package/dist/api/graphql/get_urls.d.ts +10 -0
  68. package/dist/api/graphql/get_urls.js +10 -0
  69. package/dist/api/graphql/get_urls.js.map +1 -0
  70. package/dist/api/graphql/get_variant_id.d.ts +17 -0
  71. package/dist/api/graphql/get_variant_id.js +20 -0
  72. package/dist/api/graphql/get_variant_id.js.map +1 -0
  73. package/dist/api/graphql/index.d.ts +21 -0
  74. package/dist/api/graphql/index.js +22 -0
  75. package/dist/api/graphql/index.js.map +1 -0
  76. package/dist/api/graphql/update_draft.d.ts +33 -0
  77. package/dist/api/graphql/update_draft.js +24 -0
  78. package/dist/api/graphql/update_draft.js.map +1 -0
  79. package/dist/api/graphql/update_urls.d.ts +14 -0
  80. package/dist/api/graphql/update_urls.js +12 -0
  81. package/dist/api/graphql/update_urls.js.map +1 -0
  82. package/dist/api/identity.d.ts +1 -0
  83. package/dist/api/identity.js +41 -0
  84. package/dist/api/identity.js.map +1 -0
  85. package/dist/api/oxygen.d.ts +5 -0
  86. package/dist/api/oxygen.js +30 -0
  87. package/dist/api/oxygen.js.map +1 -0
  88. package/dist/api/partners.d.ts +14 -0
  89. package/dist/api/partners.js +44 -0
  90. package/dist/api/partners.js.map +1 -0
  91. package/dist/api.d.ts +6 -0
  92. package/dist/api.js +7 -0
  93. package/dist/api.js.map +1 -0
  94. package/dist/cli.d.ts +8 -0
  95. package/dist/cli.js +18 -0
  96. package/dist/cli.js.map +1 -0
  97. package/dist/constants.d.ts +52 -0
  98. package/dist/constants.js +71 -0
  99. package/dist/constants.js.map +1 -0
  100. package/dist/content-tokens.d.ts +44 -0
  101. package/dist/content-tokens.js +105 -0
  102. package/dist/content-tokens.js.map +1 -0
  103. package/dist/environment/fqdn.d.ts +29 -0
  104. package/dist/environment/fqdn.js +72 -0
  105. package/dist/environment/fqdn.js.map +1 -0
  106. package/dist/environment/local.d.ts +92 -0
  107. package/dist/environment/local.js +169 -0
  108. package/dist/environment/local.js.map +1 -0
  109. package/dist/environment/service.d.ts +4 -0
  110. package/dist/environment/service.js +19 -0
  111. package/dist/environment/service.js.map +1 -0
  112. package/dist/environment/spin-cache.d.ts +2 -0
  113. package/dist/environment/spin-cache.js +8 -0
  114. package/dist/environment/spin-cache.js.map +1 -0
  115. package/dist/environment/spin.d.ts +50 -0
  116. package/dist/environment/spin.js +99 -0
  117. package/dist/environment/spin.js.map +1 -0
  118. package/dist/environment/utilities.d.ts +8 -0
  119. package/dist/environment/utilities.js +19 -0
  120. package/dist/environment/utilities.js.map +1 -0
  121. package/dist/environment.d.ts +7 -0
  122. package/dist/environment.js +8 -0
  123. package/dist/environment.js.map +1 -0
  124. package/dist/error.d.ts +68 -0
  125. package/dist/error.js +143 -0
  126. package/dist/error.js.map +1 -0
  127. package/dist/file.d.ts +98 -0
  128. package/dist/file.js +216 -0
  129. package/dist/file.js.map +1 -0
  130. package/dist/git.d.ts +36 -0
  131. package/dist/git.js +133 -0
  132. package/dist/git.js.map +1 -0
  133. package/dist/http/fetch.d.ts +22 -0
  134. package/dist/http/fetch.js +44 -0
  135. package/dist/http/fetch.js.map +1 -0
  136. package/dist/http/formdata.d.ts +3 -0
  137. package/dist/http/formdata.js +6 -0
  138. package/dist/http/formdata.js.map +1 -0
  139. package/dist/http/graphql.d.ts +13 -0
  140. package/dist/http/graphql.js +12 -0
  141. package/dist/http/graphql.js.map +1 -0
  142. package/dist/http.d.ts +27 -0
  143. package/dist/http.js +32 -0
  144. package/dist/http.js.map +1 -0
  145. package/dist/index.d.ts +24 -0
  146. package/dist/index.js +25 -0
  147. package/dist/index.js.map +1 -0
  148. package/dist/metadata.d.ts +53 -0
  149. package/dist/metadata.js +62 -0
  150. package/dist/metadata.js.map +1 -0
  151. package/dist/monorail.d.ts +100 -0
  152. package/dist/monorail.js +39 -0
  153. package/dist/monorail.js.map +1 -0
  154. package/dist/network/api.d.ts +2 -0
  155. package/dist/network/api.js +2 -0
  156. package/dist/network/api.js.map +1 -0
  157. package/dist/network/service.d.ts +14 -0
  158. package/dist/network/service.js +11 -0
  159. package/dist/network/service.js.map +1 -0
  160. package/dist/npm.d.ts +27 -0
  161. package/dist/npm.js +20 -0
  162. package/dist/npm.js.map +1 -0
  163. package/dist/output.d.ts +129 -0
  164. package/dist/output.js +310 -0
  165. package/dist/output.js.map +1 -0
  166. package/dist/path.d.ts +25 -0
  167. package/dist/path.js +48 -0
  168. package/dist/path.js.map +1 -0
  169. package/dist/plugins.d.ts +73 -0
  170. package/dist/plugins.js +49 -0
  171. package/dist/plugins.js.map +1 -0
  172. package/dist/private/common/json.d.ts +6 -0
  173. package/dist/private/common/json.js +2 -0
  174. package/dist/private/common/json.js.map +1 -0
  175. package/dist/private/common/lodash.d.ts +47 -0
  176. package/dist/private/common/lodash.js +2 -0
  177. package/dist/private/common/lodash.js.map +1 -0
  178. package/dist/private/node/analytics.d.ts +27 -0
  179. package/dist/private/node/analytics.js +57 -0
  180. package/dist/private/node/analytics.js.map +1 -0
  181. package/dist/private/node/ui/alert.d.ts +2 -0
  182. package/dist/private/node/ui/alert.js +18 -0
  183. package/dist/private/node/ui/alert.js.map +1 -0
  184. package/dist/private/node/ui/components/Alert.d.ts +17 -0
  185. package/dist/private/node/ui/components/Alert.js +21 -0
  186. package/dist/private/node/ui/components/Alert.js.map +1 -0
  187. package/dist/private/node/ui/components/Alert.test.d.ts +1 -0
  188. package/dist/private/node/ui/components/Alert.test.js +95 -0
  189. package/dist/private/node/ui/components/Alert.test.js.map +1 -0
  190. package/dist/private/node/ui/components/Banner.d.ts +8 -0
  191. package/dist/private/node/ui/components/Banner.js +41 -0
  192. package/dist/private/node/ui/components/Banner.js.map +1 -0
  193. package/dist/private/node/ui/components/Banner.test.d.ts +1 -0
  194. package/dist/private/node/ui/components/Banner.test.js +52 -0
  195. package/dist/private/node/ui/components/Banner.test.js.map +1 -0
  196. package/dist/private/node/ui/components/Command.d.ts +9 -0
  197. package/dist/private/node/ui/components/Command.js +13 -0
  198. package/dist/private/node/ui/components/Command.js.map +1 -0
  199. package/dist/private/node/ui/components/Command.test.d.ts +1 -0
  200. package/dist/private/node/ui/components/Command.test.js +11 -0
  201. package/dist/private/node/ui/components/Command.test.js.map +1 -0
  202. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +47 -0
  203. package/dist/private/node/ui/components/ConcurrentOutput.js +86 -0
  204. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -0
  205. package/dist/private/node/ui/components/ConcurrentOutput.test.d.ts +1 -0
  206. package/dist/private/node/ui/components/ConcurrentOutput.test.js +54 -0
  207. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -0
  208. package/dist/private/node/ui/components/FatalError.d.ts +7 -0
  209. package/dist/private/node/ui/components/FatalError.js +54 -0
  210. package/dist/private/node/ui/components/FatalError.js.map +1 -0
  211. package/dist/private/node/ui/components/FatalError.test.d.ts +1 -0
  212. package/dist/private/node/ui/components/FatalError.test.js +119 -0
  213. package/dist/private/node/ui/components/FatalError.test.js.map +1 -0
  214. package/dist/private/node/ui/components/FilePath.d.ts +9 -0
  215. package/dist/private/node/ui/components/FilePath.js +13 -0
  216. package/dist/private/node/ui/components/FilePath.js.map +1 -0
  217. package/dist/private/node/ui/components/FilePath.test.d.ts +1 -0
  218. package/dist/private/node/ui/components/FilePath.test.js +11 -0
  219. package/dist/private/node/ui/components/FilePath.test.js.map +1 -0
  220. package/dist/private/node/ui/components/FullScreen.d.ts +8 -0
  221. package/dist/private/node/ui/components/FullScreen.js +32 -0
  222. package/dist/private/node/ui/components/FullScreen.js.map +1 -0
  223. package/dist/private/node/ui/components/Link.d.ts +10 -0
  224. package/dist/private/node/ui/components/Link.js +15 -0
  225. package/dist/private/node/ui/components/Link.js.map +1 -0
  226. package/dist/private/node/ui/components/Link.test.d.ts +1 -0
  227. package/dist/private/node/ui/components/Link.test.js +22 -0
  228. package/dist/private/node/ui/components/Link.test.js.map +1 -0
  229. package/dist/private/node/ui/components/List.d.ts +13 -0
  230. package/dist/private/node/ui/components/List.js +19 -0
  231. package/dist/private/node/ui/components/List.js.map +1 -0
  232. package/dist/private/node/ui/components/List.test.d.ts +1 -0
  233. package/dist/private/node/ui/components/List.test.js +34 -0
  234. package/dist/private/node/ui/components/List.test.js.map +1 -0
  235. package/dist/private/node/ui/components/SelectInput.d.ts +12 -0
  236. package/dist/private/node/ui/components/SelectInput.js +87 -0
  237. package/dist/private/node/ui/components/SelectInput.js.map +1 -0
  238. package/dist/private/node/ui/components/SelectInput.test.d.ts +1 -0
  239. package/dist/private/node/ui/components/SelectInput.test.js +230 -0
  240. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -0
  241. package/dist/private/node/ui/components/SelectPrompt.d.ts +11 -0
  242. package/dist/private/node/ui/components/SelectPrompt.js +34 -0
  243. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -0
  244. package/dist/private/node/ui/components/SelectPrompt.test.d.ts +1 -0
  245. package/dist/private/node/ui/components/SelectPrompt.test.js +74 -0
  246. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -0
  247. package/dist/private/node/ui/components/Table.d.ts +8 -0
  248. package/dist/private/node/ui/components/Table.js +17 -0
  249. package/dist/private/node/ui/components/Table.js.map +1 -0
  250. package/dist/private/node/ui/components/Tasks.d.ts +10 -0
  251. package/dist/private/node/ui/components/Tasks.js +27 -0
  252. package/dist/private/node/ui/components/Tasks.js.map +1 -0
  253. package/dist/private/node/ui/components/Tasks.test.d.ts +1 -0
  254. package/dist/private/node/ui/components/Tasks.test.js +50 -0
  255. package/dist/private/node/ui/components/Tasks.test.js.map +1 -0
  256. package/dist/private/node/ui/components/TextAnimation.d.ts +9 -0
  257. package/dist/private/node/ui/components/TextAnimation.js +35 -0
  258. package/dist/private/node/ui/components/TextAnimation.js.map +1 -0
  259. package/dist/private/node/ui/components/TextInput.d.ts +9 -0
  260. package/dist/private/node/ui/components/TextInput.js +74 -0
  261. package/dist/private/node/ui/components/TextInput.js.map +1 -0
  262. package/dist/private/node/ui/components/TextInput.test.d.ts +1 -0
  263. package/dist/private/node/ui/components/TextInput.test.js +139 -0
  264. package/dist/private/node/ui/components/TextInput.test.js.map +1 -0
  265. package/dist/private/node/ui/components/TextPrompt.d.ts +8 -0
  266. package/dist/private/node/ui/components/TextPrompt.js +52 -0
  267. package/dist/private/node/ui/components/TextPrompt.js.map +1 -0
  268. package/dist/private/node/ui/components/TextPrompt.test.d.ts +1 -0
  269. package/dist/private/node/ui/components/TextPrompt.test.js +68 -0
  270. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -0
  271. package/dist/private/node/ui/components/TokenizedText.d.ts +36 -0
  272. package/dist/private/node/ui/components/TokenizedText.js +70 -0
  273. package/dist/private/node/ui/components/TokenizedText.js.map +1 -0
  274. package/dist/private/node/ui/components/TokenizedText.test.d.ts +1 -0
  275. package/dist/private/node/ui/components/TokenizedText.test.js +44 -0
  276. package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -0
  277. package/dist/private/node/ui/components/UserInput.d.ts +10 -0
  278. package/dist/private/node/ui/components/UserInput.js +11 -0
  279. package/dist/private/node/ui/components/UserInput.js.map +1 -0
  280. package/dist/private/node/ui/components/UserInput.test.d.ts +1 -0
  281. package/dist/private/node/ui/components/UserInput.test.js +11 -0
  282. package/dist/private/node/ui/components/UserInput.test.js.map +1 -0
  283. package/dist/private/node/ui/hooks/use-async-and-unmount.d.ts +6 -0
  284. package/dist/private/node/ui/hooks/use-async-and-unmount.js +17 -0
  285. package/dist/private/node/ui/hooks/use-async-and-unmount.js.map +1 -0
  286. package/dist/private/node/ui/hooks/use-layout.d.ts +6 -0
  287. package/dist/private/node/ui/hooks/use-layout.js +30 -0
  288. package/dist/private/node/ui/hooks/use-layout.js.map +1 -0
  289. package/dist/private/node/ui.d.ts +23 -0
  290. package/dist/private/node/ui.js +53 -0
  291. package/dist/private/node/ui.js.map +1 -0
  292. package/dist/public/common/array.d.ts +37 -0
  293. package/dist/public/common/array.js +51 -0
  294. package/dist/public/common/array.js.map +1 -0
  295. package/dist/public/common/collection.d.ts +23 -0
  296. package/dist/public/common/collection.js +29 -0
  297. package/dist/public/common/collection.js.map +1 -0
  298. package/dist/public/common/function.d.ts +30 -0
  299. package/dist/public/common/function.js +40 -0
  300. package/dist/public/common/function.js.map +1 -0
  301. package/dist/public/common/lang.d.ts +16 -0
  302. package/dist/public/common/lang.js +22 -0
  303. package/dist/public/common/lang.js.map +1 -0
  304. package/dist/public/common/object.d.ts +32 -0
  305. package/dist/public/common/object.js +45 -0
  306. package/dist/public/common/object.js.map +1 -0
  307. package/dist/public/common/string.d.ts +6 -0
  308. package/dist/public/common/string.js +109 -0
  309. package/dist/public/common/string.js.map +1 -0
  310. package/dist/public/common/url.d.ts +7 -0
  311. package/dist/public/common/url.js +17 -0
  312. package/dist/public/common/url.js.map +1 -0
  313. package/dist/public/node/abort.d.ts +16 -0
  314. package/dist/public/node/abort.js +17 -0
  315. package/dist/public/node/abort.js.map +1 -0
  316. package/dist/public/node/analytics.d.ts +13 -0
  317. package/dist/public/node/analytics.js +82 -0
  318. package/dist/public/node/analytics.js.map +1 -0
  319. package/dist/public/node/archiver.d.ts +9 -0
  320. package/dist/public/node/archiver.js +34 -0
  321. package/dist/public/node/archiver.js.map +1 -0
  322. package/dist/public/node/base-command.d.ts +26 -0
  323. package/dist/public/node/base-command.js +172 -0
  324. package/dist/public/node/base-command.js.map +1 -0
  325. package/dist/public/node/checksum.d.ts +20 -0
  326. package/dist/public/node/checksum.js +32 -0
  327. package/dist/public/node/checksum.js.map +1 -0
  328. package/dist/public/node/cli.d.ts +29 -0
  329. package/dist/public/node/cli.js +106 -0
  330. package/dist/public/node/cli.js.map +1 -0
  331. package/dist/public/node/colors.d.ts +2 -0
  332. package/dist/public/node/colors.js +3 -0
  333. package/dist/public/node/colors.js.map +1 -0
  334. package/dist/public/node/dot-env.d.ts +42 -0
  335. package/dist/public/node/dot-env.js +67 -0
  336. package/dist/public/node/dot-env.js.map +1 -0
  337. package/dist/public/node/error-handler.d.ts +41 -0
  338. package/dist/public/node/error-handler.js +198 -0
  339. package/dist/public/node/error-handler.js.map +1 -0
  340. package/dist/public/node/error.d.ts +4 -0
  341. package/dist/public/node/error.js +5 -0
  342. package/dist/public/node/error.js.map +1 -0
  343. package/dist/public/node/framework.d.ts +8 -0
  344. package/dist/public/node/framework.js +135 -0
  345. package/dist/public/node/framework.js.map +1 -0
  346. package/dist/public/node/fs.d.ts +17 -0
  347. package/dist/public/node/fs.js +21 -0
  348. package/dist/public/node/fs.js.map +1 -0
  349. package/dist/public/node/github.d.ts +50 -0
  350. package/dist/public/node/github.js +71 -0
  351. package/dist/public/node/github.js.map +1 -0
  352. package/dist/public/node/hooks/postrun.d.ts +2 -0
  353. package/dist/public/node/hooks/postrun.js +9 -0
  354. package/dist/public/node/hooks/postrun.js.map +1 -0
  355. package/dist/public/node/hooks/prerun.d.ts +12 -0
  356. package/dist/public/node/hooks/prerun.js +66 -0
  357. package/dist/public/node/hooks/prerun.js.map +1 -0
  358. package/dist/public/node/node-package-manager.d.ts +243 -0
  359. package/dist/public/node/node-package-manager.js +369 -0
  360. package/dist/public/node/node-package-manager.js.map +1 -0
  361. package/dist/public/node/os.d.ts +16 -0
  362. package/dist/public/node/os.js +77 -0
  363. package/dist/public/node/os.js.map +1 -0
  364. package/dist/public/node/plugins/tunnel.d.ts +47 -0
  365. package/dist/public/node/plugins/tunnel.js +19 -0
  366. package/dist/public/node/plugins/tunnel.js.map +1 -0
  367. package/dist/public/node/presets.d.ts +8 -0
  368. package/dist/public/node/presets.js +26 -0
  369. package/dist/public/node/presets.js.map +1 -0
  370. package/dist/public/node/result.d.ts +94 -0
  371. package/dist/public/node/result.js +134 -0
  372. package/dist/public/node/result.js.map +1 -0
  373. package/dist/public/node/ruby.d.ts +38 -0
  374. package/dist/public/node/ruby.js +234 -0
  375. package/dist/public/node/ruby.js.map +1 -0
  376. package/dist/public/node/semver.d.ts +3 -0
  377. package/dist/public/node/semver.js +6 -0
  378. package/dist/public/node/semver.js.map +1 -0
  379. package/dist/public/node/tcp.d.ts +5 -0
  380. package/dist/public/node/tcp.js +35 -0
  381. package/dist/public/node/tcp.js.map +1 -0
  382. package/dist/public/node/ui.d.ts +184 -0
  383. package/dist/public/node/ui.js +203 -0
  384. package/dist/public/node/ui.js.map +1 -0
  385. package/dist/schema.d.ts +1 -0
  386. package/dist/schema.js +2 -0
  387. package/dist/schema.js.map +1 -0
  388. package/dist/secure-store.d.ts +19 -0
  389. package/dist/secure-store.js +63 -0
  390. package/dist/secure-store.js.map +1 -0
  391. package/dist/session/authorize.d.ts +7 -0
  392. package/dist/session/authorize.js +52 -0
  393. package/dist/session/authorize.js.map +1 -0
  394. package/dist/session/device-authorization.d.ts +32 -0
  395. package/dist/session/device-authorization.js +92 -0
  396. package/dist/session/device-authorization.js.map +1 -0
  397. package/dist/session/exchange.d.ts +48 -0
  398. package/dist/session/exchange.js +159 -0
  399. package/dist/session/exchange.js.map +1 -0
  400. package/dist/session/identity.d.ts +3 -0
  401. package/dist/session/identity.js +58 -0
  402. package/dist/session/identity.js.map +1 -0
  403. package/dist/session/post-auth.d.ts +13 -0
  404. package/dist/session/post-auth.js +62 -0
  405. package/dist/session/post-auth.js.map +1 -0
  406. package/dist/session/redirect-listener.d.ts +34 -0
  407. package/dist/session/redirect-listener.js +106 -0
  408. package/dist/session/redirect-listener.js.map +1 -0
  409. package/dist/session/schema.d.ts +175 -0
  410. package/dist/session/schema.js +60 -0
  411. package/dist/session/schema.js.map +1 -0
  412. package/dist/session/scopes.d.ts +16 -0
  413. package/dist/session/scopes.js +53 -0
  414. package/dist/session/scopes.js.map +1 -0
  415. package/dist/session/store.d.ts +24 -0
  416. package/dist/session/store.js +89 -0
  417. package/dist/session/store.js.map +1 -0
  418. package/dist/session/token.d.ts +40 -0
  419. package/dist/session/token.js +22 -0
  420. package/dist/session/token.js.map +1 -0
  421. package/dist/session/validate.d.ts +17 -0
  422. package/dist/session/validate.js +65 -0
  423. package/dist/session/validate.js.map +1 -0
  424. package/dist/session.d.ts +96 -0
  425. package/dist/session.js +293 -0
  426. package/dist/session.js.map +1 -0
  427. package/dist/store/schema.d.ts +3 -0
  428. package/dist/store/schema.js +27 -0
  429. package/dist/store/schema.js.map +1 -0
  430. package/dist/store.d.ts +53 -0
  431. package/dist/store.js +134 -0
  432. package/dist/store.js.map +1 -0
  433. package/dist/string.d.ts +28 -0
  434. package/dist/string.js +77 -0
  435. package/dist/string.js.map +1 -0
  436. package/dist/system.d.ts +51 -0
  437. package/dist/system.js +128 -0
  438. package/dist/system.js.map +1 -0
  439. package/dist/template.d.ts +11 -0
  440. package/dist/template.js +50 -0
  441. package/dist/template.js.map +1 -0
  442. package/dist/testing/output.d.ts +10 -0
  443. package/dist/testing/output.js +16 -0
  444. package/dist/testing/output.js.map +1 -0
  445. package/dist/testing/store.d.ts +7 -0
  446. package/dist/testing/store.js +26 -0
  447. package/dist/testing/store.js.map +1 -0
  448. package/dist/testing/ui.d.ts +5 -0
  449. package/dist/testing/ui.js +23 -0
  450. package/dist/testing/ui.js.map +1 -0
  451. package/dist/toml.d.ts +3 -0
  452. package/dist/toml.js +8 -0
  453. package/dist/toml.js.map +1 -0
  454. package/dist/tsconfig.tsbuildinfo +1 -0
  455. package/dist/typing/deep-required.d.ts +12 -0
  456. package/dist/typing/deep-required.js +2 -0
  457. package/dist/typing/deep-required.js.map +1 -0
  458. package/dist/typing/overloaded-parameters.d.ts +6 -0
  459. package/dist/typing/overloaded-parameters.js +2 -0
  460. package/dist/typing/overloaded-parameters.js.map +1 -0
  461. package/dist/typing/pick-by-prefix.d.ts +12 -0
  462. package/dist/typing/pick-by-prefix.js +2 -0
  463. package/dist/typing/pick-by-prefix.js.map +1 -0
  464. package/dist/typing/simple-definitions.d.ts +4 -0
  465. package/dist/typing/simple-definitions.js +2 -0
  466. package/dist/typing/simple-definitions.js.map +1 -0
  467. package/dist/ui/executor.d.ts +14 -0
  468. package/dist/ui/executor.js +90 -0
  469. package/dist/ui/executor.js.map +1 -0
  470. package/dist/ui/inquirer/autocomplete.d.ts +11 -0
  471. package/dist/ui/inquirer/autocomplete.js +110 -0
  472. package/dist/ui/inquirer/autocomplete.js.map +1 -0
  473. package/dist/ui/inquirer/input.d.ts +16 -0
  474. package/dist/ui/inquirer/input.js +45 -0
  475. package/dist/ui/inquirer/input.js.map +1 -0
  476. package/dist/ui/inquirer/password.d.ts +7 -0
  477. package/dist/ui/inquirer/password.js +8 -0
  478. package/dist/ui/inquirer/password.js.map +1 -0
  479. package/dist/ui/inquirer/select.d.ts +14 -0
  480. package/dist/ui/inquirer/select.js +26 -0
  481. package/dist/ui/inquirer/select.js.map +1 -0
  482. package/dist/ui.d.ts +54 -0
  483. package/dist/ui.js +128 -0
  484. package/dist/ui.js.map +1 -0
  485. package/dist/vscode.d.ts +8 -0
  486. package/dist/vscode.js +36 -0
  487. package/dist/vscode.js.map +1 -0
  488. package/package.json +177 -0
@@ -0,0 +1,66 @@
1
+ import { startAnalytics } from '../../../private/node/analytics.js';
2
+ import { debug } from '../../../output.js';
3
+ // This hook is called before each command run. More info: https://oclif.io/docs/hooks
4
+ export const hook = async (options) => {
5
+ const commandContent = parseCommandContent({
6
+ id: options.Command.id,
7
+ aliases: options.Command.aliases,
8
+ pluginAlias: options.Command.plugin?.alias,
9
+ });
10
+ const args = options.argv;
11
+ debug(`Running command ${commandContent.command}`);
12
+ await startAnalytics({ commandContent, args, commandClass: options.Command });
13
+ };
14
+ export function parseCommandContent(cmdInfo) {
15
+ let commandContent = parseCreateCommand(cmdInfo.pluginAlias);
16
+ if (!commandContent) {
17
+ commandContent = parseNormalCommand(cmdInfo.id, cmdInfo.aliases);
18
+ }
19
+ return commandContent;
20
+ }
21
+ function parseNormalCommand(id, aliases) {
22
+ return {
23
+ command: id.replace(/:/g, ' '),
24
+ topic: parseTopic(id),
25
+ alias: findAlias(aliases),
26
+ };
27
+ }
28
+ /**
29
+ * Create commands implement Init by default, so the name of the command must be extracted from
30
+ * the plugin/module name. Neither alias or topic are supported
31
+ *
32
+ * @param commandClass - Oclif command configuration
33
+ * @returns Command content with the name of the command or undefined otherwise
34
+ */
35
+ function parseCreateCommand(pluginAlias) {
36
+ if (!pluginAlias || !pluginAlias.startsWith('@shopify/create-')) {
37
+ return undefined;
38
+ }
39
+ return { command: pluginAlias.substring(pluginAlias.indexOf('/') + 1) };
40
+ }
41
+ /**
42
+ * Commands use this pattern topic:subtopic1:...:subtopicN:command. This method extract the topic and subtopic
43
+ * information replacing the ':' separator with one space
44
+ *
45
+ * @param cmd - Complete command string to extract the topic information
46
+ * @returns The topic name or undefined otherwise
47
+ */
48
+ function parseTopic(cmd) {
49
+ if (cmd.lastIndexOf(':') === -1) {
50
+ return;
51
+ }
52
+ return cmd.slice(0, cmd.lastIndexOf(':')).replace(/:/g, ' ');
53
+ }
54
+ /**
55
+ * Identifies if the command was launched using an alias instead of the oficial command name
56
+ *
57
+ * @param aliases - List of possible alias a command has
58
+ * @returns The alias used or undefined otherwise
59
+ */
60
+ function findAlias(aliases) {
61
+ const existingAlias = aliases.find((alias) => alias.split(':').every((aliasToken) => process.argv.includes(aliasToken)));
62
+ if (existingAlias) {
63
+ return existingAlias.replace(/:/g, ' ');
64
+ }
65
+ }
66
+ //# sourceMappingURL=prerun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,oCAAoC,CAAA;AACjE,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAA;AASxC,sFAAsF;AACtF,MAAM,CAAC,MAAM,IAAI,GAAgB,KAAK,EAAE,OAAO,EAAE,EAAE;IACjD,MAAM,cAAc,GAAG,mBAAmB,CAAC;QACzC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;QAChC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK;KAC3C,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IACzB,KAAK,CAAC,mBAAmB,cAAc,CAAC,OAAO,EAAE,CAAC,CAAA;IAClD,MAAM,cAAc,CAAC,EAAC,cAAc,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,OAAoC,EAAC,CAAC,CAAA;AAC1G,CAAC,CAAA;AAED,MAAM,UAAU,mBAAmB,CAAC,OAA8D;IAChG,IAAI,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC5D,IAAI,CAAC,cAAc,EAAE;QACnB,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;KACjE;IACD,OAAO,cAAc,CAAA;AACvB,CAAC;AAED,SAAS,kBAAkB,CAAC,EAAU,EAAE,OAAiB;IACvD,OAAO;QACL,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;QAC9B,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC;QACrB,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC;KAC1B,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,WAAoB;IAC9C,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE;QAC/D,OAAO,SAAS,CAAA;KACjB;IAED,OAAO,EAAC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAC,CAAA;AACvE,CAAC;AAED;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/B,OAAM;KACP;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,OAAiB;IAClC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAC1E,CAAA;IACD,IAAI,aAAa,EAAE;QACjB,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;KACxC;AACH,CAAC","sourcesContent":["import {startAnalytics} from '../../../private/node/analytics.js'\nimport {debug} from '../../../output.js'\nimport Command from '../../../public/node/base-command.js'\nimport {Hook} from '@oclif/core'\n\nexport declare interface CommandContent {\n command: string\n topic?: string\n alias?: string\n}\n// This hook is called before each command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Prerun = async (options) => {\n const commandContent = parseCommandContent({\n id: options.Command.id,\n aliases: options.Command.aliases,\n pluginAlias: options.Command.plugin?.alias,\n })\n const args = options.argv\n debug(`Running command ${commandContent.command}`)\n await startAnalytics({commandContent, args, commandClass: options.Command as unknown as typeof Command})\n}\n\nexport function parseCommandContent(cmdInfo: {id: string; aliases: string[]; pluginAlias?: string}): CommandContent {\n let commandContent = parseCreateCommand(cmdInfo.pluginAlias)\n if (!commandContent) {\n commandContent = parseNormalCommand(cmdInfo.id, cmdInfo.aliases)\n }\n return commandContent\n}\n\nfunction parseNormalCommand(id: string, aliases: string[]): CommandContent {\n return {\n command: id.replace(/:/g, ' '),\n topic: parseTopic(id),\n alias: findAlias(aliases),\n }\n}\n\n/**\n * Create commands implement Init by default, so the name of the command must be extracted from\n * the plugin/module name. Neither alias or topic are supported\n *\n * @param commandClass - Oclif command configuration\n * @returns Command content with the name of the command or undefined otherwise\n */\nfunction parseCreateCommand(pluginAlias?: string): CommandContent | undefined {\n if (!pluginAlias || !pluginAlias.startsWith('@shopify/create-')) {\n return undefined\n }\n\n return {command: pluginAlias.substring(pluginAlias.indexOf('/') + 1)}\n}\n\n/**\n * Commands use this pattern topic:subtopic1:...:subtopicN:command. This method extract the topic and subtopic\n * information replacing the ':' separator with one space\n *\n * @param cmd - Complete command string to extract the topic information\n * @returns The topic name or undefined otherwise\n */\nfunction parseTopic(cmd: string) {\n if (cmd.lastIndexOf(':') === -1) {\n return\n }\n return cmd.slice(0, cmd.lastIndexOf(':')).replace(/:/g, ' ')\n}\n\n/**\n * Identifies if the command was launched using an alias instead of the oficial command name\n *\n * @param aliases - List of possible alias a command has\n * @returns The alias used or undefined otherwise\n */\nfunction findAlias(aliases: string[]) {\n const existingAlias = aliases.find((alias) =>\n alias.split(':').every((aliasToken) => process.argv.includes(aliasToken)),\n )\n if (existingAlias) {\n return existingAlias.replace(/:/g, ' ')\n }\n}\n"]}
@@ -0,0 +1,243 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { AbortError, BugError } from './error.js';
4
+ import { AbortSignal } from './abort.js';
5
+ import type { Writable } from 'stream';
6
+ /** The name of the Yarn lock file */
7
+ export declare const yarnLockfile = "yarn.lock";
8
+ /** The name of the npm lock file */
9
+ export declare const npmLockfile = "package-lock.json";
10
+ /** The name of the pnpm lock file */
11
+ export declare const pnpmLockfile = "pnpm-lock.yaml";
12
+ /** The name of the pnpm workspace file */
13
+ export declare const pnpmWorkspaceFile = "pnpm-workspace.yaml";
14
+ /** An array containing the lockfiles from all the package managers */
15
+ export declare const lockfiles: Lockfile[];
16
+ export declare type Lockfile = 'yarn.lock' | 'package-lock.json' | 'pnpm-lock.yaml';
17
+ /**
18
+ * A union type that represents the type of dependencies in the package.json
19
+ * - dev: devDependencies
20
+ * - prod: dependencies
21
+ * - peer: peerDependencies
22
+ */
23
+ export declare type DependencyType = 'dev' | 'prod' | 'peer';
24
+ /**
25
+ * A union that represents the package managers available.
26
+ */
27
+ export declare const packageManager: readonly ["yarn", "npm", "pnpm"];
28
+ export declare type PackageManager = typeof packageManager[number];
29
+ /**
30
+ * Returns an abort error that's thrown when a directory that's expected to have
31
+ * a package.json doesn't have it.
32
+ * @param directory - The path to the directory that should contain a package.json
33
+ * @returns An abort error.
34
+ */
35
+ export declare const PackageJsonNotFoundError: (directory: string) => AbortError;
36
+ /**
37
+ * Returns a bug error that's thrown when the lookup of the package.json traversing the directory
38
+ * hierarchy up can't find a package.json
39
+ * @param directory - The directory from which the traverse has been done
40
+ * @returns An abort error.
41
+ */
42
+ export declare const FindUpAndReadPackageJsonNotFoundError: (directory: string) => BugError;
43
+ /**
44
+ * Returns the dependency manager used to run the create workflow.
45
+ * @param env - The environment variables of the process in which the CLI runs.
46
+ * @returns The dependency manager
47
+ */
48
+ export declare function packageManagerUsedForCreating(env?: NodeJS.ProcessEnv): PackageManager | 'unknown';
49
+ /**
50
+ * Returns the dependency manager used by an existing project.
51
+ * @param directory - The root directory of the project.
52
+ * @returns The dependency manager
53
+ */
54
+ export declare function getPackageManager(directory: string): Promise<PackageManager>;
55
+ interface InstallNPMDependenciesRecursivelyOptions {
56
+ /**
57
+ * The dependency manager to use to install the dependencies.
58
+ */
59
+ packageManager: PackageManager;
60
+ /**
61
+ * The directory from where we'll find package.json's recursively
62
+ */
63
+ directory: string;
64
+ /**
65
+ * Specifies the maximum depth of the glob search.
66
+ */
67
+ deep?: number;
68
+ }
69
+ /**
70
+ * This function traverses down a directory tree to find directories containing a package.json
71
+ * and installs the dependencies if needed. To know if it's needed, it uses the "check" command
72
+ * provided by dependency managers.
73
+ * @param options - Options to install dependencies recursively.
74
+ */
75
+ export declare function installNPMDependenciesRecursively(options: InstallNPMDependenciesRecursivelyOptions): Promise<void>;
76
+ interface InstallNodeModulesOptions {
77
+ directory: string;
78
+ args: string[];
79
+ packageManager: PackageManager;
80
+ stdout?: Writable;
81
+ stderr?: Writable;
82
+ signal?: AbortSignal;
83
+ }
84
+ export declare function installNodeModules(options: InstallNodeModulesOptions): Promise<void>;
85
+ /**
86
+ * Returns the name of the package configured in its package.json
87
+ * @param packageJsonPath - Path to the package.json file
88
+ * @returns A promise that resolves with the name.
89
+ */
90
+ export declare function getPackageName(packageJsonPath: string): Promise<string | undefined>;
91
+ /**
92
+ * Returns the list of production and dev dependencies of a package.json
93
+ * @param packageJsonPath - Path to the package.json file
94
+ * @returns A promise that resolves with the list of dependencies.
95
+ */
96
+ export declare function getDependencies(packageJsonPath: string): Promise<{
97
+ [key: string]: string;
98
+ }>;
99
+ /**
100
+ * Returns true if the app uses workspaces, false otherwise.
101
+ * @param packageJsonPath - Path to the package.json file
102
+ * @param pnpmWorkspacePath - Path to the pnpm-workspace.yaml file
103
+ * @returns A promise that resolves with true if the app uses workspaces, false otherwise.
104
+ */
105
+ export declare function usesWorkspaces(appDirectory: string): Promise<boolean>;
106
+ /**
107
+ * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.
108
+ * @param dependency - The dependency name (e.g. react)
109
+ * @param currentVersion - The current version.
110
+ * @returns A promise that resolves with a more recent version or undefined if there's no more recent version.
111
+ */
112
+ export declare function checkForNewVersion(dependency: string, currentVersion: string): Promise<string | undefined>;
113
+ /**
114
+ * An interface that represents a package.json
115
+ */
116
+ export interface PackageJson {
117
+ /**
118
+ * The name attribute of the package.json
119
+ */
120
+ name?: string;
121
+ /**
122
+ * The version attribute of the package.json
123
+ */
124
+ version?: string;
125
+ /**
126
+ * The dependencies attribute of the package.json
127
+ */
128
+ dependencies?: {
129
+ [key: string]: string;
130
+ };
131
+ /**
132
+ * The devDependencies attribute of the package.json
133
+ */
134
+ devDependencies?: {
135
+ [key: string]: string;
136
+ };
137
+ /**
138
+ * The optional oclif settings attribute of the package.json
139
+ */
140
+ oclif?: {
141
+ plugins?: string[];
142
+ };
143
+ /**
144
+ * The workspaces attribute of the package.json
145
+ */
146
+ workspaces?: string[];
147
+ /**
148
+ * The resolutions attribute of the package.json. Only useful when using yarn as package manager
149
+ */
150
+ resolutions?: {
151
+ [key: string]: string;
152
+ };
153
+ /**
154
+ * The overrides attribute of the package.json. Only useful when using npm o npmn as package managers
155
+ */
156
+ overrides?: {
157
+ [key: string]: string;
158
+ };
159
+ }
160
+ /**
161
+ * Reads and parses a package.json
162
+ * @param packageJsonPath - Path to the package.json
163
+ * @returns An promise that resolves with an in-memory representation
164
+ * of the package.json or rejects with an error if the file is not found or the content is
165
+ * not decodable.
166
+ */
167
+ export declare function readAndParsePackageJson(packageJsonPath: string): Promise<PackageJson>;
168
+ interface AddNPMDependenciesIfNeededOptions {
169
+ /** How dependencies should be added */
170
+ type: DependencyType;
171
+ /** The dependency manager to use to add dependencies */
172
+ packageManager: PackageManager;
173
+ /** The directory that contains the package.json where dependencies will be added */
174
+ directory: string;
175
+ /** Standard output coming from the underlying installation process */
176
+ stdout?: Writable;
177
+ /** Standard error coming from the underlying installation process */
178
+ stderr?: Writable;
179
+ /** Abort signal to stop the process */
180
+ signal?: AbortSignal;
181
+ }
182
+ /**
183
+ * An interface that represents a dependency name with its version
184
+ */
185
+ export interface DependencyVersion {
186
+ /**
187
+ * The name of the NPM dependency as it's reflected in the package.json:
188
+ *
189
+ * @example
190
+ * In the example below name would be "react"
191
+ * ```
192
+ * {
193
+ * "react": "1.2.3"
194
+ * }
195
+ * ```
196
+ */
197
+ name: string;
198
+ /**
199
+ * The version of the NPM dependency as it's reflected in the package.json:
200
+ *
201
+ * @example
202
+ * In the example below version would be "1.2.3"
203
+ * ```
204
+ * {
205
+ * "react": "1.2.3"
206
+ * }
207
+ * ```
208
+ */
209
+ version: string | undefined;
210
+ }
211
+ /**
212
+ * Adds dependencies to a Node project (i.e. a project that has a package.json)
213
+ * @param dependencies - List of dependencies to be added.
214
+ * @param options - Options for adding dependencies.
215
+ */
216
+ export declare function addNPMDependenciesIfNeeded(dependencies: DependencyVersion[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
217
+ export declare function addNPMDependencies(dependencies: DependencyVersion[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
218
+ export declare function addNPMDependenciesWithoutVersionIfNeeded(dependencies: string[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
219
+ /**
220
+ * Given a directory it traverses the directory up looking for a package.json and if found, it reads it
221
+ * decodes the JSON, and returns its content as a Javascript object.
222
+ * @param options - The directory from which traverse up.
223
+ * @returns If found, the promise resolves with the path to the
224
+ * package.json and its content. If not found, it throws a FindUpAndReadPackageJsonNotFoundError error.
225
+ */
226
+ export declare function findUpAndReadPackageJson(fromDirectory: string): Promise<{
227
+ path: string;
228
+ content: unknown;
229
+ }>;
230
+ export declare function addResolutionOrOverride(directory: string, dependencies: {
231
+ [key: string]: string;
232
+ }): Promise<void>;
233
+ interface FindPackageVersionUpOptions {
234
+ fromModuleURL: import('url').URL | string;
235
+ }
236
+ /**
237
+ * Given a module URL, it traverses the directory hierarchy up until it finds a package.json
238
+ * and then it returns the version in it.
239
+ * @param options - Options
240
+ * @returns The version if it can find the package.json and it exists. An error otherwise.
241
+ */
242
+ export declare function findPackageVersionUp(options: FindPackageVersionUpOptions): Promise<string>;
243
+ export {};
@@ -0,0 +1,369 @@
1
+ import { AbortError, BugError } from './error.js';
2
+ import { Version } from './semver.js';
3
+ import { AbortController } from './abort.js';
4
+ import { exec } from '../../system.js';
5
+ import { exists as fileExists, read as readFile, write as writeFile } from '../../file.js';
6
+ import { glob, dirname, join as pathJoin, findUp, moduleDirectory } from '../../path.js';
7
+ import { token, content, debug } from '../../output.js';
8
+ import { Bug } from '../../error.js';
9
+ import latestVersion from 'latest-version';
10
+ /** The name of the Yarn lock file */
11
+ export const yarnLockfile = 'yarn.lock';
12
+ /** The name of the npm lock file */
13
+ export const npmLockfile = 'package-lock.json';
14
+ /** The name of the pnpm lock file */
15
+ export const pnpmLockfile = 'pnpm-lock.yaml';
16
+ /** The name of the pnpm workspace file */
17
+ export const pnpmWorkspaceFile = 'pnpm-workspace.yaml';
18
+ /** An array containing the lockfiles from all the package managers */
19
+ export const lockfiles = [yarnLockfile, pnpmLockfile, npmLockfile];
20
+ /**
21
+ * A union that represents the package managers available.
22
+ */
23
+ export const packageManager = ['yarn', 'npm', 'pnpm'];
24
+ /**
25
+ * Returns an abort error that's thrown when a directory that's expected to have
26
+ * a package.json doesn't have it.
27
+ * @param directory - The path to the directory that should contain a package.json
28
+ * @returns An abort error.
29
+ */
30
+ export const PackageJsonNotFoundError = (directory) => {
31
+ return new AbortError(`The directory ${directory} doesn't have a package.json.`);
32
+ };
33
+ /**
34
+ * Returns a bug error that's thrown when the lookup of the package.json traversing the directory
35
+ * hierarchy up can't find a package.json
36
+ * @param directory - The directory from which the traverse has been done
37
+ * @returns An abort error.
38
+ */
39
+ export const FindUpAndReadPackageJsonNotFoundError = (directory) => {
40
+ return new BugError(content `Couldn't find a a package.json traversing directories from ${token.path(directory)}`);
41
+ };
42
+ /**
43
+ * Returns the dependency manager used to run the create workflow.
44
+ * @param env - The environment variables of the process in which the CLI runs.
45
+ * @returns The dependency manager
46
+ */
47
+ export function packageManagerUsedForCreating(env = process.env) {
48
+ if (env.npm_config_user_agent?.includes('yarn')) {
49
+ return 'yarn';
50
+ }
51
+ else if (env.npm_config_user_agent?.includes('pnpm')) {
52
+ return 'pnpm';
53
+ }
54
+ else if (env.npm_config_user_agent?.includes('npm')) {
55
+ return 'npm';
56
+ }
57
+ return 'unknown';
58
+ }
59
+ /**
60
+ * Returns the dependency manager used by an existing project.
61
+ * @param directory - The root directory of the project.
62
+ * @returns The dependency manager
63
+ */
64
+ export async function getPackageManager(directory) {
65
+ debug(content `Obtaining the dependency manager in directory ${token.path(directory)}...`);
66
+ const yarnLockPath = pathJoin(directory, yarnLockfile);
67
+ const pnpmLockPath = pathJoin(directory, pnpmLockfile);
68
+ if (await fileExists(yarnLockPath)) {
69
+ return 'yarn';
70
+ }
71
+ else if (await fileExists(pnpmLockPath)) {
72
+ return 'pnpm';
73
+ }
74
+ else {
75
+ return 'npm';
76
+ }
77
+ }
78
+ /**
79
+ * This function traverses down a directory tree to find directories containing a package.json
80
+ * and installs the dependencies if needed. To know if it's needed, it uses the "check" command
81
+ * provided by dependency managers.
82
+ * @param options - Options to install dependencies recursively.
83
+ */
84
+ export async function installNPMDependenciesRecursively(options) {
85
+ const packageJsons = await glob(pathJoin(options.directory, '**/package.json'), {
86
+ ignore: [pathJoin(options.directory, 'node_modules/**/package.json')],
87
+ cwd: options.directory,
88
+ onlyFiles: true,
89
+ deep: options.deep,
90
+ });
91
+ const abortController = new AbortController();
92
+ try {
93
+ await Promise.all(packageJsons.map(async (packageJsonPath) => {
94
+ const directory = dirname(packageJsonPath);
95
+ await installNodeModules({
96
+ directory,
97
+ packageManager: options.packageManager,
98
+ stdout: undefined,
99
+ stderr: undefined,
100
+ signal: abortController.signal,
101
+ args: [],
102
+ });
103
+ }));
104
+ }
105
+ catch (error) {
106
+ abortController.abort();
107
+ throw error;
108
+ }
109
+ }
110
+ export async function installNodeModules(options) {
111
+ const execOptions = {
112
+ cwd: options.directory,
113
+ stdin: undefined,
114
+ stdout: options.stdout,
115
+ stderr: options.stderr,
116
+ signal: options.signal,
117
+ };
118
+ let args = ['install'];
119
+ if (options.args) {
120
+ args = args.concat(options.args);
121
+ }
122
+ await exec(options.packageManager, args, execOptions);
123
+ }
124
+ /**
125
+ * Returns the name of the package configured in its package.json
126
+ * @param packageJsonPath - Path to the package.json file
127
+ * @returns A promise that resolves with the name.
128
+ */
129
+ export async function getPackageName(packageJsonPath) {
130
+ const packageJsonContent = await readAndParsePackageJson(packageJsonPath);
131
+ return packageJsonContent.name;
132
+ }
133
+ /**
134
+ * Returns the list of production and dev dependencies of a package.json
135
+ * @param packageJsonPath - Path to the package.json file
136
+ * @returns A promise that resolves with the list of dependencies.
137
+ */
138
+ export async function getDependencies(packageJsonPath) {
139
+ const packageJsonContent = await readAndParsePackageJson(packageJsonPath);
140
+ const dependencies = packageJsonContent.dependencies ?? {};
141
+ const devDependencies = packageJsonContent.devDependencies ?? {};
142
+ return { ...dependencies, ...devDependencies };
143
+ }
144
+ /**
145
+ * Returns true if the app uses workspaces, false otherwise.
146
+ * @param packageJsonPath - Path to the package.json file
147
+ * @param pnpmWorkspacePath - Path to the pnpm-workspace.yaml file
148
+ * @returns A promise that resolves with true if the app uses workspaces, false otherwise.
149
+ */
150
+ export async function usesWorkspaces(appDirectory) {
151
+ const packageJsonPath = pathJoin(appDirectory, 'package.json');
152
+ const packageJsonContent = await readAndParsePackageJson(packageJsonPath);
153
+ const pnpmWorkspacePath = pathJoin(appDirectory, pnpmWorkspaceFile);
154
+ return Boolean(packageJsonContent.workspaces) || fileExists(pnpmWorkspacePath);
155
+ }
156
+ /**
157
+ * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.
158
+ * @param dependency - The dependency name (e.g. react)
159
+ * @param currentVersion - The current version.
160
+ * @returns A promise that resolves with a more recent version or undefined if there's no more recent version.
161
+ */
162
+ export async function checkForNewVersion(dependency, currentVersion) {
163
+ debug(content `Checking if there's a version of ${dependency} newer than ${currentVersion}`);
164
+ try {
165
+ const lastVersion = await getLatestNPMPackageVersion(dependency);
166
+ if (lastVersion && new Version(currentVersion).compare(lastVersion) < 0) {
167
+ return lastVersion;
168
+ }
169
+ else {
170
+ return undefined;
171
+ }
172
+ // eslint-disable-next-line no-catch-all/no-catch-all
173
+ }
174
+ catch (error) {
175
+ return undefined;
176
+ }
177
+ }
178
+ /**
179
+ * Reads and parses a package.json
180
+ * @param packageJsonPath - Path to the package.json
181
+ * @returns An promise that resolves with an in-memory representation
182
+ * of the package.json or rejects with an error if the file is not found or the content is
183
+ * not decodable.
184
+ */
185
+ export async function readAndParsePackageJson(packageJsonPath) {
186
+ if (!(await fileExists(packageJsonPath))) {
187
+ throw PackageJsonNotFoundError(dirname(packageJsonPath));
188
+ }
189
+ return JSON.parse(await readFile(packageJsonPath));
190
+ }
191
+ /**
192
+ * Adds dependencies to a Node project (i.e. a project that has a package.json)
193
+ * @param dependencies - List of dependencies to be added.
194
+ * @param options - Options for adding dependencies.
195
+ */
196
+ export async function addNPMDependenciesIfNeeded(dependencies, options) {
197
+ debug(content `Adding the following dependencies if needed:
198
+ ${token.json(dependencies)}
199
+ With options:
200
+ ${token.json(options)}
201
+ `);
202
+ const packageJsonPath = pathJoin(options.directory, 'package.json');
203
+ if (!(await fileExists(packageJsonPath))) {
204
+ throw PackageJsonNotFoundError(options.directory);
205
+ }
206
+ const existingDependencies = Object.keys(await getDependencies(packageJsonPath));
207
+ let dependenciesToAdd = dependencies;
208
+ dependenciesToAdd = dependencies.filter((dep) => {
209
+ return !existingDependencies.includes(dep.name);
210
+ });
211
+ if (dependenciesToAdd.length === 0) {
212
+ return;
213
+ }
214
+ await addNPMDependencies(dependenciesToAdd, options);
215
+ }
216
+ export async function addNPMDependencies(dependencies, options) {
217
+ let args;
218
+ const depedenciesWithVersion = dependencies.map((dep) => {
219
+ return dep.version ? `${dep.name}@${dep.version}` : dep.name;
220
+ });
221
+ switch (options.packageManager) {
222
+ case 'npm':
223
+ args = argumentsToAddDependenciesWithNPM(depedenciesWithVersion, options.type);
224
+ break;
225
+ case 'yarn':
226
+ args = argumentsToAddDependenciesWithYarn(depedenciesWithVersion, options.type);
227
+ break;
228
+ case 'pnpm':
229
+ args = argumentsToAddDependenciesWithPNPM(depedenciesWithVersion, options.type);
230
+ break;
231
+ }
232
+ options.stdout?.write(`Executing... ${[options.packageManager, ...args].join(' ')}`);
233
+ await exec(options.packageManager, args, {
234
+ cwd: options.directory,
235
+ stdout: options.stdout,
236
+ stderr: options.stderr,
237
+ signal: options.signal,
238
+ });
239
+ }
240
+ export async function addNPMDependenciesWithoutVersionIfNeeded(dependencies, options) {
241
+ await addNPMDependenciesIfNeeded(dependencies.map((dependency) => {
242
+ return { name: dependency, version: undefined };
243
+ }), options);
244
+ }
245
+ /**
246
+ * Returns the arguments to add dependencies using NPM.
247
+ * @param dependencies - The list of dependencies to add
248
+ * @param type - The dependency type.
249
+ * @returns An array with the arguments.
250
+ */
251
+ function argumentsToAddDependenciesWithNPM(dependencies, type) {
252
+ let command = ['install'];
253
+ command = command.concat(dependencies);
254
+ switch (type) {
255
+ case 'dev':
256
+ command.push('--save-dev');
257
+ break;
258
+ case 'peer':
259
+ command.push('--save-peer');
260
+ break;
261
+ case 'prod':
262
+ command.push('--save-prod');
263
+ break;
264
+ }
265
+ return command;
266
+ }
267
+ /**
268
+ * Returns the arguments to add dependencies using Yarn.
269
+ * @param dependencies - The list of dependencies to add
270
+ * @param type - The dependency type.
271
+ * @returns An array with the arguments.
272
+ */
273
+ function argumentsToAddDependenciesWithYarn(dependencies, type) {
274
+ let command = ['add'];
275
+ command = command.concat(dependencies);
276
+ switch (type) {
277
+ case 'dev':
278
+ command.push('--dev');
279
+ break;
280
+ case 'peer':
281
+ command.push('--peer');
282
+ break;
283
+ case 'prod':
284
+ command.push('--prod');
285
+ break;
286
+ }
287
+ return command;
288
+ }
289
+ /**
290
+ * Returns the arguments to add dependencies using PNPM.
291
+ * @param dependencies - The list of dependencies to add
292
+ * @param type - The dependency type.
293
+ * @returns An array with the arguments.
294
+ */
295
+ function argumentsToAddDependenciesWithPNPM(dependencies, type) {
296
+ let command = ['add'];
297
+ command = command.concat(dependencies);
298
+ switch (type) {
299
+ case 'dev':
300
+ command.push('--save-dev');
301
+ break;
302
+ case 'peer':
303
+ command.push('--save-peer');
304
+ break;
305
+ case 'prod':
306
+ command.push('--save-prod');
307
+ break;
308
+ }
309
+ return command;
310
+ }
311
+ /**
312
+ * Given a directory it traverses the directory up looking for a package.json and if found, it reads it
313
+ * decodes the JSON, and returns its content as a Javascript object.
314
+ * @param options - The directory from which traverse up.
315
+ * @returns If found, the promise resolves with the path to the
316
+ * package.json and its content. If not found, it throws a FindUpAndReadPackageJsonNotFoundError error.
317
+ */
318
+ export async function findUpAndReadPackageJson(fromDirectory) {
319
+ const packageJsonPath = await findUp('package.json', { cwd: fromDirectory, type: 'file' });
320
+ if (packageJsonPath) {
321
+ const packageJson = JSON.parse(await readFile(packageJsonPath));
322
+ return { path: packageJsonPath, content: packageJson };
323
+ }
324
+ else {
325
+ throw FindUpAndReadPackageJsonNotFoundError(fromDirectory);
326
+ }
327
+ }
328
+ export async function addResolutionOrOverride(directory, dependencies) {
329
+ const packageManager = await getPackageManager(directory);
330
+ const packageJsonPath = pathJoin(directory, 'package.json');
331
+ const packageJsonContent = await readAndParsePackageJson(packageJsonPath);
332
+ if (packageManager === 'yarn') {
333
+ packageJsonContent.resolutions = packageJsonContent.resolutions
334
+ ? { ...packageJsonContent.resolutions, ...dependencies }
335
+ : dependencies;
336
+ }
337
+ if (packageManager === 'npm' || packageManager === 'pnpm') {
338
+ packageJsonContent.overrides = packageJsonContent.overrides
339
+ ? { ...packageJsonContent.overrides, ...dependencies }
340
+ : dependencies;
341
+ }
342
+ await writeFile(packageJsonPath, JSON.stringify(packageJsonContent, null, 2));
343
+ }
344
+ /**
345
+ * Returns the latest available version of an NPM package.
346
+ * @param name - The name of the NPM package.
347
+ * @returns A promise to get the latest available version of a package.
348
+ */
349
+ async function getLatestNPMPackageVersion(name) {
350
+ debug(content `Getting the latest version of NPM package: ${token.raw(name)}`);
351
+ return latestVersion(name);
352
+ }
353
+ /**
354
+ * Given a module URL, it traverses the directory hierarchy up until it finds a package.json
355
+ * and then it returns the version in it.
356
+ * @param options - Options
357
+ * @returns The version if it can find the package.json and it exists. An error otherwise.
358
+ */
359
+ export async function findPackageVersionUp(options) {
360
+ const fromDirectory = moduleDirectory(options.fromModuleURL);
361
+ const packageJson = await findUpAndReadPackageJson(fromDirectory);
362
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
363
+ const version = packageJson.content.version;
364
+ if (!version) {
365
+ throw new Bug(content `The package.json at path ${token.path(packageJson.path)} doesn't contain a version`);
366
+ }
367
+ return version;
368
+ }
369
+ //# sourceMappingURL=node-package-manager.js.map