![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Create nice looking shell applications in minutes with Connect/Express inspired API and functionnalities.
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 global variable NODE_ENV
or the env
setting.
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'));
});
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 prompt. 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, 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
. The following properties may be provided as settings:
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 and is expecteding a Node version of 0.4.1. Here's the procedure to use a newer version:
git clone https://github.com/ajaxorg/cloud9.git
git checkout -b devel origin/devel
npm link
FAQs
Command line arguments parser and stringifier
The npm package shell receives a total of 6,622 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.