mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-23 02:32:28 +03:00
4942d809ab
* Add auto generated acl schema files for docs * update CI --------- Co-authored-by: Lucas Nogueira <118899497+lucasfernog-crabnebula@users.noreply.github.com> Co-authored-by: Lucas Nogueira <lucas@crabnebula.dev>
35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
// Copyright 2019-2024 Tauri Programme within The Commons Conservancy
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
use std::{
|
|
error::Error,
|
|
fs::File,
|
|
io::{BufWriter, Write},
|
|
path::PathBuf,
|
|
};
|
|
|
|
use schemars::schema::RootSchema;
|
|
|
|
pub fn main() -> Result<(), Box<dyn Error>> {
|
|
let cap_schema = schemars::schema_for!(tauri_utils::acl::capability::Capability);
|
|
let perm_schema = schemars::schema_for!(tauri_utils::acl::Permission);
|
|
let scope_schema = schemars::schema_for!(tauri_utils::acl::Scopes);
|
|
|
|
let crate_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?);
|
|
|
|
write_schema_file(cap_schema, crate_dir.join("capability-schema.json"))?;
|
|
write_schema_file(perm_schema, crate_dir.join("permission-schema.json"))?;
|
|
write_schema_file(scope_schema, crate_dir.join("scope-schema.json"))?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
fn write_schema_file(schema: RootSchema, outpath: PathBuf) -> Result<(), Box<dyn Error>> {
|
|
let schema_str = serde_json::to_string_pretty(&schema).unwrap();
|
|
let mut schema_file = BufWriter::new(File::create(outpath)?);
|
|
write!(schema_file, "{schema_str}")?;
|
|
|
|
Ok(())
|
|
}
|