0.0.0 • Published 3 years ago
deptrics v0.0.0
deptrics
deptrics
, like metrics
Description
A package to report dependency metrics. Currently relies on output from yarn info
commands directly. See #2.
API
getPackageMetrics
getPackageMetrics(obj)
, getPackageMetrics({packageName})
Parameters
Object
packageName
: Name of the npm package to retrieve metrics for
Return Value
Object
avgTimeBetweenMajors
: The average time, in milliseconds, between two major version releases - a measure of how often breaking changes are made to this libraryavgTimeBetweenReleases
: The average time, in milliseconds, between every release of this package - a measure of how often the package is updatedlastReleaseDate
: The last time the package was updated
getPackageVersionMetrics
getPackageVersionMetrics(obj)
,
getPackageVersionMetrics({packageName, version})
Parameters
Object
packageName
: Name of the npm package to retrieve metrics forversion
: Package version to calculate health metrics foradditionalMetricCalculation
: A function which is passed the result ofyarn info
, and whose return value is spread into the return value of this function. Allows for customization of metrics without needing to callyarn info
again.
Return Value
Object
, <PackageVersionMetricObject>
mostRecentVersion
: The most recently published version of this packageversionSequenceNumberDistance
: The number of versions published between theversion
parameter, and the latest version of the package, a measure of how outdated a version is. Note: this metric is not ideal for packages which are frequently published, as many SF libraries are - so we recommend using in conjunction with other metrics provided.versionReleaseDateDistance
: The amount of time, in milliseconds, between the time theversion
parameter of the package was published, and the time the most recent version was published, another metric of how outdated a particular version is.semverDiff
: The semver difference between two versions -major
,minor
,patch
. Returnsmajor
for multiple major differences (i.e.0.0.1
to3.0.2
), andnull
for equal versions.version
: The version passed into this functiontimeOutdated
: The amount of time a dependency has been outdated, calculated from the time the function is calledtimeOutdatedMajor
: The amount of time a dependency has been a major version out of date, calculated from the time the function is called.
getMetricsForDependencies
getMetricsForDependencies(dependencies)
Parameters
Array<DependencyObject>
DependencyObject
:{packageName: packageVersion}
Return Value
Array<PackageVersionMetricObject>
: See return value of
getPackageVersionMetrics
aggregateMetrics
aggregateMetrics(packageVersionMetrics)
Parameters
Array<PackageVersionMetricObject>
Return Value
Object
countOutdated
: The number of outdated dependencies in the list of package metricscountMajor
: The number of dependencies off by at least one major versioncountMinor
: The number of dependencies off by at least one minor version, but not a major.countPatch
: The number of dependencies off by at least one patch version, but not a minor or major.dependencyCount
: The total number of dependencies metrics computed foraverageVersionSequenceDistance
: The average of all the version sequence number distancesmedianVersionSequenceDistance
: The median of all the version sequence number distancesaverageVersionReleaseDateDistance
: The average of all the version release date distances
Example Uses
For a list of dependencies
const { getMetricsForDependencies, aggregateMetrics } = require("deptrics");
// Retrieving metrics for a list of dependencies
// Returns array of package version metrics, described below
const dependencyMetrics = getMetricsForDependencies({
semver: "7.3.2",
lib: "10.0.1",
});
// generate a report for all dependencies
const metricsReport = aggregateMetrics(dependencyMetrics);
For a single package
const { getPackageVersionMetrics, getPackageMetrics } = require("deptrics");
// Get metrics for how outdated a specific dependency is
const packageVersionMetrics = getPackageVersionMetrics({
packageName: "foo",
version: "10.0.1",
});
// Get data about the release patterns of a package
const packageVersionMetrics = getPackageMetrics({
packageName: "foo",
});
0.0.0
3 years ago