@salesforce/plugin-settings 1.4.5 → 1.4.7
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/commands/alias/set.js +5 -1
- package/lib/commands/alias/set.js.map +1 -1
- package/lib/commands/alias/unset.js +5 -1
- package/lib/commands/alias/unset.js.map +1 -1
- package/lib/commands/config/get.d.ts +3 -2
- package/lib/commands/config/get.js +10 -27
- package/lib/commands/config/get.js.map +1 -1
- package/lib/commands/config/list.d.ts +4 -3
- package/lib/commands/config/list.js +4 -9
- package/lib/commands/config/list.js.map +1 -1
- package/lib/commands/config/set.d.ts +5 -6
- package/lib/commands/config/set.js +21 -67
- package/lib/commands/config/set.js.map +1 -1
- package/lib/commands/config/unset.d.ts +5 -6
- package/lib/commands/config/unset.js +13 -35
- package/lib/commands/config/unset.js.map +1 -1
- package/lib/config.d.ts +6 -9
- package/lib/config.js +83 -70
- package/lib/config.js.map +1 -1
- package/lib/hooks/init/load_config_meta.js +2 -3
- package/lib/hooks/init/load_config_meta.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +220 -221
- package/schemas/config-get.json +1 -1
- package/schemas/config-list.json +1 -1
- package/schemas/config-set.json +3 -3
- package/schemas/config-unset.json +3 -3
package/lib/config.js
CHANGED
|
@@ -6,80 +6,93 @@
|
|
|
6
6
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
10
|
-
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
9
|
+
exports.output = exports.buildSuccessMsg = exports.buildFailureMsg = exports.calculateSuggestion = exports.CONFIG_HELP_SECTION = void 0;
|
|
11
10
|
const core_1 = require("@salesforce/core");
|
|
12
|
-
const
|
|
11
|
+
const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
|
|
13
12
|
const Levenshtein = require("fast-levenshtein");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
const ts_types_1 = require("@salesforce/ts-types");
|
|
14
|
+
exports.CONFIG_HELP_SECTION = (0, sf_plugins_core_1.toHelpSection)('CONFIGURATION VARIABLES', ...new Set(core_1.Config.getAllowedProperties().map((k) => k.newKey ?? k.key)));
|
|
15
|
+
const calculateSuggestion = (userEnteredConfig) => {
|
|
16
|
+
// we'll use this array to keep track of which key is the closest to the users entered value.
|
|
17
|
+
// keys closer to the index 0 will be a closer guess than keys indexed further from 0
|
|
18
|
+
// an entry at 0 would be a direct match, an entry at 1 would be a single character off, etc.
|
|
19
|
+
const index = [];
|
|
20
|
+
core_1.Config.getAllowedProperties()
|
|
21
|
+
.map((k) => k.newKey ?? k.key)
|
|
22
|
+
.map((k) => (index[Levenshtein.get(userEnteredConfig, k)] = k));
|
|
23
|
+
return index.find((item) => item !== undefined) ?? '';
|
|
24
|
+
};
|
|
25
|
+
exports.calculateSuggestion = calculateSuggestion;
|
|
26
|
+
const buildFailureMsg = (name, err, value) => {
|
|
27
|
+
const error = core_1.SfError.wrap(typeof err !== 'string' && !(err instanceof Error) ? 'Unknown error' : err);
|
|
28
|
+
return {
|
|
29
|
+
name,
|
|
30
|
+
success: false,
|
|
31
|
+
value,
|
|
32
|
+
error,
|
|
33
|
+
message: error.message.replace(/\.\.$/, '.'),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.buildFailureMsg = buildFailureMsg;
|
|
37
|
+
const buildSuccessMsg = (configInfo) => {
|
|
38
|
+
if (Array.isArray(configInfo.value)) {
|
|
39
|
+
throw new core_1.SfError(`Config ${configInfo.key} is an Array. It should be a primitive.`);
|
|
30
40
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
name: configInfo.key,
|
|
34
|
-
key: configInfo.key,
|
|
35
|
-
value: configInfo.value,
|
|
36
|
-
success: true,
|
|
37
|
-
location: configInfo.location,
|
|
38
|
-
});
|
|
41
|
+
if ((0, ts_types_1.isJsonMap)(configInfo.value)) {
|
|
42
|
+
throw new core_1.SfError(`Config ${configInfo.key} is an Object. It should be a primitive.`);
|
|
39
43
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
return {
|
|
45
|
+
name: configInfo.key,
|
|
46
|
+
key: configInfo.key,
|
|
47
|
+
value: configInfo.value,
|
|
48
|
+
path: configInfo.path,
|
|
49
|
+
success: true,
|
|
50
|
+
location: configInfo.location,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.buildSuccessMsg = buildSuccessMsg;
|
|
54
|
+
const output = (ux, responses, command, verbose = false) => {
|
|
55
|
+
if (!ux.outputEnabled) {
|
|
56
|
+
return;
|
|
50
57
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
const columns = {
|
|
57
|
-
name: { header: 'Name' },
|
|
58
|
-
};
|
|
59
|
-
if (!title.includes('Unset')) {
|
|
60
|
-
columns.value = {
|
|
61
|
-
header: 'Value',
|
|
62
|
-
get: (row) => row.value ?? '',
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
if (!title.includes('List')) {
|
|
66
|
-
columns.success = { header: 'Success' };
|
|
67
|
-
}
|
|
68
|
-
if (verbose) {
|
|
69
|
-
columns.location = {
|
|
70
|
-
header: 'Location',
|
|
71
|
-
get: (row) => row.location ?? '',
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
if (this.responses.some((msg) => msg.error)) {
|
|
75
|
-
columns.message = {
|
|
76
|
-
header: 'Message',
|
|
77
|
-
get: (row) => row.message ?? '',
|
|
78
|
-
};
|
|
79
|
-
this.responses.map((msg) => (msg.message = msg.error?.message));
|
|
80
|
-
}
|
|
81
|
-
this.table(this.responses, columns, { title });
|
|
58
|
+
if (responses.length === 0) {
|
|
59
|
+
ux.log('No results found');
|
|
60
|
+
return;
|
|
82
61
|
}
|
|
83
|
-
|
|
84
|
-
|
|
62
|
+
ux.table(responses, {
|
|
63
|
+
name: { header: 'Name' },
|
|
64
|
+
...(verbose
|
|
65
|
+
? {
|
|
66
|
+
location: {
|
|
67
|
+
header: 'Location',
|
|
68
|
+
get: (row) => row.location ?? '',
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
: {}),
|
|
72
|
+
...(command === 'unset'
|
|
73
|
+
? {}
|
|
74
|
+
: {
|
|
75
|
+
value: {
|
|
76
|
+
header: 'Value',
|
|
77
|
+
get: (row) => row.value,
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
...(command === 'list' ? {} : { success: { header: 'Success' } }),
|
|
81
|
+
...(responses.some((msg) => msg.error)
|
|
82
|
+
? {
|
|
83
|
+
message: {
|
|
84
|
+
header: 'Message',
|
|
85
|
+
get: (row) => row.error?.message ?? '',
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
: {}),
|
|
89
|
+
}, { title: commandToTitleMapping[command] });
|
|
90
|
+
};
|
|
91
|
+
exports.output = output;
|
|
92
|
+
const commandToTitleMapping = {
|
|
93
|
+
set: 'Set Config',
|
|
94
|
+
unset: 'Unset Config',
|
|
95
|
+
list: 'List Config',
|
|
96
|
+
get: 'Get Config',
|
|
97
|
+
};
|
|
85
98
|
//# 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;;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.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AC,QAAQ,IAAI,EAAE;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;AAzCW,QAAA,MAAM,UAyCjB;AAEF,MAAM,qBAAqB,GAAG;IAC5B,GAAG,EAAE,YAAY;IACjB,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,aAAa;IACnB,GAAG,EAAE,YAAY;CACT,CAAC"}
|
|
@@ -41,15 +41,14 @@ function loadConfigMeta(plugin) {
|
|
|
41
41
|
}
|
|
42
42
|
const hook = ({ config }) => {
|
|
43
43
|
const flattenedConfigMetas = (config.plugins || [])
|
|
44
|
-
.
|
|
44
|
+
.flatMap((plugin) => {
|
|
45
45
|
const configMeta = loadConfigMeta(plugin);
|
|
46
46
|
if (!configMeta) {
|
|
47
47
|
log.info(`No config meta found for ${plugin.name}`);
|
|
48
48
|
}
|
|
49
49
|
return configMeta;
|
|
50
50
|
})
|
|
51
|
-
.filter(ts_types_1.isObject)
|
|
52
|
-
.flat();
|
|
51
|
+
.filter(ts_types_1.isObject);
|
|
53
52
|
if (flattenedConfigMetas.length) {
|
|
54
53
|
core_2.Config.addAllowedProperties(flattenedConfigMetas);
|
|
55
54
|
}
|
|
@@ -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,GAAi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