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

chore(constraints): respect ALLOWED_INCONSISTENT_DEPENDENCIES for workspace packages; simplify logic #4800

Merged
Changes from all commits
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
38 changes: 22 additions & 16 deletions yarn.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ const { basename, resolve } = require('path');
const semver = require('semver');
const { inspect } = require('util');

/**
* These packages and ranges are allowed to mismatch expected consistency checks
* Only intended as temporary measures to faciliate upgrades and releases.
* This should trend towards empty.
*/
const ALLOWED_INCONSISTENT_DEPENDENCIES = {
'@metamask/rpc-errors': ['^7.0.0'],
};

/**
* Aliases for the Yarn type definitions, to make the code more readable.
*
Expand Down Expand Up @@ -594,6 +603,11 @@ function expectUpToDateWorkspaceDependenciesAndDevDependencies(
dependencyWorkspace !== null &&
dependency.type !== 'peerDependencies'
) {
const ignoredRanges = ALLOWED_INCONSISTENT_DEPENDENCIES[dependency.ident];
if (ignoredRanges?.includes(dependency.range)) {
continue;
}

dependency.update(`^${dependencyWorkspace.manifest.version}`);
}
}
Expand Down Expand Up @@ -714,10 +728,6 @@ function expectControllerDependenciesListedAsPeerDependencies(
}
}

const ALLOWED_INCONSISTENT_DEPENDENCIES = Object.entries({
'@metamask/rpc-errors': ['^7.0.0'],
});

/**
* Filter out dependency ranges which are not to be considered in `expectConsistentDependenciesAndDevDependencies`.
*
Expand All @@ -729,19 +739,15 @@ function getInconsistentDependenciesAndDevDependencies(
dependencyIdent,
dependenciesByRange,
) {
for (const [
allowedPackage,
ignoredRange,
] of ALLOWED_INCONSISTENT_DEPENDENCIES) {
if (allowedPackage === dependencyIdent) {
return new Map(
Object.entries(dependenciesByRange).filter(
([range]) => !ignoredRange.includes(range),
),
);
}
const ignoredRanges = ALLOWED_INCONSISTENT_DEPENDENCIES[dependencyIdent];
if (!ignoredRanges) {
return dependenciesByRange;
}
return dependenciesByRange;
return new Map(
Object.entries(dependenciesByRange).filter(
([range]) => !ignoredRanges.includes(range),
),
);
legobeat marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Loading