serverless-domain-manager
Version:
Serverless plugin for managing custom domains with API Gateways.
72 lines (71 loc) • 2.25 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const globals_1 = __importDefault(require("./globals"));
class Logging {
static cliLog(prefix, message) {
globals_1.default.serverless.cli.log(`${prefix} ${message}`, globals_1.default.pluginName);
}
/**
* Logs error message
*/
static logError(message) {
if (globals_1.default.v3Utils) {
globals_1.default.v3Utils.log.error(message);
}
else {
Logging.cliLog("[Error]", message);
}
}
/**
* Logs info message
*/
static logInfo(message) {
if (globals_1.default.v3Utils) {
globals_1.default.v3Utils.log.verbose(message);
}
else {
Logging.cliLog("[Info]", message);
}
}
/**
* Logs warning message
*/
static logWarning(message) {
if (globals_1.default.v3Utils) {
globals_1.default.v3Utils.log.warning(message);
}
else {
Logging.cliLog("[WARNING]", message);
}
}
/**
* Prints out a summary of all domain manager related info
*/
static printDomainSummary(domains) {
const summaryList = [];
domains.forEach((domain) => {
if (domain.domainInfo) {
summaryList.push(`Domain Name: ${domain.givenDomainName}`);
summaryList.push(`Target Domain: ${domain.domainInfo.domainName}`);
summaryList.push(`Hosted Zone Id: ${domain.domainInfo.hostedZoneId}`);
}
});
// don't print summary if summaryList is empty
if (!summaryList.length) {
return;
}
if (globals_1.default.v3Utils) {
globals_1.default.serverless.addServiceOutputSection(globals_1.default.pluginName, summaryList);
}
else {
Logging.cliLog("[Summary]", "Distribution Domain Name");
summaryList.forEach((item) => {
Logging.cliLog("", `${item}`);
});
}
}
}
exports.default = Logging;
;