From 6dc711b88064ec139ae44466f28eb40c29c3355b Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 13 Jan 2020 16:14:16 -0700 Subject: [PATCH] v4.0.4: bugfixes for custom / local manager file --- bin/greenlock.js | 20 +++++++++++++------- bin/init.js | 3 +++ lib/manager-wrapper.js | 32 ++++++++++++++++++++++++++++++-- package-lock.json | 2 +- package.json | 2 +- 5 files changed, 48 insertions(+), 11 deletions(-) diff --git a/bin/greenlock.js b/bin/greenlock.js index 04cb506..bcae9f7 100755 --- a/bin/greenlock.js +++ b/bin/greenlock.js @@ -5,14 +5,20 @@ var args = process.argv.slice(2); var arg0 = args[0]; //console.log(args); -var found = ['certonly', 'add', 'update', 'config', 'defaults', 'remove', 'init'].some( - function(k) { - if (k === arg0) { - require('./' + k); - return true; - } +var found = [ + 'certonly', + 'add', + 'update', + 'config', + 'defaults', + 'remove', + 'init' +].some(function(k) { + if (k === arg0) { + require('./' + k); + return true; } -); +}); if (!found) { console.error(arg0 + ': command not yet implemented'); diff --git a/bin/init.js b/bin/init.js index 84b3d07..ed0b86d 100644 --- a/bin/init.js +++ b/bin/init.js @@ -36,6 +36,9 @@ cli.main(async function(argList, flags) { flags.manager.module = manager; try { + if ('.' === String(manager)[0]) { + manager = require('path').resolve(pkgRoot, manager); + } P._loadSync(manager); } catch (e) { try { diff --git a/lib/manager-wrapper.js b/lib/manager-wrapper.js index b4e7c97..ff4c314 100644 --- a/lib/manager-wrapper.js +++ b/lib/manager-wrapper.js @@ -12,13 +12,25 @@ module.exports.wrap = function(greenlock, gconf) { var myFind = gconf.find; delete gconf.find; - var mega = mergeManager(gconf); + var mega = mergeManager(greenlock, gconf); greenlock.manager = {}; greenlock.sites = {}; //greenlock.accounts = {}; //greenlock.certs = {}; + greenlock.manager._modulename = gconf.manager.module; + if ('/' === String(gconf.manager.module)[0]) { + greenlock.manager._modulename = require('path').relative( + gconf.packageRoot, + greenlock.manager._modulename + ); + if ('.' !== String(greenlock.manager._modulename)[0]) { + greenlock.manager._modulename = + './' + greenlock.manager._modulename; + } + } + var allowed = [ 'accountKeyType', //: ["P-256", "RSA-2048"], 'serverKeyType', //: ["RSA-2048", "P-256"], @@ -409,6 +421,7 @@ function loadManager(gconf) { ); } */ + try { // wrap this to be safe for @greenlock/manager m = require(gconf.manager.module).create(gconf.manager); @@ -431,7 +444,7 @@ function loadManager(gconf) { return m; } -function mergeManager(gconf) { +function mergeManager(greenlock, gconf) { var mng; function m() { if (mng) { @@ -554,6 +567,21 @@ function mergeManager(gconf) { mega.get = m().get; } + if (!mega.find) { + mega._nofind = false; + mega.find = async function(opts) { + if (!mega._nofind) { + console.warn( + 'Warning: manager `' + + greenlock.manager._modulename + + '` does not implement `find({})`\n' + ); + mega._nofind = true; + } + return []; + }; + } + if (!mega.get) { mega.get = function(opts) { var servername = opts.servername; diff --git a/package-lock.json b/package-lock.json index 8b62aa6..ab9a130 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@root/greenlock", - "version": "4.0.3", + "version": "4.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2af7ade..a092154 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@root/greenlock", - "version": "4.0.3", + "version": "4.0.4", "description": "The easiest Let's Encrypt client for Node.js and Browsers", "homepage": "https://rootprojects.org/greenlock/", "main": "greenlock.js",