@simplysf/simply-permissions 1.7.0 → 4.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 +36 -68
- package/lib/commands/simply/permissions/build.d.ts +15 -20
- package/lib/commands/simply/permissions/build.js +29 -48
- package/lib/commands/simply/permissions/build.js.map +1 -1
- package/messages/simply.permissions.build.md +25 -49
- package/oclif.manifest.json +5 -26
- package/package.json +4 -4
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@4.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@4.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,44 +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.
|
|
158
|
-
|
|
159
|
-
Run the command with neither --file nor any of the flags that describe a single permission set to build every
|
|
160
|
-
permission sets file under the current directory: every file whose name ends in .psbuild.json, skipping node_modules,
|
|
161
|
-
.git, .sf, and .sfdx. Every file is validated before anything is written, and the results table shows which file
|
|
162
|
-
declared each permission set. If no permission sets files are found, the command prints a warning and exits
|
|
163
|
-
successfully.
|
|
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.
|
|
164
153
|
|
|
165
|
-
{
|
|
166
|
-
"defaults": {
|
|
167
|
-
"directory": "force-app",
|
|
168
|
-
"output": "force-app/main/default/permissionsets"
|
|
169
|
-
},
|
|
170
|
-
"permissionSets": [
|
|
171
|
-
{ "name": "App_Read_Only", "type": "read-only" },
|
|
172
154
|
{
|
|
173
155
|
"name": "App_Admin",
|
|
174
156
|
"type": "modify-all",
|
|
175
157
|
"label": "App Admin",
|
|
158
|
+
"directory": "force-app",
|
|
159
|
+
"output": "force-app/main/default/permissionsets",
|
|
176
160
|
"includeRecordTypes": true,
|
|
177
161
|
"config": "config/app-admin-overrides.json"
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
"name": "App_Support",
|
|
181
|
-
"type": "view-all",
|
|
182
|
-
"config": { "userPermissions": { "ViewSetup": true } }
|
|
183
|
-
}
|
|
184
|
-
]
|
|
185
162
|
}
|
|
186
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
|
+
|
|
187
171
|
To check in CI that the committed permission sets still match their source metadata, add --check. It builds each
|
|
188
172
|
permission set as usual but writes nothing: it compares each one with the file already at its output path and reports
|
|
189
173
|
it as "up-to-date", "drifted", or "missing". If any permission set has drifted or is missing, the command exits with
|
|
@@ -195,19 +179,11 @@ EXAMPLES
|
|
|
195
179
|
|
|
196
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
|
|
197
181
|
|
|
198
|
-
Regenerate
|
|
199
|
-
|
|
200
|
-
$ sf simply permissions build --file config/app.psbuild.json
|
|
201
|
-
|
|
202
|
-
In CI, fail if any permission set declared in a permission sets file needs to be regenerated:
|
|
203
|
-
|
|
204
|
-
$ sf simply permissions build --file config/app.psbuild.json --check
|
|
205
|
-
|
|
206
|
-
Regenerate every permission set declared in any .psbuild.json file under the current directory:
|
|
182
|
+
Regenerate the permission set defined by every .psbuild.json file under the current directory:
|
|
207
183
|
|
|
208
184
|
$ sf simply permissions build
|
|
209
185
|
|
|
210
|
-
|
|
186
|
+
In CI, fail if any permission set defined by a .psbuild.json file needs to be regenerated, without writing anything:
|
|
211
187
|
|
|
212
188
|
$ sf simply permissions build --check
|
|
213
189
|
|
|
@@ -222,14 +198,6 @@ FLAG DESCRIPTIONS
|
|
|
222
198
|
The path to the Salesforce source directory to scan for custom objects, fields, tabs, and record types. Required to
|
|
223
199
|
build a single permission set.
|
|
224
200
|
|
|
225
|
-
-f, --file=<value> Path to a permission sets file declaring every permission set to generate
|
|
226
|
-
|
|
227
|
-
The path to a JSON file with a "permissionSets" array, each entry describing one permission set to generate ("name",
|
|
228
|
-
"type", and optionally "label", "description", "directory", "output", "includeRecordTypes", "config"), and an
|
|
229
|
-
optional "defaults" object. Name it with the .psbuild.json suffix; any other name works but prints a warning. Can't
|
|
230
|
-
be combined with the flags that describe a single permission set. If you omit --file and those flags, every
|
|
231
|
-
.psbuild.json file under the current directory is built.
|
|
232
|
-
|
|
233
201
|
-n, --name=<value> API name for the permission set
|
|
234
202
|
|
|
235
203
|
The API name for the generated permission set; also used to derive the output filename. Required to build a single
|
|
@@ -238,8 +206,8 @@ FLAG DESCRIPTIONS
|
|
|
238
206
|
--check Check that the generated permission sets are up to date, without writing them
|
|
239
207
|
|
|
240
208
|
Instead of writing each permission set, compare what would be generated with the file already at its output path.
|
|
241
|
-
Exits with code 1 if any permission set has drifted or is missing. Works with
|
|
242
|
-
|
|
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.
|
|
243
211
|
|
|
244
212
|
--include-record-types Include record type visibilities
|
|
245
213
|
|
|
@@ -256,7 +224,7 @@ FLAG DESCRIPTIONS
|
|
|
256
224
|
Required to build a single permission set.
|
|
257
225
|
```
|
|
258
226
|
|
|
259
|
-
_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@4.0.0/packages/simply-permissions/lib/commands/simply/permissions/build.js)_
|
|
260
228
|
<!-- commandsstop -->
|
|
261
229
|
|
|
262
230
|
## Configuration Files
|
|
@@ -267,14 +235,14 @@ The `--config` flag on `sf simply permissions build` takes the path to a JSON fi
|
|
|
267
235
|
|
|
268
236
|
```json
|
|
269
237
|
{
|
|
270
|
-
"
|
|
271
|
-
"Account": { "
|
|
238
|
+
"objectPermissions": {
|
|
239
|
+
"Account": { "allowRead": true, "allowCreate": true, "allowEdit": true, "viewAllRecords": true }
|
|
272
240
|
},
|
|
273
|
-
"
|
|
241
|
+
"fieldPermissions": {
|
|
274
242
|
"Account.AnnualRevenue": { "readable": true, "editable": false }
|
|
275
243
|
},
|
|
276
|
-
"
|
|
277
|
-
"Account": { "
|
|
244
|
+
"tabSettings": {
|
|
245
|
+
"Account": { "visibility": "Visible" }
|
|
278
246
|
},
|
|
279
247
|
"recordTypeVisibilities": {
|
|
280
248
|
"Account.Enterprise": { "visible": true }
|
|
@@ -286,14 +254,14 @@ The `--config` flag on `sf simply permissions build` takes the path to a JSON fi
|
|
|
286
254
|
}
|
|
287
255
|
```
|
|
288
256
|
|
|
289
|
-
| Field | Type | Keyed by | Description
|
|
290
|
-
| ------------------------ | -------------------------------------- | ---------------------------- |
|
|
291
|
-
| `
|
|
292
|
-
| `
|
|
293
|
-
| `
|
|
294
|
-
| `recordTypeVisibilities` | `Record<string, RecordTypeVisibility>` | `Object.RecordType` API name | Overrides record type visibility. Fields: `visible` (optional boolean). Only applied when `--include-record-types` is also passed.
|
|
295
|
-
| `userPermissions` | `Record<string, boolean>` | User permission API name | Enables (`true`) or disables (`false`) individual user permissions.
|
|
296
|
-
| `hasActivationRequired` | `boolean` | — | Whether the generated permission set requires activation before it grants access. Defaults to `false`.
|
|
257
|
+
| Field | Type | Keyed by | Description |
|
|
258
|
+
| ------------------------ | -------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
259
|
+
| `objectPermissions` | `Record<string, ObjectPerm>` | Object API name | Overrides object-level access. `ObjectPerm` fields: `allowRead`, `allowCreate`, `allowEdit`, `allowDelete`, `modifyAllRecords`, `viewAllRecords`, `viewAllFields` (all optional booleans). |
|
|
260
|
+
| `fieldPermissions` | `Record<string, FieldPerm>` | `Object.Field` API name | Overrides field-level access. `FieldPerm` fields: `readable`, `editable` (optional booleans). |
|
|
261
|
+
| `tabSettings` | `Record<string, TabSetting>` | Tab API name | Overrides tab visibility. `TabSetting` fields: `visibility`: `Visible`, `Available`, or `None` (optional). A tab only the config names defaults to `None`. |
|
|
262
|
+
| `recordTypeVisibilities` | `Record<string, RecordTypeVisibility>` | `Object.RecordType` API name | Overrides record type visibility. Fields: `visible` (optional boolean). Only applied when `--include-record-types` is also passed. |
|
|
263
|
+
| `userPermissions` | `Record<string, boolean>` | User permission API name | Enables (`true`) or disables (`false`) individual user permissions. |
|
|
264
|
+
| `hasActivationRequired` | `boolean` | — | Whether the generated permission set requires activation before it grants access. Defaults to `false`. |
|
|
297
265
|
|
|
298
266
|
## License
|
|
299
267
|
|
|
@@ -9,17 +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
|
-
/** With `--file`: one entry per permission set declared in the file, in file order. */
|
|
13
|
-
export type PermissionsBuildFileResult = PermissionsBuildEntry[];
|
|
14
12
|
/**
|
|
15
|
-
* With
|
|
16
|
-
*
|
|
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.
|
|
17
15
|
*/
|
|
18
16
|
export type PermissionsBuildDiscoverResult = Array<{
|
|
19
17
|
file: string;
|
|
20
18
|
} & PermissionsBuildEntry>;
|
|
21
|
-
/** `file` renamed to carry {@link PERMISSION_SETS_FILE_SUFFIX}: `.psbuild` before a `.json` extension, or the whole suffix appended. */
|
|
22
|
-
export declare function suffixedName(file: string): string;
|
|
23
19
|
/**
|
|
24
20
|
* Scans a Salesforce project directory for custom objects, fields, tabs, and (optionally)
|
|
25
21
|
* record types, then generates a permission set XML file with a baseline of permissions
|
|
@@ -27,20 +23,18 @@ export declare function suffixedName(file: string): string;
|
|
|
27
23
|
* field, tab, record type, and user permission settings, as well as whether the permission set
|
|
28
24
|
* requires activation.
|
|
29
25
|
*
|
|
30
|
-
* With
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* them before writing anything.
|
|
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.
|
|
34
29
|
*
|
|
35
30
|
* With `--check`, writes nothing: compares each permission set it would generate with the file
|
|
36
31
|
* already at its output path, and sets `process.exitCode = 1` if any has drifted or is missing.
|
|
37
32
|
*/
|
|
38
|
-
export default class PermissionsBuild extends SfCommand<PermissionsBuildResult |
|
|
33
|
+
export default class PermissionsBuild extends SfCommand<PermissionsBuildResult | PermissionsBuildDiscoverResult> {
|
|
39
34
|
static readonly summary: string;
|
|
40
35
|
static readonly description: string;
|
|
41
36
|
static readonly examples: string[];
|
|
42
37
|
static readonly flags: {
|
|
43
|
-
file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
44
38
|
type: import("@oclif/core/interfaces").OptionFlag<PermissionSetType | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
45
39
|
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
46
40
|
directory: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -53,23 +47,24 @@ export default class PermissionsBuild extends SfCommand<PermissionsBuildResult |
|
|
|
53
47
|
'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
54
48
|
};
|
|
55
49
|
/**
|
|
56
|
-
* @returns The output file path and object/field permission counts — or, with
|
|
57
|
-
*
|
|
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.
|
|
58
52
|
* With `--check`, each also has a `status`, and `process.exitCode` is set to 1 when any isn't `up-to-date`.
|
|
59
53
|
*/
|
|
60
|
-
run(): Promise<PermissionsBuildResult |
|
|
54
|
+
run(): Promise<PermissionsBuildResult | PermissionsBuildDiscoverResult>;
|
|
61
55
|
/** Resolves the single-permission-set flags into a spec, reporting every missing required flag at once. */
|
|
62
56
|
private singleSpec;
|
|
63
57
|
/**
|
|
64
|
-
* Builds (or, with `check`, checks)
|
|
65
|
-
* current directory. Every file is loaded and validated
|
|
66
|
-
*
|
|
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.
|
|
67
62
|
*/
|
|
68
63
|
private buildDiscovered;
|
|
69
|
-
/** @param sources - With discovery, the permission
|
|
64
|
+
/** @param sources - With discovery, the permission set build file each spec came from, shown as a FILE column. */
|
|
70
65
|
private generate;
|
|
71
66
|
private check;
|
|
72
|
-
/** Prints one row per result, with a leading FILE column when `sources` gives each result's permission
|
|
67
|
+
/** Prints one row per result, with a leading FILE column when `sources` gives each result's permission set build file. */
|
|
73
68
|
private printTable;
|
|
74
69
|
private readConfig;
|
|
75
70
|
private startSpinner;
|
|
@@ -15,19 +15,10 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { Messages } from '@salesforce/core';
|
|
17
17
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
-
import { checkPermissionSets,
|
|
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
|
-
/**
|
|
28
|
-
* The flags that describe a single permission set, and so can't be combined with `--file`. When
|
|
29
|
-
* neither `--file` nor any of these is given, every discovered permission sets file is built.
|
|
30
|
-
*/
|
|
21
|
+
/** The flags that describe a single permission set. When none is given, every discovered permission set build file is built. */
|
|
31
22
|
const SINGLE_PERMISSION_SET_FLAGS = [
|
|
32
23
|
'type',
|
|
33
24
|
'name',
|
|
@@ -55,16 +46,20 @@ function toCliError(error) {
|
|
|
55
46
|
return messages.createError('error.configNotFound', error.args);
|
|
56
47
|
case 'directory-not-found':
|
|
57
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);
|
|
58
53
|
}
|
|
59
54
|
}
|
|
60
|
-
/** Loads a discovered permission
|
|
55
|
+
/** Loads a discovered permission set build file, naming the file in any validation error. */
|
|
61
56
|
async function loadDiscoveredFile(file) {
|
|
62
57
|
try {
|
|
63
|
-
return await
|
|
58
|
+
return await loadPermissionSetBuildFile(file);
|
|
64
59
|
}
|
|
65
60
|
catch (error) {
|
|
66
61
|
if (error instanceof PermissionSetBuildError) {
|
|
67
|
-
throw messages.createError('error.
|
|
62
|
+
throw messages.createError('error.invalidBuildFile', [file, toCliError(error).message]);
|
|
68
63
|
}
|
|
69
64
|
throw error;
|
|
70
65
|
}
|
|
@@ -76,10 +71,9 @@ async function loadDiscoveredFile(file) {
|
|
|
76
71
|
* field, tab, record type, and user permission settings, as well as whether the permission set
|
|
77
72
|
* requires activation.
|
|
78
73
|
*
|
|
79
|
-
* With
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* them before writing anything.
|
|
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.
|
|
83
77
|
*
|
|
84
78
|
* With `--check`, writes nothing: compares each permission set it would generate with the file
|
|
85
79
|
* already at its output path, and sets `process.exitCode = 1` if any has drifted or is missing.
|
|
@@ -90,13 +84,6 @@ export default class PermissionsBuild extends SfCommand {
|
|
|
90
84
|
static examples = messages.getMessages('examples');
|
|
91
85
|
static flags = {
|
|
92
86
|
...SfCommand.baseFlags,
|
|
93
|
-
file: Flags.file({
|
|
94
|
-
summary: messages.getMessage('flags.file.summary'),
|
|
95
|
-
description: messages.getMessage('flags.file.description'),
|
|
96
|
-
char: 'f',
|
|
97
|
-
exists: true,
|
|
98
|
-
exclusive: SINGLE_PERMISSION_SET_FLAGS,
|
|
99
|
-
}),
|
|
100
87
|
type: Flags.custom({
|
|
101
88
|
options: ['read-only', 'view-all', 'modify-all'],
|
|
102
89
|
})({
|
|
@@ -142,25 +129,18 @@ export default class PermissionsBuild extends SfCommand {
|
|
|
142
129
|
}),
|
|
143
130
|
};
|
|
144
131
|
/**
|
|
145
|
-
* @returns The output file path and object/field permission counts — or, with
|
|
146
|
-
*
|
|
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.
|
|
147
134
|
* With `--check`, each also has a `status`, and `process.exitCode` is set to 1 when any isn't `up-to-date`.
|
|
148
135
|
*/
|
|
149
136
|
async run() {
|
|
150
137
|
const { flags } = await this.parse(PermissionsBuild);
|
|
151
138
|
try {
|
|
152
|
-
|
|
153
|
-
if (!file && !SINGLE_PERMISSION_SET_FLAGS.some((flag) => flags[flag])) {
|
|
139
|
+
if (!SINGLE_PERMISSION_SET_FLAGS.some((flag) => flags[flag])) {
|
|
154
140
|
return await this.buildDiscovered(flags.check);
|
|
155
141
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
const specs = file ? await this.readConfig(() => loadPermissionSetsFile(file)) : await this.singleSpec(flags);
|
|
160
|
-
const results = flags.check ? await this.check(specs) : await this.generate(specs, Boolean(file));
|
|
161
|
-
if (file) {
|
|
162
|
-
return results;
|
|
163
|
-
}
|
|
142
|
+
const specs = await this.singleSpec(flags);
|
|
143
|
+
const results = flags.check ? await this.check(specs) : await this.generate(specs, false);
|
|
164
144
|
// Single-set mode has never included `name` in its result.
|
|
165
145
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
166
146
|
const { name, ...result } = results[0];
|
|
@@ -193,31 +173,32 @@ export default class PermissionsBuild extends SfCommand {
|
|
|
193
173
|
];
|
|
194
174
|
}
|
|
195
175
|
/**
|
|
196
|
-
* Builds (or, with `check`, checks)
|
|
197
|
-
* current directory. Every file is loaded and validated
|
|
198
|
-
*
|
|
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.
|
|
199
180
|
*/
|
|
200
181
|
async buildDiscovered(check) {
|
|
201
|
-
const files = await
|
|
182
|
+
const files = await findPermissionSetBuildFiles();
|
|
202
183
|
if (files.length === 0) {
|
|
203
184
|
this.warn(messages.getMessage('warning.noFilesFound'));
|
|
204
185
|
return [];
|
|
205
186
|
}
|
|
206
187
|
this.info(messages.getMessage('info.filesFound', [files.length]));
|
|
207
|
-
const
|
|
208
|
-
const sources = [];
|
|
188
|
+
const entries = [];
|
|
209
189
|
await this.readConfig(async () => {
|
|
210
190
|
for (const file of files) {
|
|
211
191
|
// eslint-disable-next-line no-await-in-loop -- files are loaded in order so the first invalid one is the one reported
|
|
212
|
-
|
|
213
|
-
specs.push(...loaded);
|
|
214
|
-
sources.push(...loaded.map(() => file));
|
|
192
|
+
entries.push({ file, spec: await loadDiscoveredFile(file) });
|
|
215
193
|
}
|
|
216
194
|
});
|
|
195
|
+
assertUniquePermissionSetNames(entries);
|
|
196
|
+
const specs = entries.map(({ spec }) => spec);
|
|
197
|
+
const sources = entries.map(({ file }) => file);
|
|
217
198
|
const results = check ? await this.check(specs, sources) : await this.generate(specs, true, sources);
|
|
218
199
|
return results.map((result, i) => ({ file: sources[i], ...result }));
|
|
219
200
|
}
|
|
220
|
-
/** @param sources - With discovery, the permission
|
|
201
|
+
/** @param sources - With discovery, the permission set build file each spec came from, shown as a FILE column. */
|
|
221
202
|
async generate(specs, asTable, sources) {
|
|
222
203
|
const results = await generatePermissionSets(specs, (name) => this.startSpinner('info.buildingPermissionSet', name));
|
|
223
204
|
this.spinner.stop();
|
|
@@ -244,7 +225,7 @@ export default class PermissionsBuild extends SfCommand {
|
|
|
244
225
|
}
|
|
245
226
|
return results;
|
|
246
227
|
}
|
|
247
|
-
/** Prints one row per result, with a leading FILE column when `sources` gives each result's permission
|
|
228
|
+
/** Prints one row per result, with a leading FILE column when `sources` gives each result's permission set build file. */
|
|
248
229
|
printTable(results, sources, extraColumns = []) {
|
|
249
230
|
const fileColumn = sources ? [{ key: 'file', name: 'FILE' }] : [];
|
|
250
231
|
this.table({
|
|
@@ -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,
|
|
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,8BAA8B,EAC9B,mBAAmB,EACnB,2BAA2B,EAC3B,sBAAsB,EACtB,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,GAKxB,MAAM,mCAAmC,CAAC;AAE3C,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,8BAA8B,EAAE,0BAA0B,CAAC,CAAC;AAenG,gIAAgI;AAChI,MAAM,2BAA2B,GAAG;IAClC,MAAM;IACN,MAAM;IACN,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,sBAAsB;IACtB,OAAO;IACP,aAAa;CACd,CAAC;AAEF,MAAM,aAAa,GAA+E;IAChG,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAC7B,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAC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,YAAY,CAAC;SAC5D,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,UAAU,CAAI,IAAsB;QAChD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,MAAM,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACpB,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,YAAY,CAAC,GAAW,EAAE,IAAY;QAC5C,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACpB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC"}
|
|
@@ -6,41 +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,
|
|
10
|
-
|
|
11
|
-
Run the command with neither --file nor any of the flags that describe a single permission set to build every permission sets file under the current directory: every file whose name ends in .psbuild.json, skipping node_modules, .git, .sf, and .sfdx. Every file is validated before anything is written, and the results table shows which file declared each permission set. If no permission sets files are found, the command prints a warning and exits successfully.
|
|
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.
|
|
12
10
|
|
|
13
11
|
{
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"name": "App_Admin",
|
|
22
|
-
"type": "modify-all",
|
|
23
|
-
"label": "App Admin",
|
|
24
|
-
"includeRecordTypes": true,
|
|
25
|
-
"config": "config/app-admin-overrides.json"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"name": "App_Support",
|
|
29
|
-
"type": "view-all",
|
|
30
|
-
"config": { "userPermissions": { "ViewSetup": true } }
|
|
31
|
-
}
|
|
32
|
-
]
|
|
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"
|
|
33
19
|
}
|
|
34
20
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
# flags.file.summary
|
|
38
|
-
|
|
39
|
-
Path to a permission sets file declaring every permission set to generate
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
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. If you omit --file and those flags, every .psbuild.json file under the current directory is built.
|
|
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.
|
|
44
24
|
|
|
45
25
|
# flags.type.summary
|
|
46
26
|
|
|
@@ -104,7 +84,7 @@ Check that the generated permission sets are up to date, without writing them
|
|
|
104
84
|
|
|
105
85
|
# flags.check.description
|
|
106
86
|
|
|
107
|
-
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.
|
|
108
88
|
|
|
109
89
|
# examples
|
|
110
90
|
|
|
@@ -112,29 +92,29 @@ Instead of writing each permission set, compare what would be generated with the
|
|
|
112
92
|
|
|
113
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
|
|
114
94
|
|
|
115
|
-
- Regenerate
|
|
95
|
+
- Regenerate the permission set defined by every .psbuild.json file under the current directory:
|
|
116
96
|
|
|
117
|
-
<%= config.bin %> <%= command.id %>
|
|
97
|
+
<%= config.bin %> <%= command.id %>
|
|
118
98
|
|
|
119
|
-
- 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:
|
|
120
100
|
|
|
121
|
-
<%= config.bin %> <%= command.id %> --
|
|
101
|
+
<%= config.bin %> <%= command.id %> --check
|
|
122
102
|
|
|
123
|
-
|
|
103
|
+
# error.missingRequiredFlags
|
|
124
104
|
|
|
125
|
-
|
|
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.
|
|
126
106
|
|
|
127
|
-
|
|
107
|
+
# error.invalidBuildFile
|
|
128
108
|
|
|
129
|
-
|
|
109
|
+
Permission set build file %s: %s
|
|
130
110
|
|
|
131
|
-
# error.
|
|
111
|
+
# error.legacyFormat
|
|
132
112
|
|
|
133
|
-
|
|
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.
|
|
134
114
|
|
|
135
|
-
# error.
|
|
115
|
+
# error.duplicateName
|
|
136
116
|
|
|
137
|
-
Permission
|
|
117
|
+
Permission set %s is defined by both %s and %s. Each permission set must be defined by exactly one .psbuild.json file.
|
|
138
118
|
|
|
139
119
|
# error.invalidConfig
|
|
140
120
|
|
|
@@ -170,7 +150,7 @@ Successfully generated %s permission set(s).
|
|
|
170
150
|
|
|
171
151
|
# info.filesFound
|
|
172
152
|
|
|
173
|
-
Found %s permission
|
|
153
|
+
Found %s permission set build file(s).
|
|
174
154
|
|
|
175
155
|
# info.checkingPermissionSet
|
|
176
156
|
|
|
@@ -186,8 +166,4 @@ All %s permission set(s) are up to date.
|
|
|
186
166
|
|
|
187
167
|
# warning.noFilesFound
|
|
188
168
|
|
|
189
|
-
No permission
|
|
190
|
-
|
|
191
|
-
# warning.unsuffixedFile
|
|
192
|
-
|
|
193
|
-
%s doesn't end in .psbuild.json, so `sf simply cicd build check-permission-sets` won't find it. Rename it to %s.
|
|
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,14 +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
|
|
99
|
-
"Regenerate every permission set declared in any .psbuild.json file under the current directory:\n<%= config.bin %> <%= command.id %>",
|
|
100
|
-
"Check every permission set declared in any .psbuild.json file under the current directory, without writing anything:\n<%= config.bin %> <%= command.id %> --check"
|
|
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"
|
|
101
99
|
],
|
|
102
100
|
"flags": {
|
|
103
101
|
"json": {
|
|
@@ -115,25 +113,6 @@
|
|
|
115
113
|
"multiple": false,
|
|
116
114
|
"type": "option"
|
|
117
115
|
},
|
|
118
|
-
"file": {
|
|
119
|
-
"char": "f",
|
|
120
|
-
"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. If you omit --file and those flags, every .psbuild.json file under the current directory is built.",
|
|
121
|
-
"exclusive": [
|
|
122
|
-
"type",
|
|
123
|
-
"name",
|
|
124
|
-
"directory",
|
|
125
|
-
"output",
|
|
126
|
-
"config",
|
|
127
|
-
"include-record-types",
|
|
128
|
-
"label",
|
|
129
|
-
"description"
|
|
130
|
-
],
|
|
131
|
-
"name": "file",
|
|
132
|
-
"summary": "Path to a permission sets file declaring every permission set to generate",
|
|
133
|
-
"hasDynamicHelp": false,
|
|
134
|
-
"multiple": false,
|
|
135
|
-
"type": "option"
|
|
136
|
-
},
|
|
137
116
|
"type": {
|
|
138
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.",
|
|
139
118
|
"name": "type",
|
|
@@ -204,7 +183,7 @@
|
|
|
204
183
|
"type": "option"
|
|
205
184
|
},
|
|
206
185
|
"check": {
|
|
207
|
-
"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.",
|
|
208
187
|
"name": "check",
|
|
209
188
|
"summary": "Check that the generated permission sets are up to date, without writing them",
|
|
210
189
|
"allowNo": false,
|
|
@@ -350,5 +329,5 @@
|
|
|
350
329
|
]
|
|
351
330
|
}
|
|
352
331
|
},
|
|
353
|
-
"version": "
|
|
332
|
+
"version": "4.0.0"
|
|
354
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": "4.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",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"@salesforce/kit": "^3.2.6",
|
|
62
62
|
"@salesforce/sf-plugins-core": "^12.2.16",
|
|
63
63
|
"@salesforce/source-deploy-retrieve": "^12.37.2",
|
|
64
|
-
"@simplysf/simply-core": "^1.6.
|
|
65
|
-
"@simplysf/simply-permissions-core": "^0.
|
|
64
|
+
"@simplysf/simply-core": "^1.6.11",
|
|
65
|
+
"@simplysf/simply-permissions-core": "^0.10.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": "b8c437281cdbf26710c7f7be2849de72910d6f7f"
|
|
206
206
|
}
|