Skip to content

Commit

Permalink
Merge branch 'migrate-sf-plugin' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Sep 16, 2024
2 parents 586ef76 + b0fa36b commit 6d5cac8
Show file tree
Hide file tree
Showing 251 changed files with 5,355 additions and 2,264 deletions.
85 changes: 52 additions & 33 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,58 @@ We made many tests but risk zero do not exist, so if you see any bug, please rep
- `sf hardis project deploy quick` -> Wraps `sf project deploy quick`
- `sf hardis project deploy start` -> Wraps `sf project deploy start`

### New Features / Enhancements

- **hardis:project:deploy:smart**
- New feature **useSmartDeploymentTests**: Improve performances by not running test classes when delta deployment contain only non impacting metadatas, and target org is not production
- Rename command **hardis:project:deploy:source:dx** into **hardis:project:deploy:smart** (previous command alias remains, no need to update your pipelines !)
- **commandsPreDeploy** and **commandsPostDeploy**
- New option **context** for a command, defining when it is run and when it is not: **all** (default), **check-deployment-only** or **process-deployment-only**
- New option **runOnlyOnceByOrg**: If set to `true`, the command will be run only one time per org. A record of SfdxHardisTrace__c is stored to make that possible (it needs to be existing in target org)
- New commands
- **hardis:project:deploy:simulate** to validate the deployment of a single metadata (used by VsCode extension)
- **hardis:org:diagnose:releaseupdates** to check for org Release Updates from Monitoring or locally
- **hardis:misc:purge-references** to partially automate the cleaning of related dependencies when you need to delete a field, or change its type (for example from master detail to lookup)
- **hardis:project:clean:sensitive-metadatas** to mask sensitive metadatas from git repo (ex: Certificate content)
- **hardis:work:save** and **hardis:project:deploy:sources:dx**: Improve runtime performances thanks to internalization of sfdx-essentials commands
- **hardis:work:new**
- Allow to add labels in property `availableTargetBranches`, using a comma. For examples, `- integration,Choose this branch if you are on the BUILD side of the project !`
- Add current default org in the choices when prompting which org to use
- **hardis:project:new**
- Initialize autoCleanTypes with **destructivechanges**, **flowPositions** and **minimizeProfiles**
- Initialize package-no-overwrite.xml with Certificate metadata. (certificates must be uploaded manually)
- **hardis:org:files:export**: Improve display with spinner
- **hardis:org:purge:flow**: If FlowInterview records are preventing Flow Versions to be deleted, prompt user to delete Flow Interviews before trying again to delete Flow Versions
- **hardis:project:generate:gitdelta**: Add option to generate package.xml related to a single commit
- **hardis:org:data:delete**: Check for property "runnableInProduction" in export.json before running deletion in production org.
- **hardis:org:diagnose:audittrail**: Add new filtered actions
- Customer Portal: createdcustomersuccessuser
- Authentication: do not use alias MY_ORG anymore + do not update local user config if no values to replace.
- When selecting an org, make sure it is still connected. If not, open browser so the user can authenticate again.
- Update sfdx-hardis Grafana Dashboards to import in your Grafana Cloud
- SF Instance name
- Next platform upgrade
- Release Updates to check
- Installed packages
- Org licenses
- AI Deployment assistant
- Add error `Change Matching Rule`
- Git Providers
- On Pull Requests / Merge Requests comments, add hyperlinks to errors documentation URL

### Fixes

- Avoid error when removing obsolete flows (workaround using SF CLI if tooling api connection fails). Fixes [#662](https://github.com/hardisgroupcom/sfdx-hardis/issues/662)
- Improve Slack/Teams notifications display
- Display explicit error message in case a password is required to intall a managed package.

### Documentation

- Reorganize README content
- Add link to Dreamforce 24 session
- Deployment assistant: Improve documentation by adding examples of errors, and a standalone page for each tip
- Factorize the definition of DOC_ROOT_URL https://sfdx-hardis.cloudity.com

### Deprecations

- Deprecate wrapper commands matching sfdx commands that will be removed. All replaced by sf hardis deploy start (TODO: complete !)
Expand Down Expand Up @@ -100,39 +152,6 @@ We made many tests but risk zero do not exist, so if you see any bug, please rep

- Remove not used keyValueStores to keep only Salesforce one

### New Features / Enhancements

- New command **hardis:project:deploy:simulate** to validate the deployment of a single metadata (used by VsCode extension)
- New command **hardis:org:diagnose:releaseupdates** to check for org Release Updates from Monitoring or locally
- New command **hardis:misc:purge-references** to partially automate the cleaning of related dependencies when you need to delete a field, or change its type (for example from master detail to lookup)
- **hardis:work:save** and **hardis:project:deploy:sources:dx**: Improve runtime performances thanks to internalization of sfdx-essentials commands
- **hardis:work:new**: Allow to add labels in property `availableTargetBranches`, using a comma. For examples, `- integration,Choose this branch if you are on the BUILD side of the project !`
- **hardis:org:files:export**: Improve display with spinner
- **hardis:org:purge:flow**: If FlowInterview records are preventing Flow Versions to be deleted, prompt user to delete Flow Interviews before trying again to delete Flow Versions
- **hardis:project:generate:gitdelta**: Add option to generate package.xml related to a single commit
- Authentication: do not use alias MY_ORG anymore + do not update local user config if no values to replace.
- **hardis:org:data:delete**: Check for property "runnableInProduction" in export.json before running deletion in production org.
- Update sfdx-hardis Grafana Dashboards to import in your Grafana Cloud
- SF Instance name
- Next platform upgrade
- Release Updates to check
- Installed packages
- Org licenses
- **hardis:org:diagnose:audittrail**: Add new filtered actions
- Customer Portal: createdcustomersuccessuser
- AI Deployment assistant
- Add error `Change Matching Rule`

### Fixes

- Avoid error when removing obsolete flows (workaround using SF CLI if tooling api connection fails). Fixes [#662](https://github.com/hardisgroupcom/sfdx-hardis/issues/662)
- Improve Slack/Teams notifications display

### Documentation

- Reorganize README content
- Add link to Dreamforce 24 session

## [4.53.0] 2024-08-20

- Upgrade workflows to Node 20 (fixes <https://github.com/hardisgroupcom/sfdx-hardis/issues/668>)
Expand Down
84 changes: 64 additions & 20 deletions build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,75 @@ class SfdxHardisBuilder {
""
];
for (const tip of deployTips) {
if (!tip.label) {
throw new Error(`Missing label for ${JSON.stringify(tip)}`);
}
deployTipsMd.push(`## ${tip.label}`);
deployTipsMd.push("");
if (tip.expressionRegex) {
deployTipsMd.push(...tip.expressionRegex.map((regEx) => "- `" + regEx.toString().slice(1).replace("/gm", "") + "`"));
}
if (tip.expressionString) {
deployTipsMd.push(...tip.expressionString.map((str) => "- `" + str + "`"));
}
deployTipsMd.push(...["", "**Resolution tip**", ""]);
if (!tip.tip) {
throw new Error(`Missing tip for ${JSON.stringify(tip)}`);
}
deployTipsMd.push("```shell");
deployTipsMd.push(...tip.tip.split("\n"));
deployTipsMd.push("```");
deployTipsMd.push("");
deployTipsMd.push("---");
const linkName = `sf-deployment-assistant/${tip.label.replace(/[^a-zA-Z0-9 -]|\s/g, '-')}.md`
const tipFile = `./docs/` + linkName;
this.buildIndividualMarkdownPageForTip(tip, tipFile);
this.buildMainDeployFixesMarkdown(tip, deployTipsMd, linkName);
}
fs.writeFileSync(deployTipsDocFile, deployTipsMd.join("\n") + "\n");
console.log("Written doc file " + deployTipsDocFile);
}

buildMainDeployFixesMarkdown(tip, deployTipsMd, linkName) {
if (!tip.label) {
throw new Error(`Missing label for ${JSON.stringify(tip)}`);
}
deployTipsMd.push(`## [${tip.label}](${linkName})`);
deployTipsMd.push(...["", "**Detection**", ""]);
if (tip.expressionRegex) {
deployTipsMd.push(...tip.expressionRegex.map((regEx) => "- RegExp: `" + regEx.toString().slice(1).replace("/gm", "") + "`"));
}
if (tip.expressionString) {
deployTipsMd.push(...tip.expressionString.map((str) => "- String: `" + str + "`"));
}
if (tip.examples) {
deployTipsMd.push(...["", "**Examples**", ""]);
deployTipsMd.push(...tip.examples.map((str) => "- `" + str + "`"));
}
deployTipsMd.push(...["", "**Resolution**", ""]);
if (!tip.tip) {
throw new Error(`Missing tip for ${JSON.stringify(tip)}`);
}
deployTipsMd.push("```shell");
deployTipsMd.push(...tip.tip.split("\n"));
deployTipsMd.push("```");
deployTipsMd.push("");
deployTipsMd.push("---");
}

buildIndividualMarkdownPageForTip(tip, tipFile) {
const errorDescription = tip?.examples?.length > 0 ? tip.examples[0] :
tip?.expressionString?.length > 0 ? tip?.expressionString[0] :
tip.expressionRegex[0]
const tipFileMd = [
"---",
`title: : ${tip.label} (Deployment assistant)`,
`description: How to solve Salesforce deployment error ${errorDescription}`,
"---",
"<!-- markdownlint-disable MD013 -->"
];
tipFileMd.push(`# ${tip.label}`);
tipFileMd.push(...["", "## Detection", ""]);
if (tip.expressionRegex) {
tipFileMd.push(...tip.expressionRegex.map((regEx) => "- RegExp: `" + regEx.toString().slice(1).replace("/gm", "") + "`"));
}
if (tip.expressionString) {
tipFileMd.push(...tip.expressionString.map((str) => "- String: `" + str + "`"));
}
if (tip.examples) {
tipFileMd.push(...["", "## Examples", ""]);
tipFileMd.push(...tip.examples.map((str) => "- `" + str + "`"));
}
tipFileMd.push(...["", "## Resolution", ""]);
if (!tip.tip) {
throw new Error(`Missing tip for ${JSON.stringify(tip)}`);
}
tipFileMd.push("```shell");
tipFileMd.push(...tip.tip.split("\n"));
tipFileMd.push("```");
fs.writeFileSync(tipFile, tipFileMd.join("\n") + "\n");
}

truncateReadme() {
const readmeFile = "./README.md";
const readmeContent = fs.readFileSync(readmeFile, "utf-8");
Expand Down
25 changes: 25 additions & 0 deletions config/sfdx-hardis.jsonschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"listViewsMine",
"minimizeProfiles",
"productrequest",
"sensitiveMetadatas",
"systemDebug",
"v60"
]
Expand Down Expand Up @@ -341,6 +342,23 @@
"title": "Command",
"type": "string"
},
"context": {
"$id": "#/properties/commandsPostDeploy/items/properties/context",
"description": "Context when the command must be run",
"title": "Context",
"default": "all",
"type": "string",
"enum": [
"all",
"check-deployment-only",
"process-deployment-only"
],
"examples": [
"all",
"check-deployment-only",
"process-deployment-only"
]
},
"skipIfError": {
"$id": "#/properties/commandsPostDeploy/items/properties/skipIfError",
"description": "Do not run the command if there is a deployment error",
Expand Down Expand Up @@ -1339,6 +1357,13 @@
"title": "Use Delta Deployment",
"type": "boolean"
},
"useSmartDeploymentTests": {
"$id": "#/properties/useSmartDeploymentTests",
"default": false,
"description": "Define if smart deployment tests will be activated and run test classes only if necessary (see more in hardis:project:deploy:smart documentation",
"title": "Use Smart Deployment Tests",
"type": "boolean"
},
"linterIgnoreRightMetadataFile": {
"$id": "#/properties/linterIgnoreRightMetadataFile",
"default": "",
Expand Down
2 changes: 1 addition & 1 deletion defaults/ci/.github/workflows/check-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ jobs:
run: |
echo "Simulate SFDX deployment using Hardis against \"$CONFIG_BRANCH\""
sf hardis:auth:login
sf hardis:project:deploy:sources:dx --check
sf hardis:project:deploy:smart --check
2 changes: 1 addition & 1 deletion defaults/ci/.github/workflows/process-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ jobs:
run: |
echo "Process SFDX deployment using Hardis against \"$CONFIG_BRANCH\""
sf hardis:auth:login
sf hardis:project:deploy:sources:dx
sf hardis:project:deploy:smart
16 changes: 8 additions & 8 deletions defaults/ci/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ include:

# Pipeline stages
stages:
- build # Check code quality (+ create testing scratch org if necessary)
- test # Apex unit tests on testing scratch org (if used)
- clean # Delete testing scratch org (if used)
- check_deploy # Simulate deployment to target branch
- deploy # After a merge, automatically deploys the new commit state into the related Salesforce org
- build # Check code quality (+ create testing scratch org if necessary)
- test # Apex unit tests on testing scratch org (if used)
- clean # Delete testing scratch org (if used)
- check_deploy # Simulate deployment to target branch
- deploy # After a merge, automatically deploys the new commit state into the related Salesforce org

# Jobs are run on sfdx-hardis image, that includes all required dependencies.
# You can use latest, beta or latest-recommended
Expand Down Expand Up @@ -84,7 +84,7 @@ check_deploy_to_target_branch_org:
script:
- '[ -z "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ] && exit 0;' # Skip this job if it is launched from web UI and we are not in merge request context
- sf hardis:auth:login
- sf hardis:project:deploy:sources:dx --check
- sf hardis:project:deploy:smart --check

# Create scratch org to check the sources push & the unit tests
create_scratch_org:
Expand Down Expand Up @@ -208,7 +208,7 @@ check_deploy_to_current_branch_org:
interruptible: true
script:
- sf hardis:auth:login
- sf hardis:project:deploy:sources:dx --check
- sf hardis:project:deploy:smart --check

# Deploy to branch related org when detecting new commit (after a merged merge request)
# Don't forget to define variable DEPLOY_BRANCHES to match your branches in .gitlab-ci-config.yml
Expand All @@ -226,4 +226,4 @@ deploy_to_org:
interruptible: true
script:
- sf hardis:auth:login
- sf hardis:project:deploy:sources:dx
- sf hardis:project:deploy:smart
16 changes: 8 additions & 8 deletions defaults/ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pipeline {
steps {
script {
sh 'sf hardis:auth:login'
sh 'sf hardis:project:deploy:sources:dx --check'
sh 'sf hardis:project:deploy:smart --check'
}
}
post {
Expand All @@ -77,21 +77,21 @@ pipeline {
}
//MANUAL: add your major branch if necessary
when {
allOf{
allOf {
anyOf {
branch: 'integration'; //Example
branch: 'uat'; //Example
branch: 'preprod'; //Example
branch: 'integration' //Example
branch: 'uat' //Example
branch: 'preprod' //Example
branch: 'main' //Example
};
not {changeRequest()}
};
not { changeRequest() }
}
}
//deploy on the appropriate org
steps {
script {
sh 'sf hardis:auth:login'
sh 'sf hardis:project:deploy:sources:dx'
sh 'sf hardis:project:deploy:smart'
}
}
post {
Expand Down
Loading

0 comments on commit 6d5cac8

Please sign in to comment.