@apistudio/apim-cli
Version:
CLI for API Management Products
32 lines (29 loc) • 1.29 kB
text/typescript
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: string, all: boolean, names: string, zipBuffer: Buffer) => {
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: string, all: boolean, names: string, localDir: string) : Promise<Buffer> => {
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;
}