-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Move dope.sh to top level
#531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| TOOLS_DIR=$(dirname "$(realpath "$0")") # Assumes this script is in `tools/`. | ||
| cd "${TOOLS_DIR}" && cd ../.. | ||
| SCRIPT_DIR=$(dirname "$(realpath "$0")") | ||
| # Assumes this script is in `opensaas-sh/tools/`. | ||
| ROOT_DIR="${SCRIPT_DIR}/../.." | ||
|
|
||
| cd "${ROOT_DIR}" | ||
|
|
||
| rm -rf opensaas-sh/app_diff | ||
| "${TOOLS_DIR}/dope.sh" template/app opensaas-sh/app diff | ||
| "${ROOT_DIR}/tools/dope.sh" template/app opensaas-sh/app diff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| TOOLS_DIR=$(dirname "$(realpath "$0")") # Assumes this script is in `tools/`. | ||
| cd "${TOOLS_DIR}" && cd ../.. | ||
| SCRIPT_DIR=$(dirname "$(realpath "$0")") | ||
| # Assumes this script is in `opensaas-sh/tools/`. | ||
| ROOT_DIR="${SCRIPT_DIR}/../.." | ||
|
|
||
| cd "${ROOT_DIR}" | ||
|
|
||
| # Removes all files except for some gitignored files that we don't want to bother regenerating each time, | ||
| # like node_modules and certain .env files. | ||
| find opensaas-sh/app -mindepth 1 \( -path node_modules -o -name .env.server -o -name .env.me \) -prune -o -exec rm -rf {} + | ||
| "${TOOLS_DIR}/dope.sh" template/app opensaas-sh/app patch | ||
| "${ROOT_DIR}/tools/dope.sh" template/app opensaas-sh/app patch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Open SaaS Tools | ||
|
|
||
| ## dope.sh - Diff Or Patch Executor | ||
|
|
||
| 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. | ||
|
|
||
| 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. | ||
|
|
||
| ### Usage | ||
|
|
||
| ```bash | ||
| ./dope.sh <BASE_DIR> <DERIVED_DIR> <ACTION> | ||
| ``` | ||
|
|
||
| - `<BASE_DIR>`: The base project directory (e.g., `../template/`) | ||
| - `<DERIVED_DIR>`: The derived project directory (e.g., `app/`) | ||
| - `<ACTION>`: Either `diff` or `patch` | ||
| - `diff`: Creates a diff between the base and derived directories | ||
| - `patch`: Applies existing diffs onto the base directory to recreate the derived directory | ||
|
|
||
cprecioso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| The diffs are stored in a directory named `<DERIVED_DIR>_diff/` (e.g., `app_diff/`). | ||
|
|
||
| ### Diff structure | ||
|
|
||
| The diff directory can contain `.diff` files to patch files from the base directory, | ||
| and `.copy` files to copy files directly from the diff directory to the derived directory | ||
| (useful for binary files). | ||
|
|
||
| ### Workflow | ||
|
|
||
| The typical workflow is: | ||
|
|
||
| 1. Run `dope.sh` with the `patch` action to generate `app/` from `../template/` and `app_diff/`: | ||
| ```bash | ||
| ./dope.sh ../template app patch | ||
| ``` | ||
|
|
||
| 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. | ||
|
|
||
| 3. Generate a new `app_diff/` based on the updated `app/` by running: | ||
| ```bash | ||
| ./dope.sh ../template app diff | ||
| ``` | ||
|
|
||
| ### Requirements | ||
|
|
||
| #### Running on macOS | ||
|
|
||
| If you're running the `dope.sh` script on macOS, install: | ||
|
|
||
| - `grealpath` (packaged within `coreutils`) | ||
| - `gpatch` | ||
| - `diffutils` | ||
|
|
||
| ```sh | ||
| brew install coreutils # contains grealpath | ||
| brew install gpatch | ||
| brew install diffutils | ||
| ``` | ||
|
|
||
| The script automatically detects macOS and uses `gpatch` instead of the default `patch` command. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.