Skip to content

Commit

Permalink
test: node generate
Browse files Browse the repository at this point in the history
  • Loading branch information
yanquanfahei committed Mar 9, 2023
1 parent d554433 commit f91fcea
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 11 deletions.
22 changes: 22 additions & 0 deletions test/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-node@v3
with:
node-version: 16.x

- run: npx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 2 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
16 changes: 16 additions & 0 deletions test/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"eslint.enable": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"markdown",
"json",
"jsonc",
"json5"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
1 change: 1 addition & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# test
5 changes: 1 addition & 4 deletions test/unbuild.config.ts → test/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ export default defineBuildConfig({
entries: ['src/index'],
clean: true,
rollup: {
inlineDependencies: true,
esbuild: {
minify: true
}
emitCJS: true
}
})
46 changes: 39 additions & 7 deletions test/package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,65 @@
{
"name": "test",
"type": "module",
"version": "1.0.0",
"version": "0.0.0",
"packageManager": "[email protected]",
"description": "",
"author": "",
"author": {
"name": "眼圈发黑",
"email": "[email protected]"
},
"license": "MIT",
"homepage": "https://github.com/yanquanfahei/test#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/yanquanfahei/test.git"
},
"bugs": "https://github.com/yanquanfahei/test/issues",
"keywords": [],
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
}
},
"main": "index.js",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
"dist",
"package.json",
"README.md"
],
"engines": {
"node": ">=16.11.0"
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"postinstall": "simple-git-hooks",
"dev": "unbuild --stub",
"build": "unbuild",
"typecheck": "tsc --noEmit",
"lint": "eslint --fix ."
"lint": "eslint --fix",
"prepublishOnly": "pnpm build",
"release": "bumpp package.json --commit --push --tag && pnpm publish --access public"
},
"devDependencies": {
"@eye-socket/eslint-config-ts": "^0.0.2",
"@types/node": "^18.13.0",
"bumpp": "^9.0.0",
"chalk": "^5.2.0",
"eslint": "^8.34.0",
"lint-staged": "^13.1.2",
"simple-git-hooks": "^2.8.1",
"typescript": "^4.9.5",
"unbuild": "^1.1.1"
"unbuild": "^1.1.1",
"vitest": "^0.29.2"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged",
"commit-msg": "node scripts/verify-commit.js"
},
"lint-staged": {
"*.{ts,js,json,json5}": "eslint --fix"
}
}
27 changes: 27 additions & 0 deletions test/scripts/verify-commit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// @ts-check
import { readFileSync } from 'node:fs'
import path from 'node:path'
import chalk from 'chalk'

const msgPath = path.resolve('.git/COMMIT_EDITMSG')
const msg = readFileSync(msgPath, 'utf-8').trim()

const commitRE = /^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|release|merge)(\(.+\))?: .{1,50}/

if (!commitRE.test(msg)) {
console.log()
console.error(
` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(
'invalid commit message format.'
)}\n\n` +
chalk.red(
' Proper commit message format is required for automated changelog generation. Examples:\n\n'
) +
` ${chalk.green('feat(compiler): add \'comments\' option')}\n` +
` ${chalk.green(
'fix(methods): handle events on blur (close #28)'
)}\n\n` +
chalk.red(' See .github/commit-convention.md for more details.\n')
)
process.exit(1)
}

0 comments on commit f91fcea

Please sign in to comment.