Skip to content

Commit

Permalink
chore: respect ALLOWED_INCONSISTENT_DEPENDENCIES for workspace packag…
Browse files Browse the repository at this point in the history
…es; simplify logic
  • Loading branch information
legobeat committed Oct 16, 2024
1 parent f1c6dc4 commit 0aec676
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 0aec676

Please sign in to comment.