Skip to content

Commit a5088da

Browse files
committed
Merge pull request #3 from readdle/some_bin
- added some bin
2 parents 5cb7e6e + 687691f commit a5088da

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

bin/rdconfig-crypter.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var config = require('../rdconfig.js'),
2+
args = process.argv.slice(2);
3+
4+
var mode = args[0];
5+
var value = args[1];
6+
7+
if (typeof value === 'undefined') {
8+
console.log('Usage: ' + process.argv[1] + ' <encrypt|decrypt> <value to encrypt>');
9+
process.exit(1)
10+
}
11+
12+
if (mode === 'encrypt') {
13+
console.log(config.encrypt(value));
14+
} else if (mode === 'decrypt') {
15+
console.log(config.decrypt(value));
16+
} else {
17+
throw Error('Unsupported crypter command');
18+
}

bin/rdconfig-nginx.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var config = require('../rdconfig.js'),
2+
fs = require('fs'),
3+
ejs = require('ejs');
4+
5+
if (!config.has('nginx')) {
6+
console.error("ERROR: unable to compile nginx.conf, can't load app config")
7+
process.exit(1);
8+
}
9+
10+
var configDir = process.env.NODE_CONFIG_DIR || process.cwd() + "/config";
11+
12+
if (!fs.existsSync(configDir + "/nginx/template.ejs")) {
13+
console.error("ERROR: unable to compile nginx.conf, template.ejs not found in " + configDir + "/nginx");
14+
process.exit(1);
15+
}
16+
17+
var tmpl = fs.readFileSync(configDir + "/nginx/template.ejs").toString();
18+
var nginxPath = configDir + "/nginx/_generated.conf";
19+
20+
fs.writeFile(nginxPath, ejs.render(tmpl, config.get('nginx')), function (err) {
21+
if (err) {
22+
return console.error(err);
23+
}
24+
console.log("updated nginx.conf in " + nginxPath);
25+
});
26+

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
{
22
"name": "rdconfig",
3-
"version": "1.2.3",
4-
"description": "Module rdconfig - extension of package lorenwest/node-config, which allows you to read the value of the environment from a file and encrypt/decrypt the settings with specified key",
3+
"version": "1.2.4",
4+
5+
"description": "rdconfig - unified configuration for node apps, based on lorenwest/node-config",
6+
57
"main": "rdconfig.js",
8+
"bin": {
9+
"rdconfig-crypter": "bin/rdconfig-crypter.js",
10+
"rdconfig-nginx": "bin/rdconfig-nginx.js"
11+
},
612
"dependencies": {
7-
"config": "~1.13.0"
13+
"config": "~1.13.0",
14+
"ejs": "^2.3.3"
815
},
916
"devDependencies": {},
1017
"scripts": {

0 commit comments

Comments
 (0)