Fix yarn builds with a couple of shortcuts

This commit is contained in:
Pierre Jacquier
2024-02-07 07:06:26 -05:00
parent 6b835d5149
commit 6deac3f388
13 changed files with 1670 additions and 731 deletions

2355
src-tauri/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ license = ""
repository = "https://github.com/KittyCAD/modeling-app"
default-run = "app"
edition = "2021"
rust-version = "1.60"
rust-version = "1.70"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -21,7 +21,11 @@ oauth2 = "4.4.2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tauri = { version = "2.0.0-beta", features = [ "devtools"] }
tauri-plugin-fs = "2"
tauri-plugin-dialog = { version = "2.0.0-beta.0" }
tauri-plugin-fs = { version = "2.0.0-beta.0" }
tauri-plugin-http = { version = "2.0.0-beta.0" }
tauri-plugin-os = { version = "2.0.0-beta.0" }
tauri-plugin-shell = { version = "2.0.0-beta.0" }
tokio = { version = "1.34.0", features = ["time"] }
toml = "0.8.2"
@ -33,6 +37,3 @@ tauri-driver = "0.1.3"
# If you use cargo directly instead of tauri's cli you can use this feature flag to switch between tauri's `dev` and `build` modes.
# DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]
[lib]
crate-type = ["staticlib", "cdylib", "rlib"]

View File

@ -14,7 +14,9 @@
"menu:default",
"tray:default",
"fs:allow-read-file",
"fs:allow-read-text-file",
"fs:allow-write-file",
"fs:allow-write-text-file",
"fs:allow-read-dir",
"fs:allow-copy-file",
"fs:allow-mkdir",
@ -25,8 +27,12 @@
{
"identifier": "fs:scope",
"allow": [
"$HOME/**/*",
"$APPDATA/**/*"
{
"path": "$HOME/**/*"
},
{
"path": "$APPDATA/**/*"
}
]
},
"shell:allow-open",

View File

@ -0,0 +1 @@
{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","context":"local","windows":["main"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","fs:allow-read-file","fs:allow-read-text-file","fs:allow-write-file","fs:allow-write-text-file","fs:allow-read-dir","fs:allow-copy-file","fs:allow-mkdir","fs:allow-remove","fs:allow-remove","fs:allow-rename","fs:allow-exists",{"identifier":"fs:scope","allow":[{"path":"$HOME/**/*"},{"path":"$APPDATA/**/*"}]},"shell:allow-open","dialog:allow-open","dialog:allow-save","dialog:allow-message","dialog:allow-ask","dialog:allow-confirm",{"identifier":"http:default","allow":["https://dev.kittycad.io/*","https://kittycad.io/*","https://api.dev.kittycad.io/*"]},"os:allow-platform","os:allow-version","os:allow-os-type","os:allow-family","os:allow-arch","os:allow-exe-extension","os:allow-locale","os:allow-hostname"],"platforms":["linux","macOS","windows","android","iOS"]}}

View File

@ -0,0 +1 @@
{schema_str}

View File

@ -0,0 +1 @@
{schema_str}

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,8 @@ use std::io::Read;
use anyhow::Result;
use oauth2::TokenResponse;
use tauri::{InvokeError, Manager};
use tauri::ipc::InvokeError;
use tauri_plugin_shell::ShellExt;
const DEFAULT_HOST: &str = "https://api.kittycad.io";
/// This command returns the a json string parse from a toml file at the path.
@ -84,7 +85,8 @@ async fn login(app: tauri::AppHandle, host: &str) -> Result<String, InvokeError>
fs::write("/tmp/kittycad_user_code", details.user_code().secret())
.expect("Unable to write /tmp/kittycad_user_code file");
} else {
tauri::api::shell::open(&app.shell_scope(), auth_uri.secret(), None)
println!("{}", auth_uri.secret().to_string());
app.shell().open(auth_uri.secret(), None)
.map_err(|e| InvokeError::from_anyhow(e.into()))?;
}
@ -160,7 +162,11 @@ fn main() {
read_toml,
read_txt_file
])
.plugin(tauri_plugin_fs_extra::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_http::init())
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_shell::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@ -17,7 +17,7 @@ import {
mkdir,
remove,
rename,
writeFile,
create,
} from '@tauri-apps/plugin-fs'
import { FILE_EXT, readProject } from 'lib/tauriFS'
import { isTauri } from 'lib/isTauri'
@ -84,12 +84,11 @@ export const FileMachineProvider = ({
if (event.data.makeDir) {
await mkdir(context.selectedDirectory.path + sep() + name)
} else {
await writeFile(
await create(
context.selectedDirectory.path +
sep() +
name +
(name.endsWith(FILE_EXT) ? '' : FILE_EXT),
''
)
}

View File

@ -1,3 +1,5 @@
export function isTauri(): boolean {
return '__TAURI__' in window
// return '__TAURI__' in window
// TODO: replace with working check
return true
}