Skip to content
Draft
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions crates/icp-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ base64.workspace = true
bigdecimal.workspace = true
bip32.workspace = true
byte-unit.workspace = true
camino.workspace = true
camino-tempfile.workspace = true
candid_parser = { workspace = true, features = ["assist"] }
candid.workspace = true
Expand All @@ -32,6 +33,7 @@ dunce.workspace = true
elliptic-curve.workspace = true
flate2.workspace = true
futures.workspace = true
tar.workspace = true
hex.workspace = true
httptest.workspace = true
ic-agent.workspace = true
Expand Down
41 changes: 41 additions & 0 deletions crates/icp-cli/src/commands/project/bundle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use anyhow::Context as _;
use clap::Args;
use icp::context::Context;
use icp::prelude::*;

use crate::operations::bundle::create_bundle;

/// Bundle a project into a self-contained deployable archive.
///
/// Builds all project canisters and packages them with a rewritten manifest
/// into a `.tar.gz` file. The rewritten manifest replaces all build steps
/// with pre-built steps referencing the bundled WASM files. Asset sync
/// directories are included in the archive.
///
/// Projects with script sync steps cannot be bundled.
#[derive(Args, Debug)]
pub(crate) struct BundleArgs {
/// Output path for the bundle archive (e.g. bundle.tar.gz)
#[arg(long, short)]
pub(crate) output: PathBuf,
}

pub(crate) async fn exec(ctx: &Context, args: &BundleArgs) -> Result<(), anyhow::Error> {
let project = ctx.project.load().await.context("failed to load project")?;

let canisters: Vec<_> = project.canisters.into_values().collect();

create_bundle(
&project.dir,
canisters,
ctx.builder.clone(),
ctx.artifacts.clone(),
&ctx.dirs.package_cache()?,
ctx.debug,
&args.output,
)
.await
.context("failed to create bundle")?;

Ok(())
}
4 changes: 3 additions & 1 deletion crates/icp-cli/src/commands/project/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use clap::Subcommand;

pub(crate) mod bundle;
pub(crate) mod show;

/// Display information about the current project
/// Manage the current project
#[derive(Debug, Subcommand)]
pub(crate) enum Command {
Show(show::ShowArgs),
Bundle(bundle::BundleArgs),
}
3 changes: 3 additions & 0 deletions crates/icp-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ async fn dispatch(ctx: &icp::context::Context, command: Command) -> Result<(), E
commands::project::Command::Show(args) => {
commands::project::show::exec(ctx, &args).await?
}
commands::project::Command::Bundle(args) => {
commands::project::bundle::exec(ctx, &args).await?
}
},

// Settings
Expand Down
Loading
Loading