import type { GraphqlMain } from '@teambit/graphql'; import type { CLIMain } from '@teambit/cli'; import type { Workspace } from '@teambit/workspace'; import type { EnvDefinition, EnvsMain } from '@teambit/envs'; import type { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files'; import type { ComponentMain, Component } from '@teambit/component'; import type { Harmony, SlotRegistry } from '@teambit/harmony'; import type { GitMain } from '@teambit/git'; import type { AspectLoaderMain } from '@teambit/aspect-loader'; import type { TrackerMain } from '@teambit/tracker'; import type { NewComponentHelperMain } from '@teambit/new-component-helper'; import type { Logger, LoggerMain } from '@teambit/logger'; import type { DeprecationMain } from '@teambit/deprecation'; import type { ComponentTemplate, GetComponentTemplates, PromptResults } from './component-template'; import type { CreateOptions } from './create.cmd'; import type { GenerateResult, InstallOptions, OnComponentCreateFn } from './component-generator'; import type { GetWorkspaceTemplates, WorkspaceTemplate } from './workspace-template'; import type { NewOptions } from './new.cmd'; export type ComponentTemplateSlot = SlotRegistry; export type WorkspaceTemplateSlot = SlotRegistry; export type OnComponentCreateSlot = SlotRegistry; export type TemplateDescriptor = { aspectId: string; titlePrefix?: string; name: string; description?: string; hidden?: boolean; /** * the env that will be used for components created with this template. * only relevant for component templates (not workspace templates). * expected format is an aspect ID string, e.g., "bitdev.react/react-env". */ env?: string; }; type TemplateWithId = { id: string; envName?: string; }; type WorkspaceTemplateWithId = TemplateWithId & { template: WorkspaceTemplate; }; type ComponentTemplateWithId = TemplateWithId & { template: ComponentTemplate; }; type LegacyGlobal = { classInstance: any; methodName: string; value: any; empty: any; }; export type BitApi = { isCoreAspect: (id: string) => boolean; loadBit: (path?: string) => Promise; restoreGlobalsFromSnapshot: (globals: LegacyGlobal[]) => void; takeLegacyGlobalsSnapshot: () => LegacyGlobal[]; }; export type GenerateWorkspaceTemplateResult = { workspacePath: string; appName?: string; }; export type GeneratorConfig = { /** * array of aspects to include in the list of templates. */ aspects: string[]; /** * by default core templates are shown. * use this to hide them unless `--show-all` flag of `bit templates` was used */ hideCoreTemplates: boolean; /** * default envs. */ envs?: string[]; }; export declare class GeneratorMain { private componentTemplateSlot; private workspaceTemplateSlot; private onComponentCreateSlot; private config; private workspace; private envs; private aspectLoader; private newComponentHelper; private componentAspect; private tracker; private logger; private git; private wsConfigFiles; private deprecation; private aspectLoaded; private bitApi; constructor(componentTemplateSlot: ComponentTemplateSlot, workspaceTemplateSlot: WorkspaceTemplateSlot, onComponentCreateSlot: OnComponentCreateSlot, config: GeneratorConfig, workspace: Workspace, envs: EnvsMain, aspectLoader: AspectLoaderMain, newComponentHelper: NewComponentHelperMain, componentAspect: ComponentMain, tracker: TrackerMain, logger: Logger, git: GitMain, wsConfigFiles: WorkspaceConfigFilesMain, deprecation: DeprecationMain); setBitApi(bitApi: BitApi): void; /** * register a new component template. * @param templates array of component templates or a function that returns an array of component templates. * prefer to use the function to improve performance by loading the templates only when needed. */ registerComponentTemplate(templates: ComponentTemplate[] | GetComponentTemplates): this; /** * register a new workspace starter. */ registerWorkspaceTemplate(templates: WorkspaceTemplate[] | GetWorkspaceTemplates): this; registerOnComponentCreate(fn: OnComponentCreateFn): this; /** * list all component templates registered in the workspace or workspace templates in case the * workspace is not available */ listTemplates({ aspect }?: { aspect?: string; }): Promise; private getTemplateDescriptor; /** * @deprecated use this.listTemplates() */ listComponentTemplates(opts: { aspect?: string; }): Promise; isRunningInsideWorkspace(): boolean; /** * get all component templates registered by a specific aspect ID. */ getComponentTemplateByAspect(aspectId: string): ComponentTemplate[]; /** * returns a specific component template. */ getComponentTemplate(name: string, aspectId?: string): Promise; private findTemplateByAspectIdAndName; /** * get or create a global scope, import the non-core aspects, load bit from that scope, create * capsules for the aspects and load them from the capsules. */ private loadAspectsFromGlobalScope; /** * Get the generator aspect and the envs aspect from an harmony instance of the global scope */ private getGlobalGeneratorEnvs; /** * in the case the aspect-id is given and this aspect doesn't exist locally, import it to the * global scope and load it from the capsule */ findWorkspaceTemplateInGlobalScope(aspectId: string, name?: string): Promise<{ workspaceTemplate?: WorkspaceTemplate; aspect?: Component; }>; findTemplateInOtherWorkspace(workspacePath: string, name: string, aspectId?: string): Promise<{ workspaceTemplate: WorkspaceTemplate | undefined; aspect: Component; }>; /** * returns a specific workspace template. */ getWorkspaceTemplate(name: string, aspectId?: string): Promise<{ workspaceTemplate: WorkspaceTemplate; aspect?: Component; }>; searchRegisteredWorkspaceTemplate(name?: string, aspectId?: string, remoteEnvsAspect?: EnvsMain): Promise; getTemplateWithId(templateName: string, aspect?: string): Promise; /** * Parse the scope from a component name if provided in the format: scope/name * This only works for bit.cloud scopes (containing a dot), e.g., "my-org.my-scope/hooks/use-session" * Local bare-scopes don't contain a dot, so we can't distinguish between scope/name and namespace/name. * @returns { scope, name } where scope is the extracted scope (or undefined) and name is the remaining component name */ private parseScopeFromComponentIdStr; generateComponentTemplate(componentNames: string[], templateName: string, options: Partial, installOptions?: InstallOptions, promptResults?: PromptResults): Promise; private getEnvIdFromTemplateWithId; generateWorkspaceTemplate(workspaceName: string, templateName: string, options: NewOptions & { aspect?: string; currentDir?: boolean; }): Promise; private warnAboutDeprecation; private getAllComponentTemplatesDescriptorsFlattened; private getAllComponentTemplatesFlattened; private getAllWorkspaceTemplatesDescriptorFlattened; private getAllWorkspaceTemplatesFlattened; /** * list all starter templates registered by an env. */ listEnvWorkspaceTemplates(envId: string, remoteEnvsAspect?: EnvsMain): Promise>; /** * list all component templates registered by an env. */ listEnvComponentTemplateDescriptors(ids?: string[], aspectId?: string): Promise; getConfiguredEnvs(): string[]; listEnvComponentTemplates(ids?: string[], aspectId?: string): Promise>; loadEnvs(ids?: string[], remoteEnvsAspect?: EnvsMain): Promise; loadAspects(): Promise; /** * Reload the generator config when workspace config changes. * This ensures that changes to envs configuration in workspace.jsonc are reflected * in long-running processes like "bit server". */ onWorkspaceConfigChange(): Promise; static slots: (((registerFn: () => string) => SlotRegistry) | ((registerFn: () => string) => SlotRegistry) | ((registerFn: () => string) => SlotRegistry))[]; static dependencies: import("@teambit/harmony").Aspect[]; static runtime: import("@teambit/harmony").RuntimeDefinition; static provider([workspace, cli, graphql, envs, aspectLoader, newComponentHelper, componentAspect, tracker, loggerMain, git, wsConfigFiles, deprecation,]: [ Workspace, CLIMain, GraphqlMain, EnvsMain, AspectLoaderMain, NewComponentHelperMain, ComponentMain, TrackerMain, LoggerMain, GitMain, WorkspaceConfigFilesMain, DeprecationMain ], config: GeneratorConfig, [componentTemplateSlot, workspaceTemplateSlot, onComponentCreateSlot]: [ ComponentTemplateSlot, WorkspaceTemplateSlot, OnComponentCreateSlot ]): Promise; } export {};