@leeguoo/wrangler-accounts 1.6.4 → 1.6.5
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +2 -4
- package/bin/wrangler-accounts.js +17 -68
- package/package.json +1 -1
- package/plugins/wrangler-accounts/.claude-plugin/plugin.json +1 -1
- package/plugins/wrangler-accounts/skills/wrangler-accounts/SKILL.md +4 -3
- package/skills/wrangler-accounts/SKILL.md +515 -0
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
},
|
|
6
6
|
"metadata": {
|
|
7
7
|
"description": "Claude Code plugins for practical developer workflows from the wrangler-accounts author.",
|
|
8
|
-
"version": "1.5
|
|
8
|
+
"version": "1.6.5"
|
|
9
9
|
},
|
|
10
10
|
"plugins": [
|
|
11
11
|
{
|
|
12
12
|
"name": "wrangler-accounts",
|
|
13
13
|
"source": "./plugins/wrangler-accounts",
|
|
14
14
|
"description": "Cloudflare Wrangler multi-account skill plus a Bash hook that blocks raw wrangler calls when local profiles are configured.",
|
|
15
|
-
"version": "1.5
|
|
15
|
+
"version": "1.6.5",
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "Lee Guo"
|
|
18
18
|
},
|
package/README.md
CHANGED
|
@@ -204,8 +204,6 @@ CLOUDFLARE_API_TOKEN=xxx CLOUDFLARE_ACCOUNT_ID=yyy wrangler-accounts deploy
|
|
|
204
204
|
--plain Plain output for list (one name per line)
|
|
205
205
|
--include-backups Include backup profiles in list/status
|
|
206
206
|
-f, --force Overwrite existing profile on save
|
|
207
|
-
--backup Backup current config on use (default)
|
|
208
|
-
--no-backup Disable backup on use
|
|
209
207
|
--unset With 'default': clear the persistent default
|
|
210
208
|
--deep, --verify With 'list': run wrangler whoami per profile for live verification
|
|
211
209
|
--older-than <dur> With 'gc': age threshold (e.g. 1h, 30m, 7d)
|
|
@@ -250,7 +248,7 @@ Inside an isolated session, these are automatically set for the child process:
|
|
|
250
248
|
## Breaking changes in 1.0
|
|
251
249
|
|
|
252
250
|
- **`-p` is now `--profile`** (was `--profiles` in 0.1.x). Use the long form `--profiles <path>` to specify the profiles directory.
|
|
253
|
-
- **`use` is
|
|
251
|
+
- **`use` is no longer supported**. The command now exits with migration guidance. Use `default <name>` for persistence or `--profile <name>` for one-shot execution.
|
|
254
252
|
- **`sync-active` is deprecated**, replaced by `sync-default`. The alias still works with a warning.
|
|
255
253
|
- Profile names matching management subcommand names (`exec`, `default`, `whoami`, `gc`, `login`, `list`, `status`, `save`, `sync`, `sync-default`, `remove`, `use`, `sync-active`) cannot be reached via positional shorthand. Use `--profile <name>` instead.
|
|
256
254
|
- First-time setup of a new profile via `wrangler-accounts login <name>` no longer touches your real `~/.wrangler/config/default.toml`. All credential writes go directly into the profile directory.
|
|
@@ -273,7 +271,7 @@ The profiles directory defaults to:
|
|
|
273
271
|
|
|
274
272
|
- Profile names accept only letters, numbers, dot, underscore, and dash.
|
|
275
273
|
- Saved OAuth sessions can expire. If a profile is expired, running it will stop and tell you to run `wrangler-accounts login <name>` again.
|
|
276
|
-
-
|
|
274
|
+
- Legacy backups created by older `use` flows are hidden from `list` and `status` unless you pass `--include-backups`.
|
|
277
275
|
|
|
278
276
|
## FAQ
|
|
279
277
|
|
package/bin/wrangler-accounts.js
CHANGED
|
@@ -26,13 +26,11 @@ const {
|
|
|
26
26
|
filesEqual,
|
|
27
27
|
writeMeta,
|
|
28
28
|
readMeta,
|
|
29
|
-
setActiveProfile,
|
|
30
29
|
getActiveProfile,
|
|
31
30
|
getDefaultProfile,
|
|
32
31
|
setDefaultProfile,
|
|
33
32
|
unsetDefaultProfile,
|
|
34
33
|
timestampForFile,
|
|
35
|
-
backupCurrentConfig,
|
|
36
34
|
findMatchingProfile,
|
|
37
35
|
saveProfile: saveProfileImpl,
|
|
38
36
|
saveTokenProfile: saveTokenProfileImpl,
|
|
@@ -316,9 +314,15 @@ Commands:
|
|
|
316
314
|
token-add <name> <api-token> <account-id>
|
|
317
315
|
sync <name>
|
|
318
316
|
sync-active
|
|
319
|
-
|
|
317
|
+
sync-default
|
|
318
|
+
default [name | --unset]
|
|
319
|
+
whoami [--profile <name>]
|
|
320
|
+
exec <name> [-- <cmd> [args]]
|
|
320
321
|
remove <name>
|
|
321
322
|
|
|
323
|
+
Deprecated:
|
|
324
|
+
use <name> Prints migration guidance; use 'default' or '--profile' instead
|
|
325
|
+
|
|
322
326
|
Options:
|
|
323
327
|
-c, --config <path> Wrangler config path
|
|
324
328
|
-p, --profiles <path> Profiles directory
|
|
@@ -326,8 +330,6 @@ Options:
|
|
|
326
330
|
--plain Plain output for list (one name per line)
|
|
327
331
|
--include-backups Include backup profiles in list/status
|
|
328
332
|
-f, --force Overwrite existing profile on save
|
|
329
|
-
--backup Backup current config on use (default)
|
|
330
|
-
--no-backup Disable backup on use
|
|
331
333
|
-h, --help Show help
|
|
332
334
|
-v, --version Print version
|
|
333
335
|
|
|
@@ -338,8 +340,8 @@ Env:
|
|
|
338
340
|
|
|
339
341
|
Examples:
|
|
340
342
|
wrangler-accounts save work
|
|
341
|
-
wrangler-accounts
|
|
342
|
-
wrangler-accounts
|
|
343
|
+
wrangler-accounts default work
|
|
344
|
+
wrangler-accounts --profile work deploy
|
|
343
345
|
`;
|
|
344
346
|
console.log(text);
|
|
345
347
|
process.exit(exitCode);
|
|
@@ -349,7 +351,6 @@ function parseArgs(argv) {
|
|
|
349
351
|
const opts = {
|
|
350
352
|
json: false,
|
|
351
353
|
force: false,
|
|
352
|
-
backup: true,
|
|
353
354
|
includeBackups: false,
|
|
354
355
|
};
|
|
355
356
|
const rest = [];
|
|
@@ -400,10 +401,6 @@ function parseArgs(argv) {
|
|
|
400
401
|
opts.includeBackups = true;
|
|
401
402
|
} else if (arg === "--force" || arg === "-f") {
|
|
402
403
|
opts.force = true;
|
|
403
|
-
} else if (arg === "--backup") {
|
|
404
|
-
opts.backup = true;
|
|
405
|
-
} else if (arg === "--no-backup") {
|
|
406
|
-
opts.backup = false;
|
|
407
404
|
} else if (arg === "--unset") {
|
|
408
405
|
opts.unset = true;
|
|
409
406
|
} else if (arg === "--deep" || arg === "--verify") {
|
|
@@ -451,36 +448,6 @@ function runWranglerLogin() {
|
|
|
451
448
|
}
|
|
452
449
|
}
|
|
453
450
|
|
|
454
|
-
function useProfile(name, configPath, profilesDir, backup) {
|
|
455
|
-
if (!isValidName(name)) {
|
|
456
|
-
die(`Invalid profile name: ${name}`);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
const profileDir = path.join(profilesDir, name);
|
|
460
|
-
const profileConfig = path.join(profileDir, "config.toml");
|
|
461
|
-
if (!fs.existsSync(profileConfig)) {
|
|
462
|
-
die(`Profile not found: ${name}`);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
const session = readSessionState(profileConfig);
|
|
466
|
-
if (session.effective === 'expired') {
|
|
467
|
-
die(
|
|
468
|
-
`Profile '${name}' has expired Wrangler OAuth credentials and no refresh_token to renew them (expiration_time: ${session.expirationTime}). Run 'wrangler-accounts login ${name}' to re-authenticate.`
|
|
469
|
-
);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
let backupName = null;
|
|
473
|
-
if (backup && fs.existsSync(configPath) && !filesEqual(configPath, profileConfig)) {
|
|
474
|
-
backupName = backupCurrentConfig(configPath, profilesDir);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
ensureDir(path.dirname(configPath));
|
|
478
|
-
fs.copyFileSync(profileConfig, configPath);
|
|
479
|
-
setActiveProfile(profilesDir, name);
|
|
480
|
-
|
|
481
|
-
return backupName;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
451
|
function syncProfile(name, configPath, profilesDir, identity) {
|
|
485
452
|
if (!isValidName(name)) {
|
|
486
453
|
die(`Invalid profile name: ${name}`);
|
|
@@ -1147,33 +1114,15 @@ function main() {
|
|
|
1147
1114
|
}
|
|
1148
1115
|
|
|
1149
1116
|
if (command === "use") {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1117
|
+
die(
|
|
1118
|
+
[
|
|
1119
|
+
"The 'use' command is no longer supported because it was ambiguous and rewrote Wrangler's global config.",
|
|
1120
|
+
"Use 'wrangler-accounts default <name>' for a persistent default profile.",
|
|
1121
|
+
"Use 'wrangler-accounts --profile <name> <wrangler-args...>' for a one-shot command.",
|
|
1122
|
+
"Use 'wrangler-accounts exec <name>' for an interactive subshell.",
|
|
1123
|
+
].join("\n"),
|
|
1124
|
+
2,
|
|
1153
1125
|
);
|
|
1154
|
-
const name = rest[1];
|
|
1155
|
-
if (!name) die("Missing profile name for use");
|
|
1156
|
-
ensureDir(profilesDir);
|
|
1157
|
-
const backupName = useProfile(name, configPath, profilesDir, opts.backup);
|
|
1158
|
-
const backupNote = backupName ? ` (backup: ${backupName})` : "";
|
|
1159
|
-
if (opts.json) {
|
|
1160
|
-
console.log(
|
|
1161
|
-
JSON.stringify(
|
|
1162
|
-
{
|
|
1163
|
-
command: "use",
|
|
1164
|
-
name,
|
|
1165
|
-
configPath,
|
|
1166
|
-
profilesDir,
|
|
1167
|
-
backupName,
|
|
1168
|
-
},
|
|
1169
|
-
null,
|
|
1170
|
-
2
|
|
1171
|
-
)
|
|
1172
|
-
);
|
|
1173
|
-
} else {
|
|
1174
|
-
console.log(`Switched to profile '${name}'${backupNote}`);
|
|
1175
|
-
}
|
|
1176
|
-
return;
|
|
1177
1126
|
}
|
|
1178
1127
|
|
|
1179
1128
|
if (command === "remove") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leeguoo/wrangler-accounts",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "Cloudflare Wrangler multi-account manager — save, switch, and run wrangler against multiple Cloudflare Workers accounts with AWS-style --profile and per-invocation shadow HOME isolation.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -380,12 +380,13 @@ cd "$WRANGLER_ACCOUNT_REAL_HOME"
|
|
|
380
380
|
|
|
381
381
|
Or users can add a shell alias: `alias realhome='cd "$WRANGLER_ACCOUNT_REAL_HOME"'`.
|
|
382
382
|
|
|
383
|
-
###
|
|
383
|
+
### Unsupported `use` command migration
|
|
384
384
|
|
|
385
|
-
`wrangler-accounts use <name>`
|
|
385
|
+
`wrangler-accounts use <name>` no longer switches profiles. It exits with migration guidance because the old behavior was ambiguous and rewrote Wrangler's global config. Suggest the replacement based on intent:
|
|
386
386
|
|
|
387
387
|
- "I want this account to stick for a while" → `wrangler-accounts default <name>`
|
|
388
388
|
- "Just this one command" → `wrangler-accounts --profile <name> <wrangler-args>`
|
|
389
|
+
- "I want an interactive shell on that account" → `wrangler-accounts exec <name>`
|
|
389
390
|
|
|
390
391
|
### `[ERROR] A request to the Cloudflare API ... Authentication error [code: 10000]` with `code: 7403` ("not authorized to access this service")
|
|
391
392
|
|
|
@@ -510,5 +511,5 @@ Profile names: letters, numbers, dot, underscore, dash only. Names matching mana
|
|
|
510
511
|
|
|
511
512
|
## Deprecated
|
|
512
513
|
|
|
513
|
-
- `wrangler-accounts use <name>` —
|
|
514
|
+
- `wrangler-accounts use <name>` — unsupported compatibility entry; exits with migration guidance. Use `default <name>` for persistence, `--profile <name>` for one-shot commands, or `exec <name>` for an interactive shell.
|
|
514
515
|
- `wrangler-accounts sync-active` — deprecated alias for `sync-default`.
|
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wrangler-accounts
|
|
3
|
+
description: AWS-style multi-account convenience for Cloudflare Wrangler. Use when you need to run wrangler commands against a specific Cloudflare account, manage saved OAuth profiles, set or switch the persistent default profile, or open an isolated subshell for a profile. Prefer --json for machine-readable output.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Wrangler Accounts
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
`wrangler-accounts` runs `wrangler` under per-invocation **shadow HOME** isolation, so multiple shells can use different Cloudflare accounts in parallel without any global switching. Profile resolution order: `--profile` / `-p` > positional shorthand > `$WRANGLER_PROFILE` > `profilesDir/default` > hard error.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
For Claude Code users, prefer the plugin marketplace install path because it ships this skill and the raw-`wrangler` guard hook together:
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
/plugin marketplace add leeguooooo/wrangler-accounts
|
|
18
|
+
/plugin install wrangler-accounts@leeguoo-tools
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The plugin does **not** replace the CLI binary. The actual `wrangler-accounts` executable still must be installed on `PATH`:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm i -g @leeguoo/wrangler-accounts
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Non-Claude-Code users can keep using the `skills.sh` distribution path for this same `SKILL.md` mirror:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx skills add leeguooooo/wrangler-accounts -g -y
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If a Claude Code user previously installed via `skills.sh`, removing the standalone copy avoids a duplicate `/wrangler-accounts` entry in the command picker:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx skills remove wrangler-accounts
|
|
37
|
+
# or: rm -rf ~/.agents/skills/wrangler-accounts
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Prerequisites (check before running any recipe below)
|
|
41
|
+
|
|
42
|
+
This skill is only documentation — the actual `wrangler-accounts` binary must also be installed on the user's `PATH`. Before running any command below, verify:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
command -v wrangler-accounts && wrangler-accounts --version
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If the command is missing, tell the user to install the CLI first:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm i -g @leeguoo/wrangler-accounts
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`wrangler` itself (the Cloudflare CLI) must also be on `PATH`. If missing:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm i -g wrangler
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Minimum versions you should ask the user to upgrade past
|
|
61
|
+
|
|
62
|
+
If `wrangler-accounts --version` is below any of these, **upgrade first** before debugging anything else — older versions have real bugs that will misdirect you:
|
|
63
|
+
|
|
64
|
+
| Version | What it fixed | Symptom on older versions |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| **≥ 1.2.2** | per-profile `WRANGLER_CACHE_DIR`, fixes account-id leak across profiles | `d1`/`r2 object` commands return `7403 not authorized` even though OAuth is valid; deploys silently land in the wrong account |
|
|
67
|
+
| **≥ 1.3.0** | STATUS column distinguishes `valid` / `valid*` / `EXPIRED` (refresh-token-aware) | `list` shows `EXPIRED` for healthy profiles, scaring you into running `login` for no reason |
|
|
68
|
+
| **≥ 1.4.0** | `login` refuses non-TTY contexts and accidental overwrites | `login <name>` hangs forever in non-interactive contexts; reflexive `login` overwrites a healthy profile |
|
|
69
|
+
| **≥ 1.6.0** | API token profiles (`token-add`) + anonymous env-var pass-through | only OAuth profiles existed; `CLOUDFLARE_API_TOKEN` in env still required a named profile to be selected |
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm i -g @leeguoo/wrangler-accounts@latest # always-safe upgrade
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Triage flow — when something looks wrong
|
|
76
|
+
|
|
77
|
+
**Run these in order before reaching for `login` or any destructive command.** The agent who skipped this step in a recent incident ended up overwriting a perfectly healthy profile in a sub-shell where the browser couldn't even open.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# 1. Verify your binary is recent enough (see version table above)
|
|
81
|
+
wrangler-accounts --version
|
|
82
|
+
|
|
83
|
+
# 2. Authoritative state of every profile (hits Cloudflare API per profile)
|
|
84
|
+
wrangler-accounts list --deep
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
How to read `list --deep` output:
|
|
88
|
+
|
|
89
|
+
| You see | Meaning | What to do |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| `STATUS valid` + `VERIFIED ✓ ok` | profile is fine | nothing — proceed with whatever the user actually asked |
|
|
92
|
+
| `STATUS valid*` + `VERIFIED ✓ ok` | profile is fine; access token will auto-refresh on next use | nothing — **`valid*` is healthy, do NOT re-login** |
|
|
93
|
+
| `STATUS EXPIRED` + `VERIFIED ✓ ok` | rare; only on `< 1.3.0` binaries — STATUS is lying | upgrade the CLI; profile is fine |
|
|
94
|
+
| `STATUS EXPIRED` + `VERIFIED ✗ Not logged in` | profile is genuinely broken | `wrangler-accounts login <name>` (interactive only) |
|
|
95
|
+
| `STATUS valid` + `VERIFIED ✗` of any kind | refresh token revoked server-side | `wrangler-accounts login <name>` (interactive only) |
|
|
96
|
+
| `STATUS unknown` | profile file lacks `expiration_time` | run `--deep` (already did) — trust VERIFIED |
|
|
97
|
+
|
|
98
|
+
**Rule**: only suggest `wrangler-accounts login <name>` when at least one of:
|
|
99
|
+
1. `list --deep` showed `VERIFIED ✗` for that profile, OR
|
|
100
|
+
2. The profile doesn't exist at all yet, OR
|
|
101
|
+
3. The user explicitly says "re-authenticate" / "log me in again"
|
|
102
|
+
|
|
103
|
+
**If `list --deep` shows everything ✓ but a wrangler command still fails**, the root cause is somewhere other than wrangler-accounts — most likely:
|
|
104
|
+
- Project-local `./.wrangler/state/` is sharing data across profiles (see "What is and isn't isolated")
|
|
105
|
+
- The project's `wrangler.toml` has the wrong `account_id` hardcoded
|
|
106
|
+
- The user is on a CLI version below 1.2.2 (account-id cache leak)
|
|
107
|
+
- The wrangler subcommand actually needs `--remote` or `--local` and you forgot
|
|
108
|
+
|
|
109
|
+
## Quick Start
|
|
110
|
+
|
|
111
|
+
- `wrangler-accounts login <name>` — interactive OAuth login into a new profile (never touches real `~/.wrangler`)
|
|
112
|
+
- `wrangler-accounts token-add <name> <api-token> <account-id>` — save an API token profile (no browser login needed)
|
|
113
|
+
- `wrangler-accounts default <name>` — set the persistent default profile
|
|
114
|
+
- `wrangler-accounts deploy` — run `wrangler deploy` under the default profile
|
|
115
|
+
- `wrangler-accounts --profile personal deploy` — one-shot override
|
|
116
|
+
- `wrangler-accounts exec work -- npm run release` — run a command in an isolated subshell for the `work` profile
|
|
117
|
+
|
|
118
|
+
> 💡 **Reading the STATUS column**: `valid` = healthy, `valid*` = healthy (will auto-refresh on next use, **don't re-login**), `EXPIRED` = truly broken (need login), `unknown` = run `--deep` to find out. Full table below in "List and inspect profiles".
|
|
119
|
+
|
|
120
|
+
## Tasks
|
|
121
|
+
|
|
122
|
+
### Run wrangler against a profile
|
|
123
|
+
|
|
124
|
+
Per-invocation (preferred for scripts):
|
|
125
|
+
|
|
126
|
+
`wrangler-accounts --profile <name> <wrangler-args...>`
|
|
127
|
+
|
|
128
|
+
Or with env var:
|
|
129
|
+
|
|
130
|
+
`WRANGLER_PROFILE=<name> wrangler-accounts <wrangler-args...>`
|
|
131
|
+
|
|
132
|
+
Or positional shorthand (only when `<name>` is a saved profile name, not a management subcommand):
|
|
133
|
+
|
|
134
|
+
`wrangler-accounts <name> <wrangler-args...>`
|
|
135
|
+
|
|
136
|
+
### Open a subshell for a profile
|
|
137
|
+
|
|
138
|
+
`wrangler-accounts exec <name>` — launches `$SHELL -i` with isolated `HOME` and `WRANGLER_PROFILE` set. Everything inside the subshell sees the profile, including nested `npm run` scripts, Makefiles, and `npx wrangler`.
|
|
139
|
+
|
|
140
|
+
Run a single command instead:
|
|
141
|
+
|
|
142
|
+
`wrangler-accounts exec <name> -- <cmd> [args]`
|
|
143
|
+
|
|
144
|
+
### Manage the persistent default profile
|
|
145
|
+
|
|
146
|
+
- `wrangler-accounts default` — print current default (exit 1 if none set)
|
|
147
|
+
- `wrangler-accounts default <name>` — set the default
|
|
148
|
+
- `wrangler-accounts default --unset` — clear the default
|
|
149
|
+
- `wrangler-accounts default --json` — JSON output
|
|
150
|
+
|
|
151
|
+
### Show the resolved identity for a profile
|
|
152
|
+
|
|
153
|
+
`wrangler-accounts whoami [--profile <name>]` — reports the profile name, source tier (cli / positional / env / default), and identity from `meta.json`. Does not spawn wrangler.
|
|
154
|
+
|
|
155
|
+
Use `--json` for structured output.
|
|
156
|
+
|
|
157
|
+
### List and inspect profiles
|
|
158
|
+
|
|
159
|
+
- `wrangler-accounts list` — text table with NAME / STATUS / EXPIRES / IDENTITY columns
|
|
160
|
+
- `wrangler-accounts list --json` — structured: array of `{name, isDefault, isActive, status, expirationTime, hasRefreshToken, identity, verified, verifyError}`
|
|
161
|
+
- `wrangler-accounts list --plain` — one profile name per line (scriptable)
|
|
162
|
+
- `wrangler-accounts list --deep` — **authoritative** check: spawns `wrangler whoami` in a shadow HOME for every profile and reports whether Cloudflare actually accepts the credentials. Slower (makes network calls), but the only way to catch revoked refresh tokens or broken profile files.
|
|
163
|
+
- `wrangler-accounts status` / `status --json`
|
|
164
|
+
- Pass `--include-backups` to show hidden backup profiles.
|
|
165
|
+
|
|
166
|
+
**STATUS values (1.3.0+):**
|
|
167
|
+
|
|
168
|
+
| value | meaning | user action |
|
|
169
|
+
|---|---|---|
|
|
170
|
+
| `valid` | access_token is currently valid | none |
|
|
171
|
+
| `valid*` / `refreshable` | access_token past expiry **BUT** refresh_token present; wrangler will auto-refresh on next use | **none** — this is fine, don't scare the user |
|
|
172
|
+
| `EXPIRED` / `expired` | access_token expired **AND** no refresh_token saved; profile is genuinely broken | `wrangler-accounts login <name>` |
|
|
173
|
+
| `unknown` | profile file has no `expiration_time` field | run `list --deep` to verify live |
|
|
174
|
+
| `token` | API token profile (1.6.0+) — no expiration concept, always ready | none |
|
|
175
|
+
|
|
176
|
+
**Cloudflare OAuth lifecycle reference:** access tokens are short-lived (~1 hour) by design. Every profile with `offline_access` in its scopes also has a long-lived refresh_token (~30 days, silently extended on use). Wrangler refreshes access tokens automatically whenever it runs a command and the current one is past expiry. **Do not tell the user to re-login just because `list` shows an expired access token** — check `hasRefreshToken` first. If the profile's STATUS is `valid*` / `refreshable`, nothing is wrong.
|
|
177
|
+
|
|
178
|
+
The only time a user actually needs `wrangler-accounts login <name>` again is:
|
|
179
|
+
1. STATUS is `EXPIRED` (no refresh_token at all — profile was saved without `offline_access` scope)
|
|
180
|
+
2. OR `list --deep` returns `✗` with "Not logged in" / "refresh token may be revoked" (refresh token itself got invalidated)
|
|
181
|
+
|
|
182
|
+
### Save an API token profile (no browser required)
|
|
183
|
+
|
|
184
|
+
`wrangler-accounts token-add <name> <api-token> <account-id> [--force]`
|
|
185
|
+
|
|
186
|
+
Saves a Cloudflare API token + account ID as a named profile. No OAuth browser flow needed. The credentials are stored in `token.json` (mode 0600) inside the profile directory.
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Get your API token from: Cloudflare dashboard → My Profile → API Tokens
|
|
190
|
+
wrangler-accounts token-add work CF_TOKEN_HERE ACCOUNT_ID_HERE
|
|
191
|
+
|
|
192
|
+
# Use identically to OAuth profiles
|
|
193
|
+
wrangler-accounts --profile work deploy
|
|
194
|
+
wrangler-accounts work r2 list
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Token profiles appear in `list` with a `[token]` type indicator and `STATUS: token` — there is no expiration concept, so they are always ready to use. `remove` works the same as for OAuth profiles.
|
|
198
|
+
|
|
199
|
+
**Env-var pass-through (1.6.0+):** when `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` are already set in the environment and no profile is specified, `wrangler-accounts` runs in anonymous-token mode (no named profile needed). Useful for CI jobs that inject credentials via secrets:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
CLOUDFLARE_API_TOKEN=xxx CLOUDFLARE_ACCOUNT_ID=yyy wrangler-accounts deploy
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Save, sync, login, remove
|
|
206
|
+
|
|
207
|
+
- `wrangler-accounts save <name>` — snapshot current Wrangler config as a profile
|
|
208
|
+
- `wrangler-accounts sync <name>` — refresh a specific profile from the current login
|
|
209
|
+
- `wrangler-accounts sync-default` — refresh the default profile
|
|
210
|
+
- `wrangler-accounts login <name>` — fresh isolated OAuth login
|
|
211
|
+
- `wrangler-accounts remove <name>` — delete a profile (works for both OAuth and token profiles)
|
|
212
|
+
|
|
213
|
+
### Clean up stale shadow HOMEs
|
|
214
|
+
|
|
215
|
+
`wrangler-accounts gc [--older-than 1h]` — removes `wa-*` directories under `$TMPDIR` older than the threshold (default 1h). Safe to run at any time.
|
|
216
|
+
|
|
217
|
+
## Common Recipes
|
|
218
|
+
|
|
219
|
+
These are the patterns the user is most likely asking about when they mention "Cloudflare accounts", "wrangler", or "multi-account deploys". Pick the one that matches intent.
|
|
220
|
+
|
|
221
|
+
### User wants: deploy a worker to a specific account
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
wrangler-accounts --profile work deploy
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Or, when the user will be on this account for a while:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
wrangler-accounts default work # set once
|
|
231
|
+
wrangler-accounts deploy # uses work from now on
|
|
232
|
+
wrangler-accounts deploy --env staging # wrangler flags pass through unchanged
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### User wants: tail production logs on one account while developing on another
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# shell 1
|
|
239
|
+
wrangler-accounts --profile work tail my-worker --format pretty
|
|
240
|
+
|
|
241
|
+
# shell 2 (simultaneously, zero interference)
|
|
242
|
+
wrangler-accounts --profile personal dev
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
The two shells each get their own shadow `HOME`, so there's no global state for the other to clobber.
|
|
246
|
+
|
|
247
|
+
### User wants: run a deploy script / npm script / Makefile against a specific account
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
wrangler-accounts exec work -- npm run deploy
|
|
251
|
+
wrangler-accounts exec work -- make release
|
|
252
|
+
wrangler-accounts exec work -- bash scripts/deploy.sh
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Anything inside the subshell that calls `wrangler` (directly, via `npx`, via `pnpm`, via a package.json script) automatically uses the `work` profile.
|
|
256
|
+
|
|
257
|
+
### User wants: set up a new Cloudflare account from scratch
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
wrangler-accounts login new-account # opens the browser OAuth flow
|
|
261
|
+
wrangler-accounts whoami --profile new-account # verify identity
|
|
262
|
+
wrangler-accounts list # confirm the profile is saved
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
The login flow runs inside an isolated shadow `HOME`, so the user's real `~/.wrangler/config/default.toml` is never touched.
|
|
266
|
+
|
|
267
|
+
> ⚠️ **`login` is destructive.** It opens a browser, requires the user to click "Authorize" interactively, and **OVERWRITES** the named profile. As of 1.4.0, `wrangler-accounts login <name>` refuses to run if (a) stdin is not a TTY, or (b) the profile already exists and looks healthy — both unless you pass `--force`. **Never run `login` to "verify" or "refresh" a profile** — see the antipattern below.
|
|
268
|
+
|
|
269
|
+
### ❌ Antipattern: running `login` to verify a profile works
|
|
270
|
+
|
|
271
|
+
This is wrong:
|
|
272
|
+
```bash
|
|
273
|
+
wrangler-accounts login Xdreamstar2025 # ❌ DON'T do this just to check
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Reasons:
|
|
277
|
+
1. `login` is **destructive** — it overwrites the saved profile with a brand new OAuth flow.
|
|
278
|
+
2. `login` requires a **browser and an interactive terminal** — it cannot complete in a Bash sub-shell, CI runner, or sub-agent context. The command will hang waiting for the user.
|
|
279
|
+
3. The Cloudflare access token in a healthy profile auto-refreshes via `refresh_token` — there is **nothing to "log in to"** when the profile already works.
|
|
280
|
+
|
|
281
|
+
Use one of these instead:
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
wrangler-accounts whoami --profile Xdreamstar2025 # fast, reads meta.json, no network
|
|
285
|
+
wrangler-accounts list --deep # authoritative, runs wrangler whoami per profile
|
|
286
|
+
wrangler-accounts list # quick STATUS overview (valid / valid* / EXPIRED / unknown)
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Only fall back to `wrangler-accounts login <name>` when:
|
|
290
|
+
- The profile **does not exist yet** (creating a new account profile from scratch)
|
|
291
|
+
- The profile shows `EXPIRED` (truly expired, no refresh_token left) — see STATUS table above
|
|
292
|
+
- `list --deep` returns `✗` with "Not logged in" / "refresh token may be revoked" (server-side revocation)
|
|
293
|
+
- The user **explicitly says** "re-authenticate this profile" / "log me in again"
|
|
294
|
+
|
|
295
|
+
### User wants: check which account a profile is tied to, without running wrangler
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
wrangler-accounts whoami --profile <name> # text
|
|
299
|
+
wrangler-accounts whoami --profile <name> --json # structured
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Returns the email + account ID from the saved `meta.json`. No network call.
|
|
303
|
+
|
|
304
|
+
### User wants: swap between many accounts quickly in one shell
|
|
305
|
+
|
|
306
|
+
Use `default` as a "current" setting:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
wrangler-accounts default work
|
|
310
|
+
wrangler-accounts deploy # work
|
|
311
|
+
wrangler-accounts default personal
|
|
312
|
+
wrangler-accounts dev # personal
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Or use positional shorthand inline:
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
wrangler-accounts work deploy # one-shot, no persistent default
|
|
319
|
+
wrangler-accounts personal dev
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### User wants: run wrangler in CI with multiple accounts
|
|
323
|
+
|
|
324
|
+
**Don't use `wrangler-accounts` in CI.** Use native env vars:
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
# In CI secrets:
|
|
328
|
+
CLOUDFLARE_API_TOKEN=<token-with-workers-deploy-scope>
|
|
329
|
+
CLOUDFLARE_ACCOUNT_ID=<account-id>
|
|
330
|
+
|
|
331
|
+
# In the pipeline:
|
|
332
|
+
wrangler deploy
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
`wrangler-accounts` is for **local developer** OAuth sessions. CI should use long-lived API tokens directly with plain `wrangler`. Recommend this even if the user asks to use `wrangler-accounts` in CI.
|
|
336
|
+
|
|
337
|
+
## Troubleshooting
|
|
338
|
+
|
|
339
|
+
### "Profile 'X' has expired Wrangler OAuth credentials and no refresh_token to renew them"
|
|
340
|
+
|
|
341
|
+
The saved OAuth access_token is past its `expiration_time` AND there is no `refresh_token` in the profile config (no `offline_access` scope at login time, or the token was revoked). The profile is genuinely broken; only re-authenticating fixes it:
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
wrangler-accounts login <name>
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
This overwrites the existing profile with a fresh OAuth session. Any saved metadata (identity, etc.) is re-verified.
|
|
348
|
+
|
|
349
|
+
**Note:** If you see this error in 1.5.0 or earlier, you may be hitting a known regression: any profile whose access_token had passed expiration was blocked even when a refresh_token was present. Upgrade to 1.5.1+ — `wrangler` itself silently refreshes those tokens on the next call, so wrangler-accounts no longer pre-flights against `expiration_time` alone.
|
|
350
|
+
|
|
351
|
+
### "No profile specified. Options: ..."
|
|
352
|
+
|
|
353
|
+
The user ran `wrangler-accounts <wrangler-args>` without a resolvable profile. Fix one of:
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
wrangler-accounts --profile <name> <args> # one-shot
|
|
357
|
+
WRANGLER_PROFILE=<name> wrangler-accounts <args> # env var
|
|
358
|
+
wrangler-accounts default <name> # persistent default
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**1.6.0+**: if `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` are both present in the environment, this error no longer fires — the tool runs in anonymous-token mode automatically.
|
|
362
|
+
|
|
363
|
+
### "Profile not found: X"
|
|
364
|
+
|
|
365
|
+
The profile name doesn't exist in `profilesDir`. Check what's saved:
|
|
366
|
+
|
|
367
|
+
```bash
|
|
368
|
+
wrangler-accounts list
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
Create it with `wrangler-accounts login <name>` or copy an existing Wrangler login with `wrangler-accounts save <name>`.
|
|
372
|
+
|
|
373
|
+
### Inside `wrangler-accounts exec`, `cd ~` lands in a weird tmpdir
|
|
374
|
+
|
|
375
|
+
Expected. Inside an `exec` session, `$HOME` is the shadow HOME. The real home is still accessible:
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
cd "$WRANGLER_ACCOUNT_REAL_HOME"
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Or users can add a shell alias: `alias realhome='cd "$WRANGLER_ACCOUNT_REAL_HOME"'`.
|
|
382
|
+
|
|
383
|
+
### Unsupported `use` command migration
|
|
384
|
+
|
|
385
|
+
`wrangler-accounts use <name>` no longer switches profiles. It exits with migration guidance because the old behavior was ambiguous and rewrote Wrangler's global config. Suggest the replacement based on intent:
|
|
386
|
+
|
|
387
|
+
- "I want this account to stick for a while" → `wrangler-accounts default <name>`
|
|
388
|
+
- "Just this one command" → `wrangler-accounts --profile <name> <wrangler-args>`
|
|
389
|
+
- "I want an interactive shell on that account" → `wrangler-accounts exec <name>`
|
|
390
|
+
|
|
391
|
+
### `[ERROR] A request to the Cloudflare API ... Authentication error [code: 10000]` with `code: 7403` ("not authorized to access this service")
|
|
392
|
+
|
|
393
|
+
The OAuth token is fine but **the URL contains the wrong account ID**. wrangler caches the user's selected account in `wrangler-account.json`. If that cache file is shared across profiles, profile A's OAuth token gets paired with profile B's cached account ID, sending API calls to the wrong account. Symptoms:
|
|
394
|
+
|
|
395
|
+
- `deploy` and `secret put` succeed (they don't put account ID in the URL path)
|
|
396
|
+
- `d1 execute --remote`, `r2 object get/put`, anything else with `/accounts/<id>/...` in the URL fails with 7403
|
|
397
|
+
|
|
398
|
+
**Fix path** (in order):
|
|
399
|
+
|
|
400
|
+
1. **Are you on wrangler-accounts ≥ 1.2.2?** Run `wrangler-accounts --version`. If `< 1.2.2`, upgrade — earlier versions pointed `WRANGLER_CACHE_DIR` at a shared global path. 1.2.2 isolates the cache per profile.
|
|
401
|
+
2. **Clear the polluted shared cache** (one-time, even after upgrading):
|
|
402
|
+
```bash
|
|
403
|
+
rm -f ~/.wrangler/cache/wrangler-account.json
|
|
404
|
+
rm -f ~/Library/Preferences/.wrangler/cache/wrangler-account.json # macOS env-paths fallback
|
|
405
|
+
```
|
|
406
|
+
3. **Verify with `wrangler-accounts list --deep`** — the VERIFIED column for each profile should be `✓ ok`. If `✗`, the underlying OAuth session itself is broken; run `wrangler-accounts login <name>`.
|
|
407
|
+
4. **Defense in depth**: set `CLOUDFLARE_ACCOUNT_ID=<correct-id>` in the calling environment. wrangler reads this env var directly and bypasses the cache entirely. Useful for scripts or one-off recovery commands:
|
|
408
|
+
```bash
|
|
409
|
+
CLOUDFLARE_ACCOUNT_ID=<id> wrangler-accounts <profile> r2 object put ...
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
**What to tell the user**: "wrangler returned 7403 because it cached the wrong account ID alongside your OAuth token. This was a real bug in wrangler-accounts ≤ 1.2.1 (shared cache directory across profiles). Upgrade to 1.2.2 and clear the polluted cache."
|
|
413
|
+
|
|
414
|
+
### "The OAuth config seems right, but the wrong account is being used"
|
|
415
|
+
|
|
416
|
+
Same root cause as the 7403 above. Default to the same fix path.
|
|
417
|
+
|
|
418
|
+
### `wrangler dev` (or any `--local` command) shows stale data after switching profiles
|
|
419
|
+
|
|
420
|
+
Project-local state at `<project>/.wrangler/state/` is **NOT** isolated per profile — wrangler's `getLocalPersistencePath` (cli.js:149025) hardcodes the path next to `wrangler.toml` and the only override is the `--persist-to` CLI flag (no env var hook). So if profile A's `wrangler dev` populated a local D1 emulation, then you switch to profile B and run `wrangler dev` in the same directory, B sees A's emulated rows.
|
|
421
|
+
|
|
422
|
+
This only affects `--local` simulations. **`--remote` commands hit Cloudflare directly and are unaffected** — that's the common case for d1/r2 work in a multi-account setup.
|
|
423
|
+
|
|
424
|
+
Two clean fixes:
|
|
425
|
+
|
|
426
|
+
1. **Use git worktrees** (recommended for any serious multi-profile dev workflow):
|
|
427
|
+
```bash
|
|
428
|
+
git worktree add ../my-project-work main
|
|
429
|
+
git worktree add ../my-project-personal main
|
|
430
|
+
cd ../my-project-work && wrangler-accounts exec work # isolated .wrangler/state/
|
|
431
|
+
cd ../my-project-personal && wrangler-accounts exec personal
|
|
432
|
+
```
|
|
433
|
+
2. **Clear state manually before switching**:
|
|
434
|
+
```bash
|
|
435
|
+
rm -rf .wrangler/state
|
|
436
|
+
wrangler-accounts --profile <new> dev
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
`wrangler-accounts` does not auto-isolate `.wrangler/state/` because the only mechanism would be argv injection of `--persist-to`, which has too many failure modes (different subcommands accept persistTo at different positions, can't override user-supplied flags, path selection is ambiguous between per-profile and per-profile-per-project). The honest tradeoff is documented in the "What is and isn't isolated" table above — partial isolation with hidden gotchas would be worse than honest sharing.
|
|
440
|
+
|
|
441
|
+
### Shell history / `.zsh_history` seems to grow when running `exec`
|
|
442
|
+
|
|
443
|
+
Intentional. By design the shadow HOME symlinks all top-level entries of real HOME except `.wrangler`, so shell history writes pass through to the real file. This is a **convenience** bias, not a clean-room sandbox — the goal is that `exec` subshells feel like a normal terminal with a different Cloudflare account, not a jail.
|
|
444
|
+
|
|
445
|
+
## Invariants the AI should rely on
|
|
446
|
+
|
|
447
|
+
- **Real `~/.wrangler/config/default.toml` is never written to by `wrangler-accounts`.** If a user reports that it changed, something else touched it (e.g. a direct `wrangler login` outside `wrangler-accounts`).
|
|
448
|
+
- **Two `wrangler-accounts --profile A` and `wrangler-accounts --profile B` running in parallel never clobber each other on credentials OR account-id cache.** Each gets its own `mkdtemp` shadow HOME, and each gets its own per-profile `WRANGLER_CACHE_DIR` (next to the profile's `config.toml`) so that wrangler's `wrangler-account.json` (which stores the selected Cloudflare account ID) is naturally isolated.
|
|
449
|
+
- **OAuth token refresh inside a profile is automatic.** The shadow HOME contains a symlink from `.wrangler/config/default.toml` to the saved profile file, so Wrangler's in-place `fs.writeFileSync` during `refreshToken()` flows straight back to the profile.
|
|
450
|
+
- **`wrangler-accounts <args>` without a management subcommand forwards everything to wrangler verbatim**, including `--env`, `--dry-run`, `--json`, and any wrangler-native flags. The only flags consumed by `wrangler-accounts` itself are the ones listed in "Paths and environment" below.
|
|
451
|
+
|
|
452
|
+
## What is and isn't isolated
|
|
453
|
+
|
|
454
|
+
| State | Location | Isolated? |
|
|
455
|
+
|---|---|---|
|
|
456
|
+
| OAuth credentials (`config.toml`) | shadow `$HOME/.wrangler/config/default.toml` → symlink to per-profile file | ✅ per profile |
|
|
457
|
+
| Account-id cache (`wrangler-account.json`) | per-profile `WRANGLER_CACHE_DIR` (= `<profilesDir>/<name>/cache/`) | ✅ per profile |
|
|
458
|
+
| Pages config cache (`pages-config-cache.json`) | same as above | ✅ per profile |
|
|
459
|
+
| Miniflare dev registry | `WRANGLER_REGISTRY_PATH` = `$realHome/.wrangler/registry` | ❌ shared on purpose (cross-profile worker discovery during local dev) |
|
|
460
|
+
| Wrangler debug logs | `WRANGLER_LOG_PATH` = `$realHome/.wrangler/logs` | ❌ shared (append-only, harmless) |
|
|
461
|
+
| Project-local state (`./.wrangler/state/`, `./node_modules/.cache/wrangler`) | inside the project directory | ❌ shared at project level (per-project, but not per-profile) |
|
|
462
|
+
| `cloudflared` binary | `CLOUDFLARED_PATH` or `~/.wrangler/cloudflared/` | ❌ shared (binary, not account-scoped) |
|
|
463
|
+
| Shell history, npm cache, git config, ssh keys | symlinked through to real `$HOME` | ❌ shared by design (so `exec` subshells feel like a normal terminal) |
|
|
464
|
+
|
|
465
|
+
If a user is hitting a "wrong account" symptom and the credentials look right, the most likely culprit is **project-local state** in `./.wrangler/state/` — clear that and re-run.
|
|
466
|
+
|
|
467
|
+
## CI guidance
|
|
468
|
+
|
|
469
|
+
For CI and deploy pipelines you have two options:
|
|
470
|
+
|
|
471
|
+
**Option 1 — plain `wrangler` with env vars (simplest for CI):**
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
CLOUDFLARE_API_TOKEN=<token>
|
|
475
|
+
CLOUDFLARE_ACCOUNT_ID=<account-id>
|
|
476
|
+
wrangler deploy
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**Option 2 — `wrangler-accounts` with a token profile (useful when you want the same CLI both locally and in CI):**
|
|
480
|
+
|
|
481
|
+
```bash
|
|
482
|
+
# Save once (locally or during CI bootstrap):
|
|
483
|
+
wrangler-accounts token-add work "$CF_TOKEN" "$CF_ACCOUNT_ID"
|
|
484
|
+
# Use the same commands locally and in CI:
|
|
485
|
+
wrangler-accounts --profile work deploy
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
Or use the anonymous pass-through (no profile needed if env vars are present):
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
CLOUDFLARE_API_TOKEN="$CF_TOKEN" CLOUDFLARE_ACCOUNT_ID="$CF_ACCOUNT_ID" wrangler-accounts deploy
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
`wrangler-accounts` is primarily a local developer convenience for juggling OAuth sessions on your workstation, but since 1.6.0 it also supports API token profiles for teams that want a consistent CLI interface across local and CI environments.
|
|
495
|
+
|
|
496
|
+
## Paths and environment
|
|
497
|
+
|
|
498
|
+
- `--profile <name>` / `-p <name>` — profile for this invocation (v1.0: `-p` means `--profile`)
|
|
499
|
+
- `--profiles <path>` — profiles directory (long form only since v1.0)
|
|
500
|
+
- `-c, --config <path>` — Wrangler config path
|
|
501
|
+
- `WRANGLER_PROFILE` — profile to use when no `--profile` flag is given
|
|
502
|
+
- `WRANGLER_CONFIG_PATH`, `WRANGLER_ACCOUNTS_DIR`, `XDG_CONFIG_HOME` — path overrides
|
|
503
|
+
|
|
504
|
+
## Output conventions
|
|
505
|
+
|
|
506
|
+
Use `--json` when another tool needs to parse results. All v1.0 commands that produce structured data support `--json`.
|
|
507
|
+
|
|
508
|
+
## Naming rules
|
|
509
|
+
|
|
510
|
+
Profile names: letters, numbers, dot, underscore, dash only. Names matching management subcommand names (`exec`, `default`, `whoami`, `gc`, `login`, `token-add`, `list`, `status`, `save`, `sync`, `sync-default`, `remove`, `use`, `sync-active`) cannot be reached via positional shorthand — use `--profile <name>` for those.
|
|
511
|
+
|
|
512
|
+
## Deprecated
|
|
513
|
+
|
|
514
|
+
- `wrangler-accounts use <name>` — unsupported compatibility entry; exits with migration guidance. Use `default <name>` for persistence, `--profile <name>` for one-shot commands, or `exec <name>` for an interactive shell.
|
|
515
|
+
- `wrangler-accounts sync-active` — deprecated alias for `sync-default`.
|