@salesforce/packaging 1.4.15 → 1.4.17
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.
- package/lib/interfaces/packagingInterfacesAndType.d.ts +37 -33
- package/lib/package/package.d.ts +3 -3
- package/lib/package/package.js +14 -8
- package/lib/package/packageAncestry.d.ts +24 -25
- package/lib/package/packageAncestry.js +159 -147
- package/lib/package/packageConvert.d.ts +1 -1
- package/lib/package/packageConvert.js +15 -21
- package/lib/package/packageCreate.d.ts +1 -1
- package/lib/package/packageCreate.js +14 -25
- package/lib/package/packageDelete.js +4 -1
- package/lib/package/packageInstall.d.ts +5 -4
- package/lib/package/packageInstall.js +10 -9
- package/lib/package/packageProfileApi.d.ts +3 -6
- package/lib/package/packageProfileApi.js +153 -145
- package/lib/package/packageUninstall.js +15 -9
- package/lib/package/packageVersion.d.ts +6 -5
- package/lib/package/packageVersion.js +76 -46
- package/lib/package/packageVersionCreate.d.ts +2 -2
- package/lib/package/packageVersionCreate.js +81 -59
- package/lib/package/packageVersionCreateRequest.d.ts +2 -2
- package/lib/package/packageVersionCreateRequest.js +8 -11
- package/lib/package/packageVersionCreateRequestReport.js +4 -1
- package/lib/package/packageVersionList.d.ts +5 -4
- package/lib/package/packageVersionList.js +18 -18
- package/lib/package/packageVersionReport.js +6 -4
- package/lib/package/subscriberPackageVersion.d.ts +4 -4
- package/lib/package/subscriberPackageVersion.js +23 -10
- package/lib/package/versionNumber.d.ts +8 -3
- package/lib/package/versionNumber.js +13 -4
- package/lib/package1/package1Version.js +18 -13
- package/lib/utils/packageUtils.d.ts +11 -7
- package/lib/utils/packageUtils.js +26 -15
- package/messages/package.md +4 -0
- package/messages/package1Version.md +4 -0
- package/messages/package_version.md +8 -0
- package/messages/package_version_create.md +32 -4
- package/messages/pkg_utils.md +1 -1
- package/package.json +15 -14
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
8
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
11
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
|
-
};
|
|
13
|
-
var _PackageAncestry_requestedPackageId, _PackageAncestryNode_version, _PackageAncestryNode_MajorVersion, _PackageAncestryNode_MinorVersion, _PackageAncestryNode_PatchVersion, _PackageAncestryNode_BuildNumber, _PackageAncestryNode_AncestorId, _PackageAncestryNode_SubscriberPackageVersionId, _PackageAncestryNode_depthCounter;
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.PackageAncestryNode = exports.AncestryDotProducer = exports.AncestryJsonProducer = exports.AncestryTreeProducer = exports.PackageAncestry = void 0;
|
|
16
4
|
/*
|
|
@@ -35,9 +23,21 @@ const SELECT_PACKAGE_VERSION = 'SELECT AncestorId, SubscriberPackageVersionId, M
|
|
|
35
23
|
// Add this to query calls to only show released package versions in the output
|
|
36
24
|
const releasedOnlyFilter = ' AND IsReleased = true';
|
|
37
25
|
const sortAncestryNodeData = (a, b) => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
if (!a.options || !b.options) {
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
if (!a.options.packageNode && b.options.packageNode) {
|
|
30
|
+
return -1;
|
|
31
|
+
}
|
|
32
|
+
if (a.options.packageNode && !b.options.packageNode) {
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
if (a.options.packageNode && b.options.packageNode) {
|
|
36
|
+
const aVersion = new versionNumber_1.VersionNumber(a.options.packageNode.MajorVersion, a.options.packageNode.MinorVersion, a.options.packageNode.PatchVersion, a.options.packageNode.BuildNumber);
|
|
37
|
+
const bVersion = new versionNumber_1.VersionNumber(b.options.packageNode.MajorVersion, b.options.packageNode.MinorVersion, b.options.packageNode.PatchVersion, b.options.packageNode.BuildNumber);
|
|
38
|
+
return aVersion.compareTo(bVersion);
|
|
39
|
+
}
|
|
40
|
+
return 0;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* A class that represents the package ancestry graph.
|
|
@@ -47,11 +47,24 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
47
47
|
constructor(options) {
|
|
48
48
|
super(options);
|
|
49
49
|
this.options = options;
|
|
50
|
-
|
|
50
|
+
this.roots = [];
|
|
51
51
|
this.graph = new graphology_1.DirectedGraph();
|
|
52
|
+
this.packageId = options.packageId;
|
|
52
53
|
}
|
|
53
54
|
get requestedPackageId() {
|
|
54
|
-
return
|
|
55
|
+
return this.packageId;
|
|
56
|
+
}
|
|
57
|
+
static createAttributes(node) {
|
|
58
|
+
return {
|
|
59
|
+
AncestorId: node.AncestorId,
|
|
60
|
+
BuildNumber: node.BuildNumber,
|
|
61
|
+
MajorVersion: node.MajorVersion,
|
|
62
|
+
MinorVersion: node.MinorVersion,
|
|
63
|
+
PatchVersion: node.PatchVersion,
|
|
64
|
+
SubscriberPackageVersionId: node.SubscriberPackageVersionId,
|
|
65
|
+
depthCounter: node.depthCounter,
|
|
66
|
+
node,
|
|
67
|
+
};
|
|
55
68
|
}
|
|
56
69
|
async init() {
|
|
57
70
|
await this.buildAncestryTree();
|
|
@@ -72,7 +85,7 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
72
85
|
* Convenience method to get the CliUx.Tree representation of the package ancestry graph.
|
|
73
86
|
*/
|
|
74
87
|
getTreeProducer(verbose) {
|
|
75
|
-
return this.getRepresentationProducer((opts) => new AncestryTreeProducer({ ...opts, verbose
|
|
88
|
+
return this.getRepresentationProducer((opts) => new AncestryTreeProducer({ ...opts, verbose }), this.requestedPackageId);
|
|
76
89
|
}
|
|
77
90
|
/**
|
|
78
91
|
* Convenience method to get the dot representation of the package ancestry graph.
|
|
@@ -84,13 +97,14 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
84
97
|
* Returns the producer representation of the package ancestry graph.
|
|
85
98
|
*
|
|
86
99
|
* @param producerCtor - function that returns a new instance of the producer
|
|
87
|
-
* @param
|
|
100
|
+
* @param rootPackageId - the subscriber package version id of the root node
|
|
88
101
|
*/
|
|
89
|
-
getRepresentationProducer(producerCtor,
|
|
90
|
-
const
|
|
91
|
-
? this.graph.findNode((node, attributes) => attributes.
|
|
102
|
+
getRepresentationProducer(producerCtor, rootPackageId) {
|
|
103
|
+
const treeRootKey = rootPackageId
|
|
104
|
+
? this.graph.findNode((node, attributes) => attributes.SubscriberPackageVersionId === rootPackageId)
|
|
92
105
|
: undefined;
|
|
93
|
-
const
|
|
106
|
+
const treeRoot = treeRootKey ? this.graph.getNodeAttributes(treeRootKey).node : undefined;
|
|
107
|
+
const tree = producerCtor({ packageNode: treeRoot, depth: 0 });
|
|
94
108
|
const treeStack = [];
|
|
95
109
|
function handleNode(node, attr, depth) {
|
|
96
110
|
if (treeStack.length > depth) {
|
|
@@ -98,7 +112,7 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
98
112
|
}
|
|
99
113
|
let t = treeStack[depth];
|
|
100
114
|
if (!t) {
|
|
101
|
-
t = producerCtor({
|
|
115
|
+
t = producerCtor({ packageNode: attr.node, depth });
|
|
102
116
|
treeStack.push(t);
|
|
103
117
|
}
|
|
104
118
|
if (depth === 0) {
|
|
@@ -109,7 +123,7 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
109
123
|
}
|
|
110
124
|
}
|
|
111
125
|
if (treeRoot) {
|
|
112
|
-
(0, graphology_traversal_1.dfsFromNode)(this.graph, treeRoot, handleNode);
|
|
126
|
+
(0, graphology_traversal_1.dfsFromNode)(this.graph, treeRoot.getVersion(), handleNode);
|
|
113
127
|
}
|
|
114
128
|
else {
|
|
115
129
|
(0, graphology_traversal_1.dfs)(this.graph, handleNode);
|
|
@@ -123,7 +137,7 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
123
137
|
* @param subscriberPackageVersionId
|
|
124
138
|
*/
|
|
125
139
|
getLeafPathToRoot(subscriberPackageVersionId) {
|
|
126
|
-
const root = this.graph.findNode((node, attributes) => attributes.
|
|
140
|
+
const root = this.graph.findNode((node, attributes) => attributes.AncestorId === null);
|
|
127
141
|
const paths = [];
|
|
128
142
|
let path = [];
|
|
129
143
|
let previousDepth = 0;
|
|
@@ -141,28 +155,24 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
141
155
|
});
|
|
142
156
|
// push remaining path
|
|
143
157
|
paths.push(path);
|
|
144
|
-
|
|
145
|
-
.filter(
|
|
146
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
147
|
-
(path) => path.length > 0 && // don't care about zero length paths
|
|
158
|
+
const filteredPaths = paths.filter((nodePath) => nodePath.length > 0 && // don't care about zero length paths
|
|
148
159
|
(!subscriberPackageVersionId ||
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
.map((
|
|
152
|
-
|
|
153
|
-
.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}));
|
|
160
|
+
nodePath.some((node) => node.SubscriberPackageVersionId === subscriberPackageVersionId)));
|
|
161
|
+
return filteredPaths
|
|
162
|
+
.map((nodePath) => nodePath.reverse())
|
|
163
|
+
.map((nodePath) => {
|
|
164
|
+
const subscriberPackageVersionIdIndex = nodePath.findIndex((node) => node.SubscriberPackageVersionId === subscriberPackageVersionId);
|
|
165
|
+
return nodePath.slice(subscriberPackageVersionIdIndex === -1 ? 0 : subscriberPackageVersionIdIndex);
|
|
166
|
+
});
|
|
157
167
|
}
|
|
158
168
|
async buildAncestryTree() {
|
|
159
|
-
this.roots = await this.
|
|
169
|
+
this.roots = await this.getRootsFromRequestedId();
|
|
160
170
|
await this.buildAncestryTreeFromRoots(this.roots);
|
|
161
171
|
}
|
|
162
|
-
async
|
|
172
|
+
async getRootsFromRequestedId() {
|
|
163
173
|
let roots = [];
|
|
164
|
-
|
|
165
|
-
switch (this.requestedPackageId
|
|
174
|
+
this.packageId = this.options.project.getPackageIdFromAlias(this.options.packageId) ?? this.options.packageId;
|
|
175
|
+
switch (this.requestedPackageId?.slice(0, 3)) {
|
|
166
176
|
case '0Ho':
|
|
167
177
|
pkgUtils.validateId(pkgUtils.BY_LABEL.PACKAGE_ID, this.requestedPackageId);
|
|
168
178
|
roots = await this.findRootsForPackage();
|
|
@@ -192,31 +202,42 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
192
202
|
// Check to see if the package version is part of an unlocked package
|
|
193
203
|
// if so, throw an error since ancestry only applies to managed packages
|
|
194
204
|
let packageType;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
205
|
+
if (this.requestedPackageId) {
|
|
206
|
+
const prefix = this.requestedPackageId?.slice(0, 3);
|
|
207
|
+
switch (prefix) {
|
|
208
|
+
case '04t':
|
|
209
|
+
// eslint-disable-next-line no-case-declarations
|
|
210
|
+
const packageVersion = new packageVersion_1.PackageVersion({
|
|
211
|
+
idOrAlias: this.requestedPackageId,
|
|
212
|
+
project: this.options.project,
|
|
213
|
+
connection: this.options.connection,
|
|
214
|
+
});
|
|
215
|
+
packageType = await packageVersion.getPackageType();
|
|
216
|
+
break;
|
|
217
|
+
case '0Ho':
|
|
218
|
+
// eslint-disable-next-line no-case-declarations
|
|
219
|
+
const pkg = new package_1.Package({
|
|
220
|
+
packageAliasOrId: this.requestedPackageId,
|
|
221
|
+
project: this.options.project,
|
|
222
|
+
connection: this.options.connection,
|
|
223
|
+
});
|
|
224
|
+
packageType = await pkg.getType();
|
|
225
|
+
break;
|
|
226
|
+
default:
|
|
227
|
+
throw new Error(`Not implemented yet: ${prefix} case`);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
throw new Error('Not implemented yet: undefined case');
|
|
214
232
|
}
|
|
215
233
|
if (packageType !== 'Managed') {
|
|
216
234
|
throw messages.createError('unlockedPackageError');
|
|
217
235
|
}
|
|
218
236
|
}
|
|
219
237
|
async getPackageVersion(nodeId) {
|
|
238
|
+
if (!nodeId) {
|
|
239
|
+
throw new Error('nodeId is undefined');
|
|
240
|
+
}
|
|
220
241
|
const query = `${SELECT_PACKAGE_VERSION} WHERE SubscriberPackageVersionId = '${nodeId}'`;
|
|
221
242
|
try {
|
|
222
243
|
const results = await this.options.connection.singleRecordQuery(query, {
|
|
@@ -224,11 +245,11 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
224
245
|
});
|
|
225
246
|
return new PackageAncestryNode(results);
|
|
226
247
|
}
|
|
227
|
-
catch (
|
|
228
|
-
if (
|
|
248
|
+
catch (err) {
|
|
249
|
+
if (err instanceof Error && err.message.includes('No record found for')) {
|
|
229
250
|
throw messages.createError('versionNotFound', [nodeId]);
|
|
230
251
|
}
|
|
231
|
-
throw
|
|
252
|
+
throw err;
|
|
232
253
|
}
|
|
233
254
|
}
|
|
234
255
|
async findRootsForPackage() {
|
|
@@ -247,8 +268,11 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
247
268
|
while (roots.length > 0) {
|
|
248
269
|
const subscriberPackageVersion = roots.shift();
|
|
249
270
|
// eslint-disable-next-line no-await-in-loop
|
|
250
|
-
|
|
251
|
-
|
|
271
|
+
if (subscriberPackageVersion) {
|
|
272
|
+
// eslint-disable-next-line no-await-in-loop
|
|
273
|
+
const descendants = await this.addDescendantsFromPackageVersion(subscriberPackageVersion);
|
|
274
|
+
roots.push(...descendants);
|
|
275
|
+
}
|
|
252
276
|
}
|
|
253
277
|
}
|
|
254
278
|
async addDescendantsFromPackageVersion(subscriberPackageVersion) {
|
|
@@ -258,10 +282,10 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
258
282
|
}
|
|
259
283
|
addToGraph(ancestor, descendant) {
|
|
260
284
|
if (!this.graph.hasNode(ancestor.getVersion())) {
|
|
261
|
-
this.graph.addNode(ancestor.getVersion(),
|
|
285
|
+
this.graph.addNode(ancestor.getVersion(), PackageAncestry.createAttributes(ancestor));
|
|
262
286
|
}
|
|
263
287
|
if (!this.graph.hasNode(descendant.getVersion())) {
|
|
264
|
-
this.graph.addNode(descendant.getVersion(),
|
|
288
|
+
this.graph.addNode(descendant.getVersion(), PackageAncestry.createAttributes(descendant));
|
|
265
289
|
}
|
|
266
290
|
if (!this.graph.hasEdge(ancestor.getVersion(), descendant.getVersion())) {
|
|
267
291
|
this.graph.addDirectedEdgeWithKey(`${ancestor.getVersion()}->${descendant.getVersion()}`, ancestor.getVersion(), descendant.getVersion(), {
|
|
@@ -277,37 +301,45 @@ class PackageAncestry extends kit_1.AsyncCreatable {
|
|
|
277
301
|
}
|
|
278
302
|
}
|
|
279
303
|
exports.PackageAncestry = PackageAncestry;
|
|
280
|
-
_PackageAncestry_requestedPackageId = new WeakMap();
|
|
281
304
|
class AncestryTreeProducer extends tree_1.Tree {
|
|
282
305
|
constructor(options) {
|
|
283
306
|
super();
|
|
284
|
-
this.verbose = false;
|
|
285
307
|
this.options = options;
|
|
286
|
-
this.label = this.options?.
|
|
287
|
-
this.verbose = this.options?.verbose
|
|
308
|
+
this.label = this.options?.packageNode?.getVersion() ?? 'root';
|
|
309
|
+
this.verbose = this.options?.verbose ?? false;
|
|
288
310
|
}
|
|
289
311
|
addNode(node) {
|
|
290
312
|
const label = this.createLabel(node);
|
|
291
313
|
this.insert(label, node);
|
|
292
314
|
}
|
|
293
315
|
produce() {
|
|
316
|
+
const sortAncestors = (a, b) => {
|
|
317
|
+
if (a.options?.packageNode?.version && b.options?.packageNode?.version) {
|
|
318
|
+
return a.options?.packageNode.version?.compareTo(b.options?.packageNode.version);
|
|
319
|
+
}
|
|
320
|
+
return 0;
|
|
321
|
+
};
|
|
294
322
|
const producers = [];
|
|
295
323
|
producers.push(this);
|
|
296
324
|
while (producers.length > 0) {
|
|
297
325
|
const producer = producers.shift();
|
|
298
|
-
|
|
299
|
-
.
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
326
|
+
if (producer) {
|
|
327
|
+
Object.values(producer.nodes ?? {})
|
|
328
|
+
// as AncestryTreeProducer is needed to sort and gain access producer functions. oclif Tree does not support generic for nodes
|
|
329
|
+
.map((node) => node)
|
|
330
|
+
.sort(sortAncestors)
|
|
331
|
+
.forEach((child) => {
|
|
332
|
+
delete producer.nodes[this.createLabel(child)];
|
|
333
|
+
producer.addNode(child);
|
|
334
|
+
producers.push(child);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
305
337
|
}
|
|
306
338
|
this.display(this.options ? this.options['logger'] : undefined);
|
|
307
339
|
}
|
|
308
340
|
createLabel(node) {
|
|
309
|
-
const subscriberId = this.verbose && node?.options?.
|
|
310
|
-
? ` (${node.options.
|
|
341
|
+
const subscriberId = this.verbose && node?.options?.packageNode?.SubscriberPackageVersionId
|
|
342
|
+
? ` (${node.options.packageNode.SubscriberPackageVersionId})`
|
|
311
343
|
: '';
|
|
312
344
|
return node?.label ? `${node.label}${subscriberId}` : 'root';
|
|
313
345
|
}
|
|
@@ -317,16 +349,16 @@ class AncestryJsonProducer {
|
|
|
317
349
|
constructor(options) {
|
|
318
350
|
this.children = [];
|
|
319
351
|
this.options = options;
|
|
320
|
-
this.label = this.options?.
|
|
352
|
+
this.label = this.options?.packageNode?.getVersion() ?? 'root';
|
|
321
353
|
this.data = {
|
|
322
354
|
children: [],
|
|
323
355
|
data: {
|
|
324
|
-
SubscriberPackageVersionId: this.options?.
|
|
325
|
-
MajorVersion: this.options?.
|
|
326
|
-
MinorVersion: this.options?.
|
|
327
|
-
PatchVersion: this.options?.
|
|
328
|
-
BuildNumber: this.options?.
|
|
329
|
-
depthCounter: this.options
|
|
356
|
+
SubscriberPackageVersionId: this.options.packageNode?.SubscriberPackageVersionId ?? 'unknown',
|
|
357
|
+
MajorVersion: this.options.packageNode?.MajorVersion ?? 0,
|
|
358
|
+
MinorVersion: this.options.packageNode?.MinorVersion ?? 0,
|
|
359
|
+
PatchVersion: this.options.packageNode?.PatchVersion ?? 0,
|
|
360
|
+
BuildNumber: this.options.packageNode?.BuildNumber ?? 0,
|
|
361
|
+
depthCounter: this.options.depth,
|
|
330
362
|
},
|
|
331
363
|
};
|
|
332
364
|
}
|
|
@@ -339,8 +371,10 @@ class AncestryJsonProducer {
|
|
|
339
371
|
producers.push(this);
|
|
340
372
|
while (producers.length > 0) {
|
|
341
373
|
const producer = producers.shift();
|
|
342
|
-
producer
|
|
343
|
-
|
|
374
|
+
if (producer) {
|
|
375
|
+
producer.children.sort(sortAncestryNodeData);
|
|
376
|
+
producers.push(...producer.children);
|
|
377
|
+
}
|
|
344
378
|
}
|
|
345
379
|
return this.data.children[0];
|
|
346
380
|
}
|
|
@@ -350,7 +384,7 @@ class AncestryDotProducer {
|
|
|
350
384
|
constructor(options) {
|
|
351
385
|
this.children = [];
|
|
352
386
|
this.options = options;
|
|
353
|
-
this.label = this.options?.
|
|
387
|
+
this.label = this.options?.packageNode?.getVersion() ?? 'root';
|
|
354
388
|
}
|
|
355
389
|
/**
|
|
356
390
|
* Builds a node line in DOT, of the form nodeID [label="MAJOR.MINOR.PATCH"]
|
|
@@ -358,7 +392,8 @@ class AncestryDotProducer {
|
|
|
358
392
|
* @param currentNode
|
|
359
393
|
*/
|
|
360
394
|
static buildDotNode(currentNode) {
|
|
361
|
-
|
|
395
|
+
const subscriberId = currentNode.options?.packageNode?.SubscriberPackageVersionId ?? 'unknown';
|
|
396
|
+
return `\t node${subscriberId} [label="${currentNode.label}"]`;
|
|
362
397
|
}
|
|
363
398
|
/**
|
|
364
399
|
* Builds an edge line in DOT, of the form fromNode -- toNode
|
|
@@ -367,7 +402,9 @@ class AncestryDotProducer {
|
|
|
367
402
|
* @param toNode
|
|
368
403
|
*/
|
|
369
404
|
static buildDotEdge(fromNode, toNode) {
|
|
370
|
-
|
|
405
|
+
const fromSubscriberId = fromNode.options?.packageNode?.SubscriberPackageVersionId ?? 'unknown';
|
|
406
|
+
const toSubscriberId = toNode.options?.packageNode?.SubscriberPackageVersionId ?? 'unknown';
|
|
407
|
+
return `\t node${fromSubscriberId} -- node${toSubscriberId}`;
|
|
371
408
|
}
|
|
372
409
|
addNode(node) {
|
|
373
410
|
this.children.push(node);
|
|
@@ -378,19 +415,23 @@ class AncestryDotProducer {
|
|
|
378
415
|
const dotLines = [];
|
|
379
416
|
while (producers.length > 0) {
|
|
380
417
|
const producer = producers.shift();
|
|
381
|
-
if (producer
|
|
382
|
-
|
|
418
|
+
if (producer) {
|
|
419
|
+
if (producer.options) {
|
|
420
|
+
dotLines.push(AncestryDotProducer.buildDotNode(producer));
|
|
421
|
+
}
|
|
422
|
+
producer?.children.sort(sortAncestryNodeData);
|
|
423
|
+
producers.push(...producer.children);
|
|
383
424
|
}
|
|
384
|
-
producer.children.sort(sortAncestryNodeData);
|
|
385
|
-
producers.push(...producer.children);
|
|
386
425
|
}
|
|
387
426
|
producers.push(this);
|
|
388
427
|
while (producers.length > 0) {
|
|
389
428
|
const producer = producers.shift();
|
|
390
|
-
if (producer
|
|
391
|
-
producer.
|
|
429
|
+
if (producer) {
|
|
430
|
+
if (producer.options) {
|
|
431
|
+
producer.children.forEach((child) => dotLines.push(AncestryDotProducer.buildDotEdge(producer, child)));
|
|
432
|
+
}
|
|
433
|
+
producers.push(...producer.children);
|
|
392
434
|
}
|
|
393
|
-
producers.push(...producer.children);
|
|
394
435
|
}
|
|
395
436
|
return `strict graph G {${os_1.EOL}${dotLines.join(os_1.EOL)}${os_1.EOL}}`;
|
|
396
437
|
}
|
|
@@ -400,54 +441,26 @@ class PackageAncestryNode extends kit_1.AsyncCreatable {
|
|
|
400
441
|
constructor(options) {
|
|
401
442
|
super(options);
|
|
402
443
|
this.options = options;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
__classPrivateFieldSet(this, _PackageAncestryNode_PatchVersion, typeof this.options.PatchVersion === 'number'
|
|
421
|
-
? this.options.PatchVersion
|
|
422
|
-
: parseInt(this.options.PatchVersion, 10), "f");
|
|
423
|
-
__classPrivateFieldSet(this, _PackageAncestryNode_BuildNumber, this.options.BuildNumber, "f");
|
|
424
|
-
}
|
|
425
|
-
get AncestorId() {
|
|
426
|
-
return __classPrivateFieldGet(this, _PackageAncestryNode_AncestorId, "f");
|
|
427
|
-
}
|
|
428
|
-
get SubscriberPackageVersionId() {
|
|
429
|
-
return __classPrivateFieldGet(this, _PackageAncestryNode_SubscriberPackageVersionId, "f");
|
|
430
|
-
}
|
|
431
|
-
get version() {
|
|
432
|
-
return __classPrivateFieldGet(this, _PackageAncestryNode_version, "f");
|
|
433
|
-
}
|
|
434
|
-
get MinorVersion() {
|
|
435
|
-
return __classPrivateFieldGet(this, _PackageAncestryNode_MinorVersion, "f");
|
|
436
|
-
}
|
|
437
|
-
get PatchVersion() {
|
|
438
|
-
return __classPrivateFieldGet(this, _PackageAncestryNode_PatchVersion, "f");
|
|
439
|
-
}
|
|
440
|
-
get BuildNumber() {
|
|
441
|
-
return __classPrivateFieldGet(this, _PackageAncestryNode_BuildNumber, "f");
|
|
442
|
-
}
|
|
443
|
-
get MajorVersion() {
|
|
444
|
-
return __classPrivateFieldGet(this, _PackageAncestryNode_MajorVersion, "f");
|
|
445
|
-
}
|
|
446
|
-
get depthCounter() {
|
|
447
|
-
return __classPrivateFieldGet(this, _PackageAncestryNode_depthCounter, "f");
|
|
444
|
+
this.depthCounter = 0;
|
|
445
|
+
this.version = new versionNumber_1.VersionNumber(this.options.MajorVersion, this.options.MinorVersion, this.options.PatchVersion, this.options.BuildNumber);
|
|
446
|
+
this.AncestorId = this.options.AncestorId;
|
|
447
|
+
this.SubscriberPackageVersionId = this.options.SubscriberPackageVersionId;
|
|
448
|
+
this.MajorVersion =
|
|
449
|
+
typeof this.options.MajorVersion === 'number'
|
|
450
|
+
? this.options.MajorVersion
|
|
451
|
+
: parseInt(this.options.MajorVersion, 10);
|
|
452
|
+
this.MinorVersion =
|
|
453
|
+
typeof this.options.MinorVersion === 'number'
|
|
454
|
+
? this.options.MinorVersion
|
|
455
|
+
: parseInt(this.options.MinorVersion, 10);
|
|
456
|
+
this.PatchVersion =
|
|
457
|
+
typeof this.options.PatchVersion === 'number'
|
|
458
|
+
? this.options.PatchVersion
|
|
459
|
+
: parseInt(this.options?.PatchVersion, 10);
|
|
460
|
+
this.BuildNumber = this.options?.BuildNumber;
|
|
448
461
|
}
|
|
449
462
|
getVersion() {
|
|
450
|
-
return
|
|
463
|
+
return this.version.toString();
|
|
451
464
|
}
|
|
452
465
|
// eslint-disable-next-line class-methods-use-this
|
|
453
466
|
init() {
|
|
@@ -455,5 +468,4 @@ class PackageAncestryNode extends kit_1.AsyncCreatable {
|
|
|
455
468
|
}
|
|
456
469
|
}
|
|
457
470
|
exports.PackageAncestryNode = PackageAncestryNode;
|
|
458
|
-
_PackageAncestryNode_version = new WeakMap(), _PackageAncestryNode_MajorVersion = new WeakMap(), _PackageAncestryNode_MinorVersion = new WeakMap(), _PackageAncestryNode_PatchVersion = new WeakMap(), _PackageAncestryNode_BuildNumber = new WeakMap(), _PackageAncestryNode_AncestorId = new WeakMap(), _PackageAncestryNode_SubscriberPackageVersionId = new WeakMap(), _PackageAncestryNode_depthCounter = new WeakMap();
|
|
459
471
|
//# sourceMappingURL=packageAncestry.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection, SfProject } from '@salesforce/core';
|
|
2
|
-
import {
|
|
2
|
+
import { ConvertPackageOptions, PackageVersionCreateRequestResult, PackagingSObjects } from '../interfaces';
|
|
3
3
|
export declare function findOrCreatePackage2(seedPackage: string, connection: Connection): Promise<string>;
|
|
4
4
|
export declare function convertPackage(pkg: string, connection: Connection, options: ConvertPackageOptions, project?: SfProject): Promise<PackageVersionCreateRequestResult>;
|
|
5
5
|
/**
|
|
@@ -14,10 +14,10 @@ const core_1 = require("@salesforce/core");
|
|
|
14
14
|
const kit_1 = require("@salesforce/kit");
|
|
15
15
|
const scratchOrgSettingsGenerator_1 = require("@salesforce/core/lib/org/scratchOrgSettingsGenerator");
|
|
16
16
|
const pkgUtils = require("../utils/packageUtils");
|
|
17
|
-
const interfaces_1 = require("../interfaces");
|
|
18
17
|
const packageUtils_1 = require("../utils/packageUtils");
|
|
19
|
-
const
|
|
18
|
+
const interfaces_1 = require("../interfaces");
|
|
20
19
|
const pvcr = require("./packageVersionCreateRequest");
|
|
20
|
+
const packageVersionCreateRequest_1 = require("./packageVersionCreateRequest");
|
|
21
21
|
const packageVersionCreate_1 = require("./packageVersionCreate");
|
|
22
22
|
var Package2VersionStatus = interfaces_1.PackagingSObjects.Package2VersionStatus;
|
|
23
23
|
core_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -83,10 +83,8 @@ async function convertPackage(pkg, connection, options, project) {
|
|
|
83
83
|
const createResult = await connection.tooling.create('Package2VersionCreateRequest', request);
|
|
84
84
|
if (!createResult.success) {
|
|
85
85
|
const errStr = createResult?.errors.length ? createResult.errors.join(', ') : createResult.errors;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
errStr.toString(),
|
|
89
|
-
]);
|
|
86
|
+
const id = createResult.id ?? '';
|
|
87
|
+
throw messages.createError('failedToCreatePVCRequest', [id, errStr.toString()]);
|
|
90
88
|
}
|
|
91
89
|
let results;
|
|
92
90
|
if (options.wait) {
|
|
@@ -116,32 +114,25 @@ async function createPackageVersionCreateRequest(context, packageId, apiVersion)
|
|
|
116
114
|
const settingsZipFile = path.join(packageVersBlobDirectory, 'settings.zip');
|
|
117
115
|
const metadataZipFile = path.join(packageVersBlobDirectory, 'package.zip');
|
|
118
116
|
const packageVersBlobZipFile = path.join(packageVersTmpRoot, 'package-version-info.zip');
|
|
119
|
-
|
|
117
|
+
let packageDescriptorJson = {
|
|
120
118
|
id: packageId,
|
|
121
119
|
};
|
|
122
120
|
const settingsGenerator = new scratchOrgSettingsGenerator_1.default({ asDirectory: true });
|
|
123
121
|
const definitionFile = context.definitionfile;
|
|
124
122
|
let definitionFileJson;
|
|
125
123
|
if (definitionFile) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
definitionFileJson = JSON.parse(definitionFilePayload);
|
|
129
|
-
}
|
|
130
|
-
catch (err) {
|
|
131
|
-
throw messages.createError('errorReadingDefintionFile', [err]);
|
|
124
|
+
if (!fs.existsSync(definitionFile)) {
|
|
125
|
+
throw messages.createError('errorReadingDefintionFile', [definitionFile]);
|
|
132
126
|
}
|
|
127
|
+
const definitionFilePayload = await fs.promises.readFile(definitionFile, 'utf8');
|
|
128
|
+
definitionFileJson = JSON.parse(definitionFilePayload);
|
|
133
129
|
// Load any settings from the definition
|
|
134
130
|
await settingsGenerator.extract(definitionFileJson);
|
|
135
131
|
if (settingsGenerator.hasSettings() && definitionFileJson.orgPreferences) {
|
|
136
132
|
// this is not allowed, exit with an error
|
|
137
133
|
throw messages.createError('signupDuplicateSettingsSpecified');
|
|
138
134
|
}
|
|
139
|
-
|
|
140
|
-
const propValue = definitionFileJson[prop];
|
|
141
|
-
if (propValue) {
|
|
142
|
-
packageDescriptorJson[prop] = propValue;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
135
|
+
packageDescriptorJson = (0, packageUtils_1.copyDescriptorProperties)(packageDescriptorJson, definitionFileJson);
|
|
145
136
|
}
|
|
146
137
|
await fs.promises.mkdir(packageVersTmpRoot, { recursive: true });
|
|
147
138
|
await fs.promises.mkdir(packageVersBlobDirectory, { recursive: true });
|
|
@@ -197,6 +188,9 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, project
|
|
|
197
188
|
const record = pkgQueryResult.records[0];
|
|
198
189
|
return `${record.MajorVersion}.${record.MinorVersion}.${record.PatchVersion}-${record.BuildNumber}`;
|
|
199
190
|
});
|
|
191
|
+
if (!results[0]?.SubscriberPackageVersionId) {
|
|
192
|
+
throw new core_1.SfError('No SubscriberPackageVersionId found');
|
|
193
|
+
}
|
|
200
194
|
const [alias, writtenId] = await (0, packageUtils_1.generatePackageAliasEntry)(connection, project, results[0].SubscriberPackageVersionId, packageVersionVersionString, branch, packageId);
|
|
201
195
|
project.getSfProjectJson().addPackageAlias(alias, writtenId);
|
|
202
196
|
await project.getSfProjectJson().write();
|
|
@@ -251,7 +245,7 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, project
|
|
|
251
245
|
* @param statuses array of statuses to look for
|
|
252
246
|
* @returns {boolean} if one of the values in status is found.
|
|
253
247
|
*/
|
|
254
|
-
function isStatusEqualTo(results, statuses) {
|
|
255
|
-
return results?.length
|
|
248
|
+
function isStatusEqualTo(results, statuses = []) {
|
|
249
|
+
return !results?.length ? false : statuses.some((status) => results[0].Status === status);
|
|
256
250
|
}
|
|
257
251
|
//# sourceMappingURL=packageConvert.js.map
|
|
@@ -6,7 +6,7 @@ export declare function createPackageRequestFromContext(project: SfProject, opti
|
|
|
6
6
|
* Create packageDirectory json entry for this package that can be written to sfdx-project.json
|
|
7
7
|
*
|
|
8
8
|
* @param project
|
|
9
|
-
* @param
|
|
9
|
+
* @param options - package create options
|
|
10
10
|
* @private
|
|
11
11
|
*/
|
|
12
12
|
export declare function createPackageDirEntry(project: SfProject, options: PackageCreateOptions): PackageDir | NamedPackageDir;
|