Skip to content

Commit 724d9a9

Browse files
authored
feat(zkstack_cli): Build dependencies at zkstack build time (#3157)
## What ❔ <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> Build dependencies (e.g., `yarn install`) at `zkstack` build time. ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. - [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`.
1 parent 0aecae1 commit 724d9a9

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

zkstack_cli/crates/zkstack/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ anyhow.workspace = true
5555
clap_complete.workspace = true
5656
dirs.workspace = true
5757
ethers.workspace = true
58+
xshell.workspace = true
5859
zksync_protobuf_build.workspace = true

zkstack_cli/crates/zkstack/build.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::path::{Path, PathBuf};
22

33
use anyhow::{anyhow, Context};
44
use ethers::contract::Abigen;
5+
use xshell::{cmd, Shell};
56

67
const COMPLETION_DIR: &str = "completion";
78

@@ -14,6 +15,11 @@ fn main() -> anyhow::Result<()> {
1415
.write_to_file(outdir.join("consensus_registry_abi.rs"))
1516
.context("Failed to write ABI to file")?;
1617

18+
if let Err(e) = build_dependencies() {
19+
println!("cargo:error=It was not possible to install projects dependencies");
20+
println!("cargo:error={}", e);
21+
}
22+
1723
if let Err(e) = configure_shell_autocompletion() {
1824
println!("cargo:warning=It was not possible to install autocomplete scripts. Please generate them manually with `zkstack autocomplete`");
1925
println!("cargo:error={}", e);
@@ -130,3 +136,14 @@ impl ShellAutocomplete for clap_complete::Shell {
130136
Ok(())
131137
}
132138
}
139+
140+
fn build_dependencies() -> anyhow::Result<()> {
141+
let shell = Shell::new()?;
142+
let code_dir = Path::new("../");
143+
144+
let _dir_guard = shell.push_dir(code_dir);
145+
146+
cmd!(shell, "yarn install")
147+
.run()
148+
.context("Failed to install dependencies")
149+
}

0 commit comments

Comments
 (0)