diff --git a/bin/create.js b/bin/create.js index 84954228..a5a56de6 100644 --- a/bin/create.js +++ b/bin/create.js @@ -162,6 +162,82 @@ const createAsync = async (command) => { " If you have any questions or need further assistance, please refer to the README or reach out to our team.\n" ); + console.log(chalk.blue("Happy coding! šŸŽ‰\n\n")); + return; + } else if (command.template == "valora") { + let { projectName } = await inquirer.prompt({ + type: "input", + name: "projectName", + message: "Project name: ", + }); + + const pwd = process.cwd(); + shell.cd(pwd); + shell.exec( + `git clone https://github.com/celo-org/valora-template.git ${projectName}` + ); + shell.cd(projectName); + const packageJsonPath = join(pwd, projectName, "package.json"); + fs.readFile(packageJsonPath, "utf8", (err, data) => { + if (err) { + console.error("Error reading the file:", err); + return; + } + + // Parse the JSON data + const packageData = JSON.parse(data); + + // Modify the "name" field + packageData.name = projectName; // Replace 'new-name' with your desired name + + // Convert the JSON data back to a string + const updatedData = JSON.stringify(packageData, null, 2); + + // Write the updated data back to the package.json file + fs.writeFile(packageJsonPath, updatedData, "utf8", (err) => { + if (err) { + console.error("Error writing to the file:", err); + return; + } + }); + }); + shell.exec("rm -rf .git"); + shell.exec("git init --quiet --initial-branch=main"); + shell.exec("git add ."); + console.log( + chalk.green( + "\n\nšŸš€ Your starter project has been successfully created!\n" + ) + ); + + console.log("Before you start the project, please follow these steps:\n"); + + console.log(chalk.cyan("1.") + " Rename the file:"); + console.log(chalk.yellow(" packages/react-app/.env.template")); + console.log(" to"); + console.log(chalk.yellow(" packages/react-app/.env.local\n")); + + console.log( + chalk.cyan("2.") + + " Open the newly renamed " + + chalk.yellow(".env.local") + + " file and add all the required environment variables.\n" + ); + + console.log( + "Once you've done that, you're all set to start your project!\n" + ); + console.log( + chalk.green( + "Run `yarn install` and `yarn dev` from packages/react folder to start the project\n" + ) + ); + + console.log( + chalk.green("Thank you for using Celo Composer!") + + " If you have any questions or need further assistance, please refer to the README or reach out to our team.\n" + ); + console.log(chalk.blue("Happy coding! šŸŽ‰\n\n")); return; } diff --git a/package.json b/package.json index 11ed6596..5938fe90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@celo/celo-composer", - "version": "1.0.12", + "version": "1.0.13", "description": "Get started building dApps on Celo", "repository": { "type": "git",