diff --git a/Cargo.lock b/Cargo.lock index 9837ec7..9a1d825 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,11 +26,33 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +[[package]] +name = "modify-saleor-app" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "spinners", + "thiserror", + "walkdir", +] + +[[package]] +name = "modify-turbo-json" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "spinners", + "thiserror", + "walkdir", +] + [[package]] name = "proc-macro2" -version = "1.0.80" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -46,26 +68,15 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" +checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" - -[[package]] -name = "saleor-dockerize-all-apps" -version = "0.1.0" -dependencies = [ - "serde", - "serde_json", - "spinners", - "thiserror", - "walkdir", -] +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -78,29 +89,29 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.198" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "780f1cebed1629e4753a1a38a3c72d30b97ec044f0aef68cb26650a3c5cf363c" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.201" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "c5e405930b9796f1c00bee880d03fc7e0bb4b9a11afc776885ffe84320da2865" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.61", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -153,9 +164,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.59" +version = "2.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" dependencies = [ "proc-macro2", "quote", @@ -164,22 +175,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" dependencies = [ "proc-macro2", "quote", - "syn 2.0.59", + "syn 2.0.61", ] [[package]] @@ -198,33 +209,84 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys", ] [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/Cargo.toml b/Cargo.toml index d87790d..63bc97b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,3 @@ -[package] -name = "saleor-dockerize-all-apps" -version = "0.1.0" -edition = "2021" - -[dependencies] -# owo-colors = "4.0.0" -serde = { version = "1.0.198", features = ["derive"] } -serde_json = "1.0.116" -spinners = "4.1.1" -thiserror = "1.0.58" -walkdir = "2.5.0" +[workspace] +members = ["modify-saleor-app", "modify-turbo-json"] +resolver = "2" diff --git a/Makefile.toml b/Makefile.toml new file mode 100644 index 0000000..97412ae --- /dev/null +++ b/Makefile.toml @@ -0,0 +1,48 @@ + +# Configures the default task to run +[tasks.default] +alias = "build-containers" + +# Overrides the default build task +[tasks.build] +alias = "build-containers" + + +[tasks.build-simple-payment-gateway] +script = ''' +docker build --rm --target chef-simple-payment-gateway . +docker tag $(docker image ls -q --filter=label=service=chef-simple-payment-gateway) ghcr.io/djkato/saleor-simple-payment-gateway +''' + +[tasks.build-containers] +dependencies = [ + "delete-images", + "build-sitemap-generator", + "build-simple-payment-gateway", +] + +[tasks.push-containers] +script = ''' +docker push ghcr.io/djkato/saleor-sitemap-generator:latest +docker push ghcr.io/djkato/saleor-simple-payment-gateway:latest +''' + +[tasks.delete-images] +script = ''' +docker rmi -f $(docker image ls -q --filter=label=service=chef-sitemap-generator) 2>&1 || true +docker rmi -f $(docker image ls -q --filter=label=service=chef-simple-payment-gateway) 2>&1 || true +''' +## DEPRECATED APPS: + +# abandoned checkouts needs no further patches :) + +# SKIP_ENV_VALIDATION=true pnpm run build +[tasks.build-payment-authorized-net] +script = ''' +cd all_apps/saleor-app-payment-authorized.net +rm -rf example + + +docker build --rm --target chef-sitemap-generator . +docker tag $(docker image ls -q --filter=label=service=chef-sitemap-generator) ghcr.io/djkato/saleor-sitemap-generator +''' diff --git a/apply_patches.sh b/apply_patches.sh new file mode 100755 index 0000000..8898381 --- /dev/null +++ b/apply_patches.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +CURR_PWD="$(pwd)" + +app_paths=( + "apps" + "saleor-app-abandoned-checkouts" + "saleor-app-payment-authorize.net" + "saleor-app-payment-klarna" + "saleor-app-payment-stripe" +) + +echo "creating patches for all repos" + +for i in ${app_paths[*]}; do + cd "./all_apps/$i" + echo $(pwd) + git apply "$CURR_PWD/patches/$i.patch" + # pnpm i + # pnpm i ioredis + cd "$CURR_PWD" +done diff --git a/changes.sh b/changes.sh index 4ebcfa8..8c175e9 100755 --- a/changes.sh +++ b/changes.sh @@ -43,11 +43,15 @@ redis_apl_target_paths=( echo "copying redis_apls..." +# always copies next to saleor-app.ts, so let's add some files to that file too +find . -name "saleor-app.ts" -exec cargo run --package modify-saleor-app -- {} \; +echo "modified $i to use redis_apl" +find . -name "turbo.json" -exec cargo run --package modify-turbo-json -- {} \; +echo "modified $i to turbo.json" + for i in ${redis_apl_target_paths[*]}; do echo "copying redis_apl.ts to ./all_apps/$i" cp -f "$REDIS_APL_PATH" "./all_apps/$i" - # always copies next to saleor-app.ts, so let's add some files to that file too - # find . -name "saleor-app.ts" -exec sed "/switch/ r $CURR_PWD/changes/case_redisapl.ts" {} \; done for i in ${app_paths[*]}; do diff --git a/changes/snippets/redis_apl.ts b/changes/snippets/redis_apl.ts index 5895dfc..26fa0d7 100644 --- a/changes/snippets/redis_apl.ts +++ b/changes/snippets/redis_apl.ts @@ -1,6 +1,6 @@ import Redis from "ioredis"; -import { +import type { APL, AplConfiguredResult, AplReadyResult, diff --git a/changes/snippets/redis_apl_old_sdk.ts b/changes/snippets/redis_apl_old_sdk.ts new file mode 100644 index 0000000..7dade26 --- /dev/null +++ b/changes/snippets/redis_apl_old_sdk.ts @@ -0,0 +1,93 @@ +import Redis from "ioredis"; + +import { + APL, + AplConfiguredResult, + AplReadyResult, + AuthData, +} from "@saleor/app-sdk/APL"; + +export type RedisAPLClientArgs = { + client: Redis; + appApiBaseUrl: string; +}; +export type RedisAPLUrlArgs = { + redisUrl: string; + appApiBaseUrl: string; +}; +/** + * Redis APL + * @param redisUrl - in format redis[s]://[[username][:password]@][host][:port][/db-number], + * so for example redis://alice:foobared@awesome.redis.server:6380 + * For saleor-platform, thats: `redis://redis:6379/2` + */ +export class RedisAPL implements APL { + private client; + + private appApiBaseUrl; + + constructor(args: RedisAPLClientArgs | RedisAPLUrlArgs) { + if (!args.appApiBaseUrl) + throw new Error( + "The RedisAPL requires to know the app api url beforehand", + ); + this.appApiBaseUrl = args.appApiBaseUrl; + + if ("client" in args && args.client) { + this.client = args.client; + } else if ("redisUrl" in args && args.redisUrl) { + this.client = new Redis(args.redisUrl, { lazyConnect: true }); + } else { + throw new Error("RedisAPL: No redis url or client defined"); + } + this.isConfigured().then((v) => console.log("REDIS: CONFIGURED TEST: ", v)); + } + + private prepareKey(saleorApiUrl: string) { + return `${this.appApiBaseUrl}:${saleorApiUrl}`; + } + + async get(saleorApiUrl: string): Promise { + const res = await this.client.get(this.prepareKey(saleorApiUrl)); + console.log( + `REDIS: GET FOR ${this.prepareKey(saleorApiUrl)} (is ${res ? "truthy" : "falsy"}):`, + ); + if (res) { + const data = JSON.parse(res) as AuthData; + console.dir(data, { depth: null }); + return data; + } + } + + async set(authData: AuthData): Promise { + const res = await this.client.set( + this.prepareKey(authData.domain), + JSON.stringify(authData), + ); + console.log( + `REDIS: SET FOR ${this.prepareKey(authData.domain)}: `, + res, + ); + } + + async delete(saleorApiUrl: string): Promise { + const val = await this.client.getdel(this.prepareKey(saleorApiUrl)); + console.log("REDIS: DEL: ", val); + } + + async getAll(): Promise { + throw new Error("redisAPL does not support getAll method"); + } + + async isReady(): Promise { + const ready = !!(await this.client.info()); + console.log("REDIS: ISREADY: ", ready); + return { ready: ready } as AplReadyResult; + } + + async isConfigured(): Promise { + const ready = !!(await this.client.info()); + console.log("REDIS: ISCONF: ", ready); + return { configured: ready } as AplConfiguredResult; + } +} diff --git a/changes/snippets/turbo_env.ts b/changes/snippets/turbo_env.ts index c8297a5..8edf856 100644 --- a/changes/snippets/turbo_env.ts +++ b/changes/snippets/turbo_env.ts @@ -1 +1 @@ - "REDIS_URL" + ,"REDIS_URL" diff --git a/make_patches.sh b/make_patches.sh new file mode 100755 index 0000000..678031f --- /dev/null +++ b/make_patches.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +REDIS_APL_PATH="./changes/snippets/redis_apl.ts" +CURR_PWD="$(pwd)" + +app_paths=( + "apps" + "saleor-app-abandoned-checkouts" + "saleor-app-payment-authorize.net" + "saleor-app-payment-klarna" + "saleor-app-payment-stripe" +) + +echo "creating patches for all repos" + +# for i in ${redis_apl_target_paths[*]}; do +# echo "copying redis_apl.ts to ./all_apps/$i" +# cp -f "$REDIS_APL_PATH" "./all_apps/$i" +# # always copies next to saleor-app.ts, so let's add some files to that file too +# # find . -name "saleor-app.ts" -exec sed "/switch/ r $CURR_PWD/changes/case_redisapl.ts" {} \; +# done +# +for i in ${app_paths[*]}; do + cd "./all_apps/$i" + echo "creating patch for $(pwd)" + git diff >"$CURR_PWD/patches/$i.patch" + # pnpm i + # pnpm i ioredis + cd "$CURR_PWD" +done diff --git a/modify-saleor-app/Cargo.lock b/modify-saleor-app/Cargo.lock new file mode 100644 index 0000000..9837ec7 --- /dev/null +++ b/modify-saleor-app/Cargo.lock @@ -0,0 +1,230 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "proc-macro2" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustversion" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "saleor-dockerize-all-apps" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "spinners", + "thiserror", + "walkdir", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "serde" +version = "1.0.198" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.198" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.59", +] + +[[package]] +name = "serde_json" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "spinners" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0ef947f358b9c238923f764c72a4a9d42f2d637c46e059dbd319d6e7cfb4f82" +dependencies = [ + "lazy_static", + "maplit", + "strum", +] + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.59", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/modify-saleor-app/Cargo.toml b/modify-saleor-app/Cargo.toml new file mode 100644 index 0000000..456ce50 --- /dev/null +++ b/modify-saleor-app/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "modify-saleor-app" +version = "0.1.0" +edition = "2021" + +[dependencies] +# owo-colors = "4.0.0" +serde = { version = "1.0.198", features = ["derive"] } +serde_json = "1.0.116" +spinners = "4.1.1" +thiserror = "1.0.58" +walkdir = "2.5.0" diff --git a/src/main.rs b/modify-saleor-app/src/main.rs similarity index 81% rename from src/main.rs rename to modify-saleor-app/src/main.rs index 0324bc4..92af4e5 100644 --- a/src/main.rs +++ b/modify-saleor-app/src/main.rs @@ -1,7 +1,6 @@ use std::{ - fs::{self, File}, - io::{self, BufRead, BufReader}, - path::PathBuf, + fs::{self, read_to_string}, + io, }; fn main() -> Result<(), io::Error> { @@ -10,33 +9,17 @@ fn main() -> Result<(), io::Error> { std::process::exit(1) } - let file = File::open(&args[1])?; - // let contents = fs::read_to_string(&file)?; - let reader = BufReader::new(file); - - let mut first_half = "".to_owned(); - let mut second_half = "".to_owned(); - let mut found_switch = false; - for line in reader.lines() { - let Ok(line) = line else { continue }; - match found_switch { - true => first_half.push_str(&line), - false => second_half.push_str(&line), - } + let mut file = read_to_string(&args[1])?; + let mut output = fs::read_to_string("./changes/snippets/import_redisapl.ts")?; + for line in file.as_mut().lines() { + output.push_str(&(line.to_owned() + "\n")); if line.contains("switch") { - found_switch = true; + let case = fs::read_to_string("./changes/snippets/case_redisapl.ts")?; + output.push_str(&case); } } - first_half.push_str(&fs::read_to_string("./changes/snippets/case_redisapl.ts")?); - first_half = r#"import { RedisAPL } from "./redis_apl" - "# - .to_owned() - + &first_half; - - let final_content = first_half + &second_half; - fs::write("output.ts", &final_content)?; - println!("{}", final_content); + fs::write(&args[1], output)?; Ok(()) } diff --git a/modify-turbo-json/Cargo.lock b/modify-turbo-json/Cargo.lock new file mode 100644 index 0000000..9837ec7 --- /dev/null +++ b/modify-turbo-json/Cargo.lock @@ -0,0 +1,230 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "proc-macro2" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56dea16b0a29e94408b9aa5e2940a4eedbd128a1ba20e8f7ae60fd3d465af0e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustversion" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "saleor-dockerize-all-apps" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "spinners", + "thiserror", + "walkdir", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "serde" +version = "1.0.198" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.198" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.59", +] + +[[package]] +name = "serde_json" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "spinners" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0ef947f358b9c238923f764c72a4a9d42f2d637c46e059dbd319d6e7cfb4f82" +dependencies = [ + "lazy_static", + "maplit", + "strum", +] + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6531ffc7b071655e4ce2e04bd464c4830bb585a61cabb96cf808f05172615a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.59", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/modify-turbo-json/Cargo.toml b/modify-turbo-json/Cargo.toml new file mode 100644 index 0000000..2aadb84 --- /dev/null +++ b/modify-turbo-json/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "modify-turbo-json" +version = "0.1.0" +edition = "2021" + +[dependencies] +# owo-colors = "4.0.0" +serde = { version = "1.0.198", features = ["derive"] } +serde_json = "1.0.116" +spinners = "4.1.1" +thiserror = "1.0.58" +walkdir = "2.5.0" diff --git a/modify-turbo-json/src/main.rs b/modify-turbo-json/src/main.rs new file mode 100644 index 0000000..44bad13 --- /dev/null +++ b/modify-turbo-json/src/main.rs @@ -0,0 +1,160 @@ +use std::{ + fs::{self, read_to_string}, + io, +}; + +fn main() -> Result<(), io::Error> { + let args: Vec<_> = std::env::args().collect(); + if args.len() < 2 { + std::process::exit(1) + } + + let mut file = read_to_string(&args[1])?; + + let mut output = "".to_owned(); + for line in file.as_mut().lines() { + output.push_str(&(line.to_owned() + "\n")); + if line.contains(r#""env":"#) { + let case = fs::read_to_string("./changes/snippets/turbo_env.ts")?; + output.push_str(&case); + } + } + fs::write(&args[1], output)?; + + Ok(()) +} + +// use std::{ +// io, +// path::{Path, PathBuf}, +// process::Command, +// str::FromStr, +// }; +// +// use serde::{Deserialize, Serialize}; +// use walkdir::WalkDir; +// +// fn main() -> Result<(), io::Error> { +// let snippets = get_snippets().unwrap(); +// let actions = get_actions().unwrap(); +// let changes = get_changes() +// .unwrap() +// .into_iter() +// .map(|c| Box::new(c)) +// .collect::>(); +// +// for change in changes { +// let mut current_cumulative_path = std::env::current_dir()?; +// current_cumulative_path.push("all_apps"); +// current_cumulative_path.push(&change.folder); +// +// process_change(&change, ¤t_cumulative_path); +// if let Some(sub) = change.sub { +// iter_sub(sub) +// } +// } +// +// Ok(()) +// } +// pub fn process_change( +// change: &Box, +// current_cumulative_path: &PathBuf, +// ) -> Result<(), io::Error> { +// if let Some(actions) = &change.actions { +// for action in actions { +// let mut current_file = current_cumulative_path.clone(); +// current_file.push(&action.target); +// let command; +// match action.action_type { +// ActionType::Create => Command::new("ln").args(["-s", current_file]), +// ActionType::Insert => {} +// } +// } +// } +// Ok(()) +// } +// +// pub fn iter_sub(sub: Vec>) { +// for change in sub { +// process_change(&change); +// if let Some(further_sub) = change.sub { +// iter_sub(further_sub) +// } +// } +// } +// +// pub fn get_changes() -> Result, std::io::Error> { +// Ok(serde_json::from_str(&std::fs::read_to_string( +// "./changes/changes.json", +// )?)?) +// } +// +// pub fn get_snippets() -> Result, std::io::Error> { +// let mut snippets = vec![]; +// for entry in WalkDir::new("./changes/snippets").into_iter().flatten() { +// if entry.path().is_file() { +// if let Some(name) = entry.path().file_stem() { +// if let Some(name) = name.to_str() { +// snippets.push(Snippet { +// id: SnippetId(name.to_owned()), +// value: std::fs::read_to_string(entry.path())?, +// }) +// } +// }; +// } +// } +// Ok(snippets) +// } +// +// pub fn get_actions() -> Result, std::io::Error> { +// Ok(serde_json::from_str(&std::fs::read_to_string( +// "./changes/actions.json", +// )?)?) +// } +// +// #[derive(Serialize, Deserialize, Debug)] +// pub struct Change { +// pub folder: String, +// pub sub: Option>>, +// pub actions_by_ref: Option>, +// pub actions: Option>, +// } +// +// #[derive(Serialize, Deserialize, Debug)] +// pub struct NamedActions { +// pub name: ActionsId, +// pub actions: Vec, +// } +// +// #[derive(Serialize, Deserialize, Debug)] +// pub struct Action { +// pub target: String, +// pub action_type: ActionType, +// pub snippets: Vec, +// } +// +// #[derive(Serialize, Deserialize, Debug)] +// pub struct ActionStep { +// pub after: Option, +// pub snippet: SnippetId, +// } +// +// #[derive(Serialize, Deserialize, Debug)] +// pub struct Snippet { +// id: SnippetId, +// value: String, +// } +// +// #[derive(Serialize, Deserialize, Debug)] +// pub enum ActionType { +// Insert, +// Create, +// } +// +// #[derive(Serialize, Deserialize, Debug, PartialEq)] +// #[serde(transparent)] +// pub struct SnippetId(pub String); +// +// #[derive(Serialize, Deserialize, Debug, PartialEq)] +// #[serde(transparent)] +// pub struct ActionsId(pub String); diff --git a/patches/authorize.net-app/env.mjs.patch b/patches/authorize.net-app/env.mjs.patch new file mode 100644 index 0000000..e41a772 --- /dev/null +++ b/patches/authorize.net-app/env.mjs.patch @@ -0,0 +1,13 @@ +diff --git a/src/lib/env.mjs b/src/lib/env.mjs +index f90184f..f5e832b 100644 +--- a/src/lib/env.mjs ++++ b/src/lib/env.mjs +@@ -12,7 +12,7 @@ export const env = createEnv({ + ENV: z.enum(["development", "test", "staging", "production"]).default("development"), + SECRET_KEY: z.string().min(8, { message: "Cannot be too short" }), + // SENTRY_DSN: z.string().min(1).optional(), +- APL: z.enum(["saleor-cloud", "upstash", "file"]).optional().default("file"), ++ APL: z.enum(["saleor-cloud", "upstash", "file", "redis"]).optional().default("file"), + CI: z.coerce.boolean().optional().default(false), + APP_DEBUG: z + .enum(["fatal", "error", "warn", "info", "debug", "trace", "silent"]) diff --git a/patches/authorize.net-app/next.config.mjs.patch b/patches/authorize.net-app/next.config.mjs.patch new file mode 100644 index 0000000..3e5d0ae --- /dev/null +++ b/patches/authorize.net-app/next.config.mjs.patch @@ -0,0 +1,14 @@ +diff --git a/next.config.mjs b/next.config.mjs +index f8dd123..38717b1 100644 +--- a/next.config.mjs ++++ b/next.config.mjs +@@ -14,6 +14,9 @@ import { withSentryConfig } from "@sentry/nextjs"; + + /** @type {import('next').NextConfig} */ + const config = { ++ eslint: { ++ ignoreDuringBuilds: true ++ }, + reactStrictMode: true, + /** @param { import("webpack").Configuration } config */ + webpack(config) { diff --git a/patches/authorize.net-app/saleor-app.ts.patch b/patches/authorize.net-app/saleor-app.ts.patch new file mode 100644 index 0000000..c5b85da --- /dev/null +++ b/patches/authorize.net-app/saleor-app.ts.patch @@ -0,0 +1,22 @@ +diff --git a/src/saleor-app.ts b/src/saleor-app.ts +index 42457c6..5eec90c 100644 +--- a/src/saleor-app.ts ++++ b/src/saleor-app.ts +@@ -1,3 +1,4 @@ ++import { RedisAPL } from "./redis_apl" + import { SaleorApp } from "@saleor/app-sdk/saleor-app"; + import { FileAPL, UpstashAPL, SaleorCloudAPL } from "@saleor/app-sdk/APL"; + import { invariant } from "./lib/invariant"; +@@ -18,6 +19,12 @@ const getApl = async () => { + } + /* c8 ignore start */ + switch (env.APL) { ++ case "redis": { ++ if (!process.env.REDIS_URL) throw new Error("Missing redis url"); ++ if (!process.env.APP_API_BASE_URL) ++ throw new Error("Redis relies on APP_API_BASE_URL to store keys, please set env variable"); ++ return new RedisAPL({ redisUrl: process.env.REDIS_URL, appApiBaseUrl: process.env.APP_API_BASE_URL }); ++ } + case "upstash": + invariant(env.UPSTASH_URL, "Missing UPSTASH_URL env variable!"); + invariant(env.UPSTASH_TOKEN, "Missing UPSTASH_TOKEN env variable!"); diff --git a/patches/klarna-app/klarna-env.mjs.patch b/patches/klarna-app/klarna-env.mjs.patch new file mode 100644 index 0000000..84b8961 --- /dev/null +++ b/patches/klarna-app/klarna-env.mjs.patch @@ -0,0 +1,13 @@ +diff --git a/src/lib/env.mjs b/src/lib/env.mjs +index 1c6e98e..0a20fbf 100644 +--- a/src/lib/env.mjs ++++ b/src/lib/env.mjs +@@ -12,7 +12,7 @@ export const env = createEnv({ + ENV: z.enum(["development", "test", "staging", "production"]).default("development"), + SECRET_KEY: z.string().min(8, { message: "Cannot be too short" }), + SENTRY_DSN: z.string().min(1).optional(), +- APL: z.enum(["saleor-cloud", "upstash", "file"]).optional().default("file"), ++ APL: z.enum(["saleor-cloud", "upstash", "file", "redis"]).optional().default("file"), + CI: z.coerce.boolean().optional().default(false), + APP_DEBUG: z + .enum(["fatal", "error", "warn", "info", "debug", "trace", "silent"]) diff --git a/patches/klarna-app/next.config.mjs.patch b/patches/klarna-app/next.config.mjs.patch new file mode 100644 index 0000000..3e5d0ae --- /dev/null +++ b/patches/klarna-app/next.config.mjs.patch @@ -0,0 +1,14 @@ +diff --git a/next.config.mjs b/next.config.mjs +index f8dd123..38717b1 100644 +--- a/next.config.mjs ++++ b/next.config.mjs +@@ -14,6 +14,9 @@ import { withSentryConfig } from "@sentry/nextjs"; + + /** @type {import('next').NextConfig} */ + const config = { ++ eslint: { ++ ignoreDuringBuilds: true ++ }, + reactStrictMode: true, + /** @param { import("webpack").Configuration } config */ + webpack(config) { diff --git a/patches/klarna-app/saleor-app.ts.patch b/patches/klarna-app/saleor-app.ts.patch new file mode 100644 index 0000000..f58c92f --- /dev/null +++ b/patches/klarna-app/saleor-app.ts.patch @@ -0,0 +1,24 @@ +diff --git a/src/saleor-app.ts b/src/saleor-app.ts +index 42457c6..aebcdd8 100644 +--- a/src/saleor-app.ts ++++ b/src/saleor-app.ts +@@ -1,5 +1,6 @@ + import { SaleorApp } from "@saleor/app-sdk/saleor-app"; + import { FileAPL, UpstashAPL, SaleorCloudAPL } from "@saleor/app-sdk/APL"; ++import { RedisAPL } from "./redis_apl" + import { invariant } from "./lib/invariant"; + import { env } from "./lib/env.mjs"; + import { isTest } from "./lib/isEnv"; +@@ -18,6 +19,12 @@ const getApl = async () => { + } + /* c8 ignore start */ + switch (env.APL) { ++ case "redis": { ++ if (!process.env.REDIS_URL) throw new Error("Missing redis url"); ++ if (!process.env.APP_API_BASE_URL) ++ throw new Error("Redis relies on APP_API_BASE_URL to store keys, please set env variable"); ++ return new RedisAPL({ redisUrl: process.env.REDIS_URL, appApiBaseUrl: process.env.APP_API_BASE_URL }); ++ } + case "upstash": + invariant(env.UPSTASH_URL, "Missing UPSTASH_URL env variable!"); + invariant(env.UPSTASH_TOKEN, "Missing UPSTASH_TOKEN env variable!"); diff --git a/patches/stripe-app/env.mjs.patch b/patches/stripe-app/env.mjs.patch new file mode 100644 index 0000000..5c7a1b8 --- /dev/null +++ b/patches/stripe-app/env.mjs.patch @@ -0,0 +1,13 @@ +diff --git a/src/lib/env.mjs b/src/lib/env.mjs +index 5836240..7e0a9c6 100644 +--- a/src/lib/env.mjs ++++ b/src/lib/env.mjs +@@ -12,7 +12,7 @@ export const env = createEnv({ + ENV: z.enum(["development", "test", "staging", "production"]).default("development"), + SECRET_KEY: z.string().min(8, { message: "Cannot be too short" }), + SENTRY_DSN: z.string().min(1).optional(), +- APL: z.enum(["saleor-cloud", "upstash", "file"]).optional().default("file"), ++ APL: z.enum(["saleor-cloud", "upstash", "file", "redis"]).optional().default("file"), + CI: z.coerce.boolean().optional().default(false), + APP_DEBUG: z + .enum(["fatal", "error", "warn", "info", "debug", "trace", "silent"]) diff --git a/patches/stripe-app/next.config.mjs.patch b/patches/stripe-app/next.config.mjs.patch new file mode 100644 index 0000000..59bb648 --- /dev/null +++ b/patches/stripe-app/next.config.mjs.patch @@ -0,0 +1,14 @@ +diff --git a/next.config.mjs b/next.config.mjs +index f8dd123..0b20ad0 100644 +--- a/next.config.mjs ++++ b/next.config.mjs +@@ -14,6 +14,9 @@ import { withSentryConfig } from "@sentry/nextjs"; + + /** @type {import('next').NextConfig} */ + const config = { ++ eslint: { ++ ignoreDuringBuilds: true, ++ }, + reactStrictMode: true, + /** @param { import("webpack").Configuration } config */ + webpack(config) { diff --git a/patches/stripe-app/saleor-app.ts.patch b/patches/stripe-app/saleor-app.ts.patch new file mode 100644 index 0000000..c5b85da --- /dev/null +++ b/patches/stripe-app/saleor-app.ts.patch @@ -0,0 +1,22 @@ +diff --git a/src/saleor-app.ts b/src/saleor-app.ts +index 42457c6..5eec90c 100644 +--- a/src/saleor-app.ts ++++ b/src/saleor-app.ts +@@ -1,3 +1,4 @@ ++import { RedisAPL } from "./redis_apl" + import { SaleorApp } from "@saleor/app-sdk/saleor-app"; + import { FileAPL, UpstashAPL, SaleorCloudAPL } from "@saleor/app-sdk/APL"; + import { invariant } from "./lib/invariant"; +@@ -18,6 +19,12 @@ const getApl = async () => { + } + /* c8 ignore start */ + switch (env.APL) { ++ case "redis": { ++ if (!process.env.REDIS_URL) throw new Error("Missing redis url"); ++ if (!process.env.APP_API_BASE_URL) ++ throw new Error("Redis relies on APP_API_BASE_URL to store keys, please set env variable"); ++ return new RedisAPL({ redisUrl: process.env.REDIS_URL, appApiBaseUrl: process.env.APP_API_BASE_URL }); ++ } + case "upstash": + invariant(env.UPSTASH_URL, "Missing UPSTASH_URL env variable!"); + invariant(env.UPSTASH_TOKEN, "Missing UPSTASH_TOKEN env variable!");