import { execSync } from 'child_process' import colors from 'colors' import { execConfig, installAllPackages, listRequiredPackages, requiredPackages, } from '../helpers' import { currentVersion } from './currentVersion' import { isVersionLatest } from './isVersionLatest' import { showLatestVersion } from './showLatestVersion' export const getLatestVersion = async () => { const latestVersion = await showLatestVersion() const versionIsLatest = await isVersionLatest() if (versionIsLatest === false) { console.info(colors.green(`\nUpdating versions, from ${currentVersion()} to ${latestVersion}`)) try { execSync( 'npx --yes clear-npx-cache', execConfig, ) listRequiredPackages() await installAllPackages(requiredPackages) console.info(`${colors.green('\n wappi and all dependencies have been updated')}`) } catch (error) { // console.info('error', error) console.info(`${colors.red('\n wappi failed has been updated')}`) } } }