MCPcopy
hub / github.com/CodeboxIDE/codebox / setup

Function setup

core/cb.deploy.heroku/main.js:9–73  ·  view source on GitHub ↗
(options, imports, register)

Source from the content-addressed store, hash-verified

7var api = require("./api");
8
9function setup(options, imports, register) {
10 var deploy = imports.deploy;
11 var shells = imports.shells;
12
13 deploy.add({
14 id: "heroku",
15 name: "Heroku",
16
17 settings: {
18 name: {
19 label: "Name",
20 type: "text",
21 help: "Application name from your heroku account."
22 },
23 key: {
24 label: "API Key",
25 type: "text",
26 help: "You can find your API key in your settings Heroku."
27 }
28 },
29
30 actions: [
31 {
32 id: "push:key",
33 name: "Deploy Public Key",
34 action: function(config) {
35 if (!config.key) throw "Need Heroku API key to deploy your SSH Public Key";
36
37 var publickey_file = path.join(process.env.HOME, '.ssh/id_rsa.pub');
38 return Q.nfcall(fs.readFile, publickey_file, 'utf8')
39 .then(function(content) {
40 return api.method(config.key, "POST", "account/keys", {
41 body: {
42 'public_key': content
43 }
44 })
45 .then(function() {
46 return "SSH key ("+content.slice(0, 20)+"......"+content.slice(-4)+") added to your Heroku account.";
47 });
48 });
49 }
50 },
51 {
52 id: "push",
53 name: "Push",
54 action: function(config) {
55 var shellId = "heroku:deploy";
56 var url = "git@heroku.com:"+config.name+".git";
57
58 return shells.createShellCommand(
59 shellId,
60 ["git", "push", url, "master"]
61 ).then(function(shell) {
62 return {
63 'shellId': shellId
64 };
65 });
66 }

Callers

nothing calls this directly

Calls 1

registerFunction · 0.85

Tested by

no test coverage detected