Skip to content

fix: proper release status #6603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/[locale]/next-data/api-data/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const getPathnameForApiFile = (name: string, version: string) =>
export const GET = async () => {
const releases = provideReleaseData();

const { versionWithPrefix } = releases.find(release =>
['Active LTS', 'Maintenance LTS'].includes(release.status)
const { versionWithPrefix } = releases.find(
release => release.status === 'LTS'
)!;

const gitHubApiResponse = await fetch(getGitHubApiDocsUrl(versionWithPrefix));
Expand Down
2 changes: 1 addition & 1 deletion components/Downloads/DownloadButton/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const Default: Story = {
ltsStart: '2023-10-24',
maintenanceStart: '2024-10-22',
endOfLife: '2026-04-30',
status: 'Active LTS',
status: 'LTS',
major: 20,
version: '20.11.0',
versionWithPrefix: 'v20.11.0',
Expand Down
2 changes: 1 addition & 1 deletion components/Downloads/Release/PlatformDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ReleaseContext } from '@/providers/releaseProvider';
import type { PackageManager } from '@/types/release';
import { formatDropdownItems, platformItems } from '@/util/downloadUtils';

const supportedHomebrewVersions = ['Active LTS', 'Maintenance LTS', 'Current'];
const supportedHomebrewVersions = ['LTS', 'Current'];

const PlatformDropdown: FC = () => {
const { release, os, platform, setPlatform } = useContext(ReleaseContext);
Expand Down
6 changes: 1 addition & 5 deletions components/Downloads/Release/VersionDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ import Select from '@/components/Common/Select';
import { ReleaseContext } from '@/providers/releaseProvider';

const getDropDownStatus = (version: string, status: string) => {
if (status === 'Active LTS') {
if (status === 'LTS') {
return `${version} (LTS)`;
}

if (status === 'Current') {
return `${version} (Current)`;
}

if (status === 'Maintenance') {
return `${version} (Maintenance)`;
}

return version;
};

Expand Down
6 changes: 3 additions & 3 deletions components/withDownloadCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const WithDownloadCategories: FC<PropsWithChildren> = async ({ children }) => {
const { pathname } = useClientContext();
const { page, category, subCategory } = getDownloadCategory(pathname);

const initialRelease: Array<NodeReleaseStatus> = pathname.includes('current')
? ['Current', 'Maintenance']
: ['Active LTS', 'Maintenance LTS'];
const initialRelease: NodeReleaseStatus = pathname.includes('current')
? 'Current'
: 'LTS';

return (
<LinkTabs
Expand Down
2 changes: 1 addition & 1 deletion next-data/generators/__tests__/releaseData.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ describe('generateReleaseData', () => {
expect(release.v8).toBe('8.0.276.20');
expect(release.releaseDate).toBe('2021-04-20');
expect(release.modules).toBe('83');
expect(release.status).toBe('Maintenance LTS');
expect(release.status).toBe('LTS');
});
});
14 changes: 5 additions & 9 deletions next-data/generators/releaseData.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ import nodevu from '@nodevu/core';

// Gets the appropriate release status for each major release
const getNodeReleaseStatus = (now, support) => {
const { endOfLife, maintenanceStart, ltsStart, currentStart } = support;
const { endOfLife, ltsStart, currentStart } = support;

if (endOfLife && now > new Date(endOfLife)) {
if (endOfLife && now >= new Date(endOfLife)) {
return 'End-of-life';
}

if (maintenanceStart && now > new Date(maintenanceStart)) {
return ltsStart ? 'Maintenance LTS' : 'Maintenance';
}

if (ltsStart && now > new Date(ltsStart)) {
return 'Active LTS';
if (ltsStart && now >= new Date(ltsStart)) {
return 'LTS';
}

if (currentStart && now >= new Date(currentStart)) {
Expand Down Expand Up @@ -58,7 +54,7 @@ const generateReleaseData = () => {
version: latestVersion.semver.raw,
versionWithPrefix: `v${latestVersion.semver.raw}`,
codename: major.support.codename || '',
isLts: status === 'Active LTS' || status === 'Maintenance LTS',
isLts: status === 'LTS',
npm: latestVersion.dependencies.npm || '',
v8: latestVersion.dependencies.v8 || '',
releaseDate: latestVersion.releaseDate || '',
Expand Down
4 changes: 2 additions & 2 deletions pages/en/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ layout: home
</div>

<div>
<WithNodeRelease status={['Active LTS', 'Maintenance LTS']}>
<WithNodeRelease status={['LTS']}>
{({ release }) => (
<>
<DownloadButton release={release}>Download Node.js (LTS)</DownloadButton>
Expand All @@ -28,7 +28,7 @@ layout: home
</>
)}
</WithNodeRelease>
<WithNodeRelease status={["Current", "Maintenance"]}>
<WithNodeRelease status={['Current']}>
{({ release }) => (
<small>
Want new features sooner?
Expand Down
8 changes: 1 addition & 7 deletions types/releases.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
export type NodeReleaseStatus =
| 'Maintenance LTS'
| 'Maintenance'
| 'Active LTS'
| 'Current'
| 'End-of-life'
| 'Pending';
export type NodeReleaseStatus = 'LTS' | 'Current' | 'End-of-life' | 'Pending';

export interface NodeReleaseSource {
major: number;
Expand Down