From c93fbc374111740b5e2d08d64df7126a40c8d7da Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Mon, 16 Jan 2017 17:38:50 +0800 Subject: [PATCH] feat(debug): [BREAKING_CHANGE] remove iron-node --- .gitignore | 4 +- .travis.yml | 1 - appveyor.yml | 1 - lib/debug_command.js | 41 +++---------------- package.json | 12 +++--- test/egg-dev.test.js | 10 +++++ .../node_modules/yadan/index.js | 5 +++ .../node_modules/yadan/package.json | 3 ++ .../custom-framework-app/package.json | 6 +++ 9 files changed, 36 insertions(+), 47 deletions(-) create mode 100644 test/fixtures/custom-framework-app/node_modules/yadan/index.js create mode 100644 test/fixtures/custom-framework-app/node_modules/yadan/package.json create mode 100644 test/fixtures/custom-framework-app/package.json diff --git a/.gitignore b/.gitignore index 9a36a874..ee3f397f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -node_modules/ +/node_modules/ coverage/ -!test/fixtures/**/node_modules/aliyun-egg/ +!test/fixtures/**/node_modules/ .tmp diff --git a/.travis.yml b/.travis.yml index 5ec14674..5e7a967b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ sudo: false language: node_js node_js: - - '4' - '6' - '7' install: diff --git a/appveyor.yml b/appveyor.yml index 2efd0fad..ec7400e9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,5 @@ environment: matrix: - - nodejs_version: '4' - nodejs_version: '6' - nodejs_version: '7' diff --git a/lib/debug_command.js b/lib/debug_command.js index ee9ed9d0..d5e32f8d 100644 --- a/lib/debug_command.js +++ b/lib/debug_command.js @@ -1,9 +1,6 @@ 'use strict'; -const path = require('path'); const debug = require('debug')('egg-bin:debug'); -const childprocess = require('childprocess'); -const semver = require('semver'); const Command = require('./command'); class DebugCommand extends Command { @@ -26,40 +23,12 @@ class DebugCommand extends Command { yield this.helper.checkDeps(); - // https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V6.md#2016-07-06-version-630-current-fishrock123 - const hasInspector = semver.satisfies(process.versions.node, '>=6.3.0'); - debug('%s %s, hasInspector:%s, NODE_ENV:%s, cwd:%s', - this.helper.serverBin, args.join(' '), hasInspector, options.env.NODE_ENV, process.cwd()); + debug('%s %s, NODE_ENV:%s, cwd:%s', + this.helper.serverBin, args.join(' '), options.env.NODE_ENV, process.cwd()); - if (hasInspector) { - options.execArgv = [ - '--inspect', - ]; - } else { - // try to use iron-node@3 instead - // auto download iron-node at the first time - yield this.helper.getIronNodeBin(this.npmCli, cwd); - - childprocess.inject(function(modulePath, args, opt) { - // this function will be toString() and save to tmp file - const cluster = require('cluster'); - const originSetupMaster = cluster.setupMaster; - /* istanbul ignore next */ - cluster.setupMaster = function(settings) { - if (!settings) return; - const args = settings.args || []; - args.unshift(settings.exec); - settings.args = args; - settings.exec = process.env.IRON_NODE_PATH; - originSetupMaster.call(cluster, settings); - }; - return [ modulePath, args, opt ]; - }); - - // iron-node should be installed in cwd, - // resolve after iron-node installed - options.env.IRON_NODE_PATH = require.resolve(path.join(process.cwd(), 'node_modules/iron-node/bin/run.js')); - } + options.execArgv = [ + '--inspect', + ]; this.helper.forkNode(this.helper.serverBin, args, options); } diff --git a/package.json b/package.json index c86a1f25..73c898d3 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,11 @@ "mocha": "bin/mocha.js" }, "dependencies": { - "childprocess": "^2.0.2", "commander": "^2.9.0", "common-bin": "^1.0.0", - "debug": "^2.5.2", + "debug": "^2.6.0", "detect-port": "^1.0.7", - "egg-utils": "^1.0.0", + "egg-utils": "^1.1.0", "glob": "^7.1.1", "intelli-espower-loader": "^1.0.1", "istanbul": "^0.4.5", @@ -21,7 +20,6 @@ "mocha": "^3.2.0", "power-assert": "^1.4.2", "rimraf": "^2.5.4", - "semver": "^5.3.0", "thunk-mocha": "^1.0.8" }, "devDependencies": { @@ -33,7 +31,7 @@ "cross-env": "^3.1.3", "egg-ci": "^1.1.0", "enzyme": "^2.0.0", - "eslint": "^3.12.2", + "eslint": "^3.13.1", "eslint-config-egg": "^3.2.0", "jsdom": "^8.0.1", "mm": "^2.0.0", @@ -55,7 +53,7 @@ "autod": "autod" }, "engines": { - "node": ">= 4.0.0" + "node": ">= 6.3.0" }, "files": [ "bin", @@ -63,6 +61,6 @@ "index.js" ], "ci": { - "version": "4, 6, 7" + "version": "6, 7" } } diff --git a/test/egg-dev.test.js b/test/egg-dev.test.js index d52251db..3f9eaada 100644 --- a/test/egg-dev.test.js +++ b/test/egg-dev.test.js @@ -25,6 +25,16 @@ describe('egg-bin dev', () => { .end(done); }); + it('should startCluster with custom yadan framework', done => { + const baseDir = path.join(__dirname, 'fixtures/custom-framework-app'); + const customEgg = path.join(baseDir, 'node_modules', 'yadan'); + coffee.fork(eggBin, [ 'dev' ], { cwd: baseDir }) + // .debug() + .expect('stdout', `yadan start: {"baseDir":"${baseDir}","workers":1,"customEgg":"${customEgg}"}\n`) + .expect('code', 0) + .end(done); + }); + describe('auto detect available port', () => { let server; before(done => { diff --git a/test/fixtures/custom-framework-app/node_modules/yadan/index.js b/test/fixtures/custom-framework-app/node_modules/yadan/index.js new file mode 100644 index 00000000..45e29249 --- /dev/null +++ b/test/fixtures/custom-framework-app/node_modules/yadan/index.js @@ -0,0 +1,5 @@ +'use strict'; + +exports.startCluster = options => { + console.log('yadan start: %j', options); +}; diff --git a/test/fixtures/custom-framework-app/node_modules/yadan/package.json b/test/fixtures/custom-framework-app/node_modules/yadan/package.json new file mode 100644 index 00000000..485c9a9e --- /dev/null +++ b/test/fixtures/custom-framework-app/node_modules/yadan/package.json @@ -0,0 +1,3 @@ +{ + "name": "yadan" +} diff --git a/test/fixtures/custom-framework-app/package.json b/test/fixtures/custom-framework-app/package.json new file mode 100644 index 00000000..28ebf34e --- /dev/null +++ b/test/fixtures/custom-framework-app/package.json @@ -0,0 +1,6 @@ +{ + "name": "custom-framework-app", + "egg": { + "framework": "yadan" + } +}