diff --git a/.autod.conf.js b/.autod.conf.js new file mode 100644 index 0000000..0b4e25f --- /dev/null +++ b/.autod.conf.js @@ -0,0 +1,26 @@ +'use strict'; + +module.exports = { + write: true, + prefix: '^', + test: [ + 'test', + 'benchmark', + ], + devdep: [ + 'egg', + 'egg-ci', + 'egg-bin', + 'autod', + 'eslint', + 'eslint-config-egg', + 'supertest', + 'webstorm-disable-index', + ], + exclude: [ + './test/fixtures', + './docs', + './coverage', + ], + registry: 'https://r.cnpmjs.org', +}; diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..a24e501 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +test/fixtures +coverage diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..c799fe5 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "eslint-config-egg" +} diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..48f9944 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,24 @@ + + +##### 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 + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a5bf14 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +logs/ +npm-debug.log +node_modules/ +coverage/ +.idea/ +run/ +.DS_Store +*.swp + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8363a1e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Alibaba Group Holding Limited and other contributors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..42dc221 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# egg-view-react + +[![NPM version][npm-image]][npm-url] +[![build status][travis-image]][travis-url] +[![Test coverage][codecov-image]][codecov-url] +[![David deps][david-image]][david-url] +[![Known Vulnerabilities][snyk-image]][snyk-url] +[![npm download][download-image]][download-url] + +[npm-image]: https://img.shields.io/npm/v/egg-view-react.svg?style=flat-square +[npm-url]: https://npmjs.org/package/egg-view-react +[travis-image]: https://img.shields.io/travis/eggjs/egg-view-react.svg?style=flat-square +[travis-url]: https://travis-ci.org/eggjs/egg-view-react +[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-view-react.svg?style=flat-square +[codecov-url]: https://codecov.io/github/eggjs/egg-view-react?branch=master +[david-image]: https://img.shields.io/david/eggjs/egg-view-react.svg?style=flat-square +[david-url]: https://david-dm.org/eggjs/egg-view-react +[snyk-image]: https://snyk.io/test/npm/egg-view-react/badge.svg?style=flat-square +[snyk-url]: https://snyk.io/test/npm/egg-view-react +[download-image]: https://img.shields.io/npm/dm/egg-view-react.svg?style=flat-square +[download-url]: https://npmjs.org/package/egg-view-react + +STILL WORK IN PROGRESS. + +egg view plugin for [react]. + +## Install + +```bash +$ npm i egg-view-react --save +``` + +## Usage + +```js +// {app_root}/config/plugin.js +exports.view = { + enable: true, + package: 'egg-view-react', +}; +``` + +## Configuration + +```js +// {app_root}/config/config.default.js +exports.view = { +}; +``` + +see [config/config.default.js](config/config.default.js) for more detail. + +## Example + + + +## Questions & Suggestions + +Please open an issue [here](https://github.com/eggjs/egg/issues). + +## License + +[MIT](LICENSE) + +[react]: https://facebook.github.io/react/ \ No newline at end of file diff --git a/README.zh_CN.md b/README.zh_CN.md new file mode 100644 index 0000000..6254ea1 --- /dev/null +++ b/README.zh_CN.md @@ -0,0 +1,76 @@ +# egg-view-react + +[![NPM version][npm-image]][npm-url] +[![build status][travis-image]][travis-url] +[![Test coverage][codecov-image]][codecov-url] +[![David deps][david-image]][david-url] +[![Known Vulnerabilities][snyk-image]][snyk-url] +[![npm download][download-image]][download-url] + +[npm-image]: https://img.shields.io/npm/v/egg-view-react.svg?style=flat-square +[npm-url]: https://npmjs.org/package/egg-view-react +[travis-image]: https://img.shields.io/travis/eggjs/egg-view-react.svg?style=flat-square +[travis-url]: https://travis-ci.org/eggjs/egg-view-react +[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-view-react.svg?style=flat-square +[codecov-url]: https://codecov.io/github/eggjs/egg-view-react?branch=master +[david-image]: https://img.shields.io/david/eggjs/egg-view-react.svg?style=flat-square +[david-url]: https://david-dm.org/eggjs/egg-view-react +[snyk-image]: https://snyk.io/test/npm/egg-view-react/badge.svg?style=flat-square +[snyk-url]: https://snyk.io/test/npm/egg-view-react +[download-image]: https://img.shields.io/npm/dm/egg-view-react.svg?style=flat-square +[download-url]: https://npmjs.org/package/egg-view-react + + + +## 依赖说明 + +### 依赖的 egg 版本 + +egg-view-react 版本 | egg 1.x +--- | --- +1.x | 😁 +0.x | ❌ + +### 依赖的插件 + + +## 开启插件 + +```js +// config/plugin.js +exports.view-react = { + enable: true, + package: 'egg-view-react', +}; +``` + +## 使用场景 + +- Why and What: 描述为什么会有这个插件,它主要在完成一件什么事情。 +尽可能描述详细。 +- How: 描述这个插件是怎样使用的,具体的示例代码,甚至提供一个完整的示例,并给出链接。 + +## 详细配置 + +请到 [config/config.default.js](config/config.default.js) 查看详细配置项说明。 + +## 单元测试 + + + +## 提问交流 + +请到 [egg issues](https://github.com/eggjs/egg/issues) 异步交流。 + +## License + +[MIT](LICENSE) diff --git a/agent.js b/agent.js new file mode 100644 index 0000000..4dc07e9 --- /dev/null +++ b/agent.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = agent => { + console.log('agent.config.env =', agent.config.env); +}; diff --git a/app.js b/app.js new file mode 100644 index 0000000..7c69cf1 --- /dev/null +++ b/app.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = app => { + console.log('app.config.env =', app.config.env); +}; diff --git a/config/config.default.js b/config/config.default.js new file mode 100644 index 0000000..82b042e --- /dev/null +++ b/config/config.default.js @@ -0,0 +1,10 @@ +'use strict'; + +/** + * view-react default config + * @member Config#view-react + * @property {String} SOME_KEY - some description + */ +exports.view-react = { + +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..4205cd6 --- /dev/null +++ b/package.json @@ -0,0 +1,68 @@ +{ + "name": "egg-view-react", + "version": "0.0.1", + "description": "egg view plugin for react", + "eggPlugin": { + "name": "view" + }, + "keywords": [ + "egg", + "eggPlugin", + "egg-plugin", + "egg-plugin-view" + ], + "dependencies": {}, + "devDependencies": { + "autod": "^2.7.1", + "egg": "^0.7.0", + "egg-bin": "^1.10.0", + "egg-ci": "^1.1.0", + "egg-mock": "^2.0.0", + "eslint": "^3.13.1", + "eslint-config-egg": "^3.2.0", + "supertest": "^2.0.1", + "webstorm-disable-index": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + }, + "scripts": { + "test": "npm run lint -- --fix && npm run test-local", + "test-local": "egg-bin test", + "cov": "egg-bin cov", + "lint": "eslint .", + "ci": "npm run lint && npm run cov", + "autod": "autod" + }, + "files": [ + "index.js", + "app.js", + "agent.js", + "config", + "app", + "lib" + ], + "ci": { + "version": "6, 7" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/eggjs/egg-view-react.git" + }, + "bugs": { + "url": "https://github.com/eggjs/egg/issues" + }, + "homepage": "https://github.com/eggjs/egg-view-react#readme", + "author": "TZ ", + "license": "MIT", + "boilerplate": { + "name": "egg-boilerplate-plugin", + "version": "1.7.0", + "description": "boilerplate for egg plugin", + "repository": { + "type": "git", + "url": "git@github.com:eggjs/egg-boilerplate-plugin.git" + }, + "homepage": "https://github.com/eggjs/egg-boilerplate-plugin" + } +} diff --git a/test/fixtures/apps/view-react-test/app/router.js b/test/fixtures/apps/view-react-test/app/router.js new file mode 100644 index 0000000..a6a01e4 --- /dev/null +++ b/test/fixtures/apps/view-react-test/app/router.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = app => { + app.get('/', function* () { + this.body = 'hi, ' + app.plugins['view-react'].name; + }); +}; diff --git a/test/fixtures/apps/view-react-test/package.json b/test/fixtures/apps/view-react-test/package.json new file mode 100644 index 0000000..ecc76f9 --- /dev/null +++ b/test/fixtures/apps/view-react-test/package.json @@ -0,0 +1,4 @@ +{ + "name": "view-react-test", + "version": "0.0.1" +} \ No newline at end of file diff --git a/test/view-react.test.js b/test/view-react.test.js new file mode 100644 index 0000000..d46fb8a --- /dev/null +++ b/test/view-react.test.js @@ -0,0 +1,24 @@ +'use strict'; + +const request = require('supertest'); +const mm = require('egg-mock'); + +describe('test/view-react.test.js', () => { + let app; + before(() => { + app = mm.app({ + baseDir: 'apps/view-react-test', + }); + return app.ready(); + }); + + after(() => app.close()); + afterEach(mm.restore); + + it('should GET /', () => { + return request(app.callback()) + .get('/') + .expect('hi, view-react') + .expect(200); + }); +});