Skip to content

Commit fbce6ff

Browse files
committed
Merge branch 'main' of https://github.com/VinceFINET/OrgCheck into main
2 parents 06b5bd7 + 84b3f93 commit fbce6ff

File tree

71 files changed

+6658
-5545
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+6658
-5545
lines changed

.github/workflows/apex_tests.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Apex Tests
2+
3+
on: workflow_dispatch
4+
5+
env:
6+
CUMULUSCI_SERVICE_github: ${{ secrets.CUMULUSCI_SERVICE_github }}
7+
8+
jobs:
9+
unit_tests:
10+
name: "Run Apex tests"
11+
runs-on: ubuntu-latest
12+
environment: cumulusci
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Install Salesforce CLI
16+
run: |
17+
mkdir sfdx
18+
wget -qO- https://developer.salesforce.com/media/salesforce-cli/sfdx/channels/stable/sfdx-linux-x64.tar.xz | tar xJ -C sfdx --strip-components 1
19+
echo $(realpath sfdx/bin) >> $GITHUB_PATH
20+
- name: Authenticate Dev Hub
21+
run: |
22+
echo ${{ secrets.SFDX_AUTH_URL }} > sfdx_auth
23+
sfdx force:auth:sfdxurl:store -f sfdx_auth -d
24+
- name: Set up Python
25+
uses: actions/setup-python@v1
26+
with:
27+
python-version: "3.8"
28+
- name: Install CumulusCI
29+
run: |
30+
python -m pip install -U pip
31+
pip install cumulusci
32+
- run: |
33+
cci flow run ci_feature --org dev --delete-org

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
.sfdx/
88
.localdevserver/
99

10+
# Salesforce scratch org history
11+
.sf/
12+
1013
# LWC VSCode autocomplete
1114
**/lwc/jsconfig.json
1215

build/build.sh

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
#/bin/bash
2+
3+
UGLIFY_MODE="$1"
4+
UGLIFY_MODE_ON="on"
5+
UGLIFY_MODE_OFF="off"
6+
if [ "X${UGLIFY_MODE}" == "X${UGLIFY_MODE_OFF}" ]; then
7+
echo "Uglify Mode is off"
8+
UGLIFY_MODE="${UGLIFY_MODE_OFF}"
9+
else
10+
echo "Uglify Mode is on"
11+
UGLIFY_MODE="${UGLIFY_MODE_ON}"
12+
fi
13+
echo ""
14+
15+
### -----------------------
16+
### JAVASCRIPT PART
17+
### -----------------------
18+
19+
for f in build/src/javascript/OrgCheck_*.js; do
20+
if [ "${UGLIFY_MODE}" == "${UGLIFY_MODE_ON}" ]; then
21+
uglifyjs --ie --webkit --v8 "${f}" -o /tmp/$(basename $f);
22+
else
23+
cat "${f}" > /tmp/$(basename $f);
24+
fi
25+
done
26+
for f in build/src/javascript/OrgCheck.js; do
27+
if [ "${UGLIFY_MODE}" == "${UGLIFY_MODE_ON}" ]; then
28+
uglifyjs --ie --webkit --v8 "${f}" -o /tmp/$(basename $f)
29+
else
30+
cat "${f}" > /tmp/$(basename $f);
31+
fi
32+
done
33+
34+
(
35+
for f in build/src/javascript/OrgCheck.js; do
36+
cat /tmp/$(basename $f)
37+
done
38+
for f in build/src/javascript/OrgCheck_*.js; do
39+
cat /tmp/$(basename $f)
40+
done
41+
) > force-app/main/default/staticresources/OrgCheck_OrgCheck_SR.resource
42+
43+
44+
45+
46+
## https://codeinthehole.com/tips/tips-for-using-a-git-pre-commit-hook/
47+
## ln -s ../../pre-commit.sh .git/hooks/pre-commit
48+
49+
##### ln -s ./javascript/build/build-js.sh .git/hooks/pre-commit
50+
51+
52+
53+
### -----------------------
54+
### LABELS PART
55+
### -----------------------
56+
57+
cat build/src/labels/CustomLabels-copyandpasted.txt \
58+
| sed -e 's/""/"/g' -e 's/^"//' -e 's/"$//' \
59+
> force-app/main/default/labels/CustomLabels.labels-meta.xml
60+
61+
62+
63+
### -----------------------
64+
### TRANSLATIONS PART
65+
### -----------------------
66+
67+
cat build/src/labels/Translation-FR-copyandpasted.txt \
68+
| sed -e 's/""/"/g' -e 's/^"//' -e 's/"$//' \
69+
> force-app/main/default/translations/fr.translation-meta.xml
70+
71+
cat build/src/labels/Translation-JP-copyandpasted.txt \
72+
| sed -e 's/""/"/g' -e 's/^"//' -e 's/"$//' \
73+
> force-app/main/default/translations/ja.translation-meta.xml
74+
75+
76+
77+
78+
79+
### -----------------------
80+
### Generate the TEST page
81+
### -----------------------
82+
(
83+
echo '<!DOCTYPE html>';
84+
echo '<html>';
85+
echo ' <head>';
86+
echo ' <title>Test Page</title>';
87+
echo ' </head>';
88+
echo ' <body>';
89+
echo ' <h1>Custom Labels</h1>';
90+
echo ' <p>List all custom labels in a table so that you can check if they are correct.</p>';
91+
echo ' <table border="1" summary="Custom labels">';
92+
echo ' <thead><tr><th>Label</th><th>Value</th></tr></thead>';
93+
echo ' <tbody>';
94+
cat force-app/main/default/labels/CustomLabels.labels-meta.xml \
95+
| grep '<labels>' \
96+
| sed -e 's#^.*<fullName>\([^<]*\)</fullName>.*<value>\([^<]*\)</value>.*$# <tr><td>\1</td><td>\2</td></tr>#' \
97+
-e 's@&lt;@<@g' \
98+
-e 's@&gt;@>@g' \
99+
-e 's@&#x2F;@/@g' \
100+
-e 's@&#x3D;@=@g' \
101+
-e 's@&quot;@"@g'
102+
echo ' </tbody>';
103+
echo ' </table>';
104+
for translation in force-app/main/default/translations/*.translation-meta.xml; do
105+
language=$(basename ${translation} | cut -d. -f1);
106+
echo ' <h1>Translation for <code>'${language}'</code></h1>';
107+
echo ' <p>List all <code>'${language}'</code> translations of custom labels in a table so that you can check if they are correct.</p>';
108+
echo ' <table border="1" summary="Translations for '${language}'">';
109+
echo ' <thead><tr><th>Label</th><th>Translation in <code>'${language}'</code></th></tr></thead>';
110+
echo ' <tbody>';
111+
cat ${translation} \
112+
| grep '<customLabels>' \
113+
| sed -e 's#^.*<name>\([^<]*\)</name>.*<label>\([^<]*\)</label>.*$# <tr><td>\1</td><td>\2</td></tr>#' \
114+
-e 's@&lt;@<@g' \
115+
-e 's@&gt;@>@g' \
116+
-e 's@&#x2F;@/@g' \
117+
-e 's@&#x3D;@=@g' \
118+
-e 's@&quot;@"@g'
119+
echo ' </tbody>';
120+
echo ' </table>';
121+
done
122+
echo ' </body>';
123+
echo '</html>';
124+
) > /tmp/testAll.txt
125+
tidy /tmp/testAll.txt 2>&1 | grep 'Warning' | grep -v 'character code' | sort -t' ' -k2,2n > /tmp/testWarnings
126+
if [ $(cat /tmp/testWarnings | wc -l | tr -d ' ') -ne 0 ]; then
127+
echo "WARNINGS:"
128+
cat /tmp/testWarnings
129+
fi
130+
131+
132+
### -----------------------
133+
### PUSH INTO DEV ORG
134+
### -----------------------
135+
sfdx force:source:deploy -m StaticResource:OrgCheck_OrgCheck_SR,CustomLabels,Translations 1>/dev/null

build/package.readme

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
============================================================
2+
Push source in a scratch org
3+
============================================================
4+
sfdx force:org:create --definitionfile config/project-scratch-def.json --setalias MyScratchOrg --targetdevhubusername [email protected] --wait 10
5+
sfdx force:source:push --targetusername MyScratchOrg --forceoverwrite
6+
sfdx force:user:permset:assign --targetusername MyScratchOrg --permsetname OrgCheck_Users
7+
profileName=$(sfdx force:data:soql:query --targetusername MyScratchOrg --query "SELECT Name FROM Profile WHERE UserLicense.MasterLabel = 'Salesforce' AND Name LIKE '%Admin%' AND PermissionsViewAllData = true LIMIT 1" --resultformat=csv | tail -1)
8+
sfdx force:user:create --setalias uatuser --definitionfile config/user-uat-def.json "profileName=${profileName}" permsets=OrgCheck_Users --targetusername MyScratchOrg
9+
10+
uatUserId=$(sfdx force:data:soql:query --query "SELECT Id FROM User WHERE Profile.Name = '${profileName}' AND IsActive = true" --resultformat=csv --targetusername MyScratchOrg | tail -1)
11+
12+
## Set French Local/Language
13+
sfdx force:data:record:update --sobjectid "${uatUserId}" --sobjecttype User --values "LocaleSidKey=fr LanguageLocaleKey=fr" --targetusername MyScratchOrg
14+
15+
## Set English Local/Language
16+
sfdx force:data:record:update --sobjectid "${uatUserId}" --sobjecttype User --values "LocaleSidKey=en_US LanguageLocaleKey=en_US" --targetusername MyScratchOrg
17+
18+
## Set Japanese Local/Language
19+
sfdx force:data:record:update --sobjectid "${uatUserId}" --sobjecttype User --values "LocaleSidKey=ja LanguageLocaleKey=ja" --targetusername MyScratchOrg
20+
21+
## In case of persistente language, please close all browsers before launching the next command.
22+
sfdx force:org:open --targetusername uatuser
23+
24+
25+
sfdx force:user:list --targetusername MyScratchOrg
26+
sfdx force:org:open --targetusername MyScratchOrg
27+
28+
sfdx force:org:delete --targetusername MyScratchOrg
29+
30+
31+
============================================================
32+
List of usefull commands for packaging
33+
============================================================
34+
sfdx force:package:version:list
35+
sfdx force:package:version:create --package OrgCheck --definitionfile config/project-scratch-def.json --installationkeybypass --codecoverage --wait 10
36+
sfdx force:package:version:promote --package [email protected]
37+
38+
39+
40+
41+
============================================================
42+
List of usefull commands for pushing updates
43+
============================================================
44+
45+
## List the push request to update to a newer package version
46+
sfdx force:data:soql:query [email protected] --query "SELECT Id, PackageVersionId, ScheduledStartTime, Status, SystemModstamp, StartTime, EndTime, DurationSeconds FROM PackagePushRequest WHERE SystemModstamp = TODAY" --resultformat=csv
47+
48+
## List all the subscriber part of the previous push request
49+
sfdx force:data:soql:query [email protected] --query "SELECT Id, PackagePushRequestId, SubscriberOrganizationKey, Status, SystemModstamp, StartTime, EndTime, DurationSeconds FROM PackagePushJob where SystemModstamp = today" --resultformat=csv
50+
51+
## CHeck the pending and in progress
52+
sfdx force:data:soql:query [email protected] --query "SELECT Id, PackagePushRequestId, SubscriberOrganizationKey, Status, SystemModstamp, StartTime, EndTime, DurationSeconds FROM PackagePushJob where SystemModstamp = today and status != 'Succeeded' and status != 'failed'" --resultformat=csv
53+
54+
## List all error you had during the previous push
55+
sfdx force:data:soql:query [email protected] --query "SELECT Id, PackagePushJobId, ErrorMessage, ErrorDetails, ErrorTitle, ErrorSeverity, ErrorType, SystemModstamp FROM PackagePushError where SystemModstamp = TODAY" --resultformat=csv
56+
57+
58+
59+
60+
61+
============================================================
62+
Issues with Permission Set including unwanted CRUDs & FLS
63+
============================================================
64+
65+
If needed, you should emptied the Permission Set (to make sure it does not include any reference to sobjects):
66+
67+
NOTE:
68+
If the anonymous script ends with "Internal Error", you simply go to the permission set setup,
69+
edit one of the CRUD and unselect "Create" for a random object. You save. From there the
70+
anonymous script will work again. The SOAP/REST api cannot perform an update.
71+
72+
(
73+
echo "List<ObjectPermissions> ops = [SELECT Id, ParentId, SobjectType FROM ObjectPermissions WHERE Parent.Name = 'OrgCheck_Users']; "
74+
echo "Database.delete(ops, false); ";
75+
echo "List<FieldPermissions> fps = [SELECT Id, ParentId, Field FROM FieldPermissions WHERE Parent.Name = 'OrgCheck_User']; ";
76+
echo "Database.delete(fps, false); ";
77+
) > /tmp/OrgCheck_Users_ObjectPermissions_Removal.apex
78+
79+
for i in {1..3}; do
80+
echo "Turn #${i}"
81+
nbCRUDs=$( \
82+
sfdx force:data:soql:query \
83+
--query "SELECT Id FROM ObjectPermissions WHERE Parent.Name = 'OrgCheck_Users'" \
84+
--resultformat=csv \
85+
| egrep -v '(^(Id$)|()' | wc -l | tr -d ' ' \
86+
)
87+
nbFLSs=$( \
88+
sfdx force:data:soql:query \
89+
--query "SELECT Id FROM FieldPermissions WHERE Parent.Name = 'OrgCheck_Users'" \
90+
--resultformat=csv \
91+
| egrep -v '(^Id$)|()' | wc -l | tr -d ' ' \
92+
)
93+
echo "Permission Set <OrgCheck_Users> has ${nbCRUDs} CRUDs and ${nbFLSs} FLSs"
94+
sfdx force:apex:execute --apexcodefile /tmp/OrgCheck_Users_ObjectPermissions_Removal.apex 2>&1 >/dev/null;
95+
done
96+
97+
echo "Permission Set <OrgCheck_Users> has now the following CRUDs and FLSs:"
98+
sfdx force:data:soql:query \
99+
--query "SELECT Id, SobjectType, Parent.Name FROM ObjectPermissions WHERE Parent.Name = 'OrgCheck_Users'"
100+
sfdx force:data:soql:query \
101+
--query "SELECT Id, Field, Parent.Name FROM FieldPermissions WHERE Parent.Name = 'OrgCheck_Users'"
102+

0 commit comments

Comments
 (0)