Skip to content

Commit

Permalink
PIM-658 Added grunt file to help transforming package.json for master…
Browse files Browse the repository at this point in the history
… branch
  • Loading branch information
lanekatris committed May 26, 2016
1 parent 6affb01 commit 9715379
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
46 changes: 46 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module.exports = function(grunt) {

function convertToMasterBranch ( pkgJsonObj ) {
for (var dependency in pkgJsonObj.dependencies) {
var url = pkgJsonObj.dependencies[dependency];

url = url.replace('#develop', '#master');
pkgJsonObj.dependencies[dependency] = url;
}
grunt.log.success('Set all private URLs to master branch...');
}

function updateVersion ( pkgJsonObj ) {
var rawVersion = pkgJsonObj.version;
var versionParts = rawVersion.split('.');

if ( versionParts.length !== 3 )
return grunt.log.error('Don\'t know how to parse version, only expect 3 digits: ' + rawVersion);

var revision = parseInt(versionParts[2]);
revision = revision + 1;
versionParts[2] = revision;

pkgJsonObj.version = versionParts.join('.');

grunt.log.success('Set version to ' + pkgJsonObj.version + '...');
}

// This task loads our package json, increments our version, and changes our private repos develop->master
grunt.registerTask('translate-prod', '', function () {

var filePath = './package.json';
var pkgJsonObj = grunt.file.readJSON(filePath);

convertToMasterBranch(pkgJsonObj);

updateVersion(pkgJsonObj);

grunt.file.write(filePath, JSON.stringify(pkgJsonObj, null, 2));
});

// This is where we would do "default" grunt actions.
// This would get called by calling: grunt, or: grunt default
grunt.registerTask('default', []);

};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"xml": "0.0.7",
"xml2js": "~0.1.14"
},
"devDependencies": {},
"devDependencies": {
"grunt": "^1.0.1"
},
"optionalDependencies": {},
"engines": {
"node": ">= 0.6"
Expand Down

0 comments on commit 9715379

Please sign in to comment.