Added version consistency check before each build (#896)#1
Added version consistency check before each build (#896)#1Beak-man wants to merge 2 commits intoCelestialMappingSystem:Earth_for_Moon_switchfrom
Conversation
* Added version consistency check script * Added version check step to build process in package.json
There was a problem hiding this comment.
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*"([^"]+)"/; |
There was a problem hiding this comment.
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*["']([^"']+)["']/
| const regex = /VERSION:\s*"([^"]+)"/; | |
| const regex = /VERSION:\s*["']([^"']+)["']/; |
| 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 |
There was a problem hiding this comment.
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}');
| 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); |
| 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 |
There was a problem hiding this comment.
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.
| 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); |
Co-authored-by: markpet42 <mark.e.peterson@nasa.gov>
Updating CMS fork of WebWW from upstream repository.
Added version consistency check script
Added version check step to build process in package.json