fly-import
Version:
Install and import packages on-the-fly
54 lines (53 loc) • 1.68 kB
TypeScript
export type FlyRepositoryConfig = {
repositoryPath: string;
arboristConfig?: any;
};
type IntalledPackage = {
name: string;
path: string;
realpath: string;
pkgid: string;
version: string;
packageName: string;
import: <T = any>() => Promise<T>;
};
type NotIntalledPackage = {
name: undefined;
path: undefined;
realpath: undefined;
pkgid: string;
version: undefined;
packageName: undefined;
import: <T = any>() => Promise<T>;
};
export type FlyResultPackage = NotIntalledPackage | IntalledPackage;
/**
* @private
*/
export declare class FlyRepository {
#private;
private readonly arboristConfig;
private _arborist?;
private _repositoryPath;
private nodeModulesPath;
private _require?;
constructor(config: FlyRepositoryConfig);
/**
* Repository absolute path (npm --prefix).
*/
get repositoryPath(): string;
private set repositoryPath(value);
load(): Promise<unknown>;
install(spec: string): Promise<FlyResultPackage>;
install(spec: string[]): Promise<FlyResultPackage[]>;
import<T = any>(spec: string): Promise<T>;
private resolve;
private findSpecs;
}
export declare const resetConfig: () => void;
export declare const defineConfig: (config: Partial<FlyRepositoryConfig>) => void;
export declare const getConfig: () => FlyRepositoryConfig;
export declare const getDefaultRepository: () => FlyRepository;
export declare const flyInstall: (specifier: string, options?: FlyRepositoryConfig) => Promise<FlyResultPackage>;
export declare const flyImport: <T = any>(specifier: string, options?: FlyRepositoryConfig) => Promise<T>;
export {};