@leeguoo/wrangler-accounts 1.6.2 → 1.6.3

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.
@@ -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",
@@ -604,10 +606,11 @@ function main() {
604
606
  type,
605
607
  isDefault: name === defaultName,
606
608
  isActive: name === activeName,
607
- status: session.effective, // 'valid' | 'refreshable' | 'expired' | 'unknown'
609
+ status: session.effective, // 'valid' | 'refreshable' | 'expired' | 'unknown' | 'token'
608
610
  expirationTime: session.expirationTime,
609
611
  hasRefreshToken: session.hasRefreshToken,
610
612
  identity,
613
+ description: (meta && meta.description) || null,
611
614
  verified: null,
612
615
  verifyError: null,
613
616
  };
@@ -690,11 +693,14 @@ function main() {
690
693
  : e.verified === false ? `✗ ${e.verifyError || "failed"}`
691
694
  : "—",
692
695
  identity: e.identity ? describeIdentity(e.identity) : "(no identity)",
696
+ note: e.description || "",
693
697
  }));
698
+ const hasNotes = rows.some((r) => r.note);
694
699
  const nameW = Math.max(4, ...rows.map((r) => r.name.length));
695
700
  const statusW = Math.max(6, ...rows.map((r) => r.status.length));
696
701
  const expiresW = Math.max(7, ...rows.map((r) => r.expires.length));
697
702
  const verifiedW = Math.max(8, ...rows.map((r) => r.verified.length));
703
+ const noteW = hasNotes ? Math.max(4, ...rows.map((r) => r.note.length)) : 0;
698
704
 
699
705
  let header;
700
706
  if (opts.deep) {
@@ -702,17 +708,17 @@ function main() {
702
708
  } else {
703
709
  header = ` ${"NAME".padEnd(nameW)} ${"STATUS".padEnd(statusW)} ${"EXPIRES".padEnd(expiresW)} IDENTITY`;
704
710
  }
711
+ if (hasNotes) header += ` NOTE`;
705
712
  console.log(header);
706
713
  for (const r of rows) {
714
+ let line;
707
715
  if (opts.deep) {
708
- console.log(
709
- `${r.marker} ${r.name.padEnd(nameW)} ${r.status.padEnd(statusW)} ${r.expires.padEnd(expiresW)} ${r.verified.padEnd(verifiedW)} ${r.identity}`,
710
- );
716
+ line = `${r.marker} ${r.name.padEnd(nameW)} ${r.status.padEnd(statusW)} ${r.expires.padEnd(expiresW)} ${r.verified.padEnd(verifiedW)} ${r.identity}`;
711
717
  } else {
712
- console.log(
713
- `${r.marker} ${r.name.padEnd(nameW)} ${r.status.padEnd(statusW)} ${r.expires.padEnd(expiresW)} ${r.identity}`,
714
- );
718
+ line = `${r.marker} ${r.name.padEnd(nameW)} ${r.status.padEnd(statusW)} ${r.expires.padEnd(expiresW)} ${r.identity}`;
715
719
  }
720
+ if (hasNotes) line += ` ${r.note}`;
721
+ console.log(line);
716
722
  }
717
723
  console.log();
718
724
  if (opts.deep) {
@@ -864,6 +870,36 @@ function main() {
864
870
  return;
865
871
  }
866
872
 
873
+ if (command === "note") {
874
+ const name = rest[1];
875
+ if (!name) die("Usage: wrangler-accounts note <name> [<text>] [--clear]");
876
+ if (!isValidName(name)) die(`Invalid profile name: ${name}`);
877
+ const profileDir = path.join(profilesDir, name);
878
+ if (!fs.existsSync(profileDir)) die(`Profile not found: ${name}`);
879
+
880
+ if (opts.clear) {
881
+ setProfileNoteImpl(profilesDir, name, null);
882
+ console.log(`Note cleared for profile '${name}'.`);
883
+ } else {
884
+ // Everything after the name is the note text
885
+ const noteText = rest.slice(2).join(" ").trim();
886
+ if (!noteText) {
887
+ // No text supplied — show current note
888
+ const meta = readMeta(profileDir);
889
+ const note = meta && meta.description;
890
+ if (note) {
891
+ console.log(note);
892
+ } else {
893
+ console.log(`(no note set for '${name}')`);
894
+ }
895
+ } else {
896
+ setProfileNoteImpl(profilesDir, name, noteText);
897
+ console.log(`Note set for profile '${name}'.`);
898
+ }
899
+ }
900
+ return;
901
+ }
902
+
867
903
  if (command === "login") {
868
904
  const name = rest[1];
869
905
  if (!name) die("Missing profile name for login");
@@ -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.2",
3
+ "version": "1.6.3",
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": {