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

Fetch the pirita download URL #3355

Merged
merged 2 commits into from
Nov 23, 2022
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
3 changes: 2 additions & 1 deletion lib/registry/graphql/queries/get_package_by_command.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ query GetPackageByCommandQuery ($commandName: String!) {
manifest
distribution {
downloadUrl
piritaDownloadUrl
}
package {
displayName
}
}
}
}
}
3 changes: 2 additions & 1 deletion lib/registry/graphql/queries/get_package_version.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ query GetPackageVersionQuery ($name: String!, $version: String) {
isLastVersion
distribution {
downloadUrl
piritaDownloadUrl
}
manifest
}
}
}
4 changes: 4 additions & 0 deletions lib/registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct PackageDownloadInfo {
pub commands: String,
pub manifest: String,
pub url: String,
pub pirita_url: Option<String>,
}

pub fn get_package_local_dir(
Expand Down Expand Up @@ -317,6 +318,7 @@ pub fn query_command_from_registry(
let package = command.package_version.package.display_name;
let version = command.package_version.version;
let url = command.package_version.distribution.download_url;
let pirita_url = command.package_version.distribution.pirita_download_url;

Ok(PackageDownloadInfo {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we return the type/content from command.package_version. That seems way easier than recreating a new struct each time

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll approve in any case, we can revisit this after

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you have a good point.

Something we should do is make all our GraphQL queries public. That way people can execute them directly if a high-level function (e.g. wasmer_registry::query_command_from_registry()) doesn't support exactly what you are looking for.

registry: registry_url.to_string(),
Expand All @@ -326,6 +328,7 @@ pub fn query_command_from_registry(
manifest: command.package_version.manifest,
commands: command_name.to_string(),
url,
pirita_url,
})
}

Expand Down Expand Up @@ -612,6 +615,7 @@ pub fn query_package_from_registry(
.join(", "),

url: v.distribution.download_url.clone(),
pirita_url: v.distribution.pirita_download_url.clone(),
})
}

Expand Down
9 changes: 3 additions & 6 deletions lib/wasi-types/regenerate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ rm -f \

cat "$BASEDIR"/wit-clean/typenames.wit "$BASEDIR"/wit-clean/wasi_unstable.wit > "$BASEDIR"/wit-clean/output.wit

git clone https://github.com/wasmerio/wit-bindgen --branch force-generate-structs --single-branch
cargo install --force wai-bindgen
git pull origin force-generate-structs
cd wit-bindgen
cargo build
cd ..

./wit-bindgen/target/debug/wit-bindgen rust-wasm \
wai-bindgen rust-wasm \
--import "$BASEDIR"/wit-clean/output.wit \
--force-generate-structs \
--out-dir "$BASEDIR"/src/wasi \
Expand All @@ -30,4 +27,4 @@ pwd
`pwd`/target/debug/wasi-types-generator-extra
cd ..

cargo fmt --all
cargo fmt --all
1 change: 0 additions & 1 deletion lib/wasi-types/wit-bindgen
Submodule wit-bindgen deleted from 095d29