Skip to content

Commit

Permalink
fix: update deps and linting, Drop Node < 10
Browse files Browse the repository at this point in the history
  • Loading branch information
knownasilya committed May 14, 2020
1 parent 1cab3de commit cab6f37
Show file tree
Hide file tree
Showing 17 changed files with 1,419 additions and 243 deletions.
11 changes: 11 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
parserOptions: {
ecmaVersion: 6,
sourceType: 'script',
},
env: {
node: true,
es6: true,
},
extends: 'eslint:recommended',
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
yarn-error.log
14 changes: 0 additions & 14 deletions .jshintrc

This file was deleted.

3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
singleQuote: true,
};
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
language: node_js
node_js:
- "0.10"
- "0.12"
- "4"
- "10"
- "node"

sudo: false
12 changes: 0 additions & 12 deletions Makefile

This file was deleted.

35 changes: 24 additions & 11 deletions config/config.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
<h3>Heroku!</h3>
<div ng-show="userIsCreator">
<a ng-hide="userConfig.accounts.length"
href="/ext/heroku/oauth?redirect=/[[ project.name ]]/config"
class="btn btn-success">Add a Heroku Account</a>
<a
ng-hide="userConfig.accounts.length"
href="/ext/heroku/oauth?redirect=/[[ project.name ]]/config"
class="btn btn-success"
>Add a Heroku Account</a
>
<div ng-show="userConfig.accounts.length">
<div class="accounts">
<h4>Linked Accounts</h4>
<select ng-model="account"
ng-options="account.email for account in userConfig.accounts track by account.id"></select>
<a href="/ext/heroku/oauth?redirect=/[[ project.name ]]/config"
class="btn btn-success">Add a Heroku Account</a>
<select
ng-model="account"
ng-options="account.email for account in userConfig.accounts track by account.id"
></select>
<a
href="/ext/heroku/oauth?redirect=/[[ project.name ]]/config"
class="btn btn-success"
>Add a Heroku Account</a
>
</div>
<div class="apps">
<h4>Apps</h4>
Deploy to: <select ng-model="config.app" ng-options="app.name for app in account.cache track by app.id"></select>
<button ng-click="getApps()" class="btn"><i class="icon-refresh"></i> Refresh Apps List</button>
Deploy to:
<select
ng-model="config.app"
ng-options="app.name for app in account.cache track by app.id"
></select>
<button ng-click="getApps()" class="btn">
<i class="icon-refresh"></i> Refresh Apps List
</button>
</div>
<button ng-click="save()" class="btn btn-primary">Save</button>
</div>
</div>
<p ng-hide="userIsCreator">
Only the creator can setup this project for heroku
deployment.
Only the creator can setup this project for heroku deployment.
</p>
90 changes: 49 additions & 41 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,61 @@
'use strict';
/* eslint-disable no-undef */

app.controller('HerokuController', ['$scope', '$element', function ($scope, $element) {
$scope.saving = false;
app.controller('HerokuController', [
'$scope',
'$element',
function ($scope) {
$scope.saving = false;

$scope.$watch('userConfigs.heroku', function (value) {
if (!value) return;
$scope.$watch('userConfigs.heroku', function (value) {
if (!value) return;

$scope.userConfig = value;
$scope.userConfig = value;

if (!$scope.account && value.accounts && value.accounts.length > 0) {
$scope.account = value.accounts[0];
}
});
if (!$scope.account && value.accounts && value.accounts.length > 0) {
$scope.account = value.accounts[0];
}
});

$scope.$watch('configs[branch.name].heroku.config', function (value) {
$scope.config = value;
$scope.$watch('configs[branch.name].heroku.config', function (value) {
$scope.config = value;

if (value && value.app && $scope.userConfig.accounts) {
for (var i = 0; i < $scope.userConfig.accounts.length; i++) {
if ($scope.userConfig.accounts[i].id === value.app.account) {
$scope.account = $scope.userConfig.accounts[i];
break;
if (value && value.app && $scope.userConfig.accounts) {
for (var i = 0; i < $scope.userConfig.accounts.length; i++) {
if ($scope.userConfig.accounts[i].id === value.app.account) {
$scope.account = $scope.userConfig.accounts[i];
break;
}
}
}
}
});
});

$scope.save = function () {
$scope.saving = true;
$scope.save = function () {
$scope.saving = true;

$scope.pluginConfig('heroku', $scope.config, function () {
$scope.saving = false;
});
};

$scope.getApps = function () {
if (!$scope.account) {
return console.warn('tried to getApps but no account');
}

$.ajax('/ext/heroku/apps/' + $scope.account.id, {
type: 'GET',
success: function (body, req) {
$scope.account.cache = body;
$scope.success('Got accounts list for ' + $scope.account.email, true);
},
error: function () {
$scope.error('Failed to get accounts list for ' + $scope.account.email, true);
$scope.pluginConfig('heroku', $scope.config, function () {
$scope.saving = false;
});
};

$scope.getApps = function () {
if (!$scope.account) {
return console.warn('tried to getApps but no account');
}
});
};
}]);

$.ajax('/ext/heroku/apps/' + $scope.account.id, {
type: 'GET',
success: function (body) {
$scope.account.cache = body;
$scope.success('Got accounts list for ' + $scope.account.email, true);
},
error: function () {
$scope.error(
'Failed to get accounts list for ' + $scope.account.email,
true
);
},
});
};
},
]);
1 change: 0 additions & 1 deletion config/config.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#plugin-heroku {
select {
margin-bottom: 0;
Expand Down
2 changes: 1 addition & 1 deletion config/user.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ <h4>Public Key</h4>
<button ng-click="remove(account)" class="btn btn-danger">Remove</button>
</div>
<a href="/ext/heroku/oauth" class="btn btn-success">Add a Heroku Account</a>
</div>
</div>
42 changes: 25 additions & 17 deletions config/user.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
'use strict';
/* eslint-disable no-undef */

app.controller('HerokuUserController', ['$scope', '$element', function ($scope, $element) {
$scope.$watch('user.jobplugins.heroku', function (value) {
$scope.config = value;
});

$scope.remove = function (account) {
$.ajax('/ext/heroku/account/' + account.id, {
type: 'DELETE',
success: function () {
$scope.config.accounts.splice($scope.config.accounts.indexOf(account), 1);
$scope.success('Removed account', true);
},
error: function () {
$scope.error('Failed to remove account', true);
}
app.controller('HerokuUserController', [
'$scope',
'$element',
function ($scope) {
$scope.$watch('user.jobplugins.heroku', function (value) {
$scope.config = value;
});
};
}]);

$scope.remove = function (account) {
$.ajax('/ext/heroku/account/' + account.id, {
type: 'DELETE',
success: function () {
$scope.config.accounts.splice(
$scope.config.accounts.indexOf(account),
1
);
$scope.success('Removed account', true);
},
error: function () {
$scope.error('Failed to remove account', true);
},
});
};
},
]);
3 changes: 1 addition & 2 deletions config/user.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

#job-heroku {
textarea {
width: 100%;
height: 200px;
font-size: 10px;
}
}
}
51 changes: 28 additions & 23 deletions lib/api.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@

var superagent = require('superagent')
, API = "https://api.heroku.com"
const superagent = require('superagent');
const API = 'https://api.heroku.com';

module.exports = {
getApps: getApps,
addKey: addKey
}
addKey: addKey,
};

function getApps(aid, token, done) {
superagent.get(API + '/apps')
superagent
.get(API + '/apps')
.set('Accept', 'application/vnd.heroku+json; version=3')
.set('Authorization', 'Bearer ' + token)
.end(function (res) {
if (res.status !== 200) return done(new Error('Status: ' + res.status + '; ' + res.text))
done(null, res.body.map(function (app) {
return {
id: app.id,
name: app.name,
account: aid,
git_url: app.git_url,
web_url: app.web_url,
updated_at: app.updated_at
}
}))
})
if (res.status !== 200)
return done(new Error('Status: ' + res.status + '; ' + res.text));
done(
null,
res.body.map(function (app) {
return {
id: app.id,
name: app.name,
account: aid,
git_url: app.git_url,
web_url: app.web_url,
updated_at: app.updated_at,
};
})
);
});
}

function addKey(token, key, done) {
superagent.post(API + '/user/keys')
superagent
.post(API + '/user/keys')
.set('Accept', 'application/vnd.heroku+json; version=3')
.set('Authorization', 'Bearer ' + token)
.set('Content-type', 'text/ssh-authkey')
.send(key)
.end(function (res) {
if (res.status !== 200) return done(new Error('Status: ' + res.status + '; ' + res.text))
done()
})
if (res.status !== 200)
return done(new Error('Status: ' + res.status + '; ' + res.text));
done();
});
}

18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"test": "test"
},
"scripts": {
"test": "make test"
"test": "npm run lint",
"lint": "eslint ."
},
"repository": {
"type": "git",
Expand All @@ -22,8 +23,6 @@
],
"author": "Jared Forsyth <[email protected]>",
"license": "MIT",
"gitHead": "0c7459f2fa57385c0b6bc71e98ef01be99fad226",
"readmeFilename": "Readme.md",
"strider": {
"id": "heroku",
"type": "job",
Expand All @@ -39,14 +38,13 @@
}
},
"dependencies": {
"ssh-keypair": "~1.0.0",
"strider-git": "~0.1.0",
"superagent": "~0.15.5",
"passport-heroku": "0.0.2",
"step": "0.0.5"
"passport-heroku": "1.0.0",
"ssh-keypair": "^2.0.0",
"step": "^1.0.0",
"strider-git": "^1.0.3",
"superagent": "^5.2.2"
},
"devDependencies": {
"jshint": "~2.3.0",
"mocha": "~1.14.0"
"eslint": "^7.0.0"
}
}
Loading

0 comments on commit cab6f37

Please sign in to comment.