From bf17d7e1153180fe68cc568a6f4ffa8db66010dc Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 2 Mar 2018 13:55:56 -0800 Subject: Add version bumping script One step towards automating our deploy process is automating our version bumping scheme. This PR does that. --- development/run-version-bump.js | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 development/run-version-bump.js (limited to 'development/run-version-bump.js') diff --git a/development/run-version-bump.js b/development/run-version-bump.js new file mode 100644 index 000000000..3b26b00db --- /dev/null +++ b/development/run-version-bump.js @@ -0,0 +1,51 @@ +const { promisify } = require('util') +const fs = require('fs') +const readFile = promisify(fs.readFile) +const writeFile = promisify(fs.writeFile) +const path = require('path') +const changelogPath = path.join(__dirname, '..', 'CHANGELOG.md') +const manifestPath = path.join(__dirname, '..', 'app', 'manifest.json') +const manifest = require('../app/manifest.json') +const versionBump = require('./version-bump') + +console.dir(process.argv) +const bumpType = normalizeType(process.argv[2]) + + +readFile(changelogPath) +.then(async (changeBuffer) => { + const changelog = changeBuffer.toString() + + const newData = await versionBump(bumpType, changelog, manifest) + console.dir(newData) + + const manifestString = JSON.stringify(newData.manifest, null, 2) + + console.log('now writing files to ', changelogPath, manifestPath) + console.log(typeof newData.manifest) + await writeFile(changelogPath, newData.changelog) + await writeFile(manifestPath, manifestString) + + return newData.version +}) +.then((version) => console.log(`Bumped ${bumpType} to version ${version}`)) +.catch(console.error) + + +function normalizeType (userInput) { + console.log(`user inputted ${userInput}`) + const err = new Error('First option must be a type (major, minor, or patch)') + if (!userInput || typeof userInput !== 'string') { + console.log('first no') + throw err + } + + const lower = userInput.toLowerCase() + + if (lower !== 'major' && lower !== 'minor' && lower !== 'patch') { + console.log('second no') + throw err + } + + return lower +} -- cgit v1.2.3 From 3a9b3794ebccbe3369a67e797186141dc011dd9d Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 2 Mar 2018 13:59:08 -0800 Subject: Remove logs --- development/run-version-bump.js | 7 ------- 1 file changed, 7 deletions(-) (limited to 'development/run-version-bump.js') diff --git a/development/run-version-bump.js b/development/run-version-bump.js index 3b26b00db..e06c00db3 100644 --- a/development/run-version-bump.js +++ b/development/run-version-bump.js @@ -8,7 +8,6 @@ const manifestPath = path.join(__dirname, '..', 'app', 'manifest.json') const manifest = require('../app/manifest.json') const versionBump = require('./version-bump') -console.dir(process.argv) const bumpType = normalizeType(process.argv[2]) @@ -17,12 +16,9 @@ readFile(changelogPath) const changelog = changeBuffer.toString() const newData = await versionBump(bumpType, changelog, manifest) - console.dir(newData) const manifestString = JSON.stringify(newData.manifest, null, 2) - console.log('now writing files to ', changelogPath, manifestPath) - console.log(typeof newData.manifest) await writeFile(changelogPath, newData.changelog) await writeFile(manifestPath, manifestString) @@ -33,17 +29,14 @@ readFile(changelogPath) function normalizeType (userInput) { - console.log(`user inputted ${userInput}`) const err = new Error('First option must be a type (major, minor, or patch)') if (!userInput || typeof userInput !== 'string') { - console.log('first no') throw err } const lower = userInput.toLowerCase() if (lower !== 'major' && lower !== 'minor' && lower !== 'patch') { - console.log('second no') throw err } -- cgit v1.2.3 From bdbe29906976915196f347861e913f3f5b523d0e Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 2 Mar 2018 14:33:29 -0800 Subject: Clean up run version bump script --- development/run-version-bump.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'development/run-version-bump.js') diff --git a/development/run-version-bump.js b/development/run-version-bump.js index e06c00db3..fde14566e 100644 --- a/development/run-version-bump.js +++ b/development/run-version-bump.js @@ -7,12 +7,13 @@ const changelogPath = path.join(__dirname, '..', 'CHANGELOG.md') const manifestPath = path.join(__dirname, '..', 'app', 'manifest.json') const manifest = require('../app/manifest.json') const versionBump = require('./version-bump') - const bumpType = normalizeType(process.argv[2]) +start().catch(console.error) + +async function start() { -readFile(changelogPath) -.then(async (changeBuffer) => { + const changeBuffer = await readFile(changelogPath) const changelog = changeBuffer.toString() const newData = await versionBump(bumpType, changelog, manifest) @@ -22,10 +23,8 @@ readFile(changelogPath) await writeFile(changelogPath, newData.changelog) await writeFile(manifestPath, manifestString) - return newData.version -}) -.then((version) => console.log(`Bumped ${bumpType} to version ${version}`)) -.catch(console.error) + console.log(`Bumped ${bumpType} to version ${newData.version}`) +} function normalizeType (userInput) { -- cgit v1.2.3