import type { CompilerMain } from '@teambit/compiler'; import type { CLIMain } from '@teambit/cli'; import type { Workspace } from '@teambit/workspace'; import type { GenerateResult, GeneratorMain } from '@teambit/generator'; import type { ApplicationMain } from '@teambit/application'; import type { VariantsMain } from '@teambit/variants'; import type { Component } from '@teambit/component'; import { ComponentMap } from '@teambit/component'; import type { Harmony, SlotRegistry } from '@teambit/harmony'; import { type DependenciesGraph } from '@teambit/objects'; import type { CodemodResult, NodeModulesLinksResult } from '@teambit/workspace.modules.node-modules-linker'; import type { EnvsMain } from '@teambit/envs'; import type { IpcEventsMain } from '@teambit/ipc-events'; import type { WorkspaceDependencyLifecycleType, DependencyResolverMain, LinkingOptions, LinkResults, MergedOutdatedPkg, WorkspacePolicy } from '@teambit/dependency-resolver'; import type { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files'; import type { Logger, LoggerMain } from '@teambit/logger'; import type { IssuesMain } from '@teambit/issues'; import type { AspectLoaderMain } from '@teambit/aspect-loader'; import type { BundlerMain } from '@teambit/bundler'; import type { UiMain } from '@teambit/ui'; export type WorkspaceLinkOptions = LinkingOptions & { rootPolicy?: WorkspacePolicy; linkToBitRoots?: boolean; includePeers?: boolean; }; export type WorkspaceLinkResults = { legacyLinkResults?: NodeModulesLinksResult[]; legacyLinkCodemodResults?: CodemodResult[]; } & LinkResults; export type WorkspaceInstallOptions = { addMissingDeps?: boolean; skipUnavailable?: boolean; addMissingPeers?: boolean; lifecycleType?: WorkspaceDependencyLifecycleType; dedupe?: boolean; import?: boolean; showExternalPackageManagerPrompt?: boolean; copyPeerToRuntimeOnRoot?: boolean; copyPeerToRuntimeOnComponents?: boolean; updateExisting?: boolean; skipIfExisting?: boolean; savePrefix?: string; compile?: boolean; includeOptionalDeps?: boolean; updateAll?: boolean; recurringInstall?: boolean; optimizeReportForNonTerminal?: boolean; lockfileOnly?: boolean; writeConfigFiles?: boolean; skipPrune?: boolean; dependenciesGraph?: DependenciesGraph; allowScripts?: Record; }; export type ModulesInstallOptions = Omit; type PreLink = (linkOpts?: WorkspaceLinkOptions) => Promise; type PreInstall = (installOpts?: WorkspaceInstallOptions) => Promise; type PostInstall = () => Promise; type PreLinkSlot = SlotRegistry; type PreInstallSlot = SlotRegistry; type PostInstallSlot = SlotRegistry; export declare class InstallMain { private dependencyResolver; private logger; private workspace; private variants; private compiler; private envs; private wsConfigFiles; private aspectLoader; private app; private generator; private preLinkSlot; private preInstallSlot; private postInstallSlot; private ipcEvents; private harmony; private visitedAspects; private oldNonLoadedEnvs; constructor(dependencyResolver: DependencyResolverMain, logger: Logger, workspace: Workspace, variants: VariantsMain, compiler: CompilerMain, envs: EnvsMain, wsConfigFiles: WorkspaceConfigFilesMain, aspectLoader: AspectLoaderMain, app: ApplicationMain, generator: GeneratorMain, preLinkSlot: PreLinkSlot, preInstallSlot: PreInstallSlot, postInstallSlot: PostInstallSlot, ipcEvents: IpcEventsMain, harmony: Harmony); /** * Install dependencies for all components in the workspace * * @returns * @memberof Workspace */ install(packages?: string[], options?: WorkspaceInstallOptions): Promise>; writeDependenciesToPackageJson(): Promise; registerPreLink(fn: PreLink): void; registerPreInstall(fn: PreInstall): void; registerPostInstall(fn: PostInstall): void; onComponentCreate(generateResults: GenerateResult[], installOptions?: Partial): Promise; private _addPackages; private _installModules; private shouldClearCacheOnInstall; /** * Called only when the package manager install failed. A "No matching version found" failure usually points * at a component dependency that resolves to a snap which was never published — its build failed or hasn't * completed yet (commonly a hidden lane "update-dependent" re-snapped by "snap updates" / Ripple CI, but not * necessarily). Such a dep isn't checked out, so it can't be linked from source and there's no package to * fetch. When the failing package matches one of those deps, return an actionable error (pointing at * `bit import`); otherwise return the original error unchanged. * * We resolve the culprit by matching the package manager error against the resolved component dependencies * rather than the lane's `updateDependents`, for two reasons: (1) the failing dep is not a workspace component, * so its component-id (needed for the `bit import` remediation) is only recoverable from the resolved deps of * the checked-out components — there's no package-name→id map for it; (2) `updateDependents` is unreliable — * forking a lane drops it and `reset` moves entries out of it, so a never-published snap can still be pinned * while no longer tracked there. The scan reads already-loaded in-memory dep data (no fetch). */ private enrichUnpublishedSnapDepError; /** * This function is very important to fix some issues that might happen during the installation process. * The case is the following: * during/before the installation process we load some envs from their bit.env files * this contains code like: * protected tsconfigPath = require.resolve('./config/tsconfig.json'); * protected eslintConfigPath = require.resolve('./config/eslintrc.cjs'); * When we load that file, we calculated the resolved path, and it's stored in the env * object instance. * then later on during the install we move the env to another location (like bit roots) * which points to a .pnpm folder with some peers, that changed during the install * then when we take this env object and call write ws config for example * or compile * we use that resolved path to calculate the final tsconfig * however that file is no longer exists which result in an error * This function will check if an env folder doesn't exist anymore, and will re-load it * from its new location. * This usually happen when we have install running in the middle of the process followed * by other bit ops. * examples: * bit new - which might run few installs then other ops. * bit switch - which might run few installs then other ops, and potentially change the * peer deps during the install. * bit server (vscode plugin) - which keep the process always live, so any install ops * that change the location, will cause the vscode plugin/bit server to crash later. * @returns */ private reloadMovedEnvs; private reloadRegisteredEnvs; private reloadNonLoadedEnvs; private reloadEnvs; private reloadAspects; private reloadOneAspectsGroup; /** * This function groups the components to aspects to load into groups. * The order of the groups is important, the first group should be loaded first. * The order inside the group is not important. * The groups are: * 1. aspects definitions without components (this should be an empty group, if it's not, we should check why). * 2. aspects which are not in the workspace but in the scope / node modules. * 3. envs of aspects (which are also aspects) * 4. other aspects (the rest) * @param aspects * @returns */ private groupAspectsToLoad; private regroupEnvsIdsFromTheList; private _getComponentsManifestsAndRootPolicy; /** * The function `tryWriteConfigFiles` attempts to write workspace config files, and if it fails, it logs an error * message. * @returns If the condition `!shouldWrite` is true, then nothing is being returned. Otherwise, if the `writeConfigFiles` * function is successfully executed, nothing is being returned. If an error occurs during the execution of * `writeConfigFiles`, an error message is being returned. */ private tryWriteConfigFiles; private addConfiguredAspectsToWorkspacePolicy; private addConfiguredGeneratorEnvsToWorkspacePolicy; private _addMissingPackagesToRootPolicy; private _getMissingPackagesWithoutRootDeps; private _getAllMissingPackages; private _getComponentsManifests; setOldNonLoadedEnvs(): string[]; /** * This function returns a list of old non-loaded environments names. * @returns an array of strings called `oldNonLoadedEnvs`. This array contains the names of environment variables that * failed to load as extensions and are also don't have an env.jsonc file. * If this list is not empty, then the user might need to run another install to make sure all dependencies resolved * correctly */ getOldNonLoadedEnvs(): string[]; private _updateRootDirs; private _getRootManifests; private _getEnvManifests; /** * Get the env's own peer dependencies from its policy (env.jsonc). * Resolves "+" version placeholders using workspaceDeps. */ private _getEnvDependencies; /** * Return the package name of the env with its version. * (only if the env is not a core env and is not in the workspace) * @param envId * @returns */ private _getEnvPackage; private _getAppManifests; /** * Update env.jsonc policy files for environment components based on a list of outdated packages. * @param outdatedPkgs - List of outdated packages. */ updateEnvJsoncPolicies(outdatedPkgs: MergedOutdatedPkg[]): Promise; private _getAllUsedEnvIds; /** * Updates out-of-date dependencies in the workspace. * * @param options.all {Boolean} updates all outdated dependencies without showing a prompt. */ updateDependencies(options: { forceVersionBump?: 'major' | 'minor' | 'patch' | 'compatible'; patterns?: string[]; all: boolean; }): Promise | null>; addDuplicateComponentAndPackageIssue(components: Component[]): Promise; private _updateComponentsConfig; private _updateVariantsPolicies; /** * Uninstall the specified packages from dependencies. * * @param {string[]} the list of packages that should be removed from dependencies. */ uninstallDependencies(packages: string[]): Promise>; /** * This function returns all the locations of the external links that should be created inside node_modules. * This information may then be passed to the package manager, which will create the links on its own. */ calculateLinks(options?: WorkspaceLinkOptions): Promise<{ linkResults: WorkspaceLinkResults; linkedRootDeps: Record; }>; linkCodemods(compDirMap: ComponentMap, options?: { rewire?: boolean; }): Promise<{ linksResults: NodeModulesLinksResult[]; codemodResults: any; }>; link(options?: WorkspaceLinkOptions): Promise; private _linkAllComponentsToBitRoots; private getRootComponentDirByRootId; /** * Generate a filter to pass to the installer * This will filter deps which are come from remotes which defined in scope.json * those components comes from local remotes, usually doesn't have a package in a registry * so no reason to try to install them (it will fail) */ private generateFilterFnForDepsFromLocalRemote; private getComponentsDirectory; private onRootAspectAddedSubscriber; private onAspectsResolveSubscriber; onComponentChange(component: Component): Promise; static slots: (((registerFn: () => string) => SlotRegistry) | ((registerFn: () => string) => SlotRegistry))[]; static dependencies: import("@teambit/harmony").Aspect[]; static runtime: import("@teambit/harmony").RuntimeDefinition; static provider([dependencyResolver, workspace, loggerExt, variants, cli, compiler, issues, envs, app, ipcEvents, generator, wsConfigFiles, aspectLoader, bundler, ui,]: [ DependencyResolverMain, Workspace, LoggerMain, VariantsMain, CLIMain, CompilerMain, IssuesMain, EnvsMain, ApplicationMain, IpcEventsMain, GeneratorMain, WorkspaceConfigFilesMain, AspectLoaderMain, BundlerMain, UiMain ], _: any, [preLinkSlot, preInstallSlot, postInstallSlot]: [PreLinkSlot, PreInstallSlot, PostInstallSlot], harmony: Harmony): Promise; private handleExternalPackageManagerPrompt; private disableExternalPackageManagerMode; private removePostInstallScript; } export default InstallMain;