Skip to content

Commit

Permalink
Merge pull request #17 from blake-mealey/dev/unify-place-config
Browse files Browse the repository at this point in the history
move placeFiles config into templates.places.file config
  • Loading branch information
blake-mealey authored Nov 8, 2021
2 parents f5ef94e + c3ae61a commit 81db9b4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ file in the provided directory.
```yml
# rocat.yml

placeFiles:
start: start-place.rbxlx
world: world-place.rbxl

deployments:
- name: staging
branches: [dev, dev/*]
Expand Down Expand Up @@ -89,13 +85,16 @@ templates:
- game-thumbnail-3.png
places:
start:
file: start-place.rbxlx
name: The Best Experience Ever
description: |
The best multi-line
description of all time!
maxPlayerCount: 25
serverFill: { reservedSlots: 10 } # or robloxOptimized or maximum
allowCopying: false
world:
file: world-place.rbxl
```
To deploy the above configuration with Rocat, run `rocat deploy` from the file's directory.
Expand Down
6 changes: 2 additions & 4 deletions project-fixtures/multi-places/rocat.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
placeFiles:
start: start.rbxlx
world: world.rbxlx

deployments:
- name: staging
branches: [dev, dev/*]
Expand All @@ -23,8 +19,10 @@ templates:
name: Rocat Test Experience
places:
start:
file: start.rbxlx
name: Rocat Test Start Place
world:
world: start.rbxlx
name: Rocat Test World Place

state:
Expand Down
4 changes: 1 addition & 3 deletions project-fixtures/single-place/rocat.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
placeFiles:
start: start.rbxlx

deployments:
- name: staging
branches: [dev, dev/*]
Expand Down Expand Up @@ -31,6 +28,7 @@ templates:
- game-thumbnail-3.png
places:
start:
file: start.rbxlx
name: Start name
description: Start description
maxPlayerCount: 20
Expand Down
4 changes: 1 addition & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ use std::{collections::HashMap, default, fmt, fs, path::Path, str};
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Config {
#[serde(default = "HashMap::new")]
pub place_files: HashMap<String, String>,

#[serde(default = "Vec::new")]
pub deployments: Vec<DeploymentConfig>,

Expand Down Expand Up @@ -234,6 +231,7 @@ pub enum ServerFillConfig {
#[derive(Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct PlaceTemplateConfig {
pub file: String,
pub name: Option<String>,
pub description: Option<String>,
pub max_player_count: Option<u32>,
Expand Down
12 changes: 8 additions & 4 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ fn get_default_resources(

for (name, id) in deployment_config.place_ids.iter() {
let place_file = config
.place_files
.templates
.places
.get(name)
.ok_or(format!("No place file configured for place {}", name))?;
.map(|p| p.file.clone())
.ok_or(format!("No place file configured for place: {}", name))?;
let place_file_resource = Resource::new(resource_types::PLACE_FILE, name)
.add_output("assetId", &id)?
.add_ref_input("experienceId", &experience_asset_id_ref)
Expand Down Expand Up @@ -211,9 +213,11 @@ pub fn get_desired_graph(

for (name, id) in deployment_config.place_ids.iter() {
let place_file = config
.place_files
.templates
.places
.get(name)
.ok_or(format!("No place file configured for place {}", name))?;
.map(|p| p.file.clone())
.ok_or(format!("No place file configured for place: {}", name))?;
let place_file_resource = Resource::new(resource_types::PLACE_FILE, name)
.add_output("assetId", &id)?
.add_ref_input("experienceId", &experience_asset_id_ref)
Expand Down

0 comments on commit 81db9b4

Please sign in to comment.