@salesforce/core 3.33.8 → 3.34.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.
@@ -38,13 +38,8 @@ class TTLConfig extends configFile_1.ConfigFile {
38
38
  }
39
39
  async init() {
40
40
  const contents = await this.read(this.options.throwOnNotFound);
41
- const purged = {};
42
41
  const date = new Date().getTime();
43
- for (const [key, opts] of Object.entries(contents)) {
44
- if (!this.isExpired(date, opts))
45
- purged[key] = opts;
46
- }
47
- this.setContents(purged);
42
+ this.setContents(Object.fromEntries(Object.entries(contents).filter(([, value]) => !this.isExpired(date, value))));
48
43
  }
49
44
  // eslint-disable-next-line class-methods-use-this
50
45
  timestamp(value) {
@@ -277,7 +277,7 @@ const darwinImpl = {
277
277
  // stdout. Reference: http://blog.macromates.com/2006/keychain-access-from-shell/
278
278
  if (stderr.includes('password')) {
279
279
  const match = RegExp(/"(.*)"/).exec(stderr);
280
- if (!match || !match[1]) {
280
+ if (!match?.[1]) {
281
281
  fn(messages.createError('passwordNotFoundError', [`${stdout} - ${stderr}`]));
282
282
  }
283
283
  else {
package/lib/messages.d.ts CHANGED
@@ -80,7 +80,7 @@ export type StoredMessageMap = Map<string, StoredMessage>;
80
80
  *
81
81
  * // Now you can use the messages from anywhere in your code or file.
82
82
  * // If using importMessageDirectory, the bundle name is the file name.
83
- * const messages: Messages = Messages.load(packageName, bundleName);
83
+ * const messages: Messages = Messages.loadMessages(packageName, bundleName);
84
84
  *
85
85
  * // Messages now contains all the message in the bundleName file.
86
86
  * messages.getMessage('authInfoCreationError');
@@ -101,7 +101,7 @@ export declare class Messages<T extends string> {
101
101
  /**
102
102
  * Create a new messages bundle.
103
103
  *
104
- * **Note:** Use {Messages.load} unless you are writing your own loader function.
104
+ * **Note:** Use {Messages.loadMessages} unless you are writing your own loader function.
105
105
  *
106
106
  * @param bundleName The bundle name.
107
107
  * @param locale The locale.
@@ -122,7 +122,7 @@ export declare class Messages<T extends string> {
122
122
  */
123
123
  static getLocale(): string;
124
124
  /**
125
- * Set a custom loader function for a package and bundle that will be called on {@link Messages.load}.
125
+ * Set a custom loader function for a package and bundle that will be called on {@link Messages.loadMessages}.
126
126
  *
127
127
  * @param packageName The npm package name.
128
128
  * @param bundle The name of the bundle.
@@ -148,7 +148,7 @@ export declare class Messages<T extends string> {
148
148
  static importMessageFile(packageName: string, filePath: string): void;
149
149
  /**
150
150
  * Import all json and js files in a messages directory. Use the file name as the bundle key when
151
- * {@link Messages.load} is called. By default, we're assuming the moduleDirectoryPart is a
151
+ * {@link Messages.loadMessages} is called. By default, we're assuming the moduleDirectoryPart is a
152
152
  * typescript project and will truncate to root path (where the package.json file is). If your messages
153
153
  * directory is in another spot or you are not using typescript, pass in false for truncateToProjectPath.
154
154
  *
@@ -167,11 +167,9 @@ export declare class Messages<T extends string> {
167
167
  * Load messages for a given package and bundle. If the bundle is not already cached, use the loader function
168
168
  * created from {@link Messages.setLoaderFunction} or {@link Messages.importMessagesDirectory}.
169
169
  *
170
- * **NOTE: Use {@link Messages.load} instead for safe message validation and usage.**
171
- *
172
170
  * ```typescript
173
171
  * Messages.importMessagesDirectory(__dirname);
174
- * const messages = Messages.load('packageName', 'bundleName');
172
+ * const messages = Messages.loadMessages('packageName', 'bundleName');
175
173
  * ```
176
174
  *
177
175
  * @param packageName The name of the npm package.
@@ -179,21 +177,8 @@ export declare class Messages<T extends string> {
179
177
  */
180
178
  static loadMessages(packageName: string, bundleName: string): Messages<string>;
181
179
  /**
182
- * Load messages for a given package and bundle. If the bundle is not already cached, use the loader function
183
- * created from {@link Messages.setLoaderFunction} or {@link Messages.importMessagesDirectory}.
184
- *
185
- * The message keys that will be used must be passed in for validation. This prevents runtime errors if messages are used but not defined.
186
- *
187
- * **NOTE: This should be defined at the top of the file so validation is done at load time rather than runtime.**
188
- *
189
- * ```typescript
190
- * Messages.importMessagesDirectory(__dirname);
191
- * const messages = Messages.load('packageName', 'bundleName', [
192
- * 'messageKey1',
193
- * 'messageKey2',
194
- * ]);
195
- * ```
196
180
  *
181
+ * @deprecated Use {@link Messages.loadMessages} instead.
197
182
  * @param packageName The name of the npm package.
198
183
  * @param bundleName The name of the bundle to load.
199
184
  * @param keys The message keys that will be used.
package/lib/messages.js CHANGED
@@ -140,7 +140,7 @@ const jsAndJsonLoader = (filePath, fileContents) => {
140
140
  *
141
141
  * // Now you can use the messages from anywhere in your code or file.
142
142
  * // If using importMessageDirectory, the bundle name is the file name.
143
- * const messages: Messages = Messages.load(packageName, bundleName);
143
+ * const messages: Messages = Messages.loadMessages(packageName, bundleName);
144
144
  *
145
145
  * // Messages now contains all the message in the bundleName file.
146
146
  * messages.getMessage('authInfoCreationError');
@@ -150,7 +150,7 @@ class Messages {
150
150
  /**
151
151
  * Create a new messages bundle.
152
152
  *
153
- * **Note:** Use {Messages.load} unless you are writing your own loader function.
153
+ * **Note:** Use {Messages.loadMessages} unless you are writing your own loader function.
154
154
  *
155
155
  * @param bundleName The bundle name.
156
156
  * @param locale The locale.
@@ -169,7 +169,7 @@ class Messages {
169
169
  return 'en_US';
170
170
  }
171
171
  /**
172
- * Set a custom loader function for a package and bundle that will be called on {@link Messages.load}.
172
+ * Set a custom loader function for a package and bundle that will be called on {@link Messages.loadMessages}.
173
173
  *
174
174
  * @param packageName The npm package name.
175
175
  * @param bundle The name of the bundle.
@@ -231,7 +231,7 @@ class Messages {
231
231
  }
232
232
  /**
233
233
  * Import all json and js files in a messages directory. Use the file name as the bundle key when
234
- * {@link Messages.load} is called. By default, we're assuming the moduleDirectoryPart is a
234
+ * {@link Messages.loadMessages} is called. By default, we're assuming the moduleDirectoryPart is a
235
235
  * typescript project and will truncate to root path (where the package.json file is). If your messages
236
236
  * directory is in another spot or you are not using typescript, pass in false for truncateToProjectPath.
237
237
  *
@@ -296,11 +296,9 @@ class Messages {
296
296
  * Load messages for a given package and bundle. If the bundle is not already cached, use the loader function
297
297
  * created from {@link Messages.setLoaderFunction} or {@link Messages.importMessagesDirectory}.
298
298
  *
299
- * **NOTE: Use {@link Messages.load} instead for safe message validation and usage.**
300
- *
301
299
  * ```typescript
302
300
  * Messages.importMessagesDirectory(__dirname);
303
- * const messages = Messages.load('packageName', 'bundleName');
301
+ * const messages = Messages.loadMessages('packageName', 'bundleName');
304
302
  * ```
305
303
  *
306
304
  * @param packageName The name of the npm package.
@@ -327,21 +325,8 @@ class Messages {
327
325
  throw new kit_1.NamedError('MissingBundleError', `Missing bundle ${key} for locale ${Messages.getLocale()}.`);
328
326
  }
329
327
  /**
330
- * Load messages for a given package and bundle. If the bundle is not already cached, use the loader function
331
- * created from {@link Messages.setLoaderFunction} or {@link Messages.importMessagesDirectory}.
332
- *
333
- * The message keys that will be used must be passed in for validation. This prevents runtime errors if messages are used but not defined.
334
- *
335
- * **NOTE: This should be defined at the top of the file so validation is done at load time rather than runtime.**
336
- *
337
- * ```typescript
338
- * Messages.importMessagesDirectory(__dirname);
339
- * const messages = Messages.load('packageName', 'bundleName', [
340
- * 'messageKey1',
341
- * 'messageKey2',
342
- * ]);
343
- * ```
344
328
  *
329
+ * @deprecated Use {@link Messages.loadMessages} instead.
345
330
  * @param packageName The name of the npm package.
346
331
  * @param bundleName The name of the bundle to load.
347
332
  * @param keys The message keys that will be used.
@@ -243,17 +243,20 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
243
243
  // ask all those orgs if they know this orgId
244
244
  await Promise.all(hubAuthInfos.map(async (hubAuthInfo) => {
245
245
  try {
246
- const data = await AuthInfo.queryScratchOrg(hubAuthInfo.username, fields.orgId);
247
- if (data.totalSize > 0) {
248
- // if any return a result
249
- logger.debug(`found orgId ${fields.orgId} in devhub ${hubAuthInfo.username}`);
250
- try {
251
- await orgAuthInfo.save({ ...fields, devHubUsername: hubAuthInfo.username });
252
- logger.debug(`set ${hubAuthInfo.username} as devhub for scratch org ${orgAuthInfo.getUsername()}`);
253
- }
254
- catch (error) {
255
- logger.debug(`error updating auth file for ${orgAuthInfo.getUsername()}`, error);
256
- }
246
+ const soi = await AuthInfo.queryScratchOrg(hubAuthInfo.username, fields.orgId);
247
+ // if any return a result
248
+ logger.debug(`found orgId ${fields.orgId} in devhub ${hubAuthInfo.username}`);
249
+ try {
250
+ await orgAuthInfo.save({
251
+ ...fields,
252
+ devHubUsername: hubAuthInfo.username,
253
+ expirationDate: soi.ExpirationDate,
254
+ isScratch: true,
255
+ });
256
+ logger.debug(`set ${hubAuthInfo.username} as devhub and expirationDate ${soi.ExpirationDate} for scratch org ${orgAuthInfo.getUsername()}`);
257
+ }
258
+ catch (error) {
259
+ logger.debug(`error updating auth file for ${orgAuthInfo.getUsername()}`, error);
257
260
  }
258
261
  }
259
262
  catch (error) {
@@ -270,7 +273,7 @@ class AuthInfo extends kit_1.AsyncOptionalCreatable {
270
273
  static async queryScratchOrg(devHubUsername, scratchOrgId) {
271
274
  const devHubOrg = await org_1.Org.create({ aliasOrUsername: devHubUsername });
272
275
  const conn = devHubOrg.getConnection();
273
- const data = await conn.query(`select Id from ScratchOrgInfo where ScratchOrg = '${(0, sfdc_1.trimTo15)(scratchOrgId)}'`);
276
+ const data = await conn.singleRecordQuery(`select Id, ExpirationDate from ScratchOrgInfo where ScratchOrg = '${(0, sfdc_1.trimTo15)(scratchOrgId)}'`);
274
277
  return data;
275
278
  }
276
279
  /**
@@ -32,7 +32,7 @@ const optionalErrorCodeMessage = (errorCode, args) => {
32
32
  }
33
33
  };
34
34
  const validateScratchOrgInfoForResume = async ({ jobId, scratchOrgInfo, cache, hubUsername, }) => {
35
- if (!scratchOrgInfo || !scratchOrgInfo.Id || scratchOrgInfo.Status === 'Deleted') {
35
+ if (!scratchOrgInfo?.Id || scratchOrgInfo.Status === 'Deleted') {
36
36
  // 1. scratch org info does not exist in that dev hub or has been deleted
37
37
  cache.unset(jobId);
38
38
  await cache.write();
@@ -48,7 +48,7 @@ const validateScratchOrgInfoForResume = async ({ jobId, scratchOrgInfo, cache, h
48
48
  };
49
49
  exports.validateScratchOrgInfoForResume = validateScratchOrgInfoForResume;
50
50
  const checkScratchOrgInfoForErrors = async (orgInfo, hubUsername) => {
51
- if (!orgInfo || !orgInfo.Id) {
51
+ if (!orgInfo?.Id) {
52
52
  throw new sfError_1.SfError('No scratch org info found.', 'ScratchOrgInfoNotFound');
53
53
  }
54
54
  if (orgInfo.Status === 'Active') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "3.33.8",
3
+ "version": "3.34.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",
@@ -37,12 +37,12 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@salesforce/bunyan": "^2.0.0",
40
- "@salesforce/kit": "^1.9.0",
40
+ "@salesforce/kit": "^1.9.2",
41
41
  "@salesforce/schemas": "^1.5.0",
42
42
  "@salesforce/ts-types": "^1.7.2",
43
43
  "@types/graceful-fs": "^4.1.6",
44
44
  "@types/semver": "^7.3.13",
45
- "ajv": "^8.11.2",
45
+ "ajv": "^8.12.0",
46
46
  "archiver": "^5.3.0",
47
47
  "change-case": "^4.1.2",
48
48
  "debug": "^3.2.7",
@@ -58,7 +58,7 @@
58
58
  "@salesforce/dev-config": "^3.0.1",
59
59
  "@salesforce/dev-scripts": "^4.0.0-beta.7",
60
60
  "@salesforce/prettier-config": "^0.0.2",
61
- "@salesforce/ts-sinon": "^1.4.4",
61
+ "@salesforce/ts-sinon": "^1.4.6",
62
62
  "@types/archiver": "^5.3.1",
63
63
  "@types/chai-string": "^1.4.2",
64
64
  "@types/debug": "0.0.31",
@@ -66,30 +66,30 @@
66
66
  "@types/jsonwebtoken": "9.0.1",
67
67
  "@types/lodash": "^4.14.191",
68
68
  "@types/shelljs": "0.8.11",
69
- "@typescript-eslint/eslint-plugin": "^5.53.0",
69
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
70
70
  "@typescript-eslint/parser": "^5.54.1",
71
71
  "chai": "^4.3.7",
72
72
  "chai-string": "^1.5.0",
73
73
  "commitizen": "^3.1.2",
74
- "eslint": "^8.32.0",
75
- "eslint-config-prettier": "^8.6.0",
76
- "eslint-config-salesforce": "^1.1.0",
74
+ "eslint": "^8.35.0",
75
+ "eslint-config-prettier": "^8.7.0",
76
+ "eslint-config-salesforce": "^1.1.1",
77
77
  "eslint-config-salesforce-license": "^0.2.0",
78
78
  "eslint-config-salesforce-typescript": "^1.1.1",
79
79
  "eslint-plugin-header": "^3.1.1",
80
- "eslint-plugin-import": "^2.26.0",
80
+ "eslint-plugin-import": "^2.27.5",
81
81
  "eslint-plugin-jsdoc": "^39.6.4",
82
82
  "husky": "^7.0.4",
83
83
  "lodash": "^4.17.21",
84
84
  "mocha": "^9.1.3",
85
85
  "nyc": "^15.1.0",
86
- "prettier": "^2.8.1",
86
+ "prettier": "^2.8.4",
87
87
  "pretty-quick": "^3.1.3",
88
88
  "shelljs": "0.8.5",
89
89
  "sinon": "^14.0.2",
90
90
  "ts-node": "^10.4.0",
91
91
  "ttypescript": "^1.5.15",
92
- "typescript": "^4.9.4",
92
+ "typescript": "^4.9.5",
93
93
  "wireit": "^0.9.3"
94
94
  },
95
95
  "repository": {