-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·59 lines (52 loc) · 1.42 KB
/
cli.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
#!/usr/bin/env node
const inquirer = require("inquirer");
const shell = require("shelljs");
const chalk = require("chalk");
console.log(chalk.green("\nHi, welcome to F22 Labs Starter Kit\n"));
function fancyLog(log) {
console.log("\n===================");
console.log(chalk.green(log));
console.log("===================\n\n");
}
const questions = [
{
type: "list",
name: "projectType",
message: "What kind of project are you starting ?",
choices: ["React", "React Native"],
filter: function(val) {
return val.toLowerCase();
}
},
{
type: "input",
name: "projectName",
message: "Enter the name of the project ",
validate: function(input) {
if (/^([A-Za-z\-\_\d])+$/.test(input)) {
return true;
} else {
return "Project name may only include letters, numbers, underscores and hashes.";
}
}
}
];
inquirer.prompt(questions).then(answers => {
const { projectType, projectName } = answers;
if (projectType === "react") {
// Clone React repo
console.log("Work in Progress");
} else {
fancyLog("We are setting up things for you");
shell.exec(
`git clone git@github.com:f22labs/rn-boilerplate.git ${projectName}`
);
shell.cd(projectName);
shell.rm("-rf", ".git");
shell.exec("yarn");
shell.exec(`yarn rename ${projectName}`);
shell.cd("ios");
shell.exec("pod install");
fancyLog("Done");
}
});