Skip to content

Commit 57ae0bf

Browse files
authored
Move dope.sh to top level (#531)
1 parent a41fb47 commit 57ae0bf

File tree

8 files changed

+89
-26
lines changed

8 files changed

+89
-26
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Dependencies
22
node_modules/
33

4-
# MacOS-specific files.
4+
# macOS-specific files.
55
.DS_Store
66

77
# We want to keep the template clean from the usual build artifacts.

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: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
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")")
4+
# Assumes this script is in `opensaas-sh/tools/`.
5+
ROOT_DIR="${SCRIPT_DIR}/../.."
6+
7+
cd "${ROOT_DIR}"
58

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

opensaas-sh/tools/patch.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
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")")
4+
# Assumes this script is in `opensaas-sh/tools/`.
5+
ROOT_DIR="${SCRIPT_DIR}/../.."
6+
7+
cd "${ROOT_DIR}"
58

69
# Removes all files except for some gitignored files that we don't want to bother regenerating each time,
710
# like node_modules and certain .env files.
811
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
12+
"${ROOT_DIR}/tools/dope.sh" template/app opensaas-sh/app patch

template/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MacOS-specific files.
1+
# macOS-specific files.
22
.DS_Store
33

44
# Ignore all dotenv files by default to prevent accidentally committing any secrets.

tools/README.md

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

opensaas-sh/tools/dope.sh renamed to tools/dope.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if [[ "$(uname)" == "Darwin" ]]; then
1212
if command -v gpatch &> /dev/null; then
1313
PATCH_CMD="gpatch"
1414
else
15-
echo "Error: GNU patch (gpatch) not found. On MacOS, this script requires GNU patch."
15+
echo "Error: GNU patch (gpatch) not found. On macOS, this script requires GNU patch."
1616
echo "Install it with: brew install gpatch"
1717
exit 1
1818
fi

0 commit comments

Comments
 (0)