@salesforce/plugin-org
Version:
Commands to interact with Salesforce orgs
48 lines • 1.57 kB
JavaScript
/*
* Copyright 2026, Salesforce, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ansis from 'ansis';
const styledProperties = new Map([
[
'status',
new Map([
['Active', ansis.green],
['else', ansis.red],
]),
],
[
'connectedStatus',
new Map([
['Connected', ansis.green],
['Active', ansis.green],
['else', ansis.red],
]),
],
]);
export const getStyledValue = (key, value) => {
if (!value)
return value;
const prop = styledProperties.get(key);
if (!prop)
return value;
// I'm not sure how to type the inner Map so that it knows else is definitely there
const colorMethod = prop.get(value) ?? prop.get('else');
return colorMethod(value);
};
export const getStyledObject = (objectToStyle) => Object.fromEntries(Object.entries(objectToStyle).map(([key, value]) => [
key,
typeof value === 'string' ? getStyledValue(key, value) : value,
]));
//# sourceMappingURL=orgHighlighter.js.map