Skip to content

Commit

Permalink
Add uploading function to wasmer-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
fschutt committed Dec 12, 2022
1 parent b993321 commit 874cb75
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions lib/cli/src/commands/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ pub struct Publish {
/// 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 {
Expand Down
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
}
}
}
54 changes: 54 additions & 0 deletions lib/registry/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,60 @@ pub(crate) mod proxy {
}
}

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

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

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

#[derive(GraphQLQuery)]
#[graphql(
schema_path = "graphql/schema.graphql",
query_path = "graphql/queries/get_bindings.graphql",
response_derives = "Debug,Clone,PartialEq,Eq"
)]
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()
}

#[cfg(not(target_os = "wasi"))]
pub fn whoami_distro() -> String {
whoami::distro().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 @@ -23,6 +23,7 @@ pub mod graphql;
pub mod login;
pub mod package;
pub mod queries;
pub mod publish;
pub mod utils;

pub use crate::{
Expand Down
Loading

0 comments on commit 874cb75

Please sign in to comment.