-
Notifications
You must be signed in to change notification settings - Fork 434
patch: Add proper fallback for versioning.js #3224
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Vipul Gupta (@vipulgupta2048) <[email protected]>
There was a problem hiding this 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 refactors the versioning.js tool that fetches GitHub repository releases and creates versioned documentation. The changes improve code organization, error handling, and add comprehensive documentation while maintaining the same core functionality.
- Adds comprehensive JSDoc documentation for all functions
- Refactors large functions into smaller, more focused utility functions
- Improves configuration management with centralized constants
- Enhances error handling and fallback mechanisms
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
REQUEST_TIMEOUT: 10000, | ||
MIN_SEMANTIC_VERSIONS: 10, | ||
MIN_COMPATIBLE_TAGS: 5, | ||
ONE_YEAR_IN_MS: 365 * 24 * 60 * 60 * 1000 |
Copilot
AI
Sep 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ONE_YEAR_IN_MS constant is defined but never used in the code. Consider removing it or using it in the getOneYearAgo function to replace the setFullYear approach for consistency.
Copilot uses AI. Check for mistakes.
return createVersionEntry("latest", `${tag.name} latest`, tag.name, tagDate); | ||
} | ||
|
||
if (tagDate.getTime() < oneYearAgo.getTime()) { |
Copilot
AI
Sep 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling getTime() on dates that are already compared multiple times is inefficient. Consider converting dates to timestamps once at the beginning of the function.
Copilot uses AI. Check for mistakes.
* @returns {Object} Configuration paths and names | ||
*/ | ||
function generateConfigPaths(repoName) { | ||
const versionsFileName = repoName.replaceAll(/-/g, ""); |
Copilot
AI
Sep 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using replaceAll with a global regex is redundant. Use replace(/-/g, '') instead, or keep replaceAll but remove the 'g' flag: replaceAll('-', '').
const versionsFileName = repoName.replaceAll(/-/g, ""); | |
const versionsFileName = repoName.replaceAll("-", ""); |
Copilot uses AI. Check for mistakes.
Website deployed to CF Pages, 👀 preview link https://ff22ddab.balenacloud-docs.pages.dev |
Create atleast a fallback for the lastest docs and bunch of refactoring fixed to make it more readable.
Signed-off-by: Vipul Gupta (@vipulgupta2048) [email protected]