@lvnt/release-radar-cli 0.2.10 → 0.2.12

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
@@ -7,7 +7,7 @@ import { DownloadTracker } from './tracker.js';
7
7
  import { loadVersions } from './versions.js';
8
8
  import { checkAndUpdate } from './updater.js';
9
9
  import { downloadFile, updateNpmPackage } from './downloader.js';
10
- import { promptSetup, promptToolSelection } from './ui.js';
10
+ import { promptSetup, promptToolSelection, renderTable } from './ui.js';
11
11
  import { isNpmTool } from './types.js';
12
12
  function getVersion() {
13
13
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -52,24 +52,27 @@ async function showStatus() {
52
52
  const versions = loadVersions();
53
53
  const downloaded = tracker.getAll();
54
54
  console.log(chalk.bold('\nTool Status:\n'));
55
- console.log(chalk.bold(' Tool Latest Downloaded Status Type'));
56
- console.log(chalk.gray('─'.repeat(70)));
57
- for (const tool of versions.tools) {
55
+ const rows = versions.tools.map(tool => {
58
56
  const record = downloaded[tool.name];
59
- const downloadedVersion = record?.version ?? '-';
60
57
  let status;
61
58
  if (!record) {
62
- status = chalk.blue('NEW');
59
+ status = 'new';
63
60
  }
64
61
  else if (record.version !== tool.version) {
65
- status = chalk.yellow('UPDATE');
62
+ status = 'update';
66
63
  }
67
64
  else {
68
- status = chalk.green('');
65
+ status = 'current';
69
66
  }
70
- const typeStr = isNpmTool(tool) ? chalk.magenta('npm') : chalk.cyan('wget');
71
- console.log(` ${tool.displayName.padEnd(18)} ${tool.version.padEnd(12)} ${downloadedVersion.padEnd(12)} ${status.padEnd(12)} ${typeStr}`);
72
- }
67
+ return {
68
+ displayName: tool.displayName,
69
+ version: tool.version,
70
+ downloadedVersion: record?.version ?? '-',
71
+ status,
72
+ type: isNpmTool(tool) ? 'npm' : 'download',
73
+ };
74
+ });
75
+ renderTable(rows);
73
76
  console.log('');
74
77
  }
75
78
  async function runConfig() {
package/dist/ui.d.ts CHANGED
@@ -20,5 +20,13 @@ interface ToolChoiceNpm extends ToolChoiceBase {
20
20
  package: string;
21
21
  }
22
22
  export type ToolChoice = ToolChoiceDownload | ToolChoiceNpm;
23
+ export interface TableRow {
24
+ displayName: string;
25
+ version: string;
26
+ downloadedVersion: string;
27
+ status: 'new' | 'update' | 'current';
28
+ type: 'npm' | 'download';
29
+ }
30
+ export declare function renderTable(rows: TableRow[]): void;
23
31
  export declare function promptToolSelection(tools: VersionsJsonTool[], downloaded: DownloadedState, generatedAt: string): Promise<ToolChoice[]>;
24
32
  export {};
package/dist/ui.js CHANGED
@@ -94,17 +94,28 @@ function createToolChoice(tool, downloaded) {
94
94
  };
95
95
  }
96
96
  }
97
- export async function promptToolSelection(tools, downloaded, generatedAt) {
98
- const choices = tools.map((tool) => createToolChoice(tool, downloaded));
99
- console.log(chalk.bold(`\nrelease-radar-cli`));
100
- console.log(chalk.gray(`Last updated: ${new Date(generatedAt).toLocaleString()}\n`));
101
- // Display table
102
- console.log(chalk.bold(' Tool Latest Downloaded Status Type'));
103
- console.log(chalk.gray('─'.repeat(70)));
104
- choices.forEach((choice) => {
105
- const downloadedStr = choice.downloadedVersion ?? '-';
97
+ export function renderTable(rows) {
98
+ // Calculate dynamic column widths
99
+ const colWidths = {
100
+ tool: Math.max(4, ...rows.map(r => r.displayName.length)) + 2,
101
+ latest: Math.max(6, ...rows.map(r => r.version.length)) + 2,
102
+ downloaded: Math.max(10, ...rows.map(r => r.downloadedVersion.length)) + 2,
103
+ status: 8,
104
+ type: 4,
105
+ };
106
+ const totalWidth = colWidths.tool + colWidths.latest + colWidths.downloaded + colWidths.status + colWidths.type + 2;
107
+ // Header
108
+ console.log(chalk.bold(' ' +
109
+ 'Tool'.padEnd(colWidths.tool) +
110
+ 'Latest'.padEnd(colWidths.latest) +
111
+ 'Downloaded'.padEnd(colWidths.downloaded) +
112
+ 'Status'.padEnd(colWidths.status) +
113
+ 'Type'));
114
+ console.log(chalk.gray('─'.repeat(totalWidth)));
115
+ // Rows
116
+ for (const row of rows) {
106
117
  let statusStr;
107
- switch (choice.status) {
118
+ switch (row.status) {
108
119
  case 'new':
109
120
  statusStr = chalk.blue('NEW');
110
121
  break;
@@ -115,9 +126,28 @@ export async function promptToolSelection(tools, downloaded, generatedAt) {
115
126
  statusStr = chalk.green('✓');
116
127
  break;
117
128
  }
118
- const typeStr = choice.type === 'npm' ? chalk.magenta('npm') : chalk.cyan('wget');
119
- console.log(` ${choice.displayName.padEnd(18)} ${choice.version.padEnd(12)} ${downloadedStr.padEnd(12)} ${statusStr.padEnd(12)} ${typeStr}`);
120
- });
129
+ const typeStr = row.type === 'npm' ? chalk.magenta('npm') : chalk.cyan('wget');
130
+ console.log(' ' +
131
+ row.displayName.padEnd(colWidths.tool) +
132
+ row.version.padEnd(colWidths.latest) +
133
+ row.downloadedVersion.padEnd(colWidths.downloaded) +
134
+ statusStr.padEnd(colWidths.status + 5) + // +5 for chalk color codes
135
+ typeStr);
136
+ }
137
+ }
138
+ export async function promptToolSelection(tools, downloaded, generatedAt) {
139
+ const choices = tools.map((tool) => createToolChoice(tool, downloaded));
140
+ console.log(chalk.bold(`\nrelease-radar-cli`));
141
+ console.log(chalk.gray(`Last updated: ${new Date(generatedAt).toLocaleString()}\n`));
142
+ // Convert to table rows and display
143
+ const rows = choices.map(choice => ({
144
+ displayName: choice.displayName,
145
+ version: choice.version,
146
+ downloadedVersion: choice.downloadedVersion ?? '-',
147
+ status: choice.status,
148
+ type: choice.type === 'npm' ? 'npm' : 'download',
149
+ }));
150
+ renderTable(rows);
121
151
  console.log('');
122
152
  const { selected } = await inquirer.prompt([
123
153
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvnt/release-radar-cli",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "Interactive CLI for downloading tools through Nexus proxy",
5
5
  "main": "dist/index.js",
6
6
  "bin": {