Skip to content

Commit 6f5e6a8

Browse files
authored
Merge pull request #4 from salesforcecli/t/tm-connect/move-code-from-plugin-partner-marketplace
W-21920789: moving code from plugin-partner-marketplace and deleting hello world code
2 parents ae841c3 + fd8bc03 commit 6f5e6a8

13 files changed

Lines changed: 756 additions & 198 deletions

File tree

README.md

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.
9191

9292
```bash
9393
# Run using local run file.
94-
./bin/dev hello world
94+
./bin/dev license provision
9595
```
9696

9797
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.
@@ -107,43 +107,84 @@ sf plugins
107107

108108
<!-- commands -->
109109

110-
- [`sf hello world`](#sf-hello-world)
110+
- [`sf license provision`](#sf-license-provision)
111111

112-
## `sf hello world`
112+
## `sf license provision`
113113

114-
Say hello.
114+
Provision Permission Set Licenses (PSL) into a target org.
115115

116116
```
117117
USAGE
118-
$ sf hello world [--json] [--flags-dir <value>] [-n <value>]
118+
$ sf license provision -o <value> [-n <value>] [-l <value>] [-q <value>] [-s <value>] [-e <value>] [-f <value>] [--api-version <value>] [--json] [--flags-dir <value>]
119119
120120
FLAGS
121-
-n, --name=<value> [default: World] The name of the person you'd like to say hello to.
121+
-e, --end-date=<value> License end date in YYYY-MM-DD format. Default is no expiration.
122+
-f, --definition-file=<value> Path to a JSON file that contains the PSL provisioning request information.
123+
-l, --license=<value> Permission Set License name.
124+
-n, --namespace=<value> License package namespace.
125+
-o, --target-org=<value> (required) Username or alias of the target org.
126+
-q, --quantity=<value> Number of licenses to provision.
127+
-s, --start-date=<value> License start date in YYYY-MM-DD format. Defaults to today.
128+
--api-version=<value> Override the api version used for api requests made by this command.
122129
123130
GLOBAL FLAGS
124131
--flags-dir=<value> Import flag values from a directory.
125132
--json Format output as json.
126133
127134
DESCRIPTION
128-
Say hello.
135+
Provision Permission Set Licenses (PSL) into the target org. Successful execution sets the quantity of seats for the given PSL in the indicated org.
129136
130-
Say hello either to the world or someone you know.
137+
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.
138+
139+
See <Add URL Here> for the format and options contained within the JSON file.
131140
132141
EXAMPLES
133-
Say hello to the world:
142+
Provision a single Permission Set License into an org:
143+
144+
$ sf license provision --target-org myScratchOrg --namespace demo --license newLicense --quantity 5 --start-date '2026-03-30' --end-date '2027-03-30'
145+
146+
Use a JSON formatted input file to provision one or more Permission Set Licenses into an org:
147+
148+
$ sf license provision --target-org myScratchOrg --definition-file test/config/provisionPSLs.json
134149
135-
$ sf hello world
150+
HUMAN READABLE OUTPUT
136151
137-
Say hello to someone you know:
152+
Success:
153+
Provisioned 5 licenses for the license definition 'demo__newLicense'
138154
139-
$ sf hello world --name Astro
155+
Success:
156+
Provisioned 5 licenses for the license definition 'demo__newLicense'
157+
Provisioned 8 licenses for the license definition 'demo__premiumLicense'
140158
141-
FLAG DESCRIPTIONS
142-
-n, --name=<value> The name of the person you'd like to say hello to.
159+
Error: Failed to provision licenses.
160+
License Definition not found for 'demo__badLicense'.
161+
Quantity cannot be negative for 'demo__negativeLicense'.
143162
144-
This person can be anyone in the world!
163+
JSON OUTPUT
164+
165+
{ "status": "success" }
166+
167+
{
168+
"status": "error",
169+
"messages": [
170+
{ "errorCode": "INVALID_LICENSE_DEFINITION", "message": "License definition not found for 'demo__badLicense'" },
171+
{ "errorCode": "INVALID_QUANTITY", "message": "Quantity cannot be negative for 'demo__negativeLicense'" }
172+
]
173+
}
145174
```
146175

147-
_See code: [src/commands/hello/world.ts](https://github.com/salesforcecli/plugin-license-management/blob/1.1.84/src/commands/hello/world.ts)_
176+
_See code: [src/commands/license/provision.ts](https://github.com/salesforcecli/plugin-license-management/blob/1.0.0/src/commands/license/provision.ts)_
148177

149178
<!-- commandsstop -->
179+
180+
# Local Testing
181+
182+
```bash
183+
sf org create scratch --target-dev-hub <devhub-alias> --definition-file test/config/scratch-org-def.json
184+
185+
sf package install --package <package-id> --target-org <scratch-org-username>
186+
187+
sf package install report -i <install-request-id> -o <scratch-org-username>
188+
189+
sf license provision -o <scratch-org-username> --license premium --namespace demo --quantity 10 --start-date '2026-03-20' --end-date '2027-03-20'
190+
```

command-snapshot.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
[
22
{
33
"alias": [],
4-
"command": "hello:world",
5-
"flagAliases": [],
6-
"flagChars": ["n"],
7-
"flags": ["flags-dir", "json", "name"],
4+
"command": "license:provision",
5+
"flagAliases": ["apiversion", "targetusername", "u"],
6+
"flagChars": ["e", "f", "l", "n", "o", "q", "s"],
7+
"flags": [
8+
"api-version",
9+
"definition-file",
10+
"end-date",
11+
"flags-dir",
12+
"json",
13+
"license",
14+
"namespace",
15+
"quantity",
16+
"start-date",
17+
"target-org"
18+
],
819
"plugin": "@salesforce/plugin-license-management"
920
}
1021
]

messages/hello.world.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

messages/license.provision.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 <Add URL Here> 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.start-date.summary
26+
27+
License start date in YYYY-MM-DD format. Defaults to today.
28+
29+
# flags.end-date.summary
30+
31+
License end date in YYYY-MM-DD format. Default is no expiration.
32+
33+
# flags.definition-file.summary
34+
35+
Path to a JSON file that contains the PSL provisioning request information.
36+
37+
# examples
38+
39+
- Provision a single Permission Set License into an org:
40+
41+
<%= config.bin %> <%= command.id %> --target-org myScratchOrg --namespace demo --license newLicense --quantity 5 --start-date '2026-03-30' --end-date '2027-03-30'
42+
43+
- Use a JSON formatted input file to provision one or more Permission Set Licenses into an org:
44+
45+
<%= config.bin %> <%= command.id %> --target-org myScratchOrg --definition-file test/config/provisionPSLs.json
46+
47+
# success.provisioned
48+
49+
Provisioned %s licenses for the license definition '%s'
50+
51+
# error.missingLicenseFlag
52+
53+
Either --license or --definition-file is required.
54+
55+
# error.mutuallyExclusiveFlags
56+
57+
The --definition-file flag cannot be used with --namespace, --license, --quantity, --start-date, or --end-date.
58+
59+
# error.emptyDefinitionFile
60+
61+
The definition file must contain at least one license entry.
62+
63+
# error.invalidDateFormat
64+
65+
Invalid date format '%s' for --%s. Expected YYYY-MM-DD.
66+
67+
# error.provisionFailed
68+
69+
Failed to provision licenses. %s
70+
71+
# success
72+
73+
Success:

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
"@salesforce/plugin-command-reference"
5353
],
5454
"topics": {
55-
"hello": {
56-
"description": "Commands to say hello."
55+
"license": {
56+
"description": "description for license"
5757
}
5858
},
5959
"flexibleTaxonomy": true

schemas/hello-world.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

schemas/license-provision.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/LicenseProvisionResult",
4+
"definitions": {
5+
"LicenseProvisionResult": {
6+
"type": "object",
7+
"properties": {
8+
"status": {
9+
"type": "string"
10+
},
11+
"messages": {
12+
"type": "array",
13+
"items": {
14+
"type": "object",
15+
"properties": {
16+
"errorCode": {
17+
"type": "string"
18+
},
19+
"message": {
20+
"type": "string"
21+
}
22+
},
23+
"required": ["errorCode", "message"],
24+
"additionalProperties": false
25+
}
26+
}
27+
},
28+
"required": ["status"],
29+
"additionalProperties": false
30+
}
31+
}
32+
}

src/commands/hello/world.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)