refactor(contracts): keep generator within lint budget
This commit is contained in:
@@ -78,7 +78,22 @@ fn generated_outputs(root: &Path) -> Result<GeneratedOutputs, Box<dyn std::error
|
||||
add_schema::<AppInfo>(&mut outputs, &schema_dir, "app-info")?;
|
||||
add_schema::<DemoPackSummary>(&mut outputs, &schema_dir, "demo-pack-summary")?;
|
||||
|
||||
let declarations = [
|
||||
let declarations = generated_declarations();
|
||||
let ts = format!("// @generated by crates/nana-contracts; do not edit.\n\n{declarations}\n");
|
||||
outputs.push((root.join("contracts/ts/index.ts"), ts.into_bytes()));
|
||||
|
||||
let domain_source = fs::read(root.join("crates/nana-domain/src/lib.rs"))?;
|
||||
let source_hash = format!("{:x}\n", Sha256::digest(domain_source));
|
||||
outputs.push((
|
||||
root.join("contracts/.source.sha256"),
|
||||
source_hash.into_bytes(),
|
||||
));
|
||||
|
||||
Ok(outputs)
|
||||
}
|
||||
|
||||
fn generated_declarations() -> String {
|
||||
[
|
||||
ResourceId::decl(),
|
||||
ResourceKind::decl(),
|
||||
ResourceRef::decl(),
|
||||
@@ -150,18 +165,7 @@ fn generated_outputs(root: &Path) -> Result<GeneratedOutputs, Box<dyn std::error
|
||||
.into_iter()
|
||||
.map(|declaration| format!("export {declaration}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n\n");
|
||||
let ts = format!("// @generated by crates/nana-contracts; do not edit.\n\n{declarations}\n");
|
||||
outputs.push((root.join("contracts/ts/index.ts"), ts.into_bytes()));
|
||||
|
||||
let domain_source = fs::read(root.join("crates/nana-domain/src/lib.rs"))?;
|
||||
let source_hash = format!("{:x}\n", Sha256::digest(domain_source));
|
||||
outputs.push((
|
||||
root.join("contracts/.source.sha256"),
|
||||
source_hash.into_bytes(),
|
||||
));
|
||||
|
||||
Ok(outputs)
|
||||
.join("\n\n")
|
||||
}
|
||||
|
||||
fn add_schema<T: JsonSchema + Serialize>(
|
||||
|
||||
Reference in New Issue
Block a user