UNPKG

@eljs/utils

Version:
97 lines 2.66 kB
import { type RunCommandOptions } from "../cp"; import type { OmitIndexSignature, PackageJson } from "../types"; /** * 获取 Npm 仓库 * @param options 选项 */ export declare function getNpmRegistry(options?: RunCommandOptions): Promise<string>; /** * 获取 Npm 用户 * @param options 选项 */ export declare function getNpmUser(options?: RunCommandOptions): Promise<string>; /** * Npm 包 * @link https://github.com/npm/registry/blob/main/docs/REGISTRY-API.md#package */ export interface NpmPackage extends OmitIndexSignature<PackageJson> { version: string; name: string; dist: { shasum: string; size: number; tarball: string; }; 'dist-tags': { latest: string; alpha: string; beta: string; next: string; [key: string]: string; }; versions: { [version: string]: Omit<NpmPackage, 'versions' | 'dist-tags'>; }; } /** * 获取 Npm 包 * @param name 包名 * @param options.cwd 当前工作目录 * @param options.registry 仓库地址 * @param options.timeout 超时时间 */ export declare function getNpmPackage(name: string, options?: { cwd?: string; registry?: string; timeout?: number; }): Promise<Omit<NpmPackage, 'version'> | null>; /** * 获取指定版本的 Npm 包 * @param name 包名 * @param options.version 包版本 * @param options.cwd 当前工作目录 * @param options.registry 仓库地址 * @param options.timeout 超时时间 */ export declare function getNpmPackage(name: string, options: { version: string; cwd?: string; registry?: string; timeout?: number; }): Promise<Omit<NpmPackage, 'versions' | 'dist-tags'> | null>; /** * 获取 Npm 前缀 */ export declare function getNpmPrefix(): Promise<string>; /** * 解析后的 Npm 包名 */ export interface ResolvedPkgName { /** * 包名 */ name: string; /** * 版本号 */ version: string; /** * 命名空间 */ scope: string; /** * 剔除命名空间后的包名 */ unscopedName: string; } /** * 解析 Npm 包名 * @param name 包名 * @example * '@eljs/utils@1.0.0' => { name: '@eljs/utils', version: '1.0.0', scope: '@eljs', unscopedName: 'utils' } * 'utils@1.0.0' => { name: 'utils', version: '1.0.0, scope: '', unscopedName: 'utils' } * '@eljs/utils' => { name: '@eljs/utils', version: 'latest', scope: '@eljs', unscopedName: 'utils' } * 'utils' => { name: 'utils', version: 'latest', scope: '', unscopedName: 'utils' } */ export declare function pkgNameAnalysis(name: string): ResolvedPkgName; //# sourceMappingURL=meta.d.ts.map