This repository has been archived by the owner on Dec 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
abed13e
commit a9ba467
Showing
10 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Contributing | ||
|
||
## Templating README files | ||
|
||
``` | ||
./scripts/template.sh | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Rivet Examples | ||
|
||
💾 **Important** To download the assets to run these games, use [Git LFS](https://git-lfs.com/): `git lfs pull` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "example-templater" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
anyhow = "1.0.76" | ||
semver = { version = "1.0.20", features = ["serde"] } | ||
serde = { version = "1.0.193", features = ["derive"] } | ||
tera = "1.19.1" | ||
toml = "0.8.8" | ||
walkdir = "2.4.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use anyhow::{Context, Result}; | ||
use semver::Version as SemVer; | ||
use serde::{Deserialize, Serialize}; | ||
use std::{fs, path::Path}; | ||
use tera::Tera; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
struct Config { | ||
meta: ConfigMeta, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
struct ConfigMeta { | ||
engine_version: Option<SemVer>, | ||
language: String, | ||
rendering: String, | ||
features: Vec<String>, | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let mut tera = Tera::default(); | ||
tera.add_raw_template("README.md", include_str!("../tpl/README.md.tera"))?; | ||
|
||
for entry in walkdir::WalkDir::new(".") { | ||
let entry = entry?; | ||
if entry.file_name() == "example.toml" { | ||
template_dir(&tera, entry.path().parent().context("path.parent")?)?; | ||
} | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
fn template_dir(tera: &Tera, path: &Path) -> Result<()> { | ||
// Read config | ||
let config: Config = toml::from_str(&fs::read_to_string(path.join("example.toml"))?)?; | ||
|
||
// Template Tera | ||
let mut context = tera::Context::new(); | ||
context.insert("config", &config); | ||
|
||
// Write README | ||
let readme_content = tera.render("README.md", &context)?; | ||
fs::write(path.join("README.md"), readme_content)?; | ||
|
||
fs::write(path.join("LICENSE"), include_str!("../../../LICENSE"))?; | ||
|
||
fs::write(path.join("LICENSE"), include_str!("../../../LICENSE"))?; | ||
|
||
// TODO: Write .gitignore | ||
// TODO: Write LICENSE | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# {{ config.title }} | ||
|
||
{% if config.preview %} | ||
 | ||
{% endif %} | ||
|
||
[Visit Tutorial](https://rivet.gg/learn/godot/{{ config.tutorial_id | default(value="xxxx") }}) | ||
|
||
| {% for meta in meta %} {{ key }} |{% endfor %} | ||
| {% for meta in meta %} --- |{% endfor %} | ||
| {% for meta in meta %} {{ value }} |{% endfor %} | ||
|
||
**Rivet Features** | ||
|
||
{% for feature in config.features %} | ||
- {{ feature }} | ||
{% endfor %} | ||
|
||
## Developing Locally | ||
|
||
1. Download repo (gotta cater to the git noobs) | ||
2. Open project | ||
3. Login to Rivet in plugin & create game | ||
4. Click run | ||
|
||
## Deploying | ||
|
||
[Deploying games with Godot](https://rivet.gg/docs/{{ config.deploying_id | default(value="xxxx") }}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
trailingComma: 'none', | ||
tabWidth: 2, | ||
useTabs: false, | ||
singleQuote: true, | ||
printWidth: 110, | ||
endOfLine: 'lf', | ||
arrowParens: 'avoid', | ||
bracketSpacing: true, | ||
jsxBracketSameLine: true, | ||
jsxSingleQuote: true, | ||
overrides: [ | ||
{ | ||
files: '*.yaml', | ||
options: { | ||
tabWidth: 2, | ||
useTabs: false | ||
} | ||
} | ||
], | ||
tailwindFunctions: ['clsx'], | ||
plugins: [require('prettier-plugin-tailwindcss')] | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
set -euf | ||
|
||
npx prettier@3 --write . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
set -euf | ||
|
||
cargo run --manifest-path lib/templater/Cargo.toml | ||
|