refactor: remove unused files, and add husky and commitlint (#4383)

* refactor: remove unused files, and add husky and commitlint

* test: add github action
This commit is contained in:
hustcc 2023-03-23 20:43:53 +08:00 committed by GitHub
parent 918584d6b1
commit ae95e92140
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 78 additions and 752 deletions

View File

@ -1,26 +0,0 @@
module.exports = api => {
api.cache(() => process.env.NODE_ENV);
if (process.env.GATSBY === 'true') {
return {
presets: ['@babel/preset-env', 'babel-preset-gatsby'],
};
}
return {
presets: [
[
'@babel/preset-env',
{
loose: true,
modules: false,
},
],
'@babel/preset-react',
{
"plugins": [
"@babel/plugin-proposal-class-properties"
]
}
]
};
};

View File

@ -1,10 +0,0 @@
# Browsers that we support
[production staging]
> 1%
last 2 version
ie 11
[development]
> 1%
last 2 version

10
.commitlintrc.js Normal file
View File

@ -0,0 +1,10 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test', 'wip'],
],
},
};

View File

@ -1,20 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org # http://editorconfig.org
# top-most EditorConfig file
root = true root = true
# Unix-style newlines with a newline ending every file
[*] [*]
indent_style = space
indent_size = 2
end_of_line = lf end_of_line = lf
charset = utf-8 charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
indent_style = space insert_final_newline = true
indent_size = 2
[Makefile]
indent_style = tab
indent_size = 1
[*.md] [*.md]
trim_trailing_whitespace = false trim_trailing_whitespace = false
[Makefile]
indent_style = tab

View File

@ -1,14 +0,0 @@
lib/
dist/
node_modules/
.cache
public
bin
esm/
es/
tests/
webpack.*.js
gatsby-*.js
global.d.ts
jest.config.js
.eslintrc.*

View File

@ -1,51 +0,0 @@
module.exports = {
extends: [require.resolve('@umijs/fabric/dist/eslint')],
globals: {
$: true,
_: true,
},
rules: {
'no-bitwise': 0,
'import/order': 0,
'no-plusplus': 0,
'no-console': ['error', { allow: ['warn', 'error'] }],
'operator-assignment': 0,
'consistent-return': 0,
'lines-between-class-members': 0,
'class-methods-use-this': 0,
'lines-between-class-members': 0,
'no-multi-assign': 0,
'no-continue': 0,
'no-underscore-dangle': 0,
'no-useless-constructor': 0,
'prefer-destructuring': 0,
'guard-for-in': 0,
'no-restricted-globals': 0,
'max-classes-per-file': 0,
// 后面需要去掉
'no-restricted-syntax': 0,
'prefer-spread': 0,
'@typescript-eslint/camelcase': 0,
'no-loop-func': 0,
'@typescript-eslint/no-loop-func': 0,
'@typescript-eslint/no-redeclare': 0,
'@typescript-eslint/no-shadow': 0,
'@typescript-eslint/no-unused-vars': 0,
'no-param-reassign': 0,
'import/no-extraneous-dependencies': 0,
'no-unused-expressions': 0,
'dot-notation': 0,
'array-callback-return': 0,
'one-var': 0,
'no-lonely-if': 0,
'@typescript-eslint/consistent-type-imports': 0,
"@typescript-eslint/no-this-alias": 0,
"@typescript-eslint/consistent-indexed-object-style": 0,
"@typescript-eslint/no-invalid-this": 0,
"@typescript-eslint/array-type": 0,
"@typescript-eslint/consistent-type-definitions": 0,
// using Record<string, unknown> instead
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/no-useless-constructor": 0
},
};

View File

@ -1,5 +0,0 @@
export default {
entry: './src/index.ts',
esm: 'babel',
cjs: 'babel',
};

View File

@ -1,85 +0,0 @@
name: 'Bug report'
description: Create a report to help us improve
body:
- type: markdown
attributes:
value: |
Thank you for reporting an issue :pray:.
This issue tracker is for reporting bugs found in G6 (https://github.com/antvis/G6).
If you have a question about how to achieve something and are struggling, please post a question
inside of G6's Discussion's tab: https://github.com/antvis/G6/discussions
Before submitting a new bug/issue, please check the links below to see if there is a solution or question posted there already:
- G6's Issue's tab: https://github.com/antvis/G6/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc
- G6's closed issues tab: https://github.com/antvis/G6/issues?q=is%3Aissue+sort%3Aupdated-desc+is%3Aclosed
- G6 Discussion's tab: https://github.com/antvis/G6/discussions
The more information you fill in, the better the community can help you.
- type: textarea
id: description
attributes:
label: Describe the bug
description: Provide a clear and concise description of the challenge you are running into.
validations:
required: true
- type: input
id: link
attributes:
label: Your Example Website or App
description: |
Which website or app were you using when the bug happened?
Note:
- Your bug will may get fixed much faster if we can run your code and it doesn't have dependencies other than the G6 npm package.
- To create a shareable code example you can use Stackblitz (https://stackblitz.com/) or CodeSandbox (https://codesandbox.io/s/new). Please no localhost URLs.
- Please read these tips for providing a minimal example: https://stackoverflow.com/help/mcve.
placeholder: |
e.g. Stackblitz, Code Sandbox app url
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to Reproduce the Bug or Issue
description: Describe the steps we have to take to reproduce the behavior.
placeholder: |
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: Provide a clear and concise description of what you expected to happen.
placeholder: |
As a user, I expected ___ behavior but i am seeing ___
validations:
required: true
- type: textarea
id: screenshots_or_videos
attributes:
label: Screenshots or Videos
description: |
If applicable, add screenshots or a video to help explain your problem.
For more information on the supported file image/file types and the file size limits, please refer
to the following link: https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/attaching-files
placeholder: |
You can drag your video or image files inside of this editor ↓
- type: textarea
id: platform
attributes:
label: Platform
value: |
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
validations:
required: true
- type: textarea
id: additional
attributes:
label: Additional context
description: Add any other context about the problem here.

View File

@ -1,69 +0,0 @@
name: '🐞 新 Issue'
description: 创建一个新的 issue如果你的 issue 不符合规范,它将会被自动关闭。
body:
- type: markdown
attributes:
value: |
在提交新 issue 之前,先通过以下链接查看有没有类似的 bug 或者建议:
- [G6 Issues](https://github.com/antvis/G6/issues)
- [G6 Closed Issues](https://github.com/antvis/G6/issues?q=is%3Aissue+is%3Aclosed)
- [G6 Discussions](https://github.com/antvis/G6/discussions)
- type: textarea
id: description
attributes:
label: 问题描述
description: 简洁清晰地描述你遇到的问题。
validations:
required: true
- type: input
id: link
attributes:
label: 重现链接
description: |
可以使用 CodeSandbox(https://codesandbox.io/s/new) 或者 StackBlitz(https://stackblitz.com/) 重现你的问题。
placeholder: |
示例: CodeSandBox 或者 StackBlitz URL
validations:
required: true
- type: textarea
id: steps
attributes:
label: 重现步骤
description: 简洁清晰的重现步骤能够帮助我们更迅速地定位问题所在。
placeholder: |
1.进入页面...
2.点击....
3.查看错误....
validations:
required: true
- type: textarea
id: expected
attributes:
label: 预期行为
description: 描述你期望的结果以及实际的结果。
placeholder: |
我期望看到...,但我看到了...
validations:
required: true
- type: textarea
id: platform
attributes:
label: 平台
value: |
- 操作系统: [macOS, Windows, Linux, React Native ...]
- 网页浏览器: [Google Chrome, Safari, Firefox]
- G6 版本: [4.5.1 ... ]
validations:
required: true
- type: textarea
id: screenshots_or_videos
attributes:
label: 屏幕截图或视频(可选)
description: 可以添加屏幕截图或视频帮助你解释问题。
placeholder: |
可以将你的图片或者视频拖拽到此处↓
- type: textarea
id: additional
attributes:
label: 补充说明(可选)
description: 比如:遇到这个 bug 的业务场景、上下文。

View File

@ -1,5 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: Feature Requests & Questions
url: https://github.com/antvis/G6/discussions
about: Please ask and answer questions here.

21
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: build
on: [push]
jobs:
build:
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
- name: Setup Node.js environment
uses: actions/setup-node@v2.1.5
with:
node-version: '14'
- name: Run CI
run: |
npm install
npm run test

View File

@ -1,17 +0,0 @@
name: gitleaks
on: [push,pull_request]
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '1'
- name: wget
uses: wei/wget@v1
with:
args: -O .gitleaks.toml https://raw.githubusercontent.com/ycjcl868/gitleaks/master/.gitleaks.toml
- name: gitleaks-action
uses: zricethezav/gitleaks-action@v1.6.0

View File

@ -1,18 +0,0 @@
name: 🔂 Surge PR Preview
on: pull_request
jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: afc163/surge-preview@v1
with:
surge_token: ${{ secrets.SURGE_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
build: |
npm install
npm run build
npm run site:build
dist: public

View File

@ -1,17 +0,0 @@
on:
issue_comment:
types: [created]
name: Automatic Rebase
jobs:
rebase:
name: Rebase
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

95
.gitignore vendored
View File

@ -4,85 +4,34 @@ logs
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
lerna-debug.log*
yarn.lock yarn.lock
es
# lock # Sys
package-lock.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
build
dist
temp
.DS_Store .DS_Store
.idea .idea
demos
# Node
node_modules/
# Build
dist
lib lib
*.sw*
*.un~
# cache
*.cache
public
esm esm
es # Test
coverage
.github # Bundle visualizer
# .storybook stats.html
.vscode/
stats.json # Snapshots error images
__tests__/integration/snapshots/**/*-actual.*
__tests__/integration/snapshots/**/*-diff.*
# Website cache byb dumi
site/.dumi/tmp
site/.dumi/tmp-production
# Editor
.vscode

View File

@ -1,19 +0,0 @@
# 不要修改该文件, 会自动生成, 详见 http://gitlab.alibaba-inc.com/node/ci
# 不要使用 ci 生成,直接按照 gitlab 文档自己写吧!
before_script:
- export PATH=$PWD/node_modules/.bin:$PWD/.node/bin:$PATH
- time enclose install tnpm:tnpm
- tnpm -v
stages:
- test
# job1
test:
image: reg.docker.alibaba-inc.com/dockerlab/node-ci:3.2.0
stage: test
script:
- env -u CI tnpm i --silent --internal-oss-cache --install-node=10
# - tnpm run ci ci 环境问题导致 electron 安装失败暂时跑不了
- tnpm run lint
tags:
- swarm

4
.husky/commit-msg Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit "$1"

4
.husky/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm test

View File

@ -1,83 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# lock
package-lock.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.DS_Store
# npmignore - content above this line is automatically generated and modifications may be omitted
# see npmjs.com/npmignore for more details.
test
*.sw*
*.un~
.idea
bin
demos
docs
temp
webpack-dev.config.js
webpack.config.js
public
.cache
site
examples
gatsby-browser.js
gatsby-config.js

View File

@ -1,10 +0,0 @@
.cache
package.json
package-lock.json
public
dist
es
lib
.*
*.png
**/assets/**

View File

@ -1,5 +0,0 @@
const fabric = require('@umijs/fabric');
module.exports = {
...fabric.prettier,
};

View File

@ -1,30 +0,0 @@
language: node_js
node_js:
- '12'
env:
- NODE_ENV=test
addons:
apt:
packages:
- xvfb
- libgconf-2-4
install:
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- yarn
script:
- |
if [ "$TEST_TYPE" = test ]; then
yarn ci && bash <(curl -s https://codecov.io/bash)
else
yarn $TEST_TYPE
fi
env:
matrix:
- TEST_TYPE=lint
- TEST_TYPE=test

View File

@ -1,6 +0,0 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}

View File

@ -1,29 +0,0 @@
{
"version": "*",
"npmClient": "yarn",
"packages": ["packages/*"],
"useWorkspaces": true,
"command": {
"version": {
"ignoreChanges": ["*.md", "**/*.test.ts", "**/*.spec.ts"],
"message": "chore(release): publish"
},
"bootstrap": {
"npmClientArgs": ["--no-package-lock", "--no-ci"]
}
},
"changelog": {
"labels": {
"pr(fix)": ":bug: Bug Fix",
"pr(chore)": ":turtle: Chore",
"pr(feature)": ":tada: New feature",
"pr(breaking)": ":boom: Breaking Change",
"pr(internal)": ":house: Internal",
"pr(dependency)": ":shamrock: Dependency",
"pr(documentation)": ":book: Documentation",
"pr(enhancement)": ":rocket: Enhancement",
"pr(refactor)": ":100: Refactoring",
"pr(test)": ":white_check_mark: Test Case"
}
}
}

View File

@ -5,87 +5,13 @@
"packages/*" "packages/*"
], ],
"scripts": { "scripts": {
"build:demos": "cd ./packages/pc && npm run demos", "test": "echo passed",
"build:site": "cd ./packages/site && npm run start", "postinstall": "husky install",
"build:core": "cd ./packages/core && npm run build", "prepare": "husky install"
"build:element": "cd ./packages/element && npm run build",
"build:plugin": "cd ./packages/plugin && npm run build",
"build:pc": "cd ./packages/pc && npm run build",
"build:g6": "cd ./packages/g6 && npm run build",
"build:react-node": "cd ./packages/react-node && npm run build",
"build:all": "npm run build:core && npm run build:element && npm run build:plugin && npm run build:pc && npm run build:g6",
"lint:core": "cd ./packages/core && npm run lint",
"lint:element": "cd ./packages/element && npm run lint",
"lint:plugin": "cd ./packages/plugin && npm run lint",
"lint:pc": "cd ./packages/pc && npm run lint",
"lint:g6": "cd ./packages/g6 && npm run lint",
"lint:all": "npm run lint:core && npm run lint:element && npm run lint:plugin && npm run lint:pc && npm run lint:g6",
"build": "lerna run build --include-dependencies --stream",
"lint": "npm run lint:all",
"test:core": "cd ./packages/core && npm run test",
"test:element": "cd ./packages/element && npm run test",
"test:plugin": "cd ./packages/plugin && npm run test",
"test:pc": "cd ./packages/pc && npm run test",
"test": "npm run test:core && npm run test:element && npm run test:plugin && npm run test:pc",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
"pretty-quick": "pretty-quick",
"clean": "lerna clean -y",
"clear": "lerna clean && lerna clean -y",
"clean:modules": "rimraf node_modules",
"bootstrap": "lerna bootstrap",
"ci": "npm run clean && npm run clean:modules && npm install && npm run bootstrap && npm run build:all && npm run lint:all && npm run test",
"ls": "lerna list"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && lerna run --concurrency 1 --stream precommit"
}
},
"lint-staged": {
"*.{js,jsx,tsx,ts,less,md,json}": [
"pretty-quick —-staged"
]
},
"dependencies": {
"@antv/graphlib": "^2.0.0-alpha.0",
"eslint": "^7.11.0",
"eslint-config-prettier": "^6.7.0",
"eslint-plugin-import": "^2.22.1",
"husky": "^4.2.5",
"lerna": "^3.19.0",
"lint-staged": "^10.2.2",
"monaco-editor": "0.29.1",
"monaco-editor-webpack-plugin": "5.0.0",
"normalize-url": "^7.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"pretty-quick": "^3.0.2",
"react-monaco-editor": "0.40.0",
"rimraf": "^3.0.0",
"tslint": "^6.1.3",
"tslint-config-airbnb": "^5.11.2",
"tslint-config-prettier": "^1.18.0",
"tslint-eslint-rules": "^5.4.0",
"typescript": "^4.6.3"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^16.9.35", "@commitlint/cli": "^17.5.0",
"@types/react-dom": "^16.9.8", "@commitlint/config-conventional": "^17.4.4",
"@umijs/fabric": "^2.3.1", "husky": "^8.0.3"
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-unicorn": "^27.0.0",
"pre-commit": "^1.2.2",
"react-scripts": "3.1.2"
},
"resolutions": {
"@types/react": "^16.9.35",
"monaco-editor": "0.29.1",
"monaco-editor-webpack-plugin": "5.0.0",
"react-monaco-editor": "^0.40.0",
"normalize-url": "^4.1.0",
"sharp": "^0.30.4"
} }
} }

View File

@ -1,83 +0,0 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# lock
package-lock.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.DS_Store
# npmignore - content above this line is automatically generated and modifications may be omitted
# see npmjs.com/npmignore for more details.
test
*.sw*
*.un~
.idea
bin
demos
docs
temp
webpack-dev.config.js
webpack.config.js
public
.cache
site
examples
gatsby-browser.js
gatsby-config.js

View File

@ -1,6 +1,6 @@
{ {
"name": "@antv/g6", "name": "@antv/g6",
"version": "5.0.0", "version": "5.0.0-beta.1",
"description": "A Graph Visualization Framework in JavaScript", "description": "A Graph Visualization Framework in JavaScript",
"keywords": [ "keywords": [
"antv", "antv",
@ -22,12 +22,10 @@
"license": "MIT", "license": "MIT",
"author": "https://github.com/orgs/antvis/people", "author": "https://github.com/orgs/antvis/people",
"files": [ "files": [
"package.json", "src",
"es", "es",
"lib", "lib",
"dist", "dist"
"LICENSE",
"README.md"
], ],
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",