|
| 1 | +# How to Hack on GitButler |
| 2 | + |
| 3 | +Alrighty, you want to get compiling. We love you already. Your parents raised |
| 4 | +you right. Let's get started. |
| 5 | + |
| 6 | +# Overview |
| 7 | + |
| 8 | +So how does this whole thing work? |
| 9 | + |
| 10 | +It's a [Tauri app](https://tauri.app/), which is basically like an Electron app, |
| 11 | +in that we can develop a desktop app from one source with multiple OS targets |
| 12 | +and write the UI in HTML and Javascript. Except instead of Node for the |
| 13 | +filesystem access part, Tauri uses [Rust](https://www.rust-lang.org/). |
| 14 | + |
| 15 | +So everything that hits disk is in Rust, everything that the |
| 16 | +user sees is in HTML/JS. Specifically we use [Svelte](https://svelte.dev/) |
| 17 | +in Typescript for that layer. |
| 18 | + |
| 19 | +# The Basics |
| 20 | + |
| 21 | +OK, let's get it running. |
| 22 | + |
| 23 | +## Prerequisites |
| 24 | + |
| 25 | +First of all, this is a Tauri app, which is a Rust app. So go install Rust. |
| 26 | +The Tauri site has a good primer for the various platforms |
| 27 | +[here](https://tauri.app/v1/guides/getting-started/prerequisites). |
| 28 | + |
| 29 | +The next major thing is `pnpm` (because we're a little cooler than people who |
| 30 | +use `npm`), so check out how to install that |
| 31 | +[here](https://pnpm.io/installation). |
| 32 | + |
| 33 | +## Install dependencies |
| 34 | + |
| 35 | +Next, install the app dependencies. |
| 36 | + |
| 37 | +I hope you have some disk space for 300M of `node_modules`, because this bad |
| 38 | +boy will fill er up: |
| 39 | + |
| 40 | +```bash |
| 41 | +$ pnpm install |
| 42 | +``` |
| 43 | + |
| 44 | +You'll have to re-run this occasionally when our deps change. |
| 45 | + |
| 46 | +## Run the app |
| 47 | + |
| 48 | +Now you should be able to run the app in development mode: |
| 49 | + |
| 50 | +```bash |
| 51 | +$ pnpm tauri dev |
| 52 | +``` |
| 53 | + |
| 54 | +By default it will not print debug logs to console. If you want debug logs, set `LOG_LEVEL` environment variable: |
| 55 | + |
| 56 | +```bash |
| 57 | +$ LOG_LEVEL=debug pnpm tauri dev |
| 58 | +``` |
| 59 | + |
| 60 | +## Lint & format |
| 61 | + |
| 62 | +In order to have a PR accepted, you need to make sure everything passes our |
| 63 | +Linters, so make sure to run these before submitting. Our CI will shame you |
| 64 | +if you don't. |
| 65 | + |
| 66 | +Javascript: |
| 67 | + |
| 68 | +```bash |
| 69 | +$ pnpm lint |
| 70 | +$ pnpm format |
| 71 | +``` |
| 72 | + |
| 73 | +Rust: |
| 74 | + |
| 75 | +```bash |
| 76 | +$ cargo clippy # see linting errors |
| 77 | +$ cargo fmt # format code |
| 78 | +``` |
| 79 | + |
| 80 | +# Debugging |
| 81 | + |
| 82 | +Now that you have the app running, here are some hints for debugging whatever |
| 83 | +it is that you're working on. |
| 84 | + |
| 85 | +## Logs |
| 86 | + |
| 87 | +The app writes logs into: |
| 88 | + |
| 89 | +1. `stdout` in development mode |
| 90 | +2. The Tauri [logs](https://tauri.app/v1/api/js/path/#platform-specific) directory |
| 91 | + |
| 92 | +## Tokio |
| 93 | + |
| 94 | +We are also collecting tokio's runtime tracing information that could be viewed using [tokio-console](https://github.com/tokio-rs/console#tokio-console-prototypes): |
| 95 | + |
| 96 | +- developlent: |
| 97 | + ```bash |
| 98 | + $ tokio-console |
| 99 | + ``` |
| 100 | +- nightly: |
| 101 | + ```bash |
| 102 | + $ tokio-console http://127.0.0.1:6668 |
| 103 | + ``` |
| 104 | +- production: |
| 105 | + ```bash |
| 106 | + $ tokio-console http://127.0.0.1:6667 |
| 107 | + ``` |
| 108 | + |
| 109 | +# Building |
| 110 | + |
| 111 | +To build the app in production mode, run: |
| 112 | + |
| 113 | +```bash |
| 114 | +$ pnpm tauri build --features devtools --config gitbutler-app/tauri.conf.nightly.json |
| 115 | +``` |
| 116 | + |
| 117 | +This will make an asset similar to our nightly build. |
| 118 | + |
| 119 | +## Building on Windows |
| 120 | + |
| 121 | +Building on Windows is a bit of a tricky process. Here are some helpful tips. |
| 122 | + |
| 123 | +### File permissions |
| 124 | + |
| 125 | +We use `pnpm`, which requires a relatively recent version of Node.js. |
| 126 | +Make sure that the latest stable version of Node.js is installed and |
| 127 | +on the PATH, and then `npm i -g pnpm`. |
| 128 | + |
| 129 | +This often causes file permissions. First, the AppData folder may not |
| 130 | +be present. Be sure to create it if it isn't. |
| 131 | + |
| 132 | +``` |
| 133 | +mkdir %APPDATA%\npm |
| 134 | +``` |
| 135 | + |
| 136 | +Secondly, typically folders within `Program Files` are not writable. |
| 137 | +You'll need to fix the security permissions for the `nodejs` folder. |
| 138 | + |
| 139 | +> **NOTE:** Under specific circumstances, depending on your usage of |
| 140 | +> Node.js, this may pose a security concern. Be sure to understand |
| 141 | +> the implications of this before proceeding. |
| 142 | +
|
| 143 | +1. Right click on the `nodejs` folder in `Program Files`. |
| 144 | +2. Click on `Properties`. |
| 145 | +3. Click on the `Security` tab. |
| 146 | +4. Click on `Edit` next to "change permissions". |
| 147 | +5. Click on `Add`. |
| 148 | +6. Type in the name of your user account, or type `Everyone` (case-sensitive). |
| 149 | + Click `Check Names` to verify (they will be underlined if correct). |
| 150 | +7. Make sure that `Full Control` is checked under `Allow`. |
| 151 | +8. Apply / click OK as needed to close the dialogs. |
| 152 | + |
| 153 | +## Perl |
| 154 | + |
| 155 | +A Perl interpreter is required to be installed in order to configure the `openssl-sys` |
| 156 | +crate. We've used [Strawberry Perl](https://strawberryperl.com/) without issue. |
| 157 | +Make sure it's installed and `perl` is available on the `PATH` (it is by default |
| 158 | +after installation, just make sure to restart the terminal after installing). |
| 159 | + |
| 160 | +Note that it might appear that the build has hung or frozen on the `openssl-sys` crate. |
| 161 | +It's not, it's just that Cargo can't report the status of a C/C++ build happening |
| 162 | +under the hood, and openssl is _large_. It'll take a while to compile. |
| 163 | + |
| 164 | +# That's It |
| 165 | + |
| 166 | +Now that you're up and running, if you want to change something and open a PR |
| 167 | +for us, make sure to read [CONTRIBUTING.md](CONTRIBUTING.md) to make sure you're |
| 168 | +not wasting your time. |
| 169 | + |
| 170 | +# Some Other Random Notes |
| 171 | + |
| 172 | +Most of this is for internal GitButler use, but maybe everyone else will find |
| 173 | +it interesting too. |
| 174 | + |
| 175 | +## Icon generation |
| 176 | + |
| 177 | +I always forget how to do this, but when we update our app icon, run this to |
| 178 | +import it. |
| 179 | + |
| 180 | +```bash |
| 181 | +$ pnpm tauri icon path/to/icon.png |
| 182 | +``` |
| 183 | + |
| 184 | +## Release |
| 185 | + |
| 186 | +Building is done via [GitHub Action](https://github.com/gitbutlerapp/gitbutler-client/actions/workflows/publish.yaml). |
| 187 | +Go to the link and select `Run workflow` from the desired branch. |
| 188 | + |
| 189 | +### Versioning |
| 190 | + |
| 191 | +When running the [release action](https://github.com/gitbutlerapp/gitbutler-client/actions/workflows/publish.yaml), |
| 192 | +you will have to choose one of `major`, `minor`, or `patch` release type. Action will generate a new version based on your input and current |
| 193 | +version found at `https://app.gitbutler.com/releases`. |
| 194 | + |
| 195 | +### Publishing |
| 196 | + |
| 197 | +To publish a version that you've just build, use [Release Manager](https://gitbutler.retool.com/apps/cb9cbed6-ae0a-11ed-918c-736c4335d3af/Release%20Manager). |
0 commit comments