Fix 'rojo upload' behavior

This commit is contained in:
Lucien Greathouse
2020-03-06 13:23:49 -08:00
parent 07c6fd3711
commit d4a39674de
3 changed files with 14 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
# Rojo Changelog
## Unreleased Changes
## Unreleased Changes for 0.6.x
* Fixed `rojo upload` command always uploading models.
* Removed `--kind` parameter to `rojo upload`; Rojo now automatically uploads the correct kind of asset based on your project file.
## [0.5.4](https://github.com/rojo-rbx/rojo/releases/tag/v0.5.4) (February 26, 2020)
This is a general maintenance release for the Rojo 0.5.x release series.

View File

@@ -155,10 +155,6 @@ pub struct UploadCommand {
#[structopt(default_value = "")]
pub project: PathBuf,
/// The kind of asset to generate, 'place', or 'model'. Defaults to place.
#[structopt(long, default_value = "place")]
pub kind: UploadKind,
/// Authenication cookie to use. If not specified, Rojo will attempt to find one from the system automatically.
#[structopt(long)]
pub cookie: Option<String>,

View File

@@ -43,14 +43,23 @@ fn upload_inner(options: UploadCommand) -> Result<(), Error> {
let vfs = Vfs::new(RealFetcher::new(WatchMode::Disabled));
let (_maybe_project, tree) = common_setup::start(&options.absolute_project(), &vfs);
let root_id = tree.get_root_id();
let inner_tree = tree.inner();
let root_id = inner_tree.get_root_id();
let root_instance = inner_tree.get_instance(root_id).unwrap();
let encode_ids = match root_instance.class_name.as_str() {
"DataModel" => root_instance.get_children_ids().to_vec(),
_ => vec![root_id],
};
let mut buffer = Vec::new();
log::trace!("Encoding XML model");
let config = rbx_xml::EncodeOptions::new()
.property_behavior(rbx_xml::EncodePropertyBehavior::WriteUnknown);
rbx_xml::to_writer(&mut buffer, tree.inner(), &[root_id], config).context(XmlModel)?;
rbx_xml::to_writer(&mut buffer, tree.inner(), &encode_ids, config).context(XmlModel)?;
let url = format!(
"https://data.roblox.com/Data/Upload.ashx?assetid={}",