Skip to content

Commit fcfe4da

Browse files
author
sky
committed
feat: res framework cli
0 parents  commit fcfe4da

14 files changed

Lines changed: 411 additions & 0 deletions

.eslintignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
test/fixtures
2+
coverage
3+
public
4+
test/web
5+
node_modules
6+
.spec.js
7+
coverage
8+
config
9+
.nyc_output
10+
*.test.js

.eslintrc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"extends": "eslint",
3+
"env": {
4+
"node": true,
5+
"es6": true,
6+
"mocha": true
7+
},
8+
"parserOptions": {
9+
"ecmaVersion": 6
10+
},
11+
"rules": {
12+
"indent": [
13+
"error",
14+
2,
15+
{ "SwitchCase": 1 }
16+
],
17+
"no-underscore-dangle": "off",
18+
"consistent-return": "off",
19+
"no-cond-assign": "off",
20+
"lines-around-comment": "off",
21+
"arrow-body-style": "off",
22+
"no-confusing-arrow": "off",
23+
"class-methods-use-this": "off",
24+
"newline-after-var": "off",
25+
"no-invalid-this": "off",
26+
"no-nested-ternary": "off",
27+
"no-unused-vars": "off",
28+
"eol-last": "off",
29+
"quotes": [
30+
"error",
31+
"single"
32+
],
33+
"guard-for-in": "off",
34+
"no-console": "off",
35+
"no-undefined": "off",
36+
"array-bracket-spacing": "off",
37+
"no-unused-expressions": "off",
38+
"func-style": [
39+
"error",
40+
"expression"
41+
],
42+
"comma-dangle": [
43+
"error",
44+
"never"
45+
]
46+
}
47+
}

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.js linguist-language=javascript
2+
*.css linguist-language=javascript
3+
*.html linguist-language=javascript

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
logs/
2+
npm-debug.log
3+
node_modules/
4+
coverage/
5+
.idea/
6+
run/
7+
.DS_Store
8+
*.swp
9+
package-lock.json
10+
yarn.lock
11+

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- '6'
5+
- '8'
6+
- '9'
7+
script:
8+
- npm test
9+
after_success:
10+
- npm run ci

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# res-cli
2+
3+
A Powerful Cross-platform Node React Web Framework CLI.
4+
5+
## Installation
6+
7+
```bash
8+
$ npm install -g @easy-team/res-cli
9+
```
10+
11+
Node.js >= 8.0.0 required.
12+
13+
## Features
14+
15+
- ✔︎ Res Application Development, such as `res dev`, `res start`, `res build`, `res lang`
16+
- ✔︎ Build with Webpack, such as `res build`, `res build --server`, `res build --speed`, `ves build --size`
17+
- ✔︎ Common Development Commands, such as `res open`, `res server`
18+
19+
## QuickStart
20+
21+
- Init Application
22+
23+
```bash
24+
$ res init
25+
```
26+
27+
- Development mode startup Application
28+
29+
```bash
30+
$ res dev
31+
```
32+
33+
- Publish mode startup Application
34+
35+
```bash
36+
$ res build
37+
$ res build --server
38+
```
39+
40+
- Webpack build size analysis
41+
42+
```bash
43+
$ res build --size
44+
```
45+
46+
47+
## Document
48+
49+
https://yuque.com/easy-team/res
50+
51+
## Links
52+
53+
https://yuque.com/easy-team/egg-react

bin/cli.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env node
2+
3+
'use strict';
4+
5+
const Command = require('../lib/command');
6+
new Command().run();
7+
8+

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict';
2+
module.exports = exports = require('./lib/config');
3+
exports.Action = require('./lib/action');
4+
exports.Command = require('./lib/command');

lib/action.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict';
2+
const EasyCLI = require('@easy-team/easywebpack-cli');
3+
const Command = require('egg-bin');
4+
const ScriptCommand = require('egg-scripts');
5+
const Config = require('./config');
6+
module.exports = class ResAction extends EasyCLI.Action {
7+
8+
constructor(command) {
9+
super(command);
10+
}
11+
12+
initCustomizeConfig(options) {
13+
return Config.getResConfig(options);
14+
}
15+
16+
17+
dev() {
18+
const cmd = ['dev'];
19+
if (EasyCLI.utils.isEggTypeScriptProject(this.baseDir)) {
20+
cmd.push('-r');
21+
cmd.push('egg-ts-helper/register');
22+
}
23+
new Command(cmd).start();
24+
}
25+
26+
debug() {
27+
new Command(['debug']).start();
28+
}
29+
30+
test() {
31+
new Command(['test']).start();
32+
}
33+
34+
cov() {
35+
new Command(['cov']).start();
36+
}
37+
38+
start() {
39+
new ScriptCommand().start();
40+
}
41+
42+
tsc() {
43+
const filepath = require.resolve('typescript/lib/tsc.js');
44+
this.command.tool.exec(`node ${filepath}`);
45+
}
46+
47+
};

lib/ask.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
const chalk = require('chalk');
3+
exports.boilerplateChoice = [
4+
{
5+
name: `Create ${chalk.green('Res')} ${chalk.yellow('Server Side Render')} Awesome Web Application`,
6+
value: 'egg-react',
7+
pkgName: 'egg-react-webpack-boilerplate',
8+
choices: ['name', 'description', 'npm']
9+
},
10+
{
11+
name: `Create ${chalk.green('Res + TypeScript')} ${chalk.yellow('Server Side Render')} Web Application`,
12+
value: 'egg-react-typescript',
13+
pkgName: 'egg-react-typescript-boilerplate',
14+
choices: ['name', 'description', 'npm']
15+
},
16+
{
17+
name: `Create ${chalk.green('Res + Nunjucks')} ${chalk.yellow('HTML')} Web Application`,
18+
value: 'egg-react-html-boilerplate',
19+
pkgName: 'egg-react-html-boilerplate',
20+
choices: ['name', 'description', 'npm']
21+
},
22+
{
23+
name: `Create ${chalk.green('Res + Nunjucks')} ${chalk.yellow('Asset Render')} Web Application`,
24+
value: 'egg-react-asset-boilerplate',
25+
pkgName: 'egg-react-asset-boilerplate',
26+
choices: ['name', 'description', 'npm']
27+
}
28+
];

0 commit comments

Comments
 (0)