resend-cli 1.2.1 → 1.3.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 (357) hide show
  1. package/README.md +25 -10
  2. package/dist/cli.cjs +539 -0
  3. package/package.json +31 -13
  4. package/.claude/settings.local.json +0 -5
  5. package/.claude/worktrees/emails-list/.claude/settings.local.json +0 -5
  6. package/.claude/worktrees/emails-list/.github/scripts/pr-title-check.js +0 -34
  7. package/.claude/worktrees/emails-list/.github/workflows/ci.yml +0 -32
  8. package/.claude/worktrees/emails-list/.github/workflows/pr-title-check.yml +0 -13
  9. package/.claude/worktrees/emails-list/.github/workflows/release.yml +0 -93
  10. package/.claude/worktrees/emails-list/CHANGELOG.md +0 -31
  11. package/.claude/worktrees/emails-list/LICENSE +0 -21
  12. package/.claude/worktrees/emails-list/README.md +0 -424
  13. package/.claude/worktrees/emails-list/biome.json +0 -36
  14. package/.claude/worktrees/emails-list/bun.lock +0 -76
  15. package/.claude/worktrees/emails-list/bunfig.toml +0 -2
  16. package/.claude/worktrees/emails-list/install.ps1 +0 -140
  17. package/.claude/worktrees/emails-list/install.sh +0 -301
  18. package/.claude/worktrees/emails-list/package.json +0 -43
  19. package/.claude/worktrees/emails-list/renovate.json +0 -6
  20. package/.claude/worktrees/emails-list/src/cli.ts +0 -74
  21. package/.claude/worktrees/emails-list/src/commands/api-keys/create.ts +0 -114
  22. package/.claude/worktrees/emails-list/src/commands/api-keys/delete.ts +0 -47
  23. package/.claude/worktrees/emails-list/src/commands/api-keys/index.ts +0 -26
  24. package/.claude/worktrees/emails-list/src/commands/api-keys/list.ts +0 -35
  25. package/.claude/worktrees/emails-list/src/commands/api-keys/utils.ts +0 -8
  26. package/.claude/worktrees/emails-list/src/commands/auth/index.ts +0 -20
  27. package/.claude/worktrees/emails-list/src/commands/auth/login.ts +0 -207
  28. package/.claude/worktrees/emails-list/src/commands/auth/logout.ts +0 -105
  29. package/.claude/worktrees/emails-list/src/commands/broadcasts/create.ts +0 -196
  30. package/.claude/worktrees/emails-list/src/commands/broadcasts/delete.ts +0 -46
  31. package/.claude/worktrees/emails-list/src/commands/broadcasts/get.ts +0 -59
  32. package/.claude/worktrees/emails-list/src/commands/broadcasts/index.ts +0 -43
  33. package/.claude/worktrees/emails-list/src/commands/broadcasts/list.ts +0 -60
  34. package/.claude/worktrees/emails-list/src/commands/broadcasts/send.ts +0 -56
  35. package/.claude/worktrees/emails-list/src/commands/broadcasts/update.ts +0 -95
  36. package/.claude/worktrees/emails-list/src/commands/broadcasts/utils.ts +0 -35
  37. package/.claude/worktrees/emails-list/src/commands/contact-properties/create.ts +0 -118
  38. package/.claude/worktrees/emails-list/src/commands/contact-properties/delete.ts +0 -48
  39. package/.claude/worktrees/emails-list/src/commands/contact-properties/get.ts +0 -46
  40. package/.claude/worktrees/emails-list/src/commands/contact-properties/index.ts +0 -48
  41. package/.claude/worktrees/emails-list/src/commands/contact-properties/list.ts +0 -68
  42. package/.claude/worktrees/emails-list/src/commands/contact-properties/update.ts +0 -88
  43. package/.claude/worktrees/emails-list/src/commands/contact-properties/utils.ts +0 -17
  44. package/.claude/worktrees/emails-list/src/commands/contacts/add-segment.ts +0 -78
  45. package/.claude/worktrees/emails-list/src/commands/contacts/create.ts +0 -122
  46. package/.claude/worktrees/emails-list/src/commands/contacts/delete.ts +0 -49
  47. package/.claude/worktrees/emails-list/src/commands/contacts/get.ts +0 -53
  48. package/.claude/worktrees/emails-list/src/commands/contacts/index.ts +0 -58
  49. package/.claude/worktrees/emails-list/src/commands/contacts/list.ts +0 -57
  50. package/.claude/worktrees/emails-list/src/commands/contacts/remove-segment.ts +0 -48
  51. package/.claude/worktrees/emails-list/src/commands/contacts/segments.ts +0 -39
  52. package/.claude/worktrees/emails-list/src/commands/contacts/topics.ts +0 -45
  53. package/.claude/worktrees/emails-list/src/commands/contacts/update-topics.ts +0 -90
  54. package/.claude/worktrees/emails-list/src/commands/contacts/update.ts +0 -77
  55. package/.claude/worktrees/emails-list/src/commands/contacts/utils.ts +0 -119
  56. package/.claude/worktrees/emails-list/src/commands/doctor.ts +0 -298
  57. package/.claude/worktrees/emails-list/src/commands/domains/create.ts +0 -83
  58. package/.claude/worktrees/emails-list/src/commands/domains/delete.ts +0 -42
  59. package/.claude/worktrees/emails-list/src/commands/domains/get.ts +0 -47
  60. package/.claude/worktrees/emails-list/src/commands/domains/index.ts +0 -35
  61. package/.claude/worktrees/emails-list/src/commands/domains/list.ts +0 -53
  62. package/.claude/worktrees/emails-list/src/commands/domains/update.ts +0 -75
  63. package/.claude/worktrees/emails-list/src/commands/domains/utils.ts +0 -44
  64. package/.claude/worktrees/emails-list/src/commands/domains/verify.ts +0 -38
  65. package/.claude/worktrees/emails-list/src/commands/emails/batch.ts +0 -140
  66. package/.claude/worktrees/emails-list/src/commands/emails/index.ts +0 -28
  67. package/.claude/worktrees/emails-list/src/commands/emails/list.ts +0 -73
  68. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachment.ts +0 -55
  69. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachments.ts +0 -68
  70. package/.claude/worktrees/emails-list/src/commands/emails/receiving/get.ts +0 -58
  71. package/.claude/worktrees/emails-list/src/commands/emails/receiving/index.ts +0 -28
  72. package/.claude/worktrees/emails-list/src/commands/emails/receiving/list.ts +0 -59
  73. package/.claude/worktrees/emails-list/src/commands/emails/receiving/utils.ts +0 -38
  74. package/.claude/worktrees/emails-list/src/commands/emails/send.ts +0 -189
  75. package/.claude/worktrees/emails-list/src/commands/open.ts +0 -24
  76. package/.claude/worktrees/emails-list/src/commands/segments/create.ts +0 -50
  77. package/.claude/worktrees/emails-list/src/commands/segments/delete.ts +0 -47
  78. package/.claude/worktrees/emails-list/src/commands/segments/get.ts +0 -38
  79. package/.claude/worktrees/emails-list/src/commands/segments/index.ts +0 -36
  80. package/.claude/worktrees/emails-list/src/commands/segments/list.ts +0 -58
  81. package/.claude/worktrees/emails-list/src/commands/segments/utils.ts +0 -7
  82. package/.claude/worktrees/emails-list/src/commands/teams/index.ts +0 -10
  83. package/.claude/worktrees/emails-list/src/commands/teams/list.ts +0 -35
  84. package/.claude/worktrees/emails-list/src/commands/teams/remove.ts +0 -83
  85. package/.claude/worktrees/emails-list/src/commands/teams/switch.ts +0 -73
  86. package/.claude/worktrees/emails-list/src/commands/topics/create.ts +0 -73
  87. package/.claude/worktrees/emails-list/src/commands/topics/delete.ts +0 -47
  88. package/.claude/worktrees/emails-list/src/commands/topics/get.ts +0 -42
  89. package/.claude/worktrees/emails-list/src/commands/topics/index.ts +0 -42
  90. package/.claude/worktrees/emails-list/src/commands/topics/list.ts +0 -34
  91. package/.claude/worktrees/emails-list/src/commands/topics/update.ts +0 -59
  92. package/.claude/worktrees/emails-list/src/commands/topics/utils.ts +0 -16
  93. package/.claude/worktrees/emails-list/src/commands/webhooks/create.ts +0 -128
  94. package/.claude/worktrees/emails-list/src/commands/webhooks/delete.ts +0 -49
  95. package/.claude/worktrees/emails-list/src/commands/webhooks/get.ts +0 -42
  96. package/.claude/worktrees/emails-list/src/commands/webhooks/index.ts +0 -44
  97. package/.claude/worktrees/emails-list/src/commands/webhooks/list.ts +0 -55
  98. package/.claude/worktrees/emails-list/src/commands/webhooks/update.ts +0 -83
  99. package/.claude/worktrees/emails-list/src/commands/webhooks/utils.ts +0 -36
  100. package/.claude/worktrees/emails-list/src/commands/whoami.ts +0 -71
  101. package/.claude/worktrees/emails-list/src/lib/actions.ts +0 -157
  102. package/.claude/worktrees/emails-list/src/lib/client.ts +0 -34
  103. package/.claude/worktrees/emails-list/src/lib/config.ts +0 -211
  104. package/.claude/worktrees/emails-list/src/lib/files.ts +0 -15
  105. package/.claude/worktrees/emails-list/src/lib/help-text.ts +0 -38
  106. package/.claude/worktrees/emails-list/src/lib/output.ts +0 -54
  107. package/.claude/worktrees/emails-list/src/lib/pagination.ts +0 -36
  108. package/.claude/worktrees/emails-list/src/lib/prompts.ts +0 -149
  109. package/.claude/worktrees/emails-list/src/lib/spinner.ts +0 -93
  110. package/.claude/worktrees/emails-list/src/lib/table.ts +0 -57
  111. package/.claude/worktrees/emails-list/src/lib/tty.ts +0 -28
  112. package/.claude/worktrees/emails-list/src/lib/version.ts +0 -4
  113. package/.claude/worktrees/emails-list/tests/commands/api-keys/create.test.ts +0 -195
  114. package/.claude/worktrees/emails-list/tests/commands/api-keys/delete.test.ts +0 -156
  115. package/.claude/worktrees/emails-list/tests/commands/api-keys/list.test.ts +0 -133
  116. package/.claude/worktrees/emails-list/tests/commands/auth/login.test.ts +0 -119
  117. package/.claude/worktrees/emails-list/tests/commands/auth/logout.test.ts +0 -146
  118. package/.claude/worktrees/emails-list/tests/commands/broadcasts/create.test.ts +0 -447
  119. package/.claude/worktrees/emails-list/tests/commands/broadcasts/delete.test.ts +0 -182
  120. package/.claude/worktrees/emails-list/tests/commands/broadcasts/get.test.ts +0 -146
  121. package/.claude/worktrees/emails-list/tests/commands/broadcasts/list.test.ts +0 -196
  122. package/.claude/worktrees/emails-list/tests/commands/broadcasts/send.test.ts +0 -161
  123. package/.claude/worktrees/emails-list/tests/commands/broadcasts/update.test.ts +0 -283
  124. package/.claude/worktrees/emails-list/tests/commands/contact-properties/create.test.ts +0 -250
  125. package/.claude/worktrees/emails-list/tests/commands/contact-properties/delete.test.ts +0 -183
  126. package/.claude/worktrees/emails-list/tests/commands/contact-properties/get.test.ts +0 -144
  127. package/.claude/worktrees/emails-list/tests/commands/contact-properties/list.test.ts +0 -180
  128. package/.claude/worktrees/emails-list/tests/commands/contact-properties/update.test.ts +0 -216
  129. package/.claude/worktrees/emails-list/tests/commands/contacts/add-segment.test.ts +0 -188
  130. package/.claude/worktrees/emails-list/tests/commands/contacts/create.test.ts +0 -270
  131. package/.claude/worktrees/emails-list/tests/commands/contacts/delete.test.ts +0 -192
  132. package/.claude/worktrees/emails-list/tests/commands/contacts/get.test.ts +0 -148
  133. package/.claude/worktrees/emails-list/tests/commands/contacts/list.test.ts +0 -175
  134. package/.claude/worktrees/emails-list/tests/commands/contacts/remove-segment.test.ts +0 -166
  135. package/.claude/worktrees/emails-list/tests/commands/contacts/segments.test.ts +0 -167
  136. package/.claude/worktrees/emails-list/tests/commands/contacts/topics.test.ts +0 -163
  137. package/.claude/worktrees/emails-list/tests/commands/contacts/update-topics.test.ts +0 -247
  138. package/.claude/worktrees/emails-list/tests/commands/contacts/update.test.ts +0 -205
  139. package/.claude/worktrees/emails-list/tests/commands/doctor.test.ts +0 -165
  140. package/.claude/worktrees/emails-list/tests/commands/domains/create.test.ts +0 -192
  141. package/.claude/worktrees/emails-list/tests/commands/domains/delete.test.ts +0 -156
  142. package/.claude/worktrees/emails-list/tests/commands/domains/get.test.ts +0 -137
  143. package/.claude/worktrees/emails-list/tests/commands/domains/list.test.ts +0 -164
  144. package/.claude/worktrees/emails-list/tests/commands/domains/update.test.ts +0 -223
  145. package/.claude/worktrees/emails-list/tests/commands/domains/verify.test.ts +0 -117
  146. package/.claude/worktrees/emails-list/tests/commands/emails/batch.test.ts +0 -313
  147. package/.claude/worktrees/emails-list/tests/commands/emails/list.test.ts +0 -196
  148. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachment.test.ts +0 -140
  149. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachments.test.ts +0 -168
  150. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/get.test.ts +0 -140
  151. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/list.test.ts +0 -181
  152. package/.claude/worktrees/emails-list/tests/commands/emails/send.test.ts +0 -309
  153. package/.claude/worktrees/emails-list/tests/commands/segments/create.test.ts +0 -163
  154. package/.claude/worktrees/emails-list/tests/commands/segments/delete.test.ts +0 -182
  155. package/.claude/worktrees/emails-list/tests/commands/segments/get.test.ts +0 -137
  156. package/.claude/worktrees/emails-list/tests/commands/segments/list.test.ts +0 -173
  157. package/.claude/worktrees/emails-list/tests/commands/teams/list.test.ts +0 -63
  158. package/.claude/worktrees/emails-list/tests/commands/teams/remove.test.ts +0 -103
  159. package/.claude/worktrees/emails-list/tests/commands/teams/switch.test.ts +0 -96
  160. package/.claude/worktrees/emails-list/tests/commands/topics/create.test.ts +0 -191
  161. package/.claude/worktrees/emails-list/tests/commands/topics/delete.test.ts +0 -156
  162. package/.claude/worktrees/emails-list/tests/commands/topics/get.test.ts +0 -125
  163. package/.claude/worktrees/emails-list/tests/commands/topics/list.test.ts +0 -124
  164. package/.claude/worktrees/emails-list/tests/commands/topics/update.test.ts +0 -177
  165. package/.claude/worktrees/emails-list/tests/commands/webhooks/create.test.ts +0 -224
  166. package/.claude/worktrees/emails-list/tests/commands/webhooks/delete.test.ts +0 -156
  167. package/.claude/worktrees/emails-list/tests/commands/webhooks/get.test.ts +0 -125
  168. package/.claude/worktrees/emails-list/tests/commands/webhooks/list.test.ts +0 -177
  169. package/.claude/worktrees/emails-list/tests/commands/webhooks/update.test.ts +0 -206
  170. package/.claude/worktrees/emails-list/tests/commands/whoami.test.ts +0 -99
  171. package/.claude/worktrees/emails-list/tests/helpers.ts +0 -93
  172. package/.claude/worktrees/emails-list/tests/lib/client.test.ts +0 -71
  173. package/.claude/worktrees/emails-list/tests/lib/config.test.ts +0 -414
  174. package/.claude/worktrees/emails-list/tests/lib/files.test.ts +0 -65
  175. package/.claude/worktrees/emails-list/tests/lib/help-text.test.ts +0 -97
  176. package/.claude/worktrees/emails-list/tests/lib/output.test.ts +0 -127
  177. package/.claude/worktrees/emails-list/tests/lib/prompts.test.ts +0 -178
  178. package/.claude/worktrees/emails-list/tests/lib/spinner.test.ts +0 -146
  179. package/.claude/worktrees/emails-list/tests/lib/table.test.ts +0 -63
  180. package/.claude/worktrees/emails-list/tests/lib/tty.test.ts +0 -85
  181. package/.claude/worktrees/emails-list/tsconfig.json +0 -14
  182. package/.github/scripts/pr-title-check.js +0 -34
  183. package/.github/workflows/ci.yml +0 -32
  184. package/.github/workflows/pr-title-check.yml +0 -13
  185. package/.github/workflows/release.yml +0 -120
  186. package/.github/workflows/test-install-windows.yml +0 -48
  187. package/CHANGELOG.md +0 -31
  188. package/biome.json +0 -36
  189. package/bun.lock +0 -76
  190. package/bunfig.toml +0 -2
  191. package/docs/agent-dx-gaps.md +0 -167
  192. package/docs/missing-commands.md +0 -58
  193. package/docs/production-readiness.md +0 -99
  194. package/docs/secure-key-storage.md +0 -174
  195. package/install.ps1 +0 -141
  196. package/install.sh +0 -301
  197. package/renovate.json +0 -4
  198. package/src/cli.ts +0 -82
  199. package/src/commands/api-keys/create.ts +0 -114
  200. package/src/commands/api-keys/delete.ts +0 -47
  201. package/src/commands/api-keys/index.ts +0 -26
  202. package/src/commands/api-keys/list.ts +0 -35
  203. package/src/commands/api-keys/utils.ts +0 -8
  204. package/src/commands/auth/index.ts +0 -20
  205. package/src/commands/auth/login.ts +0 -207
  206. package/src/commands/auth/logout.ts +0 -105
  207. package/src/commands/broadcasts/create.ts +0 -196
  208. package/src/commands/broadcasts/delete.ts +0 -46
  209. package/src/commands/broadcasts/get.ts +0 -59
  210. package/src/commands/broadcasts/index.ts +0 -43
  211. package/src/commands/broadcasts/list.ts +0 -60
  212. package/src/commands/broadcasts/send.ts +0 -56
  213. package/src/commands/broadcasts/update.ts +0 -95
  214. package/src/commands/broadcasts/utils.ts +0 -35
  215. package/src/commands/contact-properties/create.ts +0 -118
  216. package/src/commands/contact-properties/delete.ts +0 -48
  217. package/src/commands/contact-properties/get.ts +0 -46
  218. package/src/commands/contact-properties/index.ts +0 -48
  219. package/src/commands/contact-properties/list.ts +0 -68
  220. package/src/commands/contact-properties/update.ts +0 -88
  221. package/src/commands/contact-properties/utils.ts +0 -17
  222. package/src/commands/contacts/add-segment.ts +0 -78
  223. package/src/commands/contacts/create.ts +0 -122
  224. package/src/commands/contacts/delete.ts +0 -49
  225. package/src/commands/contacts/get.ts +0 -53
  226. package/src/commands/contacts/index.ts +0 -58
  227. package/src/commands/contacts/list.ts +0 -57
  228. package/src/commands/contacts/remove-segment.ts +0 -48
  229. package/src/commands/contacts/segments.ts +0 -39
  230. package/src/commands/contacts/topics.ts +0 -45
  231. package/src/commands/contacts/update-topics.ts +0 -90
  232. package/src/commands/contacts/update.ts +0 -77
  233. package/src/commands/contacts/utils.ts +0 -119
  234. package/src/commands/doctor.ts +0 -298
  235. package/src/commands/domains/create.ts +0 -83
  236. package/src/commands/domains/delete.ts +0 -42
  237. package/src/commands/domains/get.ts +0 -47
  238. package/src/commands/domains/index.ts +0 -35
  239. package/src/commands/domains/list.ts +0 -53
  240. package/src/commands/domains/update.ts +0 -75
  241. package/src/commands/domains/utils.ts +0 -44
  242. package/src/commands/domains/verify.ts +0 -38
  243. package/src/commands/emails/batch.ts +0 -140
  244. package/src/commands/emails/index.ts +0 -24
  245. package/src/commands/emails/receiving/attachment.ts +0 -55
  246. package/src/commands/emails/receiving/attachments.ts +0 -68
  247. package/src/commands/emails/receiving/get.ts +0 -58
  248. package/src/commands/emails/receiving/index.ts +0 -28
  249. package/src/commands/emails/receiving/list.ts +0 -59
  250. package/src/commands/emails/receiving/utils.ts +0 -38
  251. package/src/commands/emails/send.ts +0 -189
  252. package/src/commands/open.ts +0 -24
  253. package/src/commands/segments/create.ts +0 -50
  254. package/src/commands/segments/delete.ts +0 -47
  255. package/src/commands/segments/get.ts +0 -38
  256. package/src/commands/segments/index.ts +0 -36
  257. package/src/commands/segments/list.ts +0 -58
  258. package/src/commands/segments/utils.ts +0 -7
  259. package/src/commands/teams/index.ts +0 -10
  260. package/src/commands/teams/list.ts +0 -35
  261. package/src/commands/teams/remove.ts +0 -83
  262. package/src/commands/teams/switch.ts +0 -73
  263. package/src/commands/topics/create.ts +0 -73
  264. package/src/commands/topics/delete.ts +0 -47
  265. package/src/commands/topics/get.ts +0 -42
  266. package/src/commands/topics/index.ts +0 -42
  267. package/src/commands/topics/list.ts +0 -34
  268. package/src/commands/topics/update.ts +0 -59
  269. package/src/commands/topics/utils.ts +0 -16
  270. package/src/commands/webhooks/create.ts +0 -128
  271. package/src/commands/webhooks/delete.ts +0 -49
  272. package/src/commands/webhooks/get.ts +0 -42
  273. package/src/commands/webhooks/index.ts +0 -44
  274. package/src/commands/webhooks/list.ts +0 -55
  275. package/src/commands/webhooks/update.ts +0 -83
  276. package/src/commands/webhooks/utils.ts +0 -36
  277. package/src/commands/whoami.ts +0 -71
  278. package/src/lib/actions.ts +0 -157
  279. package/src/lib/client.ts +0 -37
  280. package/src/lib/config.ts +0 -211
  281. package/src/lib/files.ts +0 -15
  282. package/src/lib/help-text.ts +0 -38
  283. package/src/lib/output.ts +0 -54
  284. package/src/lib/pagination.ts +0 -36
  285. package/src/lib/prompts.ts +0 -149
  286. package/src/lib/spinner.ts +0 -93
  287. package/src/lib/table.ts +0 -57
  288. package/src/lib/tty.ts +0 -28
  289. package/src/lib/version.ts +0 -4
  290. package/tests/commands/api-keys/create.test.ts +0 -195
  291. package/tests/commands/api-keys/delete.test.ts +0 -156
  292. package/tests/commands/api-keys/list.test.ts +0 -133
  293. package/tests/commands/auth/login.test.ts +0 -119
  294. package/tests/commands/auth/logout.test.ts +0 -146
  295. package/tests/commands/broadcasts/create.test.ts +0 -447
  296. package/tests/commands/broadcasts/delete.test.ts +0 -182
  297. package/tests/commands/broadcasts/get.test.ts +0 -146
  298. package/tests/commands/broadcasts/list.test.ts +0 -196
  299. package/tests/commands/broadcasts/send.test.ts +0 -161
  300. package/tests/commands/broadcasts/update.test.ts +0 -283
  301. package/tests/commands/contact-properties/create.test.ts +0 -250
  302. package/tests/commands/contact-properties/delete.test.ts +0 -183
  303. package/tests/commands/contact-properties/get.test.ts +0 -144
  304. package/tests/commands/contact-properties/list.test.ts +0 -180
  305. package/tests/commands/contact-properties/update.test.ts +0 -216
  306. package/tests/commands/contacts/add-segment.test.ts +0 -188
  307. package/tests/commands/contacts/create.test.ts +0 -270
  308. package/tests/commands/contacts/delete.test.ts +0 -192
  309. package/tests/commands/contacts/get.test.ts +0 -148
  310. package/tests/commands/contacts/list.test.ts +0 -175
  311. package/tests/commands/contacts/remove-segment.test.ts +0 -166
  312. package/tests/commands/contacts/segments.test.ts +0 -167
  313. package/tests/commands/contacts/topics.test.ts +0 -163
  314. package/tests/commands/contacts/update-topics.test.ts +0 -247
  315. package/tests/commands/contacts/update.test.ts +0 -205
  316. package/tests/commands/doctor.test.ts +0 -165
  317. package/tests/commands/domains/create.test.ts +0 -192
  318. package/tests/commands/domains/delete.test.ts +0 -156
  319. package/tests/commands/domains/get.test.ts +0 -137
  320. package/tests/commands/domains/list.test.ts +0 -164
  321. package/tests/commands/domains/update.test.ts +0 -223
  322. package/tests/commands/domains/verify.test.ts +0 -117
  323. package/tests/commands/emails/batch.test.ts +0 -313
  324. package/tests/commands/emails/receiving/attachment.test.ts +0 -140
  325. package/tests/commands/emails/receiving/attachments.test.ts +0 -168
  326. package/tests/commands/emails/receiving/get.test.ts +0 -140
  327. package/tests/commands/emails/receiving/list.test.ts +0 -181
  328. package/tests/commands/emails/send.test.ts +0 -309
  329. package/tests/commands/segments/create.test.ts +0 -163
  330. package/tests/commands/segments/delete.test.ts +0 -182
  331. package/tests/commands/segments/get.test.ts +0 -137
  332. package/tests/commands/segments/list.test.ts +0 -173
  333. package/tests/commands/teams/list.test.ts +0 -63
  334. package/tests/commands/teams/remove.test.ts +0 -103
  335. package/tests/commands/teams/switch.test.ts +0 -96
  336. package/tests/commands/topics/create.test.ts +0 -191
  337. package/tests/commands/topics/delete.test.ts +0 -156
  338. package/tests/commands/topics/get.test.ts +0 -125
  339. package/tests/commands/topics/list.test.ts +0 -124
  340. package/tests/commands/topics/update.test.ts +0 -177
  341. package/tests/commands/webhooks/create.test.ts +0 -224
  342. package/tests/commands/webhooks/delete.test.ts +0 -156
  343. package/tests/commands/webhooks/get.test.ts +0 -125
  344. package/tests/commands/webhooks/list.test.ts +0 -177
  345. package/tests/commands/webhooks/update.test.ts +0 -206
  346. package/tests/commands/whoami.test.ts +0 -99
  347. package/tests/helpers.ts +0 -93
  348. package/tests/lib/client.test.ts +0 -71
  349. package/tests/lib/config.test.ts +0 -414
  350. package/tests/lib/files.test.ts +0 -65
  351. package/tests/lib/help-text.test.ts +0 -97
  352. package/tests/lib/output.test.ts +0 -127
  353. package/tests/lib/prompts.test.ts +0 -178
  354. package/tests/lib/spinner.test.ts +0 -146
  355. package/tests/lib/table.test.ts +0 -63
  356. package/tests/lib/tty.test.ts +0 -85
  357. package/tsconfig.json +0 -14
@@ -1,83 +0,0 @@
1
- import { Command, Option } from '@commander-js/extra-typings';
2
- import type { WebhookEvent } from 'resend';
3
- import { runWrite } from '../../lib/actions';
4
- import type { GlobalOpts } from '../../lib/client';
5
- import { buildHelpText } from '../../lib/help-text';
6
- import { outputError } from '../../lib/output';
7
- import { ALL_WEBHOOK_EVENTS } from './utils';
8
-
9
- export const updateWebhookCommand = new Command('update')
10
- .description(
11
- "Update a webhook's endpoint URL, event subscriptions, or enabled status",
12
- )
13
- .argument('<id>', 'Webhook UUID')
14
- .option('--endpoint <endpoint>', 'New HTTPS URL for this webhook')
15
- .option(
16
- '--events <events...>',
17
- 'Replace the full event subscription list. Use "all" for all 17 events.',
18
- )
19
- .addOption(
20
- new Option(
21
- '--status <status>',
22
- 'Enable or disable event delivery for this webhook',
23
- ).choices(['enabled', 'disabled'] as const),
24
- )
25
- .addHelpText(
26
- 'after',
27
- buildHelpText({
28
- context: `At least one of --endpoint, --events, or --status must be provided.
29
-
30
- --events replaces the entire event list (it is not additive).
31
- Use "all" as a shorthand for all 17 event types.
32
-
33
- --status controls whether events are delivered to this endpoint:
34
- enabled Events are delivered (default on creation)
35
- disabled Events are suppressed without deleting the webhook`,
36
- output: ` {"object":"webhook","id":"<uuid>"}`,
37
- errorCodes: ['auth_error', 'no_changes', 'update_error'],
38
- examples: [
39
- 'resend webhooks update wh_abc123 --endpoint https://new-app.example.com/hooks/resend',
40
- 'resend webhooks update wh_abc123 --events email.sent email.bounced',
41
- 'resend webhooks update wh_abc123 --events all',
42
- 'resend webhooks update wh_abc123 --status disabled',
43
- 'resend webhooks update wh_abc123 --endpoint https://new-app.example.com/hooks/resend --events all --json',
44
- ],
45
- }),
46
- )
47
- .action(async (id, opts, cmd) => {
48
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
49
-
50
- if (!opts.endpoint && !opts.events?.length && !opts.status) {
51
- outputError(
52
- {
53
- message:
54
- 'Provide at least one option to update: --endpoint, --events, or --status.',
55
- code: 'no_changes',
56
- },
57
- { json: globalOpts.json },
58
- );
59
- }
60
-
61
- const selectedEvents = opts.events?.includes('all')
62
- ? ALL_WEBHOOK_EVENTS
63
- : (opts.events as WebhookEvent[] | undefined);
64
-
65
- await runWrite(
66
- {
67
- spinner: {
68
- loading: 'Updating webhook...',
69
- success: 'Webhook updated',
70
- fail: 'Failed to update webhook',
71
- },
72
- sdkCall: (resend) =>
73
- resend.webhooks.update(id, {
74
- ...(opts.endpoint && { endpoint: opts.endpoint }),
75
- ...(selectedEvents?.length && { events: selectedEvents }),
76
- ...(opts.status && { status: opts.status }),
77
- }),
78
- errorCode: 'update_error',
79
- successMsg: `Webhook updated: ${id}`,
80
- },
81
- globalOpts,
82
- );
83
- });
@@ -1,36 +0,0 @@
1
- import type { Webhook, WebhookEvent } from 'resend';
2
- import { renderTable } from '../../lib/table';
3
-
4
- export const ALL_WEBHOOK_EVENTS: WebhookEvent[] = [
5
- 'email.sent',
6
- 'email.delivered',
7
- 'email.delivery_delayed',
8
- 'email.bounced',
9
- 'email.complained',
10
- 'email.opened',
11
- 'email.clicked',
12
- 'email.failed',
13
- 'email.scheduled',
14
- 'email.suppressed',
15
- 'email.received',
16
- 'contact.created',
17
- 'contact.updated',
18
- 'contact.deleted',
19
- 'domain.created',
20
- 'domain.updated',
21
- 'domain.deleted',
22
- ];
23
-
24
- export function renderWebhooksTable(webhooks: Webhook[]): string {
25
- const rows = webhooks.map((w) => {
26
- const eventsStr = (w.events ?? []).join(', ');
27
- const events =
28
- eventsStr.length > 60 ? `${eventsStr.slice(0, 57)}...` : eventsStr;
29
- return [w.endpoint, events, w.status, w.id];
30
- });
31
- return renderTable(
32
- ['Endpoint', 'Events', 'Status', 'ID'],
33
- rows,
34
- '(no webhooks)',
35
- );
36
- }
@@ -1,71 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import type { GlobalOpts } from '../lib/client';
3
- import { maskKey, resolveApiKey, resolveTeamName } from '../lib/config';
4
- import { buildHelpText } from '../lib/help-text';
5
- import { outputError, outputResult } from '../lib/output';
6
- import { isInteractive } from '../lib/tty';
7
-
8
- export const whoamiCommand = new Command('whoami')
9
- .description('Show current authentication status')
10
- .addHelpText(
11
- 'after',
12
- buildHelpText({
13
- setup: true,
14
- context: `Local only — no network calls.
15
- Shows which team is active and where the API key comes from.`,
16
- output: ` {"authenticated":true,"team":"production","api_key":"re_...abcd","source":"config"}
17
- {"authenticated":false}`,
18
- examples: [
19
- 'resend whoami',
20
- 'resend whoami --json',
21
- 'resend whoami --team production',
22
- ],
23
- }),
24
- )
25
- .action((_opts, cmd) => {
26
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
27
- const teamName = globalOpts.team;
28
- const resolved = resolveApiKey(globalOpts.apiKey, teamName);
29
-
30
- if (!resolved) {
31
- if (globalOpts.json || !isInteractive()) {
32
- outputResult(
33
- { authenticated: false },
34
- { json: globalOpts.json, exitCode: 1 },
35
- );
36
- // outputResult with exitCode calls process.exit, but TS doesn't know
37
- return;
38
- }
39
- outputError(
40
- {
41
- message: 'Not authenticated.\nRun `resend login` to get started.',
42
- code: 'not_authenticated',
43
- },
44
- { json: false },
45
- );
46
- return;
47
- }
48
-
49
- const team = resolved.team ?? resolveTeamName(teamName);
50
-
51
- if (globalOpts.json || !isInteractive()) {
52
- outputResult(
53
- {
54
- authenticated: true,
55
- team,
56
- api_key: maskKey(resolved.key),
57
- source: resolved.source,
58
- },
59
- { json: globalOpts.json },
60
- );
61
- return;
62
- }
63
-
64
- console.log('');
65
- console.log(` Team: ${team}`);
66
- console.log(` API Key: ${maskKey(resolved.key)}`);
67
- console.log(
68
- ` Source: ${resolved.source === 'config' ? 'config file' : resolved.source === 'env' ? 'environment variable' : 'flag'}`,
69
- );
70
- console.log('');
71
- });
@@ -1,157 +0,0 @@
1
- import type { Resend } from 'resend';
2
- import type { GlobalOpts } from './client';
3
- import { requireClient } from './client';
4
- import { outputResult } from './output';
5
- import { confirmDelete } from './prompts';
6
- import { withSpinner } from './spinner';
7
- import { isInteractive } from './tty';
8
-
9
- type SdkCall<T> = (
10
- resend: Resend,
11
- ) => Promise<{ data: T | null; error: { message: string } | null }>;
12
- type SpinnerMessages = { loading: string; success: string; fail: string };
13
-
14
- /**
15
- * Shared pattern for all get commands:
16
- * requireClient → withSpinner(fetch_error) → if/else output
17
- */
18
- export async function runGet<T>(
19
- config: {
20
- spinner: SpinnerMessages;
21
- sdkCall: SdkCall<T>;
22
- onInteractive: (data: T) => void;
23
- },
24
- globalOpts: GlobalOpts,
25
- ): Promise<void> {
26
- const resend = requireClient(globalOpts);
27
- const data = await withSpinner(
28
- config.spinner,
29
- () => config.sdkCall(resend),
30
- 'fetch_error',
31
- globalOpts,
32
- );
33
- if (!globalOpts.json && isInteractive()) {
34
- config.onInteractive(data);
35
- } else {
36
- outputResult(data, { json: globalOpts.json });
37
- }
38
- }
39
-
40
- /**
41
- * Shared pattern for all delete commands:
42
- * requireClient → confirmDelete (if needed) → withSpinner → if/else output
43
- */
44
- export async function runDelete(
45
- id: string,
46
- skipConfirm: boolean,
47
- config: {
48
- confirmMessage: string;
49
- spinner: SpinnerMessages;
50
- object: string;
51
- successMsg: string;
52
- sdkCall: SdkCall<unknown>;
53
- },
54
- globalOpts: GlobalOpts,
55
- ): Promise<void> {
56
- const resend = requireClient(globalOpts);
57
- if (!skipConfirm) {
58
- await confirmDelete(id, config.confirmMessage, globalOpts);
59
- }
60
- await withSpinner(
61
- config.spinner,
62
- () => config.sdkCall(resend),
63
- 'delete_error',
64
- globalOpts,
65
- );
66
- if (!globalOpts.json && isInteractive()) {
67
- console.log(config.successMsg);
68
- } else {
69
- outputResult(
70
- { object: config.object, id, deleted: true },
71
- { json: globalOpts.json },
72
- );
73
- }
74
- }
75
-
76
- /**
77
- * Shared pattern for create commands:
78
- * requireClient → withSpinner('create_error') → if/else output
79
- */
80
- export async function runCreate<T>(
81
- config: {
82
- spinner: SpinnerMessages;
83
- sdkCall: SdkCall<T>;
84
- onInteractive: (data: T) => void;
85
- },
86
- globalOpts: GlobalOpts,
87
- ): Promise<void> {
88
- const resend = requireClient(globalOpts);
89
- const data = await withSpinner(
90
- config.spinner,
91
- () => config.sdkCall(resend),
92
- 'create_error',
93
- globalOpts,
94
- );
95
- if (!globalOpts.json && isInteractive()) {
96
- config.onInteractive(data);
97
- } else {
98
- outputResult(data, { json: globalOpts.json });
99
- }
100
- }
101
-
102
- /**
103
- * Shared pattern for write commands (update/verify/remove-segment) where
104
- * interactive output is a single status message:
105
- * requireClient → withSpinner(errorCode) → if/else output
106
- */
107
- export async function runWrite<T>(
108
- config: {
109
- spinner: SpinnerMessages;
110
- sdkCall: SdkCall<T>;
111
- errorCode: string;
112
- successMsg: string;
113
- },
114
- globalOpts: GlobalOpts,
115
- ): Promise<void> {
116
- const resend = requireClient(globalOpts);
117
- const data = await withSpinner(
118
- config.spinner,
119
- () => config.sdkCall(resend),
120
- config.errorCode,
121
- globalOpts,
122
- );
123
- if (!globalOpts.json && isInteractive()) {
124
- console.log(config.successMsg);
125
- } else {
126
- outputResult(data, { json: globalOpts.json });
127
- }
128
- }
129
-
130
- /**
131
- * Shared pattern for all list commands:
132
- * requireClient → withSpinner → if/else output
133
- *
134
- * Callers pass pagination opts (if any) via the sdkCall closure.
135
- * The onInteractive callback handles table rendering and pagination hints.
136
- */
137
- export async function runList<T>(
138
- config: {
139
- spinner: SpinnerMessages;
140
- sdkCall: SdkCall<T>;
141
- onInteractive: (result: T) => void;
142
- },
143
- globalOpts: GlobalOpts,
144
- ): Promise<void> {
145
- const resend = requireClient(globalOpts);
146
- const result = await withSpinner(
147
- config.spinner,
148
- () => config.sdkCall(resend),
149
- 'list_error',
150
- globalOpts,
151
- );
152
- if (!globalOpts.json && isInteractive()) {
153
- config.onInteractive(result);
154
- } else {
155
- outputResult(result, { json: globalOpts.json });
156
- }
157
- }
package/src/lib/client.ts DELETED
@@ -1,37 +0,0 @@
1
- import { Resend } from 'resend';
2
- import { resolveApiKey } from './config';
3
- import { errorMessage, outputError } from './output';
4
- import { VERSION } from './version';
5
-
6
- export type GlobalOpts = {
7
- apiKey?: string;
8
- json?: boolean;
9
- quiet?: boolean;
10
- team?: string;
11
- };
12
-
13
- process.env.RESEND_USER_AGENT = `resend-cli:${VERSION}`;
14
-
15
- export function createClient(flagValue?: string, teamName?: string): Resend {
16
- const resolved = resolveApiKey(flagValue, teamName);
17
- if (!resolved) {
18
- throw new Error(
19
- 'No API key found. Set RESEND_API_KEY, use --api-key, or run: resend login',
20
- );
21
- }
22
- return new Resend(resolved.key);
23
- }
24
-
25
- export function requireClient(opts: GlobalOpts): Resend {
26
- try {
27
- return createClient(opts.apiKey, opts.team);
28
- } catch (err) {
29
- outputError(
30
- {
31
- message: errorMessage(err, 'Failed to create client'),
32
- code: 'auth_error',
33
- },
34
- { json: opts.json },
35
- );
36
- }
37
- }
package/src/lib/config.ts DELETED
@@ -1,211 +0,0 @@
1
- import { chmodSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
- import { homedir } from 'node:os';
3
- import { join } from 'node:path';
4
-
5
- export type ApiKeySource = 'flag' | 'env' | 'config';
6
- export type ResolvedKey = { key: string; source: ApiKeySource; team?: string };
7
-
8
- export type TeamProfile = { api_key: string };
9
- export type CredentialsFile = {
10
- active_team: string;
11
- teams: Record<string, TeamProfile>;
12
- };
13
-
14
- export function getConfigDir(): string {
15
- if (process.env.XDG_CONFIG_HOME) {
16
- return join(process.env.XDG_CONFIG_HOME, 'resend');
17
- }
18
- if (process.platform === 'win32' && process.env.APPDATA) {
19
- return join(process.env.APPDATA, 'resend');
20
- }
21
- return join(homedir(), '.config', 'resend');
22
- }
23
-
24
- function getCredentialsPath(): string {
25
- return join(getConfigDir(), 'credentials.json');
26
- }
27
-
28
- export function readCredentials(): CredentialsFile | null {
29
- try {
30
- const data = JSON.parse(readFileSync(getCredentialsPath(), 'utf-8'));
31
- // Support legacy format: { api_key: "re_xxx" }
32
- if (data.api_key && !data.teams) {
33
- return {
34
- active_team: 'default',
35
- teams: { default: { api_key: data.api_key } },
36
- };
37
- }
38
- if (data.teams) {
39
- return data as CredentialsFile;
40
- }
41
- return null;
42
- } catch {
43
- return null;
44
- }
45
- }
46
-
47
- export function writeCredentials(creds: CredentialsFile): string {
48
- const configDir = getConfigDir();
49
- mkdirSync(configDir, { recursive: true, mode: 0o700 });
50
-
51
- const configPath = getCredentialsPath();
52
- writeFileSync(configPath, `${JSON.stringify(creds, null, 2)}\n`, {
53
- mode: 0o600,
54
- });
55
- chmodSync(configPath, 0o600);
56
-
57
- return configPath;
58
- }
59
-
60
- export function resolveTeamName(flagValue?: string): string {
61
- if (flagValue) {
62
- return flagValue;
63
- }
64
-
65
- const envTeam = process.env.RESEND_TEAM;
66
- if (envTeam) {
67
- return envTeam;
68
- }
69
-
70
- const creds = readCredentials();
71
- if (creds?.active_team) {
72
- return creds.active_team;
73
- }
74
-
75
- return 'default';
76
- }
77
-
78
- export function resolveApiKey(
79
- flagValue?: string,
80
- teamName?: string,
81
- ): ResolvedKey | null {
82
- if (flagValue) {
83
- return { key: flagValue, source: 'flag' };
84
- }
85
-
86
- const envKey = process.env.RESEND_API_KEY;
87
- if (envKey) {
88
- return { key: envKey, source: 'env' };
89
- }
90
-
91
- const creds = readCredentials();
92
- if (creds) {
93
- const team = resolveTeamName(teamName);
94
- const profile = creds.teams[team];
95
- if (profile?.api_key) {
96
- return { key: profile.api_key, source: 'config', team };
97
- }
98
- }
99
-
100
- return null;
101
- }
102
-
103
- export function storeApiKey(apiKey: string, teamName?: string): string {
104
- const team = teamName || 'default';
105
- const creds = readCredentials() || { active_team: 'default', teams: {} };
106
-
107
- creds.teams[team] = { api_key: apiKey };
108
-
109
- // If this is the first team, set it as active
110
- if (Object.keys(creds.teams).length === 1) {
111
- creds.active_team = team;
112
- }
113
-
114
- return writeCredentials(creds);
115
- }
116
-
117
- export function removeAllApiKeys(): string {
118
- const configPath = getCredentialsPath();
119
- const { unlinkSync } = require('node:fs');
120
- unlinkSync(configPath);
121
- return configPath;
122
- }
123
-
124
- export function removeApiKey(teamName?: string): string {
125
- const creds = readCredentials();
126
- if (!creds) {
127
- const configPath = getCredentialsPath();
128
- // Try to delete legacy file
129
- const { unlinkSync } = require('node:fs');
130
- unlinkSync(configPath);
131
- return configPath;
132
- }
133
-
134
- const team = teamName || resolveTeamName();
135
- delete creds.teams[team];
136
-
137
- // If we removed the active team, switch to first available or "default"
138
- if (creds.active_team === team) {
139
- const remaining = Object.keys(creds.teams);
140
- creds.active_team = remaining[0] || 'default';
141
- }
142
-
143
- // If no teams left, delete the file
144
- if (Object.keys(creds.teams).length === 0) {
145
- const { unlinkSync } = require('node:fs');
146
- const configPath = getCredentialsPath();
147
- unlinkSync(configPath);
148
- return configPath;
149
- }
150
-
151
- return writeCredentials(creds);
152
- }
153
-
154
- export function setActiveTeam(teamName: string): void {
155
- const creds = readCredentials();
156
- if (!creds) {
157
- throw new Error('No credentials file found. Run: resend login');
158
- }
159
- if (!creds.teams[teamName]) {
160
- throw new Error(
161
- `Team "${teamName}" not found. Available teams: ${Object.keys(creds.teams).join(', ')}`,
162
- );
163
- }
164
- creds.active_team = teamName;
165
- writeCredentials(creds);
166
- }
167
-
168
- export function listTeams(): Array<{ name: string; active: boolean }> {
169
- const creds = readCredentials();
170
- if (!creds) {
171
- return [];
172
- }
173
- return Object.keys(creds.teams).map((name) => ({
174
- name,
175
- active: name === creds.active_team,
176
- }));
177
- }
178
-
179
- export function maskKey(key: string): string {
180
- if (key.length <= 7) {
181
- return `${key.slice(0, 3)}...`;
182
- }
183
- return `${key.slice(0, 3)}...${key.slice(-4)}`;
184
- }
185
-
186
- export function removeTeam(teamName: string): void {
187
- const creds = readCredentials();
188
- if (!creds) {
189
- throw new Error('No credentials file found.');
190
- }
191
- if (!creds.teams[teamName]) {
192
- throw new Error(
193
- `Team "${teamName}" not found. Available teams: ${Object.keys(creds.teams).join(', ')}`,
194
- );
195
- }
196
-
197
- delete creds.teams[teamName];
198
-
199
- if (creds.active_team === teamName) {
200
- const remaining = Object.keys(creds.teams);
201
- creds.active_team = remaining[0] || 'default';
202
- }
203
-
204
- if (Object.keys(creds.teams).length === 0) {
205
- const { unlinkSync } = require('node:fs');
206
- unlinkSync(getCredentialsPath());
207
- return;
208
- }
209
-
210
- writeCredentials(creds);
211
- }
package/src/lib/files.ts DELETED
@@ -1,15 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import type { GlobalOpts } from './client';
3
- import { outputError } from './output';
4
-
5
- /** Read a text file, exiting with file_read_error if unreadable. */
6
- export function readFile(filePath: string, globalOpts: GlobalOpts): string {
7
- try {
8
- return readFileSync(filePath, 'utf-8');
9
- } catch {
10
- outputError(
11
- { message: `Failed to read file: ${filePath}`, code: 'file_read_error' },
12
- { json: globalOpts.json },
13
- );
14
- }
15
- }
@@ -1,38 +0,0 @@
1
- export interface HelpTextOptions {
2
- context?: string; // All text before Global options (includes Non-interactive line if needed)
3
- output?: string; // Content after "Output (--json or piped):" header (raw string, may be multi-line)
4
- errorCodes?: string[]; // ['auth_error', 'list_error'] — joined with ' | '
5
- examples: string[]; // Command strings without '$ ' prefix (added automatically)
6
- setup?: boolean; // true = --json only (no --api-key); default false = full API variant
7
- }
8
-
9
- const GLOBAL_OPTS_FULL = `Global options:
10
- --api-key <key> API key (or set RESEND_API_KEY env var)
11
- --team <name> Team profile to use (overrides RESEND_TEAM)
12
- --json Force JSON output (also auto-enabled when stdout is piped)
13
- -q, --quiet Suppress spinners and status output (implies --json)`;
14
-
15
- const GLOBAL_OPTS_SETUP = `Global options:
16
- --team <name> Team profile to save the key to
17
- --json Force JSON output
18
- -q, --quiet Suppress spinners and status output (implies --json)`;
19
-
20
- const ERROR_ENVELOPE = ` {"error":{"message":"<message>","code":"<code>"}}`;
21
-
22
- export function buildHelpText(opts: HelpTextOptions): string {
23
- const parts: string[] = [];
24
- if (opts.context != null) {
25
- parts.push(opts.context);
26
- }
27
- parts.push(opts.setup ? GLOBAL_OPTS_SETUP : GLOBAL_OPTS_FULL);
28
- if (opts.output != null) {
29
- parts.push(`Output (--json or piped):\n${opts.output}`);
30
- }
31
- if (opts.errorCodes != null) {
32
- parts.push(
33
- `Errors (exit code 1):\n${ERROR_ENVELOPE}\n Codes: ${opts.errorCodes.join(' | ')}`,
34
- );
35
- }
36
- parts.push(`Examples:\n${opts.examples.map((e) => ` $ ${e}`).join('\n')}`);
37
- return `\n${parts.join('\n\n')}`;
38
- }
package/src/lib/output.ts DELETED
@@ -1,54 +0,0 @@
1
- export function errorMessage(err: unknown, fallback: string): string {
2
- return err instanceof Error ? err.message : fallback;
3
- }
4
-
5
- export interface OutputOptions {
6
- json?: boolean;
7
- exitCode?: number;
8
- }
9
-
10
- function shouldOutputJson(json?: boolean): boolean {
11
- if (json) {
12
- return true;
13
- }
14
- if (!process.stdout.isTTY) {
15
- return true;
16
- }
17
- return false;
18
- }
19
-
20
- export function outputResult(data: unknown, opts: OutputOptions = {}): void {
21
- if (shouldOutputJson(opts.json)) {
22
- console.log(JSON.stringify(data, null, 2));
23
- } else {
24
- if (typeof data === 'string') {
25
- console.log(data);
26
- } else {
27
- console.log(JSON.stringify(data, null, 2));
28
- }
29
- }
30
- if (opts.exitCode !== undefined) {
31
- process.exit(opts.exitCode);
32
- }
33
- }
34
-
35
- export function outputError(
36
- error: { message: string; code?: string },
37
- opts: OutputOptions = {},
38
- ): never {
39
- const exitCode = opts.exitCode ?? 1;
40
-
41
- if (shouldOutputJson(opts.json)) {
42
- console.error(
43
- JSON.stringify(
44
- { error: { message: error.message, code: error.code ?? 'unknown' } },
45
- null,
46
- 2,
47
- ),
48
- );
49
- } else {
50
- console.error(`Error: ${error.message}`);
51
- }
52
-
53
- process.exit(exitCode);
54
- }