UNPKG

@pega/custom-dx-components

Version:

Utility for building custom UI components

79 lines (62 loc) 2.14 kB
import chalk from 'chalk'; import { promisify } from 'util'; import { exec as LocalExec } from "child_process"; import { getComponents, getPegaServerConfig, updateConfigVersion, getLibraryArchivesVersions, addDebugLog, getConfigDefaults } from '../../util.js'; const exec = promisify(LocalExec); export const updateAllComponentsConfig = async( newVersion ) => { addDebugLog("updateAllComponentsConfig", `newVersion: ${newVersion}`, ""); const componentList = await getComponents(); const orgLib = getConfigDefaults(); const currentOrgLib = `${orgLib.organization}_${orgLib.library}`; for (const index in componentList) { const componentKey = componentList[index]; await updateConfigVersion(componentKey, newVersion, currentOrgLib); } }; export const getSwitchLibraryComponentQuestions = async (archVersionList, inputOrgLib) => { addDebugLog("getSwitchLibraryComponentQuestions", "", ""); const defaultPegaConfig = await getPegaServerConfig(); const componentDefaults = getConfigDefaults(); const orgLib = getConfigDefaults(); console.log(chalk.bold.yellow('\nBe sure to SAVE all changes before switching versions, unsaved changes will be LOST.')) return [ { name: 'okToContinue', type: 'confirm', message: 'Ok to continue ?', default: true }, { name: 'newOrgLib', type: 'rawlist', message: `Select a library (current library is ${chalk.bold.green(`${orgLib.currentOrgLib}`)}) `, choices: archVersionList, when(answers) { return answers.okToContinue === true && inputOrgLib === ""; } } ]; }; export const getSwitchVersionComponentQuestions = async (newOrgLib) => { addDebugLog("getSwitchVersionComponentQuestions", "", ""); const archVersionList = await getLibraryArchivesVersions(newOrgLib, "0.0.0"); return [ { name: 'version', type: 'rawlist', message: `Select a version `, choices: archVersionList } ]; }; export const runNpmUpdate = async () => { const script = `npm update`; const { stdout, stderr } = await exec(script); }