|
1 | | -**NOTE: This template for sf plugins is not yet official. Please consult with the Platform CLI team before using this template.** |
2 | | - |
3 | | -# plugin-license-management |
| 1 | +# License Management Plugin |
4 | 2 |
|
5 | 3 | [](https://www.npmjs.com/package/@salesforce/plugin-license-management) [](https://npmjs.org/package/@salesforce/plugin-license-management) [](https://opensource.org/license/apache-2-0) |
6 | 4 |
|
7 | | -## Using the template |
8 | | - |
9 | | -This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin: |
10 | | - |
11 | | -1. Please get in touch with the Platform CLI team. We want to help you develop your plugin. |
12 | | -2. Generate your plugin: |
13 | | - |
14 | | - ``` |
15 | | - sf plugins install dev |
16 | | - sf dev generate plugin |
17 | | -
|
18 | | - git init -b main |
19 | | - git add . && git commit -m "chore: initial commit" |
20 | | - ``` |
21 | | - |
22 | | -3. Create your plugin's repo in the salesforcecli github org |
23 | | -4. When you're ready, replace the contents of this README with the information you want. |
24 | | - |
25 | | -## Learn about `sf` plugins |
26 | | - |
27 | | -Salesforce CLI plugins are based on the [oclif plugin framework](https://oclif.io/docs/introduction). Read the [plugin developer guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_architecture_sf_cli.htm) to learn about Salesforce CLI plugin development. |
28 | | - |
29 | | -This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the [node developer packages](#tooling) used by Salesforce. There is also a default circleci config using the [release management orb](https://github.com/forcedotcom/npm-release-management-orb) standards. |
| 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. |
30 | 6 |
|
31 | | -Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the `posttest` script and it is required to keep these tests active in your plugin if you plan to have it bundled. |
| 7 | +## Before You Begin |
32 | 8 |
|
33 | | -### Tooling |
34 | | - |
35 | | -- [@salesforce/core](https://github.com/forcedotcom/sfdx-core) |
36 | | -- [@salesforce/kit](https://github.com/forcedotcom/kit) |
37 | | -- [@salesforce/sf-plugins-core](https://github.com/salesforcecli/sf-plugins-core) |
38 | | -- [@salesforce/ts-types](https://github.com/forcedotcom/ts-types) |
39 | | -- [@salesforce/ts-sinon](https://github.com/forcedotcom/ts-sinon) |
40 | | -- [@salesforce/dev-config](https://github.com/forcedotcom/dev-config) |
41 | | -- [@salesforce/dev-scripts](https://github.com/forcedotcom/dev-scripts) |
42 | | - |
43 | | -# Everything past here is only a suggestion as to what should be in your specific plugin's description |
44 | | - |
45 | | -This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm). |
46 | | - |
47 | | -We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed. |
| 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. |
48 | 11 |
|
49 | 12 | ## Install |
50 | 13 |
|
@@ -170,12 +133,53 @@ _See code: [src/commands/license/provision.ts](https://github.com/salesforcecli/ |
170 | 133 |
|
171 | 134 | # Local Testing |
172 | 135 |
|
| 136 | +### 1. Log in to your Dev Hub |
| 137 | + |
| 138 | +```bash |
| 139 | +sf org login web --set-default-dev-hub --instance-url <dev-hub-url> |
| 140 | +``` |
| 141 | + |
| 142 | +### 2. Create a scratch org |
| 143 | + |
| 144 | +Before creating the scratch org, update `test/config/scratch-org-def.json` with your values: |
| 145 | + |
| 146 | +| Field | Description | |
| 147 | +| ----------- | ------------------------------------ | |
| 148 | +| `orgName` | Display name for the scratch org | |
| 149 | +| `namespace` | Your package namespace (e.g. `myNS`) | |
| 150 | + |
| 151 | +```bash |
| 152 | +sf org create scratch --definition-file test/config/scratch-org-def.json --alias <scratch-org-alias> |
| 153 | +``` |
| 154 | + |
| 155 | +### 3. Install the package into the scratch org |
| 156 | + |
| 157 | +Make the package available in the scratch org. Some ways to do this include: |
| 158 | + |
| 159 | +**Install a released package version** |
| 160 | + |
| 161 | +```bash |
| 162 | +sf package install --package <package-version-id> --target-org <scratch-org-alias> |
| 163 | +``` |
| 164 | + |
| 165 | +**Push source directly** |
| 166 | + |
173 | 167 | ```bash |
174 | | -sf org create scratch --target-dev-hub <devhub-alias> --definition-file test/config/scratch-org-def.json |
| 168 | +sf project deploy start --target-org <scratch-org-alias> |
| 169 | +``` |
175 | 170 |
|
176 | | -sf package install --package <package-id> --target-org <scratch-org-username> |
| 171 | +### 4. Open the scratch org (optional) |
177 | 172 |
|
178 | | -sf package install report -i <install-request-id> -o <scratch-org-username> |
| 173 | +```bash |
| 174 | +sf org open --target-org <scratch-org-alias> |
| 175 | +``` |
| 176 | + |
| 177 | +### 5. Provision licenses |
| 178 | + |
| 179 | +```bash |
| 180 | +# Provision a single PSL |
| 181 | +sf license provision --target-org <scratch-org-alias> --namespace <namespace> --license <license-name> --quantity <number> |
179 | 182 |
|
180 | | -sf license provision -o <scratch-org-username> --license premium --namespace demo --quantity 10 |
| 183 | +# Provision multiple PSLs using a definition file |
| 184 | +sf license provision --target-org <scratch-org-alias> --definition-file <path-to-definition-file> |
181 | 185 | ``` |
0 commit comments