@golemio/cli
Version:
Collection of executables intended for use with Golemio services and modules
59 lines • 2.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const asyncapi_utils_1 = require("../utils/asyncapi.utils");
const asyncapi_utils_2 = require("../utils/asyncapi.utils");
const command = {
description: "Generate asyncapi document",
alias: "asp",
run: async ({ parameters, print }) => {
const [action] = parameters.array;
let { header: aspsHeaderFilePath, output: aspsMergedOutputFilePath, asps: aspsFilePath, input: fileInput, } = parameters.options;
const asyncapiConfig = {
aspsHeaderFilePath: aspsHeaderFilePath !== null && aspsHeaderFilePath !== void 0 ? aspsHeaderFilePath : null,
aspsFilesGlob: aspsFilePath !== null && aspsFilePath !== void 0 ? aspsFilePath : null,
aspsMergedOutputFilePath: aspsMergedOutputFilePath !== null && aspsMergedOutputFilePath !== void 0 ? aspsMergedOutputFilePath : null,
fileInputPath: fileInput !== null && fileInput !== void 0 ? fileInput : null,
};
switch (action) {
case "help":
case "h":
default:
(0, asyncapi_utils_2.printCommandHelp)();
return;
case "merge": {
if (!asyncapiConfig.aspsMergedOutputFilePath || !asyncapiConfig.aspsFilesGlob) {
print.error("Missing required parameters");
process.exitCode = 1;
return;
}
const { isError, message } = await (0, asyncapi_utils_1.generateAsyncApiConfig)(asyncapiConfig.aspsHeaderFilePath, asyncapiConfig.aspsFilesGlob, asyncapiConfig.aspsMergedOutputFilePath);
if (isError) {
print.error(message);
process.exitCode = 1;
}
else {
print.success(message);
}
break;
}
case "upload": {
if (!asyncapiConfig.aspsMergedOutputFilePath || !asyncapiConfig.fileInputPath) {
print.error("Missing required parameters");
process.exitCode = 1;
return;
}
const { isError, message } = await (0, asyncapi_utils_1.uploadFile)(asyncapiConfig.fileInputPath, asyncapiConfig.aspsMergedOutputFilePath);
if (isError) {
print.error(message);
process.exitCode = 1;
}
else {
print.success(message);
}
break;
}
}
},
};
exports.default = command;
//# sourceMappingURL=asyncapi.js.map