Skip to content

chore(site): rename and merge utilities #7853

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

chore(site): rename and merge utilities #7853

wants to merge 3 commits into from

Conversation

avivkeller
Copy link
Member

Description

All of our utility files are either: suffixed with Utils (Why? We are already in a utility folder), or named after a single-function that the contain. This PR updates those files to have names based on what functions they contain, rather than the function names themselves (i.e. download over downloadUtils, and api over getNodeApiLink)

Validation

Nothing should change

@Copilot Copilot AI review requested due to automatic review settings June 8, 2025 21:06
@avivkeller avivkeller requested a review from a team as a code owner June 8, 2025 21:06
Copy link

vercel bot commented Jun 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Jun 9, 2025 0:54am

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR renames several utility files and updates their import paths to improve clarity and consistency in the utility folder. The changes remove redundant naming patterns and merge similar utility functions under consolidated names.

  • Updated import paths to remove "Utils" suffixes.
  • Renamed modules (e.g., stringUtils to string, authorUtils to author, dateUtils to date, downloadUtils to download, etc.) for clarity.
  • Updated internal references in components and pages accordingly.

Reviewed Changes

Copilot reviewed 60 out of 60 changed files in this pull request and generated no comments.

Show a summary per file
File Description
apps/site/components/withBreadcrumbs.tsx Updated import for dashToCamelCase from stringUtils to string
apps/site/components/withBlogCategories.tsx Updated import for mapAuthorToCardAuthors from authorUtils to author
apps/site/components/withBanner.tsx Updated import for dateIsBetween from dateUtils to date
apps/site/components/withBadgeGroup.tsx Updated import for dateIsBetween from dateUtils to date
apps/site/components/withAvatarGroup.tsx Updated import for getAuthors from authorUtils to author
apps/site/components/Downloads/Release/ReleaseCodeBox.tsx Updated import for INSTALL_METHODS from downloadUtils to download
apps/site/components/Downloads/Release/PrebuiltDownloadButtons.tsx Updated imports from downloadUtils to download for getNodeDownloadUrl and others
apps/site/components/Downloads/Release/PlatformDropdown.tsx Updated imports for download utilities including getUserPlatform from downloadUtils to ua
apps/site/components/Downloads/Release/PackageManagerDropdown.tsx Updated imports from downloadUtils to download
apps/site/components/Downloads/Release/OperatingSystemDropdown.tsx Updated imports from downloadUtils to download
apps/site/components/Downloads/Release/InstallationMethodDropdown.tsx Updated imports from downloadUtils to download
apps/site/components/Downloads/Release/DownloadLink.tsx Updated import for DownloadKind from getNodeDownloadUrl to download
apps/site/components/Downloads/MinorReleasesTable/index.tsx Updated import for getNodeApiLink from getNodeApiLink to api
apps/site/components/Downloads/DownloadLink.tsx Updated imports for getNodeDownloadUrl and getUserPlatform from legacy paths to new ones
apps/site/components/Downloads/DownloadButton/index.tsx Updated imports for getNodeDownloadUrl and getUserPlatform from legacy paths to new ones
apps/site/components/Blog/BlogPostCard/index.tsx Updated import for mapBlogCategoryToPreviewType from blogUtils to blog
apps/site/client-context.ts Updated import for assignClientContext from assignClientContext to context
apps/site/app/[locale]/next-data/page-data/route.ts Updated import for parseRichTextIntoPlainText from stringUtils to string
apps/site/app/[locale]/next-data/og/[category]/[title]/route.tsx Updated variable naming and removed hexToRGBA conversion to use rgb() strings directly
apps/site/app/[locale]/next-data/api-data/route.ts Updated imports for getGitHubApiDocsUrl, parseRichTextIntoPlainText from legacy paths to github and string respectively

Copy link

codecov bot commented Jun 8, 2025

Codecov Report

Attention: Patch coverage is 70.10870% with 55 lines in your changes missing coverage. Please review.

Project coverage is 75.34%. Comparing base (4d1ce7b) to head (507a474).
Report is 4 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/site/util/download/index.tsx 32.43% 50 Missing ⚠️
apps/site/util/userAgent.ts 95.06% 4 Missing ⚠️
apps/site/util/misc.ts 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7853      +/-   ##
==========================================
- Coverage   75.46%   75.34%   -0.12%     
==========================================
  Files         101       96       -5     
  Lines        8305     8316      +11     
  Branches      218      218              
==========================================
- Hits         6267     6266       -1     
- Misses       2036     2048      +12     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodeApiLink is better because it's apiLink related. API alone it's explicit. Is it a rest api ? A client ? you don't know with api so it's why we need to have a better name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense, it's the API utilities.


// This is the Route Handler for the `GET` method which handles the request
// for generating OpenGraph images for Blog Posts and Pages
// @see https://nextjs.org/docs/app/building-your-application/routing/router-handlers
export const GET = async (_: Request, props: StaticParams) => {
const params = await props.params;

const categoryColour =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive by nit: i've never seen us have an authoritative stance on English or American spellings, and as such allow both personally

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name it objects?


export type DownloadKind = 'installer' | 'binary' | 'source';

export const getNodeDownloadUrl = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in another file IMO

@@ -149,3 +150,76 @@ export const PLATFORMS = Object.fromEntries(
})),
])
) as Record<UserOS | 'LOADING', Array<DownloadDropdownItem<UserPlatform>>>;

export type DownloadKind = 'installer' | 'binary' | 'source';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to types folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants