Skip to content

Commit 8c03552

Browse files
committed
Move dope.sh to top level
1 parent 0ebee55 commit 8c03552

File tree

6 files changed

+77
-23
lines changed

6 files changed

+77
-23
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ There are two ways to get help or provide feedback (and we try to always respond
7373
1. [Open an issue](https://github.com/wasp-lang/open-saas/issues)
7474
2. [Wasp Discord](https://discord.gg/aCamt5wCpS) -- please direct questions to the #🙋questions forum channel
7575

76+
## Development Tools
77+
78+
For information about the development tools used to maintain derived projects (like opensaas.sh), see [tools/README.md](./tools/README.md).
79+
7680
## Contributing
7781

7882
Note that we've tried to get as many of the core features of a SaaS app into this template as possible, but there still might be some missing features or functionality.

opensaas-sh/README.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,12 @@ Inception :)!
1212

1313
Since the demo app is just the open saas template with some small tweaks, and we want to be able to easily keep it up to date as the template changes, we don't version (in git) the actual demo app code, instead we version the diffs between it and the template: `app_diff/`.
1414

15-
So because we don't version the actual demo app (`app/`) but its diffs instead (`app_diff`), the typical workflow is as follows:
15+
**Quick Reference:**
1616

17-
1. Run `./tools/patch.sh` to generate `app/` from `../template/` and `app_diff/`.
18-
2. If there are any conflicts (normally due to updates to the template), modify `app/` till you resolve them. Do any additional changes also if you wish.
19-
3. Generate new `app_diff/`, based on the current updated `app/`, by running `./tools/diff.sh`.
17+
- Generate `app/` from template and diffs: `./tools/patch.sh`
18+
- Update diffs after modifying `app/`: `./tools/diff.sh`
2019

21-
**Running on MacOS**
22-
23-
If you're running the `patch.sh` or `diff.sh` scripts on Mac, you need to install:
24-
25-
- `grealpath` (packaged within `coreutils`),
26-
- `gpatch`,
27-
- and `diffutils`.
28-
29-
```sh
30-
brew install coreutils # contains grealpath
31-
brew install gpatch
32-
brew install diffutils
33-
```
20+
For detailed information about the diff/patch workflow and MacOS setup requirements, see [../tools/README.md](../tools/README.md).
3421

3522
### Blog (blog/)
3623

opensaas-sh/tools/diff.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env bash
22

3-
TOOLS_DIR=$(dirname "$(realpath "$0")") # Assumes this script is in `tools/`.
4-
cd "${TOOLS_DIR}" && cd ../..
3+
SCRIPT_DIR=$(dirname "$(realpath "$0")") # Assumes this script is in `opensaas-sh/tools/`.
4+
ROOT_DIR="${SCRIPT_DIR}/../.."
5+
6+
cd "${ROOT_DIR}"
57

68
rm -rf opensaas-sh/app_diff
7-
"${TOOLS_DIR}/dope.sh" template/app opensaas-sh/app diff
9+
"${ROOT_DIR}/tools/dope.sh" template/app opensaas-sh/app diff

opensaas-sh/tools/patch.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/usr/bin/env bash
22

3-
TOOLS_DIR=$(dirname "$(realpath "$0")") # Assumes this script is in `tools/`.
4-
cd "${TOOLS_DIR}" && cd ../..
3+
SCRIPT_DIR=$(dirname "$(realpath "$0")") # Assumes this script is in `opensaas-sh/tools/`.
4+
ROOT_DIR="${SCRIPT_DIR}/../.."
5+
6+
cd "${ROOT_DIR}"
57

68
# Removes all files except for some gitignored files that we don't want to bother regenerating each time,
79
# like node_modules and certain .env files.
810
find opensaas-sh/app -mindepth 1 \( -path node_modules -o -name .env.server -o -name .env.me \) -prune -o -exec rm -rf {} +
9-
"${TOOLS_DIR}/dope.sh" template/app opensaas-sh/app patch
11+
"${ROOT_DIR}/tools/dope.sh" template/app opensaas-sh/app patch

tools/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.
File renamed without changes.

0 commit comments

Comments
 (0)