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