playcademy 0.8.0 → 0.9.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.
package/dist/index.js CHANGED
@@ -9280,9 +9280,40 @@ function customTransform(text2) {
9280
9280
  const highlightCode = (text3) => text3.replace(/`([^`]+)`/g, (_, code) => greenBright(code));
9281
9281
  return highlightCode(text2);
9282
9282
  }
9283
+ function formatTable(data, title) {
9284
+ if (data.length === 0) return;
9285
+ const keys = Object.keys(data[0]);
9286
+ const rows = data.map((item) => keys.map((key) => String(item[key] ?? "")));
9287
+ const widths = keys.map((key, i) => {
9288
+ const headerWidth = key.length;
9289
+ const dataWidth = Math.max(...rows.map((row) => row[i].length));
9290
+ return Math.max(headerWidth, dataWidth);
9291
+ });
9292
+ const totalWidth = widths.reduce((sum, w) => sum + w + 3, -1);
9293
+ const separator = "\u251C" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u253C") + "\u2524";
9294
+ const topBorder = "\u250C" + "\u2500".repeat(totalWidth) + "\u2510";
9295
+ const titleSeparator = "\u251C" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u252C") + "\u2524";
9296
+ const bottomBorder = "\u2514" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u2534") + "\u2518";
9297
+ console.log(topBorder);
9298
+ if (title) {
9299
+ const titleText = bold(title);
9300
+ const titlePadding = totalWidth - title.length - 1;
9301
+ const titleRow = "\u2502 " + titleText + " ".repeat(titlePadding) + "\u2502";
9302
+ console.log(titleRow);
9303
+ console.log(titleSeparator);
9304
+ }
9305
+ const header = "\u2502 " + keys.map((key, i) => key.padEnd(widths[i])).join(" \u2502 ") + " \u2502";
9306
+ console.log(header);
9307
+ console.log(separator);
9308
+ rows.forEach((row) => {
9309
+ const dataRow = "\u2502 " + row.map((cell, i) => cell.padEnd(widths[i])).join(" \u2502 ") + " \u2502";
9310
+ console.log(dataRow);
9311
+ });
9312
+ console.log(bottomBorder);
9313
+ }
9283
9314
  var logger = {
9284
- table: (data) => {
9285
- console.table(data);
9315
+ table: (data, title) => {
9316
+ formatTable(data, title);
9286
9317
  },
9287
9318
  /**
9288
9319
  * Info message - general information
@@ -11537,8 +11568,8 @@ var loginCommand = new Command4("login").description("Authenticate with Playcade
11537
11568
  const email2 = existingProfile.email || "unknown user";
11538
11569
  const otherEnv = environment === "staging" ? "production" : "staging";
11539
11570
  const otherProfile = await getProfile(otherEnv, profileName);
11540
- logger.admonition("note", "I know you!", [
11541
- "You are already logged in",
11571
+ logger.admonition("note", "Hello again", [
11572
+ bold4("You're already logged in"),
11542
11573
  "",
11543
11574
  dim6("Email: ") + bold4(email2),
11544
11575
  dim6("Environment: ") + bold4(environment),
@@ -12210,7 +12241,6 @@ async function listProfilesAction() {
12210
12241
  }
12211
12242
  for (const [environment, profiles] of profilesMap.entries()) {
12212
12243
  if (profiles.length === 0) continue;
12213
- logger.highlight(`${environment.charAt(0).toUpperCase() + environment.slice(1)}:`);
12214
12244
  const tableData = [];
12215
12245
  for (const profileName of profiles) {
12216
12246
  const profile = await getProfile(environment, profileName);
@@ -12220,7 +12250,8 @@ async function listProfilesAction() {
12220
12250
  });
12221
12251
  }
12222
12252
  if (tableData.length > 0) {
12223
- logger.table(tableData);
12253
+ const envTitle = environment.charAt(0).toUpperCase() + environment.slice(1);
12254
+ logger.table(tableData, envTitle);
12224
12255
  logger.newLine();
12225
12256
  }
12226
12257
  }
@@ -12289,15 +12320,19 @@ var resetCommand = new Command16("reset").description(
12289
12320
  logger.newLine();
12290
12321
  for (const [environment, profiles] of profilesMap.entries()) {
12291
12322
  if (profiles.length === 0) continue;
12292
- logger.highlight(
12293
- `${environment.charAt(0).toUpperCase() + environment.slice(1)}:`,
12294
- 1
12295
- );
12323
+ const tableData = [];
12296
12324
  for (const profileName of profiles) {
12297
12325
  const profile = await getProfile(environment, profileName);
12298
- logger.data(profileName, profile?.email || "", 2);
12326
+ tableData.push({
12327
+ Profile: profileName,
12328
+ Email: profile?.email ?? ""
12329
+ });
12330
+ }
12331
+ if (tableData.length > 0) {
12332
+ const envTitle = environment.charAt(0).toUpperCase() + environment.slice(1);
12333
+ logger.table(tableData, envTitle);
12334
+ logger.newLine();
12299
12335
  }
12300
- logger.newLine();
12301
12336
  }
12302
12337
  const confirmed = await confirm6({
12303
12338
  message: "Are you sure you want to remove all profiles?",
package/dist/utils.js CHANGED
@@ -6503,9 +6503,40 @@ function customTransform(text2) {
6503
6503
  const highlightCode = (text3) => text3.replace(/`([^`]+)`/g, (_, code) => greenBright(code));
6504
6504
  return highlightCode(text2);
6505
6505
  }
6506
+ function formatTable(data, title) {
6507
+ if (data.length === 0) return;
6508
+ const keys = Object.keys(data[0]);
6509
+ const rows = data.map((item) => keys.map((key) => String(item[key] ?? "")));
6510
+ const widths = keys.map((key, i) => {
6511
+ const headerWidth = key.length;
6512
+ const dataWidth = Math.max(...rows.map((row) => row[i].length));
6513
+ return Math.max(headerWidth, dataWidth);
6514
+ });
6515
+ const totalWidth = widths.reduce((sum, w) => sum + w + 3, -1);
6516
+ const separator = "\u251C" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u253C") + "\u2524";
6517
+ const topBorder = "\u250C" + "\u2500".repeat(totalWidth) + "\u2510";
6518
+ const titleSeparator = "\u251C" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u252C") + "\u2524";
6519
+ const bottomBorder = "\u2514" + widths.map((w) => "\u2500".repeat(w + 2)).join("\u2534") + "\u2518";
6520
+ console.log(topBorder);
6521
+ if (title) {
6522
+ const titleText = bold(title);
6523
+ const titlePadding = totalWidth - title.length - 1;
6524
+ const titleRow = "\u2502 " + titleText + " ".repeat(titlePadding) + "\u2502";
6525
+ console.log(titleRow);
6526
+ console.log(titleSeparator);
6527
+ }
6528
+ const header = "\u2502 " + keys.map((key, i) => key.padEnd(widths[i])).join(" \u2502 ") + " \u2502";
6529
+ console.log(header);
6530
+ console.log(separator);
6531
+ rows.forEach((row) => {
6532
+ const dataRow = "\u2502 " + row.map((cell, i) => cell.padEnd(widths[i])).join(" \u2502 ") + " \u2502";
6533
+ console.log(dataRow);
6534
+ });
6535
+ console.log(bottomBorder);
6536
+ }
6506
6537
  var logger = {
6507
- table: (data) => {
6508
- console.table(data);
6538
+ table: (data, title) => {
6539
+ formatTable(data, title);
6509
6540
  },
6510
6541
  /**
6511
6542
  * Info message - general information
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playcademy",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "module": "./dist/index.js",
6
6
  "exports": {