This repository has been archived by the owner on Oct 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
index.js
64 lines (51 loc) · 1.44 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict';
module.exports = function(kbox) {
// Node modules
var path = require('path');
// Grab client module
var Client = require('./lib/client.js');
var pantheon = new Client(kbox);
// Load our events and create modules
require('./lib/create.js')(kbox, pantheon);
require('./lib/events.js')(kbox, pantheon);
// Declare our app to the world
kbox.create.add('pantheon', {
task: {
name: 'Pantheon',
description: 'Creates a Pantheon app.',
pkg: {
dir: path.join(__dirname, 'app')
}
}
});
// Task to create kalabox apps
kbox.tasks.add(function(task) {
kbox.create.buildTask(task, 'pantheon');
});
// Create integration.
kbox.integrations.create('pantheon', function(api) {
// Authorize login.
api.methods.auth = function(token) {
return pantheon.__auth(token)
.wrap('Error authorizing with Machine Token');
};
// Set the logins method of api.
api.methods.logins = function() {
return kbox.Promise.try(function() {
return pantheon.getTokensByEmail();
})
.wrap('Error getting logins.');
};
// Set the sites method of the api.
api.methods.sites = function(token) {
return pantheon.getSites(token)
.map(function(site) {
site.getEnvironments = function() {
return pantheon.getEnvs(token, site.name);
};
return site;
})
.wrap('Error getting sites.');
};
});
};