Skip to content

Commit c386702

Browse files
authored
feat(common): add template definition schema (#1655)
1 parent 3080c93 commit c386702

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

common/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ pub mod deployment;
1010
pub type DeploymentId = uuid::Uuid;
1111
#[cfg(feature = "extract_propagation")]
1212
pub mod extract_propagation;
13+
#[cfg(feature = "claims")]
14+
pub mod limits;
1315
#[cfg(feature = "service")]
1416
pub mod log;
1517
#[cfg(feature = "service")]
@@ -19,8 +21,7 @@ pub mod models;
1921
pub mod resource;
2022
pub mod secrets;
2123
pub use secrets::{Secret, SecretStore};
22-
#[cfg(feature = "claims")]
23-
pub mod limits;
24+
pub mod templates;
2425
#[cfg(feature = "tracing")]
2526
pub mod tracing;
2627
#[cfg(feature = "wasm")]

common/src/templates.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// Schema used in `examples/templates.toml` and services that parses it
4+
#[derive(Debug, Default, Serialize, Deserialize)]
5+
pub struct TemplateDefinition {
6+
/// Title of the template
7+
title: String,
8+
/// A short description of the template
9+
description: Option<String>,
10+
/// Path relative to the repo root
11+
path: Option<String>,
12+
/// "starter" OR "template" (default) OR "tutorial"
13+
#[serde(default)]
14+
r#type: TemplateType,
15+
/// List of areas where this template is useful. Examples: "Web app", "Discord bot", "Monitoring", "Automation", "Utility"
16+
use_cases: Vec<String>,
17+
/// List of keywords that describe the template. Examples: "axum", "serenity", "typescript", "saas", "fullstack", "database"
18+
tags: Vec<String>,
19+
/// URL to a live instance of the template (if relevant)
20+
live_demo: Option<String>,
21+
22+
/// If this template is available in the `cargo shuttle init --template` short-hand options, add that name here
23+
template: Option<String>,
24+
25+
/// Set this to true if this is a community template outside of the shuttle-examples repo
26+
community: Option<bool>,
27+
/// GitHub username of the author of the community template
28+
author: Option<String>,
29+
/// URL to the repo of the community template
30+
repo: Option<String>,
31+
}
32+
33+
#[derive(Debug, Default, Serialize, Deserialize)]
34+
#[serde(rename_all = "lowercase")]
35+
pub enum TemplateType {
36+
Starter,
37+
#[default]
38+
Template,
39+
Tutorial,
40+
}

0 commit comments

Comments
 (0)