resend-cli 1.1.0 → 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 (205) hide show
  1. package/.claude/settings.local.json +1 -10
  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/workflows/ci.yml +3 -3
  180. package/.github/workflows/pr-title-check.yml +1 -1
  181. package/.github/workflows/release.yml +2 -2
  182. package/.github/workflows/test-build-windows.yml +44 -0
  183. package/.github/workflows/test-install-windows.yml +48 -0
  184. package/README.md +8 -0
  185. package/docs/agent-dx-gaps.md +167 -0
  186. package/docs/missing-commands.md +58 -0
  187. package/docs/production-readiness.md +99 -0
  188. package/docs/secure-key-storage.md +174 -0
  189. package/install.ps1 +1 -0
  190. package/install.sh +11 -4
  191. package/package.json +1 -1
  192. package/renovate.json +4 -0
  193. package/src/cli.ts +9 -0
  194. package/src/commands/auth/login.ts +34 -13
  195. package/src/commands/doctor.ts +3 -3
  196. package/src/commands/open.ts +24 -0
  197. package/src/commands/teams/remove.ts +5 -2
  198. package/src/commands/teams/switch.ts +3 -0
  199. package/src/lib/client.ts +6 -1
  200. package/src/lib/config.ts +37 -30
  201. package/src/lib/help-text.ts +4 -2
  202. package/src/lib/spinner.ts +7 -3
  203. package/tests/commands/auth/login.test.ts +35 -0
  204. package/tests/lib/config.test.ts +40 -7
  205. package/tests/lib/help-text.test.ts +2 -1
@@ -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
+ });
@@ -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
+ }
@@ -10,7 +10,7 @@ jobs:
10
10
  lint:
11
11
  runs-on: blacksmith-2vcpu-ubuntu-2204
12
12
  steps:
13
- - uses: actions/checkout@v4
13
+ - uses: actions/checkout@v6
14
14
  - uses: oven-sh/setup-bun@v2
15
15
  - run: bun install --frozen-lockfile
16
16
  - run: bun run lint
@@ -18,7 +18,7 @@ jobs:
18
18
  typecheck:
19
19
  runs-on: blacksmith-2vcpu-ubuntu-2204
20
20
  steps:
21
- - uses: actions/checkout@v4
21
+ - uses: actions/checkout@v6
22
22
  - uses: oven-sh/setup-bun@v2
23
23
  - run: bun install --frozen-lockfile
24
24
  - run: bun run typecheck
@@ -26,7 +26,7 @@ jobs:
26
26
  test:
27
27
  runs-on: blacksmith-2vcpu-ubuntu-2204
28
28
  steps:
29
- - uses: actions/checkout@v4
29
+ - uses: actions/checkout@v6
30
30
  - uses: oven-sh/setup-bun@v2
31
31
  - run: bun install --frozen-lockfile
32
32
  - run: bun run test
@@ -9,5 +9,5 @@ jobs:
9
9
  pr-title-check:
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
- - uses: actions/checkout@v4
12
+ - uses: actions/checkout@v6
13
13
  - run: node .github/scripts/pr-title-check.js
@@ -12,7 +12,7 @@ jobs:
12
12
  release:
13
13
  runs-on: blacksmith-2vcpu-ubuntu-2204
14
14
  steps:
15
- - uses: actions/checkout@v4
15
+ - uses: actions/checkout@v6
16
16
 
17
17
  - uses: oven-sh/setup-bun@v2
18
18
 
@@ -25,7 +25,7 @@ jobs:
25
25
  bun build --compile --minify --sourcemap --bytecode src/cli.ts --target=bun-darwin-x64 --outfile dist/resend-darwin-x64
26
26
  bun build --compile --minify --sourcemap --bytecode src/cli.ts --target=bun-linux-x64 --outfile dist/resend-linux-x64
27
27
  bun build --compile --minify --sourcemap --bytecode src/cli.ts --target=bun-linux-arm64 --outfile dist/resend-linux-arm64
28
- bun build --compile --minify --sourcemap --bytecode src/cli.ts --target=bun-windows-x64 --outfile dist/resend-windows-x64.exe
28
+ bun build --compile --minify --sourcemap src/cli.ts --target=bun-windows-x64 --outfile dist/resend-windows-x64.exe
29
29
 
30
30
  - name: Verify binaries
31
31
  run: |
@@ -0,0 +1,44 @@
1
+ name: Test Windows Build
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ paths:
9
+ - src/**
10
+ - .github/workflows/test-build-windows.yml
11
+ - .github/workflows/release.yml
12
+ - bun.lock
13
+ workflow_dispatch:
14
+
15
+ jobs:
16
+ build:
17
+ runs-on: windows-latest
18
+ steps:
19
+ - uses: actions/checkout@v6
20
+
21
+ - uses: oven-sh/setup-bun@v2
22
+
23
+ - name: Install dependencies
24
+ run: bun install --frozen-lockfile
25
+
26
+ - name: Build Windows binary
27
+ run: bun build --compile --minify --sourcemap src/cli.ts --target=bun-windows-x64 --outfile dist/resend-windows-x64.exe
28
+
29
+ - name: Verify binary exists
30
+ shell: pwsh
31
+ run: |
32
+ if (-not (Test-Path dist\resend-windows-x64.exe)) {
33
+ Write-Error "Binary not found"
34
+ exit 1
35
+ }
36
+
37
+ - name: Verify binary runs
38
+ shell: pwsh
39
+ run: |
40
+ & dist\resend-windows-x64.exe --version
41
+ if ($LASTEXITCODE -ne 0) {
42
+ Write-Error "resend --version failed"
43
+ exit 1
44
+ }
@@ -0,0 +1,48 @@
1
+ name: Test Windows Installer
2
+
3
+ on:
4
+ pull_request:
5
+ paths:
6
+ - install.ps1
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: windows-latest
12
+ steps:
13
+ - uses: actions/checkout@v6
14
+
15
+ - name: Run install.ps1 from repo
16
+ shell: pwsh
17
+ run: .\install.ps1
18
+
19
+ - name: Verify binary exists
20
+ shell: pwsh
21
+ run: |
22
+ $exe = "$env:USERPROFILE\.resend\bin\resend.exe"
23
+ if (-not (Test-Path $exe)) {
24
+ Write-Error "Binary not found at $exe"
25
+ exit 1
26
+ }
27
+ Write-Host "Found binary at $exe"
28
+
29
+ - name: Verify binary runs
30
+ shell: pwsh
31
+ run: |
32
+ $exe = "$env:USERPROFILE\.resend\bin\resend.exe"
33
+ & $exe --version
34
+ if ($LASTEXITCODE -ne 0) {
35
+ Write-Error "resend --version failed"
36
+ exit 1
37
+ }
38
+
39
+ - name: Verify PATH was updated
40
+ shell: pwsh
41
+ run: |
42
+ $binDir = "$env:USERPROFILE\.resend\bin"
43
+ $path = [Environment]::GetEnvironmentVariable("PATH", "User")
44
+ if ($path -notlike "*$binDir*") {
45
+ Write-Error "$binDir was not added to PATH"
46
+ exit 1
47
+ }
48
+ Write-Host "PATH correctly updated"
package/README.md CHANGED
@@ -4,6 +4,14 @@ Command-line interface for the [Resend](https://resend.com) email API. Works for
4
4
 
5
5
  ## Install
6
6
 
7
+ ### Homebrew (macOS)
8
+
9
+ ```bash
10
+ brew install resend/cli/resend
11
+ ```
12
+
13
+ ### Shell script (macOS and Linux)
14
+
7
15
  ```bash
8
16
  curl -fsSL https://resend.com/install.sh | bash
9
17
  ```