UNPKG

pncat

Version:

A unified cli tool that enhances package managers catalogs feature.

80 lines 2.88 kB
//#region src/types/fn.d.ts type DepFilter = (name: string, specifier: string) => boolean; type HookFunction = () => Promise<void> | void; interface ParsedSpec { name: string; specifier?: string; catalogName?: string; specifierSource?: 'user' | 'catalog' | 'workspace' | 'npm'; } interface DependencyEntry { name: string; specifier: string; parents: string[]; } //#endregion //#region src/constants/cli.d.ts declare const MODE_CHOICES: readonly ["init", "detect", "migrate", "add", "remove", "clean", "revert"]; //#endregion //#region src/constants/package-manager.d.ts declare const PACKAGE_MANAGERS: readonly ["pnpm", "yarn", "bun", "vlt"]; declare const DEPS_FIELDS: readonly ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies", "pnpm.overrides", "resolutions", "overrides", "pnpm-workspace", "yarn-workspace", "bun-workspace", "vlt-workspace"]; //#endregion //#region src/constants/rules.d.ts declare const SPECIFIER_RANGE_TYPES: readonly ["||", "-", ">=", "<=", ">", "<", "x", "*", "pre-release"]; //#endregion //#region src/types/rules.d.ts interface CatalogRule { name: string; match: string | RegExp | (string | RegExp)[]; depFields?: DepType[]; priority?: number; specifierRules?: SpecifierRule[]; } interface SpecifierRule { specifier: string; match?: string | RegExp | (string | RegExp)[]; name?: string; suffix?: string; } interface SpecifierOptions { skipComplexRanges?: boolean; allowPreReleases?: boolean; allowWildcards?: boolean; allowNpmAliases?: boolean; skipRangeTypes?: SpecifierRangeType[]; } type SpecifierRangeType = (typeof SPECIFIER_RANGE_TYPES)[number]; //#endregion //#region src/types/core.d.ts type RangeMode = (typeof MODE_CHOICES)[number]; type PackageManager = (typeof PACKAGE_MANAGERS)[number]; type DepType = (typeof DEPS_FIELDS)[number]; type DepFieldOptions = Partial<Record<DepType, boolean>>; interface CommandOptions { cwd?: string; mode?: RangeMode; recursive?: boolean; force?: boolean; catalog?: string; yes?: boolean; install?: boolean; verbose?: boolean; } interface ConfigOptions { agent?: PackageManager; include?: string | string[]; exclude?: string | string[]; ignorePaths?: string | string[]; ignoreOtherWorkspaces?: boolean; depFields?: DepFieldOptions; allowedProtocols?: string[]; saveExact?: boolean; postRun?: string | HookFunction | Array<string | HookFunction>; } interface CatalogOptions extends CommandOptions, ConfigOptions { catalogRules?: CatalogRule[]; specifierOptions?: SpecifierOptions; } //#endregion export { DepType as a, CatalogRule as c, SpecifierRule as d, DepFilter as f, ParsedSpec as h, DepFieldOptions as i, SpecifierOptions as l, HookFunction as m, CommandOptions as n, PackageManager as o, DependencyEntry as p, ConfigOptions as r, RangeMode as s, CatalogOptions as t, SpecifierRangeType as u };