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

fix(component compare): import missing objects from main #8858

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { ComponentAspect, Component, ComponentMain } from '@teambit/component';
import { componentCompareSchema } from './component-compare.graphql';
import { ComponentCompareAspect } from './component-compare.aspect';
import { DiffCmd } from './diff-cmd';
import { ImporterAspect, ImporterMain } from '@teambit/importer';

export type ComponentCompareResult = {
id: string;
Expand All @@ -48,6 +49,7 @@ export class ComponentCompareMain {
private logger: Logger,
private tester: TesterMain,
private depResolver: DependencyResolverMain,
private importer: ImporterMain,
private workspace?: Workspace
) {}

Expand All @@ -60,6 +62,11 @@ export class ComponentCompareMain {
throw new BitError(`component ${compareCompId.toString()} doesn't have any version yet`);
}

// import missing components that might be on main
await this.importer.importObjectsFromMainIfExist([baseCompId, compareCompId], {
cache: true,
});

const baseVersion = baseCompId.version as string;
const compareVersion = compareCompId.version as string;

Expand Down Expand Up @@ -292,20 +299,30 @@ export class ComponentCompareMain {
WorkspaceAspect,
TesterAspect,
DependencyResolverAspect,
ImporterAspect,
];
static runtime = MainRuntime;
static async provider([graphql, component, scope, loggerMain, cli, workspace, tester, depResolver]: [
static async provider([graphql, component, scope, loggerMain, cli, workspace, tester, depResolver, importer]: [
GraphqlMain,
ComponentMain,
ScopeMain,
LoggerMain,
CLIMain,
Workspace,
TesterMain,
DependencyResolverMain
DependencyResolverMain,
ImporterMain
]) {
const logger = loggerMain.createLogger(ComponentCompareAspect.id);
const componentCompareMain = new ComponentCompareMain(component, scope, logger, tester, depResolver, workspace);
const componentCompareMain = new ComponentCompareMain(
component,
scope,
logger,
tester,
depResolver,
importer,
workspace
);
cli.register(new DiffCmd(componentCompareMain));
graphql.register(componentCompareSchema(componentCompareMain));
return componentCompareMain;
Expand Down
2 changes: 1 addition & 1 deletion scopes/lanes/lanes/lanes.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ please create a new lane instead, which will include all components of this lane
)
: [];

await this.importer.importObjectsFromMainIfExist(targetMainHeads);
await this.importer.importObjectsFromMainIfExist(targetMainHeads, { cache: true });

const diffProps = compact(
await Promise.all(
Expand Down
4 changes: 2 additions & 2 deletions scopes/scope/importer/importer.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ export class ImporterMain {
return importComponents.importComponents();
}

async importObjectsFromMainIfExist(ids: ComponentID[]) {
async importObjectsFromMainIfExist(ids: ComponentID[], { cache } = { cache: false }) {
await this.scope.legacyScope.scopeImporter.importWithoutDeps(ComponentIdList.fromArray(ids), {
cache: false,
cache,
includeVersionHistory: true,
ignoreMissingHead: true,
});
Expand Down