Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

libyear

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libyear - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

src/execute.d.ts

2

package.json
{
"name": "libyear",
"version": "0.1.5",
"version": "0.1.6",
"description": "A simple measure of software dependency freshness",

@@ -5,0 +5,0 @@ "author": "Joshua David <@jdanil>",

@@ -114,2 +114,3 @@ # `libyear`

- handle `npm ls` UNMET PEER DEPENDENCY
- fetch "latest" from dist-tags

@@ -116,0 +117,0 @@ - support `berry` w/o "required" workaround

@@ -5,3 +5,6 @@ /**

*/
export declare const calculateDrift: (currentVersion: string, latestVersion: string) => number;
export declare const calculateDrift: (
currentVersion: string,
latestVersion: string,
) => number;
/**

@@ -8,0 +11,0 @@ * Time since latest version release.

@@ -1,2 +0,1 @@

export declare const npmList: () => Promise<any>;
export declare const getDependencies: () => Promise<{

@@ -3,0 +2,0 @@ [x: string]: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const execa = require("execa");
exports.npmList = async () => {
const execute_1 = require("./execute");
exports.getDependencies = async () => {
const cmd = "npm ls --depth=0 --json --silent";
try {
const { stdout } = await execa.command(cmd);
return stdout;
}
catch (error) {
return error.stdout;
}
return Object.fromEntries(Object.entries(JSON.parse(await execute_1.execute(cmd)).dependencies).map(([dependency, data]) => {
var _a, _b;
return [
dependency,
(_a = data.version) !== null && _a !== void 0 ? _a : (((_b = data.required) === null || _b === void 0 ? void 0 : _b.version) ||
data.required).replace(/[<=>\^~]/u, ""),
];
}));
};
exports.getDependencies = async () => Object.fromEntries(Object.entries(JSON.parse(await exports.npmList()).dependencies).map(([dependency, data]) => {
var _a;
return [
dependency,
(_a = data.version) !== null && _a !== void 0 ? _a : data.required.replace(/[<=>\^~]/u, ""),
];
}));

@@ -20,5 +20,7 @@ "use strict";

const pulse = dates_1.calculatePulse(releaseTime[latestAllVersion]);
const status = stableVersions.includes(currentVersion)
? "stable"
: "pre-release";
const status = Object.entries(releaseTime).length === 0
? "symlink"
: stableVersions.includes(currentVersion)
? "stable"
: "pre-release";
return {

@@ -25,0 +27,0 @@ dependency,

@@ -11,4 +11,4 @@ "use strict";

})));
const totalDrift = dependencies.reduce((acc, { drift }) => acc + drift, 0);
const totalPulse = dependencies.reduce((acc, { pulse }) => acc + pulse, 0);
const totalDrift = dependencies.reduce((acc, { drift }) => (isNaN(drift) ? acc : acc + drift), 0);
const totalPulse = dependencies.reduce((acc, { pulse }) => (isNaN(pulse) ? acc : acc + pulse), 0);
const isBreach = (value, limit) => limit != null && value > limit;

@@ -15,0 +15,0 @@ const breaches = {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const execa = require("execa");
const execute_1 = require("./execute");
exports.getReleaseTime = async (packageManager, packageName) => {

@@ -10,20 +10,16 @@ const cmd = {

}[packageManager];
try {
const { stdout } = await execa.command(cmd);
const json = JSON.parse(stdout);
switch (packageManager) {
case "berry":
return json.time;
case "yarn":
return json.data;
case "npm":
default:
return json;
}
const stdout = await execute_1.execute(cmd);
if (!stdout) {
return {};
}
catch (error) {
process.stderr.write(`Failed to run "${cmd}".`);
process.stderr.write(error.message);
process.exit(1);
const json = JSON.parse(stdout);
switch (packageManager) {
case "berry":
return json.time;
case "yarn":
return json.data;
case "npm":
default:
return json;
}
};

@@ -5,6 +5,6 @@ /**

export declare const getSanitisedReleases: (releases: {
[version: string]: string;
[version: string]: string;
}) => {
[x: string]: string;
[x: number]: string;
[x: string]: string;
[x: number]: string;
};

@@ -15,6 +15,6 @@ /**

export declare const getStableReleases: (releases: {
[version: string]: string;
[version: string]: string;
}) => {
[x: string]: string;
[x: number]: string;
[x: string]: string;
[x: number]: string;
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc