steadybit
Version:
Command-line interface to interact with the Steadybit API
42 lines • 2.16 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultBaseUrl = void 0;
exports.getConfiguration = getConfiguration;
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2022 Steadybit GmbH
const service_1 = require("./profile/service");
exports.defaultBaseUrl = 'https://platform.steadybit.com';
function getConfiguration() {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b, _c;
let apiAccessToken;
let baseUrl = exports.defaultBaseUrl;
const profile = yield (0, service_1.getActiveProfile)();
if (profile) {
apiAccessToken = profile.apiAccessToken;
baseUrl = (_a = profile.baseUrl) !== null && _a !== void 0 ? _a : baseUrl;
}
// Environment arguments take precedence over the global system configuration.
apiAccessToken = (_b = process.env.STEADYBIT_TOKEN) !== null && _b !== void 0 ? _b : apiAccessToken;
baseUrl = (_c = process.env.STEADYBIT_URL) !== null && _c !== void 0 ? _c : baseUrl;
// A typically error case is that the baseUrl carries a trailing slash. This is fine
// in our persisted config files, but we don't want our CLI to internally work with those.
if (baseUrl.endsWith('/')) {
baseUrl = baseUrl.substring(0, baseUrl.length - 1);
}
return {
apiAccessToken,
baseUrl,
};
});
}
//# sourceMappingURL=index.js.map