mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 06:00:23 +00:00
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import type { NpmIntegrityDriftPayload } from "./npm-integrity.js";
|
|
import {
|
|
finalizeNpmSpecArchiveInstall,
|
|
installFromNpmSpecArchiveWithInstaller,
|
|
type NpmSpecArchiveFinalInstallResult,
|
|
} from "./npm-pack-install.js";
|
|
import { validateRegistryNpmSpec } from "./npm-registry-spec.js";
|
|
|
|
export async function installFromValidatedNpmSpecArchive<
|
|
TResult extends { ok: boolean },
|
|
TArchiveInstallParams extends { archivePath: string },
|
|
>(params: {
|
|
spec: string;
|
|
timeoutMs: number;
|
|
tempDirPrefix: string;
|
|
expectedIntegrity?: string;
|
|
onIntegrityDrift?: (payload: NpmIntegrityDriftPayload) => boolean | Promise<boolean>;
|
|
warn?: (message: string) => void;
|
|
installFromArchive: (params: TArchiveInstallParams) => Promise<TResult>;
|
|
archiveInstallParams: Omit<TArchiveInstallParams, "archivePath">;
|
|
}): Promise<NpmSpecArchiveFinalInstallResult<TResult>> {
|
|
const spec = params.spec.trim();
|
|
const specError = validateRegistryNpmSpec(spec);
|
|
if (specError) {
|
|
return { ok: false, error: specError };
|
|
}
|
|
const flowResult = await installFromNpmSpecArchiveWithInstaller({
|
|
tempDirPrefix: params.tempDirPrefix,
|
|
spec,
|
|
timeoutMs: params.timeoutMs,
|
|
expectedIntegrity: params.expectedIntegrity,
|
|
onIntegrityDrift: params.onIntegrityDrift,
|
|
warn: params.warn,
|
|
installFromArchive: params.installFromArchive,
|
|
archiveInstallParams: params.archiveInstallParams,
|
|
});
|
|
return finalizeNpmSpecArchiveInstall(flowResult);
|
|
}
|