Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
fix(output): fix output when validation errors
Browse files Browse the repository at this point in the history
Add details to the markdown file, when a package fails to validate
  • Loading branch information
azlam-abdulsalam committed Oct 4, 2023
1 parent 690de5c commit da88e75
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
39 changes: 21 additions & 18 deletions packages/sfpowerscripts-cli/src/impl/deploy/DeployImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export default class DeployImpl {
await this.promotePackagesBeforeInstallation(packageInfo.sourceDirectory, sfpPackage);
} catch (error) {
//skip packages already promoted
SFPLogger.log(`Package already promoted .. skipping`,LoggerLevel.INFO);
SFPLogger.log(`Package already promoted .. skipping`,LoggerLevel.WARN);
}

this.displayRetryHeader(isToBeRetried, attemptCount);
Expand Down Expand Up @@ -271,22 +271,25 @@ export default class DeployImpl {
failed = queue.slice(i).map((pkg) => packagesToPackageInfo[pkg.packageName]);
}

let postHookStatus = await this._postDeployHook?.postDeployPackage(
sfpPackage,
packageInstallationResult,
this.props.targetUsername,
sfpPackages,
this.props.devhubUserName,
this.props.logger
);

if (postHookStatus?.isToFailDeployment) {
failed = queue.slice(i).map((pkg) => packagesToPackageInfo[pkg.packageName]);
throw new Error(
postHookStatus.message
? postHookStatus.message
: 'Hook Failed to execute, but didnt provide proper message'
// Only deploy post hook when package installation is successful
if(packageInstallationResult.result === PackageInstallationStatus.Succeeded) {
let postHookStatus = await this._postDeployHook?.postDeployPackage(
sfpPackage,
packageInstallationResult,
this.props.targetUsername,
sfpPackages,
this.props.devhubUserName,
this.props.logger
);

if (postHookStatus?.isToFailDeployment) {
failed = queue.slice(i).map((pkg) => packagesToPackageInfo[pkg.packageName]);
throw new Error(
postHookStatus.message
? postHookStatus.message
: 'Hook Failed to execute, but didnt provide proper message'
);
}
}

if (packageInstallationResult.result === PackageInstallationStatus.Failed) {
Expand All @@ -303,7 +306,7 @@ export default class DeployImpl {
failed: failed,
queue: queue,
packagesToPackageInfo: packagesToPackageInfo,
error: null,
error: null
};
} catch (err) {
SFPLogger.log(err, LoggerLevel.ERROR, this.props.logger);
Expand All @@ -314,7 +317,7 @@ export default class DeployImpl {
failed: failed,
queue: queue,
packagesToPackageInfo: packagesToPackageInfo,
error: err,
error: err.message,
};
}
}
Expand Down
12 changes: 9 additions & 3 deletions packages/sfpowerscripts-cli/src/impl/validate/ValidateImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,18 @@ export default class ValidateImpl implements PostDeployHook, PreDeployHook {
);

FileOutputHandler.getInstance().appendOutput(`validation-error.md`,`### 💣 Deployment Failed 💣`);
let firstPackageFailedToValdiate = deploymentResult.failed[0];
FileOutputHandler.getInstance().appendOutput(`validation-error.md`,`Package validation failed for **${firstPackageFailedToValdiate.sfpPackage.packageName}** due to`);
FileOutputHandler.getInstance().appendOutput(`validation-error.md`,"");
FileOutputHandler.getInstance().appendOutput(`validation-error.md`,deploymentResult.error);

FileOutputHandler.getInstance().appendOutput(`validation-error.md`,`Package that are not validated:`);
deploymentResult.failed.map(
(packageInfo) => {
FileOutputHandler.getInstance().appendOutput(`validation-error.md`,`Package validation failed for **${packageInfo.sfpPackage.packageName}**`);
(packageInfo, index) => {
if (index!=0)
FileOutputHandler.getInstance().appendOutput(`validation-error.md`,`**${packageInfo.sfpPackage.packageName}**`);
}
);

}

SFPLogger.printHeaderLine('',COLOR_HEADER,LoggerLevel.INFO);
Expand Down

0 comments on commit da88e75

Please sign in to comment.