@salesforce/core 3.24.1 → 3.24.4

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,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
+ ### [3.24.4](https://github.com/forcedotcom/sfdx-core/compare/v3.24.3...v3.24.4) (2022-07-28)
6
+
7
+ ### [3.24.3](https://github.com/forcedotcom/sfdx-core/compare/v3.24.2...v3.24.3) (2022-07-28)
8
+
9
+ ### Bug Fixes
10
+
11
+ - handle ancestor keywords when creating scratch org ([72af55a](https://github.com/forcedotcom/sfdx-core/commit/72af55a53b87f1d81d22dc4e53891b3b0ab2966f))
12
+
13
+ ### [3.24.2](https://github.com/forcedotcom/sfdx-core/compare/v3.24.1...v3.24.2) (2022-07-26)
14
+
15
+ ### Bug Fixes
16
+
17
+ - use correct field for clone requests ([#623](https://github.com/forcedotcom/sfdx-core/issues/623)) ([2372f03](https://github.com/forcedotcom/sfdx-core/commit/2372f0364b87a7ac498c8d7ef637a9b5fdc725ea))
18
+
5
19
  ### [3.24.1](https://github.com/forcedotcom/sfdx-core/compare/v3.24.0...v3.24.1) (2022-07-21)
6
20
 
7
21
  ### Bug Fixes
@@ -11,7 +11,6 @@ const path_1 = require("path");
11
11
  const fs = require("fs");
12
12
  const kit_1 = require("@salesforce/kit");
13
13
  const ts_types_1 = require("@salesforce/ts-types");
14
- const mkdirp = require("mkdirp");
15
14
  const global_1 = require("../global");
16
15
  const logger_1 = require("../logger");
17
16
  const messages_1 = require("../messages");
@@ -510,7 +509,7 @@ class SfdxConfig {
510
509
  try {
511
510
  const translated = this.translate(config, 'toOld');
512
511
  const sfdxPath = this.getSfdxPath();
513
- await mkdirp((0, path_1.dirname)(sfdxPath));
512
+ await fs.promises.mkdir((0, path_1.dirname)(sfdxPath), { recursive: true });
514
513
  await fs.promises.writeFile(sfdxPath, JSON.stringify(translated, null, 2));
515
514
  }
516
515
  catch (error) {
@@ -13,7 +13,6 @@ const os_1 = require("os");
13
13
  const path_1 = require("path");
14
14
  const ts_types_1 = require("@salesforce/ts-types");
15
15
  const kit_1 = require("@salesforce/kit");
16
- const mkdirp = require("mkdirp");
17
16
  const global_1 = require("../global");
18
17
  const logger_1 = require("../logger");
19
18
  const sfError_1 = require("../sfError");
@@ -213,7 +212,12 @@ class ConfigFile extends configStore_1.BaseConfigStore {
213
212
  if (newContents) {
214
213
  this.setContents(newContents);
215
214
  }
216
- await mkdirp((0, path_1.dirname)(this.getPath()));
215
+ try {
216
+ await fs.promises.mkdir((0, path_1.dirname)(this.getPath()), { recursive: true });
217
+ }
218
+ catch (err) {
219
+ throw sfError_1.SfError.wrap(err);
220
+ }
217
221
  this.logger.info(`Writing to config file: ${this.getPath()}`);
218
222
  await fs.promises.writeFile(this.getPath(), JSON.stringify(this.toObject(), null, 2));
219
223
  return this.getContents();
@@ -228,7 +232,12 @@ class ConfigFile extends configStore_1.BaseConfigStore {
228
232
  if ((0, ts_types_1.isPlainObject)(newContents)) {
229
233
  this.setContents(newContents);
230
234
  }
231
- mkdirp.sync((0, path_1.dirname)(this.getPath()));
235
+ try {
236
+ fs.mkdirSync((0, path_1.dirname)(this.getPath()), { recursive: true });
237
+ }
238
+ catch (err) {
239
+ throw sfError_1.SfError.wrap(err);
240
+ }
232
241
  this.logger.info(`Writing to config file: ${this.getPath()}`);
233
242
  fs.writeFileSync(this.getPath(), JSON.stringify(this.toObject(), null, 2));
234
243
  return this.getContents();
@@ -15,7 +15,6 @@ const os_1 = require("os");
15
15
  const path = require("path");
16
16
  const ts_types_1 = require("@salesforce/ts-types");
17
17
  const kit_1 = require("@salesforce/kit");
18
- const mkdirp = require("mkdirp");
19
18
  const global_1 = require("../global");
20
19
  const messages_1 = require("../messages");
21
20
  messages_1.Messages.importMessagesDirectory(__dirname);
@@ -332,7 +331,7 @@ async function _writeFile(opts, fn) {
332
331
  [SecretField.SERVICE]: opts.service,
333
332
  };
334
333
  const secretFile = getSecretFile();
335
- await mkdirp(path.dirname(secretFile));
334
+ await fs.promises.mkdir(path.dirname(secretFile), { recursive: true });
336
335
  await fs.promises.writeFile(secretFile, JSON.stringify(contents, null, 4), { mode: '600' });
337
336
  fn(null, contents);
338
337
  }
package/lib/global.js CHANGED
@@ -7,10 +7,11 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.Global = exports.Mode = void 0;
10
+ const fs = require("fs");
10
11
  const os = require("os");
11
12
  const path = require("path");
12
13
  const kit_1 = require("@salesforce/kit");
13
- const mkdirp = require("mkdirp");
14
+ const sfError_1 = require("./sfError");
14
15
  /**
15
16
  * Represents an environment mode. Supports `production`, `development`, `demo`, and `test`
16
17
  * with the default mode being `production`.
@@ -68,7 +69,17 @@ class Global {
68
69
  */
69
70
  static async createDir(dirPath) {
70
71
  dirPath = dirPath ? path.join(Global.SFDX_DIR, dirPath) : Global.SFDX_DIR;
71
- await mkdirp(dirPath, '700');
72
+ try {
73
+ if (process.platform === 'win32') {
74
+ await fs.promises.mkdir(dirPath, { recursive: true });
75
+ }
76
+ else {
77
+ await fs.promises.mkdir(dirPath, { recursive: true, mode: 0o700 });
78
+ }
79
+ }
80
+ catch (error) {
81
+ throw new sfError_1.SfError(`Failed to create directory or set permissions for: ${dirPath}`);
82
+ }
72
83
  }
73
84
  }
74
85
  exports.Global = Global;
package/lib/logger.js CHANGED
@@ -18,7 +18,6 @@ const Bunyan = require("@salesforce/bunyan");
18
18
  const kit_1 = require("@salesforce/kit");
19
19
  const ts_types_1 = require("@salesforce/ts-types");
20
20
  const Debug = require("debug");
21
- const mkdirp = require("mkdirp");
22
21
  const global_1 = require("./global");
23
22
  const sfError_1 = require("./sfError");
24
23
  /**
@@ -245,12 +244,15 @@ class Logger {
245
244
  }
246
245
  catch (err1) {
247
246
  try {
248
- await mkdirp(path.dirname(logFile), {
249
- mode: '700',
250
- });
247
+ if (process.platform === 'win32') {
248
+ await fs.promises.mkdir(path.dirname(logFile), { recursive: true });
249
+ }
250
+ else {
251
+ await fs.promises.mkdir(path.dirname(logFile), { recursive: true, mode: 0o700 });
252
+ }
251
253
  }
252
254
  catch (err2) {
253
- // noop; directory exists already
255
+ throw sfError_1.SfError.wrap(err2);
254
256
  }
255
257
  try {
256
258
  await fs.promises.writeFile(logFile, '', { mode: '600' });
@@ -285,9 +287,12 @@ class Logger {
285
287
  }
286
288
  catch (err1) {
287
289
  try {
288
- mkdirp.sync(path.dirname(logFile), {
289
- mode: '700',
290
- });
290
+ if (process.platform === 'win32') {
291
+ fs.mkdirSync(path.dirname(logFile));
292
+ }
293
+ else {
294
+ fs.mkdirSync(path.dirname(logFile), { mode: 0x700 });
295
+ }
291
296
  }
292
297
  catch (err2) {
293
298
  // noop; directory exists already
package/lib/org/org.d.ts CHANGED
@@ -61,6 +61,7 @@ export declare type SandboxProcessObject = {
61
61
  export declare type SandboxRequest = {
62
62
  SandboxName: string;
63
63
  LicenseType?: string;
64
+ /** Should match a SandboxInfoId, not a SandboxProcessId */
64
65
  SourceId?: string;
65
66
  Description?: string;
66
67
  };
@@ -129,11 +130,11 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
129
130
  /**
130
131
  *
131
132
  * @param sandboxReq SandboxRequest options to create the sandbox with
132
- * @param sandboxName
133
+ * @param sourceSandboxName the name of the sandbox that your new sandbox will be based on
133
134
  * @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
135
  * @returns {SandboxProcessObject} the newly created sandbox process object
135
136
  */
136
- cloneSandbox(sandboxReq: SandboxRequest, sandboxName: string, options: {
137
+ cloneSandbox(sandboxReq: SandboxRequest, sourceSandboxName: string, options: {
137
138
  wait?: Duration;
138
139
  interval?: Duration;
139
140
  }): Promise<SandboxProcessObject>;
package/lib/org/org.js CHANGED
@@ -129,12 +129,12 @@ class Org extends kit_1.AsyncOptionalCreatable {
129
129
  /**
130
130
  *
131
131
  * @param sandboxReq SandboxRequest options to create the sandbox with
132
- * @param sandboxName
132
+ * @param sourceSandboxName the name of the sandbox that your new sandbox will be based on
133
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
134
  * @returns {SandboxProcessObject} the newly created sandbox process object
135
135
  */
136
- async cloneSandbox(sandboxReq, sandboxName, options) {
137
- sandboxReq.SourceId = (await this.querySandboxProcessBySandboxName(sandboxName)).Id;
136
+ async cloneSandbox(sandboxReq, sourceSandboxName, options) {
137
+ sandboxReq.SourceId = (await this.querySandboxProcessBySandboxName(sourceSandboxName)).SandboxInfoId;
138
138
  this.logger.debug('Clone sandbox sourceId %s', sandboxReq.SourceId);
139
139
  return this.createSandbox(sandboxReq, options);
140
140
  }
@@ -242,7 +242,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
242
242
  * @ignore
243
243
  */
244
244
  async retrieveOrgUsersConfig() {
245
- return await orgUsersConfig_1.OrgUsersConfig.create(orgUsersConfig_1.OrgUsersConfig.getOptions(this.getOrgId()));
245
+ return orgUsersConfig_1.OrgUsersConfig.create(orgUsersConfig_1.OrgUsersConfig.getOptions(this.getOrgId()));
246
246
  }
247
247
  /**
248
248
  * Cleans up all org related artifacts including users, sandbox config(if a sandbox and auth file.
@@ -269,7 +269,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
269
269
  *
270
270
  */
271
271
  async isSandbox() {
272
- return await (await stateAggregator_1.StateAggregator.getInstance()).sandboxes.hasFile(this.getOrgId());
272
+ return (await stateAggregator_1.StateAggregator.getInstance()).sandboxes.hasFile(this.getOrgId());
273
273
  }
274
274
  /**
275
275
  * Check that this org is a scratch org by asking the dev hub if it knows about it.
@@ -636,7 +636,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
636
636
  * results in a warning.
637
637
  */
638
638
  async retrieveMaxApiVersion() {
639
- return await this.getConnection().retrieveMaxApiVersion();
639
+ return this.getConnection().retrieveMaxApiVersion();
640
640
  }
641
641
  /**
642
642
  * Returns the admin username used to create the org.
@@ -707,7 +707,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
707
707
  * @private
708
708
  */
709
709
  async querySandboxProcessBySandboxName(name) {
710
- return await this.querySandboxProcess(`SandboxName='${name}'`);
710
+ return this.querySandboxProcess(`SandboxName='${name}'`);
711
711
  }
712
712
  /**
713
713
  * query SandboxProcess via SandboxInfoId
@@ -716,7 +716,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
716
716
  * @private
717
717
  */
718
718
  async querySandboxProcessBySandboxInfoId(id) {
719
- return await this.querySandboxProcess(`SandboxInfoId='${id}'`);
719
+ return this.querySandboxProcess(`SandboxInfoId='${id}'`);
720
720
  }
721
721
  /**
722
722
  * query SandboxProcess via Id
@@ -725,7 +725,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
725
725
  * @private
726
726
  */
727
727
  async querySandboxProcessById(id) {
728
- return await this.querySandboxProcess(`Id='${id}'`);
728
+ return this.querySandboxProcess(`Id='${id}'`);
729
729
  }
730
730
  /**
731
731
  * Initialize async components.
@@ -1098,7 +1098,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
1098
1098
  */
1099
1099
  async querySandboxProcess(where) {
1100
1100
  const queryStr = `SELECT Id, Status, SandboxName, SandboxInfoId, LicenseType, CreatedDate, CopyProgress, SandboxOrganization, SourceId, Description, EndDate FROM SandboxProcess WHERE ${where} AND Status != 'D'`;
1101
- return await this.connection.singleRecordQuery(queryStr, {
1101
+ return this.connection.singleRecordQuery(queryStr, {
1102
1102
  tooling: true,
1103
1103
  });
1104
1104
  }
@@ -67,13 +67,34 @@ const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
67
67
  const ancestorIds = await Promise.all(packagesWithAncestors.map(async (packageDir) => {
68
68
  // ancestorID can be 05i, or 04t, alias; OR "ancestorVersion": "4.6.0.1"
69
69
  // according to docs, 05i is not ok: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev2gp_config_file.htm
70
+ // package can be an ID, but not according to docs
71
+ const packageAliases = projectJson.get('packageAliases');
72
+ const packageId = packageAliases[(0, ts_types_1.ensureString)(packageDir.package)] ?? packageDir.package;
73
+ // Handle HIGHEST and NONE in ancestor(Version|Id).
74
+ // Precedence chain: NONE -> HIGHEST -> ancestorVersion & ancestoryId
75
+ if (packageDir.ancestorVersion === 'NONE' || packageDir.ancestorId === 'NONE') {
76
+ return '';
77
+ }
78
+ else if (packageDir.ancestorVersion === 'HIGHEST' || packageDir.ancestorId === 'HIGHEST') {
79
+ const query = 'SELECT Id FROM Package2Version ' +
80
+ `WHERE Package2Id = '${packageId}' AND IsReleased = True AND IsDeprecated = False AND PatchVersion = 0 ` +
81
+ 'ORDER BY MajorVersion Desc, MinorVersion Desc, PatchVersion Desc, BuildNumber Desc LIMIT 1';
82
+ try {
83
+ return (await hubOrg.getConnection().singleRecordQuery(query, { tooling: true })).Id;
84
+ }
85
+ catch (err) {
86
+ if (packageDir.ancestorVersion === 'HIGHEST') {
87
+ throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorError', [packageDir.ancestorVersion, packageDir.package]), 'NoMatchingAncestorError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorVersion])]);
88
+ }
89
+ else {
90
+ throw new sfError_1.SfError(messages.getMessage('NoMatchingAncestorIdError', [packageDir.ancestorId, packageDir.package]), 'NoMatchingAncestorIdError', [messages.getMessage('AncestorNotReleasedError', [packageDir.ancestorId])]);
91
+ }
92
+ }
93
+ }
70
94
  if (packageDir.ancestorVersion) {
71
95
  if (!/^[0-9]+.[0-9]+.[0-9]+(.[0-9]+)?$/.test(packageDir.ancestorVersion)) {
72
96
  throw messages.createError('InvalidAncestorVersionFormatError', [packageDir.ancestorVersion]);
73
97
  }
74
- // package can be an ID, but not according to docs
75
- const packageAliases = projectJson.get('packageAliases');
76
- const packageId = packageAliases[(0, ts_types_1.ensureString)(packageDir.package)] ?? packageDir.package;
77
98
  const [major, minor, patch] = packageDir.ancestorVersion.split('.');
78
99
  let releasedAncestor;
79
100
  try {
@@ -102,14 +123,14 @@ const getAncestorIds = async (scratchOrgInfo, projectJson, hubOrg) => {
102
123
  .getConnection()
103
124
  .singleRecordQuery(`SELECT Id FROM Package2Version WHERE SubscriberPackageVersionId = '${packageDir.ancestorId}'`, { tooling: true })).Id;
104
125
  }
105
- // ancestorID can be an alias get it from projectJson
106
- const packageAliases = projectJson.get('packageAliases');
126
+ // ancestorID can be an alias; get it from projectJson
107
127
  if (packageDir.ancestorId && packageAliases?.[packageDir.ancestorId]) {
108
128
  return packageAliases[packageDir.ancestorId];
109
129
  }
110
130
  throw new sfError_1.SfError(`Invalid ancestorId ${packageDir.ancestorId}`, 'InvalidAncestorId');
111
131
  }));
112
- return Array.from(new Set(ancestorIds)).join(';');
132
+ // strip out '' due to NONE
133
+ return Array.from(new Set(ancestorIds.filter((id) => id !== ''))).join(';');
113
134
  };
114
135
  exports.getAncestorIds = getAncestorIds;
115
136
  /**
@@ -8,7 +8,11 @@ The ancestor versionNumber must be in the format major.minor.patch but the value
8
8
 
9
9
  # NoMatchingAncestorError
10
10
 
11
- The ancestorId for ancestorVersion %s can't be found. Package ID %s.",
11
+ The ancestor for ancestorVersion %s can't be found. Package ID %s.",
12
+
13
+ # NoMatchingAncestorIdError
14
+
15
+ The ancestor for ancestorId [%s] can't be found. Package ID %s."
12
16
 
13
17
  # AncestorNotReleasedError
14
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "3.24.1",
3
+ "version": "3.24.4",
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",
@@ -39,7 +39,6 @@
39
39
  "@salesforce/schemas": "^1.1.0",
40
40
  "@salesforce/ts-types": "^1.5.20",
41
41
  "@types/graceful-fs": "^4.1.5",
42
- "@types/mkdirp": "^1.0.2",
43
42
  "@types/semver": "^7.3.9",
44
43
  "ajv": "^8.11.0",
45
44
  "archiver": "^5.3.0",
@@ -51,7 +50,6 @@
51
50
  "js2xmlparser": "^4.0.1",
52
51
  "jsforce": "^2.0.0-beta.16",
53
52
  "jsonwebtoken": "8.5.1",
54
- "mkdirp": "1.0.4",
55
53
  "ts-retry-promise": "^0.6.0"
56
54
  },
57
55
  "devDependencies": {