From f28421d7e700b9de9f2c482ab0f5ac57997816ac Mon Sep 17 00:00:00 2001
From: MadCcc <1075746765@qq.com>
Date: Tue, 20 Sep 2022 12:10:37 +0800
Subject: [PATCH 1/3] chore: migrate to dumi
---
.gitignore | 8 +++++++-
.umirc.ts | 13 +++++++++++++
docs/demo/simple.md | 3 +++
docs/examples/simple.tsx | 32 ++++++++++++++++++++++++++++++++
examples/simple.js | 40 ----------------------------------------
package.json | 8 +++++---
tsconfig.json | 19 +++++++++++++++++++
7 files changed, 79 insertions(+), 44 deletions(-)
create mode 100644 .umirc.ts
create mode 100644 docs/demo/simple.md
create mode 100644 docs/examples/simple.tsx
delete mode 100644 examples/simple.js
create mode 100644 tsconfig.json
diff --git a/.gitignore b/.gitignore
index f473a22..6c440bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,4 +27,10 @@ lib
es
yarn.lock
package-lock.json
-coverage/
\ No newline at end of file
+coverage/
+
+# umi
+.umi
+.umi-production
+.umi-test
+.env.local
\ No newline at end of file
diff --git a/.umirc.ts b/.umirc.ts
new file mode 100644
index 0000000..253c561
--- /dev/null
+++ b/.umirc.ts
@@ -0,0 +1,13 @@
+// more config: https://d.umijs.org/config
+import { defineConfig } from 'dumi';
+
+export default defineConfig({
+ title: 'rc-switch',
+ favicon: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
+ logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
+ outputPath: '.doc',
+ exportStatic: {},
+ base: '/switch',
+ publicPath: '/switch/',
+ hash: true,
+});
diff --git a/docs/demo/simple.md b/docs/demo/simple.md
new file mode 100644
index 0000000..5b3e79f
--- /dev/null
+++ b/docs/demo/simple.md
@@ -0,0 +1,3 @@
+# Simple
+
+
diff --git a/docs/examples/simple.tsx b/docs/examples/simple.tsx
new file mode 100644
index 0000000..a454799
--- /dev/null
+++ b/docs/examples/simple.tsx
@@ -0,0 +1,32 @@
+import '../../assets/index.less';
+import React, { useState } from 'react';
+import Switch, { SwitchChangeEventHandler } from 'rc-switch';
+
+const onChange: SwitchChangeEventHandler = (value, event) => {
+ // eslint-disable-next-line no-console
+ console.log(`switch checked: ${value}`, event);
+}
+
+export default () => {
+ const [disabled, setDisabled] = useState(false);
+
+ const toggle = () => {
+ setDisabled((prev) => !prev);
+ }
+
+ return (
+
+
+
+
+
+
+ )
+}
diff --git a/examples/simple.js b/examples/simple.js
deleted file mode 100644
index 1ae9dca..0000000
--- a/examples/simple.js
+++ /dev/null
@@ -1,40 +0,0 @@
-import '../assets/index.less';
-import React from 'react';
-import Switch from '../src';
-
-function onChange(value, event) {
- // eslint-disable-next-line no-console
- console.log(`switch checked: ${value}`, event);
-}
-
-export default class Simple extends React.Component {
- state = {
- disabled: false,
- };
-
- toggle = () => {
- const { disabled } = this.state;
- this.setState({
- disabled: !disabled,
- });
- };
-
- render() {
- const { disabled } = this.state;
- return (
-
-
-
-
-
-
- );
- }
-}
diff --git a/package.json b/package.json
index 53fa929..a8ea943 100644
--- a/package.json
+++ b/package.json
@@ -25,10 +25,11 @@
},
"license": "MIT",
"scripts": {
- "start": "father doc dev --storybook",
- "build": "father doc build --storybook",
+ "start": "dumi dev",
+ "docs:build": "dumi build",
+ "docs:deploy": "gh-pages -d .doc",
"compile": "father build && lessc assets/index.less assets/index.css",
- "gh-pages": "father doc deploy",
+ "gh-pages": "npm run docs:build && npm run docs:deploy",
"prepublishOnly": "npm run compile && np --yolo --no-publish",
"lint": "eslint .",
"test": "father test",
@@ -38,6 +39,7 @@
"@types/classnames": "^2.2.10",
"@types/jest": "^26.0.4",
"coveralls": "^3.0.6",
+ "dumi": "^1.1.0",
"enzyme": "^3.0.0",
"enzyme-adapter-react-16": "^1.0.1",
"enzyme-to-json": "^3.0.0",
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..4896d10
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "compilerOptions": {
+ "target": "esnext",
+ "module": "ESNext",
+ "moduleResolution": "node",
+ "baseUrl": "./",
+ "lib": ["dom", "es2017"],
+ "jsx": "react",
+ "strict": true,
+ "esModuleInterop": true,
+ "experimentalDecorators": true,
+ "emitDecoratorMetadata": true,
+ "skipLibCheck": true,
+ "declaration": true,
+ "paths": {
+ "rc-switch": ["src/index.tsx"]
+ }
+ }
+}
From 117898b039d81a496a927f9ad6a11a404af6f3e7 Mon Sep 17 00:00:00 2001
From: MadCcc <1075746765@qq.com>
Date: Tue, 20 Sep 2022 12:15:42 +0800
Subject: [PATCH 2/3] chore: use github actions ci
---
.github/workflows/main.yml | 114 +++++++++++++++++++++++++++++++++++++
.travis.yml | 31 ----------
2 files changed, 114 insertions(+), 31 deletions(-)
create mode 100644 .github/workflows/main.yml
delete mode 100644 .travis.yml
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..432a3fb
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,114 @@
+name: CI
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ setup:
+ runs-on: ubuntu-latest
+ steps:
+ - name: checkout
+ uses: actions/checkout@master
+
+ - uses: actions/setup-node@v1
+ with:
+ node-version: '12'
+
+ - name: cache package-lock.json
+ uses: actions/cache@v2
+ with:
+ path: package-temp-dir
+ key: lock-${{ github.sha }}
+
+ - name: create package-lock.json
+ run: npm i --package-lock-only
+
+ - name: hack for singe file
+ run: |
+ if [ ! -d "package-temp-dir" ]; then
+ mkdir package-temp-dir
+ fi
+ cp package-lock.json package-temp-dir
+
+ - name: cache node_modules
+ id: node_modules_cache_id
+ uses: actions/cache@v2
+ with:
+ path: node_modules
+ key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
+
+ - name: install
+ if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
+ run: npm ci
+
+ lint:
+ runs-on: ubuntu-latest
+ steps:
+ - name: checkout
+ uses: actions/checkout@master
+
+ - name: restore cache from package-lock.json
+ uses: actions/cache@v2
+ with:
+ path: package-temp-dir
+ key: lock-${{ github.sha }}
+
+ - name: restore cache from node_modules
+ uses: actions/cache@v2
+ with:
+ path: node_modules
+ key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
+
+ - name: lint
+ run: npm run lint
+
+ needs: setup
+
+ compile:
+ runs-on: ubuntu-latest
+ steps:
+ - name: checkout
+ uses: actions/checkout@master
+
+ - name: restore cache from package-lock.json
+ uses: actions/cache@v2
+ with:
+ path: package-temp-dir
+ key: lock-${{ github.sha }}
+
+ - name: restore cache from node_modules
+ uses: actions/cache@v2
+ with:
+ path: node_modules
+ key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
+
+ - name: compile
+ run: npm run compile
+
+ needs: setup
+
+ coverage:
+ runs-on: ubuntu-latest
+ steps:
+ - name: checkout
+ uses: actions/checkout@master
+
+ - name: restore cache from package-lock.json
+ uses: actions/cache@v2
+ with:
+ path: package-temp-dir
+ key: lock-${{ github.sha }}
+
+ - name: restore cache from node_modules
+ uses: actions/cache@v2
+ with:
+ path: node_modules
+ key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
+
+ - name: coverage
+ run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)
+
+ needs: setup
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 298cd9e..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-language: node_js
-
-sudo: false
-
-notifications:
- email:
- - yiminghe@gmail.com
- - afc163@gmail.com
-
-node_js:
-- 10
-
-before_install:
-- |
- if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs|examples))/'
- then
- echo "Only docs were updated, stopping build process."
- exit
- fi
-script:
-- |
- if [ "$TEST_TYPE" = test ]; then
- npm run coverage && \
- bash <(curl -s https://codecov.io/bash)
- else
- npm run $TEST_TYPE
- fi
-env:
- matrix:
- - TEST_TYPE=lint
- - TEST_TYPE=test
\ No newline at end of file
From 0a6b6d320159296e8be0ef4cabb68863445adcab Mon Sep 17 00:00:00 2001
From: MadCcc <1075746765@qq.com>
Date: Tue, 20 Sep 2022 13:57:45 +0800
Subject: [PATCH 3/3] test: fix lint
---
docs/examples/simple.tsx | 3 ++-
tests/index.spec.js | 3 +--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/examples/simple.tsx b/docs/examples/simple.tsx
index a454799..b0088be 100644
--- a/docs/examples/simple.tsx
+++ b/docs/examples/simple.tsx
@@ -1,6 +1,7 @@
import '../../assets/index.less';
import React, { useState } from 'react';
-import Switch, { SwitchChangeEventHandler } from 'rc-switch';
+import type { SwitchChangeEventHandler } from 'rc-switch';
+import Switch from 'rc-switch';
const onChange: SwitchChangeEventHandler = (value, event) => {
// eslint-disable-next-line no-console
diff --git a/tests/index.spec.js b/tests/index.spec.js
index a64b58b..02ec46a 100644
--- a/tests/index.spec.js
+++ b/tests/index.spec.js
@@ -1,8 +1,7 @@
import React from 'react';
import KeyCode from 'rc-util/lib/KeyCode';
-// eslint-disable-next-line import/no-extraneous-dependencies
import { mount } from 'enzyme';
-import Switch from '../index';
+import Switch from '..';
describe('rc-switch', () => {
function createSwitch(props = {}) {