Skip to content

Commit

Permalink
feat: all in one setup scaffold (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackHamer09 authored Sep 15, 2023
1 parent 2913e73 commit 15228f1
Show file tree
Hide file tree
Showing 29 changed files with 1,046 additions and 84 deletions.
226 changes: 192 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"zksync-cli": "bin/index.js"
},
"scripts": {
"build": "tsc -p tsconfig.build.json",
"build": "tsc -p tsconfig.build.json && copyfiles -u 4 \"src/commands/local/modules/**/!(*.ts)\" bin/commands/local/modules/",
"dev": "NODE_ENV=development ts-node --transpile-only src/index.ts",
"test": "jest",
"typecheck": "tsc -p . --noEmit",
Expand Down Expand Up @@ -49,10 +49,12 @@
"@semantic-release/github": "^8.1.0",
"@semantic-release/npm": "^8.0.3",
"@semantic-release/release-notes-generator": "^10.0.3",
"@types/dockerode": "^3.3.19",
"@types/figlet": "^1.5.6",
"@types/inquirer": "^8.0.2",
"@types/jest": "^29.5.4",
"@types/node": "^18.17.12",
"copyfiles": "^2.4.1",
"husky": "^8.0.3",
"jest": "^29.6.4",
"jest-junit": "^16.0.0",
Expand Down
8 changes: 4 additions & 4 deletions src/commands/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Option } from "commander";
import { prompt } from "inquirer";
import path from "path";

import { program } from "../";
import { zeekOption } from "../common/options";
import { program } from "../setup";
import { track } from "../utils/analytics";
import { optionNameToParam, executeCommand } from "../utils/helpers";
import Logger from "../utils/logger";
Expand Down Expand Up @@ -64,11 +64,11 @@ export const handler = async (folderName: string, options: CreateOptions) => {
const template = templates.find((e) => e.value === options.template)!;

Logger.info(`\nCreating new project from "${template.name}" template at "${path.join(options.folderName!, "/")}"`);
executeCommand(`git clone ${template.git} ${options.folderName}`);
executeCommand(`cd ${options.folderName} && rm -rf -r .git`); // removes .git folder so new repo can be initialized
await executeCommand(`git clone ${template.git} ${options.folderName}`);
await executeCommand(`cd ${options.folderName} && rm -rf -r .git`); // removes .git folder so new repo can be initialized

Logger.info("\nInstalling dependencies with yarn...");
executeCommand(`cd ${options.folderName} && yarn`);
await executeCommand(`cd ${options.folderName} && yarn`);

Logger.info(`\nAll ready 🎉🎉
Expand Down
2 changes: 1 addition & 1 deletion src/commands/deposit.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { prompt } from "inquirer";

import { program } from "../";
import {
amountOptionCreate,
chainOption,
Expand All @@ -10,7 +11,6 @@ import {
zeekOption,
} from "../common/options";
import { l2Chains } from "../data/chains";
import { program } from "../setup";
import { track } from "../utils/analytics";
import { ETH_TOKEN } from "../utils/constants";
import { bigNumberToDecimal, decimalToBigNumber } from "../utils/formatters";
Expand Down
36 changes: 36 additions & 0 deletions src/commands/local/clean.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Option } from "commander";

import { getConfig } from "./config";
import { getConfigModules } from "./modules";
import { track } from "../../utils/analytics";
import Logger from "../../utils/logger";

import { local } from ".";

const allOption = new Option("--all", "Node type to use");
type LocalStopOptions = {
all?: true;
};

export const handler = async (options: LocalStopOptions) => {
try {
Logger.debug(`Local stop options: ${JSON.stringify(options, null, 2)}`);

const config = getConfig();
Logger.debug(`Local config: ${JSON.stringify(config, null, 2)}`);

const modules = getConfigModules(config);
Logger.info(`Cleaning: ${modules.map((m) => m.name).join(", ")}...`);
await Promise.all(modules.map((m) => m.clean()));
} catch (error) {
Logger.error("There was an error while stopping the testing environment:");
Logger.error(error);
track("error", { error });
}
};

local
.command("clean")
.description("Stops the local zkSync environment and modules")
.addOption(allOption)
.action(handler);
Loading

0 comments on commit 15228f1

Please sign in to comment.