@salesforce/core 7.3.12 → 7.4.1
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.
|
@@ -18,6 +18,7 @@ const configAggregator_1 = require("../config/configAggregator");
|
|
|
18
18
|
const orgConfigProperties_1 = require("../org/orgConfigProperties");
|
|
19
19
|
const sfProject_1 = require("../sfProject");
|
|
20
20
|
const stateAggregator_1 = require("../stateAggregator/stateAggregator");
|
|
21
|
+
const sfError_1 = require("../sfError");
|
|
21
22
|
const org_1 = require("./org");
|
|
22
23
|
const scratchOrgInfoApi_1 = require("./scratchOrgInfoApi");
|
|
23
24
|
const scratchOrgSettingsGenerator_1 = __importDefault(require("./scratchOrgSettingsGenerator"));
|
|
@@ -77,6 +78,12 @@ const scratchOrgResume = async (jobId) => {
|
|
|
77
78
|
signupTargetLoginUrlConfig,
|
|
78
79
|
retry: 0,
|
|
79
80
|
});
|
|
81
|
+
await setExitCodeIfError(68)(scratchOrgAuthInfo.handleAliasAndDefaultSettings({
|
|
82
|
+
alias,
|
|
83
|
+
setDefault: setDefault ?? false,
|
|
84
|
+
setDefaultDevHub: false,
|
|
85
|
+
setTracksSource: tracksSource ?? true,
|
|
86
|
+
}));
|
|
80
87
|
const scratchOrg = await org_1.Org.create({ aliasOrUsername: username });
|
|
81
88
|
const configAggregator = await configAggregator_1.ConfigAggregator.create();
|
|
82
89
|
await (0, scratchOrgLifecycleEvents_1.emit)({ stage: 'deploy settings', scratchOrgInfo: soi });
|
|
@@ -85,18 +92,12 @@ const scratchOrgResume = async (jobId) => {
|
|
|
85
92
|
capitalizeRecordTypes,
|
|
86
93
|
});
|
|
87
94
|
await settingsGenerator.extract({ ...soi, ...definitionjson });
|
|
88
|
-
const [authInfo] = await Promise.all([
|
|
95
|
+
const [authInfo] = await setExitCodeIfError(68)(Promise.all([
|
|
89
96
|
(0, scratchOrgInfoApi_1.resolveUrl)(scratchOrgAuthInfo),
|
|
90
97
|
(0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, apiVersion ??
|
|
91
98
|
configAggregator.getPropertyValue(orgConfigProperties_1.OrgConfigProperties.ORG_API_VERSION) ??
|
|
92
99
|
(await scratchOrg.retrieveMaxApiVersion())),
|
|
93
|
-
]);
|
|
94
|
-
await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
|
|
95
|
-
alias,
|
|
96
|
-
setDefault: setDefault ?? false,
|
|
97
|
-
setDefaultDevHub: false,
|
|
98
|
-
setTracksSource: tracksSource ?? true,
|
|
99
|
-
});
|
|
100
|
+
]));
|
|
100
101
|
cache.unset(soi.Id ?? jobId);
|
|
101
102
|
const authFields = authInfo.getFields();
|
|
102
103
|
await Promise.all([(0, scratchOrgLifecycleEvents_1.emit)({ stage: 'done', scratchOrgInfo: soi }), cache.write(), (0, scratchOrgLifecycleEvents_1.emitPostOrgCreate)(authFields)]);
|
|
@@ -176,30 +177,29 @@ const scratchOrgCreate = async (options) => {
|
|
|
176
177
|
signupTargetLoginUrlConfig,
|
|
177
178
|
retry: retry || 0,
|
|
178
179
|
});
|
|
180
|
+
// anything after this point (org is created and auth'd) is potentially recoverable with the resume scratch command.
|
|
181
|
+
await setExitCodeIfError(68)(scratchOrgAuthInfo.handleAliasAndDefaultSettings({
|
|
182
|
+
...{
|
|
183
|
+
alias,
|
|
184
|
+
setDefault,
|
|
185
|
+
setDefaultDevHub: false,
|
|
186
|
+
setTracksSource: tracksSource === false ? false : true,
|
|
187
|
+
},
|
|
188
|
+
}));
|
|
179
189
|
// we'll need this scratch org connection later;
|
|
180
|
-
const scratchOrg = await org_1.Org.create({
|
|
181
|
-
aliasOrUsername: soi.Username ?? soi.SignupUsername,
|
|
182
|
-
});
|
|
190
|
+
const scratchOrg = await org_1.Org.create({ aliasOrUsername: soi.Username ?? soi.SignupUsername });
|
|
183
191
|
const username = scratchOrg.getUsername();
|
|
184
192
|
logger.debug(`scratch org username ${username}`);
|
|
185
193
|
await (0, scratchOrgLifecycleEvents_1.emit)({ stage: 'deploy settings', scratchOrgInfo: soi });
|
|
186
194
|
const configAggregator = await configAggregator_1.ConfigAggregator.create();
|
|
187
|
-
const [authInfo] = await Promise.all([
|
|
195
|
+
const [authInfo] = await setExitCodeIfError(68)(Promise.all([
|
|
188
196
|
(0, scratchOrgInfoApi_1.resolveUrl)(scratchOrgAuthInfo),
|
|
189
197
|
(0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, apiversion ??
|
|
190
198
|
configAggregator.getPropertyValue(orgConfigProperties_1.OrgConfigProperties.ORG_API_VERSION) ??
|
|
191
199
|
(await scratchOrg.retrieveMaxApiVersion()),
|
|
192
200
|
// some of our "wait" time has already been used. Calculate how much remains that we can spend on the deployment.
|
|
193
201
|
kit_1.Duration.milliseconds(wait.milliseconds - (Date.now() - startTimestamp))),
|
|
194
|
-
]);
|
|
195
|
-
await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
|
|
196
|
-
...{
|
|
197
|
-
alias,
|
|
198
|
-
setDefault,
|
|
199
|
-
setDefaultDevHub: false,
|
|
200
|
-
setTracksSource: tracksSource === false ? false : true,
|
|
201
|
-
},
|
|
202
|
-
});
|
|
202
|
+
]));
|
|
203
203
|
cache.unset(scratchOrgInfoId);
|
|
204
204
|
const authFields = authInfo.getFields();
|
|
205
205
|
await Promise.all([(0, scratchOrgLifecycleEvents_1.emit)({ stage: 'done', scratchOrgInfo: soi }), cache.write(), (0, scratchOrgLifecycleEvents_1.emitPostOrgCreate)(authFields)]);
|
|
@@ -225,9 +225,17 @@ const getSignupTargetLoginUrl = async () => {
|
|
|
225
225
|
async function getCapitalizeRecordTypesConfig() {
|
|
226
226
|
const configAgg = await configAggregator_1.ConfigAggregator.create();
|
|
227
227
|
const value = configAgg.getInfo('org-capitalize-record-types').value;
|
|
228
|
-
|
|
229
|
-
return (0, kit_1.toBoolean)(value);
|
|
230
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
231
|
-
return value;
|
|
228
|
+
return value !== undefined ? (0, kit_1.toBoolean)(value) : undefined;
|
|
232
229
|
}
|
|
230
|
+
/** wrap an async function, intercept error and set the given exit code */
|
|
231
|
+
const setExitCodeIfError = (exitCode) => async (p) => {
|
|
232
|
+
try {
|
|
233
|
+
return await p;
|
|
234
|
+
}
|
|
235
|
+
catch (e) {
|
|
236
|
+
const sfError = sfError_1.SfError.wrap(e);
|
|
237
|
+
sfError.exitCode = exitCode;
|
|
238
|
+
throw sfError;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
233
241
|
//# sourceMappingURL=scratchOrgCreate.js.map
|
|
@@ -60,6 +60,7 @@ export declare const pollForScratchOrgInfo: (hubOrg: Org, scratchOrgInfoId: stri
|
|
|
60
60
|
*/
|
|
61
61
|
export declare const deploySettings: (scratchOrg: Org, orgSettings: SettingsGenerator, apiVersion: string, timeout?: Duration) => Promise<void>;
|
|
62
62
|
/**
|
|
63
|
+
* Makes sure the scratch org's instanceUrl is resolvable (that is, DNS is ready)
|
|
63
64
|
*
|
|
64
65
|
* @param scratchOrgAuthInfo an AuthInfo class from the scratch org
|
|
65
66
|
* @returns AuthInfo
|
|
@@ -352,6 +352,7 @@ const deploySettings = async (scratchOrg, orgSettings, apiVersion, timeout = kit
|
|
|
352
352
|
};
|
|
353
353
|
exports.deploySettings = deploySettings;
|
|
354
354
|
/**
|
|
355
|
+
* Makes sure the scratch org's instanceUrl is resolvable (that is, DNS is ready)
|
|
355
356
|
*
|
|
356
357
|
* @param scratchOrgAuthInfo an AuthInfo class from the scratch org
|
|
357
358
|
* @returns AuthInfo
|
|
@@ -360,13 +361,14 @@ const resolveUrl = async (scratchOrgAuthInfo) => {
|
|
|
360
361
|
const logger = await logger_1.Logger.child('scratchOrgInfoApi-resolveUrl');
|
|
361
362
|
const { instanceUrl } = scratchOrgAuthInfo.getFields();
|
|
362
363
|
if (!instanceUrl) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
364
|
+
throw sfError_1.SfError.create({
|
|
365
|
+
message: 'Org does not have instanceUrl',
|
|
366
|
+
data: {
|
|
367
|
+
orgId: scratchOrgAuthInfo.getFields().orgId,
|
|
368
|
+
username: scratchOrgAuthInfo.getFields().username,
|
|
369
|
+
instanceUrl,
|
|
370
|
+
},
|
|
368
371
|
});
|
|
369
|
-
throw sfError;
|
|
370
372
|
}
|
|
371
373
|
logger.debug(`processScratchOrgInfoResult - resultData.instanceUrl: ${instanceUrl}`);
|
|
372
374
|
const options = {
|
|
@@ -271,9 +271,11 @@ class SettingsGenerator {
|
|
|
271
271
|
const failures = (Array.isArray(componentFailures) ? componentFailures : [componentFailures])
|
|
272
272
|
.map((failure) => `[${failure.problemType}] ${failure.fullName} : ${failure.problem} `)
|
|
273
273
|
.join('\n');
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
throw sfError_1.SfError.create({
|
|
275
|
+
message: `A scratch org was created with username ${username}, but the settings failed to deploy due to: \n${failures}`,
|
|
276
|
+
name: 'ProblemDeployingSettings',
|
|
277
|
+
data: { ...result, username },
|
|
278
|
+
});
|
|
277
279
|
}
|
|
278
280
|
}
|
|
279
281
|
async createDeployPackageContents(apiVersion) {
|
package/lib/sfProject.js
CHANGED
|
@@ -588,7 +588,9 @@ class SfProject {
|
|
|
588
588
|
*/
|
|
589
589
|
getDefaultPackage() {
|
|
590
590
|
if (!this.hasPackages()) {
|
|
591
|
-
throw new sfError_1.SfError('The sfdx-project.json does not have any packageDirectories defined.'
|
|
591
|
+
throw new sfError_1.SfError('The sfdx-project.json does not have any packageDirectories defined.', 'NoPackageDirectories', [
|
|
592
|
+
`Check ${this.getPath()} for packageDirectories.`,
|
|
593
|
+
]);
|
|
592
594
|
}
|
|
593
595
|
const defaultPackage = this.findPackage((packageDir) => packageDir.default === true);
|
|
594
596
|
return defaultPackage ?? this.getPackageDirectories()[0];
|
package/lib/testSetup.js
CHANGED
|
@@ -532,6 +532,8 @@ const restoreContext = (testContext) => {
|
|
|
532
532
|
testContext.configStubs = {};
|
|
533
533
|
// Give each test run a clean StateAggregator
|
|
534
534
|
stateAggregator_1.StateAggregator.clearInstance();
|
|
535
|
+
// @ts-expect-error accessing a private property
|
|
536
|
+
sfProject_1.SfProject.instances.clear();
|
|
535
537
|
// Allow each test to have their own config aggregator
|
|
536
538
|
// @ts-ignore clear for testing.
|
|
537
539
|
delete configAggregator_1.ConfigAggregator.instance;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.1",
|
|
4
4
|
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"benchmark": "^2.1.4",
|
|
84
84
|
"chai-string": "^1.5.0",
|
|
85
85
|
"ts-node": "^10.9.2",
|
|
86
|
-
"ts-patch": "^3.
|
|
86
|
+
"ts-patch": "^3.2.0",
|
|
87
87
|
"typescript": "^5.4.5"
|
|
88
88
|
},
|
|
89
89
|
"repository": {
|