webcreate-cli
Version:
A boilerplate to create web project.
56 lines (47 loc) • 1.77 kB
JavaScript
const shell = require('shelljs');
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"
const downloadmsg = chalk.gray.bold("✓ Component Created and imported in the components.scss");
const boxenOptions = {
padding: 1,
borderStyle: "round",
// backgroundColor: "#4ea141",
color: 'white'
};
const msgBox = boxen( downloadmsg, boxenOptions);
const options = yargs
.usage("Usage: -n <name>")
.option("n", { alias: "name", describe: "component name", type: "string", demandOption: true })
.argv;
const componentName = `${options.name}`;
const quote = "_";
if (os.platform() === 'darwin') {
shell.cd('src/components');
shell.exec('mkdir ' + componentName);
shell.cd(componentName);
shell.exec('touch ' + componentName +'.html && touch ' + componentName +'.scss');
shell.cd('..');
shell.cd('..');
shell.cd('..');
shell.exec('echo @import \'"./'+componentName + "/"+ componentName+'";\' >> src/components/components.scss;');
shell.cd('src/components');
console.log(msgBox);
} else {
shell.cd('src/components');
shell.exec('md ' + componentName);
shell.cd(componentName);
shell.exec('cd. > ' + componentName +'.html && cd. > ' + componentName +'.scss');
shell.cd('..');
shell.cd('..');
shell.cd('..');
shell.exec('echo @import \"./'+componentName + "/"+ componentName+'";\ >> src/components/components.scss');
console.log(msgBox);
}
// shell.exec('git clone https://github.com/ajoykarmakar459/WebStarterKit');
// @import "./footer/footer";