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
58git submodule init
69git submodule sync
710git 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
1116pushd " libs/SalesforceReact"
@@ -14,3 +19,53 @@ rm yarn.lock
1419yarn 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/
1621popd
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, copy sample over each path (overwriting if present).
26+ # Then substitute env vars.
27+ apply_bootconfig_paths () {
28+ local sample_file=" "
29+ [ -n " $1 " ] && [ -f " $1 " ] && sample_file=" $1 "
30+ shift
31+ while [ $# -gt 0 ]; do
32+ local bootconfig=" $1 "
33+ shift
34+ if [ -n " $sample_file " ]; then
35+ mkdir -p " $( dirname " $bootconfig " ) "
36+ cp " $sample_file " " $bootconfig "
37+ fi
38+ if [ -f " $bootconfig " ]; then
39+ # Substitute env vars if set
40+ if [ -n " ${MSDK_ANDROID_REMOTE_ACCESS_CONSUMER_KEY:- } " ]; then
41+ gsed -i " s|__CONSUMER_KEY__|${MSDK_ANDROID_REMOTE_ACCESS_CONSUMER_KEY} |g" " $bootconfig "
42+ fi
43+ if [ -n " ${MSDK_ANDROID_REMOTE_ACCESS_CALLBACK_URL:- } " ]; then
44+ gsed -i " s|__REDIRECT_URI__|${MSDK_ANDROID_REMOTE_ACCESS_CALLBACK_URL} |g" " $bootconfig "
45+ fi
46+ fi
47+ done
48+ }
49+
50+ BOOTCONFIG_SAMPLE=" shared/bootconfig.xml.sample"
51+ BOOTCONFIG_XML_PATHS=(
52+ " libs/SalesforceSDK/res/values/bootconfig.xml"
53+ " native/NativeSampleApps/RestExplorer/res/values/bootconfig.xml"
54+ " native/NativeSampleApps/AuthFlowTester/src/main/res/values/bootconfig.xml"
55+ " native/NativeSampleApps/ConfiguredApp/res/values/bootconfig.xml"
56+ )
57+ BOOTCONFIG_JSON_PATHS=(
58+ " external/shared/samples/mobilesyncexplorer/bootconfig.json"
59+ " external/shared/samples/accounteditor/bootconfig.json"
60+ )
61+
62+ apply_bootconfig_paths " $BOOTCONFIG_SAMPLE " " ${BOOTCONFIG_XML_PATHS[@]} "
63+ apply_bootconfig_paths " " " ${BOOTCONFIG_JSON_PATHS[@]} "
64+
65+ if [ -z " ${MSDK_ANDROID_REMOTE_ACCESS_CONSUMER_KEY:- } " ] || [ -z " ${MSDK_ANDROID_REMOTE_ACCESS_CALLBACK_URL:- } " ]; then
66+ echo " "
67+ echo " Note: MSDK_ANDROID_REMOTE_ACCESS_CONSUMER_KEY and/or MSDK_ANDROID_REMOTE_ACCESS_CALLBACK_URL are not set."
68+ echo " To run the sample applications, define these environment variables or ensure bootconfig.xml"
69+ echo " files exist (created from shared/bootconfig.xml.sample) with remoteAccessConsumerKey and oauthRedirectURI set."
70+ echo " "
71+ fi
0 commit comments