Skip to content

Commit

Permalink
Merge pull request #278 from celo-org/valora-template
Browse files Browse the repository at this point in the history
Valora template added to Celo Composer CLI
  • Loading branch information
therealharpaljadeja authored Feb 13, 2024
2 parents 5bdc2d6 + 56e3b49 commit 8016d45
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
76 changes: 76 additions & 0 deletions bin/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/celo-composer",
"version": "1.0.11",
"version": "1.0.13",
"description": "Get started building dApps on Celo",
"repository": {
"type": "git",
Expand Down

0 comments on commit 8016d45

Please sign in to comment.