made the install script download the note_templates and default-modules.
This commit is contained in:
Generated
+7
@@ -1261,6 +1261,12 @@ version = "0.3.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fs_extra"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures"
|
name = "futures"
|
||||||
version = "0.3.32"
|
version = "0.3.32"
|
||||||
@@ -3889,6 +3895,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
|
"fs_extra",
|
||||||
"iced",
|
"iced",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"rayon",
|
"rayon",
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ edition = "2024"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "4.6.1", features = ["derive"] }
|
clap = { version = "4.6.1", features = ["derive"] }
|
||||||
crossterm = "0.29.0"
|
crossterm = "0.29.0"
|
||||||
|
fs_extra = "1.3.0"
|
||||||
iced = { version = "0.14.0", features = ["advanced", "tokio"] }
|
iced = { version = "0.14.0", features = ["advanced", "tokio"] }
|
||||||
ratatui = "0.30.0"
|
ratatui = "0.30.0"
|
||||||
rayon = "1.12.0"
|
rayon = "1.12.0"
|
||||||
|
|||||||
+36
-4
@@ -1,8 +1,10 @@
|
|||||||
|
use fs_extra::dir::{CopyOptions, copy, create};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fs::{File, create_dir_all};
|
use std::fs::{File, create_dir_all, read_dir, remove_dir_all};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::process::Command;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use tetanus::funcs::get_user_input;
|
use tetanus::funcs::get_user_input;
|
||||||
|
|
||||||
@@ -10,12 +12,16 @@ pub fn install() -> Result<(), Box<dyn Error>> {
|
|||||||
if let Some(homedir) = env::home_dir() {
|
if let Some(homedir) = env::home_dir() {
|
||||||
let mut config_path = homedir.clone();
|
let mut config_path = homedir.clone();
|
||||||
config_path.push(".config/tetanus");
|
config_path.push(".config/tetanus");
|
||||||
|
let root_config_folder_path = config_path.clone();
|
||||||
let mut projects_path = config_path.clone();
|
let mut projects_path = config_path.clone();
|
||||||
projects_path.push("projects");
|
projects_path.push("projects");
|
||||||
let mut module_path = config_path.clone();
|
let mut module_path = config_path.clone();
|
||||||
module_path.push("modules/default");
|
module_path.push("modules");
|
||||||
|
let default_module_path = module_path.join("default");
|
||||||
|
create_dir_all(&default_module_path)?;
|
||||||
|
let mut note_templates_path = config_path.clone();
|
||||||
|
note_templates_path.push("note_templates");
|
||||||
create_dir_all(&module_path)?;
|
create_dir_all(&module_path)?;
|
||||||
module_path.pop();
|
|
||||||
module_path.push("custom");
|
module_path.push("custom");
|
||||||
create_dir_all(&module_path)?;
|
create_dir_all(&module_path)?;
|
||||||
module_path.pop();
|
module_path.pop();
|
||||||
@@ -44,7 +50,7 @@ pub fn install() -> Result<(), Box<dyn Error>> {
|
|||||||
let mut default_project_file = File::create(projects_path)?;
|
let mut default_project_file = File::create(projects_path)?;
|
||||||
config_path.pop();
|
config_path.pop();
|
||||||
config_path.push("server.conf");
|
config_path.push("server.conf");
|
||||||
let mut server_config_file = File::create(config_path)?;
|
let mut server_config_file = File::create(&config_path)?;
|
||||||
server_config_file.write("address: 127.0.0.1:31337\n".as_bytes())?;
|
server_config_file.write("address: 127.0.0.1:31337\n".as_bytes())?;
|
||||||
server_config_file.write("running: false\n".as_bytes())?;
|
server_config_file.write("running: false\n".as_bytes())?;
|
||||||
default_project_file.write("org_name: default\n".as_bytes())?;
|
default_project_file.write("org_name: default\n".as_bytes())?;
|
||||||
@@ -64,6 +70,32 @@ pub fn install() -> Result<(), Box<dyn Error>> {
|
|||||||
.write(format!("upcoming_notes: {}\n", upcoming_notes_path.display()).as_bytes())?;
|
.write(format!("upcoming_notes: {}\n", upcoming_notes_path.display()).as_bytes())?;
|
||||||
client_config_file.write(format!("module_path: {}\n", module_path.display()).as_bytes())?;
|
client_config_file.write(format!("module_path: {}\n", module_path.display()).as_bytes())?;
|
||||||
client_config_file.write(format!("template_box: {}\n", template_box).as_bytes())?;
|
client_config_file.write(format!("template_box: {}\n", template_box).as_bytes())?;
|
||||||
|
println!("\ndefault config files written!");
|
||||||
|
println!("downloading default notes and modules...");
|
||||||
|
create_dir_all("./temp")?;
|
||||||
|
env::set_current_dir("./temp")?;
|
||||||
|
let (git_clone_status) = Command::new("git")
|
||||||
|
.arg("clone")
|
||||||
|
.arg("https://git.pyro.monster/pyro/tetanus.git")
|
||||||
|
.status()?
|
||||||
|
.success();
|
||||||
|
if git_clone_status {
|
||||||
|
let mut options = CopyOptions::new();
|
||||||
|
options.overwrite = true;
|
||||||
|
println!("copying note_templates...");
|
||||||
|
copy(
|
||||||
|
"./tetanus/note_templates",
|
||||||
|
root_config_folder_path,
|
||||||
|
&options,
|
||||||
|
)?;
|
||||||
|
println!("copying default-modules...");
|
||||||
|
for entry in read_dir("./tetanus/default-modules")? {
|
||||||
|
let entry = entry?;
|
||||||
|
copy(entry.path(), default_module_path.clone(), &options)?;
|
||||||
|
}
|
||||||
|
env::set_current_dir("../")?;
|
||||||
|
remove_dir_all("./temp")?;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
eprintln!("error finding home directory!");
|
eprintln!("error finding home directory!");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user