Skip to content

Commit

Permalink
chore: init
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudcome committed Oct 13, 2023
1 parent d9894e7 commit 28d940f
Show file tree
Hide file tree
Showing 22 changed files with 6,406 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .commitlintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* commitlint.config
* @ref http://commitlint.js.org/
* @type {import('@commitlint/types').UserConfig}
*/
module.exports = {
extends: ['@commitlint/config-conventional'],
};
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
max_line_length = 120
insert_final_newline = true
trim_trailing_whitespace = true
47 changes: 47 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Macos
.DS_Store

# Windows
$RECYCLE.BIN/
Desktop.ini
ehthumbs.db
Thumbs.db

# Node
node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock

# local env files
.env.local
.env.*.local

# Log files
/logs
*.log
*.log.*

# Editor directories and files
.idea
.vscode
!.vscode/extensions.json

# dist and cache
/dist
/dist-*
/dist_*
.cache

# testing
/coverage

# next.js
.next
/out
/build

# nuxt.js
.nuxt
.nitro
.output
54 changes: 54 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { defineConfig } = require('eslint-define-config');

/**
* eslint config
* @ref https://eslint.org/
*/
module.exports = defineConfig({
root: true,

env: {
browser: true,
node: true,
es2022: true,
},

overrides: [
{
files: ['*.cjs'],
extends: [
//
'eslint:recommended',
],
rules: {
'prettier/prettier': 'error',
},
},
{
files: ['*.mjs'],
parserOptions: {
sourceType: 'module',
},
extends: [
//
'eslint:recommended',
],
rules: {
'prettier/prettier': 'error',
},
},
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
extends: [
//
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
rules: {
'prettier/prettier': 'error',
},
},
],
});
15 changes: 15 additions & 0 deletions .github/actions/setup-nvm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: setup nvm
description: 依照 nvmrc 创建 node 环境

runs:
using: composite
steps:
- run: sudo timedatectl set-timezone Asia/Shanghai
shell: bash
- run: timedatectl
shell: bash
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: '**/package-lock.json'
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: daily
34 changes: 34 additions & 0 deletions .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 代码格式、基本质量检查

name: code review

on:
push:
branches:
- v*.x
pull_request:
schedule:
# 19:00(UTC) 每天,相当于 03:00(GMT+8)
- cron: '0 19 * * *'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-nvm
- run: npm ci
- run: npm run lint

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-nvm
- run: npm ci
- run: npm run test:coverage
- uses: codacy/codacy-coverage-reporter-action@v1
if: github.actor != 'dependabot[bot]'
with:
api-token: ${{ secrets.CODACY_API_TOKEN }}
coverage-reports: coverage/lcov.info
15 changes: 15 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 此操作会扫描您的拉取请求以查找依赖项更改,如果引入任何漏洞或无效许可证,则会引发错误

name: dependency review

on:
pull_request:

jobs:
dependency-review:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/dependency-review-action@v3
70 changes: 70 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 如果 devPR 到主干,则会根据约定式提交创建一个 releasePR,是一个新版本合并请求
# 如果 releasePR 到主干,则会触发新版本发布到 npm/github 等仓库

name: release please

on:
push:
branches:
- v*.x

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
bump-minor-pre-major: true

test-coverage:
runs-on: ubuntu-latest
needs: release
if: needs.release.outputs.release_created
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-nvm
- run: npm ci
- run: npm run test:coverage
- uses: codacy/codacy-coverage-reporter-action@v1
with:
api-token: ${{ secrets.CODACY_API_TOKEN }}
coverage-reports: coverage/lcov.info

publish-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
needs: test-coverage
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-nvm
- run: npm ci
- run: npm run build
- uses: FrontEndDev-org/publish-node-package-action@v1
with:
target: npm
token: ${{ secrets.NPM_TOKEN }}
- uses: FrontEndDev-org/npm-mirror-sync-action@v1

publish-github:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: test-coverage
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-nvm
- run: npm ci
- run: npm run build
- uses: FrontEndDev-org/publish-node-package-action@v1
with:
target: github
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Macos
.DS_Store

# Windows
$RECYCLE.BIN/
Desktop.ini
ehthumbs.db
Thumbs.db

# Node
node_modules

# local env files
.env.local
.env.*.local

# Log files
/logs
*.log
*.log.*

# Editor directories and files
.idea
.vscode
!.vscode/extensions.json

# dist and cache
/dist
/dist-*
/dist_*
.cache

# testing
/coverage

# next.js
.next
/out
/build

# nuxt.js
.nuxt
.nitro
.output
4 changes: 4 additions & 0 deletions .husky/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```shell
chmod +x commit-msg
chmod +x pre-commit
```
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx commitlint --edit "$1"
7 changes: 7 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "node version = $(node -v)"
echo "npm version = $(npm -v)"
npx lint-staged --allow-empty
npx tsc --noEmit
9 changes: 9 additions & 0 deletions .lintstagedrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* lint-staged config
* @ref https://www.npmjs.com/package/lint-staged
*/
module.exports = {
'*.{cjs,mjs,ts,tsx}': 'eslint --fix',
'*.{cjs,mjs,ts,tsx,html,css,scss}': 'prettier --write',
'(package|tsconfig*).json': 'prettier --write',
};
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmmirror.com
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
47 changes: 47 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Macos
.DS_Store

# Windows
$RECYCLE.BIN/
Desktop.ini
ehthumbs.db
Thumbs.db

# Node
node_modules
package-lock.json
pnpm-lock.yaml
yarn.lock

# local env files
.env.local
.env.*.local

# Log files
/logs
*.log
*.log.*

# Editor directories and files
.idea
.vscode
!.vscode/extensions.json

# dist and cache
/dist
/dist-*
/dist_*
.cache

# testing
/coverage

# next.js
.next
/out
/build

# nuxt.js
.nuxt
.nitro
.output
Loading

0 comments on commit 28d940f

Please sign in to comment.