@leeguoo/wrangler-accounts 1.6.2 → 1.6.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/bin/wrangler-accounts.js +51 -7
- package/lib/profile-store.js +22 -0
- package/package.json +1 -1
package/bin/wrangler-accounts.js
CHANGED
|
@@ -37,6 +37,7 @@ const {
|
|
|
37
37
|
saveProfile: saveProfileImpl,
|
|
38
38
|
saveTokenProfile: saveTokenProfileImpl,
|
|
39
39
|
readTokenCredentials,
|
|
40
|
+
setProfileNote: setProfileNoteImpl,
|
|
40
41
|
removeProfile: removeProfileImpl,
|
|
41
42
|
} = require("../lib/profile-store");
|
|
42
43
|
const {
|
|
@@ -67,6 +68,7 @@ const MANAGEMENT_SUBCOMMANDS = new Set([
|
|
|
67
68
|
"remove",
|
|
68
69
|
"default",
|
|
69
70
|
"token-add",
|
|
71
|
+
"note",
|
|
70
72
|
"whoami",
|
|
71
73
|
"gc",
|
|
72
74
|
"use",
|
|
@@ -374,6 +376,14 @@ function parseArgs(argv) {
|
|
|
374
376
|
// forwarded to wrangler verbatim (including wrangler's own --env,
|
|
375
377
|
// --json, etc.).
|
|
376
378
|
if (sawFirstNonFlag && !sawManagementSubcommand) {
|
|
379
|
+
// --profile / -p must not be forwarded to wrangler; absorb it here so
|
|
380
|
+
// users can write it after the wrangler subcommand:
|
|
381
|
+
// wrangler-accounts deploy --config wrangler.prod.toml --profile myprof
|
|
382
|
+
if ((arg === "--profile" || arg === "-p") && i + 1 < argv.length) {
|
|
383
|
+
opts.profile = argv[i + 1];
|
|
384
|
+
i += 1;
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
377
387
|
rest.push(arg);
|
|
378
388
|
continue;
|
|
379
389
|
}
|
|
@@ -604,10 +614,11 @@ function main() {
|
|
|
604
614
|
type,
|
|
605
615
|
isDefault: name === defaultName,
|
|
606
616
|
isActive: name === activeName,
|
|
607
|
-
status: session.effective, // 'valid' | 'refreshable' | 'expired' | 'unknown'
|
|
617
|
+
status: session.effective, // 'valid' | 'refreshable' | 'expired' | 'unknown' | 'token'
|
|
608
618
|
expirationTime: session.expirationTime,
|
|
609
619
|
hasRefreshToken: session.hasRefreshToken,
|
|
610
620
|
identity,
|
|
621
|
+
description: (meta && meta.description) || null,
|
|
611
622
|
verified: null,
|
|
612
623
|
verifyError: null,
|
|
613
624
|
};
|
|
@@ -690,11 +701,14 @@ function main() {
|
|
|
690
701
|
: e.verified === false ? `✗ ${e.verifyError || "failed"}`
|
|
691
702
|
: "—",
|
|
692
703
|
identity: e.identity ? describeIdentity(e.identity) : "(no identity)",
|
|
704
|
+
note: e.description || "",
|
|
693
705
|
}));
|
|
706
|
+
const hasNotes = rows.some((r) => r.note);
|
|
694
707
|
const nameW = Math.max(4, ...rows.map((r) => r.name.length));
|
|
695
708
|
const statusW = Math.max(6, ...rows.map((r) => r.status.length));
|
|
696
709
|
const expiresW = Math.max(7, ...rows.map((r) => r.expires.length));
|
|
697
710
|
const verifiedW = Math.max(8, ...rows.map((r) => r.verified.length));
|
|
711
|
+
const noteW = hasNotes ? Math.max(4, ...rows.map((r) => r.note.length)) : 0;
|
|
698
712
|
|
|
699
713
|
let header;
|
|
700
714
|
if (opts.deep) {
|
|
@@ -702,17 +716,17 @@ function main() {
|
|
|
702
716
|
} else {
|
|
703
717
|
header = ` ${"NAME".padEnd(nameW)} ${"STATUS".padEnd(statusW)} ${"EXPIRES".padEnd(expiresW)} IDENTITY`;
|
|
704
718
|
}
|
|
719
|
+
if (hasNotes) header += ` NOTE`;
|
|
705
720
|
console.log(header);
|
|
706
721
|
for (const r of rows) {
|
|
722
|
+
let line;
|
|
707
723
|
if (opts.deep) {
|
|
708
|
-
|
|
709
|
-
`${r.marker} ${r.name.padEnd(nameW)} ${r.status.padEnd(statusW)} ${r.expires.padEnd(expiresW)} ${r.verified.padEnd(verifiedW)} ${r.identity}`,
|
|
710
|
-
);
|
|
724
|
+
line = `${r.marker} ${r.name.padEnd(nameW)} ${r.status.padEnd(statusW)} ${r.expires.padEnd(expiresW)} ${r.verified.padEnd(verifiedW)} ${r.identity}`;
|
|
711
725
|
} else {
|
|
712
|
-
|
|
713
|
-
`${r.marker} ${r.name.padEnd(nameW)} ${r.status.padEnd(statusW)} ${r.expires.padEnd(expiresW)} ${r.identity}`,
|
|
714
|
-
);
|
|
726
|
+
line = `${r.marker} ${r.name.padEnd(nameW)} ${r.status.padEnd(statusW)} ${r.expires.padEnd(expiresW)} ${r.identity}`;
|
|
715
727
|
}
|
|
728
|
+
if (hasNotes) line += ` ${r.note}`;
|
|
729
|
+
console.log(line);
|
|
716
730
|
}
|
|
717
731
|
console.log();
|
|
718
732
|
if (opts.deep) {
|
|
@@ -864,6 +878,36 @@ function main() {
|
|
|
864
878
|
return;
|
|
865
879
|
}
|
|
866
880
|
|
|
881
|
+
if (command === "note") {
|
|
882
|
+
const name = rest[1];
|
|
883
|
+
if (!name) die("Usage: wrangler-accounts note <name> [<text>] [--clear]");
|
|
884
|
+
if (!isValidName(name)) die(`Invalid profile name: ${name}`);
|
|
885
|
+
const profileDir = path.join(profilesDir, name);
|
|
886
|
+
if (!fs.existsSync(profileDir)) die(`Profile not found: ${name}`);
|
|
887
|
+
|
|
888
|
+
if (opts.clear) {
|
|
889
|
+
setProfileNoteImpl(profilesDir, name, null);
|
|
890
|
+
console.log(`Note cleared for profile '${name}'.`);
|
|
891
|
+
} else {
|
|
892
|
+
// Everything after the name is the note text
|
|
893
|
+
const noteText = rest.slice(2).join(" ").trim();
|
|
894
|
+
if (!noteText) {
|
|
895
|
+
// No text supplied — show current note
|
|
896
|
+
const meta = readMeta(profileDir);
|
|
897
|
+
const note = meta && meta.description;
|
|
898
|
+
if (note) {
|
|
899
|
+
console.log(note);
|
|
900
|
+
} else {
|
|
901
|
+
console.log(`(no note set for '${name}')`);
|
|
902
|
+
}
|
|
903
|
+
} else {
|
|
904
|
+
setProfileNoteImpl(profilesDir, name, noteText);
|
|
905
|
+
console.log(`Note set for profile '${name}'.`);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
|
|
867
911
|
if (command === "login") {
|
|
868
912
|
const name = rest[1];
|
|
869
913
|
if (!name) die("Missing profile name for login");
|
package/lib/profile-store.js
CHANGED
|
@@ -285,6 +285,27 @@ function readTokenSessionState() {
|
|
|
285
285
|
};
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Set or clear the human-readable note for a profile.
|
|
290
|
+
* Stored as `description` inside meta.json. Pass null/empty to clear.
|
|
291
|
+
*/
|
|
292
|
+
function setProfileNote(profilesDir, name, note) {
|
|
293
|
+
if (!isValidName(name)) {
|
|
294
|
+
throw new Error(`Invalid profile name: ${name}`);
|
|
295
|
+
}
|
|
296
|
+
const profileDir = path.join(profilesDir, name);
|
|
297
|
+
if (!fs.existsSync(profileDir)) {
|
|
298
|
+
throw new Error(`Profile not found: ${name}`);
|
|
299
|
+
}
|
|
300
|
+
const meta = readMeta(profileDir) || { name };
|
|
301
|
+
if (note && note.trim()) {
|
|
302
|
+
meta.description = note.trim();
|
|
303
|
+
} else {
|
|
304
|
+
delete meta.description;
|
|
305
|
+
}
|
|
306
|
+
fs.writeFileSync(path.join(profileDir, 'meta.json'), JSON.stringify(meta, null, 2));
|
|
307
|
+
}
|
|
308
|
+
|
|
288
309
|
function removeProfile(name, profilesDir) {
|
|
289
310
|
if (!isValidName(name)) {
|
|
290
311
|
throw new Error(`Invalid profile name: ${name}`);
|
|
@@ -327,5 +348,6 @@ module.exports = {
|
|
|
327
348
|
saveProfile,
|
|
328
349
|
saveTokenProfile,
|
|
329
350
|
readTokenCredentials,
|
|
351
|
+
setProfileNote,
|
|
330
352
|
removeProfile,
|
|
331
353
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leeguoo/wrangler-accounts",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
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": {
|