@leeguoo/wrangler-accounts 0.1.4 → 0.1.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/README.md +18 -1
- package/bin/wrangler-accounts.js +81 -9
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ wrangler-accounts remove old
|
|
|
45
45
|
```text
|
|
46
46
|
-c, --config <path> Wrangler config path
|
|
47
47
|
-p, --profiles <path> Profiles directory
|
|
48
|
-
--json JSON output for
|
|
48
|
+
--json JSON output for all commands
|
|
49
49
|
--plain Plain output for list (one name per line)
|
|
50
50
|
-f, --force Overwrite existing profile on save
|
|
51
51
|
--backup Backup current config on use (default)
|
|
@@ -58,6 +58,18 @@ wrangler-accounts remove old
|
|
|
58
58
|
- WRANGLER_ACCOUNTS_DIR
|
|
59
59
|
- XDG_CONFIG_HOME
|
|
60
60
|
|
|
61
|
+
## JSON output
|
|
62
|
+
|
|
63
|
+
Use `--json` for machine-readable output.
|
|
64
|
+
|
|
65
|
+
Examples:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
wrangler-accounts list --json
|
|
69
|
+
wrangler-accounts status --json
|
|
70
|
+
wrangler-accounts use personal --json
|
|
71
|
+
```
|
|
72
|
+
|
|
61
73
|
## Defaults
|
|
62
74
|
|
|
63
75
|
If you do not specify a config path, the CLI checks for these and uses the first existing path:
|
|
@@ -78,6 +90,11 @@ The profiles directory defaults to:
|
|
|
78
90
|
- On `use`, the current config is backed up into `__backup-YYYYMMDD-HHMMSS` unless you pass `--no-backup`.
|
|
79
91
|
- `login <name>` overwrites an existing profile with the same name.
|
|
80
92
|
|
|
93
|
+
## Discoverability (SEO / GEO / AI search)
|
|
94
|
+
|
|
95
|
+
This project is a Cloudflare Wrangler multi-account switcher for global teams.
|
|
96
|
+
Keywords: Cloudflare Workers account manager, Wrangler login profiles, multi-account, account switcher, geo-distributed ops, AI search indexing.
|
|
97
|
+
|
|
81
98
|
## Shell completion (zsh)
|
|
82
99
|
|
|
83
100
|
```bash
|
package/bin/wrangler-accounts.js
CHANGED
|
@@ -7,9 +7,15 @@ const os = require("os");
|
|
|
7
7
|
const crypto = require("crypto");
|
|
8
8
|
const { spawnSync } = require("child_process");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
let outputJson = false;
|
|
11
|
+
|
|
12
|
+
function die(message, exitCode = 1) {
|
|
13
|
+
if (outputJson) {
|
|
14
|
+
console.error(JSON.stringify({ error: message }, null, 2));
|
|
15
|
+
} else {
|
|
16
|
+
console.error(`Error: ${message}`);
|
|
17
|
+
}
|
|
18
|
+
process.exit(exitCode);
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
function printHelp(exitCode = 0) {
|
|
@@ -29,7 +35,7 @@ Commands:
|
|
|
29
35
|
Options:
|
|
30
36
|
-c, --config <path> Wrangler config path
|
|
31
37
|
-p, --profiles <path> Profiles directory
|
|
32
|
-
--json JSON output for
|
|
38
|
+
--json JSON output for all commands
|
|
33
39
|
--plain Plain output for list (one name per line)
|
|
34
40
|
-f, --force Overwrite existing profile on save
|
|
35
41
|
--backup Backup current config on use (default)
|
|
@@ -290,7 +296,9 @@ function removeProfile(name, profilesDir) {
|
|
|
290
296
|
}
|
|
291
297
|
|
|
292
298
|
function main() {
|
|
293
|
-
const
|
|
299
|
+
const argv = process.argv.slice(2);
|
|
300
|
+
outputJson = argv.includes("--json");
|
|
301
|
+
const { opts, rest } = parseArgs(argv);
|
|
294
302
|
if (opts.help) printHelp(0);
|
|
295
303
|
|
|
296
304
|
const command = rest[0];
|
|
@@ -342,8 +350,26 @@ function main() {
|
|
|
342
350
|
const name = rest[1];
|
|
343
351
|
if (!name) die("Missing profile name for save");
|
|
344
352
|
ensureDir(profilesDir);
|
|
353
|
+
const profileDir = path.join(profilesDir, name);
|
|
354
|
+
const existed = fs.existsSync(profileDir);
|
|
345
355
|
saveProfile(name, configPath, profilesDir, opts.force);
|
|
346
|
-
|
|
356
|
+
if (opts.json) {
|
|
357
|
+
console.log(
|
|
358
|
+
JSON.stringify(
|
|
359
|
+
{
|
|
360
|
+
command: "save",
|
|
361
|
+
name,
|
|
362
|
+
configPath,
|
|
363
|
+
profilesDir,
|
|
364
|
+
overwritten: existed,
|
|
365
|
+
},
|
|
366
|
+
null,
|
|
367
|
+
2
|
|
368
|
+
)
|
|
369
|
+
);
|
|
370
|
+
} else {
|
|
371
|
+
console.log(`Saved profile '${name}' from ${configPath}`);
|
|
372
|
+
}
|
|
347
373
|
return;
|
|
348
374
|
}
|
|
349
375
|
|
|
@@ -359,7 +385,23 @@ function main() {
|
|
|
359
385
|
const existed = fs.existsSync(profileDir);
|
|
360
386
|
saveProfile(name, configPath, profilesDir, true);
|
|
361
387
|
const note = existed ? " (overwritten)" : "";
|
|
362
|
-
|
|
388
|
+
if (opts.json) {
|
|
389
|
+
console.log(
|
|
390
|
+
JSON.stringify(
|
|
391
|
+
{
|
|
392
|
+
command: "login",
|
|
393
|
+
name,
|
|
394
|
+
configPath,
|
|
395
|
+
profilesDir,
|
|
396
|
+
overwritten: existed,
|
|
397
|
+
},
|
|
398
|
+
null,
|
|
399
|
+
2
|
|
400
|
+
)
|
|
401
|
+
);
|
|
402
|
+
} else {
|
|
403
|
+
console.log(`Logged in and saved profile '${name}' from ${configPath}${note}`);
|
|
404
|
+
}
|
|
363
405
|
return;
|
|
364
406
|
}
|
|
365
407
|
|
|
@@ -369,7 +411,23 @@ function main() {
|
|
|
369
411
|
ensureDir(profilesDir);
|
|
370
412
|
const backupName = useProfile(name, configPath, profilesDir, opts.backup);
|
|
371
413
|
const backupNote = backupName ? ` (backup: ${backupName})` : "";
|
|
372
|
-
|
|
414
|
+
if (opts.json) {
|
|
415
|
+
console.log(
|
|
416
|
+
JSON.stringify(
|
|
417
|
+
{
|
|
418
|
+
command: "use",
|
|
419
|
+
name,
|
|
420
|
+
configPath,
|
|
421
|
+
profilesDir,
|
|
422
|
+
backupName,
|
|
423
|
+
},
|
|
424
|
+
null,
|
|
425
|
+
2
|
|
426
|
+
)
|
|
427
|
+
);
|
|
428
|
+
} else {
|
|
429
|
+
console.log(`Switched to profile '${name}'${backupNote}`);
|
|
430
|
+
}
|
|
373
431
|
return;
|
|
374
432
|
}
|
|
375
433
|
|
|
@@ -377,7 +435,21 @@ function main() {
|
|
|
377
435
|
const name = rest[1];
|
|
378
436
|
if (!name) die("Missing profile name for remove");
|
|
379
437
|
removeProfile(name, profilesDir);
|
|
380
|
-
|
|
438
|
+
if (opts.json) {
|
|
439
|
+
console.log(
|
|
440
|
+
JSON.stringify(
|
|
441
|
+
{
|
|
442
|
+
command: "remove",
|
|
443
|
+
name,
|
|
444
|
+
profilesDir,
|
|
445
|
+
},
|
|
446
|
+
null,
|
|
447
|
+
2
|
|
448
|
+
)
|
|
449
|
+
);
|
|
450
|
+
} else {
|
|
451
|
+
console.log(`Removed profile '${name}'`);
|
|
452
|
+
}
|
|
381
453
|
return;
|
|
382
454
|
}
|
|
383
455
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leeguoo/wrangler-accounts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Local CLI to manage multiple Cloudflare Wrangler login profiles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,11 @@
|
|
|
13
13
|
"keywords": [
|
|
14
14
|
"cloudflare",
|
|
15
15
|
"wrangler",
|
|
16
|
+
"cloudflare-workers",
|
|
17
|
+
"workers",
|
|
16
18
|
"accounts",
|
|
19
|
+
"multi-account",
|
|
20
|
+
"account-switcher",
|
|
17
21
|
"cli"
|
|
18
22
|
],
|
|
19
23
|
"repository": {
|