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

Warg update 0.7 #296

Merged
merged 3 commits into from
May 16, 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
201 changes: 86 additions & 115 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ members = ["crates/core", "crates/wit"]

[workspace.dependencies]
cargo-component-core = { path = "crates/core", version = "0.11.0" }
warg-protocol = "0.6.0"
warg-crypto = "0.6.0"
warg-client = "0.6.0"
warg-server = "0.6.0"
warg-protocol = "0.7.0"
warg-crypto = "0.7.0"
warg-client = "0.7.0"
warg-server = "0.7.0"
anyhow = "1.0.82"
clap = { version = "4.5.4", features = ["derive"] }
toml_edit = { version = "0.22.9", features = ["serde"] }
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,8 @@ The `cargo component` subcommand has some analogous commands to cargo itself:
manifest file.
* `cargo component update` — same as `cargo update` but also updates the
dependencies in the component lock file.
* `cargo component publish` - publishes a WebAssembly component to a [warg](https://warg.io/)
* `cargo component publish` - publishes a WebAssembly component to a [warg](https://github.com/bytecodealliance/registry/)
component registry.
* `cargo component key` - manages signing keys for publishing WebAssembly
components.

Unrecognized commands are passed through to `cargo` itself, but only after the
bindings information for component packages has been updated.
Expand Down
10 changes: 6 additions & 4 deletions crates/core/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ pub fn find_url<'a>(
}

/// Creates a registry client with the given warg configuration.
pub fn create_client(
pub async fn create_client(
config: &warg_client::Config,
url: &str,
terminal: &Terminal,
) -> Result<FileSystemClient> {
match FileSystemClient::try_new_with_config(Some(url), config, None)? {
match FileSystemClient::try_new_with_config(Some(url), config, None).await? {
StorageLockResult::Acquired(client) => Ok(client),
StorageLockResult::NotAcquired(path) => {
terminal.status_with_color(
Expand All @@ -64,7 +64,7 @@ pub fn create_client(
Colors::Cyan,
)?;

Ok(FileSystemClient::new_with_config(Some(url), config, None)?)
Ok(FileSystemClient::new_with_config(Some(url), config, None).await?)
}
}
}
Expand Down Expand Up @@ -477,7 +477,9 @@ impl<'a> DependencyResolver<'a> {
self.warg_config.home_url.as_deref(),
)?;
e.insert(Registry {
client: Arc::new(create_client(self.warg_config, url, self.terminal)?),
client: Arc::new(
create_client(self.warg_config, url, self.terminal).await?,
),
packages: HashMap::new(),
dependencies: Vec::new(),
upserts: HashSet::new(),
Expand Down
34 changes: 3 additions & 31 deletions crates/wit/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The `wit` tool

A tool for creating and publishing WIT packages to a [WebAssembly component
registry](https://warg.io/).
registry](https://github.com/bytecodealliance/registry/).

WIT packages are used in the [WebAssembly Component Model](https://github.com/WebAssembly/component-model/)
for defining interfaces, types, and worlds used in WebAssembly components.
Expand Down Expand Up @@ -140,36 +140,8 @@ wit publish --registry https://registry.example.com --key-name my-signing-key
WebAssembly component registries accept packages based on the keys used to sign
the records being published.

The `wit` tool uses the OS-provided key ring to manage signing keys.

To create a new signing key for a registry, use the `key new` command:

```
wit key new https://registry.example.com
```

To print a Key ID (a fingerprint of the public key) for a signing key, use the
`key id` command:

```
wit key id https://registry.example.com
```

To explicitly set a signing key, use the `key set` command:

```
wit key set https://registry.example.com
```

This command will securely prompt you for the signing key to set in the OS key
ring.

To delete an existing signing key (note: use extreme caution when deleting
signing keys), use the `key delete` command:

```
wit key delete https://registry.example.com
```
The `wit` tool uses the OS-provided keyring to securely store signing keys.
Use the [`warg` CLI](https://crates.io/crates/warg-cli) to manage your signing keys.

## Contributing to `wit`

Expand Down
6 changes: 1 addition & 5 deletions crates/wit/src/bin/wit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use anyhow::Result;
use cargo_component_core::terminal::{Color, Terminal, Verbosity};
use clap::Parser;
use std::process::exit;
use wit::commands::{
AddCommand, BuildCommand, InitCommand, KeyCommand, PublishCommand, UpdateCommand,
};
use wit::commands::{AddCommand, BuildCommand, InitCommand, PublishCommand, UpdateCommand};

fn version() -> &'static str {
option_env!("WIT_VERSION_INFO").unwrap_or(env!("CARGO_PKG_VERSION"))
Expand All @@ -30,7 +28,6 @@ pub enum Command {
Add(AddCommand),
Build(BuildCommand),
Publish(PublishCommand),
Key(KeyCommand),
Update(UpdateCommand),
}

Expand All @@ -45,7 +42,6 @@ async fn main() -> Result<()> {
Command::Add(cmd) => cmd.exec().await,
Command::Build(cmd) => cmd.exec().await,
Command::Publish(cmd) => cmd.exec().await,
Command::Key(cmd) => cmd.exec().await,
Command::Update(cmd) => cmd.exec().await,
} {
let terminal = Terminal::new(Verbosity::Normal, Color::Auto);
Expand Down
2 changes: 0 additions & 2 deletions crates/wit/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
mod add;
mod build;
mod init;
mod key;
mod publish;
mod update;

pub use add::*;
pub use build::*;
pub use init::*;
pub use key::*;
pub use publish::*;
pub use update::*;
195 changes: 0 additions & 195 deletions crates/wit/src/commands/key.rs

This file was deleted.

13 changes: 4 additions & 9 deletions crates/wit/src/commands/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::{
use anyhow::{Context, Result};
use cargo_component_core::{command::CommonOptions, registry::find_url};
use clap::Args;
use warg_client::keyring::get_signing_key;
use warg_crypto::signing::PrivateKey;
use warg_protocol::registry::PackageName;

Expand Down Expand Up @@ -52,15 +51,11 @@ impl PublishCommand {
)?;

let signing_key = if let Ok(key) = std::env::var("WIT_PUBLISH_KEY") {
PrivateKey::decode(key).context(
Some(PrivateKey::decode(key).context(
"failed to parse signing key from `WIT_PUBLISH_KEY` environment variable",
)?
)?)
} else {
get_signing_key(
self.registry.as_deref(),
&warg_config.keys,
warg_config.home_url.as_deref(),
)?
None
};

publish_wit_package(
Expand All @@ -69,7 +64,7 @@ impl PublishCommand {
config_path: &config_path,
warg_config: &warg_config,
url,
signing_key: &signing_key,
signing_key,
package: self.package.as_ref(),
init: self.init,
dry_run: self.dry_run,
Expand Down
Loading
Loading