@apistudio/apim-cli
Version:
CLI for API Management Products
51 lines (50 loc) • 2.01 kB
JavaScript
/**
* Copyright Super iPaaS Integration LLC, an IBM Company 2024
*/
import { showInfo } from '../../helpers/common/message-helper.js';
import { getAllProjectNames } from '../../helpers/apim/root-dir-helper.js';
import { executeBuildProject } from '../../builders/project/projects-builder.js';
import { executeBuildProjectAssets } from '../../builders/project/project-assets-builder.js';
import { BUILD_STARTED, BUILDING_LIST_ALL_PROJECTS, CHECKING_ALL_PROJECTS, IDENTIFIED_PROJECTS, LINE, } from '../../constants/message-constants.js';
import { DebugManager } from '../../debug/debug-manager.js';
import { COMMA } from '../../constants/app-constants.js';
export const buildProjects = async (all, localDir, projects) => {
showInfo(LINE);
showInfo(BUILD_STARTED);
showInfo(LINE);
if (all) {
if (DebugManager.getInstance().isDebugEnabled()) {
showInfo(BUILDING_LIST_ALL_PROJECTS + localDir);
showInfo(CHECKING_ALL_PROJECTS + localDir);
}
projects = getAllProjectNames(localDir);
if (DebugManager.getInstance().isDebugEnabled()) {
showInfo(IDENTIFIED_PROJECTS + projects);
}
}
return executeBuildProject(localDir, projects);
};
export const buildAssets = (assets, localDir, projects) => {
showInfo(LINE);
showInfo(BUILD_STARTED);
showInfo(LINE);
return executeBuildProjectAssets(projects, localDir, assets);
};
export const getOutputPath = async (projects, all, names, fileType) => {
let outputPath = `studio-projects-${fileType}.zip`;
if (all) {
outputPath = `studio-all-${fileType}.zip`;
}
else {
const projectsArray = projects ? projects.split(COMMA) : [];
if (projectsArray.length === 1) {
if (names) {
outputPath = `studio-${projectsArray[0]}-api-${fileType}.zip`;
}
else {
outputPath = `studio-${projectsArray[0]}-${fileType}.zip`;
}
}
}
return outputPath;
};