To contribute, you need to understand G6's code structure and development workflow. The code repository for G6 is located at: https://github.com/antvis/G6
If you want to fix a bug or add a new feature, you need to first fork a copy of the code to your repository, then make modifications in your repository, and finally submit a Pull Request (PR) to the G6 repository.
Fork the G6 repository on Github to your account, then clone it locally.
# Navigate to your workspacecd /path/to/your/workspace# Navigate to the G6 directorygit clone git@github.com:[your username]/G6.git
Please ensure your local environment meets the following requirements:
# Enter the G6 code directorycd G6# Install Dependenciespnpm install
# Enter the g6 code directory.cd ./packages/g6# Start the development environmentpnpm dev
At this point, you can access G6's development environment and preview the examples by visiting http://127.0.0.1:8080 in your web browser.
Switch to a development branch:
git checkout -b [branch name]
Make code modifications according to your needs and test locally.
In the packages/g6/__tests__/unit
directory, write test cases to ensure your code behaves as expected.
Validate Your Code with Tests:
pnpm test
# Stage changesgit add .# Commit Changesgit commit -m "[commit type]: commit message"# Push to Your Repositorygit push
Submit a Pull Request (PR) to the G6 repository on GitHub.
G6 utilizes Jest for conducting unit tests, with the test cases situated in the packages/g6/__tests__/unit
directory.
We require that all code submissions must pass tests to ensure code quality.
The coverage rate for the current PR (Pull Request) submission is advised not to fall below the coverage rate of the existing codebase, and it is
G6 extends Jest tests and provides the toMatchSnapshot
assertion for generating and comparing snapshots.
If the current possible modification affects the generation of some screenshots, it is necessary to check whether there are failed test cases by executing pnpm test
.
When a failed test case is found, the console will print the path of the failed test, as well as the path information of the benchmark screenshot and the current screenshot. You can hold the Ctrl
or Command
key and click the path to view the specific test case or screenshot.
If it is confirmed that this modification is correct, then please manually delete the corresponding benchmark screenshots and regenerate the screenshots:
Regenerate all screenshots:
packages/g6/__tests__/unit/snapshots
directorypnpm test
Regenerate a single screenshot:
packages/g6/__tests__/snapshots
directory (test cases in the unit
directory will generate the corresponding directory under snapshots
)npx jest __tests__/unit/xx/xxx.spec.ts
The G6 code adheres to the following standards:
G6 adopts the Conventional Commits specification, and the commit message format is as follows:
<type>[optional scope]: <description>
The type field can be one of the following:
For example:
feat: add new featurerefactor(behavior): refactor drag-canvas behavior
Please ensure that your commit messages conform to the standards, and try to use English descriptions whenever possible. This helps us better manage the code.
After completing the above steps, you can submit a PR to the G6 repository. Please ensure that your PR adheres to the following standards:
After your PR is submitted, we will review your code. Please be patient and await the results of the review. If there are any areas that require modification, we will point them out within the PR.
We regularly release new versions. If your PR is for a non-urgent bug fix, it will be included in the next release. If your PR addresses an urgent bug fix, we will release a new version as soon as possible.
This project uses changeset to manage version release, and the specific release process is as follows:
npm run version
command, fill in the information according to the prompt, and the version number will be updated automaticallypublish
label, and merge the branch to v5