@pnpm/tarball-fetcher
Version:
Fetcher for packages hosted as tarballs
47 lines • 2.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TarballIntegrityError = exports.BadTarballError = void 0;
exports.createTarballFetcher = createTarballFetcher;
const error_1 = require("@pnpm/error");
const worker_1 = require("@pnpm/worker");
Object.defineProperty(exports, "TarballIntegrityError", { enumerable: true, get: function () { return worker_1.TarballIntegrityError; } });
const remoteTarballFetcher_js_1 = require("./remoteTarballFetcher.js");
const localTarballFetcher_js_1 = require("./localTarballFetcher.js");
const gitHostedTarballFetcher_js_1 = require("./gitHostedTarballFetcher.js");
var index_js_1 = require("./errorTypes/index.js");
Object.defineProperty(exports, "BadTarballError", { enumerable: true, get: function () { return index_js_1.BadTarballError; } });
function createTarballFetcher(fetchFromRegistry, getAuthHeader, opts) {
const download = (0, remoteTarballFetcher_js_1.createDownloader)(fetchFromRegistry, {
retry: opts.retry,
timeout: opts.timeout,
fetchMinSpeedKiBps: opts.fetchMinSpeedKiBps,
});
const remoteTarballFetcher = fetchFromTarball.bind(null, {
download,
getAuthHeaderByURI: getAuthHeader,
offline: opts.offline,
});
return {
localTarball: (0, localTarballFetcher_js_1.createLocalTarballFetcher)(),
remoteTarball: remoteTarballFetcher,
gitHostedTarball: (0, gitHostedTarballFetcher_js_1.createGitHostedTarballFetcher)(remoteTarballFetcher, opts),
};
}
async function fetchFromTarball(ctx, cafs, resolution, opts) {
if (ctx.offline) {
throw new error_1.PnpmError('NO_OFFLINE_TARBALL', `A package is missing from the store but cannot download it in offline mode. The missing package may be downloaded from ${resolution.tarball}.`);
}
return ctx.download(resolution.tarball, {
getAuthHeaderByURI: ctx.getAuthHeaderByURI,
cafs,
integrity: resolution.integrity,
readManifest: opts.readManifest,
onProgress: opts.onProgress,
onStart: opts.onStart,
registry: resolution.registry,
filesIndexFile: opts.filesIndexFile,
pkg: opts.pkg,
appendManifest: opts.appendManifest,
});
}
//# sourceMappingURL=index.js.map