Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions messages/package_version_dependency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# invalidPackageVersionIdError

Can't display package dependencies. The package version ID %s you specified is invalid. Review the package version ID and then retry this command.

# transitiveDependenciesRequiredError

Can't display package dependencies. To display package dependencies, you must first add the calculateTransitiveDependencies parameter to the sfdx-project.json file, and set the value to "true". Next, create a new package version and then run this command using the 04t ID for the new package version.

# invalidDependencyGraphError
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We originally decided on using this error message if the DependencyGraphJson field was null from the Package2VersionCreateRequest table. However, I decided to make this error more general to also occur if values in the json are invalid (ex. cannot find a 04t listed in the JSON and therefore cannot query correct package name, version, etc. information)


Can't display package dependencies. There's an issue generating the dependency graph. Before retrying this command, make sure you added the calculateTransitiveDependencies parameter to the sfdx-project.json file and set the value to "true". After setting the attribute and before retrying this command, you must create a new package version.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
],
"dependencies": {
"@jsforce/jsforce-node": "^3.6.5",
"@salesforce/core": "^8.15.0",
"@salesforce/core": "^8.18.5",
"@salesforce/kit": "^3.2.3",
"@salesforce/schemas": "^1.9.1",
"@salesforce/source-deploy-retrieve": "^12.16.9",
Expand Down
26 changes: 26 additions & 0 deletions src/interfaces/packagingInterfacesAndType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ConvertResult } from '@salesforce/source-deploy-retrieve';
import type { Package } from '@salesforce/types/metadata';
import { PackageProfileApi } from '../package/packageProfileApi';
import { PackageAncestryNode } from '../package/packageAncestry';
import { VersionNumber } from '../package/versionNumber';
import { PackagingSObjects } from './packagingSObjects';
import Package2VersionStatus = PackagingSObjects.Package2VersionStatus;
import PackageInstallRequest = PackagingSObjects.PackageInstallRequest;
Expand Down Expand Up @@ -500,6 +501,31 @@ export type AncestryRepresentationProducer = {
produce(): PackageAncestryNodeData | string | void;
};

export type PackageVersionDependencyOptions = {
packageVersionId: string;
project?: SfProject;
connection: Connection;
verbose?: boolean;
edgeDirection?: 'root-first' | 'root-last';
};

export type DependencyGraphData = {
creator: string;
nodes: DependencyGraphNode[];
edges: DependencyGraphEdge[];
};

export type DependencyGraphNode = {
subscriberPackageVersionId: string;
packageName: string;
version: VersionNumber;
};

export type DependencyGraphEdge = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I decided to store the string SubscriberPackageVersionIds (04t...) into the DependencyGraphEdge instead of DependencyGraphNodes because writing the dot code for the edges only requires the 04t... in order to match to the id of a node in the dot code (node_04t...).

source: string;
target: string;
};

export const PackageEvents = {
convert: {
success: 'Package/convert-success',
Expand Down
24 changes: 24 additions & 0 deletions src/package/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { retrievePackageVersionMetadata } from './packageVersionRetrieve';
import { listPackageVersions } from './packageVersionList';
import { deletePackage } from './packageDelete';
import { PackageAncestry } from './packageAncestry';
import { PackageVersionDependency } from './packageVersionDependency';

const packagePrefixes = {
PackageId: '0Ho',
Expand Down Expand Up @@ -177,6 +178,29 @@ export class Package {
});
}

/**
* create a PackageVersionDependency instance
*
* @param packageVersionId to get version information for
* @param project SfProject instance
* @param connection Hub Org Connection
* @param options flags for the command line
*/
public static async getDependencyGraph(
packageVersionId: string,
project: SfProject | undefined,
connection: Connection,
options?: { verbose?: boolean; edgeDirection?: 'root-first' | 'root-last' }
): Promise<PackageVersionDependency> {
return PackageVersionDependency.create({
packageVersionId,
project,
connection,
verbose: options?.verbose ?? false,
edgeDirection: options?.edgeDirection ?? 'root-first',
});
}

/**
* Convert a 1st generation package to a 2nd generation package.
* See {@link ConvertPackageOptions} for conversion options.
Expand Down
Loading
Loading