Skip to content

Commit

Permalink
feat: add husky for codebase quality
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Jul 30, 2024
1 parent 42a6824 commit 7a17deb
Show file tree
Hide file tree
Showing 10 changed files with 323 additions and 14 deletions.
7 changes: 5 additions & 2 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
"ignore": [
"weapp-tailwindcss",
"weapp-vite"
]
}
50 changes: 50 additions & 0 deletions .github/workflows/release-changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release changeset

on:
# push:
# branches:
# - main
workflow_dispatch:

concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
HUSKY: 0

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install Dependencies
run: pnpm i

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: pnpm publish-packages
env:
# this doesn't work but semantic-release works
# see https://github.com/sonofmagic/npm-lib-rollup-template/blob/main/.github/workflows/release.yml#L46
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
npm_config_registry: https://registry.npmjs.org

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/release-weapp-vite.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: release-weapp-vite
name: Release weapp-vite

permissions:
contents: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: Test

on:
pull_request:
Expand Down
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm dlx commitlint --edit $1
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm lint-staged
5 changes: 5 additions & 0 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { UserConfig } from '@commitlint/types'

export default <UserConfig>{
extends: ['@commitlint/config-conventional'],
}
5 changes: 5 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
'*.{js,jsx,mjs,ts,tsx,mts}': [
'eslint --fix',
],
}
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"format:test": "prettier --check \"test/**/*.test.{ts,js}\" -w",
"ls:pack": "npm pack --dry-run",
"cli:patch": "node bin/weapp-tailwindcss.js patch",
"prepare": "ts-patch install -s",
"prepare": "husky",
"release": "bumpp",
"css-build": "css2plugin build css-plugin.css css-plugin-scss.scss --cwd test/fixtures/css",
"css-build-out": "css2plugin build css-plugin.css css-plugin-scss.scss --cwd test/fixtures/css --out tw-plugins",
Expand All @@ -79,7 +79,7 @@
"lint:fix": "eslint . --fix",
"lint:view": "npx @eslint/config-inspector",
"changeset": "changeset",
"publish-packages": "turbo run build lint test && changeset version && changeset publish",
"publish-packages": "pnpm build && pnpm test && changeset version && changeset publish",
"run:watch": "tsx scripts/watcher"
},
"publishConfig": {
Expand All @@ -90,6 +90,8 @@
"@ast-grep/napi": "^0.25.4",
"@babel/core": "^7.24.9",
"@changesets/cli": "^2.27.7",
"@commitlint/config-conventional": "^19.2.2",
"@commitlint/types": "^19.0.3",
"@eslint/config-inspector": "^0.5.2",
"@icebreakers/eslint-config": "^0.3.14",
"@icebreakers/readme": "0.1.0",
Expand Down Expand Up @@ -164,9 +166,11 @@
"gulp": "^5.0.0",
"gulp-postcss": "^10.0.0",
"html-loader": "^5.1.0",
"husky": "^9.1.3",
"js-beautify": "^1.15.1",
"just-diff": "^6.0.2",
"klaw": "^4.1.0",
"lint-staged": "^15.2.7",
"lodash": "^4.17.21",
"mini-css-extract-plugin": "^2.9.0",
"miniprogram-automator": "^0.12.1",
Expand Down
Loading

0 comments on commit 7a17deb

Please sign in to comment.