@apistudio/apim-cli
Version:
CLI for API Management Products
31 lines (30 loc) • 1.29 kB
JavaScript
import { createBuildZip } from '../../helpers/common/fs-helper.js';
import { getOutputPath } from './../helpers/build-action-helper.js';
import { showWarning } from '../../helpers/common/message-helper.js';
import { CREATED_DEPLOY_ZIP, IGNORE_PROJECT_ARG, IGNORE_NAMES_OPT, FILE_OVERWRITTEN } from '../../constants/message-constants.js';
import { buildAssets, buildProjects } from '../helpers/build-action-helper.js';
import { BUILD } from '../../constants/app-constants.js';
export const writeArchive = async (projects, all, names, zipBuffer) => {
const zipFileName = await getOutputPath(projects, all, names, BUILD);
const isZipCreated = await createBuildZip(zipBuffer, zipFileName);
if (isZipCreated) {
showWarning(FILE_OVERWRITTEN);
showWarning(CREATED_DEPLOY_ZIP + zipFileName);
}
};
export const buildAssetsOrProjects = async (projects, all, names, localDir) => {
let zipBuffer;
if (names && !all) {
zipBuffer = await buildAssets(names, localDir, projects);
}
else {
if (projects && all) {
showWarning(IGNORE_PROJECT_ARG);
}
if (names && all) {
showWarning(IGNORE_NAMES_OPT);
}
zipBuffer = await buildProjects(all, localDir, projects);
}
return zipBuffer;
};