From 174a990c405fa76d96bcef2f16c0bad7126ba1a8 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Wed, 1 Jun 2022 17:28:48 -0400 Subject: [PATCH] QoL changes & code formatting --- package.json | 2 +- public/index.html | 4 ++-- src-tauri/src/proxy.rs | 15 ++++++++------- src-tauri/tauri.conf.json | 4 ++-- src/index.tsx | 2 +- src/ui/components/common/DirInput.tsx | 2 -- src/ui/components/menu/Options.tsx | 7 +++---- src/utils/configuration.ts | 7 +++---- 8 files changed, 20 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 2e9f49f..f2c54d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cultivation", - "version": "0.1.0", + "version": "1.0.0", "private": true, "dependencies": { "@tauri-apps/api": "^1.0.0-rc.5", diff --git a/public/index.html b/public/index.html index a31d734..030b8e7 100644 --- a/public/index.html +++ b/public/index.html @@ -7,11 +7,11 @@ - React App + Cultivation diff --git a/src-tauri/src/proxy.rs b/src-tauri/src/proxy.rs index f30324a..ff90811 100644 --- a/src-tauri/src/proxy.rs +++ b/src-tauri/src/proxy.rs @@ -82,13 +82,13 @@ pub async fn create_proxy(proxy_port: u16, certificate_path: String) { let private_key = rustls::PrivateKey( pemfile::pkcs8_private_keys(&mut private_key_bytes) .expect("Failed to parse private key") - .remove(0), + .remove(0) ); let ca_cert = rustls::Certificate( pemfile::certs(&mut ca_cert_bytes) .expect("Failed to parse CA certificate") - .remove(0), + .remove(0) ); // Create the certificate authority. @@ -168,26 +168,27 @@ pub fn generate_ca_files(path: &str) { ]; // Create certificate. + let cert_path = format!("{}\\ca", path); + let cert = Certificate::from_params(params).unwrap(); let cert_crt = cert.serialize_pem().unwrap(); - let cert_path = format!("{}\\ca", path); + let private_key = cert.serialize_private_key_pem(); + // Make certificate directory. match fs::create_dir(&cert_path) { Ok(_) => {}, Err(e) => { println!("{}", e); } }; - - println!("{}", cert_crt); + // Write the certificate to a file. match fs::write(format!("{}\\cert.crt", &cert_path), cert_crt) { Ok(_) => println!("Wrote certificate to {}", &cert_path), Err(e) => println!("Error writing certificate to {}: {}", &cert_path, e), } - let private_key = cert.serialize_private_key_pem(); - + // Write the private key to a file. match fs::write(format!("{}\\private.key", &cert_path), private_key) { Ok(_) => println!("Wrote private key to {}", &cert_path), Err(e) => println!("Error writing private key to {}: {}", &cert_path, e), diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 4af5ced..a8c7ea7 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -6,8 +6,8 @@ "distDir": "../build" }, "package": { - "productName": "cultivation", - "version": "0.1.0" + "productName": "Cultivation", + "version": "1.0.0" }, "tauri": { "allowlist": { diff --git a/src/index.tsx b/src/index.tsx index 27dbf9c..c43546b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -20,4 +20,4 @@ root.render( // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals import reportWebVitals from './utils/reportWebVitals' -reportWebVitals() \ No newline at end of file +reportWebVitals(console.log) \ No newline at end of file diff --git a/src/ui/components/common/DirInput.tsx b/src/ui/components/common/DirInput.tsx index 31b751f..024b2eb 100644 --- a/src/ui/components/common/DirInput.tsx +++ b/src/ui/components/common/DirInput.tsx @@ -72,8 +72,6 @@ export default class DirInput extends React.Component { ] }) } - - if (Array.isArray(path)) path = path[0] if (!path) return diff --git a/src/ui/components/menu/Options.tsx b/src/ui/components/menu/Options.tsx index 65fd9b8..9d0a35c 100644 --- a/src/ui/components/menu/Options.tsx +++ b/src/ui/components/menu/Options.tsx @@ -6,7 +6,6 @@ import './Options.css' import { setConfigOption, getConfig, getConfigOption } from '../../../utils/configuration' import Checkbox from '../common/Checkbox' import Divider from './Divider' -import { invoke } from '@tauri-apps/api' interface IProps { closeFn: () => void; @@ -81,8 +80,8 @@ export default class Options extends React.Component { }) } - setCustomBackground() { - setConfigOption('customBackground', this.state.bg_url_or_path) + setCustomBackground(value: string) { + setConfigOption('customBackground', value) } render() { @@ -132,7 +131,7 @@ export default class Options extends React.Component {
- +
diff --git a/src/utils/configuration.ts b/src/utils/configuration.ts index c67ffb3..4594d4a 100644 --- a/src/utils/configuration.ts +++ b/src/utils/configuration.ts @@ -40,11 +40,10 @@ export interface Configuration { } export async function setConfigOption(key: string, value: any): Promise { - const config = await getConfig() - - Object.assign(config, { [key]: value }) + const config: any = await getConfig() + config[key] = value - await saveConfig(config) + await saveConfig( config) } export async function getConfigOption(key: string): Promise {