@@ -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 = / U p g r a d i n g d e p e n d e n c y ( \S + ) f r o m ( \S + ) t o ( \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 {
0 commit comments