Skip to content

improvement(new), warn for deprecated starter #9161

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 2 commits into from
Aug 30, 2024
Merged
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
22 changes: 19 additions & 3 deletions scopes/generator/generator/generator.main.runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { TrackerAspect, TrackerMain } from '@teambit/tracker';
import { NewComponentHelperAspect, NewComponentHelperMain } from '@teambit/new-component-helper';
import { compact, uniq } from 'lodash';
import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';
import { DeprecationAspect, DeprecationMain } from '@teambit/deprecation';
import { ComponentTemplate } from './component-template';
import { GeneratorAspect } from './generator.aspect';
import { CreateCmd, CreateOptions } from './create.cmd';
Expand Down Expand Up @@ -90,7 +91,8 @@ export class GeneratorMain {
private tracker: TrackerMain,
private logger: Logger,
private git: GitMain,
private wsConfigFiles: WorkspaceConfigFilesMain
private wsConfigFiles: WorkspaceConfigFilesMain,
private deprecation: DeprecationMain
) {}

/**
Expand Down Expand Up @@ -380,10 +382,20 @@ the reason is that after refactoring, the code will have this invalid class: "cl

if (!workspaceTemplate) throw new BitError(`template "${templateName}" was not found`);
const workspaceGenerator = new WorkspaceGenerator(workspaceName, workspacePath, options, workspaceTemplate, aspect);
await this.warnAboutDeprecation(aspect);
await workspaceGenerator.generate();
return { workspacePath, appName: workspaceTemplate.appName };
}

private async warnAboutDeprecation(aspect?: Component) {
if (!aspect) return;
const deprecationInfo = await this.deprecation.getDeprecationInfo(aspect);
if (deprecationInfo.isDeprecate) {
const newStarterMsg = deprecationInfo.newId ? `, use "${deprecationInfo.newId.toString()}" instead` : '';
this.logger.consoleWarning(`the starter "${aspect?.id.toString()}" is deprecated${newStarterMsg}`);
}
}

private async getAllComponentTemplatesDescriptorsFlattened(aspectId?: string): Promise<Array<TemplateDescriptor>> {
const envTemplates = await this.listEnvComponentTemplateDescriptors([], aspectId);
if (envTemplates && envTemplates.length) {
Expand Down Expand Up @@ -541,6 +553,7 @@ the reason is that after refactoring, the code will have this invalid class: "cl
LoggerAspect,
GitAspect,
WorkspaceConfigFilesAspect,
DeprecationAspect,
];

static runtime = MainRuntime;
Expand All @@ -558,6 +571,7 @@ the reason is that after refactoring, the code will have this invalid class: "cl
loggerMain,
git,
wsConfigFiles,
deprecation,
]: [
Workspace,
CLIMain,
Expand All @@ -569,7 +583,8 @@ the reason is that after refactoring, the code will have this invalid class: "cl
TrackerMain,
LoggerMain,
GitMain,
WorkspaceConfigFilesMain
WorkspaceConfigFilesMain,
DeprecationMain
],
config: GeneratorConfig,
[componentTemplateSlot, workspaceTemplateSlot, onComponentCreateSlot]: [
Expand All @@ -592,7 +607,8 @@ the reason is that after refactoring, the code will have this invalid class: "cl
tracker,
logger,
git,
wsConfigFiles
wsConfigFiles,
deprecation
);
const commands = [new CreateCmd(generator), new TemplatesCmd(generator), new NewCmd(generator)];
cli.register(...commands);
Expand Down