Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
The project brings a Connect/Express inspired API and similar functionnalities to console based applications.
var shell = require('shell');
// Initialization
var app = new shell.Shell();
// Plugins registration
app.configure(function() {
app.use(shell.history({
shell: app
}));
app.use(shell.completer({
shell: app
}));
app.use(shell.router({
shell: app
}));
app.use(shell.redis({
shell: app,
config: 'redis.conf',
pidfile: 'redis.pid'
}));
app.use(shell.help({
shell: app,
introduction: true
}));
});
// Command registration
app.cmd('redis keys :pattern', 'Find keys', function(req, res, next){
if(!app.client){
app.client = require('redis').createClient();
}
app.client.keys(req.params.pattern, function(err, keys){
if(err){ return res.styles.red(err.message), next(); }
res.cyan(keys.join('\n')||'no keys');
res.prompt();
});
});
// Event notification
app.on('redis quit', function(){
if(app.client){
app.client.quit();
}
});
`npm install shell`
var app = new shell.Shell();
app.configure(function() {
app.use(shell.history({shell: app}));
app.use(shell.completer({shell: app}));
app.use(shell.help({shell: app, introduction: true}));
});
app.configure('prod', function() {
app.set('title', 'Production Mode');
});
The constructor shell.Shell
take an optional object. options are:
Like with Express, app.configure
allows the customization of plugins for all or specific environments while app.use
register plugins.
If app.configure
is called without specifying the environment as the first argument, the provided callback will always be called. Otherwise, the environment must match the env
setting or the global variable NODE_ENV
.
Shell settings may be set by calling app.set('key', value)
and may be retrieved by calling the same function without a second argument.
var app = new shell.Shell();
app.set('env', 'prod');
app.configure('prod', function() {
console.log(app.set('env'));
});
env
setting or NODE_ENV
if defined.By extending EventEmitter
, the following events are thrown:
A route is made of a command pattern, an optional description and one or more route specific middleware.
Middlewares recieve three parameters, a request object, a response object and a function.
The request object contains the following properties:
The response object inherit from styles which contains various utility functions for printing, coloring and bolding.
Persist command history between multiple sessions. Options passed during creation are:
process.cwd()+'/.node_shell'
Provide tab completion. Options passed during creation are:
Display help when use type "help" or when he press enter
on empty commands. Command help is only displayed if a description was provided during the command registration. Additionnaly, a new shell.help()
function is made available. Options passed during creation are:
Register two commands, http start
and http stop
. The start command will search for "./server.js" and "./app.js" to run by node
.
var app = new shell.Shell();
app.configure(function() {
app.use(shell.router({
shell: app
}));
app.use(shell.redis({
shell: app,
config: __dirname+'/redis.conf')
}));
app.use(shell.help({
shell: app,
introduction: true
}));
});
Register two commands, redis start
and redis stop
. The following properties may be provided as settings:
Exemple:
var app = new shell.Shell();
app.configure(function() {
app.use(shell.router({
shell: app
}));
app.use(shell.redis({
shell: app,
config: __dirname+'/redis.conf')
}));
app.use(shell.help({
shell: app,
introduction: true
}));
});
Register two commands, cloud9 start
and cloud9 stop
. Unless provided, the Cloud9 workspace will be automatically discovered if your project root directory contains a "package.json" file or a "node_module" directory.
Options:
null
.null
."127.0.0.1"
.3000
.Shell.set('project_dir')
.Exemple:
var app = new shell.Shell();
app.configure(function() {
app.use(shell.router({
shell: app
}));
app.use(shell.cloud9({
shell: app,
ip: '0.0.0.0'
}));
app.use(shell.help({
shell: app,
introduction: true
}));
});
Important, cloud9 must be installed as a NPM module but there's a problem. At the moment, the NPM module is based on the master branch of cloud9 on GitHub (version "0.3.0") and is expecting a Node version of 0.4.1. Here's the procedure to use the newer version on the devel branch:
git clone https://github.com/ajaxorg/cloud9.git
cd cloud9
git checkout -b devel origin/devel
git submodule update --init --recursive
npm link
Start Coffee in "wath" mode such as scripts are instantly compiled into Javascript.
Options:
Exemple:
var app = new shell.Shell();
app.configure(function() {
app.use(shell.router({
shell: app
}));
app.use(shell.coffee({
shell: app
}));
app.use(shell.help({
shell: app,
introduction: true
}));
});
FAQs
Command line arguments parser and stringifier
The npm package shell receives a total of 5,564 weekly downloads. As such, shell popularity was classified as popular.
We found that shell demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.