Skip to content

Commit

Permalink
chore(constraints): respect ALLOWED_INCONSISTENT_DEPENDENCIES for wor…
Browse files Browse the repository at this point in the history
…kspace packages; simplify logic (#4800)
  • Loading branch information
legobeat authored Oct 16, 2024
1 parent f1c6dc4 commit d106b1a
Showing 1 changed file with 22 additions and 16 deletions.
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),
),
);
}

/**
Expand Down

0 comments on commit d106b1a

Please sign in to comment.