-
Notifications
You must be signed in to change notification settings - Fork 31
/
sao.js
137 lines (134 loc) · 4.03 KB
/
sao.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
module.exports = {
template: 'handlebars',
templateOptions: {
helpers: {
if_eq: function(a, b, opts) {
return a === b ? opts.fn(this) : opts.inverse(this);
}
}
},
prompts: {
name: {
message: 'Project name',
role: 'folder:name'
},
description: {
message: 'Project description',
default: 'A React project'
},
author: {
message: 'Author',
role: 'git:name'
},
router: {
message: 'Install react-router?',
type: 'confirm'
},
routerVersion: {
when: 'router',
message: 'Pick the version of router',
type: 'list',
choices: [
{
name: 'v4',
value: 'v4',
short: 'v4'
},
{
name: 'v3',
value: 'v3',
short: 'v3'
}
]
},
history: {
when: 'router',
type: 'list',
message: 'Pick the type of router',
choices: [
{
name: 'html5 history api',
value: function(obj) {
return obj.data.root.routerVersion === 'v3'
? 'browserHistory'
: 'BrowserRouter';
},
short: 'html5'
},
{
name: 'hash router',
value: function(obj) {
return obj.data.root.routerVersion === 'v3'
? 'hashHistory'
: 'HashRouter';
},
short: 'hash'
}
]
},
redux: {
type: 'confirm',
message: 'Install redux?'
},
devtools: {
type: 'list',
when: 'redux',
message: 'Pick the type of DevTools',
choices: [
{
name: 'Browser Extension',
value: 'browser',
short: 'Browser'
},
{
name: 'Customized DevTools',
value: 'normal',
short: 'Normal'
}
]
},
lint: {
type: 'confirm',
message: 'Use ESLint to lint your code?',
short: 'Standard'
},
unit: {
type: 'confirm',
message: 'Unit test with jest?',
short: 'Jest'
}
},
filters: {
'src/routes/**/*': 'router',
'src/routes/asyncRoute.js': 'router && routerVersion === "v4"',
'src/views/**/*': 'router',
'src/redux/**/*': 'redux',
'src/components/Counter.jsx': 'redux',
'src/components/Counter.css': 'redux',
'src/components/DevTools/**/*': 'redux && devtools === "normal"',
'.eslintrc.js': 'lint',
'.eslintignore': 'lint',
'test/**/*': 'unit',
'test/unit/.eslintrc': 'lint'
},
post({ isNewFolder, folderName, chalk, install, init, answers }) {
console.log(chalk.cyan('\n To get started:\n'));
if (isNewFolder) {
console.log(` cd ${folderName}`);
}
console.log(' npm install');
console.log(' npm run dev');
if (answers.devtools === 'browser') {
console.log(
chalk.cyan('\n To make redux-devtools-extension work:\n')
);
console.log(
' https://github.com/zalmoxisus/redux-devtools-extension'
);
}
console.log(chalk.cyan('\n To build for production:\n'));
console.log(' npm run build');
console.log(chalk.cyan('\n Documentation:\n'));
console.log(' https://github.com/SidKwok/template-rwb\n');
}
};