From 83322e6578def12d87242494c7880e5befcb8815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TZ=20=7C=20=E5=A4=A9=E7=8C=AA?= Date: Mon, 26 Mar 2018 17:12:00 +0800 Subject: [PATCH] feat: revert egg-bin check (#90) --- .autod.conf | 2 - .eslintignore | 1 - README.md | 10 ----- lib/check-eslintrc | 6 --- lib/cmd/check.js | 41 ------------------- package.json | 2 - .../check-eggache/config/config.default.js | 9 ---- test/fixtures/check-eggache/config/plugin.js | 7 ---- test/fixtures/check-eggache/other.js | 7 ---- test/fixtures/check-eggache/package.json | 3 -- test/lib/cmd/autod.test.js | 4 +- test/lib/cmd/check.test.js | 32 --------------- test/lib/cmd/cov.test.js | 2 + 13 files changed, 4 insertions(+), 122 deletions(-) delete mode 100644 lib/check-eslintrc delete mode 100644 lib/cmd/check.js delete mode 100644 test/fixtures/check-eggache/config/config.default.js delete mode 100644 test/fixtures/check-eggache/config/plugin.js delete mode 100644 test/fixtures/check-eggache/other.js delete mode 100644 test/fixtures/check-eggache/package.json delete mode 100644 test/lib/cmd/check.test.js diff --git a/.autod.conf b/.autod.conf index c048647b..d5d0bbd3 100644 --- a/.autod.conf +++ b/.autod.conf @@ -14,8 +14,6 @@ module.exports = { 'intelli-espower-loader', 'power-assert', 'ypkgfiles', - 'eslint-plugin-eggache', - 'eslint', ], devdep: [ 'autod', diff --git a/.eslintignore b/.eslintignore index 04b60dd2..0bf2048d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,3 @@ node_modules/ coverage/ test/fixtures/enzyme-example-mocha/ -test/fixtures/check-eggache/ diff --git a/README.md b/README.md index efc1cb54..3e10ed6f 100644 --- a/README.md +++ b/README.md @@ -192,16 +192,6 @@ Generate `pkg.dependencies` and `pkg.devDependencies` automatically, see [autod] $ egg-bin autod ``` -## check - -Check egg project for collect useful infomation to report issue. - -```bash -$ egg-bin check -``` -### Rules: -- [eslint-plugin-eggache](https://github.com/eggjs/eslint-plugin-eggache) - ## 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. diff --git a/lib/check-eslintrc b/lib/check-eslintrc deleted file mode 100644 index 6d2d89c9..00000000 --- a/lib/check-eslintrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "plugin:eggache/recommended", - "parserOptions": { - "ecmaVersion": 6 - } -} diff --git a/lib/cmd/check.js b/lib/cmd/check.js deleted file mode 100644 index 6fd0d772..00000000 --- a/lib/cmd/check.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -const Command = require('../command'); -const path = require('path'); - -class CheckCommand extends Command { - constructor(rawArgv) { - super(rawArgv); - this.usage = 'Usage: egg-bin check'; - this.options = { - baseDir: { - description: 'directory of application, default to `process.cwd()`', - type: 'string', - }, - }; - } - - get description() { - return 'Check egg project for collect useful infomation to report issue'; - } - - * run({ cwd, argv }) { - /* istanbul ignore next */ - let baseDir = argv._[0] || argv.baseDir || cwd; - /* istanbul ignore next */ - if (!path.isAbsolute(baseDir)) baseDir = path.join(cwd, baseDir); - - // check eggache - const eslintBin = require.resolve('eslint/bin/eslint'); - const eslintArgs = this.helper.unparseArgv({ - _: [ '.' ], - config: require.resolve('../check-eslintrc'), - 'no-eslintrc': true, - format: 'codeframe', - }); - console.info('[egg-bin] run check: %s %s', eslintBin, eslintArgs.join(' ')); - yield this.helper.forkNode(eslintBin, eslintArgs, { cwd: baseDir }); - } -} - -module.exports = CheckCommand; diff --git a/package.json b/package.json index a2653b31..c2aa3727 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,6 @@ "debug": "^3.1.0", "detect-port": "^1.2.2", "egg-utils": "^2.3.0", - "eslint": "^4.18.1", - "eslint-plugin-eggache": "^1.0.0", "globby": "^8.0.1", "inspector-proxy": "^1.2.1", "intelli-espower-loader": "^1.0.1", diff --git a/test/fixtures/check-eggache/config/config.default.js b/test/fixtures/check-eggache/config/config.default.js deleted file mode 100644 index ebea593e..00000000 --- a/test/fixtures/check-eggache/config/config.default.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = appInfo => { - const config = exports = {}; - config.keys = appInfo.name; - return config; -}; - -exports.test = '12345'; diff --git a/test/fixtures/check-eggache/config/plugin.js b/test/fixtures/check-eggache/config/plugin.js deleted file mode 100644 index ffcf48cc..00000000 --- a/test/fixtures/check-eggache/config/plugin.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -exports.view = { - enable: true, - package: '', - foo: 'bar', -}; diff --git a/test/fixtures/check-eggache/other.js b/test/fixtures/check-eggache/other.js deleted file mode 100644 index 8797df52..00000000 --- a/test/fixtures/check-eggache/other.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = ''; - -exports.test = '12345'; - -let a; diff --git a/test/fixtures/check-eggache/package.json b/test/fixtures/check-eggache/package.json deleted file mode 100644 index 4c34bb7f..00000000 --- a/test/fixtures/check-eggache/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "check-eggache" -} \ No newline at end of file diff --git a/test/lib/cmd/autod.test.js b/test/lib/cmd/autod.test.js index 60024762..40ac21c7 100644 --- a/test/lib/cmd/autod.test.js +++ b/test/lib/cmd/autod.test.js @@ -18,9 +18,9 @@ describe('test/lib/cmd/autod.test.js', () => { it('should autod check fail', function* () { const cwd = path.join(__dirname, '../../fixtures/autod-missing'); yield coffee.fork(eggBin, [ 'autod', '--check' ], { cwd }) - // .debug() + .debug() .expect('code', 1) - .expect('stderr', /\[ERROR\] Missing dependencies: \["urllib"\]/) + .expect('stderr', /\[ERROR\].*Missing dependencies: \["urllib"\]/) .end(); }); diff --git a/test/lib/cmd/check.test.js b/test/lib/cmd/check.test.js deleted file mode 100644 index 20192d42..00000000 --- a/test/lib/cmd/check.test.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -const path = require('path'); -const coffee = require('coffee'); - -const eggBin = require.resolve('../../../bin/egg-bin.js'); - -describe('test/lib/cmd/check.test.js', () => { - it('should check eggache', function* () { - const cwd = path.join(__dirname, '../../fixtures/check-eggache'); - yield coffee.fork(eggBin, [ 'check' ], { cwd }) - // .debug() - .expect('stdout', /eggache\/no-override-exports/) - .expect('stdout', /eggache\/no-unexpected-plugin-keys/) - .notExpect('stdout', /no-unused-vars/) - .notExpect('stdout', /\/other.js/) - .expect('code', 1) - .end(); - }); - - it('should check eggache with --baseDir', function* () { - const cwd = path.join(__dirname, '../../fixtures/check-eggache'); - yield coffee.fork(eggBin, [ 'check', '--baseDir', cwd ]) - // .debug() - .expect('stdout', /eggache\/no-override-exports/) - .expect('stdout', /eggache\/no-unexpected-plugin-keys/) - .notExpect('stdout', /no-unused-vars/) - .notExpect('stdout', /\/other.js/) - .expect('code', 1) - .end(); - }); -}); diff --git a/test/lib/cmd/cov.test.js b/test/lib/cmd/cov.test.js index d37883b0..727ebe81 100644 --- a/test/lib/cmd/cov.test.js +++ b/test/lib/cmd/cov.test.js @@ -5,11 +5,13 @@ const path = require('path'); const assert = require('assert'); const coffee = require('coffee'); const mm = require('mm'); +const rimraf = require('mz-modules/rimraf'); describe('test/lib/cmd/cov.test.js', () => { const eggBin = require.resolve('../../../bin/egg-bin.js'); const cwd = path.join(__dirname, '../../fixtures/test-files'); + beforeEach(() => rimraf(path.join(cwd, 'coverage'))); afterEach(mm.restore); it('should success', done => {