-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Created new tasks for updating semvar tags * Created separate setup file * Standardised version in all packages
- Loading branch information
Showing
4 changed files
with
144 additions
and
60 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
var fs = require( 'fs' ); | ||
var download = require( 'gulp-download' ); | ||
var rename = require( "gulp-rename" ); | ||
var gulp = require( 'gulp' ); | ||
|
||
/** | ||
* Goes through each of the main config files and increments | ||
* the version | ||
* @param {( currentVersion: string ) => string} f A function to transform the version into a new version | ||
* @returns {string} | ||
*/ | ||
module.exports.bumpVersion = function( f, files ) { | ||
let fileStr = ''; | ||
let version = ''; | ||
|
||
if ( !fs.existsSync( './package.json' ) ) | ||
throw new Error( `You dont seem to have a package json file. This is needed to identify the version.` ); | ||
|
||
version = JSON.parse( fs.readFileSync( './package.json' ) ).version; | ||
const bumpedVersion = f( version ); | ||
|
||
return Promise.all( files.map( function( file ) { | ||
return new Promise( function( resolve, reject ) { | ||
if ( !fs.existsSync( file ) ) | ||
throw new Error( `File ${file} does not exist` ); | ||
|
||
fileStr = fs.readFileSync( file ).toString(); | ||
const matchedVersion = fileStr.match( new RegExp( version, 'i' ) ); | ||
if ( !matchedVersion || matchedVersion.length === 0 ) | ||
throw new Error( `File ${file} does not have a consistent version number of '${version}'` ); | ||
|
||
fileStr = fileStr.replace( version, bumpedVersion ); | ||
fs.writeFileSync( file, fileStr ); | ||
}); | ||
}) ); | ||
} | ||
|
||
/** | ||
* Increments a semvar version patch number | ||
* @param {string} version The version coming in. E.g. 1.0.1 | ||
* @returns {string} | ||
*/ | ||
module.exports.bumpPatchNum = function( version ) { | ||
const segments = version.split( '.' ); | ||
const patch = parseInt( segments[ 2 ] ) + 1; | ||
return `${segments[ 0 ]}.${segments[ 1 ]}.${patch}` | ||
}; | ||
|
||
/** | ||
* Increments a semvar version mid number | ||
* @param {string} version The version coming in. E.g. 1.0.1 | ||
* @returns {string} | ||
*/ | ||
module.exports.bumpMidNum = function( version ) { | ||
const segments = version.split( '.' ); | ||
const minor = parseInt( segments[ 1 ] ) + 1; | ||
return `${segments[ 0 ]}.${minor}.0` | ||
}; | ||
|
||
/** | ||
* Increments a semvar version major number | ||
* @param {string} version The version coming in. E.g. 1.0.1 | ||
* @returns {string} | ||
*/ | ||
module.exports.bumpMajorNum = function( version ) { | ||
const segments = version.split( '.' ); | ||
const major = parseInt( segments[ 0 ] ) + 1; | ||
return `${major}.0.0` | ||
}; | ||
|
||
/** | ||
* This function downloads a definition file from github and writes it to a destination | ||
* @param {string} url The url of the file to download | ||
* @param {string} dest The destination folder to move the file to | ||
* @param {string} name The name of the downloaded file | ||
*/ | ||
module.exports.getDefinition = function( url, dest, name ) { | ||
return new Promise( function( resolve, reject ) { | ||
download( url ) | ||
.pipe( rename( name ) ) | ||
.pipe( gulp.dest( dest ) ) | ||
.on( 'error', function( err ) { | ||
throw ( err ) | ||
}) | ||
.on( 'end', function() { | ||
resolve( true ); | ||
}) | ||
}); | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
{ | ||
"name": "modepress", | ||
"version": "0.3.1", | ||
"description": "A simple Mongo-Node CMS server. The server can be accessed via an admin panel and content can be requested via its RESTful API", | ||
"main": "main.js", | ||
"author": "Mathew Henson", | ||
"dependencies": { | ||
"winston": "^2.2.0", | ||
"entities": "^1.1.1", | ||
"express": "^4.13.4", | ||
"mongodb": "^2.1.12", | ||
"morgan": "^1.5.1", | ||
"body-parser": "^1.12.0", | ||
"method-override": "^2.3.1", | ||
"node-inspector": "^0.12.7", | ||
"request": "^2.69.0", | ||
"jade": "^1.10.0", | ||
"yargs": "^3.12.0", | ||
"compression": "^1.5.1", | ||
"modepress-api": "./modepress-api", | ||
"ws": "^1.0.1", | ||
"sanitize-html": "^1.11.4", | ||
"jsdom": "^8.2.0" | ||
} | ||
"name": "modepress", | ||
"version": "0.4.3", | ||
"description": "A simple Mongo-Node CMS server. The server can be accessed via an admin panel and content can be requested via its RESTful API", | ||
"main": "main.js", | ||
"author": "Mathew Henson", | ||
"dependencies": { | ||
"winston": "^2.2.0", | ||
"entities": "^1.1.1", | ||
"express": "^4.13.4", | ||
"mongodb": "^2.1.12", | ||
"morgan": "^1.5.1", | ||
"body-parser": "^1.12.0", | ||
"method-override": "^2.3.1", | ||
"node-inspector": "^0.12.7", | ||
"request": "^2.69.0", | ||
"jade": "^1.10.0", | ||
"yargs": "^3.12.0", | ||
"compression": "^1.5.1", | ||
"modepress-api": "./modepress-api", | ||
"ws": "^1.0.1", | ||
"sanitize-html": "^1.11.4", | ||
"jsdom": "^8.2.0" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"name": "modepress-tests", | ||
"version": "0.1.0", | ||
"main": "tests.js", | ||
"author": "Mathew Henson", | ||
"dependencies": { | ||
"unit.js": "^2.0.0", | ||
"yargs": "^3.12.0" | ||
} | ||
} | ||
"name": "modepress-tests", | ||
"version": "0.4.3", | ||
"main": "tests.js", | ||
"author": "Mathew Henson", | ||
"dependencies": { | ||
"unit.js": "^2.0.0", | ||
"yargs": "^3.12.0" | ||
} | ||
} |