View supported versions of node

The NodeJS core team provides a JSON file in nodejs/release: https://github.com/nodejs/Release/blob/main/schedule.json which details all of the major versions of Node, their initial release date, EOL, maintenance mode date, as well as LTS date.

I wanted to do a test run with this document of parsing it and getting some initial results. As Node 10 went EOL at the end of today, I thought it could be neat to use this to track node versions in projects you work on and if you're using a node version that is no longer supported, it could inform you of such and tell you to upgrade to the latest LTS. As a test run, I pull down the JSON file and parse it out to list the versions of Node which are still being supported.

Screen Shot 2021-04-30 at 10 33 07 PM

(Also as a fun aside, I am tending more and more of using arg() to display a list of content even if I don't then select one & go further with it. I enjoy the way it presents the data & it is filterable by default. I know of the img and html fields are around but I have yet to find neat ways of using them.)

Code:

// Menu: Available Node versions
// Description: View all supported versions of NodeJS
// Author: Benjamin Lannon
// Twitter: @lannonbr
let resp = await get(
"https://raw.githubusercontent.com/nodejs/Release/main/schedule.json"
);
const data = Object.entries(resp.data);
/** @type typeof import('dayjs') */
let dayjs = await npm("dayjs");
let opts = [];
for (let [version, info] of data) {
let isSupported =
dayjs(info.start).diff(dayjs(), "days") < 0 &&
dayjs(info.end).diff(dayjs(), "days") > 0;
if (isSupported) {
opts.push({
name: `Node ${version}`,
description: `Maintainence ends on ${dayjs(info.end).format(
"MMMM DD, YYYY"
)}`,
endDate: info.end,
});
}
}
opts = opts.sort((a, b) => {
return dayjs(a.endDate).unix() - dayjs(b.endDate).unix();
});
await arg("These versions of NodeJS are currently maintained", opts);