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: improve templating #76

Merged
merged 6 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
345 changes: 335 additions & 10 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"dotenv": "^16.3.1",
"ethers": "5.7.2",
"inquirer": "^8.1.4",
"ora": "^7.0.1",
"winston": "^3.10.0",
"zkcli-block-explorer": "^1.0.2",
"zkcli-dockerized-node": "^1.0.4",
Expand Down
3 changes: 0 additions & 3 deletions src/commands/create/command.ts

This file was deleted.

135 changes: 0 additions & 135 deletions src/commands/create/create.ts

This file was deleted.

64 changes: 64 additions & 0 deletions src/commands/create/groups/contracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import chalk from "chalk";
import inquirer from "inquirer";

import Logger from "../../../utils/logger.js";
import { packageManagers } from "../../../utils/packageManager.js";
import { askForTemplate, setupTemplate, askForPackageManager, successfulMessage } from "../utils.js";

import type { GenericTemplate } from "../index.js";

type Template = GenericTemplate & {
framework: "Hardhat";
language: "Solidity" | "Vyper";
};

export const templates: Template[] = [
{
name: "Hardhat + Solidity",
value: "hardhat_solidity",
framework: "Hardhat",
language: "Solidity",
git: "https://github.com/matter-labs/zksync-hardhat-template",
},
{
name: "Hardhat + Vyper",
value: "hardhat_vyper",
framework: "Hardhat",
language: "Vyper",
git: "https://github.com/matter-labs/zksync-hardhat-vyper-template",
},
];

export default async (folderLocation: string, folderRelativePath: string, templateKey?: string) => {
let env: Record<string, string> = {};
const template = templateKey ? templates.find((e) => e.value === templateKey)! : await askForTemplate(templates);
if (templateKey) {
Logger.info(`Using ${chalk.magentaBright(template.name)} template`);
}
const { privateKey }: { privateKey: string } = await inquirer.prompt([
{
message: "Private key of the wallet responsible for deploying contracts",
name: "privateKey",
suffix: chalk.gray(" (optional)"),
type: "input",
required: true,
},
]);
env = {
...env,
WALLET_PRIVATE_KEY: privateKey,
};
const packageManager = await askForPackageManager();
await setupTemplate(template, folderLocation, env, packageManager);

successfulMessage.start(folderRelativePath);
Logger.info(`${chalk.magentaBright("Directory Overview:")}
- Contracts: /contracts
- Deployment Scripts: /deploy

${chalk.magentaBright("Commands:")}
- Compile your contracts: ${chalk.blueBright(packageManagers[packageManager].run("compile"))}
- Deploy your contract: ${chalk.blueBright(packageManagers[packageManager].run("deploy"))}
- Tip: You can use the ${chalk.blueBright("--network")} option to specify the network to deploy to.`);
successfulMessage.end(folderRelativePath);
};
Loading