new structure

This commit is contained in:
Nikita Galaiko 2023-09-06 10:46:07 +02:00
parent fe5ebcca83
commit 746e8ccabc
No known key found for this signature in database
GPG Key ID: EBAB54E845BA519D
439 changed files with 6643 additions and 7350 deletions

View File

@ -3,8 +3,8 @@ description: Determine what kind of change has taken place
inputs: inputs:
runs-on: runs-on:
description: | description: |
Filter by project type, must be named filter from step `changes` Filter by project type, must be named filter from step `changes`
default: 'all' default: "all"
outputs: outputs:
frontend: frontend:
description: "Change affects front end" description: "Change affects front end"
@ -13,7 +13,7 @@ outputs:
description: "Change affects back end" description: "Change affects back end"
value: ${{ steps.backend.outputs.value }} value: ${{ steps.backend.outputs.value }}
runs: runs:
using: 'composite' using: "composite"
steps: steps:
- name: Getting changes - name: Getting changes
id: changes id: changes
@ -21,16 +21,14 @@ runs:
with: with:
filters: | filters: |
backend: backend:
- 'src-tauri/**' - 'packages/tauri/**'
- 'butler/**' - 'packages/butler/**'
- 'Cargo.lock'
frontend: frontend:
- 'src/**' - 'packages/ui/**'
- '.github/**' - '.github/**'
- 'package.json' - 'package.json'
- '*.config.*' - 'pnpm-lock.yaml'
- 'tsconfig.json'
- '.npmrc'
- '.env.*'
- id: frontend - id: frontend
run: echo "value=${{ steps.changes.outputs.frontend}}" >> $GITHUB_OUTPUT run: echo "value=${{ steps.changes.outputs.frontend}}" >> $GITHUB_OUTPUT
@ -51,7 +49,7 @@ runs:
name: Setup node name: Setup node
if: ${{ inputs.runs-on == 'all' || steps.changes.outputs[inputs.runs-on] == 'true' }} if: ${{ inputs.runs-on == 'all' || steps.changes.outputs[inputs.runs-on] == 'true' }}
with: with:
node-version: '18' node-version: "18"
cache: pnpm cache: pnpm
- name: Get pnpm store directory - name: Get pnpm store directory

View File

@ -68,7 +68,6 @@ jobs:
- run: cargo fmt --check - run: cargo fmt --check
if: ${{ steps.init.outputs.backend == 'true' }} if: ${{ steps.init.outputs.backend == 'true' }}
working-directory: src-tauri
story: story:
@ -108,8 +107,6 @@ jobs:
- name: Cache rust dependencies - name: Cache rust dependencies
if: ${{ steps.init.outputs.backend == 'true' }} if: ${{ steps.init.outputs.backend == 'true' }}
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- run: sudo apt-get update - run: sudo apt-get update
if: ${{ steps.init.outputs.backend == 'true' && runner.os == 'Linux' }} if: ${{ steps.init.outputs.backend == 'true' && runner.os == 'Linux' }}
@ -130,9 +127,7 @@ jobs:
- run: cargo clippy --all-features - run: cargo clippy --all-features
if: ${{ steps.init.outputs.backend == 'true' }} if: ${{ steps.init.outputs.backend == 'true' }}
working-directory: src-tauri
- name: Test rust - name: Test rust
if: ${{ steps.init.outputs.backend == 'true' }} if: ${{ steps.init.outputs.backend == 'true' }}
working-directory: src-tauri
run: cargo test --locked run: cargo test --locked

41
.gitignore vendored
View File

@ -1,41 +1,10 @@
# Logs # will have compiled rust files and executables
logs /target/
*.log /node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules # editors
dist
dist-ssr
*.local
# Editor directories and files
.vscode/* .vscode/*
!.vscode/extensions.json !.vscode/extensions.json
.idea .idea
.DS_Store .DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
/build
/.svelte-kit
/package
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
# gitbutler
.git/gb-*
src-tauri/data.txt
/.histoire
# Written to disk when using `act`
.pnpm-store

File diff suppressed because it is too large Load Diff

10
Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[workspace]
members = [
"packages/butler",
"packages/tauri",
]
[profile.release]
codegen-units = 1 # Compile crates one after another so the compiler can optimize better
lto = true # Enables link to optimizations
opt-level = "s" # Optimize for binary size

View File

@ -47,7 +47,6 @@ $ pnpm format
Rust: Rust:
```bash ```bash
$ cd ./src-tauri
$ cargo clippy # see linting errors $ cargo clippy # see linting errors
$ cargo fmt # format code $ cargo fmt # format code
``` ```
@ -83,7 +82,7 @@ We are also collecting tokio's runtime tracing information that could be viewed
To build the app in production mode, run: To build the app in production mode, run:
```bash ```bash
$ pnpm tauri build --features devtools --config src-tauri/tauri.conf.nightly.json $ pnpm tauri build --features devtools --config packages/tauri/tauri.conf.nightly.json
``` ```
This will make an asset similar to our nightly build. This will make an asset similar to our nightly build.

View File

@ -1,102 +1,20 @@
{ {
"name": "git-butler-tauri", "name": "git-butler-tauri",
"private": true, "private": true,
"version": "0.0.0", "scripts": {
"type": "module", "dev": "pnpm --filter @gitbutler/ui run dev",
"scripts": { "test": "pnpm --filter @gitbutler/ui run test",
"dev": "vite dev", "build": "pnpm --filter @gitbutler/ui run build",
"test": "vitest run --mode development", "check": "pnpm --filter @gitbutler/ui run check",
"build": "vite build", "lint": "pnpm --filter @gitbutler/ui run lint",
"check": "svelte-check --tsconfig ./tsconfig.json", "format": "pnpm --filter @gitbutler/ui run format",
"check:watch": "pnpm check --watch", "tauri": "tauri",
"lint": "prettier --plugin-search-dir . --check . && eslint .", "prepare": "pnpm --filter @gitbutler/ui run prepare",
"format": "prettier --plugin-search-dir . --write .", "story:dev": "pnpm --filter @gitbutler/ui run story:dev",
"tauri": "tauri", "story:build": "pnpm --filter @gitbutler/ui run story:build",
"story:dev": "histoire dev --open", "story:preview": "pnpm --filter @gitbutler/ui run story:preview"
"prepare": "svelte-kit sync", },
"story:build": "histoire build", "devDependencies": {
"story:preview": "histoire preview --open" "@tauri-apps/cli": "^1.4.0"
}, }
"devDependencies": {
"@codemirror/lang-cpp": "^6.0.2",
"@codemirror/lang-css": "^6.2.1",
"@codemirror/lang-html": "^6.4.6",
"@codemirror/lang-java": "^6.0.1",
"@codemirror/lang-javascript": "^6.2.1",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lang-markdown": "^6.2.0",
"@codemirror/lang-php": "^6.0.1",
"@codemirror/lang-python": "^6.1.3",
"@codemirror/lang-rust": "^6.0.1",
"@codemirror/lang-vue": "^0.1.2",
"@codemirror/lang-wast": "^6.0.1",
"@codemirror/lang-xml": "^6.0.2",
"@codemirror/language": "^6.9.0",
"@codemirror/state": "^6.2.1",
"@codemirror/view": "^6.16.0",
"@histoire/plugin-svelte": "^0.16.5",
"@lezer/common": "^1.0.4",
"@lezer/highlight": "^1.1.6",
"@replit/codemirror-lang-svelte": "^6.0.0",
"@sentry/sveltekit": "^7.64.0",
"@square/svelte-store": "git+https://git@github.com/gitbutlerapp/svelte-store.git",
"@sveltejs/adapter-static": "^2.0.3",
"@sveltejs/kit": "^1.23.0",
"@tauri-apps/api": "^1.4.0",
"@tauri-apps/cli": "^1.4.0",
"@types/crypto-js": "^4.1.1",
"@types/diff": "^5.0.3",
"@types/diff-match-patch": "^1.0.32",
"@types/lscache": "^1.3.1",
"@types/marked": "^5.0.1",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"autoprefixer": "^10.4.15",
"class-transformer": "^0.5.1",
"crypto-js": "^4.1.1",
"date-fns": "^2.30.0",
"diff-match-patch": "^1.0.5",
"eslint": "^8.47.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-square-svelte-store": "^1.0.0",
"eslint-plugin-svelte": "^2.33.0",
"histoire": "^0.16.5",
"inter-ui": "^3.19.3",
"leven": "^4.0.0",
"lscache": "^1.3.2",
"marked": "^7.0.4",
"mm-jsr": "^3.0.2",
"nanoevents": "^8.0.0",
"nanoid": "^4.0.2",
"postcss": "^8.4.28",
"postcss-load-config": "^4.0.1",
"posthog-js": "^1.77.2",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"prettier-plugin-tailwindcss": "^0.3.0",
"reflect-metadata": "^0.1.13",
"svelte": "^4.2.0",
"svelte-check": "^3.5.0",
"svelte-floating-ui": "^1.5.3",
"svelte-french-toast": "^1.2.0",
"svelte-loadable-store": "^2.0.1",
"svelte-outclick": "^3.6.2",
"svelte-resize-observer": "^2.0.0",
"tailwindcss": "^3.3.3",
"tauri-plugin-log-api": "git+https://git@github.com/tauri-apps/tauri-plugin-log.git",
"tauri-plugin-websocket-api": "git+https://git@github.com/tauri-apps/tauri-plugin-websocket.git",
"tinykeys": "^1.4.0",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vitest": "^0.34.3",
"xterm": "^5.2.1",
"xterm-addon-canvas": "^0.4.0",
"xterm-addon-fit": "^0.7.0",
"xterm-addon-ligatures": "^0.6.0",
"xterm-addon-unicode11": "^0.5.0",
"xterm-addon-webgl": "^0.15.0"
}
} }

View File

@ -15,4 +15,4 @@ colored = "2.0.0"
clap = { version = "4.0", features = ["derive"] } clap = { version = "4.0", features = ["derive"] }
dialoguer = "0.10.4" dialoguer = "0.10.4"
anyhow = "1.0.71" anyhow = "1.0.71"
git-butler-tauri = { path = "../src-tauri" } gitbutler = { path = "../tauri" }

View File

@ -1,13 +1,13 @@
use std::path;
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use git2::Repository; use git2::Repository;
use git_butler_tauri::{ use gitbutler::{database, gb_repository, project_repository, projects, sessions, storage, users};
database, gb_repository, project_repository, projects, sessions, storage, users,
};
pub struct App { pub struct App {
path: String, path: String,
local_data_dir: String, local_data_dir: path::PathBuf,
project: projects::Project, project: projects::Project,
gb_repository: gb_repository::Repository, gb_repository: gb_repository::Repository,
sessions_db: sessions::Database, sessions_db: sessions::Database,
@ -18,10 +18,10 @@ impl App {
let path = find_git_directory().context("failed to find project directory")?; let path = find_git_directory().context("failed to find project directory")?;
let local_data_dir = find_local_data_dir().context("could not find local data dir")?; let local_data_dir = find_local_data_dir().context("could not find local data dir")?;
let storage = storage::Storage::from_path(local_data_dir.clone()); let storage = storage::Storage::from(&local_data_dir);
let users_storage = users::Storage::new(storage.clone()); let users_storage = users::Storage::from(storage.clone());
let projects_storage = projects::Storage::new(storage); let projects_storage = projects::Storage::try_from(storage)?;
let projects = projects_storage let projects = projects_storage
.list_projects() .list_projects()
.context("failed to list projects")?; .context("failed to list projects")?;
@ -32,16 +32,16 @@ impl App {
.context("failed to find project")?; .context("failed to find project")?;
let gb_repository = gb_repository::Repository::open( let gb_repository = gb_repository::Repository::open(
local_data_dir.clone(), &local_data_dir,
project.id.clone(), &project.id,
projects_storage, projects_storage,
users_storage, users_storage,
) )
.context("failed to open repository")?; .context("failed to open repository")?;
let db_path = std::path::Path::new(&local_data_dir).join("database.sqlite3"); let db_path = std::path::Path::new(&local_data_dir).join("database.sqlite3");
let database = database::Database::open(db_path).context("failed to open database")?; let database = database::Database::try_from(&db_path).context("failed to open database")?;
let sessions_db = sessions::Database::new(database); let sessions_db = sessions::Database::from(database);
Ok(Self { Ok(Self {
path, path,
@ -56,7 +56,7 @@ impl App {
&self.path &self.path
} }
pub fn local_data_dir(&self) -> &str { pub fn local_data_dir(&self) -> &path::PathBuf {
&self.local_data_dir &self.local_data_dir
} }
@ -91,8 +91,8 @@ fn find_git_directory() -> Option<String> {
} }
} }
fn find_local_data_dir() -> Option<String> { fn find_local_data_dir() -> Option<path::PathBuf> {
let mut path = dirs::config_dir().unwrap(); let mut path = dirs::config_dir().unwrap();
path.push("com.gitbutler.app.dev"); path.push("com.gitbutler.app.dev");
Some(path.to_string_lossy().to_string()) Some(path::PathBuf::from(path.to_string_lossy().to_string()))
} }

View File

@ -2,7 +2,7 @@ use anyhow::{Context, Result};
use clap::Args; use clap::Args;
use colored::Colorize; use colored::Colorize;
use git_butler_tauri::virtual_branches; use gitbutler::virtual_branches;
use crate::app::App; use crate::app::App;

View File

@ -1,7 +1,7 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use clap::Args; use clap::Args;
use git_butler_tauri::{sessions, virtual_branches}; use gitbutler::{sessions, virtual_branches};
use crate::app::App; use crate::app::App;

View File

@ -3,7 +3,7 @@ use clap::Args;
use colored::Colorize; use colored::Colorize;
use dialoguer::{console::Term, theme::ColorfulTheme, Input, Select}; use dialoguer::{console::Term, theme::ColorfulTheme, Input, Select};
use git_butler_tauri::{reader, sessions, virtual_branches}; use gitbutler::{reader, sessions, virtual_branches};
use crate::app::App; use crate::app::App;

View File

@ -2,7 +2,7 @@ use anyhow::{Context, Result};
use clap::Args; use clap::Args;
use colored::Colorize; use colored::Colorize;
use git_butler_tauri::{reader, sessions, virtual_branches}; use gitbutler::{reader, sessions, virtual_branches};
use crate::app::App; use crate::app::App;
@ -15,7 +15,10 @@ impl super::RunCommand for Info {
// just print information for the project // just print information for the project
println!("path: {}", app.path().yellow()); println!("path: {}", app.path().yellow());
println!("data_dir: {}", app.local_data_dir().yellow()); println!(
"data_dir: {}",
app.local_data_dir().display().to_string().yellow()
);
// find the project in project storage that matches the cwd // find the project in project storage that matches the cwd
println!("{}", "project:".to_string().red()); println!("{}", "project:".to_string().red());

View File

@ -2,7 +2,7 @@ use anyhow::{Context, Result};
use clap::Args; use clap::Args;
use dialoguer::{console::Term, theme::ColorfulTheme, MultiSelect, Select}; use dialoguer::{console::Term, theme::ColorfulTheme, MultiSelect, Select};
use git_butler_tauri::{reader, sessions, virtual_branches}; use gitbutler::{reader, sessions, virtual_branches};
use crate::app::App; use crate::app::App;
@ -74,7 +74,7 @@ impl super::RunCommand for Move {
ownership.put( ownership.put(
&selected_files &selected_files
.join("\n") .join("\n")
.try_into() .parse()
.context("failed to convert to ownership")?, .context("failed to convert to ownership")?,
); );

View File

@ -2,7 +2,7 @@ use anyhow::{Context, Result};
use clap::Args; use clap::Args;
use dialoguer::{theme::ColorfulTheme, Input}; use dialoguer::{theme::ColorfulTheme, Input};
use git_butler_tauri::virtual_branches; use gitbutler::virtual_branches;
use crate::app::App; use crate::app::App;

View File

@ -1,7 +1,7 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use clap::Args; use clap::Args;
use git_butler_tauri::virtual_branches; use gitbutler::virtual_branches;
use crate::app::App; use crate::app::App;

View File

@ -1,7 +1,7 @@
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use clap::Args; use clap::Args;
use git_butler_tauri::{reader, sessions, virtual_branches}; use gitbutler::{reader, sessions, virtual_branches};
use crate::app::App; use crate::app::App;

View File

@ -2,6 +2,7 @@ use anyhow::{Context, Result};
use clap::Args; use clap::Args;
use colored::Colorize; use colored::Colorize;
use dialoguer::{console::Term, theme::ColorfulTheme, Select}; use dialoguer::{console::Term, theme::ColorfulTheme, Select};
use gitbutler::virtual_branches::set_base_branch;
use crate::app::App; use crate::app::App;
@ -35,9 +36,12 @@ impl super::RunCommand for Setup {
match selection { match selection {
Some(index) => { Some(index) => {
println!("Setting target to: {}", items[index].to_string().red()); println!("Setting target to: {}", items[index].to_string().red());
app.gb_repository() set_base_branch(
.set_base_branch(&app.project_repository(), &items[index].branch()) app.gb_repository(),
.context("failed to set target branch")?; &app.project_repository(),
&items[index].branch().parse()?,
)
.context("failed to set target branch")?;
} }
None => println!("User did not select anything"), None => println!("User did not select anything"),
}; };

View File

@ -2,7 +2,7 @@ use anyhow::{Context, Result};
use clap::Args; use clap::Args;
use colored::Colorize; use colored::Colorize;
use git_butler_tauri::virtual_branches; use gitbutler::virtual_branches;
use crate::app::App; use crate::app::App;

View File

@ -2,9 +2,9 @@ use std::process::ExitCode;
use clap::Parser; use clap::Parser;
mod commands;
mod app; mod app;
mod cli; mod cli;
mod commands;
fn main() -> ExitCode { fn main() -> ExitCode {
cli::Cli::parse().run() cli::Cli::parse().run()

View File

@ -1,5 +1,5 @@
[package] [package]
name = "git-butler-tauri" name = "gitbutler"
version = "0.0.0" version = "0.0.0"
description = "A Tauri App" description = "A Tauri App"
authors = ["you"] authors = ["you"]
@ -61,6 +61,7 @@ backoff = "0.4.0"
byteorder = "1.4.3" byteorder = "1.4.3"
num_cpus = "1.16.0" num_cpus = "1.16.0"
resolve-path = "0.1.0" resolve-path = "0.1.0"
posthog-rs = "0.2.2"
[features] [features]
# by default Tauri runs in production mode # by default Tauri runs in production mode
@ -74,8 +75,3 @@ devtools = ["tauri/devtools"]
# DO NOT remove this # DO NOT remove this
custom-protocol = ["tauri/custom-protocol"] custom-protocol = ["tauri/custom-protocol"]
# https://tauri.app/v1/guides/building/app-size/#rust-build-time-optimizations
[profile.release]
codegen-units = 1 # Compile crates one after another so the compiler can optimize better
lto = true # Enables link to optimizations
opt-level = "s" # Optimize for binary size

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 151 KiB

View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Some files were not shown because too many files have changed in this diff Show More