Skip to content

Commit 81ed997

Browse files
committed
Add registry URL column to dependency updates table
1 parent ba769ed commit 81ed997

File tree

4 files changed

+62
-135
lines changed

4 files changed

+62
-135
lines changed

apps/api/src/app/playground/playground.service.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -195,22 +195,8 @@ export class PlaygroundService {
195195
// Check if this is a special message type and set type accordingly
196196
let messageType = type;
197197

198-
// Log all messages that contain "branch" to debug
199-
if (parsedLine.msg && typeof parsedLine.msg === 'string' && parsedLine.msg.toLowerCase().includes('branch')) {
200-
this.logger.log(`[Backend] Branch-related messages: "${parsedLine.msg}"`);
201-
this.logger.log(`[Backend] Has branchesInformation field: ${!!parsedLine.branchesInformation}`);
202-
}
203-
204-
205198
if (parsedLine.msg === 'packageFiles with updates' && parsedLine.config) {
206-
this.logger.debug('✅ Backend: Found packageFiles with updates');
207199
messageType = 'packageFilesWithUpdates';
208-
} else if (parsedLine.msg === 'packageFiles' && parsedLine.packageFiles) {
209-
this.logger.debug('✅ Backend: Found packageFiles');
210-
messageType = 'packageFiles';
211-
} else if (parsedLine.msg === 'branches info extended' && parsedLine.branchesInformation) {
212-
this.logger.log(`✅ Backend: Found branches info extended with ${parsedLine.branchesInformation?.length} branches`);
213-
messageType = 'branchesInfoExtended';
214200
}
215201

216202
// Format the message with timestamp
@@ -220,7 +206,8 @@ export class PlaygroundService {
220206
original: line,
221207
time: timestamp,
222208
msg: parsedLine.msg || '',
223-
level: parsedLine.level || 'info'
209+
level: parsedLine.level || 'info',
210+
...(parsedLine.config && { config: parsedLine.config })
224211
},
225212
type: messageType
226213
};

apps/ui/src/app/playground/playground.component.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ <h2 class="text-xl font-semibold mb-2">Discovered Dependencies</h2>
6464
<th>Dependency</th>
6565
<th>Current Version</th>
6666
<th>New Version</th>
67+
<th>Registry URL</th>
6768
<th>Status</th>
6869
</tr>
6970
</thead>
@@ -73,14 +74,21 @@ <h2 class="text-xl font-semibold mb-2">Discovered Dependencies</h2>
7374
<td>{{ dep.name }}</td>
7475
<td>{{ dep.currentVersion }}</td>
7576
<td>{{ dep.newVersion }}</td>
77+
<td>
78+
<a *ngIf="dep.registryUrl" [href]="dep.registryUrl" target="_blank" rel="noopener noreferrer" class="text-decoration-none">
79+
{{ dep.registryUrl }}
80+
<i class="bi bi-box-arrow-up-right ms-1"></i>
81+
</a>
82+
<span *ngIf="!dep.registryUrl" class="text-muted">N/A</span>
83+
</td>
7684
<td>
7785
<span *ngIf="dep.status === 'discovered'" class="badge bg-info">Discovered</span>
7886
<span *ngIf="dep.status === 'update-available'" class="badge bg-success">Update Available</span>
7987
<span *ngIf="!dep.status" class="badge bg-secondary">Unknown</span>
8088
</td>
8189
</tr>
8290
<tr *ngIf="dependencies.length === 0">
83-
<td colspan="5" class="text-center">No dependencies updated yet.</td>
91+
<td colspan="6" class="text-center">No dependencies updated yet.</td>
8492
</tr>
8593
</tbody>
8694
</table>

apps/ui/src/app/playground/playground.component.ts

Lines changed: 51 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface Dependency {
1212
manager?: string;
1313
depType?: string;
1414
status?: 'discovered' | 'update-available';
15+
registryUrl?: string;
1516
}
1617

1718
// Define the LogEntry interface for displaying logs with time
@@ -90,9 +91,6 @@ export class PlaygroundComponent implements OnInit, AfterViewChecked, OnDestroy
9091
next: (logMessage: RenovateLogMessage) => {
9192
// Run inside Angular zone to trigger change detection
9293
this.ngZone.run(() => {
93-
console.log('Received log message:', logMessage);
94-
console.log('Received log message:', logMessage);
95-
9694
// Create a log entry from the message
9795
const logEntry: LogEntry = {
9896
message: logMessage.msg || '',
@@ -106,17 +104,6 @@ export class PlaygroundComponent implements OnInit, AfterViewChecked, OnDestroy
106104
// Process packageFiles if present
107105
if (logMessage.type === 'packageFilesWithUpdates' && logMessage.config) {
108106
this.processPackageFilesWithUpdates(logMessage.config);
109-
} else if (logMessage.type === 'packageFiles' && logMessage.packageFiles) {
110-
this.processPackageFiles(logMessage.packageFiles);
111-
} else if (logMessage.type === 'branchesInfoExtended' && logMessage.branchesInformation) {
112-
// TODO: Replace with proper logging mechanism if needed
113-
this.processBranchesInfoExtended(logMessage.branchesInformation);
114-
} else if (logMessage.msg === 'branches info extended' && logMessage.branchesInformation) {
115-
// Fallback: Check msg directly in case type wasn't set
116-
this.processBranchesInfoExtended(logMessage.branchesInformation);
117-
} else {
118-
// Still try the regex-based approach as fallback
119-
this.parseDependencyUpdate(logEntry.message);
120107
}
121108
// Force change detection and scroll to bottom
122109
this.cdr.detectChanges();
@@ -188,122 +175,68 @@ export class PlaygroundComponent implements OnInit, AfterViewChecked, OnDestroy
188175
}
189176
}
190177

191-
private parseDependencyUpdate(log: string): void {
192-
const regex = /Upgrading dependency (\S+) from (\S+) to (\S+)/;
193-
const match = log.match(regex);
194-
195-
if (match) {
196-
const dep: Dependency = {
197-
type: 'npm', // This can be enhanced to detect other types
198-
name: match[1],
199-
currentVersion: match[2],
200-
newVersion: match[3],
201-
};
202-
if (!this.dependencies.some((d) => d.name === dep.name && d.newVersion === dep.newVersion)) {
203-
this.dependencies.push(dep);
204-
}
205-
}
206-
}
207-
208-
private processPackageFiles(packageFiles: unknown): void {
209-
if (!packageFiles || !Array.isArray(packageFiles)) {
210-
return;
211-
}
212-
213-
// Process each package file
214-
for (const pkgFile of packageFiles) {
215-
if (pkgFile.deps) {
216-
// Process each dependency in the package file
217-
for (const [depName, depInfo] of Object.entries(pkgFile.deps)) {
218-
const dep = depInfo as Record<string, unknown>;
219-
if (dep.updates && Array.isArray(dep.updates) && dep.updates.length > 0) {
220-
// Get the latest update
221-
const update = dep.updates[dep.updates.length - 1] as Record<string, unknown>;
222-
223-
const dependency: Dependency = {
224-
type: pkgFile.manager || 'npm',
225-
name: depName,
226-
currentVersion: (dep.currentVersion as string) || 'unknown',
227-
newVersion: (update.newVersion as string) || 'unknown',
228-
manager: pkgFile.manager,
229-
depType: (dep.depType as string) || undefined
230-
};
231-
232-
// Check if this dependency is already in the array
233-
if (!this.dependencies.some((d) => d.name === dependency.name && d.newVersion === dependency.newVersion)) {
234-
this.dependencies.push(dependency);
235-
}
236-
}
237-
}
238-
}
239-
}
240-
}
241-
242178
private processPackageFilesWithUpdates(config: unknown): void {
243179
const configObj = config as Record<string, unknown>;
244-
if (!configObj || !configObj.regex || !Array.isArray(configObj.regex)) {
245-
return;
246-
}
247-
248-
// Process each regex configuration
249-
for (const regexConfig of configObj.regex) {
250-
if (regexConfig.deps && Array.isArray(regexConfig.deps)) {
251-
// Process each dependency in the regex config
252-
for (const dep of regexConfig.deps) {
253-
if (dep.updates && Array.isArray(dep.updates) && dep.updates.length > 0) {
254-
// Process each update for this dependency
255-
for (const update of dep.updates) {
256-
const dependency: Dependency = {
257-
type: dep.datasource || 'unknown',
258-
name: dep.packageName || dep.depName || 'unknown',
259-
currentVersion: dep.currentVersion || dep.currentValue || 'unknown',
260-
newVersion: update.newVersion || update.newValue || 'unknown',
261-
manager: regexConfig.packageFile ? 'regex' : dep.datasource,
262-
depType: dep.depType || update.updateType
263-
};
264-
265-
this.addOrUpdateDependency(dependency);
180+
181+
// Process all manager types dynamically (npm, regex, docker, maven, etc.)
182+
for (const [managerKey, managerValue] of Object.entries(configObj)) {
183+
if (!Array.isArray(managerValue)) continue;
184+
185+
for (const packageFile of managerValue) {
186+
if (packageFile.deps && Array.isArray(packageFile.deps)) {
187+
for (const dep of packageFile.deps) {
188+
// Check if there are updates for this dependency
189+
if (dep.updates && Array.isArray(dep.updates) && dep.updates.length > 0) {
190+
// Process each update
191+
for (const update of dep.updates) {
192+
const packageName = dep.packageName || dep.depName || 'unknown';
193+
const registryUrl = this.constructFullPackageUrl(
194+
dep.registryUrl || dep.sourceUrl,
195+
packageName,
196+
dep.datasource || managerKey
197+
);
198+
199+
const dependency: Dependency = {
200+
type: dep.datasource || managerKey,
201+
name: packageName,
202+
currentVersion: dep.currentVersion || dep.currentValue || 'unknown',
203+
newVersion: update.newVersion || update.newValue || 'unknown',
204+
manager: packageFile.manager || managerKey,
205+
depType: dep.depType || update.updateType,
206+
status: 'discovered', // Default status for discovered updates
207+
registryUrl: registryUrl
208+
};
209+
210+
this.addOrUpdateDependency(dependency);
211+
}
266212
}
267213
}
268214
}
269215
}
270216
}
271217
}
272218

273-
private processBranchesInfoExtended(branchesInformation: unknown[]): void {
274-
if (!branchesInformation || !Array.isArray(branchesInformation)) {
275-
return;
219+
private constructFullPackageUrl(baseUrl: string | undefined, packageName: string, datasource: string): string | undefined {
220+
if (!baseUrl || !packageName) {
221+
return undefined;
276222
}
277223

278-
// Logging: Starting to process branchesInformation
279-
280-
// Process each branch
281-
for (const branch of branchesInformation) {
282-
const branchObj = branch as Record<string, unknown>;
283-
// Check if upgrades exist
284-
if (branchObj.upgrades && Array.isArray(branchObj.upgrades)) {
285-
// Process each upgrade in the branch
286-
for (const upgrade of branchObj.upgrades) {
287-
const upgradeObj = upgrade as Record<string, unknown>;
288-
const dependency: Dependency = {
289-
type: (upgradeObj.datasource as string) || 'unknown',
290-
name: (upgradeObj.depName as string) || (upgradeObj.packageName as string) || 'unknown',
291-
currentVersion: (upgradeObj.currentVersion as string) || (upgradeObj.fixedVersion as string) || 'unknown',
292-
newVersion: (upgradeObj.newVersion as string) || 'unknown',
293-
manager: upgradeObj.datasource as string,
294-
depType: upgradeObj.updateType as string,
295-
// Set status based on prNo - null means repo is not onboarded yet
296-
status: branchObj.prNo === null ? 'discovered' : 'update-available'
297-
};
298-
299-
this.addOrUpdateDependency(dependency);
300-
// dependencyCount++;
301-
}
302-
}
224+
// Handle different datasource types
225+
switch (datasource) {
226+
case 'npm':
227+
// For npm registries, append the package name
228+
return `${baseUrl}/${packageName}`;
229+
case 'github-tags':
230+
case 'github-releases':
231+
// GitHub URLs are typically already complete
232+
return baseUrl.includes(packageName) ? baseUrl : `https://github.com/${packageName}`;
233+
case 'node-version':
234+
// Node.js distribution URL
235+
return baseUrl;
236+
default:
237+
// For other types, try to append package name if it's not already there
238+
return baseUrl.includes(packageName) ? baseUrl : `${baseUrl}/${packageName}`;
303239
}
304-
305-
// For production, consider using a proper logging service instead of console.log
306-
// Example: this.logger.info(`[UI Component] Extracted ${dependencyCount} dependencies. Total in table: ${this.dependencies.length}`);
307240
}
308241

309242
private addOrUpdateDependency(dependency: Dependency): void {

apps/ui/src/app/playground/playground.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ export class PlaygroundService {
8787

8888
try {
8989
const parsedData = JSON.parse(dataMatch[1]);
90-
console.log('SSE parsed data:', parsedData);
9190

9291
// Handle the new backend format: {data: {original, time, msg, level}, type}
9392
let logMessage: RenovateLogMessage;

0 commit comments

Comments
 (0)