This commit is contained in:
Franjo Mindek
2025-11-14 11:32:33 +01:00
parent 02e8d404e0
commit 04e7168f73
4 changed files with 27 additions and 23 deletions

View File

@@ -1,6 +1,6 @@
--- template/app/src/payment/paymentProcessor.ts --- template/app/src/payment/paymentProcessor.ts
+++ opensaas-sh/app/src/payment/paymentProcessor.ts +++ opensaas-sh/app/src/payment/paymentProcessor.ts
@@ -28,9 +28,4 @@ @@ -29,9 +29,4 @@
webhookMiddlewareConfigFn: MiddlewareConfigFn; webhookMiddlewareConfigFn: MiddlewareConfigFn;
} }

View File

@@ -1,6 +1,6 @@
--- template/app/src/payment/stripe/user.ts --- template/app/src/payment/stripe/user.ts
+++ opensaas-sh/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 type { SubscriptionStatus } from "../plans";
import { PaymentPlanId } from "../plans"; import { PaymentPlanId } from "../plans";
@@ -9,7 +9,7 @@
userId: User["id"], userId: User["id"],
prismaUserDelegate: PrismaClient["user"], prismaUserDelegate: PrismaClient["user"],
): Promise<string | null> { ): Promise<string | null> {
@@ -12,20 +12,20 @@ @@ -13,20 +13,20 @@
id: userId, id: userId,
}, },
select: { select: {
@@ -36,7 +36,7 @@
prismaUserDelegate: PrismaClient["user"], prismaUserDelegate: PrismaClient["user"],
): Promise<User> { ): Promise<User> {
return prismaUserDelegate.update({ return prismaUserDelegate.update({
@@ -33,7 +33,7 @@ @@ -34,7 +34,7 @@
id: userId, id: userId,
}, },
data: { data: {
@@ -45,7 +45,7 @@
}, },
}); });
} }
@@ -54,7 +54,7 @@ @@ -55,7 +55,7 @@
): Promise<User> { ): Promise<User> {
return userDelegate.update({ return userDelegate.update({
where: { where: {
@@ -54,7 +54,7 @@
}, },
data: { data: {
datePaid, datePaid,
@@ -81,7 +81,7 @@ @@ -82,7 +82,7 @@
): Promise<User> { ): Promise<User> {
return userDelegate.update({ return userDelegate.update({
where: { where: {

View File

@@ -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 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. 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 Since derived apps (like `opensaas-sh`) are just the Open SaaS template with some small tweaks,
we want to keep them up to date as the template changes, we don't version the actual app code in git. 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. Instead, we version the diffs between it and the template in an `opensaas-sh/app_diff/` directory.
### Usage ### Usage
```bash ```sh
./dope.sh <BASE_DIR> <DERIVED_DIR> <ACTION> ./dope.sh <BASE_DIR> <DERIVED_DIR> <ACTION>
``` ```
- `<BASE_DIR>`: The base project directory (e.g., `../template/`) - `<BASE_DIR>`: The base project directory (e.g., `template/app/`)
- `<DERIVED_DIR>`: The derived project directory (e.g., `app/`) - `<DERIVED_DIR>`: The derived project directory (e.g., `opensaas-sh/app/`)
- `<ACTION>`: Either `diff` or `patch` - `<ACTION>`: Either `diff` or `patch`
- `diff`: Creates a diff between the base and derived directories - `diff`: Creates a diff between the base and derived directories
- `patch`: Applies existing diffs onto the base directory to recreate the derived directory - `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: 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 ```bash
./dope.sh ../template app patch ./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: 3. Generate a new `opensaas-sh/app_diff/` based on the updated `opensaas-sh/app/` by running:
```bash
./dope.sh ../template app diff ```bash
``` ./dope.sh ../template app diff
```
### Requirements ### Requirements
@@ -58,6 +59,8 @@ If you're running the `dope.sh` script on macOS, install:
- `gpatch` - `gpatch`
- `diffutils` - `diffutils`
You can easily install them through `brew`:
```sh ```sh
brew install coreutils # contains grealpath brew install coreutils # contains grealpath
brew install gpatch brew install gpatch

View File

@@ -60,8 +60,8 @@ recreate_diff_dir() {
# For each source file in the derived dir, generate a .diff file between it and the # For each source file in the derived dir, generate a .diff file between it and the
# corresponding source file in the base dir. # corresponding source file in the base dir.
while IFS= read -r filepath; do while IFS= read -r filepath; do
local derivedFilepath="${DERIVED_DIR}/${filepath}"
local baseFilepath="${BASE_DIR}/${filepath}" local baseFilepath="${BASE_DIR}/${filepath}"
local derivedFilepath="${DERIVED_DIR}/${filepath}"
local filepathToBeUsedAsBase="${baseFilepath}" local filepathToBeUsedAsBase="${baseFilepath}"
# If the file is not one of the source files in base dir (e.g. is gitignored or doesn't exist), # 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" cp "${derivedFilepath}" "${DIFF_DIR}/${filepath}.copy"
echo "Generated ${DIFF_DIR}/${filepath}.copy" echo "Generated ${DIFF_DIR}/${filepath}.copy"
else 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" echo "Generated ${DIFF_DIR}/${filepath}.diff"
fi fi
done <<< "${DERIVED_FILES}" done <<< "${DERIVED_FILES}"