@pnpm/core
Version:
Fast, disk space efficient installation engine
111 lines (110 loc) • 4.54 kB
TypeScript
import { type Catalogs } from '@pnpm/catalogs.types';
import { PnpmError } from '@pnpm/error';
import { type InstallationResultStats } from '@pnpm/headless';
import { type PinnedVersion, type UpdateMatchingFunction, type WantedDependency } from '@pnpm/resolve-dependencies';
import { type PreferredVersions } from '@pnpm/resolver-base';
import { type DepPath, type DependenciesField, type IgnoredBuilds, type PeerDependencyIssues, type ProjectId, type ProjectManifest, type ReadPackageHook, type ProjectRootDir } from '@pnpm/types';
import { type InstallOptions } from './extendInstallOptions.js';
interface InstallMutationOptions {
update?: boolean;
updateToLatest?: boolean;
updateMatching?: UpdateMatchingFunction;
updatePackageManifest?: boolean;
}
export interface InstallDepsMutation extends InstallMutationOptions {
mutation: 'install';
pruneDirectDependencies?: boolean;
}
export interface InstallSomeDepsMutation extends InstallMutationOptions {
allowNew?: boolean;
dependencySelectors: string[];
mutation: 'installSome';
peer?: boolean;
pruneDirectDependencies?: boolean;
pinnedVersion?: PinnedVersion;
targetDependenciesField?: DependenciesField;
}
export interface UninstallSomeDepsMutation {
mutation: 'uninstallSome';
dependencyNames: string[];
targetDependenciesField?: DependenciesField;
}
export type DependenciesMutation = InstallDepsMutation | InstallSomeDepsMutation | UninstallSomeDepsMutation;
type Opts = Omit<InstallOptions, 'allProjects'> & {
preferredVersions?: PreferredVersions;
pruneDirectDependencies?: boolean;
binsDir?: string;
} & InstallMutationOptions;
export interface InstallResult {
/**
* A partial of new or updated catalog config entries. A change will be
* produced if a dependency using the catalog protocol was newly added or
* updated during this install. To obtain the full catalog, callers should
* merge this object with the current catalog configs in pnpm-workspace.yaml.
*/
updatedCatalogs: Catalogs | undefined;
updatedManifest: ProjectManifest;
ignoredBuilds: IgnoredBuilds | undefined;
}
export declare function install(manifest: ProjectManifest, opts: Opts): Promise<InstallResult>;
export type MutatedProject = DependenciesMutation & {
rootDir: ProjectRootDir;
};
export type MutateModulesOptions = InstallOptions & {
preferredVersions?: PreferredVersions;
hooks?: {
readPackage?: ReadPackageHook[] | ReadPackageHook;
} | InstallOptions['hooks'];
};
export interface MutateModulesInSingleProjectResult {
updatedCatalogs: Catalogs | undefined;
updatedProject: UpdatedProject;
ignoredBuilds: IgnoredBuilds | undefined;
}
export declare function mutateModulesInSingleProject(project: MutatedProject & {
binsDir?: string;
manifest: ProjectManifest;
rootDir: ProjectRootDir;
modulesDir?: string;
}, maybeOpts: Omit<MutateModulesOptions, 'allProjects'> & InstallMutationOptions): Promise<MutateModulesInSingleProjectResult>;
export interface MutateModulesResult {
updatedCatalogs?: Catalogs;
updatedProjects: UpdatedProject[];
stats: InstallationResultStats;
depsRequiringBuild?: DepPath[];
ignoredBuilds: IgnoredBuilds | undefined;
}
export declare function mutateModules(projects: MutatedProject[], maybeOpts: MutateModulesOptions): Promise<MutateModulesResult>;
export declare function addDependenciesToPackage(manifest: ProjectManifest, dependencySelectors: string[], opts: Omit<InstallOptions, 'allProjects'> & {
bin?: string;
allowNew?: boolean;
peer?: boolean;
pinnedVersion?: 'major' | 'minor' | 'patch';
targetDependenciesField?: DependenciesField;
} & InstallMutationOptions): Promise<InstallResult>;
export type ImporterToUpdate = {
buildIndex: number;
binsDir: string;
id: ProjectId;
manifest: ProjectManifest;
originalManifest?: ProjectManifest;
modulesDir: string;
rootDir: ProjectRootDir;
pruneDirectDependencies: boolean;
removePackages?: string[];
updatePackageManifest: boolean;
wantedDependencies: Array<WantedDependency & {
isNew?: boolean;
updateSpec?: boolean;
}>;
} & DependenciesMutation;
export interface UpdatedProject {
originalManifest?: ProjectManifest;
manifest: ProjectManifest;
peerDependencyIssues?: PeerDependencyIssues;
rootDir: ProjectRootDir;
}
export declare class IgnoredBuildsError extends PnpmError {
constructor(ignoredBuilds: IgnoredBuilds);
}
export {};