-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add automated check of Angular compiler versions
Relates to #758. Prevents future updates to the Angular versions from introducing version mismatch errors
- Loading branch information
1 parent
05b2b12
commit 34a7690
Showing
3 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* tslint:disable:no-console */ | ||
import path from 'path'; | ||
|
||
/** | ||
* Checks the versions of the Angular compiler packages between the `admin-ui` and `ui-devkit` packages. | ||
* These must match exactly since using different packages can introduce errors when compiling | ||
* with the ui-devkit. | ||
* See https://github.com/vendure-ecommerce/vendure/issues/758 for more on this issue. | ||
*/ | ||
async function checkAngularVersions() { | ||
const adminUiPackageJson = await import('../packages/admin-ui/package.json'); | ||
const uiDevkitPackageJson = await import('../packages/ui-devkit/package.json'); | ||
|
||
const angularCompilerPackages = ['@angular/cli', '@angular/compiler-cli', '@angular/compiler']; | ||
const illegalSemverPrefixes = /^[~^]/; | ||
const errors: string[] = []; | ||
|
||
for (const pkg of angularCompilerPackages) { | ||
const uiVersion = | ||
adminUiPackageJson.devDependencies[pkg as keyof typeof adminUiPackageJson.devDependencies]; | ||
const devkitVersion = | ||
uiDevkitPackageJson.dependencies[pkg as keyof typeof uiDevkitPackageJson.dependencies]; | ||
|
||
if (illegalSemverPrefixes.test(uiVersion)) { | ||
errors.push(`Angular compiler versions must be exact, got "${uiVersion}" in admin-ui package`); | ||
} | ||
if (illegalSemverPrefixes.test(devkitVersion)) { | ||
errors.push( | ||
`Angular compiler versions must be exact, got "${devkitVersion}" in ui-devkit package`, | ||
); | ||
} | ||
|
||
if (uiVersion !== devkitVersion) { | ||
errors.push( | ||
`Angular compiler package mismatch [${pkg}] admin-ui: "${uiVersion}", ui-devkit: "${devkitVersion}"`, | ||
); | ||
} | ||
} | ||
if (errors.length) { | ||
for (const error of errors) { | ||
console.log(`ERROR: ${error}`); | ||
} | ||
process.exit(1); | ||
} else { | ||
console.log(`Angular compiler package check passed`); | ||
process.exit(0); | ||
} | ||
} | ||
|
||
checkAngularVersions(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters