Skip to content

Commit 7ce161f

Browse files
authored
Merge pull request #109 from amtrack/feat/standard-filter
feat: add filter for standard metadata components
2 parents fcc70bf + 156a107 commit 7ce161f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/commands/force/mdapi/listallmetadata.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ export default class MdapiListAllMetadataCommand extends SfdxCommand {
128128
default: null,
129129
allowNo: true
130130
}),
131+
standard: flags.boolean({
132+
description: `list metadata components like standard objects, settings,...`,
133+
default: null,
134+
allowNo: true
135+
}),
131136
names: flags.boolean({
132137
description: `output only component names (e.g. 'CustomObject:Account',...)`
133138
}),
@@ -157,7 +162,8 @@ export default class MdapiListAllMetadataCommand extends SfdxCommand {
157162
managedwriteable: 'isManagedWriteable',
158163
manageddeprecated: 'isManagedDeprecated',
159164
unlockeddeprecated: 'isUnlockedDeprecated',
160-
deprecated: 'isDeprecated'
165+
deprecated: 'isDeprecated',
166+
standard: 'isStandard'
161167
};
162168
for (const filterFlag of Object.keys(flag2FunctionName)) {
163169
const functionName = flag2FunctionName[filterFlag];

src/filters.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const MANAGED_READONLY_TYPES = [
2121
'ApexPage'
2222
];
2323

24+
const STANDARD_USERNAMES = ['Automated Process', 'salesforce.com'];
25+
2426
export function isManaged(fileProperties: FileProperties): boolean {
2527
return fileProperties.manageableState === 'installed';
2628
}
@@ -63,3 +65,14 @@ export function isDeprecated(fileProperties: FileProperties): boolean {
6365
isUnlockedDeprecated(fileProperties) || isManagedDeprecated(fileProperties)
6466
);
6567
}
68+
69+
export function isStandard(fileProperties: FileProperties): boolean {
70+
return (
71+
(!fileProperties.namespacePrefix &&
72+
!fileProperties.manageableState &&
73+
!fileProperties.id) ||
74+
(STANDARD_USERNAMES.includes(fileProperties.createdByName) &&
75+
STANDARD_USERNAMES.includes(fileProperties.lastModifiedByName)) ||
76+
fileProperties.namespacePrefix === 'standard'
77+
);
78+
}

0 commit comments

Comments
 (0)