forked from StrafesNET/asset-tool
more
This commit is contained in:
parent
3182d5dd75
commit
67aa158e13
@ -17,7 +17,7 @@ use crate::common::{sanitize,Style,PropertiesOverride};
|
||||
//eventually:
|
||||
#[derive(Debug)]
|
||||
#[allow(dead_code)]//idk why this thinks it's dead code, the errors are printed out in various places
|
||||
enum QueryResolveError{
|
||||
pub enum QueryResolveError{
|
||||
NotFound,//0 results
|
||||
Ambiguous,//>1 results
|
||||
JoinError(tokio::task::JoinError),
|
||||
@ -234,7 +234,7 @@ struct CompileNode{
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum CompileNodeError{
|
||||
pub enum CompileNodeError{
|
||||
IO(std::io::Error),
|
||||
ScriptWithOverrides(ScriptWithOverridesError),
|
||||
InvalidHintOrClass(Option<String>,ScriptHint),
|
||||
@ -375,7 +375,7 @@ impl CompileNode{
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum ScriptHint{
|
||||
pub enum ScriptHint{
|
||||
Script,
|
||||
LocalScript,
|
||||
ModuleScript,
|
||||
@ -409,8 +409,8 @@ enum TooComplicated<T>{
|
||||
}
|
||||
|
||||
pub struct CompileConfig{
|
||||
input_folder:PathBuf,
|
||||
style:Option<Style>,
|
||||
pub input_folder:PathBuf,
|
||||
pub style:Option<Style>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
26
src/main.rs
26
src/main.rs
@ -184,11 +184,11 @@ pub enum Style{
|
||||
RoxRojo,
|
||||
}
|
||||
impl Style{
|
||||
fn rox(&self)->rox_compiler::types::Style{
|
||||
fn rox(&self)->rox_compiler::Style{
|
||||
match self{
|
||||
Style::Rox=>rox_compiler::types::Style::Rox,
|
||||
Style::Rojo=>rox_compiler::types::Style::Rojo,
|
||||
Style::RoxRojo=>rox_compiler::types::Style::RoxRojo,
|
||||
Style::Rox=>rox_compiler::Style::Rox,
|
||||
Style::Rojo=>rox_compiler::Style::Rojo,
|
||||
Style::RoxRojo=>rox_compiler::Style::RoxRojo,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -588,7 +588,7 @@ struct WriteCommitConfig{
|
||||
write_scripts:bool,
|
||||
}
|
||||
|
||||
async fn write_commit(config:WriteCommitConfig,b:Result<AResult<(AssetVersion,DecompiledContext)>,tokio::task::JoinError>,repo:&git2::Repository)->AResult<()>{
|
||||
async fn write_commit(config:WriteCommitConfig,b:Result<AResult<(AssetVersion,rox_compiler::DecompiledContext)>,tokio::task::JoinError>,repo:&git2::Repository)->AResult<()>{
|
||||
let (asset_version,context)=b??;
|
||||
println!("writing files for version {}",asset_version.assetVersionNumber);
|
||||
|
||||
@ -611,13 +611,13 @@ async fn write_commit(config:WriteCommitConfig,b:Result<AResult<(AssetVersion,De
|
||||
}
|
||||
|
||||
//write files
|
||||
write_files(WriteConfig{
|
||||
style:config.style,
|
||||
context.write_files(rox_compiler::WriteConfig{
|
||||
style:config.style.rox(),
|
||||
output_folder:config.output_folder.clone(),
|
||||
write_template:config.write_template,
|
||||
write_models:config.write_models,
|
||||
write_scripts:config.write_scripts,
|
||||
},context).await?;
|
||||
}).await?;
|
||||
|
||||
let date=asset_version.created;
|
||||
//let sig=repo.signature()?; //this pulls default name and email
|
||||
@ -695,7 +695,8 @@ async fn decompile_history_into_git(config:DecompileHistoryConfig)->AResult<()>{
|
||||
tokio::task::spawn_blocking(move||{
|
||||
file_path.push(format!("{}_v{}.rbxl",asset_version.assetId,asset_version.assetVersionNumber));
|
||||
let file=std::fs::File::open(file_path)?;
|
||||
let contents=generate_decompiled_context(file)?;
|
||||
let dom=load_dom(file)?;
|
||||
let contents=rox_compiler::DecompiledContext::from_dom(dom);
|
||||
Ok::<_,anyhow::Error>((asset_version,contents))
|
||||
})
|
||||
}))
|
||||
@ -744,7 +745,8 @@ async fn download_and_decompile_history_into_git(config:DownloadAndDecompileHist
|
||||
let context=context.clone();
|
||||
tokio::task::spawn(async move{
|
||||
let file=context.download(rbx_asset::context::DownloadRequest{asset_id,version:Some(asset_version.assetVersionNumber)}).await?;
|
||||
Ok::<_,anyhow::Error>((asset_version,generate_decompiled_context(std::io::Cursor::new(file))?))
|
||||
let dom=load_dom(std::io::Cursor::new(file))?;
|
||||
Ok::<_,anyhow::Error>((asset_version,rox_compiler::DecompiledContext::from_dom(dom)))
|
||||
})
|
||||
}))
|
||||
.buffered(CONCURRENT_DECODE)
|
||||
@ -783,9 +785,9 @@ async fn compile(config:CompileConfig)->AResult<()>{
|
||||
//hack to traverse root folder as the root object
|
||||
dom.root_mut().name="src".to_owned();
|
||||
|
||||
rox_compiler::compile::compile(rox_compiler::types::CompileConfig{
|
||||
rox_compiler::compile(rox_compiler::CompileConfig{
|
||||
input_folder:config.input_folder,
|
||||
style:config.style,
|
||||
style:config.style.map(|s|s.rox()),
|
||||
},&mut dom).await?;
|
||||
|
||||
let mut output_place=config.output_file.clone();
|
||||
|
Loading…
Reference in New Issue
Block a user