Skip to content

Commit

Permalink
Merge branch 'master' into add_v8_version
Browse files Browse the repository at this point in the history
  • Loading branch information
chicoxyzzy authored May 24, 2023
2 parents b09fb2c + c05cacf commit 2ed11e2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

- uses: actions/setup-node@v2
with:
node-version: "16.x"
node-version: "18.x"
cache: npm

- name: Install
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "node-releases",
"version": "2.0.11",
"description": "Node.js releases data",
"type": "module",
"scripts": {
"build": "node scripts/build.js"
},
Expand Down
79 changes: 26 additions & 53 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,31 @@
const http = require('https');
const fs = require('fs/promises');
const path = require('path');
const semver = require('semver');
import fs from 'node:fs';
import semver from 'semver';

function loadJSON (url) {
return new Promise((resolve, reject) => {
http.get(url, (response) => {
let data = '';
response.on('data', (chunk) => {
data += chunk;
})
response.on('end', () => {
resolve(JSON.parse(data));
})
}).on('error', (error) => {
reject(error);
});
});
}

async function writeJSON(file, data) {
await fs.writeFile(path.join(__dirname, '..', file), JSON.stringify(data));
function writeJSON(file, data) {
fs.writeFileSync(new URL(file, import.meta.url), JSON.stringify(data));
}

async function processVersions() {
const origin = await loadJSON('https://nodejs.org/dist/index.json');
const processed = origin
.filter(function (env) {
return semver.patch(env.version) === 0;
})
.map(function (env) {
return {
name: 'nodejs',
version: env.version.substr(1),
date: env.date,
lts: env.lts,
security: env.security,
v8: env.v8
};
})
.sort((a, b) => {
if (semver.gt(a.version, b.version)) return 1;
if (semver.lt(a.version, b.version)) return -1;
return 0;
});
await writeJSON('data/processed/envs.json', processed);
}
const [ dist, schedule ] = await Promise.all([
'https://nodejs.org/dist/index.json',
'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json'
].map(url => fetch(url).then(res => res.json())));

async function processSchedule() {
const origin = await loadJSON(
'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json'
);
await writeJSON('data/release-schedule/release-schedule.json', origin);
}
// Process Versions
const processed = dist
.filter(env => semver.patch(env.version) === 0)
.map(env => ({
name: 'nodejs',
version: env.version.substr(1),
date: env.date,
lts: env.lts,
security: env.security,
v8: env.v8
}))
.sort((a, b) => {
if (semver.gt(a.version, b.version)) return 1;
if (semver.lt(a.version, b.version)) return -1;
return 0;
});

processVersions();
processSchedule();
writeJSON('../data/processed/envs.json', processed);
writeJSON('../data/release-schedule/release-schedule.json', schedule);

0 comments on commit 2ed11e2

Please sign in to comment.