forked from arieunier/uglydemo_sfdx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_sfdx.sh
executable file
·84 lines (63 loc) · 2.71 KB
/
deploy_sfdx.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
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
# set me
if [ $# -ne 2 ]
then
echo "Usage : deploy_sfdx.sh ScratchOrgAlias DevelopperHubAlias"
exit 1
fi
SCRATCHORGALIAS=$1
DEVHUBALIAS=$2
echo "Creating a new ScratchOrg=$SCRATCHORGALIAS in the developper hub $DEVHUBALIAS"
sfdx force:org:create -s -f config/project-scratch-def.json -a $SCRATCHORGALIAS
read -p "------------- Finished, type enter to continue "
echo "------------- Launching web browser !"
sfdx force:org:open
read -p "------------- You can work on the org if you want to .. Beware all changes will be overwritten by the next push"
echo "Pushing all source code to the org $SCRATCHORGALIAS"
sfdx force:source:push --forceoverwrite -u $SCRATCHORGALIAS
read -p "------------- Finished, type enter to continue "
echo "Updating user permissions"
for i in `ls force-app/main/default/permissionsets/`
do
echo 'Treating Permission file : '$i
permissionName=`echo $i | cut -d'.' -f1`
echo permissionName=$permissionName
sfdx force:user:permset:assign -n $permissionName -u $SCRATCHORGALIAS
done
echo "Pushing test data into $SCRATCHORGALIAS"
#sfdx force:data:tree:import --plan ./data/*plan.json --targetusername $SCRATCHORGALIAS
for i in `find . -type f -name '*plan.json'`
do
echo 'Treating data file : '$i
sfdx force:data:tree:import --plan $i --targetusername $SCRATCHORGALIAS
done
read -p "------------- Finished, type enter to continue "
echo "Generating password on $SCRATCHORGALIAS for Heroku Connect"
sfdx force:user:password:generate
sfdx force:org:display
read -p "------------- Finished, type enter to continue "
echo "------------- Finished, Launching web browser !"
sfdx force:org:open
read -p "------------- Finished, now work on the Org and come back here to deploy to production . If you don't want to deploy changes to production, exit the program with ctrl c"
echo "Pulling changes "
sfdx force:source:pull
read -p "------------- Finished, type enter to continue "
echo "Creating Meta Data api Package"
rm -rf mdapi_output_dir
mkdir mdapi_output_dir
sfdx force:source:convert -d mdapi_output_dir/ --packagename sf-alm-demo
read -p "------------- Finished, type enter to continue "
echo "Sending Metadata Api Package to the $DEVHUBALIAS Organisation"
sfdx force:mdapi:deploy -d mdapi_output_dir -u $DEVHUBALIAS -w 1
read -p "------------- Finished, type enter to continue "
echo "Updating user permissions"
for i in `ls force-app/main/default/permissionsets/`
do
echo 'Treating Permission file : '$i
permissionName=`echo $i | cut -d'.' -f1`
echo permissionName=$permissionName
sfdx force:user:permset:assign -n $permissionName -u $DEVHUBALIAS
done
read -p "------------- Finished, type enter to continue "