W-17561980 CLI Command to Display Dependencies#1011
Conversation
jshackell-sfdc
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
| - 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: |
There was a problem hiding this comment.
| - 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: |
There was a problem hiding this comment.
| - 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. |
There was a problem hiding this comment.
| 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. |
There was a problem hiding this comment.
| 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 |
There was a problem hiding this comment.
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"/); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
I don't understand why the || [] is needed?
There was a problem hiding this comment.
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.
@W-17561980@
Summary
sf package version displaydependenciescommand--verboseand--edge-directionflags