From e4435b8516c3ec0c962cd0df71bb056d143582fb Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Fri, 1 Feb 2019 13:42:29 -0800 Subject: [PATCH 1/4] Implement new project file name, default.project.json --- server/src/commands/build.rs | 1 + server/src/commands/serve.rs | 1 + server/src/commands/upload.rs | 1 + server/src/project.rs | 37 ++++++++++++++++++++++++++++++----- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/server/src/commands/build.rs b/server/src/commands/build.rs index e5880aea8..2c839e692 100644 --- a/server/src/commands/build.rs +++ b/server/src/commands/build.rs @@ -79,6 +79,7 @@ pub fn build(options: &BuildOptions) -> Result<(), BuildError> { info!("Looking for project at {}", options.fuzzy_project_path.display()); let project = Project::load_fuzzy(&options.fuzzy_project_path)?; + project.check_compatibility(); info!("Found project at {}", project.file_location.display()); info!("Using project {:#?}", project); diff --git a/server/src/commands/serve.rs b/server/src/commands/serve.rs index 9b2db9dd5..58c0d16e7 100644 --- a/server/src/commands/serve.rs +++ b/server/src/commands/serve.rs @@ -39,6 +39,7 @@ pub fn serve(options: &ServeOptions) -> Result<(), ServeError> { info!("Looking for project at {}", options.fuzzy_project_path.display()); let project = Arc::new(Project::load_fuzzy(&options.fuzzy_project_path)?); + project.check_compatibility(); info!("Found project at {}", project.file_location.display()); info!("Using project {:#?}", project); diff --git a/server/src/commands/upload.rs b/server/src/commands/upload.rs index 0498693c1..fb26e0ab5 100644 --- a/server/src/commands/upload.rs +++ b/server/src/commands/upload.rs @@ -60,6 +60,7 @@ pub fn upload(options: &UploadOptions) -> Result<(), UploadError> { info!("Looking for project at {}", options.fuzzy_project_path.display()); let project = Project::load_fuzzy(&options.fuzzy_project_path)?; + project.check_compatibility(); info!("Found project at {}", project.file_location.display()); info!("Using project {:#?}", project); diff --git a/server/src/project.rs b/server/src/project.rs index e6c1509ca..f5365f9c5 100644 --- a/server/src/project.rs +++ b/server/src/project.rs @@ -6,12 +6,14 @@ use std::{ path::{Path, PathBuf}, }; +use log::warn; use failure::Fail; use maplit::hashmap; use rbx_tree::RbxValue; use serde_derive::{Serialize, Deserialize}; -pub static PROJECT_FILENAME: &'static str = "roblox-project.json"; +pub static PROJECT_FILENAME: &'static str = "default.project.json"; +pub static COMPAT_PROJECT_FILENAME: &'static str = "roblox-project.json"; // Methods used for Serde's default value system, which doesn't support using // value literals directly, only functions that return values. @@ -362,11 +364,17 @@ impl Project { } else if location_metadata.is_dir() { let with_file = start_location.join(PROJECT_FILENAME); - if let Ok(with_file_metadata) = fs::metadata(&with_file) { - if with_file_metadata.is_file() { + if let Ok(file_metadata) = fs::metadata(&with_file) { + if file_metadata.is_file() { return Some(with_file); - } else { - return None; + } + } + + let with_compat_file = start_location.join(COMPAT_PROJECT_FILENAME); + + if let Ok(file_metadata) = fs::metadata(&with_compat_file) { + if file_metadata.is_file() { + return Some(with_compat_file); } } } @@ -405,6 +413,25 @@ impl Project { Ok(()) } + /// Checks if there are any compatibility issues with this project file and + /// warns the user if there are any. + pub fn check_compatibility(&self) { + let file_name = self.file_location + .file_name().unwrap() + .to_str().expect("Project file path was not valid Unicode!"); + + if file_name == COMPAT_PROJECT_FILENAME { + warn!("Rojo's default project file name changed in 0.5.0-alpha3."); + warn!("Support for the old project file name will be dropped before 0.5.0 releases."); + warn!("Your project file is named {}", COMPAT_PROJECT_FILENAME); + warn!("Rename your project file to {}", PROJECT_FILENAME); + } else if !file_name.ends_with(".project.json") { + warn!("Starting in Rojo 0.5.0-alpha3, it's recommended to give all project files the"); + warn!(".project.json extension. This helps Rojo differentiate project file from"); + warn!("other JSON files!"); + } + } + fn to_source_project(&self) -> SourceProject { SourceProject { name: self.name.clone(), From 8646e79706f1f9ee939de9e7150a2073a0b9371f Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Fri, 1 Feb 2019 13:45:56 -0800 Subject: [PATCH 2/4] Rename all test projects to default.project.json --- plugin/{roblox-project.json => default.project.json} | 0 plugin/{place-project.json => place.project.json} | 0 server/tests/read_projects.rs | 8 ++++---- .../{roblox-project.json => default.project.json} | 0 .../empty/{roblox-project.json => default.project.json} | 0 .../{roblox-project.json => default.project.json} | 0 .../{roblox-project.json => default.project.json} | 0 .../{roblox-project.json => default.project.json} | 0 8 files changed, 4 insertions(+), 4 deletions(-) rename plugin/{roblox-project.json => default.project.json} (100%) rename plugin/{place-project.json => place.project.json} (100%) rename test-projects/composing-models/{roblox-project.json => default.project.json} (100%) rename test-projects/empty/{roblox-project.json => default.project.json} (100%) rename test-projects/missing-files/{roblox-project.json => default.project.json} (100%) rename test-projects/single-sync-point/{roblox-project.json => default.project.json} (100%) rename test-projects/test-model/{roblox-project.json => default.project.json} (100%) diff --git a/plugin/roblox-project.json b/plugin/default.project.json similarity index 100% rename from plugin/roblox-project.json rename to plugin/default.project.json diff --git a/plugin/place-project.json b/plugin/place.project.json similarity index 100% rename from plugin/place-project.json rename to plugin/place.project.json diff --git a/server/tests/read_projects.rs b/server/tests/read_projects.rs index af30ed992..55ae5550f 100644 --- a/server/tests/read_projects.rs +++ b/server/tests/read_projects.rs @@ -21,7 +21,7 @@ lazy_static! { #[test] fn empty() { - let project_file_location = TEST_PROJECTS_ROOT.join("empty/roblox-project.json"); + let project_file_location = TEST_PROJECTS_ROOT.join("empty/default.project.json"); let project = Project::load_exact(&project_file_location).unwrap(); assert_eq!(project.name, "empty"); @@ -29,7 +29,7 @@ fn empty() { #[test] fn empty_fuzzy_file() { - let project_file_location = TEST_PROJECTS_ROOT.join("empty/roblox-project.json"); + let project_file_location = TEST_PROJECTS_ROOT.join("empty/default.project.json"); let project = Project::load_fuzzy(&project_file_location).unwrap(); assert_eq!(project.name, "empty"); @@ -45,7 +45,7 @@ fn empty_fuzzy_folder() { #[test] fn single_sync_point() { - let project_file_location = TEST_PROJECTS_ROOT.join("single-sync-point/roblox-project.json"); + let project_file_location = TEST_PROJECTS_ROOT.join("single-sync-point/default.project.json"); let project = Project::load_exact(&project_file_location).unwrap(); let expected_project = { @@ -100,7 +100,7 @@ fn single_sync_point() { #[test] fn test_model() { - let project_file_location = TEST_PROJECTS_ROOT.join("test-model/roblox-project.json"); + let project_file_location = TEST_PROJECTS_ROOT.join("test-model/default.project.json"); let project = Project::load_exact(&project_file_location).unwrap(); assert_eq!(project.name, "test-model"); diff --git a/test-projects/composing-models/roblox-project.json b/test-projects/composing-models/default.project.json similarity index 100% rename from test-projects/composing-models/roblox-project.json rename to test-projects/composing-models/default.project.json diff --git a/test-projects/empty/roblox-project.json b/test-projects/empty/default.project.json similarity index 100% rename from test-projects/empty/roblox-project.json rename to test-projects/empty/default.project.json diff --git a/test-projects/missing-files/roblox-project.json b/test-projects/missing-files/default.project.json similarity index 100% rename from test-projects/missing-files/roblox-project.json rename to test-projects/missing-files/default.project.json diff --git a/test-projects/single-sync-point/roblox-project.json b/test-projects/single-sync-point/default.project.json similarity index 100% rename from test-projects/single-sync-point/roblox-project.json rename to test-projects/single-sync-point/default.project.json diff --git a/test-projects/test-model/roblox-project.json b/test-projects/test-model/default.project.json similarity index 100% rename from test-projects/test-model/roblox-project.json rename to test-projects/test-model/default.project.json From 179ac3204779b9a81b65802d3107bf9f1101bc0f Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Fri, 1 Feb 2019 13:47:37 -0800 Subject: [PATCH 3/4] Update CHANGELOG --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c2692d8..6618b9c84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Rojo Changelog ## [Unreleased] +* Changed default project file name from `roblox-project.json` to `default.project.json` ([#120](https://github.com/LPGhatguy/rojo/pull/120)) + * The old file name will still be supported until 0.5.0 is fully released. +* Added warning when loading project files that don't end in `.project.json` + * This new extension enables Rojo to distinguish project files from random JSON files, which is necessary to support nested projects. * Added new (empty) diagnostic page served from the server * Added better error messages for when a file is missing that's referenced by a Rojo project * Added support for visualization endpoints returning GraphViz source when Dot is not available From 44325bbd72ec5499786016e34e083973d6be0061 Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Fri, 1 Feb 2019 14:57:18 -0800 Subject: [PATCH 4/4] Fix warning message typo --- server/src/project.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/project.rs b/server/src/project.rs index f5365f9c5..c391e02d9 100644 --- a/server/src/project.rs +++ b/server/src/project.rs @@ -427,7 +427,7 @@ impl Project { warn!("Rename your project file to {}", PROJECT_FILENAME); } else if !file_name.ends_with(".project.json") { warn!("Starting in Rojo 0.5.0-alpha3, it's recommended to give all project files the"); - warn!(".project.json extension. This helps Rojo differentiate project file from"); + warn!(".project.json extension. This helps Rojo differentiate project files from"); warn!("other JSON files!"); } }