Skip to content

Added version consistency check before each build (#896)#1

Open
Beak-man wants to merge 2 commits intoCelestialMappingSystem:Earth_for_Moon_switchfrom
NASAWorldWind:develop
Open

Added version consistency check before each build (#896)#1
Beak-man wants to merge 2 commits intoCelestialMappingSystem:Earth_for_Moon_switchfrom
NASAWorldWind:develop

Conversation

@Beak-man
Copy link
Copy Markdown

@Beak-man Beak-man commented Aug 5, 2025

Updating CMS fork of WebWW from upstream repository.

  • Added version consistency check script

  • Added version check step to build process in package.json

* Added version consistency check script

* Added version check step to build process in package.json
@Beak-man Beak-man requested a review from Copilot August 5, 2025 21:52
Copy link
Copy Markdown

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 implements version consistency validation between package.json and src/WorldWind.js by adding a pre-build check that ensures version numbers are synchronized across the codebase.

  • Added a version consistency validation script that compares version numbers between package.json and WorldWind.js
  • Integrated the version check as a pre-build step in the npm build process
  • Updated the version number in WorldWind.js from "0.9.0" to "0.11.0"

Reviewed Changes

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

File Description
tools/versioncheck.js New validation script that reads and compares version numbers from package.json and WorldWind.js
src/WorldWind.js Updated VERSION constant from "0.9.0" to "0.11.0" and removed outdated comment
package.json Added version check as pre-build step and new npm script for version validation

try {
const jsFilePath = path.join(projectRoot, filePath);
const jsFileContent = fs.readFileSync(jsFilePath, 'utf8');
const regex = /VERSION:\s*"([^"]+)"/;
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The regex pattern is tightly coupled to a specific format with double quotes. Consider making it more flexible to handle both single and double quotes: /VERSION:\s*["']([^"']+)["']/

Suggested change
const regex = /VERSION:\s*"([^"]+)"/;
const regex = /VERSION:\s*["']([^"']+)["']/;

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +48
function compareVersions(version1, version2) {
if (version1 === version2) {
console.log('Version numbers are consistent between package.json and WorldWind.js');
} else {
console.error(`ERROR: Version numbers do not match between package.json and WorldWind.js`);
process.exit(1);
}
}

const packageVersion = getVersionFromPackageJson();
const jsWorldWindVersion = getVersionFromJsFile('src/WorldWind.js');
compareVersions(packageVersion, jsWorldWindVersion); No newline at end of file
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The success message hardcodes 'WorldWind.js' but the function accepts any file path. Consider using the actual file path parameter: console.log('Version numbers are consistent between package.json and ${filePath}');

Suggested change
function compareVersions(version1, version2) {
if (version1 === version2) {
console.log('Version numbers are consistent between package.json and WorldWind.js');
} else {
console.error(`ERROR: Version numbers do not match between package.json and WorldWind.js`);
process.exit(1);
}
}
const packageVersion = getVersionFromPackageJson();
const jsWorldWindVersion = getVersionFromJsFile('src/WorldWind.js');
compareVersions(packageVersion, jsWorldWindVersion);
function compareVersions(version1, version2, filePath) {
if (version1 === version2) {
console.log(`Version numbers are consistent between package.json and ${filePath}`);
} else {
console.error(`ERROR: Version numbers do not match between package.json and ${filePath}`);
process.exit(1);
}
}
const packageVersion = getVersionFromPackageJson();
const jsFilePath = 'src/WorldWind.js';
const jsWorldWindVersion = getVersionFromJsFile(jsFilePath);
compareVersions(packageVersion, jsWorldWindVersion, jsFilePath);

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +48
function compareVersions(version1, version2) {
if (version1 === version2) {
console.log('Version numbers are consistent between package.json and WorldWind.js');
} else {
console.error(`ERROR: Version numbers do not match between package.json and WorldWind.js`);
process.exit(1);
}
}

const packageVersion = getVersionFromPackageJson();
const jsWorldWindVersion = getVersionFromJsFile('src/WorldWind.js');
compareVersions(packageVersion, jsWorldWindVersion); No newline at end of file
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

Similar to the success message, the error message hardcodes 'WorldWind.js'. Since compareVersions doesn't know which file was checked, consider passing the file path as a parameter or restructuring the comparison logic.

Suggested change
function compareVersions(version1, version2) {
if (version1 === version2) {
console.log('Version numbers are consistent between package.json and WorldWind.js');
} else {
console.error(`ERROR: Version numbers do not match between package.json and WorldWind.js`);
process.exit(1);
}
}
const packageVersion = getVersionFromPackageJson();
const jsWorldWindVersion = getVersionFromJsFile('src/WorldWind.js');
compareVersions(packageVersion, jsWorldWindVersion);
function compareVersions(version1, version2, jsFilePath) {
if (version1 === version2) {
console.log(`Version numbers are consistent between package.json and ${jsFilePath}`);
} else {
console.error(`ERROR: Version numbers do not match between package.json and ${jsFilePath}`);
process.exit(1);
}
}
const packageVersion = getVersionFromPackageJson();
const jsFilePath = 'src/WorldWind.js';
const jsWorldWindVersion = getVersionFromJsFile(jsFilePath);
compareVersions(packageVersion, jsWorldWindVersion, jsFilePath);

Copilot uses AI. Check for mistakes.
Co-authored-by: markpet42 <mark.e.peterson@nasa.gov>
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.

3 participants