Skip to content

Commit

Permalink
Merge pull request #121 from amtrack/fix/empty-container-types
Browse files Browse the repository at this point in the history
fix: omit pure container types for --children flag
  • Loading branch information
amtrack authored Apr 6, 2022
2 parents f12ac13 + 0065875 commit a35bff5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/commands/force/mdapi/listallmetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ export default class MdapiListAllMetadataCommand extends SfdxCommand {
}
}
}
if (this.flags.children) {
// omit parent types which don't have own properties
ignoreFunctions.push(filters.isPureContainerType);
}
let fileProperties = await listAllMetadata(
conn,
this.flags,
Expand Down
6 changes: 0 additions & 6 deletions src/commands/package.xml/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ export default class PackageXmlGenerateCommand extends SfdxCommand {
if (this.flags.defaultignore) {
ignorePatterns.push(...this.flags.defaultignore);
}
// don't list 'CustomLabels:CustomLabels' if specific 'CustomLabel:XXX' are given
if (fileProperties.find((fp) => fp.type === 'CustomLabel') !== null) {
fileProperties = fileProperties.filter(
(fp) => fp.type !== 'CustomLabels'
);
}
const [, keep] = match(
fileProperties,
ignorePatterns,
Expand Down
16 changes: 16 additions & 0 deletions src/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ const MANAGED_READONLY_TYPES = [
'ApexPage'
];

// parent types which don't have own properties
const PURE_CONTAINER_TYPES = [
'AssignmentRules',
'AutoResponseRules',
'CustomLabels',
'EscalationRules',
'ManagedTopics',
'MatchingRules',
'SharingRules',
'Workflow'
];

const STANDARD_USERNAMES = ['Automated Process', 'salesforce.com'];

export function isManaged(fileProperties: FileProperties): boolean {
Expand Down Expand Up @@ -76,3 +88,7 @@ export function isStandard(fileProperties: FileProperties): boolean {
fileProperties.namespacePrefix === 'standard'
);
}

export function isPureContainerType(fileProperties: FileProperties): boolean {
return PURE_CONTAINER_TYPES.includes(fileProperties.type);
}

0 comments on commit a35bff5

Please sign in to comment.