Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ng-dev/release): run yarn integrity check before performing a release #264

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ng-dev/release/publish/external-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,28 @@ export async function invokeYarnInstallCommand(projectDir: string): Promise<void
export async function invokeYarnIntegryCheck(projectDir: string): Promise<void> {
try {
await spawn('yarn', ['check', '--integrity'], {cwd: projectDir, mode: 'silent'});
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need https://classic.yarnpkg.com/en/docs/cli/check/#toc-yarn-check-verify-tree?

seems like the integrity check just checks the package json against the lock file unless I misunderstand the documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we need both, now that I read it closer.

Because we want to make sure that our package.json matches installed deps and we want to make sure that our package.json matches our yarn.lock.

Does that make sense?

Copy link
Member

Choose a reason for hiding this comment

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

I think that makes sense, yeah 👍

info(green(' ✓ Confirmed installed dependencies match those defined in package.json.'));
info(green(' ✓ Confirmed dependencies from package.json match those in yarn.lock.'));
} 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();
}
}

/**
* Invokes the `yarn check --verify-tree` command in order to verify up to date dependencies.
*/
export async function invokeYarnVerifyTreeCheck(projectDir: string): Promise<void> {
try {
await spawn('yarn', ['check', '--verify-tree'], {cwd: projectDir, mode: 'silent'});
info(
green(
' ✓ Confirmed installed installed dependencies match those defined in package.json.',
josephperrott marked this conversation as resolved.
Show resolved Hide resolved
),
);
} catch (e) {
error(red(' ✘ Failed yarn verify tree check, your installed dependencies are likely out'));
error(red(' of date. Please run `yarn install` to update your installed dependencies.'));
throw new FatalReleaseActionError();
}
}
3 changes: 2 additions & 1 deletion ng-dev/release/publish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +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';
import {invokeYarnIntegryCheck, invokeYarnVerifyTreeCheck} from './external-commands';

export enum CompletionState {
SUCCESS,
Expand Down Expand Up @@ -153,6 +153,7 @@ export class ReleaseTool {
*/
private async _verifyInstalledDependenciesAreUpToDate(): Promise<boolean> {
try {
await invokeYarnVerifyTreeCheck(this._projectRoot);
await invokeYarnIntegryCheck(this._projectRoot);
return true;
} catch {
Expand Down