UNPKG

create-dapp-template

Version:
50 lines (40 loc) 1.36 kB
#!/usr/bin/env node const { execSync } = require("child_process"); const chalk = require("chalk"); const figlet = require("figlet"); const runCommand = (command) => { try { execSync(`${command}`, { stdio: "inherit" }); } catch (e) { console.log(`Failed to execute ${command}`, e); return false; } return true; }; console.log( chalk.yellow( figlet.textSync("CORE DAPP", { font: "Standard", horizontalLayout: "default", verticalLayout: "default", }) ) ); const repoName = process.argv[2]; if (!repoName) { console.error("Please provide a project name."); process.exit(1); } const gitCheckoutCommand = `git clone --depth 1 https://github.com/gr-akshaya/create-dapp-template ${repoName}`; const removeGitCommand = `cd ${repoName} && rm -rf .git`; const installDepsCommand = `cd ${repoName} && npm install`; console.log(`cloning the repository with Name ${repoName}`); const checkOut = runCommand(gitCheckoutCommand); if (!checkOut) process.exit(1); const removedGit = runCommand(removeGitCommand); if (!removedGit) process.exit(1); console.log(`Installing Dependencies for ${repoName}`); const installedDeps = runCommand(installDepsCommand); if (!installedDeps) process.exit(1); console.log("Congrats, you are ready!, Run the following commands to start"); console.log(`cd ${repoName} && npm run dev`);