Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add core/development.md #214

Merged
merged 1 commit into from
Jan 10, 2017
Merged

docs: add core/development.md #214

merged 1 commit into from
Jan 10, 2017

Conversation

shaoshuai0102
Copy link
Contributor

Checklist
  • npm test passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Description of change

@shaoshuai0102 shaoshuai0102 added this to the v1.x milestone Jan 9, 2017
@popomore popomore mentioned this pull request Jan 9, 2017
31 tasks
@codecov-io
Copy link

codecov-io commented Jan 10, 2017

Current coverage is 97.48% (diff: 100%)

No coverage report found for master at bf31c6d.

Powered by Codecov. Last update bf31c6d...68d146f

@atian25
Copy link
Member

atian25 commented Jan 10, 2017

PR title and file name typo: develope -> develop

@shaoshuai0102 shaoshuai0102 changed the title docs: add core/develope-and-debug.md docs: add core/develop-and-debug.md Jan 10, 2017
```json
{
"devDependencies": {
"egg-bin": "1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用 ^ 吧

}
```

这样我们就可以通过 `npm run test` 命令运行单元测试。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm test


### 测试框架

集成了 [mocha](https://mochajs.org/),无需再手动依赖,直接书写 mocha 用例,并且通过 [thunk-mocha](https://npmjs.com/thunk-mocha) 模块扩展了多种用例书写方式,例如 generator 函数,async await 等。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个和下面的是不是直接链到 unittest.md 去

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我这里写的比较简单,然后上面加个链接到 unittest

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

单测我觉得全都可以放到 unittest.md

这个文档可以讲讲本地启动的原理,和线上有什么区别,debug 方式等等

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

下面有的,环境配置

我们在编写用例时往往想单独执行正在编写的用例,可以通过以下方式指定特定用例文件:

```bash
TESTS=test/x.test.js egg-bin test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

支持 glob


为了提升研发体验,我们提供了便捷的方式在本地进行开发、调试、单元测试等。

在这里我们需要使用到 [egg-bin](https://github.com/eggjs/egg-bin) 模块。
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

强调下只在本地开发和单元测试使用,部署方法链接到 advanced/deployment.md


在这里我们需要使用到 [egg-bin](https://github.com/eggjs/egg-bin) 模块。

首先,我们需要把 `egg-bin` 模块作为 `devDependency` 引入到 `package.json`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

devDependencies

@popomore
Copy link
Member

@atian25 之后来补充下 IDE 的 debug?

@shaoshuai0102
Copy link
Contributor Author

改好了 @popomore

@popomore
Copy link
Member

再来一个人看


## 更多

如果想了解更多本地开发相关的内容,例如为你的团队定制一个本地开发工具,请参考 [egg-bin](https://github.com/eggjs/egg-bin)。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里也可以发挥一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个太深入了,先 ref 插件文档吧,插件文档里有描述。后续有需求再加。


![image](https://cloud.githubusercontent.com/assets/456108/21771461/66bb5232-d6c2-11e6-8d2c-9076a5e414b0.png)

### 使用 debug 模块
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们是推荐用 debug 模块,还是直接 this.logger.debug ?

我偏向后者

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

讨论了一下:

  • 框架和插件用 debug 模块
  • 业务用 logger

@shaoshuai0102
Copy link
Contributor Author

增加了 logger 的说明

@shaoshuai0102
Copy link
Contributor Author

@gxcsoccer done

@popomore
Copy link
Member

@gxcsoccer 再确认下

@shaoshuai0102 shaoshuai0102 changed the title docs: add core/develop-and-debug.md docs: add core/development.md Jan 10, 2017

### 使用 debug 模块调试

[debug](https://www.npmjs.com/package/npm) 模块是 node 社区广泛使用的 debug 工具,很多模块都使用它模块打印调试信息,egg 社区也广泛采用这一机制打印 debug 信息,__推荐在框架和插件开发中使用它。__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shaoshuai0102 shaoshuai0102 force-pushed the doc-dev-and-debug branch 2 times, most recently from f30804f to 1cd9899 Compare January 10, 2017 16:17

### 使用 logger 模块调试

框架内置了[日志](./logger.md)功能,使用 `logger.debug()` 输出调试信息,__推荐在业务代码中使用它。__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应用代码

本地启动应用默认监听 7001 端口,可指定其他端口,例如:

```bash
egg-bin dev --port 8888
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm run dev -- --port 8888

我们在编写用例时往往想单独执行正在编写的用例,可以通过以下方式指定特定用例文件:

```bash
TESTS=test/x.test.js egg-bin test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST=test/x.test.js npm test

我们也可以手动指定 reporter:

```bash
TEST_REPORTER=doc egg-bin test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上,egg-bin 安装在项目里都是找不到的,只能放到 npm scripts 里面才行

@shaoshuai0102
Copy link
Contributor Author

done

Copy link
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@fengmk2 fengmk2 merged commit 98506f0 into master Jan 10, 2017
@fengmk2 fengmk2 deleted the doc-dev-and-debug branch January 10, 2017 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants