Skip to content

Commit

Permalink
hotfix: sotrybook and undici
Browse files Browse the repository at this point in the history
  • Loading branch information
ovflowd committed Nov 25, 2023
1 parent 23202f6 commit dcde9f0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 41 deletions.
7 changes: 6 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ const config: StorybookConfig = {
`<body class="${rootClasses}"></body>`,
core: { disableTelemetry: true, disableWhatsNewNotifications: true },
framework: { name: '@storybook/nextjs', options: {} },
webpack: async config => ({ ...config, performance: { hints: false } }),
webpack: async config => ({
...config,
target: 'browserslist',
performance: { hints: false },
resolve: { ...config.resolve, alias: { '@nodevu/core': false } },
}),
};

export default config;
80 changes: 40 additions & 40 deletions next-data/generators/releaseData.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import nodevu from '@nodevu/core';

// Gets the appropriate release status for each major release
const getNodeReleaseStatus = (now, support) => {
const { endOfLife, maintenanceStart, ltsStart, currentStart } = support;
Expand Down Expand Up @@ -30,50 +28,52 @@ const getNodeReleaseStatus = (now, support) => {
* @returns {Promise<import('../../types').NodeRelease[]>}
*/
const generateReleaseData = async () => {
const nodevuOutput = await nodevu({ fetch: fetch });
return import('@nodevu/core').then(async ({ default: nodevu }) => {
const nodevuOutput = await nodevu({ fetch: fetch });

// Filter out those without documented support
// Basically those not in schedule.json
const majors = Object.values(nodevuOutput).filter(major => !!major.support);
// Filter out those without documented support
// Basically those not in schedule.json
const majors = Object.values(nodevuOutput).filter(major => !!major.support);

const nodeReleases = majors.map(major => {
const [latestVersion] = Object.values(major.releases);
const nodeReleases = majors.map(major => {
const [latestVersion] = Object.values(major.releases);

const support = {
currentStart: major.support.phases.dates.start,
ltsStart: major.support.phases.dates.lts,
maintenanceStart: major.support.phases.dates.maintenance,
endOfLife: major.support.phases.dates.end,
};
const support = {
currentStart: major.support.phases.dates.start,
ltsStart: major.support.phases.dates.lts,
maintenanceStart: major.support.phases.dates.maintenance,
endOfLife: major.support.phases.dates.end,
};

const status = getNodeReleaseStatus(new Date(), support);
const status = getNodeReleaseStatus(new Date(), support);

return {
...support,
status,
major: latestVersion.semver.major,
version: latestVersion.semver.raw,
versionWithPrefix: `v${latestVersion.semver.raw}`,
codename: major.codename || '',
isLts: status === 'Active LTS' || status === 'Maintenance LTS',
npm: latestVersion.dependencies.npm || '',
v8: latestVersion.dependencies.v8 || '',
releaseDate: latestVersion.releaseDate || '',
modules: latestVersion.modules.version || '',
};
});
return {
...support,
status,
major: latestVersion.semver.major,
version: latestVersion.semver.raw,
versionWithPrefix: `v${latestVersion.semver.raw}`,
codename: major.codename || '',
isLts: status === 'Active LTS' || status === 'Maintenance LTS',
npm: latestVersion.dependencies.npm || '',
v8: latestVersion.dependencies.v8 || '',
releaseDate: latestVersion.releaseDate || '',
modules: latestVersion.modules.version || '',
};
});

return Promise.resolve(
// nodevu returns duplicated v0.x versions (v0.12, v0.10, ...).
// This behavior seems intentional as the case is hardcoded in nodevu,
// see https://github.com/cutenode/nodevu/blob/0c8538c70195fb7181e0a4d1eeb6a28e8ed95698/core/index.js#L24.
// This line ignores those duplicated versions and takes the latest
// v0.x version (v0.12.18). It is also consistent with the legacy
// nodejs.org implementation.
nodeReleases.filter(
release => release.major !== 0 || release.version === '0.12.18'
)
);
return Promise.resolve(
// nodevu returns duplicated v0.x versions (v0.12, v0.10, ...).
// This behavior seems intentional as the case is hardcoded in nodevu,
// see https://github.com/cutenode/nodevu/blob/0c8538c70195fb7181e0a4d1eeb6a28e8ed95698/core/index.js#L24.
// This line ignores those duplicated versions and takes the latest
// v0.x version (v0.12.18). It is also consistent with the legacy
// nodejs.org implementation.
nodeReleases.filter(
release => release.major !== 0 || release.version === '0.12.18'
)
);
});
};

export default generateReleaseData;

0 comments on commit dcde9f0

Please sign in to comment.