Comparing version 3.2.0 to 3.3.0
@@ -1,6 +0,7 @@ | ||
var _ = require('lodash'); | ||
var Promises = require('bluebird'); | ||
var exec = require('child_process').exec; | ||
var semver = require('semver'); | ||
var join = require('path').join; | ||
var _ = require('lodash'); | ||
var Promises = require('bluebird'); | ||
var exec = require('child_process').exec; | ||
var semver = require('semver'); | ||
var join = require('path').join; | ||
var installSnapshotPlugin = require('./installSnapshotPlugin'); | ||
@@ -13,4 +14,20 @@ var ERR_UNKNOWN = 0; | ||
var cmd = join(path, 'bin', 'plugin'); | ||
cmd += (oldCommand === true) ? ' --install ' : ' install '; | ||
cmd += (_.isPlainObject(plugin)) ? plugin.name + ' --url ' + plugin.path : plugin; | ||
if (oldCommand) { | ||
cmd += ' --install '; | ||
if (_.isPlainObject(plugin)) { | ||
cmd += plugin.name; | ||
if (plugin.path) cmd += ' --url ' + plugin.path; | ||
if (plugin.staging) cmd += ' -Des.plugins.staging=true'; | ||
} else { | ||
cmd += plugin; | ||
} | ||
} else { | ||
cmd += ' install '; | ||
if (_.isPlainObject(plugin)) { | ||
cmd += (plugin.path) ? plugin.path : plugin.name; | ||
if (plugin.staging) cmd += ' -Des.plugins.staging=true'; | ||
} else { | ||
cmd += plugin; | ||
} | ||
} | ||
return cmd; | ||
@@ -33,3 +50,3 @@ } | ||
*/ | ||
module.exports = function (options, cb) { | ||
module.exports = function installPlugin(options, cb) { | ||
var log = options.log || _.noop; | ||
@@ -40,2 +57,4 @@ var path = options.path; | ||
if (_.isPlainObject(plugin) && plugin.snapshot) return installSnapshotPlugin(options, installPlugin, cb); | ||
function handleInstallError(resolve, reject, stdout, fn) { | ||
@@ -42,0 +61,0 @@ var errorCause = getErrorCause(stdout); |
var _ = require('lodash'); | ||
var bcrypt = require('bcrypt'); | ||
var bcrypt = require('bcryptjs'); | ||
var glob = require('glob'); | ||
@@ -33,3 +33,5 @@ var path = require('path'); | ||
return Promise.each(users, function (user) { | ||
return hash(user.password, 10) | ||
return Promise.fromNode(function (cb) { | ||
bcrypt.hash(user.password, bcrypt.genSaltSync(10), cb); | ||
}) | ||
.then(function (hash) { | ||
@@ -64,10 +66,9 @@ userHash[user.username] = hash; | ||
return function (configPath) { | ||
if (options.shield && options.shield.users) { | ||
return copyShieldFiles(options.path, configPath) | ||
.then(createUsersAndRoles(configPath, options.shield.users)) | ||
.thenReturn(configPath); | ||
} | ||
return Promise.resolve(configPath); | ||
if (!options.shield || !options.shield.users) return Promise.resolve(configPath); | ||
return copyShieldFiles(options.path, configPath) | ||
.then(createUsersAndRoles(configPath, options.shield.users)) | ||
.thenReturn(configPath); | ||
} | ||
} | ||
{ | ||
"name": "libesvm", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "libesvm is a library for managning an Elasticsearch process for development and testing.", | ||
@@ -20,3 +20,3 @@ "main": "index.js", | ||
], | ||
"license": "Apache 2.0", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
@@ -27,4 +27,4 @@ "url": "https://github.com/ccowan/libesvm/issues" | ||
"dependencies": { | ||
"bcrypt": "^0.8.5", | ||
"bluebird": "~2.1.2", | ||
"bcryptjs": "^2.3.0", | ||
"bluebird": "~2.10.2", | ||
"fs-extra": "^0.24.0", | ||
@@ -36,2 +36,3 @@ "glob": "^6.0.1", | ||
"properties-parser": "^0.2.3", | ||
"rcloader": "^0.1.4", | ||
"request": "~2.65.0", | ||
@@ -38,0 +39,0 @@ "rimraf": "~2.2.8", |
var fs = require('fs'); | ||
var expect = require('chai').expect; | ||
var cache = require('../lib/cache'); | ||
var crypto = require('crypto'); | ||
var temp = require('temp').track(); | ||
/** | ||
* A utility to create a temp file name | ||
* @param {string} prefix The prefix for the cache file | ||
* @param {function} cb The node style callback | ||
* @returns {null} | ||
*/ | ||
var tmpfile = function (prefix, cb) { | ||
prefix = prefix && prefix + '-' || ''; | ||
crypto.randomBytes(32, function (err, buf) { | ||
if (err) return cb(err); | ||
var filename = crypto.createHash('sha1') | ||
.update(buf) | ||
.digest('hex'); | ||
cb(null, '/tmp/' + prefix + filename); | ||
}); | ||
}; | ||
describe('Cache', function() { | ||
describe('File opperations', function() { | ||
describe('File operations', function() { | ||
after(function (done) { | ||
temp.cleanup(done); | ||
}); | ||
it('should return an empty object when fetch is called and the cache is new', function (done) { | ||
tmpfile('empty-test', function (err, filename) { | ||
var source = cache.source; | ||
cache.source = filename; | ||
temp.open('empty-test', function (err, filename) { | ||
cache.source = filename.path; | ||
cache.fetch().then(function (data) { | ||
cache.source = source; | ||
expect(data).to.be.empty; | ||
@@ -39,18 +23,28 @@ done(); | ||
it('should save a new value', function (done) { | ||
tmpfile('test', function (err, filename) { | ||
var source = cache.source; | ||
cache.source = filename; | ||
cache.set('myTest', 'test'); | ||
cache.save(function (err) { | ||
cache.source = source; | ||
if (err) return done(err); | ||
fs.readFile(filename, function (err, buf) { | ||
if (err) return done(err); | ||
var data = JSON.parse(buf.toString('utf8')); | ||
expect(data).to.have.property('myTest', 'test'); | ||
fs.unlink(filename, done); | ||
}); | ||
it('should save a new value on set', function (done) { | ||
temp.open('set-test', function (err, filename) { | ||
cache.source = filename.path; | ||
cache.set('myTest', 'test', function (err) { | ||
var contents = fs.readFileSync(filename.path, { encoding: 'utf8' }); | ||
var data = JSON.parse(contents); | ||
expect(data).to.have.property('myTest', 'test'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should save a new value on save', function (done) { | ||
temp.open('save-test', function (err, filename) { | ||
cache.source = filename.path; | ||
cache.set('myTest', 'test') | ||
.then(function () { | ||
cache.save(function (err) { | ||
var contents = fs.readFileSync(filename.path, { encoding: 'utf8' }); | ||
var data = JSON.parse(contents); | ||
expect(data).to.have.property('myTest', 'test'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -57,0 +51,0 @@ }); |
var fs = require('fs'); | ||
var path = require('path'); | ||
var temp = require('temp').track(); | ||
var expect = require('chai').expect; | ||
var cache = require('../lib/cache'); | ||
var crypto = require('crypto'); | ||
/** | ||
* A utility to create a temp file name | ||
* @param {string} prefix The prefix for the cache file | ||
* @param {function} cb The node style callback | ||
* @returns {null} | ||
*/ | ||
var tmpfile = function (prefix, cb) { | ||
prefix = prefix && prefix + '-' || ''; | ||
crypto.randomBytes(32, function (err, buf) { | ||
if (err) return cb(err); | ||
var filename = crypto.createHash('sha1') | ||
.update(buf) | ||
.digest('hex'); | ||
cb(null, '/tmp/' + prefix + filename); | ||
}); | ||
}; | ||
describe('Cache', function() { | ||
describe('Base functionality', function () { | ||
var fixture = { | ||
example: 'test', | ||
bar: 'foo', | ||
foo: 'bar', | ||
}; | ||
var fixture = { | ||
example: 'test', | ||
bar: 'foo', | ||
foo: 'bar', | ||
}; | ||
// Create the cache fixture | ||
before(function (done) { | ||
temp.open('es-load-cache', function (err, filename) { | ||
if (err) return done(err); | ||
// Create the cache fixture | ||
before(function (done) { | ||
tmpfile('es-load-cache', function (err, filename) { | ||
if (err) return done(err); | ||
cache.source = filename; | ||
fs.writeFile(cache.source, JSON.stringify(fixture), done); | ||
cache.source = filename.path; | ||
fs.writeFile(cache.source, JSON.stringify(fixture), done); | ||
}); | ||
}); | ||
}); | ||
// Clean up the cache file | ||
after(function (done) { | ||
fs.unlink(cache.source, done); | ||
}); | ||
it('should return valid data', function(done) { | ||
cache.get('bar').then(function (val) { | ||
expect(val).to.equal('foo'); | ||
done(); | ||
// Clean up the cache file | ||
after(function (done) { | ||
temp.cleanup(done); | ||
}); | ||
}); | ||
it('should return undefined for invalid data', function(done) { | ||
cache.get('monkey').then(function (val) { | ||
expect(val).to.be.an('undefined'); | ||
done(); | ||
it('should return valid data', function(done) { | ||
cache.get('bar').then(function (val) { | ||
expect(val).to.equal('foo'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should set a new value', function() { | ||
cache.set('name', 'test').then(function () { | ||
return cache.get('name'); | ||
}) | ||
.then(function (val) { | ||
expect(val).to.equal('test'); | ||
it('should return undefined for invalid data', function(done) { | ||
cache.get('monkey').then(function (val) { | ||
expect(val).to.be.an('undefined'); | ||
done(); | ||
}); | ||
}); | ||
it('should set a new value', function() { | ||
cache.set('name', 'test').then(function () { | ||
return cache.get('name'); | ||
}) | ||
.then(function (val) { | ||
expect(val).to.equal('test'); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59964
46
1659
16
15
9
+ Addedbcryptjs@^2.3.0
+ Addedrcloader@^0.1.4
+ Addedbcryptjs@2.4.3(transitive)
+ Addedbluebird@2.10.2(transitive)
+ Addedlodash@3.10.1(transitive)
+ Addedlodash.clonedeep@4.5.0(transitive)
+ Addedrcfinder@0.1.9(transitive)
+ Addedrcloader@0.1.4(transitive)
- Removedbcrypt@^0.8.5
- Removedbcrypt@0.8.7(transitive)
- Removedbindings@1.2.1(transitive)
- Removedbluebird@2.1.3(transitive)
- Removednan@2.3.5(transitive)
Updatedbluebird@~2.10.2