Skip to content

Commit

Permalink
Merge pull request #599 from vlocityinc/beta
Browse files Browse the repository at this point in the history
Changes to ignore the local compilation
  • Loading branch information
manas-sf authored Jul 17, 2023
2 parents 7fa6deb + 385cc65 commit cd74d8f
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 33 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ ignoreLWCActivationCards: true

Otherwise these are now on by default.

To disable the local compilation of the FlexCards so that the npmAuthKey is used only for the local compilation of OmniScript. In this case legacy method would be used for the FlexCard LWC activation:

```
ignoreLocalCompilationCards: true
```

In cases where there is a specific executable path for Chrome, or there is no interest in the use of its headless feature, it is possible to do as follows:
```
puppeteerHeadless: false
Expand Down Expand Up @@ -453,6 +459,12 @@ when set to false or ommited, this is the expected output:

![Bindings](doc/deployGeneratedLwcWithSfdxCli.png)

To keep OmniScript activated post deployment and activation, in case of LWC deployment failure, Please add below parameter:

```
keepOSActiveWhenLWCDeploymentFails: true
```

*obs: At the moment, configuring this property only affects OmniScript / FlexCards local compilation step*

# The Job File
Expand Down Expand Up @@ -769,7 +781,7 @@ The Job file additionally supports some Vlocity Build based options and the opti
## Job Options
| Option | Description | Type | Default |
| ------------- |------------- |----- | -----|
| activate | Will Activate everything after it is imported / deployed | Boolean | false |
| activate | Will Activate everything after it is imported / deployed | Boolean | true |
| addSourceKeys | Generate Global / Unique Keys for Records that are missing this data. Improves ability to import exported data | Boolean | false |
| autoFixPicklists | Makes metadata changes across orgs for Vlocity Managed Package fields automatically propagate and eliminates errors due to this missing metadata. Does not work for Managed Global Value Sets - Like Vlocity's CurrencyCode field. | Boolean | true |
| autoRetryErrors | Will automatically retry after a deploy to see if any errors can be fixed by retrying due primarily to references that did not correctly resolve | Boolean | false |
Expand Down Expand Up @@ -1030,6 +1042,7 @@ These types are what would be specified when creating a Query or Manifest for th
| DocumentTemplate | DocumentTemplate__c<br>DocumentTemplateSection__c<br>DocumentTemplateSectionCondition__c |
| EntityFilter | EntityFilter__c<br>EntityFilterCondition__c<br>EntityFilterMember__c<br>EntityFilterConditionArgument__c |
| IntegrationProcedure | OmniScript__c<br>Element__c |
| IntegrationRetryPolicy | IntegrationRetryPolicy__c |
| InterfaceImplementation | InterfaceImplementation__c<br>InterfaceImplementationDetail__c |
| ItemImplementation | ItemImplementation__c |
| ManualQueue | ManualQueue__c |
Expand Down
30 changes: 27 additions & 3 deletions lib/datapacksjob.js
Original file line number Diff line number Diff line change
Expand Up @@ -2820,9 +2820,33 @@ DataPacksJob.prototype.deployJob = async function(jobInfo) {
);
}
} catch (err) {
VlocityUtils.log(err);
jobInfo.errors.push( "Exception while deploying compiled LWC components:\n" + JSON.stringify(err, null, 2));
jobInfo.hasError = true;
if (jobInfo.keepOSActiveWhenLWCDeploymentFails) {
if (err.result && err.result.details && err.result.details.componentSuccesses) {
err.result.details.componentSuccesses
.forEach((metadata) => {
if (metadata.componentType) {
var metadataKey = `${metadata.componentType}/${metadata.fullName}`;
VlocityUtils.success('Metadata Deployed', metadataKey);
jobInfo.currentStatus[metadataKey] = 'Success';
}
}
);
err.result.details.componentFailures
.forEach((metadata) => {
if (metadata.componentType) {
var metadataKey = `${metadata.componentType}/${metadata.fullName}`;
VlocityUtils.error('Metadata Deployment Failed - ' + metadata.problem, metadataKey);
jobInfo.currentStatus[metadataKey] = 'Failure';
}
}
);
}
VlocityUtils.log('Skipping Deactivation of OmniScript as keepOSActiveWhenLWCDeploymentFails = true. As per this param, Deployed OmniScripts will remain active irrespective of LWC is deployed or not.');
} else {
VlocityUtils.log(err);
jobInfo.errors.push("Exception while deploying compiled LWC components:\n" + JSON.stringify(err, null, 2));
jobInfo.hasError = true;
}
}
}
}
Expand Down
40 changes: 21 additions & 19 deletions lib/datapacktypes/flexcard.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,26 +160,28 @@ FlexCard.prototype.onDeployFinish = async function(jobInfo) {
if (idsArray.length < 1){
return;
}

//--------Load Flexcard compiler-------
// Make sure we load the package version
await this.vlocity.utilityservice.getPackageVersion();

const compilerName = 'flexcard-compiler';
const namespace = this.vlocity.namespace;
const packageVersion = this.vlocity.PackageVersion;

const flexCardsCompiler = await VlocityUtils.loadCompiler(compilerName,
jobInfo, packageVersion, namespace);
if(flexCardsCompiler){
for (let i = 0; i < idsArray.length; i++) {
let flexCardID = idsArray[i];
await this.compileFlexCardsLwc(flexCardID,jobInfo,flexCardsCompiler) ;
}
if (!jobInfo.ignoreLocalCompilationCards){
//--------Load Flexcard compiler-------
// Make sure we load the package version
await this.vlocity.utilityservice.getPackageVersion();

const compilerName = 'flexcard-compiler';
const namespace = this.vlocity.namespace;
const packageVersion = this.vlocity.PackageVersion;

const flexCardsCompiler = await VlocityUtils.loadCompiler(compilerName,
jobInfo, packageVersion, namespace);
if(flexCardsCompiler){
for (let i = 0; i < idsArray.length; i++) {
let flexCardID = idsArray[i];
await this.compileFlexCardsLwc(flexCardID,jobInfo,flexCardsCompiler) ;
}
} else{
hasFlexCardCompiler= false;
}
} else{
hasFlexCardCompiler= false;
}

hasFlexCardCompiler= false;
}
} catch (e) {
hasFlexCardCompiler= false;
VlocityUtils.error('Error while loading Flexcard Compiler', e);
Expand Down
20 changes: 12 additions & 8 deletions lib/datapacktypes/omniscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,23 @@ OmniScript.prototype.createTitleObjects = function (input) {
return titleObjects;
};

OmniScript.prototype.deactivateOmniScript = async function (omniscriptID) {
OmniScript.prototype.deactivateOmniScript = async function (omniscriptID, jobInfo) {
const osAPIName = this.vlocity.namespace + '__OmniScript__c';
const osAPIActiveFieldName = this.vlocity.namespace + '__IsActive__c';
var toUpdate = {};
toUpdate[osAPIActiveFieldName] = false;
toUpdate.Id = omniscriptID;
try {
var result = await this.vlocity.jsForceConnection.sobject(osAPIName).update(toUpdate);
if (!result.success) {
VlocityUtils.error('Deactivating OmniScript ', 'Id: ' + omniscriptID + ' Unable to deactivate OmniScript. OmniScript is still activated.');
}
else {
VlocityUtils.log('Deactivating OmniScript ', omniscriptID, 'OmniScript was deactivated');
if (jobInfo && jobInfo.keepOSActiveWhenLWCDeploymentFails) {
VlocityUtils.log('Skipping Deactivation of OmniScript - ' + omniscriptID + ' as keepOSActiveWhenLWCDeploymentFails = true. As per this param, Deployed OmniScript will remain active irrespective of LWC is deployed or not.');
} else {
var result = await this.vlocity.jsForceConnection.sobject(osAPIName).update(toUpdate);
if (!result.success) {
VlocityUtils.error('Deactivating OmniScript ', 'Id: ' + omniscriptID + ' Unable to deactivate OmniScript. OmniScript is still activated.');
}
else {
VlocityUtils.log('Deactivating OmniScript ', omniscriptID, 'OmniScript was deactivated');
}
}
} catch (error) {
VlocityUtils.error('Deactivating OmniScript ', 'Id: ' + omniscriptID + ' Unable to deactivate OmniScript. OmniScript is still activated - ' + error);
Expand Down Expand Up @@ -402,7 +406,7 @@ OmniScript.prototype.compileOSLWC = async function (jobInfo, omniScriptId, omniS
jobInfo.currentErrors[omniScriptKey] = 'LWC Activation Error >> ' + omniScriptKey + ' - ' + e;
jobInfo.errors.push('LWC Activation Error >> ' + omniScriptKey + ' - ' + e);
VlocityUtils.error('LWC Activation Error', omniScriptKey + ' - ' + e);
await this.deactivateOmniScript(omniScriptId);
await this.deactivateOmniScript(omniScriptId, jobInfo);

try {
browser.close();
Expand Down
4 changes: 3 additions & 1 deletion lib/vlocitycli.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ var VLOCITY_COMMANDLINE_OPTIONS = {
"puppeteerHeadless": Boolean,
"ignoreLWCActivationOS": Boolean,
"ignoreLWCActivationCards": Boolean,
"ignoreLocalCompilationCards": Boolean,
"puppeteerHttpProxy": String,
"overrideOrgCommit": String
"overrideOrgCommit": String,
"keepOSActiveWhenLWCDeploymentFails": Boolean
};

var VLOCITY_COMMANDLINE_OPTIONS_SHORTHAND = {
Expand Down
2 changes: 1 addition & 1 deletion lib/vlocityutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ VlocityUtils.loadCompiler = async function (nameOfCompiler, jobInfo, packageVers
return await VlocityUtils.requirePlugin(jobInfo, lwcCompiler, lwcCompilerVersion);
} catch (err) {
VlocityUtils.log(`Can also install compiler with npm install ${lwcCompiler}`);
VlocityUtils.error('An error occurred while loading OmniScript compiler: ' + err + ' - If you are using Puppeteer for LWC compilation this error can be ignored');
VlocityUtils.log('An error occurred while loading OmniScript compiler: ' + err + ' - If you are using Puppeteer for LWC compilation this error can be ignored');
return null;
}
}

0 comments on commit cd74d8f

Please sign in to comment.