diff --git a/index-old.d.ts b/index-old.d.ts index b09956ad21..7f7e014db9 100644 --- a/index-old.d.ts +++ b/index-old.d.ts @@ -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'; diff --git a/package.json b/package.json index c4325f2c8e..75800c3b7f 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/site/docs/advanced/loader.md b/site/docs/advanced/loader.md index 8836cfc009..2b83556571 100644 --- a/site/docs/advanced/loader.md +++ b/site/docs/advanced/loader.md @@ -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 diff --git a/site/docs/advanced/loader.zh-CN.md b/site/docs/advanced/loader.zh-CN.md index 074a23a284..037432a794 100644 --- a/site/docs/advanced/loader.zh-CN.md +++ b/site/docs/advanced/loader.zh-CN.md @@ -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) 来查看加载过程。 ### 文件加载规则 @@ -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) \ No newline at end of file +- [agentworkerloader](/~https://github.com/eggjs/egg/blob/master/lib/loader/agent_worker_loader.js) diff --git a/site/docs/basics/plugin.md b/site/docs/basics/plugin.md index 2bb91b711f..b2d7126157 100644 --- a/site/docs/basics/plugin.md +++ b/site/docs/basics/plugin.md @@ -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 diff --git a/site/docs/basics/plugin.zh-CN.md b/site/docs/basics/plugin.zh-CN.md index 5d7d75ea08..1f697166fd 100644 --- a/site/docs/basics/plugin.zh-CN.md +++ b/site/docs/basics/plugin.zh-CN.md @@ -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) 静态服务器 diff --git a/site/docs/core/development.md b/site/docs/core/development.md index 94c21efc6c..bfdb9fde6f 100644 --- a/site/docs/core/development.md +++ b/site/docs/core/development.md @@ -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` diff --git a/site/docs/core/development.zh-CN.md b/site/docs/core/development.zh-CN.md index 4b53e175ca..6f21994ba5 100644 --- a/site/docs/core/development.zh-CN.md +++ b/site/docs/core/development.zh-CN.md @@ -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` 功能 diff --git a/site/docs/intro/quickstart.md b/site/docs/intro/quickstart.md index 1e1934b818..caf4cac843 100644 --- a/site/docs/intro/quickstart.md +++ b/site/docs/intro/quickstart.md @@ -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 @@ -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`. @@ -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: @@ -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. @@ -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 . 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 @@ -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 @@ -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). @@ -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/ diff --git a/site/docs/intro/quickstart.zh-CN.md b/site/docs/intro/quickstart.zh-CN.md index 23817e278b..715538a201 100644 --- a/site/docs/intro/quickstart.zh-CN.md +++ b/site/docs/intro/quickstart.zh-CN.md @@ -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)。 @@ -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/ \ No newline at end of file +[nunjucks]: https://mozilla.github.io/nunjucks/ diff --git a/src/config/plugin.ts b/src/config/plugin.ts index 5c22a02e01..ab62e547bf 100644 --- a/src/config/plugin.ts +++ b/src/config/plugin.ts @@ -74,7 +74,7 @@ export default { */ development: { enable: true, - package: 'egg-development', + package: '@eggjs/development', }, /** diff --git a/src/lib/types.ts b/src/lib/types.ts index f4de59175a..dbe4ed513f 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -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, diff --git a/test/index.test-d.ts b/test/index.test-d.ts index 2938304bde..ac0229b347 100644 --- a/test/index.test-d.ts +++ b/test/index.test-d.ts @@ -19,10 +19,15 @@ expectType(ctx); expectType(ctx.httpClient); expectType(ctx.request.body); +// watcher plugin types expectType(app.watcher); expectType(app.config.watcher.type); expectType(app.config.watcher.eventSources.default); +// development plugin types +expectType(app.config.development.fastReady); +expectType(app.config.development.watchDirs); + class AppBoot implements ILifecycleBoot { private readonly app: Application;