A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/development/version-bump.js

51 lines
1.2 KiB

const { cloneDeep } = require('lodash')
7 years ago
async function versionBump (bumpType, changelog, oldManifest) {
const manifest = cloneDeep(oldManifest)
const newVersion = newVersionFrom(manifest, bumpType)
manifest.version = newVersion
const date = (new Date()).toDateString()
const logHeader = `\n## ${newVersion} ${date}`
const logLines = changelog.split('\n')
for (let i = 0; i < logLines.length; i++) {
if (logLines[i].includes('Current Develop Branch')) {
logLines.splice(i + 1, 0, logHeader)
break
}
}
return {
version: newVersion,
manifest: manifest,
7 years ago
changelog: logLines.join('\n'),
}
}
function newVersionFrom (manifest, bumpType) {
const string = manifest.version
7 years ago
const segments = string.split('.').map((str) => parseInt(str))
switch (bumpType) {
case 'major':
segments[0] += 1
segments[1] = 0
segments[2] = 0
break
case 'minor':
segments[1] += 1
segments[2] = 0
break
case 'patch':
segments[2] += 1
break
default:
throw new Error(`invalid bumpType ${bumpType}`)
}
return segments.map(String).join('.')
}
module.exports = versionBump