tauri/crates/tauri-schema-generator/build.rs
Amr Bashir 36eee37220
Restructure the repository (#10796)
* Restructure the repository

* lock file

* fmt

* fix bench

* fix cli template test

* remove accidental file

* fix mv command

* clippy

* upgrade paths-filter github action

* fix cli migration tests

* lockfile

* license headers

* clippy

* scope test-core to tauri crate

* license header

* correct --manifest-path usage

* lockfile

* fix tauri-driver on macOS [skip ci]

* build target ios

* try downgrade env_logger

* downgrade 0.1.7

* try to fix bench

* bench overflow

* revert overflow fix, fix tauri_root_path

* revert env_logger downgrade

* fmt

* raise msrv to 1.71

* fmt

* delete .cargo/config.toml [skip ci]

---------

Co-authored-by: Lucas Nogueira <lucas@tauri.app>
2024-08-27 18:42:30 -03:00

43 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, path::PathBuf};
use tauri_utils::{
acl::{capability::Capability, Permission, Scopes},
config::Config,
write_if_changed,
};
macro_rules! schema {
($name:literal, $path:ty) => {
(concat!($name, ".schema.json"), schemars::schema_for!($path))
};
}
pub fn main() -> Result<(), Box<dyn Error>> {
let schemas = [
schema!("config", Config),
schema!("capability", Capability),
schema!("permission", Permission),
schema!("scope", Scopes),
];
let out = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?);
let schemas_dir = out.join("schemas");
std::fs::create_dir_all(&schemas_dir)?;
for (filename, schema) in schemas {
let schema = serde_json::to_string_pretty(&schema)?;
write_if_changed(schemas_dir.join(filename), &schema)?;
if filename.starts_with("config") {
write_if_changed(out.join("../tauri-cli/config.schema.json"), schema)?;
}
}
Ok(())
}