Skip to content

Commit 331b533

Browse files
committed
feat: add org list flag
1 parent 7b9e5ab commit 331b533

File tree

3 files changed

+47
-35
lines changed

3 files changed

+47
-35
lines changed

command-snapshot.json

+10-18
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@
179179
"flags": ["api-version", "flags-dir", "json", "loglevel", "target-dev-hub", "verbose"],
180180
"plugin": "@salesforce/plugin-packaging"
181181
},
182+
{
183+
"alias": [],
184+
"command": "package:pushupgrade:abort",
185+
"flagAliases": [],
186+
"flagChars": ["i", "v"],
187+
"flags": ["api-version", "flags-dir", "json", "push-request-id", "target-dev-hub"],
188+
"plugin": "@salesforce/plugin-packaging"
189+
},
182190
{
183191
"alias": ["force:package:pushupgrade:list"],
184192
"command": "package:pushupgrade:list",
@@ -199,24 +207,8 @@
199207
"alias": [],
200208
"command": "package:pushupgrade:schedule",
201209
"flagAliases": [],
202-
"flagChars": ["l", "p", "t", "v"],
203-
"flags": [
204-
"api-version",
205-
"flags-dir",
206-
"json",
207-
"org-list",
208-
"package-version-id",
209-
"scheduled-start-time",
210-
"target-dev-hub"
211-
],
212-
"plugin": "@salesforce/plugin-packaging"
213-
}
214-
{
215-
"alias": ["force:package:pushupgrade:abort"],
216-
"command": "package:pushupgrade:abort",
217-
"flagAliases": [],
218-
"flagChars": ["i", "v"],
219-
"flags": ["api-version", "flags-dir", "json", "push-request-id", "target-dev-hub"],
210+
"flagChars": ["f", "l", "p", "t", "v"],
211+
"flags": ["api-version", "flags-dir", "json", "org-file", "org-list", "package", "start-time", "target-dev-hub"],
220212
"plugin": "@salesforce/plugin-packaging"
221213
},
222214
{

messages/package_pushupgrade_schedule.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,22 @@ Username or alias of the Dev Hub org.
1919

2020
Overrides the value of the target-dev-hub configuration variable, if set.
2121

22-
# flags.package-version-id.summary
22+
# flags.package.summary
2323

2424
ID (starts with 04t) of the package version that the package is be upgraded to. The package version must be an active, non-beta package version.
2525

26-
# flags.scheduled-start-time.summary
26+
# flags.start-time.summary
2727

2828
Specify the date and time (UTC) when the push upgrade is processed. Set this value to the earliest time that you want Salesforce to attempt to start the upgrade.
2929

30-
# flags.org-list.summary
30+
# flags.org-file.summary
3131

3232
The filename of the .csv file that contains the list of orgs that need the package upgrade.
3333

34+
# flags.org-list.summary
35+
36+
Supply subscriber organization ids that can be pushed upgrade.
37+
3438
# error.invalid-package-version
3539

3640
Invalid package version.

src/commands/package/pushupgrade/schedule.ts

+30-14
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,47 @@ export class PackagePushScheduleCommand extends SfCommand<PackagePushScheduleRes
2626
required: true,
2727
}),
2828
'api-version': Flags.orgApiVersion(),
29-
'package-version-id': Flags.salesforceId({
29+
package: Flags.salesforceId({
3030
length: 'both',
3131
char: 'p',
32-
summary: messages.getMessage('flags.package-version-id.summary'),
32+
summary: messages.getMessage('flags.package.summary'),
3333
required: true,
3434
startsWith: '04t',
3535
}),
36-
'scheduled-start-time': Flags.string({
36+
'start-time': Flags.string({
3737
char: 't',
38-
summary: messages.getMessage('flags.scheduled-start-time.summary'),
38+
summary: messages.getMessage('flags.start-time.summary'),
3939
}),
40-
'org-list': Flags.file({
40+
'org-file': Flags.file({
41+
char: 'f',
42+
summary: messages.getMessage('flags.org-file.summary'),
43+
exactlyOne: ['org-list', 'org-file'],
44+
exists: true,
45+
}),
46+
'org-list': Flags.string({
4147
char: 'l',
4248
summary: messages.getMessage('flags.org-list.summary'),
43-
required: true,
44-
exists: true,
49+
allowStdin: true,
50+
exactlyOne: ['org-list', 'org-file'],
4551
}),
4652
};
4753

4854
public async run(): Promise<PackagePushScheduleResult> {
4955
const { flags } = await this.parse(PackagePushScheduleCommand);
56+
let orgList: string[] = [];
5057

5158
// Read and validate org list
52-
const orgList = await readOrgListFile(flags['org-list']);
59+
if (flags['org-file']) {
60+
orgList = await readOrgListFile(flags['org-file']);
61+
} else if (flags['org-list']) {
62+
orgList = getOrgListFromInput(flags['org-list']);
63+
}
5364

5465
// Connect to the Dev Hub
5566
const conn = flags['target-dev-hub'].getConnection(flags['api-version']);
5667

5768
// Schedule the push upgrade
58-
const result = await PackagePushUpgrade.schedule(
59-
conn,
60-
flags['package-version-id'],
61-
flags['scheduled-start-time']!,
62-
orgList
63-
);
69+
const result = await PackagePushUpgrade.schedule(conn, flags['package'], flags['start-time']!, orgList);
6470

6571
this.log(messages.getMessage('output', [result?.PushRequestId]));
6672

@@ -78,3 +84,13 @@ async function readOrgListFile(filePath: string): Promise<string[]> {
7884
throw new SfError(messages.getMessage('error.invalid-org-list-file'), error as string | undefined);
7985
}
8086
}
87+
88+
function getOrgListFromInput(orgInput: string): string[] {
89+
if (!orgInput) {
90+
throw new Error('Org input is required');
91+
}
92+
93+
const orgList = orgInput.split(',').map((org) => org.trim());
94+
95+
return orgList.filter((org) => org.length > 0);
96+
}

0 commit comments

Comments
 (0)