Skip to content

Commit c7de3bb

Browse files
committed
chore: standardize repository maintenance
1 parent 75ebc66 commit c7de3bb

11 files changed

Lines changed: 309 additions & 97 deletions

File tree

‎.github/FUNDING.yml‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,2 @@
1-
# These are supported funding model platforms
2-
31
github: ant-design
4-
patreon: # Replace with a single Patreon username
5-
open_collective: # Replace with a single Open Collective username
6-
ko_fi: # Replace with a single Ko-fi username
7-
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8-
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9-
liberapay: # Replace with a single Liberapay username
10-
issuehunt: # Replace with a single IssueHunt username
11-
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12-
polar: # Replace with a single Polar username
13-
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14-
thanks_dev: # Replace with a single thanks.dev username
15-
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
2+
open_collective: ant-design

‎.github/dependabot.yml‎

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
# To get started with Dependabot version updates, you'll need to specify which
2-
# package ecosystems to update and where the package manifests are located.
3-
# Please see the documentation for all configuration options:
4-
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5-
61
version: 2
72
updates:
8-
- package-ecosystem: "npm" # See documentation for possible values
9-
directory: "/" # Location of package manifests
3+
- package-ecosystem: npm
4+
directory: '/'
5+
schedule:
6+
interval: weekly
7+
day: monday
8+
time: '21:00'
9+
timezone: Asia/Shanghai
10+
open-pull-requests-limit: 10
11+
groups:
12+
npm-dependencies:
13+
patterns:
14+
- '*'
15+
16+
- package-ecosystem: github-actions
17+
directory: '/'
1018
schedule:
11-
interval: "weekly"
19+
interval: weekly
20+
day: monday
21+
time: '21:00'
22+
timezone: Asia/Shanghai
23+
open-pull-requests-limit: 10
24+
groups:
25+
github-actions:
26+
patterns:
27+
- '*'

‎.github/workflows/codeql.yml‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: 'CodeQL'
2+
3+
on:
4+
push:
5+
branches: ['master']
6+
pull_request:
7+
branches: ['master']
8+
schedule:
9+
- cron: '36 13 * * 3'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [javascript-typescript]
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v7
28+
with:
29+
persist-credentials: false
30+
31+
- name: Initialize CodeQL
32+
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e
33+
with:
34+
languages: ${{ matrix.language }}
35+
queries: +security-and-quality
36+
37+
- name: Autobuild
38+
uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e
39+
40+
- name: Perform CodeQL Analysis
41+
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e
42+
with:
43+
category: '/language:${{ matrix.language }}'

‎.github/workflows/react-doctor.yml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: React Doctor
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
issues: write
12+
statuses: write
13+
14+
jobs:
15+
react-doctor:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v7
19+
with:
20+
fetch-depth: 0
21+
persist-credentials: false
22+
- uses: millionco/react-doctor@0b4f4f4bd248a154e64eb508a48347f71154b3f3
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Surge Preview
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
pull-requests: write
9+
checks: write
10+
11+
jobs:
12+
preview:
13+
runs-on: ubuntu-latest
14+
concurrency:
15+
group: surge-preview-${{ github.event.pull_request.number }}
16+
cancel-in-progress: true
17+
steps:
18+
- uses: actions/checkout@v7
19+
with:
20+
persist-credentials: false
21+
- name: Check Surge token
22+
id: surge-token
23+
env:
24+
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
25+
run: |
26+
if [ -n "$SURGE_TOKEN" ]; then
27+
echo "enabled=true" >> "$GITHUB_OUTPUT"
28+
else
29+
echo "enabled=false" >> "$GITHUB_OUTPUT"
30+
fi
31+
- name: Build preview
32+
if: ${{ steps.surge-token.outputs.enabled == 'true' }}
33+
run: |
34+
npm install
35+
npm run build
36+
- uses: afc163/surge-preview@bf90a5a86111f6311ca42f0a5a0f80fb0fb03cec
37+
if: ${{ steps.surge-token.outputs.enabled == 'true' }}
38+
env:
39+
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
40+
with:
41+
surge_token: ${{ env.SURGE_TOKEN }}
42+
github_token: ${{ secrets.GITHUB_TOKEN }}
43+
dist: .docs-dist
44+
failOnError: false
45+
setCommitStatus: false
46+
- name: Skip Surge preview
47+
if: ${{ steps.surge-token.outputs.enabled != 'true' }}
48+
run: echo "SURGE_TOKEN is not configured; skip Surge preview."

‎.github/workflows/test.yml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: ✅ test
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
uses: react-component/rc-test/.github/workflows/test-utoo.yml@main
15+
secrets:
16+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

‎README.md‎

Lines changed: 64 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,80 @@
1-
# @rc-component/async-validator
2-
3-
[![NPM version][npm-image]][npm-url]
4-
[![npm download][download-image]][download-url]
5-
[![build status][github-actions-image]][github-actions-url]
6-
[![Codecov][codecov-image]][codecov-url]
7-
[![dumi][dumi-image]][dumi-url]
8-
9-
[npm-image]: http://img.shields.io/npm/v/@rc-component/async-validator.svg?style=flat-square
10-
[npm-url]: http://npmjs.org/package/@rc-component/async-validator
11-
[travis-image]: https://img.shields.io/travis/react-component/async-validator/master?style=flat-square
12-
[travis-url]: https://travis-ci.com/react-component/async-validator
13-
[github-actions-image]: https://github.com/react-component/async-validator/actions/workflows/ci.yml/badge.svg
14-
[github-actions-url]: https://github.com/react-component/async-validator/actions/workflows/ci.yml
15-
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/async-validator/master.svg?style=flat-square
16-
[codecov-url]: https://app.codecov.io/gh/react-component/async-validator
17-
[david-url]: https://david-dm.org/react-component/async-validator
18-
[david-image]: https://david-dm.org/react-component/async-validator/status.svg?style=flat-square
19-
[david-dev-url]: https://david-dm.org/react-component/async-validator?type=dev
20-
[david-dev-image]: https://david-dm.org/react-component/async-validator/dev-status.svg?style=flat-square
21-
[download-image]: https://img.shields.io/npm/dm/@rc-component/async-validator.svg?style=flat-square
22-
[download-url]: https://npmjs.org/package/@rc-component/async-validator
23-
[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/async-validator
24-
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/async-validator
25-
[dumi-url]: https://github.com/umijs/dumi
26-
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square
27-
28-
Validate form asynchronous. A variation of https://github.com/freeformsystems/async-validate
1+
<div align="center">
2+
<h1>@rc-component/async-validator</h1>
3+
<p><sub><a href="https://ant.design"><img alt="Ant Design" height="14" src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" style="vertical-align: -0.125em;" /></a> Part of the Ant Design ecosystem.</sub></p>
4+
<p>✅ Async validation engine for schema-based form rules.</p>
5+
6+
<p>
7+
<a href="https://npmjs.org/package/@rc-component/async-validator"><img alt="NPM version" src="https://img.shields.io/npm/v/@rc-component/async-validator.svg?style=flat-square"></a>
8+
<a href="https://npmjs.org/package/@rc-component/async-validator"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@rc-component/async-validator.svg?style=flat-square"></a>
9+
<a href="https://github.com/react-component/async-validator/actions/workflows/test.yml"><img alt="build status" src="https://github.com/react-component/async-validator/actions/workflows/test.yml/badge.svg"></a>
10+
<a href="https://app.codecov.io/gh/react-component/async-validator"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/react-component/async-validator/master.svg?style=flat-square"></a>
11+
<a href="https://bundlephobia.com/package/@rc-component/async-validator"><img alt="bundle size" src="https://img.shields.io/bundlephobia/minzip/@rc-component/async-validator?style=flat-square"></a>
12+
<a href="https://github.com/umijs/dumi"><img alt="dumi" src="https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square"></a>
13+
</p>
14+
</div>
15+
16+
<p align="center">English | [简体中文](./README.zh-CN.md)</p>
17+
18+
## Highlights
19+
20+
| Area | Support |
21+
| ------- | ---------------------------------------------------- |
22+
| Purpose | Async validation engine for schema-based form rules. |
23+
| Package | `@rc-component/async-validator` |
24+
| Release | `@rc-component/np` / `rc-np` |
2925

3026
## Install
3127

3228
```bash
33-
npm i @rc-component/async-validator
29+
npm install @rc-component/async-validator
3430
```
3531

3632
## Usage
3733

38-
Basic usage involves defining a descriptor, assigning it to a schema and passing the object to be validated and a callback function to the `validate` method of the schema:
39-
40-
```js
34+
```tsx | pure
4135
import Schema from '@rc-component/async-validator';
42-
const descriptor = {
43-
name: {
44-
type: 'string',
45-
required: true,
46-
validator: (rule, value) => value === 'muji',
47-
},
48-
age: {
49-
type: 'number',
50-
asyncValidator: (rule, value) => {
51-
return new Promise((resolve, reject) => {
52-
if (value < 18) {
53-
reject('too young'); // reject with error message
54-
} else {
55-
resolve();
56-
}
57-
});
58-
},
59-
},
60-
};
61-
const validator = new Schema(descriptor);
62-
validator.validate({ name: 'muji' }, (errors, fields) => {
63-
if (errors) {
64-
// validation failed, errors is an array of all errors
65-
// fields is an object keyed by field name with an array of
66-
// errors per field
67-
return handleErrors(errors, fields);
68-
}
36+
37+
const validator = new Schema({
38+
name: { type: 'string', required: true },
39+
});
40+
41+
validator.validate({ name: 'Ant Design' }).then(() => {
6942
// validation passed
7043
});
44+
```
7145

72-
// PROMISE USAGE
73-
validator
74-
.validate({ name: 'muji', age: 16 })
75-
.then(() => {
76-
// validation passed or without error message
77-
})
78-
.catch(({ errors, fields }) => {
79-
return handleErrors(errors, fields);
80-
});
46+
## API
47+
48+
| API | Description |
49+
| --------------------------------------- | ------------------------------------------ |
50+
| `new Schema(descriptor)` | Create a validator from a rule descriptor. |
51+
| `validate(source, options?, callback?)` | Validate source data and return a Promise. |
52+
| `messages` | Customize validation messages. |
53+
54+
## Development
55+
56+
```bash
57+
npm install
58+
npm start
59+
npm test
60+
npm run coverage
61+
npm run lint
62+
npm run tsc
63+
npm run compile
64+
```
65+
66+
The dumi site runs at `http://localhost:8000`.
67+
68+
## Release
69+
70+
```bash
71+
npm run prepublishOnly
8172
```
8273

74+
The release flow is handled by `@rc-component/np` through the `rc-np` command when the package uses the shared release flow.
75+
76+
## Detailed API
77+
8378
## API
8479

8580
### Validate
@@ -478,4 +473,4 @@ Open coverage/ dir
478473

479474
## License
480475

481-
Everything is [MIT](https://en.wikipedia.org/wiki/MIT_License).
476+
@rc-component/async-validator is released under the [MIT](./LICENSE.md) license.

0 commit comments

Comments
 (0)