|
| 1 | +NODE=$(shell which node) |
| 2 | +NPM=$(shell which npm) |
| 3 | +YARN=$(shell which yarn) |
| 4 | +JQ=$(shell which jq) |
| 5 | + |
| 6 | +VERSION=$(shell jq ".version" package.json) |
| 7 | + |
| 8 | +help: info |
| 9 | + @echo |
| 10 | + @echo "List of commands:" |
| 11 | + @echo |
| 12 | + @echo " make info - display node, npm and yarn versions..." |
| 13 | + @echo " make deps - install all dependencies." |
| 14 | + @echo " make serve - start the server." |
| 15 | + @echo " make tests - run tests." |
| 16 | + @echo " make docs - build and serve the docs." |
| 17 | + @echo " make build - build project artifacts." |
| 18 | + @echo " make publish - build and publish version on npm." |
| 19 | + @echo " make publish-docs - build the docs and publish to gh-pages." |
| 20 | + @echo " make publish-all - publish version and docs." |
| 21 | + |
| 22 | +info: |
| 23 | + @echo node version: `$(NODE) --version` "($(NODE))" |
| 24 | + @echo npm version: `$(NPM) --version` "($(NPM))" |
| 25 | + @echo yarn version: `$(YARN) --version` "($(YARN))" |
| 26 | + @echo jq version: `$(JQ) --version` "($(JQ))" |
| 27 | + @echo react-modal version: $(VERSION) |
| 28 | + |
| 29 | +deps: |
| 30 | + @[[ ! -z "$(YARN)" ]] && $(YARN) install || $(NPM) install |
| 31 | + @gitbook install |
| 32 | + |
| 33 | +# Rules for development |
| 34 | + |
| 35 | +serve: |
| 36 | + @npm start |
| 37 | + |
| 38 | +tests: |
| 39 | + @npm run test |
| 40 | + |
| 41 | +tests-ci: |
| 42 | + @npm run test -- --single-run |
| 43 | + |
| 44 | +docs: build-docs |
| 45 | + gitbook serve |
| 46 | + |
| 47 | +# Rules for build and publish |
| 48 | + |
| 49 | +build: |
| 50 | + @echo "[Building dists]" |
| 51 | + @./node_modules/.bin/webpack --config webpack.dist.config.js |
| 52 | + |
| 53 | +build-docs: |
| 54 | + @echo "[Building documentation]" |
| 55 | + @rm -rf _book/* |
| 56 | + @gitbook build -g reactjs/react-modal |
| 57 | + |
| 58 | +version: |
| 59 | + @echo "[Updating react-modal version]" |
| 60 | + @sh ./scripts/version $(VERSION) |
| 61 | + |
| 62 | +release-commit: |
| 63 | + @$(JQ) '.version' package.json | cut -d\" -f2 > .version |
| 64 | + git commit --allow-empty -m "Release v`cat .version`." |
| 65 | + @rm .version |
| 66 | + git add . |
| 67 | + git commit --amend -m "`git log -1 --format=%s`" |
| 68 | + |
| 69 | +release-tag: |
| 70 | + @$(JQ) '.version' package.json | cut -d\" -f2 > .version |
| 71 | + git tag "v`cat .version`" |
| 72 | + @rm .version |
| 73 | + |
| 74 | +publish-version: release-commit release-tag |
| 75 | + @echo "[Publishing]" |
| 76 | + @$(JQ) '.version' package.json | cut -d\" -f2 > .version |
| 77 | + git push [email protected]:reactjs/react-modal "`git branch | grep '^*' | awk '{ print $$2 }'`" "v`cat .version`" |
| 78 | + npm publish |
| 79 | + @rm .version |
| 80 | + |
| 81 | +publish: version build publish-version publish-finished |
| 82 | + |
| 83 | +publish-docs: build-docs |
| 84 | + @echo "[Publishing docs]" |
| 85 | + cd _book |
| 86 | + git init |
| 87 | + git commit --allow-empty -m 'update book' |
| 88 | + git checkout -b gh-pages |
| 89 | + touch .nojekyll |
| 90 | + git add . |
| 91 | + git commit -am 'update book' |
| 92 | + git push [email protected]:reactjs/react-modal gh-pages --force |
| 93 | + cd .. |
| 94 | + |
| 95 | +publish-all: publish publish-docs |
0 commit comments