Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
cli-router
Advanced tools
A simple Cli router to Controllers
$ npm install --save cli-router
Example of binary usage:
./usage.txt
:Hello Word
Usage:
usage hello <name> [--help]
usage now [--help]
usage version
usage [--version | -h | --help]
Options:
--help, -h Show this help.
--version Show version.
./hello
#!/usr/bin/env node
var Cli = require('cli-router').Cli;
var cli = new Cli({
// Caminho para o arquivo de usage (seguindo o padrão do docopt.
path: path.join(__dirname, `usage.txt`),
// Diretório onde estão os controladores
controllers_root: path.join(__dirname, "controllers")
});
cli
.route('help', function(p, args) { return p.help || p['--help'] || args.length <= 0 })
.route('version', function(p) { return p.version || p['--version'] })
.route('now', null, function() { return (new Date()).toString(); });
.route('hello');
// passa os argumentos para o cli-router executar
var result = cli.run({ argv: process.argv.slice(2) });
console.log(result);
controllers/hello.js
// Used ES6 JS
var CliController = require('cli-router').CliController;
class Hello extends CliController {
}
module.exports = Hello;
controllers/help.js
// Used ES6 JS
var chalk = require('chalk');
var CliControllers = require('cli-router').CliControllers;
class Help extends CliControllers.Help {
index(params, cli) {
var usage = super.index(params, cli);
usage = this.colorizeSections(params, usage);
console.log(usage);
return 0;
}
colorizeSections(params, usage) {
_.map(this.sections, (section) => {
var regex = new RegExp(`^(${section}:)`, 'gmi');
var match = regex.match(usage);
if (match) {
usage = usage.replace(regex, chalk.blue(`${match[1]}`));
}
});
return usage;
}
}
module.exports = Help;
Install/Update dependencies:
$ npm install --save-dev azk-dev
$ gulp editor:config
$ gulp babel:runtime:install
$ npm install
Commit
$ git add .
$ git commit -m 'Updated azk-dev.'
Show all gulp tasks:
$ gulp help
# default (lint + test, no watch)
$ gulp lint test
# test + lint + watch
$ gulp watch:lint:test
# test + watch (no-lint)
$ gulp watch:test
You can deploy package with:
$ npm run deploy [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]
This should run the following steps:
npm test
package.json
, commit and add tagFAQs
cli-router
The npm package cli-router receives a total of 3 weekly downloads. As such, cli-router popularity was classified as not popular.
We found that cli-router demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.