@salesforce/packaging 0.1.17 → 0.1.18

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.
@@ -23,29 +23,29 @@ export declare class PackageAncestry extends AsyncCreatable<PackageAncestryOptio
23
23
  /**
24
24
  * Convenience method to get the json representation of the package ancestry graph.
25
25
  */
26
- getJsonProducer(): Promise<AncestryRepresentationProducer>;
26
+ getJsonProducer(): AncestryRepresentationProducer;
27
27
  /**
28
28
  * Convenience method to get the CliUx.Tree representation of the package ancestry graph.
29
29
  */
30
- getTreeProducer(verbose: boolean): Promise<AncestryRepresentationProducer>;
30
+ getTreeProducer(verbose: boolean): AncestryRepresentationProducer;
31
31
  /**
32
32
  * Convenience method to get the dot representation of the package ancestry graph.
33
33
  */
34
- getDotProducer(): Promise<AncestryRepresentationProducer>;
34
+ getDotProducer(): AncestryRepresentationProducer;
35
35
  /**
36
36
  * Returns the producer representation of the package ancestry graph.
37
37
  *
38
38
  * @param producerCtor - function that returns a new instance of the producer
39
39
  * @param root - the subscriber package version id of the root node
40
40
  */
41
- getRepresentationProducer(producerCtor: (options?: AncestryRepresentationProducerOptions) => AncestryRepresentationProducer, root: string | undefined): Promise<AncestryRepresentationProducer>;
41
+ getRepresentationProducer(producerCtor: (options?: AncestryRepresentationProducerOptions) => AncestryRepresentationProducer, root: string | undefined): AncestryRepresentationProducer;
42
42
  /**
43
43
  * Returns a list of ancestry nodes that represent the path from subscriber package version id to the root of the
44
44
  * package ancestry tree.
45
45
  *
46
46
  * @param subscriberPackageVersionId
47
47
  */
48
- getLeafPathToRoot(subscriberPackageVersionId?: string): Promise<PackageAncestryNode[][]>;
48
+ getLeafPathToRoot(subscriberPackageVersionId?: string): PackageAncestryNode[][];
49
49
  private buildAncestryTree;
50
50
  private getRoots;
51
51
  private findRootsForPackageVersion;
@@ -65,19 +65,19 @@ class PackageAncestry extends kit_1.AsyncCreatable {
65
65
  /**
66
66
  * Convenience method to get the json representation of the package ancestry graph.
67
67
  */
68
- async getJsonProducer() {
68
+ getJsonProducer() {
69
69
  return this.getRepresentationProducer((opts) => new AncestryJsonProducer(opts), this.requestedPackageId);
70
70
  }
71
71
  /**
72
72
  * Convenience method to get the CliUx.Tree representation of the package ancestry graph.
73
73
  */
74
- async getTreeProducer(verbose) {
74
+ getTreeProducer(verbose) {
75
75
  return this.getRepresentationProducer((opts) => new AncestryTreeProducer({ ...opts, verbose: !!verbose }), this.requestedPackageId);
76
76
  }
77
77
  /**
78
78
  * Convenience method to get the dot representation of the package ancestry graph.
79
79
  */
80
- async getDotProducer() {
80
+ getDotProducer() {
81
81
  return this.getRepresentationProducer((opts) => new AncestryDotProducer(opts), this.requestedPackageId);
82
82
  }
83
83
  /**
@@ -86,7 +86,7 @@ class PackageAncestry extends kit_1.AsyncCreatable {
86
86
  * @param producerCtor - function that returns a new instance of the producer
87
87
  * @param root - the subscriber package version id of the root node
88
88
  */
89
- async getRepresentationProducer(producerCtor, root) {
89
+ getRepresentationProducer(producerCtor, root) {
90
90
  const treeRoot = root
91
91
  ? this.graph.findNode((node, attributes) => attributes.node.SubscriberPackageVersionId === root)
92
92
  : undefined;
@@ -122,12 +122,12 @@ class PackageAncestry extends kit_1.AsyncCreatable {
122
122
  *
123
123
  * @param subscriberPackageVersionId
124
124
  */
125
- async getLeafPathToRoot(subscriberPackageVersionId) {
125
+ getLeafPathToRoot(subscriberPackageVersionId) {
126
126
  const root = this.graph.findNode((node, attributes) => attributes.node.AncestorId === null);
127
127
  const paths = [];
128
128
  let path = [];
129
129
  let previousDepth = 0;
130
- (0, graphology_traversal_1.dfsFromNode)(this.graph, root, function (node, attr, depth) {
130
+ (0, graphology_traversal_1.dfsFromNode)(this.graph, root, (node, attr, depth) => {
131
131
  if (depth === 0) {
132
132
  paths.push(path);
133
133
  path = [];
@@ -141,15 +141,19 @@ class PackageAncestry extends kit_1.AsyncCreatable {
141
141
  });
142
142
  // push remaining path
143
143
  paths.push(path);
144
- return paths
145
- .filter((path) => path.length > 0 && // don't care about zero length paths
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
146
148
  (!subscriberPackageVersionId ||
147
149
  path.some((node) => node.SubscriberPackageVersionId === subscriberPackageVersionId)))
150
+ // eslint-disable-next-line @typescript-eslint/no-shadow
148
151
  .map((path) => path.reverse())
152
+ // eslint-disable-next-line @typescript-eslint/no-shadow
149
153
  .map((path) => {
150
154
  const subscriberPackageVersionIdIndex = path.findIndex((node) => node.SubscriberPackageVersionId === subscriberPackageVersionId);
151
155
  return path.slice(subscriberPackageVersionIdIndex === -1 ? 0 : subscriberPackageVersionIdIndex);
152
- });
156
+ }));
153
157
  }
154
158
  async buildAncestryTree() {
155
159
  this.roots = await this.getRoots();
@@ -177,6 +181,7 @@ class PackageAncestry extends kit_1.AsyncCreatable {
177
181
  // Start with the node, and shoot up
178
182
  let node = await this.getPackageVersion(this.requestedPackageId);
179
183
  while (node.AncestorId !== null) {
184
+ // eslint-disable-next-line no-await-in-loop
180
185
  const ancestor = await this.getPackageVersion(node.AncestorId);
181
186
  this.addToGraph(ancestor, node);
182
187
  node = ancestor;
@@ -241,6 +246,7 @@ class PackageAncestry extends kit_1.AsyncCreatable {
241
246
  async buildAncestryTreeFromRoots(roots) {
242
247
  while (roots.length > 0) {
243
248
  const subscriberPackageVersion = roots.shift();
249
+ // eslint-disable-next-line no-await-in-loop
244
250
  const descendants = await this.addDescendantsFromPackageVersion(subscriberPackageVersion);
245
251
  roots.push(...descendants);
246
252
  }
@@ -443,6 +449,7 @@ class PackageAncestryNode extends kit_1.AsyncCreatable {
443
449
  getVersion() {
444
450
  return __classPrivateFieldGet(this, _PackageAncestryNode_version, "f").toString();
445
451
  }
452
+ // eslint-disable-next-line class-methods-use-this
446
453
  init() {
447
454
  return Promise.resolve();
448
455
  }
@@ -76,7 +76,7 @@ async function convertPackage(pkg, connection, options, project) {
76
76
  // TODO: a lot of this is duplicated from PC, PVC, and PVCR.
77
77
  const createResult = await connection.tooling.create('Package2VersionCreateRequest', request);
78
78
  if (!createResult.success) {
79
- const errStr = createResult.errors && createResult.errors.length ? createResult.errors.join(', ') : createResult.errors;
79
+ const errStr = createResult?.errors.length ? createResult.errors.join(', ') : createResult.errors;
80
80
  throw messages.createError('failedToCreatePVCRequest', [
81
81
  createResult.id ? ` [${createResult.id}]` : '',
82
82
  errStr.toString(),
@@ -169,9 +169,9 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, withPro
169
169
  const pollingClient = await core_1.PollingClient.create({
170
170
  poll: async () => {
171
171
  const results = await pvcr.byId(id, connection);
172
- if (_isStatusEqualTo(results, [Package2VersionStatus.success, Package2VersionStatus.error])) {
172
+ if (isStatusEqualTo(results, [Package2VersionStatus.success, Package2VersionStatus.error])) {
173
173
  // complete
174
- if (_isStatusEqualTo(results, [Package2VersionStatus.success])) {
174
+ if (isStatusEqualTo(results, [Package2VersionStatus.success])) {
175
175
  // update sfdx-project.json
176
176
  let projectUpdated = false;
177
177
  if (withProject && !process.env.SFDX_PROJECT_AUTOUPDATE_DISABLE_FOR_PACKAGE_VERSION_CREATE) {
@@ -183,8 +183,8 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, withPro
183
183
  const record = pkgQueryResult.records[0];
184
184
  return `${record.MajorVersion}.${record.MinorVersion}.${record.PatchVersion}-${record.BuildNumber}`;
185
185
  });
186
- const [alias, id] = await (0, utils_1.generatePackageAliasEntry)(connection, withProject, results[0].SubscriberPackageVersionId, packageVersionVersionString, branch, packageId);
187
- withProject.getSfProjectJson().addPackageAlias(alias, id);
186
+ const [alias, writtenId] = await (0, utils_1.generatePackageAliasEntry)(connection, withProject, results[0].SubscriberPackageVersionId, packageVersionVersionString, branch, packageId);
187
+ withProject.getSfProjectJson().addPackageAlias(alias, writtenId);
188
188
  await withProject.getSfProjectJson().write();
189
189
  }
190
190
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageEvents.convert.success, {
@@ -238,7 +238,7 @@ async function pollForStatusWithInterval(id, retries, packageId, branch, withPro
238
238
  * @param statuses array of statuses to look for
239
239
  * @returns {boolean} if one of the values in status is found.
240
240
  */
241
- function _isStatusEqualTo(results, statuses) {
241
+ function isStatusEqualTo(results, statuses) {
242
242
  return results?.length <= 0 ? false : statuses?.some((status) => results[0].Status === status);
243
243
  }
244
244
  //# sourceMappingURL=packageConvert.js.map
@@ -169,6 +169,7 @@ class PackageProfileApi extends kit_1.AsyncCreatable {
169
169
  }
170
170
  catch (err) {
171
171
  // It is normal for the file to not exist if the profile is in the workspace but not in the directory being packaged.
172
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
172
173
  if (err.code !== 'ENOENT') {
173
174
  throw err;
174
175
  }
@@ -215,20 +216,18 @@ class PackageProfileApi extends kit_1.AsyncCreatable {
215
216
  // eslint-disable-next-line @typescript-eslint/prefer-for-of
216
217
  for (let i = 0; i < nodes.length; i++) {
217
218
  const name = nodes[i].getElementsByTagName(childElement)[0].childNodes[0].nodeValue;
218
- if (members.indexOf(name) >= 0) {
219
+ if (members.includes(name)) {
219
220
  // appendChild will take the passed in node (newNode) and find the parent if it exists and then remove
220
221
  // the newNode from the parent. This causes issues with the way this is copying the nodes, so pass in a clone instead.
221
222
  const currentNode = nodes[i].cloneNode(true);
222
223
  appendToNode.appendChild(currentNode);
223
224
  nodesAdded = true;
224
225
  }
225
- else {
226
+ else if (this.generateProfileInformation) {
226
227
  // Tell the user which profile setting has been removed from the package
227
- if (this.generateProfileInformation) {
228
- const profile = this.profiles.find(({ ProfileName }) => ProfileName === profileName);
229
- if (profile) {
230
- profile.appendRemovedSetting(name);
231
- }
228
+ const profile = this.profiles.find(({ ProfileName }) => ProfileName === profileName);
229
+ if (profile) {
230
+ profile.appendRemovedSetting(name);
232
231
  }
233
232
  }
234
233
  }
@@ -21,7 +21,7 @@ async function getUninstallErrors(conn, id) {
21
21
  }
22
22
  exports.getUninstallErrors = getUninstallErrors;
23
23
  async function pollUninstall(uninstallRequestId, conn, frequency, wait) {
24
- const poll = async (id, conn) => {
24
+ const poll = async (id) => {
25
25
  const uninstallRequest = (await conn.tooling
26
26
  .sobject('SubscriberPackageVersionUninstallRequest')
27
27
  .retrieve(id));
@@ -46,7 +46,7 @@ async function pollUninstall(uninstallRequestId, conn, frequency, wait) {
46
46
  }
47
47
  };
48
48
  const pollingClient = await core_1.PollingClient.create({
49
- poll: () => poll(uninstallRequestId, conn),
49
+ poll: () => poll(uninstallRequestId),
50
50
  frequency,
51
51
  timeout: wait,
52
52
  });
@@ -64,7 +64,7 @@ async function uninstallPackage(id, conn, frequency = kit_1.Duration.seconds(0),
64
64
  .retrieve(uninstallRequest.id));
65
65
  }
66
66
  else {
67
- return pollUninstall(uninstallRequest.id, conn, frequency, wait);
67
+ return await pollUninstall(uninstallRequest.id, conn, frequency, wait);
68
68
  }
69
69
  }
70
70
  catch (err) {
@@ -45,6 +45,8 @@ export declare class PackageVersion {
45
45
  * progress and current status. Events also carry a payload of type PackageVersionCreateRequestResult.
46
46
  *
47
47
  * @param createPackageVersionRequestId
48
+ * @param connection Connection to the org
49
+ * @param project SfProject to read/write aliases from
48
50
  * @param polling frequency and timeout Durations to be used in polling
49
51
  * */
50
52
  static pollCreateStatus(createPackageVersionRequestId: string, connection: Connection, project: SfProject, polling: {
@@ -15,6 +15,7 @@ const packageVersionCreate_1 = require("./packageVersionCreate");
15
15
  const packageVersionReport_1 = require("./packageVersionReport");
16
16
  const packageVersionCreateRequestReport_1 = require("./packageVersionCreateRequestReport");
17
17
  const packageVersionCreateRequest_1 = require("./packageVersionCreateRequest");
18
+ var Package2VersionStatus = interfaces_1.PackagingSObjects.Package2VersionStatus;
18
19
  core_1.Messages.importMessagesDirectory(__dirname);
19
20
  const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'package_version');
20
21
  exports.Package2VersionFields = [
@@ -84,7 +85,7 @@ class PackageVersion {
84
85
  }) {
85
86
  const pvc = new packageVersionCreate_1.PackageVersionCreate({ ...options });
86
87
  const createResult = await pvc.createPackageVersion();
87
- return await PackageVersion.pollCreateStatus(createResult.Id, options.connection, options.project, polling).catch((err) => {
88
+ return PackageVersion.pollCreateStatus(createResult.Id, options.connection, options.project, polling).catch((err) => {
88
89
  // TODO
89
90
  // until package2 is GA, wrap perm-based errors w/ 'contact sfdc' action (REMOVE once package2 is GA'd)
90
91
  throw (0, utils_1.applyErrorAction)((0, utils_1.massageErrorMessage)(err));
@@ -97,7 +98,7 @@ class PackageVersion {
97
98
  * @param connection
98
99
  */
99
100
  static async getCreateStatus(createPackageRequestId, connection) {
100
- return await (0, packageVersionCreateRequestReport_1.getCreatePackageVersionCreateRequestReport)({
101
+ return (0, packageVersionCreateRequestReport_1.getCreatePackageVersionCreateRequestReport)({
101
102
  createPackageVersionRequestId: createPackageRequestId,
102
103
  connection,
103
104
  }).catch((err) => {
@@ -123,6 +124,8 @@ class PackageVersion {
123
124
  * progress and current status. Events also carry a payload of type PackageVersionCreateRequestResult.
124
125
  *
125
126
  * @param createPackageVersionRequestId
127
+ * @param connection Connection to the org
128
+ * @param project SfProject to read/write aliases from
126
129
  * @param polling frequency and timeout Durations to be used in polling
127
130
  * */
128
131
  static async pollCreateStatus(createPackageVersionRequestId, connection, project, polling) {
@@ -135,19 +138,19 @@ class PackageVersion {
135
138
  poll: async () => {
136
139
  report = await this.getCreateStatus(createPackageVersionRequestId, connection);
137
140
  switch (report.Status) {
138
- case 'Queued':
141
+ case Package2VersionStatus.queued:
139
142
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.enqueued, { ...report, remainingWaitTime });
140
143
  remainingWaitTime = kit_1.Duration.seconds(remainingWaitTime.seconds - polling.frequency.seconds);
141
144
  return {
142
145
  completed: false,
143
146
  payload: report,
144
147
  };
145
- case 'InProgress':
146
- case 'Initializing':
147
- case 'VerifyingFeaturesAndSettings':
148
- case 'VerifyingDependencies':
149
- case 'VerifyingMetadata':
150
- case 'FinalizingPackageVersion':
148
+ case Package2VersionStatus.inProgress:
149
+ case Package2VersionStatus.initializing:
150
+ case Package2VersionStatus.verifyingFeaturesAndSettings:
151
+ case Package2VersionStatus.verifyingDependencies:
152
+ case Package2VersionStatus.verifyingMetadata:
153
+ case Package2VersionStatus.finalizingPackageVersion:
151
154
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.progress, {
152
155
  ...report,
153
156
  remainingWaitTime,
@@ -157,7 +160,7 @@ class PackageVersion {
157
160
  completed: false,
158
161
  payload: report,
159
162
  };
160
- case 'Success': {
163
+ case Package2VersionStatus.success: {
161
164
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.success, report);
162
165
  const packageVersion = new PackageVersion({
163
166
  connection,
@@ -167,7 +170,7 @@ class PackageVersion {
167
170
  await packageVersion.updateProjectWithPackageVersion(report);
168
171
  return { completed: true, payload: report };
169
172
  }
170
- case 'Error':
173
+ case Package2VersionStatus.error:
171
174
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.error, report);
172
175
  return { completed: true, payload: report };
173
176
  }
@@ -176,7 +179,7 @@ class PackageVersion {
176
179
  timeout: polling.timeout,
177
180
  });
178
181
  try {
179
- return pollingClient.subscribe();
182
+ return await pollingClient.subscribe();
180
183
  }
181
184
  catch (err) {
182
185
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create['timed-out'], report);
@@ -190,7 +193,7 @@ class PackageVersion {
190
193
  * @param connection
191
194
  */
192
195
  static async getCreateVersionReport(createPackageRequestId, connection) {
193
- return await (0, packageVersionCreateRequestReport_1.getCreatePackageVersionCreateRequestReport)({
196
+ return (0, packageVersionCreateRequestReport_1.getCreatePackageVersionCreateRequestReport)({
194
197
  createPackageVersionRequestId: createPackageRequestId,
195
198
  connection,
196
199
  }).catch((err) => {
@@ -220,19 +223,19 @@ class PackageVersion {
220
223
  poll: async () => {
221
224
  report = await this.getCreateVersionReport(createPackageVersionRequestId, connection);
222
225
  switch (report.Status) {
223
- case 'Queued':
226
+ case Package2VersionStatus.queued:
224
227
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.enqueued, { ...report, remainingWaitTime });
225
228
  remainingWaitTime = kit_1.Duration.seconds(remainingWaitTime.seconds - polling.frequency.seconds);
226
229
  return {
227
230
  completed: false,
228
231
  payload: report,
229
232
  };
230
- case 'InProgress':
231
- case 'Initializing':
232
- case 'VerifyingFeaturesAndSettings':
233
- case 'VerifyingDependencies':
234
- case 'VerifyingMetadata':
235
- case 'FinalizingPackageVersion':
233
+ case Package2VersionStatus.inProgress:
234
+ case Package2VersionStatus.initializing:
235
+ case Package2VersionStatus.verifyingFeaturesAndSettings:
236
+ case Package2VersionStatus.verifyingDependencies:
237
+ case Package2VersionStatus.verifyingMetadata:
238
+ case Package2VersionStatus.finalizingPackageVersion:
236
239
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.progress, {
237
240
  ...report,
238
241
  remainingWaitTime,
@@ -242,7 +245,7 @@ class PackageVersion {
242
245
  completed: false,
243
246
  payload: report,
244
247
  };
245
- case 'Success':
248
+ case Package2VersionStatus.success:
246
249
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.success, report);
247
250
  await new PackageVersion({
248
251
  idOrAlias: report.SubscriberPackageVersionId,
@@ -250,7 +253,7 @@ class PackageVersion {
250
253
  connection,
251
254
  }).updateProjectWithPackageVersion(report);
252
255
  return { completed: true, payload: report };
253
- case 'Error':
256
+ case Package2VersionStatus.error:
254
257
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create.error, report);
255
258
  return { completed: true, payload: report };
256
259
  }
@@ -259,7 +262,7 @@ class PackageVersion {
259
262
  timeout: polling.timeout,
260
263
  });
261
264
  try {
262
- return pollingClient.subscribe();
265
+ return await pollingClient.subscribe();
263
266
  }
264
267
  catch (err) {
265
268
  await core_1.Lifecycle.getInstance().emit(interfaces_1.PackageVersionEvents.create['timed-out'], report);
@@ -417,7 +420,7 @@ class PackageVersion {
417
420
  const pvc = new packageVersionCreate_1.PackageVersionCreate({ ...options, ...this.options });
418
421
  const createResult = await pvc.createPackageVersion();
419
422
  if (polling.timeout?.milliseconds > 0) {
420
- return await PackageVersion.waitForCreateVersion(createResult.Id, this.project, this.connection, polling).catch((err) => {
423
+ return PackageVersion.waitForCreateVersion(createResult.Id, this.project, this.connection, polling).catch((err) => {
421
424
  // TODO
422
425
  // until package2 is GA, wrap perm-based errors w/ 'contact sfdc' action (REMOVE once package2 is GA'd)
423
426
  throw (0, utils_1.applyErrorAction)((0, utils_1.massageErrorMessage)(err));
@@ -276,8 +276,10 @@ class PackageVersionCreate {
276
276
  throw messages.createError('signupDuplicateSettingsSpecified');
277
277
  }
278
278
  ['country', 'edition', 'language', 'features', 'orgPreferences', 'snapshot', 'release', 'sourceOrg'].forEach((prop) => {
279
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
279
280
  const propValue = definitionFileJson[prop];
280
281
  if (propValue) {
282
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
281
283
  packageDescriptorJson[prop] = propValue;
282
284
  }
283
285
  });
@@ -318,7 +320,7 @@ class PackageVersionCreate {
318
320
  // metadata exclusions. If necessary, read the existing package.xml and then re-write it.
319
321
  const currentPackageXml = await fs.promises.readFile(path.join(packageVersMetadataFolder, 'package.xml'), 'utf8');
320
322
  // convert to json
321
- const packageJson = await xml2js.parseStringPromise(currentPackageXml);
323
+ const packageJson = (await xml2js.parseStringPromise(currentPackageXml));
322
324
  if (!packageJson?.Package) {
323
325
  throw messages.createError('packageXmlDoesNotContainPackage');
324
326
  }
@@ -346,7 +348,7 @@ class PackageVersionCreate {
346
348
  }, [clientSideInfo.get('UnpackagedMetadataPath')]);
347
349
  if (excludedProfiles.length > 0) {
348
350
  const profileIdx = typesArr.findIndex((e) => e.name[0] === 'Profile');
349
- typesArr[profileIdx].members = typesArr[profileIdx].members.filter((e) => excludedProfiles.indexOf(e) === -1);
351
+ typesArr[profileIdx].members = typesArr[profileIdx].members.filter((e) => !excludedProfiles.includes(e));
350
352
  }
351
353
  packageJson.Package.types = typesArr;
352
354
  // Re-write the package.xml in case profiles have been added or removed
@@ -443,7 +445,7 @@ class PackageVersionCreate {
443
445
  packageName = pkg.startsWith('0Ho') ? this.project.getAliasesFromPackageId(pkg).find((alias) => alias) : pkg;
444
446
  if (!packageName)
445
447
  throw messages.createError('errorMissingPackage', [this.options.packageId]);
446
- this.packageObject = this.project.findPackage((pkg) => pkg.package === packageName || pkg.name === packageName);
448
+ this.packageObject = this.project.findPackage((namedPackageDir) => namedPackageDir.package === packageName || namedPackageDir.name === packageName);
447
449
  }
448
450
  else {
449
451
  // We'll either have a package ID or alias, or a directory path
@@ -498,7 +500,7 @@ class PackageVersionCreate {
498
500
  }
499
501
  async resolveUserLicenses(includeUserLicenses) {
500
502
  const shouldGenerateProfileInformation = this.logger.shouldLog(core_1.LoggerLevel.INFO) || this.logger.shouldLog(core_1.LoggerLevel.DEBUG);
501
- return await packageProfileApi_1.PackageProfileApi.create({
503
+ return packageProfileApi_1.PackageProfileApi.create({
502
504
  project: this.project,
503
505
  includeUserLicenses,
504
506
  generateProfileInformation: shouldGenerateProfileInformation,
@@ -519,6 +521,7 @@ class PackageVersionCreate {
519
521
  /**
520
522
  * Cleans invalid attribute(s) from the packageDescriptorJSON
521
523
  */
524
+ // eslint-disable-next-line class-methods-use-this
522
525
  cleanPackageDescriptorJson(packageDescriptorJson) {
523
526
  delete packageDescriptorJson.default; // for client-side use only, not needed
524
527
  delete packageDescriptorJson.includeProfileUserLicenses; // for client-side use only, not needed
@@ -570,6 +573,7 @@ class PackageVersionCreate {
570
573
  packageDescriptorJson.uninstallScript = options.uninstallscript;
571
574
  }
572
575
  }
576
+ // eslint-disable-next-line class-methods-use-this
573
577
  validateVersionNumber(versionNumberString, supportedBuildNumberToken, supportedBuildNumberToken2) {
574
578
  const versionNumber = utils_1.VersionNumber.from(versionNumberString);
575
579
  // build number can be a number or valid token
@@ -651,16 +655,16 @@ class PackageVersionCreate {
651
655
  }
652
656
  if (!explicitUseNoAncestor && packageDescriptorJson.ancestorVersion) {
653
657
  const regNumbers = new RegExp('^[0-9]+$');
654
- const versionNumber = packageDescriptorJson.ancestorVersion.split(utils_2.VERSION_NUMBER_SEP);
655
- if (versionNumber.length < 3 ||
656
- versionNumber.length > 4 ||
657
- !versionNumber[0].match(regNumbers) ||
658
- !versionNumber[1].match(regNumbers) ||
659
- !versionNumber[2].match(regNumbers)) {
658
+ const versionNumberSplit = packageDescriptorJson.ancestorVersion.split(utils_2.VERSION_NUMBER_SEP);
659
+ if (versionNumberSplit.length < 3 ||
660
+ versionNumberSplit.length > 4 ||
661
+ !versionNumberSplit[0].match(regNumbers) ||
662
+ !versionNumberSplit[1].match(regNumbers) ||
663
+ !versionNumberSplit[2].match(regNumbers)) {
660
664
  throw new Error(messages.getMessage('errorInvalidAncestorVersionFormat', [packageDescriptorJson.ancestorVersion]));
661
665
  }
662
666
  const query = 'SELECT Id, IsReleased FROM Package2Version ' +
663
- `WHERE Package2Id = '${packageId}' AND MajorVersion = ${versionNumber[0]} AND MinorVersion = ${versionNumber[1]} AND PatchVersion = ${versionNumber[2]}`;
667
+ `WHERE Package2Id = '${packageId}' AND MajorVersion = ${versionNumberSplit[0]} AND MinorVersion = ${versionNumberSplit[1]} AND PatchVersion = ${versionNumberSplit[2]}`;
664
668
  let queriedAncestorId;
665
669
  const ancestorVersionResult = await this.connection.tooling.query(query);
666
670
  if (!ancestorVersionResult || !ancestorVersionResult.totalSize) {
@@ -687,6 +691,7 @@ class PackageVersionCreate {
687
691
  }
688
692
  return this.validateAncestorId(ancestorId, highestReleasedVersion, explicitUseNoAncestor, versionNumber.patch !== '0', skipAncestorCheck, origSpecifiedAncestor);
689
693
  }
694
+ // eslint-disable-next-line class-methods-use-this
690
695
  validateAncestorId(ancestorId, highestReleasedVersion, explicitUseNoAncestor, isPatch, skipAncestorCheck, origSpecifiedAncestor) {
691
696
  if (explicitUseNoAncestor) {
692
697
  if (!highestReleasedVersion) {
@@ -716,7 +721,10 @@ class PackageVersionCreate {
716
721
  async getAncestorIdHighestRelease(packageId, versionNumberString, explicitUseHighestRelease, skipAncestorCheck) {
717
722
  const versionNumber = versionNumberString.split(utils_2.VERSION_NUMBER_SEP);
718
723
  const isPatch = versionNumber[2] !== '0';
719
- const result = { finalAncestorId: null, highestReleasedVersion: null };
724
+ const result = {
725
+ finalAncestorId: null,
726
+ highestReleasedVersion: null,
727
+ };
720
728
  if (isPatch && explicitUseHighestRelease) {
721
729
  // based on server-side validation, whatever ancestor is specified for a patch is
722
730
  // tightly controlled; therefore we only need concern ourselves if explicitUseHighestRelease == true;
@@ -743,7 +751,7 @@ class PackageVersionCreate {
743
751
  'ORDER BY MajorVersion Desc, MinorVersion Desc, PatchVersion Desc, BuildNumber Desc LIMIT 1';
744
752
  const highestVersionResult = await this.connection.tooling.query(query);
745
753
  const highestVersionRecords = highestVersionResult.records;
746
- if (highestVersionRecords && highestVersionRecords[0]) {
754
+ if (highestVersionRecords?.[0]) {
747
755
  result.highestReleasedVersion = highestVersionRecords[0];
748
756
  if (explicitUseHighestRelease) {
749
757
  result.finalAncestorId = result.highestReleasedVersion.Id;
@@ -18,16 +18,13 @@ const QUERY = 'SELECT Id, Status, Package2Id, Package2VersionId, Package2Version
18
18
  'FROM Package2VersionCreateRequest ' +
19
19
  '%s' + // WHERE, if applicable
20
20
  'ORDER BY CreatedDate desc';
21
- const ERROR_QUERY = "SELECT Message FROM Package2VersionCreateRequestError WHERE ParentRequest.Id = '%s'";
22
21
  function formatDate(date) {
23
- const pad = (num) => {
24
- return num < 10 ? `0${num}` : `${num}`;
25
- };
22
+ const pad = (num) => (num < 10 ? `0${num}` : `${num}`);
26
23
  return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
27
24
  }
28
25
  async function list(options) {
29
26
  try {
30
- const whereClause = _constructWhere(options);
27
+ const whereClause = constructWhere(options);
31
28
  return await query(util.format(QUERY, whereClause), options.connection);
32
29
  }
33
30
  catch (err) {
@@ -38,11 +35,12 @@ exports.list = list;
38
35
  async function byId(packageVersionCreateRequestId, connection) {
39
36
  const results = await query(util.format(QUERY, `WHERE Id = '${packageVersionCreateRequestId}' `), connection);
40
37
  if (results && results.length === 1 && results[0].Status === STATUS_ERROR) {
41
- results[0].Error = await _queryErrors(packageVersionCreateRequestId, connection);
38
+ results[0].Error = await queryForErrors(packageVersionCreateRequestId, connection);
42
39
  }
43
40
  return results;
44
41
  }
45
42
  exports.byId = byId;
43
+ // eslint-disable-next-line @typescript-eslint/no-shadow
46
44
  async function query(query, connection) {
47
45
  const queryResult = await connection.autoFetchQuery(query, { tooling: true });
48
46
  return (queryResult.records ? queryResult.records : []).map((record) => ({
@@ -59,9 +57,9 @@ async function query(query, connection) {
59
57
  CreatedBy: record.CreatedById,
60
58
  }));
61
59
  }
62
- async function _queryErrors(packageVersionCreateRequestId, connection) {
60
+ async function queryForErrors(packageVersionCreateRequestId, connection) {
63
61
  const errorResults = [];
64
- const queryResult = await connection.tooling.query(util.format(ERROR_QUERY, packageVersionCreateRequestId));
62
+ const queryResult = await connection.tooling.query(util.format("SELECT Message FROM Package2VersionCreateRequestError WHERE ParentRequest.Id = '%s'", packageVersionCreateRequestId));
65
63
  if (queryResult.records) {
66
64
  queryResult.records.forEach((record) => {
67
65
  errorResults.push(record.Message);
@@ -69,7 +67,7 @@ async function _queryErrors(packageVersionCreateRequestId, connection) {
69
67
  }
70
68
  return errorResults;
71
69
  }
72
- function _constructWhere(options) {
70
+ function constructWhere(options) {
73
71
  const where = [];
74
72
  if (options?.id) {
75
73
  where.push(`Id = '${options.id}'`);
@@ -48,11 +48,9 @@ async function getPackageVersionReport(options) {
48
48
  const ancestorVersionMap = await pkgUtils.getPackageVersionStrings([record.AncestorId], options.connection);
49
49
  record.AncestorVersion = ancestorVersionMap.get(record.AncestorId);
50
50
  }
51
- else {
52
- if (record.PackageType !== 'Managed') {
53
- record.AncestorVersion = null;
54
- record.AncestorId = null;
55
- }
51
+ else if (record.PackageType !== 'Managed') {
52
+ record.AncestorVersion = null;
53
+ record.AncestorId = null;
56
54
  }
57
55
  record.HasPassedCodeCoverageCheck =
58
56
  record.Package2.IsOrgDependent === true || record.ValidationSkipped === true
@@ -297,7 +297,7 @@ class SubscriberPackageVersion {
297
297
  // before starting the install, check to see if the package version is available for install
298
298
  await (0, packageInstall_1.waitForPublish)(this.connection, await this.getId(), options.publishFrequency, options.publishTimeout, pkgInstallCreateRequest.Password);
299
299
  const pkgVersionInstallRequest = await (0, packageInstall_1.createPackageInstallRequest)(this.connection, pkgInstallCreateRequest, await this.getPackageType());
300
- return SubscriberPackageVersion.installStatus(this.connection, pkgVersionInstallRequest.Id, pkgInstallCreateRequest.Password, options);
300
+ return await SubscriberPackageVersion.installStatus(this.connection, pkgVersionInstallRequest.Id, pkgInstallCreateRequest.Password, options);
301
301
  }
302
302
  catch (e) {
303
303
  throw (0, utils_1.applyErrorAction)((0, utils_1.massageErrorMessage)(e));
@@ -310,7 +310,7 @@ class SubscriberPackageVersion {
310
310
  * @param wait
311
311
  */
312
312
  async uninstall(frequency = kit_1.Duration.milliseconds(0), wait = kit_1.Duration.milliseconds(0)) {
313
- return await (0, packageUninstall_1.uninstallPackage)(await this.getId(), this.connection, frequency, wait);
313
+ return (0, packageUninstall_1.uninstallPackage)(await this.getId(), this.connection, frequency, wait);
314
314
  }
315
315
  /**
316
316
  * Returns an array of RSS and CSP external sites for the package.
@@ -338,6 +338,7 @@ class SubscriberPackageVersion {
338
338
  }
339
339
  return Reflect.get(this.data || {}, field);
340
340
  }
341
+ // eslint-disable-next-line class-methods-use-this
341
342
  getFieldsForQuery(options) {
342
343
  return exports.SubscriberPackageVersionFields.filter((field) => !highCostQueryFields.includes(field) || options.includeHighCostFields);
343
344
  }
@@ -104,9 +104,11 @@ class Package1Version {
104
104
  await core_1.Lifecycle.getInstance().emit(interfaces_1.Package1VersionEvents.create.progress, { timeout, pollingResult });
105
105
  return { completed: false, payload: pollingResult };
106
106
  default: {
107
- if (pollingResult?.Errors?.errors?.length > 0) {
107
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
108
+ const errors = pollingResult?.Errors?.errors;
109
+ if (errors?.length > 0) {
108
110
  throw messages.createError('package1VersionCreateCommandUploadFailure', [
109
- pollingResult.Errors.errors.map((e) => e.message).join(os.EOL),
111
+ errors.map((e) => e.message).join(os.EOL),
110
112
  ]);
111
113
  }
112
114
  else {
@@ -25,7 +25,7 @@ export declare const BY_PREFIX: IdRegistry;
25
25
  export declare const BY_LABEL: IdRegistry;
26
26
  export declare function validateId(idObj: Many<IdRegistryValue>, value: string): void;
27
27
  export declare function getSourceApiVersion(project: SfProject): string;
28
- export declare function validateIdNoThrow(idObj: Many<IdRegistryValue>, value: any): IdRegistryValue | false;
28
+ export declare function validateIdNoThrow(idObj: Many<IdRegistryValue>, value: string): IdRegistryValue | boolean;
29
29
  export declare function applyErrorAction(err: Error): Error;
30
30
  export declare function massageErrorMessage(err: Error): Error;
31
31
  /**
@@ -44,12 +44,8 @@ exports.DEFAULT_PACKAGE_DIR = {
44
44
  versionNumber: '0.1.0.NEXT',
45
45
  default: true,
46
46
  };
47
- exports.BY_PREFIX = (() => {
48
- return Object.fromEntries(ID_REGISTRY.map((id) => [id.prefix, { prefix: id.prefix, label: id.label }]));
49
- })();
50
- exports.BY_LABEL = (() => {
51
- return Object.fromEntries(ID_REGISTRY.map((id) => [id.label.replace(/ /g, '_').toUpperCase(), { prefix: id.prefix, label: id.label }]));
52
- })();
47
+ exports.BY_PREFIX = (() => Object.fromEntries(ID_REGISTRY.map((id) => [id.prefix, { prefix: id.prefix, label: id.label }])))();
48
+ exports.BY_LABEL = (() => Object.fromEntries(ID_REGISTRY.map((id) => [id.label.replace(/ /g, '_').toUpperCase(), { prefix: id.prefix, label: id.label }])))();
53
49
  function validateId(idObj, value) {
54
50
  if (!validateIdNoThrow(idObj, value)) {
55
51
  throw messages.createError('invalidIdOrAlias', [
@@ -61,8 +57,7 @@ function validateId(idObj, value) {
61
57
  }
62
58
  exports.validateId = validateId;
63
59
  function getSourceApiVersion(project) {
64
- const apiVersion = project.getSfProjectJson().get('sourceApiVersion');
65
- return apiVersion;
60
+ return project?.getSfProjectJson().get('sourceApiVersion');
66
61
  }
67
62
  exports.getSourceApiVersion = getSourceApiVersion;
68
63
  function validateIdNoThrow(idObj, value) {
@@ -259,6 +254,7 @@ async function queryWithInConditionChunking(query, items, replaceToken, connecti
259
254
  }
260
255
  const itemsStr = `${items.slice(itemsQueried, itemsQueried + chunkCount).join("','")}`;
261
256
  const queryChunk = query.replace(replaceToken, itemsStr);
257
+ // eslint-disable-next-line no-await-in-loop
262
258
  const result = await connection.tooling.query(queryChunk);
263
259
  if (result && result.records.length > 0) {
264
260
  records = records.concat(result.records);
@@ -367,9 +363,7 @@ async function generatePackageAliasEntry(connection, project, packageVersionId,
367
363
  }
368
364
  exports.generatePackageAliasEntry = generatePackageAliasEntry;
369
365
  function formatDate(date) {
370
- const pad = (num) => {
371
- return num < 10 ? `0${num}` : `${num}`;
372
- };
366
+ const pad = (num) => (num < 10 ? `0${num}` : `${num}`);
373
367
  return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
374
368
  }
375
369
  exports.formatDate = formatDate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/packaging",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "packing libraries to Salesforce packaging platform",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",
@@ -57,7 +57,7 @@
57
57
  "devDependencies": {
58
58
  "@salesforce/cli-plugins-testkit": "^3.2.2",
59
59
  "@salesforce/dev-config": "^3.1.0",
60
- "@salesforce/dev-scripts": "^2.0.4",
60
+ "@salesforce/dev-scripts": "^3.1.0",
61
61
  "@salesforce/prettier-config": "^0.0.2",
62
62
  "@salesforce/ts-sinon": "^1.4.1",
63
63
  "@types/debug": "4.1.7",
@@ -70,17 +70,16 @@
70
70
  "commitizen": "^4.2.4",
71
71
  "eslint": "^8.26.0",
72
72
  "eslint-config-prettier": "^8.5.0",
73
- "eslint-config-salesforce": "^0.1.6",
73
+ "eslint-config-salesforce": "^1.1.0",
74
74
  "eslint-config-salesforce-license": "^0.1.6",
75
- "eslint-config-salesforce-typescript": "^0.2.8",
75
+ "eslint-config-salesforce-typescript": "^1.1.1",
76
76
  "eslint-plugin-header": "3.1.1",
77
77
  "eslint-plugin-import": "^2.26.0",
78
78
  "eslint-plugin-jsdoc": "^39.3.25",
79
- "eslint-plugin-prettier": "^4.0.0",
80
79
  "husky": "^8.0.1",
81
80
  "mocha": "^10.0.0",
82
81
  "nyc": "^15.1.0",
83
- "prettier": "^2.6.2",
82
+ "prettier": "^2.7.1",
84
83
  "pretty-quick": "^3.1.3",
85
84
  "shelljs": "0.8.5",
86
85
  "sinon": "14.0.1",