@juit/check-updates
Version:
Small and fast utility to update package dependencies
67 lines (65 loc) • 2.92 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// versions.ts
var versions_exports = {};
__export(versions_exports, {
VersionsCache: () => VersionsCache
});
module.exports = __toCommonJS(versions_exports);
var import_npm_registry_fetch = __toESM(require("npm-registry-fetch"), 1);
var import_semver = __toESM(require("semver"), 1);
var import_debug = require("./debug.cjs");
var VersionsCache = class {
_cache;
_debug;
constructor(debug = false) {
this._debug = (0, import_debug.makeDebug)(debug);
this._cache = {};
}
/** Return the available versions for a package, sorted */
getVersions(name, npmrc, includePrerelease) {
const key = includePrerelease ? name + "+prerelease" : name;
if (this._cache[key]) {
this._debug(`Returning cached versions for ${import_debug.Y}${name}${import_debug.X}`);
return this._cache[key];
}
this._debug(`Retrieving versions for package ${import_debug.Y}${name}${import_debug.X}`);
const range = new import_semver.default.Range(">=0.0.0", { includePrerelease });
const promise = import_npm_registry_fetch.default.json(name, Object.assign({}, npmrc, { spec: name })).then((data) => {
return Object.entries(data.versions).filter(([, info]) => !info.deprecated).map(([version]) => version).filter((version) => range.test(version)).sort(import_semver.default.rcompare);
});
this._cache[key] = promise;
return promise;
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
VersionsCache
});
//# sourceMappingURL=versions.cjs.map
;