@salesforce/core 3.30.7 → 3.30.9
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/org/scratchOrgCreate.js +5 -2
- package/lib/sfProject.d.ts +7 -1
- package/lib/sfProject.js +26 -9
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ const ts_types_1 = require("@salesforce/ts-types");
|
|
|
12
12
|
const messages_1 = require("../messages");
|
|
13
13
|
const logger_1 = require("../logger");
|
|
14
14
|
const configAggregator_1 = require("../config/configAggregator");
|
|
15
|
+
const orgConfigProperties_1 = require("../org/orgConfigProperties");
|
|
15
16
|
const sfProject_1 = require("../sfProject");
|
|
16
17
|
const stateAggregator_1 = require("../stateAggregator");
|
|
17
18
|
const org_1 = require("./org");
|
|
@@ -79,13 +80,14 @@ const scratchOrgResume = async (jobId) => {
|
|
|
79
80
|
retry: 0,
|
|
80
81
|
});
|
|
81
82
|
const scratchOrg = await org_1.Org.create({ aliasOrUsername: username });
|
|
83
|
+
const configAggregator = await configAggregator_1.ConfigAggregator.create();
|
|
82
84
|
await (0, scratchOrgLifecycleEvents_1.emit)({ stage: 'deploy settings', scratchOrgInfo: soi });
|
|
83
85
|
const settingsGenerator = new scratchOrgSettingsGenerator_1.default();
|
|
84
86
|
settingsGenerator.extract({ ...soi, ...definitionjson });
|
|
85
87
|
const [authInfo] = await Promise.all([
|
|
86
88
|
(0, scratchOrgInfoApi_1.resolveUrl)(scratchOrgAuthInfo),
|
|
87
89
|
(0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, apiVersion ??
|
|
88
|
-
|
|
90
|
+
configAggregator.getPropertyValue(orgConfigProperties_1.OrgConfigProperties.ORG_API_VERSION) ??
|
|
89
91
|
(await scratchOrg.retrieveMaxApiVersion())),
|
|
90
92
|
]);
|
|
91
93
|
await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
|
|
@@ -174,10 +176,11 @@ const scratchOrgCreate = async (options) => {
|
|
|
174
176
|
const username = scratchOrg.getUsername();
|
|
175
177
|
logger.debug(`scratch org username ${username}`);
|
|
176
178
|
await (0, scratchOrgLifecycleEvents_1.emit)({ stage: 'deploy settings', scratchOrgInfo: soi });
|
|
179
|
+
const configAggregator = await configAggregator_1.ConfigAggregator.create();
|
|
177
180
|
const [authInfo] = await Promise.all([
|
|
178
181
|
(0, scratchOrgInfoApi_1.resolveUrl)(scratchOrgAuthInfo),
|
|
179
182
|
(0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, apiversion ??
|
|
180
|
-
|
|
183
|
+
configAggregator.getPropertyValue(orgConfigProperties_1.OrgConfigProperties.ORG_API_VERSION) ??
|
|
181
184
|
(await scratchOrg.retrieveMaxApiVersion())),
|
|
182
185
|
]);
|
|
183
186
|
await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
|
package/lib/sfProject.d.ts
CHANGED
|
@@ -150,7 +150,7 @@ export declare class SfProjectJson extends ConfigFile {
|
|
|
150
150
|
*
|
|
151
151
|
* @param packageDir
|
|
152
152
|
*/
|
|
153
|
-
addPackageDirectory(packageDir:
|
|
153
|
+
addPackageDirectory(packageDir: NamedPackageDir): void;
|
|
154
154
|
private doesPackageExist;
|
|
155
155
|
private validateKeys;
|
|
156
156
|
}
|
|
@@ -285,6 +285,12 @@ export declare class SfProject {
|
|
|
285
285
|
* @param packageName Name of the package directory. E.g., 'force-app'
|
|
286
286
|
*/
|
|
287
287
|
getPackage(packageName: string): Optional<NamedPackageDir>;
|
|
288
|
+
/**
|
|
289
|
+
* Returns the package directory.
|
|
290
|
+
*
|
|
291
|
+
* @param packageName Name of the package directory. E.g., 'force-app'
|
|
292
|
+
*/
|
|
293
|
+
findPackage(predicate: (packageDir: NamedPackageDir) => boolean): Optional<NamedPackageDir>;
|
|
288
294
|
/**
|
|
289
295
|
* Returns the absolute path of the package directory ending with the path separator.
|
|
290
296
|
* E.g., /Users/jsmith/projects/ebikes-lwc/force-app/
|
package/lib/sfProject.js
CHANGED
|
@@ -220,12 +220,12 @@ class SfProjectJson extends configFile_1.ConfigFile {
|
|
|
220
220
|
* for packaging operations that want to do something for each package entry.
|
|
221
221
|
*/
|
|
222
222
|
getUniquePackageDirectories() {
|
|
223
|
-
const visited =
|
|
223
|
+
const visited = new Set();
|
|
224
224
|
const uniqueValues = [];
|
|
225
225
|
// Keep original order defined in sfdx-project.json
|
|
226
226
|
this.getPackageDirectoriesSync().forEach((packageDir) => {
|
|
227
|
-
if (!visited
|
|
228
|
-
visited
|
|
227
|
+
if (!visited.has(packageDir.name)) {
|
|
228
|
+
visited.add(packageDir.name);
|
|
229
229
|
uniqueValues.push(packageDir);
|
|
230
230
|
}
|
|
231
231
|
});
|
|
@@ -289,10 +289,19 @@ class SfProjectJson extends configFile_1.ConfigFile {
|
|
|
289
289
|
* @param packageDir
|
|
290
290
|
*/
|
|
291
291
|
addPackageDirectory(packageDir) {
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
// there is no notion of uniqueness in package directory entries
|
|
293
|
+
// so an attempt of matching an existing entry is a bit convoluted
|
|
294
|
+
// an entry w/o a package or id is considered a directory entry for which a package has yet to be created
|
|
295
|
+
// so first attempt is to find a matching dir entry that where path is the same and id and package are not present
|
|
296
|
+
// if that fails, then find a matching dir entry package is present and is same as the new entry
|
|
297
|
+
const dirIndex = this.getContents().packageDirectories.findIndex((pd) => {
|
|
298
|
+
const withId = pd;
|
|
299
|
+
return ((withId.path === packageDir.path && !withId.id && !withId.package) ||
|
|
300
|
+
(!!packageDir.package && packageDir.package === withId.package));
|
|
294
301
|
});
|
|
302
|
+
// merge new package dir with existing entry, if present
|
|
295
303
|
const packageDirEntry = Object.assign({}, dirIndex > -1 ? this.getContents().packageDirectories[dirIndex] : packageDir, packageDir);
|
|
304
|
+
// update package dir entries
|
|
296
305
|
if (dirIndex > -1) {
|
|
297
306
|
this.getContents().packageDirectories[dirIndex] = packageDirEntry;
|
|
298
307
|
}
|
|
@@ -489,7 +498,7 @@ class SfProject {
|
|
|
489
498
|
*/
|
|
490
499
|
getPackageFromPath(path) {
|
|
491
500
|
const packageDirs = this.getPackageDirectories();
|
|
492
|
-
const match = packageDirs.find((packageDir) => (0, path_1.basename)(path) === packageDir.
|
|
501
|
+
const match = packageDirs.find((packageDir) => (0, path_1.basename)(path) === packageDir.path || path.includes(packageDir.fullPath));
|
|
493
502
|
return match;
|
|
494
503
|
}
|
|
495
504
|
/**
|
|
@@ -499,7 +508,7 @@ class SfProject {
|
|
|
499
508
|
*/
|
|
500
509
|
getPackageNameFromPath(path) {
|
|
501
510
|
const packageDir = this.getPackageFromPath(path);
|
|
502
|
-
return packageDir ? packageDir.
|
|
511
|
+
return packageDir ? packageDir.package || packageDir.path : undefined;
|
|
503
512
|
}
|
|
504
513
|
/**
|
|
505
514
|
* Returns the package directory.
|
|
@@ -510,6 +519,14 @@ class SfProject {
|
|
|
510
519
|
const packageDirs = this.getPackageDirectories();
|
|
511
520
|
return packageDirs.find((packageDir) => packageDir.name === packageName);
|
|
512
521
|
}
|
|
522
|
+
/**
|
|
523
|
+
* Returns the package directory.
|
|
524
|
+
*
|
|
525
|
+
* @param packageName Name of the package directory. E.g., 'force-app'
|
|
526
|
+
*/
|
|
527
|
+
findPackage(predicate) {
|
|
528
|
+
return this.getPackageDirectories().find(predicate);
|
|
529
|
+
}
|
|
513
530
|
/**
|
|
514
531
|
* Returns the absolute path of the package directory ending with the path separator.
|
|
515
532
|
* E.g., /Users/jsmith/projects/ebikes-lwc/force-app/
|
|
@@ -518,7 +535,7 @@ class SfProject {
|
|
|
518
535
|
*/
|
|
519
536
|
getPackagePath(packageName) {
|
|
520
537
|
const packageDir = this.getPackage(packageName);
|
|
521
|
-
return packageDir
|
|
538
|
+
return packageDir?.fullPath;
|
|
522
539
|
}
|
|
523
540
|
/**
|
|
524
541
|
* Has package directories defined in the project.
|
|
@@ -561,7 +578,7 @@ class SfProject {
|
|
|
561
578
|
if (!this.hasPackages()) {
|
|
562
579
|
throw new sfError_1.SfError('The sfdx-project.json does not have any packageDirectories defined.');
|
|
563
580
|
}
|
|
564
|
-
const defaultPackage = this.
|
|
581
|
+
const defaultPackage = this.findPackage((packageDir) => packageDir.default === true);
|
|
565
582
|
return defaultPackage || this.getPackageDirectories()[0];
|
|
566
583
|
}
|
|
567
584
|
/**
|