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: add required child type entries to manifest #446

Merged
merged 4 commits into from
Sep 9, 2021
Merged

Conversation

shetzel
Copy link
Contributor

@shetzel shetzel commented Sep 1, 2021

What does this PR do?

When deploying certain parent metadata types to orgs for packaging, the child type entries must also be included within the manifest or the deployment will fail.

This PR changes some parent types in the registry so that their children are included when creating the manifest. Specifically, when calling SourceComponent.getChildren() for non-decomposed types, and the types have both a uniqueIdElement and xmlElementName defined, it will create child SourceComponents for manifest entries.

Also, some changes were made to ComponentSet.getObject() so that duplicate entries and wildcard entries with non-wildcard entries are prevented.

What issues does this PR fix or reference?

forcedotcom/cli#1115
forcedotcom/cli#1163
forcedotcom/cli#1170
@W-9798333@
@W-9816625@

Functionality Before

Deploy error when trying to deploy certain parent types to an org for packaging. E.g., Workflow, SharingRules, ManagedTopics.

"Missing in package.xml

Functionality After

Successful deploy. Converting these types generate the correct manifest.

Testing Notes

Types to test with:
CustomLabel, Settings, Workflows, SharingRules, MatchingRules, AssignmentRules, AutoResponseRules, EscalationRules

Source commands to use for testing (all/any types listed above can be used):
sfdx force:source:manifest:create -m Settings
sfdx force:source:manifest:create -m Settings:<specific_setting>

sfdx force:source:convert -m Settings -d settings1
sfdx force:source:convert -m Settings:<specific_setting> -d settings2
sfdx force:source:convert -m Settings:<specific_setting> -n MyPkg -d settings3

// deploy the converted source from above commands
sfdx force:mdapi:deploy -w 3 -d settings1
sfdx force:mdapi:deploy -w 3 -d settings2
sfdx force:mdapi:deploy -w 3 -d settings3

sfdx force:source:deploy -m Settings
sfdx force:source:deploy -m Settings:<specific_setting>

sfdx force:source:retrieve -m Settings
sfdx force:source:retrieve -m Settings:<specific_setting>

@shetzel shetzel requested review from a team as code owners September 1, 2021 18:39
@mshanemc
Copy link
Contributor

mshanemc commented Sep 2, 2021

QA notes: using sharingRules/Workflow repo
✅ converts without error (and that output deploys via mdapi:deploy). Has the same error as below
✅ deploy -p without error
❌ manifest:generate generates some odd duplicated *

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Lead</members>
        <name>SharingRules</name>
    </types>
    <types>
        <members>*</members>
        <name>SharingOwnerRule</name>
    </types>
    <types>
        <members>*</members>
        <name>SharingCriteriaRule</name>
    </types>
    <types>
        <members>*</members>
        <name>SharingGuestRule</name>
    </types>
    <types>
        <members>*</members>
        <name>SharingTerritoryRule</name>
    </types>
    <types>
        <members>Account</members>
        <members>Case</members>
        <name>Workflow</name>
    </types>
    <types>
        <members>*</members>
        <members>*</members>
        <name>WorkflowFieldUpdate</name>
    </types>
    <types>
        <members>*</members>
        <members>*</members>
        <name>WorkflowKnowledgePublish</name>
    </types>
    <types>
        <members>*</members>
        <members>*</members>
        <name>WorkflowTask</name>
    </types>
    <types>
        <members>*</members>
        <members>*</members>
        <name>WorkflowAlert</name>
    </types>
    <types>
        <members>*</members>
        <members>*</members>
        <name>WorkflowSend</name>
    </types>
    <types>
        <members>*</members>
        <members>*</members>
        <name>WorkflowOutboundMessage</name>
    </types>
    <types>
        <members>*</members>
        <members>*</members>
        <name>WorkflowRule</name>
    </types>
    <version>52.0</version>
</Package>

❌ deploy using -x and the above generated manifest throws ERROR running force:source:deploy: The specified metadata type is unsupported: [sharingguestrule]
✅ force:source:deploy -m SharingRules
✅ source:retrieve -m SharingRules pulled a giant number of them (most every object, almost all empty)
✅ force:source:retrieve -m SharingRules:Lead, -p force-app pulls existing ones
❌ retrieve -x package.xml ERROR running force:source:retrieve: The specified metadata type is unsupported: [sharingguestrule]

} else {
if (!typeEntry.includes(fullName) && !typeEntry.includes(ComponentSet.WILDCARD)) {
typeMap.get(typeName).push(fullName);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This conditional prevents a wildcard from being written in addition to fullNames. It also prevents duplicates.

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