Added lock-versions admin tool.

This commit is contained in:
Richard Moore 2019-08-31 23:58:54 -04:00
parent 85b4db7d6d
commit 2187604913
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
2 changed files with 41 additions and 8 deletions

@ -0,0 +1,41 @@
"use strict";
const { getOrdered, loadPackage } = require("../depgraph");
const { savePackage } = require("../local");
const { log } = require("../log");
(async function() {
let versions = { };
const dirnames = getOrdered();
dirnames.forEach((dirname) => {
let info = loadPackage(dirname);
if (info.name.split("/")[0] === "@ethersproject" || info.name === "ethers") {
versions[info.name] = info.version;
}
});
dirnames.forEach((dirname) => {
const info = loadPackage(dirname);
let shown = false;
["dependencies", "devDependencies"].forEach((key) => {
const deps = info[key];
if (!deps) { return; }
Object.keys(deps).forEach((name) => {
if (versions[name] == null) { return; }
const value = ">=" + versions[name];
if (value !== deps[name])
if (!deps[name]) { return; }
if (!shown) {
log(`<bold:Locking ${ info.name }:>`);
shown = true;
}
log(` <green:${ name }>: ${ deps[name] } => <bold:${ value.substring(2) }>`);
deps[name] = value;
});
});
savePackage(dirname, info);
});
})();

@ -51,14 +51,6 @@ if (process.argv.length > 2) {
// Get local package.json (update the tarballHash) // Get local package.json (update the tarballHash)
let info = await updatePackage(dirname); let info = await updatePackage(dirname);
/*
let info = await updatePackage(dirname, {
repository: {
type: "git",
url: "git://github.com/ethers-io/ethers.js.git"
}
});
*/
// Get the remote package.json (or sub in a placeholder for new pacakges) // Get the remote package.json (or sub in a placeholder for new pacakges)
let npmInfo = await getPackageVersion(info.name); let npmInfo = await getPackageVersion(info.name);