这个文件能够容许咱们在自动npm install的时候对当前npm环境设置参数
例如 registry = https://registry.npm.taobao.org 定义当前项目镜像源地址
还有等等的能够参考 npm参数设置
https://docs.npmjs.com/cli/co...css
顾名思义是在里面定义git 忽略的东西
它是符合globs模式的
写起来与常见的匹配文件文件夹模式相似。
/xxxxxm ,!/dsdasd
过!前端
因为项目是react的,因此选择react-styleguidist
因为没有中文文档,因此只能了解英文文档了
主要也是配一个config文件node
至于配置方法,就是通常的webpack配置手段了。react
在组件文件夹中,而后分发到指定的example.mdwebpack
jest是react如今最经常使用的测试库之一。
通常常见有两个地方进行config 设置。git
package.json文件
jest.config.js文件web
主要是看我的喜爱。
下面简单介绍一下jest配置shell
module.exports = { setupFiles: ['./jest.setup.js'], rootDir: '', testMatch: ['<rootDir>/__test__/*.test.js','<rootDir>/__test__/**/*.test.js'], coverageDirectory: '<rootDir>/.coverage/', collectCoverageFrom: [ '**/*.{js,jsx}', '!**/*.{config,setup}.js', '!**/node_modules/**', '!**/*.test.js', '!dist/*', ], collectCoverage: true, coverageReporters: ['lcov', 'text', 'text-summary'], moduleDirectories: [ 'node_modules', '<rootDir>', ], coverageThreshold: { global: { branches: 50, functions: 50, lines: 50, statements: 50, }, }, verbose: true, transform: { '^.+\\.js$': 'babel-jest' }, moduleNameMapper: { "^.+\\.scss$": "<rootDir>/__test__/__mocks__/css-transform.js", "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__test__/__mocks__/fileMock.js", "^@app(.*)$": "<rootDir>/src/components$1", }, testURL: "http://localhost/", };
// jest.setup.js const enzyme = require('enzyme'); const Adapter = require('enzyme-adapter-react-16'); enzyme.configure({ adapter: new Adapter() }); global.shallow = enzyme.shallow; global.mount = enzyme.mount; global.render = enzyme.render;
主要是连接travis ci服务
build的主要生命周期
选择可用的apt插件
可选安装缓存组件npm
sudo: false language: node_js node_js: - 6 install: - npm install -g codecov - npm install script: - npm run test && codecov cache: directories: - node_modules before_install: - echo registry = https://registry.npmjs.org/ > .npmrc
附上自用的设置。json
之因此 覆写.npmrc文件 ,是travis ci服务机子应该在国外,使用npm的源应该会快一些,而咱们本地使用应该使用公司源或者taobao源
首先须要在coverage得到一个项目的token值。
而后将token值定义在travis ci的环境变量中。
而后codecov 默认的是.coverage文件夹上传~~。
咱们的开源协议啦~~
在咱们有了文档,这里能够定义几个简单的shell脚本
例如自动将文档push上gh-pages分支上
无非就是npx styleguidist build
拿出来的文件push 上分支就能够啦~~
当咱们有了ci coverage等等的时候
咱们能够给项目增长小徽章~~~!!!
相信你们都很熟悉。
对类库模块的版本控制,由于babel,webpack都更新了一个大版本。
若是盲目的npm install -S webpack babel的话。
容易形成配置不可用等问题。要注意版本
另外也要区别devDependencies 与dependencies等等的差异
script脚本
"test": "jest --env=jsdom --config ./jest.config.js", "test:watch": "jest --env=jsdom --config ./jest.config.js --watch", "start": "npm run dev", "dev": "npx styleguidist server", "lint": "eslint --ignore-path .gitignore ./src", "build": "webpack", "build:doc": "npx styleguidist build", "deploy:doc": "./publish-doc.sh"