@salesforce/core 3.24.2 → 3.24.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [3.24.3](https://github.com/forcedotcom/sfdx-core/compare/v3.24.2...v3.24.3) (2022-07-28)
6
+
7
+ ### Bug Fixes
8
+
9
+ - handle ancestor keywords when creating scratch org ([72af55a](https://github.com/forcedotcom/sfdx-core/commit/72af55a53b87f1d81d22dc4e53891b3b0ab2966f))
10
+
5
11
  ### [3.24.2](https://github.com/forcedotcom/sfdx-core/compare/v3.24.1...v3.24.2) (2022-07-26)
6
12
 
7
13
  ### Bug Fixes
@@ -67,13 +67,34 @@ const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
67
67
  const ancestorIds = await Promise.all(packagesWithAncestors.map(async (packageDir) => {
68
68
  // ancestorID can be 05i, or 04t, alias; OR "ancestorVersion": "4.6.0.1"
69
69
  // according to docs, 05i is not ok: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev2gp_config_file.htm
70
+ // package can be an ID, but not according to docs
71
+ const packageAliases = projectJson.get('packageAliases');
72
+ const packageId = packageAliases[(0, ts_types_1.ensureString)(packageDir.package)] ?? packageDir.package;
73
+ // Handle HIGHEST and NONE in ancestor(Version|Id).
74
+ // Precedence chain: NONE -> HIGHEST -> ancestorVersion & ancestoryId
75
+ if (packageDir.ancestorVersion === 'NONE' || packageDir.ancestorId === 'NONE') {
76
+ return '';
77
+ }
78
+ else if (packageDir.ancestorVersion === 'HIGHEST' || packageDir.ancestorId === 'HIGHEST') {
79
+ const query = 'SELECT Id FROM Package2Version ' +
80
+ `WHERE Package2Id = '${packageId}' AND IsReleased = True AND IsDeprecated = False AND PatchVersion = 0 ` +
81
+ 'ORDER BY MajorVersion Desc, MinorVersion Desc, PatchVersion Desc, BuildNumber Desc LIMIT 1';
82
+ try {
83
+ return (await hubOrg.getConnection().singleRecordQuery(query, { tooling: true })).Id;
84
+ }
85
+ catch (err) {
86
+ if (packageDir.ancestorVersion === 'HIGHEST') {
87
+ throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorError', [packageDir.ancestorVersion, packageDir.package]), 'NoMatchingAncestorError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorVersion])]);
88
+ }
89
+ else {
90
+ throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorIdError', [packageDir.ancestorId, packageDir.package]), 'NoMatchingAncestorIdError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorId])]);
91
+ }
92
+ }
93
+ }
70
94
  if (packageDir.ancestorVersion) {
71
95
  if (!/^[0-9]+.[0-9]+.[0-9]+(.[0-9]+)?$/.test(packageDir.ancestorVersion)) {
72
96
  throw messages.createError('InvalidAncestorVersionFormatError', [packageDir.ancestorVersion]);
73
97
  }
74
- // package can be an ID, but not according to docs
75
- const packageAliases = projectJson.get('packageAliases');
76
- const packageId = packageAliases[(0, ts_types_1.ensureString)(packageDir.package)] ?? packageDir.package;
77
98
  const [major, minor, patch] = packageDir.ancestorVersion.split('.');
78
99
  let releasedAncestor;
79
100
  try {
@@ -102,14 +123,14 @@ const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
102
123
  .getConnection()
103
124
  .singleRecordQuery(`SELECT Id FROM Package2Version WHERE SubscriberPackageVersionId = '${packageDir.ancestorId}'`, { tooling: true })).Id;
104
125
  }
105
- // ancestorID can be an alias get it from projectJson
106
- const packageAliases = projectJson.get('packageAliases');
126
+ // ancestorID can be an alias; get it from projectJson
107
127
  if (packageDir.ancestorId && packageAliases?.[packageDir.ancestorId]) {
108
128
  return packageAliases[packageDir.ancestorId];
109
129
  }
110
130
  throw new sfError_1.SfError(`Invalid ancestorId ${packageDir.ancestorId}`, 'InvalidAncestorId');
111
131
  }));
112
- return Array.from(new Set(ancestorIds)).join(';');
132
+ // strip out '' due to NONE
133
+ return Array.from(new Set(ancestorIds.filter((id) => id !== ''))).join(';');
113
134
  };
114
135
  exports.getAncestorIds = getAncestorIds;
115
136
  /**
@@ -8,7 +8,11 @@ The ancestor versionNumber must be in the format major.minor.patch but the value
8
8
 
9
9
  # NoMatchingAncestorError
10
10
 
11
- The ancestorId for ancestorVersion %s can't be found. Package ID %s.",
11
+ The ancestor for ancestorVersion %s can't be found. Package ID %s.",
12
+
13
+ # NoMatchingAncestorIdError
14
+
15
+ The ancestor for ancestorId [%s] can't be found. Package ID %s."
12
16
 
13
17
  # AncestorNotReleasedError
14
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "3.24.2",
3
+ "version": "3.24.3",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",