diff --git a/opensaas-sh/app_diff/src/payment/paymentProcessor.ts.diff b/opensaas-sh/app_diff/src/payment/paymentProcessor.ts.diff index 2fd85bc2..dc2265a3 100644 --- a/opensaas-sh/app_diff/src/payment/paymentProcessor.ts.diff +++ b/opensaas-sh/app_diff/src/payment/paymentProcessor.ts.diff @@ -1,6 +1,6 @@ --- template/app/src/payment/paymentProcessor.ts +++ opensaas-sh/app/src/payment/paymentProcessor.ts -@@ -28,9 +28,4 @@ +@@ -29,9 +29,4 @@ webhookMiddlewareConfigFn: MiddlewareConfigFn; } diff --git a/opensaas-sh/app_diff/src/payment/stripe/user.ts.diff b/opensaas-sh/app_diff/src/payment/stripe/user.ts.diff index e351ef20..4a0d3d51 100644 --- a/opensaas-sh/app_diff/src/payment/stripe/user.ts.diff +++ b/opensaas-sh/app_diff/src/payment/stripe/user.ts.diff @@ -1,6 +1,6 @@ --- template/app/src/payment/stripe/user.ts +++ opensaas-sh/app/src/payment/stripe/user.ts -@@ -3,7 +3,7 @@ +@@ -4,7 +4,7 @@ import type { SubscriptionStatus } from "../plans"; import { PaymentPlanId } from "../plans"; @@ -9,7 +9,7 @@ userId: User["id"], prismaUserDelegate: PrismaClient["user"], ): Promise { -@@ -12,20 +12,20 @@ +@@ -13,20 +13,20 @@ id: userId, }, select: { @@ -36,7 +36,7 @@ prismaUserDelegate: PrismaClient["user"], ): Promise { return prismaUserDelegate.update({ -@@ -33,7 +33,7 @@ +@@ -34,7 +34,7 @@ id: userId, }, data: { @@ -45,7 +45,7 @@ }, }); } -@@ -54,7 +54,7 @@ +@@ -55,7 +55,7 @@ ): Promise { return userDelegate.update({ where: { @@ -54,7 +54,7 @@ }, data: { datePaid, -@@ -81,7 +81,7 @@ +@@ -82,7 +82,7 @@ ): Promise { return userDelegate.update({ where: { diff --git a/tools/README.md b/tools/README.md index 8cd7f857..746d5906 100644 --- a/tools/README.md +++ b/tools/README.md @@ -7,18 +7,18 @@ or to patch those diffs onto the base project to get the derived one. This is us 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. +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 `opensaas-sh/app_diff/` directory. ### Usage -```bash +```sh ./dope.sh ``` -- ``: The base project directory (e.g., `../template/`) -- ``: The derived project directory (e.g., `app/`) +- ``: The base project directory (e.g., `template/app/`) +- ``: The derived project directory (e.g., `opensaas-sh/app/`) - ``: 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 @@ -35,18 +35,19 @@ and `.copy` files to copy files directly from the diff directory to the derived The typical workflow is: -1. Run `dope.sh` with the `patch` action to generate `app/` from `../template/` and `app_diff/`: +1. Run `dope.sh` with the `patch` action to generate `opensaas-sh/app/` from `template/app/` and `opensaash-sh/app_diff/`: - ```bash - ./dope.sh ../template app patch - ``` +```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. +2. If there are any conflicts (usually due to updates to the template), modify `opensaas-sh/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 - ``` +3. Generate a new `opensaas-sh/app_diff/` based on the updated `opensaas-sh/app/` by running: + +```bash +./dope.sh ../template app diff +``` ### Requirements @@ -58,6 +59,8 @@ If you're running the `dope.sh` script on macOS, install: - `gpatch` - `diffutils` +You can easily install them through `brew`: + ```sh brew install coreutils # contains grealpath brew install gpatch diff --git a/tools/dope.sh b/tools/dope.sh index e43c5478..2bc9c4dd 100755 --- a/tools/dope.sh +++ b/tools/dope.sh @@ -60,8 +60,8 @@ recreate_diff_dir() { # For each source file in the derived dir, generate a .diff file between it and the # corresponding source file in the base dir. while IFS= read -r filepath; do - local derivedFilepath="${DERIVED_DIR}/${filepath}" local baseFilepath="${BASE_DIR}/${filepath}" + local derivedFilepath="${DERIVED_DIR}/${filepath}" local filepathToBeUsedAsBase="${baseFilepath}" # If the file is not one of the source files in base dir (e.g. is gitignored or doesn't exist), @@ -80,7 +80,8 @@ recreate_diff_dir() { cp "${derivedFilepath}" "${DIFF_DIR}/${filepath}.copy" echo "Generated ${DIFF_DIR}/${filepath}.copy" else - diff -Nu --label "${baseFilepath}" --label "${derivedFilepath}" "${filepathToBeUsedAsBase}" "${derivedFilepath}" > "${DIFF_DIR}/${filepath}.diff" + diff -Nu --label "${baseFilepath}" --label "${derivedFilepath}" \ + "${filepathToBeUsedAsBase}" "${derivedFilepath}" > "${DIFF_DIR}/${filepath}.diff" echo "Generated ${DIFF_DIR}/${filepath}.diff" fi done <<< "${DERIVED_FILES}"