@salesforce/core 3.18.1 → 3.19.0

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,23 @@
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.19.0](https://github.com/forcedotcom/sfdx-core/compare/v3.18.3...v3.19.0) (2022-05-20)
6
+
7
+ ### Features
8
+
9
+ - missing prop and logic correction ([debe97e](https://github.com/forcedotcom/sfdx-core/commit/debe97e08f54bbd55edd2cb5b18e9d14abd3652f))
10
+ - property on org with inteligent defaults and handling of undefined ([e7295d3](https://github.com/forcedotcom/sfdx-core/commit/e7295d38f2b8defdb54a77e61b4ef8862e5398f9))
11
+ - tracking property on AuthFields ([2243d34](https://github.com/forcedotcom/sfdx-core/commit/2243d345c5cc81bd637c889adbe1db6eae6c93fc))
12
+ - tracksSource in TestSetup mock ([7544c60](https://github.com/forcedotcom/sfdx-core/commit/7544c604bd4a32d21d105e8472f41b2d37fbf601))
13
+
14
+ ### [3.18.3](https://github.com/forcedotcom/sfdx-core/compare/v3.18.2...v3.18.3) (2022-05-20)
15
+
16
+ ### [3.18.2](https://github.com/forcedotcom/sfdx-core/compare/v3.18.1...v3.18.2) (2022-05-17)
17
+
18
+ ### Bug Fixes
19
+
20
+ - remove unreachable code ([#585](https://github.com/forcedotcom/sfdx-core/issues/585)) ([2a6d611](https://github.com/forcedotcom/sfdx-core/commit/2a6d611a9ded7d4a0718864ca4023a0f7f259e8a))
21
+
5
22
  ### [3.18.1](https://github.com/forcedotcom/sfdx-core/compare/v3.18.0...v3.18.1) (2022-05-16)
6
23
 
7
24
  ## [3.18.0](https://github.com/forcedotcom/sfdx-core/compare/v3.17.0...v3.18.0) (2022-05-12)
@@ -6,6 +6,7 @@ export declare type SandboxRequestCacheEntry = {
6
6
  prodOrgUsername: string;
7
7
  sandboxProcessObject: Partial<SandboxProcessObject>;
8
8
  sandboxRequest: Partial<SandboxRequest>;
9
+ tracksSource?: boolean;
9
10
  };
10
11
  export declare class SandboxRequestCache extends TTLConfig<TTLConfig.Options, SandboxRequestCacheEntry> {
11
12
  static getDefaultOptions(): TTLConfig.Options;
@@ -37,6 +37,7 @@ export declare type AuthFields = {
37
37
  usernames?: string[];
38
38
  userProfileName?: string;
39
39
  expirationDate?: string;
40
+ tracksSource?: boolean;
40
41
  };
41
42
  export declare type OrgAuthorization = {
42
43
  orgId: string;
@@ -64,6 +65,7 @@ export declare type AuthSideEffects = {
64
65
  alias?: string;
65
66
  setDefault: boolean;
66
67
  setDefaultDevHub: boolean;
68
+ setTracksSource?: boolean;
67
69
  };
68
70
  /**
69
71
  * A function to update a refresh token when the access token is expired.
@@ -463,14 +463,22 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
463
463
  * @param sideEffects - instance of AuthSideEffects
464
464
  */
465
465
  async handleAliasAndDefaultSettings(sideEffects) {
466
- if (sideEffects.alias || sideEffects.setDefault || sideEffects.setDefaultDevHub) {
466
+ if (sideEffects.alias ||
467
+ sideEffects.setDefault ||
468
+ sideEffects.setDefaultDevHub ||
469
+ typeof sideEffects.setTracksSource === 'boolean') {
467
470
  if (sideEffects.alias)
468
471
  await this.setAlias(sideEffects.alias);
469
472
  if (sideEffects.setDefault)
470
473
  await this.setAsDefault({ org: true });
471
474
  if (sideEffects.setDefaultDevHub)
472
475
  await this.setAsDefault({ devHub: true });
473
- await this.save();
476
+ if (typeof sideEffects.setTracksSource === 'boolean') {
477
+ await this.save({ tracksSource: sideEffects.setTracksSource });
478
+ }
479
+ else {
480
+ await this.save();
481
+ }
474
482
  }
475
483
  }
476
484
  /**
package/lib/org/org.d.ts CHANGED
@@ -119,6 +119,17 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
119
119
  interval?: Duration;
120
120
  async?: boolean;
121
121
  }): Promise<SandboxProcessObject>;
122
+ /**
123
+ *
124
+ * @param sandboxReq SandboxRequest options to create the sandbox with
125
+ * @param sandboxName
126
+ * @param options Wait: The amount of time to wait before timing out, defaults to 0, Interval: The time interval between polling defaults to 30 seconds
127
+ * @returns {SandboxProcessObject} the newly created sandbox process object
128
+ */
129
+ cloneSandbox(sandboxReq: SandboxRequest, sandboxName: string, options: {
130
+ wait?: Duration;
131
+ interval?: Duration;
132
+ }): Promise<SandboxProcessObject>;
122
133
  /**
123
134
  * resume a sandbox creation from a production org
124
135
  * 'this' needs to be a production org with sandbox licenses available
@@ -224,6 +235,17 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
224
235
  * scratch org**. If you need accuracy, use the {@link Org.determineIfScratch} method.
225
236
  */
226
237
  isScratch(): boolean;
238
+ /**
239
+ * Returns `true` if the org uses source tracking.
240
+ * Side effect: updates files where the property doesn't currently exist
241
+ */
242
+ tracksSource(): Promise<boolean>;
243
+ /**
244
+ * Set the tracking property on the org's auth file
245
+ *
246
+ * @param value true or false (whether the org should use source tracking or not)
247
+ */
248
+ setTracksSource(value: boolean): Promise<void>;
227
249
  /**
228
250
  * Returns `true` if the org is a scratch org.
229
251
  *
@@ -517,6 +539,11 @@ export declare namespace Org {
517
539
  /**
518
540
  * The snapshot used to create the scratch org.
519
541
  */
520
- SNAPSHOT = "snapshot"
542
+ SNAPSHOT = "snapshot",
543
+ /**
544
+ * true: the org supports and wants source tracking
545
+ * false: the org opted out of tracking or can't support it
546
+ */
547
+ TRACKS_SOURCE = "tracksSource"
521
548
  }
522
549
  }
package/lib/org/org.js CHANGED
@@ -104,14 +104,14 @@ class Org extends kit_1.AsyncOptionalCreatable {
104
104
  async: false,
105
105
  interval: kit_1.Duration.seconds(30),
106
106
  }) {
107
- this.logger.debug('CreateSandbox called with SandboxRequest:', sandboxReq);
107
+ this.logger.debug(`CreateSandbox called with SandboxRequest: ${sandboxReq}`);
108
108
  const createResult = await this.connection.tooling.create('SandboxInfo', sandboxReq);
109
- this.logger.debug('Return from calling tooling.create:', createResult);
109
+ this.logger.debug(`Return from calling tooling.create: ${createResult}`);
110
110
  if (Array.isArray(createResult) || !createResult.success) {
111
111
  throw messages.createError('sandboxInfoCreateFailed', [JSON.stringify(createResult)]);
112
112
  }
113
113
  const sandboxCreationProgress = await this.querySandboxProcessBySandboxInfoId(createResult.id);
114
- this.logger.debug('Return from calling singleRecordQuery with tooling:', sandboxCreationProgress);
114
+ this.logger.debug(`Return from calling singleRecordQuery with tooling: ${sandboxCreationProgress}`);
115
115
  const isAsync = !!options.async;
116
116
  if (isAsync) {
117
117
  // The user didn't want us to poll, so simply return the status
@@ -119,13 +119,25 @@ class Org extends kit_1.AsyncOptionalCreatable {
119
119
  return sandboxCreationProgress;
120
120
  }
121
121
  const [wait, pollInterval] = this.validateWaitOptions(options);
122
- this.logger.debug(`create - pollStatusAndAuth sandboxProcessObj, max wait time of ${wait.minutes} minutes`, sandboxCreationProgress);
122
+ this.logger.debug(`create - pollStatusAndAuth sandboxProcessObj ${sandboxCreationProgress}, max wait time of ${wait.minutes} minutes`);
123
123
  return this.pollStatusAndAuth({
124
124
  sandboxProcessObj: sandboxCreationProgress,
125
125
  wait,
126
126
  pollInterval,
127
127
  });
128
128
  }
129
+ /**
130
+ *
131
+ * @param sandboxReq SandboxRequest options to create the sandbox with
132
+ * @param sandboxName
133
+ * @param options Wait: The amount of time to wait before timing out, defaults to 0, Interval: The time interval between polling defaults to 30 seconds
134
+ * @returns {SandboxProcessObject} the newly created sandbox process object
135
+ */
136
+ async cloneSandbox(sandboxReq, sandboxName, options) {
137
+ sandboxReq.SourceId = (await this.querySandboxProcessBySandboxName(sandboxName)).Id;
138
+ this.logger.debug('Clone sandbox sourceId %s', sandboxReq.SourceId);
139
+ return this.createSandbox(sandboxReq, options);
140
+ }
129
141
  /**
130
142
  * resume a sandbox creation from a production org
131
143
  * 'this' needs to be a production org with sandbox licenses available
@@ -140,7 +152,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
140
152
  interval: kit_1.Duration.seconds(30),
141
153
  }) {
142
154
  var _a;
143
- this.logger.debug('ResumeSandbox called with ResumeSandboxRequest:', resumeSandboxRequest);
155
+ this.logger.debug(`ResumeSandbox called with ResumeSandboxRequest: ${resumeSandboxRequest}`);
144
156
  let sandboxCreationProgress;
145
157
  // seed the sandboxCreationProgress via the resumeSandboxRequest options
146
158
  if (resumeSandboxRequest.SandboxName) {
@@ -154,7 +166,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
154
166
  (_a = resumeSandboxRequest.SandboxName) !== null && _a !== void 0 ? _a : resumeSandboxRequest.SandboxProcessObjId,
155
167
  ]);
156
168
  }
157
- this.logger.debug('Return from calling singleRecordQuery with tooling:', sandboxCreationProgress);
169
+ this.logger.debug(`Return from calling singleRecordQuery with tooling: ${sandboxCreationProgress}`);
158
170
  await lifecycleEvents_1.Lifecycle.getInstance().emit(SandboxEvents.EVENT_RESUME, sandboxCreationProgress);
159
171
  const [wait, pollInterval] = this.validateWaitOptions(options);
160
172
  // if wait is 0, return the sandboxCreationProgress immediately
@@ -165,7 +177,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
165
177
  if (sandboxInfo) {
166
178
  await lifecycleEvents_1.Lifecycle.getInstance().emit(SandboxEvents.EVENT_AUTH, sandboxInfo);
167
179
  try {
168
- this.logger.debug('sandbox signup complete with', sandboxInfo);
180
+ this.logger.debug(`sandbox signup complete with ${sandboxInfo}`);
169
181
  await this.writeSandboxAuthFile(sandboxCreationProgress, sandboxInfo);
170
182
  return sandboxCreationProgress;
171
183
  }
@@ -177,7 +189,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
177
189
  await lifecycleEvents_1.Lifecycle.getInstance().emit(SandboxEvents.EVENT_ASYNC_RESULT, sandboxCreationProgress);
178
190
  throw messages.createError('sandboxCreateNotComplete');
179
191
  }
180
- this.logger.debug(`resume - pollStatusAndAuth sandboxProcessObj, max wait time of ${wait.minutes} minutes`, sandboxCreationProgress);
192
+ this.logger.debug(`resume - pollStatusAndAuth sandboxProcessObj ${sandboxCreationProgress}, max wait time of ${wait.minutes} minutes`);
181
193
  return this.pollStatusAndAuth({
182
194
  sandboxProcessObj: sandboxCreationProgress,
183
195
  wait,
@@ -406,6 +418,41 @@ class Org extends kit_1.AsyncOptionalCreatable {
406
418
  return false;
407
419
  }
408
420
  }
421
+ /**
422
+ * Returns `true` if the org uses source tracking.
423
+ * Side effect: updates files where the property doesn't currently exist
424
+ */
425
+ async tracksSource() {
426
+ // use the property if it exists
427
+ const tracksSource = this.getField(Org.Fields.TRACKS_SOURCE);
428
+ if ((0, ts_types_1.isBoolean)(tracksSource)) {
429
+ return tracksSource;
430
+ }
431
+ // scratch orgs with no property use tracking by default
432
+ if (await this.determineIfScratch()) {
433
+ // save true for next time to avoid checking again
434
+ await this.setTracksSource(true);
435
+ return true;
436
+ }
437
+ if (await this.determineIfSandbox()) {
438
+ // does the sandbox know about the SourceMember object?
439
+ const supportsSourceMembers = await this.supportsSourceTracking();
440
+ await this.setTracksSource(supportsSourceMembers);
441
+ return supportsSourceMembers;
442
+ }
443
+ // any other non-sandbox, non-scratch orgs won't use tracking
444
+ await this.setTracksSource(false);
445
+ return false;
446
+ }
447
+ /**
448
+ * Set the tracking property on the org's auth file
449
+ *
450
+ * @param value true or false (whether the org should use source tracking or not)
451
+ */
452
+ async setTracksSource(value) {
453
+ const originalAuth = await authInfo_1.AuthInfo.create({ username: this.getUsername() });
454
+ originalAuth.handleAliasAndDefaultSettings({ setDefault: false, setDefaultDevHub: false, setTracksSource: value });
455
+ }
409
456
  /**
410
457
  * Returns `true` if the org is a scratch org.
411
458
  *
@@ -644,9 +691,8 @@ class Org extends kit_1.AsyncOptionalCreatable {
644
691
  if (this.isScratch()) {
645
692
  return true;
646
693
  }
647
- const conn = this.getConnection();
648
694
  try {
649
- await conn.tooling.sobject('SourceMember').describe();
695
+ await this.getConnection().tooling.sobject('SourceMember').describe();
650
696
  return true;
651
697
  }
652
698
  catch (err) {
@@ -673,10 +719,6 @@ class Org extends kit_1.AsyncOptionalCreatable {
673
719
  */
674
720
  async querySandboxProcessBySandboxInfoId(id) {
675
721
  return await this.querySandboxProcess(`SandboxInfoId='${id}'`);
676
- const queryStr = `SELECT Id, Status, SandboxName, SandboxInfoId, LicenseType, CreatedDate, CopyProgress, SandboxOrganization, SourceId, Description, EndDate FROM SandboxProcess WHERE SandboxInfoId='${id}' AND Status != 'D'`;
677
- return await this.connection.singleRecordQuery(queryStr, {
678
- tooling: true,
679
- });
680
722
  }
681
723
  /**
682
724
  * query SandboxProcess via Id
@@ -1199,6 +1241,11 @@ exports.Org = Org;
1199
1241
  * The snapshot used to create the scratch org.
1200
1242
  */
1201
1243
  Fields["SNAPSHOT"] = "snapshot";
1244
+ /**
1245
+ * true: the org supports and wants source tracking
1246
+ * false: the org opted out of tracking or can't support it
1247
+ */
1248
+ Fields["TRACKS_SOURCE"] = "tracksSource";
1202
1249
  // Should it be on org? Leave it off for now, as it might
1203
1250
  // be confusing to the consumer what this actually is.
1204
1251
  // USERNAMES = 'usernames',
@@ -11,6 +11,7 @@ export declare type CachedOptions = {
11
11
  apiVersion?: string;
12
12
  alias?: string;
13
13
  setDefault?: boolean;
14
+ tracksSource?: boolean;
14
15
  };
15
16
  export declare class ScratchOrgCache extends TTLConfig<TTLConfig.Options, CachedOptions> {
16
17
  static getFileName(): string;
@@ -47,6 +47,8 @@ export interface ScratchOrgCreateOptions {
47
47
  alias?: string;
48
48
  /** after complete, set the org as the default */
49
49
  setDefault?: boolean;
50
+ /** do not use source tracking for this org */
51
+ tracksSource?: boolean;
50
52
  }
51
53
  export declare const scratchOrgResume: (jobId: string) => Promise<ScratchOrgCreateResult>;
52
54
  export declare const scratchOrgCreate: (options: ScratchOrgCreateOptions) => Promise<ScratchOrgCreateResult>;
@@ -67,7 +67,7 @@ const scratchOrgResume = async (jobId) => {
67
67
  if (!cache.has(jobId)) {
68
68
  throw messages.createError('CacheMissError', [jobId]);
69
69
  }
70
- const { hubUsername, apiVersion, clientSecret, signupTargetLoginUrlConfig, definitionjson, alias, setDefault } = cache.get(jobId);
70
+ const { hubUsername, apiVersion, clientSecret, signupTargetLoginUrlConfig, definitionjson, alias, setDefault, tracksSource, } = cache.get(jobId);
71
71
  const hubOrg = await org_1.Org.create({ aliasOrUsername: hubUsername });
72
72
  const soi = await (0, scratchOrgInfoApi_1.queryScratchOrgInfo)(hubOrg, jobId);
73
73
  await (0, scratchOrgErrorCodes_1.validateScratchOrgInfoForResume)({ jobId, scratchOrgInfo: soi, cache, hubUsername });
@@ -99,6 +99,7 @@ const scratchOrgResume = async (jobId) => {
99
99
  alias,
100
100
  setDefault: setDefault !== null && setDefault !== void 0 ? setDefault : false,
101
101
  setDefaultDevHub: false,
102
+ setTracksSource: tracksSource !== null && tracksSource !== void 0 ? tracksSource : true,
102
103
  });
103
104
  cache.unset((_c = soi.Id) !== null && _c !== void 0 ? _c : jobId);
104
105
  const authFields = authInfo.getFields();
@@ -117,7 +118,7 @@ const scratchOrgCreate = async (options) => {
117
118
  const logger = await logger_1.Logger.child('scratchOrgCreate');
118
119
  logger.debug('scratchOrgCreate');
119
120
  await (0, scratchOrgLifecycleEvents_1.emit)({ stage: 'prepare request' });
120
- const { hubOrg, connectedAppConsumerKey, durationDays = 1, nonamespace, noancestors, wait = kit_1.Duration.minutes(exports.DEFAULT_STREAM_TIMEOUT_MINUTES), retry = 0, apiversion, definitionjson, definitionfile, orgConfig, clientSecret = undefined, alias, setDefault = false, } = options;
121
+ const { hubOrg, connectedAppConsumerKey, durationDays = 1, nonamespace, noancestors, wait = kit_1.Duration.minutes(exports.DEFAULT_STREAM_TIMEOUT_MINUTES), retry = 0, apiversion, definitionjson, definitionfile, orgConfig, clientSecret = undefined, alias, setDefault = false, tracksSource = true, } = options;
121
122
  validateDuration(durationDays);
122
123
  validateRetry(retry);
123
124
  const { scratchOrgInfoPayload, ignoreAncestorIds, warnings } = await (0, scratchOrgInfoGenerator_1.getScratchOrgInfoPayload)({
@@ -153,6 +154,7 @@ const scratchOrgCreate = async (options) => {
153
154
  clientSecret,
154
155
  alias,
155
156
  setDefault,
157
+ tracksSource,
156
158
  });
157
159
  await cache.write();
158
160
  logger.debug(`scratch org has recordId ${scratchOrgInfoId}`);
@@ -185,9 +187,12 @@ const scratchOrgCreate = async (options) => {
185
187
  (0, scratchOrgInfoApi_1.deploySettings)(scratchOrg, settingsGenerator, (_c = apiversion !== null && apiversion !== void 0 ? apiversion : new configAggregator_1.ConfigAggregator().getPropertyValue('org-api-version')) !== null && _c !== void 0 ? _c : (await scratchOrg.retrieveMaxApiVersion())),
186
188
  ]);
187
189
  await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
188
- alias,
189
- setDefault,
190
- setDefaultDevHub: false,
190
+ ...{
191
+ alias,
192
+ setDefault,
193
+ setDefaultDevHub: false,
194
+ setTracksSource: tracksSource === false ? false : true,
195
+ },
191
196
  });
192
197
  cache.unset(scratchOrgInfoId);
193
198
  const authFields = authInfo.getFields();
@@ -389,6 +389,7 @@ export declare class MockTestOrgData {
389
389
  authcode: string;
390
390
  accessToken: string;
391
391
  refreshToken: string;
392
+ tracksSource: boolean | undefined;
392
393
  userId: string;
393
394
  redirectUri: string;
394
395
  isDevHub?: boolean;
package/lib/testSetup.js CHANGED
@@ -543,6 +543,7 @@ class MockTestOrgData {
543
543
  config.createdOrgInstance = 'CS1';
544
544
  config.created = '1519163543003';
545
545
  config.userId = this.userId;
546
+ config.tracksSource = this.tracksSource;
546
547
  if (this.devHubUsername) {
547
548
  config.devHubUsername = this.devHubUsername;
548
549
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "3.18.1",
3
+ "version": "3.19.0",
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",
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "@salesforce/bunyan": "^2.0.0",
38
- "@salesforce/kit": "^1.5.34",
38
+ "@salesforce/kit": "^1.5.41",
39
39
  "@salesforce/schemas": "^1.1.0",
40
40
  "@salesforce/ts-types": "^1.5.20",
41
41
  "@types/graceful-fs": "^4.1.5",
@@ -49,7 +49,7 @@
49
49
  "form-data": "^4.0.0",
50
50
  "graceful-fs": "^4.2.9",
51
51
  "js2xmlparser": "^4.0.1",
52
- "jsforce": "2.0.0-beta.9",
52
+ "jsforce": "2.0.0-beta.10",
53
53
  "jsonwebtoken": "8.5.1",
54
54
  "mkdirp": "1.0.4",
55
55
  "ts-retry-promise": "^0.6.0"