Makefile 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. # https://github.com/aclark4life/project-makefile
  2. #
  3. # The MIT License (MIT)
  4. #
  5. # Copyright (c) 2016 Alex Clark
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a copy
  8. # of this software and associated documentation files (the "Software"), to deal
  9. # in the Software without restriction, including without limitation the rights
  10. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. # copies of the Software, and to permit persons to whom the Software is
  12. # furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be included in all
  15. # copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. # SOFTWARE.
  24. .DEFAULT_GOAL=git-commit-edit-push
  25. APP=app
  26. MESSAGE="Update"
  27. PROJECT=project
  28. TMP:=$(shell echo `tmp`)
  29. commit: git-commit-auto-push
  30. co: git-checkout-branches
  31. db: django-migrate django-su
  32. db-clean: django-db-clean-postgres
  33. django-start: django-init
  34. fe-init: npm-init npm-install grunt-init grunt-serve
  35. fe: npm-install grunt-serve
  36. freeze: python-pip-freeze
  37. heroku: heroku-push
  38. install: python3.5-virtualenv python-pip-install
  39. lint: python-flake python-yapf python-wc
  40. migrate: django-migrate
  41. push: git-push
  42. plone-start: plone-init
  43. readme: python-package-readme-test
  44. release: python-package-release
  45. releasetest: python-package-release-test
  46. serve: python-serve
  47. sphinx-start: sphinx-init
  48. static: django-static
  49. test: django-test
  50. vm: vagrant-up
  51. vm-down: vagrant-suspend
  52. # Django
  53. django-db-clean-postgres:
  54. -dropdb $(PROJECT)-$(APP)
  55. -createdb $(PROJECT)-$(APP)
  56. django-db-clean-sqlite:
  57. -rm -f $(PROJECT)-$(APP).sqlite3
  58. django-init:
  59. -mkdir -p $(PROJECT)/$(APP)
  60. -django-admin startproject $(PROJECT) .
  61. -django-admin startapp $(APP) $(PROJECT)/$(APP)
  62. django-install:
  63. $(MAKE) python-virtualenv
  64. bin/pip install Django
  65. django-migrate:
  66. python manage.py migrate
  67. django-migrations:
  68. python manage.py makemigrations $(APP)
  69. django-migrations-clean:
  70. rm -rf $(PROJECT)/$(APP)/migrations
  71. $(MAKE) django-migrations
  72. django-serve:
  73. python manage.py runserver
  74. django-test:
  75. python manage.py test
  76. django-shell:
  77. python manage.py shell
  78. django-static:
  79. python manage.py collectstatic --noinput
  80. django-su:
  81. python manage.py createsuperuser
  82. # Git
  83. REMOTE_BRANCHES=`git branch -a |\
  84. grep remote |\
  85. grep -v HEAD |\
  86. grep -v master`
  87. git-checkout-branches:
  88. -for i in $(REMOTE_BRANCHES) ; do \
  89. git checkout -t $$i ; done
  90. git-commit-auto-push:
  91. git commit -a -m $(MESSAGE)
  92. $(MAKE) git-push
  93. git-commit-edit-push:
  94. git commit -a
  95. $(MAKE) git-push
  96. git-push:
  97. git push
  98. # Heroku
  99. heroku-debug-on:
  100. heroku config:set DEBUG=1
  101. heroku-debug-off:
  102. heroku config:unset DEBUG
  103. heroku-push:
  104. git push heroku
  105. heroku-shell:
  106. heroku run bash
  107. # Misc
  108. help:
  109. @echo "\nPlease run \`make\` with one of these targets:\n"
  110. @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F:\
  111. '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}'\
  112. | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs | tr ' ' '\n' | awk\
  113. '{print " - "$$0}'
  114. @echo "\n"
  115. review:
  116. open -a "Sublime Text 2" `find $(PROJECT) -name \*.py | grep -v __init__.py`\
  117. `find $(PROJECT) -name \*.html`
  118. # Node
  119. npm-init:
  120. npm init
  121. npm-install:
  122. npm install
  123. grunt-init:
  124. npm install grunt
  125. grunt-init Gruntfile
  126. grunt-serve:
  127. grunt serve
  128. # Plone
  129. plone-heroku:
  130. -@createuser -s plone > /dev/null 2>&1
  131. -@createdb -U plone plone > /dev/null 2>&1
  132. @export PORT=8080 && \
  133. export USERNAME=admin && \
  134. export PASSWORD=admin && \
  135. bin/buildout -c heroku.cfg
  136. plone-init:
  137. plock --force --no-cache --no-virtualenv .
  138. plone-install:
  139. $(MAKE) install
  140. bin/buildout
  141. plone-db-sync:
  142. bin/buildout -c database.cfg
  143. plone-serve:
  144. @echo "Zope about to handle requests here:\n\n\thttp://localhost:8080\n"
  145. @bin/plone fg
  146. # Python
  147. python-clean-pyc:
  148. find . -name \*.pyc | xargs rm -v
  149. python-flake:
  150. -flake8 *.py
  151. -flake8 $(PROJECT)/*.py
  152. -flake8 $(PROJECT)/$(APP)/*.py
  153. python-package-check:
  154. check-manifest
  155. pyroma .
  156. python-package-readme-test:
  157. rst2html.py README.rst > readme.html; open readme.html
  158. python-package-release:
  159. python setup.py sdist --format=gztar,zip upload
  160. python-package-release-test:
  161. python setup.py sdist --format=gztar,zip upload -r test
  162. python-package-test:
  163. python setup.py test
  164. python-pip-freeze:
  165. bin/pip freeze | sort > $(TMP)/requirements.txt
  166. mv -f $(TMP)/requirements.txt .
  167. python-pip-install:
  168. bin/pip install -r requirements.txt
  169. python-serve:
  170. @echo "\n\tServing HTTP on http://0.0.0.0:8000\n"
  171. python -m SimpleHTTPServer
  172. python-virtualenv:
  173. virtualenv .
  174. python-yapf:
  175. -yapf -i *.py
  176. -yapf -i -e $(PROJECT)/urls.py $(PROJECT)/*.py
  177. -yapf -i $(PROJECT)/$(APP)/*.py
  178. python-wc:
  179. -wc -l *.py
  180. -wc -l $(PROJECT)/*.py
  181. -wc -l $(PROJECT)/$(APP)/*.py
  182. # Sphinx
  183. sphinx-init:
  184. sphinx-quickstart -q -p "Python Project" -a "Alex Clark" -v 0.0.1 doc
  185. sphinx-serve:
  186. @echo "\nServing HTTP on http://0.0.0.0:8085 ...\n"
  187. pushd _build/html; python -m SimpleHTTPServer 8085; popd
  188. # Vagrant
  189. vagrant-box-update:
  190. vagrant box update
  191. vagrant-clean:
  192. vagrant destroy
  193. vagrant-down:
  194. vagrant suspend
  195. vagrant-init:
  196. vagrant init ubuntu/trusty64
  197. vagrant up --provider virtualbox
  198. vagrant-up:
  199. vagrant up --provision
  200. # Django-axes
  201. python3.5-virtualenv:
  202. virtualenv-3.5 .