import type { INpmCheckPackageSummary } from '@rushstack/npm-check-fork';
import { type ITerminal } from '@rushstack/terminal';
import type { RushConfiguration } from '../api/RushConfiguration';
import { DependencyType } from '../api/PackageJsonEditor';
import type { RushGlobalFolder } from '../api/RushGlobalFolder';
import type { RushConfigurationProject } from '../api/RushConfigurationProject';
import type { VersionMismatchFinderEntity } from './versionMismatch/VersionMismatchFinderEntity';
import { type IPackageJsonUpdaterRushBaseUpdateOptions } from './PackageJsonUpdaterTypes';
/**
 * Options for adding a dependency to a particular project.
 */
export interface IPackageJsonUpdaterRushUpgradeOptions {
    /**
     * The projects whose package.jsons should get updated
     */
    projects: RushConfigurationProject[];
    /**
     * The dependencies to be added.
     */
    packagesToAdd: INpmCheckPackageSummary[];
    /**
     * If specified, other packages that use this dependency will also have their package.json's updated.
     */
    updateOtherPackages: boolean;
    /**
     * If specified, "rush update" will not be run after updating the package.json file(s).
     */
    skipUpdate: boolean;
    /**
     * If specified, "rush update" will be run in debug mode.
     */
    debugInstall: boolean;
    /**
     * The variant to consider when performing installations and validating shrinkwrap updates.
     */
    variant: string | undefined;
}
/**
 * Configuration options for adding or updating a dependency in single project
 * or removing a dependency from a particular project
 */
export interface IBaseUpdateProjectOptions {
    /**
     * The project which will have its package.json updated
     */
    project: VersionMismatchFinderEntity;
    /**
     * Map of packages to update
     * Its key is the name of the dependency to be added or updated in the project
     * Its value is the new SemVer specifier that should be added to the project's package.json
     * If trying to remove this packages, value can be empty string
     */
    dependenciesToAddOrUpdateOrRemove: Record<string, string>;
}
/**
 * Configuration options for adding or updating a dependency in a single project
 */
export interface IUpdateProjectOptions extends IBaseUpdateProjectOptions {
    /**
     * The type of dependency that should be updated. If left empty, this will be auto-detected.
     * If it cannot be auto-detected an exception will be thrown.
     */
    dependencyType?: DependencyType;
}
/**
 * Configuration options for removing dependencies from a single project
 */
export interface IRemoveProjectOptions extends IBaseUpdateProjectOptions {
}
/**
 * A helper class for managing the dependencies of various package.json files.
 * @internal
 */
export declare class PackageJsonUpdater {
    private readonly _terminal;
    private readonly _rushConfiguration;
    private readonly _rushGlobalFolder;
    constructor(terminal: ITerminal, rushConfiguration: RushConfiguration, rushGlobalFolder: RushGlobalFolder);
    /**
     * Upgrade dependencies to a particular project, or across specified projects. This is the core business logic for
     * "rush upgrade-interactive".
     */
    doRushUpgradeAsync(options: IPackageJsonUpdaterRushUpgradeOptions): Promise<void>;
    doRushUpdateAsync(options: IPackageJsonUpdaterRushBaseUpdateOptions): Promise<void>;
    private _doUpdateAsync;
    /**
     * Adds a dependency to a particular project. The core business logic for "rush add".
     */
    private _doRushAddAsync;
    private _updateProjectsAsync;
    private _getUpdates;
    /**
     * Remove a dependency from a particular project. The core business logic for "rush remove".
     */
    private _doRushRemoveAsync;
    /**
     * Updates several projects' package.json files
     */
    updateProjects(projectUpdates: IUpdateProjectOptions[]): void;
    /**
     * Updates a single project's package.json file
     */
    updateProject(options: IUpdateProjectOptions): void;
    removePackageFromProject(options: IRemoveProjectOptions): void;
    /**
     * Selects an appropriate version number for a particular package, given an optional initial SemVer spec.
     * If ensureConsistentVersions, tries to pick a version that will be consistent.
     * Otherwise, will choose the latest semver matching the initialSpec and append the proper range style.
     * @param projects - the projects which will have their package.json's updated
     * @param packageName - the name of the package to be used
     * @param initialSpec - a semver pattern that should be used to find the latest version matching the spec
     * @param implicitlyPreferredVersion - the implicitly preferred (aka common/primary) version of the package in use
     * @param rangeStyle - if this version is selected by querying registry, then this range specifier is prepended to
     *   the selected version.
     */
    private _getNormalizedVersionSpecAsync;
    private _collectAllDownstreamDependencies;
    /**
     * Given a package name, this function returns a {@see RushConfigurationProject} if the package is a project
     * in the local Rush repo and is not marked as cyclic for any of the projects.
     *
     * @remarks
     * This function throws an error if adding the discovered local project as a dependency
     * would create a dependency cycle, or if it would be added to multiple projects.
     */
    private _tryGetLocalProject;
    private _cheaplyDetectSemVerRangeStyle;
    private _normalizeDepsToUpgrade;
}
//# sourceMappingURL=PackageJsonUpdater.d.ts.map