Compare commits

..

No commits in common. "0ebb53f5633de7de76b809942a908b3a71dc9a10" and "4b47fb4eb679594a6f2978484f0b40788e7047b6" have entirely different histories.

6 changed files with 35 additions and 91 deletions

2
.gitignore vendored
View File

@ -1,5 +1,3 @@
*delete-me*
# ---> Node
# Logs
logs

View File

@ -10,28 +10,22 @@ A simple file-based management strategy for Greenlock v3
npm install --save greenlock-manager-fs@v3
```
## Usage
## Use with Greenlock
```js
npx greenlock init --manager greenlock-manager-fs --config-dir './greenlock.d'
```
var greenlock = require('greenlock').create({
// ...
Or, place this file in the root of your project:
`.greenlockrc`:
```json
{
"manager": "greenlock-manager-fs",
"configDir": "./greenlock.d"
}
manager: 'greenlock-manager-fs',
configFile: '~/.config/greenlock/manager.json'
});
```
## Example config file
You might start your config file like this:
`./greenlock.d/config.json`:
`~/.config/greenlock/manager.json`:
```json
{

View File

@ -19,13 +19,8 @@ var mkdirp = promisify(require('@root/mkdirp'));
// and wanting to be fairly sure it works and produces
// meaningful errors
// IMPORTANT
// For your use case you'll probably find a better example
// in greenlock-manager-test:
//
// npm install --save greenlock-manager-test
// npx greenlock-manager-init
//
// in greenlock-manager-test
Manage.create = function(CONF) {
if (!CONF) {
@ -80,31 +75,6 @@ Manage.create = function(CONF) {
return manage._txPromise;
};
manage.get = async function(args) {
manage._txPromise = manage._txPromise.then(async function() {
var config = await Manage._getLatest(manage, CONF);
var site;
Object.keys(config.sites).some(function(k) {
// if subject is specified, don't return anything else
var _site = config.sites[k];
// altnames, servername, and wildname all get rolled into one
return _site.altnames.some(function(altname) {
if ([args.servername, args.wildname].includes(altname)) {
site = _site;
}
});
});
if (site && !site.deletedAt) {
return doctor.site(config.sites, site.subject);
}
return null;
});
return manage._txPromise;
};
manage._merge = function(config, current, args) {
if (!current || current.deletedAt) {
current = config.sites[args.subject] = {
@ -280,16 +250,8 @@ Manage.create = function(CONF) {
manage._save = async function(config) {
await mkdirp(path.dirname(CONF.configFile));
// pretty-print the config file
var data = JSON.parse(JSON.stringify(config));
var sites = data.sites || {};
data.sites = Object.keys(sites).map(function(k) {
return sites[k];
});
await sfs.writeFileAsync(
CONF.configFile,
JSON.stringify(data, null, 2),
'utf8'
);
var data = JSON.stringify(config, null, 2);
await sfs.writeFileAsync(CONF.configFile, data, 'utf8');
// this file may contain secrets, so keep it safe
return chmodFile(CONF.configFile, parseInt('0600', 8))
@ -304,9 +266,8 @@ Manage.create = function(CONF) {
};
manage.init = async function(deps) {
// even though we don't need it
manage.request = deps.request;
return null;
var request = deps.request;
// how nice...
};
return manage;
@ -349,10 +310,7 @@ doctor.config = function(config) {
doctor.sites(config);
Object.keys(config).forEach(function(key) {
// .greenlockrc and greenlock.json shall merge as one
// and be called greenlock.json because calling it
// .greenlockrc seems to rub people the wrong way
if (['manager', 'defaults', 'routes', 'sites'].includes(key)) {
if (['defaults', 'routes', 'sites'].includes(key)) {
return;
}
config.defaults[key] = config[key];

14
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "greenlock-manager-fs",
"version": "3.1.0",
"version": "3.0.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -16,9 +16,9 @@
"dev": true
},
"greenlock-manager-fs": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/greenlock-manager-fs/-/greenlock-manager-fs-3.0.5.tgz",
"integrity": "sha512-r/q+tEFuDwklfzPfiGhcIrHuJxMrppC+EseESpu5f0DMokh+1iZVm9nGC/VE7/7GETdOYfEYhhQkmspsi8Gr/A==",
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/greenlock-manager-fs/-/greenlock-manager-fs-3.0.1.tgz",
"integrity": "sha512-vZfGFq1TTKxaAqdGDUwNservrNzXx0xCwT/ovG/N378GrhS+U5S8B8LUlNtQU7Fdw6RToMiBcm22OOxSrvZ2zw==",
"dev": true,
"requires": {
"@root/mkdirp": "^1.0.0",
@ -26,9 +26,9 @@
}
},
"greenlock-manager-test": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/greenlock-manager-test/-/greenlock-manager-test-3.1.1.tgz",
"integrity": "sha512-wZ+Oxn5qTEoN+VDd3Y+kBYZ8MlaLlhm40KwIwfyR90bj08IZpfzE7zGY8SwBEbIx0wNSo6ztDku4Y0gVgxxwCA==",
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/greenlock-manager-test/-/greenlock-manager-test-3.0.0.tgz",
"integrity": "sha512-grqpUcxT7v5KzJ04r8wJWXjSVm7us1z/2QluCJRl9BZUM4CXzQuP1C0d2wdsV4NHwziEGJpA+4mFsntuh3f1YA==",
"dev": true,
"requires": {
"@root/request": "^1.4.1",

View File

@ -1,6 +1,6 @@
{
"name": "greenlock-manager-fs",
"version": "3.1.0",
"version": "3.0.5",
"description": "A simple file-based management strategy for Greenlock",
"main": "manager.js",
"scripts": {
@ -27,6 +27,6 @@
"safe-replace": "^1.1.0"
},
"devDependencies": {
"greenlock-manager-test": "^3.1.1"
"greenlock-manager-test": "^3.0.0"
}
}

View File

@ -1,24 +1,18 @@
"use strict";
'use strict';
var Tester = require("greenlock-manager-test");
var Tester = require('greenlock-manager-test');
var Manager = require("../manager.js");
var Manager = require('../');
var config = {
configFile: "greenlock-manager-test.delete-me.json"
configFile: 'greenlock-manager-test.delete-me.json'
};
Tester.test(Manager, config)
.then(function(features) {
console.info("PASS");
console.info();
console.info("Optional Feature Support:");
features.forEach(function(feature) {
console.info(feature.supported ? "✓ (YES)" : "✘ (NO) ", feature.description);
});
console.info();
.then(function() {
console.log('PASS: Known-good test module passes');
})
.catch(function(err) {
console.error("Oops, you broke it. Here are the details:");
console.error('Oops, you broke it. Here are the details:');
console.error(err.stack);
console.error();
console.error("That's all I know.");