-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·51 lines (45 loc) · 1.33 KB
/
index.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
#!/usr/bin/env node
const program = require('commander');
const packageJson = require('./package.json');
const shell = require('shelljs');
program
.version(packageJson.version)
.arguments('<name>')
.action(function(name) {
shell.exec(`npx create-react-app ${name}`, function() {
shell.cd(name);
const projectPackageJson = {
...JSON.parse(shell.cat('package.json')),
'lint-staged': {
'src/**/*.js': ['eslint --fix', 'git add'],
},
husky: {
hooks: {
'pre-commit': 'lint-staged',
},
},
};
shell
.ShellString(JSON.stringify(projectPackageJson, null, 2))
.to('package.json');
shell.rm('-rf', '.git');
shell.cp('-rf', __dirname + '/template/root/*', '.');
shell.cp('-rf', __dirname + '/template/root/.*', '.');
shell.rm('-r', 'src/*');
shell.cp('-rf', __dirname + '/template/src/*', 'src/');
const devDependencies = [
'dotenv',
'eslint-config-prettier',
'eslint-plugin-prettier',
'husky',
'lint-staged',
'prettier',
'prop-types',
].join(' ');
const useYarn = shell.ls().includes('yarn.lock');
shell.exec(
`${useYarn ? 'yarn add' : 'npm install'} -D ${devDependencies}`
);
});
})
.parse(process.argv);