-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathensureObjectPermissions.ts.example
32 lines (28 loc) · 1.1 KB
/
ensureObjectPermissions.ts.example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { readFileSync, writeJsonSync, readJSONSync } from 'fs-extra';
import { parse } from 'fast-xml-parser';
var objectPermissions = parse(readFileSync('force-app/main/default/profiles/Admin.profile-meta.xml', 'utf8'), {
ignoreAttributes: false,
parseNodeValue: false,
})
.Profile.objectPermissions.map((el: { object: string }) => el.object)
.filter(Boolean);
let fieldPermissions = parse(readFileSync('force-app/main/default/profiles/Admin.profile-meta.xml', 'utf8'), {
ignoreAttributes: false,
parseNodeValue: false,
})
.Profile.fieldPermissions.map((el: { field: string }) => el.field.split('.')[0])
.filter(Boolean);
let tabVisibilities = parse(readFileSync('force-app/main/default/profiles/Admin.profile-meta.xml', 'utf8'), {
ignoreAttributes: false,
parseNodeValue: false,
})
.Profile.tabVisibilities.map((el: { tab: string }) => el.tab.split('-')[1])
.filter(Boolean);
writeJsonSync(
'.sfdx-jayree.json',
{
...readJSONSync('.sfdx-jayree.json'),
ensureObjectPermissions: [...new Set([...objectPermissions, ...fieldPermissions, ...tabVisibilities])].sort(),
},
{ spaces: 4 }
);