-
Notifications
You must be signed in to change notification settings - Fork 12
W-17561980 CLI Command to Display Dependencies #1011
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
Closed
MimiRaiSalesforce
wants to merge
9
commits into
main
from
t/managed-packaging/W-17561980/display-dependency-graph
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2da5ad1
feat: implement display dependencies CLI command
MimiRaiSalesforce 1fa2e94
feat: added in displaydependencies cli command
MimiRaiSalesforce c8d1bf5
feat: display dependencies
MimiRaiSalesforce a7661fb
feat: updated messages for displaydependencies command
MimiRaiSalesforce 6e1fde3
feat: updated comments and created constant variables for regex
MimiRaiSalesforce 141d65f
"Merging to update branch"
MimiRaiSalesforce fd88741
Merge branch 'main' of https://github.com/salesforcecli/plugin-packag…
MimiRaiSalesforce 6d09006
feat: merged from main
MimiRaiSalesforce 4095c18
feat: updated snapshot
MimiRaiSalesforce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # summary | ||
|
|
||
| Display the dependency graph for an unlocked or 2GP managed package version. | ||
|
|
||
| # examples | ||
|
|
||
| - 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 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: | ||
|
|
||
| <%= config.bin %> <%= command.id %> --package 08c... | ||
|
|
||
| # flags.package.summary | ||
|
|
||
| ID or alias of the package version (starts with 04t) or the package version create request (starts with 08c) to display the dependency graph for. | ||
|
|
||
| # 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. | ||
|
|
||
| # flags.edge-direction.summary | ||
|
|
||
| Order (root-first or root-last) in which the dependencies are displayed. | ||
|
|
||
| # 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. | ||
|
|
||
| # flags.verbose.summary | ||
|
|
||
| Display both the package version ID (starts with 04t) and the version number (major.minor.patch.build) in each node. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "$ref": "#/definitions/DisplayDependenciesCommandResult", | ||
| "definitions": { | ||
| "DisplayDependenciesCommandResult": { | ||
| "anyOf": [ | ||
| { | ||
| "type": "string" | ||
| }, | ||
| { | ||
| "type": "null" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| /* | ||
| * Copyright (c) 2022, salesforce.com, inc. | ||
| * All rights reserved. | ||
| * Licensed under the BSD 3-Clause license. | ||
| * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
| */ | ||
| import { Flags, loglevel, orgApiVersionFlagWithDeprecations, SfCommand } from '@salesforce/sf-plugins-core'; | ||
| import { Messages } from '@salesforce/core/messages'; | ||
| import { Package } from '@salesforce/packaging'; | ||
| import { requiredHubFlag } from '../../../utils/hubFlag.js'; | ||
| import { maybeGetProject } from '../../../utils/getProject.js'; | ||
|
|
||
| Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); | ||
| const messages = Messages.loadMessages('@salesforce/plugin-packaging', 'package_version_displaydependencies'); | ||
| export type DisplayDependenciesCommandResult = string | void; | ||
|
|
||
| export class PackageVersionDisplayDependenciesCommand extends SfCommand<DisplayDependenciesCommandResult> { | ||
| public static readonly summary = messages.getMessage('summary'); | ||
| public static readonly examples = messages.getMessages('examples'); | ||
| public static readonly deprecateAliases = true; | ||
|
|
||
| public static readonly flags = { | ||
| loglevel, | ||
| 'target-dev-hub': requiredHubFlag, | ||
| 'api-version': orgApiVersionFlagWithDeprecations, | ||
| package: Flags.string({ | ||
| char: 'p', | ||
| summary: messages.getMessage('flags.package.summary'), | ||
| description: messages.getMessage('flags.package.description'), | ||
| required: true, | ||
| }), | ||
| 'edge-direction': Flags.custom<'root-first' | 'root-last'>({ | ||
| options: ['root-first', 'root-last'], | ||
| })({ | ||
| summary: messages.getMessage('flags.edge-direction.summary'), | ||
| description: messages.getMessage('flags.edge-direction.description'), | ||
| default: 'root-first', | ||
| }), | ||
| verbose: Flags.boolean({ | ||
| summary: messages.getMessage('flags.verbose.summary'), | ||
| default: false, | ||
| }), | ||
| }; | ||
|
|
||
| public async run(): Promise<DisplayDependenciesCommandResult> { | ||
| const { flags } = await this.parse(PackageVersionDisplayDependenciesCommand); | ||
| const packageDependencyGraph = await Package.getDependencyGraph( | ||
| flags.package, | ||
| await maybeGetProject(), | ||
| flags['target-dev-hub'].getConnection(flags['api-version']), | ||
| { | ||
| verbose: flags['verbose'], | ||
| edgeDirection: flags['edge-direction'], | ||
| } | ||
| ); | ||
|
|
||
| const dotProducer = await packageDependencyGraph.getDependencyDotProducer(); | ||
| const dotCodeResult = dotProducer.produce(); | ||
|
|
||
| if (flags.json) { | ||
| return dotCodeResult; | ||
| } | ||
| this.log(dotCodeResult); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.