Skip to content

Commit

Permalink
resolve dependencies versions from updateDependents prop if exists (#…
Browse files Browse the repository at this point in the history
…8883)

In case the current lane has `updateDependents` prop (see
#8534 for more info) , the
dependencies versions are resolved from there.
  • Loading branch information
davidfirst authored May 13, 2024
1 parent 8bdaf5c commit 08282da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class DependenciesLoader {
applyOverrides.issues = dependenciesData.issues;
const results = await applyOverrides.getDependenciesData();
this.setDependenciesDataOnComponent(results.dependenciesData, results.overridesDependencies);
updateDependenciesVersions(
await updateDependenciesVersions(
this.depsResolver,
workspace,
this.component,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { DebugComponentsDependency, getValidVersion } from './auto-detect-deps';

type DepType = 'dependencies' | 'devDependencies' | 'peerDependencies';

export function updateDependenciesVersions(
export async function updateDependenciesVersions(
depsResolver: DependencyResolverMain,
workspace: Workspace,
component: Component,
Expand All @@ -25,6 +25,7 @@ export function updateDependenciesVersions(
) {
const consumer: Consumer = workspace.consumer;
const autoDetectConfigMerge = workspace.getAutoDetectConfigMerge(component.id) || {};
const currentLane = await workspace.getCurrentLaneObject();

updateDependencies(component.dependencies, 'dependencies');
updateDependencies(component.devDependencies, 'devDependencies');
Expand All @@ -44,6 +45,7 @@ export function updateDependenciesVersions(
const idFromComponentConfig = getIdFromComponentConfig(id);
const getFromComponentConfig = () => idFromComponentConfig;
const getFromBitMap = () => idFromBitMap || null;
const getFromUpdateDependentsOnLane = () => getIdFromUpdateDependentsOnLane(id);
// later, change this to return the version from the overrides.
const getFromOverrides = () => resolveFromOverrides(id, depType, pkg);
const debugDep = debugDependencies?.find((dep) => dep.id.isEqualWithoutVersion(id));
Expand All @@ -67,6 +69,7 @@ export function updateDependenciesVersions(
getFromComponentConfig,
getFromOverrides,
getFromBitMap,
getFromUpdateDependentsOnLane,
getFromDepPackageJsonDueToWorkspacePolicy,
getFromMergeConfig,
getFromDepPackageJsonDueToAutoDetectOverrides,
Expand Down Expand Up @@ -126,6 +129,12 @@ export function updateDependenciesVersions(
return existingIds.length === 1 ? existingIds[0] : undefined;
}

function getIdFromUpdateDependentsOnLane(id: ComponentID) {
const updateDependents = currentLane?.updateDependents;
if (!updateDependents) return undefined;
return updateDependents.find((dep) => dep.isEqualWithoutVersion(id));
}

function getIdFromComponentConfig(componentId: ComponentID): ComponentID | undefined {
const dependencies = component.overrides.getComponentDependenciesWithVersion();
if (isEmpty(dependencies)) return undefined;
Expand Down

0 comments on commit 08282da

Please sign in to comment.