|
| 1 | +# Open SaaS Tools |
| 2 | + |
| 3 | +This directory contains utilities for managing derived projects that are built on top of the Open SaaS template. |
| 4 | + |
| 5 | +## dope.sh - Diff Or Patch Executor |
| 6 | + |
| 7 | +The `dope.sh` script allows you to easily create a diff between two projects (base and derived), or to patch those diffs onto the base project to get the derived one. This is useful when a derived project has only small changes on top of the base project and you want to keep it in a directory in the same repo as the main project. |
| 8 | + |
| 9 | +### Usage |
| 10 | + |
| 11 | +```bash |
| 12 | +./dope.sh <BASE_DIR> <DERIVED_DIR> <ACTION> |
| 13 | +``` |
| 14 | + |
| 15 | +- `<BASE_DIR>`: The base project directory (e.g., `../template/`) |
| 16 | +- `<DERIVED_DIR>`: The derived project directory (e.g., `app/`) |
| 17 | +- `<ACTION>`: Either `diff` or `patch` |
| 18 | + - `diff`: Creates a diff between the base and derived directories |
| 19 | + - `patch`: Applies existing diffs onto the base directory to recreate the derived directory |
| 20 | + |
| 21 | +### Workflow |
| 22 | + |
| 23 | +Since derived apps (like opensaas-sh) are just the Open SaaS template with some small tweaks, and we want to keep them up to date as the template changes, we don't version the actual app code in git. Instead, we version the diffs between it and the template in an `app_diff/` directory. |
| 24 | + |
| 25 | +The typical workflow is: |
| 26 | + |
| 27 | +1. Run `dope.sh` with `patch` action to generate `app/` from `../template/` and `app_diff/`: |
| 28 | + ```bash |
| 29 | + ./dope.sh ../template app patch |
| 30 | + ``` |
| 31 | + |
| 32 | +2. If there are any conflicts (normally due to updates to the template), modify `app/` until you resolve them. Make any additional changes as needed. |
| 33 | + |
| 34 | +3. Generate new `app_diff/` based on the current updated `app/` by running: |
| 35 | + ```bash |
| 36 | + ./dope.sh ../template app diff |
| 37 | + ``` |
| 38 | + |
| 39 | +### Running on MacOS |
| 40 | + |
| 41 | +If you're running the `dope.sh` script on Mac, you need to install: |
| 42 | + |
| 43 | +- `grealpath` (packaged within `coreutils`) |
| 44 | +- `gpatch` |
| 45 | +- `diffutils` |
| 46 | + |
| 47 | +```sh |
| 48 | +brew install coreutils # contains grealpath |
| 49 | +brew install gpatch |
| 50 | +brew install diffutils |
| 51 | +``` |
| 52 | + |
| 53 | +The script will automatically detect macOS and use `gpatch` instead of the default `patch` command. |
| 54 | + |
| 55 | +## Usage in Different Projects |
| 56 | + |
| 57 | +### opensaas-sh |
| 58 | + |
| 59 | +The opensaas.sh demo app uses this tool to maintain a patched version of the template. See `opensaas-sh/README.md` for more details. |
0 commit comments