Upgrade and pin deps so that rbx-tree can break some APIs

This commit is contained in:
Lucien Greathouse
2019-01-11 18:19:06 -08:00
parent 811db2e668
commit 3e1c467b65
4 changed files with 51 additions and 241 deletions

View File

@@ -35,9 +35,9 @@ serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
uuid = { version = "0.7", features = ["v4", "serde"] }
rbx_tree = { git = "https://github.com/LPGhatguy/rbx-tree.git" }
rbx_xml = { git = "https://github.com/LPGhatguy/rbx-tree.git" }
rbx_binary = { git = "https://github.com/LPGhatguy/rbx-tree.git" }
rbx_tree = { rev = "8442d57a7a21072a380134962724281d044c65ad", git = "https://github.com/LPGhatguy/rbx-tree.git" }
rbx_xml = { rev = "8442d57a7a21072a380134962724281d044c65ad", git = "https://github.com/LPGhatguy/rbx-tree.git" }
rbx_binary = { rev = "8442d57a7a21072a380134962724281d044c65ad", git = "https://github.com/LPGhatguy/rbx-tree.git" }
[dev-dependencies]
tempfile = "3.0"

View File

@@ -49,6 +49,9 @@ pub enum BuildError {
#[fail(display = "IO error: {}", _0)]
IoError(#[fail(cause)] io::Error),
#[fail(display = "XML model file error")]
XmlModelEncodeError(rbx_xml::EncodeError),
}
impl From<ProjectLoadFuzzyError> for BuildError {
@@ -63,6 +66,12 @@ impl From<io::Error> for BuildError {
}
}
impl From<rbx_xml::EncodeError> for BuildError {
fn from(error: rbx_xml::EncodeError) -> BuildError {
BuildError::XmlModelEncodeError(error)
}
}
pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
let output_kind = options.output_kind
.or_else(|| detect_output_kind(options))
@@ -88,7 +97,7 @@ pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
// descendants.
let root_id = tree.get_root_id();
rbx_xml::encode(&tree, &[root_id], &mut file);
rbx_xml::encode(&tree, &[root_id], &mut file)?;
},
OutputKind::Rbxlx => {
// Place files don't contain an entry for the DataModel, but our
@@ -96,7 +105,7 @@ pub fn build(options: &BuildOptions) -> Result<(), BuildError> {
let root_id = tree.get_root_id();
let top_level_ids = tree.get_instance(root_id).unwrap().get_children_ids();
rbx_xml::encode(&tree, top_level_ids, &mut file);
rbx_xml::encode(&tree, top_level_ids, &mut file)?;
},
OutputKind::Rbxm => {
let root_id = tree.get_root_id();

View File

@@ -29,6 +29,9 @@ pub enum UploadError {
#[fail(display = "HTTP error: {}", _0)]
HttpError(#[fail(cause)] reqwest::Error),
#[fail(display = "XML model file error")]
XmlModelEncodeError(rbx_xml::EncodeError),
}
impl From<ProjectLoadFuzzyError> for UploadError {
@@ -49,6 +52,12 @@ impl From<reqwest::Error> for UploadError {
}
}
impl From<rbx_xml::EncodeError> for UploadError {
fn from(error: rbx_xml::EncodeError) -> UploadError {
UploadError::XmlModelEncodeError(error)
}
}
#[derive(Debug)]
pub struct UploadOptions<'a> {
pub fuzzy_project_path: PathBuf,
@@ -77,10 +86,10 @@ pub fn upload(options: &UploadOptions) -> Result<(), UploadError> {
match options.kind {
Some("place") | None => {
let top_level_ids = tree.get_instance(root_id).unwrap().get_children_ids();
rbx_xml::encode(&tree, top_level_ids, &mut contents);
rbx_xml::encode(&tree, top_level_ids, &mut contents)?;
},
Some("model") => {
rbx_xml::encode(&tree, &[root_id], &mut contents);
rbx_xml::encode(&tree, &[root_id], &mut contents)?;
},
Some(invalid) => return Err(UploadError::InvalidKind(invalid.to_owned())),
}