Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for flutter template #322

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {

const requiredNodeVersion = 20;
const currentNodeVersion = process.versions.node.split(".")[0];
const TEMPLATES = ["Minipay", "Valora", "Social Connect", "Flutter"] as const;

if (Number.parseInt(currentNodeVersion, 10) < requiredNodeVersion) {
throw new Error(
Expand Down Expand Up @@ -79,10 +80,13 @@ export default class Create extends Command {
type: "confirm",
});

let template = "";
type Template = (typeof TEMPLATES)[number];

let template = "" as Template;

if (useTemplate) {
const { templateName } = await inquirer.prompt({
choices: ["Minipay", "Valora", "Social Connect"],
choices: TEMPLATES,
default: "Minipay",
message: "Which template do you want to use?",
name: "templateName",
Expand Down Expand Up @@ -113,7 +117,7 @@ export default class Create extends Command {

const spinner = loading(`Generating custom Celo Composer project...\n`);
try {
if (template === "") {
if (template === ("" as string)) {
await execa(
"git",
[
Expand Down Expand Up @@ -186,6 +190,8 @@ export default class Create extends Command {
packageJson.author = ownerName;
const updatedData = JSON.stringify(packageJson, null, 2);
await fs.writeFile(packageJsonPath, updatedData, "utf8");

// TODO check if hardhat was required and if it was not then remove it after git clone
}

const gitDir = path.join(process.cwd(), projectName, ".git");
Expand Down
5 changes: 4 additions & 1 deletion src/utils/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const getProjectJson = (projectName: string, author: string) => ({

export const getTemplateUrl = (template: string) => {
switch (template) {

case "Minipay": {
return "https://github.com/celo-org/minipay-template.git";
}
Expand All @@ -45,6 +44,10 @@ export const getTemplateUrl = (template: string) => {
return "https://github.com/celo-org/valora-template.git";
}

case "Flutter": {
return "https://github.com/emee-dev/flutter-template.git";
}

default: {
return "https://github.com/celo-org/minipay-template.git";
}
Expand Down
Loading