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: convert project to use a new source behavior #1015

Merged
merged 23 commits into from
May 29, 2024

Conversation

mshanemc
Copy link
Contributor

What does this PR do?

adds command project convert source-behavior
mostly uses only NUTs to test (local-only project is reasonably quick)

What issues does this PR fix or reference?

@W-15639938@

@mshanemc mshanemc requested a review from a team as a code owner May 21, 2024 15:51

For example, run this command with the "--behavior decomposePermissionSet" flag to start decomposing permission sets when you deploy or retrieve them. Decomposing means breaking up the monolithic metadata API format XML file that corresponds to a metadata component into smaller XML files and directories based on its subtypes. Permission sets are not decomposed by default; you must opt-in to start decomposing them by using this command. When the command finishes, your "sfdx-project.json" file is updated to always decompose permission sets, and the existing permission set files in your local package directories are converted into the new decomposed format. You run this command only once for a given behavior change.

For more information about the possible values for the --behavior flag, see the "sourceBehaviorOptions" section in the https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm topic.
Copy link
Contributor

Choose a reason for hiding this comment

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

Just confirming this is going to be updated (cc @jshackell-sfdc)

Copy link
Contributor

@jshackell-sfdc jshackell-sfdc May 28, 2024

Choose a reason for hiding this comment

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

My initial thought when I reviewed the help was to NOT include the Beta label in the --help because then we have to remember to update it for GA. But if you think it's better to show it now, then that's fine. I realize that the example wouldn't work in its original form until GA...

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, the command does tell you what the correct behavior names are in the error message:

> sf project convert source-behavior --behavior decomposePermissionSet
Warning: This command is currently in beta. Any aspect of this command can change without advanced notice. Don't use beta commands in your scripts.
Error (2): Expected --behavior=decomposePermissionSet to be one of: decomposeCustomLabelsBeta, decomposePermissionSetBeta, decomposeSharingRulesBeta, decomposeWorkflowBeta
See more help with --help

...but the See more help with --help would be confusing if we don't update them to the correct names (with Beta)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh sorry, and by "this", I meant the https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm docs page. It does not currently have a sourceBehaviorOptions section

Copy link
Contributor

Choose a reason for hiding this comment

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

I checked in an update with that new section last week, it should show up tomorrow. Cross your fingers!

});

if (!flags['preserve-temp-dir']) {
await rm(TMP_DIR, { recursive: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 This is not working, when I use --dry-run without --preserve-temp-dir I have a directory call DRY-RUN-RESULTS. It looks like the value of TMP_DIR is decompositionConverterTempDir

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, intentional. DRY-RUN-RESULTS is not the TMP_DIR.

You'd want to see what would have ended up in your project if you use --dry-run. Not just the filenames, but the contents of those files.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. I do see the distinction now. I added a simple change to the --help to specify where the dry-run files will be created
https://github.com/salesforcecli/plugin-deploy-retrieve/pull/1015/files#r1617872864

@iowillhoit
Copy link
Contributor

iowillhoit commented May 28, 2024

QA NOTES

  • 🟢 Using a non-existent behavior provides a list of all options
  • 🟢 Running the convert on a project with a source-tracked org will show a warning/instructions
  • 🟢 Running convert on CustomLabels decomposes type and updates sfdx-project.json
    • 🟢 Able to deploy a change to a custom label
  • 🟢 Running convert on Workflow decomposes type and updates sfdx-project.json
    • 🟢 Able to deploy a change to a workflow
  • 🟢 Running convert on PermissionSets decomposes type and updates sfdx-project.json
    • 🟢 Able to deploy a change to a permission set
    • 🟠 I edited a field permission and ran sf project deploy start, and the deploy showed every file under permissionsets/ as Changed. This is not the same behavior that I noticed on Workflows and CustomLabels.
  • 🟠 --dry-run does not clean up temp dir. See comment

Edit:
🟠 above have been clarified

  • 🟢 --preserve-temp-dir does leave the md results dir

@mshanemc
Copy link
Contributor Author

This is not the same behavior that I noticed on Workflows and CustomLabels

yeah, the metadata API doesn't provide child-level responses for PermissionSet because there aren't any. The response can't tell you what child actually changed.

The other types can, so we use that. Open to alternative ways of handling it, but I couldn't think of a good one.

Co-authored-by: Willhoit <iowillhoit@users.noreply.github.com>
Co-authored-by: Willhoit <iowillhoit@users.noreply.github.com>
@mshanemc mshanemc merged commit 014500e into main May 29, 2024
39 of 40 checks passed
@mshanemc mshanemc deleted the sm/presets-conversion-command branch May 29, 2024 14:25
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