const fs = require('fs-extra')
const path = require('path')

var json = fs.readJsonSync('./package.json')
var version = json.version.split('.')
var upgrade = process.argv[2] ? parseInt(process.argv[2]) : 0
var index = 2 - upgrade
index = index < 0 ? 0 : index
index = index > 2 ? 2 : index

version = version.map(ver => parseInt(ver)).map((ver, i) => {
	if (i === index) {
		return ver + 1
	} else if (i > index) {
		return 0
	} else {
		return ver
	}
})
json.version = version.join('.')

fs.writeJsonSync('./package.json', json, {
	spaces: '\t'
})
