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

Make avet build to of egg #30

Merged
merged 36 commits into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ bench/**/build
bench/**/.isomorphic

.next
.stats.json
.stats.json
.build
.dist
6 changes: 0 additions & 6 deletions examples/egg/.eslintrc

This file was deleted.

11 changes: 0 additions & 11 deletions examples/egg/config/config.default.js

This file was deleted.

7 changes: 0 additions & 7 deletions examples/egg/config/plugin.prod.js

This file was deleted.

35 changes: 0 additions & 35 deletions examples/egg/package.json

This file was deleted.

Empty file.
21 changes: 0 additions & 21 deletions examples/egg/web/config/config.local.js

This file was deleted.

19 changes: 0 additions & 19 deletions examples/egg/web/config/plugin.js

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { Controller } = require('egg');

class HelloController extends Controller {
index() {
this.ctx.body = 'Hello, Welcome to use Avet and Egg!!';
this.ctx.body = 'Hello, Welcome to Avet!';
}
}

Expand Down
File renamed without changes.
13 changes: 0 additions & 13 deletions examples/simple/component/header.js

This file was deleted.

11 changes: 11 additions & 0 deletions examples/simple/config/config.default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const pkg = require('../package.json');

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

// use for cookie sign key, should change to your own and keep security
exports.keys = `${pkg.name}_1509640041953_6564`;
1 change: 0 additions & 1 deletion examples/simple/config/plugin.js
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
'use strict';
3 changes: 3 additions & 0 deletions examples/simple/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('avet').startCluster({
baseDir: __dirname,
});
16 changes: 9 additions & 7 deletions examples/simple/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"name": "avet-example-simple",
"name": "avet-example-egg",
"version": "1.0.0",
"description": "simple example for avet",
"description": "this is a avet and egg example",
"private": true,
"scripts": {
"start": "NODE_ENV=production EGG_SERVER_ENV=prod node index.js",
"dev": "avet-bin dev",
"build": "avet-bin build"
},
"dependencies": {
"avet": "^1.0.0-9"
"avet": "^1.0.0-16",
"avet-antd": "^1.0.0",
"egg": "^2.2.0",
"eslint-config-avet": "^0.3.10"
},
"devDependencies": {
"avet-bin": "^1.0.0-9",
"babel-eslint": "^8.0.2",
"eslint": "^4.9.0",
"eslint-config-avet": "^0.3.9"
"avet-bin": "^1.0.0-16"
},
"tnpm": {
"mode": "npm"
Expand Down
19 changes: 0 additions & 19 deletions examples/simple/page/index.js

This file was deleted.

12 changes: 0 additions & 12 deletions examples/simple/page/page2.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ 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 res = await httpclient.get('/api/getHello');
return { hello: 'dddd' };
}

render() {
return (
<div className="index-container">
<Header />
<h1>hello00</h1>
<h1>hello test work</h1>
<p>{this.props.hello}</p>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"scripts": {
"dev": "lerna bootstrap",
"dev": "lerna bootstrap && npm run build",
"clean": "lerna clean",
"changelog": "lerna-changelog",
"build": "lerna run build",
Expand Down
2 changes: 1 addition & 1 deletion packages/avet-bin/bin/avet-bin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node

const Command = require('../lib/command');
const Command = require('..');

new Command().start();
15 changes: 8 additions & 7 deletions packages/avet-bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ const Command = require('./lib/command');
class AvetBin extends Command {
constructor(rawArgv) {
super(rawArgv);

this.usage = 'Usage: avet-bin [command] [options]';

// load directory
this.load(path.join(__dirname, 'lib/cmd'));
}
}

AvetBin.Command = Command;
AvetBin.DevCommand = require('./lib/cmd/dev');
AvetBin.TestCommand = require('./lib/cmd/test');
AvetBin.BuildCommand = require('./lib/cmd/build');

module.exports = AvetBin;
module.exports = exports = AvetBin;
exports.Command = Command;
exports.CovCommand = require('./lib/cmd/cov');
exports.DebugCommand = require('./lib/cmd/debug');
exports.DevCommand = require('./lib/cmd/dev');
exports.BuildCommand = require('./lib/cmd/build');
exports.TestCommand = require('./lib/cmd/test');
13 changes: 1 addition & 12 deletions packages/avet-bin/lib/cmd/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ class BuildCommand extends Command {
description: 'directory of application, default to `process.cwd()`',
type: 'string',
},
rootDir: {
description:
'directory of application root, a application may have multiple root.',
type: 'string',
default: './',
},
framework: {
description:
'specify framework that can be absolute path or npm package',
Expand All @@ -58,7 +52,7 @@ class BuildCommand extends Command {
const devArgs = this.formatArgs(context);
const options = {
execArgv: context.execArgv,
env: { NODE_ENV: 'production' },
env: { NODE_ENV: 'production', AVET_RUN_ENV: 'build' },
};

yield this.helper.forkNode(this.buildBin, devArgs, options);
Expand All @@ -80,14 +74,9 @@ class BuildCommand extends Command {
argv.baseDir = join(cwd, argv.baseDir);
}

if (!isAbsolute(argv.rootDir)) {
argv.rootDir = join(argv.baseDir, argv.rootDir);
}

argv.framework = utils.getFrameworkPath({
framework: argv.framework,
baseDir: argv.baseDir,
rootDir: argv.rootDir,
});

argv.p = undefined;
Expand Down
5 changes: 5 additions & 0 deletions packages/avet-bin/lib/cmd/cov.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { CovCommand } = require('egg-bin');

class AvetCovCommand extends CovCommand {}

module.exports = AvetCovCommand;
5 changes: 5 additions & 0 deletions packages/avet-bin/lib/cmd/debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { DebugCommand } = require('egg-bin');

class AvetDebugCommand extends DebugCommand {}

module.exports = AvetDebugCommand;
Loading