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

Implement wasmer publish #3325

Closed
wants to merge 3 commits into from
Closed
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
26 changes: 26 additions & 0 deletions Cargo.lock

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

9 changes: 8 additions & 1 deletion lib/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ use crate::commands::CreateExe;
use crate::commands::CreateObj;
#[cfg(feature = "wast")]
use crate::commands::Wast;
use crate::commands::{Add, Cache, Config, Inspect, List, Login, Run, SelfUpdate, Validate};
use crate::commands::{
Add, Cache, Config, Inspect, List, Login, Publish, Run, SelfUpdate, Validate,
};
use crate::error::PrettyError;
use clap::{CommandFactory, ErrorKind, Parser};
use std::{fmt, str::FromStr};
Expand Down Expand Up @@ -48,6 +50,10 @@ enum WasmerCLIOptions {
#[clap(name = "login")]
Login(Login),

/// Login into a wapm.io-like registry
#[clap(name = "publish")]
Publish(Publish),

/// Wasmer cache
#[clap(subcommand, name = "cache")]
Cache(Cache),
Expand Down Expand Up @@ -172,6 +178,7 @@ impl WasmerCLIOptions {
Self::Inspect(inspect) => inspect.execute(),
Self::List(list) => list.execute(),
Self::Login(login) => login.execute(),
Self::Publish(publish) => publish.execute(),
#[cfg(feature = "wast")]
Self::Wast(wast) => wast.execute(),
#[cfg(target_os = "linux")]
Expand Down
4 changes: 3 additions & 1 deletion lib/cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod create_obj;
mod inspect;
mod list;
mod login;
mod publish;
mod run;
mod self_update;
mod validate;
Expand All @@ -30,7 +31,8 @@ pub use create_obj::*;
#[cfg(feature = "wast")]
pub use wast::*;
pub use {
add::*, cache::*, config::*, inspect::*, list::*, login::*, run::*, self_update::*, validate::*,
add::*, cache::*, config::*, inspect::*, list::*, login::*, publish::*, run::*, self_update::*,
validate::*,
};

/// The kind of object format to emit.
Expand Down
26 changes: 26 additions & 0 deletions lib/cli/src/commands/publish.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use clap::Parser;

/// CLI options for the `wasmer publish` command
#[derive(Debug, Parser)]
pub struct Publish {
/// Directory containing the `wapm.toml` (defaults to current root dir)
#[clap(long, name = "dir", env = "DIR")]
pub dir: Option<String>,
/// Registry to publish to
#[clap(long, name = "registry")]
pub registry: Option<String>,
/// Run the publish logic without sending anything to the registry server
#[clap(long, name = "dry-run")]
dry_run: bool,
/// Run the publish command without any output
#[clap(long, name = "quiet")]
quiet: bool,
}

impl Publish {
/// Executes `wasmer publish`
pub fn execute(&self) -> Result<(), anyhow::Error> {
println!("{:?}", self);
Ok(())
}
}
2 changes: 2 additions & 0 deletions lib/registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ hex = "0.4.3"
tokio = "1.21.2"
tempdir = "0.3.7"
log = "0.4.17"
indicatif = "0.17.2"
console = "0.15.2"
5 changes: 5 additions & 0 deletions lib/registry/graphql/queries/get_signed_url.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query GetSignedUrl ($name:String!, $version:String!,$expiresAfterSeconds:Int) {
url: getSignedUrlForPackageUpload(name:$name, version:$version,expiresAfterSeconds:$expiresAfterSeconds) {
url
}
}
22 changes: 22 additions & 0 deletions lib/registry/graphql/queries/publish_package_chunked.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
mutation PublishPackageMutationChunked($name: String!, $version: String!, $description: String!, $manifest: String!, $license: String, $licenseFile: String, $readme: String, $fileName:String, $repository:String, $homepage:String, $signature: InputSignature, $signedUrl:String) {
publishPackage(input: {
name: $name,
version: $version,
description: $description,
manifest: $manifest,
license: $license,
licenseFile: $licenseFile,
readme: $readme,
file: $fileName,
signedUrl: $signedUrl,
repository: $repository,
homepage: $homepage,
signature: $signature,
clientMutationId: ""
}) {
success
packageVersion {
version
}
}
}
16 changes: 16 additions & 0 deletions lib/registry/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@ pub(crate) struct TestIfRegistryPresent;
)]
pub(crate) struct GetBindingsQuery;

#[derive(GraphQLQuery)]
#[graphql(
schema_path = "graphql/schema.graphql",
query_path = "graphql/queries/publish_package_chunked.graphql",
response_derives = "Debug"
)]
pub(crate) struct PublishPackageMutationChunked;

#[derive(GraphQLQuery)]
#[graphql(
schema_path = "graphql/schema.graphql",
query_path = "graphql/queries/get_signed_url.graphql",
response_derives = "Debug, Clone"
)]
pub(crate) struct GetSignedUrl;

#[cfg(target_os = "wasi")]
pub fn whoami_distro() -> String {
whoami::os().to_lowercase()
Expand Down
1 change: 1 addition & 0 deletions lib/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use url::Url;
pub mod config;
pub mod graphql;
pub mod login;
pub mod publish;
pub mod utils;

pub use crate::{
Expand Down
Loading