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,51 @@ 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 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
0 commit comments