From f91fcea45048fb26111c09eaa1256f21df11c8c9 Mon Sep 17 00:00:00 2001 From: yanquanfahei <1449826851@qq.com> Date: Thu, 9 Mar 2023 11:32:35 +0800 Subject: [PATCH] test: node generate --- test/.github/workflows/release.yml | 22 ++++++++++ test/.gitignore | 2 + test/.vscode/settings.json | 16 +++++++ test/README.md | 1 + test/{unbuild.config.ts => build.config.ts} | 5 +-- test/package.json | 46 +++++++++++++++++---- test/scripts/verify-commit.js | 27 ++++++++++++ 7 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 test/.github/workflows/release.yml create mode 100644 test/.gitignore create mode 100644 test/.vscode/settings.json create mode 100644 test/README.md rename test/{unbuild.config.ts => build.config.ts} (66%) create mode 100644 test/scripts/verify-commit.js diff --git a/test/.github/workflows/release.yml b/test/.github/workflows/release.yml new file mode 100644 index 0000000..a0f7509 --- /dev/null +++ b/test/.github/workflows/release.yml @@ -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}} \ No newline at end of file diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..76add87 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/test/.vscode/settings.json b/test/.vscode/settings.json new file mode 100644 index 0000000..a1ab9c9 --- /dev/null +++ b/test/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "eslint.enable": true, + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "markdown", + "json", + "jsonc", + "json5" + ], + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + } +} diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..83c831f --- /dev/null +++ b/test/README.md @@ -0,0 +1 @@ +# test diff --git a/test/unbuild.config.ts b/test/build.config.ts similarity index 66% rename from test/unbuild.config.ts rename to test/build.config.ts index a22cf6f..05b35c2 100644 --- a/test/unbuild.config.ts +++ b/test/build.config.ts @@ -4,9 +4,6 @@ export default defineBuildConfig({ entries: ['src/index'], clean: true, rollup: { - inlineDependencies: true, - esbuild: { - minify: true - } + emitCJS: true } }) diff --git a/test/package.json b/test/package.json index 392118a..5c6848c 100644 --- a/test/package.json +++ b/test/package.json @@ -1,33 +1,65 @@ { "name": "test", "type": "module", - "version": "1.0.0", + "version": "0.0.0", + "packageManager": "pnpm@7.26.0", "description": "", - "author": "", + "author": { + "name": "ηœΌεœˆε‘ι»‘", + "email": "1449826851@qq.com" + }, "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" } } diff --git a/test/scripts/verify-commit.js b/test/scripts/verify-commit.js new file mode 100644 index 0000000..3a76510 --- /dev/null +++ b/test/scripts/verify-commit.js @@ -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) +}