Skip to content

Commit 5e7a52b

Browse files
committed
Install.sh populate bootconfig.plist for sample apps from environment variables (if defined)
1 parent 20b609f commit 5e7a52b

7 files changed

Lines changed: 63 additions & 30 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ yarn.lock
2121
index.android.bundle*
2222
shared/test/test_credentials.json
2323
shared/test/ui_test_config.json
24+
**/bootconfig.xml
25+
!libs/test/**/bootconfig.xml
2426
native/NativeSampleApps/AuthFlowTester/src/main/assets/
2527
.vscode/

install.sh

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#!/bin/bash
2-
# Running this script will install all dependencies needed for all of the projects
2+
# Running this script will install all dependencies needed for all of the projects
3+
4+
# Run from repo root so relative paths work regardless of invocation directory
5+
cd "$(dirname "$0")"
36

47
# ensure that we have the correct version of all submodules
58
git submodule init
69
git submodule sync
710
git submodule update
811

12+
# Restore bootconfig.json in shared submodule to committed placeholders
13+
git -C external/shared checkout -- samples/mobilesyncexplorer/bootconfig.json samples/accounteditor/bootconfig.json 2>/dev/null || true
914

1015
# get react native
1116
pushd "libs/SalesforceReact"
@@ -14,3 +19,51 @@ rm yarn.lock
1419
yarn install
1520
./node_modules/.bin/react-native bundle --platform android --dev true --entry-file node_modules/react-native-force/test/alltests.js --bundle-output ../test/SalesforceReactTest/assets/index.android.bundle --assets-dest ../test/SalesforceReactTest/assets/
1621
popd
22+
23+
# Apply bootconfig placeholder substitution. Usage:
24+
# apply_bootconfig_paths [sample_file] path1 path2 ...
25+
# First arg is sample path (or empty for no sample). If sample is set and a path does not exist, copy sample there. Then substitute env vars.
26+
apply_bootconfig_paths() {
27+
local sample_file=""
28+
[ -n "$1" ] && [ -f "$1" ] && sample_file="$1"
29+
shift
30+
while [ $# -gt 0 ]; do
31+
local bootconfig="$1"
32+
shift
33+
if [ -n "$sample_file" ] && [ ! -f "$bootconfig" ]; then
34+
mkdir -p "$(dirname "$bootconfig")"
35+
cp "$sample_file" "$bootconfig"
36+
fi
37+
if [ -f "$bootconfig" ]; then
38+
if [ -n "${MSDK_IOS_REMOTE_ACCESS_CLIENT_KEY:-}" ]; then
39+
gsed -i "s|__CONSUMER_KEY__|${MSDK_IOS_REMOTE_ACCESS_CLIENT_KEY}|g" "$bootconfig"
40+
fi
41+
if [ -n "${MSDK_IOS_REMOTE_ACCESS_CALLBACK_URL:-}" ]; then
42+
gsed -i "s|__REDIRECT_URI__|${MSDK_IOS_REMOTE_ACCESS_CALLBACK_URL}|g" "$bootconfig"
43+
fi
44+
fi
45+
done
46+
}
47+
48+
BOOTCONFIG_SAMPLE="shared/bootconfig.xml.sample"
49+
BOOTCONFIG_XML_PATHS=(
50+
"libs/SalesforceSDK/res/values/bootconfig.xml"
51+
"native/NativeSampleApps/RestExplorer/res/values/bootconfig.xml"
52+
"native/NativeSampleApps/AuthFlowTester/src/main/res/values/bootconfig.xml"
53+
"native/NativeSampleApps/ConfiguredApp/res/values/bootconfig.xml"
54+
)
55+
BOOTCONFIG_JSON_PATHS=(
56+
"external/shared/samples/mobilesyncexplorer/bootconfig.json"
57+
"external/shared/samples/accounteditor/bootconfig.json"
58+
)
59+
60+
apply_bootconfig_paths "$BOOTCONFIG_SAMPLE" "${BOOTCONFIG_XML_PATHS[@]}"
61+
apply_bootconfig_paths "" "${BOOTCONFIG_JSON_PATHS[@]}"
62+
63+
if [ -z "${MSDK_IOS_REMOTE_ACCESS_CLIENT_KEY:-}" ] || [ -z "${MSDK_IOS_REMOTE_ACCESS_CALLBACK_URL:-}" ]; then
64+
echo ""
65+
echo "Note: MSDK_IOS_REMOTE_ACCESS_CLIENT_KEY and/or MSDK_IOS_REMOTE_ACCESS_CALLBACK_URL are not set."
66+
echo "To run the sample applications, define these environment variables or ensure bootconfig.xml"
67+
echo "files exist (created from shared/bootconfig.xml.sample) with remoteAccessConsumerKey and oauthRedirectURI set."
68+
echo ""
69+
fi

libs/SalesforceSDK/res/values/bootconfig.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

native/NativeSampleApps/AuthFlowTester/src/main/res/values/bootconfig.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

native/NativeSampleApps/ConfiguredApp/res/values/bootconfig.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

native/NativeSampleApps/RestExplorer/res/values/bootconfig.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

shared/bootconfig.xml.sample

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<resources>
4+
<!-- Replace placeholders via install script env vars or edit manually -->
5+
<string name="remoteAccessConsumerKey">__CONSUMER_KEY__</string>
6+
<string name="oauthRedirectURI">__REDIRECT_URI__</string>
7+
</resources>

0 commit comments

Comments
 (0)