From 111c4e9c679bc8c73a2d26fcd8c2afc25fb51f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Di=C3=A9ffrei=20Quadros?= Date: Sun, 26 May 2024 22:17:42 -0300 Subject: [PATCH] fix(deploy): 54-Skip deployment when deployment artifacts filter result is empty (#64) * chore: skip deployment when artifact filters didnt match any artifact available to deploy * chore: remove unecessary imports --- .gitignore | 3 ++- .../sfp-cli/src/impl/deploy/DeployImpl.ts | 21 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 68d368d1a..83965c629 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ packages/apexlink/coverage packages/sfp-cli/oclif.manifest.json packages/apexlink/tests/resources/core-crm/apexlink.json packages/apexlink/tests/resources/feature-mgmt/apexlink.json -.nx \ No newline at end of file +.nx +.idea/ diff --git a/packages/sfp-cli/src/impl/deploy/DeployImpl.ts b/packages/sfp-cli/src/impl/deploy/DeployImpl.ts index 55f17ab00..e23ed204a 100644 --- a/packages/sfp-cli/src/impl/deploy/DeployImpl.ts +++ b/packages/sfp-cli/src/impl/deploy/DeployImpl.ts @@ -1,5 +1,5 @@ import ArtifactFetcher, { Artifact } from '../../core/artifacts/ArtifactFetcher'; -import SFPLogger, { COLOR_ERROR, COLOR_SUCCESS, FileLogger, Logger, LoggerLevel } from '@flxbl-io/sfp-logger'; +import SFPLogger, { COLOR_ERROR, COLOR_SUCCESS, Logger, LoggerLevel } from '@flxbl-io/sfp-logger'; import { Stage } from '../Stage'; import ProjectConfig from '../../core/project/ProjectConfig'; import semver = require('semver'); @@ -25,7 +25,6 @@ import convertBuildNumDotDelimToHyphen from '../../core/utils/VersionNumberConve import ReleaseConfigLoader from '../release/ReleaseConfigLoader'; import { Align, getMarkdownTable } from 'markdown-table-ts'; import FileOutputHandler from '../../outputs/FileOutputHandler'; -import { ValidateProps } from '../validate/ValidateImpl'; const Table = require('cli-table'); const retry = require('async-retry'); @@ -81,7 +80,7 @@ export default class DeployImpl { public async exec(): Promise { let deployed: PackageInfo[] = []; let failed: PackageInfo[] = []; - let queue: SfpPackage[]; + let queue: SfpPackage[] = []; let packagesToPackageInfo: { [p: string]: PackageInfo }; try { //Create Org @@ -108,6 +107,18 @@ export default class DeployImpl { this.props.logger ); + if (sfpPackages.length <= 0 && (this.props.releaseConfigPath || this.props.filterByProvidedArtifacts)) { + SFPLogger.log(`Skipping deployment, no artifacts found based on filters defined in ${this.props.releaseConfigPath ? ' release config' : '--artifacts parameter'}`,LoggerLevel.INFO, this.props.logger); + return { + scheduled: 0, + deployed: deployed, + failed: failed, + queue: queue, + packagesToPackageInfo: null, + error: null, + }; + } + //Grab the latest projectConfig from Packages let sfpPackageInquirer: SfpPackageInquirer = new SfpPackageInquirer(sfpPackages, this.props.logger); let sfdxProjectConfig = sfpPackageInquirer.getLatestProjectConfig(); @@ -124,6 +135,7 @@ export default class DeployImpl { queue = this.getPackagesToDeploy(sfdxProjectConfig, packagesToPackageInfo); + SFPLogger.log('queue:' + JSON.stringify(queue), LoggerLevel.TRACE, this.props.logger); if (this.props.skipIfPackageInstalled) { @@ -874,8 +886,7 @@ export default class DeployImpl { else return true; }); - if (packagesToDeploy.length === 0) throw new Error(`No artifacts from project config to be deployed`); - else return packagesToDeploy; + return packagesToDeploy; } }