resend-cli 1.0.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/.claude/settings.local.json +5 -0
  2. package/.claude/worktrees/emails-list/.claude/settings.local.json +5 -0
  3. package/.claude/worktrees/emails-list/.github/scripts/pr-title-check.js +34 -0
  4. package/.claude/worktrees/emails-list/.github/workflows/ci.yml +32 -0
  5. package/.claude/worktrees/emails-list/.github/workflows/pr-title-check.yml +13 -0
  6. package/.claude/worktrees/emails-list/.github/workflows/release.yml +93 -0
  7. package/.claude/worktrees/emails-list/CHANGELOG.md +31 -0
  8. package/.claude/worktrees/emails-list/LICENSE +21 -0
  9. package/.claude/worktrees/emails-list/README.md +424 -0
  10. package/.claude/worktrees/emails-list/biome.json +36 -0
  11. package/.claude/worktrees/emails-list/bun.lock +76 -0
  12. package/.claude/worktrees/emails-list/bunfig.toml +2 -0
  13. package/.claude/worktrees/emails-list/install.ps1 +140 -0
  14. package/.claude/worktrees/emails-list/install.sh +301 -0
  15. package/.claude/worktrees/emails-list/package.json +43 -0
  16. package/.claude/worktrees/emails-list/renovate.json +6 -0
  17. package/.claude/worktrees/emails-list/src/cli.ts +74 -0
  18. package/.claude/worktrees/emails-list/src/commands/api-keys/create.ts +114 -0
  19. package/.claude/worktrees/emails-list/src/commands/api-keys/delete.ts +47 -0
  20. package/.claude/worktrees/emails-list/src/commands/api-keys/index.ts +26 -0
  21. package/.claude/worktrees/emails-list/src/commands/api-keys/list.ts +35 -0
  22. package/.claude/worktrees/emails-list/src/commands/api-keys/utils.ts +8 -0
  23. package/.claude/worktrees/emails-list/src/commands/auth/index.ts +20 -0
  24. package/.claude/worktrees/emails-list/src/commands/auth/login.ts +207 -0
  25. package/.claude/worktrees/emails-list/src/commands/auth/logout.ts +105 -0
  26. package/.claude/worktrees/emails-list/src/commands/broadcasts/create.ts +196 -0
  27. package/.claude/worktrees/emails-list/src/commands/broadcasts/delete.ts +46 -0
  28. package/.claude/worktrees/emails-list/src/commands/broadcasts/get.ts +59 -0
  29. package/.claude/worktrees/emails-list/src/commands/broadcasts/index.ts +43 -0
  30. package/.claude/worktrees/emails-list/src/commands/broadcasts/list.ts +60 -0
  31. package/.claude/worktrees/emails-list/src/commands/broadcasts/send.ts +56 -0
  32. package/.claude/worktrees/emails-list/src/commands/broadcasts/update.ts +95 -0
  33. package/.claude/worktrees/emails-list/src/commands/broadcasts/utils.ts +35 -0
  34. package/.claude/worktrees/emails-list/src/commands/contact-properties/create.ts +118 -0
  35. package/.claude/worktrees/emails-list/src/commands/contact-properties/delete.ts +48 -0
  36. package/.claude/worktrees/emails-list/src/commands/contact-properties/get.ts +46 -0
  37. package/.claude/worktrees/emails-list/src/commands/contact-properties/index.ts +48 -0
  38. package/.claude/worktrees/emails-list/src/commands/contact-properties/list.ts +68 -0
  39. package/.claude/worktrees/emails-list/src/commands/contact-properties/update.ts +88 -0
  40. package/.claude/worktrees/emails-list/src/commands/contact-properties/utils.ts +17 -0
  41. package/.claude/worktrees/emails-list/src/commands/contacts/add-segment.ts +78 -0
  42. package/.claude/worktrees/emails-list/src/commands/contacts/create.ts +122 -0
  43. package/.claude/worktrees/emails-list/src/commands/contacts/delete.ts +49 -0
  44. package/.claude/worktrees/emails-list/src/commands/contacts/get.ts +53 -0
  45. package/.claude/worktrees/emails-list/src/commands/contacts/index.ts +58 -0
  46. package/.claude/worktrees/emails-list/src/commands/contacts/list.ts +57 -0
  47. package/.claude/worktrees/emails-list/src/commands/contacts/remove-segment.ts +48 -0
  48. package/.claude/worktrees/emails-list/src/commands/contacts/segments.ts +39 -0
  49. package/.claude/worktrees/emails-list/src/commands/contacts/topics.ts +45 -0
  50. package/.claude/worktrees/emails-list/src/commands/contacts/update-topics.ts +90 -0
  51. package/.claude/worktrees/emails-list/src/commands/contacts/update.ts +77 -0
  52. package/.claude/worktrees/emails-list/src/commands/contacts/utils.ts +119 -0
  53. package/.claude/worktrees/emails-list/src/commands/doctor.ts +298 -0
  54. package/.claude/worktrees/emails-list/src/commands/domains/create.ts +83 -0
  55. package/.claude/worktrees/emails-list/src/commands/domains/delete.ts +42 -0
  56. package/.claude/worktrees/emails-list/src/commands/domains/get.ts +47 -0
  57. package/.claude/worktrees/emails-list/src/commands/domains/index.ts +35 -0
  58. package/.claude/worktrees/emails-list/src/commands/domains/list.ts +53 -0
  59. package/.claude/worktrees/emails-list/src/commands/domains/update.ts +75 -0
  60. package/.claude/worktrees/emails-list/src/commands/domains/utils.ts +44 -0
  61. package/.claude/worktrees/emails-list/src/commands/domains/verify.ts +38 -0
  62. package/.claude/worktrees/emails-list/src/commands/emails/batch.ts +140 -0
  63. package/.claude/worktrees/emails-list/src/commands/emails/index.ts +28 -0
  64. package/.claude/worktrees/emails-list/src/commands/emails/list.ts +73 -0
  65. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachment.ts +55 -0
  66. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachments.ts +68 -0
  67. package/.claude/worktrees/emails-list/src/commands/emails/receiving/get.ts +58 -0
  68. package/.claude/worktrees/emails-list/src/commands/emails/receiving/index.ts +28 -0
  69. package/.claude/worktrees/emails-list/src/commands/emails/receiving/list.ts +59 -0
  70. package/.claude/worktrees/emails-list/src/commands/emails/receiving/utils.ts +38 -0
  71. package/.claude/worktrees/emails-list/src/commands/emails/send.ts +189 -0
  72. package/.claude/worktrees/emails-list/src/commands/open.ts +24 -0
  73. package/.claude/worktrees/emails-list/src/commands/segments/create.ts +50 -0
  74. package/.claude/worktrees/emails-list/src/commands/segments/delete.ts +47 -0
  75. package/.claude/worktrees/emails-list/src/commands/segments/get.ts +38 -0
  76. package/.claude/worktrees/emails-list/src/commands/segments/index.ts +36 -0
  77. package/.claude/worktrees/emails-list/src/commands/segments/list.ts +58 -0
  78. package/.claude/worktrees/emails-list/src/commands/segments/utils.ts +7 -0
  79. package/.claude/worktrees/emails-list/src/commands/teams/index.ts +10 -0
  80. package/.claude/worktrees/emails-list/src/commands/teams/list.ts +35 -0
  81. package/.claude/worktrees/emails-list/src/commands/teams/remove.ts +83 -0
  82. package/.claude/worktrees/emails-list/src/commands/teams/switch.ts +73 -0
  83. package/.claude/worktrees/emails-list/src/commands/topics/create.ts +73 -0
  84. package/.claude/worktrees/emails-list/src/commands/topics/delete.ts +47 -0
  85. package/.claude/worktrees/emails-list/src/commands/topics/get.ts +42 -0
  86. package/.claude/worktrees/emails-list/src/commands/topics/index.ts +42 -0
  87. package/.claude/worktrees/emails-list/src/commands/topics/list.ts +34 -0
  88. package/.claude/worktrees/emails-list/src/commands/topics/update.ts +59 -0
  89. package/.claude/worktrees/emails-list/src/commands/topics/utils.ts +16 -0
  90. package/.claude/worktrees/emails-list/src/commands/webhooks/create.ts +128 -0
  91. package/.claude/worktrees/emails-list/src/commands/webhooks/delete.ts +49 -0
  92. package/.claude/worktrees/emails-list/src/commands/webhooks/get.ts +42 -0
  93. package/.claude/worktrees/emails-list/src/commands/webhooks/index.ts +44 -0
  94. package/.claude/worktrees/emails-list/src/commands/webhooks/list.ts +55 -0
  95. package/.claude/worktrees/emails-list/src/commands/webhooks/update.ts +83 -0
  96. package/.claude/worktrees/emails-list/src/commands/webhooks/utils.ts +36 -0
  97. package/.claude/worktrees/emails-list/src/commands/whoami.ts +71 -0
  98. package/.claude/worktrees/emails-list/src/lib/actions.ts +157 -0
  99. package/.claude/worktrees/emails-list/src/lib/client.ts +34 -0
  100. package/.claude/worktrees/emails-list/src/lib/config.ts +211 -0
  101. package/.claude/worktrees/emails-list/src/lib/files.ts +15 -0
  102. package/.claude/worktrees/emails-list/src/lib/help-text.ts +38 -0
  103. package/.claude/worktrees/emails-list/src/lib/output.ts +54 -0
  104. package/.claude/worktrees/emails-list/src/lib/pagination.ts +36 -0
  105. package/.claude/worktrees/emails-list/src/lib/prompts.ts +149 -0
  106. package/.claude/worktrees/emails-list/src/lib/spinner.ts +93 -0
  107. package/.claude/worktrees/emails-list/src/lib/table.ts +57 -0
  108. package/.claude/worktrees/emails-list/src/lib/tty.ts +28 -0
  109. package/.claude/worktrees/emails-list/src/lib/version.ts +4 -0
  110. package/.claude/worktrees/emails-list/tests/commands/api-keys/create.test.ts +195 -0
  111. package/.claude/worktrees/emails-list/tests/commands/api-keys/delete.test.ts +156 -0
  112. package/.claude/worktrees/emails-list/tests/commands/api-keys/list.test.ts +133 -0
  113. package/.claude/worktrees/emails-list/tests/commands/auth/login.test.ts +119 -0
  114. package/.claude/worktrees/emails-list/tests/commands/auth/logout.test.ts +146 -0
  115. package/.claude/worktrees/emails-list/tests/commands/broadcasts/create.test.ts +447 -0
  116. package/.claude/worktrees/emails-list/tests/commands/broadcasts/delete.test.ts +182 -0
  117. package/.claude/worktrees/emails-list/tests/commands/broadcasts/get.test.ts +146 -0
  118. package/.claude/worktrees/emails-list/tests/commands/broadcasts/list.test.ts +196 -0
  119. package/.claude/worktrees/emails-list/tests/commands/broadcasts/send.test.ts +161 -0
  120. package/.claude/worktrees/emails-list/tests/commands/broadcasts/update.test.ts +283 -0
  121. package/.claude/worktrees/emails-list/tests/commands/contact-properties/create.test.ts +250 -0
  122. package/.claude/worktrees/emails-list/tests/commands/contact-properties/delete.test.ts +183 -0
  123. package/.claude/worktrees/emails-list/tests/commands/contact-properties/get.test.ts +144 -0
  124. package/.claude/worktrees/emails-list/tests/commands/contact-properties/list.test.ts +180 -0
  125. package/.claude/worktrees/emails-list/tests/commands/contact-properties/update.test.ts +216 -0
  126. package/.claude/worktrees/emails-list/tests/commands/contacts/add-segment.test.ts +188 -0
  127. package/.claude/worktrees/emails-list/tests/commands/contacts/create.test.ts +270 -0
  128. package/.claude/worktrees/emails-list/tests/commands/contacts/delete.test.ts +192 -0
  129. package/.claude/worktrees/emails-list/tests/commands/contacts/get.test.ts +148 -0
  130. package/.claude/worktrees/emails-list/tests/commands/contacts/list.test.ts +175 -0
  131. package/.claude/worktrees/emails-list/tests/commands/contacts/remove-segment.test.ts +166 -0
  132. package/.claude/worktrees/emails-list/tests/commands/contacts/segments.test.ts +167 -0
  133. package/.claude/worktrees/emails-list/tests/commands/contacts/topics.test.ts +163 -0
  134. package/.claude/worktrees/emails-list/tests/commands/contacts/update-topics.test.ts +247 -0
  135. package/.claude/worktrees/emails-list/tests/commands/contacts/update.test.ts +205 -0
  136. package/.claude/worktrees/emails-list/tests/commands/doctor.test.ts +165 -0
  137. package/.claude/worktrees/emails-list/tests/commands/domains/create.test.ts +192 -0
  138. package/.claude/worktrees/emails-list/tests/commands/domains/delete.test.ts +156 -0
  139. package/.claude/worktrees/emails-list/tests/commands/domains/get.test.ts +137 -0
  140. package/.claude/worktrees/emails-list/tests/commands/domains/list.test.ts +164 -0
  141. package/.claude/worktrees/emails-list/tests/commands/domains/update.test.ts +223 -0
  142. package/.claude/worktrees/emails-list/tests/commands/domains/verify.test.ts +117 -0
  143. package/.claude/worktrees/emails-list/tests/commands/emails/batch.test.ts +313 -0
  144. package/.claude/worktrees/emails-list/tests/commands/emails/list.test.ts +196 -0
  145. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachment.test.ts +140 -0
  146. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachments.test.ts +168 -0
  147. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/get.test.ts +140 -0
  148. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/list.test.ts +181 -0
  149. package/.claude/worktrees/emails-list/tests/commands/emails/send.test.ts +309 -0
  150. package/.claude/worktrees/emails-list/tests/commands/segments/create.test.ts +163 -0
  151. package/.claude/worktrees/emails-list/tests/commands/segments/delete.test.ts +182 -0
  152. package/.claude/worktrees/emails-list/tests/commands/segments/get.test.ts +137 -0
  153. package/.claude/worktrees/emails-list/tests/commands/segments/list.test.ts +173 -0
  154. package/.claude/worktrees/emails-list/tests/commands/teams/list.test.ts +63 -0
  155. package/.claude/worktrees/emails-list/tests/commands/teams/remove.test.ts +103 -0
  156. package/.claude/worktrees/emails-list/tests/commands/teams/switch.test.ts +96 -0
  157. package/.claude/worktrees/emails-list/tests/commands/topics/create.test.ts +191 -0
  158. package/.claude/worktrees/emails-list/tests/commands/topics/delete.test.ts +156 -0
  159. package/.claude/worktrees/emails-list/tests/commands/topics/get.test.ts +125 -0
  160. package/.claude/worktrees/emails-list/tests/commands/topics/list.test.ts +124 -0
  161. package/.claude/worktrees/emails-list/tests/commands/topics/update.test.ts +177 -0
  162. package/.claude/worktrees/emails-list/tests/commands/webhooks/create.test.ts +224 -0
  163. package/.claude/worktrees/emails-list/tests/commands/webhooks/delete.test.ts +156 -0
  164. package/.claude/worktrees/emails-list/tests/commands/webhooks/get.test.ts +125 -0
  165. package/.claude/worktrees/emails-list/tests/commands/webhooks/list.test.ts +177 -0
  166. package/.claude/worktrees/emails-list/tests/commands/webhooks/update.test.ts +206 -0
  167. package/.claude/worktrees/emails-list/tests/commands/whoami.test.ts +99 -0
  168. package/.claude/worktrees/emails-list/tests/helpers.ts +93 -0
  169. package/.claude/worktrees/emails-list/tests/lib/client.test.ts +71 -0
  170. package/.claude/worktrees/emails-list/tests/lib/config.test.ts +414 -0
  171. package/.claude/worktrees/emails-list/tests/lib/files.test.ts +65 -0
  172. package/.claude/worktrees/emails-list/tests/lib/help-text.test.ts +97 -0
  173. package/.claude/worktrees/emails-list/tests/lib/output.test.ts +127 -0
  174. package/.claude/worktrees/emails-list/tests/lib/prompts.test.ts +178 -0
  175. package/.claude/worktrees/emails-list/tests/lib/spinner.test.ts +146 -0
  176. package/.claude/worktrees/emails-list/tests/lib/table.test.ts +63 -0
  177. package/.claude/worktrees/emails-list/tests/lib/tty.test.ts +85 -0
  178. package/.claude/worktrees/emails-list/tsconfig.json +14 -0
  179. package/.github/scripts/pr-title-check.js +34 -0
  180. package/.github/workflows/ci.yml +32 -0
  181. package/.github/workflows/pr-title-check.yml +13 -0
  182. package/.github/workflows/release.yml +93 -0
  183. package/.github/workflows/test-build-windows.yml +44 -0
  184. package/.github/workflows/test-install-windows.yml +48 -0
  185. package/CHANGELOG.md +31 -0
  186. package/LICENSE +21 -21
  187. package/README.md +424 -19
  188. package/biome.json +36 -0
  189. package/bun.lock +76 -0
  190. package/bunfig.toml +2 -0
  191. package/docs/agent-dx-gaps.md +167 -0
  192. package/docs/missing-commands.md +58 -0
  193. package/docs/production-readiness.md +99 -0
  194. package/docs/secure-key-storage.md +174 -0
  195. package/install.ps1 +141 -0
  196. package/install.sh +301 -0
  197. package/package.json +43 -22
  198. package/renovate.json +4 -0
  199. package/src/cli.ts +74 -0
  200. package/src/commands/api-keys/create.ts +114 -0
  201. package/src/commands/api-keys/delete.ts +47 -0
  202. package/src/commands/api-keys/index.ts +26 -0
  203. package/src/commands/api-keys/list.ts +35 -0
  204. package/src/commands/api-keys/utils.ts +8 -0
  205. package/src/commands/auth/index.ts +20 -0
  206. package/src/commands/auth/login.ts +232 -0
  207. package/src/commands/auth/logout.ts +105 -0
  208. package/src/commands/broadcasts/create.ts +196 -0
  209. package/src/commands/broadcasts/delete.ts +46 -0
  210. package/src/commands/broadcasts/get.ts +59 -0
  211. package/src/commands/broadcasts/index.ts +43 -0
  212. package/src/commands/broadcasts/list.ts +60 -0
  213. package/src/commands/broadcasts/send.ts +56 -0
  214. package/src/commands/broadcasts/update.ts +95 -0
  215. package/src/commands/broadcasts/utils.ts +35 -0
  216. package/src/commands/contact-properties/create.ts +118 -0
  217. package/src/commands/contact-properties/delete.ts +48 -0
  218. package/src/commands/contact-properties/get.ts +46 -0
  219. package/src/commands/contact-properties/index.ts +48 -0
  220. package/src/commands/contact-properties/list.ts +68 -0
  221. package/src/commands/contact-properties/update.ts +88 -0
  222. package/src/commands/contact-properties/utils.ts +17 -0
  223. package/src/commands/contacts/add-segment.ts +78 -0
  224. package/src/commands/contacts/create.ts +122 -0
  225. package/src/commands/contacts/delete.ts +49 -0
  226. package/src/commands/contacts/get.ts +53 -0
  227. package/src/commands/contacts/index.ts +58 -0
  228. package/src/commands/contacts/list.ts +57 -0
  229. package/src/commands/contacts/remove-segment.ts +48 -0
  230. package/src/commands/contacts/segments.ts +39 -0
  231. package/src/commands/contacts/topics.ts +45 -0
  232. package/src/commands/contacts/update-topics.ts +90 -0
  233. package/src/commands/contacts/update.ts +77 -0
  234. package/src/commands/contacts/utils.ts +119 -0
  235. package/src/commands/doctor.ts +298 -0
  236. package/src/commands/domains/create.ts +83 -0
  237. package/src/commands/domains/delete.ts +42 -0
  238. package/src/commands/domains/get.ts +47 -0
  239. package/src/commands/domains/index.ts +35 -0
  240. package/src/commands/domains/list.ts +53 -0
  241. package/src/commands/domains/update.ts +75 -0
  242. package/src/commands/domains/utils.ts +44 -0
  243. package/src/commands/domains/verify.ts +38 -0
  244. package/src/commands/emails/batch.ts +140 -0
  245. package/src/commands/emails/index.ts +24 -0
  246. package/src/commands/emails/receiving/attachment.ts +55 -0
  247. package/src/commands/emails/receiving/attachments.ts +68 -0
  248. package/src/commands/emails/receiving/get.ts +58 -0
  249. package/src/commands/emails/receiving/index.ts +28 -0
  250. package/src/commands/emails/receiving/list.ts +59 -0
  251. package/src/commands/emails/receiving/utils.ts +38 -0
  252. package/src/commands/emails/send.ts +189 -0
  253. package/src/commands/open.ts +24 -0
  254. package/src/commands/segments/create.ts +50 -0
  255. package/src/commands/segments/delete.ts +47 -0
  256. package/src/commands/segments/get.ts +38 -0
  257. package/src/commands/segments/index.ts +36 -0
  258. package/src/commands/segments/list.ts +58 -0
  259. package/src/commands/segments/utils.ts +7 -0
  260. package/src/commands/teams/index.ts +10 -0
  261. package/src/commands/teams/list.ts +35 -0
  262. package/src/commands/teams/remove.ts +86 -0
  263. package/src/commands/teams/switch.ts +76 -0
  264. package/src/commands/topics/create.ts +73 -0
  265. package/src/commands/topics/delete.ts +47 -0
  266. package/src/commands/topics/get.ts +42 -0
  267. package/src/commands/topics/index.ts +42 -0
  268. package/src/commands/topics/list.ts +34 -0
  269. package/src/commands/topics/update.ts +59 -0
  270. package/src/commands/topics/utils.ts +16 -0
  271. package/src/commands/webhooks/create.ts +128 -0
  272. package/src/commands/webhooks/delete.ts +49 -0
  273. package/src/commands/webhooks/get.ts +42 -0
  274. package/src/commands/webhooks/index.ts +44 -0
  275. package/src/commands/webhooks/list.ts +55 -0
  276. package/src/commands/webhooks/update.ts +83 -0
  277. package/src/commands/webhooks/utils.ts +36 -0
  278. package/src/commands/whoami.ts +71 -0
  279. package/src/lib/actions.ts +157 -0
  280. package/src/lib/client.ts +34 -0
  281. package/src/lib/config.ts +218 -0
  282. package/src/lib/files.ts +15 -0
  283. package/src/lib/help-text.ts +38 -0
  284. package/src/lib/output.ts +54 -0
  285. package/src/lib/pagination.ts +36 -0
  286. package/src/lib/prompts.ts +149 -0
  287. package/src/lib/spinner.ts +93 -0
  288. package/src/lib/table.ts +57 -0
  289. package/src/lib/tty.ts +28 -0
  290. package/src/lib/version.ts +4 -0
  291. package/tests/commands/api-keys/create.test.ts +195 -0
  292. package/tests/commands/api-keys/delete.test.ts +156 -0
  293. package/tests/commands/api-keys/list.test.ts +133 -0
  294. package/tests/commands/auth/login.test.ts +154 -0
  295. package/tests/commands/auth/logout.test.ts +146 -0
  296. package/tests/commands/broadcasts/create.test.ts +447 -0
  297. package/tests/commands/broadcasts/delete.test.ts +182 -0
  298. package/tests/commands/broadcasts/get.test.ts +146 -0
  299. package/tests/commands/broadcasts/list.test.ts +196 -0
  300. package/tests/commands/broadcasts/send.test.ts +161 -0
  301. package/tests/commands/broadcasts/update.test.ts +283 -0
  302. package/tests/commands/contact-properties/create.test.ts +250 -0
  303. package/tests/commands/contact-properties/delete.test.ts +183 -0
  304. package/tests/commands/contact-properties/get.test.ts +144 -0
  305. package/tests/commands/contact-properties/list.test.ts +180 -0
  306. package/tests/commands/contact-properties/update.test.ts +216 -0
  307. package/tests/commands/contacts/add-segment.test.ts +188 -0
  308. package/tests/commands/contacts/create.test.ts +270 -0
  309. package/tests/commands/contacts/delete.test.ts +192 -0
  310. package/tests/commands/contacts/get.test.ts +148 -0
  311. package/tests/commands/contacts/list.test.ts +175 -0
  312. package/tests/commands/contacts/remove-segment.test.ts +166 -0
  313. package/tests/commands/contacts/segments.test.ts +167 -0
  314. package/tests/commands/contacts/topics.test.ts +163 -0
  315. package/tests/commands/contacts/update-topics.test.ts +247 -0
  316. package/tests/commands/contacts/update.test.ts +205 -0
  317. package/tests/commands/doctor.test.ts +165 -0
  318. package/tests/commands/domains/create.test.ts +192 -0
  319. package/tests/commands/domains/delete.test.ts +156 -0
  320. package/tests/commands/domains/get.test.ts +137 -0
  321. package/tests/commands/domains/list.test.ts +164 -0
  322. package/tests/commands/domains/update.test.ts +223 -0
  323. package/tests/commands/domains/verify.test.ts +117 -0
  324. package/tests/commands/emails/batch.test.ts +313 -0
  325. package/tests/commands/emails/receiving/attachment.test.ts +140 -0
  326. package/tests/commands/emails/receiving/attachments.test.ts +168 -0
  327. package/tests/commands/emails/receiving/get.test.ts +140 -0
  328. package/tests/commands/emails/receiving/list.test.ts +181 -0
  329. package/tests/commands/emails/send.test.ts +309 -0
  330. package/tests/commands/segments/create.test.ts +163 -0
  331. package/tests/commands/segments/delete.test.ts +182 -0
  332. package/tests/commands/segments/get.test.ts +137 -0
  333. package/tests/commands/segments/list.test.ts +173 -0
  334. package/tests/commands/teams/list.test.ts +63 -0
  335. package/tests/commands/teams/remove.test.ts +103 -0
  336. package/tests/commands/teams/switch.test.ts +96 -0
  337. package/tests/commands/topics/create.test.ts +191 -0
  338. package/tests/commands/topics/delete.test.ts +156 -0
  339. package/tests/commands/topics/get.test.ts +125 -0
  340. package/tests/commands/topics/list.test.ts +124 -0
  341. package/tests/commands/topics/update.test.ts +177 -0
  342. package/tests/commands/webhooks/create.test.ts +224 -0
  343. package/tests/commands/webhooks/delete.test.ts +156 -0
  344. package/tests/commands/webhooks/get.test.ts +125 -0
  345. package/tests/commands/webhooks/list.test.ts +177 -0
  346. package/tests/commands/webhooks/update.test.ts +206 -0
  347. package/tests/commands/whoami.test.ts +99 -0
  348. package/tests/helpers.ts +93 -0
  349. package/tests/lib/client.test.ts +71 -0
  350. package/tests/lib/config.test.ts +447 -0
  351. package/tests/lib/files.test.ts +65 -0
  352. package/tests/lib/help-text.test.ts +97 -0
  353. package/tests/lib/output.test.ts +127 -0
  354. package/tests/lib/prompts.test.ts +178 -0
  355. package/tests/lib/spinner.test.ts +146 -0
  356. package/tests/lib/table.test.ts +63 -0
  357. package/tests/lib/tty.test.ts +85 -0
  358. package/tsconfig.json +14 -0
  359. package/src/index.js +0 -72
  360. package/src/routes.js +0 -37
  361. package/src/sections/apikeys.js +0 -99
  362. package/src/sections/audiences.js +0 -84
  363. package/src/sections/contacts.js +0 -177
  364. package/src/sections/domain.js +0 -195
  365. package/src/sections/email.js +0 -132
@@ -0,0 +1,127 @@
1
+ import { afterEach, describe, expect, spyOn, test } from 'bun:test';
2
+ import { outputError, outputResult } from '../../src/lib/output';
3
+
4
+ describe('outputResult', () => {
5
+ let logSpy: ReturnType<typeof spyOn>;
6
+ const originalIsTTY = process.stdout.isTTY;
7
+
8
+ afterEach(() => {
9
+ logSpy?.mockRestore();
10
+ Object.defineProperty(process.stdout, 'isTTY', {
11
+ value: originalIsTTY,
12
+ writable: true,
13
+ });
14
+ });
15
+
16
+ test('outputs JSON when json option is true', () => {
17
+ logSpy = spyOn(console, 'log').mockImplementation(() => {});
18
+ outputResult({ id: '123' }, { json: true });
19
+ expect(logSpy).toHaveBeenCalledWith(JSON.stringify({ id: '123' }, null, 2));
20
+ });
21
+
22
+ test('outputs JSON when stdout is not TTY', () => {
23
+ Object.defineProperty(process.stdout, 'isTTY', {
24
+ value: undefined,
25
+ writable: true,
26
+ });
27
+ logSpy = spyOn(console, 'log').mockImplementation(() => {});
28
+ outputResult({ id: '123' });
29
+ expect(logSpy).toHaveBeenCalledWith(JSON.stringify({ id: '123' }, null, 2));
30
+ });
31
+
32
+ test('outputs string directly for human-readable mode', () => {
33
+ Object.defineProperty(process.stdout, 'isTTY', {
34
+ value: true,
35
+ writable: true,
36
+ });
37
+ logSpy = spyOn(console, 'log').mockImplementation(() => {});
38
+ outputResult('Email sent successfully');
39
+ expect(logSpy).toHaveBeenCalledWith('Email sent successfully');
40
+ });
41
+
42
+ test('outputs JSON for objects in human mode (fallback)', () => {
43
+ Object.defineProperty(process.stdout, 'isTTY', {
44
+ value: true,
45
+ writable: true,
46
+ });
47
+ logSpy = spyOn(console, 'log').mockImplementation(() => {});
48
+ outputResult({ id: '123' });
49
+ expect(logSpy).toHaveBeenCalledWith(JSON.stringify({ id: '123' }, null, 2));
50
+ });
51
+ });
52
+
53
+ describe('outputError', () => {
54
+ let errorSpy: ReturnType<typeof spyOn>;
55
+ let exitSpy: ReturnType<typeof spyOn>;
56
+ const originalIsTTY = process.stdout.isTTY;
57
+
58
+ afterEach(() => {
59
+ errorSpy?.mockRestore();
60
+ exitSpy?.mockRestore();
61
+ Object.defineProperty(process.stdout, 'isTTY', {
62
+ value: originalIsTTY,
63
+ writable: true,
64
+ });
65
+ });
66
+
67
+ test('outputs JSON error when json is true', () => {
68
+ errorSpy = spyOn(console, 'error').mockImplementation(() => {});
69
+ exitSpy = spyOn(process, 'exit').mockImplementation(
70
+ () => undefined as never,
71
+ );
72
+
73
+ outputError({ message: 'not found', code: 'not_found' }, { json: true });
74
+
75
+ const expected = JSON.stringify(
76
+ { error: { message: 'not found', code: 'not_found' } },
77
+ null,
78
+ 2,
79
+ );
80
+ expect(errorSpy).toHaveBeenCalledWith(expected);
81
+ expect(exitSpy).toHaveBeenCalledWith(1);
82
+ });
83
+
84
+ test('outputs text error when TTY and no json flag', () => {
85
+ Object.defineProperty(process.stdout, 'isTTY', {
86
+ value: true,
87
+ writable: true,
88
+ });
89
+ errorSpy = spyOn(console, 'error').mockImplementation(() => {});
90
+ exitSpy = spyOn(process, 'exit').mockImplementation(
91
+ () => undefined as never,
92
+ );
93
+
94
+ outputError({ message: 'something broke' });
95
+
96
+ expect(errorSpy).toHaveBeenCalledWith('Error: something broke');
97
+ expect(exitSpy).toHaveBeenCalledWith(1);
98
+ });
99
+
100
+ test('uses custom exit code', () => {
101
+ errorSpy = spyOn(console, 'error').mockImplementation(() => {});
102
+ exitSpy = spyOn(process, 'exit').mockImplementation(
103
+ () => undefined as never,
104
+ );
105
+
106
+ outputError({ message: 'error' }, { exitCode: 2, json: true });
107
+
108
+ expect(exitSpy).toHaveBeenCalledWith(2);
109
+ });
110
+
111
+ test('defaults error code to "unknown" when not provided', () => {
112
+ Object.defineProperty(process.stdout, 'isTTY', {
113
+ value: undefined,
114
+ writable: true,
115
+ });
116
+ errorSpy = spyOn(console, 'error').mockImplementation(() => {});
117
+ exitSpy = spyOn(process, 'exit').mockImplementation(
118
+ () => undefined as never,
119
+ );
120
+
121
+ outputError({ message: 'oops' });
122
+
123
+ const output = errorSpy.mock.calls[0][0] as string;
124
+ const parsed = JSON.parse(output);
125
+ expect(parsed.error.code).toBe('unknown');
126
+ });
127
+ });
@@ -0,0 +1,178 @@
1
+ import { afterEach, describe, expect, spyOn, test } from 'bun:test';
2
+ import { expectExit1, mockExitThrow } from '../helpers';
3
+
4
+ describe('promptForMissing', () => {
5
+ const originalStdinIsTTY = process.stdin.isTTY;
6
+ const originalStdoutIsTTY = process.stdout.isTTY;
7
+ let errorSpy: ReturnType<typeof spyOn> | undefined;
8
+ let exitSpy: ReturnType<typeof spyOn> | undefined;
9
+
10
+ afterEach(() => {
11
+ errorSpy?.mockRestore();
12
+ exitSpy?.mockRestore();
13
+ errorSpy = undefined;
14
+ exitSpy = undefined;
15
+ Object.defineProperty(process.stdin, 'isTTY', {
16
+ value: originalStdinIsTTY,
17
+ writable: true,
18
+ });
19
+ Object.defineProperty(process.stdout, 'isTTY', {
20
+ value: originalStdoutIsTTY,
21
+ writable: true,
22
+ });
23
+ });
24
+
25
+ test('returns options unchanged when nothing is missing', async () => {
26
+ const { promptForMissing } = require('../../src/lib/prompts');
27
+ const opts = { from: 'a@b.com', to: 'c@d.com', subject: 'Hi' };
28
+ const result = await promptForMissing(
29
+ opts,
30
+ [
31
+ { flag: 'from', message: 'From' },
32
+ { flag: 'to', message: 'To' },
33
+ { flag: 'subject', message: 'Subject' },
34
+ ],
35
+ {},
36
+ );
37
+ expect(result).toEqual(opts);
38
+ });
39
+
40
+ test('exits with missing_flags error in non-interactive mode', async () => {
41
+ Object.defineProperty(process.stdin, 'isTTY', {
42
+ value: undefined,
43
+ writable: true,
44
+ });
45
+ Object.defineProperty(process.stdout, 'isTTY', {
46
+ value: undefined,
47
+ writable: true,
48
+ });
49
+ errorSpy = spyOn(console, 'error').mockImplementation(() => {});
50
+ exitSpy = mockExitThrow();
51
+
52
+ const { promptForMissing } = require('../../src/lib/prompts');
53
+
54
+ await expectExit1(() =>
55
+ promptForMissing(
56
+ { from: undefined, to: 'c@d.com', subject: undefined },
57
+ [
58
+ { flag: 'from', message: 'From' },
59
+ { flag: 'to', message: 'To' },
60
+ { flag: 'subject', message: 'Subject' },
61
+ ],
62
+ {},
63
+ ),
64
+ );
65
+
66
+ const allErrors = errorSpy?.mock.calls.map((c) => c[0]).join(' ');
67
+ expect(allErrors).toContain('--from');
68
+ expect(allErrors).toContain('--subject');
69
+ // --to should NOT be listed since it has a value
70
+ expect(allErrors).not.toContain('--to,');
71
+ });
72
+
73
+ test('errors output includes missing_flags code', async () => {
74
+ Object.defineProperty(process.stdin, 'isTTY', {
75
+ value: undefined,
76
+ writable: true,
77
+ });
78
+ Object.defineProperty(process.stdout, 'isTTY', {
79
+ value: undefined,
80
+ writable: true,
81
+ });
82
+ errorSpy = spyOn(console, 'error').mockImplementation(() => {});
83
+ exitSpy = mockExitThrow();
84
+
85
+ const { promptForMissing } = require('../../src/lib/prompts');
86
+
87
+ await expectExit1(() =>
88
+ promptForMissing(
89
+ { from: undefined },
90
+ [{ flag: 'from', message: 'From' }],
91
+ {},
92
+ ),
93
+ );
94
+
95
+ const allErrors = errorSpy?.mock.calls.map((c) => c[0]).join(' ');
96
+ expect(allErrors).toContain('missing_flags');
97
+ });
98
+
99
+ test('skips fields marked as required=false', async () => {
100
+ const { promptForMissing } = require('../../src/lib/prompts');
101
+ const opts = { from: 'a@b.com', to: undefined };
102
+ const result = await promptForMissing(
103
+ opts,
104
+ [
105
+ { flag: 'from', message: 'From' },
106
+ { flag: 'to', message: 'To', required: false },
107
+ ],
108
+ {},
109
+ );
110
+ expect(result).toEqual(opts);
111
+ });
112
+ });
113
+
114
+ describe('confirmDelete', () => {
115
+ const originalStdinIsTTY = process.stdin.isTTY;
116
+ const originalStdoutIsTTY = process.stdout.isTTY;
117
+ let errorSpy: ReturnType<typeof spyOn> | undefined;
118
+ let exitSpy: ReturnType<typeof spyOn> | undefined;
119
+
120
+ afterEach(() => {
121
+ errorSpy?.mockRestore();
122
+ exitSpy?.mockRestore();
123
+ errorSpy = undefined;
124
+ exitSpy = undefined;
125
+ Object.defineProperty(process.stdin, 'isTTY', {
126
+ value: originalStdinIsTTY,
127
+ writable: true,
128
+ });
129
+ Object.defineProperty(process.stdout, 'isTTY', {
130
+ value: originalStdoutIsTTY,
131
+ writable: true,
132
+ });
133
+ });
134
+
135
+ test('exits with confirmation_required when non-interactive', async () => {
136
+ Object.defineProperty(process.stdin, 'isTTY', {
137
+ value: undefined,
138
+ writable: true,
139
+ });
140
+ Object.defineProperty(process.stdout, 'isTTY', {
141
+ value: undefined,
142
+ writable: true,
143
+ });
144
+ errorSpy = spyOn(console, 'error').mockImplementation(() => {});
145
+ exitSpy = mockExitThrow();
146
+
147
+ const { confirmDelete } = require('../../src/lib/prompts');
148
+
149
+ await expectExit1(() =>
150
+ confirmDelete('res_123', 'Delete resource res_123?', { json: false }),
151
+ );
152
+
153
+ const output = errorSpy?.mock.calls.map((c) => c[0]).join(' ');
154
+ expect(output).toContain('confirmation_required');
155
+ });
156
+
157
+ test('outputs JSON confirmation_required error when json option is true', async () => {
158
+ Object.defineProperty(process.stdin, 'isTTY', {
159
+ value: undefined,
160
+ writable: true,
161
+ });
162
+ Object.defineProperty(process.stdout, 'isTTY', {
163
+ value: undefined,
164
+ writable: true,
165
+ });
166
+ errorSpy = spyOn(console, 'error').mockImplementation(() => {});
167
+ exitSpy = mockExitThrow();
168
+
169
+ const { confirmDelete } = require('../../src/lib/prompts');
170
+ await expectExit1(() =>
171
+ confirmDelete('res_123', 'Delete?', { json: true }),
172
+ );
173
+
174
+ const raw = errorSpy?.mock.calls.map((c) => c[0]).join(' ');
175
+ const parsed = JSON.parse(raw);
176
+ expect(parsed.error.code).toBe('confirmation_required');
177
+ });
178
+ });
@@ -0,0 +1,146 @@
1
+ import { afterEach, describe, expect, spyOn, test } from 'bun:test';
2
+
3
+ describe('createSpinner', () => {
4
+ const originalStdinIsTTY = process.stdin.isTTY;
5
+ const originalStdoutIsTTY = process.stdout.isTTY;
6
+ let stderrSpy: ReturnType<typeof spyOn>;
7
+
8
+ afterEach(() => {
9
+ stderrSpy?.mockRestore();
10
+ Object.defineProperty(process.stdin, 'isTTY', {
11
+ value: originalStdinIsTTY,
12
+ writable: true,
13
+ });
14
+ Object.defineProperty(process.stdout, 'isTTY', {
15
+ value: originalStdoutIsTTY,
16
+ writable: true,
17
+ });
18
+ delete process.env.CI;
19
+ });
20
+
21
+ test('returns no-op spinner in non-interactive mode', () => {
22
+ Object.defineProperty(process.stdin, 'isTTY', {
23
+ value: undefined,
24
+ writable: true,
25
+ });
26
+ Object.defineProperty(process.stdout, 'isTTY', {
27
+ value: undefined,
28
+ writable: true,
29
+ });
30
+
31
+ const { createSpinner } = require('../../src/lib/spinner');
32
+ const spinner = createSpinner('test message');
33
+
34
+ // Should not throw when calling any method
35
+ expect(() => spinner.stop('done')).not.toThrow();
36
+ expect(() => spinner.fail('error')).not.toThrow();
37
+ expect(() => spinner.warn('warning')).not.toThrow();
38
+ expect(() => spinner.update('updating')).not.toThrow();
39
+ });
40
+
41
+ test('returns functional spinner in interactive mode', () => {
42
+ Object.defineProperty(process.stdin, 'isTTY', {
43
+ value: true,
44
+ writable: true,
45
+ });
46
+ Object.defineProperty(process.stdout, 'isTTY', {
47
+ value: true,
48
+ writable: true,
49
+ });
50
+ delete process.env.CI;
51
+ delete process.env.GITHUB_ACTIONS;
52
+ delete process.env.TERM;
53
+
54
+ stderrSpy = spyOn(process.stderr, 'write').mockImplementation(() => true);
55
+
56
+ const { createSpinner } = require('../../src/lib/spinner');
57
+ const spinner = createSpinner('loading...');
58
+
59
+ expect(spinner).toHaveProperty('stop');
60
+ expect(spinner).toHaveProperty('fail');
61
+ expect(spinner).toHaveProperty('warn');
62
+ expect(spinner).toHaveProperty('update');
63
+
64
+ // Stop to clean up the interval
65
+ spinner.stop('done');
66
+ expect(stderrSpy).toHaveBeenCalled();
67
+ });
68
+
69
+ test('stop writes checkmark to stderr', () => {
70
+ Object.defineProperty(process.stdin, 'isTTY', {
71
+ value: true,
72
+ writable: true,
73
+ });
74
+ Object.defineProperty(process.stdout, 'isTTY', {
75
+ value: true,
76
+ writable: true,
77
+ });
78
+ delete process.env.CI;
79
+ delete process.env.GITHUB_ACTIONS;
80
+ delete process.env.TERM;
81
+
82
+ stderrSpy = spyOn(process.stderr, 'write').mockImplementation(() => true);
83
+
84
+ const { createSpinner } = require('../../src/lib/spinner');
85
+ const spinner = createSpinner('loading...');
86
+ spinner.stop('completed');
87
+
88
+ const lastCall = stderrSpy.mock.calls[
89
+ stderrSpy.mock.calls.length - 1
90
+ ][0] as string;
91
+ expect(lastCall).toContain('✔');
92
+ expect(lastCall).toContain('completed');
93
+ });
94
+
95
+ test('fail writes cross mark to stderr', () => {
96
+ Object.defineProperty(process.stdin, 'isTTY', {
97
+ value: true,
98
+ writable: true,
99
+ });
100
+ Object.defineProperty(process.stdout, 'isTTY', {
101
+ value: true,
102
+ writable: true,
103
+ });
104
+ delete process.env.CI;
105
+ delete process.env.GITHUB_ACTIONS;
106
+ delete process.env.TERM;
107
+
108
+ stderrSpy = spyOn(process.stderr, 'write').mockImplementation(() => true);
109
+
110
+ const { createSpinner } = require('../../src/lib/spinner');
111
+ const spinner = createSpinner('loading...');
112
+ spinner.fail('error occurred');
113
+
114
+ const lastCall = stderrSpy.mock.calls[
115
+ stderrSpy.mock.calls.length - 1
116
+ ][0] as string;
117
+ expect(lastCall).toContain('✗');
118
+ expect(lastCall).toContain('error occurred');
119
+ });
120
+
121
+ test('warn writes warning icon to stderr', () => {
122
+ Object.defineProperty(process.stdin, 'isTTY', {
123
+ value: true,
124
+ writable: true,
125
+ });
126
+ Object.defineProperty(process.stdout, 'isTTY', {
127
+ value: true,
128
+ writable: true,
129
+ });
130
+ delete process.env.CI;
131
+ delete process.env.GITHUB_ACTIONS;
132
+ delete process.env.TERM;
133
+
134
+ stderrSpy = spyOn(process.stderr, 'write').mockImplementation(() => true);
135
+
136
+ const { createSpinner } = require('../../src/lib/spinner');
137
+ const spinner = createSpinner('loading...');
138
+ spinner.warn('watch out');
139
+
140
+ const lastCall = stderrSpy.mock.calls[
141
+ stderrSpy.mock.calls.length - 1
142
+ ][0] as string;
143
+ expect(lastCall).toContain('⚠');
144
+ expect(lastCall).toContain('watch out');
145
+ });
146
+ });
@@ -0,0 +1,63 @@
1
+ import { describe, expect, test } from 'bun:test';
2
+ import { renderTable } from '../../src/lib/table';
3
+
4
+ describe('renderTable', () => {
5
+ test('renders a table with correct border characters', () => {
6
+ const output = renderTable(['Name', 'ID'], [['Alice', 'abc-123']]);
7
+ expect(output).toContain('┌');
8
+ expect(output).toContain('┐');
9
+ expect(output).toContain('└');
10
+ expect(output).toContain('┘');
11
+ expect(output).toContain('│');
12
+ });
13
+
14
+ test('includes headers in output', () => {
15
+ const output = renderTable(
16
+ ['Name', 'Status'],
17
+ [['my-domain.com', 'verified']],
18
+ );
19
+ expect(output).toContain('Name');
20
+ expect(output).toContain('Status');
21
+ });
22
+
23
+ test('includes row data in output', () => {
24
+ const output = renderTable(
25
+ ['Name', 'Status'],
26
+ [['my-domain.com', 'verified']],
27
+ );
28
+ expect(output).toContain('my-domain.com');
29
+ expect(output).toContain('verified');
30
+ });
31
+
32
+ test('pads columns to the widest cell in each column', () => {
33
+ const output = renderTable(
34
+ ['Key', 'Value'],
35
+ [
36
+ ['short', 'a very long value here'],
37
+ ['much longer key', 'v'],
38
+ ],
39
+ );
40
+ // All rows should have the same line length
41
+ const lines = output.split('\n');
42
+ const lengths = lines.map((l) => l.length);
43
+ expect(new Set(lengths).size).toBe(1);
44
+ });
45
+
46
+ test('renders multiple rows', () => {
47
+ const output = renderTable(
48
+ ['A', 'B'],
49
+ [
50
+ ['row1a', 'row1b'],
51
+ ['row2a', 'row2b'],
52
+ ],
53
+ );
54
+ expect(output).toContain('row1a');
55
+ expect(output).toContain('row2a');
56
+ });
57
+
58
+ test('contains a separator row between header and data', () => {
59
+ const output = renderTable(['Col'], [['val']]);
60
+ expect(output).toContain('├');
61
+ expect(output).toContain('┤');
62
+ });
63
+ });
@@ -0,0 +1,85 @@
1
+ import { afterEach, describe, expect, test } from 'bun:test';
2
+ import { captureTestEnv } from '../helpers';
3
+
4
+ // We need to import the module fresh per test to pick up env changes,
5
+ // so we use dynamic imports.
6
+
7
+ describe('isInteractive', () => {
8
+ const restoreEnv = captureTestEnv();
9
+
10
+ afterEach(() => {
11
+ restoreEnv();
12
+ });
13
+
14
+ function setTTY(stdin: boolean, stdout: boolean) {
15
+ Object.defineProperty(process.stdin, 'isTTY', {
16
+ value: stdin ? true : undefined,
17
+ writable: true,
18
+ });
19
+ Object.defineProperty(process.stdout, 'isTTY', {
20
+ value: stdout ? true : undefined,
21
+ writable: true,
22
+ });
23
+ }
24
+
25
+ test('returns true when stdin and stdout are TTY and no CI env', () => {
26
+ setTTY(true, true);
27
+ delete process.env.CI;
28
+ delete process.env.GITHUB_ACTIONS;
29
+ delete process.env.TERM;
30
+
31
+ const { isInteractive } = require('../../src/lib/tty');
32
+ expect(isInteractive()).toBe(true);
33
+ });
34
+
35
+ test('returns false when stdin is not TTY', () => {
36
+ setTTY(false, true);
37
+ delete process.env.CI;
38
+
39
+ const { isInteractive } = require('../../src/lib/tty');
40
+ expect(isInteractive()).toBe(false);
41
+ });
42
+
43
+ test('returns false when stdout is not TTY', () => {
44
+ setTTY(true, false);
45
+ delete process.env.CI;
46
+
47
+ const { isInteractive } = require('../../src/lib/tty');
48
+ expect(isInteractive()).toBe(false);
49
+ });
50
+
51
+ test('returns false when CI=true', () => {
52
+ setTTY(true, true);
53
+ process.env.CI = 'true';
54
+
55
+ const { isInteractive } = require('../../src/lib/tty');
56
+ expect(isInteractive()).toBe(false);
57
+ });
58
+
59
+ test('returns false when CI=1', () => {
60
+ setTTY(true, true);
61
+ process.env.CI = '1';
62
+
63
+ const { isInteractive } = require('../../src/lib/tty');
64
+ expect(isInteractive()).toBe(false);
65
+ });
66
+
67
+ test('returns false when GITHUB_ACTIONS is set', () => {
68
+ setTTY(true, true);
69
+ delete process.env.CI;
70
+ process.env.GITHUB_ACTIONS = 'true';
71
+
72
+ const { isInteractive } = require('../../src/lib/tty');
73
+ expect(isInteractive()).toBe(false);
74
+ });
75
+
76
+ test('returns false when TERM=dumb', () => {
77
+ setTTY(true, true);
78
+ delete process.env.CI;
79
+ delete process.env.GITHUB_ACTIONS;
80
+ process.env.TERM = 'dumb';
81
+
82
+ const { isInteractive } = require('../../src/lib/tty');
83
+ expect(isInteractive()).toBe(false);
84
+ });
85
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "outDir": "./dist",
10
+ "rootDir": "./src",
11
+ "types": ["bun"]
12
+ },
13
+ "include": ["src/**/*.ts"]
14
+ }
package/src/index.js DELETED
@@ -1,72 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import enquirer from "enquirer"
4
- import * as fs from "fs/promises"
5
- import {homedir} from "os"
6
- import figlet from "figlet"
7
- import {promisify} from "util"
8
- const fig = promisify(figlet)
9
- import ora from "ora"
10
- import { Resend } from "resend"
11
- import routes from "./routes.js"
12
- import readline from "readline"
13
-
14
- if (process.platform === "win32") {
15
- var rl = readline.createInterface({
16
- input: process.stdin,
17
- output: process.stdout
18
- });
19
-
20
- rl.on("SIGINT", function () {
21
- process.emit("SIGINT");
22
- });
23
- }
24
-
25
- process.on("SIGINT", function () {
26
- //graceful shutdown
27
- console.log("\nExiting...");
28
- process.exit();
29
- });
30
-
31
- const text = await fig("resend-cli")
32
- console.log(text)
33
- const configPath = `${homedir()}/.resend_config.json`
34
- const fileExists = await fs.access(configPath).then(() => true).catch(() => false);
35
- if (fileExists) {
36
- let config, instance
37
- try {
38
- let fileContents = await fs.readFile(configPath)
39
- fileContents = fileContents + ''
40
- config = JSON.parse(fileContents)
41
- //console.log(config.apiKey)
42
- instance = new Resend(config.apiKey)
43
- } catch (e) {
44
- console.error("Error reading config file")
45
- console.error(e)
46
- process.exit(1)
47
- }
48
-
49
- try {
50
- await routes({resend: instance, apiKey: config.apiKey, config})
51
- } catch {} // this is needed so that Ctrl+C doesn't throw an exception
52
- } else {
53
- const apiKeyResponse = await enquirer.password({
54
- message: "Enter an API key with full access: "
55
- })
56
- const spinner = ora({text: "Authenticating...", spinner: "toggle9"}).start()
57
- const resend = new Resend(apiKeyResponse)
58
- const apiKeys = await resend.apiKeys.list()
59
- spinner.stop()
60
- if (apiKeys?.error?.statusCode === 400) {
61
- console.error("Invalid API key")
62
- process.exit(1)
63
- } else {
64
- const config = {
65
- apiKey: apiKeyResponse
66
- }
67
- await fs.writeFile(configPath, JSON.stringify(config))
68
- console.log("API key saved in plain text to ~/.resend_config.json.")
69
- console.log("Run `resend-cli` again to use the CLI.")
70
- process.exit(0)
71
- }
72
- }