Skip to content

fix(create), show installation progress when running bit-create from the bit-server-cli #9225

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

Merged
merged 1 commit into from
Oct 2, 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
9 changes: 6 additions & 3 deletions scopes/generator/generator/component-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export type GenerateResult = {
installMissingDependencies?: boolean;
};

export type OnComponentCreateFn = (generateResults: GenerateResult[]) => Promise<void>;
export type InstallOptions = { optimizeReportForNonTerminal?: boolean };

export type OnComponentCreateFn = (generateResults: GenerateResult[], installOptions?: InstallOptions) => Promise<void>;

export class ComponentGenerator {
constructor(
Expand All @@ -48,7 +50,8 @@ export class ComponentGenerator {
private logger: Logger,
private onComponentCreateSlot: OnComponentCreateSlot,
private aspectId: string,
private envId?: ComponentID
private envId?: ComponentID,
private installOptions: InstallOptions = {}
) {}

async generate(force = false): Promise<GenerateResult[]> {
Expand Down Expand Up @@ -101,7 +104,7 @@ export class ComponentGenerator {
private async runOnComponentCreateHook(generateResults: GenerateResult[]) {
const fns = this.onComponentCreateSlot.values();
if (!fns.length) return;
await Promise.all(fns.map((fn) => fn(generateResults)));
await Promise.all(fns.map((fn) => fn(generateResults, this.installOptions)));
}

/**
Expand Down
8 changes: 5 additions & 3 deletions scopes/generator/generator/generator.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { GeneratorAspect } from './generator.aspect';
import { CreateCmd, CreateOptions } from './create.cmd';
import { TemplatesCmd } from './templates.cmd';
import { generatorSchema } from './generator.graphql';
import { ComponentGenerator, GenerateResult, OnComponentCreateFn } from './component-generator';
import { ComponentGenerator, GenerateResult, InstallOptions, OnComponentCreateFn } from './component-generator';
import { WorkspaceGenerator } from './workspace-generator';
import { WorkspaceTemplate } from './workspace-template';
import { NewCmd, NewOptions } from './new.cmd';
Expand Down Expand Up @@ -299,7 +299,8 @@ export class GeneratorMain {
async generateComponentTemplate(
componentNames: string[],
templateName: string,
options: Partial<CreateOptions>
options: Partial<CreateOptions>,
installOptions?: InstallOptions
): Promise<GenerateResult[]> {
if (!this.workspace) throw new OutsideWorkspaceError();
await this.loadAspects();
Expand Down Expand Up @@ -340,7 +341,8 @@ the reason is that after refactoring, the code will have this invalid class: "cl
this.logger,
this.onComponentCreateSlot,
templateWithId.id,
envId
envId,
installOptions
);
return componentGenerator.generate(options.force);
}
Expand Down
7 changes: 6 additions & 1 deletion scopes/harmony/api-server/api-for-ide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,12 @@ export class APIForIDE {
throw new Error('id should include the scope name');
}
const [scope, ...nameSplit] = idIncludeScope.split('/');
return this.generator.generateComponentTemplate([nameSplit.join('/')], templateName, { scope });
return this.generator.generateComponentTemplate(
[nameSplit.join('/')],
templateName,
{ scope },
{ optimizeReportForNonTerminal: true }
);
}

async removeComponent(componentsPattern: string) {
Expand Down
4 changes: 2 additions & 2 deletions scopes/workspace/install/install.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class InstallMain {
this.postInstallSlot.register(fn);
}

async onComponentCreate(generateResults: GenerateResult[]) {
async onComponentCreate(generateResults: GenerateResult[], installOptions?: Partial<WorkspaceInstallOptions>) {
this.workspace.inInstallContext = true;
let runInstall = false;
let packages: string[] = [];
Expand Down Expand Up @@ -243,10 +243,10 @@ export class InstallMain {
// `the following environments are not installed yet: ${nonLoadedEnvs.join(', ')}. installing them now...`
// );
await this.install(packages, {
...installOptions,
addMissingDeps: installMissing,
skipIfExisting: true,
writeConfigFiles: false,
optimizeReportForNonTerminal: !process.stdout.isTTY,
// skipPrune: true,
});
}
Expand Down