@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.
Files changed (38) hide show
  1. package/lib/interfaces/packagingInterfacesAndType.d.ts +37 -33
  2. package/lib/package/package.d.ts +3 -3
  3. package/lib/package/package.js +14 -8
  4. package/lib/package/packageAncestry.d.ts +24 -25
  5. package/lib/package/packageAncestry.js +159 -147
  6. package/lib/package/packageConvert.d.ts +1 -1
  7. package/lib/package/packageConvert.js +15 -21
  8. package/lib/package/packageCreate.d.ts +1 -1
  9. package/lib/package/packageCreate.js +14 -25
  10. package/lib/package/packageDelete.js +4 -1
  11. package/lib/package/packageInstall.d.ts +5 -4
  12. package/lib/package/packageInstall.js +10 -9
  13. package/lib/package/packageProfileApi.d.ts +3 -6
  14. package/lib/package/packageProfileApi.js +153 -145
  15. package/lib/package/packageUninstall.js +15 -9
  16. package/lib/package/packageVersion.d.ts +6 -5
  17. package/lib/package/packageVersion.js +76 -46
  18. package/lib/package/packageVersionCreate.d.ts +2 -2
  19. package/lib/package/packageVersionCreate.js +81 -59
  20. package/lib/package/packageVersionCreateRequest.d.ts +2 -2
  21. package/lib/package/packageVersionCreateRequest.js +8 -11
  22. package/lib/package/packageVersionCreateRequestReport.js +4 -1
  23. package/lib/package/packageVersionList.d.ts +5 -4
  24. package/lib/package/packageVersionList.js +18 -18
  25. package/lib/package/packageVersionReport.js +6 -4
  26. package/lib/package/subscriberPackageVersion.d.ts +4 -4
  27. package/lib/package/subscriberPackageVersion.js +23 -10
  28. package/lib/package/versionNumber.d.ts +8 -3
  29. package/lib/package/versionNumber.js +13 -4
  30. package/lib/package1/package1Version.js +18 -13
  31. package/lib/utils/packageUtils.d.ts +11 -7
  32. package/lib/utils/packageUtils.js +26 -15
  33. package/messages/package.md +4 -0
  34. package/messages/package1Version.md +4 -0
  35. package/messages/package_version.md +8 -0
  36. package/messages/package_version_create.md +32 -4
  37. package/messages/pkg_utils.md +1 -1
  38. 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
- const aVersion = new versionNumber_1.VersionNumber(a.options.node.MajorVersion, a.options.node.MinorVersion, a.options.node.PatchVersion, a.options.node.BuildNumber);
39
- const bVersion = new versionNumber_1.VersionNumber(b.options.node.MajorVersion, b.options.node.MinorVersion, b.options.node.PatchVersion, b.options.node.BuildNumber);
40
- return aVersion.compareTo(bVersion);
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
- _PackageAncestry_requestedPackageId.set(this, void 0);
50
+ this.roots = [];
51
51
  this.graph = new graphology_1.DirectedGraph();
52
+ this.packageId = options.packageId;
52
53
  }
53
54
  get requestedPackageId() {
54
- return __classPrivateFieldGet(this, _PackageAncestry_requestedPackageId, "f");
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: !!verbose }), this.requestedPackageId);
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 root - the subscriber package version id of the root node
100
+ * @param rootPackageId - the subscriber package version id of the root node
88
101
  */
89
- getRepresentationProducer(producerCtor, root) {
90
- const treeRoot = root
91
- ? this.graph.findNode((node, attributes) => attributes.node.SubscriberPackageVersionId === root)
102
+ getRepresentationProducer(producerCtor, rootPackageId) {
103
+ const treeRootKey = rootPackageId
104
+ ? this.graph.findNode((node, attributes) => attributes.SubscriberPackageVersionId === rootPackageId)
92
105
  : undefined;
93
- const tree = producerCtor();
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({ node: attr.node, depth });
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.node.AncestorId === null);
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
- return (paths
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
- path.some((node) => node.SubscriberPackageVersionId === subscriberPackageVersionId)))
150
- // eslint-disable-next-line @typescript-eslint/no-shadow
151
- .map((path) => path.reverse())
152
- // eslint-disable-next-line @typescript-eslint/no-shadow
153
- .map((path) => {
154
- const subscriberPackageVersionIdIndex = path.findIndex((node) => node.SubscriberPackageVersionId === subscriberPackageVersionId);
155
- return path.slice(subscriberPackageVersionIdIndex === -1 ? 0 : subscriberPackageVersionIdIndex);
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.getRoots();
169
+ this.roots = await this.getRootsFromRequestedId();
160
170
  await this.buildAncestryTreeFromRoots(this.roots);
161
171
  }
162
- async getRoots() {
172
+ async getRootsFromRequestedId() {
163
173
  let roots = [];
164
- __classPrivateFieldSet(this, _PackageAncestry_requestedPackageId, this.options.project.getPackageIdFromAlias(this.options.packageId) ?? this.options.packageId, "f");
165
- switch (this.requestedPackageId.slice(0, 3)) {
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
- switch (this.requestedPackageId.slice(0, 3)) {
196
- case '04t':
197
- // eslint-disable-next-line no-case-declarations
198
- const packageVersion = new packageVersion_1.PackageVersion({
199
- idOrAlias: this.requestedPackageId,
200
- project: this.options.project,
201
- connection: this.options.connection,
202
- });
203
- packageType = await packageVersion.getPackageType();
204
- break;
205
- case '0Ho':
206
- // eslint-disable-next-line no-case-declarations
207
- const pkg = new package_1.Package({
208
- packageAliasOrId: this.requestedPackageId,
209
- project: this.options.project,
210
- connection: this.options.connection,
211
- });
212
- packageType = await pkg.getType();
213
- break;
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 (e) {
228
- if (e.message.includes('No record found for')) {
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 e;
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
- const descendants = await this.addDescendantsFromPackageVersion(subscriberPackageVersion);
251
- roots.push(...descendants);
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(), { node: ancestor });
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(), { node: descendant });
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?.node?.getVersion() || 'root';
287
- this.verbose = this.options?.verbose || false;
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
- Object.values(producer.nodes)
299
- .sort((a, b) => a.options.node.version.compareTo(b.options.node.version))
300
- .forEach((child) => {
301
- delete producer.nodes[this.createLabel(child)];
302
- producer.addNode(child);
303
- producers.push(child);
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?.node?.SubscriberPackageVersionId
310
- ? ` (${node.options.node.SubscriberPackageVersionId})`
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?.node?.getVersion() || 'root';
352
+ this.label = this.options?.packageNode?.getVersion() ?? 'root';
321
353
  this.data = {
322
354
  children: [],
323
355
  data: {
324
- SubscriberPackageVersionId: this.options?.node?.SubscriberPackageVersionId,
325
- MajorVersion: this.options?.node?.MajorVersion,
326
- MinorVersion: this.options?.node?.MinorVersion,
327
- PatchVersion: this.options?.node?.PatchVersion,
328
- BuildNumber: this.options?.node?.BuildNumber,
329
- depthCounter: this.options?.depth,
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.children.sort(sortAncestryNodeData);
343
- producers.push(...producer.children);
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?.node?.getVersion() || 'root';
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
- return `\t node${currentNode.options.node.SubscriberPackageVersionId} [label="${currentNode.label}"]`;
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
- return `\t node${fromNode.options.node.SubscriberPackageVersionId} -- node${toNode.options.node.SubscriberPackageVersionId}`;
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.options) {
382
- dotLines.push(AncestryDotProducer.buildDotNode(producer));
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.options) {
391
- producer.children.forEach((child) => dotLines.push(AncestryDotProducer.buildDotEdge(producer, child)));
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
- _PackageAncestryNode_version.set(this, void 0);
404
- _PackageAncestryNode_MajorVersion.set(this, void 0);
405
- _PackageAncestryNode_MinorVersion.set(this, void 0);
406
- _PackageAncestryNode_PatchVersion.set(this, void 0);
407
- _PackageAncestryNode_BuildNumber.set(this, void 0);
408
- _PackageAncestryNode_AncestorId.set(this, void 0);
409
- _PackageAncestryNode_SubscriberPackageVersionId.set(this, void 0);
410
- _PackageAncestryNode_depthCounter.set(this, void 0);
411
- __classPrivateFieldSet(this, _PackageAncestryNode_version, new versionNumber_1.VersionNumber(this.options.MajorVersion, this.options.MinorVersion, this.options.PatchVersion, this.options.BuildNumber), "f");
412
- __classPrivateFieldSet(this, _PackageAncestryNode_AncestorId, this.options.AncestorId, "f");
413
- __classPrivateFieldSet(this, _PackageAncestryNode_SubscriberPackageVersionId, this.options.SubscriberPackageVersionId, "f");
414
- __classPrivateFieldSet(this, _PackageAncestryNode_MajorVersion, typeof this.options.MajorVersion === 'number'
415
- ? this.options.MajorVersion
416
- : parseInt(this.options.MajorVersion, 10), "f");
417
- __classPrivateFieldSet(this, _PackageAncestryNode_MinorVersion, typeof this.options.MinorVersion === 'number'
418
- ? this.options.MinorVersion
419
- : parseInt(this.options.MinorVersion, 10), "f");
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 __classPrivateFieldGet(this, _PackageAncestryNode_version, "f").toString();
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 { PackagingSObjects, PackageVersionCreateRequestResult, ConvertPackageOptions } from '../interfaces';
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 packageVersionCreateRequest_1 = require("./packageVersionCreateRequest");
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
- throw messages.createError('failedToCreatePVCRequest', [
87
- createResult.id ? ` [${createResult.id}]` : '',
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
- const packageDescriptorJson = {
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
- try {
127
- const definitionFilePayload = await fs.promises.readFile(definitionFile, 'utf8');
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
- ['country', 'edition', 'language', 'features', 'orgPreferences', 'snapshot', 'release', 'sourceOrg'].forEach((prop) => {
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 <= 0 ? false : statuses?.some((status) => results[0].Status === status);
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 packageId the 0Ho id of the package to create the entry for
9
+ * @param options - package create options
10
10
  * @private
11
11
  */
12
12
  export declare function createPackageDirEntry(project: SfProject, options: PackageCreateOptions): PackageDir | NamedPackageDir;