Skip to content

Commit

Permalink
Merge pull request #260 from forcedotcom/develop
Browse files Browse the repository at this point in the history
merge develop to master
  • Loading branch information
amphro authored Jul 29, 2020
2 parents 63cb8fd + bd186c9 commit 3389a79
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
2 changes: 2 additions & 0 deletions messages/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"InvalidConfigValue": "Invalid config value. %s",
"InvalidInstanceUrl": "Specify a valid Salesforce instance URL",
"InvalidApiVersion": "Specify a valid Salesforce API version, for example, 42.0",
"InvalidIsvDebuggerSid": "Specify a valid Debugger SID",
"InvalidIsvDebuggerUrl": "Specify a valid Debugger URL",
"InvalidBooleanConfigValue": "The config value can only be set to true or false.",
"InvalidProjectWorkspace": "This directory does not contain a valid Salesforce DX project",
"SchemaValidationWarning": "The config file: %s is not schema valid\nDue to: %s",
Expand Down
37 changes: 34 additions & 3 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,21 @@ export class Config extends ConfigFile<ConfigFile.Options> {
return this.getContents();
}

/**
* Unsets a value for a property.
*
* **Throws** *{@link SfdxError}{ name: 'UnknownConfigKey' }* If the input validator fails.
* @param key The property to unset.
*/
public unset(key: string): boolean {
const property = Config.allowedProperties.find(allowedProp => allowedProp.key === key);

if (!property) {
throw SfdxError.create('@salesforce/core', 'config', 'UnknownConfigKey', [key]);
}
return super.unset(property.key);
}

/**
* Initializer for supported config types.
*/
Expand All @@ -255,14 +270,30 @@ export class Config extends ConfigFile<ConfigFile.Options> {
hidden: true,
input: {
// If a value is provided validate it otherwise no value is unset.
validator: value => isString(value) && sfdc.validateApiVersion(value),
validator: value => value == null || (isString(value) && sfdc.validateApiVersion(value)),
failedMessage: Config.messages.getMessage('InvalidApiVersion')
}
},
{ key: Config.DEFAULT_DEV_HUB_USERNAME },
{ key: Config.DEFAULT_USERNAME },
{ key: Config.ISV_DEBUGGER_SID, encrypted: true },
{ key: Config.ISV_DEBUGGER_URL },
{
key: Config.ISV_DEBUGGER_SID,
encrypted: true,
input: {
// If a value is provided validate it otherwise no value is unset.
validator: value => value == null || isString(value),
failedMessage: Config.messages.getMessage('InvalidIsvDebuggerSid')
}
},
{
key: Config.ISV_DEBUGGER_URL,
encrypted: true,
input: {
// If a value is provided validate it otherwise no value is unset.
validator: value => value == null || isString(value),
failedMessage: Config.messages.getMessage('InvalidIsvDebuggerUrl')
}
},
{
key: Config.DISABLE_TELEMETRY,
input: {
Expand Down
12 changes: 10 additions & 2 deletions src/config/configStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@
*/

import { AsyncCreatable, set } from '@salesforce/kit';
import { AnyJson, definiteEntriesOf, definiteValuesOf, get, getAnyJson, JsonMap, Optional } from '@salesforce/ts-types';
import { Dictionary } from '@salesforce/ts-types';
import {
AnyJson,
definiteEntriesOf,
definiteValuesOf,
Dictionary,
get,
getAnyJson,
JsonMap,
Optional
} from '@salesforce/ts-types';

/**
* The allowed types stored in a config store.
Expand Down

0 comments on commit 3389a79

Please sign in to comment.