From 21876049137644af2b3afa31120ee95d032843a8 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sat, 31 Aug 2019 23:58:54 -0400 Subject: [PATCH] Added lock-versions admin tool. --- admin/cmds/lock-versions.js | 41 +++++++++++++++++++++++++++++++++++ admin/cmds/update-versions.js | 8 ------- 2 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 admin/cmds/lock-versions.js diff --git a/admin/cmds/lock-versions.js b/admin/cmds/lock-versions.js new file mode 100644 index 0000000000..81a1274f76 --- /dev/null +++ b/admin/cmds/lock-versions.js @@ -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(``); + shown = true; + } + log(` : ${ deps[name] } => `); + deps[name] = value; + }); + }); + savePackage(dirname, info); + }); + +})(); diff --git a/admin/cmds/update-versions.js b/admin/cmds/update-versions.js index e7031847e8..9c245e219b 100644 --- a/admin/cmds/update-versions.js +++ b/admin/cmds/update-versions.js @@ -51,14 +51,6 @@ if (process.argv.length > 2) { // Get local package.json (update the tarballHash) 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) let npmInfo = await getPackageVersion(info.name);