Skip to content

Commit 4a518d5

Browse files
authored
Merge pull request #236 from VinceFINET/helium
Helium
2 parents 2b3ea7b + e44d2eb commit 4a518d5

File tree

75 files changed

+2267
-1533
lines changed

Some content is hidden

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

75 files changed

+2267
-1533
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Vincent FINET
3+
Copyright (c) 2022 Salesforce Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

build/bin/OrgCheck_SR.zip

4.55 KB
Binary file not shown.

build/build.sh

Lines changed: 68 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
#/bin/bash
22

3+
4+
### --------------------------------------------------------------------------------------------
5+
### Dependency and other checkings
6+
### --------------------------------------------------------------------------------------------
7+
which uglifyjs 1>/dev/null; if [ $? -ne 0 ]; then
8+
echo 'Uglifyjs is not installed. You can install it via $ npm install uglify-js -g';
9+
exit 1;
10+
fi
11+
which tidy 1>/dev/null; if [ $? -ne 0 ]; then
12+
echo 'Tidy is not installed. You can install it via $ brew tidy';
13+
exit 1;
14+
fi
15+
if [ $(sfdx force:auth:list --json | wc -l) -le 4 ]; then
16+
echo "There is no Salesforce Org authentified with sfdx yet. Please register one with (for example) $ sfdx force:auth:web:login";
17+
exit 2;
18+
fi
19+
if [ $(sfdx config:get defaultusername --json | grep 'value' | wc -l) -eq 0 ]; then
20+
echo "There is no Salesforce Default Username defined with sfdx yet. Please register one with $ sfdx config:set defaultusername=<username>";
21+
exit 3;
22+
fi
23+
24+
25+
26+
### --------------------------------------------------------------------------------------------
27+
### Argument for this script checkings
28+
### --------------------------------------------------------------------------------------------
29+
330
UGLIFY_MODE="$1"
431
UGLIFY_MODE_ON="on"
532
UGLIFY_MODE_OFF="off"
@@ -12,89 +39,77 @@ else
1239
fi
1340
echo ""
1441

15-
### -----------------------
16-
### JAVASCRIPT PART
17-
### -----------------------
1842

19-
for f in build/src/javascript/orgcheck/OrgCheck.*.js; do
43+
44+
### --------------------------------------------------------------------------------------------
45+
### Javascript and static resource build
46+
### --------------------------------------------------------------------------------------------
47+
48+
echo "Javascript build..."
49+
for f in build/src/javascript/orgcheck/OrgCheck.*.js build/src/javascript/orgcheck/OrgCheck.js; do
50+
echo " - $f"
2051
if [ "${UGLIFY_MODE}" == "${UGLIFY_MODE_ON}" ]; then
2152
uglifyjs --ie --webkit --v8 "${f}" -o /tmp/$(basename $f);
2253
else
2354
cat "${f}" > /tmp/$(basename $f);
2455
fi
2556
done
26-
for f in build/src/javascript/orgcheck/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
3357

3458
rm -Rf build/tmp/*
3559
rm -Rf build/bin/*
3660
mkdir build/tmp/js
3761
mkdir build/tmp/img
3862

63+
echo " >> into one unique js file"
3964
(
40-
for f in build/src/javascript/orgcheck/OrgCheck.js; do
41-
cat /tmp/$(basename $f)
42-
done
43-
for f in build/src/javascript/orgcheck/OrgCheck.*.js; do
65+
for f in build/src/javascript/orgcheck/OrgCheck.js build/src/javascript/orgcheck/OrgCheck.*.js; do
4466
cat /tmp/$(basename $f)
4567
done
4668
) > build/tmp/js/orgcheck.js
69+
echo ""
4770

4871
cp build/src/javascript/d3/d3.js build/tmp/js/d3.js
4972
cp build/src/javascript/jsforce/jsforce.js build/tmp/js/jsforce.js
5073
cp build/src/logos/Logo.svg build/tmp/img
5174
cp build/src/logos/Mascot.svg build/tmp/img
5275
cp build/src/logos/Mascot+Animated.svg build/tmp/img
5376

77+
echo "Making a unique zip file"
5478
(
5579
cd build/tmp
5680
zip -9 ../bin/OrgCheck_SR.zip -r ./*
5781
)
82+
echo ""
5883

84+
echo "Transfering the zip into the Salesforce App project"
5985
cp build/bin/OrgCheck_SR.zip force-app/main/default/staticresources/OrgCheck_SR.resource
86+
echo ""
6087

6188

62-
## https://codeinthehole.com/tips/tips-for-using-a-git-pre-commit-hook/
63-
## ln -s ../../pre-commit.sh .git/hooks/pre-commit
64-
65-
##### ln -s ./javascript/build/build-js.sh .git/hooks/pre-commit
66-
67-
89+
### --------------------------------------------------------------------------------------------
90+
### Custom Labels and Translations build
91+
### --------------------------------------------------------------------------------------------
6892

69-
### -----------------------
70-
### LABELS PART
71-
### -----------------------
93+
echo "Custom labels and translations..."
7294

95+
echo " - transfering custom labels (in English) into the Salesforce App project"
7396
cat build/src/labels/CustomLabels-copyandpasted.txt \
7497
| sed -e 's/""/"/g' -e 's/^"//' -e 's/"$//' \
7598
> force-app/main/default/labels/CustomLabels.labels-meta.xml
7699

77-
78-
79-
### -----------------------
80-
### TRANSLATIONS PART
81-
### -----------------------
82-
100+
echo " - transfering French translations into the Salesforce App project"
83101
cat build/src/labels/Translation-FR-copyandpasted.txt \
84102
| sed -e 's/""/"/g' -e 's/^"//' -e 's/"$//' \
85103
> force-app/main/default/translations/fr.translation-meta.xml
86104

105+
echo " - transfering Japanese translations into the Salesforce App project"
87106
cat build/src/labels/Translation-JP-copyandpasted.txt \
88107
| sed -e 's/""/"/g' -e 's/^"//' -e 's/"$//' \
89108
> force-app/main/default/translations/ja.translation-meta.xml
90109

110+
echo ""
91111

92-
93-
94-
95-
### -----------------------
96-
### Generate the TEST page
97-
### -----------------------
112+
echo "Checking if custom labels and translation are correct (the syntax!)"
98113
(
99114
echo '<!DOCTYPE html>';
100115
echo '<html>';
@@ -137,15 +152,23 @@ cat build/src/labels/Translation-JP-copyandpasted.txt \
137152
done
138153
echo ' </body>';
139154
echo '</html>';
140-
) > /tmp/testAll.txt
141-
tidy /tmp/testAll.txt 2>&1 | grep 'Warning' | grep -v 'character code' | sort -t' ' -k2,2n > /tmp/testWarnings
142-
if [ $(cat /tmp/testWarnings | wc -l | tr -d ' ') -ne 0 ]; then
155+
) > /tmp/testAll.html
156+
tidy /tmp/testAll.html 2>/tmp/testAll.err 1>/dev/null
157+
cat /tmp/testAll.err | grep -e ' - Warning: ' | grep -v 'character code' | sort -t' ' -k2,2n > /tmp/testWarnings.err
158+
rm /tmp/testAll.html
159+
rm /tmp/testAll.err
160+
if [ $(cat /tmp/testWarnings.err | wc -l | tr -d ' ') -ne 0 ]; then
143161
echo "WARNINGS:"
144-
cat /tmp/testWarnings
162+
cat /tmp/testWarnings.err
163+
rm /tmp/testWarnings.err
164+
exit 100;
145165
fi
166+
rm /tmp/testWarnings.err
167+
echo "OK"
168+
echo ""
146169

147-
148-
### -----------------------
149-
### PUSH INTO DEV ORG
150-
### -----------------------
151-
### sfdx force:source:deploy -m StaticResource:OrgCheck_OrgCheck_SR,CustomLabels,Translations 1>/dev/null
170+
### --------------------------------------------------------------------------------------------
171+
### If everything is OK push the resulting built items into dev org
172+
### --------------------------------------------------------------------------------------------
173+
echo "Deploying to default org (username=$(sfdx config:get defaultusername --json | grep value | cut -d'"' -f4))"
174+
sfdx force:source:deploy -m StaticResource,CustomLabels,Translations 1>/dev/null

build/package.readme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ List of usefull commands for packaging
3232
============================================================
3333
sfdx force:package:version:list --targetdevhubusername vfinet.devhub@salesforce.com
3434
sfdx force:package:version:create --targetdevhubusername vfinet.devhub@salesforce.com --package OrgCheck --definitionfile config/project-scratch-def.json --installationkeybypass --codecoverage --wait 10
35-
sfdx force:package:version:promote --targetdevhubusername vfinet.devhub@salesforce.com --package OrgCheck@2.1.2-0
35+
sfdx force:package:version:promote --targetdevhubusername vfinet.devhub@salesforce.com --package OrgCheck@2.4.1-0
3636

3737

3838

build/src/javascript/d3/d3.LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2010-2021 Mike Bostock
2+
3+
Permission to use, copy, modify, and/or distribute this software for any purpose
4+
with or without fee is hereby granted, provided that the above copyright notice
5+
and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
11+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
12+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
13+
THIS SOFTWARE.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2011 Shinichi Tomita <shinichi.tomita@gmail.com>;
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

build/src/javascript/orgcheck/OrgCheck.Cache.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ OrgCheck.Cache = {
4444
const SECTION = configuration.section;
4545

4646
/**
47-
* Method to clear all OrgCheck cached items
47+
* Method to clear all Org Check cached items
4848
*/
4949
this.clearAll = function () {
5050
let keys_to_remove = private_get_keys();
@@ -54,7 +54,7 @@ OrgCheck.Cache = {
5454
};
5555

5656
/**
57-
* Method to clear one OrgCheck cached item
57+
* Method to clear one Org Check cached item
5858
* @param key in cache (without the prefix) to use
5959
* @return the previous value that has been deleted
6060
*/
@@ -144,12 +144,38 @@ OrgCheck.Cache = {
144144
}
145145
};
146146

147+
/**
148+
* Method to get a property of an item from the cache
149+
* @param key in cache (without the prefix) to use
150+
* @param propertyKey the key of the property within the value in cache
151+
* @param defaultPropertyValue if the cache is not present or the property is not set, return that value
152+
* @return the value for this property
153+
*/
154+
this.getItemProperty = function (key, propertyKey, defaultPropertyValue) {
155+
const value = private_get_item(key) || {};
156+
const propertyValue = value[propertyKey];
157+
if (propertyValue === undefined) return defaultPropertyValue;
158+
return propertyValue;
159+
};
160+
161+
/**
162+
* Method to set a property of an item from the cache
163+
* @param key in cache (without the prefix) to use
164+
* @param propertyKey the key of the property within the value in cache
165+
* @param propertyValue the value for this property
166+
*/
167+
this.setItemProperty = function (key, propertyKey, propertyValue) {
168+
const value = private_get_item(key) || {};
169+
value[propertyKey] = propertyValue;
170+
private_set_item(key, value);
171+
};
172+
147173
/**
148174
* Log actions from the cache
149175
* @param e Error
150176
*/
151177
function private_log_error(e) {
152-
console.error("[OrgCheck:Cache]", { error: e });
178+
console.error("[Org Check:Cache]", { error: e });
153179
}
154180

155181
/**
@@ -161,8 +187,8 @@ OrgCheck.Cache = {
161187
}
162188

163189
/**
164-
* Returns all the OrgCheck keys in cache
165-
* @return All the keys of the OrgCheck cache for the given section
190+
* Returns all the Org Check keys in cache
191+
* @return All the keys of the Org Check cache for the given section
166192
*/
167193
function private_get_keys() {
168194
const prefix = private_generate_prefix();
@@ -219,7 +245,7 @@ OrgCheck.Cache = {
219245
}
220246

221247
/**
222-
* Private method to clear one OrgCheck cached item
248+
* Private method to clear one Org Check cached item
223249
* @param key in cache (without the prefix) to use
224250
* @return the previous value that has been deleted
225251
*/

0 commit comments

Comments
 (0)