@billionsend/cli 0.5.0 → 0.5.1
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 +28 -27
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @billionsend/cli
|
|
2
2
|
|
|
3
|
-
Moves an email account to [BillionSend](https://billionsend.com): contacts, segments, topics, properties, templates, webhooks, domains and suppressions. Reads from the source provider, writes to your BillionSend account, and is safe to run again — a second run right before cutover syncs what changed since the first.
|
|
3
|
+
Moves an email account to [BillionSend](https://billionsend.com): contacts, segments, topics, properties, templates, webhooks, domains and suppressions. Reads from the source provider, writes to your BillionSend account, and is safe to run again — a second run right before cutover syncs what changed since the first. It also sends broadcasts and emails from your terminal with a BillionSend API key (see [Sending](#sending)). The documentation page is <https://billionsend.com/docs/cli>.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
npx @billionsend/cli migrate --from resend # interactive: connect, choose, plan, confirm, apply, summary
|
|
@@ -8,28 +8,29 @@ npx @billionsend/cli migrate plan --from resend --out plan.json # read-only; e
|
|
|
8
8
|
npx @billionsend/cli migrate apply plan.json --yes
|
|
9
9
|
npx @billionsend/cli migrate status
|
|
10
10
|
npx @billionsend/cli migrate rollback # deletes only what the tool created
|
|
11
|
+
npx @billionsend/cli broadcasts send --help # sending: broadcasts, emails, segments, contact imports
|
|
11
12
|
```
|
|
12
13
|
|
|
13
|
-
Node 18 or newer; no dependencies.
|
|
14
|
+
Node 18 or newer; no dependencies. Install once with `npm install -g @billionsend/cli`, then run `billionsend`.
|
|
14
15
|
|
|
15
16
|
## What moves
|
|
16
17
|
|
|
17
|
-
| Resource | How
|
|
18
|
-
| ---------------------------- |
|
|
19
|
-
| Contacts | Upserted by email through the batch endpoint; `unsubscribed` and topic opt-outs are preserved, never re-subscribed. Resend's `unsubscribed` is global, so it lands as BillionSend's team-wide `unsubscribed: true`; no per-domain unsubscribe is created. Topic subscriptions and properties follow in two per-contact passes that run after everything else, so the account is sendable before they finish. The batch endpoint answers created, updated or skipped but never whether a matched contact changed, so the summary reports those as `matched existing`, not as updated or unchanged.
|
|
20
|
-
| Segments, topics, properties | Matched by name / name / key: created when missing, updated when different, left alone when equal. Segment memberships follow the contacts. BillionSend property keys ignore case, Resend's do not: when Resend has both `plan` and `PLAN`, only the first is created, the other is listed as a manual note, and the report counts the contacts whose value for it was not written. A key that differs only in case from one already on BillionSend is the same property, and values are written under the spelling it has.
|
|
21
|
-
| Templates | Name, alias, subject, html, text, default from, reply-to and variables (up to 50 reply-to addresses and 50 variables; what does not fit is listed as a manual note).
|
|
22
|
-
| Webhooks | Endpoint and events. Signing secrets are copied so receivers keep verifying (`--fresh-webhook-secrets` mints new ones, shown once). Events BillionSend also emits carry over (`email.*`, `contact.created`, `contact.updated`, `contact.deleted`, `contact.topics.updated`, `suppression.added`, `suppression.removed`, `domain.created`, `domain.updated`, `domain.deleted`, `topic.created`, `topic.updated`, `topic.deleted` and `inbox.*`); the rest are dropped per webhook and listed.
|
|
23
|
-
| Suppressions | Bounces, complaints and manual entries, with their origin.
|
|
24
|
-
| Domains | Created with return path and tracking settings, in
|
|
25
|
-
| Broadcasts | Drafts and scheduled ones import as drafts; sent ones are skipped unless `--include-sent`.
|
|
26
|
-
| API keys | Not recreated (the source only exposes names); the report lists them as a to-do.
|
|
18
|
+
| Resource | How |
|
|
19
|
+
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
20
|
+
| Contacts | Upserted by email through the batch endpoint; `unsubscribed` and topic opt-outs are preserved, never re-subscribed. Resend's `unsubscribed` is global, so it lands as BillionSend's team-wide `unsubscribed: true`; no per-domain unsubscribe is created. Topic subscriptions and properties follow in two per-contact passes that run after everything else, so the account is sendable before they finish. The batch endpoint answers created, updated or skipped but never whether a matched contact changed, so the summary reports those as `matched existing`, not as updated or unchanged. |
|
|
21
|
+
| Segments, topics, properties | Matched by name / name / key: created when missing, updated when different, left alone when equal. Segment memberships follow the contacts. BillionSend property keys ignore case, Resend's do not: when Resend has both `plan` and `PLAN`, only the first is created, the other is listed as a manual note, and the report counts the contacts whose value for it was not written. A key that differs only in case from one already on BillionSend is the same property, and values are written under the spelling it has. |
|
|
22
|
+
| Templates | Name, alias, subject, html, text, default from, reply-to and variables (up to 50 reply-to addresses and 50 variables; what does not fit is listed as a manual note). |
|
|
23
|
+
| Webhooks | Endpoint and events. Signing secrets are copied so receivers keep verifying (`--fresh-webhook-secrets` mints new ones, shown once). Events BillionSend also emits carry over (`email.*`, `contact.created`, `contact.updated`, `contact.deleted`, `contact.topics.updated`, `suppression.added`, `suppression.removed`, `domain.created`, `domain.updated`, `domain.deleted`, `topic.created`, `topic.updated`, `topic.deleted` and `inbox.*`); the rest are dropped per webhook and listed. |
|
|
24
|
+
| Suppressions | Bounces, complaints and manual entries, with their origin. |
|
|
25
|
+
| Domains | Created with return path and tracking settings, in your team's default sending region (the CLI sends no region, and the Resend region does not carry over). The return path is always set explicitly and is never the label the domain has on Resend (`send` unless Resend names another): BillionSend gets `bounce`, or `bounces` when Resend's is already `bounce`, so the bounce MX record on Resend's side is not touched and both providers run in parallel until cutover; the plan and the report state both labels. BillionSend fixes the label at creation (changing it later means deleting the domain and creating it again). A domain that already exists on BillionSend is left as it is. DNS records must be added again (DKIM keys are per provider); the report prints a copy-ready table. Both providers can stay verified side by side. Resend has no unsubscribe subdomain or page, so those are left unset. |
|
|
26
|
+
| Broadcasts | Drafts and scheduled ones import as drafts; sent ones are skipped unless `--include-sent`. |
|
|
27
|
+
| API keys | Not recreated (the source only exposes names); the report lists them as a to-do. |
|
|
27
28
|
|
|
28
29
|
Audiences (deprecated in Resend) are skipped — segments cover them.
|
|
29
30
|
|
|
30
31
|
## Sending
|
|
31
32
|
|
|
32
|
-
The same `BILLIONSEND_API_KEY` sends from the command line. A broadcast goes to a segment, and to a topic's subscribers only when `--topic` is given; segments and topics are named by name or id.
|
|
33
|
+
The same `BILLIONSEND_API_KEY` sends from the command line, with no source account (the key can come from `--key-stdin` instead, and the API URL from `--to-url` or `BILLIONSEND_BASE_URL`; default `https://api.billionsend.com`). A broadcast goes to a segment, and to a topic's subscribers only when `--topic` is given; segments and topics are named by name or id.
|
|
33
34
|
|
|
34
35
|
```bash
|
|
35
36
|
export BILLIONSEND_API_KEY=bs_...
|
|
@@ -52,17 +53,18 @@ billionsend contacts import --file buyers.csv --segment "Black Friday last call"
|
|
|
52
53
|
billionsend emails send --from "Leo <leo@mail.example.com>" --to you@example.com --subject "Hi" --text-file hi.txt --yes
|
|
53
54
|
```
|
|
54
55
|
|
|
55
|
-
`--test` puts the test addresses in a segment named "CLI test recipients" that holds exactly them (contacts that do not exist yet are created; an existing contact's name, topics and unsubscribe state are left as they are) and sends the broadcast there with `[TEST]` before the subject, so a test goes through the real broadcast path: merge tags such as `{{{FIRST_NAME|there}}}` are filled per recipient and the unsubscribe link is the recipient's own. Without a terminal, sending needs `--yes`. `--wait` follows the broadcast until it is sent, failed or canceled, for 30 minutes unless `--wait-timeout <minutes>` says otherwise; a small broadcast reads as sent within about five minutes of its last email, and a first send to contacts the team never mailed is released in steps over about an hour, so give that one `--wait-timeout 90` or more. `contacts import` uploads a CSV (a header row with an email column, at most 20 MiB), follows the import to its end and prints the counts; contacts who unsubscribed stay unsubscribed, and it exits 3 when some rows failed. Contacts the team already has are updated from the file and join `--segment` (a column the file lacks keeps its value); `--on-conflict skip` leaves them out entirely, segment included. By default a contact who got 8 or more of your broadcasts and automation emails with no open or click for 120 days gets a short "still want these?" email instead of the broadcast (only where the sending domain tracks opens or clicks); `--no-dormant-check` sends the content to everyone, and `--include-dormant` also reaches contacts who never answered that email. `broadcasts list` shows each broadcast's id, time, status and name, newest first. `broadcasts recipients` lists who was sent, delivered, opened, clicked, bounced, complained, unsubscribed or suppressed, as CSV or JSON, one page of 100 or every page with `--all`. `billionsend broadcasts --help` lists every option.
|
|
56
|
+
`--test` puts the test addresses in a segment named "CLI test recipients" that holds exactly them (contacts that do not exist yet are created; an existing contact's name, topics and unsubscribe state are left as they are) and sends the broadcast there with `[TEST]` before the subject, so a test goes through the real broadcast path: merge tags such as `{{{FIRST_NAME|there}}}` are filled per recipient and the unsubscribe link is the recipient's own. Without a terminal, sending needs `--yes`. `--wait` follows the broadcast until it is sent, failed or canceled, for 30 minutes unless `--wait-timeout <minutes>` says otherwise; a small broadcast reads as sent within about five minutes of its last email, and a first send to contacts the team never mailed is released in steps over about an hour, so give that one `--wait-timeout 90` or more. `contacts import` uploads a CSV (a header row with an email column, at most 20 MiB), follows the import to its end and prints the counts; contacts who unsubscribed stay unsubscribed, and it exits 3 when some rows failed. Contacts the team already has are updated from the file and join `--segment` (a column the file lacks keeps its value); `--on-conflict skip` leaves them out entirely, segment included. By default a contact who got 8 or more of your broadcasts and automation emails with no open or click for 120 days gets a short "still want these?" email instead of the broadcast (only where the sending domain tracks opens or clicks); `--no-dormant-check` sends the content to everyone, and `--include-dormant` also reaches contacts who never answered that email. `broadcasts list` shows each broadcast's id, time, status and name, newest first. `broadcasts recipients` lists who was sent, delivered, opened, clicked, bounced, complained, unsubscribed or suppressed, as CSV or JSON, one page of 100 or every page with `--all`. `emails send` sends one email (`--to` repeatable, `--html-file` or `--text-file`) and asks first unless `--yes`; with `--idempotency-key <key>` a retry sends once. `broadcasts send` also takes `--name`, `--preview-text` and `--reply-to`. `--json` writes JSON on stdout. Exit codes for these commands: 0 done, 1 refused or failed (a broadcast that failed or was still running when `--wait` gave up included), 3 `contacts import` finished with some rows failed. `billionsend broadcasts --help` lists every option.
|
|
56
57
|
|
|
57
58
|
## Environment
|
|
58
59
|
|
|
59
|
-
| Variable | Meaning
|
|
60
|
-
| ---------------------- |
|
|
61
|
-
| `RESEND_API_KEY` | Source key (full access; the tool only ever reads). Alternatives: `--from-key-stdin`, or a masked prompt in a terminal.
|
|
62
|
-
| `BILLIONSEND_API_KEY` | BillionSend key (full access). Alternatives: `--to-key-stdin`, or a masked prompt
|
|
63
|
-
| `BILLIONSEND_BASE_URL` | BillionSend API URL. Same as `--to-url`. Unset, the target is `https://api.billionsend.com`, like the SDKs.
|
|
64
|
-
| `NO_COLOR` | Disables ANSI colors.
|
|
65
|
-
| `
|
|
60
|
+
| Variable | Meaning |
|
|
61
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
62
|
+
| `RESEND_API_KEY` | Source key (full access; the tool only ever reads). Alternatives: `--from-key-stdin`, or a masked prompt in a terminal. |
|
|
63
|
+
| `BILLIONSEND_API_KEY` | BillionSend key (full access). Alternatives: `--to-key-stdin`, or a masked prompt; the send commands take `--key-stdin`. |
|
|
64
|
+
| `BILLIONSEND_BASE_URL` | BillionSend API URL. Same as `--to-url`. Unset, the target is `https://api.billionsend.com`, like the SDKs. |
|
|
65
|
+
| `NO_COLOR` | Disables ANSI colors. |
|
|
66
|
+
| `FORCE_COLOR` | Colors even when piped, same as `--color always`. |
|
|
67
|
+
| `DO_NOT_TRACK` | Honored as a no-op: the tool sends no telemetry, never phones home and never checks for updates. |
|
|
66
68
|
|
|
67
69
|
## Flags
|
|
68
70
|
|
|
@@ -75,7 +77,7 @@ billionsend emails send --from "Leo <leo@mail.example.com>" --to you@example.com
|
|
|
75
77
|
- `--include-sent`, `--fresh-webhook-secrets`, `--fresh` (ignore the state file).
|
|
76
78
|
- `--yes`, `--non-interactive` (automatic when stdin is not a terminal), `--json` (JSON on stdout, progress on stderr), `--verbose`, `--color auto|always|never` (`--no-color` = `never`).
|
|
77
79
|
|
|
78
|
-
`migrate plan --out plan.json` records the options that decide the plan's content (`--only`, `--skip`, `--segment`, `--on-conflict`, `--include-sent`, `--fresh-webhook-secrets`). `migrate apply plan.json` follows them: leave those flags out, or give the same values; a flag that disagrees with the file stops the run with an error. If the plan built from the file's options still differs from the file, the source or your BillionSend account changed since it was made, and the message names the items that differ. `--report <file>` writes the Markdown report there; with `migrate plan` it writes the plan as a Markdown report.
|
|
80
|
+
`migrate plan --out plan.json` records the options that decide the plan's content (`--only`, `--skip`, `--segment`, `--on-conflict`, `--include-sent`, `--fresh-webhook-secrets`). `migrate apply plan.json` follows them: leave those flags out, or give the same values; a flag that disagrees with the file stops the run with an error. If the plan built from the file's options still differs from the file, the source or your BillionSend account changed since it was made, and the message names the items that differ. `--report <file>` writes the Markdown report there; with `migrate plan` it writes the plan as a Markdown report. Before any write the plan reads your BillionSend plan's limits (`GET /usage`) and says what does not fit, for example that more domains are to be created than the plan allows, and estimates the time. It also looks up the source's contacts on BillionSend by address (one request per 1,000) and lists the ones that are new apart from the ones already there. Whatever the run does, an opt-in is never written over an opt-out the contact made on BillionSend.
|
|
79
81
|
|
|
80
82
|
Exit codes: 0 ok · 1 error · 2 plan has changes (`plan` only) · 3 partial, some items failed (details in the report).
|
|
81
83
|
|
|
@@ -102,7 +104,7 @@ pnpm install
|
|
|
102
104
|
pnpm typecheck && pnpm lint && pnpm build && pnpm test
|
|
103
105
|
```
|
|
104
106
|
|
|
105
|
-
The tests never reach a real account. The source side is a fake account (`test/helpers/fake-resend.ts`); the BillionSend side is a contract API (`test/helpers/contract-api.ts`): an in-memory API that checks every request the CLI sends and every answer it gives against the published OpenAPI document, kept in `openapi/api.openapi.json`. A request to an undocumented path or with an undocumented parameter, a body off its schema, or an answer the document does not describe fails the test that caused it.
|
|
107
|
+
The tests never reach a real account. The source side is a fake account (`test/helpers/fake-resend.ts`); the BillionSend side is a contract API (`test/helpers/contract-api.ts`): an in-memory API that checks every request the CLI sends and every answer it gives against the published OpenAPI document, kept in `openapi/api.openapi.json`. The snapshot holds every operation of the API; the CLI calls only the ones for the resources it moves and for sending, so a new operation in the API changes nothing here until the CLI uses it. A request to an undocumented path or with an undocumented parameter, a body off its schema, or an answer the document does not describe fails the test that caused it.
|
|
106
108
|
|
|
107
109
|
`pnpm openapi:sync` refreshes the snapshot from https://billionsend.com/docs/api.openapi.json (`-- --from <file|url>` takes another source, `-- --check` only compares); run the tests after it, and what fails is what the CLI has to follow. CI compares the snapshot with the published document on every push and pull request and every day.
|
|
108
110
|
|
|
@@ -110,10 +112,9 @@ The tests never reach a real account. The source side is a fake account (`test/h
|
|
|
110
112
|
|
|
111
113
|
Publishing is manual; nothing is published on push.
|
|
112
114
|
|
|
113
|
-
1. Set `version` in `package.json`, commit, then tag and push: `git tag
|
|
114
|
-
2.
|
|
115
|
-
3.
|
|
116
|
-
4. Every later version: Actions → `release` → Run workflow, on the version tag. The workflow refuses a branch or a tag that differs from `package.json`, runs every check, and publishes with npm Trusted Publishing (no token stored).
|
|
115
|
+
1. Set `version` in `package.json`, commit, then tag and push: `git tag v<version> && git push origin main v<version>`.
|
|
116
|
+
2. Once: on npmjs.com, `@billionsend/cli` → Settings → Trusted Publisher → GitHub Actions, repository `billionsend/billionsend-cli`, workflow `release.yml`.
|
|
117
|
+
3. Each version: Actions → `release` → Run workflow, on the version tag. The workflow refuses a branch or a tag that differs from `package.json`, runs every check, and publishes with npm Trusted Publishing (no token stored).
|
|
117
118
|
|
|
118
119
|
## License
|
|
119
120
|
|
package/dist/index.js
CHANGED
|
@@ -2123,7 +2123,7 @@ function describePlanDiff(saved, current) {
|
|
|
2123
2123
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
2124
2124
|
|
|
2125
2125
|
// src/meta.ts
|
|
2126
|
-
var VERSION = true ? "0.5.
|
|
2126
|
+
var VERSION = true ? "0.5.1" : "0.0.0-dev";
|
|
2127
2127
|
var REPO_URL = "https://github.com/billionsend/billionsend-cli";
|
|
2128
2128
|
var USER_AGENT = `billionsend-cli/${VERSION} (+${REPO_URL})`;
|
|
2129
2129
|
var CLOUD_API_URL = "https://api.billionsend.com";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@billionsend/cli",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "Migrate an email account to BillionSend
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "Migrate an email account to BillionSend (contacts, segments, topics, properties, templates, webhooks, domains and suppressions; re-run safe) and send broadcasts and emails from your terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|