From 99390f307d222dce3754757f160ee1559cf9f675 Mon Sep 17 00:00:00 2001 From: David First Date: Fri, 30 Aug 2024 11:13:40 -0400 Subject: [PATCH] fix(sign), do not throw a ComponentNotFound when a component is in updateDependents prop (#9158) --- scopes/scope/scope/scope.main.runtime.ts | 6 +++ scopes/scope/sign/sign.main.runtime.ts | 6 ++- .../scope-components-importer.ts | 37 +++++++++++++------ 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/scopes/scope/scope/scope.main.runtime.ts b/scopes/scope/scope/scope.main.runtime.ts index 26c3f7d3f2a7..039ede231c6b 100644 --- a/scopes/scope/scope/scope.main.runtime.ts +++ b/scopes/scope/scope/scope.main.runtime.ts @@ -653,6 +653,7 @@ export class ScopeMain implements ComponentFactory { useCache = true, reFetchUnBuiltVersion = true, preferDependencyGraph = true, + includeUpdateDependents = false, lane, reason, }: { @@ -674,6 +675,10 @@ export class ScopeMain implements ComponentFactory { * if an external is missing and the remote has it with the dependency graph, don't fetch all its dependencies */ preferDependencyGraph?: boolean; + /** + * include the updateDependents components on a lane (generally, on a workspace, it's not needed) + */ + includeUpdateDependents?: boolean; /** * reason why this import is needed (to show in the terminal) */ @@ -690,6 +695,7 @@ export class ScopeMain implements ComponentFactory { reFetchUnBuiltVersion, lane, preferDependencyGraph, + includeUpdateDependents, reason, }); } diff --git a/scopes/scope/sign/sign.main.runtime.ts b/scopes/scope/sign/sign.main.runtime.ts index aed2425ac437..11bc9c9e7f0f 100644 --- a/scopes/scope/sign/sign.main.runtime.ts +++ b/scopes/scope/sign/sign.main.runtime.ts @@ -76,7 +76,11 @@ export class SignMain { this.scope.legacyScope.setCurrentLaneId(laneId); this.scope.legacyScope.scopeImporter.shouldOnlyFetchFromCurrentLane = true; } - await this.scope.import(ids, { lane, reason: 'which are the seeders for the sign process' }); + await this.scope.import(ids, { + lane, + includeUpdateDependents: true, + reason: 'which are the seeders for the sign process', + }); longProcessLogger.end('success'); } const { componentsToSkip, componentsToSign } = await this.getComponentIdsToSign(ids, rebuild); diff --git a/src/scope/component-ops/scope-components-importer.ts b/src/scope/component-ops/scope-components-importer.ts index 233efaf2a3d1..2e859d44c6c8 100644 --- a/src/scope/component-ops/scope-components-importer.ts +++ b/src/scope/component-ops/scope-components-importer.ts @@ -106,6 +106,7 @@ export default class ScopeComponentsImporter { ignoreMissingHead = false, preferDependencyGraph = true, includeUnexported = false, + includeUpdateDependents = false, reason, }: { ids: ComponentIdList; @@ -117,6 +118,7 @@ export default class ScopeComponentsImporter { ignoreMissingHead?: boolean; // needed when fetching "main" objects when on a lane preferDependencyGraph?: boolean; // if an external is missing and the remote has it with the dependency graph, don't fetch all its dependencies includeUnexported?: boolean; // whether filter out new component-ids that were not exported yet (default), or not (for cases we want to fix out-of-sync scenarios) + includeUpdateDependents?: boolean; // whether to include the updateDependents components on a lane reason?: string; // reason why this import is needed }): Promise { if (!ids.length) return []; @@ -165,16 +167,15 @@ export default class ScopeComponentsImporter { logger.debug('importMany', `total missing externals: ${uniqExternals.length}`); const remotes = await getScopeRemotes(this.scope); // we don't care about the VersionDeps returned here as it may belong to the dependencies - await this.getExternalMany( - uniqExternals, - remotes, + await this.getExternalMany(uniqExternals, remotes, { throwForDependencyNotFound, lane, - throwForSeederNotFound, + throwOnUnavailableScope: throwForSeederNotFound, preferDependencyGraph, includeUnexported, - reason - ); + includeUpdateDependents, + reason, + }); if (shouldRefetchIncompleteHistory) { await this.warnForIncompleteVersionHistory(incompleteVersionHistory); @@ -803,12 +804,23 @@ export default class ScopeComponentsImporter { private async getExternalMany( ids: ComponentID[], remotes: Remotes, - throwForDependencyNotFound = false, - lane?: Lane, - throwOnUnavailableScope = true, - preferDependencyGraph = false, - includeUnexported = false, - reason?: string + { + throwForDependencyNotFound = false, + lane, + throwOnUnavailableScope = true, + preferDependencyGraph = false, + includeUnexported = false, + includeUpdateDependents = false, + reason, + }: { + throwForDependencyNotFound?: boolean; + lane?: Lane; + throwOnUnavailableScope?: boolean; + preferDependencyGraph?: boolean; + includeUnexported?: boolean; + includeUpdateDependents?: boolean; + reason?: string; + } = {} ): Promise { if (!ids.length) return []; lane = await this.getLaneForFetcher(lane); @@ -830,6 +842,7 @@ export default class ScopeComponentsImporter { withoutDependencies: false, // backward compatibility. not needed for remotes > 0.0.900 includeDependencies: true, includeVersionHistory: true, + includeUpdateDependents, onlyIfBuilt, preferDependencyGraph, laneId: lane?.id(),