mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
41 lines
852 B
TypeScript
41 lines
852 B
TypeScript
import type { PathMetadata } from "./package-manager.ts";
|
|
|
|
export type SourceScope = "user" | "project" | "temporary";
|
|
export type SourceOrigin = "package" | "top-level";
|
|
|
|
export interface SourceInfo {
|
|
path: string;
|
|
source: string;
|
|
scope: SourceScope;
|
|
origin: SourceOrigin;
|
|
baseDir?: string;
|
|
}
|
|
|
|
export function createSourceInfo(path: string, metadata: PathMetadata): SourceInfo {
|
|
return {
|
|
path,
|
|
source: metadata.source,
|
|
scope: metadata.scope,
|
|
origin: metadata.origin,
|
|
baseDir: metadata.baseDir,
|
|
};
|
|
}
|
|
|
|
export function createSyntheticSourceInfo(
|
|
path: string,
|
|
options: {
|
|
source: string;
|
|
scope?: SourceScope;
|
|
origin?: SourceOrigin;
|
|
baseDir?: string;
|
|
},
|
|
): SourceInfo {
|
|
return {
|
|
path,
|
|
source: options.source,
|
|
scope: options.scope ?? "temporary",
|
|
origin: options.origin ?? "top-level",
|
|
baseDir: options.baseDir,
|
|
};
|
|
}
|