1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 11:01:41 +01:00
metamask-extension/development/version-bump.js
2018-03-02 14:01:53 -08:00

53 lines
1.1 KiB
JavaScript

const clone = require('clone')
async function versionBump(bumpType, changelog, oldManifest) {
const manifest = clone(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 Master')) {
logLines.splice(i + 1, 0, logHeader)
break
}
}
return {
version: newVersion,
manifest: manifest,
changelog: logLines.join('\n')
}
}
function newVersionFrom (manifest, bumpType) {
const string = manifest.version
let 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
}
return segments.map(String).join('.')
}
function bumpManifest (manifest, bumpType) {
}
module.exports = versionBump