eggjs/egg-bin

Name: egg-bin

Owner: egg

Description: egg developer tool

Created: 2016-06-18 06:59:02.0

Updated: 2018-05-12 09:40:27.0

Pushed: 2018-04-18 03:29:38.0

Homepage:

Size: 287

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

egg-bin

NPM version build status Test coverage David deps Known Vulnerabilities npm download

egg developer tool, extends common-bin.


Install
m i egg-bin --save-dev
Usage

Add egg-bin to package.json scripts:


cripts": {
"dev": "egg-bin dev",
"debug": "egg-bin debug",
"test-local": "egg-bin test",
"test": "npm run lint -- --fix && npm run test-local",
"cov": "egg-bin cov",
"lint": "eslint .",
"pkgfiles": "egg-bin pkgfiles",
"autod": "egg-bin autod",
"ci": "npm run lint && npm run autod -- --check && npm run pkgfiles -- --check && npm run cov"


Command

All the commands support these specific v8 options:

g-bin [command] --debug --es_staging

if process.env.NODE_DEBUG_OPTION is provided (WebStorm etc), will use it as debug options.

dev

Start dev cluster on local env, it will start a master, an agent and a worker.

g-bin dev
options
debug

Debug egg app with V8 Inspector Integration.

automatically detect the protocol, use the new inspector when the targeted runtime >=7.0.0 .

if running without VSCode or WebStorm, we will use inspector-proxy to proxy worker debug, so you don't need to worry about reload.

g-bin debug --debug-port=9229 --proxy=9999
options
test

Using mocha with co-mocha to run test.

power-assert is the default assert library, and intelli-espower-loader will be auto required.

g-bin test [files] [options]
auto require test/.setup.js

If test/.setup.js file exists, it will be auto require as the first test file.


? .setup.js
? foo.test.js
options

You can pass any mocha argv.

environment

Environment is also support, will use it if options not provide.

You can set TESTS env to set the tests directory, it support glob grammar.

S=test/a.test.js egg-bin test

And the reporter can set by the TEST_REPORTER env, default is spec.

_REPORTER=doc egg-bin test

The test timeout can set by TEST_TIMEOUT env, default is 30000 ms.

_TIMEOUT=2000 egg-bin test
cov

Using [nyc] to run code coverage, it support all test params above.

Coverage reporter will output text-summary, json and lcov.

options

You can pass any mocha argv.

environment

You can set COV_EXCLUDES env to add dir ignore coverage.

V_EXCLUDES="app/plugins/c*,app/autocreate/**" egg-bin cov
pkgfiles

Generate pkg.files automatically before npm publish, see ypkgfiles for detail

g-bin pkgfiles
autod

Generate pkg.dependencies and pkg.devDependencies automatically, see autod for detail

g-bin autod
Custom egg-bin for your team

You maybe need a custom egg-bin to implement more custom features if your team has develop a framework base on egg.

Now you can implement a Command sub class to do that. Or you can just override the exists command.

See more at common-bin.

Example: Add nsp for security scan

nsp has provide a useful security scan feature.

This example will show you how to add a new NspCommand to create a new egg-bin tool.

my-egg-bin
t EggBinCommand = require('egg-bin');

s MyEggBinCommand extends EggBinCommand {
nstructor(rawArgv) {
super(rawArgv);
this.usage = 'Usage: egg-bin [command] [options]';

// load directory
this.load(path.join(__dirname, 'lib/cmd'));



le.exports = MyEggBinCommand;
NspCommand
t Command = require('egg-bin').Command;

s NspCommand extends Command {
run({ cwd, argv }) {
console.log('run nsp check at %s with %j', cwd, argv);


scription() {
return 'nsp check';



le.exports = NspCommand;
my-egg-bin.js
sr/bin/env node

 strict';
t Command = require('..');
Command().start();
Run result
-egg-bin nsp

nsp check at /foo/bar with {}
License

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.