Move shared code to core lib
This commit is contained in:
parent
e029e02cc2
commit
5343912699
35 changed files with 945 additions and 454 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
/target
|
||||
/*/target
|
||||
.data/*.log
|
||||
|
|
|
|||
1184
Cargo.lock
generated
1184
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -14,6 +14,6 @@
|
|||
# along with Deja-vu. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
[workspace]
|
||||
members = ["deja_vu", "pe_menu"]
|
||||
members = ["core", "deja_vu", "pe_menu"]
|
||||
description = "Clone/Install Windows, create/edit boot files, and troubleshoot boot issues."
|
||||
resolver = "2"
|
||||
|
|
|
|||
46
core/Cargo.toml
Normal file
46
core/Cargo.toml
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
[package]
|
||||
name = "core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
better-panic = "0.3.0"
|
||||
clap = { version = "4.4.5", features = [
|
||||
"derive",
|
||||
"cargo",
|
||||
"wrap_help",
|
||||
"unicode",
|
||||
"string",
|
||||
"unstable-styles",
|
||||
] }
|
||||
color-eyre = "0.6.3"
|
||||
config = "0.14.0"
|
||||
crossterm = { version = "0.28.1", features = ["serde", "event-stream"] }
|
||||
derive_deref = "1.1.1"
|
||||
directories = "5.0.1"
|
||||
futures = "0.3.30"
|
||||
human-panic = "2.0.1"
|
||||
json5 = "0.4.1"
|
||||
lazy_static = "1.5.0"
|
||||
libc = "0.2.158"
|
||||
once_cell = "1.20.2"
|
||||
pretty_assertions = "1.4.0"
|
||||
ratatui = { version = "0.28.1", features = ["serde", "macros"] }
|
||||
raw-cpuid = "11.2.0"
|
||||
regex = "1.11.1"
|
||||
serde = { version = "1.0.217", features = ["derive"] }
|
||||
serde_json = "1.0.125"
|
||||
signal-hook = "0.3.17"
|
||||
strip-ansi-escapes = "0.2.0"
|
||||
strum = { version = "0.26.3", features = ["derive"] }
|
||||
tempfile = "3.13.0"
|
||||
tokio = { version = "1.43.0", features = ["full"] }
|
||||
tokio-util = "0.7.11"
|
||||
tracing = "0.1.41"
|
||||
tracing-error = "0.2.0"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "serde"] }
|
||||
walkdir = "2.5.0"
|
||||
|
||||
[build-dependencies]
|
||||
anyhow = "1.0.86"
|
||||
vergen-gix = { version = "1.0.0", features = ["build", "cargo"] }
|
||||
28
core/build.rs
Normal file
28
core/build.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// This file is part of Deja-vu.
|
||||
//
|
||||
// Deja-vu is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Deja-vu is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Deja-vu. If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
use anyhow::Result;
|
||||
use vergen_gix::{BuildBuilder, CargoBuilder, Emitter, GixBuilder};
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let build = BuildBuilder::all_build()?;
|
||||
let gix = GixBuilder::all_git()?;
|
||||
let cargo = CargoBuilder::all_cargo()?;
|
||||
Emitter::default()
|
||||
.add_instructions(&build)?
|
||||
.add_instructions(&gix)?
|
||||
.add_instructions(&cargo)?
|
||||
.emit()
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ use ratatui::{
|
|||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
use super::Component;
|
||||
use crate::{action::Action, config::Config, state::Mode};
|
||||
use crate::{action::Action, config::Config};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Footer {
|
||||
|
|
@ -23,7 +23,7 @@ use strum::Display;
|
|||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
use super::Component;
|
||||
use crate::{action::Action, config::Config, state::Mode};
|
||||
use crate::{action::Action, config::Config};
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq, Display, Serialize, Deserialize)]
|
||||
pub enum Type {
|
||||
|
|
@ -37,7 +37,6 @@ pub enum Type {
|
|||
pub struct Popup {
|
||||
command_tx: Option<UnboundedSender<Action>>,
|
||||
config: Config,
|
||||
mode: Mode,
|
||||
popup_type: Type,
|
||||
popup_text: String,
|
||||
}
|
||||
|
|
@ -69,12 +68,6 @@ impl Component for Popup {
|
|||
self.popup_type = new_type;
|
||||
self.popup_text = new_text;
|
||||
}
|
||||
Action::SetMode(mode) => {
|
||||
if mode == Mode::ScanDisks {
|
||||
self.popup_text = String::from("Scanning Disks...");
|
||||
}
|
||||
self.mode = mode;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
Ok(None)
|
||||
|
|
@ -28,7 +28,7 @@ use tracing::error;
|
|||
|
||||
use crate::{action::Action, state::Mode};
|
||||
|
||||
const CONFIG: &str = include_str!("../config/config.json5");
|
||||
const CONFIG: &str = include_str!("../../config/config.json5");
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Default)]
|
||||
pub struct AppConfig {
|
||||
26
core/src/lib.rs
Normal file
26
core/src/lib.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// This file is part of Deja-vu.
|
||||
//
|
||||
// Deja-vu is free software: you can redistribute it and/or modify it
|
||||
// under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Deja-vu is distributed in the hope that it will be useful, but
|
||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Deja-vu. If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
pub mod action;
|
||||
pub mod cli;
|
||||
pub mod components;
|
||||
pub mod config;
|
||||
pub mod errors;
|
||||
pub mod line;
|
||||
pub mod logging;
|
||||
pub mod state;
|
||||
pub mod system;
|
||||
pub mod tasks;
|
||||
pub mod tui;
|
||||
|
|
@ -24,7 +24,8 @@ version = "0.2.0"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
better-panic = "0.3.0"
|
||||
core = { path = "../core" }
|
||||
color-eyre = "0.6.3"
|
||||
clap = { version = "4.4.5", features = [
|
||||
"derive",
|
||||
"cargo",
|
||||
|
|
@ -32,34 +33,15 @@ clap = { version = "4.4.5", features = [
|
|||
"unicode",
|
||||
"string",
|
||||
"unstable-styles",
|
||||
] }
|
||||
color-eyre = "0.6.3"
|
||||
config = "0.14.0"
|
||||
crossterm = { version = "0.28.1", features = ["serde", "event-stream"] }
|
||||
derive_deref = "1.1.1"
|
||||
directories = "5.0.1"
|
||||
futures = "0.3.30"
|
||||
human-panic = "2.0.1"
|
||||
json5 = "0.4.1"
|
||||
lazy_static = "1.5.0"
|
||||
libc = "0.2.158"
|
||||
once_cell = "1.20.2"
|
||||
pretty_assertions = "1.4.0"
|
||||
] }
|
||||
ratatui = { version = "0.28.1", features = ["serde", "macros"] }
|
||||
raw-cpuid = "11.2.0"
|
||||
regex = "1.11.1"
|
||||
serde = { version = "1.0.208", features = ["derive"] }
|
||||
serde = { version = "1.0.217", features = ["derive"] }
|
||||
serde_json = "1.0.125"
|
||||
signal-hook = "0.3.17"
|
||||
strip-ansi-escapes = "0.2.0"
|
||||
strum = { version = "0.26.3", features = ["derive"] }
|
||||
tempfile = "3.13.0"
|
||||
tokio = { version = "1.39.3", features = ["full"] }
|
||||
tokio = { version = "1.43.0", features = ["full"] }
|
||||
tokio-util = "0.7.11"
|
||||
tracing = "0.1.40"
|
||||
tracing = "0.1.41"
|
||||
tracing-error = "0.2.0"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "serde"] }
|
||||
walkdir = "2.5.0"
|
||||
|
||||
[build-dependencies]
|
||||
anyhow = "1.0.86"
|
||||
|
|
|
|||
|
|
@ -14,23 +14,7 @@
|
|||
// along with Deja-vu. If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
use std::{
|
||||
env,
|
||||
iter::zip,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use color_eyre::Result;
|
||||
use crossterm::event::KeyEvent;
|
||||
use ratatui::{
|
||||
layout::{Constraint, Direction, Layout},
|
||||
prelude::Rect,
|
||||
style::Color,
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::{debug, info};
|
||||
|
||||
use crate::{
|
||||
use core::{
|
||||
action::Action,
|
||||
components::{
|
||||
footer::Footer, fps::FpsCounter, left::Left, popup, right::Right, state::StatefulList,
|
||||
|
|
@ -46,6 +30,21 @@ use crate::{
|
|||
tasks::{Task, Tasks},
|
||||
tui::{Event, Tui},
|
||||
};
|
||||
use std::{
|
||||
env,
|
||||
iter::zip,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use color_eyre::Result;
|
||||
use ratatui::{
|
||||
crossterm::event::KeyEvent,
|
||||
layout::{Constraint, Direction, Layout},
|
||||
prelude::Rect,
|
||||
style::Color,
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
use tracing::{debug, info};
|
||||
|
||||
pub struct App {
|
||||
// TUI
|
||||
|
|
@ -151,6 +150,10 @@ impl App {
|
|||
if self.tasks.idle() {
|
||||
self.tasks.add(Task::ScanDisks);
|
||||
}
|
||||
self.action_tx.send(Action::DisplayPopup(
|
||||
popup::Type::Info,
|
||||
String::from("Scanning Disks..."),
|
||||
))?;
|
||||
}
|
||||
Mode::PreClone => {
|
||||
self.action_tx.send(Action::DisplayPopup(
|
||||
|
|
|
|||
|
|
@ -14,31 +14,19 @@
|
|||
// along with Deja-vu. If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
use clap::Parser;
|
||||
use cli::Cli;
|
||||
use color_eyre::Result;
|
||||
use core;
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
mod action;
|
||||
mod app;
|
||||
mod cli;
|
||||
mod components;
|
||||
mod config;
|
||||
mod errors;
|
||||
mod line;
|
||||
mod logging;
|
||||
mod state;
|
||||
mod system;
|
||||
mod tasks;
|
||||
mod tests;
|
||||
mod tui;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
crate::errors::init()?;
|
||||
crate::logging::init()?;
|
||||
core::errors::init()?;
|
||||
core::logging::init()?;
|
||||
|
||||
let args = Cli::parse();
|
||||
let args = core::cli::Cli::parse();
|
||||
let mut app = App::new(args.tick_rate, args.frame_rate)?;
|
||||
app.run().await?;
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Reference in a new issue