hookmeup

A Git hook to automate your Pipenv and Django workflow
git clone git://git.danielmoch.com/hookmeup.git
Log | Files | Refs | README | LICENSE

make.bat (2974B)


      1 @echo off
      2 setlocal ENABLEDELAYEDEXPANSION
      3 set BROWSER_PYSCRIPT=import os, webbrowser, sys^
      4 
      5 try:^
      6 
      7 	from urllib import pathname2url^
      8 
      9 except:^
     10 
     11 	from urllib.request import pathname2url^
     12 
     13 webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
     14 set PRINT_HELP_PYSCRIPT=import re, sys^
     15 
     16 for line in sys.stdin:^
     17 
     18 	match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$', line)^
     19 
     20 	if match:^
     21 
     22 		target, help = match.groups()^
     23 
     24 		print("%%-20s %%s" %% (target, help))
     25 
     26 if "%PYTHON%"=="" (
     27     set PYTHON=python
     28 ) else (
     29     set "PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%"
     30     set PYTHON=python
     31 )
     32 
     33 set PIP=pip
     34 set PIPENV=pipenv
     35 set PIPRUN=%PIPENV% run
     36 set PIPINST=%PIPENV% --bare install --dev --skip-lock
     37 set BROWSER=%PYTHON% -c !BROWSER_PYSCRIPT!
     38 
     39 if "%1"=="help" (
     40     %PYTHON% -c "!PRINT_HELP_PYSCRIPT!" < %~f0
     41     goto :end
     42 )
     43 
     44 if "%1"=="clean" (
     45     call :cleanbuild
     46     call :cleanpyc
     47     call :cleantest
     48     goto :end
     49 )
     50 
     51 if "%1"=="cleanbuild" (
     52     call :cleanbuild
     53     goto :end
     54 )
     55 
     56 if "%1"=="cleanpyc" (
     57     call :cleanpyc
     58     goto :end
     59 )
     60 
     61 if "%1"=="cleantest" (
     62     call :cleantest
     63     goto :end
     64 )
     65 
     66 if "%1"=="lint" (
     67     @echo on
     68     %PIPRUN% pylint hookmeup tests --disable=parse-error
     69     @echo off
     70     goto :end
     71 )
     72  
     73 if "%1"=="test" (
     74     @echo on
     75     %PIPRUN% %PYTHON% -m pytest
     76     @echo off
     77     goto :end
     78 )
     79 
     80 if "%1"=="test-all" (
     81     @echo on
     82     %PIPRUN% tox
     83     @echo off
     84     goto :end
     85 )
     86 
     87 if "%1"=="test-install" (
     88     @echo on
     89     %PYTHON% -m %PIP% install --upgrade %PIP% %PIPENV% python-coveralls
     90     %PIPINST%
     91     @echo off
     92     goto :end
     93 )
     94 
     95 if "%1"=="coverage" (
     96     @echo on
     97     %PIPRUN% %PYTHON% -m pytest --cov=hookmeup
     98     @echo off
     99     goto :end
    100 )
    101 
    102 if "%1"=="coverage-html" (
    103     @echo on
    104     %PIPRUN% %PYTHON% -m pytest --cov=hookmeup
    105     %PIPRUN% coverage html
    106     %BROWSER% htmlcov\index.html
    107     @echo off
    108     goto :end
    109 )
    110 
    111 if "%1"=="release" (
    112     @echo on
    113     %PIPRUN% flit build
    114     dir dist
    115     %PIPRUN% flit publish
    116     @echo off
    117     goto :end
    118 )
    119 
    120 if "%1"=="dist" (
    121     @echo on
    122     %PIPRUN% flit build
    123     dir dist
    124     @echo off
    125     goto :end
    126 )
    127 
    128 if "%1"=="install" (
    129     @echo on
    130     %PIPRUN% flit install --deps=none
    131     @echo off
    132     goto :end
    133 )
    134 
    135 if "%1"=="run" (
    136     @echo on
    137     %PIPRUN% %PYTHON% -m hookmeup %cmd%
    138     @echo off
    139     goto :end
    140 )
    141 
    142 if "%1"=="debug" (
    143     @echo on
    144     %PIPRUN% flit install --deps=none
    145     %PIPRUN% pudb3 hookmeup %cmd%
    146     @echo off
    147     goto :end
    148 )
    149 
    150 :cleanbuild
    151 @echo on
    152 rmdir /S /Q build
    153 rmdir /S /Q dist
    154 rmdir /S /Q .eggs
    155 del /S *.egg-info
    156 del /S *.egg
    157 @echo off
    158 exit /B 0
    159 
    160 :cleanpyc
    161 @echo on
    162 del /S *.pyc
    163 del /S *.pyo
    164 del /S *~
    165 del /S __pycache__
    166 %PIPRUN% %PIP% uninstall -y hookmeup
    167 @echo off
    168 exit /B 0
    169 
    170 :cleantest
    171 @echo on
    172 del .coverage
    173 rmdir /S /Q htmlcov
    174 rmdir /S /Q .pytest_cache
    175 rmdir /S /Q .tox
    176 @echo off
    177 exit /B 0
    178 
    179 :end