Skip to content

Commit 88a03a1

Browse files
committed
chore: add Node releases JSON to bundle
1 parent e02925f commit 88a03a1

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

providers/nodeReleasesProvider.tsx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,53 @@
11
import { createContext } from 'react';
2-
import { useFetchNodeReleases } from '../hooks/useFetchNodeReleases';
2+
import { getNodeReleaseStatus } from '../util/nodeRelease';
3+
import NodeReleasesJSON from '../public/node-releases-data.json';
34
import type { FC, PropsWithChildren } from 'react';
45
import type { NodeRelease } from '../types';
56

7+
type NodeReleaseJSON = {
8+
major: number;
9+
version: string;
10+
codename?: string;
11+
currentStart: string;
12+
ltsStart?: string;
13+
maintenanceStart?: string;
14+
endOfLife: string;
15+
npm?: string;
16+
v8?: string;
17+
releaseDate?: string;
18+
modules?: string;
19+
};
20+
621
export const NodeReleasesContext = createContext<NodeRelease[]>([]);
722

823
export const NodeReleasesProvider: FC<PropsWithChildren> = ({ children }) => {
9-
const releases = useFetchNodeReleases();
24+
const data: NodeReleaseJSON[] = NodeReleasesJSON;
25+
const now = new Date();
26+
27+
const releases = data.map(raw => {
28+
const support = {
29+
currentStart: raw.currentStart,
30+
ltsStart: raw.ltsStart,
31+
maintenanceStart: raw.maintenanceStart,
32+
endOfLife: raw.endOfLife,
33+
};
34+
35+
const status = getNodeReleaseStatus(now, support);
36+
37+
return {
38+
...support,
39+
major: raw.major,
40+
version: raw.version,
41+
versionWithPrefix: `v${raw.version}`,
42+
codename: raw.codename || '',
43+
isLts: status === 'Active LTS' || status === 'Maintenance LTS',
44+
status: status,
45+
npm: raw.npm || '',
46+
v8: raw.v8 || '',
47+
releaseDate: raw.releaseDate || '',
48+
modules: raw.modules || '',
49+
};
50+
});
1051

1152
return (
1253
<NodeReleasesContext.Provider value={releases}>

0 commit comments

Comments
 (0)