diff --git a/pgml-apps/cargo-pgml-components/Cargo.lock b/pgml-apps/cargo-pgml-components/Cargo.lock index c02281263..518bdd2e6 100644 --- a/pgml-apps/cargo-pgml-components/Cargo.lock +++ b/pgml-apps/cargo-pgml-components/Cargo.lock @@ -79,7 +79,7 @@ checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "cargo-pgml-components" -version = "0.1.8" +version = "0.1.10" dependencies = [ "anyhow", "clap", diff --git a/pgml-apps/cargo-pgml-components/Cargo.toml b/pgml-apps/cargo-pgml-components/Cargo.toml index be13f563c..2b6bd6c32 100644 --- a/pgml-apps/cargo-pgml-components/Cargo.toml +++ b/pgml-apps/cargo-pgml-components/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-pgml-components" -version = "0.1.9" +version = "0.1.10" edition = "2021" authors = ["PostgresML "] license = "MIT" diff --git a/pgml-apps/cargo-pgml-components/src/frontend/components.rs b/pgml-apps/cargo-pgml-components/src/frontend/components.rs index d1833b281..2dbb0a705 100644 --- a/pgml-apps/cargo-pgml-components/src/frontend/components.rs +++ b/pgml-apps/cargo-pgml-components/src/frontend/components.rs @@ -1,11 +1,11 @@ use convert_case::{Case, Casing}; use sailfish::TemplateOnce; -use std::fs::{create_dir_all, read_dir}; +use std::fs::{create_dir_all, read_dir, read_to_string}; use std::path::Path; use std::process::exit; use crate::frontend::templates; -use crate::util::{error, info, unwrap_or_exit, write_to_file}; +use crate::util::{compare_strings, error, info, unwrap_or_exit, write_to_file}; static COMPONENT_DIRECTORY: &'static str = "src/components"; static COMPONENT_MOD: &'static str = "src/components/mod.rs"; @@ -131,7 +131,13 @@ pub fn update_modules() { } let modules = unwrap_or_exit!(templates::Mod { modules }.render_once()); + let existing_modules = unwrap_or_exit!(read_to_string(COMPONENT_MOD)); - unwrap_or_exit!(write_to_file(&Path::new(COMPONENT_MOD), &modules)); - info(&format!("written {}", COMPONENT_MOD)); + if !unwrap_or_exit!(compare_strings(&modules, &existing_modules)) { + debug!("mod.rs is different"); + unwrap_or_exit!(write_to_file(&Path::new(COMPONENT_MOD), &modules)); + info(&format!("written {}", COMPONENT_MOD)); + } + + debug!("mod.rs is the same"); } diff --git a/pgml-apps/cargo-pgml-components/src/util.rs b/pgml-apps/cargo-pgml-components/src/util.rs index ec3d4aa3d..d500aa78d 100644 --- a/pgml-apps/cargo-pgml-components/src/util.rs +++ b/pgml-apps/cargo-pgml-components/src/util.rs @@ -1,5 +1,5 @@ use owo_colors::OwoColorize; -use std::fs::File; +use std::fs::{read_to_string, File}; use std::io::{ErrorKind, Write}; use std::path::Path; use std::process::Command; @@ -78,3 +78,16 @@ pub fn write_to_file(path: &Path, content: &str) -> std::io::Result<()> { Ok(()) } + +#[allow(dead_code)] +pub fn compare_files(path1: &Path, path2: &Path) -> std::io::Result { + let content1 = read_to_string(path1)?; + let content2 = read_to_string(path2)?; + + compare_strings(&content1, &content2) +} + +pub fn compare_strings(string1: &str, string2: &str) -> std::io::Result { + // TODO: faster string comparison method needed. + Ok(string1 == string2) +} diff --git a/pgml-dashboard/static/js/.ignore b/pgml-dashboard/static/js/.ignore new file mode 100644 index 000000000..a9b203a6e --- /dev/null +++ b/pgml-dashboard/static/js/.ignore @@ -0,0 +1 @@ +main.js diff --git a/pgml-dashboard/templates/content/playground.html b/pgml-dashboard/templates/content/playground.html index 792f7621d..1d03bb214 100644 --- a/pgml-dashboard/templates/content/playground.html +++ b/pgml-dashboard/templates/content/playground.html @@ -1 +1,11 @@ +<% use crate::components::*; %> +

Playground

+ +
+ <%+ GithubIcon::new() %> +
+ +
+ <%- Navbar::render(None) %> +
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy