@salesforce/core
Version:
Core libraries to interact with SFDX projects, orgs, and APIs.
52 lines • 2.29 kB
JavaScript
;
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrgConfigProperties = void 0;
const ts_types_1 = require("@salesforce/ts-types");
const aliases_1 = require("../config/aliases");
const configAggregator_1 = require("../config/configAggregator");
const globalInfoConfig_1 = require("../config/globalInfoConfig");
var OrgConfigProperties;
(function (OrgConfigProperties) {
OrgConfigProperties["TARGET_ORG"] = "target-org";
OrgConfigProperties["TARGET_DEV_HUB"] = "target-dev-hub";
})(OrgConfigProperties = exports.OrgConfigProperties || (exports.OrgConfigProperties = {}));
function exist(aliasOrUsername) {
try {
const username = aliases_1.Aliases.get(aliasOrUsername) || aliasOrUsername;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const globalInfo = globalInfoConfig_1.GlobalInfo.instance || new globalInfoConfig_1.GlobalInfo();
globalInfo.readSync();
return globalInfo.hasOrg(username);
}
catch (error) {
return false;
}
}
configAggregator_1.ConfigAggregator.getInstance().addAllowedProperties([
{
key: OrgConfigProperties.TARGET_ORG,
description: 'The target to be used for any command communicating with an org.',
input: {
// If a value is provided validate it otherwise no value is unset.
validator: (value) => value == null || (ts_types_1.isString(value) && exist(value)),
failedMessage: (value) => `org "${value}" is not authenticated`,
},
},
{
key: OrgConfigProperties.TARGET_DEV_HUB,
description: 'The target to be used for any command communicating with a dev hub org.',
input: {
// If a value is provided validate it otherwise no value is unset.
validator: (value) => value == null || (ts_types_1.isString(value) && exist(value)),
failedMessage: (value) => `org "${value}" is not authenticated`,
},
},
]);
//# sourceMappingURL=orgConfigProperties.js.map