Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create/consume branch flag to filter PVL #690

Merged
merged 4 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion command-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,10 @@
"target-hub-org",
"targetdevhubusername"
],
"flagChars": ["c", "m", "o", "p", "r", "v"],
"flagChars": ["b", "c", "m", "o", "p", "r", "v"],
"flags": [
"api-version",
"branch",
"concise",
"created-last-days",
"flags-dir",
Expand Down
8 changes: 8 additions & 0 deletions messages/package_version_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ All filter parameters are applied using the AND logical operator (not OR).

Display limited package version details.

# flags.branch.summary

Branch in your source control system used to filter the results; only package versions based on the specified branch are listed.

# flags.packages.summary

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

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

- 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:

<%= config.bin %> <%= command.id %> --concise --modified-last-days 0 --branch featureA

- List released package versions that were created in the last 3 days in your default Dev Hub org; show limited details:

<%= config.bin %> <%= command.id %> --concise --created-last-days 3 --released
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^4",
"@salesforce/core": "^7.3.8",
"@salesforce/core": "^7.4.0",
"@salesforce/kit": "^3.1.0",
"@salesforce/packaging": "^3.5.16",
"@salesforce/sf-plugins-core": "^10.0.0",
Expand Down
13 changes: 9 additions & 4 deletions src/commands/package/version/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
char: 'r',
summary: messages.getMessage('flags.released.summary'),
}),
branch: Flags.string({
char: 'b',
summary: messages.getMessage('flags.branch.summary'),
}),
'order-by': Flags.string({
// eslint-disable-next-line sf-plugin/dash-o
char: 'o',
Expand All @@ -103,13 +107,14 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
const project = SfProject.getInstance();

const records = await Package.listVersions(connection, project, {
createdLastDays: flags['created-last-days'] as number,
createdLastDays: flags['created-last-days'],
concise: flags.concise,
modifiedLastDays: flags['modified-last-days'] as number,
modifiedLastDays: flags['modified-last-days'],
packages: flags.packages?.split(',') ?? [],
isReleased: flags.released,
orderBy: flags['order-by'] as string,
orderBy: flags['order-by'],
verbose: flags.verbose,
branch: flags.branch,
showConversionsOnly: flags['show-conversions-only'],
});

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

records.forEach((record) => {
const ids = [record.Id, record.SubscriberPackageVersionId];
const aliases: string[] = ids.map((id) => project.getAliasesFromPackageId(id)).flat();
const aliases = ids.map((id) => project.getAliasesFromPackageId(id)).flat();
const AliasStr = aliases.length > 0 ? aliases.join() : '';

// set Ancestor display values
Expand Down
14 changes: 11 additions & 3 deletions test/commands/package/packageVersion.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ describe('package:version:*', () => {
describe('package:version:create', () => {
it('should create a new package version (human)', () => {
const result = execCmd(
`package:version:create --package ${pkgName} -x --code-coverage --version-description "Initial version"`,
`package:version:create --package ${pkgName} -x --code-coverage --version-description "Initial version" --branch testing`,
{ ensureExitCode: 0 }
).shellOutput.stdout;
// eslint-disable-next-line no-console
console.log(result);
expect(result).to.include("Package version creation request status is '");
expect(result).to.match(/Run "sfd?x? package:version:create:report -i 08c.{15}" to query for status\./);
});
Expand Down Expand Up @@ -286,6 +284,16 @@ describe('package:version:*', () => {
/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/
);
});

it("should list installed packages in dev hub - verbose human readable results only on the 'testing' branch", () => {
const command = `package:version:list -v ${session.hubOrg.username} --verbose --branch testing`;
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout;
expect(output).to.contain('=== Package Versions [');
expect(output).to.match(
/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/
);
expect(output).to.include('testing');
});
it('should list package versions in dev hub - json results', () => {
const command = `package:version:list -v ${session.hubOrg.username} --json`;
const output = execCmd<[PackageVersionListCommandResult]>(command, { ensureExitCode: 0 }).jsonOutput?.result;
Expand Down
11 changes: 6 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1478,17 +1478,18 @@
strip-ansi "6.0.1"
ts-retry-promise "^0.8.0"

"@salesforce/core@^7.0.0", "@salesforce/core@^7.3.1", "@salesforce/core@^7.3.10", "@salesforce/core@^7.3.5", "@salesforce/core@^7.3.6", "@salesforce/core@^7.3.8":
version "7.3.10"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-7.3.10.tgz#83da85c4e93ca625e2c13118aad9c1df2931bc0f"
integrity sha512-kEKoqkmhWNoiucAE3Ylv6FpC4iVgk4aE0dmcwSmNrMjxSbtjQJGUybprfO/itrLJv+56eM7/4FARQQ2gDbRzQQ==
"@salesforce/core@^7.0.0", "@salesforce/core@^7.3.1", "@salesforce/core@^7.3.10", "@salesforce/core@^7.3.5", "@salesforce/core@^7.3.6", "@salesforce/core@^7.4.0":
version "7.4.0"
resolved "https://registry.yarnpkg.com/@salesforce/core/-/core-7.4.0.tgz#11c45a5f432e032bf242aaace1a175779e3e096f"
integrity sha512-wn3fJnpG8h493qKR52Il3xgRbXg4zwbV34wonf/mTZP3n5rJeC/7S69249CGN155Os6Lds5rEUo3pGJFwgCBdQ==
dependencies:
"@jsforce/jsforce-node" "^3.2.0"
"@salesforce/kit" "^3.1.1"
"@salesforce/kit" "^3.1.2"
"@salesforce/schemas" "^1.9.0"
"@salesforce/ts-types" "^2.0.9"
ajv "^8.15.0"
change-case "^4.1.2"
fast-levenshtein "^3.0.0"
faye "^1.4.0"
form-data "^4.0.0"
js2xmlparser "^4.0.1"
Expand Down
Loading