Skip to content

Commit

Permalink
Update dependencies (#57)
Browse files Browse the repository at this point in the history
* Update dependencies

* Update defaultBranch reference

* Fix lint
  • Loading branch information
job13er authored Apr 19, 2022
1 parent 8a287b7 commit a247557
Show file tree
Hide file tree
Showing 7 changed files with 1,442 additions and 1,499 deletions.
11 changes: 6 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['airbnb'],
extends: ['prettier-airbnb'],

// globals for jest
globals: {
Expand All @@ -8,18 +8,19 @@ module.exports = {
describe: false,
expect: false,
it: false,
jest: false
jest: false,
},

rules: {
'arrow-parens': 'off', // conflicts with prettier
'comma-dangle': ['error', 'never'], // conflicts with prettier
'comma-dangle': ['error', 'only-multiline'], // conflicts with prettier
'function-paren-newline': 'off', // conflicts with prettier
'max-len': ['error', 120], // to match prettier settings
'no-extra-semi': 'off', // conflicts with prettier
'object-curly-spacing': ['error', 'never'], // to match prettier settings
'object-curly-newline': 'off', // conflicts with prettier
'operator-linebreak': 'off', // conflicts with prettier
'semi-style': 'off', // conflicts with prettier
semi: ['error', 'never'] // to match prettier settings
}
semi: ['error', 'never'], // to match prettier settings
},
}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[ci-img]: https://travis-ci.com/all-i-code/bumpr.svg?branch=master "Travis CI Build Status"
[ci-img]: https://travis-ci.com/all-i-code/bumpr.svg?branch=main "Travis CI Build Status"
[ci-url]: https://travis-ci.com/all-i-code/bumpr

[npm-img]: https://img.shields.io/npm/v/bumpr.svg "NPM Version"
Expand Down Expand Up @@ -497,6 +497,9 @@ ssh keys which have proper permissions and will not use any token.
#### `vcs.repository`
Holds info about the name and organization of the repository.
##### `vcs.repository.defaultBranch`
The name of the default branch of the repository (default is `main`)
##### `vcs.repository.name`
The name of the repository
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@
"versiony": "^2.0.1"
},
"devDependencies": {
"eslint": "^7.29.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier-airbnb": "^0.3.0",
"eslint-plugin-import": "^2.11.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4",
"eslint": "^8.13.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier-airbnb": "^0.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.4.0",
"freezly": "^2.0.2",
"husky": "^7.0.0",
"jest": "^27.0.5",
"lint-staged": "^11.0.0",
"jest": "^27.5.1",
"lint-staged": "^12.3.8",
"prettier": "^2.3.1"
}
}
26 changes: 13 additions & 13 deletions src/ci/tests/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ describe('CI / Base', () => {
config = {
computed: {
ci: {
branch: 'my-branch'
}
}
branch: 'my-branch',
},
},
}
base = new CiBase(config, {id: 'vcs'})
})
Expand All @@ -33,7 +33,7 @@ describe('CI / Base', () => {

beforeEach(() => {
exec.mockReturnValue(Promise.resolve('added'))
return base.add(['foo', 'bar', 'baz']).then(res => {
return base.add(['foo', 'bar', 'baz']).then((res) => {
result = res
})
})
Expand All @@ -52,7 +52,7 @@ describe('CI / Base', () => {

beforeEach(() => {
exec.mockReturnValue(Promise.resolve('committed'))
return base.commit('my summary message', 'my detail message').then(res => {
return base.commit('my summary message', 'my detail message').then((res) => {
result = res
})
})
Expand All @@ -71,10 +71,10 @@ describe('CI / Base', () => {

beforeEach(() => {
base.vcs = {
addRemoteForPush: jest.fn().mockReturnValue(Promise.resolve('my-origin'))
addRemoteForPush: jest.fn().mockReturnValue(Promise.resolve('my-origin')),
}
exec.mockReturnValue(Promise.resolve('pushed'))
return base.push().then(res => {
return base.push().then((res) => {
result = res
})
})
Expand All @@ -87,7 +87,7 @@ describe('CI / Base', () => {
expect(Logger.log).toHaveBeenCalledWith('Pushing my-branch to my-origin')
})

it('should push origin to master with --tags', () => {
it('should push origin to my-branch with --tags', () => {
expect(exec).toHaveBeenCalledWith('git push my-origin my-branch --tags')
})

Expand All @@ -104,13 +104,13 @@ describe('CI / Base', () => {
ci: {
gitUser: {
email: 'ci-user@domain.com',
name: 'ci-user'
}
}
name: 'ci-user',
},
},
}

exec.mockReturnValue(Promise.resolve('executed'))
return base.setupGitEnv().then(res => {
return base.setupGitEnv().then((res) => {
result = res
})
})
Expand All @@ -133,7 +133,7 @@ describe('CI / Base', () => {

beforeEach(() => {
exec.mockReturnValue(Promise.resolve('tagged'))
return base.tag('v1.2.3', 'Super-cool tag description').then(res => {
return base.tag('v1.2.3', 'Super-cool tag description').then((res) => {
result = res
})
})
Expand Down
12 changes: 6 additions & 6 deletions src/ci/tests/travis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ describe('CI / Travis', () => {
config = {
computed: {
ci: {
branch: 'my-branch'
}
}
branch: 'my-branch',
},
},
}
travis = new Travis(config, {id: 'vcs'})
ctx.ci = travis
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('CI / Travis', () => {
jest.spyOn(travis.vcs, 'addRemoteForPush').mockReturnValue(Promise.resolve('ci-origin'))
exec.mockReturnValue(Promise.resolve('pushed'))

return travis.push().then(res => {
return travis.push().then((res) => {
result = res
})
})
Expand All @@ -60,7 +60,7 @@ describe('CI / Travis', () => {
expect(travis.vcs.addRemoteForPush).toHaveBeenCalledTimes(1)
})

it('should log that it is about to push my-master to the new remote', () => {
it('should log that it is about to push ci-my-branch to the new remote', () => {
expect(Logger.log).toHaveBeenCalledWith('Pushing ci-my-branch to ci-origin')
})

Expand All @@ -80,7 +80,7 @@ describe('CI / Travis', () => {
jest.spyOn(CiBase.prototype, 'setupGitEnv').mockReturnValue(Promise.resolve())
exec.mockReturnValue(Promise.resolve('checked-out'))

return travis.setupGitEnv().then(res => {
return travis.setupGitEnv().then((res) => {
result = res
})
})
Expand Down
69 changes: 35 additions & 34 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const DEPENDABOT_IDENTIFIER = '<summary>Dependabot commands and options</summary
* @param {Object} leaves - the simple key-value mapping of object path -> value
*/
function walkObject(prefix, object, leaves) {
Object.keys(object).forEach(key => {
Object.keys(object).forEach((key) => {
const value = object[key]
const fullPrefix = prefix ? `${prefix}.${key}` : key
if (isObject(value) && !isArray(value)) {
Expand Down Expand Up @@ -104,7 +104,7 @@ function processEnv(config) {
}

config.computed.ci.isPr = config.computed.ci.prNumber !== 'false'
config.computed.ci.branch = getEnv(config.ci.env.branch, 'master')
config.computed.ci.branch = getEnv(config.ci.env.branch, get(config.vcs.repository, 'defaultBranch', 'main'))

// Grab slack URL from env (if feature enabled)
if (config.features.slack.enabled) {
Expand All @@ -116,7 +116,7 @@ function processEnv(config) {
// Grab the VCS stuff from the env
config.computed.vcs.auth = {
readToken: getEnv(config.vcs.env.readToken),
writeToken: getEnv(config.vcs.env.writeToken)
writeToken: getEnv(config.vcs.env.writeToken),
}
/* eslint-enable no-param-reassign */
}
Expand All @@ -129,7 +129,7 @@ const utils = {
getConfig() {
return cosmiconfig('bumpr')
.search()
.then(result => {
.then((result) => {
let config = {}
if (result && result.config) {
config = result.config // eslint-disable-line prefer-destructuring
Expand All @@ -144,74 +144,74 @@ const utils = {
branch: 'TRAVIS_BRANCH',
buildNumber: 'TRAVIS_BUILD_NUMBER',
prNumber: 'TRAVIS_PULL_REQUEST',
prUrl: ''
prUrl: '',
},
gitUser: {
email: 'bumpr@domain.com',
name: 'Bumpr'
name: 'Bumpr',
},
provider: 'travis'
provider: 'travis',
},
// This is where we put everything we calculate/compute based on other settings (@job13er 2017-06-16)
computed: {
ci: {
buildNumber: '',
branch: '',
isPr: false,
prNumber: ''
prNumber: '',
},
vcs: {
auth: {
readToken: '',
writeToken: ''
}
}
writeToken: '',
},
},
},
features: {
changelog: {
enabled: false,
file: 'CHANGELOG.md'
file: 'CHANGELOG.md',
},
comments: {
enabled: false
enabled: false,
},
maxScope: {
enabled: false,
value: 'major'
value: 'major',
},
logging: {
enabled: false,
file: '.bumpr-log.json'
file: '.bumpr-log.json',
},
release: {
enabled: false,
artifacts: ''
artifacts: '',
},
slack: {
enabled: false,
env: {
url: 'SLACK_URL'
url: 'SLACK_URL',
},
channels: []
channels: [],
},
timezone: {
enabled: false,
zone: 'Etc/UTC'
}
zone: 'Etc/UTC',
},
},
files: ['package.json'],
vcs: {
domain: 'github.com',
env: {
readToken: 'GITHUB_READ_ONLY_TOKEN',
writeToken: 'GITHUB_TOKEN'
writeToken: 'GITHUB_TOKEN',
},
provider: 'github'
}
provider: 'github',
},
}

walkObject('', defaults, leaves)
Object.keys(leaves).forEach(key => {
Object.keys(leaves).forEach((key) => {
const value = leaves[key]
if (get(config, key) === undefined) {
set(config, key, value)
Expand Down Expand Up @@ -249,7 +249,7 @@ const utils = {
none: 1,
patch: 2,
minor: 3,
major: 4
major: 4,
}

const scopeWeight = scopeWeights[scope]
Expand Down Expand Up @@ -280,7 +280,7 @@ const utils = {
scope: 'patch',
maxScope,
prNumber: pr.number,
prUrl: pr.url
prUrl: pr.url,
})
}

Expand Down Expand Up @@ -313,7 +313,7 @@ const utils = {
scope: scope.toLowerCase(),
maxScope,
prNumber: pr.number,
prUrl: pr.url
prUrl: pr.url,
})
},

Expand All @@ -340,13 +340,14 @@ const utils = {

if (changelog.trim() === '') {
const link = 'https://github.com/all-i-code/bumpr#changelog'
const msg = 'No CHANGELOG content found in PR description.\n'
+ 'Please add a `## CHANGELOG` section to your PR description with some content describing your change.\n'
+ `See ${link} for details.`
const msg =
'No CHANGELOG content found in PR description.\n' +
'Please add a `## CHANGELOG` section to your PR description with some content describing your change.\n' +
`See ${link} for details.`
throw new Error(msg)
}

required.forEach(pattern => {
required.forEach((pattern) => {
if (!new RegExp(pattern).test(changelog)) {
throw new Error(`Changelog does not match pattern: ${pattern}`)
}
Expand All @@ -366,7 +367,7 @@ const utils = {
maybePostComment(config, vcs, msg, isError) {
if (!process.env.SKIP_COMMENTS && config.computed.ci.isPr && config.isEnabled('comments')) {
const comment = isError ? `## ERROR\n${msg}` : msg
return vcs.postComment(config.computed.ci.prNumber, comment).catch(err => {
return vcs.postComment(config.computed.ci.prNumber, comment).catch((err) => {
const newMessage = `Received error: ${err.message} while trying to post PR comment: ${comment}`
throw new Error(newMessage)
})
Expand All @@ -393,7 +394,7 @@ const utils = {
.then(() => {
throw e
})
.catch(err => {
.catch((err) => {
if (err !== e) {
const msg = `Received error: ${err.message} while trying to post PR comment about error: ${e.message}`
throw new Error(msg)
Expand All @@ -416,7 +417,7 @@ const utils = {
readJsonFile(filename) {
const fullPath = path.join(process.cwd(), filename)
return JSON.parse(fs.readFileSync(fullPath, {encoding: 'utf8'}))
}
},
}

module.exports = utils
Loading

0 comments on commit a247557

Please sign in to comment.