Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freshen up deps #93

Merged
merged 17 commits into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: node_js
node_js:
- 4
- 6
- 'stable'
- 'lts/*'
- 'node'
sudo: false
cache:
directories:
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,16 @@ var options = {
var options = {}

// auth is required
// it can either be a username & password...
// it can be an API token...
options.auth = {
username: 'ungoldman',
password: 'XXXXXXXX'
token: 'XXXXXXXX'
}

// or an API token
// or it can either be a username & password
// (But only for GitHub Enterprise when endpoint is set)
options.auth = {
token: 'XXXXXXXX'
username: 'ungoldman',
password: 'XXXXXXXX'
}

ghRelease(options, function (err, result) {
Expand Down
10 changes: 6 additions & 4 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var extend = require('deep-extend')
var fs = require('fs')
var path = require('path')
var chalk = require('chalk')
var ghauth = require('ghauth')
var ghauth = require('@bret/ghauth')
var inquirer = require('inquirer')
var ghRelease = require('../')
var getDefaults = require('./lib/get-defaults')
Expand Down Expand Up @@ -35,6 +35,7 @@ var isEnterprise = !!argv.endpoint && argv.endpoint !== 'https://api.github.com'
// get auth

var ghauthOpts = {
clientId: ghRelease.clientId,
configName: 'gh-release',
scopes: ['repo'],
note: 'gh-release',
Expand All @@ -53,9 +54,10 @@ if (process.env.GH_RELEASE_GITHUB_API_TOKEN) {
token: process.env.GH_RELEASE_GITHUB_API_TOKEN
})
} else {
ghauth(ghauthOpts, function (err, auth) {
if (err) return handleError(err)
ghauth(ghauthOpts).then(function (auth) {
releaseWithAuth(auth)
}).catch(function (err) {
return handleError(err)
})
}

Expand Down Expand Up @@ -155,7 +157,7 @@ function performRelease (options) {
}

function handleError (err) {
var msg = err.msg || JSON.stringify(err)
var msg = err.message || JSON.stringify(err)
console.log(chalk.red(msg))
process.exit(1)
}
4 changes: 2 additions & 2 deletions bin/lib/get-defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function getDefaults (workPath, isEnterprise, callback) {
var pkg = require(path.resolve(workPath, 'package.json'))
var lernaPath = path.resolve(workPath, 'lerna.json')

if (!pkg.hasOwnProperty('repository')) {
if (!Object.hasOwnProperty.call(pkg, 'repository')) {
return callback(new Error('You must define a repository for your module => https://docs.npmjs.com/files/package.json#repository'))
}

Expand Down Expand Up @@ -81,7 +81,7 @@ function getDefaults (workPath, isEnterprise, callback) {
}

function getTargetCommitish () {
var commit = exec('git rev-parse HEAD', { silent: true }).output.split('\n')[0]
var commit = exec('git rev-parse HEAD', { silent: true }).split('\n')[0]
if (commit.indexOf('fatal') === -1) return commit
return 'master'
}
Expand Down
2 changes: 1 addition & 1 deletion bin/lib/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function formatOptions (options) {
var body = formatBody(copy.body)
formatted.push.apply(formatted, body)
} else {
formatted.push({column1: justify(key), column2: copy[key]})
formatted.push({ column1: justify(key), column2: copy[key] })
}
})

Expand Down
24 changes: 12 additions & 12 deletions bin/lib/yargs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,59 +8,59 @@ try {
module.exports = require('yargs')
.usage('Usage: $0 [options]')
.options({
't': {
t: {
alias: 'tag_name',
type: 'string',
describe: 'tag for this release'
},
'c': {
c: {
alias: 'target_commitish',
type: 'string',
describe: 'commitish value for tag'
},
'n': {
n: {
alias: 'name',
type: 'string',
describe: 'text of release title'
},
'b': {
b: {
alias: 'body',
type: 'string',
describe: 'text of release body'
},
'o': {
o: {
alias: 'owner',
describe: 'repo owner'
},
'r': {
r: {
alias: 'repo',
describe: 'repo name'
},
'd': {
d: {
alias: 'draft',
type: 'boolean',
default: false,
describe: 'publish as draft'
},
'p': {
p: {
alias: 'prerelease',
type: 'boolean',
default: false,
describe: 'publish as prerelease'
},
'w': {
w: {
alias: 'workpath',
type: 'string',
default: process.cwd(),
describe: 'path to working directory'
},
'e': {
e: {
alias: 'endpoint',
type: 'string',
default: 'https://api.github.com',
describe: 'GitHub API endpoint URL'
},
'a': {
a: {
alias: 'assets',
type: 'string',
default: false,
Expand All @@ -71,7 +71,7 @@ module.exports = require('yargs')
default: false,
describe: 'dry run (stops before release step)'
},
'y': {
y: {
alias: 'yes',
type: 'boolean',
default: false,
Expand Down
20 changes: 14 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var ghReleaseAssets = require('gh-release-assets')
var getDefaults = require('./bin/lib/get-defaults')
var Emitter = require('events').EventEmitter

var clientId = '04dac3c40b7e49b11f38'

var OPTIONS = {
required: [
'auth',
Expand All @@ -18,12 +20,12 @@ var OPTIONS = {
],
valid: [],
defaults: {
'dryRun': false,
'yes': false,
'draft': false,
'endpoint': 'https://api.github.com',
'prerelease': false,
'workpath': process.cwd()
dryRun: false,
yes: false,
draft: false,
endpoint: 'https://api.github.com',
prerelease: false,
workpath: process.cwd()
},
whitelist: [
'auth',
Expand Down Expand Up @@ -120,6 +122,11 @@ function _Release (options, emitter, callback) {
return callback(err)
}

if (res.statusCode === 404) {
var authErrorMessage = format('404 Not Found. Review gh-release oAuth Organization access: https://github.com/settings/connections/applications/%s', clientId)
return callback(new Error(authErrorMessage))
}

if (body.errors) {
if (body.errors[0].code !== 'already_exists') {
return callback(body.errors)
Expand Down Expand Up @@ -221,5 +228,6 @@ function getAuth (options) {

Release.OPTIONS = OPTIONS
Release.validate = validate
Release.clientId = clientId

module.exports = Release
39 changes: 21 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@
"Ted Janeczko <tjaneczko@brightcove.com>"
],
"dependencies": {
"chalk": "^1.0.0",
"chalk": "^4.1.0",
"changelog-parser": "^2.0.0",
"deep-extend": "^0.6.0",
"gauge": "^2.7.4",
"gauge": "^3.0.0",
"gh-release-assets": "^1.1.0",
"ghauth": "^3.2.0",
"github-url-to-object": "^3.0.0",
"inquirer": "^6.2.0",
"@bret/ghauth": "^5.0.0",
"github-url-to-object": "^4.0.4",
"inquirer": "^7.3.3",
"request": "^2.82.0",
"shelljs": "^0.3.0",
"update-notifier": "^2.2.0",
"yargs": "^2.1.1"
"shelljs": "^0.8.4",
"update-notifier": "^4.1.0",
"yargs": "^15.4.1"
},
"devDependencies": {
"gh-pages": "^0.11.0",
"gh-pages": "^3.1.0",
"git-pull-or-clone": "^2.0.1",
"live-server": "^1.1.0",
"npm-run-all": "^3.1.0",
"quick-gits": "^1.0.4",
"rimraf": "^2.2.8",
"sitedown": "^3.1.0",
"snazzy": "^5.0.0",
"standard": "^8.1.0",
"tap-spec": "^4.1.1",
"tape": "^4.6.0",
"tmp": "0.0.25"
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"sitedown": "^4.0.0",
"snazzy": "^8.0.0",
"standard": "^14.3.4",
"tap-spec": "^5.0.0",
"tape": "^5.0.1",
"tmp": "v0.2.1"
},
"files": [
"bin/",
Expand All @@ -66,6 +66,9 @@
"type": "git",
"url": "git+https://github.com/hypermodules/gh-release.git"
},
"engines": {
"node": ">=10.0.0"
},
"scripts": {
"gh-pages": "npm run site && gh-pages -d site",
"pretest": "standard | snazzy",
Expand Down
10 changes: 5 additions & 5 deletions test/get-defaults-test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
var test = require('tape')
var path = require('path')
var tmp = require('tmp')
var gits = require('quick-gits')
var gitPullOrClone = require('git-pull-or-clone')
var rimraf = require('rimraf')

var getDefaults = require('../bin/lib/get-defaults')
var remote = 'https://github.com/bcomnes/gh-release-test.git'

var tmpDir, repo
var repoDir, tmpDir

test('Set up test environment', function (t) {
t.plan(2)
tmpDir = tmp.dirSync({ unsafeCleanup: true })
repoDir = path.join(tmpDir.name, 'test-repo')
t.ok(tmpDir.name, 'valid tmp dir exists')
repo = gits(tmpDir.name)
repo.clone(remote, function (err) {
gitPullOrClone(remote, repoDir, function (err) {
t.error(err, 'cloned test repo')
})
})
Expand All @@ -23,7 +23,7 @@ test('get-defaults', function (t) {
t.plan(2)
var commitish = getDefaults.getTargetCommitish()
t.ok(commitish, 'Check for commitish')
getDefaults(tmpDir.name, false, function (err, defaults) {
getDefaults(repoDir, false, function (err, defaults) {
t.error(err, 'Got the defaults from the test repo')
})
})
Expand Down