@leeguoo/wrangler-accounts 0.1.2 → 0.1.4
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 +16 -0
- package/bin/wrangler-accounts.js +10 -2
- package/completions/wrangler-accounts.zsh +36 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ wrangler-accounts remove old
|
|
|
46
46
|
-c, --config <path> Wrangler config path
|
|
47
47
|
-p, --profiles <path> Profiles directory
|
|
48
48
|
--json JSON output for list/status
|
|
49
|
+
--plain Plain output for list (one name per line)
|
|
49
50
|
-f, --force Overwrite existing profile on save
|
|
50
51
|
--backup Backup current config on use (default)
|
|
51
52
|
--no-backup Disable backup on use
|
|
@@ -75,3 +76,18 @@ The profiles directory defaults to:
|
|
|
75
76
|
|
|
76
77
|
- Profile names accept only letters, numbers, dot, underscore, and dash.
|
|
77
78
|
- On `use`, the current config is backed up into `__backup-YYYYMMDD-HHMMSS` unless you pass `--no-backup`.
|
|
79
|
+
- `login <name>` overwrites an existing profile with the same name.
|
|
80
|
+
|
|
81
|
+
## Shell completion (zsh)
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
mkdir -p ~/.zsh/completions
|
|
85
|
+
cp $(pnpm root -g)/@leeguoo/wrangler-accounts/completions/wrangler-accounts.zsh ~/.zsh/completions/_wrangler-accounts
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Then add to your `~/.zshrc`:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
fpath=(~/.zsh/completions $fpath)
|
|
92
|
+
autoload -Uz compinit && compinit
|
|
93
|
+
```
|
package/bin/wrangler-accounts.js
CHANGED
|
@@ -30,6 +30,7 @@ Options:
|
|
|
30
30
|
-c, --config <path> Wrangler config path
|
|
31
31
|
-p, --profiles <path> Profiles directory
|
|
32
32
|
--json JSON output for list/status
|
|
33
|
+
--plain Plain output for list (one name per line)
|
|
33
34
|
-f, --force Overwrite existing profile on save
|
|
34
35
|
--backup Backup current config on use (default)
|
|
35
36
|
--no-backup Disable backup on use
|
|
@@ -73,6 +74,8 @@ function parseArgs(argv) {
|
|
|
73
74
|
opts.help = true;
|
|
74
75
|
} else if (arg === "--json") {
|
|
75
76
|
opts.json = true;
|
|
77
|
+
} else if (arg === "--plain") {
|
|
78
|
+
opts.plain = true;
|
|
76
79
|
} else if (arg === "--force" || arg === "-f") {
|
|
77
80
|
opts.force = true;
|
|
78
81
|
} else if (arg === "--backup") {
|
|
@@ -300,6 +303,8 @@ function main() {
|
|
|
300
303
|
const profiles = listProfiles(profilesDir);
|
|
301
304
|
if (opts.json) {
|
|
302
305
|
console.log(JSON.stringify(profiles, null, 2));
|
|
306
|
+
} else if (opts.plain) {
|
|
307
|
+
if (profiles.length) console.log(profiles.join("\n"));
|
|
303
308
|
} else if (profiles.length === 0) {
|
|
304
309
|
console.log("No profiles found.");
|
|
305
310
|
} else {
|
|
@@ -350,8 +355,11 @@ function main() {
|
|
|
350
355
|
if (!fs.existsSync(configPath)) {
|
|
351
356
|
die(`Config file not found after login: ${configPath}`);
|
|
352
357
|
}
|
|
353
|
-
|
|
354
|
-
|
|
358
|
+
const profileDir = path.join(profilesDir, name);
|
|
359
|
+
const existed = fs.existsSync(profileDir);
|
|
360
|
+
saveProfile(name, configPath, profilesDir, true);
|
|
361
|
+
const note = existed ? " (overwritten)" : "";
|
|
362
|
+
console.log(`Logged in and saved profile '${name}' from ${configPath}${note}`);
|
|
355
363
|
return;
|
|
356
364
|
}
|
|
357
365
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#compdef wrangler-accounts
|
|
2
|
+
|
|
3
|
+
_wrangler_accounts() {
|
|
4
|
+
local -a commands
|
|
5
|
+
commands=(
|
|
6
|
+
'list:List profiles'
|
|
7
|
+
'status:Show status'
|
|
8
|
+
'login:Login and save profile'
|
|
9
|
+
'save:Save current profile'
|
|
10
|
+
'use:Switch to profile'
|
|
11
|
+
'remove:Remove profile'
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
local state
|
|
15
|
+
_arguments -C \
|
|
16
|
+
'1:command:->command' \
|
|
17
|
+
'*::arg:->args'
|
|
18
|
+
|
|
19
|
+
case $state in
|
|
20
|
+
command)
|
|
21
|
+
_describe 'command' commands
|
|
22
|
+
return
|
|
23
|
+
;;
|
|
24
|
+
args)
|
|
25
|
+
case $words[1] in
|
|
26
|
+
save|use|remove|login)
|
|
27
|
+
local profiles
|
|
28
|
+
profiles=(${(f)"$(wrangler-accounts list --plain 2>/dev/null | grep -v '^__backup-')"})
|
|
29
|
+
_describe 'profiles' profiles
|
|
30
|
+
;;
|
|
31
|
+
esac
|
|
32
|
+
;;
|
|
33
|
+
esac
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
_wrangler_accounts "$@"
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leeguoo/wrangler-accounts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Local CLI to manage multiple Cloudflare Wrangler login profiles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
7
|
"wrangler-accounts": "bin/wrangler-accounts.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"bin"
|
|
10
|
+
"bin",
|
|
11
|
+
"completions"
|
|
11
12
|
],
|
|
12
13
|
"keywords": [
|
|
13
14
|
"cloudflare",
|