Skip to content

Commit

Permalink
Merge pull request #359 from SalesforceLabs/Beryllium
Browse files Browse the repository at this point in the history
Beryllium
  • Loading branch information
VinceFINET authored Mar 14, 2024
2 parents defbf95 + 509da1b commit a4b3491
Show file tree
Hide file tree
Showing 221 changed files with 25,402 additions and 5,571 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["@salesforce/eslint-config-lwc/recommended"]
}
16 changes: 0 additions & 16 deletions .vscode/launch.json

This file was deleted.

Binary file modified build/bin/OrgCheck_SR.zip
Binary file not shown.
93 changes: 58 additions & 35 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -1,58 +1,61 @@
#/bin/bash

Black='\033[0;30m'
DarkGray='\033[1;30m'
LightGray='\033[0;37m'
Red='\033[0;31m'
LightRed='\033[1;31m'
Green='\033[0;32m'
LightGreen='\033[1;32m'
Orange='\033[0;33m'
Yellow='\033[1;33m'
Blue='\033[0;34m'
LightBlue='\033[1;34m'
Purple='\033[0;35m'
LightPurple='\033[1;35m'
Cyan='\033[0;36m'
LightCyan='\033[1;36m'
White='\033[1;37m'
NoColor='\033[0m'

### --------------------------------------------------------------------------------------------
### Dependency and other checkings
### --------------------------------------------------------------------------------------------
which uglifyjs 1>/dev/null; if [ $? -ne 0 ]; then
echo 'Uglifyjs is not installed. You can install it via $ npm install uglify-js -g';
echo -e "${Red}Uglifyjs is not installed.${NoColor}"
echo -e "${LightRed}For example, you could install it via $ npm install uglify-js -g${NoColor}";
exit 1;
fi
which tidy 1>/dev/null; if [ $? -ne 0 ]; then
echo 'Tidy is not installed. You can install it via $ brew tidy';
echo -e "${Red}Tidy is not installed.${NoColor}"
echo -e "${LightRed}For example, you could install it via $ brew tidy${NoColor}";
exit 1;
fi
if [ $(sfdx force:auth:list --json | wc -l) -le 4 ]; then
echo "There is no Salesforce Org authentified with sfdx yet. Please register one with (for example) $ sfdx force:auth:web:login";
echo -e "${Red}There is no Salesforce Org authentified with sfdx yet.${NoColor}"
echo -e "${LightRed}Please register one with (for example) $ sfdx force:auth:web:login${NoColor}";
exit 2;
fi
if [ $(sfdx config:get defaultusername --json | grep 'value' | wc -l) -eq 0 ]; then
echo "There is no Salesforce Default Username defined with sfdx yet. Please register one with $ sfdx config:set defaultusername=<username>";
echo -e "${Red}There is no Salesforce Default Username defined with sfdx yet.${NoColor}"
echo -e "${LightRed}Please register one with $ sfdx config:set defaultusername=<username>${NoColor}";
exit 3;
fi



### --------------------------------------------------------------------------------------------
### Argument for this script checkings
### --------------------------------------------------------------------------------------------

UGLIFY_MODE="$1"
UGLIFY_MODE_ON="on"
UGLIFY_MODE_OFF="off"
if [ "X${UGLIFY_MODE}" == "X${UGLIFY_MODE_OFF}" ]; then
echo "Uglify Mode is off"
UGLIFY_MODE="${UGLIFY_MODE_OFF}"
else
echo "Uglify Mode is on"
UGLIFY_MODE="${UGLIFY_MODE_ON}"
fi
echo ""



### --------------------------------------------------------------------------------------------
### Javascript and static resource build
### --------------------------------------------------------------------------------------------
TYPE_ORIGINAL=orginal
TYPE_UGLIFIED=uglified

echo "Javascript build..."
for f in build/src/javascript/orgcheck/OrgCheck.*.js build/src/javascript/orgcheck/OrgCheck.js; do
echo " - $f"
if [ "${UGLIFY_MODE}" == "${UGLIFY_MODE_ON}" ]; then
uglifyjs --ie --webkit --v8 "${f}" -o /tmp/$(basename $f);
else
cat "${f}" > /tmp/$(basename $f);
fi
uglifyjs --ie --webkit --v8 "${f}" -o /tmp/${TYPE_UGLIFIED}-$(basename $f);
cat "${f}" > /tmp/${TYPE_ORIGINAL}-$(basename $f);
done

rm -Rf build/tmp/*
Expand All @@ -61,23 +64,41 @@ mkdir build/tmp/js
mkdir build/tmp/img

echo " >> into one unique js file"
(
for f in build/src/javascript/orgcheck/OrgCheck.js build/src/javascript/orgcheck/OrgCheck.*.js; do
cat /tmp/$(basename $f)
done
) > build/tmp/js/orgcheck.js
for type in ${TYPE_ORIGINAL} ${TYPE_UGLIFIED}; do
(
for f in build/src/javascript/orgcheck/${type}-OrgCheck.js build/src/javascript/orgcheck/${type}-OrgCheck.*.js; do
cat /tmp/$(basename $f)
done
) > build/tmp/js/${type}-orgcheck.js
done
echo ""

## echo "Launch the scan for Org Check javascript"
## REPORT_FILE=build/reports/report-javascript
## for type in html csv; do
## sfdx scanner:run --target "build/tmp/js/${TYPE_ORIGINAL}-orgcheck.js" --format ${type} > ${REPORT_FILE}.${type} 2> /dev/null
## done;
## if [ $(grep 'No rule violations found' ${REPORT_FILE}.csv | wc -l) -eq 1 ]; then
## echo -e "${LightGreen}Congratulations! No syntax issues.${NoColor}";
## else
## echo -e "${Red}You have $(( $(grep -v '^$' ${REPORT_FILE}.csv | wc -l) - 1 )) issue(s) you need to check.${NoColor}"
## echo -e "${LightRed}Open the file ${REPORT_FILE}.html in your browser.${NoColor}";
## fi
## echo ""

mv build/tmp/js/${TYPE_UGLIFIED}-orgcheck.js build/tmp/js/orgcheck.js
cp build/src/javascript/orgcheck/orgcheck-api.js build/tmp/js/orgcheck-api.js
cp build/src/javascript/d3/d3.js build/tmp/js/d3.js
cp build/src/javascript/jsforce/jsforce.js build/tmp/js/jsforce.js
cp build/src/javascript/sheetjs/xlsx.js build/tmp/js/xlsx.js
cp build/src/logos/Logo.svg build/tmp/img
cp build/src/logos/Mascot.svg build/tmp/img
cp build/src/logos/Mascot+Animated.svg build/tmp/img

echo "Making a unique zip file"
(
cd build/tmp
zip -9 ../bin/OrgCheck_SR.zip -r ./*
zip -9 ../bin/OrgCheck_SR.zip -r ./* -x ./build/tmp/js/${TYPE_ORIGINAL}-orgcheck.js
)
echo ""

Expand Down Expand Up @@ -158,17 +179,19 @@ cat /tmp/testAll.err | grep -e ' - Warning: ' | grep -v 'character code' | sort
rm /tmp/testAll.html
rm /tmp/testAll.err
if [ $(cat /tmp/testWarnings.err | wc -l | tr -d ' ') -ne 0 ]; then
echo "WARNINGS:"
echo -e "${Red}WARNINGS:"
cat /tmp/testWarnings.err
echo -e "${NoColor}"
rm /tmp/testWarnings.err
exit 100;
fi
rm /tmp/testWarnings.err
echo "OK"
echo -e "${LightGreen}OK${NoColor}"
echo ""

### --------------------------------------------------------------------------------------------
### If everything is OK push the resulting built items into dev org
### --------------------------------------------------------------------------------------------
echo "Deploying to default org (username=$(sfdx config:get defaultusername --json | grep value | cut -d'"' -f4))"
echo "Deploying to default org (username=$(sfdx config:get target-org --json | grep value | cut -d'"' -f4))"
sfdx project deploy start --metadata StaticResource CustomLabels Translations 1>/dev/null

1 change: 1 addition & 0 deletions build/reports/report-javascript.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executed engines: pmd, eslint, retire-js. No rule violations found.
1 change: 1 addition & 0 deletions build/reports/report-javascript.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Executed engines: pmd, eslint, retire-js. No rule violations found.
2 changes: 1 addition & 1 deletion build/src/javascript/d3/d3.LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2010-2021 Mike Bostock
Copyright 2010-2023 Mike Bostock

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
Expand Down
4 changes: 2 additions & 2 deletions build/src/javascript/d3/d3.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/src/javascript/d3/install.readme
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Name: Data-Driven Documents framework
Website: https://d3js.org/
Version: v7.3.0 minimized
Source: https://registry.npmjs.org/d3/-/d3-7.3.0.tgz
Version: v7.8.5 minimized
Source: https://registry.npmjs.org/d3/-/d3-7.8.5.tgz
File renamed without changes.
8 changes: 4 additions & 4 deletions build/src/javascript/orgcheck/OrgCheck.DataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
* @param value to format (number if a timestamp, string otherwise)
*/
this.dateFormat = (value) => {
return private_date_format(value, UserContext?.dateFormat,
return private_date_format(value, OrgCheck.externalLibs.salesforce.usercontext?.dateFormat,
configuration.defaultDateFormat
);
};
Expand All @@ -77,7 +77,7 @@
* @param value to format (number if a timestamp, string otherwise)
*/
this.datetimeFormat = (value) => {
return private_date_format(value, UserContext?.dateTimeFormat,
return private_date_format(value, OrgCheck.externalLibs.salesforce.usercontext?.dateTimeFormat,
configuration.defaultDatetimeFormat
);
};
Expand All @@ -91,7 +91,7 @@
const private_date_format = (value, format, formatIfNull) => {
if (value) {
const timestamp = typeof value === "number" ? value : Date.parse(value);
return DateUtil.formatDate(new Date(timestamp), format ? format : formatIfNull);
return OrgCheck.externalLibs.salesforce.dateutil?.formatDate(new Date(timestamp), format ? format : formatIfNull);
}
return '';
}
Expand Down Expand Up @@ -156,7 +156,7 @@
*/
this.setValue = (map, key, value) => {
if (private_is_safe_key(key)) {
if (map.hasOwnProperty(key) === false) map[configuration.keySize]++;;
if (Object.prototype.hasOwnProperty.call(map, key) === false) map[configuration.keySize]++;
map[key] = value;
}
};
Expand Down
13 changes: 6 additions & 7 deletions build/src/javascript/orgcheck/OrgCheck.Datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ OrgCheck.Datasets = {
* @return true or false
*/
this.hasDataset = (name) => {
return private_datasets_collection.hasOwnProperty(name);
return Object.prototype.hasOwnProperty.call(private_datasets_collection, name);
};

/**
Expand Down Expand Up @@ -83,9 +83,9 @@ OrgCheck.Datasets = {
const METADATA_CACHE_HANDLER = handlers.MetadataCacheHandler;

/**
* Preference Cache handler to use for perfomance
* Preference Cache handler to use for perfomance (unused)
*/
const PREFERENCE_CACHE_HANDLER = handlers.PreferenceCacheHandler;
//const PREFERENCE_CACHE_HANDLER = handlers.PreferenceCacheHandler;

/**
* Map handler for output data
Expand Down Expand Up @@ -147,7 +147,6 @@ OrgCheck.Datasets = {
*/
this.runDatasets = (datasets, dependencies, decorators) => {
const onLoadPromises = [];
const errors = [];
datasets.forEach(ds => {
decorators.startDatasetDecorator(ds);
const dataset = private_datasets.getDataset(ds);
Expand Down Expand Up @@ -603,7 +602,7 @@ OrgCheck.Datasets = {
value.description = psgByName2[key].description;
value.isUndescribedCustom = value.isCustom && !value.description;
MAP_HANDLER.setValue(records, value.id, value);
};
}
resolve(records);
})
.on('error', (error) => reject(error))
Expand Down Expand Up @@ -744,7 +743,7 @@ OrgCheck.Datasets = {
}
MAP_HANDLER.setValue(records, item.name, item);
});
};
}
resolve(records);
})
.on('error', (err) => reject(err))
Expand Down Expand Up @@ -1294,7 +1293,7 @@ OrgCheck.Datasets = {
case 'testMethod': item.isTest = true; break;
}
});
};
}
}
}
if (item.isEnum === true || item.isInterface === true) item.specifiedSharing = 'n/a';
Expand Down
27 changes: 18 additions & 9 deletions build/src/javascript/orgcheck/OrgCheck.Salesforce.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ OrgCheck.Salesforce = {
'error': (error) => { console.error(error); }
};
const private_error_event = private_events.error;
this.has = (name) => private_events.hasOwnProperty(name);
this.has = (name) => Object.prototype.hasOwnProperty.call(private_events, name);
this.fire = (name, ...args) => {
if (private_events.hasOwnProperty(name)) {
if (Object.prototype.hasOwnProperty.call(private_events, name)) {
private_events[name](...args);
}
};
Expand Down Expand Up @@ -133,7 +133,7 @@ OrgCheck.Salesforce = {
}));
promises.push(new Promise((resolve, reject) => {
const query = 'SELECT DurableId, Description, NamespacePrefix, ExternalSharingModel, InternalSharingModel, '+
'(SELECT Id, DurableId, QualifiedApiName, Description FROM Fields), '+
'(SELECT Id, DurableId, QualifiedApiName, Description, BusinessOwner.Name, BusinessStatus, ComplianceGroup, SecurityClassification FROM Fields), '+
'(SELECT Id, Name FROM ApexTriggers), '+
'(SELECT Id, MasterLabel, Description FROM FieldSets), '+
'(SELECT Id, Name, LayoutType FROM Layouts), '+
Expand Down Expand Up @@ -266,14 +266,22 @@ OrgCheck.Salesforce = {
const fieldIds = [];
entityDef.Fields.records.forEach((r) => {
const id = r.DurableId.split('.')[1];
fieldsMapper[r.QualifiedApiName] = { 'id': id, 'description': r.Description };
fieldsMapper[r.QualifiedApiName] = {
'id': id,
'description': r.Description,
'dataOwner': r.BusinessOwner?.Name, // Data Owner Name
'fieldUsage': r.BusinessStatus, // Field Usage
'complianceCategory': r.ComplianceGroup, // Compliance Categorization
'dataSensitivityLevel': r.SecurityClassification // Data Sensitivity Level
};
fieldIds.push(id);
});
object.fields.forEach((f) => {
const mapper = fieldsMapper[f.name];
if (mapper) {
f.id = mapper.id;
f.description = mapper.description;
for (const property in mapper) {
f[property] = mapper[property];
}
}
});
dapi(fieldIds, (deps) => {
Expand Down Expand Up @@ -393,8 +401,9 @@ OrgCheck.Salesforce = {
error.context = {
when: 'While creating a promise to call the Tooling Composite API.',
what: {
type: metadataInformation.type,
ids: metadataInformation.ids,
type: type,
ids: ids,
byPasses: byPasses,
body: requestBody
}
};
Expand Down Expand Up @@ -492,7 +501,7 @@ OrgCheck.Salesforce = {
/**
* Private connection to Salesforce using JsForce
*/
const CONNECTION = new jsforce.Connection({
const CONNECTION = new OrgCheck.externalLibs.jsforce.Connection({
accessToken: configuration.accessToken,
version: API_VERSION + ".0",
maxRequest: "10000",
Expand Down
4 changes: 2 additions & 2 deletions build/src/javascript/orgcheck/OrgCheck.Shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
'naht relooc hcum si eman siht kniht uoy fi ,>b/<grOmedloV>b< dellac saw loot taht'+
' ylsuoiverp taht wonk uoy diD');_z.appendChild(_x);_z.appendChild(_y);_y.width=
_a.innerWidth;_y.height=_a.innerHeight;const _u=Array.from({length:_y.width/16})
.fill(_y.height);let _t='';for(i=12449;i<=12532;i++)_t+=String.fromCharCode(i);
for(i=48;i<=90;i++)_t+=String.fromCharCode(i);const _q=()=>{_v.fillStyle='rgb'+
.fill(_y.height);let _t='';for(let i=12449;i<=12532;i++)_t+=String.fromCharCode(i);
for(let i=48;i<=90;i++)_t+=String.fromCharCode(i);const _q=()=>{_v.fillStyle='rgb'+
'a(0,0,0,0.05)';_v.fillRect(0,0,_y.width,_y.height);_v.fillStyle='#0F0';_v.font
=16+_d('ecapsonom xp');for(let i=0;i<_u.length;i++){_v.fillText(_t.charAt(Math.
floor(Math.random()*_t.length)),i*16,_u[i]*16);if(_u[i]*16>_y.height && Math.
Expand Down
Loading

0 comments on commit a4b3491

Please sign in to comment.