@salesforce/core 3.18.3 → 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,15 @@
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
+
5
14
  ### [3.18.3](https://github.com/forcedotcom/sfdx-core/compare/v3.18.2...v3.18.3) (2022-05-20)
6
15
 
7
16
  ### [3.18.2](https://github.com/forcedotcom/sfdx-core/compare/v3.18.1...v3.18.2) (2022-05-17)
@@ -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
@@ -235,6 +235,17 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
235
235
  * scratch org**. If you need accuracy, use the {@link Org.determineIfScratch} method.
236
236
  */
237
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>;
238
249
  /**
239
250
  * Returns `true` if the org is a scratch org.
240
251
  *
@@ -528,6 +539,11 @@ export declare namespace Org {
528
539
  /**
529
540
  * The snapshot used to create the scratch org.
530
541
  */
531
- 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"
532
548
  }
533
549
  }
package/lib/org/org.js CHANGED
@@ -418,6 +418,41 @@ class Org extends kit_1.AsyncOptionalCreatable {
418
418
  return false;
419
419
  }
420
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
+ }
421
456
  /**
422
457
  * Returns `true` if the org is a scratch org.
423
458
  *
@@ -656,9 +691,8 @@ class Org extends kit_1.AsyncOptionalCreatable {
656
691
  if (this.isScratch()) {
657
692
  return true;
658
693
  }
659
- const conn = this.getConnection();
660
694
  try {
661
- await conn.tooling.sobject('SourceMember').describe();
695
+ await this.getConnection().tooling.sobject('SourceMember').describe();
662
696
  return true;
663
697
  }
664
698
  catch (err) {
@@ -1207,6 +1241,11 @@ exports.Org = Org;
1207
1241
  * The snapshot used to create the scratch org.
1208
1242
  */
1209
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";
1210
1249
  // Should it be on org? Leave it off for now, as it might
1211
1250
  // be confusing to the consumer what this actually is.
1212
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.3",
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"