UNPKG

sfdx-hardis

Version:

Swiss-army-knife Toolbox for Salesforce. Allows you to define a complete CD/CD Pipeline. Orchestrate base commands and assist users with interactive wizards

100 lines 4.47 kB
import { SfError } from "@salesforce/core"; import c from "chalk"; import { uxLog } from "../utils/index.js"; import { extractImagesFromMarkdown, replaceImagesInMarkdown } from "./utilsMarkdown.js"; import { getEnvVar } from "../../config/index.js"; export class GitProviderRoot { serverUrl; token; getLabel() { throw new SfError("getLabel should be implemented on this call"); } async getBranchDeploymentCheckId(gitBranch) { uxLog(this, `Method getBranchDeploymentCheckId(${gitBranch}) is not implemented yet on ${this.getLabel()}`); return null; } async getPullRequestDeploymentCheckId() { uxLog(this, `Method getPullRequestDeploymentCheckId() is not implemented yet on ${this.getLabel()}`); return null; } async getCurrentJobUrl() { uxLog(this, `Method getCurrentJobUrl is not implemented yet on ${this.getLabel()}`); return null; } async getCurrentBranchUrl() { uxLog(this, `Method getCurrentBranchUrl is not implemented yet on ${this.getLabel()}`); return null; } async supportsMermaidInPrMarkdown() { uxLog(this, `Method supportsMermaidInPrMarkdown is not implemented yet on ${this.getLabel()}`); return false; } async supportsSvgAttachments() { // False by default, might be used later return false; } async getPullRequestInfo() { uxLog(this, `Method getPullRequestInfo is not implemented yet on ${this.getLabel()}`); return null; } // eslint-disable-next-line @typescript-eslint/no-unused-vars async uploadImage(image) { uxLog(this, `Method uploadImage is not implemented yet on ${this.getLabel()}`); return null; } // eslint-disable-next-line @typescript-eslint/no-unused-vars async listPullRequests(filters = {}, options = { formatted: false }) { uxLog(this, `Method listPullRequests is not implemented yet on ${this.getLabel()}`); return null; } async postPullRequestMessage(prMessage) { uxLog(this, c.yellow("Method postPullRequestMessage is not yet implemented on " + this.getLabel() + " to post " + JSON.stringify(prMessage))); return { posted: false, providerResult: { error: "Not implemented in sfdx-hardis" } }; } /* jscpd:ignore-start */ // Do not make crash the whole process in case there is an issue with integration async tryPostPullRequestMessage(prMessage) { let prResult = null; try { prResult = await this.postPullRequestMessage(prMessage); } catch (e) { uxLog(this, c.yellow(`[GitProvider] Error while trying to post pull request message.\n${e.message}\n${e.stack}`)); prResult = { posted: false, providerResult: { error: e } }; } return prResult; } /* jscpd:ignore-end */ async uploadAndReplaceImageReferences(markdownBody, sourceFile = null) { const replacements = {}; const markdownImages = extractImagesFromMarkdown(markdownBody, sourceFile); for (const image of markdownImages) { const imageUrl = await this.uploadImage(image.path); if (imageUrl) { replacements[image.name] = imageUrl; } } markdownBody = replaceImagesInMarkdown(markdownBody, replacements); return markdownBody; } completeWithCustomBehaviors(pullRequestInfo) { const desc = pullRequestInfo.description || ""; if (desc.includes("NO_DELTA") || getEnvVar("NO_DELTA") === "true" || getEnvVar("NO_DELTA_" + pullRequestInfo.targetBranch) === "true") { pullRequestInfo.customBehaviors.noDeltaDeployment = true; } if (desc.includes("PURGE_FLOW_VERSIONS") || getEnvVar("PURGE_FLOW_VERSIONS") === "true" || getEnvVar("PURGE_FLOW_VERSIONS_" + pullRequestInfo.targetBranch) === "true") { pullRequestInfo.customBehaviors.purgeFlowVersions = true; } if (desc.includes("DESTRUCTIVE_CHANGES_AFTER_DEPLOYMENT") || getEnvVar("DESTRUCTIVE_CHANGES_AFTER_DEPLOYMENT") === "true" || getEnvVar("DESTRUCTIVE_CHANGES_AFTER_DEPLOYMENT_" + pullRequestInfo.targetBranch) === "true") { pullRequestInfo.customBehaviors.destructiveChangesAfterDeployment = true; } return pullRequestInfo; } } //# sourceMappingURL=gitProviderRoot.js.map