@salesforce/core 2.36.0 → 2.36.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 +14 -0
- package/lib/config/config.js +4 -2
- package/lib/org.d.ts +34 -0
- package/lib/org.js +62 -0
- package/lib/util/sfdcUrl.d.ts +1 -1
- package/lib/util/sfdcUrl.js +3 -1
- package/messages/org.json +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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
|
+
### [2.36.3](https://github.com/forcedotcom/sfdx-core/compare/v2.36.2...v2.36.3) (2022-04-21)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- log rotation errors ([#562](https://github.com/forcedotcom/sfdx-core/issues/562)) ([16a5423](https://github.com/forcedotcom/sfdx-core/commit/16a5423079daad37e1ada6d47767923ec0b7cc94))
|
|
10
|
+
|
|
11
|
+
### [2.36.2](https://github.com/forcedotcom/sfdx-core/compare/v2.36.1...v2.36.2) (2022-04-20)
|
|
12
|
+
|
|
13
|
+
### [2.36.1](https://github.com/forcedotcom/sfdx-core/compare/v2.36.0...v2.36.1) (2022-04-14)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- sandbox cname recognition ([#555](https://github.com/forcedotcom/sfdx-core/issues/555)) ([105bc9a](https://github.com/forcedotcom/sfdx-core/commit/105bc9a043b3c984846e060e5176b290fe49b5bc))
|
|
18
|
+
|
|
5
19
|
## [2.36.0](https://github.com/forcedotcom/sfdx-core/compare/v2.35.3...v2.36.0) (2022-03-23)
|
|
6
20
|
|
|
7
21
|
### Features
|
package/lib/config/config.js
CHANGED
|
@@ -16,7 +16,6 @@ const sfdxError_1 = require("../sfdxError");
|
|
|
16
16
|
const sfdc_1 = require("../util/sfdc");
|
|
17
17
|
const sfdcUrl_1 = require("../util/sfdcUrl");
|
|
18
18
|
const configFile_1 = require("./configFile");
|
|
19
|
-
const log = logger_1.Logger.childFromRoot('core:config');
|
|
20
19
|
const SFDX_CONFIG_FILE_NAME = 'sfdx-config.json';
|
|
21
20
|
/**
|
|
22
21
|
* The files where sfdx config values are stored for projects and the global space.
|
|
@@ -64,9 +63,12 @@ class Config extends configFile_1.ConfigFile {
|
|
|
64
63
|
*/
|
|
65
64
|
static addAllowedProperties(metas) {
|
|
66
65
|
const currentMetaKeys = Object.keys(Config.propertyConfigMap);
|
|
66
|
+
// If logger is needed elsewhere in this file, do not move this outside of the Config class.
|
|
67
|
+
// It was causing issues with Bunyan log rotation. See https://github.com/forcedotcom/sfdx-core/pull/562
|
|
68
|
+
const logger = logger_1.Logger.childFromRoot('core:config');
|
|
67
69
|
metas.forEach((meta) => {
|
|
68
70
|
if (currentMetaKeys.includes(meta.key)) {
|
|
69
|
-
|
|
71
|
+
logger.info(`Key ${meta.key} already exists in allowedProperties, skipping.`);
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
74
|
Config.allowedProperties.push(meta);
|
package/lib/org.d.ts
CHANGED
|
@@ -113,6 +113,17 @@ export declare class Org extends AsyncCreatable<Org.Options> {
|
|
|
113
113
|
* @returns {ScratchOrgCreateResult}
|
|
114
114
|
*/
|
|
115
115
|
scratchOrgCreate(options: ScratchOrgRequest): Promise<ScratchOrgCreateResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Reports sandbox org creation status. If the org is ready, authenticates to the org.
|
|
118
|
+
*
|
|
119
|
+
* @param {sandboxname} string the sandbox name
|
|
120
|
+
* @param options Wait: The amount of time to wait before timing out, Interval: The time interval between polling
|
|
121
|
+
* @returns {SandboxProcessObject} the sandbox process object
|
|
122
|
+
*/
|
|
123
|
+
sandboxStatus(sandboxname: string, options: {
|
|
124
|
+
wait?: Duration;
|
|
125
|
+
interval?: Duration;
|
|
126
|
+
}): Promise<SandboxProcessObject>;
|
|
116
127
|
/**
|
|
117
128
|
* Clean all data files in the org's data path. Usually <workspace>/.sfdx/orgs/<username>.
|
|
118
129
|
*
|
|
@@ -264,6 +275,29 @@ export declare class Org extends AsyncCreatable<Org.Options> {
|
|
|
264
275
|
* **Throws** *{@link SfdxError} Throws and unsupported error.
|
|
265
276
|
*/
|
|
266
277
|
protected getDefaultOptions(): Org.Options;
|
|
278
|
+
/**
|
|
279
|
+
* Query the sandbox for the SandboxProcessObject by sandbox name
|
|
280
|
+
*
|
|
281
|
+
* @param sandboxName The name of the sandbox to query
|
|
282
|
+
* @returns {SandboxProcessObject} The SandboxProcessObject for the sandbox
|
|
283
|
+
*/
|
|
284
|
+
private queryLatestSandboxProcessBySandboxName;
|
|
285
|
+
/**
|
|
286
|
+
* Gets the sandboxProcessObject and then polls for it to complete.
|
|
287
|
+
*
|
|
288
|
+
* @param sandboxProcessName sanbox process name
|
|
289
|
+
* @param options { wait?: Duration; interval?: Duration }
|
|
290
|
+
* @returns {SandboxProcessObject} The SandboxProcessObject for the sandbox
|
|
291
|
+
*/
|
|
292
|
+
private authWithRetriesByName;
|
|
293
|
+
/**
|
|
294
|
+
* Polls the sandbox org for the sandboxProcessObject.
|
|
295
|
+
*
|
|
296
|
+
* @param sandboxProcessObj: The in-progress sandbox signup request
|
|
297
|
+
* @param options { wait?: Duration; interval?: Duration }
|
|
298
|
+
* @returns {SandboxProcessObject}
|
|
299
|
+
*/
|
|
300
|
+
private authWithRetries;
|
|
267
301
|
private queryProduction;
|
|
268
302
|
/**
|
|
269
303
|
* this method will delete the sandbox org from the production org and clean up any local files
|
package/lib/org.js
CHANGED
|
@@ -110,6 +110,16 @@ class Org extends kit_1.AsyncCreatable {
|
|
|
110
110
|
async scratchOrgCreate(options) {
|
|
111
111
|
return scratchOrgCreate_1.scratchOrgCreate({ ...options, hubOrg: this });
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Reports sandbox org creation status. If the org is ready, authenticates to the org.
|
|
115
|
+
*
|
|
116
|
+
* @param {sandboxname} string the sandbox name
|
|
117
|
+
* @param options Wait: The amount of time to wait before timing out, Interval: The time interval between polling
|
|
118
|
+
* @returns {SandboxProcessObject} the sandbox process object
|
|
119
|
+
*/
|
|
120
|
+
async sandboxStatus(sandboxname, options) {
|
|
121
|
+
return this.authWithRetriesByName(sandboxname, options);
|
|
122
|
+
}
|
|
113
123
|
/**
|
|
114
124
|
* Clean all data files in the org's data path. Usually <workspace>/.sfdx/orgs/<username>.
|
|
115
125
|
*
|
|
@@ -500,6 +510,58 @@ class Org extends kit_1.AsyncCreatable {
|
|
|
500
510
|
getDefaultOptions() {
|
|
501
511
|
throw new sfdxError_1.SfdxError('Not Supported');
|
|
502
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* Query the sandbox for the SandboxProcessObject by sandbox name
|
|
515
|
+
*
|
|
516
|
+
* @param sandboxName The name of the sandbox to query
|
|
517
|
+
* @returns {SandboxProcessObject} The SandboxProcessObject for the sandbox
|
|
518
|
+
*/
|
|
519
|
+
async queryLatestSandboxProcessBySandboxName(sandboxNameIn) {
|
|
520
|
+
var _a;
|
|
521
|
+
const { tooling } = this.getConnection();
|
|
522
|
+
this.logger.debug('QueryLatestSandboxProcessBySandboxName called with SandboxName: %s ', sandboxNameIn);
|
|
523
|
+
const queryStr = `SELECT Id, Status, SandboxName, SandboxInfoId, LicenseType, CreatedDate, CopyProgress, SandboxOrganization, SourceId, Description, EndDate FROM SandboxProcess WHERE SandboxName='${sandboxNameIn}' AND Status != 'D' ORDER BY CreatedDate DESC LIMIT 1`;
|
|
524
|
+
const queryResult = await tooling.query(queryStr);
|
|
525
|
+
this.logger.debug('Return from calling queryToolingApi: %s ', queryResult);
|
|
526
|
+
if (((_a = queryResult === null || queryResult === void 0 ? void 0 : queryResult.records) === null || _a === void 0 ? void 0 : _a.length) === 1) {
|
|
527
|
+
return queryResult.records[0];
|
|
528
|
+
}
|
|
529
|
+
else if (queryResult.records && queryResult.records.length > 1) {
|
|
530
|
+
throw sfdxError_1.SfdxError.create('@salesforce/core', 'org', 'MultiSandboxProcessNotFoundBySandboxName', [sandboxNameIn]);
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
throw sfdxError_1.SfdxError.create('@salesforce/core', 'org', 'SandboxProcessNotFoundBySandboxName', [sandboxNameIn]);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Gets the sandboxProcessObject and then polls for it to complete.
|
|
538
|
+
*
|
|
539
|
+
* @param sandboxProcessName sanbox process name
|
|
540
|
+
* @param options { wait?: Duration; interval?: Duration }
|
|
541
|
+
* @returns {SandboxProcessObject} The SandboxProcessObject for the sandbox
|
|
542
|
+
*/
|
|
543
|
+
async authWithRetriesByName(sandboxProcessName, options) {
|
|
544
|
+
return this.authWithRetries(await this.queryLatestSandboxProcessBySandboxName(sandboxProcessName), options);
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Polls the sandbox org for the sandboxProcessObject.
|
|
548
|
+
*
|
|
549
|
+
* @param sandboxProcessObj: The in-progress sandbox signup request
|
|
550
|
+
* @param options { wait?: Duration; interval?: Duration }
|
|
551
|
+
* @returns {SandboxProcessObject}
|
|
552
|
+
*/
|
|
553
|
+
async authWithRetries(sandboxProcessObj, options) {
|
|
554
|
+
var _a;
|
|
555
|
+
const retries = options.wait ? options.wait.seconds / kit_1.Duration.seconds(30).seconds : 0;
|
|
556
|
+
const pollInterval = (_a = options.interval) !== null && _a !== void 0 ? _a : kit_1.Duration.seconds(30);
|
|
557
|
+
this.logger.debug('AuthWithRetries sandboxProcessObj %s, retries %i', sandboxProcessObj, retries);
|
|
558
|
+
return this.pollStatusAndAuth({
|
|
559
|
+
sandboxProcessObj,
|
|
560
|
+
retries,
|
|
561
|
+
shouldPoll: retries > 0,
|
|
562
|
+
pollInterval,
|
|
563
|
+
});
|
|
564
|
+
}
|
|
503
565
|
async queryProduction(org, field, value) {
|
|
504
566
|
return org.connection.singleRecordQuery(`SELECT SandboxInfoId FROM SandboxProcess WHERE ${field} ='${value}' AND Status NOT IN ('D', 'E')`, { tooling: true });
|
|
505
567
|
}
|
package/lib/util/sfdcUrl.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export declare class SfdcUrl extends URL {
|
|
|
62
62
|
isSandboxUrl(createdOrgInstance?: string): boolean;
|
|
63
63
|
/**
|
|
64
64
|
* Tests whether this url is a sandbox url
|
|
65
|
-
* otherwise
|
|
65
|
+
* otherwise tries to resolve dns cnames and then look if any is sandbox url
|
|
66
66
|
*
|
|
67
67
|
* @param createdOrgInstance The Salesforce instance the org was created on. e.g. `cs42`
|
|
68
68
|
* @returns {Promise<boolean>} true if this domain resolves to sanbox url
|
package/lib/util/sfdcUrl.js
CHANGED
|
@@ -156,13 +156,15 @@ class SfdcUrl extends url_1.URL {
|
|
|
156
156
|
this.origin.endsWith('sandbox.my.salesforce.mil') ||
|
|
157
157
|
/sandbox\.my\.salesforce\.com/gi.test(this.origin) || // enhanced domains >= 230
|
|
158
158
|
/(cs[0-9]+(\.my|)\.salesforce\.com)/gi.test(this.origin) || // my domains on CS instance OR CS instance without my domain
|
|
159
|
+
/(cs[0-9]+\.force\.com)/gi.test(this.origin) || // sandboxes have cnames like cs123.force.com
|
|
160
|
+
/(\w+--\w+\.my\.salesforce\.com)/gi.test(this.origin) || // sandboxes myDomain like foo--bar.my.salesforce.com
|
|
159
161
|
/([a-z]{3}[0-9]+s\.sfdc-.+\.salesforce\.com)/gi.test(this.origin) || // falcon sandbox ex: usa2s.sfdc-whatever.salesforce.com
|
|
160
162
|
/([a-z]{3}[0-9]+s\.sfdc-.+\.force\.com)/gi.test(this.origin) || // falcon sandbox ex: usa2s.sfdc-whatever.force.com
|
|
161
163
|
this.hostname === 'test.salesforce.com');
|
|
162
164
|
}
|
|
163
165
|
/**
|
|
164
166
|
* Tests whether this url is a sandbox url
|
|
165
|
-
* otherwise
|
|
167
|
+
* otherwise tries to resolve dns cnames and then look if any is sandbox url
|
|
166
168
|
*
|
|
167
169
|
* @param createdOrgInstance The Salesforce instance the org was created on. e.g. `cs42`
|
|
168
170
|
* @returns {Promise<boolean>} true if this domain resolves to sanbox url
|
package/messages/org.json
CHANGED
|
@@ -9,5 +9,7 @@
|
|
|
9
9
|
"SandboxNotFound": "We can't find a SandboxProcess for the sandbox org %s.",
|
|
10
10
|
"SandboxInfoCreateFailed": "The sandbox org creation failed with a result of %s.",
|
|
11
11
|
"MissingAuthUsername": "The sandbox %s does not have an authorized username.",
|
|
12
|
-
"OrgPollingTimeout": "Sandbox status is %s; timed out waiting for completion."
|
|
12
|
+
"OrgPollingTimeout": "Sandbox status is %s; timed out waiting for completion.",
|
|
13
|
+
"SandboxProcessNotFoundBySandboxName": "We can't find a SandboxProcess with the SandboxName %s.",
|
|
14
|
+
"MultiSandboxProcessNotFoundBySandboxName": "We found more than one SandboxProcess with the SandboxName %s."
|
|
13
15
|
}
|