Skip to content

Commit cba0016

Browse files
authored
feat: clickstream SDK for WeChat Mini Program (#1)
1 parent 9f2bdc7 commit cba0016

39 files changed

+10083
-7
lines changed

.eslintrc.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"prettier"
10+
],
11+
"overrides": [],
12+
"parserOptions": {
13+
"ecmaVersion": "latest",
14+
"sourceType": "module"
15+
},
16+
"plugins": [
17+
"import"
18+
],
19+
"rules": {
20+
"eqeqeq": "warn",
21+
"@typescript-eslint/no-explicit-any": "off",
22+
"import/order": [
23+
"error",
24+
{
25+
"groups": [
26+
"builtin",
27+
"external"
28+
],
29+
"alphabetize": {
30+
"order": "asc",
31+
"caseInsensitive": true
32+
}
33+
}
34+
]
35+
}
36+
}

.github/release.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
changelog:
2+
categories:
3+
- title: Feature
4+
labels:
5+
- enhancement
6+
- title: Fix
7+
labels:
8+
- bug
9+
- title: Other Changes
10+
labels:
11+
- "*"

.github/workflows/build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: WeChat SDK Build
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
code-build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Run build
15+
run: |
16+
npm i
17+
npm run build

.github/workflows/code-lint.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: WeChat SDK Lint
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
code-lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Run npm install
15+
run: npm i
16+
- name: Run code format
17+
run: npm run format
18+
- name: Run code lint
19+
run: npm run lint

.github/workflows/release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release next version
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
release_tag:
6+
description: 'Release Tag'
7+
required: true
8+
type: string
9+
env:
10+
NEW_VERSION: ${{ github.event.inputs.release_tag }}
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
with:
17+
ref: main
18+
fetch-depth: 0
19+
token: ${{ secrets.PROJECT_TOKEN }}
20+
- name: Modify for next release
21+
run: |
22+
chmod +x release.sh
23+
./release.sh ${{ env.NEW_VERSION }}
24+
npm i
25+
git diff
26+
git config user.name '${{ vars.USER_NAME }}'
27+
git config user.email '${{ vars.USER_EMAIL }}'
28+
git add .
29+
git commit -m 'release: clickstream WeChat SDK ${{ env.NEW_VERSION }}'
30+
git push
31+
git tag v${{ env.NEW_VERSION }}
32+
git push origin v${{ env.NEW_VERSION }}
33+
- name: Prepare release file
34+
run: |
35+
npm i
36+
npm run release
37+
- name: Create GitHub release
38+
uses: softprops/action-gh-release@v1
39+
with:
40+
name: "Clickstream WeChat ${{ env.NEW_VERSION }}"
41+
files: |
42+
dist/clickstream-wechat.min.js
43+
dist/clickstream-wechat.min.js.map
44+
tag_name: "v${{ env.NEW_VERSION }}"
45+
prerelease: true
46+
generate_release_notes: true

.github/workflows/test.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: WeChat SDK Test
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
code-test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Run test
15+
run: |
16+
npm i
17+
npm run test
18+
- name: Upload Test Report
19+
uses: codecov/codecov-action@v3
20+
with:
21+
name: report
22+
files: coverage/coverage-final.json

.github/workflows/title-lint.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Commit Title Lint
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
title-lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: amannn/action-semantic-pull-request@v5.3.0
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
with:
15+
# Configure which types are allowed.
16+
# Default: https://github.com/commitizen/conventional-commit-types
17+
types: |
18+
fix
19+
feat
20+
docs
21+
style
22+
refactor
23+
perf
24+
test
25+
build
26+
ci
27+
chore
28+
revert
29+
release
30+
# Configure that a scope must always be provided.
31+
requireScope: false
32+
# Configure additional validation for the subject based on a regex.
33+
# This example ensures the subject doesn't start with an uppercase character.
34+
subjectPattern: ^(?![A-Z]).+$
35+
# If `subjectPattern` is configured, you can use this property to override
36+
# the default error message that is shown when the pattern doesn't match.
37+
# The variables `subject` and `title` can be used within the message.
38+
subjectPatternError: |
39+
The subject "{subject}" found in the pull request title "{title}"
40+
didn't match the configured pattern. Please ensure that the subject
41+
doesn't start with an uppercase character.
42+
# For work-in-progress PRs you can typically use draft pull requests
43+
# from Github. However, private repositories on the free plan don't have
44+
# this option and therefore this action allows you to opt-in to using the
45+
# special "[WIP]" prefix to indicate this state. This will avoid the
46+
# validation of the PR title and the pull request checks remain pending.
47+
# Note that a second check will be reported if this is enabled.
48+
wip: true

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.DS_Store
2+
.idea/
3+
*.iml
4+
.vscode
5+
node_modules
6+
/dist
7+
/lib
8+
/coverage
9+
/src/config.ts
10+

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
package.json
4+
package-lock.json

.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
trailingComma: 'es5',
3+
singleQuote: true,
4+
useTabs: true,
5+
tabWidth: 2,
6+
arrowParens: 'avoid',
7+
};

0 commit comments

Comments
 (0)