Skip to content

Commit

Permalink
feat: update all examples base code
Browse files Browse the repository at this point in the history
  • Loading branch information
okoala committed Dec 26, 2017
1 parent a13a382 commit 36f9e62
Show file tree
Hide file tree
Showing 34 changed files with 171 additions and 209 deletions.
3 changes: 3 additions & 0 deletions examples/amp/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "eslint-config-avet"
}
19 changes: 5 additions & 14 deletions examples/amp/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "amp",
"name": "avet-example-amp",
"version": "1.0.0",
"description": "amp example for avet",
"scripts": {
Expand All @@ -8,29 +8,20 @@
"start": "avet-bin start"
},
"dependencies": {
"avet": "^0.5.0",
"avet": "^1.0.0-9",
"avet-amp": "^0.1.0"
},
"devDependencies": {
"avet-bin": "^0.7.0",
"avet-bin": "^1.0.0-9",
"babel-eslint": "^8.0.2",
"eslint": "^4.10.0",
"eslint-config-avet": "^0.3.8"
"eslint": "^4.9.0",
"eslint-config-avet": "^0.3.9"
},
"tnpm": {
"mode": "npm"
},
"engines": {
"node": ">= 8"
},
"repository": {
"type": "git",
"url": "https://github.com/avetjs/avet"
},
"bugs": {
"url": "https://github.com/avetjs/avet/issues"
},
"homepage": "http://avetjs.github.io/avet/",
"author": "okoala <[email protected]>",
"license": "MIT"
}
3 changes: 3 additions & 0 deletions examples/antd/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "eslint-config-avet"
}
20 changes: 7 additions & 13 deletions examples/antd/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "antd",
"name": "avet-example-antd",
"version": "1.0.0",
"description": "antd example for avet",
"scripts": {
Expand All @@ -8,26 +8,20 @@
"start": "avet-bin start"
},
"dependencies": {
"avet": "^0.4.1",
"avet-antd": "^0.1.0"
"avet": "^1.0.0-9",
"avet-antd": "^0.1.1"
},
"devDependencies": {
"avet-bin": "^0.4.1"
"avet-bin": "^1.0.0-9",
"babel-eslint": "^8.0.2",
"eslint": "^4.9.0",
"eslint-config-avet": "^0.3.9"
},
"tnpm": {
"mode": "npm"
},
"engines": {
"node": ">= 8"
},
"repository": {
"type": "git",
"url": "https://github.com/avetjs/avet"
},
"bugs": {
"url": "https://github.com/avetjs/avet/issues"
},
"homepage": "http://avetjs.github.io/avet/",
"author": "okoala <[email protected]>",
"license": "MIT"
}
3 changes: 3 additions & 0 deletions examples/dva/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "eslint-config-avet"
}
18 changes: 6 additions & 12 deletions examples/dva/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "dva",
"name": "avet-example-dva",
"version": "1.0.0",
"description": "dva example for avet",
"scripts": {
Expand All @@ -8,26 +8,20 @@
"start": "avet-bin start"
},
"dependencies": {
"avet": "^0.4.3",
"avet": "^1.0.0-9",
"avet-dva": "^0.2.1"
},
"devDependencies": {
"avet-bin": "^0.5.1"
"avet-bin": "^1.0.0-9",
"babel-eslint": "^8.0.2",
"eslint": "^4.9.0",
"eslint-config-avet": "^0.3.9"
},
"tnpm": {
"mode": "npm"
},
"engines": {
"node": ">= 8"
},
"repository": {
"type": "git",
"url": "https://github.com/avetjs/avet"
},
"bugs": {
"url": "https://github.com/avetjs/avet/issues"
},
"homepage": "http://avetjs.github.io/avet/",
"author": "okoala <[email protected]>",
"license": "MIT"
}
6 changes: 6 additions & 0 deletions examples/egg/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "eslint-config-avet",
"globals": {
"API_HOST": true
}
}
8 changes: 3 additions & 5 deletions examples/egg/app/controller/hello.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict';
const { Controller } = require('egg');

const app = require('egg');

class HelloController extends app.Controller {
* index() {
class HelloController extends Controller {
index() {
this.ctx.body = 'Hello, Welcome to use Avet and Egg!!';
}
}
Expand Down
2 changes: 0 additions & 2 deletions examples/egg/app/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

module.exports = app => {
app.get('/api/getHello', 'hello.index');
};
13 changes: 0 additions & 13 deletions examples/egg/avet/component/header.js

This file was deleted.

18 changes: 0 additions & 18 deletions examples/egg/avet/config/config.local.js

This file was deleted.

16 changes: 0 additions & 16 deletions examples/egg/avet/config/plugin.js

This file was deleted.

6 changes: 2 additions & 4 deletions examples/egg/config/config.default.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use strict';

module.exports = appInfo => {
const config = exports = {};
const config = (exports = {});

// use for cookie sign key, should change to your own and keep security
config.keys = appInfo.name + '_1509640041953_6564';
config.keys = `${appInfo.name}_1509640041953_6564`;

// add your config here
config.middleware = [];
Expand Down
9 changes: 5 additions & 4 deletions examples/egg/config/config.local.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

exports.security = {
domainWhiteList: ['http://localhost:3000']
};
domainWhiteList: [ 'http://localhost:3000' ],
csrf: {
enable: false,
},
};
6 changes: 2 additions & 4 deletions examples/egg/config/plugin.prod.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict';

// had enabled by egg
// exports.static = true;

exports.avet = {
enable: true,
package: 'egg-avet'
}
package: 'egg-avet',
};
30 changes: 11 additions & 19 deletions examples/egg/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "avet-egg",
"name": "avet-example-egg",
"version": "1.0.0",
"description": "this is a avet and egg example",
"private": true,
Expand All @@ -8,36 +8,28 @@
"stop": "egg-scripts stop",
"dev": "npm run dev:egg & npm run dev:avet",
"dev:egg": "egg-bin dev",
"dev:avet": "avet-bin dev --rootDir ./avet",
"build": "avet-bin build"
"dev:avet": "avet-bin dev --rootDir ./web",
"build": "avet-bin build --rootDir ./web"
},
"dependencies": {
"avet": "^0.4.3",
"avet": "^1.0.0-9",
"avet-define": "^0.1.2",
"avet-fetch": "^0.1.0",
"avet-fetch": "^0.2.2",
"avet-preact": "^0.2.3",
"egg": "^1.10.0",
"egg-avet": "^1.1.0",
"egg-scripts": "^2.1.0"
"avet-proxy": "^1.0.0",
"egg": "^2.0.0",
"egg-avet": "^1.1.1",
"egg-scripts": "^2.4.0"
},
"devDependencies": {
"egg-bin": "^4.3.5",
"avet-bin": "^0.5.1"
"egg-bin": "^4.3.6",
"avet-bin": "^1.0.0-9"
},
"tnpm": {
"mode": "npm"
},
"engines": {
"node": ">= 8"
},
"repository": {
"type": "git",
"url": "https://github.com/avetjs/avet"
},
"bugs": {
"url": "https://github.com/avetjs/avet/issues"
},
"homepage": "http://avetjs.github.io/avet/",
"author": "okoala <[email protected]>",
"license": "MIT"
}
9 changes: 9 additions & 0 deletions examples/egg/web/component/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

const Header = () => (
<div>
<p>this is a component.</p>
</div>
);

export default Header;
File renamed without changes.
21 changes: 21 additions & 0 deletions examples/egg/web/config/config.local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const path = require('path');

exports.build = {
webpackDevMiddleware: {
noInfo: true,
quiet: true,
},
};

exports.avet = {
dir: path.join(process.cwd(), 'web'),
};

exports.define = {
API_HOST: 'http://127.0.0.1:7001',
};

exports.proxy = {
host: 'http://127.0.0.1:7001',
match: /^\/api\//,
};
19 changes: 19 additions & 0 deletions examples/egg/web/config/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
exports.preact = {
enable: true,
package: 'avet-preact',
};

exports.fetch = {
enable: true,
package: 'avet-fetch',
};

exports.define = {
enable: true,
package: 'avet-define',
};

exports.proxy = {
enable: true,
package: 'avet-proxy',
};
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import React from 'react';
import Header from '../component/header';

class IndexPage extends React.Component {
static async getInitialProps() {
const res = await fetch(`${API_HOST}/api/getHello`);
const hello = await res.text()
return { hello }
const hello = await res.text();
return { hello };
}

render() {
return (
<div className="index-container">
<Header></Header>
<Header />
<h1>hello00</h1>
<p>{this.props.hello}</p>
</div>
)
);
}
}

export default IndexPage;
export default IndexPage;
3 changes: 3 additions & 0 deletions examples/ga/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "eslint-config-avet"
}
Loading

0 comments on commit 36f9e62

Please sign in to comment.