diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..d0824f433 --- /dev/null +++ b/.babelrc @@ -0,0 +1,46 @@ +{ + "env": { + "development": { + "presets": [ + "react-native" + ], + "plugins": [ + [ + "import", + { + "libraryName": "antd-mobile", + "libraryDirectory": "components" + } + ] + ] + }, + "production": { + "presets": [ + "react-native" + ], + "plugins": [ + [ + "import", + { + "libraryName": "antd-mobile", + "libraryDirectory": "components" + } + ] + ] + }, + "test": { + "presets": [ + "react-native" + ], + "plugins": [ + [ + "import", + { + "libraryName": "antd-mobile", + "libraryDirectory": "components" + } + ] + ] + } + } +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..3d31c1249 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +# editorconfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..bb7762f79 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +components/**/*.js +components/**/*.jsx +components/*/__tests__/type.tsx +!.eslintrc.js +!components/*/__tests__/**/*.js +!components/*/demo/* diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..589cbf0f6 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,77 @@ +const eslintrc = { + extends: ['eslint-config-airbnb'], + env: { + browser: true, + node: true, + mocha: true, + jest: true, + es6: true, + }, + parser: 'babel-eslint', + parserOptions: { + ecmaVersion: 6, + ecmaFeatures: { + jsx: true, + experimentalObjectRestSpread: true, + }, + }, + plugins: [ + 'markdown', + 'react', + 'babel', + 'jsx-a11y', + ], + rules: { + 'class-methods-use-this': 0, + 'func-names': 0, + 'react/sort-comp': 0, + 'react/prop-types': 0, + 'react/jsx-first-prop-new-line': 0, + 'no-param-reassign': 0, + 'no-return-assign': 0, + 'max-len': 0, + 'react/no-multi-comp': 0, + 'array-callback-return': 0, + 'import/no-unresolved': 0, + 'jsx-a11y/img-has-alt': 0, + 'import/extensions': 0, + 'import/no-extraneous-dependencies': 0, + 'react/no-string-refs': 0, + 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', '.tsx', '.md'] }], + 'react/no-array-index-key': 0, + 'react/no-find-dom-node': 0, + 'react/require-extension': 0, + 'jsx-a11y/anchor-has-content': 0, + 'jsx-a11y/href-no-hash': 0, + 'jsx-a11y/no-static-element-interactions': 0, + 'jsx-a11y/click-events-have-key-events': 0, + 'prefer-destructuring': 0, + 'jsx-a11y/anchor-is-valid': 0, + 'react/jsx-no-comment-textnodes': 0, + 'object-curly-newline': 0, + }, +}; + +if (process.env.RUN_ENV === 'DEMO') { + eslintrc.globals = { + React: true, + ReactDOM: true, + mountNode: true, + AlipayJSBridge: true, + $: true, + dd: true, + process: true, + }; + + Object.assign(eslintrc.rules, { + 'no-console': 0, + 'no-alert': 0, + 'no-plusplus': 0, + 'import/no-webpack-loader-syntax': 0, + 'eol-last': 0, + 'prefer-rest-params': 0, + 'react/no-multi-comp': 0, + }); +} + +module.exports = eslintrc; diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 000000000..fb3fe2fc0 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,56 @@ +# Contributing to Ant Design Mobile + +The following is a set of guidelines for contributing to Ant Design Mobile. Please spend several minutes in reading these guidelines before you create an issue or pull request. + +Anyway, these are just guidelines, not rules, use your best judgment and feel free to propose changes to this document in a pull request. + + +## Do your homework before asking a question + +It's a great idea to read Eric Steven Raymond's [How To Ask Questions The Smart Way](http://www.catb.org/esr/faqs/smart-questions.html) twice before asking a question. But if you are busy now, I recommend to read [Don't post homework questions](http://www.catb.org/esr/faqs/smart-questions.html#homework) first. + +The following guidelines are about *How to avoid Homework Questions*. + +### 1. Read the documentation. + +It sad but true that someone just glance(not read) [Ant Design Mobile's documentation](http://mobile.ant.design/). Please read the documentation closely. + +Tips: choose the corresponding documentation with versions selector which in the bottom-right corner. + +### 2. Make sure that your question is about Ant Design Mobile, not React + +Someone may think all of the questions that he/she meets in developing are about Ant Design Mobile, but it's not true. So, please read [React's documentaion](http://facebook.github.io/react/docs/getting-started.html) or just Google(not Baidu, seriously) your questions with keywork *React* first. If you are sure that your question is about Ant Design Mobile, go ahead. + +### 3. Read the FAQ and search the issues list of Ant Design Mobile + +Your questions may be asked and solved by others. So please spend several minutes on searching. Remember [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself), both code and questions. + +P.S. + +1. [FAQ](https://github.com/ant-design/ant-design-mobile-rn/wiki/FAQ) +1. [Issues list](https://github.com/ant-design/ant-design-mobile-rn/issues) + +## Close your issue if it's solved + +It is a good habit which will save maintainers' time. Thank you! + +## Providing a demo while reporting a bug + +It would be helpful to provide a demo which can re-produce the bug 100%. Please give us the steps in detail that can help us re-producing the bug you met. Then, create an issue. The most important thing is: double check before claiming that you have found a bug. + + +## Tips about Feature Request + +If you believe that Ant Design Mobile should provide some features, but it does not. You could create an issue to discuss. However, Ant Design Mobile is not Swiss Army Knife, there are some features which Ant Design Mobile will not support: + +1. Request or operate data + + +## Tips about Pull Request + +It's welcomed to pull request. And there are some tips about that: + +1. It is a good habit to create a feature request issue to disscuss whether the feature is necessary before you implement it. However, it's unnecessary to create an issue to claim that you found a typo or improved the readability of documentaion, just create a pull request. +1. Run `npm run lint` and fix those errors before committing in order to keep consistent code style. +1. Rebase before creating a PR to keep commit history clear. +1. Add some descriptions and refer relative issues for you PR. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..84edd3f5b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,15 @@ + + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..5d43c208d --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,21 @@ +First of all, thank you for your contribution! :-) + +Please makes sure that these checkboxes are checked before submitting your PR, thank you! + +* [ ] Make sure that you follow antd's [code convention](https://github.com/ant-design/ant-design/wiki/Code-convention-for-antd). +* [ ] Run `npm run lint` and fix those errors before submitting in order to keep consistent code style. +* [ ] Rebase before creating a PR to keep commit history clear. +* [ ] Add some descriptions and refer relative issues for you PR. + +Extra checklist: + +**if** *isBugFix* **:** + + * [ ] Make sure that you add at least one unit test for the bug which you had fixed. + +**elif** *isNewFeature* **:** + + * [ ] Update API docs for the component. + * [ ] Update/Add demo to demonstrate new feature. + * [ ] Update TypeScript definition for the component. + * [ ] Add unit tests for the feature. diff --git a/.github/lock.yml b/.github/lock.yml new file mode 100644 index 000000000..1322279db --- /dev/null +++ b/.github/lock.yml @@ -0,0 +1,14 @@ +# Configuration for lock-threads - https://github.com/dessant/lock-threads + +# Number of days of inactivity before a closed issue or pull request is locked +daysUntilLock: 510 +# Comment to post before locking. Set to `false` to disable +lockComment: > + This thread has been automatically locked because it has not had recent + activity. Please open a new issue for related bugs and link to relevant + comments in this thread. +# Issues or pull requests with these labels will not be locked +# exemptLabels: +# - no-locking +# Limit to only `issues` or `pulls` +only: issues diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..ba8733433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +*.iml +.idea/ +.ipr +.iws +*~ +~* +*.diff +*.patch +*.bak +.DS_Store +Thumbs.db +.project +.*proj +.svn/ +*.swp +*.swo +*.log +node_modules/ +.buildpath +.settings +npm-debug.log +nohup.out +_site +/dist +lib +elasticsearch-* +config/base.yaml +_data +rn-kitchen-sink/ios/build +rn-kitchen-sink/ios/bundle +rn-kitchen-sink/android/bundle +rn-kitchen-sink/android/.gradle +rn-kitchen-sink/android/app/build +rn-kitchen-sink/android/build +rn-kitchen-sink/android/local.properties +rn-kitchen-sink/android/app/src/main/res/drawable* +rn-kitchen-sink/app/*.ipa +rn-kitchen-sink/app/*.apk +xcuserdata +components/**/*.jsx +components/**/*.js +my-release-key.keystore +.vscode +yarn.lock +npm-debug.log* +!components/**/__tests__/*.js +coverage +/es/ +package-lock.json +.cdnkey diff --git a/.jest.native.js b/.jest.native.js new file mode 100644 index 000000000..275aff144 --- /dev/null +++ b/.jest.native.js @@ -0,0 +1,46 @@ +const libDir = process.env.LIB_DIR; + +const transformPackages = [ + 'react-native', + 'react-native-menu', + 'react-native-tab-view', + 'react-native-collapsible', + 'react-native-swipeout', + 'react-native-camera-roll-picker', +] + +module.exports = { + preset: 'react-native', + setupFiles: [ + './tests/setup.native.js' + ], + moduleFileExtensions: [ + 'native.ts', + 'native.tsx', + 'native.js', + 'native.jsx', + 'ts', + 'tsx', + 'js', + 'jsx', + 'json', + ], + testPathIgnorePatterns: [ + '/node_modules/', + '_site', + 'site', + ], + transform: { + '\\.tsx?$': './node_modules/antd-tools/lib/jest/codePreprocessor', + '\\.js$': './node_modules/antd-tools/lib/jest/codePreprocessor', + '\\.png': '/tests/imageStub.js', + }, + testRegex: libDir === 'dist' ? 'demo\\.test\\.native\\.js$' : '.*\\.test\\.native\\.js$', + collectCoverageFrom: [ + 'components/**/*.native.{ts,tsx}', + '!components/*/style/*.{ts,tsx}', + ], + transformIgnorePatterns: [ + `node_modules/(?!(${transformPackages.join('|')})/)`, + ], +}; diff --git a/.npmignore b/.npmignore new file mode 100644 index 000000000..53fe3b21b --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +lib/**/demo/*.* diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..26fc1999e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,45 @@ +sudo: false + +git: + submodules: false + +language: node_js + +notifications: + email: + - hust2012jiangkai@gmail.com + - hualei5280@gmail.com + - zhang740@qq.com + - rjmuqiang@gmail.com + +node_js: + - "8" + +env: + matrix: + - TEST_TYPE=lint + - TEST_TYPE=dist + - TEST_TYPE=compile + - TEST_TYPE=test:web + - TEST_TYPE=test:rn + +script: + - | + if [ "$TEST_TYPE" = lint ]; then + npm run lint + elif [ "$TEST_TYPE" = dist ]; then + npm run dist && \ + LIB_DIR=dist npm run test:web -- -w 2 + elif [ "$TEST_TYPE" = compile ]; then + npm run compile && \ + LIB_DIR=lib npm run test:web -- -w 2 && \ + LIB_DIR=lib npm run test:rn -- -w 2 && \ + LIB_DIR=es npm run test:web -- -w 2 + LIB_DIR=es npm run test:rn -- -w 2 + elif [ "$TEST_TYPE" = test:web ]; then + npm run test:web -- -w 2 --coverage && \ + bash <(curl -s https://codecov.io/bash) -cF web + elif [ "$TEST_TYPE" = test:rn ]; then + npm run test:rn -- -w 2 --coverage && \ + bash <(curl -s https://codecov.io/bash) -cF rn + fi diff --git a/AUTHORS.txt b/AUTHORS.txt new file mode 100644 index 000000000..d6a623339 --- /dev/null +++ b/AUTHORS.txt @@ -0,0 +1,51 @@ +Alexander Kiryukhin +BccSafe +Benjy Cui +Chris +Daniel Wang +David Sun +Guten Ye +Kim <261835705@qq.com> +Lxxyx +Shafley Xia +Wei Zhu +Zhang Weijie +afc163 +benjycui +ddcat1115 +foriacus <634844533@qq.com> +foriacus +jljsj +ko +liqi07 +lixiaochou077 +lixiaoyang +lotushacker +paranoidjk +pingan1927 +rubyinwater +silentcloud +slientcloud +snadn +temu.psc +u9lyfish@gmail.com +warmhug +yang.deng +yezongyang <948704165@qq.com> +yiminghe +zengyue ye +zhaocai +万焱 +偏右 +加里 +勤拭 +叶宗洋 +左宜 +本杰 +林法鑫 +欧自成 +沐泊 +法新 +法新 +然则 +观通 diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..cdd744ae7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT LICENSE + +Copyright (c) 2016-present Alipay.com, https://www.alipay.com/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 000000000..6304ef710 --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +English | [简体中文](./README.zh-CN.md) + +

+ + + +

+ +# Ant Design Mobile +[![](https://img.shields.io/travis/ant-design/ant-design-mobile.svg?style=flat-square)](https://travis-ci.org/ant-design/ant-design-mobile) +[![Codecov](https://img.shields.io/codecov/c/github/ant-design/ant-design-mobile.svg?style=flat-square)](https://codecov.io/gh/ant-design/ant-design-mobile) +[![npm package](https://img.shields.io/npm/v/antd-mobile.svg?style=flat-square)](https://www.npmjs.org/package/antd-mobile) +[![NPM downloads](http://img.shields.io/npm/dm/antd-mobile.svg?style=flat-square)](https://npmjs.org/package/antd-mobile) +[![Dependency Status](https://david-dm.org/ant-design/ant-design-mobile.svg?style=flat-square)](https://david-dm.org/ant-design/ant-design-mobile) +[![CDNJS](https://img.shields.io/cdnjs/v/antd-mobile.svg?style=flat-square)](https://cdnjs.com/libraries/antd-mobile) +[![Percentage of issues still open](http://isitmaintained.com/badge/open/ant-design/ant-design-mobile.svg)](http://isitmaintained.com/project/ant-design/ant-design-mobile "Percentage of issues still open") +[![Join the chat at https://gitter.im/ant-design/ant-design](https://img.shields.io/gitter/room/ant-design/ant-design.svg?style=flat-square)](https://gitter.im/ant-design/ant-design?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +A configurable Mobile UI specification and React-based implementation. + +[中文 README](README.zh-CN.md) + +

+Note: In antd-mobile@2.2.0, React Native components will be transferred to the separate `antd-mobile-rn` package. Ref: #2556 +

+ +## Features + +- Follow Ant Design Mobile UI specification. +- Configurable UI style for different products. +- Support web and native usages based on React Native. +- Develop in TypeScript. + +## Demo + +### mobile web demo + + + +http://mobile.ant.design/kitchen-sink/ + +### react native demo + + + +install expo app: https://expo.io/tools + +## Install & Usage + +[introduce](docs/react/introduce.en-US.md#安装) + +## Browser Support + +- `iOS` +- `Android 4.0+` + +## Links + +- [Home Page](http://mobile.ant.design) +- [Developer Instruction](http://github.com/ant-design/ant-design-mobile/blob/master/development.en-US.md) +- [React components](http://github.com/react-component/) +- [Demos](https://github.com/ant-design/antd-mobile-samples) + +## Contributing + +We welcome all contributions, please read our [CONTRIBUTING.md](https://github.com/ant-design/ant-design-mobile/blob/master/.github/CONTRIBUTING.md) first. You can submit any ideas as [pull requests](https://github.com/ant-design/ant-design-mobile/pulls) or as a [GitHub issue](https://github.com/ant-design/ant-design-mobile/issues). If you'd like to improve code, check out the [Development Instruction](https://github.com/ant-design/ant-design-mobile/blob/master/development.en-US.md) and have a good time! :) diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 000000000..c000ca48a --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,63 @@ +[English](./README.md) | 简体中文 + +

+ + + +

+ +# Ant Design Mobile +[![](https://img.shields.io/travis/ant-design/ant-design-mobile.svg?style=flat-square)](https://travis-ci.org/ant-design/ant-design-mobile) +[![Codecov](https://img.shields.io/codecov/c/github/ant-design/ant-design-mobile.svg?style=flat-square)](https://codecov.io/gh/ant-design/ant-design-mobile) +[![npm package](https://img.shields.io/npm/v/antd-mobile.svg?style=flat-square)](https://www.npmjs.org/package/antd-mobile) +[![NPM downloads](http://img.shields.io/npm/dm/antd-mobile.svg?style=flat-square)](https://npmjs.org/package/antd-mobile) +[![Dependency Status](https://david-dm.org/ant-design/ant-design-mobile.svg?style=flat-square)](https://david-dm.org/ant-design/ant-design-mobile) +[![CDNJS](https://img.shields.io/cdnjs/v/antd-mobile.svg?style=flat-square)](https://cdnjs.com/libraries/antd-mobile) +[![Percentage of issues still open](http://isitmaintained.com/badge/open/ant-design/ant-design-mobile.svg)](http://isitmaintained.com/project/ant-design/ant-design-mobile "Percentage of issues still open") +[![Join the chat at https://gitter.im/ant-design/ant-design](https://img.shields.io/gitter/room/ant-design/ant-design.svg?style=flat-square)](https://gitter.im/ant-design/ant-design?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +Ant Design 移动端设计规范。`antd-mobile` 是 Ant Design 的移动规范的 React 实现,服务于蚂蚁及口碑无线业务。 + +[README in English](README.md) + +## 特性 + +- 基于 Ant Design 移动设计规范。 +- 规则化的视觉样式配置,适应各类产品风格。 +- 基于 React Native 的多平台支持。 +- 使用 TypeScript 开发,提供类型定义文件。 + +## 演示 + +### mobile web demo + + + +http://mobile.ant.design/kitchen-sink/ + +### react native demo + + + +请先安装 expo app: https://expo.io/tools + +## 安装 & 使用 + +[介绍](docs/react/introduce.zh-CN.md#安装) + +## 浏览器支持 + +- `iOS` +- `Android 4.0+` + +## 链接 + +- [首页](http://mobile.ant.design) +- [国内镜像站点 🇨🇳](https://antd-mobile.gitee.io) +- [开发文档](development.zh-CN.md) +- [底层 React 模块](http://github.com/react-component) +- [官方 Demo 集合](https://github.com/ant-design/antd-mobile-samples) + +## 欢迎贡献 + +有任何建议或意见您可以进行 [提问](http://github.com/ant-design/ant-design-mobile/issues)。 diff --git a/index.native.js b/index.native.js new file mode 100644 index 000000000..139c25135 --- /dev/null +++ b/index.native.js @@ -0,0 +1 @@ +module.exports = require('./components/index.native'); diff --git a/package.json b/package.json index b3d14fb84..faa3ba285 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,153 @@ { "name": "antd-mobile-rn", - "version": "0.0.0", - "description": "", - "keywords": [], - "author": "", - "license": "MIT" + "version": "2.2.0-beta.0", + "description": "基于蚂蚁金服移动设计规范的 React Native 组件库", + "keywords": [ + "ant", + "design", + "react", + "react-component", + "component", + "components", + "ui", + "framework", + "frontend", + "mobile", + "react native" + ], + "repository": { + "type": "git", + "url": "http://github.com/ant-design/ant-design-mobile-rn" + }, + "bugs": { + "url": "http://github.com/ant-design/ant-design-mobile-rn/issues" + }, + "files": [ + "lib", + "es" + ], + "license": "MIT", + "main": "lib/index.native.js", + "module": "es/index.native.js", + "dependencies": { + "array-tree-filter": "~2.1.0", + "babel-runtime": "6.x", + "rc-swipeout": "~2.0.0", + "react-native-camera-roll-picker": "^1.2.1", + "react-native-collapsible": "^0.9.0", + "react-native-drawer-layout": "~1.3.0", + "react-native-menu": "^0.23.0", + "rmc-cascader": "~5.0.0", + "rmc-date-picker": "^6.0.8", + "rmc-dialog": "^1.0.1", + "rmc-input-number": "^1.0.0", + "rmc-picker": "~5.0.0", + "rmc-tabs": "~1.2.0", + "rn-topview": "^0.1.6" + }, + "devDependencies": { + "@types/prop-types": "^15.5.2", + "@types/react": "~16.0.36", + "@types/react-dom": "16.0.3", + "@types/react-native": "^0.52.8", + "@types/react-native-collapsible": "^0.8.0", + "@types/react-native-drawer-layout": "1.3.3", + "antd": "3.x", + "antd-mobile-demo-data": "^0.2.0", + "antd-tools": "^4.0.2", + "babel-eslint": "^7.2.3", + "babel-plugin-import": "^1.6.2", + "babel-plugin-transform-runtime": "^6.23.0", + "babel-preset-react-native": "^1.0.0", + "bisheng": "^0.28.0", + "bisheng-plugin-antd": "^0.16.0", + "bisheng-plugin-description": "^0.1.1", + "bisheng-plugin-react": "^0.6.0", + "bisheng-plugin-toc": "^0.4.0", + "concurrently": "^3.4.0", + "cross-env": "^5.0.1", + "dora-plugin-upload": "^0.3.1", + "enquire.js": "^2.1.1", + "enzyme": "^3.0.0", + "enzyme-adapter-react-16": "^1.0.0", + "enzyme-to-json": "^3.0.0", + "eslint": "~4.3.0", + "eslint-config-airbnb": "~15.1.0", + "eslint-plugin-babel": "~4.1.1", + "eslint-plugin-import": "~2.7.0", + "eslint-plugin-jsx-a11y": "~6.0.2", + "eslint-plugin-markdown": "~1.0.0-beta.6", + "eslint-plugin-react": "~7.2.0", + "eslint-tinker": "~0.4.1", + "glob": "^7.1.1", + "jest": "^21.0.0", + "jsonml.js": "^0.1.0", + "lint-staged": "^7.0.0", + "mockdate": "^2.0.1", + "pre-commit": "1.x", + "qrcode.react": "^0.7.1", + "raf": "^3.4.0", + "rc-form": "1.x", + "react": "^16.0.0", + "react-copy-to-clipboard": "^5.0.0", + "react-document-title": "^2.0.1", + "react-dom": "^16.0.0", + "react-github-button": "^0.1.9", + "react-intl": "^2.2.3", + "react-native": "~0.49.3", + "react-native-code-push": "^5.1.1-beta", + "react-native-mocker": "^0.0.12", + "react-navigation": "1.0.0-beta.12", + "react-sticky": "^6.0.1", + "react-test-renderer": "^16.0.0", + "typescript": "~2.4.0" + }, + "scripts": { + "lint": "npm run tslint && npm run srclint && npm run stylelint && npm run applint", + "srclint": "eslint site scripts --ext '.js,.jsx'", + "tslint": "antd-tools run ts-lint && npm run compile && rm -rf lib", + "tslint-fix": "antd-tools run ts-lint-fix && npm run compile && rm -rf lib", + "applint": "eslint rn-kitchen-sink --ext '.js'", + "pre-publish": "npm run test:all && node ./scripts/build-less-entry", + "prepublish": "antd-tools run guard", + "prepare": "antd-tools run guard", + "prepublishOnly": "antd-tools run guard", + "test": "jest --config .jest.native.js", + "test:all": "./scripts/test-all.sh", + "dist": "cross-env BABEL_ENV=dist antd-tools run dist", + "compile": "cross-env BABEL_ENV=dist antd-tools run compile", + "watch-tsc": "antd-tools run watch-tsc", + "clean": "antd-tools run clean", + "start": "cross-env NODE_ENV=development cross-env DEMO_ENV=react bisheng start -c ./site/bisheng.desktop.config.js", + "site": "cross-env NODE_ENV=production cross-env DEMO_ENV=react bisheng build -c ./site/bisheng.desktop.config.js && node scripts/copy-app-res", + "deploy": "npm run clean && npm run site && bisheng gh-pages --push-only", + "pub": "cross-env BABEL_ENV=dist antd-tools run pub", + "rn-start": "node node_modules/react-native/local-cli/cli.js start", + "ios": "concurrently \"npm run watch-tsc\" \"npm run _ios\"", + "android": "concurrently \"npm run watch-tsc\" \"npm run _android\"", + "_ios": "node node_modules/react-native/local-cli/cli.js run-ios --project-path rn-kitchen-sink/ios", + "_android": "node node_modules/react-native/local-cli/cli.js run-android --root rn-kitchen-sink", + "build-rn-ios": "node scripts/rn-mkdir && node node_modules/react-native/local-cli/cli.js bundle --platform ios --dev false --entry-file rn-kitchen-sink/index.ios.js --bundle-output rn-kitchen-sink/ios/bundle/index.ios.bundle --assets-dest rn-kitchen-sink/ios/bundle", + "build-rn-android": "node scripts/rn-mkdir && node node_modules/react-native/local-cli/cli.js bundle --platform android --dev false --entry-file rn-kitchen-sink/index.android.js --bundle-output rn-kitchen-sink/android/bundle/index.android.bundle --assets-dest rn-kitchen-sink/android/bundle", + "build-rn": "npm run tsc && npm run build-rn-ios && npm run build-rn-android", + "lint-staged": "lint-staged", + "lint-staged:ts": "npm run tsc && node node_modules/tslint/bin/tslint -c node_modules/antd-tools/lib/tslint.json components/**/*.tsx", + "lint-staged:es": "eslint ./.eslintrc.js", + "tsc": "antd-tools run tsc" + }, + "lint-staged": { + "components/**/*.tsx": [ + "npm run lint-staged:ts" + ], + "{tests,site,scripts,components}/**/*.{js,jsx}": [ + "npm run lint-staged:es" + ] + }, + "config": { + "port": 8003 + }, + "typings": "lib/index.native.d.ts", + "pre-commit": [ + "lint-staged" + ] } diff --git a/scripts/copy-app-res.js b/scripts/copy-app-res.js new file mode 100644 index 000000000..a1782e6c9 --- /dev/null +++ b/scripts/copy-app-res.js @@ -0,0 +1,10 @@ +const path = require('path'); +const shell = require('child_process').execSync; + +const fromDir = path.join(__dirname, '../rn-kitchen-sink/app'); +const fromDir2 = path.join(__dirname, '../rn-kitchen-sink/dist'); +const toDir = path.join(__dirname, '../_site/rn-kitchen-sink'); + +shell(`mkdir -p ${toDir}`); +shell(`cp -r ${fromDir}/* ${toDir}`); +shell(`cp -r ${fromDir2}/* ${toDir}`); diff --git a/scripts/rn-mkdir.js b/scripts/rn-mkdir.js new file mode 100644 index 000000000..c2e036d4f --- /dev/null +++ b/scripts/rn-mkdir.js @@ -0,0 +1,12 @@ +const fs = require('fs'); +const path = require('path'); + +const iosDir = path.join(__dirname, '../rn-kitchen-sink/ios/bundle'); +if (!fs.existsSync(iosDir)) { + fs.mkdirSync(iosDir); +} + +const androidDir = path.join(__dirname, '../rn-kitchen-sink/android/bundle'); +if (!fs.existsSync(androidDir)) { + fs.mkdirSync(androidDir); +} diff --git a/scripts/test-all.sh b/scripts/test-all.sh new file mode 100755 index 000000000..b5ec9919c --- /dev/null +++ b/scripts/test-all.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +set -x + +npm run lint && \ +npm run dist && \ +npm run compile && \ +LIB_DIR=lib npm run test -- --no-cache && \ +LIB_DIR=es npm run test -- --no-cache && \ +npm run test diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..f9b0948a7 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "strictNullChecks": true, + "moduleResolution": "node", + "jsx": "preserve", + "noUnusedParameters": true, + "noUnusedLocals": true, + "allowSyntheticDefaultImports":true, + "target": "es6", + "noImplicitAny": true, + "types": [ + "classnames", + "react", + "react-dom", + "react-native" + ] + }, + "exclude": [ + "node_modules", + "lib", + "es" + ], + "compileOnSave": false +} diff --git a/typings/custom.d.ts b/typings/custom.d.ts new file mode 100644 index 000000000..50713e55e --- /dev/null +++ b/typings/custom.d.ts @@ -0,0 +1,19 @@ +declare module 'antd-mobile'; + +declare module 'antd-mobile-demo-data'; + +declare module 'rn-topview'; + +declare module 'react-native-camera-roll-picker'; + +declare module 'rmc-dialog'; +declare module 'react-native-menu'; +declare module 'react-native/Libraries/StyleSheet/normalizeColor'; +declare module 'react-native/Libraries/StyleSheet/setNormalizedColorAlpha'; + +declare var process: { + env: { + NODE_ENV: string; + DISABLE_ANTD_MOBILE_UPGRADE: string; + }; +}; diff --git a/typings/index.d.ts b/typings/index.d.ts new file mode 100644 index 000000000..09e70c535 --- /dev/null +++ b/typings/index.d.ts @@ -0,0 +1 @@ +///