UNPKG

@pega/custom-dx-components

Version:

Utility for building custom UI components

83 lines (69 loc) 2.29 kB
import chalk from 'chalk'; import { getComponents, validateSemver, updateConfigVersion, addDebugLog, getLibraryArchivesVersions, getConfigDefaults } from '../../util.js'; export const updateAllComponentsConfig = async( newVersion ) => { addDebugLog("updateAllComponentsConfig", `newVersion: ${newVersion}`, ""); const componentList = await getComponents(); const orgLib = getConfigDefaults(); // const currentOrgLib = `${orgLib.organization}_${orgLib.library}`; const currentOrgLib = orgLib.currentOrgLib; for (const index in componentList) { const componentKey = componentList[index]; await updateConfigVersion(componentKey, newVersion, currentOrgLib); } }; export const getNextVersion = async () => { addDebugLog("getNextVersion", "", ""); const orgLib = getConfigDefaults(); const currentOrgLib = orgLib.currentOrgLib; const archiveVersionList = await getLibraryArchivesVersions(currentOrgLib); if (archiveVersionList && archiveVersionList.length > 0) { let lastVersion = archiveVersionList[archiveVersionList.length - 1]; lastVersion = lastVersion.replaceAll("-dev", ""); const arVer = lastVersion.split("."); arVer[2] = (parseInt(arVer[2]) + 1).toString(); const incrVersion = arVer.join("."); return incrVersion; } else { return "0.0.1"; } } export const getCreateVersionComponentQuestions = async () => { addDebugLog("getCreateVersionComponentQuestions", "", ""); const componentDefaults = getConfigDefaults(); // increment the version const incrVersion = await getNextVersion(); console.log(`\nCurrent library: ${chalk.green(`${componentDefaults.currentOrgLib}`)}`); return [ { name: 'version', message: 'Enter version ', default: incrVersion, validate: value => { if (validateSemver(value)) { return true; } return 'Please provide semver compatible version e.g 0.0.1'; } }, { name: 'permBuild', type: 'confirm', message: `Version ${chalk.bold.yellow('PERMANENT')} upon publish ?`, default: !componentDefaults.devBuild }, { name: 'copyExisting', type: 'confirm', message: 'Copy current components to new version ?', default: true }, ]; };