Skip to content

Commit c83d1b5

Browse files
authored
fix: restructure commands (#64)
1 parent e980375 commit c83d1b5

24 files changed

+115
-83
lines changed

.github/CONTRIBUTING.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Contributing to zkSync Era CLI
1+
# Contributing to zkSync CLI
22

33
## Welcome! 🎉
44

5-
Hello, contributor! Thanks for thinking about helping with the `zkSync Era CLI` project. This guide will help you understand how to contribute to our CLI tool.
5+
Hello, contributor! Thanks for thinking about helping with the zkSync CLI project. This guide will help you understand how to contribute to our CLI tool.
66

77
## Getting Started
88

9-
- **Fork the project.** First, fork the `zkSync Era CLI` repository to your GitHub account.
9+
- **Fork the project.** First, fork the `zksync-cli` repository to your GitHub account.
1010

1111
- **Download the project.** Now, get the project on your computer:
1212

@@ -41,7 +41,7 @@ Hello, contributor! Thanks for thinking about helping with the `zkSync Era CLI`
4141

4242
## Sending a Pull Request
4343

44-
- **Ask to add your changes.** Go to the `zkSync Era CLI` repository on GitHub. You'll see a button "Compare & pull request." Click it and tell us about your changes.
44+
- **Ask to add your changes.** Go to the `zksync-cli` repository on GitHub. You'll see a button "Compare & pull request." Click it and tell us about your changes.
4545

4646
- **Wait for feedback.** Our team will look at your changes. We might ask you to change some things.
4747

@@ -61,7 +61,7 @@ If you have questions, you can ask on our [zkSync Community Hub](https://github.
6161

6262
## Thank You!
6363

64-
After we add your changes to the `zkSync Era CLI` project, we'll be very thankful! Your help makes our project better.
64+
After we add your changes to the `zksync-cli` project, we'll be very thankful! Your help makes our project better.
6565

6666
We hope you enjoy helping and come back to help more. Thanks for being part of our team!
6767

.github/ISSUE_TEMPLATE/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ contact_links:
33
- name: zksync-developers Discussion
44
url: https://github.com/zkSync-Community-Hub/zkync-developers/discussions
55
about: Please provide feedback, and ask questions here.
6-
- name: zksync-cli documentation page
6+
- name: zkSync CLI documentation page
77
url: https://era.zksync.io/docs/tools/zksync-cli
88
about: Please refer to the documentation for immediate answers.

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<div align="center">
22

3-
# ‣ zkSync Era CLI
3+
# ‣ zkSync CLI
44

5-
![zksync cli](./zksync-cli-banner.png)
5+
![zkSync CLI](./zksync-cli-banner.png)
66

7-
This CLI tool simplifies the process of developing applications and interacting with zkSync Era.
7+
This CLI tool simplifies the process of developing applications and interacting with zkSync.
88

99
[Documentation](https://era.zksync.io/docs/tools/zksync-cli) | [Report a bug](https://github.com/matter-labs/zksync-cli/issues/new) | [Request a feature](https://github.com/matter-labs/zksync-cli/issues/new)
1010

@@ -17,7 +17,7 @@ This CLI tool simplifies the process of developing applications and interacting
1717
- [Node.js v18 or higher](https://nodejs.org/en)
1818
- [Git](https://git-scm.com/downloads)
1919
- [Docker](https://www.docker.com/get-started/) (for `zksync-cli dev` commands)
20-
- [Yarn](https://v3.yarnpkg.com/getting-started/install) (for `zksync-cli create-project`)
20+
- [Yarn](https://v3.yarnpkg.com/getting-started/install) (for `zksync-cli create` commands)
2121

2222
## 📥 Usage
2323

@@ -27,7 +27,7 @@ Or you can install the CLI globally with `npm i -g zksync-cli` and run the comma
2727
## 💻 Commands
2828

2929
### Local development commands
30-
`zksync-cli dev` - All-in-one tool for local zkSync development. It allows to easily start zkSync stack locally, for example: local Ethereum and zkSync nodes, Wallet and Bridge.
30+
`zksync-cli dev` - Manage local zkSync development environment. It allows to easily start zkSync stack locally, for example: local Ethereum and zkSync nodes, Wallet and Bridge.
3131

3232
**General:**
3333
- `zksync-cli dev start` - start local development environment (will ask to configure if starting for the first time)
@@ -44,16 +44,16 @@ In addition to default modules, you can install custom modules from NPM.
4444
Run `zksync-cli dev` to see the full list of commands.
4545

4646
### Bridge commands
47-
- `zksync-cli deposit`: deposits funds from Ethereum (L1) to zkSync (L2)
48-
- `zksync-cli withdraw`: withdraws funds from zkSync (L2) to Ethereum (L1)
49-
- `zksync-cli withdraw-finalize`: finalizes withdrawal of funds from zkSync (L2) to Ethereum (L1)
47+
- `zksync-cli bridge deposit`: deposits funds from Ethereum (L1) to zkSync (L2)
48+
- `zksync-cli bridge withdraw`: withdraws funds from zkSync (L2) to Ethereum (L1)
49+
- `zksync-cli bridge withdraw-finalize`: finalizes withdrawal of funds from zkSync (L2) to Ethereum (L1)
5050

5151
### Create project commands
52-
- `zksync-cli create-project {FOLDER_NAME}`: creates project from template in the specified folder
52+
- `zksync-cli create project {FOLDER_NAME}`: creates project from template in the specified folder
5353

5454
### Other commands
5555
- `zksync-cli help`: Provides information about all supported commands
56-
- `zksync-cli help <command>`: Provides detailed information about how to use a specific command. Replace <command> with the name of the command you want help with (e.g., create-project, deposit, withdraw, withdraw-finalize)
56+
- `zksync-cli help <command>`: Provides detailed information about how to use a specific command. Replace <command> with the name of the command you want help with (e.g., `create`, `dev config`, `bridge withdraw-finalize`)
5757
- `zksync-cli --version`: Returns the current version
5858

5959

@@ -68,7 +68,7 @@ If you're using [local setup (dockerized testing node)](https://github.com/matte
6868
### Run in development mode
6969

7070
1. Install all dependencies with `npm i`.
71-
2. To use CLI in development mode run `npm run dev -- [command] [options]` (eg. `npm run dev -- deposit --chain=era-testnet`).
71+
2. To use CLI in development mode run `npm run dev -- [command] [options]` (eg. `npm run dev -- bridge deposit --chain=era-testnet`).
7272

7373
### Building for production
7474

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "zksync-cli",
33
"type": "module",
44
"version": "0.0.0-development",
5-
"description": "CLI tool that simplifies the process of developing applications and interacting with the zkSync Era network",
5+
"description": "CLI tool that simplifies the process of developing applications and interacting with the zkSync network",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/matter-labs/zksync-cli.git"

src/commands/bridge/command.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Program from "../../program.js";
2+
3+
export default Program.command("bridge").description("Bridge operations for zkSync");

src/commands/deposit.ts src/commands/bridge/deposit.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import inquirer from "inquirer";
22

3+
import Program from "./command.js";
34
import {
45
amountOptionCreate,
56
chainOption,
@@ -8,24 +9,23 @@ import {
89
privateKeyOption,
910
recipientOptionCreate,
1011
zeekOption,
11-
} from "../common/options.js";
12-
import { l2Chains } from "../data/chains.js";
13-
import Program from "../program.js";
14-
import { track } from "../utils/analytics.js";
15-
import { ETH_TOKEN } from "../utils/constants.js";
16-
import { bigNumberToDecimal, decimalToBigNumber } from "../utils/formatters.js";
12+
} from "../../common/options.js";
13+
import { l2Chains } from "../../data/chains.js";
14+
import { track } from "../../utils/analytics.js";
15+
import { ETH_TOKEN } from "../../utils/constants.js";
16+
import { bigNumberToDecimal, decimalToBigNumber } from "../../utils/formatters.js";
1717
import {
1818
getAddressFromPrivateKey,
1919
getL1Provider,
2020
getL2Provider,
2121
getL2Wallet,
2222
optionNameToParam,
23-
} from "../utils/helpers.js";
24-
import Logger from "../utils/logger.js";
25-
import { isDecimalAmount, isAddress, isPrivateKey } from "../utils/validators.js";
26-
import zeek from "../utils/zeek.js";
23+
} from "../../utils/helpers.js";
24+
import Logger from "../../utils/logger.js";
25+
import { isDecimalAmount, isAddress, isPrivateKey } from "../../utils/validators.js";
26+
import zeek from "../../utils/zeek.js";
2727

28-
import type { DefaultTransferOptions } from "../common/options.js";
28+
import type { DefaultTransferOptions } from "../../common/options.js";
2929

3030
const amountOption = amountOptionCreate("deposit");
3131
const recipientOption = recipientOptionCreate("L2");
@@ -135,7 +135,7 @@ export const handler = async (options: DepositOptions) => {
135135
};
136136

137137
Program.command("deposit")
138-
.description("Deposit ETH from L1 to L2")
138+
.description("Transfer ETH from L1 to L2")
139139
.addOption(amountOption)
140140
.addOption(chainOption)
141141
.addOption(recipientOption)

src/commands/bridge/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import "./deposit.js";
2+
import "./withdraw.js";
3+
import "./withdraw-finalize.js";
4+
5+
import "./command.js"; // registers all the commands above

src/commands/withdraw-finalize.ts src/commands/bridge/withdraw-finalize.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { Option } from "commander";
22
import inquirer from "inquirer";
33

4-
import { chainOption, l1RpcUrlOption, l2RpcUrlOption, privateKeyOption, zeekOption } from "../common/options.js";
5-
import { l2Chains } from "../data/chains.js";
6-
import Program from "../program.js";
7-
import { track } from "../utils/analytics.js";
8-
import { bigNumberToDecimal } from "../utils/formatters.js";
4+
import Program from "./command.js";
5+
import { chainOption, l1RpcUrlOption, l2RpcUrlOption, privateKeyOption, zeekOption } from "../../common/options.js";
6+
import { l2Chains } from "../../data/chains.js";
7+
import { track } from "../../utils/analytics.js";
8+
import { bigNumberToDecimal } from "../../utils/formatters.js";
99
import {
1010
getAddressFromPrivateKey,
1111
getL1Provider,
1212
getL2Provider,
1313
getL2Wallet,
1414
optionNameToParam,
15-
} from "../utils/helpers.js";
16-
import Logger from "../utils/logger.js";
17-
import { isPrivateKey, isTransactionHash } from "../utils/validators.js";
18-
import zeek from "../utils/zeek.js";
15+
} from "../../utils/helpers.js";
16+
import Logger from "../../utils/logger.js";
17+
import { isPrivateKey, isTransactionHash } from "../../utils/validators.js";
18+
import zeek from "../../utils/zeek.js";
1919

20-
import type { DefaultTransactionOptions } from "../common/options.js";
20+
import type { DefaultTransactionOptions } from "../../common/options.js";
2121

2222
const transactionHashOption = new Option("--hash <transaction_hash>", "L2 withdrawal transaction hash to finalize");
2323

@@ -133,7 +133,7 @@ export const handler = async (options: WithdrawFinalizeOptions) => {
133133
};
134134

135135
Program.command("withdraw-finalize")
136-
.description("Finalizes withdrawal of funds")
136+
.description("Finalize withdrawal of funds")
137137
.addOption(transactionHashOption)
138138
.addOption(chainOption)
139139
.addOption(l1RpcUrlOption)

src/commands/withdraw.ts src/commands/bridge/withdraw.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import inquirer from "inquirer";
22

3+
import Program from "./command.js";
34
import {
45
amountOptionCreate,
56
chainOption,
@@ -8,24 +9,23 @@ import {
89
privateKeyOption,
910
recipientOptionCreate,
1011
zeekOption,
11-
} from "../common/options.js";
12-
import { l2Chains } from "../data/chains.js";
13-
import Program from "../program.js";
14-
import { track } from "../utils/analytics.js";
15-
import { ETH_TOKEN } from "../utils/constants.js";
16-
import { bigNumberToDecimal, decimalToBigNumber } from "../utils/formatters.js";
12+
} from "../../common/options.js";
13+
import { l2Chains } from "../../data/chains.js";
14+
import { track } from "../../utils/analytics.js";
15+
import { ETH_TOKEN } from "../../utils/constants.js";
16+
import { bigNumberToDecimal, decimalToBigNumber } from "../../utils/formatters.js";
1717
import {
1818
getAddressFromPrivateKey,
1919
getL1Provider,
2020
getL2Provider,
2121
getL2Wallet,
2222
optionNameToParam,
23-
} from "../utils/helpers.js";
24-
import Logger from "../utils/logger.js";
25-
import { isDecimalAmount, isAddress, isPrivateKey } from "../utils/validators.js";
26-
import zeek from "../utils/zeek.js";
23+
} from "../../utils/helpers.js";
24+
import Logger from "../../utils/logger.js";
25+
import { isDecimalAmount, isAddress, isPrivateKey } from "../../utils/validators.js";
26+
import zeek from "../../utils/zeek.js";
2727

28-
import type { DefaultTransferOptions } from "../common/options.js";
28+
import type { DefaultTransferOptions } from "../../common/options.js";
2929

3030
const amountOption = amountOptionCreate("withdraw");
3131
const recipientOption = recipientOptionCreate("L1");
@@ -135,7 +135,7 @@ export const handler = async (options: WithdrawOptions) => {
135135
};
136136

137137
Program.command("withdraw")
138-
.description("Withdraw ETH from L2 to L1")
138+
.description("Transfer ETH from L2 to L1")
139139
.addOption(amountOption)
140140
.addOption(chainOption)
141141
.addOption(recipientOption)

src/commands/create/command.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Program from "../../program.js";
2+
3+
export default Program.command("create").description("Scaffold new project for zkSync");

src/commands/create-project.ts src/commands/create/create.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import { Option } from "commander";
22
import inquirer from "inquirer";
33
import path from "path";
44

5-
import { zeekOption } from "../common/options.js";
6-
import Program from "../program.js";
7-
import { track } from "../utils/analytics.js";
8-
import { optionNameToParam, executeCommand } from "../utils/helpers.js";
9-
import Logger from "../utils/logger.js";
10-
import zeek from "../utils/zeek.js";
5+
import Program from "./command.js";
6+
import { zeekOption } from "../../common/options.js";
7+
import { track } from "../../utils/analytics.js";
8+
import { optionNameToParam, executeCommand } from "../../utils/helpers.js";
9+
import Logger from "../../utils/logger.js";
10+
import zeek from "../../utils/zeek.js";
1111

12-
import type { DefaultOptions } from "../common/options.js";
12+
import type { DefaultOptions } from "../../common/options.js";
1313

1414
const templates = [
1515
{
@@ -39,7 +39,7 @@ export const handler = async (folderName: string, options: CreateOptions) => {
3939
...options,
4040
folderName,
4141
};
42-
Logger.debug(`Initial create-project options: ${JSON.stringify(options, null, 2)}`);
42+
Logger.debug(`Initial create project options: ${JSON.stringify(options, null, 2)}`);
4343

4444
const answers: CreateOptions = await inquirer.prompt(
4545
[
@@ -59,7 +59,7 @@ export const handler = async (folderName: string, options: CreateOptions) => {
5959
...answers,
6060
};
6161

62-
Logger.debug(`Final create-project options: ${JSON.stringify(options, null, 2)}`);
62+
Logger.debug(`Final create project options: ${JSON.stringify(options, null, 2)}`);
6363

6464
const template = templates.find((e) => e.value === options.template)!;
6565

@@ -95,9 +95,9 @@ Read the ${path.join(options.folderName!, "README.md")} file to learn more.
9595
}
9696
};
9797

98-
Program.command("create-project")
98+
Program.command("project")
99+
.description("Initiate a project using a template in the chosen folder")
99100
.argument("<folder_name>", "Folder name to create project in")
100-
.description("Creates project from template in the specified folder")
101101
.addOption(templateOption)
102102
.addOption(zeekOption)
103103
.action(handler);

src/commands/create/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import "./create.js";
2+
3+
import "./command.js"; // registers all the commands above

src/commands/dev/clean.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ export const handler = async () => {
3131
}
3232
};
3333

34-
Program.command("clean").description("Cleans data for all config modules").action(handler);
34+
Program.command("clean").description("Clean data for all config modules").action(handler);

src/commands/dev/command.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import Program from "../../program.js";
22

3-
export default Program.command("dev").description("All-in-one tool for local zkSync development");
3+
export default Program.command("dev").description("Manage local zkSync development environment");

src/commands/dev/install.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const handler = async (moduleNames: string[], options: { link: boolean })
3131

3232
Program.command("install")
3333
.alias("i")
34-
.argument("[module...]", "NPM package name of the module to install")
3534
.description("Install module with NPM")
35+
.argument("<module...>", "NPM package name of the module to install")
3636
.addOption(linkOption)
3737
.action(handler);

src/commands/dev/logs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ export const handler = async () => {
3838
}
3939
};
4040

41-
Program.command("logs").description("Displays logs for configured modules").action(handler);
41+
Program.command("logs").description("Show logs for configured modules").action(handler);

src/commands/dev/modules/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ export const handler = async () => {
3434
}
3535
};
3636

37-
Program.command("modules").description("Displays list of installed modules").action(handler);
37+
Program.command("modules").description("List currently installed modules").action(handler);

src/commands/dev/restart.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ export const handler = async () => {
1515
}
1616
};
1717

18-
Program.command("restart").description("Restarts the local zkSync environment and modules").action(handler);
18+
Program.command("restart").description("Restart local zkSync environment and modules").action(handler);

src/commands/dev/start.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ const checkForUpdates = async (modules: Module[]) => {
5959
str += chalk.gray(` - zksync-cli dev update ${module.package.name}`);
6060
Logger.info(str);
6161
}
62+
if (modulesRequiringUpdates.length > 1) {
63+
Logger.info(
64+
chalk.gray(
65+
`Update all modules: zksync-cli dev update ${modulesRequiringUpdates
66+
.map(({ module }) => module.package.name)
67+
.join(" ")}`
68+
)
69+
);
70+
}
6271
};
6372

6473
const showStartupInfo = async (modules: Module[]) => {
@@ -106,4 +115,4 @@ export const handler = async () => {
106115
}
107116
};
108117

109-
Program.command("start").description("Starts the local zkSync environment and modules").action(handler);
118+
Program.command("start").description("Start local zkSync environment and modules").action(handler);

src/commands/dev/stop.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ export const handler = async () => {
1515
}
1616
};
1717

18-
Program.command("stop").description("Stops the local zkSync environment and modules").action(handler);
18+
Program.command("stop").description("Stop local zkSync environment and modules").action(handler);

0 commit comments

Comments
 (0)