Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

libesvm

Package Overview
Dependencies
Maintainers
3
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libesvm - npm Package Compare versions

Comparing version 3.5.1 to 3.5.2

lib/featureDetection.js

41

lib/getActualVersion.js

@@ -1,30 +0,8 @@

var _ = require('lodash');
var Promise = require('bluebird');
var exec = Promise.promisify(require('child_process').exec);
var join = require('path').join;
var _ = require('lodash');
var Promise = require('bluebird');
var exec = Promise.promisify(require('child_process').exec);
var join = require('path').join;
var getFeatures = require('./featureDetection').getFeatures;
var version;
function versionCommand(path) {
var cmd = join(path, 'bin', 'elasticsearch');
return exec(cmd + ' --help')
.then(function (results) {
var stdout = results[0];
var stderr = results[1];
// versions 5.0+
if(/-V\b/g.test(stdout)){
return cmd + ' -V';
}
// versions <2.0
if(/-v\b/g.test(stdout)){
return cmd + ' -v';
}
// Some 2.0 version don't have --version in the help command so we can just
// try to assume that it will work. All the 1.x have -v
return cmd + ' --version';
});
}
function parseStdOut(results) {

@@ -42,3 +20,6 @@ var stdout = results[0];

if (version) return Promise.resolve(version);
return versionCommand(path)
return getFeatures(path)
.then(function (features) {
return join(path, 'bin', 'elasticsearch') + ' ' + features.versionFlag;
})
.then(function (cmd) {

@@ -49,6 +30,6 @@ return exec(cmd).then(parseStdOut);

.map(function (line) {
return ' ' + line
return ' ' + line;
}).join('\n');
throw new Error(message);
});
}
};
var _ = require('lodash');
var Promises = require('bluebird');
var Bluebird = require('bluebird');
var exec = require('child_process').exec;

@@ -8,2 +8,3 @@ var semver = require('semver');

var getActualVersion = require('./getActualVersion');
var getFeatures = require('./featureDetection').getFeatures;

@@ -14,3 +15,3 @@ var ERR_UNKNOWN = 0;

function createLegacyPluginInstallCommand(path, plugin) {
function createLegacyPluginInstallCommand(path, plugin, features) {
var cmd = join(path, 'bin', 'plugin');

@@ -21,3 +22,3 @@ cmd += ' --install ';

if (plugin.path) cmd += ' --url ' + plugin.path;
if (plugin.staging) cmd += ' -Des.plugins.staging=true';
if (plugin.staging) cmd += ' ' + features.configVarFlag + 'features.es.plugins.staging=true';
} else {

@@ -29,3 +30,3 @@ cmd += plugin;

function create2xPluginInstallCommand(path, plugin) {
function create2xPluginInstallCommand(path, plugin, features) {
var cmd = join(path, 'bin', 'plugin');

@@ -35,3 +36,3 @@ cmd += ' install ';

cmd += (plugin.path) ? plugin.path : plugin.name;
if (plugin.staging) cmd += ' -Des.plugins.staging=true';
if (plugin.staging) cmd += ' ' + features.configVarFlag + 'plugins.staging=true';
} else {

@@ -43,3 +44,3 @@ cmd += plugin;

function create5xPluginInstallCommand(path, plugin) {
function create5xPluginInstallCommand(path, plugin, features) {
var cmd = join(path, 'bin', 'elasticsearch-plugin');

@@ -49,3 +50,3 @@ cmd += ' install ';

cmd += (plugin.path) ? plugin.path : plugin.name;
if (plugin.staging) cmd += ' -Des.plugins.staging=true';
if (plugin.staging) cmd += ' ' + features.configVarFlag + 'plugins.staging=true';
} else {

@@ -59,14 +60,21 @@ cmd += plugin;

function installCommand(path, plugin) {
return getActualVersion(path).then(function (version) {
return Bluebird.all([
getFeatures(path),
getActualVersion(path),
])
.spread(function (features, version) {
if (semver.satisfies(version, '<=1.x')) {
return createLegacyPluginInstallCommand(path, plugin);
return createLegacyPluginInstallCommand(path, plugin, features);
}
if (semver.satisfies(version, '2.x')) {
return create2xPluginInstallCommand(path, plugin);
return create2xPluginInstallCommand(path, plugin, features);
}
if (semver.satisfies(version, '5.x || 3.x')) {
return create5xPluginInstallCommand(path, plugin);
return create5xPluginInstallCommand(path, plugin, features);
}
throw new Error('Not sure how to install plugins for version ' + version);
});

@@ -87,3 +95,3 @@ }

* @param {function} [options.log] The logger
* @returns {Promises}
* @returns {Promise}
*/

@@ -111,3 +119,3 @@ module.exports = function installPlugin(options, cb) {

return installCommand(path, plugin).then(function (cmd) {
return new Promises(function (resolve, reject) {
return new Bluebird(function (resolve, reject) {
exec(cmd, function (err, stdout) {

@@ -123,2 +131,1 @@ if (!err) return resolve(stdout);

};

@@ -5,3 +5,3 @@ var child_process = require('child_process');

var _ = require('lodash');
var Promises = require('bluebird');
var Bluebird = require('bluebird');
var utils = require('./utils');

@@ -17,2 +17,3 @@ var join = require('path').join;

var getActualVersion = require('./getActualVersion');
var getFeatures = require('./featureDetection').getFeatures;

@@ -35,9 +36,13 @@ var startOfStackTraceRE = /^Exception in thread /;

var self = this;
return getActualVersion(self.path).then(function (version) {
return Bluebird.all([
getActualVersion(self.path),
getFeatures(self.path),
])
.spread(function (version, features) {
return writeTempConfig(self.config, self.path)
.then(writeShieldConfig(self.options))
.then(writeShieldConfig(self.options, version))
.then(function (configPath) {
return new Promises(function (resolve, reject) {
return new Bluebird(function (resolve, reject) {
self.configPath = configPath;
var args = ['-Des.path.conf='+configPath];
var args = [features.configVarFlag + 'path.conf='+configPath];

@@ -51,3 +56,3 @@ // branch names aren't valid semver, just check the first number

if (self.clusterNameOverride) {
args.push('-Des.cluster.name='+self.clusterNameOverride);
args.push(features.configVarFlag + 'cluster.name='+self.clusterNameOverride);
}

@@ -201,3 +206,3 @@

var self = this;
return new Promises(function (resolve, reject) {
return new Bluebird(function (resolve, reject) {
if (!self.process) return;

@@ -204,0 +209,0 @@ self.process.on('close', resolve);

@@ -8,2 +8,3 @@ var _ = require('lodash');

var fs = require('fs');
var semver = require('semver');
var copy = Promise.promisify(fsExtra.copy);

@@ -17,18 +18,2 @@ var mkdirs = Promise.promisify(fsExtra.mkdirs);

function copyShieldFiles(basePath, configPath) {
return new Promise(function (resolve, reject) {
glob(path.join(basePath, 'config', 'shield', '*'), function (err, files) {
if (err) return reject(err);
mkdirs(path.join(configPath, 'shield'))
.then(function () {
return Promise.each(files, function (file) {
var src = file;
var dest = path.join(configPath, 'shield', path.basename(file));
return copy(src, dest);
});
}).then(resolve, reject);
});
});
}
function createUsersAndRoles(configPath, users) {

@@ -57,3 +42,3 @@ return function () {

})
return outputFile(path.join(configPath, 'shield', 'users'), data.join("\n"));
return outputFile(path.join(configPath, 'users'), data.join("\n"));
})

@@ -65,3 +50,3 @@ .then(function () {

})
return outputFile(path.join(configPath, 'shield', 'users_roles'), data.join("\n"));
return outputFile(path.join(configPath, 'users_roles'), data.join("\n"));
});

@@ -72,3 +57,3 @@ };

function createRoles(configPath, roles) {
var rolesYml = path.join(configPath, 'shield', 'roles.yml');
var rolesYml = path.join(configPath, 'roles.yml');
return stat(rolesYml).then(function (arg) {

@@ -86,10 +71,14 @@ return readFile(rolesYml, 'utf8').then(function (data) {

module.exports = function writeShieldConfig(options) {
module.exports = function writeShieldConfig(options, version) {
return function (configPath) {
// append the shield/xpack directory to configPath
var usersConfig = semver.satisfies(version, '5.x || 3.x') ? 'xpack' : 'shield';
var shieldConfigPath = path.join(configPath, usersConfig);
if (!options.shield || !options.shield.users) return Promise.resolve(configPath);
return Promise.try(createUsersAndRoles(configPath, options.shield.users))
return Promise.try(createUsersAndRoles(shieldConfigPath, options.shield.users))
.then(function (result) {
if (options.shield.roles) {
return createRoles(configPath, options.shield.roles);
return createRoles(shieldConfigPath, options.shield.roles);
} else {

@@ -96,0 +85,0 @@ return result;

{
"name": "libesvm",
"version": "3.5.1",
"version": "3.5.2",
"description": "libesvm is a library for managning an Elasticsearch process for development and testing.",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc