Skip to content

Commit a57f9a9

Browse files
committed
feat: remove startDate and endDate from license provision command
1 parent eb70540 commit a57f9a9

5 files changed

Lines changed: 11 additions & 72 deletions

File tree

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,14 @@ Provision Permission Set Licenses (PSL) into a target org.
115115

116116
```
117117
USAGE
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>]
118+
$ sf license provision -o <value> [-n <value>] [-l <value>] [-q <value>] [-f <value>] [--api-version <value>] [--json] [--flags-dir <value>]
119119
120120
FLAGS
121-
-e, --end-date=<value> License end date in YYYY-MM-DD format. Default is no expiration.
122121
-f, --definition-file=<value> Path to a JSON file that contains the PSL provisioning request information.
123122
-l, --license=<value> Permission Set License name.
124123
-n, --namespace=<value> License package namespace.
125124
-o, --target-org=<value> (required) Username or alias of the target org.
126125
-q, --quantity=<value> Number of licenses to provision.
127-
-s, --start-date=<value> License start date in YYYY-MM-DD format. Defaults to today.
128126
--api-version=<value> Override the api version used for api requests made by this command.
129127
130128
GLOBAL FLAGS
@@ -141,7 +139,7 @@ DESCRIPTION
141139
EXAMPLES
142140
Provision a single Permission Set License into an org:
143141
144-
$ sf license provision --target-org myScratchOrg --namespace demo --license newLicense --quantity 5 --start-date '2026-03-30' --end-date '2027-03-30'
142+
$ sf license provision --target-org myScratchOrg --namespace demo --license newLicense --quantity 5
145143
146144
Use a JSON formatted input file to provision one or more Permission Set Licenses into an org:
147145
@@ -186,5 +184,5 @@ sf package install --package <package-id> --target-org <scratch-org-username>
186184

187185
sf package install report -i <install-request-id> -o <scratch-org-username>
188186

189-
sf license provision -o <scratch-org-username> --license premium --namespace demo --quantity 10 --start-date '2026-03-20' --end-date '2027-03-20'
187+
sf license provision -o <scratch-org-username> --license premium --namespace demo --quantity 10
190188
```

command-snapshot.json

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,8 @@
33
"alias": [],
44
"command": "license:provision",
55
"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-
],
6+
"flagChars": ["f", "l", "n", "o", "q"],
7+
"flags": ["api-version", "definition-file", "flags-dir", "json", "license", "namespace", "quantity", "target-org"],
198
"plugin": "@salesforce/plugin-license-management"
209
}
2110
]

messages/license.provision.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ Permission Set License name.
2222

2323
Number of licenses to provision.
2424

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-
3325
# flags.definition-file.summary
3426

3527
Path to a JSON file that contains the PSL provisioning request information.
@@ -38,7 +30,7 @@ Path to a JSON file that contains the PSL provisioning request information.
3830

3931
- Provision a single Permission Set License into an org:
4032

41-
<%= config.bin %> <%= command.id %> --target-org myScratchOrg --namespace demo --license newLicense --quantity 5 --start-date '2026-03-30' --end-date '2027-03-30'
33+
<%= config.bin %> <%= command.id %> --target-org myScratchOrg --namespace demo --license newLicense --quantity 5
4234

4335
- Use a JSON formatted input file to provision one or more Permission Set Licenses into an org:
4436

@@ -54,7 +46,7 @@ Either --license or --definition-file is required.
5446

5547
# error.mutuallyExclusiveFlags
5648

57-
The --definition-file flag cannot be used with --namespace, --license, --quantity, --start-date, or --end-date.
49+
The --definition-file flag cannot be used with --namespace, --license, or --quantity.
5850

5951
# error.emptyDefinitionFile
6052

src/commands/license/provision.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ type ProvisionLicenseSpec = {
2525
namespacePrefix?: string;
2626
permissionSetLicense?: string;
2727
quantity?: number;
28-
startDate?: string;
29-
endDate?: string;
3028
};
3129

3230
type ProvisionPslRequest = {
@@ -72,14 +70,6 @@ export default class LicenseProvision extends SfCommand<LicenseProvisionResult>
7270
min: 0,
7371
max: Number.MAX_SAFE_INTEGER,
7472
}),
75-
'start-date': Flags.string({
76-
char: 's',
77-
summary: messages.getMessage('flags.start-date.summary'),
78-
}),
79-
'end-date': Flags.string({
80-
char: 'e',
81-
summary: messages.getMessage('flags.end-date.summary'),
82-
}),
8373
'definition-file': Flags.string({
8474
char: 'f',
8575
summary: messages.getMessage('flags.definition-file.summary'),
@@ -92,13 +82,7 @@ export default class LicenseProvision extends SfCommand<LicenseProvisionResult>
9282
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9383
flags: Record<string, any>
9484
): Promise<ProvisionLicenseSpec[]> {
95-
if (
96-
flags['license'] ||
97-
flags['namespace'] ||
98-
flags['quantity'] !== undefined ||
99-
flags['start-date'] ||
100-
flags['end-date']
101-
) {
85+
if (flags['license'] || flags['namespace'] || flags['quantity'] !== undefined) {
10286
throw messages.createError('error.mutuallyExclusiveFlags');
10387
}
10488

@@ -118,15 +102,11 @@ export default class LicenseProvision extends SfCommand<LicenseProvisionResult>
118102
throw messages.createError('error.missingLicenseFlag');
119103
}
120104

121-
const startDate = (flags['start-date'] as string | undefined) ?? new Date().toISOString().slice(0, 10);
122-
123105
return [
124106
{
125107
namespacePrefix: flags['namespace'] as string | undefined,
126108
permissionSetLicense: flags['license'] as string,
127109
quantity: flags['quantity'] as number | undefined,
128-
startDate,
129-
endDate: flags['end-date'] as string | undefined,
130110
},
131111
];
132112
}

test/commands/license/provision.test.ts

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ describe('license provision', () => {
6565
'demo',
6666
'--quantity',
6767
'5',
68-
'--start-date',
69-
'2026-03-30',
70-
'--end-date',
71-
'2027-03-30',
7268
]);
7369

7470
const tableCall = sfCommandStubs.table.firstCall.args[0] as { data: Array<Record<string, string>>; title: string };
@@ -99,10 +95,6 @@ describe('license provision', () => {
9995
'demo',
10096
'--quantity',
10197
'5',
102-
'--start-date',
103-
'2026-03-30',
104-
'--end-date',
105-
'2027-03-30',
10698
]);
10799

108100
expect(requestStub.calledOnce).to.be.true;
@@ -116,21 +108,9 @@ describe('license provision', () => {
116108
namespacePrefix: 'demo',
117109
permissionSetLicense: 'newLicense',
118110
quantity: 5,
119-
startDate: '2026-03-30',
120-
endDate: '2027-03-30',
121111
});
122112
});
123113

124-
it('defaults start-date to today when not provided', async () => {
125-
const today = new Date().toISOString().slice(0, 10);
126-
127-
await LicenseProvision.run(['--target-org', testOrg.username, '--license', 'myLicense']);
128-
129-
const callArgs = requestStub.firstCall.args[0] as { body: string };
130-
const body = JSON.parse(callArgs.body) as { licenses: Array<{ startDate: string }> };
131-
expect(body.licenses[0].startDate).to.equal(today);
132-
});
133-
134114
it('returns status:success result with traceId', async () => {
135115
const result = await LicenseProvision.run(['--target-org', testOrg.username, '--license', 'myLicense']);
136116
expect(result).to.deep.equal({ status: 'success', traceId: 'tm_test123' });
@@ -268,16 +248,16 @@ describe('license provision', () => {
268248

269249
it('wraps a HTTP 400 provisioning error as SfError', async () => {
270250
requestStub.rejects(
271-
Object.assign(new Error("Invalid endDate format for permissionSetLicense 'premium'"), {
272-
name: 'INVALID_END_DATE',
251+
Object.assign(new Error("Invalid quantity for permissionSetLicense 'premium'"), {
252+
name: 'INVALID_QUANTITY',
273253
})
274254
);
275255

276256
try {
277257
await LicenseProvision.run(['--target-org', testOrg.username, '--license', 'premium']);
278258
expect.fail('Expected an error to be thrown');
279259
} catch (error: unknown) {
280-
expect((error as Error).message).to.include('Invalid endDate format');
260+
expect((error as Error).message).to.include('Invalid quantity');
281261
}
282262
});
283263

0 commit comments

Comments
 (0)