webcreate-cli
Version:
A boilerplate to create web project.
51 lines (43 loc) • 1.52 kB
JavaScript
const shell = require('shelljs');
// shell.exec('npm i -g chalk');
// shell.exec('npm i -g boxen');
// shell.exec('npm i -g yargs');
const os = require('os');
const chalk = require("chalk");
const boxen = require("boxen");
const yargs = require("yargs");
// console.log(os.type()); // "Windows_NT"
// console.log(os.release()); // "10.0.14393"
// console.log(String(os.platform())); // "win32"
shell.exec('git clone https://github.com/ajoykarmakar459/WebStarterKit');
const downloadmsg = chalk.gray.bold("✓ Template Downloaded & Dependency installing...");
const boxenOptions = {
padding: 1,
borderStyle: "round",
color: 'white'
};
const msgBox = boxen( downloadmsg, boxenOptions);
const options = yargs
.usage("Usage: -n <name>")
.option("n", { alias: "name", describe: "Project name", type: "string", demandOption: true })
.argv;
const projectName = `${options.name}`;
if (os.platform() === 'darwin') {
shell.exec('mv WebStarterKit ' + projectName);
shell.cd(projectName);
console.log(msgBox);
shell.exec('npm install');
shell.rm('-rf', '.idea');
shell.rm('-rf', '.git');
shell.rm('-rf', 'root_package.json');
} else {
shell.exec('Rename WebStarterKit ' + projectName);
console.log(msgBox);
shell.cd(projectName);
shell.exec('npm install');
shell.rm('-rf', '.idea');
shell.rm('-rf', '.git');
shell.rm('-rf', 'root_package.json');
}
// shell.exec('git clone https://github.com/ajoykarmakar459/WebStarterKit');