resend-cli 1.2.0 → 1.2.2

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 (193) hide show
  1. package/.github/workflows/release.yml +35 -8
  2. package/README.md +12 -1
  3. package/biome.json +1 -1
  4. package/bun.lock +0 -3
  5. package/package.json +3 -4
  6. package/src/cli.ts +23 -5
  7. package/src/commands/auth/login.ts +10 -8
  8. package/src/commands/doctor.ts +30 -112
  9. package/src/lib/client.ts +3 -0
  10. package/src/lib/config.ts +2 -3
  11. package/src/lib/spinner.ts +17 -10
  12. package/src/lib/update-check.ts +172 -0
  13. package/tests/commands/auth/login.test.ts +3 -1
  14. package/tests/lib/config.test.ts +4 -6
  15. package/tests/lib/update-check.test.ts +169 -0
  16. package/.claude/worktrees/emails-list/.claude/settings.local.json +0 -5
  17. package/.claude/worktrees/emails-list/.github/scripts/pr-title-check.js +0 -34
  18. package/.claude/worktrees/emails-list/.github/workflows/ci.yml +0 -32
  19. package/.claude/worktrees/emails-list/.github/workflows/pr-title-check.yml +0 -13
  20. package/.claude/worktrees/emails-list/.github/workflows/release.yml +0 -93
  21. package/.claude/worktrees/emails-list/CHANGELOG.md +0 -31
  22. package/.claude/worktrees/emails-list/LICENSE +0 -21
  23. package/.claude/worktrees/emails-list/README.md +0 -424
  24. package/.claude/worktrees/emails-list/biome.json +0 -36
  25. package/.claude/worktrees/emails-list/bun.lock +0 -76
  26. package/.claude/worktrees/emails-list/bunfig.toml +0 -2
  27. package/.claude/worktrees/emails-list/install.ps1 +0 -140
  28. package/.claude/worktrees/emails-list/install.sh +0 -301
  29. package/.claude/worktrees/emails-list/package.json +0 -43
  30. package/.claude/worktrees/emails-list/renovate.json +0 -6
  31. package/.claude/worktrees/emails-list/src/cli.ts +0 -74
  32. package/.claude/worktrees/emails-list/src/commands/api-keys/create.ts +0 -114
  33. package/.claude/worktrees/emails-list/src/commands/api-keys/delete.ts +0 -47
  34. package/.claude/worktrees/emails-list/src/commands/api-keys/index.ts +0 -26
  35. package/.claude/worktrees/emails-list/src/commands/api-keys/list.ts +0 -35
  36. package/.claude/worktrees/emails-list/src/commands/api-keys/utils.ts +0 -8
  37. package/.claude/worktrees/emails-list/src/commands/auth/index.ts +0 -20
  38. package/.claude/worktrees/emails-list/src/commands/auth/login.ts +0 -207
  39. package/.claude/worktrees/emails-list/src/commands/auth/logout.ts +0 -105
  40. package/.claude/worktrees/emails-list/src/commands/broadcasts/create.ts +0 -196
  41. package/.claude/worktrees/emails-list/src/commands/broadcasts/delete.ts +0 -46
  42. package/.claude/worktrees/emails-list/src/commands/broadcasts/get.ts +0 -59
  43. package/.claude/worktrees/emails-list/src/commands/broadcasts/index.ts +0 -43
  44. package/.claude/worktrees/emails-list/src/commands/broadcasts/list.ts +0 -60
  45. package/.claude/worktrees/emails-list/src/commands/broadcasts/send.ts +0 -56
  46. package/.claude/worktrees/emails-list/src/commands/broadcasts/update.ts +0 -95
  47. package/.claude/worktrees/emails-list/src/commands/broadcasts/utils.ts +0 -35
  48. package/.claude/worktrees/emails-list/src/commands/contact-properties/create.ts +0 -118
  49. package/.claude/worktrees/emails-list/src/commands/contact-properties/delete.ts +0 -48
  50. package/.claude/worktrees/emails-list/src/commands/contact-properties/get.ts +0 -46
  51. package/.claude/worktrees/emails-list/src/commands/contact-properties/index.ts +0 -48
  52. package/.claude/worktrees/emails-list/src/commands/contact-properties/list.ts +0 -68
  53. package/.claude/worktrees/emails-list/src/commands/contact-properties/update.ts +0 -88
  54. package/.claude/worktrees/emails-list/src/commands/contact-properties/utils.ts +0 -17
  55. package/.claude/worktrees/emails-list/src/commands/contacts/add-segment.ts +0 -78
  56. package/.claude/worktrees/emails-list/src/commands/contacts/create.ts +0 -122
  57. package/.claude/worktrees/emails-list/src/commands/contacts/delete.ts +0 -49
  58. package/.claude/worktrees/emails-list/src/commands/contacts/get.ts +0 -53
  59. package/.claude/worktrees/emails-list/src/commands/contacts/index.ts +0 -58
  60. package/.claude/worktrees/emails-list/src/commands/contacts/list.ts +0 -57
  61. package/.claude/worktrees/emails-list/src/commands/contacts/remove-segment.ts +0 -48
  62. package/.claude/worktrees/emails-list/src/commands/contacts/segments.ts +0 -39
  63. package/.claude/worktrees/emails-list/src/commands/contacts/topics.ts +0 -45
  64. package/.claude/worktrees/emails-list/src/commands/contacts/update-topics.ts +0 -90
  65. package/.claude/worktrees/emails-list/src/commands/contacts/update.ts +0 -77
  66. package/.claude/worktrees/emails-list/src/commands/contacts/utils.ts +0 -119
  67. package/.claude/worktrees/emails-list/src/commands/doctor.ts +0 -298
  68. package/.claude/worktrees/emails-list/src/commands/domains/create.ts +0 -83
  69. package/.claude/worktrees/emails-list/src/commands/domains/delete.ts +0 -42
  70. package/.claude/worktrees/emails-list/src/commands/domains/get.ts +0 -47
  71. package/.claude/worktrees/emails-list/src/commands/domains/index.ts +0 -35
  72. package/.claude/worktrees/emails-list/src/commands/domains/list.ts +0 -53
  73. package/.claude/worktrees/emails-list/src/commands/domains/update.ts +0 -75
  74. package/.claude/worktrees/emails-list/src/commands/domains/utils.ts +0 -44
  75. package/.claude/worktrees/emails-list/src/commands/domains/verify.ts +0 -38
  76. package/.claude/worktrees/emails-list/src/commands/emails/batch.ts +0 -140
  77. package/.claude/worktrees/emails-list/src/commands/emails/index.ts +0 -28
  78. package/.claude/worktrees/emails-list/src/commands/emails/list.ts +0 -73
  79. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachment.ts +0 -55
  80. package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachments.ts +0 -68
  81. package/.claude/worktrees/emails-list/src/commands/emails/receiving/get.ts +0 -58
  82. package/.claude/worktrees/emails-list/src/commands/emails/receiving/index.ts +0 -28
  83. package/.claude/worktrees/emails-list/src/commands/emails/receiving/list.ts +0 -59
  84. package/.claude/worktrees/emails-list/src/commands/emails/receiving/utils.ts +0 -38
  85. package/.claude/worktrees/emails-list/src/commands/emails/send.ts +0 -189
  86. package/.claude/worktrees/emails-list/src/commands/open.ts +0 -24
  87. package/.claude/worktrees/emails-list/src/commands/segments/create.ts +0 -50
  88. package/.claude/worktrees/emails-list/src/commands/segments/delete.ts +0 -47
  89. package/.claude/worktrees/emails-list/src/commands/segments/get.ts +0 -38
  90. package/.claude/worktrees/emails-list/src/commands/segments/index.ts +0 -36
  91. package/.claude/worktrees/emails-list/src/commands/segments/list.ts +0 -58
  92. package/.claude/worktrees/emails-list/src/commands/segments/utils.ts +0 -7
  93. package/.claude/worktrees/emails-list/src/commands/teams/index.ts +0 -10
  94. package/.claude/worktrees/emails-list/src/commands/teams/list.ts +0 -35
  95. package/.claude/worktrees/emails-list/src/commands/teams/remove.ts +0 -83
  96. package/.claude/worktrees/emails-list/src/commands/teams/switch.ts +0 -73
  97. package/.claude/worktrees/emails-list/src/commands/topics/create.ts +0 -73
  98. package/.claude/worktrees/emails-list/src/commands/topics/delete.ts +0 -47
  99. package/.claude/worktrees/emails-list/src/commands/topics/get.ts +0 -42
  100. package/.claude/worktrees/emails-list/src/commands/topics/index.ts +0 -42
  101. package/.claude/worktrees/emails-list/src/commands/topics/list.ts +0 -34
  102. package/.claude/worktrees/emails-list/src/commands/topics/update.ts +0 -59
  103. package/.claude/worktrees/emails-list/src/commands/topics/utils.ts +0 -16
  104. package/.claude/worktrees/emails-list/src/commands/webhooks/create.ts +0 -128
  105. package/.claude/worktrees/emails-list/src/commands/webhooks/delete.ts +0 -49
  106. package/.claude/worktrees/emails-list/src/commands/webhooks/get.ts +0 -42
  107. package/.claude/worktrees/emails-list/src/commands/webhooks/index.ts +0 -44
  108. package/.claude/worktrees/emails-list/src/commands/webhooks/list.ts +0 -55
  109. package/.claude/worktrees/emails-list/src/commands/webhooks/update.ts +0 -83
  110. package/.claude/worktrees/emails-list/src/commands/webhooks/utils.ts +0 -36
  111. package/.claude/worktrees/emails-list/src/commands/whoami.ts +0 -71
  112. package/.claude/worktrees/emails-list/src/lib/actions.ts +0 -157
  113. package/.claude/worktrees/emails-list/src/lib/client.ts +0 -34
  114. package/.claude/worktrees/emails-list/src/lib/config.ts +0 -211
  115. package/.claude/worktrees/emails-list/src/lib/files.ts +0 -15
  116. package/.claude/worktrees/emails-list/src/lib/help-text.ts +0 -38
  117. package/.claude/worktrees/emails-list/src/lib/output.ts +0 -54
  118. package/.claude/worktrees/emails-list/src/lib/pagination.ts +0 -36
  119. package/.claude/worktrees/emails-list/src/lib/prompts.ts +0 -149
  120. package/.claude/worktrees/emails-list/src/lib/spinner.ts +0 -93
  121. package/.claude/worktrees/emails-list/src/lib/table.ts +0 -57
  122. package/.claude/worktrees/emails-list/src/lib/tty.ts +0 -28
  123. package/.claude/worktrees/emails-list/src/lib/version.ts +0 -4
  124. package/.claude/worktrees/emails-list/tests/commands/api-keys/create.test.ts +0 -195
  125. package/.claude/worktrees/emails-list/tests/commands/api-keys/delete.test.ts +0 -156
  126. package/.claude/worktrees/emails-list/tests/commands/api-keys/list.test.ts +0 -133
  127. package/.claude/worktrees/emails-list/tests/commands/auth/login.test.ts +0 -119
  128. package/.claude/worktrees/emails-list/tests/commands/auth/logout.test.ts +0 -146
  129. package/.claude/worktrees/emails-list/tests/commands/broadcasts/create.test.ts +0 -447
  130. package/.claude/worktrees/emails-list/tests/commands/broadcasts/delete.test.ts +0 -182
  131. package/.claude/worktrees/emails-list/tests/commands/broadcasts/get.test.ts +0 -146
  132. package/.claude/worktrees/emails-list/tests/commands/broadcasts/list.test.ts +0 -196
  133. package/.claude/worktrees/emails-list/tests/commands/broadcasts/send.test.ts +0 -161
  134. package/.claude/worktrees/emails-list/tests/commands/broadcasts/update.test.ts +0 -283
  135. package/.claude/worktrees/emails-list/tests/commands/contact-properties/create.test.ts +0 -250
  136. package/.claude/worktrees/emails-list/tests/commands/contact-properties/delete.test.ts +0 -183
  137. package/.claude/worktrees/emails-list/tests/commands/contact-properties/get.test.ts +0 -144
  138. package/.claude/worktrees/emails-list/tests/commands/contact-properties/list.test.ts +0 -180
  139. package/.claude/worktrees/emails-list/tests/commands/contact-properties/update.test.ts +0 -216
  140. package/.claude/worktrees/emails-list/tests/commands/contacts/add-segment.test.ts +0 -188
  141. package/.claude/worktrees/emails-list/tests/commands/contacts/create.test.ts +0 -270
  142. package/.claude/worktrees/emails-list/tests/commands/contacts/delete.test.ts +0 -192
  143. package/.claude/worktrees/emails-list/tests/commands/contacts/get.test.ts +0 -148
  144. package/.claude/worktrees/emails-list/tests/commands/contacts/list.test.ts +0 -175
  145. package/.claude/worktrees/emails-list/tests/commands/contacts/remove-segment.test.ts +0 -166
  146. package/.claude/worktrees/emails-list/tests/commands/contacts/segments.test.ts +0 -167
  147. package/.claude/worktrees/emails-list/tests/commands/contacts/topics.test.ts +0 -163
  148. package/.claude/worktrees/emails-list/tests/commands/contacts/update-topics.test.ts +0 -247
  149. package/.claude/worktrees/emails-list/tests/commands/contacts/update.test.ts +0 -205
  150. package/.claude/worktrees/emails-list/tests/commands/doctor.test.ts +0 -165
  151. package/.claude/worktrees/emails-list/tests/commands/domains/create.test.ts +0 -192
  152. package/.claude/worktrees/emails-list/tests/commands/domains/delete.test.ts +0 -156
  153. package/.claude/worktrees/emails-list/tests/commands/domains/get.test.ts +0 -137
  154. package/.claude/worktrees/emails-list/tests/commands/domains/list.test.ts +0 -164
  155. package/.claude/worktrees/emails-list/tests/commands/domains/update.test.ts +0 -223
  156. package/.claude/worktrees/emails-list/tests/commands/domains/verify.test.ts +0 -117
  157. package/.claude/worktrees/emails-list/tests/commands/emails/batch.test.ts +0 -313
  158. package/.claude/worktrees/emails-list/tests/commands/emails/list.test.ts +0 -196
  159. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachment.test.ts +0 -140
  160. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachments.test.ts +0 -168
  161. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/get.test.ts +0 -140
  162. package/.claude/worktrees/emails-list/tests/commands/emails/receiving/list.test.ts +0 -181
  163. package/.claude/worktrees/emails-list/tests/commands/emails/send.test.ts +0 -309
  164. package/.claude/worktrees/emails-list/tests/commands/segments/create.test.ts +0 -163
  165. package/.claude/worktrees/emails-list/tests/commands/segments/delete.test.ts +0 -182
  166. package/.claude/worktrees/emails-list/tests/commands/segments/get.test.ts +0 -137
  167. package/.claude/worktrees/emails-list/tests/commands/segments/list.test.ts +0 -173
  168. package/.claude/worktrees/emails-list/tests/commands/teams/list.test.ts +0 -63
  169. package/.claude/worktrees/emails-list/tests/commands/teams/remove.test.ts +0 -103
  170. package/.claude/worktrees/emails-list/tests/commands/teams/switch.test.ts +0 -96
  171. package/.claude/worktrees/emails-list/tests/commands/topics/create.test.ts +0 -191
  172. package/.claude/worktrees/emails-list/tests/commands/topics/delete.test.ts +0 -156
  173. package/.claude/worktrees/emails-list/tests/commands/topics/get.test.ts +0 -125
  174. package/.claude/worktrees/emails-list/tests/commands/topics/list.test.ts +0 -124
  175. package/.claude/worktrees/emails-list/tests/commands/topics/update.test.ts +0 -177
  176. package/.claude/worktrees/emails-list/tests/commands/webhooks/create.test.ts +0 -224
  177. package/.claude/worktrees/emails-list/tests/commands/webhooks/delete.test.ts +0 -156
  178. package/.claude/worktrees/emails-list/tests/commands/webhooks/get.test.ts +0 -125
  179. package/.claude/worktrees/emails-list/tests/commands/webhooks/list.test.ts +0 -177
  180. package/.claude/worktrees/emails-list/tests/commands/webhooks/update.test.ts +0 -206
  181. package/.claude/worktrees/emails-list/tests/commands/whoami.test.ts +0 -99
  182. package/.claude/worktrees/emails-list/tests/helpers.ts +0 -93
  183. package/.claude/worktrees/emails-list/tests/lib/client.test.ts +0 -71
  184. package/.claude/worktrees/emails-list/tests/lib/config.test.ts +0 -414
  185. package/.claude/worktrees/emails-list/tests/lib/files.test.ts +0 -65
  186. package/.claude/worktrees/emails-list/tests/lib/help-text.test.ts +0 -97
  187. package/.claude/worktrees/emails-list/tests/lib/output.test.ts +0 -127
  188. package/.claude/worktrees/emails-list/tests/lib/prompts.test.ts +0 -178
  189. package/.claude/worktrees/emails-list/tests/lib/spinner.test.ts +0 -146
  190. package/.claude/worktrees/emails-list/tests/lib/table.test.ts +0 -63
  191. package/.claude/worktrees/emails-list/tests/lib/tty.test.ts +0 -85
  192. package/.claude/worktrees/emails-list/tsconfig.json +0 -14
  193. package/.github/workflows/test-build-windows.yml +0 -44
@@ -1,301 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Resend CLI installer
3
- #
4
- # Usage:
5
- # curl -fsSL https://resend.com/install.sh | bash
6
- # curl -fsSL https://resend.com/install.sh | bash -s v0.1.0
7
- #
8
- # Environment variables:
9
- # RESEND_INSTALL - Custom install directory (default: ~/.resend)
10
- # GITHUB_BASE - Custom GitHub base URL (default: https://github.com)
11
-
12
- # Wrap everything in a function to protect against partial download.
13
- # If the connection drops mid-transfer, bash won't execute a truncated script.
14
- main() {
15
-
16
- set -euo pipefail
17
-
18
- # ─── Colors (only when outputting to a terminal) ─────────────────────────────
19
-
20
- Color_Off='' Red='' Green='' Dim='' Bold='' Blue='' Yellow=''
21
-
22
- if [[ -t 1 ]]; then
23
- Color_Off='\033[0m'
24
- Red='\033[0;31m'
25
- Green='\033[0;32m'
26
- Yellow='\033[0;33m'
27
- Dim='\033[0;2m'
28
- Bold='\033[1m'
29
- Blue='\033[0;34m'
30
- fi
31
-
32
- # ─── Helpers ─────────────────────────────────────────────────────────────────
33
-
34
- error() {
35
- printf "%b\n" "${Red}error${Color_Off}: $*" >&2
36
- exit 1
37
- }
38
-
39
- warn() {
40
- printf "%b\n" "${Yellow}warn${Color_Off}: $*" >&2
41
- }
42
-
43
- info() {
44
- printf "%b\n" "${Dim}$*${Color_Off}"
45
- }
46
-
47
- success() {
48
- printf "%b\n" "${Green}$*${Color_Off}"
49
- }
50
-
51
- bold() {
52
- printf "%b\n" "${Bold}$*${Color_Off}"
53
- }
54
-
55
- tildify() {
56
- if [[ $1 == "$HOME"/* ]]; then
57
- echo "~${1#"$HOME"}"
58
- else
59
- echo "$1"
60
- fi
61
- }
62
-
63
- # ─── Dependency checks ──────────────────────────────────────────────────────
64
-
65
- command -v curl >/dev/null 2>&1 || error "curl is required but not found. Install it and try again."
66
- command -v tar >/dev/null 2>&1 || error "tar is required but not found. Install it and try again."
67
-
68
- # ─── OS / Architecture detection ────────────────────────────────────────────
69
-
70
- platform=$(uname -ms)
71
-
72
- case $platform in
73
- 'Darwin x86_64') target=darwin-x64 ;;
74
- 'Darwin arm64') target=darwin-arm64 ;;
75
- 'Linux aarch64') target=linux-arm64 ;;
76
- 'Linux arm64') target=linux-arm64 ;;
77
- 'Linux x86_64') target=linux-x64 ;;
78
- *)
79
- error "Unsupported platform: ${platform}.
80
-
81
- Resend CLI supports:
82
- - macOS (Apple Silicon / Intel)
83
- - Linux (x64 / arm64)
84
-
85
- For Windows, run this in PowerShell:
86
- irm https://resend.com/install.ps1 | iex"
87
- ;;
88
- esac
89
-
90
- # Detect Rosetta 2 on macOS — prefer native arm64 binary
91
- if [[ $target == "darwin-x64" ]]; then
92
- if [[ $(sysctl -n sysctl.proc_translated 2>/dev/null || echo 0) == "1" ]]; then
93
- target=darwin-arm64
94
- info " Rosetta 2 detected — installing native arm64 binary"
95
- fi
96
- fi
97
-
98
- # Detect musl (Alpine Linux) — glibc binaries won't work
99
- if [[ $target == linux-* ]]; then
100
- if ldd --version 2>&1 | grep -qi musl 2>/dev/null; then
101
- error "Alpine Linux (musl) is not currently supported.
102
-
103
- The compiled binary requires glibc. Use one of these alternatives:
104
- - npm install -g resend-cli
105
- - Run in a glibc-based container (e.g., ubuntu, debian)"
106
- fi
107
- fi
108
-
109
- # ─── Version + Download URL ─────────────────────────────────────────────────
110
-
111
- GITHUB_BASE=${GITHUB_BASE:-"https://github.com"}
112
-
113
- # Validate GITHUB_BASE is HTTPS to prevent download from arbitrary sources
114
- case "$GITHUB_BASE" in
115
- https://*) ;;
116
- *) error "GITHUB_BASE must start with https:// (got: ${GITHUB_BASE})" ;;
117
- esac
118
-
119
- REPO="${GITHUB_BASE}/resend/resend-cli"
120
-
121
- VERSION=${1:-}
122
-
123
- # Validate version format if provided
124
- if [[ -n $VERSION ]]; then
125
- # Strip leading 'v' if present, then re-add for the tag
126
- VERSION="${VERSION#v}"
127
- if ! [[ $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
128
- error "Invalid version format: ${VERSION}
129
-
130
- Expected: semantic version like 0.1.0 or 1.2.3-beta.1
131
- Usage: curl -fsSL https://resend.com/install.sh | bash -s v0.1.0"
132
- fi
133
- url="${REPO}/releases/download/v${VERSION}/resend-${target}.tar.gz"
134
- else
135
- url="${REPO}/releases/latest/download/resend-${target}.tar.gz"
136
- fi
137
-
138
- # ─── Install directory ──────────────────────────────────────────────────────
139
-
140
- install_dir="${RESEND_INSTALL:-$HOME/.resend}"
141
- bin_dir="${install_dir}/bin"
142
- exe="${bin_dir}/resend"
143
-
144
- mkdir -p "$bin_dir" || error "Failed to create install directory: ${bin_dir}"
145
-
146
- # ─── Download + Extract ─────────────────────────────────────────────────────
147
-
148
- echo ""
149
- bold " Installing Resend CLI..."
150
- echo ""
151
-
152
- tmpdir=$(mktemp -d) || error "Failed to create temporary directory"
153
- trap 'rm -rf "$tmpdir"' EXIT INT TERM
154
-
155
- tmpfile="${tmpdir}/resend.tar.gz"
156
-
157
- info " Downloading from ${url}"
158
- echo ""
159
-
160
- curl --fail --location --progress-bar --output "$tmpfile" "$url" ||
161
- error "Download failed.
162
-
163
- Possible causes:
164
- - No internet connection
165
- - The version does not exist: ${VERSION:-latest}
166
- - GitHub is unreachable
167
-
168
- URL: ${url}"
169
-
170
- tar -xzf "$tmpfile" -C "$bin_dir" ||
171
- error "Failed to extract archive. The download may be corrupted — try again."
172
-
173
- chmod +x "$exe" || error "Failed to make binary executable"
174
-
175
- # Strip macOS Gatekeeper quarantine flag (set automatically on curl downloads)
176
- # Without this, macOS will block the binary: "cannot be opened because Apple
177
- # cannot check it for malicious software"
178
- if [[ $(uname -s) == "Darwin" ]]; then
179
- xattr -d com.apple.quarantine "$exe" 2>/dev/null || true
180
- fi
181
-
182
- # ─── Verify installation ────────────────────────────────────────────────────
183
-
184
- installed_version=$("$exe" --version 2>/dev/null || echo "unknown")
185
-
186
- echo ""
187
- success " Resend CLI ${installed_version} installed successfully!"
188
- echo ""
189
- info " Binary: $(tildify "$exe")"
190
-
191
- # ─── PATH setup ─────────────────────────────────────────────────────────────
192
-
193
- # Check if already on PATH
194
- if command -v resend >/dev/null 2>&1; then
195
- existing=$(command -v resend)
196
- if [[ "$existing" == "$exe" ]]; then
197
- echo ""
198
- bold " Run ${Blue}resend --help${Color_Off}${Bold} to get started${Color_Off}"
199
- echo ""
200
- exit 0
201
- else
202
- warn "another 'resend' was found at ${existing}"
203
- info " The new installation at $(tildify "$exe") may be shadowed."
204
- fi
205
- fi
206
-
207
- # Check if bin_dir is already in PATH
208
- if echo "$PATH" | tr ':' '\n' | grep -qxF "${bin_dir}" 2>/dev/null; then
209
- echo ""
210
- bold " Run ${Blue}resend --help${Color_Off}${Bold} to get started${Color_Off}"
211
- echo ""
212
- exit 0
213
- fi
214
-
215
- # Determine shell config file
216
- shell_name=$(basename "${SHELL:-}")
217
- config=""
218
- shell_line=""
219
-
220
- # Build a $HOME-relative path for shell config (~ doesn't expand inside quotes)
221
- if [[ $bin_dir == "$HOME"/* ]]; then
222
- shell_bin_dir="\$HOME${bin_dir#"$HOME"}"
223
- else
224
- shell_bin_dir="$bin_dir"
225
- fi
226
-
227
- case $shell_name in
228
- zsh)
229
- config="${ZDOTDIR:-$HOME}/.zshrc"
230
- shell_line="export PATH=\"${shell_bin_dir}:\$PATH\""
231
- ;;
232
- bash)
233
- # macOS bash opens login shells — .bash_profile is loaded, not .bashrc.
234
- # Linux bash opens non-login interactive shells — .bashrc is preferred.
235
- if [[ $(uname -s) == "Darwin" ]]; then
236
- if [[ -f "$HOME/.bash_profile" ]]; then
237
- config="$HOME/.bash_profile"
238
- elif [[ -f "$HOME/.bashrc" ]]; then
239
- config="$HOME/.bashrc"
240
- else
241
- config="$HOME/.bash_profile"
242
- fi
243
- else
244
- if [[ -f "$HOME/.bashrc" ]]; then
245
- config="$HOME/.bashrc"
246
- elif [[ -f "$HOME/.bash_profile" ]]; then
247
- config="$HOME/.bash_profile"
248
- else
249
- config="$HOME/.bashrc"
250
- fi
251
- fi
252
- shell_line="export PATH=\"${shell_bin_dir}:\$PATH\""
253
- ;;
254
- fish)
255
- config="${XDG_CONFIG_HOME:-$HOME/.config}/fish/conf.d/resend.fish"
256
- mkdir -p "$(dirname "$config")"
257
- shell_line="fish_add_path ${shell_bin_dir}"
258
- ;;
259
- esac
260
-
261
- if [[ -n $config ]]; then
262
- # Check if PATH entry already exists (check both tildified and absolute)
263
- if [[ -f "$config" ]] && (grep -qF "$(tildify "$bin_dir")" "$config" 2>/dev/null || grep -qF "$bin_dir" "$config" 2>/dev/null); then
264
- info " PATH already configured in $(tildify "$config")"
265
- elif [[ -w "${config%/*}" ]] || [[ -w "$config" ]]; then
266
- {
267
- echo ""
268
- echo "# Resend CLI"
269
- echo "$shell_line"
270
- } >> "$config"
271
- info " Added $(tildify "$bin_dir") to \$PATH in $(tildify "$config")"
272
- echo ""
273
- info " To start using Resend CLI, run:"
274
- echo ""
275
- bold " source $(tildify "$config")"
276
- bold " resend --help"
277
- else
278
- echo ""
279
- info " Manually add to your shell config:"
280
- echo ""
281
- bold " ${shell_line}"
282
- fi
283
- else
284
- echo ""
285
- info " Add to your shell config:"
286
- echo ""
287
- bold " export PATH=\"${shell_bin_dir}:\$PATH\""
288
- fi
289
-
290
- echo ""
291
- info " Next steps:"
292
- echo ""
293
- bold " export RESEND_API_KEY=re_..."
294
- bold " resend --help"
295
- echo ""
296
-
297
- }
298
-
299
- # Run the installer — this line MUST be the last line in the file.
300
- # If the download is interrupted, bash will not execute an incomplete function.
301
- main "$@"
@@ -1,43 +0,0 @@
1
- {
2
- "name": "resend-cli",
3
- "version": "1.1.0",
4
- "description": "Resend CLI — email for developers",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/resend/resend-cli"
9
- },
10
- "homepage": "https://github.com/resend/resend-cli#readme",
11
- "keywords": [
12
- "cli",
13
- "resend",
14
- "email",
15
- "api"
16
- ],
17
- "packageManager": "bun@1.3.10",
18
- "type": "module",
19
- "bin": {
20
- "resend": "./src/cli.ts"
21
- },
22
- "scripts": {
23
- "dev": "bun run src/cli.ts",
24
- "dev:watch": "bun --watch src/cli.ts",
25
- "build": "bun build --compile --minify --sourcemap --bytecode src/cli.ts --outfile dist/resend",
26
- "lint": "biome check",
27
- "format": "biome format --write",
28
- "typecheck": "tsc --noEmit",
29
- "test": "bun test tests/commands tests/lib"
30
- },
31
- "dependencies": {
32
- "commander": "14.0.3",
33
- "@commander-js/extra-typings": "14.0.0",
34
- "resend": "6.9.3",
35
- "@clack/prompts": "1.1.0",
36
- "unicode-animations": "1.0.3"
37
- },
38
- "devDependencies": {
39
- "@biomejs/biome": "2.4.6",
40
- "@types/bun": "1.3.10",
41
- "typescript": "5.9.3"
42
- }
43
- }
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:recommended"
5
- ]
6
- }
@@ -1,74 +0,0 @@
1
- #!/usr/bin/env bun
2
- import { Command } from '@commander-js/extra-typings';
3
- import { apiKeysCommand } from './commands/api-keys/index';
4
- import { loginCommand } from './commands/auth/login';
5
- import { logoutCommand } from './commands/auth/logout';
6
- import { broadcastsCommand } from './commands/broadcasts/index';
7
- import { contactPropertiesCommand } from './commands/contact-properties/index';
8
- import { contactsCommand } from './commands/contacts/index';
9
- import { doctorCommand } from './commands/doctor';
10
- import { domainsCommand } from './commands/domains/index';
11
- import { emailsCommand } from './commands/emails/index';
12
- import { openCommand } from './commands/open';
13
- import { segmentsCommand } from './commands/segments/index';
14
- import { teamsCommand } from './commands/teams/index';
15
- import { topicsCommand } from './commands/topics/index';
16
- import { webhooksCommand } from './commands/webhooks/index';
17
- import { whoamiCommand } from './commands/whoami';
18
- import { PACKAGE_NAME, VERSION } from './lib/version';
19
-
20
- const program = new Command()
21
- .name('resend')
22
- .description('Resend CLI — email for developers')
23
- .version(
24
- `${PACKAGE_NAME} v${VERSION}`,
25
- '-v, --version',
26
- 'Output the current version',
27
- )
28
- .option('--api-key <key>', 'Resend API key (overrides env/config)')
29
- .option('--team <name>', 'Team profile to use (overrides RESEND_TEAM)')
30
- .option('--json', 'Force JSON output')
31
- .option('-q, --quiet', 'Suppress spinners and status output (implies --json)')
32
- .configureHelp({ showGlobalOptions: true })
33
- .hook('preAction', (thisCommand, actionCommand) => {
34
- if (actionCommand.optsWithGlobals().quiet) {
35
- thisCommand.setOptionValue('json', true);
36
- }
37
- })
38
- .addHelpText(
39
- 'after',
40
- `
41
- Environment:
42
- RESEND_API_KEY API key — checked after --api-key, before stored credentials
43
- Priority: --api-key flag > RESEND_API_KEY > ~/.config/resend/credentials.json
44
- RESEND_TEAM Team profile — checked after --team flag, before active_team in config
45
- Priority: --team flag > RESEND_TEAM > active_team in config > "default"
46
-
47
- Output:
48
- Human-readable by default. Pass --json or pipe stdout for machine-readable JSON.
49
- Use --quiet (-q) in CI to suppress spinners and status messages (implies --json).
50
- Errors always exit with code 1: {"error":{"message":"...","code":"..."}}
51
-
52
- Examples:
53
- $ resend login --key re_123456789
54
- $ resend emails send --from you@domain.com --to user@example.com --subject "Hi" --text "Hello"
55
- $ resend emails batch --file ./emails.json --json
56
- $ resend doctor --json`,
57
- )
58
- .addCommand(loginCommand)
59
- .addCommand(logoutCommand)
60
- .addCommand(emailsCommand)
61
- .addCommand(domainsCommand)
62
- .addCommand(apiKeysCommand)
63
- .addCommand(broadcastsCommand)
64
- .addCommand(contactsCommand)
65
- .addCommand(contactPropertiesCommand)
66
- .addCommand(segmentsCommand)
67
- .addCommand(topicsCommand)
68
- .addCommand(webhooksCommand)
69
- .addCommand(doctorCommand)
70
- .addCommand(teamsCommand)
71
- .addCommand(openCommand)
72
- .addCommand(whoamiCommand);
73
-
74
- program.parse();
@@ -1,114 +0,0 @@
1
- import * as p from '@clack/prompts';
2
- import { Command, Option } from '@commander-js/extra-typings';
3
- import { runCreate } 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 { cancelAndExit } from '../../lib/prompts';
8
- import { isInteractive } from '../../lib/tty';
9
-
10
- export const createApiKeyCommand = new Command('create')
11
- .description(
12
- 'Create a new API key and display the token (shown once — store it immediately)',
13
- )
14
- .option('--name <name>', 'API key name (max 50 characters)')
15
- .addOption(
16
- new Option('--permission <permission>', 'Permission level').choices([
17
- 'full_access',
18
- 'sending_access',
19
- ] as const),
20
- )
21
- .option(
22
- '--domain-id <id>',
23
- 'Restrict a sending_access key to a single domain ID',
24
- )
25
- .addHelpText(
26
- 'after',
27
- buildHelpText({
28
- context: `Non-interactive: --name is required (no prompts when stdin/stdout is not a TTY).
29
-
30
- Permissions:
31
- full_access Full API access (default)
32
- sending_access Send-only access; optionally scope to a domain with --domain-id`,
33
- output: ` {"id":"<id>","token":"<token>"}
34
- The token is only returned at creation time and cannot be retrieved again.`,
35
- errorCodes: ['auth_error', 'missing_name', 'create_error'],
36
- examples: [
37
- 'resend api-keys create --name "Production"',
38
- 'resend api-keys create --name "CI Token" --permission sending_access',
39
- 'resend api-keys create --name "Domain Token" --permission sending_access --domain-id <domain-id>',
40
- 'resend api-keys create --name "Production" --json',
41
- ],
42
- }),
43
- )
44
- .action(async (opts, cmd) => {
45
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
46
-
47
- let name = opts.name;
48
- let permission = opts.permission;
49
-
50
- if (!name) {
51
- if (!isInteractive()) {
52
- outputError(
53
- { message: 'Missing --name flag.', code: 'missing_name' },
54
- { json: globalOpts.json },
55
- );
56
- }
57
-
58
- const nameResult = await p.text({
59
- message: 'Key name',
60
- placeholder: 'My API Key',
61
- validate: (v) => {
62
- if (!v) {
63
- return 'Name is required';
64
- }
65
- if (v.length > 50) {
66
- return 'Name must be 50 characters or less';
67
- }
68
- return undefined;
69
- },
70
- });
71
- if (p.isCancel(nameResult)) {
72
- cancelAndExit('Cancelled.');
73
- }
74
- name = nameResult;
75
-
76
- const permissionResult = await p.select({
77
- message: 'Permission level',
78
- options: [
79
- { value: 'full_access' as const, label: 'Full access' },
80
- { value: 'sending_access' as const, label: 'Sending access only' },
81
- ],
82
- });
83
- if (p.isCancel(permissionResult)) {
84
- cancelAndExit('Cancelled.');
85
- }
86
- permission = permissionResult;
87
- }
88
-
89
- await runCreate(
90
- {
91
- spinner: {
92
- loading: 'Creating API key...',
93
- success: 'API key created',
94
- fail: 'Failed to create API key',
95
- },
96
- sdkCall: (resend) =>
97
- resend.apiKeys.create({
98
- name,
99
- ...(permission && { permission }),
100
- ...(opts.domainId && { domain_id: opts.domainId }),
101
- }),
102
- onInteractive: (d) => {
103
- console.log('\nAPI key created!\n');
104
- console.log(` Name: ${name}`);
105
- console.log(` ID: ${d.id}`);
106
- console.log(` Token: ${d.token}`);
107
- console.log(
108
- '\n⚠ Store this token now — it cannot be retrieved again.',
109
- );
110
- },
111
- },
112
- globalOpts,
113
- );
114
- });
@@ -1,47 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runDelete } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
-
6
- export const deleteApiKeyCommand = new Command('delete')
7
- .alias('rm')
8
- .description(
9
- 'Delete an API key — any services using it will immediately lose access',
10
- )
11
- .argument('<id>', 'API key ID')
12
- .option('--yes', 'Skip confirmation prompt')
13
- .addHelpText(
14
- 'after',
15
- buildHelpText({
16
- context: `Non-interactive: --yes is required to confirm deletion when stdin/stdout is not a TTY.
17
-
18
- Warning: Deleting a key is immediate and irreversible. Any service using this key
19
- will stop authenticating instantly. The current key (used to call this command)
20
- can delete itself — the API does not prevent self-deletion.`,
21
- output: ` {"object":"api-key","id":"<id>","deleted":true}`,
22
- errorCodes: ['auth_error', 'confirmation_required', 'delete_error'],
23
- examples: [
24
- 'resend api-keys delete dacf4072-aa82-4ff3-97de-514ae3000ee0 --yes',
25
- 'resend api-keys delete dacf4072-aa82-4ff3-97de-514ae3000ee0 --yes --json',
26
- ],
27
- }),
28
- )
29
- .action(async (id, opts, cmd) => {
30
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
31
- await runDelete(
32
- id,
33
- !!opts.yes,
34
- {
35
- confirmMessage: `Delete API key ${id}?\nAny services using this key will stop working.`,
36
- spinner: {
37
- loading: 'Deleting API key...',
38
- success: 'API key deleted',
39
- fail: 'Failed to delete API key',
40
- },
41
- object: 'api-key',
42
- successMsg: 'API key deleted.',
43
- sdkCall: (resend) => resend.apiKeys.remove(id),
44
- },
45
- globalOpts,
46
- );
47
- });
@@ -1,26 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { buildHelpText } from '../../lib/help-text';
3
- import { createApiKeyCommand } from './create';
4
- import { deleteApiKeyCommand } from './delete';
5
- import { listApiKeysCommand } from './list';
6
-
7
- export const apiKeysCommand = new Command('api-keys')
8
- .description('Manage API keys for authentication')
9
- .addHelpText(
10
- 'after',
11
- buildHelpText({
12
- context: `Security notes:
13
- - Tokens are only shown at creation time and cannot be retrieved again.
14
- - Use sending_access keys with --domain-id for per-domain CI tokens.
15
- - Deleting a key is immediate — any service using it loses access instantly.`,
16
- examples: [
17
- 'resend api-keys list',
18
- 'resend api-keys create --name "Production"',
19
- 'resend api-keys create --name "CI Token" --permission sending_access --domain-id <domain-id>',
20
- 'resend api-keys delete <id> --yes',
21
- ],
22
- }),
23
- )
24
- .addCommand(createApiKeyCommand)
25
- .addCommand(listApiKeysCommand, { isDefault: true })
26
- .addCommand(deleteApiKeyCommand);
@@ -1,35 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { runList } from '../../lib/actions';
3
- import type { GlobalOpts } from '../../lib/client';
4
- import { buildHelpText } from '../../lib/help-text';
5
- import { renderApiKeysTable } from './utils';
6
-
7
- export const listApiKeysCommand = new Command('list')
8
- .alias('ls')
9
- .description(
10
- 'List all API keys (IDs and names — tokens are never returned by this endpoint)',
11
- )
12
- .addHelpText(
13
- 'after',
14
- buildHelpText({
15
- output: ` {"object":"list","data":[{"id":"<id>","name":"<name>","created_at":"<date>"}]}
16
- Tokens are never included in list responses.`,
17
- errorCodes: ['auth_error', 'list_error'],
18
- examples: ['resend api-keys list', 'resend api-keys list --json'],
19
- }),
20
- )
21
- .action(async (_opts, cmd) => {
22
- const globalOpts = cmd.optsWithGlobals() as GlobalOpts;
23
- await runList(
24
- {
25
- spinner: {
26
- loading: 'Fetching API keys...',
27
- success: 'API keys fetched',
28
- fail: 'Failed to list API keys',
29
- },
30
- sdkCall: (resend) => resend.apiKeys.list(),
31
- onInteractive: (list) => console.log(renderApiKeysTable(list.data)),
32
- },
33
- globalOpts,
34
- );
35
- });
@@ -1,8 +0,0 @@
1
- import { renderTable } from '../../lib/table';
2
-
3
- export function renderApiKeysTable(
4
- keys: Array<{ id: string; name: string; created_at: string }>,
5
- ): string {
6
- const rows = keys.map((k) => [k.name, k.id, k.created_at]);
7
- return renderTable(['Name', 'ID', 'Created'], rows, '(no API keys)');
8
- }
@@ -1,20 +0,0 @@
1
- import { Command } from '@commander-js/extra-typings';
2
- import { buildHelpText } from '../../lib/help-text';
3
- import { loginCommand } from './login';
4
- import { logoutCommand } from './logout';
5
-
6
- export const authCommand = new Command('auth')
7
- .description('Manage authentication')
8
- .addHelpText(
9
- 'after',
10
- buildHelpText({
11
- setup: true,
12
- examples: [
13
- 'resend login',
14
- 'resend login --key re_123456789',
15
- 'resend logout',
16
- ],
17
- }),
18
- )
19
- .addCommand(loginCommand)
20
- .addCommand(logoutCommand);