UNPKG

@digipolis/start-ui

Version:
24 lines (20 loc) 674 B
import axios from 'axios'; import fs from 'fs'; import merge from 'deepmerge'; export const getlatestverion = async (packageName) => { let key = packageName; if (Array.isArray(packageName)) { key = packageName[packageName.length - 1]; } const response = await axios.get(`https://registry.npmjs.com/${key}`); return response.data['dist-tags'].latest; }; export const updatePackageJson = (newValues, pkgLocation) => { const pkgJson = JSON.parse(fs.readFileSync(pkgLocation)); const newPkgJson = merge(pkgJson, newValues); fs.writeFileSync(pkgLocation, JSON.stringify(newPkgJson, null, 2)); }; export default { getlatestverion, updatePackageJson, };