Created
November 27, 2019 16:50
-
-
Save fuad-ardiono/0825b73eb73930021948736ae6173d37 to your computer and use it in GitHub Desktop.
Build versioning vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"coreVersion": "1", | |
"enhancementNumber": 1, | |
"date": "2019-11-27T16:33:20.906Z", | |
"version": "1.1.191128" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable */ | |
const fs = require('fs'); | |
const chalk = require('chalk'); | |
const moment = require('moment'); | |
const log = console.log; | |
const jsonBeautify = require('json-beautify'); | |
const appVersion = require('./version.json'); | |
/* | |
Requirement | |
- Make sure all package on at line 2 - 7 is installed | |
Behavior | |
- Not change core version | |
- Count enhancement number and reset day by day to zero | |
*/ | |
const today = moment(); | |
const versionDate = moment(appVersion.date); | |
const formattedVersionDate = moment(appVersion.date).format('YYMMDD'); | |
if (today.get('day') === versionDate.get('day') && today.get('month') === versionDate.get('month') | |
&& today.get('year') === versionDate.get('year') | |
) { | |
appVersion.enhancementNumber += 1; | |
appVersion.version = `${appVersion.coreVersion}.${appVersion.enhancementNumber}.` | |
+ `${formattedVersionDate}`; | |
} else { | |
appVersion.enhancementNumber = 0; | |
appVersion.date = today; | |
} | |
const json = jsonBeautify(appVersion, null, 2, 100); | |
fs.writeFile('./version.json', json, 'utf8', (err) => { | |
if(err !== null){ | |
log(chalk.red(err)); | |
} else { | |
log(chalk.green('Build versioning success')); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment