@@ -77,42 +77,60 @@ const hasReleaseDelayElapsed = (publishedAt, now = Date.now()) => {
7777 return now - publishedTimestamp >= releaseDelayMs ;
7878} ;
7979
80- // The updater tracks the exact current latest release for each ecosystem.
81- // If that latest has not aged for a full 24 hours yet, it must not fall back to
82- // an older version, because creating a PR for that older version would still
83- // violate the latest-only cooldown rule.
80+ // The updater tracks the exact current latest eligible release for each ecosystem.
81+ // For Node.js, that means the latest release from an LTS line instead of the
82+ // overall latest Current release. If that latest eligible release has not aged
83+ // for a full 24 hours yet, it must not fall back to an older version, because
84+ // creating a PR for that older version would still violate the latest-only
85+ // cooldown rule.
8486const logSkippedLatest = ( ecosystem , version , publishedAt ) => {
8587 console . log (
8688 [
87- `Skipping ${ ecosystem } update because the current latest release ${ version } was published at ${ publishedAt } .` ,
88- "The updater only adopts the current latest after a full 24-hour delay and never falls back to an older version while that latest is still cooling down." ,
89+ `Skipping ${ ecosystem } update because the current latest eligible release ${ version } was published at ${ publishedAt } .` ,
90+ "The updater only adopts the current latest eligible release after a full 24-hour delay and never falls back to an older version while that release is still cooling down." ,
8991 ] . join ( " " ) ,
9092 ) ;
9193} ;
9294
95+ const isNodeLtsRelease = ( release ) => {
96+ const lts = release ?. lts ;
97+ return lts === true || ( typeof lts === "string" && lts . trim ( ) !== "" ) ;
98+ } ;
99+
93100const fetchLatestNodeMajor = async ( ) => {
94- const response = await fetch ( "https://api.github.com/repos/nodejs/node/releases/latest " , {
101+ const response = await fetch ( "https://nodejs.org/dist/index.json " , {
95102 headers : {
96- Accept : "application/vnd.github+ json" ,
103+ Accept : "application/json" ,
97104 "User-Agent" : userAgent ,
98105 } ,
99106 } ) ;
100107
101108 if ( ! response . ok ) {
102- throw new Error ( `Failed to fetch the latest Node.js release: ${ response . status } ${ response . statusText } ` ) ;
109+ throw new Error ( `Failed to fetch the Node.js release index: ${ response . status } ${ response . statusText } ` ) ;
110+ }
111+
112+ const releases = await response . json ( ) ;
113+
114+ if ( ! Array . isArray ( releases ) ) {
115+ throw new Error ( "Invalid Node.js release index payload" ) ;
103116 }
104117
105- const latestRelease = await response . json ( ) ;
106- const latestVersion = typeof latestRelease . tag_name === "string" ? latestRelease . tag_name . trim ( ) : "" ;
107- const publishedAt = typeof latestRelease . published_at === "string" ? latestRelease . published_at . trim ( ) : "" ;
118+ const latestRelease = releases . find ( isNodeLtsRelease ) ;
119+
120+ if ( ! latestRelease || typeof latestRelease !== "object" ) {
121+ throw new Error ( "Unable to resolve the latest Node.js LTS release" ) ;
122+ }
123+
124+ const latestVersion = typeof latestRelease . version === "string" ? latestRelease . version . trim ( ) : "" ;
125+ const publishedAt = typeof latestRelease . date === "string" ? latestRelease . date . trim ( ) : "" ;
108126 const parsedVersion = parseSemVer ( latestVersion ) ;
109127
110128 if ( ! parsedVersion ) {
111- throw new Error ( `Invalid latest Node.js release version: ${ latestVersion || "<empty>" } ` ) ;
129+ throw new Error ( `Invalid latest Node.js LTS release version: ${ latestVersion || "<empty>" } ` ) ;
112130 }
113131
114132 if ( ! hasReleaseDelayElapsed ( publishedAt ) ) {
115- logSkippedLatest ( "Node.js" , latestVersion , publishedAt ) ;
133+ logSkippedLatest ( "Node.js LTS " , latestVersion , publishedAt ) ;
116134 return null ;
117135 }
118136
@@ -355,9 +373,11 @@ const nodeMajor = await fetchLatestNodeMajor();
355373const pnpmVersion = await fetchLatestPnpmVersion ( ) ;
356374
357375if ( nodeMajor === null ) {
358- console . log ( "Resolved latest Node.js major: skipped because the current latest release has not reached the 24-hour delay" ) ;
376+ console . log (
377+ "Resolved latest Node.js LTS major: skipped because the current latest eligible release has not reached the 24-hour delay" ,
378+ ) ;
359379} else {
360- console . log ( `Resolved latest Node.js major after 24-hour latest-only delay: ${ nodeMajor } ` ) ;
380+ console . log ( `Resolved latest Node.js LTS major after 24-hour latest-only delay: ${ nodeMajor } ` ) ;
361381}
362382
363383if ( pnpmVersion === null ) {
0 commit comments