@leeguoo/wrangler-accounts 1.0.1 → 1.1.0

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.
@@ -408,15 +408,66 @@ function main() {
408
408
 
409
409
  if (command === "list") {
410
410
  const profiles = listProfiles(profilesDir, { includeBackups });
411
+ const defaultName = getDefaultProfile(profilesDir);
412
+ const activeName = getActiveProfile(profilesDir);
413
+
414
+ const entries = profiles.map((name) => {
415
+ const profileDir = path.join(profilesDir, name);
416
+ const cfgPath = path.join(profileDir, "config.toml");
417
+ const session = readSessionState(cfgPath);
418
+ const meta = readMeta(profileDir);
419
+ const identity = getMetaIdentity(meta);
420
+ let status;
421
+ if (session.expired === true) status = "expired";
422
+ else if (session.expired === false) status = "valid";
423
+ else status = "unknown";
424
+ return {
425
+ name,
426
+ isDefault: name === defaultName,
427
+ isActive: name === activeName,
428
+ status,
429
+ expirationTime: session.expirationTime,
430
+ identity,
431
+ };
432
+ });
433
+
434
+ if (opts.plain) {
435
+ // --plain keeps the v1.0 contract: one name per line, scriptable.
436
+ if (entries.length) console.log(entries.map((e) => e.name).join("\n"));
437
+ return;
438
+ }
439
+
411
440
  if (opts.json) {
412
- console.log(JSON.stringify(profiles, null, 2));
413
- } else if (opts.plain) {
414
- if (profiles.length) console.log(profiles.join("\n"));
415
- } else if (profiles.length === 0) {
441
+ console.log(JSON.stringify(entries, null, 2));
442
+ return;
443
+ }
444
+
445
+ // Text output: human-friendly table with status markers.
446
+ if (entries.length === 0) {
416
447
  console.log("No profiles found.");
417
- } else {
418
- console.log(profiles.join("\n"));
448
+ return;
419
449
  }
450
+ if (defaultName) console.log(`Default: ${defaultName}\n`);
451
+ const nameW = Math.max(4, ...entries.map((e) => e.name.length));
452
+ const statusW = 8; // fits 'expired', 'valid', 'unknown'
453
+ const header = ` ${"NAME".padEnd(nameW)} ${"STATUS".padEnd(statusW)} IDENTITY`;
454
+ console.log(header);
455
+ for (const e of entries) {
456
+ const marker = e.isDefault ? "*" : " ";
457
+ const statusLabel =
458
+ e.status === "expired" ? "EXPIRED"
459
+ : e.status === "valid" ? "valid"
460
+ : "unknown";
461
+ const idStr = e.identity ? describeIdentity(e.identity) : "(no identity)";
462
+ const exp = e.expirationTime ? ` (${e.expirationTime})` : "";
463
+ console.log(
464
+ `${marker} ${e.name.padEnd(nameW)} ${statusLabel.padEnd(statusW)} ${idStr}${e.status === "expired" ? exp : ""}`,
465
+ );
466
+ }
467
+ console.log();
468
+ console.log(
469
+ `Legend: * = default profile, EXPIRED = OAuth session needs 'wrangler-accounts login <name>'`,
470
+ );
420
471
  return;
421
472
  }
422
473
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leeguoo/wrangler-accounts",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "AWS-style multi-account convenience for Cloudflare Wrangler — per-invocation OAuth isolation via shadow HOME.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -34,7 +34,9 @@
34
34
  "access": "public"
35
35
  },
36
36
  "scripts": {
37
- "test": "node --test test/*.test.js"
37
+ "test": "node --test test/*.test.js",
38
+ "verify-package": "node scripts/verify-package.js",
39
+ "prepublishOnly": "npm test && npm run verify-package"
38
40
  },
39
41
  "engines": {
40
42
  "node": ">=16"