Skip to content

Commit 0f11629

Browse files
authored
Merge pull request #690 from salesforcecli/wr/filterPVLbyBranch
feat: create/consume branch flag to filter PVL
2 parents 9aa716b + fadad0f commit 0f11629

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

command-snapshot.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,10 @@
325325
"target-hub-org",
326326
"targetdevhubusername"
327327
],
328-
"flagChars": ["c", "m", "o", "p", "r", "v"],
328+
"flagChars": ["b", "c", "m", "o", "p", "r", "v"],
329329
"flags": [
330330
"api-version",
331+
"branch",
331332
"concise",
332333
"created-last-days",
333334
"flags-dir",

messages/package_version_list.md

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ All filter parameters are applied using the AND logical operator (not OR).
1212

1313
Display limited package version details.
1414

15+
# flags.branch.summary
16+
17+
Branch in your source control system used to filter the results; only package versions based on the specified branch are listed.
18+
1519
# flags.packages.summary
1620

1721
Comma-delimited list of packages (aliases or 0Ho IDs) to list.
@@ -50,6 +54,10 @@ Filter the list output to display only converted package version.
5054

5155
<%= config.bin %> <%= command.id %> --concise --modified-last-days 0
5256

57+
- List package versions that are based on the "featureA" branch in your source control system that were modified today in your default Dev Hub org; show limited details about each one:
58+
59+
<%= config.bin %> <%= command.id %> --concise --modified-last-days 0 --branch featureA
60+
5361
- List released package versions that were created in the last 3 days in your default Dev Hub org; show limited details:
5462

5563
<%= config.bin %> <%= command.id %> --concise --created-last-days 3 --released

src/commands/package/version/create.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ export class PackageVersionCreateCommand extends SfCommand<PackageVersionCommand
199199
// no async methods
200200
// eslint-disable-next-line @typescript-eslint/require-await
201201
async (data: PackageVersionCreateReportProgress) => {
202-
if (data.Status !== Package2VersionStatus.success && data.Status !== Package2VersionStatus.error && data.Status !== Package2VersionStatus.performingValidations
202+
if (
203+
data.Status !== Package2VersionStatus.success &&
204+
data.Status !== Package2VersionStatus.error &&
205+
data.Status !== Package2VersionStatus.performingValidations
203206
) {
204207
const status = messages.getMessage('packageVersionCreateWaitingStatus', [
205208
data.remainingWaitTime.minutes,

src/commands/package/version/list.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
8585
char: 'r',
8686
summary: messages.getMessage('flags.released.summary'),
8787
}),
88+
branch: Flags.string({
89+
char: 'b',
90+
summary: messages.getMessage('flags.branch.summary'),
91+
}),
8892
'order-by': Flags.string({
8993
// eslint-disable-next-line sf-plugin/dash-o
9094
char: 'o',
@@ -103,13 +107,14 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
103107
const project = SfProject.getInstance();
104108

105109
const records = await Package.listVersions(connection, project, {
106-
createdLastDays: flags['created-last-days'] as number,
110+
createdLastDays: flags['created-last-days'],
107111
concise: flags.concise,
108-
modifiedLastDays: flags['modified-last-days'] as number,
112+
modifiedLastDays: flags['modified-last-days'],
109113
packages: flags.packages?.split(',') ?? [],
110114
isReleased: flags.released,
111-
orderBy: flags['order-by'] as string,
115+
orderBy: flags['order-by'],
112116
verbose: flags.verbose,
117+
branch: flags.branch,
113118
showConversionsOnly: flags['show-conversions-only'],
114119
});
115120

@@ -129,7 +134,7 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
129134

130135
records.forEach((record) => {
131136
const ids = [record.Id, record.SubscriberPackageVersionId];
132-
const aliases: string[] = ids.map((id) => project.getAliasesFromPackageId(id)).flat();
137+
const aliases = ids.map((id) => project.getAliasesFromPackageId(id)).flat();
133138
const AliasStr = aliases.length > 0 ? aliases.join() : '';
134139

135140
// set Ancestor display values

test/commands/package/packageVersion.nut.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ describe('package:version:*', () => {
7171
describe('package:version:create', () => {
7272
it('should create a new package version (human)', () => {
7373
const result = execCmd(
74-
`package:version:create --package ${pkgName} -x --code-coverage --version-description "Initial version"`,
74+
`package:version:create --package ${pkgName} -x --code-coverage --version-description "Initial version" --branch testing`,
7575
{ ensureExitCode: 0 }
7676
).shellOutput.stdout;
77-
// eslint-disable-next-line no-console
78-
console.log(result);
7977
expect(result).to.include("Package version creation request status is '");
8078
expect(result).to.match(/Run "sfd?x? package:version:create:report -i 08c.{15}" to query for status\./);
8179
});
@@ -297,6 +295,16 @@ describe('package:version:*', () => {
297295
/Package Name\s+Namespace\s+Version Name\s+Version\s+Subscriber Package Version Id\sAlias\s+Installation Key\s+Released\s+Validation Skipped\s+Ancestor\s+Ancestor Version\s+Branch\s+Package Id\s+Installation URL\s+Package Version Id\s+Created Date\s+Last Modified Date\s+Tag\s+Description\s+Code Coverage\s+Code Coverage Met\s+Converted From Version Id\s+Org-Dependent\s+Unlocked Package\s+Release\s+Version\s+Build Duration in Seconds\s+Managed Metadata Removed\s+Created By/
298296
);
299297
});
298+
299+
it("should list installed packages in dev hub - verbose human readable results only on the 'testing' branch", () => {
300+
const command = `package:version:list -v ${session.hubOrg.username} --verbose --branch testing`;
301+
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout;
302+
expect(output).to.contain('=== Package Versions [');
303+
expect(output).to.match(
304+
/Package Name\s+Namespace\s+Version Name\s+Version\s+Subscriber Package Version Id\sAlias\s+Installation Key\s+Released\s+Validation Skipped\s+Ancestor\s+Ancestor Version\s+Branch\s+Package Id\s+Installation URL\s+Package Version Id\s+Created Date\s+Last Modified Date\s+Tag\s+Description\s+Code Coverage\s+Code Coverage Met\s+Converted From Version Id\s+Org-Dependent\s+Unlocked Package\s+Release\s+Version\s+Build Duration in Seconds\s+Managed Metadata Removed\s+Created By/
305+
);
306+
expect(output).to.include('testing');
307+
});
300308
it('should list package versions in dev hub - json results', () => {
301309
const command = `package:version:list -v ${session.hubOrg.username} --json`;
302310
const output = execCmd<[PackageVersionListCommandResult]>(command, { ensureExitCode: 0 }).jsonOutput?.result;

0 commit comments

Comments
 (0)