@@ -46,6 +46,51 @@ interface VersionHistory {
4646 versions : VersionHistoryEntry [ ] ;
4747}
4848
49+ /**
50+ * Map legacy/alias platform keys to canonical keys to avoid duplicates
51+ */
52+ function canonicalizePlatformKey ( key : string ) : string {
53+ const aliasMap : Record < string , string > = {
54+ // Windows aliases – prefer explicit "-system" variants
55+ "win32-x64" : "win32-x64-system" ,
56+ "win32-arm64" : "win32-arm64-system" ,
57+ } ;
58+ return aliasMap [ key ] || key ;
59+ }
60+
61+ /**
62+ * Dedupe a platform map by collapsing aliases to their canonical keys
63+ */
64+ function dedupePlatformsMap (
65+ platforms : { [ platform : string ] : string } ,
66+ ) : { [ platform : string ] : string } {
67+ const result : { [ platform : string ] : string } = { } ;
68+ for ( const [ key , url ] of Object . entries ( platforms || { } ) ) {
69+ const canonical = canonicalizePlatformKey ( key ) ;
70+ // Prefer values that already use the canonical key
71+ if ( ! result [ canonical ] || key === canonical ) {
72+ result [ canonical ] = url ;
73+ }
74+ }
75+ return result ;
76+ }
77+
78+ /**
79+ * Dedupe platform details with the same canonical rules as platforms
80+ */
81+ function dedupePlatformDetailsMap (
82+ details : { [ platform : string ] : { sizeBytes ?: number ; sha256 ?: string } } ,
83+ ) : { [ platform : string ] : { sizeBytes ?: number ; sha256 ?: string } } {
84+ const result : { [ platform : string ] : { sizeBytes ?: number ; sha256 ?: string } } = { } ;
85+ for ( const [ key , value ] of Object . entries ( details || { } ) ) {
86+ const canonical = canonicalizePlatformKey ( key ) ;
87+ if ( ! result [ canonical ] || key === canonical ) {
88+ result [ canonical ] = value ;
89+ }
90+ }
91+ return result ;
92+ }
93+
4994const PLATFORMS : PlatformMap = {
5095 windows : {
5196 platforms : [
@@ -577,8 +622,10 @@ async function sendNewVersionNotification(
577622 * Generate release notes for RELEASE_NOTES.md
578623 */
579624function generateReleaseNotes ( latestEntry : VersionHistoryEntry ) : string {
580- const platforms = latestEntry . platforms || { } ;
581- const latestDetails = latestEntry . platformDetails || { } ;
625+ const platforms = dedupePlatformsMap ( latestEntry . platforms || { } ) ;
626+ const latestDetails = dedupePlatformDetailsMap (
627+ latestEntry . platformDetails || { } ,
628+ ) ;
582629 const displayName = ( key : string ) : string => {
583630 const map : Record < string , string > = {
584631 "win32-x64-user" : "Windows x64 (User)" ,
@@ -639,8 +686,10 @@ function generateReadmeMarkdown(
639686 const liveSiteUrl = "https://downloadcursor.app" ;
640687
641688 // Build downloads table for all available platforms
642- const platforms = latestEntry . platforms || { } ;
643- const latestDetails = latestEntry . platformDetails || { } ;
689+ const platforms = dedupePlatformsMap ( latestEntry . platforms || { } ) ;
690+ const latestDetails = dedupePlatformDetailsMap (
691+ latestEntry . platformDetails || { } ,
692+ ) ;
644693 const displayName = ( key : string ) : string => {
645694 const map : Record < string , string > = {
646695 "win32-x64-user" : "Windows x64 (User)" ,
@@ -829,12 +878,14 @@ async function main(): Promise<void> {
829878 // Add new version to history if it doesn't exist
830879 let isNewVersion = false ;
831880 if ( existingVersionIndex === - 1 ) {
832- const platforms : { [ platform : string ] : string } = { } ;
881+ // Aggregate and then dedupe platform keys (collapse aliases)
882+ const aggregated : { [ platform : string ] : string } = { } ;
833883 for ( const osKey in results ) {
834884 for ( const [ platform , info ] of Object . entries ( results [ osKey ] ) ) {
835- platforms [ platform ] = info . url ;
885+ aggregated [ platform ] = info . url ;
836886 }
837887 }
888+ const platforms : { [ platform : string ] : string } = dedupePlatformsMap ( aggregated ) ;
838889 // Compute platform details (size and optional SHA256)
839890 const platformDetails : {
840891 [ platform : string ] : { sizeBytes ?: number ; sha256 ?: string } ;
@@ -854,12 +905,14 @@ async function main(): Promise<void> {
854905 } ;
855906 } catch { }
856907 }
908+ // Ensure details map aligns with deduped keys
909+ const dedupedDetails = dedupePlatformDetailsMap ( platformDetails ) ;
857910
858911 const newEntry : VersionHistoryEntry = {
859912 version : latestVersion ,
860913 date : currentDate ,
861914 platforms,
862- platformDetails,
915+ platformDetails : dedupedDetails ,
863916 } ;
864917 history . versions . unshift ( newEntry ) ; // Add to top
865918 console . log ( `Added new version ${ latestVersion } to history` ) ;
0 commit comments