Skip to content

Commit

Permalink
Overhaul the project structure with new design based on git as backend.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Roy committed Aug 19, 2024
1 parent ff92b8f commit 1b9b1b0
Show file tree
Hide file tree
Showing 60 changed files with 151 additions and 121 deletions.
41 changes: 6 additions & 35 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["gawires-gist"]
members = ["gist", "central", "core"]

[package]
name = "gawires"
Expand All @@ -13,45 +13,16 @@ default-run = "gaw"

[[bin]]
name = "gaw"
path = "src/main.rs"
path = "src/bin/gaw.rs"

[lib]
name = "gawires"
path = "src/lib.rs"



[dependencies]
notify = "6.1.1"
libloading = "0.8.5"
gawires-gist ={ path = "./gist"}
gawires-core ={ path = "./core"}
gawires-central ={ path = "./central"}

clap = {version = "4.5.15", features = ["derive"]}
paw = "1.0.0"
interprocess = "2.2.1"
dirs = "5.0.1"
petgraph = "0.6.5"
blake2 = "0.10.6"

# Specific dependencies for the gawires kernel
gawires-diff = { git = "https://github.com/metakernel/gawires-diff"}
gawires-patch = { git = "https://github.com/metakernel/gawires-diff"}

[dependencies.uuid]
version = "1.10.0"
features = [
"v4", # Lets you generate random UUIDs
"fast-rng", # Use a faster (but still sufficiently random) RNG
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
]


[target.'cfg(unix)'.dependencies]
# Used for the filesystem in linux and macos
fuser = "0.14.0"

[target.'cfg(windows)'.dependencies]
# Used for the filesystem in windows
dokan = "0.3.1+dokan206"
windows = "0.58.0"

[target.'cfg(windows)'.build-dependencies]
windows = "0.58.0"
10 changes: 10 additions & 0 deletions central/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "gawires-central"
version = "0.1.0"
edition = "2021"

[lib]
name = "gwclib"
path = "src/lib.rs"

[dependencies]
14 changes: 14 additions & 0 deletions central/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: u64, right: u64) -> u64 {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
38 changes: 38 additions & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[package]
name = "gawires-core"
version = "0.1.0"
edition = "2021"

[dependencies]
notify = "6.1.1"
libloading = "0.8.5"
interprocess = "2.2.1"
dirs = "5.0.1"
petgraph = "0.6.5"
blake2 = "0.10.6"

# Specific dependencies for the gawires kernel
gawires-diff = { git = "https://github.com/metakernel/gawires-diff"}
gawires-patch = { git = "https://github.com/metakernel/gawires-diff"}
git2 = "0.19.0"

[dependencies.uuid]
version = "1.10.0"
features = [
"v4", # Lets you generate random UUIDs
"fast-rng", # Use a faster (but still sufficiently random) RNG
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
]


[target.'cfg(unix)'.dependencies]
# Used for the filesystem in linux and macos
fuser = "0.14.0"

[target.'cfg(windows)'.dependencies]
# Used for the filesystem in windows
dokan = "0.3.1+dokan206"
windows = "0.58.0"

[target.'cfg(windows)'.build-dependencies]
windows = "0.58.0"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions src/core.rs → core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
pub mod repository;
pub mod workspace;
pub mod workpod;
pub mod user;
pub mod arenatree;
pub mod config;
pub mod tree;
pub mod asset;
pub mod extension;
pub mod filesystem;
pub mod process;
pub mod wire;
pub mod diff;
pub mod wire;
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/core/repository.rs → core/src/repository.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::workspace::Workspace;
use super::workpod::Workpod;

use super::user::UserStamp;

Expand All @@ -13,7 +13,7 @@ pub struct Repository<'a> {
/// Repository owner.
pub owner: UserStamp,
/// Ref of repository workplaces.
pub workspaces: Vec<&'a Workspace<'a>>,
pub workpods: Vec<&'a Workpod<'a>>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion src/core/user.rs → core/src/user.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::core::config::user_config::UserConfig;
use crate::config::user_config::UserConfig;

/// A User Stamp is some informations used to identify a user in the system.
#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions core/src/workpod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// In Gawires a Workpod is a slice of a project that can be worked on independently, each Workpod can act on a subset of the project assets.
/// From a local perspective a gawires Workpod is a folder that contains assets and a .gaw folder that contains the Workpod configuration and metadata.

use crate::repository::{Repository, Remote};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Workpod<'a> {
pub name: String,
pub owning_project: Repository<'a>,
pub workpod_type: WorkpodType,
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum WorkpodType {
Central,
Clone,
}

pub enum WorkpodError {
WorkpodNotFound,
}

pub enum WorkpodState {
Connected(Remote),
Offline,
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions src/main.rs → src/bin/gaw.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
mod cli;
use paw::Args;
pub use clap::Parser;

use crate::cli::Cli;
use crate::cli::handling::handle_cmds;
use gawires::cli::Cli;
use gawires::cli::handling::handle_cmds;

/// The main entry point for Gawires.
#[paw::main]
Expand Down
8 changes: 8 additions & 0 deletions src/bin/gwc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use paw::Args;
pub use clap::Parser;

/// The main entry point for Gawires.
#[paw::main]
fn main(_args: Args) {
//println!("{:#?}", opt);
}
77 changes: 38 additions & 39 deletions src/cli/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@ use clap::{Parser,Subcommand};
/// Enum of all possible subcommands
#[derive(Debug, PartialEq,Subcommand)]
pub enum Commands{
Add(Add), // Add new assets or changes to the workspace, add tags and other operations.
Checkout(Checkout), // Checkout contents from a remote workspace.
Release(Release), // Release a workspace
Init(Init), // Initialize a connection to a remote project or workspace(For a centralized workflow).
Sync(Sync), // Sync the workspace with the distant repository (Will Pull & Push for a distributed workflow).
Clone(Clone), // Clone a remote workspace locally, it will clone a complete copy of it.
Status(Status), // Display the status of the local workspace
Layout(Layout), // Change or create content layout for the workspace (This enables to switch between different layout for the same workspace)
Push(Push), // Push the local workspace changes to the distant repository
Pull(Pull), // Pull the distant repository changes to the local workspace
Workspace(Workspace), // Display the workspace information or create/change to another workspace.
Add(Add), // Add new assets or changes to the workpod, add tags and other operations.
Checkout(Checkout), // Checkout contents from a remote workpod.
Init(Init), // Initialize a connection to a remote project or workpod(For a centralized workflow).
Sync(Sync), // Sync the workpod with the distant repository (Will Pull & Push for a distributed workflow).
Clone(Clone), // Clone a remote workpod locally, it will clone a complete copy of it.
Status(Status), // Display the status of the local workpod
Layout(Layout), // Change or create content layout for the workpod (This enables to switch between different layout for the same workpod)
Push(Push), // Push the local workpod changes to the distant repository
Pull(Pull), // Pull the distant repository changes to the local workpod
Workpod(Workpod), // Display the workpod information or create/change to another workpod.
Preview(Preview), // Preview and compare different commit or assets
Reset(Reset), // Reset the local workspace to a specific commit (If non use the latest), can use --preserve to keep the local changes or --overwrite to delete them.
Remove(Remove), // Remove a file or folder from the local workspace
Branch(Branch), // Create a new branch inside the workspace
Reset(Reset), // Reset objects in local workpod to a specific commit (If non use the latest), can use --preserve to keep the local changes or --overwrite to delete them.
Remove(Remove), // Remove a file or folder from the local workpod
Branch(Branch), // Create a new branch inside the workpod
Wire(Wire), // Commands related to Wires creation and configuration. Wires are bound to assets and can be used to specify how those assets are handled.
Connect(Connect), // Start a LiveWire connection beetween local and remote workspace.
Filter(Filter), // Filter files or folders in the workspace or project and return the filtered list
Rebase(Rebase), // Rebase a workspace branch on another branch
Merge(Merge), // Merge a workspace branch on another branch
Clean(Clean), // Clean the workspace
Connect(Connect), // Start a LiveWire connection beetween local and remote workpod.
Filter(Filter), // Filter files or folders in the workpod or project and return the filtered list
Rebase(Rebase), // Rebase a workpod branch on another branch
Merge(Merge), // Merge a workpod branch on another branch
Clean(Clean), // Clean the workpod
Project(Project),
Install(Install),
Uninstall(Uninstall),
Expand All @@ -38,7 +37,7 @@ use clap::{Parser,Subcommand};
pub struct Add{
/// Tracks new file
pub path: Option<std::path::PathBuf>,
/// Stage all changes in workspace that are not ignored
/// Stage all changes in workpod that are not ignored
#[arg(short = 'a', long = "all")]
pub all: bool,
/// Stop tracking the assets from a given path
Expand All @@ -50,58 +49,58 @@ use clap::{Parser,Subcommand};
pub tag_name: Option<Vec<String>>,
}

/// Checkout assets in local workspace from a source like . When assets are checkout, they are locked by default when in centralized mode.
/// Checkout assets in local workpod from a source like . When assets are checkout, they are locked by default when in centralized mode.
#[derive(Debug, PartialEq, Parser)]
pub struct Checkout{
/// Specific assets or complete directory structure can be checkout
pub path: Option<std::path::PathBuf>,
/// Option use to specify if a lock should be put on the assets, this will tell central to lock them. (On by default if centralized, WARNING: If not set to lock you should clone the workspace instead "gawires checkout --clone" if you dont want any conflict issues)
/// Option use to specify if a lock should be put on the assets, this will tell central to lock them. (On by default if centralized, WARNING: If not set to lock you should clone the workpod instead "gawires checkout --clone" if you dont want any conflict issues)
#[clap(name = "Lock",short = 'l', long = "lock")]
pub lock_remote: Option<bool>,
/// Can be use to specify that the checkout must clone the assets instead of synchronizing them.(Will need to initiate a push request each time you try to synchronize)
pub clone: Option<bool>,

}
/// Release checkout assets from local workspace.
/// Release checkout assets from local workpod.
#[derive(Debug, PartialEq, Parser)]
pub struct Release{
}
/// Initialize a new local workspace that can be connected to a project
/// Initialize a new local workpod that can be connected to a project
#[derive(Debug, PartialEq, Parser)]
pub struct Init{
}

/// While used in a distributed workspace this will fetch the remote, while in centralized workspace this will synchronize local workspace state with remote.
/// While used in a distributed workpod this will fetch the remote, while in centralized workpod this will synchronize local workpod state with remote.
#[derive(Debug, PartialEq, Parser)]
pub struct Sync{
}

/// Log and fetch information about local workspace
/// Log and fetch information about local workpod
#[derive(Debug, PartialEq, Parser)]
pub struct Status{
}

/// Change or create content layout for the workspace (This enables to switch between different layout for the same workspace)
/// Change or create content layout for the workpod (This enables to switch between different layout for the same workpod)
#[derive(Debug, PartialEq, Parser)]
pub struct Layout{
}

/// Used in a distributed workspace to push local changes to remote, will use Sync in centralized.
/// Used in a distributed workpod to push local changes to remote, will use Sync in centralized.
#[derive(Debug, PartialEq, Parser)]
pub struct Push{
}

/// Used in a distributed workspace to pull localy changes from remote, will use Sync in centralized.
/// Used in a distributed workpod to pull localy changes from remote, will use Sync in centralized.
#[derive(Debug, PartialEq, Parser)]
pub struct Pull{
}

/// Commands to manage workspace, change or create workspace layout and other operations.
/// Commands to manage workpod, change or create workpod layout and other operations.
#[derive(Debug, PartialEq, Parser)]
pub struct Workspace{
pub struct Workpod{
}

/// Clone a remote workspace locally, it will clone a complete copy of it.
/// Clone a remote workpod locally, it will clone a complete copy of it.
#[derive(Debug, PartialEq, Parser)]
pub struct Clone{
}
Expand All @@ -111,7 +110,7 @@ use clap::{Parser,Subcommand};
pub struct Preview{
}

/// Reset workspace assets to an earlier state
/// Reset workpod assets to an earlier state
#[derive(Debug, PartialEq, Parser)]
pub struct Reset{
}
Expand All @@ -132,7 +131,7 @@ use clap::{Parser,Subcommand};
pub struct Wire{
}

/// Connect and sync a Centralized Workspace.
/// Connect and sync a Centralized Workpod.
#[derive(Debug, PartialEq, Parser)]
pub struct Connect{
}
Expand All @@ -143,17 +142,17 @@ use clap::{Parser,Subcommand};
}


/// Rebase a branch or a centralized workspace
/// Rebase a branch or a centralized workpod
#[derive(Debug, PartialEq, Parser)]
pub struct Rebase{
}

/// Merge changes between 2 branches or centralized workspaces
/// Merge changes between 2 branches or centralized workpods
#[derive(Debug, PartialEq, Parser)]
pub struct Merge{
}

/// Cleanup tools for local workspace
/// Cleanup tools for local workpod
#[derive(Debug, PartialEq, Parser)]
pub struct Clean{
}
Expand All @@ -163,12 +162,12 @@ use clap::{Parser,Subcommand};
pub struct Project{
}

/// Install a Gawire extension in current workspace.
/// Install a Gawire extension in current workpod.
#[derive(Debug, PartialEq, Parser)]
pub struct Install{
}

/// Uninstall a Gawire extension in current workspace.
/// Uninstall a Gawire extension in current workpod.
#[derive(Debug, PartialEq, Parser)]
pub struct Uninstall{
}
Expand Down
Loading

0 comments on commit 1b9b1b0

Please sign in to comment.