@salesforce/plugin-settings 1.5.0-qa.5 → 2.0.2

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.
Files changed (43) hide show
  1. package/README.md +173 -17
  2. package/lib/alias.js +2 -6
  3. package/lib/alias.js.map +1 -1
  4. package/lib/commands/alias/list.d.ts +2 -2
  5. package/lib/commands/alias/list.js +15 -16
  6. package/lib/commands/alias/list.js.map +1 -1
  7. package/lib/commands/alias/set.d.ts +2 -2
  8. package/lib/commands/alias/set.js +22 -19
  9. package/lib/commands/alias/set.js.map +1 -1
  10. package/lib/commands/alias/unset.d.ts +4 -4
  11. package/lib/commands/alias/unset.js +31 -28
  12. package/lib/commands/alias/unset.js.map +1 -1
  13. package/lib/commands/config/get.d.ts +5 -4
  14. package/lib/commands/config/get.js +31 -32
  15. package/lib/commands/config/get.js.map +1 -1
  16. package/lib/commands/config/list.d.ts +5 -4
  17. package/lib/commands/config/list.js +18 -23
  18. package/lib/commands/config/list.js.map +1 -1
  19. package/lib/commands/config/set.d.ts +7 -8
  20. package/lib/commands/config/set.js +46 -69
  21. package/lib/commands/config/set.js.map +1 -1
  22. package/lib/commands/config/unset.d.ts +7 -8
  23. package/lib/commands/config/unset.js +39 -52
  24. package/lib/commands/config/unset.js.map +1 -1
  25. package/lib/config.d.ts +8 -10
  26. package/lib/config.js +80 -75
  27. package/lib/config.js.map +1 -1
  28. package/lib/hooks/init/load_config_meta.js +14 -41
  29. package/lib/hooks/init/load_config_meta.js.map +1 -1
  30. package/lib/index.d.ts +1 -1
  31. package/lib/index.js +2 -3
  32. package/lib/index.js.map +1 -1
  33. package/messages/config.get.md +3 -1
  34. package/messages/config.list.md +6 -2
  35. package/messages/config.set.md +8 -8
  36. package/messages/config.unset.md +7 -1
  37. package/oclif.lock +8550 -0
  38. package/oclif.manifest.json +286 -144
  39. package/package.json +225 -220
  40. package/schemas/config-get.json +1 -1
  41. package/schemas/config-list.json +1 -1
  42. package/schemas/config-set.json +3 -3
  43. package/schemas/config-unset.json +3 -3
package/lib/config.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { SfCommand } from '@salesforce/sf-plugins-core';
1
+ import { Ux } from '@salesforce/sf-plugins-core';
2
2
  import { ConfigInfo } from '@salesforce/core';
3
+ import { HelpSection } from '@oclif/core';
3
4
  export type Msg = {
4
5
  name: string;
5
- value?: string;
6
+ value?: string | boolean | number | null;
6
7
  success: boolean;
7
8
  location?: string;
8
9
  path?: string;
@@ -20,11 +21,8 @@ export type Msg = {
20
21
  deprecated?: boolean;
21
22
  };
22
23
  export type ConfigResponses = Msg[];
23
- export declare const CONFIG_HELP_SECTION: import("@oclif/core").HelpSection;
24
- export declare abstract class ConfigCommand<T> extends SfCommand<T> {
25
- protected responses: ConfigResponses;
26
- calculateSuggestion(userEnteredConfig: string): string;
27
- protected pushSuccess(configInfo: ConfigInfo): void;
28
- protected pushFailure(name: string, err: string | Error, value?: string): void;
29
- protected output(title: string, verbose: boolean): void;
30
- }
24
+ export declare const CONFIG_HELP_SECTION: HelpSection;
25
+ export declare const calculateSuggestion: (userEnteredConfig: string) => string;
26
+ export declare const buildFailureMsg: (name: string, err: unknown, value?: string) => Msg;
27
+ export declare const buildSuccessMsg: (configInfo: ConfigInfo) => Msg;
28
+ export declare const output: (ux: Ux, responses: Msg[], command: 'set' | 'unset' | 'list' | 'get', verbose?: boolean) => void;
package/lib/config.js CHANGED
@@ -1,86 +1,91 @@
1
- "use strict";
2
1
  /*
3
2
  * Copyright (c) 2020, salesforce.com, inc.
4
3
  * All rights reserved.
5
4
  * Licensed under the BSD 3-Clause license.
6
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
6
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ConfigCommand = exports.CONFIG_HELP_SECTION = void 0;
10
- const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
11
- const core_1 = require("@salesforce/core");
12
- const sf_plugins_core_2 = require("@salesforce/sf-plugins-core");
13
- const Levenshtein = require("fast-levenshtein");
14
- exports.CONFIG_HELP_SECTION = (0, sf_plugins_core_2.toHelpSection)('CONFIGURATION VARIABLES', ...new Set(core_1.Config.getAllowedProperties().map((k) => k.newKey ?? k.key)));
15
- class ConfigCommand extends sf_plugins_core_1.SfCommand {
16
- constructor() {
17
- super(...arguments);
18
- this.responses = [];
7
+ import { SfError, Config } from '@salesforce/core';
8
+ import { toHelpSection } from '@salesforce/sf-plugins-core';
9
+ import Levenshtein from 'fast-levenshtein';
10
+ import { isJsonMap } from '@salesforce/ts-types';
11
+ export const CONFIG_HELP_SECTION = toHelpSection('CONFIGURATION VARIABLES', ...new Set(Config.getAllowedProperties().map((k) => k.newKey ?? k.key)));
12
+ export const calculateSuggestion = (userEnteredConfig) => {
13
+ // we'll use this array to keep track of which key is the closest to the users entered value.
14
+ // keys closer to the index 0 will be a closer guess than keys indexed further from 0
15
+ // an entry at 0 would be a direct match, an entry at 1 would be a single character off, etc.
16
+ const index = [];
17
+ Config.getAllowedProperties()
18
+ .map((k) => k.newKey ?? k.key)
19
+ .map((k) => (index[Levenshtein.get(userEnteredConfig, k)] = k));
20
+ return index.find((item) => item !== undefined) ?? '';
21
+ };
22
+ export const buildFailureMsg = (name, err, value) => {
23
+ const error = SfError.wrap(typeof err !== 'string' && !(err instanceof Error) ? 'Unknown error' : err);
24
+ return {
25
+ name,
26
+ success: false,
27
+ value,
28
+ error,
29
+ message: error.message.replace(/\.\.$/, '.'),
30
+ };
31
+ };
32
+ export const buildSuccessMsg = (configInfo) => {
33
+ if (Array.isArray(configInfo.value)) {
34
+ throw new SfError(`Config ${configInfo.key} is an Array. It should be a primitive.`);
19
35
  }
20
- // eslint-disable-next-line class-methods-use-this
21
- calculateSuggestion(userEnteredConfig) {
22
- // we'll use this array to keep track of which key is the closest to the users entered value.
23
- // keys closer to the index 0 will be a closer guess than keys indexed further from 0
24
- // an entry at 0 would be a direct match, an entry at 1 would be a single character off, etc.
25
- const index = [];
26
- core_1.Config.getAllowedProperties()
27
- .map((k) => k.newKey ?? k.key)
28
- .map((k) => (index[Levenshtein.get(userEnteredConfig, k)] = k));
29
- return index.find((item) => item !== undefined) ?? '';
36
+ if (isJsonMap(configInfo.value)) {
37
+ throw new SfError(`Config ${configInfo.key} is an Object. It should be a primitive.`);
30
38
  }
31
- pushSuccess(configInfo) {
32
- this.responses.push({
33
- name: configInfo.key,
34
- key: configInfo.key,
35
- value: configInfo.value,
36
- path: configInfo.path,
37
- success: true,
38
- location: configInfo.location,
39
- });
39
+ return {
40
+ name: configInfo.key,
41
+ key: configInfo.key,
42
+ value: configInfo.value,
43
+ path: configInfo.path,
44
+ success: true,
45
+ location: configInfo.location,
46
+ };
47
+ };
48
+ export const output = (ux, responses, command, verbose = false) => {
49
+ if (!ux.outputEnabled) {
50
+ return;
40
51
  }
41
- pushFailure(name, err, value) {
42
- const error = core_1.SfError.wrap(err);
43
- this.responses.push({
44
- name,
45
- success: false,
46
- value,
47
- error,
48
- message: error.message.replace(/\.\.$/, '.'),
49
- });
50
- process.exitCode = 1;
52
+ if (responses.length === 0) {
53
+ ux.log('No results found');
54
+ return;
51
55
  }
52
- output(title, verbose) {
53
- if (this.responses.length === 0) {
54
- this.log('No results found');
55
- return;
56
- }
57
- const columns = {
58
- name: { header: 'Name' },
59
- };
60
- if (!title.includes('Unset')) {
61
- columns.value = {
62
- header: 'Value',
63
- get: (row) => row.value ?? '',
64
- };
65
- }
66
- if (!title.includes('List')) {
67
- columns.success = { header: 'Success' };
68
- }
69
- if (verbose) {
70
- columns.location = {
71
- header: 'Location',
72
- get: (row) => row.location ?? '',
73
- };
74
- }
75
- if (this.responses.some((msg) => msg.error)) {
76
- columns.message = {
77
- header: 'Message',
78
- get: (row) => row.message ?? '',
79
- };
80
- this.responses.map((msg) => (msg.message = msg.error?.message));
81
- }
82
- this.table(this.responses, columns, { title });
83
- }
84
- }
85
- exports.ConfigCommand = ConfigCommand;
56
+ ux.table(responses, {
57
+ name: { header: 'Name' },
58
+ ...(verbose
59
+ ? {
60
+ location: {
61
+ header: 'Location',
62
+ get: (row) => row.location ?? '',
63
+ },
64
+ }
65
+ : {}),
66
+ ...(command === 'unset'
67
+ ? {}
68
+ : {
69
+ value: {
70
+ header: 'Value',
71
+ get: (row) => row.value,
72
+ },
73
+ }),
74
+ ...(command === 'list' ? {} : { success: { header: 'Success' } }),
75
+ ...(responses.some((msg) => msg.error)
76
+ ? {
77
+ message: {
78
+ header: 'Message',
79
+ get: (row) => row.error?.message ?? '',
80
+ },
81
+ }
82
+ : {}),
83
+ }, { title: commandToTitleMapping[command] });
84
+ };
85
+ const commandToTitleMapping = {
86
+ set: 'Set Config',
87
+ unset: 'Unset Config',
88
+ list: 'List Config',
89
+ get: 'Get Config',
90
+ };
86
91
  //# sourceMappingURL=config.js.map
package/lib/config.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,iEAAwD;AAExD,2CAA+D;AAC/D,iEAA4D;AAC5D,gDAAgD;AAmBnC,QAAA,mBAAmB,GAAG,IAAA,+BAAa,EAC9C,yBAAyB,EACzB,GAAG,IAAI,GAAG,CAAC,aAAM,CAAC,oBAAoB,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CACxE,CAAC;AAEF,MAAsB,aAAiB,SAAQ,2BAAY;IAA3D;;QACY,cAAS,GAAoB,EAAE,CAAC;IAyE5C,CAAC;IAxEC,kDAAkD;IAC3C,mBAAmB,CAAC,iBAAyB;QAClD,6FAA6F;QAC7F,qFAAqF;QACrF,6FAA6F;QAC7F,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,aAAM,CAAC,oBAAoB,EAAE;aAC1B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM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AE;iBACjC;aACF;YACH,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,OAAO,KAAK,OAAO;YACrB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACE,KAAK,EAAE;oBACL,MAAM,EAAE,OAAO;oBACf,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK;iBACxB;aACF,CAAC;QACN,GAAG,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC;QACjE,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;YACpC,CAAC,CAAC;gBACE,OAAO,EAAE;oBACP,MAAM,EAAE,SAAS;oBACjB,GAAG,EAAE,CAAC,GAAG,EAAU,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,IAAI,EAAE;iBAC/C;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,EACD,EAAE,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAC1C,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG;IAC5B,GAAG,EAAE,YAAY;IACjB,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,aAAa;IACnB,GAAG,EAAE,YAAY;CACT,CAAC"}
@@ -1,59 +1,32 @@
1
- "use strict";
2
1
  /*
3
2
  * Copyright (c) 2020, salesforce.com, inc.
4
3
  * All rights reserved.
5
4
  * Licensed under the BSD 3-Clause license.
6
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
6
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const core_1 = require("@oclif/core");
10
- const core_2 = require("@salesforce/core");
11
- const ts_types_1 = require("@salesforce/ts-types");
12
- const log = core_2.Logger.childFromRoot('plugin-settings:load_config_meta');
7
+ import { Config } from '@salesforce/core';
8
+ import { isObject, get } from '@salesforce/ts-types';
9
+ import { ModuleLoader } from '@oclif/core';
13
10
  const OCLIF_META_PJSON_KEY = 'configMeta';
14
- function loadConfigMeta(plugin) {
15
- let configMetaRequireLocation;
16
- try {
17
- const configMetaPath = (0, ts_types_1.get)(plugin, `pjson.oclif.${OCLIF_META_PJSON_KEY}`, null);
11
+ const hook = async ({ config, context }) => {
12
+ const flattenedConfigMetas = (await Promise.all((config.getPluginsList() || []).flatMap(async (plugin) => {
13
+ const configMetaPath = get(plugin, `pjson.oclif.${OCLIF_META_PJSON_KEY}`, null);
18
14
  if (typeof configMetaPath !== 'string') {
19
15
  return;
20
16
  }
21
- const relativePath = (0, core_1.tsPath)(plugin.root, configMetaPath);
22
- // use relative path if it exists, require string as is
23
- configMetaRequireLocation = relativePath ?? configMetaPath;
24
- }
25
- catch {
26
- return;
27
- }
28
- if (!configMetaRequireLocation) {
29
- return;
30
- }
31
- try {
32
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
33
- const configMetaPathModule = require(configMetaRequireLocation);
34
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
35
- return configMetaPathModule?.default ?? configMetaPathModule;
36
- }
37
- catch {
38
- log.error(`Error trying to load config meta from ${configMetaRequireLocation}`);
39
- return;
40
- }
41
- }
42
- const hook = ({ config }) => {
43
- const flattenedConfigMetas = (config.plugins || [])
44
- .map((plugin) => {
45
- const configMeta = loadConfigMeta(plugin);
17
+ const module = await ModuleLoader.load(plugin, configMetaPath);
18
+ const configMeta = module.default;
46
19
  if (!configMeta) {
47
- log.info(`No config meta found for ${plugin.name}`);
20
+ context.debug(`No config meta found for ${plugin.name}`);
48
21
  }
49
22
  return configMeta;
50
- })
51
- .filter(ts_types_1.isObject)
52
- .flat();
23
+ })))
24
+ .flatMap((d) => d)
25
+ .filter(isObject);
53
26
  if (flattenedConfigMetas.length) {
54
- core_2.Config.addAllowedProperties(flattenedConfigMetas);
27
+ Config.addAllowedProperties(flattenedConfigMetas);
55
28
  }
56
29
  return Promise.resolve();
57
30
  };
58
- exports.default = hook;
31
+ export default hook;
59
32
  //# sourceMappingURL=load_config_meta.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load_config_meta.js","sourceRoot":"","sources":["../../../src/hooks/init/load_config_meta.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAGH,sCAAqC;AACrC,2CAAsE;AACtE,mDAAqD;AAErD,MAAM,GAAG,GAAG,aAAM,CAAC,aAAa,CAAC,kCAAkC,CAAC,CAAC;AACrE,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C,SAAS,cAAc,CAAC,MAAyB;IAC/C,IAAI,yBAA6C,CAAC;IAElD,IAAI;QACF,MAAM,cAAc,GAAG,IAAA,cAAG,EAAC,MAAM,EAAE,eAAe,oBAAoB,EAAE,EAAE,IAAI,CAAC,CAAC;QAEhF,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;YACtC,OAAO;SACR;QAED,MAAM,YAAY,GAAG,IAAA,aAAM,EAAC,MAAM,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAEzD,uDAAuD;QACvD,yBAAyB,GAAG,YAAY,IAAI,cAAc,CAAC;KAC5D;IAAC,MAAM;QACN,OAAO;KACR;IAED,IAAI,CAAC,yBAAyB,EAAE;QAC9B,OAAO;KACR;IAED,IAAI;QACF,uGAAuG;QACvG,MAAM,oBAAoB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;QAEhE,2GAA2G;QAC3G,OAAO,oBAAoB,EAAE,OAAO,IAAI,oBAAoB,CAAC;KAC9D;IAAC,MAAM;QACN,GAAG,CAAC,KAAK,CAAC,yCAAyC,yBAAyB,EAAE,CAAC,CAAC;QAChF,OAAO;KACR;AACH,CAAC;AAED,MAAM,IAAI,GAAiB,CAAC,EAAE,MAAM,EAAE,EAAiB,EAAE;IACvD,MAAM,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C,OAAO;SACR;QAED,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,IAAI,CAAqC,MAAM,EAAE,cAAc,CAAC,CAAC;QACnG,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;QAElC,IAAI,CAAC,UAAU,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;SAC1D;QACD,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC,CACH,CACF;SACE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;SACjB,MAAM,CAAqB,QAAQ,CAAC,CAAC;IAExC,IAAI,oBAAoB,CAAC,MAAM,EAAE;QAC/B,MAAM,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAC;KACnD;IACD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  declare const _default: {};
2
- export = _default;
2
+ export default _default;
package/lib/index.js CHANGED
@@ -1,9 +1,8 @@
1
- "use strict";
2
1
  /*
3
- * Copyright (c) 2022, salesforce.com, inc.
2
+ * Copyright (c) 2023, salesforce.com, inc.
4
3
  * All rights reserved.
5
4
  * Licensed under the BSD 3-Clause license.
6
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
6
  */
8
- module.exports = {};
7
+ export default {};
9
8
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,iBAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAe,EAAE,CAAC"}
@@ -4,7 +4,9 @@ Get the value of a configuration variable.
4
4
 
5
5
  # description
6
6
 
7
- Run "sf config list" to see all the configuration variables you've set. Global configuration variable are always displayed; local ones are displayed if you run the command in a project directory. Run "sf config set" to set a configuration variable.
7
+ Run "sf config list" to see the configuration variables you've already set and their level (local or global).
8
+
9
+ Run "sf config set" to set a configuration variable. For the full list of available configuration variables, see https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_config_values.htm.
8
10
 
9
11
  # examples
10
12
 
@@ -4,10 +4,14 @@ List the configuration variables that you've previously set.
4
4
 
5
5
  # description
6
6
 
7
- Global configuration variables apply to any Salesforce DX project and are always displayed. If you run this command from a project directory, local configuration variables are also displayed.
7
+ A config variable can be global or local, depending on whether you used the --global flag when you set it. Local config variables apply only to the current project and override global config variables, which apply to all projects. You can set all config variables as environment variables. Environment variables override their equivalent local and global config variables.
8
+
9
+ The output of this command takes into account your current context. For example, let's say you run this command from a Salesforce DX project in which you've locally set the "target-org" config variable. The command displays the local value, even if you've also set "target-org" globally. If you haven't set the config variable locally, then the global value is displayed, if set. If you set the SF_TARGET_ORG environment variable, it's displayed as such and overrides any locally or globally set "target-org" config variable.
10
+
11
+ For the full list of available configuration variables, see https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_config_values.htm.
8
12
 
9
13
  # examples
10
14
 
11
- - List both global configuration variables and those local to your project:
15
+ - List the global and local configuration variables that apply to your current context:
12
16
 
13
17
  $ <%= config.bin %> <%= command.id %>
@@ -16,23 +16,23 @@ The resolution order if you've set a flag value in multiple ways is as follows:
16
16
 
17
17
  Run "sf config list" to see the configuration variables you've already set and their level (local or global).
18
18
 
19
+ If you're setting a single config variable, you don't need to use an equal sign between the variable and value. But you must use the equal sign if setting multiple config variables.
20
+
21
+ For the full list of available configuration variables, see https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_config_values.htm.
22
+
19
23
  # examples
20
24
 
21
25
  - Set the local target-org configuration variable to an org username:
22
26
 
23
- <%= config.bin %> <%= command.id %> target-org=me@my.org
27
+ <%= config.bin %> <%= command.id %> target-org me@my.org
24
28
 
25
29
  - Set the local target-org configuration variable to an alias:
26
30
 
27
- <%= config.bin %> <%= command.id %> target-org=my-scratch-org
28
-
29
- - Set the global target-org configuration variable:
30
-
31
- <%= config.bin %> <%= command.id %> --global target-org=my-scratch-org
31
+ <%= config.bin %> <%= command.id %> target-org my-scratch-org
32
32
 
33
- - Set a single configuration variable without using an equal sign; this syntax doesn't work when setting multiple configuration variables:
33
+ - Set the global target-org and target-dev-hub configuration variables using aliases:
34
34
 
35
- <%= config.bin %> <%= command.id %> target-org me@my.com
35
+ <%= config.bin %> <%= command.id %> --global target-org=my-scratch-org target-dev-hub=my-dev-hub
36
36
 
37
37
  # flags.global.summary
38
38
 
@@ -6,6 +6,8 @@ Unset local or global configuration variables.
6
6
 
7
7
  Local configuration variables apply only to your current project. Global configuration variables apply in any Salesforce DX project.
8
8
 
9
+ For the full list of available configuration variables, see https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_dev_cli_config_values.htm.
10
+
9
11
  # examples
10
12
 
11
13
  - Unset the local "target-org" configuration variable:
@@ -18,7 +20,7 @@ Local configuration variables apply only to your current project. Global configu
18
20
 
19
21
  # flags.global.summary
20
22
 
21
- Unset the configuration variables globally, so they can no longer be used from any Salesforce DX project.
23
+ Unset the configuration variables globally.
22
24
 
23
25
  # error.NoConfigKeysFound
24
26
 
@@ -27,3 +29,7 @@ You must provide one or more configuration variables to unset. Run "sf config li
27
29
  # didYouMean
28
30
 
29
31
  Did you mean %s?
32
+
33
+ # unsetGlobalWarning
34
+
35
+ The %s config variable is still set globally, unset it by using the --global flag.