-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #280 from flask-dashboard/development
Development
- Loading branch information
Showing
105 changed files
with
2,369 additions
and
657 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 19.3b0 | ||
hooks: | ||
- id: black | ||
args: [-S, --line-length=100] | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: flake8 | ||
args: ['--max-line-length=100', '--ignore=F401, W503'] | ||
- repo: local | ||
hooks: | ||
- id: version_increase | ||
name: version_increase | ||
description: Increase version in constants.json | ||
entry: env/bin/python config/increase_version.py | ||
language: python | ||
files: ^$ | ||
args: ['patch'] | ||
always_run: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Run this script to increase the version defined in flask_monitoringdashboard/constants.py | ||
The script can use the arguments 'major', 'minor', or 'patch' to increase the corresponding | ||
version. If no argument is specified, the 'patch' version is increased | ||
""" | ||
import argparse | ||
import json | ||
import sys | ||
import requests | ||
import os | ||
import subprocess | ||
|
||
HERE = os.path.dirname(os.path.realpath(__file__)) | ||
FILE = os.path.abspath(os.path.join(HERE, '..', 'flask_monitoringdashboard', 'constants.json')) | ||
|
||
|
||
def main(argv=None): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("type", nargs="?", default="patch") | ||
args = parser.parse_args(argv) | ||
|
||
options = ['major', 'minor', 'patch'] | ||
if args.type not in options: | ||
print('Incorrect argument type: {}. Options are: {}'.format(args.type, ', '.join(options))) | ||
return 1 | ||
|
||
branch = ( | ||
subprocess.Popen("git rev-parse --abbrev-ref HEAD", shell=True, stdout=subprocess.PIPE) | ||
.stdout.read() | ||
.decode('utf-8') | ||
.replace('\n', '') | ||
) | ||
|
||
if branch != 'development': | ||
print('Only increasing version on development, not on branch "{}"'.format(branch)) | ||
return 0 | ||
|
||
index = options.index(args.type) | ||
|
||
# read current data | ||
with open(FILE, 'r', encoding='UTF-8') as json_file: | ||
constants = json.load(json_file) | ||
|
||
# retrieve latest version | ||
response = requests.get('https://pypi.org/pypi/Flask-MonitoringDashboard/json') | ||
pypi_json = response.json() | ||
version = pypi_json['info']['version'].split('.') | ||
|
||
version[index] = int(version[index]) + 1 | ||
for i in range(index + 1, len(version)): # set version after updated version to 0 | ||
version[i] = 0 | ||
constants['version'] = '.'.join(str(v) for v in version) | ||
print('Increased {} version to {}'.format(args.type, constants['version'])) | ||
|
||
# write new version | ||
with open(FILE, 'w', encoding='UTF-8') as json_file: | ||
json.dump(constants, json_file, indent=4, separators=(',', ': ')) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Run from the root directory with ./config/install.sh | ||
# Note that pre-commit is not in the requirements.txt, as we don't want this to ship with the package. | ||
|
||
python -m venv env | ||
source env/bin/activate | ||
pip install -r requirements-dev.txt | ||
cd config || exit | ||
pre-commit install | ||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.