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

Commit

Permalink
fix(validate): --installdeps flag was getting ignored in certain mode…
Browse files Browse the repository at this point in the history
…s in validateAgainstOrg

This commit simplifies the whole preDependncies installation and installs it as same as both for
validate and validateAgainst Org, with only caveat being in validateAgainstOrg you need to be
explicit with in installDeps
  • Loading branch information
azlam-abdulsalam committed Aug 25, 2023
1 parent e839abf commit 3fb9684
Showing 1 changed file with 40 additions and 81 deletions.
121 changes: 40 additions & 81 deletions packages/sfpowerscripts-cli/src/impl/validate/ValidateImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,88 +650,47 @@ export default class ValidateImpl implements PostDeployHook, PreDeployHook {
}

async preDeployPackage(
sfpPackage: SfpPackage,
targetUsername: string,
deployedPackages?: SfpPackage[],
devhubUserName?: string,
): Promise<{ isToFailDeployment: boolean; message?: string }> {
//Its a scratch org fetched from pool.. install dependencies
//Assume hubOrg will be available, no need to check
switch (this.props.validateAgainst) {
case ValidateAgainst.PRECREATED_POOL:
if (
this.props.validationMode == ValidationMode.THOROUGH ||
this.props.validationMode ==
ValidationMode.THOROUGH_LIMITED_BY_RELEASE_CONFIG
) {
await this.installPackageDependencies(
ProjectConfig.getSFDXProjectConfig(null),
this.orgAsSFPOrg,
sfpPackage,
deployedPackages,
);
} else if (this.props.validationMode == ValidationMode.INDIVIDUAL) {
await this.installPackageDependencies(
ProjectConfig.cleanupMPDFromProjectDirectory(
null,
sfpPackage.package_name,
),
this.orgAsSFPOrg,
sfpPackage,
deployedPackages,
);
}
else if (this.props.validationMode == ValidationMode.FASTFEEDBACK_LIMITED_BY_RELEASE_CONFIG
|| this.props.validationMode == ValidationMode.FAST_FEEDBACK) {
if(this.props.installExternalDependencies)
await this.installPackageDependencies(
ProjectConfig.cleanupMPDFromProjectDirectory(
null,
sfpPackage.package_name,
),
this.orgAsSFPOrg,
sfpPackage,
deployedPackages,
);
}
break;
case ValidateAgainst.PROVIDED_ORG:
if (this.props.validationMode == ValidationMode.INDIVIDUAL) {
if (this.props.hubOrg)
await this.installPackageDependencies(
ProjectConfig.cleanupMPDFromProjectDirectory(
null,
sfpPackage.package_name,
),
this.orgAsSFPOrg,
sfpPackage,
deployedPackages,
);
else
SFPLogger.log(
`${COLOR_WARNING(
`DevHub was not provided, will skip installing /updating external dependencies of this package`,
)}`,
LoggerLevel.INFO,
);
}
else if (this.props.validationMode == ValidationMode.FASTFEEDBACK_LIMITED_BY_RELEASE_CONFIG
|| this.props.validationMode == ValidationMode.FAST_FEEDBACK) {
if(this.props.installExternalDependencies)
await this.installPackageDependencies(
ProjectConfig.cleanupMPDFromProjectDirectory(
null,
sfpPackage.package_name,
),
this.orgAsSFPOrg,
sfpPackage,
deployedPackages,
);
}
}
sfpPackage: SfpPackage,
targetUsername: string,
deployedPackages?: SfpPackage[],
devhubUserName?: string,
): Promise<{ isToFailDeployment: boolean; message?: string }> {

const shouldInstallDependencies = (mode: ValidationMode) => {
if (this.props.validateAgainst === ValidateAgainst.PROVIDED_ORG &&
!this.props.installExternalDependencies) {
return false;
}

const isThoroughValidation = mode === ValidationMode.THOROUGH ||
mode === ValidationMode.THOROUGH_LIMITED_BY_RELEASE_CONFIG;

const isFastFeedbackWithExternalDependencies =
(mode === ValidationMode.FASTFEEDBACK_LIMITED_BY_RELEASE_CONFIG ||
mode === ValidationMode.FAST_FEEDBACK) &&
this.props.installExternalDependencies;

return isThoroughValidation ||
mode === ValidationMode.INDIVIDUAL ||
isFastFeedbackWithExternalDependencies;
};

if (shouldInstallDependencies(this.props.validationMode)) {
const projectConfig = this.props.validationMode === ValidationMode.INDIVIDUAL ?
ProjectConfig.cleanupMPDFromProjectDirectory(null, sfpPackage.package_name) :
ProjectConfig.getSFDXProjectConfig(null);

await this.installPackageDependencies(
projectConfig,
this.orgAsSFPOrg,
sfpPackage,
deployedPackages,
);
}

return { isToFailDeployment: false };
}

return { isToFailDeployment: false };
}

async postDeployPackage(
sfpPackage: SfpPackage,
Expand Down

0 comments on commit 3fb9684

Please sign in to comment.