@simplysf/simply-permissions 1.6.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -48
- package/lib/commands/simply/permissions/build.d.ts +24 -10
- package/lib/commands/simply/permissions/build.js +67 -31
- package/lib/commands/simply/permissions/build.js.map +1 -1
- package/messages/simply.permissions.build.md +38 -40
- package/oclif.manifest.json +9 -28
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ FLAG DESCRIPTIONS
|
|
|
66
66
|
The path to write the generated HTML report to.
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
_See code: [lib/commands/simply/permissions/analyze.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@
|
|
69
|
+
_See code: [lib/commands/simply/permissions/analyze.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@2.0.0/packages/simply-permissions/lib/commands/simply/permissions/analyze.js)_
|
|
70
70
|
|
|
71
71
|
## `sf simply permissions assignment delete`
|
|
72
72
|
|
|
@@ -109,7 +109,7 @@ EXAMPLES
|
|
|
109
109
|
$ sf simply permissions assignment delete --permission-set-group-name My_Permission_Set_Group --target-org myOrg
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
_See code: [lib/commands/simply/permissions/assignment/delete.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@
|
|
112
|
+
_See code: [lib/commands/simply/permissions/assignment/delete.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@2.0.0/packages/simply-permissions/lib/commands/simply/permissions/assignment/delete.js)_
|
|
113
113
|
|
|
114
114
|
## `sf simply permissions build`
|
|
115
115
|
|
|
@@ -117,14 +117,13 @@ Generate permission sets from Salesforce source metadata.
|
|
|
117
117
|
|
|
118
118
|
```
|
|
119
119
|
USAGE
|
|
120
|
-
$ sf simply permissions build [--json] [--flags-dir <value>] [
|
|
121
|
-
|
|
120
|
+
$ sf simply permissions build [--json] [--flags-dir <value>] [--type read-only|view-all|modify-all] [-n <value>] [-d
|
|
121
|
+
<value>] [-c <value>] [--output <value>] [--include-record-types] [--label <value>] [--description <value>]
|
|
122
122
|
[--check]
|
|
123
123
|
|
|
124
124
|
FLAGS
|
|
125
125
|
-c, --config=<value> Path to a permission set configuration file
|
|
126
126
|
-d, --directory=<value> Path to the Salesforce project directory
|
|
127
|
-
-f, --file=<value> Path to a permission sets file declaring every permission set to generate
|
|
128
127
|
-n, --name=<value> API name for the permission set
|
|
129
128
|
--check Check that the generated permission sets are up to date, without writing them
|
|
130
129
|
--description=<value> Description for the permission set
|
|
@@ -146,38 +145,29 @@ DESCRIPTION
|
|
|
146
145
|
override individual object, field, tab, record type, and user permission settings, as well as whether the permission
|
|
147
146
|
set requires activation.
|
|
148
147
|
|
|
149
|
-
To regenerate every permission set in a project with one command,
|
|
150
|
-
|
|
151
|
-
of this command
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
file, including referenced override files and source directories, is validated before anything is written, and each
|
|
155
|
-
source directory is scanned only once. Name the file with the .psbuild.json suffix (for example
|
|
156
|
-
config/app.psbuild.json): that's how `sf simply cicd build check-permission-sets` finds permission sets files, and
|
|
157
|
-
this command warns about a file without it.
|
|
148
|
+
To regenerate every permission set in a project with one command, define each one in its own permission set build
|
|
149
|
+
file: a JSON file whose name ends in .psbuild.json (for example config/app-admin.psbuild.json), with the same settings
|
|
150
|
+
as one run of this command. "name", "type", "directory", and "output" are required; "label", "description",
|
|
151
|
+
"includeRecordTypes", and "config" are optional. "config" is either a path to a --config file or the same overrides
|
|
152
|
+
inline. Relative paths are resolved against the current directory, as they are for flags.
|
|
158
153
|
|
|
159
|
-
{
|
|
160
|
-
"defaults": {
|
|
161
|
-
"directory": "force-app",
|
|
162
|
-
"output": "force-app/main/default/permissionsets"
|
|
163
|
-
},
|
|
164
|
-
"permissionSets": [
|
|
165
|
-
{ "name": "App_Read_Only", "type": "read-only" },
|
|
166
154
|
{
|
|
167
155
|
"name": "App_Admin",
|
|
168
156
|
"type": "modify-all",
|
|
169
157
|
"label": "App Admin",
|
|
158
|
+
"directory": "force-app",
|
|
159
|
+
"output": "force-app/main/default/permissionsets",
|
|
170
160
|
"includeRecordTypes": true,
|
|
171
161
|
"config": "config/app-admin-overrides.json"
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
"name": "App_Support",
|
|
175
|
-
"type": "view-all",
|
|
176
|
-
"config": { "userPermissions": { "ViewSetup": true } }
|
|
177
|
-
}
|
|
178
|
-
]
|
|
179
162
|
}
|
|
180
163
|
|
|
164
|
+
Then run the command with none of the flags that describe a single permission set. It builds the permission set
|
|
165
|
+
defined by every .psbuild.json file under the current directory, skipping node_modules, .git, .sf, and .sfdx. Every
|
|
166
|
+
file, including referenced override files and source directories, is validated before anything is written, no two
|
|
167
|
+
files can define the same permission set name, and each source directory is scanned only once. The results table shows
|
|
168
|
+
which file defined each permission set. If no .psbuild.json files are found, the command prints a warning and exits
|
|
169
|
+
successfully. `sf simply cicd build check-permission-sets` finds the same files.
|
|
170
|
+
|
|
181
171
|
To check in CI that the committed permission sets still match their source metadata, add --check. It builds each
|
|
182
172
|
permission set as usual but writes nothing: it compares each one with the file already at its output path and reports
|
|
183
173
|
it as "up-to-date", "drifted", or "missing". If any permission set has drifted or is missing, the command exits with
|
|
@@ -189,13 +179,13 @@ EXAMPLES
|
|
|
189
179
|
|
|
190
180
|
$ sf simply permissions build --type modify-all --name My_Admin_Access --directory force-app --config config/permission-overrides.json --output force-app/main/default/permissionsets --include-record-types
|
|
191
181
|
|
|
192
|
-
Regenerate
|
|
182
|
+
Regenerate the permission set defined by every .psbuild.json file under the current directory:
|
|
193
183
|
|
|
194
|
-
$ sf simply permissions build
|
|
184
|
+
$ sf simply permissions build
|
|
195
185
|
|
|
196
|
-
In CI, fail if any permission set
|
|
186
|
+
In CI, fail if any permission set defined by a .psbuild.json file needs to be regenerated, without writing anything:
|
|
197
187
|
|
|
198
|
-
$ sf simply permissions build --
|
|
188
|
+
$ sf simply permissions build --check
|
|
199
189
|
|
|
200
190
|
FLAG DESCRIPTIONS
|
|
201
191
|
-c, --config=<value> Path to a permission set configuration file
|
|
@@ -205,26 +195,19 @@ FLAG DESCRIPTIONS
|
|
|
205
195
|
|
|
206
196
|
-d, --directory=<value> Path to the Salesforce project directory
|
|
207
197
|
|
|
208
|
-
The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types. Required
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
-f, --file=<value> Path to a permission sets file declaring every permission set to generate
|
|
212
|
-
|
|
213
|
-
The path to a JSON file with a "permissionSets" array, each entry describing one permission set to generate ("name",
|
|
214
|
-
"type", and optionally "label", "description", "directory", "output", "includeRecordTypes", "config"), and an
|
|
215
|
-
optional "defaults" object. Name it with the .psbuild.json suffix; any other name works but prints a warning. Can't
|
|
216
|
-
be combined with the flags that describe a single permission set.
|
|
198
|
+
The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types. Required to
|
|
199
|
+
build a single permission set.
|
|
217
200
|
|
|
218
201
|
-n, --name=<value> API name for the permission set
|
|
219
202
|
|
|
220
|
-
The API name for the generated permission set; also used to derive the output filename. Required
|
|
221
|
-
|
|
203
|
+
The API name for the generated permission set; also used to derive the output filename. Required to build a single
|
|
204
|
+
permission set.
|
|
222
205
|
|
|
223
206
|
--check Check that the generated permission sets are up to date, without writing them
|
|
224
207
|
|
|
225
208
|
Instead of writing each permission set, compare what would be generated with the file already at its output path.
|
|
226
|
-
Exits with code 1 if any permission set has drifted or is missing. Works with
|
|
227
|
-
|
|
209
|
+
Exits with code 1 if any permission set has drifted or is missing. Works with the single-permission-set flags, and
|
|
210
|
+
without them, which checks the permission set defined by every .psbuild.json file under the current directory.
|
|
228
211
|
|
|
229
212
|
--include-record-types Include record type visibilities
|
|
230
213
|
|
|
@@ -232,16 +215,16 @@ FLAG DESCRIPTIONS
|
|
|
232
215
|
|
|
233
216
|
--output=<value> Output directory
|
|
234
217
|
|
|
235
|
-
The directory to write the generated permission set XML file to. Required
|
|
218
|
+
The directory to write the generated permission set XML file to. Required to build a single permission set.
|
|
236
219
|
|
|
237
220
|
--type=read-only|view-all|modify-all Baseline permission type
|
|
238
221
|
|
|
239
222
|
The baseline permission level to generate: 'read-only' grants read access to all discovered objects and fields,
|
|
240
223
|
'view-all' additionally grants view-all-records, and 'modify-all' grants full CRUD and modify-all-records access.
|
|
241
|
-
Required
|
|
224
|
+
Required to build a single permission set.
|
|
242
225
|
```
|
|
243
226
|
|
|
244
|
-
_See code: [lib/commands/simply/permissions/build.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@
|
|
227
|
+
_See code: [lib/commands/simply/permissions/build.js](https://github.com/SimplySF/simply-plugins/blob/@simplysf/simply-permissions@2.0.0/packages/simply-permissions/lib/commands/simply/permissions/build.js)_
|
|
245
228
|
<!-- commandsstop -->
|
|
246
229
|
|
|
247
230
|
## Configuration Files
|
|
@@ -9,10 +9,13 @@ type PermissionsBuildEntry = PermissionSetBuildResult & {
|
|
|
9
9
|
* permissions it grants. With `--check`, `status` says whether the file there matches.
|
|
10
10
|
*/
|
|
11
11
|
export type PermissionsBuildResult = Omit<PermissionsBuildEntry, 'name'>;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/**
|
|
13
|
+
* With none of the single-permission-set flags: one entry per discovered permission set build file,
|
|
14
|
+
* each with the `file` that defined it, in file order.
|
|
15
|
+
*/
|
|
16
|
+
export type PermissionsBuildDiscoverResult = Array<{
|
|
17
|
+
file: string;
|
|
18
|
+
} & PermissionsBuildEntry>;
|
|
16
19
|
/**
|
|
17
20
|
* Scans a Salesforce project directory for custom objects, fields, tabs, and (optionally)
|
|
18
21
|
* record types, then generates a permission set XML file with a baseline of permissions
|
|
@@ -20,18 +23,18 @@ export declare function suffixedName(file: string): string;
|
|
|
20
23
|
* field, tab, record type, and user permission settings, as well as whether the permission set
|
|
21
24
|
* requires activation.
|
|
22
25
|
*
|
|
23
|
-
* With
|
|
24
|
-
*
|
|
26
|
+
* With none of the single-permission-set flags, does the same for every permission set build file
|
|
27
|
+
* under the current directory, each of which defines one permission set, validating all of them
|
|
28
|
+
* before writing anything.
|
|
25
29
|
*
|
|
26
30
|
* With `--check`, writes nothing: compares each permission set it would generate with the file
|
|
27
31
|
* already at its output path, and sets `process.exitCode = 1` if any has drifted or is missing.
|
|
28
32
|
*/
|
|
29
|
-
export default class PermissionsBuild extends SfCommand<PermissionsBuildResult |
|
|
33
|
+
export default class PermissionsBuild extends SfCommand<PermissionsBuildResult | PermissionsBuildDiscoverResult> {
|
|
30
34
|
static readonly summary: string;
|
|
31
35
|
static readonly description: string;
|
|
32
36
|
static readonly examples: string[];
|
|
33
37
|
static readonly flags: {
|
|
34
|
-
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
35
38
|
type: import("@oclif/core/interfaces").OptionFlag<PermissionSetType | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
36
39
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
37
40
|
directory: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -44,14 +47,25 @@ export default class PermissionsBuild extends SfCommand<PermissionsBuildResult |
|
|
|
44
47
|
'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
45
48
|
};
|
|
46
49
|
/**
|
|
47
|
-
* @returns The output file path and object/field permission counts — or, with
|
|
50
|
+
* @returns The output file path and object/field permission counts — or, with no single-permission-set flags,
|
|
51
|
+
* one such entry (plus its name and file) per discovered permission set build file.
|
|
48
52
|
* With `--check`, each also has a `status`, and `process.exitCode` is set to 1 when any isn't `up-to-date`.
|
|
49
53
|
*/
|
|
50
|
-
run(): Promise<PermissionsBuildResult |
|
|
54
|
+
run(): Promise<PermissionsBuildResult | PermissionsBuildDiscoverResult>;
|
|
51
55
|
/** Resolves the single-permission-set flags into a spec, reporting every missing required flag at once. */
|
|
52
56
|
private singleSpec;
|
|
57
|
+
/**
|
|
58
|
+
* Builds (or, with `check`, checks) the permission set defined by every permission set build file
|
|
59
|
+
* under the current directory. Every file is loaded and validated, and names are checked for
|
|
60
|
+
* duplicates across files, before anything is written. No files is a warning, not an error, so the
|
|
61
|
+
* command is safe to run in any repo.
|
|
62
|
+
*/
|
|
63
|
+
private buildDiscovered;
|
|
64
|
+
/** @param sources - With discovery, the permission set build file each spec came from, shown as a FILE column. */
|
|
53
65
|
private generate;
|
|
54
66
|
private check;
|
|
67
|
+
/** Prints one row per result, with a leading FILE column when `sources` gives each result's permission set build file. */
|
|
68
|
+
private printTable;
|
|
55
69
|
private readConfig;
|
|
56
70
|
private startSpinner;
|
|
57
71
|
}
|
|
@@ -15,16 +15,10 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Messages } from '@salesforce/core';
|
|
17
17
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
-
import { checkPermissionSets, generatePermissionSets, loadPermissionSetBuildConfig,
|
|
18
|
+
import { assertUniquePermissionSetNames, checkPermissionSets, findPermissionSetBuildFiles, generatePermissionSets, loadPermissionSetBuildConfig, loadPermissionSetBuildFile, PermissionSetBuildError, } from '@simplysf/simply-permissions-core';
|
|
19
19
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
20
20
|
const messages = Messages.loadMessages('@simplysf/simply-permissions', 'simply.permissions.build');
|
|
21
|
-
/**
|
|
22
|
-
export function suffixedName(file) {
|
|
23
|
-
return file.endsWith('.json')
|
|
24
|
-
? `${file.slice(0, -'.json'.length)}${PERMISSION_SETS_FILE_SUFFIX}`
|
|
25
|
-
: `${file}${PERMISSION_SETS_FILE_SUFFIX}`;
|
|
26
|
-
}
|
|
27
|
-
/** The flags that describe a single permission set, and so can't be combined with `--file`. */
|
|
21
|
+
/** The flags that describe a single permission set. When none is given, every discovered permission set build file is built. */
|
|
28
22
|
const SINGLE_PERMISSION_SET_FLAGS = [
|
|
29
23
|
'type',
|
|
30
24
|
'name',
|
|
@@ -52,6 +46,22 @@ function toCliError(error) {
|
|
|
52
46
|
return messages.createError('error.configNotFound', error.args);
|
|
53
47
|
case 'directory-not-found':
|
|
54
48
|
return messages.createError('error.directoryNotFound', error.args);
|
|
49
|
+
case 'legacy-format':
|
|
50
|
+
return messages.createError('error.legacyFormat', error.args);
|
|
51
|
+
case 'duplicate-name':
|
|
52
|
+
return messages.createError('error.duplicateName', error.args);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Loads a discovered permission set build file, naming the file in any validation error. */
|
|
56
|
+
async function loadDiscoveredFile(file) {
|
|
57
|
+
try {
|
|
58
|
+
return await loadPermissionSetBuildFile(file);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
if (error instanceof PermissionSetBuildError) {
|
|
62
|
+
throw messages.createError('error.invalidBuildFile', [file, toCliError(error).message]);
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
55
65
|
}
|
|
56
66
|
}
|
|
57
67
|
/**
|
|
@@ -61,8 +71,9 @@ function toCliError(error) {
|
|
|
61
71
|
* field, tab, record type, and user permission settings, as well as whether the permission set
|
|
62
72
|
* requires activation.
|
|
63
73
|
*
|
|
64
|
-
* With
|
|
65
|
-
*
|
|
74
|
+
* With none of the single-permission-set flags, does the same for every permission set build file
|
|
75
|
+
* under the current directory, each of which defines one permission set, validating all of them
|
|
76
|
+
* before writing anything.
|
|
66
77
|
*
|
|
67
78
|
* With `--check`, writes nothing: compares each permission set it would generate with the file
|
|
68
79
|
* already at its output path, and sets `process.exitCode = 1` if any has drifted or is missing.
|
|
@@ -73,13 +84,6 @@ export default class PermissionsBuild extends SfCommand {
|
|
|
73
84
|
static examples = messages.getMessages('examples');
|
|
74
85
|
static flags = {
|
|
75
86
|
...SfCommand.baseFlags,
|
|
76
|
-
file: Flags.file({
|
|
77
|
-
summary: messages.getMessage('flags.file.summary'),
|
|
78
|
-
description: messages.getMessage('flags.file.description'),
|
|
79
|
-
char: 'f',
|
|
80
|
-
exists: true,
|
|
81
|
-
exclusive: SINGLE_PERMISSION_SET_FLAGS,
|
|
82
|
-
}),
|
|
83
87
|
type: Flags.custom({
|
|
84
88
|
options: ['read-only', 'view-all', 'modify-all'],
|
|
85
89
|
})({
|
|
@@ -125,21 +129,18 @@ export default class PermissionsBuild extends SfCommand {
|
|
|
125
129
|
}),
|
|
126
130
|
};
|
|
127
131
|
/**
|
|
128
|
-
* @returns The output file path and object/field permission counts — or, with
|
|
132
|
+
* @returns The output file path and object/field permission counts — or, with no single-permission-set flags,
|
|
133
|
+
* one such entry (plus its name and file) per discovered permission set build file.
|
|
129
134
|
* With `--check`, each also has a `status`, and `process.exitCode` is set to 1 when any isn't `up-to-date`.
|
|
130
135
|
*/
|
|
131
136
|
async run() {
|
|
132
137
|
const { flags } = await this.parse(PermissionsBuild);
|
|
133
138
|
try {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.warn(messages.getMessage('warning.unsuffixedFile', [file, suffixedName(file)]));
|
|
137
|
-
}
|
|
138
|
-
const specs = file ? await this.readConfig(() => loadPermissionSetsFile(file)) : await this.singleSpec(flags);
|
|
139
|
-
const results = flags.check ? await this.check(specs) : await this.generate(specs, Boolean(file));
|
|
140
|
-
if (file) {
|
|
141
|
-
return results;
|
|
139
|
+
if (!SINGLE_PERMISSION_SET_FLAGS.some((flag) => flags[flag])) {
|
|
140
|
+
return await this.buildDiscovered(flags.check);
|
|
142
141
|
}
|
|
142
|
+
const specs = await this.singleSpec(flags);
|
|
143
|
+
const results = flags.check ? await this.check(specs) : await this.generate(specs, false);
|
|
143
144
|
// Single-set mode has never included `name` in its result.
|
|
144
145
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
145
146
|
const { name, ...result } = results[0];
|
|
@@ -171,11 +172,38 @@ export default class PermissionsBuild extends SfCommand {
|
|
|
171
172
|
},
|
|
172
173
|
];
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Builds (or, with `check`, checks) the permission set defined by every permission set build file
|
|
177
|
+
* under the current directory. Every file is loaded and validated, and names are checked for
|
|
178
|
+
* duplicates across files, before anything is written. No files is a warning, not an error, so the
|
|
179
|
+
* command is safe to run in any repo.
|
|
180
|
+
*/
|
|
181
|
+
async buildDiscovered(check) {
|
|
182
|
+
const files = await findPermissionSetBuildFiles();
|
|
183
|
+
if (files.length === 0) {
|
|
184
|
+
this.warn(messages.getMessage('warning.noFilesFound'));
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
this.info(messages.getMessage('info.filesFound', [files.length]));
|
|
188
|
+
const entries = [];
|
|
189
|
+
await this.readConfig(async () => {
|
|
190
|
+
for (const file of files) {
|
|
191
|
+
// eslint-disable-next-line no-await-in-loop -- files are loaded in order so the first invalid one is the one reported
|
|
192
|
+
entries.push({ file, spec: await loadDiscoveredFile(file) });
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
assertUniquePermissionSetNames(entries);
|
|
196
|
+
const specs = entries.map(({ spec }) => spec);
|
|
197
|
+
const sources = entries.map(({ file }) => file);
|
|
198
|
+
const results = check ? await this.check(specs, sources) : await this.generate(specs, true, sources);
|
|
199
|
+
return results.map((result, i) => ({ file: sources[i], ...result }));
|
|
200
|
+
}
|
|
201
|
+
/** @param sources - With discovery, the permission set build file each spec came from, shown as a FILE column. */
|
|
202
|
+
async generate(specs, asTable, sources) {
|
|
175
203
|
const results = await generatePermissionSets(specs, (name) => this.startSpinner('info.buildingPermissionSet', name));
|
|
176
204
|
this.spinner.stop();
|
|
177
|
-
if (
|
|
178
|
-
this.
|
|
205
|
+
if (asTable) {
|
|
206
|
+
this.printTable(results, sources);
|
|
179
207
|
this.info(messages.getMessage('info.filesGenerated', [results.length]));
|
|
180
208
|
}
|
|
181
209
|
else {
|
|
@@ -183,10 +211,10 @@ export default class PermissionsBuild extends SfCommand {
|
|
|
183
211
|
}
|
|
184
212
|
return results;
|
|
185
213
|
}
|
|
186
|
-
async check(specs) {
|
|
214
|
+
async check(specs, sources) {
|
|
187
215
|
const results = await checkPermissionSets(specs, (name) => this.startSpinner('info.checkingPermissionSet', name));
|
|
188
216
|
this.spinner.stop();
|
|
189
|
-
this.
|
|
217
|
+
this.printTable(results, sources, [{ key: 'status', name: 'STATUS' }]);
|
|
190
218
|
const stale = results.filter((result) => result.status !== 'up-to-date').length;
|
|
191
219
|
if (stale > 0) {
|
|
192
220
|
this.warn(messages.getMessage('warning.drifted', [stale, results.length]));
|
|
@@ -197,6 +225,14 @@ export default class PermissionsBuild extends SfCommand {
|
|
|
197
225
|
}
|
|
198
226
|
return results;
|
|
199
227
|
}
|
|
228
|
+
/** Prints one row per result, with a leading FILE column when `sources` gives each result's permission set build file. */
|
|
229
|
+
printTable(results, sources, extraColumns = []) {
|
|
230
|
+
const fileColumn = sources ? [{ key: 'file', name: 'FILE' }] : [];
|
|
231
|
+
this.table({
|
|
232
|
+
data: results.map((result, i) => ({ file: sources?.[i], ...result })),
|
|
233
|
+
columns: [...fileColumn, ...TABLE_COLUMNS, ...extraColumns],
|
|
234
|
+
});
|
|
235
|
+
}
|
|
200
236
|
async readConfig(load) {
|
|
201
237
|
this.spinner.start(messages.getMessage('info.readingConfig'));
|
|
202
238
|
const loaded = await load();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../src/commands/simply/permissions/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,4BAA4B,EAC5B,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["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CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC"}
|
|
@@ -6,39 +6,21 @@ Generate permission sets from Salesforce source metadata.
|
|
|
6
6
|
|
|
7
7
|
Scans a Salesforce project directory for custom objects, fields, tabs, and (optionally) record types, then generates a permission set XML file with a baseline of permissions determined by --type. An optional JSON --config file can override individual object, field, tab, record type, and user permission settings, as well as whether the permission set requires activation.
|
|
8
8
|
|
|
9
|
-
To regenerate every permission set in a project with one command,
|
|
9
|
+
To regenerate every permission set in a project with one command, define each one in its own permission set build file: a JSON file whose name ends in .psbuild.json (for example config/app-admin.psbuild.json), with the same settings as one run of this command. "name", "type", "directory", and "output" are required; "label", "description", "includeRecordTypes", and "config" are optional. "config" is either a path to a --config file or the same overrides inline. Relative paths are resolved against the current directory, as they are for flags.
|
|
10
10
|
|
|
11
11
|
{
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"name": "App_Admin",
|
|
20
|
-
"type": "modify-all",
|
|
21
|
-
"label": "App Admin",
|
|
22
|
-
"includeRecordTypes": true,
|
|
23
|
-
"config": "config/app-admin-overrides.json"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
"name": "App_Support",
|
|
27
|
-
"type": "view-all",
|
|
28
|
-
"config": { "userPermissions": { "ViewSetup": true } }
|
|
29
|
-
}
|
|
30
|
-
]
|
|
12
|
+
"name": "App_Admin",
|
|
13
|
+
"type": "modify-all",
|
|
14
|
+
"label": "App Admin",
|
|
15
|
+
"directory": "force-app",
|
|
16
|
+
"output": "force-app/main/default/permissionsets",
|
|
17
|
+
"includeRecordTypes": true,
|
|
18
|
+
"config": "config/app-admin-overrides.json"
|
|
31
19
|
}
|
|
32
20
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
# flags.file.summary
|
|
36
|
-
|
|
37
|
-
Path to a permission sets file declaring every permission set to generate
|
|
38
|
-
|
|
39
|
-
# flags.file.description
|
|
21
|
+
Then run the command with none of the flags that describe a single permission set. It builds the permission set defined by every .psbuild.json file under the current directory, skipping node_modules, .git, .sf, and .sfdx. Every file, including referenced override files and source directories, is validated before anything is written, no two files can define the same permission set name, and each source directory is scanned only once. The results table shows which file defined each permission set. If no .psbuild.json files are found, the command prints a warning and exits successfully. `sf simply cicd build check-permission-sets` finds the same files.
|
|
40
22
|
|
|
41
|
-
|
|
23
|
+
To check in CI that the committed permission sets still match their source metadata, add --check. It builds each permission set as usual but writes nothing: it compares each one with the file already at its output path and reports it as "up-to-date", "drifted", or "missing". If any permission set has drifted or is missing, the command exits with code 1. Formatting differences, such as indentation, line endings, or comments, don't count as drift, so files reformatted by Prettier still pass. Any other difference does, including hand edits and reordered entries.
|
|
42
24
|
|
|
43
25
|
# flags.type.summary
|
|
44
26
|
|
|
@@ -46,7 +28,7 @@ Baseline permission type
|
|
|
46
28
|
|
|
47
29
|
# flags.type.description
|
|
48
30
|
|
|
49
|
-
The baseline permission level to generate: 'read-only' grants read access to all discovered objects and fields, 'view-all' additionally grants view-all-records, and 'modify-all' grants full CRUD and modify-all-records access. Required
|
|
31
|
+
The baseline permission level to generate: 'read-only' grants read access to all discovered objects and fields, 'view-all' additionally grants view-all-records, and 'modify-all' grants full CRUD and modify-all-records access. Required to build a single permission set.
|
|
50
32
|
|
|
51
33
|
# flags.name.summary
|
|
52
34
|
|
|
@@ -54,7 +36,7 @@ API name for the permission set
|
|
|
54
36
|
|
|
55
37
|
# flags.name.description
|
|
56
38
|
|
|
57
|
-
The API name for the generated permission set; also used to derive the output filename. Required
|
|
39
|
+
The API name for the generated permission set; also used to derive the output filename. Required to build a single permission set.
|
|
58
40
|
|
|
59
41
|
# flags.directory.summary
|
|
60
42
|
|
|
@@ -62,7 +44,7 @@ Path to the Salesforce project directory
|
|
|
62
44
|
|
|
63
45
|
# flags.directory.description
|
|
64
46
|
|
|
65
|
-
The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types. Required
|
|
47
|
+
The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types. Required to build a single permission set.
|
|
66
48
|
|
|
67
49
|
# flags.config.summary
|
|
68
50
|
|
|
@@ -78,7 +60,7 @@ Output directory
|
|
|
78
60
|
|
|
79
61
|
# flags.output.description
|
|
80
62
|
|
|
81
|
-
The directory to write the generated permission set XML file to. Required
|
|
63
|
+
The directory to write the generated permission set XML file to. Required to build a single permission set.
|
|
82
64
|
|
|
83
65
|
# flags.include-record-types.summary
|
|
84
66
|
|
|
@@ -102,7 +84,7 @@ Check that the generated permission sets are up to date, without writing them
|
|
|
102
84
|
|
|
103
85
|
# flags.check.description
|
|
104
86
|
|
|
105
|
-
Instead of writing each permission set, compare what would be generated with the file already at its output path. Exits with code 1 if any permission set has drifted or is missing. Works with
|
|
87
|
+
Instead of writing each permission set, compare what would be generated with the file already at its output path. Exits with code 1 if any permission set has drifted or is missing. Works with the single-permission-set flags, and without them, which checks the permission set defined by every .psbuild.json file under the current directory.
|
|
106
88
|
|
|
107
89
|
# examples
|
|
108
90
|
|
|
@@ -110,17 +92,29 @@ Instead of writing each permission set, compare what would be generated with the
|
|
|
110
92
|
|
|
111
93
|
- <%= config.bin %> <%= command.id %> --type modify-all --name My_Admin_Access --directory force-app --config config/permission-overrides.json --output force-app/main/default/permissionsets --include-record-types
|
|
112
94
|
|
|
113
|
-
- Regenerate
|
|
95
|
+
- Regenerate the permission set defined by every .psbuild.json file under the current directory:
|
|
114
96
|
|
|
115
|
-
<%= config.bin %> <%= command.id %>
|
|
97
|
+
<%= config.bin %> <%= command.id %>
|
|
116
98
|
|
|
117
|
-
- In CI, fail if any permission set
|
|
99
|
+
- In CI, fail if any permission set defined by a .psbuild.json file needs to be regenerated, without writing anything:
|
|
118
100
|
|
|
119
|
-
<%= config.bin %> <%= command.id %> --
|
|
101
|
+
<%= config.bin %> <%= command.id %> --check
|
|
120
102
|
|
|
121
103
|
# error.missingRequiredFlags
|
|
122
104
|
|
|
123
|
-
Missing required flag(s): %s. Provide them, or
|
|
105
|
+
Missing required flag(s): %s. Provide them, or omit all of the single permission set flags to build every .psbuild.json file under the current directory.
|
|
106
|
+
|
|
107
|
+
# error.invalidBuildFile
|
|
108
|
+
|
|
109
|
+
Permission set build file %s: %s
|
|
110
|
+
|
|
111
|
+
# error.legacyFormat
|
|
112
|
+
|
|
113
|
+
%s uses the old format, a "permissionSets" list, which is no longer supported. Split it into one .psbuild.json file per permission set, with each permission set's settings at the top level.
|
|
114
|
+
|
|
115
|
+
# error.duplicateName
|
|
116
|
+
|
|
117
|
+
Permission set %s is defined by both %s and %s. Each permission set must be defined by exactly one .psbuild.json file.
|
|
124
118
|
|
|
125
119
|
# error.invalidConfig
|
|
126
120
|
|
|
@@ -154,6 +148,10 @@ Permission set successfully generated at %s
|
|
|
154
148
|
|
|
155
149
|
Successfully generated %s permission set(s).
|
|
156
150
|
|
|
151
|
+
# info.filesFound
|
|
152
|
+
|
|
153
|
+
Found %s permission set build file(s).
|
|
154
|
+
|
|
157
155
|
# info.checkingPermissionSet
|
|
158
156
|
|
|
159
157
|
Checking permission set %s...
|
|
@@ -166,6 +164,6 @@ All %s permission set(s) are up to date.
|
|
|
166
164
|
|
|
167
165
|
%s of %s permission set(s) have drifted from their source metadata or are missing. Run this command without --check to regenerate them.
|
|
168
166
|
|
|
169
|
-
# warning.
|
|
167
|
+
# warning.noFilesFound
|
|
170
168
|
|
|
171
|
-
|
|
169
|
+
No permission set build files (files ending in .psbuild.json) found under the current directory. Nothing to build.
|
package/oclif.manifest.json
CHANGED
|
@@ -90,12 +90,12 @@
|
|
|
90
90
|
"simply:permissions:build": {
|
|
91
91
|
"aliases": [],
|
|
92
92
|
"args": {},
|
|
93
|
-
"description": "Scans a Salesforce project directory for custom objects, fields, tabs, and (optionally) record types, then generates a permission set XML file with a baseline of permissions determined by --type. An optional JSON --config file can override individual object, field, tab, record type, and user permission settings, as well as whether the permission set requires activation.\n\nTo regenerate every permission set in a project with one command,
|
|
93
|
+
"description": "Scans a Salesforce project directory for custom objects, fields, tabs, and (optionally) record types, then generates a permission set XML file with a baseline of permissions determined by --type. An optional JSON --config file can override individual object, field, tab, record type, and user permission settings, as well as whether the permission set requires activation.\n\nTo regenerate every permission set in a project with one command, define each one in its own permission set build file: a JSON file whose name ends in .psbuild.json (for example config/app-admin.psbuild.json), with the same settings as one run of this command. \"name\", \"type\", \"directory\", and \"output\" are required; \"label\", \"description\", \"includeRecordTypes\", and \"config\" are optional. \"config\" is either a path to a --config file or the same overrides inline. Relative paths are resolved against the current directory, as they are for flags.\n\n {\n \"name\": \"App_Admin\",\n \"type\": \"modify-all\",\n \"label\": \"App Admin\",\n \"directory\": \"force-app\",\n \"output\": \"force-app/main/default/permissionsets\",\n \"includeRecordTypes\": true,\n \"config\": \"config/app-admin-overrides.json\"\n }\n\nThen run the command with none of the flags that describe a single permission set. It builds the permission set defined by every .psbuild.json file under the current directory, skipping node_modules, .git, .sf, and .sfdx. Every file, including referenced override files and source directories, is validated before anything is written, no two files can define the same permission set name, and each source directory is scanned only once. The results table shows which file defined each permission set. If no .psbuild.json files are found, the command prints a warning and exits successfully. `sf simply cicd build check-permission-sets` finds the same files.\n\nTo check in CI that the committed permission sets still match their source metadata, add --check. It builds each permission set as usual but writes nothing: it compares each one with the file already at its output path and reports it as \"up-to-date\", \"drifted\", or \"missing\". If any permission set has drifted or is missing, the command exits with code 1. Formatting differences, such as indentation, line endings, or comments, don't count as drift, so files reformatted by Prettier still pass. Any other difference does, including hand edits and reordered entries.",
|
|
94
94
|
"examples": [
|
|
95
95
|
"<%= config.bin %> <%= command.id %> --type read-only --name My_Read_Only_Access --directory force-app --output force-app/main/default/permissionsets",
|
|
96
96
|
"<%= config.bin %> <%= command.id %> --type modify-all --name My_Admin_Access --directory force-app --config config/permission-overrides.json --output force-app/main/default/permissionsets --include-record-types",
|
|
97
|
-
"Regenerate
|
|
98
|
-
"In CI, fail if any permission set
|
|
97
|
+
"Regenerate the permission set defined by every .psbuild.json file under the current directory:\n<%= config.bin %> <%= command.id %>",
|
|
98
|
+
"In CI, fail if any permission set defined by a .psbuild.json file needs to be regenerated, without writing anything:\n<%= config.bin %> <%= command.id %> --check"
|
|
99
99
|
],
|
|
100
100
|
"flags": {
|
|
101
101
|
"json": {
|
|
@@ -113,27 +113,8 @@
|
|
|
113
113
|
"multiple": false,
|
|
114
114
|
"type": "option"
|
|
115
115
|
},
|
|
116
|
-
"file": {
|
|
117
|
-
"char": "f",
|
|
118
|
-
"description": "The path to a JSON file with a \"permissionSets\" array, each entry describing one permission set to generate (\"name\", \"type\", and optionally \"label\", \"description\", \"directory\", \"output\", \"includeRecordTypes\", \"config\"), and an optional \"defaults\" object. Name it with the .psbuild.json suffix; any other name works but prints a warning. Can't be combined with the flags that describe a single permission set.",
|
|
119
|
-
"exclusive": [
|
|
120
|
-
"type",
|
|
121
|
-
"name",
|
|
122
|
-
"directory",
|
|
123
|
-
"output",
|
|
124
|
-
"config",
|
|
125
|
-
"include-record-types",
|
|
126
|
-
"label",
|
|
127
|
-
"description"
|
|
128
|
-
],
|
|
129
|
-
"name": "file",
|
|
130
|
-
"summary": "Path to a permission sets file declaring every permission set to generate",
|
|
131
|
-
"hasDynamicHelp": false,
|
|
132
|
-
"multiple": false,
|
|
133
|
-
"type": "option"
|
|
134
|
-
},
|
|
135
116
|
"type": {
|
|
136
|
-
"description": "The baseline permission level to generate: 'read-only' grants read access to all discovered objects and fields, 'view-all' additionally grants view-all-records, and 'modify-all' grants full CRUD and modify-all-records access. Required
|
|
117
|
+
"description": "The baseline permission level to generate: 'read-only' grants read access to all discovered objects and fields, 'view-all' additionally grants view-all-records, and 'modify-all' grants full CRUD and modify-all-records access. Required to build a single permission set.",
|
|
137
118
|
"name": "type",
|
|
138
119
|
"summary": "Baseline permission type",
|
|
139
120
|
"hasDynamicHelp": false,
|
|
@@ -147,7 +128,7 @@
|
|
|
147
128
|
},
|
|
148
129
|
"name": {
|
|
149
130
|
"char": "n",
|
|
150
|
-
"description": "The API name for the generated permission set; also used to derive the output filename. Required
|
|
131
|
+
"description": "The API name for the generated permission set; also used to derive the output filename. Required to build a single permission set.",
|
|
151
132
|
"name": "name",
|
|
152
133
|
"summary": "API name for the permission set",
|
|
153
134
|
"hasDynamicHelp": false,
|
|
@@ -156,7 +137,7 @@
|
|
|
156
137
|
},
|
|
157
138
|
"directory": {
|
|
158
139
|
"char": "d",
|
|
159
|
-
"description": "The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types. Required
|
|
140
|
+
"description": "The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types. Required to build a single permission set.",
|
|
160
141
|
"name": "directory",
|
|
161
142
|
"summary": "Path to the Salesforce project directory",
|
|
162
143
|
"hasDynamicHelp": false,
|
|
@@ -173,7 +154,7 @@
|
|
|
173
154
|
"type": "option"
|
|
174
155
|
},
|
|
175
156
|
"output": {
|
|
176
|
-
"description": "The directory to write the generated permission set XML file to. Required
|
|
157
|
+
"description": "The directory to write the generated permission set XML file to. Required to build a single permission set.",
|
|
177
158
|
"name": "output",
|
|
178
159
|
"summary": "Output directory",
|
|
179
160
|
"hasDynamicHelp": false,
|
|
@@ -202,7 +183,7 @@
|
|
|
202
183
|
"type": "option"
|
|
203
184
|
},
|
|
204
185
|
"check": {
|
|
205
|
-
"description": "Instead of writing each permission set, compare what would be generated with the file already at its output path. Exits with code 1 if any permission set has drifted or is missing. Works with
|
|
186
|
+
"description": "Instead of writing each permission set, compare what would be generated with the file already at its output path. Exits with code 1 if any permission set has drifted or is missing. Works with the single-permission-set flags, and without them, which checks the permission set defined by every .psbuild.json file under the current directory.",
|
|
206
187
|
"name": "check",
|
|
207
188
|
"summary": "Check that the generated permission sets are up to date, without writing them",
|
|
208
189
|
"allowNo": false,
|
|
@@ -348,5 +329,5 @@
|
|
|
348
329
|
]
|
|
349
330
|
}
|
|
350
331
|
},
|
|
351
|
-
"version": "
|
|
332
|
+
"version": "2.0.0"
|
|
352
333
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysf/simply-permissions",
|
|
3
3
|
"description": "Utilities for working with permissions",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"author": "@ClayChipps",
|
|
6
6
|
"homepage": "https://github.com/SimplySF/simply-plugins",
|
|
7
7
|
"bugs": "https://github.com/SimplySF/simply-plugins/issues",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@salesforce/sf-plugins-core": "^12.2.16",
|
|
63
63
|
"@salesforce/source-deploy-retrieve": "^12.37.2",
|
|
64
64
|
"@simplysf/simply-core": "^1.6.7",
|
|
65
|
-
"@simplysf/simply-permissions-core": "^0.
|
|
65
|
+
"@simplysf/simply-permissions-core": "^0.7.0",
|
|
66
66
|
"@simplysf/simply-plugin-kit": "^1.0.9",
|
|
67
67
|
"zod": "^4.6.5"
|
|
68
68
|
},
|
|
@@ -202,5 +202,5 @@
|
|
|
202
202
|
"output": []
|
|
203
203
|
}
|
|
204
204
|
},
|
|
205
|
-
"gitHead": "
|
|
205
|
+
"gitHead": "c6b42eec62005e590b6eb019df0d317c4e200e62"
|
|
206
206
|
}
|