Skip to content

Commit

Permalink
feat: update node template
Browse files Browse the repository at this point in the history
  • Loading branch information
yanquanfahei committed Mar 9, 2023
1 parent c226dae commit d554433
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 8 deletions.
2 changes: 2 additions & 0 deletions templates/node/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
1 change: 1 addition & 0 deletions templates/node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# pkg-name
46 changes: 38 additions & 8 deletions templates/node/package.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,65 @@
{
"name": "node-template",
"name": "pkg-name",
"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/pkg-name#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/yanquanfahei/pkg-name.git"
},
"bugs": "https://github.com/yanquanfahei/pkg-name/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 templates/node/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 d554433

Please sign in to comment.