Skip to content

Commit

Permalink
Merge pull request ember-cli-deploy#2 in UX/ember-cli-deploy-audit-lo…
Browse files Browse the repository at this point in the history
…g from feature/cs-18036-active-revision to master

* commit '84c78fdc9e0b9fb601f178489c7138fec63a077c':
  CS-18036 - Addressing CR feedback
  Linting fixes
  CS-18036 - Add Author Date and Commiter Date to the returns commit json
  CS-18036 - Create an active-revision.json file on didActivate so we can easily display the active version from swift-ui list
  CS-18036 - Bugfix: check for when no intital revisions are availble
  • Loading branch information
onlymejosh committed Mar 3, 2016
2 parents dd4c13f + 84c78fd commit 0ebef2a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
29 changes: 21 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var gitlog = require('./lib/gitlog');
var S3 = require('./lib/s3');
var LibraryVersion = require('./lib/library-versions');
var _ = require('lodash');
var SWIFT_URL = 'swift.cs.sys/'
module.exports = {
name: 'ember-cli-deploy-audit-log',

Expand All @@ -24,14 +25,14 @@ module.exports = {
return {
audit: {
didUpload: false,
isActive: false,
timestamp: '',
deployer: {
name: user.name,
email: user.email
},
commitsSinceLastDeploy: [],
emberInfo: {
appName: library.readPackageJSON().name,
appVersion: library.readPackageJSON().version,
libraryVersions: library.getLibraryVersions()
}
Expand All @@ -40,9 +41,12 @@ module.exports = {
},

willUpload: function(context) {
var activeRevision = context.initialRevisions.find(function(revision) {
return revision.active === true;
});
var activeRevision;
if (context.initialRevisions) {
activeRevision = context.initialRevisions.find(function(revision) {
return revision.active === true;
});
}
var currentRevision = context.revisionData;
this.log('Checking for previous revisions...');
if (activeRevision) {
Expand All @@ -59,14 +63,15 @@ module.exports = {
revision: currentRevision.revisionKey,
commitsSinceLastDeploy: commits
}
}
};
});
}
},

upload: function(context) {
var plugin = this;
var s3 = new S3({
plugin: this
plugin: plugin
});
var timestamp = (new Date).getTime();
var uploadOptions = {
Expand All @@ -75,6 +80,8 @@ module.exports = {
};
return s3.upload(uploadOptions)
.then(function() {
var link = 'http://' + context.revisionData.revisionKey + '.' + context.audit.emberInfo.appName + '.' + SWIFT_URL;
plugin.log('Do It Live: ' + link);
return {
auditFileName: uploadOptions.fileName,
audit: {
Expand All @@ -101,8 +108,14 @@ module.exports = {
},

didActivate: function(context) {
this.log('didActivate');
this.log(context);
var s3 = new S3({
plugin: this
});
var uploadOptions = {
fileName: 'active-revision.json',
data: JSON.stringify(context.audit, null, 2)
};
return s3.upload(uploadOptions);
}
});

Expand Down
2 changes: 1 addition & 1 deletion lib/gitlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function gitlog(options) {
}

var defaultOptions = {
fields: ['abbrevHash', 'hash', 'subject', 'authorName', 'authorEmail']
fields: ['abbrevHash', 'hash', 'subject', 'authorName', 'authorEmail', 'authorDate', 'committerDate']
};

options = lodash.extend(defaultOptions, options);
Expand Down

0 comments on commit 0ebef2a

Please sign in to comment.