Skip to content

Commit 15c528e

Browse files
authored
chore: formatting (#224)
1 parent 5ad3073 commit 15c528e

16 files changed

+704
-429
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "eslint:recommended",
2+
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
33
"env": {
44
"node": true,
55
"es6": true

dist/index.js

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9690,7 +9690,12 @@ const toolkit = __nccwpck_require__(2183)
96909690
const packageInfo = __nccwpck_require__(4147)
96919691
const { githubClient } = __nccwpck_require__(3386)
96929692
const { logInfo, logWarning, logError } = __nccwpck_require__(653)
9693-
const { isValidSemver, isCommitHash, getInputs, getPackageName } = __nccwpck_require__(6254)
9693+
const {
9694+
isValidSemver,
9695+
isCommitHash,
9696+
getInputs,
9697+
getPackageName,
9698+
} = __nccwpck_require__(6254)
96949699
const { targetOptions } = __nccwpck_require__(5013)
96959700
const {
96969701
getModuleVersionChanges,
@@ -9742,7 +9747,9 @@ module.exports = async function run() {
97429747
}
97439748
}
97449749

9745-
const changedExcludedPackages = EXCLUDE_PKGS.filter((pkg) => pkg in moduleChanges)
9750+
const changedExcludedPackages = EXCLUDE_PKGS.filter(
9751+
pkg => pkg in moduleChanges
9752+
)
97469753
if (changedExcludedPackages.length > 0) {
97479754
return logInfo(`${changedExcludedPackages.length} package(s) excluded: \
97489755
${changedExcludedPackages.join(', ')}. Skipping.`)
@@ -9775,7 +9782,7 @@ function isAMajorReleaseBump(change) {
97759782
const from = change.delete
97769783
const to = change.insert
97779784

9778-
if (isCommitHash(from) && isCommitHash(to)) {
9785+
if (isCommitHash(from) && isCommitHash(to)) {
97799786
return false
97809787
}
97819788

@@ -9788,7 +9795,9 @@ function parsePrTitle(pullRequest) {
97889795
const match = expression.exec(pullRequest.title)
97899796

97909797
if (!match) {
9791-
throw new Error('Error while parsing PR title, expected: `bump <package> from <old-version> to <new-version>`')
9798+
throw new Error(
9799+
'Error while parsing PR title, expected: `bump <package> from <old-version> to <new-version>`'
9800+
)
97929801
}
97939802

97949803
const packageName = getPackageName(pullRequest.head.ref)
@@ -9799,8 +9808,8 @@ function parsePrTitle(pullRequest) {
97999808
return {
98009809
[packageName]: {
98019810
delete: isValid ? semverCoerce(oldVersion)?.raw : oldVersion,
9802-
insert: isValid ? semverCoerce(newVersion)?.raw : newVersion
9803-
}
9811+
insert: isValid ? semverCoerce(newVersion)?.raw : newVersion,
9812+
},
98049813
}
98059814
}
98069815

@@ -9821,7 +9830,7 @@ const targetOptions = {
98219830
patch: 'patch',
98229831
prepatch: 'prepatch',
98239832
prerelease: 'prerelease',
9824-
any: 'any'
9833+
any: 'any',
98259834
}
98269835

98279836
const semanticVersionOrder = [
@@ -9832,7 +9841,7 @@ const semanticVersionOrder = [
98329841
targetOptions.minor,
98339842
targetOptions.premajor,
98349843
targetOptions.major,
9835-
targetOptions.any
9844+
targetOptions.any,
98369845
]
98379846

98389847
const getTargetInput = input => {
@@ -9876,7 +9885,7 @@ function githubClient(githubToken) {
98769885
repo: repoName,
98779886
pull_number: pullRequestNumber,
98789887
event: 'APPROVE',
9879-
body: approveComment
9888+
body: approveComment,
98809889
})
98819890
// todo assert
98829891
return data
@@ -9920,10 +9929,10 @@ module.exports = { githubClient }
99209929

99219930
const { debug, error, info, warning } = __nccwpck_require__(2186)
99229931

9923-
const stringify = (msg) =>
9932+
const stringify = msg =>
99249933
typeof msg === 'string' ? msg : msg.stack || msg.toString()
99259934

9926-
const log = (logger) => (message) => logger(stringify(message))
9935+
const log = logger => message => logger(stringify(message))
99279936

99289937
exports.logDebug = log(debug)
99299938
exports.logError = log(error)
@@ -9962,7 +9971,9 @@ const checkModuleVersionChanges = (moduleChanges, target) => {
99629971
}
99639972

99649973
if (!isValidSemver(from) || !isValidSemver(to)) {
9965-
throw new Error(`Module "${module}" contains invalid semver versions from: ${from} to: ${to}`)
9974+
throw new Error(
9975+
`Module "${module}" contains invalid semver versions from: ${from} to: ${to}`
9976+
)
99669977
}
99679978

99689979
const diff = semverDiff(semverCoerce(from), semverCoerce(to))
@@ -9977,17 +9988,19 @@ const checkModuleVersionChanges = (moduleChanges, target) => {
99779988
return true
99789989
}
99799990

9980-
const getModuleVersionChanges = (prDiff) => {
9991+
const getModuleVersionChanges = prDiff => {
99819992
const parsedDiffFiles = parse(prDiff)
9982-
const packageJsonChanges = parsedDiffFiles.find((file) => file.newPath === 'package.json')
9993+
const packageJsonChanges = parsedDiffFiles.find(
9994+
file => file.newPath === 'package.json'
9995+
)
99839996
if (!packageJsonChanges) {
99849997
return false
99859998
}
99869999

998710000
const moduleChanges = {}
998810001
for (const idx in packageJsonChanges.hunks) {
998910002
const changes = packageJsonChanges.hunks[idx].changes.filter(
9990-
(c) => c.type === 'delete' || c.type === 'insert'
10003+
c => c.type === 'delete' || c.type === 'insert'
999110004
)
999210005

999310006
for (const changeIdx in changes) {
@@ -10050,8 +10063,8 @@ const getMergeMethod = () => {
1005010063
return mergeMethods[input]
1005110064
}
1005210065

10053-
const parseCommaSeparatedValue = (value) => {
10054-
return value ? value.split(',').map(el => el.trim()) : [];
10066+
const parseCommaSeparatedValue = value => {
10067+
return value ? value.split(',').map(el => el.trim()) : []
1005510068
}
1005610069

1005710070
exports.getInputs = () => ({
@@ -10071,7 +10084,7 @@ exports.getInputs = () => ({
1007110084
* @param {String} branchName
1007210085
* @returns Package name extracted from branch
1007310086
*/
10074-
exports.getPackageName = (branchName) => {
10087+
exports.getPackageName = branchName => {
1007510088
const nameWithVersion = branchName.split('/').pop().split('-')
1007610089
const version = nameWithVersion.pop()
1007710090
const packageName = nameWithVersion.join('-')
@@ -10090,7 +10103,7 @@ exports.getPackageName = (branchName) => {
1009010103
* @param {String} version
1009110104
* @returns Boolean indicating whether version
1009210105
*/
10093-
exports.isCommitHash = function(version) {
10106+
exports.isCommitHash = function (version) {
1009410107
return /^[a-f0-9]{5,40}$/.test(version)
1009510108
}
1009610109

@@ -10246,7 +10259,7 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
1024610259
/***/ ((module) => {
1024710260

1024810261
"use strict";
10249-
module.exports = JSON.parse('{"name":"github-action-merge-dependabot","version":"3.1.7","description":"A GitHub action to automatically merge and approve Dependabot pull requests","main":"src/index.js","scripts":{"build":"ncc build src/index.js","lint":"eslint .","test":"tap test/**.test.js","prepare":"husky install"},"author":{"name":"Salman Mitha","email":"[email protected]"},"contributors":["Simone Busoli <[email protected]>"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/fastify/github-action-merge-dependabot.git"},"bugs":{"url":"https://github.com/fastify/github-action-merge-dependabot/issues"},"homepage":"https://github.com/fastify/github-action-merge-dependabot#readme","dependencies":{"@actions/core":"^1.8.2","@actions/github":"^5.0.3","actions-toolkit":"github:nearform/actions-toolkit","gitdiff-parser":"^0.2.2","semver":"^7.3.7"},"devDependencies":{"@vercel/ncc":"^0.33.4","eslint":"^8.16.0","husky":"^8.0.1","prettier":"^2.6.2","proxyquire":"^2.1.3","sinon":"^14.0.0","tap":"^16.2.0"}}');
10262+
module.exports = JSON.parse('{"name":"github-action-merge-dependabot","version":"3.1.7","description":"A GitHub action to automatically merge and approve Dependabot pull requests","main":"src/index.js","scripts":{"build":"ncc build src/index.js","lint":"eslint .","test":"tap test/**.test.js","prepare":"husky install"},"author":{"name":"Salman Mitha","email":"[email protected]"},"contributors":["Simone Busoli <[email protected]>"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/fastify/github-action-merge-dependabot.git"},"bugs":{"url":"https://github.com/fastify/github-action-merge-dependabot/issues"},"homepage":"https://github.com/fastify/github-action-merge-dependabot#readme","dependencies":{"@actions/core":"^1.8.2","@actions/github":"^5.0.3","actions-toolkit":"github:nearform/actions-toolkit","gitdiff-parser":"^0.2.2","semver":"^7.3.7"},"devDependencies":{"@vercel/ncc":"^0.33.4","eslint":"^8.16.0","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","husky":"^8.0.1","prettier":"^2.6.2","proxyquire":"^2.1.3","sinon":"^14.0.0","tap":"^16.2.0"}}');
1025010263

1025110264
/***/ })
1025210265

package-lock.json

Lines changed: 85 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"devDependencies": {
3636
"@vercel/ncc": "^0.33.4",
3737
"eslint": "^8.16.0",
38+
"eslint-config-prettier": "^8.5.0",
39+
"eslint-plugin-prettier": "^4.0.0",
3840
"husky": "^8.0.1",
3941
"prettier": "^2.6.2",
4042
"proxyquire": "^2.1.3",

src/action.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ const toolkit = require('actions-toolkit')
99
const packageInfo = require('../package.json')
1010
const { githubClient } = require('./github-client')
1111
const { logInfo, logWarning, logError } = require('./log')
12-
const { isValidSemver, isCommitHash, getInputs, getPackageName } = require('./util')
12+
const {
13+
isValidSemver,
14+
isCommitHash,
15+
getInputs,
16+
getPackageName,
17+
} = require('./util')
1318
const { targetOptions } = require('./getTargetInput')
1419
const {
1520
getModuleVersionChanges,
@@ -61,7 +66,9 @@ module.exports = async function run() {
6166
}
6267
}
6368

64-
const changedExcludedPackages = EXCLUDE_PKGS.filter((pkg) => pkg in moduleChanges)
69+
const changedExcludedPackages = EXCLUDE_PKGS.filter(
70+
pkg => pkg in moduleChanges
71+
)
6572
if (changedExcludedPackages.length > 0) {
6673
return logInfo(`${changedExcludedPackages.length} package(s) excluded: \
6774
${changedExcludedPackages.join(', ')}. Skipping.`)
@@ -94,7 +101,7 @@ function isAMajorReleaseBump(change) {
94101
const from = change.delete
95102
const to = change.insert
96103

97-
if (isCommitHash(from) && isCommitHash(to)) {
104+
if (isCommitHash(from) && isCommitHash(to)) {
98105
return false
99106
}
100107

@@ -107,7 +114,9 @@ function parsePrTitle(pullRequest) {
107114
const match = expression.exec(pullRequest.title)
108115

109116
if (!match) {
110-
throw new Error('Error while parsing PR title, expected: `bump <package> from <old-version> to <new-version>`')
117+
throw new Error(
118+
'Error while parsing PR title, expected: `bump <package> from <old-version> to <new-version>`'
119+
)
111120
}
112121

113122
const packageName = getPackageName(pullRequest.head.ref)
@@ -118,7 +127,7 @@ function parsePrTitle(pullRequest) {
118127
return {
119128
[packageName]: {
120129
delete: isValid ? semverCoerce(oldVersion)?.raw : oldVersion,
121-
insert: isValid ? semverCoerce(newVersion)?.raw : newVersion
122-
}
130+
insert: isValid ? semverCoerce(newVersion)?.raw : newVersion,
131+
},
123132
}
124133
}

src/getTargetInput.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const targetOptions = {
88
patch: 'patch',
99
prepatch: 'prepatch',
1010
prerelease: 'prerelease',
11-
any: 'any'
11+
any: 'any',
1212
}
1313

1414
const semanticVersionOrder = [
@@ -19,7 +19,7 @@ const semanticVersionOrder = [
1919
targetOptions.minor,
2020
targetOptions.premajor,
2121
targetOptions.major,
22-
targetOptions.any
22+
targetOptions.any,
2323
]
2424

2525
const getTargetInput = input => {

0 commit comments

Comments
 (0)