diff --git a/ng-dev/release/publish/external-commands.ts b/ng-dev/release/publish/external-commands.ts index 402f9df3ed..d14fcbe3c7 100644 --- a/ng-dev/release/publish/external-commands.ts +++ b/ng-dev/release/publish/external-commands.ts @@ -97,3 +97,17 @@ export async function invokeYarnInstallCommand(projectDir: string): Promise { + try { + await spawn('yarn', ['check', '--integrity'], {cwd: projectDir, mode: 'silent'}); + info(green(' ✓ Confirmed installed dependencies match those defined in package.json.')); + } catch (e) { + error(red(' ✘ Failed yarn integrity check, your installed dependencies are likely out of')); + error(red(' date. Please run `yarn install` to update your installed dependencies.')); + throw new FatalReleaseActionError(); + } +} diff --git a/ng-dev/release/publish/index.ts b/ng-dev/release/publish/index.ts index 4d536c4e0b..c82ff6eeeb 100644 --- a/ng-dev/release/publish/index.ts +++ b/ng-dev/release/publish/index.ts @@ -19,6 +19,7 @@ import {getNextBranchName, ReleaseRepoWithApi} from '../versioning/version-branc import {ReleaseAction} from './actions'; import {FatalReleaseActionError, UserAbortedReleaseActionError} from './actions-error'; import {actions} from './actions/index'; +import {invokeYarnIntegryCheck} from './external-commands'; export enum CompletionState { SUCCESS, @@ -51,7 +52,8 @@ export class ReleaseTool { if ( !(await this._verifyNoUncommittedChanges()) || !(await this._verifyRunningFromNextBranch(nextBranchName)) || - !(await this._verifyNoShallowRepository()) + !(await this._verifyNoShallowRepository()) || + !(await this._verifyInstalledDependenciesAreUpToDate()) ) { return CompletionState.FATAL_ERROR; } @@ -144,6 +146,20 @@ export class ReleaseTool { return true; } + /** + * Verifiy that the install dependencies match the the versions defined in the package.json and + * yarn.lock files. + * @returns a boolean indicating success or failure. + */ + private async _verifyInstalledDependenciesAreUpToDate(): Promise { + try { + await invokeYarnIntegryCheck(this._projectRoot); + return true; + } catch { + return false; + } + } + /** * Verifies that the local repository is not configured as shallow. * @returns a boolean indicating success or failure.