From 31872456250efc2c40705cb7840227b0c1bf0eea Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 9 Jun 2024 14:46:34 -0500 Subject: [PATCH] fix: migrate cli --- .bin/update-release-cache | 3 ++- .bin/update-requirements | 32 -------------------------------- .devcontainer/devcontainer.json | 2 +- .docker/entrypoint.sh | 2 +- .vscode/tasks.json | 4 ++-- README.md | 6 +++--- docs/dev.md | 6 +++--- src/uiprotect/cli/base.py | 2 +- 8 files changed, 13 insertions(+), 44 deletions(-) mode change 100644 => 100755 .bin/update-release-cache delete mode 100755 .bin/update-requirements diff --git a/.bin/update-release-cache b/.bin/update-release-cache old mode 100644 new mode 100755 index 4e83e61c..5ee059f1 --- a/.bin/update-release-cache +++ b/.bin/update-release-cache @@ -4,4 +4,5 @@ set -o errexit set -o pipefail set -o nounset -unifi-protect release-versions +poetry install +poetry run uiprotect release-versions diff --git a/.bin/update-requirements b/.bin/update-requirements deleted file mode 100755 index 0c916593..00000000 --- a/.bin/update-requirements +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -set -o errexit -set -o pipefail -set -o nounset - -BASE_DIR=$( realpath $( dirname "${BASH_SOURCE[0]}" )/../ ) -source "$BASE_DIR/.bin/lib/common.sh" -setRoot - -IN_DEVCONTAINER=$([[ -f /.dockerenv && -d /workspaces/uiprotect ]] && echo "true" || echo "false") - -if [[ $IN_DEVCONTAINER == "true" ]]; then - echo "Inside of devcontainer" -fi - -pushd "$ROOT_PATH" 2>&1 >/dev/null - -if [[ $IN_DEVCONTAINER == "true" ]]; then - sudo rm -rf /workspaces/uiprotect/uiprotect.egg-info -fi - -echo "Updating requirements.txt..." -uv pip compile -v --upgrade --extra=full --output-file=requirements.txt pyproject.toml -echo "Updating dev-requirements.txt..." -uv pip compile -v -c requirements.txt --upgrade --extra=full --extra=dev --output-file=dev-requirements.txt pyproject.toml - -if [[ $IN_DEVCONTAINER == "true" ]]; then - echo "Upgrading dev container environment..." - sudo -E uv pip sync requirements.txt dev-requirements.txt -fi -popd 2>&1 >/dev/null diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b892596a..ba18490f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -16,7 +16,7 @@ "onCreateCommand": [ "/bin/bash", "-c", - "sudo -E HOME=/root uv pip install -e '.[dev]' && /usr/local/bin/unifi-protect --install-completion bash && docker-fix" + "sudo -E HOME=/root uv pip install -e '.[dev]' && /usr/local/bin/uiprotect --install-completion bash && docker-fix" ], "updateContentCommand": [ "/bin/bash", diff --git a/.docker/entrypoint.sh b/.docker/entrypoint.sh index 4e8a8cb9..d947e282 100644 --- a/.docker/entrypoint.sh +++ b/.docker/entrypoint.sh @@ -4,4 +4,4 @@ set -o errexit set -o pipefail set -o nounset -/usr/local/bin/unifi-protect "$@" +/usr/local/bin/uiprotect "$@" diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f9b66e4e..a9be5642 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -28,7 +28,7 @@ { "label": "Generate Sample Data", "type": "shell", - "command": "unifi-protect generate-sample-data -w ${input:sampleTime} ${input:sampleAnonymize}", + "command": "uiprotect generate-sample-data -w ${input:sampleTime} ${input:sampleAnonymize}", "problemMatcher": [], "options": { "env": { @@ -39,7 +39,7 @@ { "label": "Regenerate Release Cache", "type": "shell", - "command": "unifi-protect release-versions", + "command": "uiprotect release-versions", "problemMatcher": [], }, ], diff --git a/README.md b/README.md index 68fd8dca..d3363154 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ pip install git+https://github.com/uilibs/uiprotect.git#egg=uiprotect A Docker container is also provided so you do not need to install/manage Python as well. You can add the following to your `.bashrc` or similar. ```bash -function unifi-protect() { +function uiprotect() { docker run --rm -it \ -e UFP_USERNAME=YOUR_USERNAME_HERE \ -e UFP_PASSWORD=YOUR_PASSWORD_HERE \ @@ -164,8 +164,8 @@ export UFP_PORT=443 # change to false if you do not have a valid HTTPS Certificate for your instance export UFP_SSL_VERIFY=True -unifi-protect --help -unifi-protect nvr +uiprotect --help +uiprotect nvr ``` ### Python diff --git a/docs/dev.md b/docs/dev.md index 1b0a5c9c..f08af551 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -22,7 +22,7 @@ Once you have all three setup, 2. Open the main folder 3. You should be prompted to "Reopen folder to develop in a container". If you are not, you can open the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) run the "Remote-Containers: Reopen in Container" command. -This should be all you need to do to get a working development environment. The docker container will automatically be build and VS Code will attach itself to it. The integrated terminal in VS Code will already be set up with the `unifi-protect` command. +This should be all you need to do to get a working development environment. The docker container will automatically be build and VS Code will attach itself to it. The integrated terminal in VS Code will already be set up with the `uiprotect` command. ### Docker (without VS Code) @@ -75,7 +75,7 @@ There is also a [VS Code task](https://code.visualstudio.com/Docs/editor/tasks) All of the tests in the project are ran against that is generated from a real UniFi Protect instance and then anonymized so it is safe to commit to a Git repo. To generate new sample test data: ``` -unifi-protect generate-sample-data +uiprotect generate-sample-data ``` This will gather test data for 30 seconds and write it all into the `tests/sample_data` directory. During this time, it is a good idea to generate some good events that can tested. An example would be to generate a motion event for a FloodLight, Camera and/or Doorbell and then also ring a Doorbell. @@ -87,7 +87,7 @@ This will gather test data for 30 seconds and write it all into the `tests/sampl ```bash export UFP_SAMPLE_DIR=/workspaces/uiprotect/test-data -unifi-protect generate-sample-data +uiprotect generate-sample-data ``` ### Real Data in Tests diff --git a/src/uiprotect/cli/base.py b/src/uiprotect/cli/base.py index d261d1d6..34420644 100644 --- a/src/uiprotect/cli/base.py +++ b/src/uiprotect/cli/base.py @@ -208,7 +208,7 @@ def adopt(ctx: typer.Context, name: Optional[str] = typer.Argument(None)) -> Non Adopts a device. By default, unadopted devices do not show up in the bootstrap. Use - `unifi-protect -u` to show unadopted devices. + `uiprotect -u` to show unadopted devices. """ require_device_id(ctx) obj: ProtectAdoptableDeviceModel = ctx.obj.device