Skip to content

Commit

Permalink
54-Skip deployment when deployment artifacts filter result is empty (#64
Browse files Browse the repository at this point in the history
)

* chore: skip deployment when artifact filters didnt match any artifact available to deploy

* chore: remove unecessary imports
  • Loading branch information
dieffrei authored May 27, 2024
1 parent 3386438 commit 90c6165
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
.nx
.idea/
21 changes: 16 additions & 5 deletions packages/sfp-cli/src/impl/deploy/DeployImpl.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -81,7 +80,7 @@ export default class DeployImpl {
public async exec(): Promise<DeploymentResult> {
let deployed: PackageInfo[] = [];
let failed: PackageInfo[] = [];
let queue: SfpPackage[];
let queue: SfpPackage[] = [];
let packagesToPackageInfo: { [p: string]: PackageInfo };
try {
//Create Org
Expand All @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 90c6165

Please sign in to comment.