From 3eff40b37b8d6c168d9cba82cfe4e3efb44d6499 Mon Sep 17 00:00:00 2001 From: xiaoiver Date: Fri, 29 Nov 2019 15:38:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Windows=20=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=BC=80=E5=8F=91=E9=97=AE=E9=A2=98=20(#109)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(windows): preparing Windows environment * re #101, add `CONTRIBUTING.md` * chore(windows): fix lerna watch command in Windows --- .github/CONTRIBUTING.md | 84 +++++++++++++++++++++++++ .travis.yml | 14 +++++ README.md | 26 +------- README.zh-CN.md | 51 +-------------- jest.config.js | 2 +- package.json | 19 +++--- stories/Components/components/Popup.tsx | 1 - yarn.lock | 7 +++ 8 files changed, 119 insertions(+), 85 deletions(-) create mode 100644 .github/CONTRIBUTING.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000000..c298f0aade --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,84 @@ +# Contributing to L7 + +👍🎉 欢迎向 L7 贡献代码! 🎉👍 + +## 前置依赖安装 + +### 安装 Yarn + +由于使用了 Yarn workspace,首先需要安装 Yarn:https://yarnpkg.com/en/docs/install#windows-stable + +### Windows 环境配置 + +[L7 测试方案](https://github.com/antvis/L7/blob/master/dev-docs/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E6%96%B9%E6%A1%88.md)依赖 headless-gl,其中需要 node-gyp [编译本地依赖](https://github.com/nodejs/node-gyp#on-windows)。 + +1. 首先以管理员身份启动 PowerShell +2. 运行 `npm install --global --production windows-build-tools`,安装 Microsoft's windows-build-tools + +安装过程中其他问题[详见](https://github.com/antvis/L7/issues/101)。 + +## 安装依赖 + +安装依赖并完成 Yarn workspace 初始化: +```bash +yarn install +``` + +### Windows + +```bash +copy node_modules/gl/deps/windows/dll/x64/*.dll c:\windows\system32 +``` + +## 运行 DEMO + +启动各个 package 代码变更监听: +```bash +yarn watch +``` + +启动 Storybook,会自动打开 `http://localhost:6006/`: +```bash +yarn storybook +``` + +## 运行测试 + +运行单元测试: +```bash +yarn test +``` + +运行单元测试并查看代码覆盖率: +```bash +yarn coveralls +``` + +## 添加 Lerna package + +添加一个新的 lerna package: +```bash +lerna create my-pack -y +``` + +将 ui-lib 作为 my-pack 的依赖: +```bash +yarn workspace my-pack add ui-lib/1.0.0 +``` + +将 lodash 添加为所有 package 的依赖(不包含root) +```bash +yarn workspaces run add lodash +``` + +将 typescript 设置为 root 的开发依赖 +```bash +yarn add -W -D typescript jest +``` + +## 提交代码 + +代替 `git commit` 提交: +```bash +yarn commit +``` diff --git a/.travis.yml b/.travis.yml index 5e93af2455..237f315d4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,15 @@ language: node_js +os: linux +sudo: required +dist: trusty +addons: + apt: + packages: + - mesa-utils + - xvfb + - libgl1-mesa-dri + - libglapi-mesa + - libosmesa6 node_js: - '12' @@ -13,6 +24,9 @@ before_install: install: - yarn install +before_script: + - export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start + script: - yarn lint - yarn test diff --git a/README.md b/README.md index 204ea92095..4c7fad7d74 100644 --- a/README.md +++ b/README.md @@ -88,31 +88,7 @@ scene.addLayer(pointLayer); ## 🔨 Development -使用 Yarn Workspace 完成依赖安装以及各包之间的 link 工作: - -```bash -yarn install -``` - -开发模式: - -```bash -yarn watch -``` - -运行 Demo,基于 Storybook: - -```bash -yarn storybook -``` - -## view doc example - -```bash -yarn start -``` - -Visit http://localhost:8000/ +We wrote a [contribution guide](./.github/CONTRIBUTING.md) to help you get started. ## ✅ License diff --git a/README.zh-CN.md b/README.zh-CN.md index 761fa9f6fb..6c28918687 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -67,53 +67,6 @@ npm install @antv/l7@beta ![L7 Road Map](https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*3j9HTLTQT2MAAAAAAAAAAABkARQnAQ) -## Development +## 向 L7 贡献代码 -使用 Yarn Workspace 完成依赖安装以及各包之间的 link 工作: -```bash -yarn install -``` - -开发模式: -```bash -yarn watch -``` - -运行 Demo -```bash -yarn storybook -``` - -代替 `git commit` 提交: -```bash -yarn commit -``` - -## view doc example - -```bash - npm start -``` -visit http://localhost:8000/ - -## Add Package - -add new package: -```bash -lerna create my-pack -y -``` - -将 ui-lib 作为 my-pack 的依赖: -```bash -yarn workspace my-pack add ui-lib/1.0.0 -``` - -将 lodash 添加为所有 package 的依赖(不包含root) -```bash -yarn workspaces run add lodash -``` - -将 typescript 设置为 root 的开发依赖 -```bash -yarn add -W -D typescript jest -``` +您可以参考 [CONTRIBUTING.md](./.github/CONTRIBUTING.md) 向 L7 贡献代码。 diff --git a/jest.config.js b/jest.config.js index 774d65ea17..7499dfa676 100644 --- a/jest.config.js +++ b/jest.config.js @@ -24,7 +24,7 @@ module.exports = { // }, // }, moduleFileExtensions: [ 'ts', 'tsx', 'js' ], - modulePathIgnorePatterns: [ 'dist', 'packages/renderer' ], // TODO: 暂时关闭render test + modulePathIgnorePatterns: [ 'dist' ], moduleNameMapper: { '@antv/l7-(.+)$': 'packages/$1/src' }, diff --git a/package.json b/package.json index 77b6543a0c..75772d9bc3 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "commitizen": "^4.0.3", "copy-webpack-plugin": "^4.5.2", "coveralls": "^3.0.7", + "cross-env": "^6.0.3", "css-loader": "^3.2.0", "cz-conventional-changelog": "^3.0.2", "dat.gui": "^0.7.2", @@ -115,11 +116,11 @@ "worker-loader": "^2.0.0" }, "scripts": { - "start": "npm run site:clean && npm run site:develop", - "site:develop": "BABEL_ENV=site gatsby develop --open -H 0.0.0.0", - "site:build": "npm run site:clean && BABEL_ENV=site gatsby build --prefix-paths", + "start": "yarn run site:clean && yarn run site:develop", + "site:develop": "cross-env BABEL_ENV=site gatsby develop --open -H 0.0.0.0", + "site:build": "yarn run site:clean && cross-env BABEL_ENV=site gatsby build --prefix-paths", "site:clean": "gatsby clean", - "site:deploy": "npm run site:build && gh-pages -d public", + "site:deploy": "yarn run site:build && gh-pages -d public", "site:publish": "gh-pages -d public", "lint-fix:examples": "prettier --write examples/**/**/*.js", "lint:site": "eslint examples/**/**/*.js --fix", @@ -139,12 +140,12 @@ "prerelease": "yarn build && yarn bundle", "release": "lerna publish from-package --registry https://registry.npmjs.com/", "storybook": "start-storybook -p 6006", - "test": "BABEL_ENV=test jest", + "test": "cross-env BABEL_ENV=test jest", "coveralls": "jest --coverage && cat ./tests/coverage/lcov.info | coveralls", "tsc": "tsc", - "watch": "yarn clean && lerna exec --parallel 'BABEL_ENV=cjs babel --watch src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments'", - "bundle": "BABEL_ENV=bundle node_modules/.bin/rollup -c ./build/rollup.config.js", - "bundle:watch": "BABEL_ENV=bundle node_modules/.bin/rollup -c ./build/rollup.config.js --watch", + "watch": "yarn clean && lerna exec --parallel -- cross-env BABEL_ENV=cjs babel --watch src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments", + "bundle": "cross-env BABEL_ENV=bundle node_modules/.bin/rollup -c ./build/rollup.config.js", + "bundle:watch": "cross-env BABEL_ENV=bundle node_modules/.bin/rollup -c ./build/rollup.config.js --watch", "glsl-minify": "node_modules/.bin/glsl-minifier -i ./build/example.frag -o ./build/example.min.frag", "clean": "lerna run clean" }, @@ -154,7 +155,7 @@ ], "husky": { "hooks": { - "pre-commit": "npm run lint", + "pre-commit": "yarn run lint", "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } }, diff --git a/stories/Components/components/Popup.tsx b/stories/Components/components/Popup.tsx index 0fc5175c85..b5d92d2975 100644 --- a/stories/Components/components/Popup.tsx +++ b/stories/Components/components/Popup.tsx @@ -52,7 +52,6 @@ export default class PopupComponent extends React.Component { }) .setText('hello'); scene.addPopup(popup); - } public render() { diff --git a/yarn.lock b/yarn.lock index 3835ab8e35..f2d9da05b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7649,6 +7649,13 @@ create-react-context@^0.3.0: gud "^1.0.0" warning "^4.0.3" +cross-env@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-6.0.3.tgz#4256b71e49b3a40637a0ce70768a6ef5c72ae941" + integrity sha512-+KqxF6LCvfhWvADcDPqo64yVIB31gv/jQulX2NGzKS/g3GEVz6/pt4wjHFtFWsHMddebWD/sDthJemzM4MaAag== + dependencies: + cross-spawn "^7.0.0" + cross-fetch@2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/cross-fetch/-/cross-fetch-2.0.0.tgz#a17475449561e0f325146cea636a8619efb9b382"