From 281895e259a4d331dbcdfed2fdd33f12a9d60b7f Mon Sep 17 00:00:00 2001 From: thatmattlove Date: Thu, 9 Sep 2021 18:03:22 -0700 Subject: [PATCH] Implement version manager & add tasks to poetry --- hyperglass/ui/package.json | 2 +- poetry.lock | 188 +++++++------------------------------ pyproject.toml | 17 +++- version.py | 134 ++++++++++++++++++++++++++ 4 files changed, 182 insertions(+), 159 deletions(-) create mode 100755 version.py diff --git a/hyperglass/ui/package.json b/hyperglass/ui/package.json index a6189c2..54b24bc 100644 --- a/hyperglass/ui/package.json +++ b/hyperglass/ui/package.json @@ -1,6 +1,6 @@ { + "version": "2.0.0-dev", "name": "ui", - "version": "1.0.0", "description": "UI for hyperglass, the modern network looking glass", "author": "Matt Love", "license": "BSD-3-Clause-Clear", diff --git a/poetry.lock b/poetry.lock index 81c565b..0ed5bf2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,14 +1,3 @@ -[[package]] -name = "aiocontextvars" -version = "0.2.2" -description = "Asyncio support for PEP-567 contextvars backport." -category = "main" -optional = false -python-versions = ">=3.5" - -[package.dependencies] -contextvars = {version = "2.4", markers = "python_version < \"3.7\""} - [[package]] name = "aiofiles" version = "0.6.0" @@ -41,9 +30,6 @@ category = "main" optional = false python-versions = "*" -[package.dependencies] -contextvars = {version = "*", markers = "python_version < \"3.7\""} - [[package]] name = "aspy.yaml" version = "1.3.0" @@ -55,14 +41,6 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [package.dependencies] pyyaml = "*" -[[package]] -name = "async-generator" -version = "1.10" -description = "Async generators and context managers for Python 3.5+" -category = "main" -optional = false -python-versions = ">=3.5" - [[package]] name = "asyncssh" version = "2.7.0" @@ -198,7 +176,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "colorama" -version = "0.4.3" +version = "0.4.4" description = "Cross-platform colored terminal text." category = "main" optional = false @@ -215,17 +193,6 @@ python-versions = "*" [package.extras] test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"] -[[package]] -name = "contextvars" -version = "2.4" -description = "PEP 567 Backport" -category = "main" -optional = false -python-versions = "*" - -[package.dependencies] -immutables = ">=0.9" - [[package]] name = "cryptography" version = "3.0" @@ -262,14 +229,6 @@ webencodings = "*" doc = ["sphinx", "sphinx-rtd-theme"] test = ["pytest-runner", "pytest-cov", "pytest-flake8", "pytest-isort"] -[[package]] -name = "dataclasses" -version = "0.7" -description = "A backport of the dataclasses module for Python 3.6" -category = "main" -optional = false -python-versions = ">=3.6, <3.7" - [[package]] name = "distlib" version = "0.3.1" @@ -343,7 +302,6 @@ optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" [package.dependencies] -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} mccabe = ">=0.6.0,<0.7.0" pycodestyle = ">=2.6.0a1,<2.7.0" pyflakes = ">=2.2.0,<2.3.0" @@ -421,7 +379,6 @@ python-versions = ">=3.5" [package.dependencies] flake8 = ">=3.0,<3.2.0 || >3.2.0,<4" -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} [[package]] name = "flake8-deprecated" @@ -641,43 +598,6 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -[[package]] -name = "immutables" -version = "0.14" -description = "Immutable Collections" -category = "main" -optional = false -python-versions = ">=3.5" - -[[package]] -name = "importlib-metadata" -version = "2.0.0" -description = "Read metadata from Python packages" -category = "dev" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" - -[package.dependencies] -zipp = ">=0.5" - -[package.extras] -docs = ["sphinx", "rst.linker"] -testing = ["packaging", "pep517", "importlib-resources (>=1.3)"] - -[[package]] -name = "importlib-resources" -version = "3.0.0" -description = "Read resources from Python packages" -category = "main" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" - -[package.dependencies] -zipp = {version = ">=0.4", markers = "python_version < \"3.8\""} - -[package.extras] -docs = ["sphinx", "rst.linker", "jaraco.packaging"] - [[package]] name = "inquirer" version = "2.7.0" @@ -724,7 +644,6 @@ optional = false python-versions = ">=3.5" [package.dependencies] -aiocontextvars = {version = ">=0.2.0", markers = "python_version < \"3.7\""} colorama = {version = ">=0.3.4", markers = "sys_platform == \"win32\""} win32-setctime = {version = ">=1.0.0", markers = "sys_platform == \"win32\""} @@ -753,6 +672,14 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "mslex" +version = "0.3.0" +description = "shlex for windows" +category = "dev" +optional = false +python-versions = ">=3.5" + [[package]] name = "netmiko" version = "3.4.0" @@ -762,7 +689,6 @@ optional = false python-versions = "*" [package.dependencies] -importlib-resources = {version = "*", markers = "python_version < \"3.7\""} ntc-templates = "*" paramiko = ">=2.6.0" pyserial = "*" @@ -857,8 +783,6 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" "aspy.yaml" = "*" cfgv = ">=2.0.0" identify = ">=1.0.0" -importlib-metadata = {version = "*", markers = "python_version < \"3.8\""} -importlib-resources = {version = "*", markers = "python_version < \"3.7\""} nodeenv = ">=0.11.1" pyyaml = "*" six = "*" @@ -909,7 +833,6 @@ optional = false python-versions = ">=3.6.1" [package.dependencies] -dataclasses = {version = ">=0.6", markers = "python_version < \"3.7\""} typing-extensions = ">=3.7.4.3" [package.extras] @@ -1074,7 +997,6 @@ python-versions = ">=3.6,<4.0" [package.dependencies] colorama = ">=0.4.0,<0.5.0" commonmark = ">=0.9.0,<0.10.0" -dataclasses = {version = ">=0.7,<0.8", markers = "python_version >= \"3.6\" and python_version < \"3.7\""} pygments = ">=2.6.0,<3.0.0" typing-extensions = ">=3.7.4,<4.0.0" @@ -1101,9 +1023,7 @@ optional = false python-versions = ">=3.6" [package.dependencies] -async-generator = {version = ">=1.10,<2.0", markers = "python_version < \"3.7\""} asyncssh = {version = ">=2.2.1,<3.0.0", optional = true, markers = "extra == \"asyncssh\""} -dataclasses = {version = ">=0.7,<1.0", markers = "python_version < \"3.7\""} [package.extras] asyncssh = ["asyncssh (>=2.2.1,<3.0.0)"] @@ -1139,9 +1059,6 @@ category = "main" optional = false python-versions = ">=3.5" -[package.dependencies] -contextvars = {version = ">=2.1", markers = "python_version < \"3.7\""} - [[package]] name = "snowballstemmer" version = "2.0.0" @@ -1178,7 +1095,6 @@ optional = false python-versions = ">=3.6" [package.dependencies] -importlib-metadata = {version = ">=1.7.0", markers = "python_version < \"3.8\""} pbr = ">=2.0.0,<2.1.0 || >2.1.0" [[package]] @@ -1195,6 +1111,20 @@ lxml = "*" reportlab = "*" tinycss2 = ">=0.6.0" +[[package]] +name = "taskipy" +version = "1.8.2" +description = "tasks runner for python projects" +category = "dev" +optional = false +python-versions = ">=3.6,<4.0" + +[package.dependencies] +colorama = ">=0.4.4,<0.5.0" +mslex = {version = ">=0.3.0,<0.4.0", markers = "sys_platform == \"win32\""} +psutil = ">=5.7.2,<6.0.0" +toml = ">=0.10.0,<0.11.0" + [[package]] name = "tenacity" version = "7.0.0" @@ -1305,7 +1235,6 @@ h11 = ">=0.8" httptools = {version = ">=0.1.0,<0.2.0", optional = true, markers = "sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\" and extra == \"standard\""} python-dotenv = {version = ">=0.13", optional = true, markers = "extra == \"standard\""} PyYAML = {version = ">=5.1", optional = true, markers = "extra == \"standard\""} -typing-extensions = {version = "*", markers = "python_version < \"3.8\""} uvloop = {version = ">=0.14.0,<0.15.0 || >0.15.0,<0.15.1 || >0.15.1", optional = true, markers = "sys_platform != \"win32\" and sys_platform != \"cygwin\" and platform_python_implementation != \"PyPy\" and extra == \"standard\""} watchgod = {version = ">=0.6", optional = true, markers = "extra == \"standard\""} websockets = {version = ">=8.0.0,<9.0.0", optional = true, markers = "extra == \"standard\""} @@ -1333,8 +1262,6 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" appdirs = ">=1.4.3,<2" distlib = ">=0.3.1,<1" filelock = ">=3.0.0,<4" -importlib-metadata = {version = ">=0.12,<3", markers = "python_version < \"3.8\""} -importlib-resources = {version = ">=1.0", markers = "python_version < \"3.7\""} six = ">=1.9.0,<2" [package.extras] @@ -1392,28 +1319,12 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -[[package]] -name = "zipp" -version = "3.3.0" -description = "Backport of pathlib-compatible object wrapper for zip files" -category = "main" -optional = false -python-versions = ">=3.6" - -[package.extras] -docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] -testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-cov", "jaraco.test (>=3.2.0)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy"] - [metadata] lock-version = "1.1" -python-versions = ">=3.6.1,<4.0" -content-hash = "c36e22b0981b31fb48f071ac413e8919ad946ef9ff08628b813370ae0f6b1cfd" +python-versions = ">=3.8.1,<4.0" +content-hash = "5848c2f76c3539cc28fefa0489ab357c95c2137f07a1c6500a9a0f053141ed40" [metadata.files] -aiocontextvars = [ - {file = "aiocontextvars-0.2.2-py2.py3-none-any.whl", hash = "sha256:885daf8261818767d8f7cbd79f9d4482d118f024b6586ef6e67980236a27bfa3"}, - {file = "aiocontextvars-0.2.2.tar.gz", hash = "sha256:f027372dc48641f683c559f247bd84962becaacdc9ba711d583c3871fb5652aa"}, -] aiofiles = [ {file = "aiofiles-0.6.0-py3-none-any.whl", hash = "sha256:bd3019af67f83b739f8e4053c6c0512a7f545b9a8d91aaeab55e6e0f9d123c27"}, {file = "aiofiles-0.6.0.tar.gz", hash = "sha256:e0281b157d3d5d59d803e3f4557dcc9a3dff28a4dd4829a9ff478adae50ca092"}, @@ -1433,10 +1344,6 @@ aredis = [ {file = "aspy.yaml-1.3.0-py2.py3-none-any.whl", hash = "sha256:463372c043f70160a9ec950c3f1e4c3a82db5fca01d334b6bc89c7164d744bdc"}, {file = "aspy.yaml-1.3.0.tar.gz", hash = "sha256:e7c742382eff2caed61f87a39d13f99109088e5e93f04d76eb8d4b28aa143f45"}, ] -async-generator = [ - {file = "async_generator-1.10-py3-none-any.whl", hash = "sha256:01c7bf666359b4967d2cda0000cc2e4af16a0ae098cbffcb8472fb9e8ad6585b"}, - {file = "async_generator-1.10.tar.gz", hash = "sha256:6ebb3d106c12920aaae42ccb6f787ef5eefdcdd166ea3d628fa8476abe712144"}, -] asyncssh = [ {file = "asyncssh-2.7.0-py3-none-any.whl", hash = "sha256:ccc62a1b311c71d4bf8e4bc3ac141eb00ebb28b324e375aed1d0a03232893ca1"}, {file = "asyncssh-2.7.0.tar.gz", hash = "sha256:185013d8e67747c3c0f01b72416b8bd78417da1df48c71f76da53c607ef541b6"}, @@ -1517,16 +1424,13 @@ click = [ {file = "click-7.1.2.tar.gz", hash = "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a"}, ] colorama = [ - {file = "colorama-0.4.3-py2.py3-none-any.whl", hash = "sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff"}, - {file = "colorama-0.4.3.tar.gz", hash = "sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"}, + {file = "colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"}, + {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, ] commonmark = [ {file = "commonmark-0.9.1-py2.py3-none-any.whl", hash = "sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9"}, {file = "commonmark-0.9.1.tar.gz", hash = "sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"}, ] -contextvars = [ - {file = "contextvars-2.4.tar.gz", hash = "sha256:f38c908aaa59c14335eeea12abea5f443646216c4e29380d7bf34d2018e2c39e"}, -] cryptography = [ {file = "cryptography-3.0-cp27-cp27m-macosx_10_10_x86_64.whl", hash = "sha256:ab49edd5bea8d8b39a44b3db618e4783ef84c19c8b47286bf05dfdb3efb01c83"}, {file = "cryptography-3.0-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:124af7255ffc8e964d9ff26971b3a6153e1a8a220b9a685dc407976ecb27a06a"}, @@ -1552,10 +1456,6 @@ cssselect2 = [ {file = "cssselect2-0.3.0-py3-none-any.whl", hash = "sha256:97d7d4234f846f9996d838964d38e13b45541c18143bc55cf00e4bc1281ace76"}, {file = "cssselect2-0.3.0.tar.gz", hash = "sha256:5c2716f06b5de93f701d5755a9666f2ee22cbcd8b4da8adddfc30095ffea3abc"}, ] -dataclasses = [ - {file = "dataclasses-0.7-py3-none-any.whl", hash = "sha256:3459118f7ede7c8bea0fe795bff7c6c2ce287d01dd226202f7c9ebc0610a7836"}, - {file = "dataclasses-0.7.tar.gz", hash = "sha256:494a6dcae3b8bcf80848eea2ef64c0cc5cd307ffc263e17cdf42f3e5420808e6"}, -] distlib = [ {file = "distlib-0.3.1-py2.py3-none-any.whl", hash = "sha256:8c09de2c67b3e7deef7184574fc060ab8a793e7adbb183d942c389c8b13c52fb"}, {file = "distlib-0.3.1.zip", hash = "sha256:edf6116872c863e1aa9d5bb7cb5e05a022c519a4594dc703843343a9ddd9bff1"}, @@ -1688,28 +1588,6 @@ idna = [ {file = "idna-2.10-py2.py3-none-any.whl", hash = "sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"}, {file = "idna-2.10.tar.gz", hash = "sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6"}, ] -immutables = [ - {file = "immutables-0.14-cp35-cp35m-macosx_10_14_x86_64.whl", hash = "sha256:860666fab142401a5535bf65cbd607b46bc5ed25b9d1eb053ca8ed9a1a1a80d6"}, - {file = "immutables-0.14-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:ce01788878827c3f0331c254a4ad8d9721489a5e65cc43e19c80040b46e0d297"}, - {file = "immutables-0.14-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:8797eed4042f4626b0bc04d9cf134208918eb0c937a8193a2c66df5041e62d2e"}, - {file = "immutables-0.14-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:33ce2f977da7b5e0dddd93744862404bdb316ffe5853ec853e53141508fa2e6a"}, - {file = "immutables-0.14-cp36-cp36m-win_amd64.whl", hash = "sha256:6c8eace4d98988c72bcb37c05e79aae756832738305ae9497670482a82db08bc"}, - {file = "immutables-0.14-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:ab6c18b7b2b2abc83e0edc57b0a38bf0915b271582a1eb8c7bed1c20398f8040"}, - {file = "immutables-0.14-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:c099212fd6504513a50e7369fe281007c820cf9d7bb22a336486c63d77d6f0b2"}, - {file = "immutables-0.14-cp37-cp37m-win_amd64.whl", hash = "sha256:714aedbdeba4439d91cb5e5735cb10631fc47a7a69ea9cc8ecbac90322d50a4a"}, - {file = "immutables-0.14-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:1c11050c49e193a1ec9dda1747285333f6ba6a30bbeb2929000b9b1192097ec0"}, - {file = "immutables-0.14-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:c453e12b95e1d6bb4909e8743f88b7f5c0c97b86a8bc0d73507091cb644e3c1e"}, - {file = "immutables-0.14-cp38-cp38-win_amd64.whl", hash = "sha256:ef9da20ec0f1c5853b5c8f8e3d9e1e15b8d98c259de4b7515d789a606af8745e"}, - {file = "immutables-0.14.tar.gz", hash = "sha256:a0a1cc238b678455145bae291d8426f732f5255537ed6a5b7645949704c70a78"}, -] -importlib-metadata = [ - {file = "importlib_metadata-2.0.0-py2.py3-none-any.whl", hash = "sha256:cefa1a2f919b866c5beb7c9f7b0ebb4061f30a8a9bf16d609b000e2dfaceb9c3"}, - {file = "importlib_metadata-2.0.0.tar.gz", hash = "sha256:77a540690e24b0305878c37ffd421785a6f7e53c8b5720d211b211de8d0e95da"}, -] -importlib-resources = [ - {file = "importlib_resources-3.0.0-py2.py3-none-any.whl", hash = "sha256:d028f66b66c0d5732dae86ba4276999855e162a749c92620a38c1d779ed138a7"}, - {file = "importlib_resources-3.0.0.tar.gz", hash = "sha256:19f745a6eca188b490b1428c8d1d4a0d2368759f32370ea8fb89cad2ab1106c3"}, -] inquirer = [ {file = "inquirer-2.7.0-py2.py3-none-any.whl", hash = "sha256:d15e15de1ad5696f1967e7a23d8e2fce69d2e41a70b008948d676881ed94c3a5"}, {file = "inquirer-2.7.0.tar.gz", hash = "sha256:e819188de0ca7985a99c282176c6f50fb08b0d33867fd1965d3f3e97d6c8f83f"}, @@ -1763,6 +1641,10 @@ mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, ] +mslex = [ + {file = "mslex-0.3.0-py2.py3-none-any.whl", hash = "sha256:380cb14abf8fabf40e56df5c8b21a6d533dc5cbdcfe42406bbf08dda8f42e42a"}, + {file = "mslex-0.3.0.tar.gz", hash = "sha256:4a1ac3f25025cad78ad2fe499dd16d42759f7a3801645399cce5c404415daa97"}, +] netmiko = [ {file = "netmiko-3.4.0-py3-none-any.whl", hash = "sha256:b66f25717db3609878f83c85604349dd40a0ab494d8eafd817dcde8388131136"}, {file = "netmiko-3.4.0.tar.gz", hash = "sha256:acadb9dd97864ee848e2032f1f0e301c7b31e7a4153757d98f5c8ba1b9614993"}, @@ -2075,6 +1957,10 @@ stevedore = [ svglib = [ {file = "svglib-1.0.1.tar.gz", hash = "sha256:ff01593e8c07ea462d3742e1f4141bfa261cbd4400ceb25dfb8fec3508ad0e50"}, ] +taskipy = [ + {file = "taskipy-1.8.2-py3-none-any.whl", hash = "sha256:24b899ae17908fe9a61f4dc596792d5d2afef471ecfd8c6e9abb68a9568b40b7"}, + {file = "taskipy-1.8.2.tar.gz", hash = "sha256:36e958f646f2c435b39f748b8bbdb0b9c33a2c4a96b293427feaf48ad4e2caa0"}, +] tenacity = [ {file = "tenacity-7.0.0-py2.py3-none-any.whl", hash = "sha256:a0ce48587271515db7d3a5e700df9ae69cce98c4b57c23a4886da15243603dd8"}, {file = "tenacity-7.0.0.tar.gz", hash = "sha256:5bd16ef5d3b985647fe28dfa6f695d343aa26479a04e8792b9d3c8f49e361ae1"}, @@ -2189,7 +2075,3 @@ xmltodict = [ {file = "xmltodict-0.12.0-py2.py3-none-any.whl", hash = "sha256:8bbcb45cc982f48b2ca8fe7e7827c5d792f217ecf1792626f808bf41c3b86051"}, {file = "xmltodict-0.12.0.tar.gz", hash = "sha256:50d8c638ed7ecb88d90561beedbf720c9b4e851a9fa6c47ebd64e99d166d8a21"}, ] -zipp = [ - {file = "zipp-3.3.0-py3-none-any.whl", hash = "sha256:eed8ec0b8d1416b2ca33516a37a08892442f3954dee131e92cfd92d8fe3e7066"}, - {file = "zipp-3.3.0.tar.gz", hash = "sha256:64ad89efee774d1897a58607895d80789c59778ea02185dd846ac38394a8642b"}, -] diff --git a/pyproject.toml b/pyproject.toml index ed5b827..8239048 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,17 +80,24 @@ mccabe = "^0.6.1" pep8-naming = "^0.9.1" pre-commit = "^1.21.0" stackprinter = "^0.2.3" +taskipy = "^1.8.2" [tool.black] line-length = 88 [tool.pyright] -exclude = [ - "**/node_modules", - "**/ui", - "**/__pycache__", -] +exclude = ["**/node_modules", "**/ui", "**/__pycache__"] include = ["hyperglass"] pythonVersion = "3.6" reportMissingImports = true reportMissingTypeStubs = true + +[tool.taskipy.tasks] +start = {cmd = "uvicorn hyperglass.api:app", help = "Start hyperglass via Uvicorn"} +start-direct = {cmd = "python3 -m hyperglass.console start", help = "Start hyperglass via hyperglass.console.CLI"} +ui-build = {cmd = "python3 -m hyperglass.console build-ui", help = "Run a UI Build"} +ui-dev = {cmd = "yarn --cwd ./hyperglass/ui/ dev", help = "Start the Next.JS dev server"} +ui-format = {cmd = "yarn --cwd ./hyperglass/ui/ format", help = "Run Prettier"} +ui-lint = {cmd = "yarn --cwd ./hyperglass/ui/ lint", help = "Run ESLint"} +ui-typecheck = {cmd = "yarn --cwd ./hyperglass/ui/ typecheck", help = "Run TypeScript Check"} +upgrade = {cmd = "python3 version.py", help = "Upgrade hyperglass version"} diff --git a/version.py b/version.py new file mode 100755 index 0000000..a074946 --- /dev/null +++ b/version.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python3 +"""Manage hyperglass version across multiple files.""" + +# Standard Library +import re +from typing import Tuple, Union, Pattern +from pathlib import Path + +# Third Party +import click + +PACKAGE_JSON = Path(__file__).parent / "hyperglass" / "ui" / "package.json" +PACKAGE_JSON_PATTERN = re.compile(r"\s+\"version\"\:\s\"(.+)\"\,$") + +PYPROJECT_TOML = Path(__file__).parent / "pyproject.toml" +PYPROJECT_PATTERN = re.compile(r"^version\s\=\s\"(.+)\"$") + +CONSTANTS = Path(__file__).parent / "hyperglass" / "constants.py" +CONSTANT_PATTERN = re.compile(r"^__version__\s\=\s\"(.+)\"$") + +UPGRADES = ( + ("package.json", PACKAGE_JSON, PACKAGE_JSON_PATTERN), + ("pyproject.toml", PYPROJECT_TOML, PYPROJECT_PATTERN), + ("constants.py", CONSTANTS, CONSTANT_PATTERN), +) + + +class Version: + """Upgrade a file's version from one version to another.""" + + new_version: Union[str, int] + file: Path + line_pattern: Pattern[str] + old_version: Union[None, str, int] = None + _did_check: bool = False + _did_update: bool = False + + def __init__( + self, + *, + name: str, + new_version: Union[str, int], + line_pattern: Union[Pattern, str], + file: Union[Path, str], + ) -> None: + """Initialize version manager.""" + + self.name = name + self.new_version = new_version + + if isinstance(file, Path): + self.file = file + elif isinstance(file, str): + self.file = Path(file) + else: + raise TypeError(f"'{repr(file)}' must be a string or Path object") + + if isinstance(line_pattern, Pattern): + self.line_pattern = line_pattern + elif isinstance(line_pattern, str): + self.line_pattern = re.compile(line_pattern) + else: + raise TypeError(f"'{repr(line_pattern)}' is not a supported pattern") + + def __enter__(self) -> "Version": + """Exit context manager for 0.01% better DX.""" + return self + + def __exit__(self, *args, **kwargs) -> None: + """Exit context manager for 0.01% better DX.""" + pass + + def __str__(self) -> str: + """Represent the state and/or action taken.""" + if self._did_update: + old, new = self.upgrade_path + return f"Upgraded {self.name} from {old} → {new}" + elif self._did_check: + return f"No update required for {self.name} from version {self.old_version}" + else: + return f"{self.name} has not been checked" + + def upgrade(self) -> None: + """Find a matching current version and upgrade it to the new version.""" + with self.file.open("r+") as file: + found_match = False + lines = file.readlines() + self._did_check = True + + for idx, line in enumerate(lines): + match = self.line_pattern.match(line) + if match: + old_version = match.group(1).strip() + try: + old_version = int(old_version) + except ValueError: + # Old version can't be converted to an integer, which is fine. + pass + self.old_version = old_version + + if self.old_version != self.new_version: + lines[idx] = re.sub(old_version, self.new_version, line) + found_match = True + break + + if found_match: + file.seek(0) + file.writelines(lines) + file.truncate() + self._did_update = True + + @property + def upgrade_path(self) -> Tuple[Union[str, int], Union[str, int]]: + """Get the old and new versions.""" + return (self.old_version, self.new_version) + + +@click.command( + name="Upgrade hyperglass Version", + help="Update pyproject.toml, constants.py, and package.json version statements", +) +@click.argument("new-version", nargs=1) +def update_versions(new_version: str) -> None: + """Upgrade versions in pre-configured files to new version.""" + for name, file, pattern in UPGRADES: + with Version( + name=name, file=file, line_pattern=pattern, new_version=new_version, + ) as version: + version.upgrade() + click.echo(str(version)) + + +if __name__ == "__main__": + update_versions()