Skip to content

Commit

Permalink
use @eggjs/development
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Jan 11, 2025
1 parent 4f705dc commit 1427f72
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 37 deletions.
2 changes: 0 additions & 2 deletions index-old.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@
// import 'egg-onerror';
// import 'egg-session';
// import 'egg-i18n';
// import '@eggjs/watcher';
// import 'egg-multipart';
// import 'egg-security';
// import 'egg-development';
// import 'egg-logrotator';
// import '@eggjs/schedule';
// import 'egg-static';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"@eggjs/cluster": "^3.0.0",
"@eggjs/cookies": "^3.0.0",
"@eggjs/core": "^6.2.13",
"@eggjs/development": "^4.0.0",
"@eggjs/schedule": "^5.0.2",
"@eggjs/utils": "^4.2.4",
"@eggjs/watcher": "^4.0.3",
"circular-json-for-egg": "^1.0.0",
"cluster-client": "^3.7.0",
"egg-development": "^3.0.0",
"egg-errors": "^2.3.1",
"egg-i18n": "^2.1.1",
"egg-jsonp": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion site/docs/advanced/loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ All the methods mounted on `beforeClose` are called in an inverted order after `

**We don't recommend to use this function in a PROD env, because the process may end before it finishes.**

What's more, we can use [`egg-development`](/~https://github.com/eggjs/egg-development#loader-trace) to see the loading process.
What's more, we can use [`@eggjs/development`](/~https://github.com/eggjs/development#loader-trace) to see the loading process.

### File-Loading Rules

Expand Down
4 changes: 2 additions & 2 deletions site/docs/advanced/loader.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ module.exports = AppBootHook;

**此方法不建议在生产环境使用,因可能会出现未完全执行结束就结束进程的情况。**

另外,我们可以使用 [`egg-development`](/~https://github.com/eggjs/egg-development#loader-trace) 来查看加载过程。
另外,我们可以使用 [`@eggjs/development`](/~https://github.com/eggjs/development#loader-trace) 来查看加载过程。

### 文件加载规则

Expand Down Expand Up @@ -537,4 +537,4 @@ module.exports = {
参考链接:
- [loader](/~https://github.com/eggjs/egg-core/blob/master/lib/loader/egg_loader.js)
- [appworkerloader](/~https://github.com/eggjs/egg/blob/master/lib/loader/app_worker_loader.js)
- [agentworkerloader](/~https://github.com/eggjs/egg/blob/master/lib/loader/agent_worker_loader.js)
- [agentworkerloader](/~https://github.com/eggjs/egg/blob/master/lib/loader/agent_worker_loader.js)
4 changes: 2 additions & 2 deletions site/docs/basics/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ Specific consolidation rules can be found in [Configuration](./config.md).
  - [onerror](/~https://github.com/eggjs/egg-onerror) Uniform Exception Handling
  - [Session](/~https://github.com/eggjs/egg-session) Session implementation
  - [i18n](/~https://github.com/eggjs/egg-i18n) Multilingual
  - [watcher](/~https://github.com/eggjs/egg-watcher) File and folder monitoring
  - [watcher](/~https://github.com/eggjs/watcher) File and folder monitoring
  - [multipart](/~https://github.com/eggjs/egg-multipart) File Streaming Upload
  - [security](/~https://github.com/eggjs/egg-security) Security
  - [development](/~https://github.com/eggjs/egg-development) Development Environment Configuration
  - [development](/~https://github.com/eggjs/development) Development Environment Configuration
  - [logrotator](/~https://github.com/eggjs/egg-logrotator) Log segmentation
  - [schedule](/~https://github.com/eggjs/egg-schedule) Timing tasks
  - [static](/~https://github.com/eggjs/egg-static) Static server
Expand Down
4 changes: 2 additions & 2 deletions site/docs/basics/plugin.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ exports.mysql = {
- [onerror](/~https://github.com/eggjs/egg-onerror) 统一异常处理
- [Session](/~https://github.com/eggjs/egg-session) Session 实现
- [i18n](/~https://github.com/eggjs/egg-i18n) 多语言
- [watcher](/~https://github.com/eggjs/egg-watcher) 文件和文件夹监控
- [watcher](/~https://github.com/eggjs/watcher) 文件和文件夹监控
- [multipart](/~https://github.com/eggjs/egg-multipart) 文件流式上传
- [security](/~https://github.com/eggjs/egg-security) 安全
- [development](/~https://github.com/eggjs/egg-development) 开发环境配置
- [development](/~https://github.com/eggjs/development) 开发环境配置
- [logrotator](/~https://github.com/eggjs/egg-logrotator) 日志切分
- [schedule](/~https://github.com/eggjs/egg-schedule) 定时任务
- [static](/~https://github.com/eggjs/egg-static) 静态服务器
Expand Down
2 changes: 1 addition & 1 deletion site/docs/core/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ And then we may start app by `npm run dev`.

To start app in local, environment needs to be set as `env: local`. The configuration comes from the combination of both `config.local.js` and `config.default.js`.

> Note: The local development environment relies on 'egg-development' module, enabled by default, and closed other environment, Configuration reference [config/config.default.js](/~https://github.com/eggjs/egg-development/blob/master/config/config.default.js)
> Note: The local development environment relies on '@eggjs/development' module, enabled by default, and closed other environment, Configuration reference [config/config.default.ts](/~https://github.com/eggjs/development/blob/master/src/config/config.default.ts)
### About `Reload`

Expand Down
2 changes: 1 addition & 1 deletion site/docs/core/development.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $ npm i egg-bin --save-dev

本地启动的应用是以 `env: local` 启动的,读取的配置是 `config.default.js``config.local.js` 合并的结果。

> 注意:本地开发环境依赖 `egg-development` 插件,该插件默认开启,而在其他环境下关闭。配置参考 [config/config.default.js](/~https://github.com/eggjs/egg-development/blob/master/config/config.default.js)
> 注意:本地开发环境依赖 `@eggjs/development` 插件,该插件默认开启,而在其他环境下关闭。配置参考 [config/config.default.ts](/~https://github.com/eggjs/development/blob/master/src/config/config.default.ts)
### 关于 `Reload` 功能

Expand Down
39 changes: 19 additions & 20 deletions site/docs/intro/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ To begin with, let's quickly initialize the project by using a scaffold,
which will quickly generate some of the major pieces of the application (`npm >=6.1.0`).

```bash
$ mkdir egg-example && cd egg-example
$ npm init egg --type=simple
$ npm i
mkdir egg-example && cd egg-example
npm init egg --type=simple
npm i
```

Then get up and run by using the following commands.

```bash
$ npm run dev
$ open http://localhost:7001
npm run dev
open http://localhost:7001
```

## Step by Step
Expand All @@ -44,11 +44,11 @@ However, in this section, instead of using scaffolds we will build a project cal
First let's create the project directory and initialize its structure.

```bash
$ mkdir egg-example
$ cd egg-example
$ npm init
$ npm i egg --save
$ npm i egg-bin --save-dev
mkdir egg-example
cd egg-example
npm init
npm i egg --save
npm i egg-bin --save-dev
```

Then add `npm scripts` to `package.json`.
Expand Down Expand Up @@ -116,8 +116,8 @@ For more information about directory structure, see [Directory Structure](../bas
Now you can start up the Web Server and see your application in action.

```bash
$ npm run dev
$ open http://localhost:7001
npm run dev
open http://localhost:7001
```

> Note:
Expand Down Expand Up @@ -159,7 +159,7 @@ In this example, we will use [Nunjucks].
First install the corresponding plugin [egg-view-nunjucks].

```bash
$ npm i egg-view-nunjucks --save
npm i egg-view-nunjucks --save
```

And enable it.
Expand Down Expand Up @@ -236,10 +236,10 @@ module.exports = (app) => {
};
```

Open a browser window and navigate to http://localhost:7001/news.
Open a browser window and navigate to <http://localhost:7001/news>.
You should be able to see the rendered page.

**Tip:In development, Egg enables the [development][egg-development] plugin by default, which reloads your worker process when changes are made to your back-end code.**
**Tip:In development, Egg enables the [development][@eggjs/development] plugin by default, which reloads your worker process when changes are made to your back-end code.**

### Create a Service

Expand Down Expand Up @@ -331,7 +331,7 @@ For more information, cf. [Extensions](../basics/extend.md).
In the case of view, we can just write a helper as an extension.

```bash
$ npm i moment --save
npm i moment --save
```

```js
Expand Down Expand Up @@ -452,13 +452,13 @@ Then add `npm scripts`.
Also install dependencies.

```bash
$ npm i egg-mock --save-dev
npm i egg-mock --save-dev
```

Run it.

```bash
$ npm test
npm test
```

That is all of it, for more detail, see [Unit Testing](../core/unittest.md).
Expand All @@ -477,7 +477,6 @@ Where to go from here? read our documentation to better understand the framework
[node.js]: http://nodejs.org
[egg-bin]: /~https://github.com/eggjs/egg-bin
[egg-static]: /~https://github.com/eggjs/egg-static
[egg-development]: /~https://github.com/eggjs/egg-development
[@eggjs/development]: /~https://github.com/eggjs/development
[egg-view-nunjucks]: /~https://github.com/eggjs/egg-view-nunjucks
[urllib]: https://www.npmjs.com/package/urllib
[nunjucks]: https://mozilla.github.io/nunjucks/
7 changes: 4 additions & 3 deletions site/docs/intro/quickstart.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ module.exports = app => {

在浏览器中启动并访问 [http://localhost:7001/news](http://localhost:7001/news) 即可看到渲染后的页面。

**提示:** 开发期默认开启了 [development][egg-development] 插件,修改后端代码后,会自动重启 Worker 进程。
**提示:** 开发期默认开启了 [development][@eggjs/development] 插件,修改后端代码后,会自动重启 Worker 进程。

### 编写 Service

在实际应用中,Controller 一般不会自己产出数据,也不会包含复杂的逻辑,复杂的过程应抽象为业务逻辑层 [Service](../basics/service.md)
Expand Down Expand Up @@ -456,7 +457,7 @@ $ npm test
[node.js]: http://nodejs.org
[egg-bin]: /~https://github.com/eggjs/egg-bin
[egg-static]: /~https://github.com/eggjs/egg-static
[egg-development]: /~https://github.com/eggjs/egg-development
[@eggjs/development]: /~https://github.com/eggjs/development
[egg-view-nunjucks]: /~https://github.com/eggjs/egg-view-nunjucks
[urllib]: https://www.npmjs.com/package/urllib
[nunjucks]: https://mozilla.github.io/nunjucks/
[nunjucks]: https://mozilla.github.io/nunjucks/
2 changes: 1 addition & 1 deletion src/config/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default {
*/
development: {
enable: true,
package: 'egg-development',
package: '@eggjs/development',
},

/**
Expand Down
3 changes: 2 additions & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import type { MetaMiddlewareOptions } from '../app/middleware/meta.js';
import type { NotFoundMiddlewareOptions } from '../app/middleware/notfound.js';
import type { SiteFileMiddlewareOptions } from '../app/middleware/site_file.js';

// import @eggjs/watcher types
// import plugins types
import '@eggjs/watcher';
import '@eggjs/development';

export type {
EggAppInfo,
Expand Down
5 changes: 5 additions & 0 deletions test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ expectType<Context>(ctx);
expectType<HttpClient>(ctx.httpClient);
expectType<any>(ctx.request.body);

// watcher plugin types
expectType<object>(app.watcher);
expectType<string>(app.config.watcher.type);
expectType<string>(app.config.watcher.eventSources.default);

// development plugin types
expectType<boolean>(app.config.development.fastReady);
expectType<string[]>(app.config.development.watchDirs);

class AppBoot implements ILifecycleBoot {
private readonly app: Application;

Expand Down

0 comments on commit 1427f72

Please sign in to comment.