-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·54 lines (46 loc) · 1.99 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
52
53
54
#! /usr/bin/env node
'use strict';
const program = require('commander');
const fs = require('fs');
const generateComponent = require('./lib/component-generation');
const generateNewReactApp = require('./lib/react-app-generation');
const { commitFile } = require('./lib/commit-files');
const { getOptions, printConfigOptions, setConfigOptions } = require('./lib/config-options');
const version = require('./package.json')['version'];
//If committed-files folder does not exist, create
const folderPath = `${__dirname}/committed-files/`;
if (!fs.existsSync(folderPath)) {
fs.mkdirSync(folderPath);
}
program
.version(version)
.usage('help for commands and options')
.command('g <name>')
.option('-p, --pure', 'creates a pure component')
.option('-s, --style [style]', 'it will create a file sheet along with your component')
.option('-t, --test', 'it will create a test along with your component')
.option('-d, --dir', "it will place the file in it's own directory")
.option('-o, --overwrite', 'will overwrites file it if exists')
.option('-l, --lifecycle', 'it will add life cycle methods')
.description('generates a new component')
.action((name, cmd) => generateComponent(name, getOptions(cmd)));
program
.command('new <name>')
.description("generates a new react app using Facebook's create-react-app")
.action(name => generateNewReactApp(name));
program
.command('config')
.description('allows you to set up your own personalize configuration')
.action(() => setConfigOptions());
program
.command('commit [file]')
.description('Allows you to commit your own presets, such as a .eslint file or a .prettierfile, etc')
.option('-r, --remove', 'removes specified file name')
.option('-p, --purge', 'removes all committed files')
.option('-l, --list', 'lists all committed files')
.action((file, cmd) => commitFile(file, cmd));
program
.command('print')
.description('Prints out your currently configured options')
.action(() => printConfigOptions());
program.parse(process.argv);