Skip to content

Commit b71699d

Browse files
authored
Merge pull request #4703 from wasmerio/new-templates
Use registry templates to create new app
2 parents cca7b0a + aaf33dc commit b71699d

File tree

18 files changed

+1030
-1381
lines changed

18 files changed

+1030
-1381
lines changed

Cargo.lock

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/backend-api/src/query.rs

+32-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use wasmer_config::package::PackageIdent;
1212
use crate::{
1313
types::{
1414
self, CreateNamespaceVars, DeployApp, DeployAppConnection, DeployAppVersion,
15-
DeployAppVersionConnection, DnsDomain, GetCurrentUserWithAppsVars, GetDeployAppAndVersion,
15+
DeployAppVersionConnection, DnsDomain, GetAppTemplateFromSlugVariables,
16+
GetAppTemplatesQueryVariables, GetCurrentUserWithAppsVars, GetDeployAppAndVersion,
1617
GetDeployAppVersionsVars, GetNamespaceAppsVars, GetSignedUrlForPackageUploadVariables, Log,
1718
LogStream, PackageVersionConnection, PublishDeployAppVars, PushPackageReleasePayload,
1819
SignedUrl, TagPackageReleasePayload, UpsertDomainFromZoneFileVars,
@@ -55,6 +56,36 @@ pub async fn fetch_webc_package(
5556
webc::compat::Container::from_bytes(data).context("failed to parse webc package")
5657
}
5758

59+
/// Fetch app templates.
60+
pub async fn fetch_app_template_from_slug(
61+
client: &WasmerClient,
62+
slug: String,
63+
) -> Result<Option<types::AppTemplate>, anyhow::Error> {
64+
client
65+
.run_graphql_strict(types::GetAppTemplateFromSlug::build(
66+
GetAppTemplateFromSlugVariables { slug },
67+
))
68+
.await
69+
.map(|v| v.get_app_template)
70+
}
71+
72+
/// Fetch app templates.
73+
pub async fn fetch_app_templates(
74+
client: &WasmerClient,
75+
category_slug: String,
76+
first: i32,
77+
) -> Result<Option<types::AppTemplateConnection>, anyhow::Error> {
78+
client
79+
.run_graphql_strict(types::GetAppTemplatesQuery::build(
80+
GetAppTemplatesQueryVariables {
81+
category_slug,
82+
first,
83+
},
84+
))
85+
.await
86+
.map(|r| r.get_app_templates)
87+
}
88+
5889
/// Get a signed URL to upload packages.
5990
pub async fn get_signed_url_for_package_upload(
6091
client: &WasmerClient,

lib/backend-api/src/types.rs

+66-2
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,75 @@ mod queries {
121121
pub version: String,
122122
pub created_at: DateTime,
123123
pub pirita_manifest: Option<JSONString>,
124-
pub distribution: PackageDistribution,
125-
126124
pub package: Package,
125+
126+
#[arguments(version: "V3")]
127+
#[cynic(rename = "distribution")]
128+
pub distribution_v3: PackageDistribution,
129+
130+
#[arguments(version: "V2")]
131+
#[cynic(rename = "distribution")]
132+
pub distribution_v2: PackageDistribution,
133+
}
134+
135+
#[derive(cynic::QueryVariables, Debug)]
136+
pub struct GetAppTemplateFromSlugVariables {
137+
pub slug: String,
138+
}
139+
140+
#[derive(cynic::QueryFragment, Debug)]
141+
#[cynic(graphql_type = "Query", variables = "GetAppTemplateFromSlugVariables")]
142+
pub struct GetAppTemplateFromSlug {
143+
#[arguments(slug: $slug)]
144+
pub get_app_template: Option<AppTemplate>,
145+
}
146+
#[derive(cynic::QueryVariables, Debug)]
147+
pub struct GetAppTemplatesQueryVariables {
148+
pub category_slug: String,
149+
pub first: i32,
150+
}
151+
152+
#[derive(cynic::QueryFragment, Debug)]
153+
#[cynic(graphql_type = "Query", variables = "GetAppTemplatesQueryVariables")]
154+
pub struct GetAppTemplatesQuery {
155+
#[arguments(categorySlug: $category_slug, first: $first)]
156+
pub get_app_templates: Option<AppTemplateConnection>,
157+
}
158+
159+
#[derive(cynic::QueryFragment, Debug)]
160+
pub struct AppTemplateConnection {
161+
pub edges: Vec<Option<AppTemplateEdge>>,
162+
pub page_info: PageInfo,
127163
}
128164

165+
#[derive(cynic::QueryFragment, Debug)]
166+
pub struct AppTemplateEdge {
167+
pub node: Option<AppTemplate>,
168+
pub cursor: String,
169+
}
170+
171+
#[derive(cynic::QueryFragment, Debug)]
172+
pub struct AppTemplate {
173+
pub demo_url: String,
174+
pub language: String,
175+
pub name: String,
176+
pub framework: String,
177+
pub created_at: DateTime,
178+
pub description: String,
179+
pub id: cynic::Id,
180+
pub is_public: bool,
181+
pub repo_license: String,
182+
pub readme: String,
183+
pub repo_url: String,
184+
pub slug: String,
185+
pub updated_at: DateTime,
186+
pub use_cases: Jsonstring,
187+
}
188+
189+
#[derive(cynic::Scalar, Debug, Clone)]
190+
#[cynic(graphql_type = "JSONString")]
191+
pub struct Jsonstring(pub String);
192+
129193
#[derive(cynic::QueryVariables, Debug)]
130194
pub struct GetPackageReleaseVars {
131195
pub hash: String,

lib/cli/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ wasmer-compiler-singlepass = { version = "=4.3.0", path = "../compiler-singlepas
118118
wasmer-compiler-llvm = { version = "=4.3.0", path = "../compiler-llvm", optional = true }
119119
wasmer-emscripten = { version = "=4.3.0", path = "../emscripten" }
120120
wasmer-vm = { version = "=4.3.0", path = "../vm", optional = true }
121-
wasmer-wasix = { path = "../wasix", version="=0.20.0" , features = [
121+
wasmer-wasix = { path = "../wasix", version = "=0.20.0", features = [
122122
"logging",
123123
"webc_runner_rt_wcgi",
124124
"webc_runner_rt_dcgi",
@@ -185,7 +185,7 @@ tldextract = "0.6.0"
185185
hex = "0.4.3"
186186
flate2 = "1.0.25"
187187
cargo_metadata = "0.15.2"
188-
tar = "0.4.38"
188+
tar = "0.4.40"
189189
bytes = "1"
190190
thiserror = "1.0.37"
191191
log = "0.4.17"
@@ -229,6 +229,7 @@ tun-tap = { version = "0.1.3", features = ["tokio"], optional = true }
229229

230230
clap_complete = "4.5.2"
231231
clap_mangen = "0.2.20"
232+
zip = { version = "1.2.3", default-features = false, features = ["deflate"] }
232233

233234
# NOTE: Must use different features for clap because the "color" feature does not
234235
# work on wasi due to the anstream dependency not compiling.

0 commit comments

Comments
 (0)