jsr
Version:
jsr.io package manager for npm, yarn, pnpm and bun
54 lines (53 loc) • 2.11 kB
TypeScript
import * as util from "node:util";
import type { PkgManagerName } from "./pkg_manager.ts";
export declare let DEBUG: boolean;
export declare function setDebug(enabled: boolean): void;
export declare function logDebug(msg: string): void;
export declare class JsrPackageNameError extends Error {
}
export declare class JsrPackage {
scope: string;
name: string;
version: string | null;
private constructor();
static from(input: string): JsrPackage;
toNpmPackage(): string;
toString(): string;
}
export declare function fileExists(file: string): Promise<boolean>;
export interface ProjectInfo {
projectDir: string;
pkgManagerName: PkgManagerName | null;
pkgJsonPath: string | null;
root: string | null;
}
export declare function findProjectDir(cwd: string, dir?: string, result?: ProjectInfo): Promise<ProjectInfo>;
export declare function prettyTime(diff: number): string;
export declare function timeAgo(diff: number): string;
export declare class ExecError extends Error {
code: number;
constructor(code: number);
}
export interface ExecOutput {
combined: string;
stdout: string;
stderr: string;
}
export declare function exec(cmd: string, args: string[], cwd: string, env?: Record<string, string | undefined>, captureOutput?: boolean): Promise<ExecOutput>;
export declare function getNewLineChars(source: string): "\n" | "\r\n";
export declare function readJson<T>(file: string): Promise<T>;
export interface PkgJson {
name?: string;
version?: string;
license?: string;
workspaces?: string[];
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
optionalDependencies?: Record<string, string>;
exports?: string | Record<string, string | Record<string, string>>;
scripts?: Record<string, string>;
}
export declare function writeJson<T>(file: string, data: T): Promise<void>;
export declare function readTextFile(file: string): Promise<string>;
export declare function writeTextFile(file: string, content: string): Promise<void>;
export declare const styleText: typeof util.styleText;