-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-tm1-scratch-org.sh
executable file
·87 lines (74 loc) · 2.61 KB
/
build-tm1-scratch-org.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
# Specify the alias or username associated with your connection to the TM-Tools Test Drive DevHub.
DEV_HUB_ALIAS="DevHub:TMT-Test-Drive"
# You SHOULD NOT need to change anything below this line.
PROJECT_ROOT="."
SCRATCH_ORG_CONFIG="${PROJECT_ROOT}/config/tm1-scratch-def.json"
SCRATCH_ORG_ALIAS="TestDrive:tm1-scratch-org"
SCRATCH_ORG_EXPIRATION_DAYS="2"
SCRATCH_ORG_WAIT_TIME="10"
API_VERSION="46.0"
createScratchOrg() {
# Create a new scratch org using the scratch-def.json locally configured for this project.
echo "Creating scratch org $SCRATCH_ORG_ALIAS using $DEV_HUB_ALIAS."
echo ""
echo "Scratch org creation may take several minutes. Please be patient."
echo ""
(cd $PROJECT_ROOT && exec sfdx force:org:create -f $SCRATCH_ORG_CONFIG -a $SCRATCH_ORG_ALIAS -v $DEV_HUB_ALIAS -s -d $SCRATCH_ORG_EXPIRATION_DAYS -w $SCRATCH_ORG_WAIT_TIME --apiversion $API_VERSION --json --json > /dev/null 2>&1)
if [ $? -ne 0 ]; then
echo ""
echo "Scratch org could not be created. Aborting Script."
exit 1
fi
echo "------------------------------"
}
deleteScratchOrg () {
# Delete the current scratch org.
echo "Deleting scratch org $SCRATCH_ORG_ALIAS (if present)"
echo ""
(cd $PROJECT_ROOT && exec sfdx force:org:delete -p -u $SCRATCH_ORG_ALIAS -v $DEV_HUB_ALIAS --json > /dev/null 2>&1)
echo "------------------------------"
}
generatePassword () {
# Generates a password for the admin user of the scratch org. Necessary to use workbench.
echo "Generating password for $SCRATCH_ORG_ALIAS (useful if you want to use non-CLI tools)"
echo ""
sfdx force:user:password:generate -u $SCRATCH_ORG_ALIAS --json
echo ""
echo "------------------------------"
}
openScratchOrg () {
# Opens the specified scratch org.
if [ ! -z $1 ]; then
ORG_PATH_TO_OPEN="-p $1"
else
ORG_PATH_TO_OPEN=""
fi
echo "Opening scratch org $SCRATCH_ORG_ALIAS"
echo ""
sfdx force:org:open -u $SCRATCH_ORG_ALIAS $ORG_PATH_TO_OPEN
echo ""
echo "------------------------------"
}
pushSfdxSource () {
# Pushes SFDX Source from the current projet to the specified scratch org.
echo "Pushing basic org config to $SCRATCH_ORG_ALIAS"
echo ""
(cd $PROJECT_ROOT && exec sfdx force:source:push -u $SCRATCH_ORG_ALIAS --json > /dev/null 2>&1)
echo "------------------------------"
}
# 1. Delete the old TM1 scratch org (if it exists)
# 2. Create a new TM1 scratch org
# 3. Generate a password for the admin user
# 4. Open the newly created TM1 scratch org
echo ''
deleteScratchOrg
echo ''
createScratchOrg
echo ''
generatePassword
echo ''
pushSfdxSource
echo ''
openScratchOrg lightning/setup/Territories/home
echo ''