Skip to content

Remove compare-versions dependency#1303

Merged
minggangw merged 1 commit into
RobotWebTools:developfrom
minggangw:fix-1301
Oct 20, 2025
Merged

Remove compare-versions dependency#1303
minggangw merged 1 commit into
RobotWebTools:developfrom
minggangw:fix-1301

Conversation

@minggangw

@minggangw minggangw commented Oct 20, 2025

Copy link
Copy Markdown
Member

This PR removes the external compare-versions dependency by implementing a custom version comparison function in the project's utils module.

  • Replaces the external compare-versions package with a custom implementation
  • Updates import statements to use the new local function
  • Removes the dependency from package.json

Fix: #1301

Copilot AI review requested due to automatic review settings October 20, 2025 02:56

Copilot AI left a comment

Copy link
Copy Markdown

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 removes the external compare-versions dependency by implementing a custom version comparison function in the project's utils module.

  • Replaces the external compare-versions package with a custom implementation
  • Updates import statements to use the new local function
  • Removes the dependency from package.json

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
package.json Removes compare-versions dependency
lib/utils.js Adds custom compareVersions function implementation
rosidl_parser/rosidl_parser.js Updates import to use local compareVersions function
index.js Updates import to use local compareVersions function

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread lib/utils.js
Comment on lines +259 to +261
// Parse version strings into arrays of integers
const v1Parts = version1.split('.').map((part) => parseInt(part, 10));
const v2Parts = version2.split('.').map((part) => parseInt(part, 10));

Copilot AI Oct 20, 2025

Copy link

Choose a reason for hiding this comment

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

The parseInt function will return NaN for invalid version parts, which could lead to incorrect comparisons. Consider adding validation to ensure all parts are valid integers before proceeding with the comparison.

Suggested change
// Parse version strings into arrays of integers
const v1Parts = version1.split('.').map((part) => parseInt(part, 10));
const v2Parts = version2.split('.').map((part) => parseInt(part, 10));
// Helper to parse and validate version string
function parseVersionParts(version) {
const parts = version.split('.');
return parts.map((part, idx) => {
// Only allow non-empty strings of digits
if (!/^\d+$/.test(part)) {
throw new Error(`Invalid version part '${part}' at position ${idx} in version string '${version}'`);
}
return parseInt(part, 10);
});
}
const v1Parts = parseVersionParts(version1);
const v2Parts = parseVersionParts(version2);

Copilot uses AI. Check for mistakes.
Comment thread lib/utils.js
* compareVersions('1.2.3', '1.2.3', '==') // true
* compareVersions('1.2.3', '1.2.3', '>=') // true
*/
function compareVersions(version1, version2, operator) {

Copilot AI Oct 20, 2025

Copy link

Choose a reason for hiding this comment

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

The function doesn't validate input parameters. Consider adding checks for null/undefined version strings and ensuring the operator is a valid string to prevent runtime errors.

Copilot uses AI. Check for mistakes.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 82.607% (-0.2%) from 82.845%
when pulling 9b8da46 on minggangw:fix-1301
into 89b99e3 on RobotWebTools:develop.

@minggangw minggangw merged commit c8f0ae6 into RobotWebTools:develop Oct 20, 2025
26 of 27 checks passed
minggangw added a commit that referenced this pull request Oct 30, 2025
This PR removes the external `compare-versions` dependency by implementing a custom version comparison function in the project's utils module.

- Replaces the external `compare-versions` package with a custom implementation
- Updates import statements to use the new local function
- Removes the dependency from package.json

Fix: #1301
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.

Remove compare-versions dependency

3 participants