forked from rojo-rbx/rojo
Implement new project file name, default.project.json (#120)
* Implement new project file name, default.project.json * Rename all test projects to default.project.json * Update CHANGELOG * Fix warning message typo
This commit is contained in:
committed by
GitHub
parent
78a1947cec
commit
785bdb8ecb
@@ -1,6 +1,10 @@
|
|||||||
# Rojo Changelog
|
# Rojo Changelog
|
||||||
|
|
||||||
## [Unreleased]
|
## [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 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 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
|
* Added support for visualization endpoints returning GraphViz source when Dot is not available
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
|
|||||||
info!("Looking for project at {}", options.fuzzy_project_path.display());
|
info!("Looking for project at {}", options.fuzzy_project_path.display());
|
||||||
|
|
||||||
let project = Project::load_fuzzy(&options.fuzzy_project_path)?;
|
let project = Project::load_fuzzy(&options.fuzzy_project_path)?;
|
||||||
|
project.check_compatibility();
|
||||||
|
|
||||||
info!("Found project at {}", project.file_location.display());
|
info!("Found project at {}", project.file_location.display());
|
||||||
info!("Using project {:#?}", project);
|
info!("Using project {:#?}", project);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ pub fn serve(options: &ServeOptions) -> Result<(), ServeError> {
|
|||||||
info!("Looking for project at {}", options.fuzzy_project_path.display());
|
info!("Looking for project at {}", options.fuzzy_project_path.display());
|
||||||
|
|
||||||
let project = Arc::new(Project::load_fuzzy(&options.fuzzy_project_path)?);
|
let project = Arc::new(Project::load_fuzzy(&options.fuzzy_project_path)?);
|
||||||
|
project.check_compatibility();
|
||||||
|
|
||||||
info!("Found project at {}", project.file_location.display());
|
info!("Found project at {}", project.file_location.display());
|
||||||
info!("Using project {:#?}", project);
|
info!("Using project {:#?}", project);
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ pub fn upload(options: &UploadOptions) -> Result<(), UploadError> {
|
|||||||
info!("Looking for project at {}", options.fuzzy_project_path.display());
|
info!("Looking for project at {}", options.fuzzy_project_path.display());
|
||||||
|
|
||||||
let project = Project::load_fuzzy(&options.fuzzy_project_path)?;
|
let project = Project::load_fuzzy(&options.fuzzy_project_path)?;
|
||||||
|
project.check_compatibility();
|
||||||
|
|
||||||
info!("Found project at {}", project.file_location.display());
|
info!("Found project at {}", project.file_location.display());
|
||||||
info!("Using project {:#?}", project);
|
info!("Using project {:#?}", project);
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use log::warn;
|
||||||
use failure::Fail;
|
use failure::Fail;
|
||||||
use maplit::hashmap;
|
use maplit::hashmap;
|
||||||
use rbx_tree::RbxValue;
|
use rbx_tree::RbxValue;
|
||||||
use serde_derive::{Serialize, Deserialize};
|
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
|
// Methods used for Serde's default value system, which doesn't support using
|
||||||
// value literals directly, only functions that return values.
|
// value literals directly, only functions that return values.
|
||||||
@@ -362,11 +364,17 @@ impl Project {
|
|||||||
} else if location_metadata.is_dir() {
|
} else if location_metadata.is_dir() {
|
||||||
let with_file = start_location.join(PROJECT_FILENAME);
|
let with_file = start_location.join(PROJECT_FILENAME);
|
||||||
|
|
||||||
if let Ok(with_file_metadata) = fs::metadata(&with_file) {
|
if let Ok(file_metadata) = fs::metadata(&with_file) {
|
||||||
if with_file_metadata.is_file() {
|
if file_metadata.is_file() {
|
||||||
return Some(with_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(())
|
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 files from");
|
||||||
|
warn!("other JSON files!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn to_source_project(&self) -> SourceProject {
|
fn to_source_project(&self) -> SourceProject {
|
||||||
SourceProject {
|
SourceProject {
|
||||||
name: self.name.clone(),
|
name: self.name.clone(),
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ lazy_static! {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty() {
|
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();
|
let project = Project::load_exact(&project_file_location).unwrap();
|
||||||
|
|
||||||
assert_eq!(project.name, "empty");
|
assert_eq!(project.name, "empty");
|
||||||
@@ -29,7 +29,7 @@ fn empty() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_fuzzy_file() {
|
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();
|
let project = Project::load_fuzzy(&project_file_location).unwrap();
|
||||||
|
|
||||||
assert_eq!(project.name, "empty");
|
assert_eq!(project.name, "empty");
|
||||||
@@ -45,7 +45,7 @@ fn empty_fuzzy_folder() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn single_sync_point() {
|
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 project = Project::load_exact(&project_file_location).unwrap();
|
||||||
|
|
||||||
let expected_project = {
|
let expected_project = {
|
||||||
@@ -100,7 +100,7 @@ fn single_sync_point() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_model() {
|
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();
|
let project = Project::load_exact(&project_file_location).unwrap();
|
||||||
|
|
||||||
assert_eq!(project.name, "test-model");
|
assert_eq!(project.name, "test-model");
|
||||||
|
|||||||
Reference in New Issue
Block a user