egg-bin
egg developer tool
Last updated 8 years ago by fengmk2 .
Repository · Bugs · Original npm · Tarball · package.json
$ npm install egg-bin 
SYNC missed versions from official npm registry.

egg-bin

NPM version build status Test coverage Known Vulnerabilities npm download

egg developer tool, extends @artus-cli/artus-cli.


Install

npm i egg-bin --save-dev

Usage

Add egg-bin to package.json scripts:

{
  "scripts": {
    "dev": "egg-bin dev",
    "test-local": "egg-bin test",
    "test": "npm run lint -- --fix && npm run test-local",
    "cov": "egg-bin cov",
    "lint": "eslint .",
    "ci": "npm run lint && npm run cov"
  }
}

Command

All the commands support these specific options:

  • --inspect
  • --inspect-brk
  • --typescript / --ts enable typescript support. Auto detect from package.json's pkg.egg.typescript, or pkg.dependencies.typescript/pkg.devDependencies.typescript.
  • --base / --baseDir application's root path, default to process.cwd().
  • --require will add to execArgv, support multiple. Also support read from package.json's pkg.egg.require
  • --dry-run / -d whether dry-run the test command, just show the command
egg-bin [command] --inspect
egg-bin [command] --inspect-brk
egg-bin [command] --typescript
egg-bin [command] --base /foo/bar

dev

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

egg-bin dev

dev options

  • --framework egg web framework root path.
  • --port server port. If not specified, the port is obtained in the following order: egg.js configuration config/config.*.js > process.env.EGG_BIN_DEFAULT_PORT > 7001 > other available ports.
  • --workers worker process number, default to 1 worker at local mode.
  • --sticky start a sticky cluster server, default to false.

debug/inspect on VSCode

Create .vscode/launch.json file:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Egg Debug",
      "runtimeExecutable": "npm",
      "runtimeArgs": [
        "run",
        "dev",
        "--",
        "--inspect-brk"
      ],
      "console": "integratedTerminal",
      "restart": true,
      "protocol": "auto",
      "port": 9229,
      "autoAttachChildProcesses": true
    },
    {
      "type": "node",
      "request": "launch",
      "name": "Egg Test",
      "runtimeExecutable": "npm",
      "runtimeArgs": [
        "run",
        "test-local",
        "--",
        "--inspect-brk"
      ],
      "protocol": "auto",
      "port": 9229,
      "autoAttachChildProcesses": true
    }
  ]
}

test

Using mocha to run test.

egg-bin test [...files] [options]
  • files is optional, default to test/**/*.test.ts
  • test/fixtures, test/node_modules is always exclude.

auto require test/.setup.ts

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

test
  ├── .setup.ts
  └── foo.test.ts

test options

You can pass any mocha argv.

  • --timeout milliseconds, default to 60000
  • --changed / -c only test changed test files(test files means files that match ${pwd}/test/**/*.test.(js|ts))
  • --parallel enable mocha parallel mode, default to false.
  • --auto-agent auto start agent in mocha master agent.
  • --jobs number of jobs to run in parallel, default to os.cpus().length - 1.
  • --mochawesome enable mochawesome reporter, default to true.

test 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.

TESTS=test/a.test.ts egg-bin test

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

TEST_REPORTER=doc egg-bin test

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

TEST_TIMEOUT=2000 egg-bin test

cov

Using mocha and [c8] to run code coverage, it support all test params above.

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

cov options

You can pass any mocha argv.

  • -x add dir ignore coverage, support multiple argv
  • --prerequire prerequire files for coverage instrument, you can use this options if load files slowly when call mm.app or mm.cluster
  • --typescript / --ts enable typescript support. If true, will auto add .ts extension and ignore typings and d.ts.
  • --c8 c8 instruments passthrough. you can use this to overwrite egg-bin's default c8 instruments and add additional ones.
    • egg-bin have some default instruments passed to c8 like -r and --temp-directory
    • egg-bin cov --c8="-r teamcity -r text" --c8-report=true
  • also support all test params above.

cov environment

You can set COV_EXCLUDES env to add dir ignore coverage.

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

Custom egg-bin for your team

See https://artus-cli.github.io

License

MIT

Contributors


fengmk2


atian25


popomore


whxaxes


semantic-release-bot


dead-horse


killagu


hyj1991


mansonchor


ngot


waitingsong


onlylovermb


snyk-bot


BiosSun


luckydrq


gxkl


stormslowly


Solais


snapre


ZYSzys


angleshe


ahungrynoob


yinseny


liuhanqu


okoala

This project follows the git-contributor spec, auto updated at Sat Jun 03 2023 16:58:54 GMT+0800.

Current Tags

  • 6.10.0                                ...           latest (5 months ago)
  • 4.20.0                                ...           latest-4 (2 years ago)
  • 5.18.1                                ...           latest-5 (7 months ago)
  • 5.16.0                                ...           release-5.x (8 months ago)

178 Versions

  • 6.10.0                                ...           5 months ago
  • 6.9.0                                ...           6 months ago
  • 5.18.1                                ...           7 months ago
  • 5.18.0                                ...           7 months ago
  • 5.17.1                                ...           8 months ago
  • 5.17.0                                ...           8 months ago
  • 5.16.0                                ...           8 months ago
  • 6.8.1                                ...           8 months ago
  • 5.15.1                                ...           9 months ago
  • 5.15.0                                ...           9 months ago
  • 6.8.0                                ...           9 months ago
  • 6.7.0                                ...           10 months ago
  • 6.6.0                                ...           10 months ago
  • 6.5.2                                ...           a year ago
  • 6.5.1                                ...           a year ago
  • 6.5.0                                ...           a year ago
  • 5.14.2                                ...           a year ago
  • 5.14.1                                ...           a year ago
  • 6.4.2                                ...           a year ago
  • 6.4.1                                ...           a year ago
  • 6.4.0                                ...           2 years ago
  • 5.14.0                                ...           2 years ago
  • 6.3.0                                ...           2 years ago
  • 6.2.0                                ...           2 years ago
  • 6.1.2                                ...           2 years ago
  • 6.2.0-beta.0                                ...           2 years ago
  • 6.1.1                                ...           2 years ago
  • 6.1.0                                ...           2 years ago
  • 6.0.0                                ...           2 years ago
  • 6.0.0-beta.5                                ...           2 years ago
  • 6.0.0-beta.4                                ...           2 years ago
  • 6.0.0-beta.3                                ...           2 years ago
  • 6.0.0-beta.2                                ...           2 years ago
  • 6.0.0-beta.1                                ...           2 years ago
  • 6.0.0-beta.0                                ...           2 years ago
  • 5.13.4                                ...           2 years ago
  • 5.13.3                                ...           2 years ago
  • 5.13.2                                ...           2 years ago
  • 5.13.1                                ...           2 years ago
  • 5.13.0                                ...           2 years ago
  • 5.12.6                                ...           2 years ago
  • 5.12.5                                ...           2 years ago
  • 5.12.4                                ...           2 years ago
  • 5.12.3                                ...           2 years ago
  • 5.12.2                                ...           2 years ago
  • 5.12.1                                ...           2 years ago
  • 5.12.0                                ...           2 years ago
  • 5.11.3                                ...           2 years ago
  • 5.11.2                                ...           2 years ago
  • 5.11.1                                ...           2 years ago
  • 5.11.0                                ...           2 years ago
  • 5.10.0                                ...           2 years ago
  • 5.9.0                                ...           2 years ago
  • 5.8.1                                ...           2 years ago
  • 5.8.0                                ...           2 years ago
  • 5.7.0                                ...           2 years ago
  • 5.6.1                                ...           2 years ago
  • 5.6.0                                ...           2 years ago
  • 5.5.0                                ...           2 years ago
  • 5.4.1                                ...           2 years ago
  • 5.4.0                                ...           2 years ago
  • 5.3.3                                ...           2 years ago
  • 5.3.2                                ...           2 years ago
  • 5.3.1                                ...           2 years ago
  • 5.3.0                                ...           2 years ago
  • 4.20.0                                ...           2 years ago
  • 5.2.0                                ...           2 years ago
  • 4.19.2                                ...           2 years ago
  • 5.1.2                                ...           2 years ago
  • 4.19.1                                ...           2 years ago
  • 5.1.1                                ...           2 years ago
  • 5.1.0                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.19.0                                ...           3 years ago
  • 4.18.1                                ...           3 years ago
  • 4.18.0                                ...           3 years ago
  • 4.17.0                                ...           3 years ago
  • 4.17.0-beta2                                ...           3 years ago
  • 4.17.0-beta1                                ...           3 years ago
  • 4.16.4                                ...           3 years ago
  • 4.16.3                                ...           3 years ago
  • 4.16.2                                ...           4 years ago
  • 4.16.1                                ...           4 years ago
  • 4.16.0                                ...           4 years ago
  • 4.15.0                                ...           4 years ago
  • 4.14.1                                ...           5 years ago
  • 4.14.0                                ...           5 years ago
  • 4.13.2                                ...           5 years ago
  • 4.13.1                                ...           6 years ago
  • 4.13.0                                ...           6 years ago
  • 4.12.3                                ...           6 years ago
  • 4.12.2                                ...           6 years ago
  • 4.12.1                                ...           6 years ago
  • 4.12.0                                ...           6 years ago
  • 4.11.1                                ...           6 years ago
  • 4.11.0                                ...           6 years ago
  • 4.10.0                                ...           6 years ago
  • 4.9.0                                ...           6 years ago
  • 4.8.5                                ...           6 years ago
  • 4.8.4                                ...           6 years ago
  • 4.8.3                                ...           6 years ago
  • 4.8.2                                ...           6 years ago
  • 4.8.1                                ...           6 years ago
  • 4.8.0                                ...           6 years ago
  • 4.7.1                                ...           6 years ago
  • 4.7.0                                ...           7 years ago
  • 4.6.3                                ...           7 years ago
  • 4.6.2                                ...           7 years ago
  • 4.6.1                                ...           7 years ago
  • 4.6.0                                ...           7 years ago
  • 4.5.0                                ...           7 years ago
  • 4.4.1                                ...           7 years ago
  • 4.4.0                                ...           7 years ago
  • 4.3.7                                ...           7 years ago
  • 4.3.6                                ...           7 years ago
  • 4.3.5                                ...           7 years ago
  • 4.3.4                                ...           7 years ago
  • 4.3.3                                ...           7 years ago
  • 4.3.2                                ...           7 years ago
  • 4.3.1                                ...           7 years ago
  • 4.3.0                                ...           7 years ago
  • 4.2.0                                ...           7 years ago
  • 4.1.0                                ...           7 years ago
  • 4.0.5                                ...           7 years ago
  • 4.0.4                                ...           7 years ago
  • 4.0.3                                ...           7 years ago
  • 4.0.2                                ...           7 years ago
  • 4.0.1                                ...           7 years ago
  • 4.0.0                                ...           7 years ago
  • 3.7.0                                ...           7 years ago
  • 1.11.1                                ...           7 years ago
  • 3.6.0                                ...           7 years ago
  • 3.4.2                                ...           7 years ago
  • 3.4.1                                ...           7 years ago
  • 3.4.0                                ...           7 years ago
  • 3.3.2                                ...           8 years ago
  • 3.3.1                                ...           8 years ago
  • 3.3.0                                ...           8 years ago
  • 3.2.1                                ...           8 years ago
  • 3.2.0                                ...           8 years ago
  • 3.1.0                                ...           8 years ago
  • 3.0.1                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 2.4.0                                ...           8 years ago
  • 2.3.0                                ...           8 years ago
  • 2.2.3                                ...           8 years ago
  • 2.2.2                                ...           8 years ago
  • 2.2.1                                ...           8 years ago
  • 2.2.0                                ...           8 years ago
  • 2.1.0                                ...           8 years ago
  • 1.10.3                                ...           8 years ago
  • 2.0.2                                ...           8 years ago
  • 1.10.2                                ...           8 years ago
  • 2.0.1                                ...           8 years ago
  • 2.0.0                                ...           8 years ago
  • 1.10.1                                ...           8 years ago
  • 1.10.0                                ...           8 years ago
  • 1.9.1                                ...           8 years ago
  • 1.9.0                                ...           8 years ago
  • 1.8.1                                ...           8 years ago
  • 1.8.0-test                                ...           8 years ago
  • 1.8.0                                ...           8 years ago
  • 1.7.0                                ...           8 years ago
  • 1.6.0                                ...           8 years ago
  • 1.5.3                                ...           8 years ago
  • 1.5.2                                ...           8 years ago
  • 1.5.1                                ...           8 years ago
  • 1.5.0                                ...           8 years ago
  • 1.4.0                                ...           8 years ago
  • 1.3.0                                ...           8 years ago
  • 1.2.1                                ...           8 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.2                                ...           8 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (14)
Dev Dependencies (7)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE