@@ -8,8 +8,8 @@ async function getJSONFromCDN (urlPath) {
88 return JSON . parse ( response . body )
99}
1010
11- async function fetchElectronVersions ( ) {
12- return ( await getJSONFromCDN ( 'electron/releases/lite.json' ) ) . map ( metadata => metadata . version )
11+ async function fetchElectronReleases ( ) {
12+ return ( await getJSONFromCDN ( 'electron/releases/lite.json' ) )
1313}
1414
1515async function fetchNodeVersions ( ) {
@@ -39,19 +39,51 @@ async function fetchAbiVersions () {
3939 . filter ( ( { modules } ) => modules > 66 )
4040}
4141
42+ function electronTargetsByModules ( releases ) {
43+ const versions = releases . map ( ( { version } ) => version )
44+ const versionsByModules = releases
45+ . filter ( release => release . deps && Number ( release . deps . modules ) >= 70 )
46+ . map ( ( { version, deps : { modules } } ) => ( {
47+ version,
48+ modules,
49+ } ) )
50+ . reduce (
51+ ( acc , { modules, version } ) => ( {
52+ ...acc ,
53+ [ modules ] : version ,
54+ } ) ,
55+ { }
56+ )
57+
58+ return Object . entries ( versionsByModules )
59+ . map (
60+ ( [ modules , version ] ) => ( {
61+ abi : modules ,
62+ future : ! versions . find (
63+ v => {
64+ const major = version . split ( "." ) [ 0 ]
65+ return semver . satisfies (
66+ v ,
67+ / ^ [ 0 - 9 ] / . test ( major ) ? `>= ${ major } ` : major
68+ )
69+ }
70+ ) ,
71+ lts : false ,
72+ runtime : 'electron' ,
73+ target : version
74+ } )
75+ )
76+ }
77+
4278async function main ( ) {
4379 const nodeVersions = await fetchNodeVersions ( )
4480 const abiVersions = await fetchAbiVersions ( )
45- const electronVersions = await fetchElectronVersions ( )
81+ const electronReleases = await fetchElectronReleases ( )
82+ const electronTargets = electronTargetsByModules ( electronReleases )
4683
4784 const abiVersionSet = new Set ( )
4885 const supportedTargets = [ ]
4986 for ( const abiVersion of abiVersions ) {
50- if ( abiVersion . runtime === 'electron' && abiVersion . modules < 70 ) {
51- // Don't try to parse Electron ABI versions below Electron 5
52- continue
53- }
54-
5587 let target
5688 if ( abiVersion . runtime === 'node' ) {
5789 const nodeVersion = abiVersion . versions . replace ( '-pre' , '' )
@@ -67,12 +99,7 @@ async function main () {
6799 future : false
68100 }
69101 if ( target . runtime === 'electron' ) {
70- target . target = `${ target . target } .0.0`
71- const constraint = / ^ [ 0 - 9 ] / . test ( abiVersion . versions ) ? `>= ${ abiVersion . versions } ` : abiVersion . versions
72- if ( ! electronVersions . find ( electronVersion => semver . satisfies ( electronVersion , constraint ) ) ) {
73- target . target = `${ target . target } -beta.1`
74- target . future = true
75- }
102+ continue
76103 }
77104 }
78105
@@ -88,6 +115,10 @@ async function main () {
88115 } )
89116 }
90117
118+ for ( const electronTarget of electronTargets ) {
119+ supportedTargets . push ( electronTarget )
120+ }
121+
91122 await writeFile ( path . resolve ( __dirname , '..' , 'abi_registry.json' ) , JSON . stringify ( supportedTargets , null , 2 ) )
92123}
93124
0 commit comments