Skip to content

W-17561980 CLI Command to Display Dependencies#1011

Closed
MimiRaiSalesforce wants to merge 9 commits into
mainfrom
t/managed-packaging/W-17561980/display-dependency-graph
Closed

W-17561980 CLI Command to Display Dependencies#1011
MimiRaiSalesforce wants to merge 9 commits into
mainfrom
t/managed-packaging/W-17561980/display-dependency-graph

Conversation

@MimiRaiSalesforce

@MimiRaiSalesforce MimiRaiSalesforce commented Jul 23, 2025

Copy link
Copy Markdown
Collaborator

@W-17561980@

Summary

  • Include sf package version displaydependencies command
  • Include --verbose and --edge-direction flags

@MimiRaiSalesforce MimiRaiSalesforce requested a review from a team as a code owner July 23, 2025 16:29

@jshackell-sfdc jshackell-sfdc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my small edits. But the messages look great overall, which is why I also approved.


# examples

- Display the dependency graph for a package version with the specified alias, using your default Dev Hub org, and the default edge-direction:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Display the dependency graph for a package version with the specified alias, using your default Dev Hub org, and the default edge-direction:
- Display the dependency graph for a package version with the specified alias, using your default Dev Hub org and the default edge-direction:


<%= config.bin %> <%= command.id %> --package package_version_alias

- Display the dependency graph for a package version with the specified ID, display the graph using a root-last edge direction. Use the Dev Hub org with username devhub@example.com:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Display the dependency graph for a package version with the specified ID, display the graph using a root-last edge direction. Use the Dev Hub org with username devhub@example.com:
- Display the dependency graph for a package version with the specified ID and display the graph using a root-last edge direction. Use the Dev Hub org with username devhub@example.com:


<%= config.bin %> <%= command.id %> --package 04t... --edge-direction root-last --target-dev-hub devhub@example.com

- Display the dependency graph of a version create request with the specified ID, using your default Dev Hub org, and the default edge-direction:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Display the dependency graph of a version create request with the specified ID, using your default Dev Hub org, and the default edge-direction:
- Display the dependency graph of a version create request with the specified ID, using your default Dev Hub org and the default edge-direction:


# flags.package.description

Before running this command, update your sfdx-project.json file to specify the calculateTransitiveDependencies attribute, and set the value to true. This command returns GraphViz code, which can be compiled to a graph using DOT code, or another graph visualization software.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Before running this command, update your sfdx-project.json file to specify the calculateTransitiveDependencies attribute, and set the value to true. This command returns GraphViz code, which can be compiled to a graph using DOT code, or another graph visualization software.
Before running this command, update your sfdx-project.json file to specify the calculateTransitiveDependencies attribute, and set the value to true. This command returns GraphViz code, which can be compiled to a graph using DOT code or another graph visualization software.


# flags.edge-direction.description

A root-first graph declares the root as the package that must be installed last. A root-last graph is the reverse order of root-first. If you specify --edge-direction=root-last, the graph displays the packages in the order they must be installed. The root starts with the farthest leaf of the package dependencies, and ends with the base package, which must be installed last.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A root-first graph declares the root as the package that must be installed last. A root-last graph is the reverse order of root-first. If you specify --edge-direction=root-last, the graph displays the packages in the order they must be installed. The root starts with the farthest leaf of the package dependencies, and ends with the base package, which must be installed last.
A root-first graph declares the root as the package that must be installed last. A root-last graph is the reverse order of root-first. If you specify "--edge-direction root-last", the graph displays the packages in the order they must be installed. The root starts with the farthest leaf of the package dependencies and ends with the base package, which must be installed last.

import { requiredHubFlag } from '../../../utils/hubFlag.js';
import { maybeGetProject } from '../../../utils/getProject.js';

// Import i18n messages

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this comment is strictly necessary

expect(result).to.contain('strict digraph G {');
const hasValidNode = result.includes('node_');
expect(hasValidNode).to.be.true;
expect(result).to.match(/label="[^"]*@\d\.\d\.\d\.\d"/);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using regex like this, I recommend making these well-named string constants to help document what you're looking for. In this case, it's looking like the version number, so maybe VERSION_NUMBER_REGEX as a name.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the following new constants NODE_LABEL_REGEX = /label="[^"]*@\d+\.\d+\.\d+\.\d+"/ and EDGE_REGEX = /\t node_\w+ -> node_\w+/g

const resultRootLast = execCmd(commandRootLast, { ensureExitCode: 0 }).shellOutput.stdout;
expect(resultRootFirst).to.contain('strict digraph G {');
expect(resultRootLast).to.contain('strict digraph G {');
const hasMultipleNodes = ((resultRootFirst.match(/node_/g) && resultRootLast.match(/node_/g)) || []).length > 1;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why the || [] is needed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the empty array to find the length if the results return null.

g bransch 'main' of https://github.com/salesforcecli/plugin-packaging into t/managed-packaging/W-17561980/display-dependency-graph
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
 into t/managed-packaging/W-17561980/display-dependency-graph
@MimiRaiSalesforce MimiRaiSalesforce deleted the t/managed-packaging/W-17561980/display-dependency-graph branch July 29, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants