Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: warn when a flow is deleted #894

Merged
merged 10 commits into from
Jul 31, 2024
Merged

Conversation

scolladon
Copy link
Owner

Explain your changes


Add a warning in the output of SGD when the plugin detect a deletion of a flow

Does this close any currently open issues?


closes #893

  • Jest tests added to cover the fix.

Any particular element that can be tested locally


Any other comments


@scolladon
Copy link
Owner Author

Please help reviewing here @amtrack :)

Copy link

codecov bot commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (f79d3dc) to head (39d040f).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #894   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           39        40    +1     
  Lines         1066      1074    +8     
  Branches       115       115           
=========================================
+ Hits          1066      1074    +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/locales/en.ts Outdated Show resolved Hide resolved
README.md Outdated

We know 2 ways to delete flow (documented [here](https://github.com/scolladon/sfdx-git-delta/issues/588#issuecomment-1534318729))
- with `FlowDefinition` metadata, but is obsolete since v44 (and yet still working)
- with flow status and purge of deactivated versions
Copy link
Contributor

@amtrack amtrack Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scolladon I've just tested deploying the Flow with Status=Draft and Status=Obsolete and it didn't disable the Flow in my org.

This is also described here: #588 (comment)

In my opinion the second way would be be actually an addition to the first way:

What I have tested is, that you can disable the Flow using the FlowDefinition activeVersionNumber=0 and delete inactive Flow Versions in a single deployment (here v1 and v2) using a destructiveChanges.xml like:

Set_Account_Description.flowDefinition-meta.xml:

<?xml version="1.0" encoding="UTF-8"?>
<FlowDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
    <activeVersionNumber>0</activeVersionNumber>
</FlowDefinition>

package.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Set_Account_Description</members>
        <name>FlowDefinition</name>
    </types>
    <version>61.0</version>
</Package>

destructiveChanges.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Set_Account_Description-1</members>
        <members>Set_Account_Description-2</members>
        <name>Flow</name>
    </types>
    <version>61.0</version>
</Package>

Copy link
Owner Author

@scolladon scolladon Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great combo, it could be the way to delete a flow with one go (until the v44 is decomissionated and FlowDefinition metadata is not available anymore).

The issue I see is it requires to know which flow versions to list in the destructiveChanges.xml... Which can be a complicated things to determine for SGD because it could not be the same in different environments and the plugin is not connected to any environment.

So I think it should not be handled by SGD.
It could be automatized by another plugin dedicated to deleting flow.

I'll update the documentation in the PR with your solution, thx

README.md Outdated
Comment on lines 539 to 543
We suggest to deal with flow deletion in one go by following those steps (it requires the `FlowDefinition` metadata which is not avalable in API `v44+`)
1. Set the `FlowDefinition` `activeVersionNumber` to `0`
2. List the `FlowDefinition` in the `package.xml`
3. List all the existing version of the `Flow` in the `destructiveChanges.xml` (can be fetch via SOQL using this query : `SELECT FlowDefinitionView.ApiName, VersionNumber, Status FROM FlowVersionView WHERE FlowDefinitionView.ApiName='<FLOW_API_NAME>'`)
4. Deploy this `FlowDefinition` with a `package.xml` and post delete all the `Flow` versions with a post `destructiveChangesPost.xml`
Copy link
Owner Author

@scolladon scolladon Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: do you think you could deal with this automation inside sfdx-hardis

I think it could be wrap behind a command like sf hardis org delete flow -n <FLOW_API_NAME>, what do you think @nvuillam ?

Co-authored-by: Matthias Rolke <mr.amtrack@gmail.com>
@scolladon scolladon force-pushed the feat/document-flow-deletion branch from d4368f8 to 4e9fafc Compare July 29, 2024 16:42
@scolladon scolladon force-pushed the feat/document-flow-deletion branch from 4e9fafc to fc5cfe0 Compare July 29, 2024 16:51
mehdicherf
mehdicherf previously approved these changes Jul 31, 2024
@scolladon
Copy link
Owner Author

Hi @amtrack !

We have updated the warning message and the readme, what do you think now ?

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link
Contributor

@amtrack amtrack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scolladon Thanks! Looks good to me! I've only suggested to correct destructiveChanges.xml to destructiveChangesPost.xml.

Co-authored-by: Matthias Rolke <mr.amtrack@gmail.com>
Co-authored-by: Matthias Rolke <mr.amtrack@gmail.com>
Copy link

codeclimate bot commented Jul 31, 2024

Code Climate has analyzed commit 39d040f and detected 0 issues on this pull request.

View more on Code Climate.

@scolladon scolladon merged commit 0f186ce into main Jul 31, 2024
18 of 21 checks passed
@scolladon scolladon deleted the feat/document-flow-deletion branch July 31, 2024 14:50
Copy link

github-actions bot commented Aug 2, 2024

Shipped in release v5.41.0.
You can install the new version using the version number or the latest-rc channel

$ sfdx plugins:install sfdx-git-delta@latest-rc
$ sfdx plugins:install sfdx-git-delta@v5.41.0

Happy incremental deployment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants