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.
- package/README.md +25 -10
- package/dist/cli.cjs +539 -0
- package/package.json +31 -13
- package/.claude/settings.local.json +0 -5
- package/.claude/worktrees/emails-list/.claude/settings.local.json +0 -5
- package/.claude/worktrees/emails-list/.github/scripts/pr-title-check.js +0 -34
- package/.claude/worktrees/emails-list/.github/workflows/ci.yml +0 -32
- package/.claude/worktrees/emails-list/.github/workflows/pr-title-check.yml +0 -13
- package/.claude/worktrees/emails-list/.github/workflows/release.yml +0 -93
- package/.claude/worktrees/emails-list/CHANGELOG.md +0 -31
- package/.claude/worktrees/emails-list/LICENSE +0 -21
- package/.claude/worktrees/emails-list/README.md +0 -424
- package/.claude/worktrees/emails-list/biome.json +0 -36
- package/.claude/worktrees/emails-list/bun.lock +0 -76
- package/.claude/worktrees/emails-list/bunfig.toml +0 -2
- package/.claude/worktrees/emails-list/install.ps1 +0 -140
- package/.claude/worktrees/emails-list/install.sh +0 -301
- package/.claude/worktrees/emails-list/package.json +0 -43
- package/.claude/worktrees/emails-list/renovate.json +0 -6
- package/.claude/worktrees/emails-list/src/cli.ts +0 -74
- package/.claude/worktrees/emails-list/src/commands/api-keys/create.ts +0 -114
- package/.claude/worktrees/emails-list/src/commands/api-keys/delete.ts +0 -47
- package/.claude/worktrees/emails-list/src/commands/api-keys/index.ts +0 -26
- package/.claude/worktrees/emails-list/src/commands/api-keys/list.ts +0 -35
- package/.claude/worktrees/emails-list/src/commands/api-keys/utils.ts +0 -8
- package/.claude/worktrees/emails-list/src/commands/auth/index.ts +0 -20
- package/.claude/worktrees/emails-list/src/commands/auth/login.ts +0 -207
- package/.claude/worktrees/emails-list/src/commands/auth/logout.ts +0 -105
- package/.claude/worktrees/emails-list/src/commands/broadcasts/create.ts +0 -196
- package/.claude/worktrees/emails-list/src/commands/broadcasts/delete.ts +0 -46
- package/.claude/worktrees/emails-list/src/commands/broadcasts/get.ts +0 -59
- package/.claude/worktrees/emails-list/src/commands/broadcasts/index.ts +0 -43
- package/.claude/worktrees/emails-list/src/commands/broadcasts/list.ts +0 -60
- package/.claude/worktrees/emails-list/src/commands/broadcasts/send.ts +0 -56
- package/.claude/worktrees/emails-list/src/commands/broadcasts/update.ts +0 -95
- package/.claude/worktrees/emails-list/src/commands/broadcasts/utils.ts +0 -35
- package/.claude/worktrees/emails-list/src/commands/contact-properties/create.ts +0 -118
- package/.claude/worktrees/emails-list/src/commands/contact-properties/delete.ts +0 -48
- package/.claude/worktrees/emails-list/src/commands/contact-properties/get.ts +0 -46
- package/.claude/worktrees/emails-list/src/commands/contact-properties/index.ts +0 -48
- package/.claude/worktrees/emails-list/src/commands/contact-properties/list.ts +0 -68
- package/.claude/worktrees/emails-list/src/commands/contact-properties/update.ts +0 -88
- package/.claude/worktrees/emails-list/src/commands/contact-properties/utils.ts +0 -17
- package/.claude/worktrees/emails-list/src/commands/contacts/add-segment.ts +0 -78
- package/.claude/worktrees/emails-list/src/commands/contacts/create.ts +0 -122
- package/.claude/worktrees/emails-list/src/commands/contacts/delete.ts +0 -49
- package/.claude/worktrees/emails-list/src/commands/contacts/get.ts +0 -53
- package/.claude/worktrees/emails-list/src/commands/contacts/index.ts +0 -58
- package/.claude/worktrees/emails-list/src/commands/contacts/list.ts +0 -57
- package/.claude/worktrees/emails-list/src/commands/contacts/remove-segment.ts +0 -48
- package/.claude/worktrees/emails-list/src/commands/contacts/segments.ts +0 -39
- package/.claude/worktrees/emails-list/src/commands/contacts/topics.ts +0 -45
- package/.claude/worktrees/emails-list/src/commands/contacts/update-topics.ts +0 -90
- package/.claude/worktrees/emails-list/src/commands/contacts/update.ts +0 -77
- package/.claude/worktrees/emails-list/src/commands/contacts/utils.ts +0 -119
- package/.claude/worktrees/emails-list/src/commands/doctor.ts +0 -298
- package/.claude/worktrees/emails-list/src/commands/domains/create.ts +0 -83
- package/.claude/worktrees/emails-list/src/commands/domains/delete.ts +0 -42
- package/.claude/worktrees/emails-list/src/commands/domains/get.ts +0 -47
- package/.claude/worktrees/emails-list/src/commands/domains/index.ts +0 -35
- package/.claude/worktrees/emails-list/src/commands/domains/list.ts +0 -53
- package/.claude/worktrees/emails-list/src/commands/domains/update.ts +0 -75
- package/.claude/worktrees/emails-list/src/commands/domains/utils.ts +0 -44
- package/.claude/worktrees/emails-list/src/commands/domains/verify.ts +0 -38
- package/.claude/worktrees/emails-list/src/commands/emails/batch.ts +0 -140
- package/.claude/worktrees/emails-list/src/commands/emails/index.ts +0 -28
- package/.claude/worktrees/emails-list/src/commands/emails/list.ts +0 -73
- package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachment.ts +0 -55
- package/.claude/worktrees/emails-list/src/commands/emails/receiving/attachments.ts +0 -68
- package/.claude/worktrees/emails-list/src/commands/emails/receiving/get.ts +0 -58
- package/.claude/worktrees/emails-list/src/commands/emails/receiving/index.ts +0 -28
- package/.claude/worktrees/emails-list/src/commands/emails/receiving/list.ts +0 -59
- package/.claude/worktrees/emails-list/src/commands/emails/receiving/utils.ts +0 -38
- package/.claude/worktrees/emails-list/src/commands/emails/send.ts +0 -189
- package/.claude/worktrees/emails-list/src/commands/open.ts +0 -24
- package/.claude/worktrees/emails-list/src/commands/segments/create.ts +0 -50
- package/.claude/worktrees/emails-list/src/commands/segments/delete.ts +0 -47
- package/.claude/worktrees/emails-list/src/commands/segments/get.ts +0 -38
- package/.claude/worktrees/emails-list/src/commands/segments/index.ts +0 -36
- package/.claude/worktrees/emails-list/src/commands/segments/list.ts +0 -58
- package/.claude/worktrees/emails-list/src/commands/segments/utils.ts +0 -7
- package/.claude/worktrees/emails-list/src/commands/teams/index.ts +0 -10
- package/.claude/worktrees/emails-list/src/commands/teams/list.ts +0 -35
- package/.claude/worktrees/emails-list/src/commands/teams/remove.ts +0 -83
- package/.claude/worktrees/emails-list/src/commands/teams/switch.ts +0 -73
- package/.claude/worktrees/emails-list/src/commands/topics/create.ts +0 -73
- package/.claude/worktrees/emails-list/src/commands/topics/delete.ts +0 -47
- package/.claude/worktrees/emails-list/src/commands/topics/get.ts +0 -42
- package/.claude/worktrees/emails-list/src/commands/topics/index.ts +0 -42
- package/.claude/worktrees/emails-list/src/commands/topics/list.ts +0 -34
- package/.claude/worktrees/emails-list/src/commands/topics/update.ts +0 -59
- package/.claude/worktrees/emails-list/src/commands/topics/utils.ts +0 -16
- package/.claude/worktrees/emails-list/src/commands/webhooks/create.ts +0 -128
- package/.claude/worktrees/emails-list/src/commands/webhooks/delete.ts +0 -49
- package/.claude/worktrees/emails-list/src/commands/webhooks/get.ts +0 -42
- package/.claude/worktrees/emails-list/src/commands/webhooks/index.ts +0 -44
- package/.claude/worktrees/emails-list/src/commands/webhooks/list.ts +0 -55
- package/.claude/worktrees/emails-list/src/commands/webhooks/update.ts +0 -83
- package/.claude/worktrees/emails-list/src/commands/webhooks/utils.ts +0 -36
- package/.claude/worktrees/emails-list/src/commands/whoami.ts +0 -71
- package/.claude/worktrees/emails-list/src/lib/actions.ts +0 -157
- package/.claude/worktrees/emails-list/src/lib/client.ts +0 -34
- package/.claude/worktrees/emails-list/src/lib/config.ts +0 -211
- package/.claude/worktrees/emails-list/src/lib/files.ts +0 -15
- package/.claude/worktrees/emails-list/src/lib/help-text.ts +0 -38
- package/.claude/worktrees/emails-list/src/lib/output.ts +0 -54
- package/.claude/worktrees/emails-list/src/lib/pagination.ts +0 -36
- package/.claude/worktrees/emails-list/src/lib/prompts.ts +0 -149
- package/.claude/worktrees/emails-list/src/lib/spinner.ts +0 -93
- package/.claude/worktrees/emails-list/src/lib/table.ts +0 -57
- package/.claude/worktrees/emails-list/src/lib/tty.ts +0 -28
- package/.claude/worktrees/emails-list/src/lib/version.ts +0 -4
- package/.claude/worktrees/emails-list/tests/commands/api-keys/create.test.ts +0 -195
- package/.claude/worktrees/emails-list/tests/commands/api-keys/delete.test.ts +0 -156
- package/.claude/worktrees/emails-list/tests/commands/api-keys/list.test.ts +0 -133
- package/.claude/worktrees/emails-list/tests/commands/auth/login.test.ts +0 -119
- package/.claude/worktrees/emails-list/tests/commands/auth/logout.test.ts +0 -146
- package/.claude/worktrees/emails-list/tests/commands/broadcasts/create.test.ts +0 -447
- package/.claude/worktrees/emails-list/tests/commands/broadcasts/delete.test.ts +0 -182
- package/.claude/worktrees/emails-list/tests/commands/broadcasts/get.test.ts +0 -146
- package/.claude/worktrees/emails-list/tests/commands/broadcasts/list.test.ts +0 -196
- package/.claude/worktrees/emails-list/tests/commands/broadcasts/send.test.ts +0 -161
- package/.claude/worktrees/emails-list/tests/commands/broadcasts/update.test.ts +0 -283
- package/.claude/worktrees/emails-list/tests/commands/contact-properties/create.test.ts +0 -250
- package/.claude/worktrees/emails-list/tests/commands/contact-properties/delete.test.ts +0 -183
- package/.claude/worktrees/emails-list/tests/commands/contact-properties/get.test.ts +0 -144
- package/.claude/worktrees/emails-list/tests/commands/contact-properties/list.test.ts +0 -180
- package/.claude/worktrees/emails-list/tests/commands/contact-properties/update.test.ts +0 -216
- package/.claude/worktrees/emails-list/tests/commands/contacts/add-segment.test.ts +0 -188
- package/.claude/worktrees/emails-list/tests/commands/contacts/create.test.ts +0 -270
- package/.claude/worktrees/emails-list/tests/commands/contacts/delete.test.ts +0 -192
- package/.claude/worktrees/emails-list/tests/commands/contacts/get.test.ts +0 -148
- package/.claude/worktrees/emails-list/tests/commands/contacts/list.test.ts +0 -175
- package/.claude/worktrees/emails-list/tests/commands/contacts/remove-segment.test.ts +0 -166
- package/.claude/worktrees/emails-list/tests/commands/contacts/segments.test.ts +0 -167
- package/.claude/worktrees/emails-list/tests/commands/contacts/topics.test.ts +0 -163
- package/.claude/worktrees/emails-list/tests/commands/contacts/update-topics.test.ts +0 -247
- package/.claude/worktrees/emails-list/tests/commands/contacts/update.test.ts +0 -205
- package/.claude/worktrees/emails-list/tests/commands/doctor.test.ts +0 -165
- package/.claude/worktrees/emails-list/tests/commands/domains/create.test.ts +0 -192
- package/.claude/worktrees/emails-list/tests/commands/domains/delete.test.ts +0 -156
- package/.claude/worktrees/emails-list/tests/commands/domains/get.test.ts +0 -137
- package/.claude/worktrees/emails-list/tests/commands/domains/list.test.ts +0 -164
- package/.claude/worktrees/emails-list/tests/commands/domains/update.test.ts +0 -223
- package/.claude/worktrees/emails-list/tests/commands/domains/verify.test.ts +0 -117
- package/.claude/worktrees/emails-list/tests/commands/emails/batch.test.ts +0 -313
- package/.claude/worktrees/emails-list/tests/commands/emails/list.test.ts +0 -196
- package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachment.test.ts +0 -140
- package/.claude/worktrees/emails-list/tests/commands/emails/receiving/attachments.test.ts +0 -168
- package/.claude/worktrees/emails-list/tests/commands/emails/receiving/get.test.ts +0 -140
- package/.claude/worktrees/emails-list/tests/commands/emails/receiving/list.test.ts +0 -181
- package/.claude/worktrees/emails-list/tests/commands/emails/send.test.ts +0 -309
- package/.claude/worktrees/emails-list/tests/commands/segments/create.test.ts +0 -163
- package/.claude/worktrees/emails-list/tests/commands/segments/delete.test.ts +0 -182
- package/.claude/worktrees/emails-list/tests/commands/segments/get.test.ts +0 -137
- package/.claude/worktrees/emails-list/tests/commands/segments/list.test.ts +0 -173
- package/.claude/worktrees/emails-list/tests/commands/teams/list.test.ts +0 -63
- package/.claude/worktrees/emails-list/tests/commands/teams/remove.test.ts +0 -103
- package/.claude/worktrees/emails-list/tests/commands/teams/switch.test.ts +0 -96
- package/.claude/worktrees/emails-list/tests/commands/topics/create.test.ts +0 -191
- package/.claude/worktrees/emails-list/tests/commands/topics/delete.test.ts +0 -156
- package/.claude/worktrees/emails-list/tests/commands/topics/get.test.ts +0 -125
- package/.claude/worktrees/emails-list/tests/commands/topics/list.test.ts +0 -124
- package/.claude/worktrees/emails-list/tests/commands/topics/update.test.ts +0 -177
- package/.claude/worktrees/emails-list/tests/commands/webhooks/create.test.ts +0 -224
- package/.claude/worktrees/emails-list/tests/commands/webhooks/delete.test.ts +0 -156
- package/.claude/worktrees/emails-list/tests/commands/webhooks/get.test.ts +0 -125
- package/.claude/worktrees/emails-list/tests/commands/webhooks/list.test.ts +0 -177
- package/.claude/worktrees/emails-list/tests/commands/webhooks/update.test.ts +0 -206
- package/.claude/worktrees/emails-list/tests/commands/whoami.test.ts +0 -99
- package/.claude/worktrees/emails-list/tests/helpers.ts +0 -93
- package/.claude/worktrees/emails-list/tests/lib/client.test.ts +0 -71
- package/.claude/worktrees/emails-list/tests/lib/config.test.ts +0 -414
- package/.claude/worktrees/emails-list/tests/lib/files.test.ts +0 -65
- package/.claude/worktrees/emails-list/tests/lib/help-text.test.ts +0 -97
- package/.claude/worktrees/emails-list/tests/lib/output.test.ts +0 -127
- package/.claude/worktrees/emails-list/tests/lib/prompts.test.ts +0 -178
- package/.claude/worktrees/emails-list/tests/lib/spinner.test.ts +0 -146
- package/.claude/worktrees/emails-list/tests/lib/table.test.ts +0 -63
- package/.claude/worktrees/emails-list/tests/lib/tty.test.ts +0 -85
- package/.claude/worktrees/emails-list/tsconfig.json +0 -14
- package/.github/scripts/pr-title-check.js +0 -34
- package/.github/workflows/ci.yml +0 -32
- package/.github/workflows/pr-title-check.yml +0 -13
- package/.github/workflows/release.yml +0 -120
- package/.github/workflows/test-install-windows.yml +0 -48
- package/CHANGELOG.md +0 -31
- package/biome.json +0 -36
- package/bun.lock +0 -76
- package/bunfig.toml +0 -2
- package/docs/agent-dx-gaps.md +0 -167
- package/docs/missing-commands.md +0 -58
- package/docs/production-readiness.md +0 -99
- package/docs/secure-key-storage.md +0 -174
- package/install.ps1 +0 -141
- package/install.sh +0 -301
- package/renovate.json +0 -4
- package/src/cli.ts +0 -82
- package/src/commands/api-keys/create.ts +0 -114
- package/src/commands/api-keys/delete.ts +0 -47
- package/src/commands/api-keys/index.ts +0 -26
- package/src/commands/api-keys/list.ts +0 -35
- package/src/commands/api-keys/utils.ts +0 -8
- package/src/commands/auth/index.ts +0 -20
- package/src/commands/auth/login.ts +0 -207
- package/src/commands/auth/logout.ts +0 -105
- package/src/commands/broadcasts/create.ts +0 -196
- package/src/commands/broadcasts/delete.ts +0 -46
- package/src/commands/broadcasts/get.ts +0 -59
- package/src/commands/broadcasts/index.ts +0 -43
- package/src/commands/broadcasts/list.ts +0 -60
- package/src/commands/broadcasts/send.ts +0 -56
- package/src/commands/broadcasts/update.ts +0 -95
- package/src/commands/broadcasts/utils.ts +0 -35
- package/src/commands/contact-properties/create.ts +0 -118
- package/src/commands/contact-properties/delete.ts +0 -48
- package/src/commands/contact-properties/get.ts +0 -46
- package/src/commands/contact-properties/index.ts +0 -48
- package/src/commands/contact-properties/list.ts +0 -68
- package/src/commands/contact-properties/update.ts +0 -88
- package/src/commands/contact-properties/utils.ts +0 -17
- package/src/commands/contacts/add-segment.ts +0 -78
- package/src/commands/contacts/create.ts +0 -122
- package/src/commands/contacts/delete.ts +0 -49
- package/src/commands/contacts/get.ts +0 -53
- package/src/commands/contacts/index.ts +0 -58
- package/src/commands/contacts/list.ts +0 -57
- package/src/commands/contacts/remove-segment.ts +0 -48
- package/src/commands/contacts/segments.ts +0 -39
- package/src/commands/contacts/topics.ts +0 -45
- package/src/commands/contacts/update-topics.ts +0 -90
- package/src/commands/contacts/update.ts +0 -77
- package/src/commands/contacts/utils.ts +0 -119
- package/src/commands/doctor.ts +0 -298
- package/src/commands/domains/create.ts +0 -83
- package/src/commands/domains/delete.ts +0 -42
- package/src/commands/domains/get.ts +0 -47
- package/src/commands/domains/index.ts +0 -35
- package/src/commands/domains/list.ts +0 -53
- package/src/commands/domains/update.ts +0 -75
- package/src/commands/domains/utils.ts +0 -44
- package/src/commands/domains/verify.ts +0 -38
- package/src/commands/emails/batch.ts +0 -140
- package/src/commands/emails/index.ts +0 -24
- package/src/commands/emails/receiving/attachment.ts +0 -55
- package/src/commands/emails/receiving/attachments.ts +0 -68
- package/src/commands/emails/receiving/get.ts +0 -58
- package/src/commands/emails/receiving/index.ts +0 -28
- package/src/commands/emails/receiving/list.ts +0 -59
- package/src/commands/emails/receiving/utils.ts +0 -38
- package/src/commands/emails/send.ts +0 -189
- package/src/commands/open.ts +0 -24
- package/src/commands/segments/create.ts +0 -50
- package/src/commands/segments/delete.ts +0 -47
- package/src/commands/segments/get.ts +0 -38
- package/src/commands/segments/index.ts +0 -36
- package/src/commands/segments/list.ts +0 -58
- package/src/commands/segments/utils.ts +0 -7
- package/src/commands/teams/index.ts +0 -10
- package/src/commands/teams/list.ts +0 -35
- package/src/commands/teams/remove.ts +0 -83
- package/src/commands/teams/switch.ts +0 -73
- package/src/commands/topics/create.ts +0 -73
- package/src/commands/topics/delete.ts +0 -47
- package/src/commands/topics/get.ts +0 -42
- package/src/commands/topics/index.ts +0 -42
- package/src/commands/topics/list.ts +0 -34
- package/src/commands/topics/update.ts +0 -59
- package/src/commands/topics/utils.ts +0 -16
- package/src/commands/webhooks/create.ts +0 -128
- package/src/commands/webhooks/delete.ts +0 -49
- package/src/commands/webhooks/get.ts +0 -42
- package/src/commands/webhooks/index.ts +0 -44
- package/src/commands/webhooks/list.ts +0 -55
- package/src/commands/webhooks/update.ts +0 -83
- package/src/commands/webhooks/utils.ts +0 -36
- package/src/commands/whoami.ts +0 -71
- package/src/lib/actions.ts +0 -157
- package/src/lib/client.ts +0 -37
- package/src/lib/config.ts +0 -211
- package/src/lib/files.ts +0 -15
- package/src/lib/help-text.ts +0 -38
- package/src/lib/output.ts +0 -54
- package/src/lib/pagination.ts +0 -36
- package/src/lib/prompts.ts +0 -149
- package/src/lib/spinner.ts +0 -93
- package/src/lib/table.ts +0 -57
- package/src/lib/tty.ts +0 -28
- package/src/lib/version.ts +0 -4
- package/tests/commands/api-keys/create.test.ts +0 -195
- package/tests/commands/api-keys/delete.test.ts +0 -156
- package/tests/commands/api-keys/list.test.ts +0 -133
- package/tests/commands/auth/login.test.ts +0 -119
- package/tests/commands/auth/logout.test.ts +0 -146
- package/tests/commands/broadcasts/create.test.ts +0 -447
- package/tests/commands/broadcasts/delete.test.ts +0 -182
- package/tests/commands/broadcasts/get.test.ts +0 -146
- package/tests/commands/broadcasts/list.test.ts +0 -196
- package/tests/commands/broadcasts/send.test.ts +0 -161
- package/tests/commands/broadcasts/update.test.ts +0 -283
- package/tests/commands/contact-properties/create.test.ts +0 -250
- package/tests/commands/contact-properties/delete.test.ts +0 -183
- package/tests/commands/contact-properties/get.test.ts +0 -144
- package/tests/commands/contact-properties/list.test.ts +0 -180
- package/tests/commands/contact-properties/update.test.ts +0 -216
- package/tests/commands/contacts/add-segment.test.ts +0 -188
- package/tests/commands/contacts/create.test.ts +0 -270
- package/tests/commands/contacts/delete.test.ts +0 -192
- package/tests/commands/contacts/get.test.ts +0 -148
- package/tests/commands/contacts/list.test.ts +0 -175
- package/tests/commands/contacts/remove-segment.test.ts +0 -166
- package/tests/commands/contacts/segments.test.ts +0 -167
- package/tests/commands/contacts/topics.test.ts +0 -163
- package/tests/commands/contacts/update-topics.test.ts +0 -247
- package/tests/commands/contacts/update.test.ts +0 -205
- package/tests/commands/doctor.test.ts +0 -165
- package/tests/commands/domains/create.test.ts +0 -192
- package/tests/commands/domains/delete.test.ts +0 -156
- package/tests/commands/domains/get.test.ts +0 -137
- package/tests/commands/domains/list.test.ts +0 -164
- package/tests/commands/domains/update.test.ts +0 -223
- package/tests/commands/domains/verify.test.ts +0 -117
- package/tests/commands/emails/batch.test.ts +0 -313
- package/tests/commands/emails/receiving/attachment.test.ts +0 -140
- package/tests/commands/emails/receiving/attachments.test.ts +0 -168
- package/tests/commands/emails/receiving/get.test.ts +0 -140
- package/tests/commands/emails/receiving/list.test.ts +0 -181
- package/tests/commands/emails/send.test.ts +0 -309
- package/tests/commands/segments/create.test.ts +0 -163
- package/tests/commands/segments/delete.test.ts +0 -182
- package/tests/commands/segments/get.test.ts +0 -137
- package/tests/commands/segments/list.test.ts +0 -173
- package/tests/commands/teams/list.test.ts +0 -63
- package/tests/commands/teams/remove.test.ts +0 -103
- package/tests/commands/teams/switch.test.ts +0 -96
- package/tests/commands/topics/create.test.ts +0 -191
- package/tests/commands/topics/delete.test.ts +0 -156
- package/tests/commands/topics/get.test.ts +0 -125
- package/tests/commands/topics/list.test.ts +0 -124
- package/tests/commands/topics/update.test.ts +0 -177
- package/tests/commands/webhooks/create.test.ts +0 -224
- package/tests/commands/webhooks/delete.test.ts +0 -156
- package/tests/commands/webhooks/get.test.ts +0 -125
- package/tests/commands/webhooks/list.test.ts +0 -177
- package/tests/commands/webhooks/update.test.ts +0 -206
- package/tests/commands/whoami.test.ts +0 -99
- package/tests/helpers.ts +0 -93
- package/tests/lib/client.test.ts +0 -71
- package/tests/lib/config.test.ts +0 -414
- package/tests/lib/files.test.ts +0 -65
- package/tests/lib/help-text.test.ts +0 -97
- package/tests/lib/output.test.ts +0 -127
- package/tests/lib/prompts.test.ts +0 -178
- package/tests/lib/spinner.test.ts +0 -146
- package/tests/lib/table.test.ts +0 -63
- package/tests/lib/tty.test.ts +0 -85
- package/tsconfig.json +0 -14
|
@@ -1,414 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
2
|
-
import { mkdirSync, readFileSync, rmSync, statSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import {
|
|
6
|
-
getConfigDir,
|
|
7
|
-
listTeams,
|
|
8
|
-
removeTeam,
|
|
9
|
-
resolveApiKey,
|
|
10
|
-
resolveTeamName,
|
|
11
|
-
setActiveTeam,
|
|
12
|
-
storeApiKey,
|
|
13
|
-
} from '../../src/lib/config';
|
|
14
|
-
import { captureTestEnv } from '../helpers';
|
|
15
|
-
|
|
16
|
-
describe('getConfigDir', () => {
|
|
17
|
-
const restoreEnv = captureTestEnv();
|
|
18
|
-
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
restoreEnv();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('respects XDG_CONFIG_HOME', () => {
|
|
24
|
-
process.env.XDG_CONFIG_HOME = '/custom/config';
|
|
25
|
-
expect(getConfigDir()).toBe('/custom/config/resend');
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('falls back to ~/.config/resend on non-Windows', () => {
|
|
29
|
-
delete process.env.XDG_CONFIG_HOME;
|
|
30
|
-
const dir = getConfigDir();
|
|
31
|
-
expect(dir).toMatch(/\.config\/resend$/);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('resolveApiKey', () => {
|
|
36
|
-
const restoreEnv = captureTestEnv();
|
|
37
|
-
let tmpDir: string;
|
|
38
|
-
|
|
39
|
-
beforeEach(() => {
|
|
40
|
-
tmpDir = join(
|
|
41
|
-
tmpdir(),
|
|
42
|
-
`resend-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
43
|
-
);
|
|
44
|
-
mkdirSync(tmpDir, { recursive: true });
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
afterEach(() => {
|
|
48
|
-
restoreEnv();
|
|
49
|
-
rmSync(tmpDir, { recursive: true, force: true });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('flag value takes highest priority', () => {
|
|
53
|
-
process.env.RESEND_API_KEY = 're_env_key';
|
|
54
|
-
const result = resolveApiKey('re_flag_key');
|
|
55
|
-
expect(result).toEqual({ key: 're_flag_key', source: 'flag' });
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('env var is second priority', () => {
|
|
59
|
-
process.env.RESEND_API_KEY = 're_env_key';
|
|
60
|
-
const result = resolveApiKey();
|
|
61
|
-
expect(result).toEqual({ key: 're_env_key', source: 'env' });
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('config file is third priority', () => {
|
|
65
|
-
delete process.env.RESEND_API_KEY;
|
|
66
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
67
|
-
const configDir = join(tmpDir, 'resend');
|
|
68
|
-
mkdirSync(configDir, { recursive: true });
|
|
69
|
-
Bun.write(
|
|
70
|
-
join(configDir, 'credentials.json'),
|
|
71
|
-
JSON.stringify({
|
|
72
|
-
active_team: 'default',
|
|
73
|
-
teams: { default: { api_key: 're_config_key' } },
|
|
74
|
-
}),
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const result = resolveApiKey();
|
|
78
|
-
expect(result).toEqual({
|
|
79
|
-
key: 're_config_key',
|
|
80
|
-
source: 'config',
|
|
81
|
-
team: 'default',
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('reads legacy format (api_key at root)', () => {
|
|
86
|
-
delete process.env.RESEND_API_KEY;
|
|
87
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
88
|
-
const configDir = join(tmpDir, 'resend');
|
|
89
|
-
mkdirSync(configDir, { recursive: true });
|
|
90
|
-
Bun.write(
|
|
91
|
-
join(configDir, 'credentials.json'),
|
|
92
|
-
JSON.stringify({ api_key: 're_legacy_key' }),
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
const result = resolveApiKey();
|
|
96
|
-
expect(result).toEqual({
|
|
97
|
-
key: 're_legacy_key',
|
|
98
|
-
source: 'config',
|
|
99
|
-
team: 'default',
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('resolves specific team from config', () => {
|
|
104
|
-
delete process.env.RESEND_API_KEY;
|
|
105
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
106
|
-
const configDir = join(tmpDir, 'resend');
|
|
107
|
-
mkdirSync(configDir, { recursive: true });
|
|
108
|
-
Bun.write(
|
|
109
|
-
join(configDir, 'credentials.json'),
|
|
110
|
-
JSON.stringify({
|
|
111
|
-
active_team: 'default',
|
|
112
|
-
teams: {
|
|
113
|
-
default: { api_key: 're_default' },
|
|
114
|
-
staging: { api_key: 're_staging' },
|
|
115
|
-
},
|
|
116
|
-
}),
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
const result = resolveApiKey(undefined, 'staging');
|
|
120
|
-
expect(result).toEqual({
|
|
121
|
-
key: 're_staging',
|
|
122
|
-
source: 'config',
|
|
123
|
-
team: 'staging',
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test('returns null when no key found', () => {
|
|
128
|
-
delete process.env.RESEND_API_KEY;
|
|
129
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
130
|
-
const result = resolveApiKey();
|
|
131
|
-
expect(result).toBeNull();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test('returns null on malformed config JSON', () => {
|
|
135
|
-
delete process.env.RESEND_API_KEY;
|
|
136
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
137
|
-
const configDir = join(tmpDir, 'resend');
|
|
138
|
-
mkdirSync(configDir, { recursive: true });
|
|
139
|
-
Bun.write(join(configDir, 'credentials.json'), 'not json');
|
|
140
|
-
|
|
141
|
-
const result = resolveApiKey();
|
|
142
|
-
expect(result).toBeNull();
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test('returns null when team does not exist in config', () => {
|
|
146
|
-
delete process.env.RESEND_API_KEY;
|
|
147
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
148
|
-
const configDir = join(tmpDir, 'resend');
|
|
149
|
-
mkdirSync(configDir, { recursive: true });
|
|
150
|
-
Bun.write(
|
|
151
|
-
join(configDir, 'credentials.json'),
|
|
152
|
-
JSON.stringify({
|
|
153
|
-
active_team: 'default',
|
|
154
|
-
teams: { default: { api_key: 're_default' } },
|
|
155
|
-
}),
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
const result = resolveApiKey(undefined, 'nonexistent');
|
|
159
|
-
expect(result).toBeNull();
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe('resolveTeamName', () => {
|
|
164
|
-
const restoreEnv = captureTestEnv();
|
|
165
|
-
let tmpDir: string;
|
|
166
|
-
|
|
167
|
-
beforeEach(() => {
|
|
168
|
-
tmpDir = join(
|
|
169
|
-
tmpdir(),
|
|
170
|
-
`resend-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
171
|
-
);
|
|
172
|
-
mkdirSync(tmpDir, { recursive: true });
|
|
173
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
afterEach(() => {
|
|
177
|
-
restoreEnv();
|
|
178
|
-
rmSync(tmpDir, { recursive: true, force: true });
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
test('flag value takes highest priority', () => {
|
|
182
|
-
process.env.RESEND_TEAM = 'env_team';
|
|
183
|
-
expect(resolveTeamName('flag_team')).toBe('flag_team');
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
test('env var is second priority', () => {
|
|
187
|
-
process.env.RESEND_TEAM = 'env_team';
|
|
188
|
-
expect(resolveTeamName()).toBe('env_team');
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
test('active_team from config is third priority', () => {
|
|
192
|
-
delete process.env.RESEND_TEAM;
|
|
193
|
-
const configDir = join(tmpDir, 'resend');
|
|
194
|
-
mkdirSync(configDir, { recursive: true });
|
|
195
|
-
Bun.write(
|
|
196
|
-
join(configDir, 'credentials.json'),
|
|
197
|
-
JSON.stringify({
|
|
198
|
-
active_team: 'production',
|
|
199
|
-
teams: { production: { api_key: 're_xxx' } },
|
|
200
|
-
}),
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
expect(resolveTeamName()).toBe('production');
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
test('defaults to "default" when nothing configured', () => {
|
|
207
|
-
delete process.env.RESEND_TEAM;
|
|
208
|
-
expect(resolveTeamName()).toBe('default');
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
describe('storeApiKey', () => {
|
|
213
|
-
const restoreEnv = captureTestEnv();
|
|
214
|
-
let tmpDir: string;
|
|
215
|
-
|
|
216
|
-
beforeEach(() => {
|
|
217
|
-
tmpDir = join(
|
|
218
|
-
tmpdir(),
|
|
219
|
-
`resend-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
220
|
-
);
|
|
221
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
afterEach(() => {
|
|
225
|
-
restoreEnv();
|
|
226
|
-
rmSync(tmpDir, { recursive: true, force: true });
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
test('writes credentials.json with team structure', () => {
|
|
230
|
-
const configPath = storeApiKey('re_test_key_123');
|
|
231
|
-
expect(configPath).toContain('credentials.json');
|
|
232
|
-
|
|
233
|
-
const data = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
234
|
-
expect(data.active_team).toBe('default');
|
|
235
|
-
expect(data.teams.default.api_key).toBe('re_test_key_123');
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
test('stores key under specific team name', () => {
|
|
239
|
-
const configPath = storeApiKey('re_staging_key', 'staging');
|
|
240
|
-
const data = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
241
|
-
expect(data.teams.staging.api_key).toBe('re_staging_key');
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
test('preserves existing teams when adding new one', () => {
|
|
245
|
-
storeApiKey('re_default_key');
|
|
246
|
-
storeApiKey('re_staging_key', 'staging');
|
|
247
|
-
|
|
248
|
-
const configPath = join(tmpDir, 'resend', 'credentials.json');
|
|
249
|
-
const data = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
250
|
-
expect(data.teams.default.api_key).toBe('re_default_key');
|
|
251
|
-
expect(data.teams.staging.api_key).toBe('re_staging_key');
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
test('creates config directory if it does not exist', () => {
|
|
255
|
-
storeApiKey('re_test_key');
|
|
256
|
-
const configDir = join(tmpDir, 'resend');
|
|
257
|
-
const stat = statSync(configDir);
|
|
258
|
-
expect(stat.isDirectory()).toBe(true);
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
test('sets file permissions to 0600', () => {
|
|
262
|
-
const configPath = storeApiKey('re_test_key');
|
|
263
|
-
const stat = statSync(configPath);
|
|
264
|
-
const mode = stat.mode & 0o777;
|
|
265
|
-
expect(mode).toBe(0o600);
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
test('overwrites existing team key', () => {
|
|
269
|
-
storeApiKey('re_first_key');
|
|
270
|
-
storeApiKey('re_second_key');
|
|
271
|
-
|
|
272
|
-
const configPath = join(tmpDir, 'resend', 'credentials.json');
|
|
273
|
-
const data = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
274
|
-
expect(data.teams.default.api_key).toBe('re_second_key');
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
test('sets first team as active', () => {
|
|
278
|
-
storeApiKey('re_first_key', 'myteam');
|
|
279
|
-
|
|
280
|
-
const configPath = join(tmpDir, 'resend', 'credentials.json');
|
|
281
|
-
const data = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
282
|
-
expect(data.active_team).toBe('myteam');
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
describe('listTeams', () => {
|
|
287
|
-
const restoreEnv = captureTestEnv();
|
|
288
|
-
let tmpDir: string;
|
|
289
|
-
|
|
290
|
-
beforeEach(() => {
|
|
291
|
-
tmpDir = join(
|
|
292
|
-
tmpdir(),
|
|
293
|
-
`resend-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
294
|
-
);
|
|
295
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
afterEach(() => {
|
|
299
|
-
restoreEnv();
|
|
300
|
-
rmSync(tmpDir, { recursive: true, force: true });
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
test('returns empty array when no config', () => {
|
|
304
|
-
expect(listTeams()).toEqual([]);
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
test('returns teams with active flag', () => {
|
|
308
|
-
storeApiKey('re_default', 'default');
|
|
309
|
-
storeApiKey('re_staging', 'staging');
|
|
310
|
-
|
|
311
|
-
const teams = listTeams();
|
|
312
|
-
expect(teams).toEqual([
|
|
313
|
-
{ name: 'default', active: true },
|
|
314
|
-
{ name: 'staging', active: false },
|
|
315
|
-
]);
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
describe('setActiveTeam', () => {
|
|
320
|
-
const restoreEnv = captureTestEnv();
|
|
321
|
-
let tmpDir: string;
|
|
322
|
-
|
|
323
|
-
beforeEach(() => {
|
|
324
|
-
tmpDir = join(
|
|
325
|
-
tmpdir(),
|
|
326
|
-
`resend-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
327
|
-
);
|
|
328
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
afterEach(() => {
|
|
332
|
-
restoreEnv();
|
|
333
|
-
rmSync(tmpDir, { recursive: true, force: true });
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
test('switches active team', () => {
|
|
337
|
-
storeApiKey('re_default', 'default');
|
|
338
|
-
storeApiKey('re_staging', 'staging');
|
|
339
|
-
|
|
340
|
-
setActiveTeam('staging');
|
|
341
|
-
|
|
342
|
-
const configPath = join(tmpDir, 'resend', 'credentials.json');
|
|
343
|
-
const data = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
344
|
-
expect(data.active_team).toBe('staging');
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
test('throws when team does not exist', () => {
|
|
348
|
-
storeApiKey('re_default');
|
|
349
|
-
expect(() => setActiveTeam('nonexistent')).toThrow('not found');
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
test('throws when no credentials file', () => {
|
|
353
|
-
expect(() => setActiveTeam('any')).toThrow('No credentials file');
|
|
354
|
-
});
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
describe('removeTeam', () => {
|
|
358
|
-
const restoreEnv = captureTestEnv();
|
|
359
|
-
let tmpDir: string;
|
|
360
|
-
|
|
361
|
-
beforeEach(() => {
|
|
362
|
-
tmpDir = join(
|
|
363
|
-
tmpdir(),
|
|
364
|
-
`resend-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
365
|
-
);
|
|
366
|
-
process.env.XDG_CONFIG_HOME = tmpDir;
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
afterEach(() => {
|
|
370
|
-
restoreEnv();
|
|
371
|
-
rmSync(tmpDir, { recursive: true, force: true });
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
test('removes a team entry', () => {
|
|
375
|
-
storeApiKey('re_default', 'default');
|
|
376
|
-
storeApiKey('re_staging', 'staging');
|
|
377
|
-
|
|
378
|
-
removeTeam('staging');
|
|
379
|
-
|
|
380
|
-
const teams = listTeams();
|
|
381
|
-
expect(teams).toEqual([{ name: 'default', active: true }]);
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
test('adjusts active_team when active is removed', () => {
|
|
385
|
-
storeApiKey('re_default', 'default');
|
|
386
|
-
storeApiKey('re_staging', 'staging');
|
|
387
|
-
setActiveTeam('staging');
|
|
388
|
-
|
|
389
|
-
removeTeam('staging');
|
|
390
|
-
|
|
391
|
-
const configPath = join(tmpDir, 'resend', 'credentials.json');
|
|
392
|
-
const data = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
393
|
-
expect(data.active_team).toBe('default');
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
test('deletes file when last team removed', () => {
|
|
397
|
-
storeApiKey('re_only', 'only');
|
|
398
|
-
|
|
399
|
-
removeTeam('only');
|
|
400
|
-
|
|
401
|
-
const { existsSync } = require('node:fs');
|
|
402
|
-
const configPath = join(tmpDir, 'resend', 'credentials.json');
|
|
403
|
-
expect(existsSync(configPath)).toBe(false);
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
test('throws when team does not exist', () => {
|
|
407
|
-
storeApiKey('re_default');
|
|
408
|
-
expect(() => removeTeam('nonexistent')).toThrow('not found');
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
test('throws when no credentials file', () => {
|
|
412
|
-
expect(() => removeTeam('any')).toThrow('No credentials file');
|
|
413
|
-
});
|
|
414
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, spyOn, test } from 'bun:test';
|
|
2
|
-
import { unlinkSync, writeFileSync } from 'node:fs';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
|
-
import { expectExit1, mockExitThrow } from '../helpers';
|
|
5
|
-
|
|
6
|
-
const globalOpts = { json: false, apiKey: undefined };
|
|
7
|
-
const jsonOpts = { json: true, apiKey: undefined };
|
|
8
|
-
|
|
9
|
-
describe('readFile', () => {
|
|
10
|
-
const tmpFile = join(import.meta.dir, 'tmp-test.txt');
|
|
11
|
-
let errorSpy: ReturnType<typeof spyOn> | undefined;
|
|
12
|
-
let exitSpy: ReturnType<typeof spyOn> | undefined;
|
|
13
|
-
|
|
14
|
-
afterEach(() => {
|
|
15
|
-
errorSpy?.mockRestore();
|
|
16
|
-
errorSpy = undefined;
|
|
17
|
-
exitSpy?.mockRestore();
|
|
18
|
-
exitSpy = undefined;
|
|
19
|
-
try {
|
|
20
|
-
unlinkSync(tmpFile);
|
|
21
|
-
} catch {
|
|
22
|
-
/* already removed */
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('reads file content and returns it as a string', () => {
|
|
27
|
-
writeFileSync(tmpFile, '<h1>Hello</h1>', 'utf-8');
|
|
28
|
-
const { readFile } = require('../../src/lib/files');
|
|
29
|
-
const content = readFile(tmpFile, globalOpts);
|
|
30
|
-
expect(content).toBe('<h1>Hello</h1>');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('reads JSON file content and returns it as a string', () => {
|
|
34
|
-
writeFileSync(tmpFile, '[{"id":1}]', 'utf-8');
|
|
35
|
-
const { readFile } = require('../../src/lib/files');
|
|
36
|
-
const content = readFile(tmpFile, globalOpts);
|
|
37
|
-
expect(content).toBe('[{"id":1}]');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test('exits with file_read_error when file does not exist', async () => {
|
|
41
|
-
errorSpy = spyOn(console, 'error').mockImplementation(() => {});
|
|
42
|
-
exitSpy = mockExitThrow();
|
|
43
|
-
|
|
44
|
-
const { readFile } = require('../../src/lib/files');
|
|
45
|
-
await expectExit1(async () =>
|
|
46
|
-
readFile('/nonexistent/path/data.txt', globalOpts),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const output = errorSpy?.mock.calls.map((c) => c[0]).join(' ');
|
|
50
|
-
expect(output).toContain('Failed to read file:');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('outputs JSON error with file_read_error code when json option is true', async () => {
|
|
54
|
-
errorSpy = spyOn(console, 'error').mockImplementation(() => {});
|
|
55
|
-
exitSpy = mockExitThrow();
|
|
56
|
-
|
|
57
|
-
const { readFile } = require('../../src/lib/files');
|
|
58
|
-
await expectExit1(async () => readFile('/nonexistent/file.txt', jsonOpts));
|
|
59
|
-
|
|
60
|
-
const raw = errorSpy?.mock.calls.map((c) => c[0]).join(' ');
|
|
61
|
-
const parsed = JSON.parse(raw);
|
|
62
|
-
expect(parsed.error.code).toBe('file_read_error');
|
|
63
|
-
expect(parsed.error.message).toContain('Failed to read file:');
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { buildHelpText } from '../../src/lib/help-text';
|
|
3
|
-
|
|
4
|
-
describe('buildHelpText', () => {
|
|
5
|
-
it('full leaf command — all options, setup: false', () => {
|
|
6
|
-
const result = buildHelpText({
|
|
7
|
-
context: 'Some context line\n\nNon-interactive: --required-flag <value>',
|
|
8
|
-
output: ' {"id":"em_123"}',
|
|
9
|
-
errorCodes: ['auth_error', 'send_error'],
|
|
10
|
-
examples: [
|
|
11
|
-
'resend emails send --to user@example.com --subject Hi --text Hello',
|
|
12
|
-
],
|
|
13
|
-
setup: false,
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
expect(result).toBe(
|
|
17
|
-
'\n' +
|
|
18
|
-
'Some context line\n\nNon-interactive: --required-flag <value>' +
|
|
19
|
-
'\n\n' +
|
|
20
|
-
'Global options:\n' +
|
|
21
|
-
' --api-key <key> API key (or set RESEND_API_KEY env var)\n' +
|
|
22
|
-
' --team <name> Team profile to use (overrides RESEND_TEAM)\n' +
|
|
23
|
-
' --json Force JSON output (also auto-enabled when stdout is piped)\n' +
|
|
24
|
-
' -q, --quiet Suppress spinners and status output (implies --json)' +
|
|
25
|
-
'\n\n' +
|
|
26
|
-
'Output (--json or piped):\n' +
|
|
27
|
-
' {"id":"em_123"}' +
|
|
28
|
-
'\n\n' +
|
|
29
|
-
'Errors (exit code 1):\n' +
|
|
30
|
-
' {"error":{"message":"<message>","code":"<code>"}}\n' +
|
|
31
|
-
' Codes: auth_error | send_error' +
|
|
32
|
-
'\n\n' +
|
|
33
|
-
'Examples:\n' +
|
|
34
|
-
' $ resend emails send --to user@example.com --subject Hi --text Hello',
|
|
35
|
-
);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('setup variant — no --api-key line, short --json form', () => {
|
|
39
|
-
const result = buildHelpText({
|
|
40
|
-
context: 'Setup context',
|
|
41
|
-
output: ' {"configured":true}',
|
|
42
|
-
errorCodes: ['write_error'],
|
|
43
|
-
examples: ['resend setup cursor'],
|
|
44
|
-
setup: true,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
expect(result).not.toContain('--api-key');
|
|
48
|
-
expect(result).toContain('--json Force JSON output');
|
|
49
|
-
expect(result).not.toContain('--json Force JSON output');
|
|
50
|
-
expect(result).toContain('Global options:');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('index command — no output, no errorCodes', () => {
|
|
54
|
-
const result = buildHelpText({
|
|
55
|
-
context: 'Manage emails.',
|
|
56
|
-
examples: ['resend emails send', 'resend emails receiving list'],
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
expect(result).not.toContain('Output (--json or piped):');
|
|
60
|
-
expect(result).not.toContain('Errors (exit code 1):');
|
|
61
|
-
expect(result).toContain('Global options:');
|
|
62
|
-
expect(result).toContain('Examples:');
|
|
63
|
-
expect(result).toContain(' $ resend emails send');
|
|
64
|
-
expect(result).toContain(' $ resend emails receiving list');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('no context — string starts with newline then Global options header directly', () => {
|
|
68
|
-
const result = buildHelpText({
|
|
69
|
-
output: ' {"id":"dm_abc"}',
|
|
70
|
-
errorCodes: ['auth_error'],
|
|
71
|
-
examples: ['resend domains list'],
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
expect(result.startsWith('\nGlobal options:')).toBe(true);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('multi-line output — verbatim after the Output header', () => {
|
|
78
|
-
const multiLineOutput =
|
|
79
|
-
' {"id":"em_123"}\n // or with all fields:\n {"id":"em_456","to":["a@b.com"]}';
|
|
80
|
-
const result = buildHelpText({
|
|
81
|
-
output: multiLineOutput,
|
|
82
|
-
errorCodes: ['auth_error'],
|
|
83
|
-
examples: ['resend emails send --to a@b.com --subject Hi --text Hi'],
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
expect(result).toContain(`Output (--json or piped):\n${multiLineOutput}`);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('error codes join — uses " | " separator', () => {
|
|
90
|
-
const result = buildHelpText({
|
|
91
|
-
errorCodes: ['auth_error', 'list_error', 'fetch_error'],
|
|
92
|
-
examples: ['resend domains list'],
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
expect(result).toContain('Codes: auth_error | list_error | fetch_error');
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, spyOn, test } from 'bun:test';
|
|
2
|
-
import { outputError, outputResult } from '../../src/lib/output';
|
|
3
|
-
|
|
4
|
-
describe('outputResult', () => {
|
|
5
|
-
let logSpy: ReturnType<typeof spyOn>;
|
|
6
|
-
const originalIsTTY = process.stdout.isTTY;
|
|
7
|
-
|
|
8
|
-
afterEach(() => {
|
|
9
|
-
logSpy?.mockRestore();
|
|
10
|
-
Object.defineProperty(process.stdout, 'isTTY', {
|
|
11
|
-
value: originalIsTTY,
|
|
12
|
-
writable: true,
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('outputs JSON when json option is true', () => {
|
|
17
|
-
logSpy = spyOn(console, 'log').mockImplementation(() => {});
|
|
18
|
-
outputResult({ id: '123' }, { json: true });
|
|
19
|
-
expect(logSpy).toHaveBeenCalledWith(JSON.stringify({ id: '123' }, null, 2));
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('outputs JSON when stdout is not TTY', () => {
|
|
23
|
-
Object.defineProperty(process.stdout, 'isTTY', {
|
|
24
|
-
value: undefined,
|
|
25
|
-
writable: true,
|
|
26
|
-
});
|
|
27
|
-
logSpy = spyOn(console, 'log').mockImplementation(() => {});
|
|
28
|
-
outputResult({ id: '123' });
|
|
29
|
-
expect(logSpy).toHaveBeenCalledWith(JSON.stringify({ id: '123' }, null, 2));
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('outputs string directly for human-readable mode', () => {
|
|
33
|
-
Object.defineProperty(process.stdout, 'isTTY', {
|
|
34
|
-
value: true,
|
|
35
|
-
writable: true,
|
|
36
|
-
});
|
|
37
|
-
logSpy = spyOn(console, 'log').mockImplementation(() => {});
|
|
38
|
-
outputResult('Email sent successfully');
|
|
39
|
-
expect(logSpy).toHaveBeenCalledWith('Email sent successfully');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('outputs JSON for objects in human mode (fallback)', () => {
|
|
43
|
-
Object.defineProperty(process.stdout, 'isTTY', {
|
|
44
|
-
value: true,
|
|
45
|
-
writable: true,
|
|
46
|
-
});
|
|
47
|
-
logSpy = spyOn(console, 'log').mockImplementation(() => {});
|
|
48
|
-
outputResult({ id: '123' });
|
|
49
|
-
expect(logSpy).toHaveBeenCalledWith(JSON.stringify({ id: '123' }, null, 2));
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe('outputError', () => {
|
|
54
|
-
let errorSpy: ReturnType<typeof spyOn>;
|
|
55
|
-
let exitSpy: ReturnType<typeof spyOn>;
|
|
56
|
-
const originalIsTTY = process.stdout.isTTY;
|
|
57
|
-
|
|
58
|
-
afterEach(() => {
|
|
59
|
-
errorSpy?.mockRestore();
|
|
60
|
-
exitSpy?.mockRestore();
|
|
61
|
-
Object.defineProperty(process.stdout, 'isTTY', {
|
|
62
|
-
value: originalIsTTY,
|
|
63
|
-
writable: true,
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test('outputs JSON error when json is true', () => {
|
|
68
|
-
errorSpy = spyOn(console, 'error').mockImplementation(() => {});
|
|
69
|
-
exitSpy = spyOn(process, 'exit').mockImplementation(
|
|
70
|
-
() => undefined as never,
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
outputError({ message: 'not found', code: 'not_found' }, { json: true });
|
|
74
|
-
|
|
75
|
-
const expected = JSON.stringify(
|
|
76
|
-
{ error: { message: 'not found', code: 'not_found' } },
|
|
77
|
-
null,
|
|
78
|
-
2,
|
|
79
|
-
);
|
|
80
|
-
expect(errorSpy).toHaveBeenCalledWith(expected);
|
|
81
|
-
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('outputs text error when TTY and no json flag', () => {
|
|
85
|
-
Object.defineProperty(process.stdout, 'isTTY', {
|
|
86
|
-
value: true,
|
|
87
|
-
writable: true,
|
|
88
|
-
});
|
|
89
|
-
errorSpy = spyOn(console, 'error').mockImplementation(() => {});
|
|
90
|
-
exitSpy = spyOn(process, 'exit').mockImplementation(
|
|
91
|
-
() => undefined as never,
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
outputError({ message: 'something broke' });
|
|
95
|
-
|
|
96
|
-
expect(errorSpy).toHaveBeenCalledWith('Error: something broke');
|
|
97
|
-
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test('uses custom exit code', () => {
|
|
101
|
-
errorSpy = spyOn(console, 'error').mockImplementation(() => {});
|
|
102
|
-
exitSpy = spyOn(process, 'exit').mockImplementation(
|
|
103
|
-
() => undefined as never,
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
outputError({ message: 'error' }, { exitCode: 2, json: true });
|
|
107
|
-
|
|
108
|
-
expect(exitSpy).toHaveBeenCalledWith(2);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
test('defaults error code to "unknown" when not provided', () => {
|
|
112
|
-
Object.defineProperty(process.stdout, 'isTTY', {
|
|
113
|
-
value: undefined,
|
|
114
|
-
writable: true,
|
|
115
|
-
});
|
|
116
|
-
errorSpy = spyOn(console, 'error').mockImplementation(() => {});
|
|
117
|
-
exitSpy = spyOn(process, 'exit').mockImplementation(
|
|
118
|
-
() => undefined as never,
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
outputError({ message: 'oops' });
|
|
122
|
-
|
|
123
|
-
const output = errorSpy.mock.calls[0][0] as string;
|
|
124
|
-
const parsed = JSON.parse(output);
|
|
125
|
-
expect(parsed.error.code).toBe('unknown');
|
|
126
|
-
});
|
|
127
|
-
});
|