From 8664055c7abb416cf0b0f93d3a065081d8c52f64 Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Tue, 11 Jul 2023 22:49:27 +0530 Subject: [PATCH 1/4] Changes to ignore the local compilation of FlexCards when npmAuthKey is used in job file --- lib/datapacktypes/flexcard.js | 40 ++++++++++++++++++----------------- lib/vlocitycli.js | 1 + 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/datapacktypes/flexcard.js b/lib/datapacktypes/flexcard.js index b49f4dc7..8526e88c 100644 --- a/lib/datapacktypes/flexcard.js +++ b/lib/datapacktypes/flexcard.js @@ -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); diff --git a/lib/vlocitycli.js b/lib/vlocitycli.js index e7d747f3..22f451bb 100755 --- a/lib/vlocitycli.js +++ b/lib/vlocitycli.js @@ -106,6 +106,7 @@ var VLOCITY_COMMANDLINE_OPTIONS = { "puppeteerHeadless": Boolean, "ignoreLWCActivationOS": Boolean, "ignoreLWCActivationCards": Boolean, + "ignoreLocalCompilationCards": Boolean, "puppeteerHttpProxy": String, "overrideOrgCommit": String }; From d6bd77409660e37bb74fe46d65f2250f670a10fa Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Tue, 11 Jul 2023 22:57:25 +0530 Subject: [PATCH 2/4] Updated the README file to include the new option for FlexCard LWC Activation --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 373e4921..f3f39414 100644 --- a/README.md +++ b/README.md @@ -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 From 642d897ee3e079b5762a5f3be234a83c4aa57f24 Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Thu, 13 Jul 2023 13:33:35 +0530 Subject: [PATCH 3/4] Corrected the documentation --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f3f39414..33d5bb0b 100644 --- a/README.md +++ b/README.md @@ -775,7 +775,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 | @@ -1036,6 +1036,7 @@ These types are what would be specified when creating a Query or Manifest for th | DocumentTemplate | DocumentTemplate__c
DocumentTemplateSection__c
DocumentTemplateSectionCondition__c | | EntityFilter | EntityFilter__c
EntityFilterCondition__c
EntityFilterMember__c
EntityFilterConditionArgument__c | | IntegrationProcedure | OmniScript__c
Element__c | +| IntegrationRetryPolicy | IntegrationRetryPolicy__c | | InterfaceImplementation | InterfaceImplementation__c
InterfaceImplementationDetail__c | | ItemImplementation | ItemImplementation__c | | ManualQueue | ManualQueue__c | From b01b4a5a164a57ef634bfa0832f445daf25ea242 Mon Sep 17 00:00:00 2001 From: Manas Agarwal Date: Mon, 17 Jul 2023 01:15:55 +0530 Subject: [PATCH 4/4] Skip LWC Deployment for OS upon any failure --- README.md | 6 ++++++ lib/datapacksjob.js | 30 +++++++++++++++++++++++++++--- lib/datapacktypes/omniscript.js | 20 ++++++++++++-------- lib/vlocitycli.js | 3 ++- lib/vlocityutils.js | 2 +- 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 33d5bb0b..e8792dc5 100644 --- a/README.md +++ b/README.md @@ -459,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 diff --git a/lib/datapacksjob.js b/lib/datapacksjob.js index 1dbed051..8dc831bc 100644 --- a/lib/datapacksjob.js +++ b/lib/datapacksjob.js @@ -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; + } } } } diff --git a/lib/datapacktypes/omniscript.js b/lib/datapacktypes/omniscript.js index 3c7e0007..f4e105f8 100644 --- a/lib/datapacktypes/omniscript.js +++ b/lib/datapacktypes/omniscript.js @@ -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); @@ -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(); diff --git a/lib/vlocitycli.js b/lib/vlocitycli.js index 22f451bb..6e74a659 100755 --- a/lib/vlocitycli.js +++ b/lib/vlocitycli.js @@ -108,7 +108,8 @@ var VLOCITY_COMMANDLINE_OPTIONS = { "ignoreLWCActivationCards": Boolean, "ignoreLocalCompilationCards": Boolean, "puppeteerHttpProxy": String, - "overrideOrgCommit": String + "overrideOrgCommit": String, + "keepOSActiveWhenLWCDeploymentFails": Boolean }; var VLOCITY_COMMANDLINE_OPTIONS_SHORTHAND = { diff --git a/lib/vlocityutils.js b/lib/vlocityutils.js index bf3f6257..82fe0b95 100644 --- a/lib/vlocityutils.js +++ b/lib/vlocityutils.js @@ -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; } } \ No newline at end of file