Skip to content

Commit

Permalink
chore: migrate to neostandard (#677)
Browse files Browse the repository at this point in the history
* chore: migrate to neostandard

* use node v20
  • Loading branch information
Uzlopak authored Jan 6, 2025
1 parent c8cb7e7 commit ee2d704
Show file tree
Hide file tree
Showing 16 changed files with 4,984 additions and 789 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

15 changes: 0 additions & 15 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
v20
50 changes: 25 additions & 25 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3607,15 +3607,15 @@ const { dependabotAuthor } = __nccwpck_require__(138)
const { updateTypes } = __nccwpck_require__(539)
const { updateTypesPriority } = __nccwpck_require__(539)

module.exports = async function run({
module.exports = async function run ({
github,
context,
inputs,
dependabotMetadata,
}) {
const { updateType } = dependabotMetadata
const dependencyNames = parseCommaOrSemicolonSeparatedValue(
dependabotMetadata.dependencyNames,
dependabotMetadata.dependencyNames
)

const {
Expand All @@ -3636,16 +3636,16 @@ module.exports = async function run({
try {
toolkit.logActionRefWarning()

const { pull_request } = context.payload
if (!pull_request && !PR_NUMBER) {
const PULLREQUEST = context.payload.pull_request
if (!PULLREQUEST && !PR_NUMBER) {
core.setOutput(MERGE_STATUS_KEY, MERGE_STATUS.skippedNotADependabotPr)
return logError(
'This action must be used in the context of a Pull Request or with a Pull Request number',
'This action must be used in the context of a Pull Request or with a Pull Request number'
)
}

const client = githubClient(github, context)
const pr = pull_request || (await client.getPullRequest(PR_NUMBER))
const pr = PULLREQUEST || (await client.getPullRequest(PR_NUMBER))

const isDependabotPR = pr.user.login === dependabotAuthor
if (!SKIP_VERIFICATION && !isDependabotPR) {
Expand All @@ -3668,17 +3668,17 @@ module.exports = async function run({
} catch {
core.setOutput(
MERGE_STATUS_KEY,
MERGE_STATUS.skippedCommitVerificationFailed,
MERGE_STATUS.skippedCommitVerificationFailed
)
return logWarning(
'PR contains invalid dependabot commit signatures, skipping.',
'PR contains invalid dependabot commit signatures, skipping.'
)
}
}

const target = getTarget(
{ TARGET, TARGET_DEV, TARGET_PROD, TARGET_INDIRECT },
dependabotMetadata,
dependabotMetadata
)

if (
Expand All @@ -3702,7 +3702,7 @@ Tried to do a '${updateType}' update but the max allowed is '${target}'`)
}

const changedExcludedPackages = EXCLUDE_PKGS.filter(
pkg => dependencyNames.indexOf(pkg) > -1,
pkg => dependencyNames.indexOf(pkg) > -1
)

// TODO: Improve error message for excluded packages?
Expand All @@ -3729,7 +3729,7 @@ ${changedExcludedPackages.join(', ')}. Skipping.`)
if (APPROVE_ONLY) {
core.setOutput(MERGE_STATUS_KEY, MERGE_STATUS.approved)
return logInfo(
'APPROVE_ONLY set, PR was approved but it will not be merged',
'APPROVE_ONLY set, PR was approved but it will not be merged'
)
}

Expand Down Expand Up @@ -3774,15 +3774,15 @@ module.exports = {
"use strict";


function githubClient(github, context) {
function githubClient (github, context) {
const payload = context.payload

const repo = payload.repository
const owner = repo.owner.login
const repoName = repo.name

return {
async getPullRequest(pullRequestNumber) {
async getPullRequest (pullRequestNumber) {
const { data: pullRequest } = await github.rest.pulls.get({
owner,
repo: repoName,
Expand All @@ -3791,7 +3791,7 @@ function githubClient(github, context) {
return pullRequest
},

async approvePullRequest(pullRequestNumber, approveComment) {
async approvePullRequest (pullRequestNumber, approveComment) {
const { data } = await github.rest.pulls.createReview({
owner,
repo: repoName,
Expand All @@ -3803,7 +3803,7 @@ function githubClient(github, context) {
return data
},

async mergePullRequest(pullRequestNumber, mergeMethod) {
async mergePullRequest (pullRequestNumber, mergeMethod) {
const { data } = await github.rest.pulls.merge({
owner,
repo: repoName,
Expand All @@ -3814,7 +3814,7 @@ function githubClient(github, context) {
return data
},

async enableAutoMergePullRequest(pullRequestId, mergeMethod) {
async enableAutoMergePullRequest (pullRequestId, mergeMethod) {
const query = `
mutation ($pullRequestId: ID!, $mergeMethod: PullRequestMergeMethod!) {
enablePullRequestAutoMerge(
Expand All @@ -3838,7 +3838,7 @@ mutation ($pullRequestId: ID!, $mergeMethod: PullRequestMergeMethod!) {
return data
},

async getPullRequestDiff(pullRequestNumber) {
async getPullRequestDiff (pullRequestNumber) {
const { data: pullRequest } = await github.rest.pulls.get({
owner,
repo: repoName,
Expand All @@ -3850,7 +3850,7 @@ mutation ($pullRequestId: ID!, $mergeMethod: PullRequestMergeMethod!) {
return pullRequest
},

async getPullRequestCommits(pullRequestNumber) {
async getPullRequestCommits (pullRequestNumber) {
const { data } = await github.rest.pulls.listCommits({
owner,
repo: repoName,
Expand Down Expand Up @@ -3959,7 +3959,7 @@ const getMergeMethod = inputs => {

if (!mergeMethods[input]) {
logWarning(
'merge-method input is ignored because it is malformed, defaulting to `squash`.',
'merge-method input is ignored because it is malformed, defaulting to `squash`.'
)
return mergeMethods.squash
}
Expand Down Expand Up @@ -4001,7 +4001,7 @@ exports.getInputs = inputs => {

exports.getTarget = (
{ TARGET, TARGET_DEV, TARGET_PROD, TARGET_INDIRECT },
{ dependencyType },
{ dependencyType }
) => {
if (dependencyType === 'direct:development' && TARGET_DEV) {
return TARGET_DEV
Expand Down Expand Up @@ -4044,7 +4044,7 @@ const {
dependabotCommitter,
} = __nccwpck_require__(138)

function verifyCommits(commits) {
function verifyCommits (commits) {
commits.forEach(function (commit) {
const {
commit: {
Expand All @@ -4058,19 +4058,19 @@ function verifyCommits(commits) {
})
}

function verifyCommitSignatureCommitterAndAuthor(
function verifyCommitSignatureCommitterAndAuthor (
sha,
author,
committer,
verified,
verified
) {
if (
!verified ||
committer.name !== dependabotCommitter ||
author.name !== dependabotAuthor
) {
throw new Error(
`Signature for commit ${sha} could not be verified - Not a dependabot commit`,
`Signature for commit ${sha} could not be verified - Not a dependabot commit`
)
}
}
Expand All @@ -4087,7 +4087,7 @@ module.exports = {
/***/ ((module) => {

"use strict";
module.exports = /*#__PURE__*/JSON.parse('{"name":"github-action-merge-dependabot","version":"3.11.0","description":"A GitHub action to automatically merge and approve Dependabot pull requests","main":"src/index.js","type":"commonjs","scripts":{"build":"ncc build src/index.js","lint":"eslint .","lint:fix":"eslint . --fix","test":"tap","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.11.1","actions-toolkit":"github:nearform/actions-toolkit"},"devDependencies":{"@vercel/ncc":"^0.38.2","eslint":"^8.57.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.1","husky":"^9.1.6","prettier":"^3.3.3","proxyquire":"^2.1.3","sinon":"^19.0.2","tap":"^21.0.1"}}');
module.exports = /*#__PURE__*/JSON.parse('{"name":"github-action-merge-dependabot","version":"3.11.0","description":"A GitHub action to automatically merge and approve Dependabot pull requests","main":"src/index.js","type":"commonjs","scripts":{"build":"ncc build src/index.js","lint":"eslint .","lint:fix":"eslint . --fix","test":"tap","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.11.1","actions-toolkit":"github:nearform/actions-toolkit"},"devDependencies":{"@vercel/ncc":"^0.38.3","eslint":"^9.17.0","husky":"^9.1.7","neostandard":"^0.12.0","prettier":"^3.4.2","proxyquire":"^2.1.3","sinon":"^19.0.2","tap":"^21.0.1"}}');

/***/ })

Expand Down
7 changes: 7 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

module.exports = require('neostandard')({
semi: false,
ignores: ['dist', 'node_modules'],
env: ['es2015', 'node'],
})
Loading

0 comments on commit ee2d704

Please sign in to comment.