-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.sh
101 lines (80 loc) · 1.98 KB
/
utils.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
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
function prepareFolders() {
rm -rf retrieve/*
rm -rf orgs/*
for org in "$@"
do
mkdir -p retrieve/$org
mkdir -p orgs/$org
done
}
function retrieveMetadata() {
retrieveMetadataOrRetry "$@"
#Retry failed retrieves
retrieveMetadataOrRetry "$@"
unzipPackages "$@"
}
function retrieveMetadataOrRetry() {
i=1
for f in ./packages/*.xml; do
for org in "$@"
do
if [ ! -d "./retrieve/$org/$i" ]; then
sfdx force:mdapi:retrieve -u "$org" -k "$f" --singlepackage --retrievetargetdir "./retrieve/$org/$i" &
fi
done
let "i += 1"
done
wait
}
function unzipPackages() {
i=1
for f in ./packages/*.xml; do
for org in "$@"
do
unzip -o -qq "./retrieve/$org/$i/unpackaged.zip" -d "./orgs/$org/"
done
let "i += 1"
done
wait
}
function queryData() {
i=1
for f in ./queries/*.soql; do
SOQL="$(cat $f | tr -s '\n' ' ')"
fileName="$(basename -- $f)"
for org in "$@"
do
mkdir -p "./orgs/$org/data"
sfdx force:data:soql:query -u "$org" -q "$SOQL" -r human $([[ $fileName =~ .*__t.soql$ ]] && echo "--usetoolingapi") > "./orgs/$org/data/$fileName.csv" &
done
let "i += 1"
done
wait
}
function createComparisonRepository() {
initRepository
commitSandboxes "$@"
}
function initRepository() {
rm -rf ./orgs/gitcompare
mkdir ./orgs/gitcompare
(
cd ./orgs/gitcompare || exit
git init
git commit --allow-empty -m 'init'
git tag -a -m '' ROOT
)
}
function commitSandboxes() {
for org in "$@"
do
rm -rf ./orgs/gitcompare/*
cp -rf "./orgs/$org/." "./orgs/gitcompare/"
(
cd ./orgs/gitcompare || exit
git add --all
git commit --quiet -m "$org"
)
done
}