Skip to content

Commit

Permalink
feat(a-ret): 增加 NotFoundInternalServerError 组件
Browse files Browse the repository at this point in the history
  • Loading branch information
twinh committed Jan 24, 2024
1 parent 2d92887 commit 80670fb
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 0 deletions.
134 changes: 134 additions & 0 deletions .github/workflows/build.yml
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
14 changes: 14 additions & 0 deletions InternalServerError.js
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;
14 changes: 14 additions & 0 deletions NotFound.js
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;
5 changes: 5 additions & 0 deletions README.md
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)
15 changes: 15 additions & 0 deletions __tests__/Ret.js
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('出错了');
});
});
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'babel-preset-miaoxing',
],
};
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export NotFound from './NotFound';
export InternalServerError from './InternalServerError';
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,31 @@
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"jest": {
"preset": "jest-preset-miaoxing"
},
"dependencies": {
"@mxjs/a-button": "^3.0.5",
"antd": "~5.1.6",
"prop-types": "^15.7.2",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0"
},
"devDependencies": {
"@miaoxing/dev": "^9.1.0",
"@testing-library/react": "^11.2.6",
"react": ">=16.13.1",
"react-dom": ">=16.13.1"
},
"peerDependencies": {
"react": ">=16.13.1",
"react-dom": ">=16.13.1"
},
"ciDependencies": {
"miaoxing": "miaoxing/miaoxing-js",
"babel-preset-miaoxing": "miaoxing/babel-preset-miaoxing",
"jest-preset-miaoxing": "miaoxing/jest-preset-miaoxing",
"@miaoxing/dev": "miaoxing/dev"
}
}

0 comments on commit 80670fb

Please sign in to comment.