@salesforce/packaging 4.13.1 → 4.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,13 +10,16 @@ export declare class PackageVersionDependency extends AsyncCreatable<PackageVers
|
|
|
10
10
|
private userPackageVersionId;
|
|
11
11
|
private verbose;
|
|
12
12
|
private edgeDirection;
|
|
13
|
-
private
|
|
13
|
+
private resolvedPackageVersionCreateRequestId;
|
|
14
|
+
private allPackageVersionId;
|
|
14
15
|
constructor(options: PackageVersionDependencyOptions);
|
|
15
16
|
init(): Promise<void>;
|
|
16
17
|
/**
|
|
17
18
|
* Returns a DependencyDotProducer that can be used to produce a DOT code representation of the package dependency graph.
|
|
18
19
|
*/
|
|
19
20
|
getDependencyDotProducer(): Promise<DependencyDotProducer>;
|
|
21
|
+
private getTransitiveDependencyGraph;
|
|
22
|
+
private createFlatDependencyGraph;
|
|
20
23
|
/**
|
|
21
24
|
* Resolves id input to a 08c. User can input a 08c or 04t.
|
|
22
25
|
* Currently a 04t is not supported in filtering the Package2VersionCreateRequest. So a user's input of 04t will be resolved to a 05i and then a 08c.
|
|
@@ -24,12 +27,9 @@ export declare class PackageVersionDependency extends AsyncCreatable<PackageVers
|
|
|
24
27
|
private resolvePackageCreateRequestId;
|
|
25
28
|
private query05iFrom04t;
|
|
26
29
|
private query08cFrom05i;
|
|
27
|
-
|
|
28
|
-
* Checks that the given Package2VersionCreateRequest ID (08c) contains a valid DependencyGraphJson to generate DOT code
|
|
29
|
-
*/
|
|
30
|
-
private validatePackageVersion;
|
|
30
|
+
private isValidPackageVersion;
|
|
31
31
|
private verifyCreateRequesIdExistsOnDevHub;
|
|
32
|
-
private
|
|
32
|
+
private isTransitiveDependenciesCalculated;
|
|
33
33
|
}
|
|
34
34
|
export declare class DependencyDotProducer {
|
|
35
35
|
private dependencyGraphString;
|
|
@@ -31,7 +31,8 @@ class PackageVersionDependency extends kit_1.AsyncCreatable {
|
|
|
31
31
|
userPackageVersionId;
|
|
32
32
|
verbose;
|
|
33
33
|
edgeDirection;
|
|
34
|
-
|
|
34
|
+
resolvedPackageVersionCreateRequestId;
|
|
35
|
+
allPackageVersionId;
|
|
35
36
|
constructor(options) {
|
|
36
37
|
super(options);
|
|
37
38
|
this.options = options;
|
|
@@ -40,7 +41,8 @@ class PackageVersionDependency extends kit_1.AsyncCreatable {
|
|
|
40
41
|
this.userPackageVersionId = options.packageVersionId;
|
|
41
42
|
this.verbose = options.verbose ?? false;
|
|
42
43
|
this.edgeDirection = options.edgeDirection ?? 'root-first';
|
|
43
|
-
this.
|
|
44
|
+
this.resolvedPackageVersionCreateRequestId = '';
|
|
45
|
+
this.allPackageVersionId = '';
|
|
44
46
|
}
|
|
45
47
|
async init() {
|
|
46
48
|
await this.resolvePackageCreateRequestId();
|
|
@@ -49,21 +51,51 @@ class PackageVersionDependency extends kit_1.AsyncCreatable {
|
|
|
49
51
|
* Returns a DependencyDotProducer that can be used to produce a DOT code representation of the package dependency graph.
|
|
50
52
|
*/
|
|
51
53
|
async getDependencyDotProducer() {
|
|
52
|
-
|
|
53
|
-
if (!isValid) {
|
|
54
|
+
if (!this.isValidPackageVersion()) {
|
|
54
55
|
throw messages.createError('invalidPackageVersionIdError', [this.userPackageVersionId]);
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
let dependencyGraphJson;
|
|
58
|
+
if (await this.isTransitiveDependenciesCalculated()) {
|
|
59
|
+
dependencyGraphJson = await this.getTransitiveDependencyGraph();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
dependencyGraphJson = await this.createFlatDependencyGraph();
|
|
62
63
|
}
|
|
63
|
-
const producer = new DependencyDotProducer(this.connection, dependencyGraphJson, this.verbose, this.edgeDirection, this.
|
|
64
|
+
const producer = new DependencyDotProducer(this.connection, dependencyGraphJson, this.verbose, this.edgeDirection, this.resolvedPackageVersionCreateRequestId);
|
|
64
65
|
await producer.init();
|
|
65
66
|
return producer;
|
|
66
67
|
}
|
|
68
|
+
async getTransitiveDependencyGraph() {
|
|
69
|
+
const query = `${SELECT_PACKAGE_VERSION_DEPENDENCY} WHERE Id = '${this.resolvedPackageVersionCreateRequestId}'`;
|
|
70
|
+
const result = await this.connection.tooling.query(query);
|
|
71
|
+
if (result.records[0].DependencyGraphJson == null) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
return result.records[0].DependencyGraphJson;
|
|
75
|
+
}
|
|
76
|
+
async createFlatDependencyGraph() {
|
|
77
|
+
if (!this.allPackageVersionId) {
|
|
78
|
+
throw messages.createError('noDependencyGraphJsonMustProvideVersion');
|
|
79
|
+
}
|
|
80
|
+
const query = `SELECT Dependencies FROM SubscriberPackageVersion WHERE Id = '${this.allPackageVersionId}'`;
|
|
81
|
+
const result = await this.connection.tooling.query(query);
|
|
82
|
+
if (result?.records?.length !== 1) {
|
|
83
|
+
throw messages.createError('invalidPackageVersionIdError', [this.userPackageVersionId]);
|
|
84
|
+
}
|
|
85
|
+
const flatDependencyGraph = {
|
|
86
|
+
nodes: [],
|
|
87
|
+
edges: [],
|
|
88
|
+
};
|
|
89
|
+
flatDependencyGraph.nodes.push({ id: this.allPackageVersionId });
|
|
90
|
+
result.records[0].Dependencies?.ids.forEach((dependency) => {
|
|
91
|
+
flatDependencyGraph.nodes.push({ id: dependency.subscriberPackageVersionId });
|
|
92
|
+
flatDependencyGraph.edges.push({
|
|
93
|
+
source: dependency.subscriberPackageVersionId,
|
|
94
|
+
target: this.allPackageVersionId,
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
return JSON.stringify(flatDependencyGraph);
|
|
98
|
+
}
|
|
67
99
|
/**
|
|
68
100
|
* Resolves id input to a 08c. User can input a 08c or 04t.
|
|
69
101
|
* Currently a 04t is not supported in filtering the Package2VersionCreateRequest. So a user's input of 04t will be resolved to a 05i and then a 08c.
|
|
@@ -72,12 +104,14 @@ class PackageVersionDependency extends kit_1.AsyncCreatable {
|
|
|
72
104
|
const versionId = this.project?.getPackageIdFromAlias(this.userPackageVersionId) ?? this.userPackageVersionId;
|
|
73
105
|
// User provided a Package2VersionCreateRequest ID (08c) and doesn't need to be resolved
|
|
74
106
|
if (versionId.startsWith('08c')) {
|
|
75
|
-
this.
|
|
107
|
+
this.resolvedPackageVersionCreateRequestId = versionId;
|
|
76
108
|
}
|
|
77
|
-
// User provided a SubscriberPackageVersionId (04t) and needs to be resolved to a Package2VersionCreateRequest ID (08c)
|
|
78
109
|
else if (versionId.startsWith('04t')) {
|
|
110
|
+
// User provided a SubscriberPackageVersionId (04t) and needs to be resolved to a Package2VersionCreateRequest ID (08c)
|
|
111
|
+
this.allPackageVersionId = versionId;
|
|
112
|
+
// TODO: Make this one query when W-18944974 is fixed.
|
|
79
113
|
const package2VersionId = await this.query05iFrom04t(versionId);
|
|
80
|
-
this.
|
|
114
|
+
this.resolvedPackageVersionCreateRequestId = await this.query08cFrom05i(package2VersionId);
|
|
81
115
|
}
|
|
82
116
|
else {
|
|
83
117
|
throw messages.createError('invalidPackageVersionIdError', [this.userPackageVersionId]);
|
|
@@ -99,29 +133,23 @@ class PackageVersionDependency extends kit_1.AsyncCreatable {
|
|
|
99
133
|
}
|
|
100
134
|
return result08c.records[0].Id;
|
|
101
135
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*/
|
|
105
|
-
async validatePackageVersion() {
|
|
106
|
-
if (!this.resolvedPackageVersionId) {
|
|
136
|
+
isValidPackageVersion() {
|
|
137
|
+
if (!this.resolvedPackageVersionCreateRequestId && !this.allPackageVersionId) {
|
|
107
138
|
throw messages.createError('invalidPackageVersionIdError', [this.userPackageVersionId]);
|
|
108
139
|
}
|
|
109
|
-
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
return false;
|
|
140
|
+
return true;
|
|
113
141
|
}
|
|
114
142
|
async verifyCreateRequesIdExistsOnDevHub() {
|
|
115
|
-
const query = `${SELECT_PACKAGE_VERSION_DEPENDENCY} WHERE Id = '${this.
|
|
143
|
+
const query = `${SELECT_PACKAGE_VERSION_DEPENDENCY} WHERE Id = '${this.resolvedPackageVersionCreateRequestId}'`;
|
|
116
144
|
const result = await this.connection.tooling.query(query);
|
|
117
145
|
if (result.records?.length === 0) {
|
|
118
146
|
throw messages.createError('invalidPackageVersionIdError', [this.userPackageVersionId]);
|
|
119
147
|
}
|
|
120
148
|
return true;
|
|
121
149
|
}
|
|
122
|
-
async
|
|
150
|
+
async isTransitiveDependenciesCalculated() {
|
|
123
151
|
if (await this.verifyCreateRequesIdExistsOnDevHub()) {
|
|
124
|
-
const query = `${SELECT_PACKAGE_VERSION_DEPENDENCY} WHERE Id = '${this.
|
|
152
|
+
const query = `${SELECT_PACKAGE_VERSION_DEPENDENCY} WHERE Id = '${this.resolvedPackageVersionCreateRequestId}'`;
|
|
125
153
|
const result = await this.connection.tooling.query(query);
|
|
126
154
|
if (result.records?.length === 1) {
|
|
127
155
|
const record = result.records[0];
|
|
@@ -133,9 +161,6 @@ class PackageVersionDependency extends kit_1.AsyncCreatable {
|
|
|
133
161
|
throw messages.createError('invalidDependencyGraphError');
|
|
134
162
|
}
|
|
135
163
|
}
|
|
136
|
-
else {
|
|
137
|
-
throw messages.createError('transitiveDependenciesRequiredError');
|
|
138
|
-
}
|
|
139
164
|
}
|
|
140
165
|
}
|
|
141
166
|
return false;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Can't display package dependencies. The package version ID %s you specified is invalid. Review the package version ID and then retry this command.
|
|
4
4
|
|
|
5
|
-
# transitiveDependenciesRequiredError
|
|
6
|
-
|
|
7
|
-
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.
|
|
8
|
-
|
|
9
5
|
# invalidDependencyGraphError
|
|
10
6
|
|
|
11
7
|
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.
|
|
8
|
+
|
|
9
|
+
# noDependencyGraphJsonMustProvideVersion
|
|
10
|
+
|
|
11
|
+
Can't display package dependencies. This Package2VersionCreateRequest does not have CalcTransitiveDependencies set to true. To display package dependencies, either specify a package version id (starts with 04t or 05i) or create a new package version with the calculateTransitiveDependencies parameter in the sfdx-project.json file to "true".
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/packaging",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.14.1",
|
|
4
4
|
"description": "Packaging library for the Salesforce packaging platform",
|
|
5
5
|
"main": "lib/exported",
|
|
6
6
|
"types": "lib/exported.d.ts",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"@types/globby": "^9.1.0",
|
|
64
64
|
"@types/jszip": "^3.4.1",
|
|
65
65
|
"eslint-plugin-sf-plugin": "^1.20.8",
|
|
66
|
-
"shelljs": "0.8.5",
|
|
67
66
|
"ts-node": "^10.9.2",
|
|
68
67
|
"typescript": "^5.5.4"
|
|
69
68
|
},
|