@beezer-pet/instant-cli 0.0.0-stage → 1.0.67-beezer.4

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 (443) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/LICENSE.md +202 -0
  3. package/README.md +34 -2
  4. package/__tests__/appCommands.test.ts +228 -0
  5. package/__tests__/args.test.ts +358 -0
  6. package/__tests__/auth.test.ts +128 -0
  7. package/__tests__/authClientAddApple.test.ts +376 -0
  8. package/__tests__/authClientAddClerk.test.ts +222 -0
  9. package/__tests__/authClientAddGithub.test.ts +245 -0
  10. package/__tests__/authClientAddGoogle.test.ts +373 -0
  11. package/__tests__/authClientAddLinkedin.test.ts +262 -0
  12. package/__tests__/authClientList.test.ts +90 -0
  13. package/__tests__/authClientUpdate.test.ts +583 -0
  14. package/__tests__/authOriginManagement.test.ts +308 -0
  15. package/__tests__/backupDownload.test.ts +206 -0
  16. package/__tests__/backups.test.ts +221 -0
  17. package/__tests__/config.test.ts +57 -0
  18. package/__tests__/e2e/cli.e2e.test.ts +1267 -0
  19. package/__tests__/e2e/helpers.ts +177 -0
  20. package/__tests__/effectHelpers.ts +45 -0
  21. package/__tests__/mergeSchema.test.ts +197 -0
  22. package/__tests__/multiSelect.test.ts +236 -0
  23. package/__tests__/oauthMock.ts +76 -0
  24. package/__tests__/promptOk.test.ts +44 -0
  25. package/__tests__/redirectUriPrompt.test.ts +40 -0
  26. package/__tests__/sdkInstallSpec.test.ts +36 -0
  27. package/__tests__/select.test.ts +224 -0
  28. package/__tests__/webhooks.test.ts +728 -0
  29. package/bin/index.js +3 -0
  30. package/dist/auth/index.d.ts +4 -0
  31. package/dist/auth/index.d.ts.map +1 -0
  32. package/dist/auth/index.js +103 -0
  33. package/dist/auth/index.js.map +1 -0
  34. package/dist/commands/app/delete.d.ts +7 -0
  35. package/dist/commands/app/delete.d.ts.map +1 -0
  36. package/dist/commands/app/delete.js +57 -0
  37. package/dist/commands/app/delete.js.map +1 -0
  38. package/dist/commands/app/list.d.ts +6 -0
  39. package/dist/commands/app/list.d.ts.map +1 -0
  40. package/dist/commands/app/list.js +29 -0
  41. package/dist/commands/app/list.js.map +1 -0
  42. package/dist/commands/auth/client/add.d.ts +9 -0
  43. package/dist/commands/auth/client/add.d.ts.map +1 -0
  44. package/dist/commands/auth/client/add.js +409 -0
  45. package/dist/commands/auth/client/add.js.map +1 -0
  46. package/dist/commands/auth/client/delete.d.ts +11 -0
  47. package/dist/commands/auth/client/delete.d.ts.map +1 -0
  48. package/dist/commands/auth/client/delete.js +48 -0
  49. package/dist/commands/auth/client/delete.js.map +1 -0
  50. package/dist/commands/auth/client/list.d.ts +6 -0
  51. package/dist/commands/auth/client/list.d.ts.map +1 -0
  52. package/dist/commands/auth/client/list.js +38 -0
  53. package/dist/commands/auth/client/list.js.map +1 -0
  54. package/dist/commands/auth/client/shared.d.ts +70 -0
  55. package/dist/commands/auth/client/shared.d.ts.map +1 -0
  56. package/dist/commands/auth/client/shared.js +140 -0
  57. package/dist/commands/auth/client/shared.js.map +1 -0
  58. package/dist/commands/auth/client/update.d.ts +8 -0
  59. package/dist/commands/auth/client/update.d.ts.map +1 -0
  60. package/dist/commands/auth/client/update.js +445 -0
  61. package/dist/commands/auth/client/update.js.map +1 -0
  62. package/dist/commands/auth/email/pull.d.ts +24 -0
  63. package/dist/commands/auth/email/pull.d.ts.map +1 -0
  64. package/dist/commands/auth/email/pull.js +100 -0
  65. package/dist/commands/auth/email/pull.js.map +1 -0
  66. package/dist/commands/auth/email/push.d.ts +8 -0
  67. package/dist/commands/auth/email/push.d.ts.map +1 -0
  68. package/dist/commands/auth/email/push.js +58 -0
  69. package/dist/commands/auth/email/push.js.map +1 -0
  70. package/dist/commands/auth/email/resend.d.ts +3 -0
  71. package/dist/commands/auth/email/resend.d.ts.map +1 -0
  72. package/dist/commands/auth/email/resend.js +7 -0
  73. package/dist/commands/auth/email/resend.js.map +1 -0
  74. package/dist/commands/auth/email/reset.d.ts +5 -0
  75. package/dist/commands/auth/email/reset.d.ts.map +1 -0
  76. package/dist/commands/auth/email/reset.js +25 -0
  77. package/dist/commands/auth/email/reset.js.map +1 -0
  78. package/dist/commands/auth/email/status.d.ts +57 -0
  79. package/dist/commands/auth/email/status.d.ts.map +1 -0
  80. package/dist/commands/auth/email/status.js +96 -0
  81. package/dist/commands/auth/email/status.js.map +1 -0
  82. package/dist/commands/auth/email/verify.d.ts +5 -0
  83. package/dist/commands/auth/email/verify.d.ts.map +1 -0
  84. package/dist/commands/auth/email/verify.js +12 -0
  85. package/dist/commands/auth/email/verify.js.map +1 -0
  86. package/dist/commands/auth/origin/add.d.ts +12 -0
  87. package/dist/commands/auth/origin/add.d.ts.map +1 -0
  88. package/dist/commands/auth/origin/add.js +153 -0
  89. package/dist/commands/auth/origin/add.js.map +1 -0
  90. package/dist/commands/auth/origin/delete.d.ts +8 -0
  91. package/dist/commands/auth/origin/delete.d.ts.map +1 -0
  92. package/dist/commands/auth/origin/delete.js +38 -0
  93. package/dist/commands/auth/origin/delete.js.map +1 -0
  94. package/dist/commands/auth/origin/list.d.ts +9 -0
  95. package/dist/commands/auth/origin/list.d.ts.map +1 -0
  96. package/dist/commands/auth/origin/list.js +52 -0
  97. package/dist/commands/auth/origin/list.js.map +1 -0
  98. package/dist/commands/backup/download.d.ts +10 -0
  99. package/dist/commands/backup/download.d.ts.map +1 -0
  100. package/dist/commands/backup/download.js +174 -0
  101. package/dist/commands/backup/download.js.map +1 -0
  102. package/dist/commands/backup/list.d.ts +11 -0
  103. package/dist/commands/backup/list.d.ts.map +1 -0
  104. package/dist/commands/backup/list.js +74 -0
  105. package/dist/commands/backup/list.js.map +1 -0
  106. package/dist/commands/claim.d.ts +6 -0
  107. package/dist/commands/claim.d.ts.map +1 -0
  108. package/dist/commands/claim.js +22 -0
  109. package/dist/commands/claim.js.map +1 -0
  110. package/dist/commands/explorer.d.ts +6 -0
  111. package/dist/commands/explorer.d.ts.map +1 -0
  112. package/dist/commands/explorer.js +13 -0
  113. package/dist/commands/explorer.js.map +1 -0
  114. package/dist/commands/info.d.ts +9 -0
  115. package/dist/commands/info.d.ts.map +1 -0
  116. package/dist/commands/info.js +41 -0
  117. package/dist/commands/info.js.map +1 -0
  118. package/dist/commands/init.d.ts +5 -0
  119. package/dist/commands/init.d.ts.map +1 -0
  120. package/dist/commands/init.js +41 -0
  121. package/dist/commands/init.js.map +1 -0
  122. package/dist/commands/initWithoutFiles.d.ts +6 -0
  123. package/dist/commands/initWithoutFiles.d.ts.map +1 -0
  124. package/dist/commands/initWithoutFiles.js +64 -0
  125. package/dist/commands/initWithoutFiles.js.map +1 -0
  126. package/dist/commands/login.d.ts +9 -0
  127. package/dist/commands/login.d.ts.map +1 -0
  128. package/dist/commands/login.js +44 -0
  129. package/dist/commands/login.js.map +1 -0
  130. package/dist/commands/logout.d.ts +3 -0
  131. package/dist/commands/logout.d.ts.map +1 -0
  132. package/dist/commands/logout.js +14 -0
  133. package/dist/commands/logout.js.map +1 -0
  134. package/dist/commands/pull.d.ts +5 -0
  135. package/dist/commands/pull.d.ts.map +1 -0
  136. package/dist/commands/pull.js +15 -0
  137. package/dist/commands/pull.js.map +1 -0
  138. package/dist/commands/push.d.ts +6 -0
  139. package/dist/commands/push.d.ts.map +1 -0
  140. package/dist/commands/push.js +20 -0
  141. package/dist/commands/push.js.map +1 -0
  142. package/dist/commands/query.d.ts +7 -0
  143. package/dist/commands/query.d.ts.map +1 -0
  144. package/dist/commands/query.js +52 -0
  145. package/dist/commands/query.js.map +1 -0
  146. package/dist/commands/webhooks/add.d.ts +9 -0
  147. package/dist/commands/webhooks/add.d.ts.map +1 -0
  148. package/dist/commands/webhooks/add.js +75 -0
  149. package/dist/commands/webhooks/add.js.map +1 -0
  150. package/dist/commands/webhooks/delete.d.ts +6 -0
  151. package/dist/commands/webhooks/delete.d.ts.map +1 -0
  152. package/dist/commands/webhooks/delete.js +17 -0
  153. package/dist/commands/webhooks/delete.js.map +1 -0
  154. package/dist/commands/webhooks/disable.d.ts +7 -0
  155. package/dist/commands/webhooks/disable.d.ts.map +1 -0
  156. package/dist/commands/webhooks/disable.js +18 -0
  157. package/dist/commands/webhooks/disable.js.map +1 -0
  158. package/dist/commands/webhooks/enable.d.ts +6 -0
  159. package/dist/commands/webhooks/enable.d.ts.map +1 -0
  160. package/dist/commands/webhooks/enable.js +18 -0
  161. package/dist/commands/webhooks/enable.js.map +1 -0
  162. package/dist/commands/webhooks/events/list.d.ts +7 -0
  163. package/dist/commands/webhooks/events/list.d.ts.map +1 -0
  164. package/dist/commands/webhooks/events/list.js +31 -0
  165. package/dist/commands/webhooks/events/list.js.map +1 -0
  166. package/dist/commands/webhooks/events/payload.d.ts +8 -0
  167. package/dist/commands/webhooks/events/payload.d.ts.map +1 -0
  168. package/dist/commands/webhooks/events/payload.js +39 -0
  169. package/dist/commands/webhooks/events/payload.js.map +1 -0
  170. package/dist/commands/webhooks/events/resend.d.ts +8 -0
  171. package/dist/commands/webhooks/events/resend.d.ts.map +1 -0
  172. package/dist/commands/webhooks/events/resend.js +43 -0
  173. package/dist/commands/webhooks/events/resend.js.map +1 -0
  174. package/dist/commands/webhooks/list.d.ts +8 -0
  175. package/dist/commands/webhooks/list.d.ts.map +1 -0
  176. package/dist/commands/webhooks/list.js +29 -0
  177. package/dist/commands/webhooks/list.js.map +1 -0
  178. package/dist/commands/webhooks/shared.d.ts +40 -0
  179. package/dist/commands/webhooks/shared.d.ts.map +1 -0
  180. package/dist/commands/webhooks/shared.js +248 -0
  181. package/dist/commands/webhooks/shared.js.map +1 -0
  182. package/dist/commands/webhooks/update.d.ts +10 -0
  183. package/dist/commands/webhooks/update.d.ts.map +1 -0
  184. package/dist/commands/webhooks/update.js +189 -0
  185. package/dist/commands/webhooks/update.js.map +1 -0
  186. package/dist/context/authToken.d.ts +29 -0
  187. package/dist/context/authToken.d.ts.map +1 -0
  188. package/dist/context/authToken.js +73 -0
  189. package/dist/context/authToken.js.map +1 -0
  190. package/dist/context/currentApp.d.ts +38 -0
  191. package/dist/context/currentApp.d.ts.map +1 -0
  192. package/dist/context/currentApp.js +222 -0
  193. package/dist/context/currentApp.js.map +1 -0
  194. package/dist/context/globalOpts.d.ts +11 -0
  195. package/dist/context/globalOpts.d.ts.map +1 -0
  196. package/dist/context/globalOpts.js +13 -0
  197. package/dist/context/globalOpts.js.map +1 -0
  198. package/dist/context/platformApi.d.ts +19 -0
  199. package/dist/context/platformApi.d.ts.map +1 -0
  200. package/dist/context/platformApi.js +24 -0
  201. package/dist/context/platformApi.js.map +1 -0
  202. package/dist/context/projectInfo.d.ts +30 -0
  203. package/dist/context/projectInfo.d.ts.map +1 -0
  204. package/dist/context/projectInfo.js +153 -0
  205. package/dist/context/projectInfo.js.map +1 -0
  206. package/dist/errors.d.ts +10 -0
  207. package/dist/errors.d.ts.map +1 -0
  208. package/dist/errors.js +6 -0
  209. package/dist/errors.js.map +1 -0
  210. package/dist/index.d.ts +159 -0
  211. package/dist/index.d.ts.map +1 -0
  212. package/dist/index.js +714 -0
  213. package/dist/index.js.map +1 -0
  214. package/dist/layer.d.ts +25 -0
  215. package/dist/layer.d.ts.map +1 -0
  216. package/dist/layer.js +119 -0
  217. package/dist/layer.js.map +1 -0
  218. package/dist/lib/args.d.ts +212 -0
  219. package/dist/lib/args.d.ts.map +1 -0
  220. package/dist/lib/args.js +313 -0
  221. package/dist/lib/args.js.map +1 -0
  222. package/dist/lib/backupDownload.d.ts +21 -0
  223. package/dist/lib/backupDownload.d.ts.map +1 -0
  224. package/dist/lib/backupDownload.js +151 -0
  225. package/dist/lib/backupDownload.js.map +1 -0
  226. package/dist/lib/backups.d.ts +12 -0
  227. package/dist/lib/backups.d.ts.map +1 -0
  228. package/dist/lib/backups.js +26 -0
  229. package/dist/lib/backups.js.map +1 -0
  230. package/dist/lib/config.d.ts +6 -0
  231. package/dist/lib/config.d.ts.map +1 -0
  232. package/dist/lib/config.js +39 -0
  233. package/dist/lib/config.js.map +1 -0
  234. package/dist/lib/createApp.d.ts +12 -0
  235. package/dist/lib/createApp.d.ts.map +1 -0
  236. package/dist/lib/createApp.js +15 -0
  237. package/dist/lib/createApp.js.map +1 -0
  238. package/dist/lib/email.d.ts +47 -0
  239. package/dist/lib/email.d.ts.map +1 -0
  240. package/dist/lib/email.js +71 -0
  241. package/dist/lib/email.js.map +1 -0
  242. package/dist/lib/handleEnv.d.ts +7 -0
  243. package/dist/lib/handleEnv.d.ts.map +1 -0
  244. package/dist/lib/handleEnv.js +99 -0
  245. package/dist/lib/handleEnv.js.map +1 -0
  246. package/dist/lib/http.d.ts +30 -0
  247. package/dist/lib/http.d.ts.map +1 -0
  248. package/dist/lib/http.js +55 -0
  249. package/dist/lib/http.js.map +1 -0
  250. package/dist/lib/login.d.ts +12 -0
  251. package/dist/lib/login.d.ts.map +1 -0
  252. package/dist/lib/login.js +38 -0
  253. package/dist/lib/login.js.map +1 -0
  254. package/dist/lib/oauth.d.ts +306 -0
  255. package/dist/lib/oauth.d.ts.map +1 -0
  256. package/dist/lib/oauth.js +195 -0
  257. package/dist/lib/oauth.js.map +1 -0
  258. package/dist/lib/platformApi.d.ts +5 -0
  259. package/dist/lib/platformApi.d.ts.map +1 -0
  260. package/dist/lib/platformApi.js +11 -0
  261. package/dist/lib/platformApi.js.map +1 -0
  262. package/dist/lib/pullPerms.d.ts +7 -0
  263. package/dist/lib/pullPerms.d.ts.map +1 -0
  264. package/dist/lib/pullPerms.js +41 -0
  265. package/dist/lib/pullPerms.js.map +1 -0
  266. package/dist/lib/pullSchema.d.ts +12 -0
  267. package/dist/lib/pullSchema.d.ts.map +1 -0
  268. package/dist/lib/pullSchema.js +62 -0
  269. package/dist/lib/pullSchema.js.map +1 -0
  270. package/dist/lib/pushPerms.d.ts +13 -0
  271. package/dist/lib/pushPerms.d.ts.map +1 -0
  272. package/dist/lib/pushPerms.js +54 -0
  273. package/dist/lib/pushPerms.js.map +1 -0
  274. package/dist/lib/pushSchema.d.ts +53 -0
  275. package/dist/lib/pushSchema.d.ts.map +1 -0
  276. package/dist/lib/pushSchema.js +165 -0
  277. package/dist/lib/pushSchema.js.map +1 -0
  278. package/dist/lib/ui.d.ts +18 -0
  279. package/dist/lib/ui.d.ts.map +1 -0
  280. package/dist/lib/ui.js +32 -0
  281. package/dist/lib/ui.js.map +1 -0
  282. package/dist/lib/webhooks.d.ts +27 -0
  283. package/dist/lib/webhooks.d.ts.map +1 -0
  284. package/dist/lib/webhooks.js +95 -0
  285. package/dist/lib/webhooks.js.map +1 -0
  286. package/dist/logging.d.ts +5 -0
  287. package/dist/logging.d.ts.map +1 -0
  288. package/dist/logging.js +25 -0
  289. package/dist/logging.js.map +1 -0
  290. package/dist/old.d.ts +17 -0
  291. package/dist/old.d.ts.map +1 -0
  292. package/dist/old.js +410 -0
  293. package/dist/old.js.map +1 -0
  294. package/dist/program.d.ts +3 -0
  295. package/dist/program.d.ts.map +1 -0
  296. package/dist/program.js +3 -0
  297. package/dist/program.js.map +1 -0
  298. package/dist/renderSchemaPlan.d.ts +19 -0
  299. package/dist/renderSchemaPlan.d.ts.map +1 -0
  300. package/dist/renderSchemaPlan.js +220 -0
  301. package/dist/renderSchemaPlan.js.map +1 -0
  302. package/dist/ui/index.d.ts +292 -0
  303. package/dist/ui/index.d.ts.map +1 -0
  304. package/dist/ui/index.js +1296 -0
  305. package/dist/ui/index.js.map +1 -0
  306. package/dist/ui/lib.d.ts +124 -0
  307. package/dist/ui/lib.d.ts.map +1 -0
  308. package/dist/ui/lib.js +333 -0
  309. package/dist/ui/lib.js.map +1 -0
  310. package/dist/util/findConfigCandidates.d.ts +13 -0
  311. package/dist/util/findConfigCandidates.d.ts.map +1 -0
  312. package/dist/util/findConfigCandidates.js +211 -0
  313. package/dist/util/findConfigCandidates.js.map +1 -0
  314. package/dist/util/fs.d.ts +4 -0
  315. package/dist/util/fs.d.ts.map +1 -0
  316. package/dist/util/fs.js +22 -0
  317. package/dist/util/fs.js.map +1 -0
  318. package/dist/util/getAppName.d.ts +5 -0
  319. package/dist/util/getAppName.d.ts.map +1 -0
  320. package/dist/util/getAppName.js +14 -0
  321. package/dist/util/getAppName.js.map +1 -0
  322. package/dist/util/instantConfig.d.ts +9 -0
  323. package/dist/util/instantConfig.d.ts.map +1 -0
  324. package/dist/util/instantConfig.js +13 -0
  325. package/dist/util/instantConfig.js.map +1 -0
  326. package/dist/util/isHeadlessEnvironment.d.ts +4 -0
  327. package/dist/util/isHeadlessEnvironment.d.ts.map +1 -0
  328. package/dist/util/isHeadlessEnvironment.js +11 -0
  329. package/dist/util/isHeadlessEnvironment.js.map +1 -0
  330. package/dist/util/loadConfig.d.ts +3 -0
  331. package/dist/util/loadConfig.d.ts.map +1 -0
  332. package/dist/util/loadConfig.js +72 -0
  333. package/dist/util/loadConfig.js.map +1 -0
  334. package/dist/util/loadEnv.d.ts +2 -0
  335. package/dist/util/loadEnv.d.ts.map +1 -0
  336. package/dist/util/loadEnv.js +10 -0
  337. package/dist/util/loadEnv.js.map +1 -0
  338. package/dist/util/mergeSchema.d.ts +10 -0
  339. package/dist/util/mergeSchema.d.ts.map +1 -0
  340. package/dist/util/mergeSchema.js +338 -0
  341. package/dist/util/mergeSchema.js.map +1 -0
  342. package/dist/util/projectDir.d.ts +7 -0
  343. package/dist/util/projectDir.d.ts.map +1 -0
  344. package/dist/util/projectDir.js +43 -0
  345. package/dist/util/projectDir.js.map +1 -0
  346. package/dist/util/renamePrompt.d.ts +15 -0
  347. package/dist/util/renamePrompt.d.ts.map +1 -0
  348. package/dist/util/renamePrompt.js +57 -0
  349. package/dist/util/renamePrompt.js.map +1 -0
  350. package/dist/util/sdkInstallSpec.d.ts +13 -0
  351. package/dist/util/sdkInstallSpec.d.ts.map +1 -0
  352. package/dist/util/sdkInstallSpec.js +37 -0
  353. package/dist/util/sdkInstallSpec.js.map +1 -0
  354. package/dist/version.d.ts +3 -0
  355. package/dist/version.d.ts.map +1 -0
  356. package/dist/version.js +3 -0
  357. package/dist/version.js.map +1 -0
  358. package/package.json +91 -3
  359. package/src/auth/index.ts +125 -0
  360. package/src/commands/app/delete.ts +82 -0
  361. package/src/commands/app/list.ts +44 -0
  362. package/src/commands/auth/client/add.ts +744 -0
  363. package/src/commands/auth/client/delete.ts +60 -0
  364. package/src/commands/auth/client/list.ts +60 -0
  365. package/src/commands/auth/client/shared.ts +190 -0
  366. package/src/commands/auth/client/update.ts +830 -0
  367. package/src/commands/auth/email/pull.ts +143 -0
  368. package/src/commands/auth/email/push.ts +94 -0
  369. package/src/commands/auth/email/resend.ts +8 -0
  370. package/src/commands/auth/email/reset.ts +37 -0
  371. package/src/commands/auth/email/status.ts +154 -0
  372. package/src/commands/auth/email/verify.ts +20 -0
  373. package/src/commands/auth/origin/add.ts +237 -0
  374. package/src/commands/auth/origin/delete.ts +50 -0
  375. package/src/commands/auth/origin/list.ts +66 -0
  376. package/src/commands/backup/download.ts +231 -0
  377. package/src/commands/backup/list.ts +94 -0
  378. package/src/commands/claim.ts +31 -0
  379. package/src/commands/explorer.ts +21 -0
  380. package/src/commands/info.ts +57 -0
  381. package/src/commands/init.ts +60 -0
  382. package/src/commands/initWithoutFiles.ts +107 -0
  383. package/src/commands/login.ts +62 -0
  384. package/src/commands/logout.ts +22 -0
  385. package/src/commands/pull.ts +22 -0
  386. package/src/commands/push.ts +25 -0
  387. package/src/commands/query.ts +61 -0
  388. package/src/commands/webhooks/add.ts +111 -0
  389. package/src/commands/webhooks/delete.ts +23 -0
  390. package/src/commands/webhooks/disable.ts +24 -0
  391. package/src/commands/webhooks/enable.ts +24 -0
  392. package/src/commands/webhooks/events/list.ts +38 -0
  393. package/src/commands/webhooks/events/payload.ts +56 -0
  394. package/src/commands/webhooks/events/resend.ts +66 -0
  395. package/src/commands/webhooks/list.ts +41 -0
  396. package/src/commands/webhooks/shared.ts +339 -0
  397. package/src/commands/webhooks/update.ts +276 -0
  398. package/src/context/authToken.ts +134 -0
  399. package/src/context/currentApp.ts +301 -0
  400. package/src/context/globalOpts.ts +22 -0
  401. package/src/context/platformApi.ts +35 -0
  402. package/src/context/projectInfo.ts +219 -0
  403. package/src/errors.ts +7 -0
  404. package/src/index.ts +1212 -0
  405. package/src/layer.ts +211 -0
  406. package/src/lib/args.ts +453 -0
  407. package/src/lib/backupDownload.ts +188 -0
  408. package/src/lib/backups.ts +33 -0
  409. package/src/lib/config.ts +73 -0
  410. package/src/lib/createApp.ts +28 -0
  411. package/src/lib/email.ts +93 -0
  412. package/src/lib/handleEnv.ts +122 -0
  413. package/src/lib/http.ts +128 -0
  414. package/src/lib/login.ts +48 -0
  415. package/src/lib/oauth.ts +310 -0
  416. package/src/lib/platformApi.ts +11 -0
  417. package/src/lib/pullPerms.ts +50 -0
  418. package/src/lib/pullSchema.ts +95 -0
  419. package/src/lib/pushPerms.ts +80 -0
  420. package/src/lib/pushSchema.ts +248 -0
  421. package/src/lib/ui.ts +48 -0
  422. package/src/lib/webhooks.ts +118 -0
  423. package/src/logging.ts +41 -0
  424. package/src/old.js +487 -0
  425. package/src/program.ts +3 -0
  426. package/src/renderSchemaPlan.ts +324 -0
  427. package/src/ui/index.ts +1615 -0
  428. package/src/ui/lib.ts +424 -0
  429. package/src/util/findConfigCandidates.ts +262 -0
  430. package/src/util/fs.ts +26 -0
  431. package/src/util/getAppName.ts +14 -0
  432. package/src/util/instantConfig.ts +21 -0
  433. package/src/util/isHeadlessEnvironment.ts +15 -0
  434. package/src/util/loadConfig.ts +93 -0
  435. package/src/util/loadEnv.ts +11 -0
  436. package/src/util/mergeSchema.ts +374 -0
  437. package/src/util/projectDir.ts +54 -0
  438. package/src/util/renamePrompt.ts +79 -0
  439. package/src/util/sdkInstallSpec.ts +45 -0
  440. package/src/version.js +3 -0
  441. package/tsconfig.build.json +20 -0
  442. package/tsconfig.json +23 -0
  443. package/vitest.config.ts +22 -0
@@ -0,0 +1,143 @@
1
+ import { HttpClientResponse, Path } from '@effect/platform';
2
+ import { Effect, Schema } from 'effect';
3
+ import { ProjectInfo } from '../../../context/projectInfo.ts';
4
+ import { BadArgsError } from '../../../errors.ts';
5
+ import { readLocalEmailFile } from '../../../old.js';
6
+ import { UI } from '../../../ui/index.ts';
7
+ import { getEmailPathToWrite } from '../../../util/findConfigCandidates.ts';
8
+ import { writeTypescript } from '../../../lib/pullSchema.ts';
9
+ import { promptOk } from '../../../lib/ui.ts';
10
+ import { getEmailTemplateStatus, type EmailTemplateInfo } from './status.ts';
11
+ import type { authEmailPullDef, OptsFromCommand } from '../../../index.ts';
12
+ import { InstantHttp } from '../../../lib/http.ts';
13
+ import { getAppName } from '../../../util/getAppName.ts';
14
+ import type { EmailConfig } from '../../../lib/email.ts';
15
+
16
+ export const authEmailPullCmd = Effect.fn(function* (
17
+ opts: OptsFromCommand<typeof authEmailPullDef>,
18
+ ) {
19
+ yield* pullEmail(opts.file);
20
+ });
21
+
22
+ export type EmailConfig = (typeof EmailConfig.Type)['authEmail'];
23
+
24
+ type WriteEmailTemplateOpts = {
25
+ emailPath?: string;
26
+ confirmOverwrite?: boolean;
27
+ };
28
+
29
+ const pullEmail = (emailPath?: string) =>
30
+ Effect.gen(function* () {
31
+ yield* Effect.log('Pulling email template...');
32
+
33
+ const info = yield* getEmailTemplateStatus;
34
+
35
+ const emailConfig = info
36
+ ? infoToEmailConfig(info)
37
+ : yield* getDefaultEmailTemplate;
38
+
39
+ yield* writeEmailTemplate(emailConfig, { emailPath });
40
+ });
41
+
42
+ export const writeEmailTemplate = (
43
+ emailConfig: EmailConfig,
44
+ { emailPath, confirmOverwrite = true }: WriteEmailTemplateOpts = {},
45
+ ) =>
46
+ Effect.gen(function* () {
47
+ const prevEmailFile = yield* Effect.tryPromise({
48
+ try: () => readLocalEmailFile(emailPath),
49
+ catch: (e) =>
50
+ BadArgsError.make({
51
+ message: `Error reading local email file: ${e}`,
52
+ }),
53
+ });
54
+
55
+ const shortEmailPath =
56
+ prevEmailFile?.path ?? emailPath ?? getEmailPathToWrite();
57
+
58
+ if (prevEmailFile && confirmOverwrite) {
59
+ const shouldContinue = yield* promptOk({
60
+ promptText: `This will overwrite your local ${shortEmailPath} file, OK to proceed?`,
61
+ modifyOutput: UI.modifiers.yPadding,
62
+ inline: true,
63
+ });
64
+ if (!shouldContinue) {
65
+ yield* Effect.log('Cancelled email pull');
66
+ return;
67
+ }
68
+ }
69
+
70
+ const path = yield* Path.Path;
71
+ const { pkgDir } = yield* ProjectInfo;
72
+ const fullEmailPath = shortEmailPath.startsWith('/')
73
+ ? shortEmailPath
74
+ : path.join(pkgDir, shortEmailPath);
75
+
76
+ const typescriptFile = yield* generateEmailTypescriptFile(emailConfig);
77
+
78
+ yield* writeTypescript(fullEmailPath, typescriptFile);
79
+ yield* Effect.log('Wrote email template to ' + shortEmailPath);
80
+ });
81
+
82
+ const DefaultEmailTemplateSchema = Schema.Struct({
83
+ subject: Schema.String,
84
+ body: Schema.String,
85
+ 'sender-email': Schema.String.pipe(Schema.optional),
86
+ });
87
+
88
+ export const getDefaultEmailTemplate = Effect.gen(function* () {
89
+ const http = yield* InstantHttp;
90
+ const template = yield* http
91
+ .get('/dash/default-email-template')
92
+ .pipe(
93
+ Effect.flatMap(
94
+ HttpClientResponse.schemaBodyJson(DefaultEmailTemplateSchema),
95
+ ),
96
+ );
97
+
98
+ const appName = yield* getAppName;
99
+
100
+ return {
101
+ subject: template.subject,
102
+ senderName: appName,
103
+ senderEmail: template['sender-email'],
104
+ body: template.body,
105
+ };
106
+ });
107
+
108
+ const infoToEmailConfig = (info: EmailTemplateInfo) => ({
109
+ subject: info.subject,
110
+ senderName: info.name,
111
+ senderEmail: info.email,
112
+ body: info.body,
113
+ });
114
+
115
+ const generateEmailTypescriptFile = Effect.fn(function* (
116
+ emailConfig: EmailConfig,
117
+ ) {
118
+ const senderEmail = emailConfig.senderEmail
119
+ ? JSON.stringify(emailConfig.senderEmail)
120
+ : 'undefined';
121
+
122
+ return `
123
+ // We provide a few dynamic variables for you to use in your email:
124
+ // {code}, the magic code e.g. 123456
125
+ // {app_title}, your app's title, i.e. test-fresh
126
+ // {user_email}, the user's email address, e.g. happyuser@gmail.com
127
+ // {expiration}, the magic code expiration, e.g. 10 minutes
128
+ // Note: {code} is required in both the subject and body.
129
+ const email = {
130
+ authEmail: {
131
+ subject: ${JSON.stringify(emailConfig.subject)},
132
+ senderName: ${JSON.stringify(emailConfig.senderName)},
133
+ senderEmail: ${senderEmail},
134
+ body: ${toTemplateLiteral(emailConfig.body)},
135
+ },
136
+ };
137
+
138
+ export default email;
139
+ `;
140
+ });
141
+
142
+ const toTemplateLiteral = (value: string) =>
143
+ `\`${value.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${')}\``;
@@ -0,0 +1,94 @@
1
+ import { Effect, Schema } from 'effect';
2
+ import type { authEmailPushDef, OptsFromCommand } from '../../../index.ts';
3
+ import {
4
+ getVerification,
5
+ readEmailConfig,
6
+ sendSenderVerification,
7
+ } from '../../../lib/email.ts';
8
+ import { CurrentApp } from '../../../context/currentApp.ts';
9
+ import { InstantHttpAuthed, withCommand } from '../../../lib/http.ts';
10
+ import {
11
+ HttpClient,
12
+ HttpClientRequest,
13
+ HttpClientResponse,
14
+ } from '@effect/platform';
15
+ import boxen from 'boxen';
16
+ import {
17
+ formatSenderVerificationDnsRecords,
18
+ getEmailTemplateStatus,
19
+ } from './status.ts';
20
+ import chalk from 'chalk';
21
+ import { getDefaultEmailTemplate } from './pull.ts';
22
+
23
+ export const authEmailPushCmd = Effect.fn(function* (
24
+ opts: OptsFromCommand<typeof authEmailPushDef>,
25
+ ) {
26
+ const emailConfig = yield* readEmailConfig(opts.file);
27
+ const { appId } = yield* CurrentApp;
28
+ const http = yield* InstantHttpAuthed;
29
+ const authEmail = emailConfig.authEmail;
30
+ const defTemplate = yield* getDefaultEmailTemplate;
31
+ const senderEmail =
32
+ // If the value in the code is the default instant-owned email, remove it from the request
33
+ authEmail.senderEmail === defTemplate.senderEmail
34
+ ? undefined
35
+ : emailConfig.authEmail.senderEmail;
36
+
37
+ yield* http
38
+ .pipe(
39
+ withCommand('auth email push'),
40
+ HttpClient.mapRequestInputEffect(
41
+ HttpClientRequest.bodyJson({
42
+ 'email-type': 'magic-code',
43
+ subject: authEmail.subject,
44
+ body: authEmail.body,
45
+ 'sender-email': senderEmail,
46
+ 'sender-name': authEmail.senderName,
47
+ }),
48
+ ),
49
+ )
50
+ .post(`/dash/apps/${appId}/email_templates`)
51
+ .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));
52
+
53
+ const info = yield* getEmailTemplateStatus;
54
+
55
+ yield* Effect.log(
56
+ [
57
+ chalk.green('Email template saved!'),
58
+ '',
59
+ chalk.bold('Pushed fields:'),
60
+ ` Email type: ${chalk.cyan('magic-code')}`,
61
+ ` Subject: ${chalk.cyan(authEmail.subject)}`,
62
+ ` Sender name: ${chalk.cyan(authEmail.senderName)}`,
63
+ ` Sender email: ${chalk.cyan(senderEmail || '(default)')}`,
64
+ ` Body: ${chalk.cyan(`${authEmail.body.length} characters`)}`,
65
+ ].join('\n'),
66
+ );
67
+
68
+ // Check if verification email needs to be sent
69
+
70
+ if (info?.verification_verified === false) {
71
+ yield* sendSenderVerification;
72
+ yield* Effect.log(
73
+ boxen(
74
+ "We've sent a confirmation email containing a six digit code to verify the sender email address.\nUse instant-cli auth email verify <code> to complete verification.",
75
+ {
76
+ borderColor: 'yellow',
77
+ padding: { right: 1, left: 1 },
78
+ },
79
+ ),
80
+ );
81
+ }
82
+
83
+ if (
84
+ emailConfig.authEmail.senderEmail &&
85
+ emailConfig.authEmail.senderEmail !== defTemplate.senderEmail
86
+ ) {
87
+ const verification = yield* getVerification;
88
+ if (verification.verification) {
89
+ yield* Effect.log(
90
+ formatSenderVerificationDnsRecords(verification.verification),
91
+ );
92
+ }
93
+ }
94
+ });
@@ -0,0 +1,8 @@
1
+ import { Effect } from 'effect';
2
+ import { sendSenderVerification } from '../../../lib/email.ts';
3
+
4
+ export const resendEmailCmd = Effect.gen(function* () {
5
+ yield* sendSenderVerification;
6
+
7
+ yield* Effect.log('Verification email re-sent!');
8
+ });
@@ -0,0 +1,37 @@
1
+ import { HttpClientRequest, HttpClientResponse } from '@effect/platform';
2
+ import { Effect, Schema } from 'effect';
3
+ import { CurrentApp } from '../../../context/currentApp.ts';
4
+ import { InstantHttpAuthed, withCommand } from '../../../lib/http.ts';
5
+ import { getDefaultEmailTemplate, writeEmailTemplate } from './pull.ts';
6
+ import { getEmailTemplateStatus } from './status.ts';
7
+
8
+ export const authEmailResetCmd = Effect.fn(function* () {
9
+ const { appId } = yield* CurrentApp;
10
+ const http = (yield* InstantHttpAuthed).pipe(withCommand('auth email reset'));
11
+
12
+ const status = yield* getEmailTemplateStatus;
13
+
14
+ if (!status) {
15
+ yield* Effect.log(
16
+ 'No email template configured. Resetting local email template.',
17
+ );
18
+ } else {
19
+ yield* http
20
+ .execute(
21
+ HttpClientRequest.del(
22
+ `/dash/apps/${appId}/email_templates/${status.id}`,
23
+ ),
24
+ )
25
+ .pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Any)));
26
+ }
27
+
28
+ const defaultConfig = yield* getDefaultEmailTemplate;
29
+
30
+ yield* writeEmailTemplate(defaultConfig, {
31
+ confirmOverwrite: false,
32
+ });
33
+
34
+ yield* Effect.log(
35
+ 'instant.email.ts file reset to default. To apply this change, run instant-cli auth email push',
36
+ );
37
+ });
@@ -0,0 +1,154 @@
1
+ import boxen from 'boxen';
2
+ import chalk from 'chalk';
3
+ import { Effect, Option, Schema } from 'effect';
4
+ import { CurrentApp } from '../../../context/currentApp.ts';
5
+ import type { authEmailStatusDef, OptsFromCommand } from '../../../index.ts';
6
+ import { InstantHttpAuthed } from '../../../lib/http.ts';
7
+ import { HttpClientResponse } from '@effect/platform';
8
+ import { getVerification } from '../../../lib/email.ts';
9
+
10
+ const formatValue = (value: string | number | null | undefined) =>
11
+ value ?? 'n/a';
12
+
13
+ const formatVerified = (value: boolean | null | undefined) => {
14
+ if (value === true) {
15
+ return chalk.green('verified');
16
+ }
17
+ if (value === false) {
18
+ return chalk.yellow('pending');
19
+ }
20
+ return 'n/a';
21
+ };
22
+
23
+ const formatDnsRecord = (type: string, name: string, value: string) =>
24
+ [chalk.bold(type), `Name: ${name}`, `Value: ${value}`].join('\n');
25
+
26
+ export const formatSenderVerificationDnsRecords = (verification: {
27
+ Confirmed: boolean;
28
+ DKIMPendingHost: string;
29
+ DKIMPendingTextValue: string;
30
+ ReturnPathDomain: string;
31
+ ReturnPathDomainCNAMEValue: string;
32
+ }) =>
33
+ boxen(
34
+ [
35
+ chalk.bold('Add these DNS records to verify your sender email:'),
36
+ '',
37
+ formatDnsRecord(
38
+ 'TXT',
39
+ verification.DKIMPendingHost,
40
+ verification.DKIMPendingTextValue,
41
+ ),
42
+ '',
43
+ formatDnsRecord(
44
+ 'CNAME',
45
+ verification.ReturnPathDomain,
46
+ verification.ReturnPathDomainCNAMEValue,
47
+ ),
48
+ ].join('\n'),
49
+ {
50
+ borderColor: verification.Confirmed ? 'green' : 'yellow',
51
+ padding: { right: 1, left: 1 },
52
+ },
53
+ );
54
+
55
+ export const EmailTemplateInfoSchema = Schema.Struct({
56
+ id: Schema.String,
57
+ email: Schema.String.pipe(Schema.NullishOr),
58
+ name: Schema.String,
59
+ sender_id: Schema.String.pipe(Schema.NullishOr),
60
+ app_id: Schema.String,
61
+ postmark_id: Schema.Number.pipe(Schema.NullishOr),
62
+ verification_verified: Schema.Boolean.pipe(Schema.NullishOr),
63
+ verification_id: Schema.String.pipe(Schema.NullishOr),
64
+ email_type: Schema.String,
65
+ body: Schema.String,
66
+ subject: Schema.String,
67
+ });
68
+
69
+ export type EmailTemplateInfo = typeof EmailTemplateInfoSchema.Type;
70
+
71
+ export const EmailTemplateSchema = Schema.Union(
72
+ Schema.Struct({
73
+ info: EmailTemplateInfoSchema.pipe(Schema.NullishOr),
74
+ }),
75
+ Schema.Null,
76
+ );
77
+
78
+ export const getEmailTemplateStatus = Effect.gen(function* () {
79
+ const { appId } = yield* CurrentApp;
80
+ const http = yield* InstantHttpAuthed;
81
+
82
+ const app = yield* http
83
+ .get(`/dash/apps/${appId}/email_status`)
84
+ .pipe(
85
+ Effect.flatMap(HttpClientResponse.schemaBodyJson(EmailTemplateSchema)),
86
+ );
87
+ return app?.info;
88
+ });
89
+
90
+ export const emailStatusCmd = Effect.fn(function* (
91
+ opts: OptsFromCommand<typeof authEmailStatusDef>,
92
+ ) {
93
+ const info = yield* getEmailTemplateStatus;
94
+
95
+ if (!info) {
96
+ yield* Effect.log(
97
+ "No custom magic code email associated with this app.\nTo add one, run 'instant-cli auth email pull', edit the file, then run 'instant-cli auth email push'",
98
+ );
99
+ return;
100
+ }
101
+
102
+ const verification = yield* Option.match(
103
+ Option.fromNullable(info.sender_id),
104
+ {
105
+ onNone: () => Effect.succeed(null),
106
+ onSome: () => getVerification,
107
+ },
108
+ );
109
+
110
+ if (opts.json) {
111
+ const fullInfo = verification
112
+ ? {
113
+ ...info,
114
+ verification: verification,
115
+ }
116
+ : info;
117
+
118
+ yield* Effect.log(JSON.stringify(fullInfo, null, 2));
119
+ return;
120
+ }
121
+
122
+ yield* Effect.log(chalk.cyan('Custom Magic Code Email'));
123
+ yield* Effect.log(` Sender name: ${info.name}`);
124
+ yield* Effect.log(` Sender email: ${formatValue(info.email)}`);
125
+ yield* Effect.log(` Subject: ${info.subject}`);
126
+ yield* Effect.log(` Body: ${info.body}`);
127
+
128
+ if (verification) {
129
+ yield* Effect.log(
130
+ '\n' +
131
+ boxen(
132
+ [
133
+ `Instant verified: ${formatVerified(verification.instant['verified?'])}`,
134
+ `Postmark verified: ${formatVerified(verification.verification?.Confirmed)}`,
135
+ ].join('\n'),
136
+ {
137
+ title: 'Custom Sender Verification',
138
+ borderColor:
139
+ verification.instant['verified?'] &&
140
+ verification.verification?.Confirmed
141
+ ? 'green'
142
+ : 'yellow',
143
+ padding: { right: 1, left: 1 },
144
+ },
145
+ ),
146
+ );
147
+
148
+ if (verification.verification) {
149
+ yield* Effect.log(
150
+ '\n' + formatSenderVerificationDnsRecords(verification.verification),
151
+ );
152
+ }
153
+ }
154
+ });
@@ -0,0 +1,20 @@
1
+ import { Effect } from 'effect';
2
+ import type { authEmailVerifyDef, OptsFromCommand } from '../../../index.ts';
3
+ import { getVerification, submitVerification } from '../../../lib/email.ts';
4
+
5
+ export const verifyCmd = Effect.fn(function* (
6
+ code: string,
7
+ _opts: OptsFromCommand<typeof authEmailVerifyDef>,
8
+ ) {
9
+ yield* submitVerification(code);
10
+
11
+ // get verification status
12
+ const verificationInfo = yield* getVerification;
13
+
14
+ if (
15
+ verificationInfo.instant['verified?'] &&
16
+ verificationInfo.verification?.Confirmed
17
+ ) {
18
+ yield* Effect.log('Verification successful for both Postmark and Instant!');
19
+ }
20
+ });
@@ -0,0 +1,237 @@
1
+ import { Effect, Match, Option, Schema } from 'effect';
2
+ import type { authOriginAddDef, OptsFromCommand } from '../../../index.ts';
3
+ import { BadArgsError } from '../../../errors.ts';
4
+ import { GlobalOpts } from '../../../context/globalOpts.ts';
5
+ import { Args } from '../../../lib/args.ts';
6
+ import { runUIEffect } from '../../../lib/ui.ts';
7
+ import { addAuthorizedOrigin } from '../../../lib/oauth.ts';
8
+ import { UI } from '../../../ui/index.ts';
9
+ import chalk from 'chalk';
10
+ import boxen from 'boxen';
11
+ import { originDisplay, originSource } from './list.ts';
12
+
13
+ export const OriginTypeSchema = Schema.Literal(
14
+ 'website',
15
+ 'vercel',
16
+ 'netlify',
17
+ 'custom-scheme',
18
+ );
19
+
20
+ type OriginParams = string[];
21
+
22
+ type Validated =
23
+ | { type: 'success'; params: OriginParams }
24
+ | { type: 'error'; message: string };
25
+
26
+ const validateGenericUrl = (input: string): Validated => {
27
+ const trimmed = input.trim();
28
+ try {
29
+ const url = new URL(trimmed);
30
+ const host = url.host;
31
+ if (!host) {
32
+ throw new Error('missing host');
33
+ }
34
+ if (host.split('.').length === 1 && !url.port) {
35
+ throw new Error('invalid url');
36
+ }
37
+ return { type: 'success', params: [host] };
38
+ } catch {
39
+ if (!trimmed.startsWith('http')) {
40
+ return validateGenericUrl(`http://${trimmed}`);
41
+ }
42
+ return { type: 'error', message: 'Invalid URL.' };
43
+ }
44
+ };
45
+
46
+ const validateNetlifyUrl = (input: string): Validated => {
47
+ const trimmed = input.trim();
48
+ if (!trimmed) {
49
+ return { type: 'error', message: 'Netlify site name is required.' };
50
+ }
51
+ return { type: 'success', params: [trimmed] };
52
+ };
53
+
54
+ const validateVercelUrl = (input: string): Validated => {
55
+ const trimmed = input.trim();
56
+ if (!trimmed) {
57
+ return { type: 'error', message: 'Vercel project name is required.' };
58
+ }
59
+ return { type: 'success', params: ['vercel.app', trimmed] };
60
+ };
61
+
62
+ const validateCustomScheme = (input: string): Validated => {
63
+ const trimmed = input.trim();
64
+ try {
65
+ const url = new URL(trimmed);
66
+ const scheme = url.protocol.slice(0, -1);
67
+ return { type: 'success', params: [scheme] };
68
+ } catch {
69
+ return { type: 'error', message: 'Invalid scheme.' };
70
+ }
71
+ };
72
+
73
+ const addOriginHandler = Effect.fn(function* (
74
+ type: Schema.Schema.Type<typeof OriginTypeSchema>,
75
+ validated: { params: OriginParams },
76
+ ) {
77
+ const response = yield* addAuthorizedOrigin({
78
+ service: type === 'website' ? 'generic' : type,
79
+ params: validated.params,
80
+ });
81
+
82
+ yield* Effect.log(
83
+ '\n' +
84
+ boxen(
85
+ [
86
+ `Origin added: ${originDisplay(response.origin)}`,
87
+ `Type: ${originSource(response.origin)}`,
88
+ `ID: ${response.origin.id}`,
89
+ ].join('\n'),
90
+ { dimBorder: true, padding: { right: 1, left: 1 } },
91
+ ),
92
+ );
93
+ });
94
+
95
+ const handleGenericOrigin = Effect.fn(function* (
96
+ opts: Record<string, unknown>,
97
+ ) {
98
+ const url = yield* Args.text(opts, 'url').pipe(
99
+ Args.prompt({
100
+ prompt: 'Website URL:',
101
+ placeholder: 'example.com',
102
+ modifyOutput: UI.modifiers.piped([
103
+ UI.modifiers.topPadding,
104
+ UI.modifiers.dimOnComplete,
105
+ ]),
106
+ }),
107
+ Args.required(),
108
+ );
109
+
110
+ const validated = validateGenericUrl(url);
111
+ if (validated.type === 'error') {
112
+ return yield* BadArgsError.make({ message: validated.message });
113
+ }
114
+
115
+ yield* addOriginHandler('website', validated);
116
+ });
117
+
118
+ const handleVercelOrigin = Effect.fn(function* (opts: Record<string, unknown>) {
119
+ const project = yield* Args.text(opts, 'project').pipe(
120
+ Args.prompt({
121
+ prompt: 'Vercel project name:',
122
+ placeholder: 'vercel-project-name',
123
+ modifyOutput: UI.modifiers.piped([
124
+ UI.modifiers.topPadding,
125
+ UI.modifiers.dimOnComplete,
126
+ ]),
127
+ }),
128
+ Args.required(),
129
+ );
130
+
131
+ const validated = validateVercelUrl(project);
132
+ if (validated.type === 'error') {
133
+ return yield* BadArgsError.make({ message: validated.message });
134
+ }
135
+
136
+ yield* addOriginHandler('vercel', validated);
137
+ });
138
+
139
+ const handleNetlifyOrigin = Effect.fn(function* (
140
+ opts: Record<string, unknown>,
141
+ ) {
142
+ const site = yield* Args.text(opts, 'site').pipe(
143
+ Args.prompt({
144
+ prompt: 'Netlify site name:',
145
+ placeholder: 'netlify-site-name',
146
+ modifyOutput: UI.modifiers.piped([
147
+ UI.modifiers.topPadding,
148
+ UI.modifiers.dimOnComplete,
149
+ ]),
150
+ }),
151
+ Args.required(),
152
+ );
153
+
154
+ const validated = validateNetlifyUrl(site);
155
+ if (validated.type === 'error') {
156
+ return yield* BadArgsError.make({ message: validated.message });
157
+ }
158
+
159
+ yield* addOriginHandler('netlify', validated);
160
+ });
161
+
162
+ const handleCustomSchemeOrigin = Effect.fn(function* (
163
+ opts: Record<string, unknown>,
164
+ ) {
165
+ const scheme = yield* Args.text(opts, 'scheme').pipe(
166
+ Args.prompt({
167
+ prompt: 'App scheme:',
168
+ placeholder: 'app-scheme://',
169
+ modifyOutput: UI.modifiers.piped([
170
+ UI.modifiers.topPadding,
171
+ UI.modifiers.dimOnComplete,
172
+ ]),
173
+ }),
174
+ Args.required(),
175
+ );
176
+
177
+ const validated = validateCustomScheme(scheme);
178
+ if (validated.type === 'error') {
179
+ return yield* BadArgsError.make({ message: validated.message });
180
+ }
181
+
182
+ yield* addOriginHandler('custom-scheme', validated);
183
+ });
184
+
185
+ export const authOriginAddCmd = Effect.fn(
186
+ function* (
187
+ opts: OptsFromCommand<typeof authOriginAddDef> & Record<string, unknown>,
188
+ ) {
189
+ const { yes } = yield* GlobalOpts;
190
+ if (!opts.type && yes) {
191
+ return yield* BadArgsError.make({
192
+ message: `Missing required value for --type. Expected one of: ${OriginTypeSchema.literals.join(', ')}`,
193
+ });
194
+ }
195
+ const originType = yield* Option.fromNullable(opts.type).pipe(
196
+ Effect.catchTag('NoSuchElementException', () =>
197
+ runUIEffect(
198
+ new UI.Select({
199
+ options: [
200
+ { label: 'Website', value: 'website' },
201
+ { label: 'Vercel previews', value: 'vercel' },
202
+ { label: 'Netlify previews', value: 'netlify' },
203
+ { label: 'App scheme', value: 'custom-scheme' },
204
+ ],
205
+ promptText: 'Select an origin type:',
206
+ modifyOutput: UI.modifiers.piped([UI.modifiers.dimOnComplete]),
207
+ }),
208
+ ),
209
+ ),
210
+ Effect.andThen((s) => Schema.decodeUnknown(OriginTypeSchema)(s)),
211
+ Effect.catchTag('ParseError', () =>
212
+ BadArgsError.make({
213
+ message: `Invalid origin type, must be one of: ${OriginTypeSchema.literals.join(', ')}`,
214
+ }),
215
+ ),
216
+ );
217
+
218
+ yield* Match.value(originType).pipe(
219
+ Match.withReturnType<Effect.Effect<void, any, any>>(),
220
+ Match.when('website', () => handleGenericOrigin(opts)),
221
+ Match.when('vercel', () => handleVercelOrigin(opts)),
222
+ Match.when('netlify', () => handleNetlifyOrigin(opts)),
223
+ Match.when('custom-scheme', () => handleCustomSchemeOrigin(opts)),
224
+ Match.exhaustive,
225
+ );
226
+ },
227
+ Effect.catchTag('BadArgsError', (e) =>
228
+ Effect.gen(function* () {
229
+ yield* Effect.logError(e.message);
230
+ yield* Effect.log(
231
+ chalk.dim(
232
+ 'hint: run `instant-cli auth origin add --help` for available arguments',
233
+ ),
234
+ );
235
+ }),
236
+ ),
237
+ );