Skip to content

Commit

Permalink
Fix monitoring config & legacy api notifications (#479)
Browse files Browse the repository at this point in the history
* Fix monitoring config to allow to mix with deployment repo

- Allow to configure monitoring on deployment repositories (Fix [#477](#477))
- Forbid to configure CI authentication on main or master branch

* Do not send legacy API notifications when there are no issues

* Upgrade axios

* [Mega-Linter] Apply linters fixes

---------

Co-authored-by: nvuillam <nvuillam@users.noreply.github.com>
  • Loading branch information
nvuillam and nvuillam authored Nov 12, 2023
1 parent 18b6ca5 commit c2913de
Show file tree
Hide file tree
Showing 9 changed files with 434 additions and 305 deletions.
1 change: 1 addition & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CVE-2023-32314
CVE-2023-34104
CVE-2023-38704
CVE-2023-45133
CVE-2023-45857
DS001
DS002
DS026
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

Note: Can be used with `sfdx plugins:install sfdx-hardis@beta` and docker image `hardisgroupcom/sfdx-hardis@beta`

## [4.10.3] 2023-11-12

- Allow to configure monitoring on deployment repositories (Fix [#477](https://github.com/hardisgroupcom/sfdx-hardis/issues/477))
- Forbid to configure CI authentication on main or master branch
- Do not send legacy API notifications when there are no issues (Fix [#478](https://github.com/hardisgroupcom/sfdx-hardis/issues/478))
- Upgrade dependencies

## [4.10.2] 2023-11-07

- If you want to force the use full deployment on a delta project Pull Request/ Merge Request, add **nodelta** in your latest commit title or text.
Expand Down
470 changes: 235 additions & 235 deletions README.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/deployTips.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ description: Learn how to fix issues that can happen during sfdx deployments

This page summarizes all errors that can be detected by sfdx-hardis wrapper commands

| sfdx command | sfdx-hardis wrapper command |
| :----------- | :-------------------------- |
| [sfdx force:source:deploy](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm#cli_reference_force_source_deploy) | [sfdx hardis:source:deploy](https://sfdx-hardis.cloudity.com/hardis/source/deploy/) |
| [sfdx force:source:push](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm#cli_reference_force_source_push) | [sfdx hardis:source:push](https://sfdx-hardis.cloudity.com/hardis/source/push/) |
| [sfdx force:mdapi:deploy](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_mdapi.htm#cli_reference_force_mdapi_beta_deploy) | [sfdx hardis:mdapi:deploy](https://sfdx-hardis.cloudity.com/hardis/mdapi/deploy/) |
| sfdx command | sfdx-hardis wrapper command |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|
| [sfdx force:source:deploy](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm#cli_reference_force_source_deploy) | [sfdx hardis:source:deploy](https://sfdx-hardis.cloudity.com/hardis/source/deploy/) |
| [sfdx force:source:push](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_source.htm#cli_reference_force_source_push) | [sfdx hardis:source:push](https://sfdx-hardis.cloudity.com/hardis/source/push/) |
| [sfdx force:mdapi:deploy](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_mdapi.htm#cli_reference_force_mdapi_beta_deploy) | [sfdx hardis:mdapi:deploy](https://sfdx-hardis.cloudity.com/hardis/mdapi/deploy/) |

You can also use this function on a [sfdx-hardis Salesforce CI/CD project](https://sfdx-hardis.cloudity.com/salesforce-ci-cd-home/)

Expand Down Expand Up @@ -302,7 +302,7 @@ You probably also need to add CRM Analytics Admin Permission Set assignment to t
## Error parsing file
- `Error (.*) Error parsing file: (.*) `
- `Error (.*) Error parsing file: (.*)`
**Resolution tip**
Expand Down Expand Up @@ -912,7 +912,7 @@ Please check https://developer.salesforce.com/forums/?id=9060G0000005kVLQAY
## Test classes with 0% coverage
- ` 0%`
- `0%`
**Resolution tip**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@typescript-eslint/eslint-plugin": "^4.17.0",
"@typescript-eslint/parser": "^4.17.0",
"@xmldom/xmldom": "^0.8.6",
"axios": "^0.21.1",
"axios": "^1.6.1",
"azure-devops-node-api": "^12.0.0",
"chalk": "^4.1.0",
"changed-git-files": "^0.0.1",
Expand Down
13 changes: 12 additions & 1 deletion src/commands/hardis/org/configure/monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,18 @@ export default class OrgConfigureMonitoring extends SfdxCommand {
// Check git repo name is valid (contains monitoring)
const repoName = await getGitRepoName();
if (!repoName.includes("monitoring")) {
throw new SfdxError('Your git repository name must contain the expression "monitoring"');
const confirmMix = await prompts({
type: "select",
name: "value",
choices: [
{ title: "Yes, I'm sure because I know what I'm doing, like Roman :)", value: "yes" },
{ title: 'Mmmmm no, let me create another repo with the word "monitoring" in its name !', value: "no" },
],
message: c.cyanBright("It's safer to have monitoring in a separate repo. Are you sure you want to mix monitoring and deployment sources ?"),
});
if (confirmMix.value === "no") {
throw new SfdxError('Your git repository name must contain the expression "monitoring"');
}
}
const preRequisitesUrl = "https://sfdx-hardis.cloudity.com/salesforce-monitoring-home/#configuration";
uxLog(this, c.yellow("Monitoring pre-requisites documentation: " + c.bold(preRequisitesUrl)));
Expand Down
29 changes: 16 additions & 13 deletions src/commands/hardis/org/diagnose/legacyapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,20 +230,23 @@ See article below
- EN: https://nicolas.vuillamy.fr/handle-salesforce-api-versions-deprecation-like-a-pro-335065f52238
- FR: https://leblog.hardis-group.com/portfolio/versions-dapi-salesforce-decommissionnees-que-faire/`;

const branchName = process.env.CI_COMMIT_REF_NAME || (await getCurrentGitBranch({ formatted: true })) || "Missing CI_COMMIT_REF_NAME variable";
const targetLabel = this.org?.getConnection()?.instanceUrl || branchName;
const linkMarkdown = UtilsNotifs.markdownLink(targetLabel, targetLabel.replace("https://", "").replace(".my.salesforce.com", ""));
const notifButtons = [];
const jobUrl = await GitProvider.getJobUrl();
if (jobUrl) {
notifButtons.push({ text: "View Job", url: jobUrl });
// Manage notifications
if (allErrors.length > 0) {
const branchName = process.env.CI_COMMIT_REF_NAME || (await getCurrentGitBranch({ formatted: true })) || "Missing CI_COMMIT_REF_NAME variable";
const targetLabel = this.org?.getConnection()?.instanceUrl || branchName;
const linkMarkdown = UtilsNotifs.markdownLink(targetLabel, targetLabel.replace("https://", "").replace(".my.salesforce.com", ""));
const notifButtons = [];
const jobUrl = await GitProvider.getJobUrl();
if (jobUrl) {
notifButtons.push({ text: "View Job", url: jobUrl });
}
NotifProvider.postNotifications({
text: `Deprecated Salesforce API versions are used in ${linkMarkdown}`,
attachments: [{ text: notifDetailText }],
buttons: notifButtons,
severity: "error",
});
}
NotifProvider.postNotifications({
text: `Deprecated Salesforce API versions are used in ${linkMarkdown}`,
attachments: [{ text: notifDetailText }],
buttons: notifButtons,
severity: "error",
});

// Send notification if possible
if (isCI && allErrors.length > 0 && (await canSendNotifications())) {
Expand Down
5 changes: 4 additions & 1 deletion src/commands/hardis/project/configure/auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* jscpd:ignore-start */
import { flags, SfdxCommand } from "@salesforce/command";
import { Messages } from "@salesforce/core";
import { Messages, SfdxError } from "@salesforce/core";
import { AnyJson } from "@salesforce/ts-types";
import * as c from "chalk";
import { execSfdxJson, generateSSLCertificate, promptInstanceUrl, uxLog } from "../../../../common/utils";
Expand Down Expand Up @@ -108,6 +108,9 @@ export default class ConfigureAuth extends SfdxCommand {
message: c.cyanBright("What is the name of the git branch you want to configure ? Examples: developpement,recette,production"),
});
branchName = branchResponse.value.replace(/\s/g, "-");
if (["main", "master"].includes(branchName)) {
throw new SfdxError("You can not use main or master as deployment branch name. Maybe you want to use production ?");
}
instanceUrl = await promptInstanceUrl(["login", "test"], `${branchName} related org`, {
instanceUrl: devHub ? this.hubOrg.getConnection().instanceUrl : this.org.getConnection().instanceUrl,
});
Expand Down
Loading

0 comments on commit c2913de

Please sign in to comment.