New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

widenbot

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

widenbot - npm Package Compare versions

Comparing version 2.6.1 to 3.0.0

widenbot-2.6.1.zip

167

bin/cli.js
#!/usr/bin/env node
var
pkg = require('../package.json'),
path = require('path')

@@ -9,3 +10,3 @@ ;

_ = require('lodash'),
minimist = require('minimist')
dashdash = require('dashdash')
;

@@ -16,69 +17,131 @@

var DEV_MODE = false;
function help()
{
console.log("usage: widenbot [OPTIONS]\n" +
"\nOPTIONS:\n" +
"\n\n" +
"\t--help\t\t Show this.\n" +
"\t\n" +
"\t--c=CONFIG_FILE\t Path to the configuration file (required).\n" +
"\t--host=HOST\t Hostname to use (default: 127.0.0.1)\n" +
"\t--port=PORT\t Port number to assign (default: 8080)\n" +
"\t\n");
}
function parse_args(args)
{
var parse_args = function parse_args2(args) {
if (args && _.isObject(args))
{
var result = minimist(args, {
strings: [
'configuration',
'help',
'port'
],
boolean: ['help', 'debug'],
default: {
'port': 8000
var options = [
{
names: ['hostname', 'host', 'h'],
type: 'string',
help: 'The local address to bind to (default: localhost)',
default: 'localhost',
env: 'HOSTNAME'
},
{
names: ['port', 'p'],
type: 'number',
help: 'The local port to bind to (default: 8000)',
default: 8000,
env: 'PORT'
},
{
names: ['config', 'c'],
type: 'string',
help: 'Path to configuration file to use (default: config.js)',
default: 'config.js'
},
{
names: ['botname', 'n'],
type: 'string',
help: 'The name of the bot (default: widenbot)',
default: 'widenbot',
env: 'BOT_NAME'
},
{
names: ['token', 't'],
type: 'string',
help: 'The Slack auth token (default: "")',
default: '',
env: 'SLACK_TOKEN'
},
{
names: ['url', 'u'],
type: 'string',
help: 'The Slack url (default: "")',
default: '',
env: 'SLACK_URL'
},
{
names: ['dbpath', 'd'],
type: 'string',
help: 'Path for the bot database (default: \'./db\')',
default: './db',
env: 'DB_PATH'
},
{
names: ['environment', 'env', 'e'],
type: 'string',
help: 'Environment to run in(default: \'production\')',
default: 'production',
env: 'NODE_ENV'
},
{
names: ['repl', 'r'],
type: 'bool',
help: 'Launch into a REPL environment for testing',
},
{
names: ['verbose', 'v'],
type: 'arrayOfBool',
help: 'Verbosity. Use multiple times for more verbose',
},
{
names: ['version'],
type: 'bool',
help: 'Print verison and exit',
},
{
names: ['help'],
type: 'bool',
help: 'Print this help and exit',
}
];
alias: {
'help': ['h'],
'configuration': [
'c',
'conf',
'config'
],
'port': ['p']
}
});
return result;
var parser = dashdash.createParser({ options: options });
var opts;
try {
opts = parser.parse(args);
} catch (e) {
console.error('widenbot [error]: %s', e.message);
process.exit(1);
}
if (opts.help) {
var help = parser.help({includeEnv: true}).trimRight();
console.log('usage: widenbot [OPTIONS]\n' +
'options:\n' +
help);
process.exit(0);
}
else if (opts.version) {
console.log('widenbot ' + pkg.version + '\n');
process.exit(0);
}
else {
return opts;
}
}
return {};
};
}
function main()
var main = function main()
{
var args = process.argv ? process.argv.slice(2) : null,
argv = parse_args(args);
var argv = parse_args(process.argv);
if (argv.help === true)
{
help();
process.exit(1);
}
var config = {
plugins: {}
};
var configPath = path.resolve(process.cwd(), argv.config),
try {
var configPath = path.resolve(process.cwd(), argv.config);
config = require(configPath);
} catch (exception) {}
config.port = process.env.PORT || config.port || argv.port || 8000;
config = _.extend(config, argv);
var widenbot = new Widenbot(config);
widenbot.listen();
return widenbot;
};
}
main();

@@ -19,6 +19,12 @@ var

assert(options && _.isObject(options), "Must provide options");
var self = this;
var defaultOptions = {};
var defaultOptions = {
botname: 'widenbot',
port: 8000,
token: '',
url: '',
dbpath: './widenbot.level.db'
};
this.options = _.extend(defaultOptions, options);

@@ -28,3 +34,3 @@ this.log = logging(this.options);

this.plugins = this.loadPlugins();
this.brain = new Brain(this.options.brain);
this.brain = new Brain(this.options);
this.webhooks = this.loadWebHooks();

@@ -92,3 +98,3 @@

this.client = restify.createJSONClient({ url: options.url });
this.client = restify.createJSONClient({ url: this.options.url });
}

@@ -95,0 +101,0 @@

@@ -23,42 +23,15 @@ /**

if (opts.logging.path)
if (opts.environment === 'dev')
{
if (!fs.existsSync(opts.logging.path))
fs.mkdirSync(opts.logging.path);
var fname = path.join(opts.logging.path, opts.botname + '.log');
logopts.streams.push({ level: 'trace', path: fname, });
}
if (opts.logging.console)
{
if (process.env.NODE_ENV === 'dev' || opts.debug === true)
var prettystream = new PrettyStream();
prettystream.pipe(process.stdout);
logopts.streams.push(
{
var prettystream = new PrettyStream();
prettystream.pipe(process.stdout);
logopts.streams.push(
{
level: 'debug',
type: 'raw',
stream: prettystream
});
}
else
logopts.streams.push({level: 'debug', stream: process.stdout});
}
if (opts.logging.logentries)
{
var logentries = require('bunyan-logentries');
console.log(opts.logging.logentries.token);
logopts.streams.push({
level: 'info',
stream: logentries.createStream({
token: opts.logging.logentries.token
}),
type: 'raw'
level: 'trace',
type: 'raw',
stream: prettystream
});
}
else
logopts.streams.push({level: 'debug', stream: process.stdout});

@@ -65,0 +38,0 @@ exports.logger = bunyan.createLogger(logopts);

{
"name": "widenbot",
"version": "2.6.1",
"version": "3.0.0",
"description": "Slack bot for Widen",

@@ -43,2 +43,3 @@ "keywords": [

"concat-stream": "^1.4.6",
"dashdash": "^1.10.0",
"level": "^0.18.0",

@@ -45,0 +46,0 @@ "lodash": "^2.4.1",

@@ -22,4 +22,3 @@ var

url: HOOK_URL,
logging: { console: false, path: './log'},
brain: { dbpath: './testdb' }
dbpath: './testdb'
};

@@ -69,5 +68,5 @@

st.throws(function(){
st.doesNotThrow(function(){
new Bot();
}, undefined, "should throw when no parameters");
}, undefined, "should not throw when no parameters");

@@ -74,0 +73,0 @@ st.doesNotThrow(function(){

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