From 47a062b7bd4e3314167140b4d161da463010b1c3 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Mon, 3 Aug 2020 09:51:47 -0600 Subject: [PATCH 01/17] chore: update gauge and chalk Unaffected by the breaking changes other than dropped node versions. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9d4e633..c0a6fa2 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,10 @@ "Ted Janeczko " ], "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", From cb0a65f4d66ef7e398db866e6338a88fd638e9bf Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Mon, 3 Aug 2020 10:47:59 -0600 Subject: [PATCH 02/17] deps: Update more deps that don't require changes --- package.json | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index c0a6fa2..6ad78cb 100644 --- a/package.json +++ b/package.json @@ -27,25 +27,25 @@ "gauge": "^3.0.0", "gh-release-assets": "^1.1.0", "ghauth": "^3.2.0", - "github-url-to-object": "^3.0.0", + "github-url-to-object": "^4.0.4", "inquirer": "^6.2.0", "request": "^2.82.0", "shelljs": "^0.3.0", - "update-notifier": "^2.2.0", + "update-notifier": "^4.1.0", "yargs": "^2.1.1" }, "devDependencies": { - "gh-pages": "^0.11.0", + "gh-pages": "^3.1.0", "live-server": "^1.1.0", - "npm-run-all": "^3.1.0", + "npm-run-all": "^4.1.5", "quick-gits": "^1.0.4", - "rimraf": "^2.2.8", - "sitedown": "^3.1.0", - "snazzy": "^5.0.0", + "rimraf": "^3.0.2", + "sitedown": "^4.0.0", + "snazzy": "^8.0.0", "standard": "^8.1.0", - "tap-spec": "^4.1.1", - "tape": "^4.6.0", - "tmp": "0.0.25" + "tap-spec": "^5.0.0", + "tape": "^5.0.1", + "tmp": "v0.2.1" }, "files": [ "bin/", @@ -66,6 +66,9 @@ "type": "git", "url": "git+https://github.com/hypermodules/gh-release.git" }, + "engines" : { + "node" : ">=12.0.0" + }, "scripts": { "gh-pages": "npm run site && gh-pages -d site", "pretest": "standard | snazzy", From 01758f2d60c3e3703807a065091c1dedaf7abd2b Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Mon, 3 Aug 2020 10:53:47 -0600 Subject: [PATCH 03/17] deps: update standard to ^14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6ad78cb..858c6eb 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "rimraf": "^3.0.2", "sitedown": "^4.0.0", "snazzy": "^8.0.0", - "standard": "^8.1.0", + "standard": "^14.3.4", "tap-spec": "^5.0.0", "tape": "^5.0.1", "tmp": "v0.2.1" From bd1ea871e7303085f299438a9e16018ce197cf4a Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Mon, 3 Aug 2020 10:53:59 -0600 Subject: [PATCH 04/17] chore: standard --fmt --- bin/lib/get-defaults.js | 2 +- bin/lib/preview.js | 2 +- bin/lib/yargs.js | 24 ++++++++++++------------ index.js | 12 ++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bin/lib/get-defaults.js b/bin/lib/get-defaults.js index 3b6a6eb..f012c8f 100644 --- a/bin/lib/get-defaults.js +++ b/bin/lib/get-defaults.js @@ -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')) } diff --git a/bin/lib/preview.js b/bin/lib/preview.js index 6e1dca0..1d860e8 100644 --- a/bin/lib/preview.js +++ b/bin/lib/preview.js @@ -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] }) } }) diff --git a/bin/lib/yargs.js b/bin/lib/yargs.js index bb0fdcb..ce24cdd 100644 --- a/bin/lib/yargs.js +++ b/bin/lib/yargs.js @@ -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, @@ -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, diff --git a/index.js b/index.js index 334a168..3703d55 100644 --- a/index.js +++ b/index.js @@ -18,12 +18,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', From f3d2941d68f017093d47fc5b30e4d6411acb14e1 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Mon, 3 Aug 2020 10:57:54 -0600 Subject: [PATCH 05/17] deps: update inquirer to 7.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 858c6eb..c0f9f2c 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "gh-release-assets": "^1.1.0", "ghauth": "^3.2.0", "github-url-to-object": "^4.0.4", - "inquirer": "^6.2.0", + "inquirer": "^7.3.3", "request": "^2.82.0", "shelljs": "^0.3.0", "update-notifier": "^4.1.0", From d2488cfed7fa4d920d82bb4a5a7f4e5f55a25903 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Mon, 3 Aug 2020 18:08:32 -0600 Subject: [PATCH 06/17] chore: expand range of support to last maintained node --- .travis.yml | 5 ++--- package.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad0f071..c092ef6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: node_js node_js: - - 4 - - 6 - - 'stable' + - 10 + - 12 sudo: false cache: directories: diff --git a/package.json b/package.json index c0f9f2c..2508b52 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "url": "git+https://github.com/hypermodules/gh-release.git" }, "engines" : { - "node" : ">=12.0.0" + "node" : ">=10.0.0" }, "scripts": { "gh-pages": "npm run site && gh-pages -d site", From cfdd01a22df06ae3ef0d8b58f599e3b07e063e33 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Tue, 4 Aug 2020 09:59:58 -0600 Subject: [PATCH 07/17] chore: update 13 major versions to yargs 15 How many more majors will yargs get! Nobody knows! At least it was easy. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2508b52..f86a5ff 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "request": "^2.82.0", "shelljs": "^0.3.0", "update-notifier": "^4.1.0", - "yargs": "^2.1.1" + "yargs": "^15.4.1" }, "devDependencies": { "gh-pages": "^3.1.0", From 7e6dbe44cbb7304f86b7d559102f39fafeb22373 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Tue, 4 Aug 2020 10:17:25 -0600 Subject: [PATCH 08/17] chore: update shelljs and adjust usage --- bin/lib/get-defaults.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/lib/get-defaults.js b/bin/lib/get-defaults.js index f012c8f..9048c92 100644 --- a/bin/lib/get-defaults.js +++ b/bin/lib/get-defaults.js @@ -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' } diff --git a/package.json b/package.json index f86a5ff..a4f7338 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "github-url-to-object": "^4.0.4", "inquirer": "^7.3.3", "request": "^2.82.0", - "shelljs": "^0.3.0", + "shelljs": "^0.8.4", "update-notifier": "^4.1.0", "yargs": "^15.4.1" }, From f3e68e5abcbe66851e8cd49df849e8e3b189c029 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Tue, 4 Aug 2020 10:50:00 -0600 Subject: [PATCH 09/17] deps: update ghauth Doesn't fix our deprecated endpoint issue, but it does update to the latest version of the dep. I opened an upstream issue regarding the endpoint: https://github.com/rvagg/ghauth/issues/26 --- bin/cli.js | 5 +++-- package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 42a94b3..f39990b 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -53,9 +53,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) }) } diff --git a/package.json b/package.json index a4f7338..3dde025 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "deep-extend": "^0.6.0", "gauge": "^3.0.0", "gh-release-assets": "^1.1.0", - "ghauth": "^3.2.0", + "ghauth": "^4.0.0", "github-url-to-object": "^4.0.4", "inquirer": "^7.3.3", "request": "^2.82.0", From a360f708aa203953952c921f8f2d684f7771f46b Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Tue, 4 Aug 2020 11:01:37 -0600 Subject: [PATCH 10/17] chore: package.json formatting --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3dde025..8ec46d4 100644 --- a/package.json +++ b/package.json @@ -66,8 +66,8 @@ "type": "git", "url": "git+https://github.com/hypermodules/gh-release.git" }, - "engines" : { - "node" : ">=10.0.0" + "engines": { + "node": ">=10.0.0" }, "scripts": { "gh-pages": "npm run site && gh-pages -d site", From 55700f0d9be7dd40fad7708c9067576c6327f56d Mon Sep 17 00:00:00 2001 From: Bret Comnes <166301+bcomnes@users.noreply.github.com> Date: Tue, 4 Aug 2020 12:15:46 -0600 Subject: [PATCH 11/17] Update .travis.yml Co-authored-by: john gravois --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c092ef6..2498ffd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - - 10 - - 12 + - 'lts/*' + - 'node' sudo: false cache: directories: From 6ea5b6321a6d737c6a67e0658abc411b672ae749 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sat, 8 Aug 2020 11:07:32 -0600 Subject: [PATCH 12/17] bug: fix missing error messages --- bin/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cli.js b/bin/cli.js index f39990b..95bbef7 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -156,7 +156,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) } From 725b85997671e001f5f471f1c3039acce92c99df Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sat, 8 Aug 2020 11:09:22 -0600 Subject: [PATCH 13/17] chore: update ghauth to support device flow Also not to stop using basic auth unless you are using GHE. --- README.md | 11 ++++++----- bin/cli.js | 1 + package.json | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f2ce52b..6273c00 100644 --- a/README.md +++ b/README.md @@ -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) { diff --git a/bin/cli.js b/bin/cli.js index 95bbef7..9b7c81a 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -35,6 +35,7 @@ var isEnterprise = !!argv.endpoint && argv.endpoint !== 'https://api.github.com' // get auth var ghauthOpts = { + clientId: '04dac3c40b7e49b11f38', configName: 'gh-release', scopes: ['repo'], note: 'gh-release', diff --git a/package.json b/package.json index 8ec46d4..20380a1 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "deep-extend": "^0.6.0", "gauge": "^3.0.0", "gh-release-assets": "^1.1.0", - "ghauth": "^4.0.0", + "ghauth": "bcomnes/ghauth#oauth-device-flow", "github-url-to-object": "^4.0.4", "inquirer": "^7.3.3", "request": "^2.82.0", From 20c2121a2b7265894d6282d444c66b50a63f2414 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sun, 13 Sep 2020 08:48:23 -0700 Subject: [PATCH 14/17] Use fork of ghauth while we wait for upstream --- bin/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cli.js b/bin/cli.js index 9b7c81a..7c94e23 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -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') From afffc1728d44301810aae8293677c627b4038331 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sun, 13 Sep 2020 09:12:36 -0700 Subject: [PATCH 15/17] remove depreciated package --- package.json | 2 +- test/get-defaults-test.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 20380a1..b02a32b 100644 --- a/package.json +++ b/package.json @@ -36,9 +36,9 @@ }, "devDependencies": { "gh-pages": "^3.1.0", + "git-pull-or-clone": "^2.0.1", "live-server": "^1.1.0", "npm-run-all": "^4.1.5", - "quick-gits": "^1.0.4", "rimraf": "^3.0.2", "sitedown": "^4.0.0", "snazzy": "^8.0.0", diff --git a/test/get-defaults-test.js b/test/get-defaults-test.js index 6b21be8..a7f2ed4 100644 --- a/test/get-defaults-test.js +++ b/test/get-defaults-test.js @@ -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') }) }) @@ -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') }) }) From 7a828e8dce00c7bb9eb351b24e2af840070bdd11 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sun, 13 Sep 2020 09:21:38 -0700 Subject: [PATCH 16/17] Install fork of ghauth --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b02a32b..82950f8 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "deep-extend": "^0.6.0", "gauge": "^3.0.0", "gh-release-assets": "^1.1.0", - "ghauth": "bcomnes/ghauth#oauth-device-flow", + "@bret/ghauth": "^5.0.0", "github-url-to-object": "^4.0.4", "inquirer": "^7.3.3", "request": "^2.82.0", From 1a61d26a1a73444681a11839a84e8e9ecf9f4a46 Mon Sep 17 00:00:00 2001 From: Bret Comnes Date: Sun, 13 Sep 2020 10:05:06 -0700 Subject: [PATCH 17/17] Improve error messaging around bad org permissions --- bin/cli.js | 2 +- index.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/cli.js b/bin/cli.js index 7c94e23..62e2b5c 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -35,7 +35,7 @@ var isEnterprise = !!argv.endpoint && argv.endpoint !== 'https://api.github.com' // get auth var ghauthOpts = { - clientId: '04dac3c40b7e49b11f38', + clientId: ghRelease.clientId, configName: 'gh-release', scopes: ['repo'], note: 'gh-release', diff --git a/index.js b/index.js index 3703d55..8317505 100644 --- a/index.js +++ b/index.js @@ -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', @@ -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) @@ -221,5 +228,6 @@ function getAuth (options) { Release.OPTIONS = OPTIONS Release.validate = validate +Release.clientId = clientId module.exports = Release