UNPKG

1.32 kBJavaScriptView Raw
1'use strict';
2
3const DeployPluginBase = require('ember-cli-deploy-plugin');
4const ScmTable = require('./lib/scm-table');
5const LegacyTable = require('./lib/legacy-table');
6
7module.exports = {
8 name: 'ember-cli-deploy-display-revisions',
9
10 createDeployPlugin(options) {
11 let DeployPlugin = DeployPluginBase.extend({
12 name: options.name,
13
14 defaultConfig: {
15 amount(context) {
16 return context.commandOptions.amount || 10;
17 },
18
19 revisions(context) {
20 return context.revisions;
21 }
22 },
23
24 displayRevisions(/* context */) {
25 let table;
26 let revisions = this.readConfig('revisions');
27 if(!revisions || revisions.length === 0) {
28 this.log("Could not display latest revisions because no revisions were found in context.", {color: 'yellow'});
29 return;
30 }
31
32 revisions = revisions.slice(0, this.readConfig("amount"));
33
34 let hasRevisionData = revisions.reduce(function(prev, current) {
35 return !prev ? false : !!current.revisionData;
36 }, true);
37
38 if (hasRevisionData) {
39 table = new ScmTable(this, revisions);
40 } else {
41 table = new LegacyTable(this, revisions);
42 }
43
44 table.display();
45 }
46 });
47
48 return new DeployPlugin();
49 }
50};