@salesforce/core 3.32.14 → 3.33.1
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/lib/messages.d.ts +15 -0
- package/lib/messages.js +35 -6
- package/lib/org/org.d.ts +7 -1
- package/lib/org/org.js +21 -1
- package/package.json +4 -4
package/lib/messages.d.ts
CHANGED
|
@@ -253,6 +253,20 @@ export declare class Messages<T extends string> {
|
|
|
253
253
|
* @param cause The underlying error that caused this error to be raised.
|
|
254
254
|
*/
|
|
255
255
|
createError(key: T, tokens?: Tokens, actionTokens?: Tokens, exitCodeOrCause?: number | Error, cause?: Error): SfError;
|
|
256
|
+
/**
|
|
257
|
+
* SfError wants error names to end with the suffix Error. Use this to create errors while preserving their existing name (for compatibility reasons).
|
|
258
|
+
*
|
|
259
|
+
* @deprecated Use `createError` instead unless you need to preserver the error name to avoid breaking changes.
|
|
260
|
+
* `error.name` will be the upper-cased key, remove prefixed `error.`.
|
|
261
|
+
* `error.actions` will be loaded using `${key}.actions` if available.
|
|
262
|
+
*
|
|
263
|
+
* @param key The key of the error message.
|
|
264
|
+
* @param tokens The error message tokens.
|
|
265
|
+
* @param actionTokens The action messages tokens.
|
|
266
|
+
* @param exitCodeOrCause The exit code which will be used by SfdxCommand or the underlying error that caused this error to be raised.
|
|
267
|
+
* @param cause The underlying error that caused this error to be raised.
|
|
268
|
+
*/
|
|
269
|
+
createErrorButPreserveName(key: T, tokens?: Tokens, actionTokens?: Tokens, exitCodeOrCause?: number | Error, cause?: Error): SfError;
|
|
256
270
|
/**
|
|
257
271
|
* Convenience method to create warning using message labels.
|
|
258
272
|
*
|
|
@@ -285,6 +299,7 @@ export declare class Messages<T extends string> {
|
|
|
285
299
|
* @param key The key of the warning message.
|
|
286
300
|
* @param tokens The warning message tokens.
|
|
287
301
|
* @param actionTokens The action messages tokens.
|
|
302
|
+
* @param preserveName Do not require that the name end in the type ('error' | 'warning' | 'info').
|
|
288
303
|
*/
|
|
289
304
|
private formatMessageContents;
|
|
290
305
|
private getMessageWithMap;
|
package/lib/messages.js
CHANGED
|
@@ -442,8 +442,36 @@ class Messages {
|
|
|
442
442
|
* @param cause The underlying error that caused this error to be raised.
|
|
443
443
|
*/
|
|
444
444
|
createError(key, tokens = [], actionTokens = [], exitCodeOrCause, cause) {
|
|
445
|
-
const
|
|
446
|
-
|
|
445
|
+
const { message, name, actions } = this.formatMessageContents({
|
|
446
|
+
type: 'error',
|
|
447
|
+
key,
|
|
448
|
+
tokens,
|
|
449
|
+
actionTokens,
|
|
450
|
+
});
|
|
451
|
+
return new sfError_1.SfError(message, name, actions, exitCodeOrCause, cause);
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* SfError wants error names to end with the suffix Error. Use this to create errors while preserving their existing name (for compatibility reasons).
|
|
455
|
+
*
|
|
456
|
+
* @deprecated Use `createError` instead unless you need to preserver the error name to avoid breaking changes.
|
|
457
|
+
* `error.name` will be the upper-cased key, remove prefixed `error.`.
|
|
458
|
+
* `error.actions` will be loaded using `${key}.actions` if available.
|
|
459
|
+
*
|
|
460
|
+
* @param key The key of the error message.
|
|
461
|
+
* @param tokens The error message tokens.
|
|
462
|
+
* @param actionTokens The action messages tokens.
|
|
463
|
+
* @param exitCodeOrCause The exit code which will be used by SfdxCommand or the underlying error that caused this error to be raised.
|
|
464
|
+
* @param cause The underlying error that caused this error to be raised.
|
|
465
|
+
*/
|
|
466
|
+
createErrorButPreserveName(key, tokens = [], actionTokens = [], exitCodeOrCause, cause) {
|
|
467
|
+
const { message, name, actions } = this.formatMessageContents({
|
|
468
|
+
type: 'error',
|
|
469
|
+
key,
|
|
470
|
+
tokens,
|
|
471
|
+
actionTokens,
|
|
472
|
+
preserveName: true,
|
|
473
|
+
});
|
|
474
|
+
return new sfError_1.SfError(message, name, actions, exitCodeOrCause, cause);
|
|
447
475
|
}
|
|
448
476
|
/**
|
|
449
477
|
* Convenience method to create warning using message labels.
|
|
@@ -456,7 +484,7 @@ class Messages {
|
|
|
456
484
|
* @param actionTokens The action messages tokens.
|
|
457
485
|
*/
|
|
458
486
|
createWarning(key, tokens = [], actionTokens = []) {
|
|
459
|
-
return this.formatMessageContents('warning', key, tokens, actionTokens);
|
|
487
|
+
return this.formatMessageContents({ type: 'warning', key, tokens, actionTokens });
|
|
460
488
|
}
|
|
461
489
|
/**
|
|
462
490
|
* Convenience method to create info using message labels.
|
|
@@ -469,7 +497,7 @@ class Messages {
|
|
|
469
497
|
* @param actionTokens The action messages tokens.
|
|
470
498
|
*/
|
|
471
499
|
createInfo(key, tokens = [], actionTokens = []) {
|
|
472
|
-
return this.formatMessageContents('info', key, tokens, actionTokens);
|
|
500
|
+
return this.formatMessageContents({ type: 'info', key, tokens, actionTokens });
|
|
473
501
|
}
|
|
474
502
|
/**
|
|
475
503
|
* Formats message contents given a message type, key, tokens and actions tokens
|
|
@@ -481,8 +509,9 @@ class Messages {
|
|
|
481
509
|
* @param key The key of the warning message.
|
|
482
510
|
* @param tokens The warning message tokens.
|
|
483
511
|
* @param actionTokens The action messages tokens.
|
|
512
|
+
* @param preserveName Do not require that the name end in the type ('error' | 'warning' | 'info').
|
|
484
513
|
*/
|
|
485
|
-
formatMessageContents(type, key, tokens = [], actionTokens = []) {
|
|
514
|
+
formatMessageContents({ type, key, tokens = [], actionTokens = [], preserveName = false, }) {
|
|
486
515
|
const label = (0, kit_1.upperFirst)(type);
|
|
487
516
|
const labelRegExp = new RegExp(`${label}$`);
|
|
488
517
|
const searchValue = type === 'error' ? /^error.*\./ : new RegExp(`^${type}.`);
|
|
@@ -490,7 +519,7 @@ class Messages {
|
|
|
490
519
|
// 'myMessage' -> `MyMessageWarning`
|
|
491
520
|
// 'myMessageError' -> `MyMessageError`
|
|
492
521
|
// 'warning.myMessage' -> `MyMessageWarning`
|
|
493
|
-
const name = `${(0, kit_1.upperFirst)(key.replace(searchValue, ''))}${labelRegExp.exec(key) ? '' : label}`;
|
|
522
|
+
const name = `${(0, kit_1.upperFirst)(key.replace(searchValue, ''))}${labelRegExp.exec(key) || preserveName ? '' : label}`;
|
|
494
523
|
const message = this.getMessage(key, tokens);
|
|
495
524
|
let actions;
|
|
496
525
|
try {
|
package/lib/org/org.d.ts
CHANGED
|
@@ -182,7 +182,7 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
|
|
|
182
182
|
*/
|
|
183
183
|
retrieveOrgUsersConfig(): Promise<OrgUsersConfig>;
|
|
184
184
|
/**
|
|
185
|
-
* Cleans up all org related artifacts including users, sandbox config(if a sandbox and auth file.
|
|
185
|
+
* Cleans up all org related artifacts including users, sandbox config (if a sandbox), source tracking files, and auth file.
|
|
186
186
|
*
|
|
187
187
|
* @param throwWhenRemoveFails Determines if the call should throw an error or fail silently.
|
|
188
188
|
*/
|
|
@@ -468,6 +468,12 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
|
|
|
468
468
|
*/
|
|
469
469
|
private sandboxSignupComplete;
|
|
470
470
|
private validateWaitOptions;
|
|
471
|
+
/**
|
|
472
|
+
* removes source tracking files hosted in the project/.sf/orgs/<org id>/
|
|
473
|
+
*
|
|
474
|
+
* @private
|
|
475
|
+
*/
|
|
476
|
+
private removeSourceTrackingFiles;
|
|
471
477
|
}
|
|
472
478
|
export declare namespace Org {
|
|
473
479
|
/**
|
package/lib/org/org.js
CHANGED
|
@@ -246,7 +246,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
246
246
|
return orgUsersConfig_1.OrgUsersConfig.create(orgUsersConfig_1.OrgUsersConfig.getOptions(this.getOrgId()));
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
249
|
-
* Cleans up all org related artifacts including users, sandbox config(if a sandbox and auth file.
|
|
249
|
+
* Cleans up all org related artifacts including users, sandbox config (if a sandbox), source tracking files, and auth file.
|
|
250
250
|
*
|
|
251
251
|
* @param throwWhenRemoveFails Determines if the call should throw an error or fail silently.
|
|
252
252
|
*/
|
|
@@ -264,6 +264,7 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
264
264
|
//
|
|
265
265
|
// So, just in case no users are added to this org we will try the remove again.
|
|
266
266
|
await this.removeAuth();
|
|
267
|
+
await this.removeSourceTrackingFiles();
|
|
267
268
|
}
|
|
268
269
|
/**
|
|
269
270
|
* Check if org is a sandbox org by checking its SandboxOrgConfig.
|
|
@@ -1176,6 +1177,25 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
1176
1177
|
pollInterval = pollInterval.seconds > wait.seconds ? wait : pollInterval;
|
|
1177
1178
|
return [wait, pollInterval];
|
|
1178
1179
|
}
|
|
1180
|
+
/**
|
|
1181
|
+
* removes source tracking files hosted in the project/.sf/orgs/<org id>/
|
|
1182
|
+
*
|
|
1183
|
+
* @private
|
|
1184
|
+
*/
|
|
1185
|
+
async removeSourceTrackingFiles() {
|
|
1186
|
+
try {
|
|
1187
|
+
const rootFolder = await config_1.Config.resolveRootFolder(false);
|
|
1188
|
+
await fs.promises.rm((0, path_1.join)(rootFolder, global_1.Global.SF_STATE_FOLDER, 'orgs', this.getOrgId()), {
|
|
1189
|
+
recursive: true,
|
|
1190
|
+
force: true,
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
catch (e) {
|
|
1194
|
+
const err = sfError_1.SfError.wrap(e);
|
|
1195
|
+
// consume the error in case something went wrong
|
|
1196
|
+
this.logger.debug(`error deleting source tracking information for ${this.getOrgId()} error: ${err.message}`);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1179
1199
|
}
|
|
1180
1200
|
exports.Org = Org;
|
|
1181
1201
|
(function (Org) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.33.1",
|
|
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",
|
|
@@ -69,10 +69,10 @@
|
|
|
69
69
|
"chai": "^4.3.7",
|
|
70
70
|
"chai-string": "^1.5.0",
|
|
71
71
|
"commitizen": "^3.1.2",
|
|
72
|
-
"eslint": "^8.
|
|
73
|
-
"eslint-config-prettier": "^8.
|
|
72
|
+
"eslint": "^8.32.0",
|
|
73
|
+
"eslint-config-prettier": "^8.6.0",
|
|
74
74
|
"eslint-config-salesforce": "^1.1.0",
|
|
75
|
-
"eslint-config-salesforce-license": "^0.
|
|
75
|
+
"eslint-config-salesforce-license": "^0.2.0",
|
|
76
76
|
"eslint-config-salesforce-typescript": "^1.1.1",
|
|
77
77
|
"eslint-plugin-header": "^3.1.1",
|
|
78
78
|
"eslint-plugin-import": "^2.26.0",
|