@salesforce/plugin-license-management 1.1.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/LICENSE.txt ADDED
@@ -0,0 +1,206 @@
1
+ Apache License Version 2.0
2
+
3
+ Copyright (c) 2026 Salesforce, Inc.
4
+ All rights reserved.
5
+
6
+ Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship, whether in Source or
41
+ Object form, made available under the License, as indicated by a
42
+ copyright notice that is included in or attached to the work
43
+ (an example is provided in the Appendix below).
44
+
45
+ "Derivative Works" shall mean any work, whether in Source or Object
46
+ form, that is based on (or derived from) the Work and for which the
47
+ editorial revisions, annotations, elaborations, or other modifications
48
+ represent, as a whole, an original work of authorship. For the purposes
49
+ of this License, Derivative Works shall not include works that remain
50
+ separable from, or merely link (or bind by name) to the interfaces of,
51
+ the Work and Derivative Works thereof.
52
+
53
+ "Contribution" shall mean any work of authorship, including
54
+ the original version of the Work and any modifications or additions
55
+ to that Work or Derivative Works thereof, that is intentionally
56
+ submitted to Licensor for inclusion in the Work by the copyright owner
57
+ or by an individual or Legal Entity authorized to submit on behalf of
58
+ the copyright owner. For the purposes of this definition, "submitted"
59
+ means any form of electronic, verbal, or written communication sent
60
+ to the Licensor or its representatives, including but not limited to
61
+ communication on electronic mailing lists, source code control systems,
62
+ and issue tracking systems that are managed by, or on behalf of, the
63
+ Licensor for the purpose of discussing and improving the Work, but
64
+ excluding communication that is conspicuously marked or otherwise
65
+ designated in writing by the copyright owner as "Not a Contribution."
66
+
67
+ "Contributor" shall mean Licensor and any individual or Legal Entity
68
+ on behalf of whom a Contribution has been received by Licensor and
69
+ subsequently incorporated within the Work.
70
+
71
+ 2. Grant of Copyright License. Subject to the terms and conditions of
72
+ this License, each Contributor hereby grants to You a perpetual,
73
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
74
+ copyright license to reproduce, prepare Derivative Works of,
75
+ publicly display, publicly perform, sublicense, and distribute the
76
+ Work and such Derivative Works in Source or Object form.
77
+
78
+ 3. Grant of Patent License. Subject to the terms and conditions of
79
+ this License, each Contributor hereby grants to You a perpetual,
80
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
81
+ (except as stated in this section) patent license to make, have made,
82
+ use, offer to sell, sell, import, and otherwise transfer the Work,
83
+ where such license applies only to those patent claims licensable
84
+ by such Contributor that are necessarily infringed by their
85
+ Contribution(s) alone or by combination of their Contribution(s)
86
+ with the Work to which such Contribution(s) was submitted. If You
87
+ institute patent litigation against any entity (including a
88
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
89
+ or a Contribution incorporated within the Work constitutes direct
90
+ or contributory patent infringement, then any patent licenses
91
+ granted to You under this License for that Work shall terminate
92
+ as of the date such litigation is filed.
93
+
94
+ 4. Redistribution. You may reproduce and distribute copies of the
95
+ Work or Derivative Works thereof in any medium, with or without
96
+ modifications, and in Source or Object form, provided that You
97
+ meet the following conditions:
98
+
99
+ (a) You must give any other recipients of the Work or
100
+ Derivative Works a copy of this License; and
101
+
102
+ (b) You must cause any modified files to carry prominent notices
103
+ stating that You changed the files; and
104
+
105
+ (c) You must retain, in the Source form of any Derivative Works
106
+ that You distribute, all copyright, patent, trademark, and
107
+ attribution notices from the Source form of the Work,
108
+ excluding those notices that do not pertain to any part of
109
+ the Derivative Works; and
110
+
111
+ (d) If the Work includes a "NOTICE" text file as part of its
112
+ distribution, then any Derivative Works that You distribute must
113
+ include a readable copy of the attribution notices contained
114
+ within such NOTICE file, excluding those notices that do not
115
+ pertain to any part of the Derivative Works, in at least one
116
+ of the following places: within a NOTICE text file distributed
117
+ as part of the Derivative Works; within the Source form or
118
+ documentation, if provided along with the Derivative Works; or,
119
+ within a display generated by the Derivative Works, if and
120
+ wherever such third-party notices normally appear. The contents
121
+ of the NOTICE file are for informational purposes only and
122
+ do not modify the License. You may add Your own attribution
123
+ notices within Derivative Works that You distribute, alongside
124
+ or as an addendum to the NOTICE text from the Work, provided
125
+ that such additional attribution notices cannot be construed
126
+ as modifying the License.
127
+
128
+ You may add Your own copyright statement to Your modifications and
129
+ may provide additional or different license terms and conditions
130
+ for use, reproduction, or distribution of Your modifications, or
131
+ for any such Derivative Works as a whole, provided Your use,
132
+ reproduction, and distribution of the Work otherwise complies with
133
+ the conditions stated in this License.
134
+
135
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
136
+ any Contribution intentionally submitted for inclusion in the Work
137
+ by You to the Licensor shall be under the terms and conditions of
138
+ this License, without any additional terms or conditions.
139
+ Notwithstanding the above, nothing herein shall supersede or modify
140
+ the terms of any separate license agreement you may have executed
141
+ with Licensor regarding such Contributions.
142
+
143
+ 6. Trademarks. This License does not grant permission to use the trade
144
+ names, trademarks, service marks, or product names of the Licensor,
145
+ except as required for reasonable and customary use in describing the
146
+ origin of the Work and reproducing the content of the NOTICE file.
147
+
148
+ 7. Disclaimer of Warranty. Unless required by applicable law or
149
+ agreed to in writing, Licensor provides the Work (and each
150
+ Contributor provides its Contributions) on an "AS IS" BASIS,
151
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152
+ implied, including, without limitation, any warranties or conditions
153
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
154
+ PARTICULAR PURPOSE. You are solely responsible for determining the
155
+ appropriateness of using or redistributing the Work and assume any
156
+ risks associated with Your exercise of permissions under this License.
157
+
158
+ 8. Limitation of Liability. In no event and under no legal theory,
159
+ whether in tort (including negligence), contract, or otherwise,
160
+ unless required by applicable law (such as deliberate and grossly
161
+ negligent acts) or agreed to in writing, shall any Contributor be
162
+ liable to You for damages, including any direct, indirect, special,
163
+ incidental, or consequential damages of any character arising as a
164
+ result of this License or out of the use or inability to use the
165
+ Work (including but not limited to damages for loss of goodwill,
166
+ work stoppage, computer failure or malfunction, or any and all
167
+ other commercial damages or losses), even if such Contributor
168
+ has been advised of the possibility of such damages.
169
+
170
+ 9. Accepting Warranty or Additional Liability. While redistributing
171
+ the Work or Derivative Works thereof, You may choose to offer,
172
+ and charge a fee for, acceptance of support, warranty, indemnity,
173
+ or other liability obligations and/or rights consistent with this
174
+ License. However, in accepting such obligations, You may act only
175
+ on Your own behalf and on Your sole responsibility, not on behalf
176
+ of any other Contributor, and only if You agree to indemnify,
177
+ defend, and hold each Contributor harmless for any liability
178
+ incurred by, or claims asserted against, such Contributor by reason
179
+ of your accepting any such warranty or additional liability.
180
+
181
+ END OF TERMS AND CONDITIONS
182
+
183
+ APPENDIX: How to apply the Apache License to your work.
184
+
185
+ To apply the Apache License to your work, attach the following
186
+ boilerplate notice, with the fields enclosed by brackets "{}"
187
+ replaced with your own identifying information. (Don't include
188
+ the brackets!) The text should be enclosed in the appropriate
189
+ comment syntax for the file format. We also recommend that a
190
+ file or class name and description of purpose be included on the
191
+ same "printed page" as the copyright notice for easier
192
+ identification within third-party archives.
193
+
194
+ Copyright {yyyy} {name of copyright owner}
195
+
196
+ Licensed under the Apache License, Version 2.0 (the "License");
197
+ you may not use this file except in compliance with the License.
198
+ You may obtain a copy of the License at
199
+
200
+ http://www.apache.org/licenses/LICENSE-2.0
201
+
202
+ Unless required by applicable law or agreed to in writing, software
203
+ distributed under the License is distributed on an "AS IS" BASIS,
204
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
205
+ See the License for the specific language governing permissions and
206
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # License Management Plugin
2
+
3
+ [![NPM](https://img.shields.io/npm/v/@salesforce/plugin-license-management.svg?label=@salesforce/plugin-license-management)](https://www.npmjs.com/package/@salesforce/plugin-license-management) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-license-management.svg)](https://npmjs.org/package/@salesforce/plugin-license-management) [![License](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/license/apache-2-0)
4
+
5
+ Manage Permission Set Licenses (PSLs) in your scratch orgs. This plugin lets you provision PSL seats into a target scratch org — either one at a time via command line flags, or in bulk using a JSON definition file.
6
+
7
+ ## Before You Begin
8
+
9
+ - Install and authenticate the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli).
10
+ - Ensure you have the appropriate permissions to manage Permission Set Licenses in the target org.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ sf plugins install @salesforce/plugin-license-management@x.y.z
16
+ ```
17
+
18
+ ## Issues
19
+
20
+ Please report any issues at https://github.com/forcedotcom/cli/issues
21
+
22
+ ## Contributing
23
+
24
+ 1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
25
+ 2. Create a new issue before starting your project so that we can keep track of
26
+ what you are trying to add/fix. That way, we can also offer suggestions or
27
+ let you know if there is already an effort in progress.
28
+ 3. Fork this repository.
29
+ 4. [Build the plugin locally](#build)
30
+ 5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
31
+ 6. Edit the code in your fork.
32
+ 7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
33
+ 8. Sign CLA (see [CLA](#cla) below).
34
+ 9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
35
+
36
+ ### CLA
37
+
38
+ External contributors will be required to sign a Contributor's License
39
+ Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
40
+
41
+ ### Build
42
+
43
+ To build the plugin locally, make sure to have yarn installed and run the following commands:
44
+
45
+ ```bash
46
+ # Clone the repository
47
+ git clone git@github.com:salesforcecli/plugin-license-management
48
+
49
+ # Install the dependencies and compile
50
+ yarn && yarn build
51
+ ```
52
+
53
+ To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.
54
+
55
+ ```bash
56
+ # Run using local run file.
57
+ ./bin/dev license provision
58
+ ```
59
+
60
+ There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
61
+
62
+ ```bash
63
+ # Link your plugin to the sf cli
64
+ sf plugins link .
65
+ # To verify
66
+ sf plugins
67
+ ```
68
+
69
+ ## Commands
70
+
71
+ <!-- commands -->
72
+
73
+ - [`sf license provision`](#sf-license-provision)
74
+
75
+ ## `sf license provision`
76
+
77
+ Provision Permission Set Licenses (PSL) into a target org.
78
+
79
+ ```
80
+ USAGE
81
+ $ sf license provision -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-n <value> | -f <value>]
82
+ [-l <value> | ] [-q <value> | ]
83
+
84
+ FLAGS
85
+ -f, --definition-file=<value> Path to a JSON file that contains the PSL provisioning request information.
86
+ -l, --license=<value> Permission Set License name.
87
+ -n, --namespace=<value> License package namespace.
88
+ -o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
89
+ configuration variable is already set.
90
+ -q, --quantity=<value> Number of licenses to provision.
91
+ --api-version=<value> Override the api version used for api requests made by this command
92
+
93
+ GLOBAL FLAGS
94
+ --flags-dir=<value> Import flag values from a directory.
95
+ --json Format output as json.
96
+
97
+ DESCRIPTION
98
+ Provision Permission Set Licenses (PSL) into a target org.
99
+
100
+ Provision Permission Set Licenses (PSL) into the target org. Successful execution sets the quantity of seats for the
101
+ given PSL in the indicated org.
102
+
103
+ There are two ways to run this command. You can provide the information to identify a single PSL via command line
104
+ flags, or provision multiple PSLs in a single call by supplying a JSON formatted file.
105
+
106
+ See https://github.com/salesforcecli/plugin-license-management#sf-license-provision for the format and options
107
+ contained within the JSON file.
108
+
109
+ EXAMPLES
110
+ Provision a single Permission Set License into an org:
111
+
112
+ $ sf license provision --target-org myScratchOrg --namespace demo --license newLicense --quantity 5
113
+
114
+ Use a JSON formatted input file to provision one or more Permission Set Licenses into an org:
115
+
116
+ $ sf license provision --target-org myScratchOrg --definition-file test/config/provisionPSLs.json
117
+ ```
118
+
119
+ _See code: [src/commands/license/provision.ts](https://github.com/salesforcecli/plugin-license-management/blob/0.1.0/src/commands/license/provision.ts)_
120
+
121
+ <!-- commandsstop -->
122
+
123
+ # Local Testing
124
+
125
+ ### 1. Log in to your Dev Hub
126
+
127
+ ```bash
128
+ sf org login web --set-default-dev-hub --instance-url <dev-hub-url>
129
+ ```
130
+
131
+ ### 2. Create a scratch org
132
+
133
+ Before creating the scratch org, update `test/config/scratch-org-def.json` with your values:
134
+
135
+ | Field | Description |
136
+ | ----------- | ------------------------------------ |
137
+ | `orgName` | Display name for the scratch org |
138
+ | `namespace` | Your package namespace (e.g. `myNS`) |
139
+
140
+ ```bash
141
+ sf org create scratch --definition-file test/config/scratch-org-def.json --alias <scratch-org-alias>
142
+ ```
143
+
144
+ ### 3. Install the package into the scratch org
145
+
146
+ Make the package available in the scratch org. Some ways to do this include:
147
+
148
+ **Install a released package version**
149
+
150
+ ```bash
151
+ sf package install --package <package-version-id> --target-org <scratch-org-alias>
152
+ ```
153
+
154
+ **Push source directly**
155
+
156
+ ```bash
157
+ sf project deploy start --target-org <scratch-org-alias>
158
+ ```
159
+
160
+ ### 4. Open the scratch org (optional)
161
+
162
+ ```bash
163
+ sf org open --target-org <scratch-org-alias>
164
+ ```
165
+
166
+ ### 5. Provision licenses
167
+
168
+ ```bash
169
+ # Provision a single PSL
170
+ sf license provision --target-org <scratch-org-alias> --namespace <namespace> --license <license-name> --quantity <number>
171
+
172
+ # Provision multiple PSLs using a definition file
173
+ sf license provision --target-org <scratch-org-alias> --definition-file <path-to-definition-file>
174
+ ```
@@ -0,0 +1,28 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ type ProvisionLicenseSpec = {
3
+ namespace?: string;
4
+ license?: string;
5
+ quantity?: number;
6
+ };
7
+ export type LicenseProvisionResult = {
8
+ status: string;
9
+ traceId?: string;
10
+ };
11
+ export default class LicenseProvision extends SfCommand<LicenseProvisionResult> {
12
+ static readonly summary: string;
13
+ static readonly description: string;
14
+ static readonly examples: string[];
15
+ static readonly flags: {
16
+ 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ namespace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ license: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ quantity: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
21
+ 'definition-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ };
23
+ protected static loadSpecsFromFile(filePath: string): Promise<ProvisionLicenseSpec[]>;
24
+ private static buildSpecsFromFlags;
25
+ run(): Promise<LicenseProvisionResult>;
26
+ private display;
27
+ }
28
+ export {};
@@ -0,0 +1,151 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { readFile } from 'node:fs/promises';
17
+ import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
18
+ import { Messages, SfError } from '@salesforce/core';
19
+ Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
20
+ const messages = Messages.loadMessages('@salesforce/plugin-license-management', 'license.provision');
21
+ function getLicenseDefinitionName(spec) {
22
+ const psl = spec.license ?? '';
23
+ return spec.namespace ? `${spec.namespace}__${psl}` : psl;
24
+ }
25
+ function toApiSpec(spec) {
26
+ return {
27
+ namespace: spec.namespace,
28
+ permissionSetLicense: spec.license,
29
+ quantity: spec.quantity,
30
+ };
31
+ }
32
+ export default class LicenseProvision extends SfCommand {
33
+ static summary = messages.getMessage('summary');
34
+ static description = messages.getMessage('description');
35
+ static examples = messages.getMessages('examples');
36
+ static flags = {
37
+ 'target-org': Flags.requiredOrg(),
38
+ 'api-version': Flags.orgApiVersion(),
39
+ namespace: Flags.string({
40
+ char: 'n',
41
+ summary: messages.getMessage('flags.namespace.summary'),
42
+ exclusive: ['definition-file'],
43
+ relationships: [{ type: 'all', flags: ['license', 'quantity'] }],
44
+ }),
45
+ license: Flags.string({
46
+ char: 'l',
47
+ summary: messages.getMessage('flags.license.summary'),
48
+ exclusive: ['definition-file'],
49
+ relationships: [{ type: 'all', flags: ['namespace', 'quantity'] }],
50
+ }),
51
+ quantity: Flags.integer({
52
+ char: 'q',
53
+ summary: messages.getMessage('flags.quantity.summary'),
54
+ min: 0,
55
+ max: Number.MAX_SAFE_INTEGER,
56
+ exclusive: ['definition-file'],
57
+ relationships: [{ type: 'all', flags: ['namespace', 'license'] }],
58
+ }),
59
+ 'definition-file': Flags.file({
60
+ char: 'f',
61
+ summary: messages.getMessage('flags.definition-file.summary'),
62
+ exclusive: ['license', 'namespace', 'quantity'],
63
+ exists: true,
64
+ }),
65
+ };
66
+ // Protected to allow stubbing in tests
67
+ static async loadSpecsFromFile(filePath) {
68
+ const fileContent = await readFile(filePath, 'utf-8');
69
+ let definition;
70
+ try {
71
+ definition = JSON.parse(fileContent);
72
+ }
73
+ catch (e) {
74
+ throw messages.createError('error.invalidDefinitionFileJson', [e.message]);
75
+ }
76
+ if (!Array.isArray(definition.licenses) || definition.licenses.length === 0) {
77
+ throw messages.createError('error.emptyDefinitionFile');
78
+ }
79
+ const allowedFields = new Set(['namespace', 'license', 'quantity']);
80
+ const unknownFields = [
81
+ ...new Set(definition.licenses.flatMap((entry) => Object.keys(entry).filter((key) => !allowedFields.has(key)))),
82
+ ];
83
+ if (unknownFields.length > 0) {
84
+ throw messages.createError('error.unsupportedDefinitionFileFields', [unknownFields.join(', ')]);
85
+ }
86
+ const requiredFields = ['namespace', 'license', 'quantity'];
87
+ const missingFields = definition.licenses.flatMap((entry, index) => requiredFields
88
+ .filter((field) => entry[field] === undefined || entry[field] === null)
89
+ .map((field) => `licenses[${index}].${field}`));
90
+ if (missingFields.length > 0) {
91
+ throw messages.createError('error.missingRequiredDefinitionFileFields', [missingFields.join(', ')]);
92
+ }
93
+ return definition.licenses;
94
+ }
95
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
96
+ static buildSpecsFromFlags(flags) {
97
+ if (!flags['license']) {
98
+ throw messages.createError('error.missingLicenseFlag');
99
+ }
100
+ return [
101
+ {
102
+ namespace: flags['namespace'],
103
+ license: flags['license'],
104
+ quantity: flags['quantity'],
105
+ },
106
+ ];
107
+ }
108
+ async run() {
109
+ const { flags } = await this.parse(LicenseProvision);
110
+ const connection = flags['target-org'].getConnection(flags['api-version']);
111
+ const licenseSpecs = flags['definition-file']
112
+ ? await LicenseProvision.loadSpecsFromFile(flags['definition-file'])
113
+ : LicenseProvision.buildSpecsFromFlags(flags);
114
+ const endpoint = `/services/data/v${connection.getApiVersion()}/partnerdevelopment/permissionsetlicenses`;
115
+ const requestBody = { licenses: licenseSpecs.map(toApiSpec) };
116
+ let response;
117
+ try {
118
+ response = await connection.request({
119
+ method: 'POST',
120
+ url: endpoint,
121
+ body: JSON.stringify(requestBody),
122
+ headers: { 'Content-Type': 'application/json' },
123
+ });
124
+ }
125
+ catch (error) {
126
+ throw SfError.wrap(error instanceof Error ? error : new Error(String(error)));
127
+ }
128
+ if (response.status !== 'SUCCESS') {
129
+ throw SfError.create({
130
+ message: messages.getMessage('error.provisionFailed', [response.message ?? 'Unknown error']),
131
+ name: 'PROVISION_FAILED',
132
+ data: { traceId: response.traceId },
133
+ });
134
+ }
135
+ this.display(licenseSpecs, response);
136
+ return { status: 'success', traceId: response.traceId };
137
+ }
138
+ display(licenseSpecs, response) {
139
+ this.table({
140
+ data: licenseSpecs.map((spec) => ({
141
+ [messages.getMessage('success.column.licenseDefinition')]: getLicenseDefinitionName(spec),
142
+ [messages.getMessage('success.column.provisionedQuantity')]: String(spec.quantity ?? 0),
143
+ })),
144
+ title: messages.getMessage('success'),
145
+ });
146
+ if (response.traceId) {
147
+ this.log(messages.getMessage('success.traceId', [response.traceId]));
148
+ }
149
+ }
150
+ }
151
+ //# sourceMappingURL=provision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provision.js","sourceRoot":"","sources":["../../../src/commands/license/provision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAErD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAA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I,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC;IACH,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
package/lib/index.js ADDED
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2026, Salesforce, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export default {};
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAe,EAAE,CAAC"}
@@ -0,0 +1,77 @@
1
+ # summary
2
+
3
+ Provision Permission Set Licenses (PSL) into a target org.
4
+
5
+ # description
6
+
7
+ Provision Permission Set Licenses (PSL) into the target org. Successful execution sets the quantity of seats for the given PSL in the indicated org.
8
+
9
+ There are two ways to run this command. You can provide the information to identify a single PSL via command line flags, or provision multiple PSLs in a single call by supplying a JSON formatted file.
10
+
11
+ See https://github.com/salesforcecli/plugin-license-management#sf-license-provision for the format and options contained within the JSON file.
12
+
13
+ # flags.namespace.summary
14
+
15
+ License package namespace.
16
+
17
+ # flags.license.summary
18
+
19
+ Permission Set License name.
20
+
21
+ # flags.quantity.summary
22
+
23
+ Number of licenses to provision.
24
+
25
+ # flags.definition-file.summary
26
+
27
+ Path to a JSON file that contains the PSL provisioning request information.
28
+
29
+ # examples
30
+
31
+ - Provision a single Permission Set License into an org:
32
+
33
+ <%= config.bin %> <%= command.id %> --target-org myScratchOrg --namespace demo --license newLicense --quantity 5
34
+
35
+ - Use a JSON formatted input file to provision one or more Permission Set Licenses into an org:
36
+
37
+ <%= config.bin %> <%= command.id %> --target-org myScratchOrg --definition-file test/config/provisionPSLs.json
38
+
39
+ # success.traceId
40
+
41
+ Trace ID: %s
42
+
43
+ # error.missingLicenseFlag
44
+
45
+ Either --license or --definition-file is required.
46
+
47
+ # error.emptyDefinitionFile
48
+
49
+ The definition file must contain at least one license entry.
50
+
51
+ # error.unsupportedDefinitionFileFields
52
+
53
+ Unknown fields in definition file: %s
54
+
55
+ # error.invalidDefinitionFileJson
56
+
57
+ Definition file contains invalid JSON: %s
58
+
59
+ # error.missingRequiredDefinitionFileFields
60
+
61
+ Missing required fields: %s
62
+
63
+ # error.provisionFailed
64
+
65
+ Failed to provision licenses. %s
66
+
67
+ # success
68
+
69
+ Success:
70
+
71
+ # success.column.licenseDefinition
72
+
73
+ License Definition
74
+
75
+ # success.column.provisionedQuantity
76
+
77
+ Provisioned Quantity