@pega/custom-dx-components
Version:
Utility for building custom UI components
89 lines (65 loc) • 2.15 kB
JavaScript
import chalk from 'chalk';
import {
showVersion,
getLibraryBased,
getLibraryBasedCL,
checkLibraryAndArchives,
getConfigDefaults,
addDebugLog,
cleanUpTemp,
getUseInputConfig,
getInputConfigForCommand,
convertYNToBoolean
} from '../../util.js';
import { deleteLibraryVersion } from '../delete-lib/index.js';
export default async (options) => {
const isLibraryBased = getLibraryBased();
const isLibraryBasedCL = getLibraryBasedCL();
const useInputConfig = getUseInputConfig();
if (!isLibraryBased) {
console.log(`Command only supported for ${chalk.bold.green('library mode')} components.`)
process.exit();
}
await showVersion();
await checkLibraryAndArchives();
await cleanUpTemp();
addDebugLog("deleteVersion", "", "+");
let version = "";
let okToDelete;
const configDef = getConfigDefaults();
let libraryName = configDef.currentOrgLib;
if (useInputConfig) {
const inputConfig = await getInputConfigForCommand("deleteLibVersion");
if (!inputConfig || Object.keys(inputConfig).length === 0) {
console.log(chalk.redBright("Configured for input config, but no input.config.json file found."));
process.exit(1);
}
version = inputConfig.libraryVersion;
const isPermanent = inputConfig?.isPermanent || "N";
let permBuild = convertYNToBoolean(isPermanent);
if (isLibraryBasedCL) {
// no -dev for PegaInfinity
permBuild = true;
}
if (!permBuild && version != "ALL") {
version = version.concat("-dev");
}
okToDelete = convertYNToBoolean(inputConfig.confirmDelete);
}
else {
if (options.params.length >= 5) {
libraryName = options.params[3]
version = options.params[4];
if (options.params.length >=6 ) {
const okToDel = options.params[5];
okToDelete = !!(okToDel === 'Y' || okToDel === 'y' || okToDel === true || okToDel === 'true');
}
}
else if (options.params.length >= 4) {
libraryName = options.params[3];
}
}
await deleteLibraryVersion(libraryName, version, okToDelete);
addDebugLog("deleteVersion", "END", "-");
return true;
};