Skip to content

Commit

Permalink
feat: lots of updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Bugs5382 committed Jun 25, 2024
1 parent 60de797 commit e57d1b0
Show file tree
Hide file tree
Showing 21 changed files with 287 additions and 88 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
jest.config.ts
/__tests__/*
vitest.config.ts
release.config.cjs
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug Report
about: Report a bug
labels: bug
---

## Search terms

<!-- Include keywords that might help others with the same problem find this issue -->

## Environment

- Fastify plugin version:
- TypeScript version:
- Node.js version:
- OS:

## Expected Behavior

<!-- How did you expect your code to work? -->

## Actual Behavior

<!-- What does this plugin fail to do? -->

## Steps to reproduce the bug

11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Question
about: Ask a question
labels: question
---

## Search terms

<!-- Include keywords that might help others with the same question find this issue -->

## Question
15 changes: 15 additions & 0 deletions .github/pr-title-checker-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"LABEL": {
"name": "title needs formatting",
"color": "EEEEEE"
},
"CHECKS": {
"prefixes": ["[Bot] docs: "],
"regexp": "^(feat|fix|docs|test|ci|chore)!?(\\(.*\\))?!?:.*"
},
"MESSAGES": {
"success": "PR title is valid",
"failure": "PR title is invalid",
"notice": "PR Title needs to pass regex '^(feat|fix|docs|test|ci|chore)!?(\\(.*\\))?!?:.*"
}
}
52 changes: 52 additions & 0 deletions .github/workflows/dependabot-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Dependabot Auto-Merge

on:
pull_request_target:
types: [review_requested]

permissions:
contents: write
pull-requests: write
packages: read

jobs:
Dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.3.4
with:
github-token: "${{ secrets.GH_TOKEN }}"
skip-commit-verification: true
- name: Checkout repository
uses: actions/checkout@v4
- name: Approve PR, if not already approved
run: |
gh pr checkout "$PR_URL"
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ]; then
gh pr review --approve "$PR_URL"
else
echo "PR Already Approved.";
fi
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Run unit tests
run: |
npm test
- name: Aggregate Dependabot PRs
id: aggregate_prs
run: |
PR_URL=$(gh pr list --json state:open author:dependabot[bot] base:$PR_BASE_BRANCH -q '.[].url' | jq -r 'join(" ")')
echo "::set-output name=pr_url::$PR_URL"
env:
PR_BASE_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Merge aggregated PRs
if: steps.aggregate_prs.outputs.pr_url != ''
run: |
gh pr merge --auto --merge ${{ steps.aggregate_prs.outputs.pr_url }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
43 changes: 32 additions & 11 deletions .github/workflows/ci.yaml → .github/workflows/deploy-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
name: GitHub CI
name: "Deploy: CI"
on:
push:
branches: [ 'main' ]

permissions:
contents: write
issues: write
pull-requests: write
id-token: write

jobs:
Test:
runs-on: ubuntu-latest
Expand All @@ -11,11 +17,6 @@ jobs:
image: rabbitmq:3-alpine
ports:
- 5672:5672
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
strategy:
matrix:
node-version: [ 20.x, 'lts/*' ]
Expand All @@ -29,16 +30,13 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm install --ignore-scripts
- name: Run Lint Fix
run: npm run lint:fix
- name: Run Unit Tests
run: npm run test
Release:
runs-on: ubuntu-latest
needs: [ 'Test' ]
permissions:
contents: write
issues: write
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -59,3 +57,26 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Docs:
runs-on: ubuntu-latest
needs: [ 'Release' ]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: NPM Install
run: npm install --ignore-scripts
- name: Generate Typedoc documentation
run: npm run typedoc
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GH_TOKEN }}
publish_dir: ./docs
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
29 changes: 29 additions & 0 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "PR: Lint Title"

on:
pull_request_target:
types: [opened, edited, reopened, synchronize]

# IMPORTANT: No checkout actions, scripts, or builds should be added to this workflow. Permissions should always be used
# with extreme caution. https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
permissions: {}

# PR updates can happen in quick succession, leading to this
# workflow being trigger a number of times. This limits it
# to one run per PR.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}


jobs:
Validate:
permissions:
contents: read
pull-requests: read
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- uses: thehanimo/pr-title-checker@v1.4.2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
configuration_path: ".github/pr-title-checker-config.json"
34 changes: 34 additions & 0 deletions .github/workflows/pr-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "PR: Unit Tests"

on:
pull_request:
branches:
- main
types:
- opened
- synchronize

jobs:
Test:
name: Run Unit tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.x, 'lts/*' ]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm install --ignore-scripts
- name: Run Lint Fix
run: npm run lint:fix
- name: Run Unit Tests
run: npm run test
- name: Check test results
run: exit ${{ steps.Test.outputs.test_result }}
id: check_test_result
15 changes: 10 additions & 5 deletions __tests__/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"extends": "../tsconfig.json",
"extends": "../tsconfig.base.json",
"compilerOptions": {
"noEmit": true,
"typeRoots": ["../node_modules/@types", "../@types"]
"rootDir": ".",
},
"include": ["./**/*"]
}
"references": [
{ "path": "../src/" }
],
"include": [
"./**/*",
"../src"
]
}
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"node": ">=20.0.0"
},
"scripts": {
"clean": "rm -rf lib coverage",
"build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json && ./bin/build-types.sh",
"build:watch": "tsc -p tsconfig.esm.json -w",
"clean": "rm -rf lib docs coverage",
"build": "tsc -p src/tsconfig.esm.json && tsc -p src/tsconfig.cjs.json && tsc -p src/tsconfig.types.json && ./bin/build-types.sh",
"build:watch": "tsc -p src/tsconfig.esm.json -w",
"npmPkgJsonLint": "npmPkgJsonLint .",
"lint": "npmPkgJsonLint . && ts-standard | snazzy",
"lint:fix": "npmPkgJsonLint . && ts-standard --fix | snazzy",
"lint": "npmPkgJsonLint . && ts-standard -p src/tsconfig.esm.json | snazzy",
"lint:fix": "npmPkgJsonLint . && ts-standard -p src/tsconfig.esm.json --fix | snazzy",
"pack": "npm pack",
"prepublishOnly": "npm run clean && npm run build && npm run pack",
"test": "vitest run",
Expand Down Expand Up @@ -57,31 +57,31 @@
},
"homepage": "https://github.com/Bugs5382/fastify-rabbitmq#readme",
"dependencies": {
"@fastify/error": "^3.4.1",
"@fastify/error": "^4.0.0",
"fastify-plugin": "^4.5.1",
"rabbitmq-client": "^4.5.1"
"rabbitmq-client": "^4.6.0"
},
"devDependencies": {
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@the-rabbit-hole/semantic-release-config": "^1.5.0",
"@types/node": "^20.11.24",
"@types/randomstring": "^1.1.12",
"@typescript-eslint/parser": "^7.1.0",
"@vitest/coverage-v8": "^1.3.1",
"@vitest/ui": "^1.3.1",
"fastify": "^4.26.1",
"npm-check-updates": "^16.14.15",
"npm-package-json-lint": "^7.1.0",
"@types/node": "^20.14.8",
"@types/randomstring": "^1.3.0",
"@typescript-eslint/parser": "^7.14.1",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/ui": "^1.6.0",
"fastify": "^4.28.0",
"npm-check-updates": "^16.14.20",
"npm-package-json-lint": "^8.0.0",
"pre-commit": "^1.2.2",
"semantic-release": "^23.0.2",
"snazzy": "^9.0.0",
"ts-node": "^10.9.2",
"ts-standard": "^12.0.2",
"tsd": "^0.31.0",
"typedoc": "^0.25.9",
"typescript": "^5.3.3",
"vitest": "^1.3.1"
"tsd": "^0.31.1",
"typedoc": "^0.26.2",
"typescript": "^5.5.2",
"vitest": "^1.6.0"
},
"precommit": [
"test",
Expand Down
10 changes: 10 additions & 0 deletions src/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig.base.json",
"include": [
"**/*.ts"
],
"exclude": [
"./vitest.config.ts",
"./release.config.{cjs|js}"
]
}
6 changes: 3 additions & 3 deletions tsconfig.cjs.json → src/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"declaration": false,
"sourceMap": false,
"module": "commonjs",
"outDir": "./lib/cjs"
"outDir": "../lib/cjs",
"declaration": false,
"sourceMap": false
}
}
9 changes: 9 additions & 0 deletions src/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"module": "ESNext",
"outDir": "../lib/esm",
"declaration": true,
"sourceMap": false
}
}
9 changes: 9 additions & 0 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "../dist",
"rootDir": ".",
},
"include": ["**/*.ts"],
"exclude": ["node_modules"]
}
3 changes: 2 additions & 1 deletion tsconfig.types.json → src/tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./lib/types"
"outDir": "../lib/types",
"sourceMap": false
}
}
Loading

0 comments on commit e57d1b0

Please sign in to comment.