From 25f995a3dde149115a1b65d14b00afaa7cd76380 Mon Sep 17 00:00:00 2001 From: JPTomorrow Date: Mon, 12 Dec 2022 21:52:35 -0700 Subject: [PATCH] ready for first release --- src-tauri/src/main.rs | 7 ----- src/components/FileUpload.tsx | 19 ++++++++----- test/Cargo.json | 51 +++++++++++++++++++++++++++++++++++ test/Cargo.toml | 28 +++++++++++++++++++ test/Cargo.yaml | 37 +++++++++++++++++++++++++ 5 files changed, 128 insertions(+), 14 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 734e01e..0dd41ca 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -3,15 +3,8 @@ windows_subsystem = "windows" )] -use serde_json::to_string; use tauri::api::file; -// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command -#[tauri::command] -fn greet(name: &str) -> String { - format!("Hello, {}! You've been greeted from Rust!", name) -} - enum FileType { TOML, JSON, diff --git a/src/components/FileUpload.tsx b/src/components/FileUpload.tsx index 9395b07..d3f3999 100644 --- a/src/components/FileUpload.tsx +++ b/src/components/FileUpload.tsx @@ -1,7 +1,7 @@ import { invoke } from "@tauri-apps/api/tauri"; import { open } from "@tauri-apps/api/dialog"; import { writeTextFile } from "@tauri-apps/api/fs"; -import { useEffect, useState } from "react"; +import { useState } from "react"; import { AiOutlineFileText } from "react-icons/ai"; type FileTextView = { @@ -58,18 +58,17 @@ const FileUpload = ({ text }: { text?: string }) => { err: err, }); }); + }; + const writeOutputFiles = async () => { var lastIndex = path.lastIndexOf("/"); var fileName = (ext: string) => path.slice(lastIndex + 1, path.length).split(".")[0] + "." + ext; var newPath = path.slice(0, lastIndex + 1); - if (jsonView !== "") - await writeTextFile(newPath + fileName("json"), jsonView); - if (tomlView !== "") - await writeTextFile(newPath + fileName("toml"), tomlView); - if (yamlView !== "") - await writeTextFile(newPath + fileName("yaml"), yamlView); + if (jsonView) await writeTextFile(newPath + fileName("json"), jsonView); + if (tomlView) await writeTextFile(newPath + fileName("toml"), tomlView); + if (yamlView) await writeTextFile(newPath + fileName("yaml"), yamlView); }; return ( <> @@ -116,6 +115,12 @@ const FileUpload = ({ text }: { text?: string }) => {

) : null} +
+ {jsonView || yamlView || tomlView ? ( + + ) : null} ); }; diff --git a/test/Cargo.json b/test/Cargo.json index e69de29..821531d 100644 --- a/test/Cargo.json +++ b/test/Cargo.json @@ -0,0 +1,51 @@ +{ + "build-dependencies": { + "tauri-build": { + "features": [], + "version": "1.2" + } + }, + "dependencies": { + "serde_json": "1.0", + "tsu": "1.0.1", + "serde": { + "features": [ + "derive" + ], + "version": "1.0" + }, + "tauri": { + "features": [ + "dialog-open", + "dialog-save", + "fs-copy-file", + "fs-create-dir", + "fs-exists", + "fs-read-dir", + "fs-read-file", + "fs-write-file" + ], + "version": "1.2" + } + }, + "features": { + "custom-protocol": [ + "tauri/custom-protocol" + ], + "default": [ + "custom-protocol" + ] + }, + "package": { + "authors": [ + "you" + ], + "description": "A Tauri App", + "edition": "2021", + "license": "", + "name": "tauri-desktop-app", + "repository": "", + "rust-version": "1.57", + "version": "0.0.0" + } +} \ No newline at end of file diff --git a/test/Cargo.toml b/test/Cargo.toml index e69de29..b970d79 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "tauri-desktop-app" +version = "0.0.0" +description = "A Tauri App" +authors = ["you"] +license = "" +repository = "" +edition = "2021" +rust-version = "1.57" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +tauri-build = {version = "1.2", features = [] } + +[dependencies] +serde_json = "1.0" +serde = { version = "1.0", features = ["derive"] } +tauri = {version = "1.2", features = ["dialog-open", "dialog-save", "fs-copy-file", "fs-create-dir", "fs-exists", "fs-read-dir", "fs-read-file", "fs-write-file"] } +tsu = "1.0.1" + +[features] +# by default Tauri runs in production mode +# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL +default = [ "custom-protocol" ] +# this feature is used used for production builds where `devPath` points to the filesystem +# DO NOT remove this +custom-protocol = [ "tauri/custom-protocol" ] diff --git a/test/Cargo.yaml b/test/Cargo.yaml index e69de29..6d7bd9e 100644 --- a/test/Cargo.yaml +++ b/test/Cargo.yaml @@ -0,0 +1,37 @@ +build-dependencies: + tauri-build: + features: [] + version: '1.2' +dependencies: + serde_json: '1.0' + tsu: 1.0.1 + serde: + features: + - derive + version: '1.0' + tauri: + features: + - dialog-open + - dialog-save + - fs-copy-file + - fs-create-dir + - fs-exists + - fs-read-dir + - fs-read-file + - fs-write-file + version: '1.2' +features: + custom-protocol: + - tauri/custom-protocol + default: + - custom-protocol +package: + authors: + - you + description: A Tauri App + edition: '2021' + license: '' + name: tauri-desktop-app + repository: '' + rust-version: '1.57' + version: 0.0.0