Skip to content

Commit

Permalink
Merge pull request #363 from vlocityinc/beta
Browse files Browse the repository at this point in the history
Allow OS / Cards to Compile - New Minor Version
  • Loading branch information
Adam Rutland authored Mar 3, 2021
2 parents 9b6c6b7 + ddccf77 commit f2bbc53
Show file tree
Hide file tree
Showing 20 changed files with 1,442 additions and 339 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ vlocity-temp/
example_vlocity_build/
test/testJobRunning/
test/salesforce_sfdx_test/
testJobRunning/testBuildFile.*
.nyc_output/
.vscode/
.sfdx/
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Vlocity Build is a command line tool to export and deploy Vlocity DataPacks in a
- [Vlocity Build + Salesforce DX](#vlocity-build--salesforce-dx)
- [Vlocity Managed Package](#vlocity-managed-package)
- [Running in Jenkins](#running-in-jenkins)
- [Auto Compilation of LWC OmniScript and Cards](#auto-compilation-of-lwc-omniscript-and-cards)
- [The Job File](#the-job-file)
- [What will be Exported?](#what-will-be-exported)
- [Example Job File](#example-job-file)
Expand Down Expand Up @@ -379,6 +380,20 @@ The first step of setting up Jenkins for this project is adding the JWT Bindings
Then adding the build step:
![Build](doc/Build.png)

## Auto Compilation of LWC OmniScript and Cards
The Vlocity Build Tool will not automatically compile and deploy OmniScript and Cards LWCs after Activation through Puppeteer or Chrome installed on your local machine. To install puppeteer into a build machine or locally run:
```
npm install puppeteer -g
```

If you system has Chrome installed VBT will automatically start a headless chrome session, authentictae to the deployment org, and use a page in the Vlocity Managed Package to compile and deploy the OmniScript or Card.

To disable this feature add to your Job File:
ignoreLWCActivationOS: true
ignoreLWCActivationCards: true

Otherwise these are now on by default.

# The Job File
A Job File is similar to a Salesforce package.xml file, however it also includes runtime options like the maximum number of concurrent API calls running.

Expand Down Expand Up @@ -705,6 +720,8 @@ The Job file additionally supports some Vlocity Build based options and the opti
| useAllRelationships | Determines whether or not to store the _AllRelations.json file which may not generate consistently enough for Version Control. Recommended to set to false. | Boolean | true |
| useVlocityTriggers | Boolean | Turn on / off Vlocity's AllTriggers Custom Setting during the Deploy | true |
| disableVlocityTriggers | Boolean | Turn off Vlocity's AllTriggers Custom Setting during the Deploy | false |
| ignoreLWCActivationOS | Boolean | Do not compile and deploy LWC OmniScripts | false |
| ignoreLWCActivationCards | Boolean | Do not compile and deploy LWC Cards | false |

## Vlocity Build Options
| Option | Description | Type | Default |
Expand Down
2 changes: 2 additions & 0 deletions lib/buildToolsMinVersionCards-LWC.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vlocity_cmt: '900.394'
vlocity_ins: '890.272'
2 changes: 2 additions & 0 deletions lib/buildToolsMinVersionOS-LWC.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vlocity_cmt: '900.374'
vlocity_ins: '890.220'
10 changes: 8 additions & 2 deletions lib/datapacksbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,13 @@ DataPacksBuilder.prototype.initializeTypeAtPath = async function(dataPackTypeDir
try {
await this.loadFilesAtPath(path.join(dataPackTypeDir, dataPackName), jobInfo, dataPackKey);
var sobjectData = JSON.parse(self.getFileData(metadataFilename));
var generatedDataPackKey = dataPackType + '/' + self.vlocity.datapacksexpand.getDataPackFolder(dataPackType, sobjectData.VlocityRecordSObjectType, sobjectData);

let sObjDataRecordType = sobjectData.VlocityRecordSObjectType;
if (jobInfo.upgradeDataPackFields && !this.vlocity.namespace) {
sObjDataRecordType = sObjDataRecordType.replace('%vlocity_namespace%__', '');
}

var generatedDataPackKey = dataPackType + '/' + self.vlocity.datapacksexpand.getDataPackFolder(dataPackType, sObjDataRecordType, sobjectData);

jobInfo.keysToDirectories[generatedDataPackKey] = dataPackType + '/' + dataPackName;

Expand All @@ -565,7 +571,7 @@ DataPacksBuilder.prototype.initializeTypeAtPath = async function(dataPackTypeDir

var apexImportData = {};

self.vlocity.datapacksutils.getApexImportDataKeys(sobjectData.VlocityRecordSObjectType).forEach(function(field) {
self.vlocity.datapacksutils.getApexImportDataKeys(sObjDataRecordType).forEach(function(field) {
apexImportData[field] = sobjectData[field];
});

Expand Down
53 changes: 32 additions & 21 deletions lib/datapacksexpand.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DataPacksExpand.prototype.generateFilepath = function(dataPackType, parentName,
return this.generateFolderPath(dataPackType, parentName) + validFileName;
};

DataPacksExpand.prototype.getNameWithFields = function(nameFields, dataPackData) {
DataPacksExpand.prototype.getNameWithFields = function(nameFields, dataPackData, isUpgradeDataPackFields) {
var self = this;
var processedNames = (nameFields || []).map(function(key) {
if(dataPackData && !dataPackData[key]){
Expand All @@ -83,7 +83,7 @@ DataPacksExpand.prototype.getNameWithFields = function(nameFields, dataPackData)
} else if (dataPackData[key] && typeof dataPackData[key] === "string") {
return dataPackData[key].replace(/[/\\]+/g,' '); // do not allow directory slashes in names
} else if (dataPackData[key] != null && typeof dataPackData[key] === "object") {
return self.getDataPackFolder(null, dataPackData[key].VlocityRecordSObjectType, dataPackData[key]);
return self.getDataPackFolder(null, dataPackData[key].VlocityRecordSObjectType, dataPackData[key], isUpgradeDataPackFields);
}
});

Expand All @@ -97,18 +97,18 @@ DataPacksExpand.prototype.getNameWithFields = function(nameFields, dataPackData)
return null;
};

DataPacksExpand.prototype.getDataPackName = function(dataPackType, sObjectType, dataPackData) {
var name = this.getNameWithFields(this.vlocity.datapacksutils.getFileName(dataPackType, sObjectType), dataPackData);
DataPacksExpand.prototype.getDataPackName = function(dataPackType, sObjectType, dataPackData, isUpgradeObjects) {
var name = this.getNameWithFields(this.vlocity.datapacksutils.getFileName(dataPackType, sObjectType, isUpgradeObjects), dataPackData);
return name ? name : dataPackType;
};

DataPacksExpand.prototype.getListFileName = function(dataPackType, sObjectType, dataPackData) {
var name = this.getNameWithFields(this.vlocity.datapacksutils.getListFileName(dataPackType, sObjectType), dataPackData);
DataPacksExpand.prototype.getListFileName = function(dataPackType, sObjectType, dataPackData, isUpgradeObjects) {
var name = this.getNameWithFields(this.vlocity.datapacksutils.getListFileName(dataPackType, sObjectType, isUpgradeObjects), dataPackData);
return name ? name : dataPackType;
};

DataPacksExpand.prototype.getDataPackFolder = function(dataPackType, sObjectType, dataPackData) {
return this.getNameWithFields(this.vlocity.datapacksutils.getFolderName(dataPackType, sObjectType), dataPackData);
DataPacksExpand.prototype.getDataPackFolder = function(dataPackType, sObjectType, dataPackData, isUpgradeObjects) {
return this.getNameWithFields(this.vlocity.datapacksutils.getFolderName(dataPackType, sObjectType, isUpgradeObjects), dataPackData);
};

DataPacksExpand.prototype.buildHierarchyKey = function(listDataBySourceKey, sortFields, listRec, depth) {
Expand Down Expand Up @@ -220,7 +220,7 @@ DataPacksExpand.prototype.processList = async function(dataPackType, parentName,
listData.forEach(function(dataPack) {
self.processObjectEntry(dataPackType, dataPack, isPagination);
});

var fileType = self.vlocity.datapacksutils.getFileType(dataPackType, sObjectType);

listData = self.sortList(listData, dataPackType);
Expand Down Expand Up @@ -559,6 +559,7 @@ DataPacksExpand.prototype.preprocessSObjects = async function(currentData, dataP

} else {


// Remove all Fields with . in them like AttributeId__r.CategoryName__c
Object.keys(currentData).forEach(function(fieldKey) {
if (fieldKey.indexOf('.') != -1 && typeof currentData[fieldKey] === 'object') {
Expand Down Expand Up @@ -608,8 +609,10 @@ DataPacksExpand.prototype.preprocessSObjects = async function(currentData, dataP

var defaultFilterFields = self.vlocity.datapacksutils.getFilterFields(null, 'All');

defaultFilterFields.forEach(function(field) {
delete currentData[field];
defaultFilterFields.forEach(function (field) {
if (field === 'HierarchyKey' || currentData.VlocityRecordSObjectType) {
delete currentData[field];
}
});

var filterFields = self.vlocity.datapacksutils.getFilterFields(dataPackType, currentData.VlocityRecordSObjectType);
Expand Down Expand Up @@ -702,8 +705,10 @@ DataPacksExpand.prototype.preprocessSObjects = async function(currentData, dataP

var sourceKeyData = self.getSourceKeyData(currentData, jobInfo);

currentData.VlocityRecordSourceKey = sourceKeyData.VlocityRecordSourceKeyNew;
currentData.VlocityRecordSourceKeyOriginal = sourceKeyData.VlocityRecordSourceKeyOriginal;
if (sourceKeyData.VlocityRecordSourceKeyOriginal) {
currentData.VlocityRecordSourceKey = sourceKeyData.VlocityRecordSourceKeyNew;
currentData.VlocityRecordSourceKeyOriginal = sourceKeyData.VlocityRecordSourceKeyOriginal;
}

if (currentData.VlocityDataPackType != 'VlocityLookupMatchingKeyObject'
&& currentData.VlocityDataPackType != 'VlocityMatchingKeyObject') {
Expand Down Expand Up @@ -781,8 +786,9 @@ DataPacksExpand.prototype.preprocessDataPack = async function(currentData, jobIn
for (var sobjectData of currentData.VlocityDataPackData[dataField]) {
if (sobjectData) {
await self.preprocessSObjects(sobjectData, currentData.VlocityDataPackType, currentData.VlocityDataPackKey, jobInfo, currentData.VlocityDataPackParents);

var parentName = self.getDataPackFolder(dataPackType, sobjectData.VlocityRecordSObjectType, sobjectData);

let sObjDataRecordType = sobjectData.VlocityRecordSObjectType;
var parentName = self.getDataPackFolder(dataPackType, sObjDataRecordType, sobjectData, jobInfo.upgradeDataPackFields);
var generatedKey = dataPackType + "/" + parentName;

jobInfo.vlocityKeysToNewNamesMap[currentData.VlocityDataPackKey] = generatedKey;
Expand Down Expand Up @@ -884,13 +890,15 @@ DataPacksExpand.prototype.updateSourceKeysInDataPack = function(currentData, job
}
}

Object.keys(currentData).forEach(function(sobjectField) {
Object.keys(currentData).forEach(function (sobjectField) {

if (typeof currentData[sobjectField] === "object") {
self.updateSourceKeysInDataPack(currentData[sobjectField], jobInfo, allLocalKeys, parentKey);
} else if (jobInfo.vlocityRecordSourceKeyMap[currentData[sobjectField]]) {
// This attempts to replace any Id with a SourceKey
currentData[sobjectField] = jobInfo.vlocityRecordSourceKeyMap[currentData[sobjectField]].VlocityRecordSourceKeyNew;
if (currentData.VlocityRecordSObjectType) {
currentData[sobjectField] = jobInfo.vlocityRecordSourceKeyMap[currentData[sobjectField]].VlocityRecordSourceKeyNew;
}
}
});

Expand Down Expand Up @@ -958,8 +966,9 @@ DataPacksExpand.prototype.processDataPack = async function(dataPackData, jobInfo
delete dataPackData.VlocityDataPackData[dataField][0].targetOrgUrl;
}

var parentName = self.getDataPackFolder(dataPackType, sobjectData.VlocityRecordSObjectType, sobjectData);
var dataPackName = self.getDataPackName(dataPackType, sobjectData.VlocityRecordSObjectType, sobjectData);
let sObjDataRecordType = sobjectData.VlocityRecordSObjectType;
var parentName = self.getDataPackFolder(dataPackType, sObjDataRecordType, sobjectData, jobInfo.upgradeDataPackFields);
var dataPackName = self.getDataPackName(dataPackType, sObjDataRecordType, sobjectData, jobInfo.upgradeDataPackFields);

var labelData = JSON.parse(JSON.stringify(sobjectData));
labelData.VlocityDataPackType = dataPackData.VlocityDataPackType;
Expand Down Expand Up @@ -1074,7 +1083,9 @@ DataPacksExpand.prototype.processDataPackData = async function(dataPackType, par

if (dataPackData.VlocityRecordSObjectType) {
var sObjectType = dataPackData.VlocityRecordSObjectType;

if (jobInfo.upgradeDataPackFields && !this.vlocity.namespace) {
sObjectType = sObjectType.replace('%vlocity_namespace%__', '');
}
var currentObjectName = this.getDataPackName(dataPackType, sObjectType, dataPackData);

var packName = null;
Expand Down
Loading

0 comments on commit f2bbc53

Please sign in to comment.