Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
Merge f84f1df into e509cfb
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed May 12, 2016
2 parents e509cfb + f84f1df commit d51bb5a
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: node_js
services:
- postgres
node_js:
- "node"
- "5"
before_script:
- psql -c 'create database oauth2_server;' -U postgres
after_success: npm run coverage
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="1.4.0"></a>
# [1.4.0](https://github.com/npm/oauth2-server-pg/compare/v1.2.0...v1.4.0) (2016-05-06)


### Features

* allow an integration provider to specify a post-install hook ([#15](https://github.com/npm/oauth2-server-pg/issues/15)) ([e509cfb](https://github.com/npm/oauth2-server-pg/commit/e509cfb))
* you can now remove a client once it is added ([#13](https://github.com/npm/oauth2-server-pg/issues/13)) ([d81ac92](https://github.com/npm/oauth2-server-pg/commit/d81ac92))



<a name="1.3.0"></a>
# [1.3.0](https://github.com/npm/oauth2-server-pg/compare/v1.2.0...v1.3.0) (2016-05-06)

Expand Down
12 changes: 9 additions & 3 deletions lib/install.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const _ = require('lodash')
const isUrl = require('is-url')
const request = require('request')
const Promise = require('bluebird')
const figures = require('figures')
const npmInstall = require('./util').npmInstall
const getMeta = require('./util').getMeta
const exists = require('./util').exists

const prefix = 'npm-addon-'
Expand Down Expand Up @@ -31,11 +33,15 @@ exports.handler = function (argv) {
exists(addon, argv)
.then(function () {
console.info(figures.tick + ' found addon "' + argv.addon + '"')
return npmInstall(addon, argv)
if (isUrl(argv.addon)) {
return getMeta(argv.addon, argv)
} else {
return npmInstall(addon, argv)
}
})
.then(function () {
.then(function (_meta) {
meta = _meta
console.info(figures.tick + ' installed addon "' + argv.addon + '"')
meta = require(addon)
return createClient(meta, argv)
})
.then(function (_client) {
Expand Down
12 changes: 8 additions & 4 deletions lib/remove.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const isUrl = require('is-url')
const request = require('request')
const Promise = require('bluebird')
const figures = require('figures')
const npmInstall = require('./util').npmInstall
const getMeta = require('./util').getMeta
const exists = require('./util').exists

const prefix = 'npm-addon-'
Expand All @@ -24,16 +26,18 @@ exports.builder = function (yargs) {

exports.handler = function (argv) {
var addon = prefix + argv.addon
var meta = null

exists(addon, argv)
.then(function () {
console.info(figures.tick + ' found addon "' + argv.addon + '"')
return npmInstall(addon, argv)
if (isUrl(argv.addon)) {
return getMeta(argv.addon, argv)
} else {
return npmInstall(addon, argv)
}
})
.then(function () {
.then(function (meta) {
console.info(figures.tick + ' installed addon for "' + argv.addon + '"')
meta = require(addon)
return deleteClient(meta, argv)
})
.then(function () {
Expand Down
27 changes: 25 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const figures = require('figures')
const Promise = require('bluebird')
const request = require('request')
const resolve = require('url').resolve
const isUrl = require('is-url')

module.exports = {
// npm install a module from an npm module.
Expand All @@ -18,15 +19,20 @@ module.exports = {
var msg = figures.cross + ' failed to install ' + argv.addon
return deferred.reject(Error(msg))
}
return deferred.resolve()

return deferred.resolve(require(addon))
})

return deferred.promise
},
exists (addon, argv) {
const deferred = Promise.defer()
var url = argv.addon
if (!isUrl(url)) {
url = resolve(argv.registry, addon)
}

request.get(resolve(argv.registry, addon), function (err, res) {
request.get(url, function (err, res) {
if (err) return deferred.reject(err)
if (res.statusCode >= 400) {
var msg = figures.cross + ' could not find addon "' + argv.addon + '" in registry ' + argv.registry
Expand All @@ -35,6 +41,23 @@ module.exports = {
return deferred.resolve()
})

return deferred.promise
},
getMeta (url, argv) {
const deferred = Promise.defer()

request.get({
url: url,
json: true
}, function (err, res, meta) {
if (err) return deferred.reject(err)
if (res.statusCode >= 400) {
var msg = figures.cross + ' could not find addon "' + argv.addon + '" in registry ' + argv.registry
return deferred.reject(Error(msg))
}
return deferred.resolve(meta)
})

return deferred.promise
}
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oauth2-server-pg",
"version": "1.3.0",
"version": "1.4.0",
"description": "PostgreSQL and Express powered OAuth 2.0 server",
"main": "./lib/server.js",
"bin": "./bin/oauth2-server-pg.js",
Expand Down Expand Up @@ -34,6 +34,7 @@
"db-migrate": "^0.9.23",
"express": "^4.13.4",
"figures": "^1.5.0",
"is-url": "^1.2.1",
"lodash": "^4.8.2",
"moment": "^2.12.0",
"ormnomnom": "^2.3.0",
Expand All @@ -57,4 +58,4 @@
"**/test/**"
]
}
}
}

0 comments on commit d51bb5a

Please sign in to comment.