-
Notifications
You must be signed in to change notification settings - Fork 0
/
meta.js
111 lines (107 loc) · 2.64 KB
/
meta.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
const exec = require('child_process').execSync
const {sortDependencies, printMessage} = require('./utils')
let version = ''
try {
version = exec('react -V')
} catch (e) {}
if (version.toString().trim() === '1.0.0') {
throw new Error('current init-react version doesn\'t support this template, ' +
'please run `npm i init-react@latest -g` and try again!')
}
module.exports = {
prompts: {
name: {
type: 'input',
required: true,
message: 'Project name'
},
description: {
type: 'input',
required: false,
message: 'Project description',
default: 'A React project'
},
author: {
type: 'input',
message: 'Author'
},
lint: {
type: 'confirm',
message: 'Use ESLint to lint your code? '
},
lintConfig: {
when: 'lint',
type: 'list',
message: 'Pick an ESLint preset',
choices: [
{
name: 'Standard (https://github.com/standard/standard)',
value: 'standard',
short: 'Standard'
},
{
name: 'Airbnb (https://github.com/airbnb/javascript)',
value: 'airbnb',
short: 'Airbnb'
},
{
name: 'none (configure it yourself)',
value: 'none',
short: 'none'
}
]
},
typescript: {
type: 'confirm',
message: 'Use TypeScript? '
},
test: {
type: 'confirm',
message: 'Set up unit test with Jest?'
}
},
filters: {
lint: ['.eslintrc.js'], // if key = false, the listed files will be removed
typescript: [
// if key = true, remove arr[1]; if key = false, remove arr[0]
[
'modules.d.ts',
'tsconfig.json',
'src/components/header/index.tsx',
'src/views/about/index.tsx',
'src/views/home/index.tsx',
'src/views/app.tsx',
'src/index.tsx',
'src/index.test.tsx'
],
[
'.babelrc',
'src/components/header/index.jsx',
'src/views/about/index.jsx',
'src/views/home/index.jsx',
'src/views/app.jsx',
'src/index.jsx',
'src/index.test.jsx'
]
],
test: [
'jest.config.js',
'stub.js',
'src/index.test.tsx',
'src/index.test.jsx'
]
},
complete: function (data) {
sortDependencies(data)
printMessage(data)
try {
const version = exec('react -V')
if (version === '1.0.0') {
console.log('can\'t remove unused file, please update init-react to latest version!')
}
} catch (e) {
console.log('can\'t remove unused file, please update init-react to latest version!')
console.log(e)
}
}
}