@@ -459,6 +459,8 @@ export async function handleRefreshReleaseFile<T extends 'app' | 'client'>(
459459
460460 const repositories = releaseFile . repositories || [ ]
461461
462+ const updatedAppReleases : AppLatestServer [ ] = [ ]
463+
462464 try {
463465 update ( `Fetching the new list of available apps` , 80 )
464466 const githubStore = await storeProvider . getStore ( 'githubStore' )
@@ -486,13 +488,62 @@ export async function handleRefreshReleaseFile<T extends 'app' | 'client'>(
486488 repositories . push ( ...newRepos )
487489 }
488490
489- update ( `Found ${ repositories . length } apps with ${ newRepos . length } new repositories` , 95 )
491+ update ( `Found ${ repositories . length } apps with ${ newRepos . length } new repositories` , 90 )
490492
491493 // Now just as a bonus, see if there are any new app IDs included in the multi release
492494 // TODO: Actually do that for the love of *** I'll never be done with having to update my stupid release logic
493495 // I'm debating if I should re-couple the multi release wit the individual releases cuz release discovery is *stupid* and I think I would rather *die*
494496 // send help
495497
498+ // Now just quickly go over the available apps and see if there are any new ones
499+
500+ // First get an easily mappable list of existing app IDs
501+ const existingAppIds = migratedReleases . map ( ( release ) => release . id )
502+
503+ // Then iterate over the server's app IDs and find any new ones
504+
505+ if (
506+ 'fileIds' in latestJSON &&
507+ Array . isArray ( latestJSON . fileIds ) &&
508+ latestJSON . fileIds . length > 0
509+ ) {
510+ const newAppIds = latestJSON . fileIds . filter ( ( id ) => ! existingAppIds . includes ( id ) )
511+
512+ if ( newAppIds . length > 0 ) {
513+ // If there are new ones, then add those just like the addMultiReleaseServer does
514+ update ( `Found ${ newAppIds . length } new app IDs` , 93 )
515+
516+ const results = await Promise . allSettled (
517+ newAppIds . map ( async ( fileId ) =>
518+ convertIdToReleaseServer ( fileId , appsRepo , allReleases )
519+ ) ?? [ ]
520+ )
521+
522+ // Get the successful results
523+ const apps = results
524+ . filter ( ( result ) => result . status === 'fulfilled' )
525+ . map ( ( result ) => result . value ) as AppLatestServer [ ]
526+
527+ // Handle logging the errors
528+ results
529+ . filter ( ( result ) : result is PromiseRejectedResult => result . status === 'rejected' )
530+ . forEach ( ( result , index ) => {
531+ const fileId = newAppIds [ index ]
532+ logger . warn (
533+ `Unable to convert ${ fileId } to a full release using ${ appsRepo } because ${ handleError ( result . reason ) } ` ,
534+ { function : 'refreshReleaseFile' , source : 'handleRefreshReleaseFile' }
535+ )
536+ } )
537+
538+ updatedAppReleases . push ( ...apps )
539+ }
540+ }
541+
542+ // If there are new ones, then add those just like the addMultiReleaseServer does
543+
544+ // Add those to the current working structure
545+
546+ // Stonks?
496547 } catch ( error ) {
497548 logger . warn ( `Error fetching releases for ${ appsRepo } : ${ handleError ( error ) } ` )
498549 update ( `Failed to find new repos, reverting and continuing anyways` , 95 )
@@ -502,7 +553,7 @@ export async function handleRefreshReleaseFile<T extends 'app' | 'client'>(
502553 version : '0.11.11' ,
503554 type : 'app' ,
504555 repositories : releaseFile . repositories ,
505- releases : migratedReleases as AppLatestServer [ ] ,
556+ releases : [ ... updatedAppReleases , ... ( migratedReleases as AppLatestServer [ ] ) ] ,
506557 timestamp : Date . now ( )
507558 }
508559 update ( 'Saving app release file' , 100 )
@@ -543,8 +594,10 @@ export async function handleRefreshReleaseFile<T extends 'app' | 'client'>(
543594
544595 const repositories = releaseFile . repositories || [ ]
545596
597+ const updatedClientReleases : ClientLatestServer [ ] = [ ]
598+
546599 try {
547- update ( `Fetching the new list of available apps ` , 80 )
600+ update ( `Fetching the new list of available clients ` , 80 )
548601 const githubStore = await storeProvider . getStore ( 'githubStore' )
549602 const allReleases = await githubStore . getAllReleases ( clientRepo , force )
550603
@@ -570,7 +623,58 @@ export async function handleRefreshReleaseFile<T extends 'app' | 'client'>(
570623 repositories . push ( ...newRepos )
571624 }
572625
573- update ( `Found ${ repositories . length } apps with ${ newRepos . length } new repositories` , 95 )
626+ update ( `Found ${ repositories . length } apps with ${ newRepos . length } new repositories` , 90 )
627+
628+ // Now just as a bonus, see if there are any new app IDs included in the multi release
629+ // TODO: Actually do that for the love of *** I'll never be done with having to update my stupid release logic
630+ // I'm debating if I should re-couple the multi release wit the individual releases cuz release discovery is *stupid* and I think I would rather *die*
631+ // send help
632+
633+ // Now just quickly go over the available apps and see if there are any new ones
634+
635+ // First get an easily mappable list of existing app IDs
636+ const existingAppIds = migratedReleases . map ( ( release ) => release . id )
637+
638+ // Then iterate over the server's app IDs and find any new ones
639+
640+ if (
641+ 'fileIds' in latestJSON &&
642+ Array . isArray ( latestJSON . fileIds ) &&
643+ latestJSON . fileIds . length > 0
644+ ) {
645+ const newAppIds = latestJSON . fileIds . filter ( ( id ) => ! existingAppIds . includes ( id ) )
646+
647+ if ( newAppIds . length > 0 ) {
648+ // If there are new ones, then add those just like the addMultiReleaseServer does
649+ update ( `Found ${ newAppIds . length } new app IDs` , 93 )
650+
651+ const results = await Promise . allSettled (
652+ newAppIds . map ( async ( fileId ) =>
653+ convertIdToReleaseServer ( fileId , clientRepo , allReleases )
654+ ) ?? [ ]
655+ )
656+
657+ // Get the successful results
658+ const apps = results
659+ . filter ( ( result ) => result . status === 'fulfilled' )
660+ . map ( ( result ) => result . value ) as ClientLatestServer [ ]
661+
662+ // Handle logging the errors
663+ results
664+ . filter ( ( result ) : result is PromiseRejectedResult => result . status === 'rejected' )
665+ . forEach ( ( result , index ) => {
666+ const fileId = newAppIds [ index ]
667+ logger . warn (
668+ `Unable to convert ${ fileId } to a full release using ${ clientRepo } because ${ handleError ( result . reason ) } ` ,
669+ { function : 'refreshReleaseFile' , source : 'handleRefreshReleaseFile' }
670+ )
671+ } )
672+
673+ update ( `Found ${ apps . length } new apps` , 95 )
674+
675+ updatedClientReleases . push ( ...apps )
676+ }
677+ }
574678 } catch ( error ) {
575679 logger . warn ( `Error fetching releases for ${ clientRepo } : ${ handleError ( error ) } ` )
576680 update ( `Failed to find new repos, reverting and continuing anyways` , 95 )
@@ -580,7 +684,7 @@ export async function handleRefreshReleaseFile<T extends 'app' | 'client'>(
580684 version : '0.11.11' ,
581685 type : 'client' ,
582686 repositories : repositories ,
583- releases : migratedReleases as ClientLatestServer [ ] ,
687+ releases : [ ... updatedClientReleases , ... ( migratedReleases as ClientLatestServer [ ] ) ] ,
584688 timestamp : Date . now ( )
585689 }
586690 update ( 'Saving client release file' , 100 )
0 commit comments