Socket
Socket
Sign inDemoInstall

couchdb-configure

Package Overview
Dependencies
91
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.5.0 to 1.5.1

12

cli.js

@@ -5,14 +5,12 @@ #!/usr/bin/env node

var args = process.argv.slice(2);
var args = process.argv.slice(2)
if (!args.length) {
return console.log('Usage: \ncouchdb-configure URL [SOURCE]')
console.log('Usage: \ncouchdb-configure URL [SOURCE]')
process.exit()
}
var url = args[0];
var url = args[0]
var source = args[1] || process.cwd()
configure(url, source, function(error, response) {
configure(url, source, function (error, response) {
if (error) return console.error(error)

@@ -19,0 +17,0 @@

@@ -6,3 +6,3 @@ var nanoOption = require('nano-option')

module.exports = function configure(url, source, callback) {
module.exports = function configure (url, source, callback) {
var couch = nanoOption(url)

@@ -13,9 +13,13 @@

compile(source, { index: true }, function(error, config) {
compile(source, { index: true }, function (error, config) {
if (error) {
return callback(error)
}
var settings = Object.keys(config)
.reduce(function(memo, key) {
.reduce(function (memo, key) {
if (typeof config[key] !== 'object') return memo
var section = Object.keys(config[key])
.map(function(k) {
.map(function (k) {
return {

@@ -30,3 +34,3 @@ path: encodeURIComponent(key) + '/' + encodeURIComponent(k),

async.map(settings, function(setting, next) {
async.map(settings, function (setting, next) {
couch.request({

@@ -36,3 +40,3 @@ method: 'PUT',

body: setting.value
}, function(error, oldValue) {
}, function (error, oldValue) {
if (error) return next(error)

@@ -46,6 +50,6 @@

})
}, function(error, responses) {
}, function (error, responses) {
if (error) return callback(error)
var response = responses.reduce(function(memo, response) {
var response = responses.reduce(function (memo, response) {
memo[response.path] = {

@@ -52,0 +56,0 @@ ok: true,

@@ -5,5 +5,7 @@ {

"main": "index.js",
"bin": "cli.js",
"bin": {
"couchdb-configure": "cli.js"
},
"scripts": {
"test": "tape test/index.js | tap-spec",
"test": "standard && tap --coverage test/index.js",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"

@@ -13,3 +15,3 @@ },

"type": "git",
"url": "https://github.com/eHealthAfrica/couchdb-configure.git"
"url": "git+https://github.com/eHealthAfrica/couchdb-configure.git"
},

@@ -20,3 +22,7 @@ "keywords": [

],
"author": "Johannes J. Schmidt <schmidt@netzmerk.com> (http://die-tf.de/)",
"author": {
"name": "Johannes J. Schmidt",
"email": "schmidt@netzmerk.com",
"url": "http://die-tf.de/"
},
"license": "Apache-2.0",

@@ -28,13 +34,15 @@ "bugs": {

"dependencies": {
"async": "^1.4.2",
"couchdb-compile": "^1.6.2",
"nano-option": "^1.2.1"
"async": "^1.5.2",
"couchdb-compile": "^1.6.3",
"nano-option": "^1.2.2"
},
"devDependencies": {
"nano": "^6.1.5",
"tap-spec": "^4.1.0",
"tape": "^4.2.1",
"semantic-release": "^6.0.3"
"nano": "^6.2.0",
"semantic-release": "^6.0.3",
"standard": "^6.0.4",
"tap": "^5.4.3"
},
"version": "1.5.0"
"version": "1.5.1",
"readme": "ERROR: No README data found!",
"_id": "couchdb-configure@"
}

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tap').test
var path = require('path')

@@ -8,7 +8,5 @@ var async = require('async')

var url = process.env.COUCH || 'http://localhost:5984'
var couch = nano(url)
// There is an issue with section deletion in CouchDB.

@@ -18,9 +16,9 @@ // You cannot delete an entire section:

// {"error":"method_not_allowed","reason":"Only GET,PUT,DELETE allowed"}
function clear(callback) {
function clear (callback) {
couch.request({
path: '_config/couchdb-configure'
}, function(error, config) {
}, function (error, config) {
if (error) return callback(error)
async.map(Object.keys(config), function(key, next) {
async.map(Object.keys(config), function (key, next) {
couch.request({

@@ -34,5 +32,5 @@ method: 'DELETE',

test('use url', function(t) {
configure(url, path.join(__dirname, 'fixtures', 'config.json'), function(error, responses) {
t.error(error, 'no error occured')
test('use url', function (t) {
configure(url, path.join(__dirname, 'fixtures', 'config.json'), function (error, responses) {
t.error(error)
t.end()

@@ -42,5 +40,5 @@ })

test('use url with trailing slash', function(t) {
configure(url + '/', path.join(__dirname, 'fixtures', 'config.json'), function(error, responses) {
t.error(error, 'no error occured')
test('use url with trailing slash', function (t) {
configure(url + '/', path.join(__dirname, 'fixtures', 'config.json'), function (error, responses) {
t.error(error)
t.end()

@@ -50,5 +48,5 @@ })

test('use nano object', function(t) {
configure(couch, path.join(__dirname, 'fixtures', 'config.json'), function(error, responses) {
t.error(error, 'no error occured')
test('use nano object', function (t) {
configure(couch, path.join(__dirname, 'fixtures', 'config.json'), function (error, responses) {
t.error(error)
t.end()

@@ -58,12 +56,13 @@ })

test('configure from json', function(t) {
clear(function(error) {
t.error(error, 'no error occured')
test('configure from json', function (t) {
clear(function (error) {
t.error(error)
configure(url, path.join(__dirname, 'fixtures', 'config.json'), function(error, responses) {
t.error(error, 'no error occured')
configure(url, path.join(__dirname, 'fixtures', 'config.json'), function (error, responses) {
t.error(error)
couch.request({
path: '_config/couchdb-configure/foo'
}, function(error, config) {
}, function (error, config) {
t.error(error)
t.equal(config, 'bar')

@@ -76,12 +75,13 @@ t.end()

test('configure from commonjs', function(t) {
clear(function(error) {
t.error(error, 'no error occured')
test('configure from commonjs', function (t) {
clear(function (error) {
t.error(error)
configure(url, path.join(__dirname, 'fixtures', 'config.js'), function(error, responses) {
t.error(error, 'no error occured')
configure(url, path.join(__dirname, 'fixtures', 'config.js'), function (error, responses) {
t.error(error)
couch.request({
path: '_config/couchdb-configure/baz'
}, function(error, config) {
}, function (error, config) {
t.error(error)
t.equal(config, 'foo')

@@ -94,12 +94,13 @@ t.end()

test('configure from commonjs/index', function(t) {
clear(function(error) {
t.error(error, 'no error occured')
test('configure from commonjs/index', function (t) {
clear(function (error) {
t.error(error)
configure(url, path.join(__dirname, 'fixtures', 'commonjs'), function(error, responses) {
t.error(error, 'no error occured')
configure(url, path.join(__dirname, 'fixtures', 'commonjs'), function (error, responses) {
t.error(error)
couch.request({
path: '_config/couchdb-configure/bar'
}, function(error, config) {
}, function (error, config) {
t.error(error)
t.equal(config, 'baz')

@@ -112,12 +113,13 @@ t.end()

test('configure from filesystem', function(t) {
clear(function(error) {
t.error(error, 'no error occured')
test('configure from filesystem', function (t) {
clear(function (error) {
t.error(error)
configure(url, path.join(__dirname, 'fixtures', 'config'), function(error, responses) {
t.error(error, 'no error occured')
configure(url, path.join(__dirname, 'fixtures', 'config'), function (error, responses) {
t.error(error)
couch.request({
path: '_config/couchdb-configure/foo'
}, function(error, config) {
}, function (error, config) {
t.error(error)
t.equal(config, 'bar')

@@ -124,0 +126,0 @@ t.end()

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc