-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(a-ret): 增加
NotFound
和 InternalServerError
组件
- Loading branch information
Showing
8 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 22 * * *' | ||
|
||
jobs: | ||
jest: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [ 12, 14, 16 ] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- uses: actions/cache@v1 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Replace package dependencies | ||
run: npx replace-pkg-dep package.json main | ||
|
||
- name: Yarn install | ||
run: yarn install --ignore-engines | ||
|
||
- name: Run | ||
run: yarn miaoxing-jest | ||
|
||
- name: Coveralls | ||
if: startsWith(hashFiles('coverage/lcov.info'), '5df6e0e27613') == false | ||
continue-on-error: true | ||
env: | ||
COVERALLS_FLAG_NAME: node-${{ matrix.node-version }} | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
parallel: true | ||
|
||
coveralls-finish: | ||
needs: [ jest ] | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
steps: | ||
- name: Coveralls Finished | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.github_token }} | ||
parallel-finished: true | ||
|
||
eslint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [ 20 ] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- uses: actions/cache@v1 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Replace package dependencies | ||
run: npx replace-pkg-dep package.json main | ||
|
||
- name: Yarn install | ||
run: yarn install | ||
|
||
- name: Run | ||
run: yarn miaoxing-eslint | ||
|
||
stylelint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [ 20 ] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- uses: actions/cache@v1 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/package.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Replace package dependencies | ||
run: npx replace-pkg-dep package.json main | ||
|
||
- name: Yarn install | ||
run: yarn install | ||
|
||
- name: Run | ||
run: yarn miaoxing-stylelint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Result} from 'antd'; | ||
import {BtnLink} from '@mxjs/a-button'; | ||
|
||
const InternalServerError = (props) => ( | ||
<Result | ||
status="500" | ||
title="出错了" | ||
subTitle="很抱歉,加载出错!" | ||
extra={<BtnLink to="/" type="primary">返回首页</BtnLink>} | ||
{...props} | ||
/> | ||
); | ||
|
||
export default InternalServerError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Result} from 'antd'; | ||
import {BtnLink} from '@mxjs/a-button'; | ||
|
||
const NotFound = (props) => ( | ||
<Result | ||
status="404" | ||
title="404" | ||
subTitle="很抱歉,您访问的页面不存在,请检查后再试。" | ||
extra={<BtnLink to="/" type="primary">返回首页</BtnLink>} | ||
{...props} | ||
/> | ||
); | ||
|
||
export default NotFound; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# miaoxing-a-ret | ||
|
||
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/miaoxing/mxjs-a-ret/build.yml?style=flat-square)](https://github.com/miaoxing/mxjs-a-ret/actions) | ||
[![Coverage Status](https://img.shields.io/coveralls/miaoxing/mxjs-a-ret.svg?style=flat-square)](https://coveralls.io/r/miaoxing/mxjs-a-ret) | ||
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://www.opensource.org/licenses/MIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { InternalServerError, NotFound } from '..'; | ||
import { render } from '@testing-library/react'; | ||
import { MemoryRouter } from 'react-router'; | ||
|
||
describe('Ret', () => { | ||
test('NotFound', async () => { | ||
const result = render(<MemoryRouter><NotFound/></MemoryRouter>); | ||
await result.findByText('404'); | ||
}); | ||
|
||
test('InternalServerError', async () => { | ||
const result = render(<MemoryRouter><InternalServerError/></MemoryRouter>); | ||
await result.findByText('出错了'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
presets: [ | ||
'babel-preset-miaoxing', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export NotFound from './NotFound'; | ||
export InternalServerError from './InternalServerError'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters