Skip to content

Commit

Permalink
chore(deps-dev): bump standard from 15.0.1 to 16.0.2 (#116)
Browse files Browse the repository at this point in the history
* chore(deps-dev): bump standard from 15.0.1 to 16.0.2

Bumps [standard](https://github.com/standard/standard) from 15.0.1 to 16.0.2.
- [Release notes](https://github.com/standard/standard/releases)
- [Changelog](https://github.com/standard/standard/blob/master/CHANGELOG.md)
- [Commits](standard/standard@v15.0.1...v16.0.2)

Signed-off-by: dependabot[bot] <support@github.com>

* lint fixes

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: john gravois <jagravois@gmail.com>
  • Loading branch information
dependabot[bot] and jgravois committed Nov 12, 2020
1 parent 5e1ae2e commit 306f913
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 100 deletions.
48 changes: 24 additions & 24 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
#!/usr/bin/env node

var extend = require('deep-extend')
var fs = require('fs')
var path = require('path')
var chalk = require('chalk')
var ghauth = require('ghauth')
var inquirer = require('inquirer')
var ghRelease = require('../')
var getDefaults = require('./lib/get-defaults')
var preview = require('./lib/preview')
var yargs = require('./lib/yargs')
var updateNotifier = require('update-notifier')
var pkg = require('../package.json')
var Gauge = require('gauge')
var argv = yargs.argv
const extend = require('deep-extend')
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')
const ghauth = require('ghauth')
const inquirer = require('inquirer')
const ghRelease = require('../')
const getDefaults = require('./lib/get-defaults')
const preview = require('./lib/preview')
const yargs = require('./lib/yargs')
const updateNotifier = require('update-notifier')
const pkg = require('../package.json')
const Gauge = require('gauge')
const argv = yargs.argv

// notify of update if needed

updateNotifier({ pkg: pkg }).notify()

// check dir

var pkgExists = fs.existsSync(path.resolve(argv.workpath, 'package.json'))
var logExists = fs.existsSync(path.resolve(argv.workpath, 'CHANGELOG.md'))
const pkgExists = fs.existsSync(path.resolve(argv.workpath, 'package.json'))
const logExists = fs.existsSync(path.resolve(argv.workpath, 'CHANGELOG.md'))

if (!pkgExists || !logExists) {
console.log('Must be run in a directory with package.json and CHANGELOG.md')
yargs.showHelp()
process.exit(1)
}

var isEnterprise = !!argv.endpoint && argv.endpoint !== 'https://api.github.com'
const isEnterprise = !!argv.endpoint && argv.endpoint !== 'https://api.github.com'

// get auth

var ghauthOpts = {
const ghauthOpts = {
clientId: ghRelease.clientId,
configName: 'gh-release',
scopes: ['repo'],
Expand Down Expand Up @@ -62,7 +62,7 @@ if (process.env.GH_RELEASE_GITHUB_API_TOKEN) {
}

function releaseWithAuth (auth) {
var options = {}
const options = {}
options.auth = auth
options.cli = true
// get defaults
Expand All @@ -76,7 +76,7 @@ function releaseWithAuth (auth) {

// filter options through whitelist

var whitelist = ghRelease.OPTIONS.whitelist
const whitelist = ghRelease.OPTIONS.whitelist

Object.keys(options).forEach(function (key) {
if (whitelist.indexOf(key) === -1) delete options[key]
Expand All @@ -100,7 +100,7 @@ function releaseWithAuth (auth) {
}
// confirm & release

var confirmation = [{
const confirmation = [{
type: 'confirm',
name: 'confirm',
message: 'publish release to github?',
Expand All @@ -121,7 +121,7 @@ function releaseWithAuth (auth) {
function performRelease (options) {
// pass options to api

var release = ghRelease(options, function ghReleaseCallback (err, result) {
const release = ghRelease(options, function ghReleaseCallback (err, result) {
// handle errors
if (err) return handleError(err)

Expand All @@ -139,7 +139,7 @@ function performRelease (options) {
console.log(result.html_url)
process.exit(0)
})
var gauge = new Gauge(process.stderr, {
const gauge = new Gauge(process.stderr, {
updateInterval: 50,
theme: 'colorBrailleSpinner'
})
Expand All @@ -157,7 +157,7 @@ function performRelease (options) {
}

function handleError (err) {
var msg = err.message || JSON.stringify(err)
const msg = err.message || JSON.stringify(err)
console.log(chalk.red(msg))
process.exit(1)
}
37 changes: 19 additions & 18 deletions bin/lib/get-defaults.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
var path = require('path')
var fs = require('fs')
var changelogParser = require('changelog-parser')
var exec = require('shelljs').exec
var parseRepo = require('github-url-to-object')
const path = require('path')
const fs = require('fs')
const changelogParser = require('changelog-parser')
const exec = require('shelljs').exec
const parseRepo = require('github-url-to-object')

function getDefaults (workPath, isEnterprise, callback) {
var pkg = require(path.resolve(workPath, 'package.json'))
var lernaPath = path.resolve(workPath, 'lerna.json')
const pkg = require(path.resolve(workPath, 'package.json'))
const lernaPath = path.resolve(workPath, 'lerna.json')

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'))
}

var commit = getTargetCommitish()
var repoParts = parseRepo(pkg.repository, {
const commit = getTargetCommitish()
const repoParts = parseRepo(pkg.repository, {
enterprise: isEnterprise
})
if (!repoParts) {
return callback(new Error('The repository defined in your package.json is invalid => https://docs.npmjs.com/files/package.json#repository'))
}
var owner = repoParts.user
var repo = repoParts.repo
var logPath = path.resolve(workPath, 'CHANGELOG.md')
const owner = repoParts.user
const repo = repoParts.repo
const logPath = path.resolve(workPath, 'CHANGELOG.md')

changelogParser(logPath, function (err, result) {
if (err) return callback(err)

// check for 'unreleased' section in CHANGELOG: allow sections which do not include a body (eg. 'Added', 'Changed', etc.)

var unreleased = result.versions.filter(function (release) {
const unreleased = result.versions.filter(function (release) {
return release.title && release.title.toLowerCase
? release.title.toLowerCase().indexOf('unreleased') !== -1
: false
Expand All @@ -40,17 +40,18 @@ function getDefaults (workPath, isEnterprise, callback) {
return callback(new Error('Unreleased changes detected in CHANGELOG.md, aborting'))
}

var log = result.versions.filter(function (release) { return release.version !== null })[0]
const log = result.versions.filter(function (release) { return release.version !== null })[0]

if (!log) {
return callback(new Error('CHANGELOG.md does not contain any versions'))
}

var lerna = {}
let lerna = {}
let errStr
if (fs.existsSync(lernaPath)) {
lerna = require(lernaPath) /* || {} */ // 👈 though I prefer this expression
if (log.version !== lerna.version) {
var errStr = 'CHANGELOG.md out of sync with lerna.json '
errStr = 'CHANGELOG.md out of sync with lerna.json '
errStr += '(' + (log.version || log.title) + ' !== ' + lerna.version + ')'
return callback(new Error(errStr))
}
Expand All @@ -60,7 +61,7 @@ function getDefaults (workPath, isEnterprise, callback) {
return callback(new Error(errStr))
}

var version = pkg.version ? 'v' + pkg.version : lerna.version ? 'v' + lerna.version : null
const version = pkg.version ? 'v' + pkg.version : lerna.version ? 'v' + lerna.version : null

callback(null, {
body: log.body,
Expand All @@ -81,7 +82,7 @@ function getDefaults (workPath, isEnterprise, callback) {
}

function getTargetCommitish () {
var commit = exec('git rev-parse HEAD', { silent: true }).split('\n')[0]
const commit = exec('git rev-parse HEAD', { silent: true }).split('\n')[0]
if (commit.indexOf('fatal') === -1) return commit
return 'master'
}
Expand Down
24 changes: 12 additions & 12 deletions bin/lib/preview.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var chalk = require('chalk')
var extend = require('deep-extend')
var columnWidth = 20
const chalk = require('chalk')
const extend = require('deep-extend')
const columnWidth = 20

function preview (options) {
var intro = '\ncreating release ' + chalk.bold(options.tag_name) +
const intro = '\ncreating release ' + chalk.bold(options.tag_name) +
' for ' + chalk.bold(options.owner + '/' + options.repo) + '\n'
var prettyOptions = formatOptions(options)
const prettyOptions = formatOptions(options)

console.log(intro)

Expand All @@ -17,8 +17,8 @@ function preview (options) {
}

function formatOptions (options) {
var formatted = []
var copy = extend({}, options)
const formatted = []
const copy = extend({}, options)

delete copy.auth
delete copy.owner
Expand All @@ -27,15 +27,15 @@ function formatOptions (options) {
delete copy.yes
delete copy.workpath

var keys = Object.keys(copy).reverse()
const keys = Object.keys(copy).reverse()

keys.forEach(function (key) {
if (['assets', 'draft', 'prerelease'].indexOf(key) > -1) {
if (!copy[key]) return
}

if (key === 'body') {
var body = formatBody(copy.body)
const body = formatBody(copy.body)
formatted.push.apply(formatted, body)
} else {
formatted.push({ column1: justify(key), column2: copy[key] })
Expand All @@ -46,17 +46,17 @@ function formatOptions (options) {
}

function formatBody (body) {
var arr = []
const arr = []
arr.push({ column1: justify('body'), column2: '' })
arr.push({ column1: '', column2: '' })
body.split('\n').map(function (line, i) {
body.split('\n').forEach(function (line) {
arr.push({ column1: '', column2: line })
})
return arr
}

function justify (word) {
var justified = word + ':'
let justified = word + ':'
while (justified.length < columnWidth) justified += ' '
return justified
}
Expand Down
2 changes: 1 addition & 1 deletion bin/lib/yargs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var version
let version
try {
version = require('../../lerna.json').version
} catch (_) {
Expand Down
Loading

0 comments on commit 306f913

Please sign in to comment.