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

chore: deprecate deploy #139

Merged
merged 2 commits into from
Jan 4, 2024
Merged
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
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ The following must be installed and available to use Capsule.
$ cargo install cross --git https://github.com/cross-rs/cross
```

- ckb-cli (optional) - Capsule requires `ckb-cli` to enable the smart contract deployment feature. https://github.com/nervosnetwork/ckb-cli/releases

Note: All commands must be accessible in the `PATH` in order for them to be used by Capsule.

Note: The current user must have permission to manage Docker instances. [How to manage Docker as a non-root user.](https://docs.docker.com/engine/install/linux-postinstall/)
Expand Down Expand Up @@ -88,11 +86,9 @@ capsule test
### Project Layout

* `capsule.toml` - Capsule manifest file.
* `deployment.toml` - Deployment configuration.
* `contracts` - Contracts directory.
* `tests` - Contracts tests.
* `build` - Contracts binaries.
* `migrations` - Deployment histories.

## Documentation

Expand Down
2 changes: 0 additions & 2 deletions crates/tests/test-contract/capsule.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

# capsule version
version = "0.10.0"
# path of deployment config file
deployment = "deployment.toml"

[[contracts]]
name = "test-contract"
Expand Down
4 changes: 3 additions & 1 deletion src/bin/capsule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn run_cli() -> Result<()> {
).display_order(5))
.subcommand(
SubCommand::with_name("deploy")
.about("Deploy contracts, edit deployment.toml to custodian deployment recipe.")
.about("[DEPRECATED] Deploy contracts, edit deployment.toml to custodian deployment recipe.")
.args(&[
Arg::with_name("address").long("address").help(
"Denote which address provides cells",
Expand Down Expand Up @@ -374,6 +374,8 @@ fn run_cli() -> Result<()> {
Tester::run(&context, build_env, test_name)?;
}
("deploy", Some(args)) => {
eprintln!("Warning: capsule deploy is deprecated in favor of ckb-cli deploy");

let ckb_cli_bin = args.value_of("ckb-cli").expect("ckb-cli");
Checker::build(ckb_cli_bin).check_ckb_cli()?;
let address = {
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct Config {
pub version: String,
#[serde(default)]
pub contracts: Vec<Contract>,
pub deployment: PathBuf, // path of deployment config file
pub deployment: Option<PathBuf>, // path of deployment config file
#[serde(default)]
pub rust: RustConfig,
}
Expand Down
3 changes: 1 addition & 2 deletions src/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn gen_project_layout<P: AsRef<Path>>(name: String, project_path: P) -> Result<(
};
fs::create_dir(&project_path)
.with_context(|| format!("directory exists {:?}", &project_path))?;
for f in &["contracts", "build", "migrations"] {
for f in &["contracts", "build"] {
let mut dir_path = PathBuf::new();
dir_path.push(&project_path);
dir_path.push(f);
Expand All @@ -64,7 +64,6 @@ fn gen_project_layout<P: AsRef<Path>>(name: String, project_path: P) -> Result<(
})?;
for (f, template_name) in &[
("capsule.toml", None),
("deployment.toml", None),
("README.md", None),
("rust-toolchain", None),
("Cross.toml", None),
Expand Down
7 changes: 6 additions & 1 deletion src/project_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ impl Context {

pub fn load_deployment(&self) -> Result<Deployment> {
let mut path = self.project_path.clone();
path.push(&self.config.deployment);
path.push(
self.config
.deployment
.as_deref()
.unwrap_or_else(|| Path::new("deployment.toml")),
);
match toml_edit::de::from_str(&fs::read_to_string(&path)?) {
Ok(deployment) => Ok(deployment),
Err(err) => {
Expand Down
2 changes: 0 additions & 2 deletions templates/capsule.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@

# capsule version
version = "{{ version }}"
# path of deployment config file
deployment = "deployment.toml"
27 changes: 0 additions & 27 deletions templates/deployment.toml

This file was deleted.