@leeguoo/wrangler-accounts 0.1.0 → 0.1.2
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 +2 -0
- package/bin/wrangler-accounts.js +26 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ node bin/wrangler-accounts.js <command>
|
|
|
34
34
|
```bash
|
|
35
35
|
wrangler-accounts list
|
|
36
36
|
wrangler-accounts status
|
|
37
|
+
wrangler-accounts login work
|
|
37
38
|
wrangler-accounts save work
|
|
38
39
|
wrangler-accounts use personal
|
|
39
40
|
wrangler-accounts remove old
|
|
@@ -61,6 +62,7 @@ wrangler-accounts remove old
|
|
|
61
62
|
If you do not specify a config path, the CLI checks for these and uses the first existing path:
|
|
62
63
|
|
|
63
64
|
- ~/.wrangler/config/default.toml
|
|
65
|
+
- ~/Library/Preferences/.wrangler/config/default.toml
|
|
64
66
|
- ~/.config/.wrangler/config/default.toml
|
|
65
67
|
- ~/.config/wrangler/config/default.toml
|
|
66
68
|
|
package/bin/wrangler-accounts.js
CHANGED
|
@@ -5,6 +5,7 @@ const fs = require("fs");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const os = require("os");
|
|
7
7
|
const crypto = require("crypto");
|
|
8
|
+
const { spawnSync } = require("child_process");
|
|
8
9
|
|
|
9
10
|
function die(message) {
|
|
10
11
|
console.error(`Error: ${message}`);
|
|
@@ -20,6 +21,7 @@ Usage:
|
|
|
20
21
|
Commands:
|
|
21
22
|
list
|
|
22
23
|
status
|
|
24
|
+
login <name>
|
|
23
25
|
save <name>
|
|
24
26
|
use <name>
|
|
25
27
|
remove <name>
|
|
@@ -101,6 +103,7 @@ function detectConfigPath(cliPath) {
|
|
|
101
103
|
const home = os.homedir();
|
|
102
104
|
const candidates = [
|
|
103
105
|
path.join(home, ".wrangler", "config", "default.toml"),
|
|
106
|
+
path.join(home, "Library", "Preferences", ".wrangler", "config", "default.toml"),
|
|
104
107
|
path.join(home, ".config", ".wrangler", "config", "default.toml"),
|
|
105
108
|
path.join(home, ".config", "wrangler", "config", "default.toml"),
|
|
106
109
|
];
|
|
@@ -232,6 +235,16 @@ function saveProfile(name, configPath, profilesDir, force) {
|
|
|
232
235
|
writeMeta(profileDir, name, configPath);
|
|
233
236
|
}
|
|
234
237
|
|
|
238
|
+
function runWranglerLogin() {
|
|
239
|
+
const result = spawnSync("wrangler", ["login"], { stdio: "inherit" });
|
|
240
|
+
if (result.error) {
|
|
241
|
+
die(`Failed to run 'wrangler login': ${result.error.message}`);
|
|
242
|
+
}
|
|
243
|
+
if (result.status !== 0) {
|
|
244
|
+
die(`'wrangler login' exited with code ${result.status}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
235
248
|
function useProfile(name, configPath, profilesDir, backup) {
|
|
236
249
|
if (!isValidName(name)) {
|
|
237
250
|
die(`Invalid profile name: ${name}`);
|
|
@@ -329,6 +342,19 @@ function main() {
|
|
|
329
342
|
return;
|
|
330
343
|
}
|
|
331
344
|
|
|
345
|
+
if (command === "login") {
|
|
346
|
+
const name = rest[1];
|
|
347
|
+
if (!name) die("Missing profile name for login");
|
|
348
|
+
ensureDir(profilesDir);
|
|
349
|
+
runWranglerLogin();
|
|
350
|
+
if (!fs.existsSync(configPath)) {
|
|
351
|
+
die(`Config file not found after login: ${configPath}`);
|
|
352
|
+
}
|
|
353
|
+
saveProfile(name, configPath, profilesDir, opts.force);
|
|
354
|
+
console.log(`Logged in and saved profile '${name}' from ${configPath}`);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
|
|
332
358
|
if (command === "use") {
|
|
333
359
|
const name = rest[1];
|
|
334
360
|
if (!name) die("Missing profile name for use");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leeguoo/wrangler-accounts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Local CLI to manage multiple Cloudflare Wrangler login profiles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/leeguooooo/wrangler-accounts.git"
|
|
20
|
+
"url": "git+https://github.com/leeguooooo/wrangler-accounts.git"
|
|
21
21
|
},
|
|
22
22
|
"bugs": {
|
|
23
23
|
"url": "https://github.com/leeguooooo/wrangler-accounts/issues"
|