Skip to content

Commit

Permalink
feat: remove jest for vitest (#45)
Browse files Browse the repository at this point in the history
- updated packages
- update ci
- added in pr lint check

BREAKING CHANGE:

- node 20
  • Loading branch information
Bugs5382 committed Feb 4, 2024
2 parents 70b1f43 + b12c09e commit f1afd46
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 58 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
@@ -1,3 +1,2 @@
/__tests__/**/*
/template/**/**
jest.config.ts
/template/**/**
15 changes: 15 additions & 0 deletions .github/pr-title-checker-config.json
@@ -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)!?(\\(.*\\))?!?:.*"
}
}
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Expand Up @@ -12,11 +12,11 @@ jobs:
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: NPM Install
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/pr-title-check.yml
@@ -0,0 +1,29 @@
name: "Lint PR"

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@0cf5902181e78341bb97bb06646396e5bd354b3f # v1.4.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
configuration_path: ".github/pr-title-checker-config.json"
11 changes: 0 additions & 11 deletions jest.config.ts

This file was deleted.

14 changes: 5 additions & 9 deletions package.json
Expand Up @@ -12,7 +12,7 @@
"template/"
],
"engines": {
"node": "^20"
"node": ">=20.0.0"
},
"scripts": {
"clean": "rm -rf coverage docs dist",
Expand All @@ -33,7 +33,7 @@
"semantic-release:dry-run": "semantic-release --dry-run",
"typedoc": "typedoc",
"typedoc:watch": "typedoc -watch",
"update": "npx npm-check-updates -u && npm run update:post-update",
"update": "npx npm-check-updates -u --enginesNode && npm run update:post-update",
"update:post-update": "npm install"
},
"repository": {
Expand Down Expand Up @@ -67,29 +67,25 @@
"@types/cli-progress": "^3.11.5",
"@types/inquirer": "^9.0.7",
"@types/inquirer-npm-name": "^3.0.7",
"@types/jest": "^29.5.11",
"@types/lodash": "^4.14.202",
"@types/node": "^20.11.2",
"@types/yargs": "^17.0.32",
"jest": "^29.7.0",
"jest-ts-webcompat-resolver": "^1.0.0",
"npm-package-json-lint": "^7.1.0",
"precommit": "^1.2.2",
"semantic-release": "^23.0.0",
"snazzy": "^9.0.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"ts-standard": "^12.0.2",
"tsd": "^0.30.3",
"tsd": "^0.30.4",
"typedoc": "^0.25.7",
"typescript": "^5.3.3"
},
"dependencies": {
"cli-progress": "^3.12.0",
"execa": "^8.0.1",
"inquirer": "^9.2.12",
"inquirer": "^9.2.14",
"inquirer-npm-name": "^4.0.0",
"listr2": "^8.0.1",
"listr2": "^8.0.2",
"lodash": "^4.17.21",
"pino": "^8.17.2",
"pino-pretty": "^10.3.1",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -38,7 +38,7 @@ export const main = async (): Promise<void> => {
choices: [
{ name: 'Github', value: 'github' },
{ name: 'Private Repo', value: 'private-repo' },
{ name: 'Skip Git', value: 'skip-git' },
{ name: 'Skip Git', value: 'skip-git' }
],
default: 0,
name: 'gitLocation',
Expand Down
7 changes: 3 additions & 4 deletions src/modules/constants.ts
Expand Up @@ -105,10 +105,9 @@ export const NPM_PACKAGE: Dependencies = {
dependencies: [],
devDependencies: [
...sharedDev,
'ts-jest',
'@types/jest',
'jest',
'jest-ts-webcompat-resolver'
'@vitest/coverage-v8',
'@vitest/ui',
'vitest'
]
}

Expand Down
15 changes: 7 additions & 8 deletions src/modules/npm.ts
Expand Up @@ -69,17 +69,16 @@ export const generatePackageJson = (params: GeneratePackageJsonParams, input: Ge
...sharedScripts,
pack: 'npm pack',
prepublishOnly: 'npm run clean && npm run build && npm run pack',
test: 'jest',
'test:open': 'jest --detectOpenHandles',
'test:watch': 'jest --watch',
'test:ci': 'jest --ci',
'test:coverage': 'jest --coverage',
test: 'vitest run',
'test:verbose': 'vitest run --reporter verbose',
'test:watch': 'vitest watch',
'test:coverage': 'vitest --coverage',
typedoc: 'typedoc',
'typedoc:watch': 'typedoc -watch',
'semantic-release': 'semantic-release',
'semantic-release:dry-run': 'semantic-release --dry-run',
update: 'npx npm-check-updates -u && npm run update:post-update',
'update:post-update': 'npm install && npm run test:ci'
update: 'npx npm-check-updates -u --enginesNode && npm run update:post-update',
'update:post-update': 'npm install && npm run test'
}
}
break
Expand Down Expand Up @@ -118,7 +117,7 @@ export const generatePackageJson = (params: GeneratePackageJsonParams, input: Ge
version: '0.0.0-development',
description: params.description,
engines: {
node: '^20'
node: '>=20.0.0'
},
...finalPackage,
repository: {
Expand Down
15 changes: 15 additions & 0 deletions template/__shared__/.github/pr-title-checker-config.json
@@ -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)!?(\\(.*\\))?!?:.*"
}
}
29 changes: 29 additions & 0 deletions template/__shared__/.github/workflows/pr-title-check.yml
@@ -0,0 +1,29 @@
name: "Lint PR"

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@0cf5902181e78341bb97bb06646396e5bd354b3f # v1.4.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
configuration_path: ".github/pr-title-checker-config.json"
1 change: 1 addition & 0 deletions template/__shared__/.npmpackagejsonlintrc.json
Expand Up @@ -32,6 +32,7 @@
"<%- author %>"
]],
"valid-values-private": ["error", [
true,
false
]],
"no-restricted-dependencies": ["error", [
Expand Down
12 changes: 6 additions & 6 deletions template/__shared__npm__/.github/workflows/ci.yaml
Expand Up @@ -13,19 +13,19 @@ jobs:
id-token: write
strategy:
matrix:
node-version: [ 18.x, 20.x, 'lts/*' ]
node-version: [ 20.x, 'lts/*' ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm install --ignore-scripts
- name: Run Unit Tests
run: npm run test:ci
run: npm run test
Release:
runs-on: ubuntu-latest
needs: [ 'Test' ]
Expand All @@ -35,11 +35,11 @@ jobs:
pull-requests: write
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: NPM Install
Expand Down
13 changes: 0 additions & 13 deletions template/__shared__npm__/jest.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion template/__shared__npm__/tsconfig.build.json
Expand Up @@ -4,7 +4,7 @@
"./src/**/*.ts"
],
"exclude": [
"./jest.config.ts",
"./vitest.config.mts",
"./release.config.{cjs|js}"
]
}
16 changes: 16 additions & 0 deletions template/__shared__npm__/vitest.config.mts
@@ -0,0 +1,16 @@
// @ts-nocheck
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
coverage: {
exclude: [
'__tests__/__utils__/**',
'bin',
'docs',
'lib',
'release.config.cjs'
]
}
}
})
1 change: 0 additions & 1 deletion template/npm-fastify-plugin/src/types.ts
@@ -1,5 +1,4 @@
// @ts-nocheck

declare module 'fastify' {
export interface FastifyInstance {
/** Main Decorator for Fastify **/
Expand Down

0 comments on commit f1afd46

Please sign in to comment.