diff --git a/.github/actions/build/action.yaml b/.github/actions/build/action.yaml new file mode 100644 index 0000000..fe1c6ef --- /dev/null +++ b/.github/actions/build/action.yaml @@ -0,0 +1,19 @@ +name: "Build" +description: "Build the project." + +runs: + using: "composite" # This is the magic + steps: + - uses: pnpm/action-setup@v2 + with: + version: 7 + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: "pnpm" + registry-url: https://registry.npmjs.org/ + + - run: pnpm install --frozen-lockfile + shell: bash + - run: pnpm run build + shell: bash diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 14fd478..bef56aa 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -23,16 +23,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - with: - version: 7 - - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: "pnpm" - - - run: pnpm install - - run: pnpm run build + - uses: ./.github/actions/build - uses: actions/configure-pages@v3 - uses: actions/upload-pages-artifact@v1 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..506c82d --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,18 @@ +name: Release + +on: + push: + tags: + - "v*.*.*" + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/build + + - run: pnpm test + - run: pnpm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 406c7ac..3b511f7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -14,14 +14,5 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: pnpm/action-setup@v2 - with: - version: 7 - - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: "pnpm" - - - run: pnpm install --frozen-lockfile - - run: pnpm run compile + - uses: ./.github/actions/build - run: pnpm run test diff --git a/README.md b/README.md index af7fc04..689bfa7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ ![Logo](https://raw.githubusercontent.com/cupcakearmy/formhero/master/.github/Logo.jpg) -![dependencies](https://badgen.net/david/dep/cupcakearmy/formhero) -![downloads badge](https://badgen.net/npm/dt/formhero) -![types badge](https://badgen.net/npm/types/formhero) ![version badge](https://badgen.net/npm/v/formhero) +![types badge](https://badgen.net/npm/types/formhero) +![downloads badge](https://badgen.net/npm/dt/formhero) +![dependencies](https://badgen.net//bundlephobia/dependency-count/formhero) ![minzip size badge](https://badgen.net/bundlephobia/minzip/formhero) **Fully customisable react form utility.** @@ -22,7 +22,7 @@ npm i formhero ``` -*Note:* Requires at least typescript version `3.5`, otherwise the error object will not have the right inherited types. +_Note:_ Requires at least typescript version `3.5`, otherwise the error object will not have the right inherited types. ### 👁 Demos @@ -99,7 +99,7 @@ const Form = () => { password: '', }, { - username: value => value.length > 3, + username: (value) => value.length > 3, email: { validator: /@/, message: 'Must contain an @', @@ -146,7 +146,7 @@ const Form = () => { return (
- ); -}; + ) +} ``` ## 📖 Documentation @@ -267,9 +267,9 @@ const validators = { message: 'My custom error message', }, /[\d]/, - async value => value.length > 0, + async (value) => value.length > 0, { - validator: value => true, + validator: (value) => true, message: 'Some other error', }, ], @@ -282,8 +282,8 @@ const validators = { const validators = { username: async (s: string) => { const taken = await API.isUsernameTaken(s) - return taken ? 'Username is taken': true - } + return taken ? 'Username is taken' : true + }, } ``` @@ -307,7 +307,7 @@ const validators = {} const options = { setter: 'value', // This is not stricly necessarry as 'value' would already be the default. getter: 'onChangeText', - extractor: text => text.toLowerCase(), + extractor: (text) => text.toLowerCase(), } export default () => { @@ -339,7 +339,7 @@ export default () => { {...field('username', { setter: 'value', // This is not stricly necessarry as 'value' would already be the default. getter: 'onChangeText', - extractor: text => text.toLowerCase(), + extractor: (text) => text.toLowerCase(), })} />