From 2dc8584f02a29d911f3c66ba12360580a19da41b Mon Sep 17 00:00:00 2001 From: tharindu-rhino Date: Thu, 1 Aug 2024 10:25:31 +0530 Subject: [PATCH 1/8] Update readme.md --- readme.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/readme.md b/readme.md index b01252d..6dc0d38 100644 --- a/readme.md +++ b/readme.md @@ -64,6 +64,15 @@ export default function PaymentScreen() { You can [visit our docs](https://doc.komoju.com/reference/createsession) to see how a session id can be created +### Setup a return URL. + +Many payment method types require a return URL, so if you fail to provide it, we can’t present those payment methods to your user, even if you’ve enabled them. +When a customer exits your app, for example to authenticate in Safari or their banking app, provide a way for them to automatically return to your app afterward. +#### 1. Use `return_url` parameter when creating a session +#### 2. [Configure the custom URL scheme](https://reactnative.dev/docs/linking) in your AndroidManifest.xml and Info.plist files +> Note: +> If you’re using Expo, [set your scheme](https://docs.expo.dev/guides/linking/#in-a-standalone-app) in the app.json file. + To initialize Komoju in your React Native app, use the `KomojuSDK.KomojuProvider` component in the root component of your application. `KomojuProvider` can accept `publicKey`, `payment_methods` and `language` as props. Only `publicKey` is required. From e5f3a62b6cac47ed5bafce14532b9bd067f4c446 Mon Sep 17 00:00:00 2001 From: tharindu-rhino Date: Thu, 1 Aug 2024 10:26:09 +0530 Subject: [PATCH 2/8] Update readme.md --- payment_sdk/readme.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/payment_sdk/readme.md b/payment_sdk/readme.md index b01252d..6dc0d38 100644 --- a/payment_sdk/readme.md +++ b/payment_sdk/readme.md @@ -64,6 +64,15 @@ export default function PaymentScreen() { You can [visit our docs](https://doc.komoju.com/reference/createsession) to see how a session id can be created +### Setup a return URL. + +Many payment method types require a return URL, so if you fail to provide it, we can’t present those payment methods to your user, even if you’ve enabled them. +When a customer exits your app, for example to authenticate in Safari or their banking app, provide a way for them to automatically return to your app afterward. +#### 1. Use `return_url` parameter when creating a session +#### 2. [Configure the custom URL scheme](https://reactnative.dev/docs/linking) in your AndroidManifest.xml and Info.plist files +> Note: +> If you’re using Expo, [set your scheme](https://docs.expo.dev/guides/linking/#in-a-standalone-app) in the app.json file. + To initialize Komoju in your React Native app, use the `KomojuSDK.KomojuProvider` component in the root component of your application. `KomojuProvider` can accept `publicKey`, `payment_methods` and `language` as props. Only `publicKey` is required. From 575851a757c666a8369f7ea59247b914fab2ae9b Mon Sep 17 00:00:00 2001 From: chathurapathiranage Date: Thu, 1 Aug 2024 16:22:44 +0530 Subject: [PATCH 3/8] example app ios deeplink fix --- example/ios/example/AppDelegate.mm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/example/ios/example/AppDelegate.mm b/example/ios/example/AppDelegate.mm index ba286dc..f1a0c99 100644 --- a/example/ios/example/AppDelegate.mm +++ b/example/ios/example/AppDelegate.mm @@ -1,6 +1,7 @@ #import "AppDelegate.h" #import +#import // Add this import @implementation AppDelegate @@ -28,4 +29,12 @@ - (NSURL *)bundleURL #endif } -@end +// Add this method to handle opening URLs +- (BOOL)application:(UIApplication *)application + openURL:(NSURL *)url + options:(NSDictionary *)options +{ + return [RCTLinkingManager application:application openURL:url options:options]; +} + +@end \ No newline at end of file From ad9dd03ad642d0a79ffc26f5cd35803d6f8e2f4d Mon Sep 17 00:00:00 2001 From: chathurapathiranage Date: Thu, 1 Aug 2024 22:01:38 +0530 Subject: [PATCH 4/8] ui fixes MOB-36, MOB-37 --- payment_sdk/package.json | 2 +- payment_sdk/src/assets/images/thunder.png | Bin 0 -> 351 bytes payment_sdk/src/assets/images/thunder@2x.png | Bin 0 -> 571 bytes payment_sdk/src/assets/images/thunder@3x.png | Bin 0 -> 811 bytes payment_sdk/src/components/LightBox.tsx | 18 +++++++++++------- .../sections/SimpleRedirectSection.tsx | 1 - .../sections/TransferFormSection.tsx | 1 + payment_sdk/src/theme/defaultColorTheme.ts | 2 +- 8 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 payment_sdk/src/assets/images/thunder.png create mode 100644 payment_sdk/src/assets/images/thunder@2x.png create mode 100644 payment_sdk/src/assets/images/thunder@3x.png diff --git a/payment_sdk/package.json b/payment_sdk/package.json index b01fd5d..8cd479e 100644 --- a/payment_sdk/package.json +++ b/payment_sdk/package.json @@ -1,6 +1,6 @@ { "name": "@komoju/komoju-react-native", - "version": "0.0.5", + "version": "0.0.6", "private": false, "description": "degica payment SDK", "main": "dist/index.js", diff --git a/payment_sdk/src/assets/images/thunder.png b/payment_sdk/src/assets/images/thunder.png new file mode 100644 index 0000000000000000000000000000000000000000..dbc132d8ec1c38958a5763555e8a8ab487cc7b84 GIT binary patch literal 351 zcmeAS@N?(olHy`uVBq!ia0vp^LO?9c!3HGfPKx~mq&N#aB8wRqxP?KOkzv*x37{Zj zage(c!@6@aFM%AEbVpxD28NCO+yRJ2HYQ~njN4 zN6E-a@jWYbUH7u8D4#X|+^g%N_~vlQc}1;4!(@(AFHZLu4^P)H@CAcEEqAO8j16HE?<5(J7MQi6DF6a|jKR1nA- zV&z2I9KaWt3Uj1(A~n<(V9FarzTu8OM&?1x(FaHcAv>D!fbR%9HCjSUi(c^8WjSI@ zh(^J8g9Xx>5N#sAKUg5G3DNZp4>^H!CPbUOBS)+W*_LOIbauB(LNqP$KG9uz+N@r;W>1y$vnOgHQNB&83H?Bf>5`Ocv6-4F z1~{Uob-jm(YVHj+AkOz^s4Tru?oH))b zY;S&{Z+b3{XbFiAQa7s&LQ6<|5L=Is6D|-zAo9iHMn^)Tg3y@*3q%gqa=vQskAe#k z24e0Hr-Z}>(H{fO35g9-HjWqxF)8RjG}`T7(+Xz<@ytnxNx!vllAlaD#^?Y5002ov JPDHLkV1gyj;x7OI literal 0 HcmV?d00001 diff --git a/payment_sdk/src/assets/images/thunder@3x.png b/payment_sdk/src/assets/images/thunder@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..3dc4061d5a89bd389f754c1d8ff54f74ecfc5d24 GIT binary patch literal 811 zcmV+`1JwM9P)DW`K~#7F)tXOM z+b|G^e{#ENS3QDm(DnvlLqk{137Vdu&nIZO0XHZ;0c`px-H;oU-atoy4Lc%6egR@z zvGr%h*xx2#%YlhBpGHy?2F6}sMlUm1T&vGG2NMbdV*lVLy)1VwovJy$fq?=8VK4Cm z^&lL}Z4YHLNFeqvzSB@z?YTVz1LA>D5FfC?NkE zNT8t_5Ao!OgC&q)L$xtrf~Q9U4duariR?fk4Aq8d4sm2vzm=illDq!L=X}+7a*re! zs)+$3Nr5C8s*M37(Sc+bstMa1;)w5&bVJo)oI@N@$+k7r3LGd}uW#@lIViH8#ko3y z2@WLJP@*WTf&$qZ>K{f-Z;mh-N}SFfsSNd|>IsdJ)7>Lnh8lpqfn?QCFMxMwjoMIt z+WMV>p;{F9SQ}bXF;s)n?Znh`L{Iwjw0|umdWJ|J$ZD(fJQ{}bA$ww_s7LZ?8On$B(Oa(4 zy@vAf8nS5Q;0$#bwrwQcBO2+HF{fE_XNbS4icWs`xrPcwZfF&W`QZ#TkKb~V99kOj z1R2W5m;wnlln=R~6+4GS7|Q>+95Fdk=AO5|{Lo4;ln=35D`>SDP(y_x^Ua5_IV9Oo zK4gYg{~VHKC?8VR(w%oR4ds7J8Fa_JlIt5myGRAH_FiQ&ln*&;UEq}7{p<4u{Gz4m p5<buVeXzNrkhrXbc3 { +const LightBox = ({ content }: Props) => { const { t } = useTranslation(); const theme = useCurrentTheme(); const styles = getStyles(theme); return ( - {icon && {icon}} + + + {t(content)} ); @@ -37,13 +41,12 @@ const getStyles = (theme: ThemeSchemeType) => { flexDirection: "row", backgroundColor: theme.LIGHT_BOX, borderRadius: responsiveScale(8), - justifyContent: "center", alignItems: "center", }, content: { fontSize: resizeFonts(16), color: theme.TEXT_COLOR, - flex: 0.9, + flex: 1, }, iconWrapper: { marginRight: responsiveScale(8), @@ -56,7 +59,8 @@ const getStyles = (theme: ThemeSchemeType) => { alignItems: 'center' }, icon: { - fontSize: resizeFonts(20) + width: responsiveScale(18), + height: responsiveScale(18), } }); diff --git a/payment_sdk/src/components/sections/SimpleRedirectSection.tsx b/payment_sdk/src/components/sections/SimpleRedirectSection.tsx index e9e39d7..daccc6e 100644 --- a/payment_sdk/src/components/sections/SimpleRedirectSection.tsx +++ b/payment_sdk/src/components/sections/SimpleRedirectSection.tsx @@ -38,7 +38,6 @@ const SimpleRedirectSection = ({ type }: SimpleRedirectSectionProps) => { diff --git a/payment_sdk/src/components/sections/TransferFormSection.tsx b/payment_sdk/src/components/sections/TransferFormSection.tsx index 2b8b084..9eef7a2 100644 --- a/payment_sdk/src/components/sections/TransferFormSection.tsx +++ b/payment_sdk/src/components/sections/TransferFormSection.tsx @@ -122,6 +122,7 @@ const TransferFormSection = ({ type }: TransferFormSectionProps) => { { diff --git a/payment_sdk/src/theme/defaultColorTheme.ts b/payment_sdk/src/theme/defaultColorTheme.ts index 734089f..14b6aab 100644 --- a/payment_sdk/src/theme/defaultColorTheme.ts +++ b/payment_sdk/src/theme/defaultColorTheme.ts @@ -27,7 +27,7 @@ const lightTheme = { WHITE50: '#00000050', CARD_BACKGROUND: '#ffffff', CARD_BORDER: '#CAD6E1', - LIGHT_BOX: '#dbdbdb', + LIGHT_BOX: '#F3F7F9', CARD_SHADOW_IOS_COLOR: '#D9D9D9', CARD_SHADOW_ANDROID_COLOR: '#c4c2c2', }; From afe2e612e1bd19fb5469fb348af505d4519fad01 Mon Sep 17 00:00:00 2001 From: Richard Ramsden Date: Sun, 4 Aug 2024 15:38:16 +0900 Subject: [PATCH 5/8] Add tsc-alias to the project --- payment_sdk/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/payment_sdk/package.json b/payment_sdk/package.json index b01fd5d..bcae15c 100644 --- a/payment_sdk/package.json +++ b/payment_sdk/package.json @@ -55,6 +55,7 @@ "react-native": "0.74.1", "react-test-renderer": "^18.2.0", "ts-jest": "^29.1.4", + "tsc-alias": "^1.8.10", "typescript": "^5.4.5", "typescript-eslint": "^7.12.0" }, From 9984398dd888d7edaaf83876fab8c78b1e38cf60 Mon Sep 17 00:00:00 2001 From: Tharindu Kumarasiri Date: Thu, 8 Aug 2024 00:58:41 +0530 Subject: [PATCH 6/8] Payment Modal added --- payment_sdk/src/components/PaymentModal.tsx | 185 ++++++++++++++++++ payment_sdk/src/context/KomojuProvider.tsx | 1 + payment_sdk/src/context/MainStateProvider.tsx | 36 +++- payment_sdk/src/util/types.ts | 1 + 4 files changed, 217 insertions(+), 6 deletions(-) create mode 100644 payment_sdk/src/components/PaymentModal.tsx diff --git a/payment_sdk/src/components/PaymentModal.tsx b/payment_sdk/src/components/PaymentModal.tsx new file mode 100644 index 0000000..2a382cd --- /dev/null +++ b/payment_sdk/src/components/PaymentModal.tsx @@ -0,0 +1,185 @@ +import React, { Dispatch, SetStateAction, useContext } from "react"; + +import { + TouchableOpacity, + Modal, + View, + Image, + StyleSheet, + Alert, + Keyboard, +} from "react-native"; + +import { t } from "i18next"; + +import { Actions, DispatchContext, StateContext } from "@context/state"; +import { useTheme } from "@context/ThemeContext"; + +import { + paymentFailedCtaText, + paymentSuccessCtaText, + ThemeModes, +} from "@util/constants"; +import { ResponseScreenStatuses, ThemeSchemeType } from "@util/types"; + +import closeIcon from "@assets/images/close.png"; +import closeDMIcon from "@assets/images/close_dm.png"; + +import { resizeFonts, responsiveScale, WINDOW_HEIGHT } from "@theme/scalling"; +import { useCurrentTheme } from "@theme/useCurrentTheme"; + +import KomojuText from "./KomojuText"; +import ResponseScreen from "./ResponseScreen"; +import SheetContent from "./SheetContent"; + +type PaymentModalProps = { + modalVisible: boolean; + setModalVisible: Dispatch>; + onDismiss?: () => void; +}; + +const PaymentModal = ({ + modalVisible, + setModalVisible, + onDismiss, +}: PaymentModalProps) => { + const { paymentState } = useContext(StateContext); + const dispatch = useContext(DispatchContext); + + const theme = useCurrentTheme(); + const styles = getStyles(theme); + const { mode } = useTheme(); + + const closeSheet = (showAlert = true) => { + Keyboard.dismiss(); + + if (showAlert) { + // showing an alert when user try to close the SDK modal + Alert.alert(`${t("CANCEL_PAYMENT")}?`, "", [ + { + text: t("NO"), + style: "cancel", + }, + { + text: t("YES"), + onPress: () => { + // invoking client provided onDismiss() callback when closing the SDK modal + onDismiss && onDismiss(); + setModalVisible(false); + }, + }, + ]); + } else { + // invoking client provided callback when closing the SDK modal + onDismiss && onDismiss(); + setModalVisible(false); + } + }; + + const getCtaText = () => { + switch (paymentState) { + case ResponseScreenStatuses.SUCCESS: + return paymentSuccessCtaText; + case ResponseScreenStatuses.FAILED: + return paymentFailedCtaText; + default: + return ""; + } + }; + + const ctaOnPress = () => { + switch (paymentState) { + case ResponseScreenStatuses.SUCCESS: + return closeSheet(false); + case ResponseScreenStatuses.FAILED: + return dispatch({ + type: Actions.SET_PAYMENT_STATE, + payload: "", + }); + default: + return ""; + } + }; + + const onCloseModal = () => { + closeSheet( + !( + paymentState === ResponseScreenStatuses.SUCCESS || + // TODO: Fix this type error + // @ts-expect-error - Property 'COMPLETE' does not exist on type 'ResponseScreenStatuses'. + paymentState === ResponseScreenStatuses.COMPLETE + ) + ); + }; + + return ( + + + + + + PAYMENT_OPTIONS + + + + + { + // TODO: Fix this type error + // @ts-expect-error - Property 'COMPLETE' does not exist on type 'ResponseScreenStatuses'. + paymentState && paymentState !== ResponseScreenStatuses.COMPLETE ? ( + + ) : ( + + ) + } + + + ); +}; + +const getStyles = (theme: ThemeSchemeType) => { + return StyleSheet.create({ + container: { + flex: 1, + backgroundColor: theme.WHITE50, + }, + bottomSheetContainer: { + height: WINDOW_HEIGHT - 85, + width: "100%", + backgroundColor: theme.BACKGROUND_COLOR, + }, + line: { + flexDirection: "row", + alignItems: "center", + marginVertical: responsiveScale(20), + marginHorizontal: responsiveScale(16), + }, + headerLabel: { + fontSize: resizeFonts(18), + fontWeight: "bold", + flex: 1, + alignItems: "center", + textAlign: "center", + color: theme.TEXT_COLOR, + }, + crossBtn: { + position: "absolute", + right: 0, + padding: responsiveScale(10), + fontSize: resizeFonts(16), + }, + }); +}; + +export default PaymentModal; diff --git a/payment_sdk/src/context/KomojuProvider.tsx b/payment_sdk/src/context/KomojuProvider.tsx index d52cdee..ec4a834 100644 --- a/payment_sdk/src/context/KomojuProvider.tsx +++ b/payment_sdk/src/context/KomojuProvider.tsx @@ -15,6 +15,7 @@ export const KomojuProvider = (props: KomojuProviderIprops) => { publicKey={props.publicKey} payment_methods={props?.payment_methods} language={props?.language} + useBottomSheet={props?.useBottomSheet} > {props.children} diff --git a/payment_sdk/src/context/MainStateProvider.tsx b/payment_sdk/src/context/MainStateProvider.tsx index 902a317..2e93934 100644 --- a/payment_sdk/src/context/MainStateProvider.tsx +++ b/payment_sdk/src/context/MainStateProvider.tsx @@ -4,12 +4,14 @@ import React, { useEffect, useMemo, useRef, + useState, } from "react"; import { Alert, Linking } from "react-native"; import i18next from "i18next"; +import PaymentModal from "@components/PaymentModal"; import Sheet, { SheetRefProps } from "@components/Sheet"; import payForSession from "@services/payForSessionService"; @@ -32,6 +34,7 @@ import { Actions, DispatchContext, KomojuContext } from "./state"; export const MainStateProvider = (props: KomojuProviderIprops) => { const dispatch = useContext(DispatchContext); + const [modalVisible, setModalVisible] = useState(false); const sheetRef = useRef(null); // ref to hold client provided onComplete callback @@ -53,6 +56,21 @@ export const MainStateProvider = (props: KomojuProviderIprops) => { }; }, []); + const openPaymentSheet = () => { + if (props?.useBottomSheet) { + sheetRef?.current?.open(); + } else { + setModalVisible(true); + } + }; + + const closePaymentSheet = () => { + // TODO: Fix this type error + // @ts-expect-error - Object is possibly 'null'. + sheetRef?.current?.close(false); + setModalVisible(false); + }; + // when payment is success global state is rest and invoking the success screen const onPaymentSuccess = () => { dispatch({ @@ -122,9 +140,7 @@ export const MainStateProvider = (props: KomojuProviderIprops) => { // validating the session data and closing the payment gateway if data is not valid if (validateSessionResponse(sessionData)) { - // TODO: Fix this type error - // @ts-expect-error - Object is possibly 'null'. - sheetRef?.current?.close(false); + closePaymentSheet(); Alert.alert("Error", "Invalid Session"); } else { // if explicitly language is not set. set to the localization from session @@ -253,7 +269,7 @@ export const MainStateProvider = (props: KomojuProviderIprops) => { sessionId, }), }); - sheetRef?.current?.open(); + openPaymentSheet(); }, [props] ); @@ -267,9 +283,17 @@ export const MainStateProvider = (props: KomojuProviderIprops) => { const initializeKomoju = useCallback((params: InitPrams) => {}, []); const renderPaymentUI = useMemo(() => { - const UI = ; + const UI = props?.useBottomSheet ? ( + + ) : ( + + ); return UI; - }, [sheetRef]); + }, [sheetRef, modalVisible]); const renderChildren = useMemo(() => props?.children, [props.children]); diff --git a/payment_sdk/src/util/types.ts b/payment_sdk/src/util/types.ts index caa215a..f46503b 100644 --- a/payment_sdk/src/util/types.ts +++ b/payment_sdk/src/util/types.ts @@ -4,6 +4,7 @@ export type InitPrams = { publicKey: string; payment_methods?: Array; language?: LanguageTypes; + useBottomSheet?: boolean; }; export type CreatePaymentFuncType = { From 95991487968a89813a327b5ad78119ad03c39ba2 Mon Sep 17 00:00:00 2001 From: chathurapathiranage Date: Sun, 11 Aug 2024 05:56:32 +0530 Subject: [PATCH 7/8] example app flow changes --- example/package.json | 10 +++--- example/scripts/installer.sh | 61 ++++++++++++++++++++++++++++++++++ example/scripts/start-metro.sh | 20 +++++++++++ payment_sdk/scripts/publish.sh | 19 +++++++---- 4 files changed, 99 insertions(+), 11 deletions(-) create mode 100755 example/scripts/installer.sh create mode 100755 example/scripts/start-metro.sh diff --git a/example/package.json b/example/package.json index 4363bfc..348ff8e 100644 --- a/example/package.json +++ b/example/package.json @@ -1,12 +1,12 @@ { "name": "example", - "version": "0.0.1", + "version": "0.0.7", "private": true, "scripts": { - "android": "react-native run-android", - "ios": "react-native run-ios", + "android": "./scripts/installer.sh android", + "ios": "./scripts/installer.sh ios", "lint": "eslint .", - "start": "react-native start", + "start": "./scripts/start-metro.sh", "test": "jest" }, "dependencies": { @@ -36,4 +36,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/example/scripts/installer.sh b/example/scripts/installer.sh new file mode 100755 index 0000000..79ff160 --- /dev/null +++ b/example/scripts/installer.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' + +PLATFORM=${1:-} + +# Function to fetch the version from the package.json using Node.js +get_package_version() { + node -p "require('../payment_sdk/package.json').version" +} + +# Function to terminate Metro +terminate_metro() { + if pgrep -f "node.*metro" > /dev/null; then + echo "Terminating Metro server..." + pkill -f "node.*metro" + else + echo "Metro server is not running." + fi +} + +# Uninstall the package from example +echo "Uninstalling @komoju/komoju-react-native from example" +npm uninstall @komoju/komoju-react-native + +# Change directory to payment_sdk +echo "Changing directory to payment_sdk" +cd ../payment_sdk + +# Build the package +echo "Building the package" +npm run build + +# Get the version from package.json +PACKAGE_VERSION=$(get_package_version) +echo "Package version found: $PACKAGE_VERSION" + +# Change directory back to example +echo "Changing directory back to example" +cd ../example + +# Install the built package +echo "Installing the built package version $PACKAGE_VERSION" +npm i "../payment_sdk/komoju-komoju-react-native-${PACKAGE_VERSION}.tgz" + +# Terminate Metro +terminate_metro + +# Run platform-specific command if provided +case $PLATFORM in + android) + echo "Running on Android" + react-native run-android + ;; + ios) + echo "Running on iOS" + react-native run-ios + ;; +esac + +echo "Installation and build process complete!" diff --git a/example/scripts/start-metro.sh b/example/scripts/start-metro.sh new file mode 100755 index 0000000..f11c4c6 --- /dev/null +++ b/example/scripts/start-metro.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' + +# Function to terminate Metro +terminate_metro() { + if pgrep -f "node.*metro" > /dev/null; then + echo "Terminating Metro server..." + pkill -f "node.*metro" + else + echo "Metro server is not running." + fi +} + +# Terminate any running Metro server +terminate_metro + +# Start the Metro server with cache clean +echo "Starting Metro server with cache clean" +npx react-native start --reset-cache diff --git a/payment_sdk/scripts/publish.sh b/payment_sdk/scripts/publish.sh index 4ce575f..80d9954 100755 --- a/payment_sdk/scripts/publish.sh +++ b/payment_sdk/scripts/publish.sh @@ -15,7 +15,7 @@ EOF } percentEncodeString() { - jq -rn --arg x "$1" '$x|@uri' + node -p "encodeURIComponent('$1')" } create_github_release() { @@ -128,20 +128,27 @@ npm run build echo "Bumping package.json $RELEASE_TYPE version and tagging commit" npm version $RELEASE_TYPE +# Extract the new version from package.json +NEW_VERSION=$(node -p "require('./package.json').version") + +# Update the version in ../example/package.json +echo "Updating version in ../example/package.json to $NEW_VERSION" +node -p "const fs = require('fs'); const path = '../example/package.json'; const pkg = JSON.parse(fs.readFileSync(path, 'utf8')); pkg.version = '$NEW_VERSION'; fs.writeFileSync(path, JSON.stringify(pkg, null, 2))" + echo "Publishing release to npm" npm publish --access=public echo "Pushing git commit and tag" +git add package.json ../example/package.json +git commit -m "Update package.json and example package.json to version $NEW_VERSION" git push --follow-tags -# echo "Pushing git changes to main brach" -# git add package.json -# git commit -m "package.json" -# git push origin main +echo "Updating the main branch" +git push origin main echo "Publish successful!" echo "" create_github_release -echo "Done!" \ No newline at end of file +echo "Done!" From abd0d436bceb04db7e01541dba9e75fc6a01d412 Mon Sep 17 00:00:00 2001 From: chathurapathiranage Date: Sun, 11 Aug 2024 10:20:04 +0530 Subject: [PATCH 8/8] example app flow changes --- example/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/package.json b/example/package.json index 348ff8e..64d466a 100644 --- a/example/package.json +++ b/example/package.json @@ -1,6 +1,6 @@ { "name": "example", - "version": "0.0.7", + "version": "0.0.1", "private": true, "scripts": { "android": "./scripts/installer.sh android",