Compare commits
No commits in common. "main" and "subclasses" have entirely different histories.
main
...
subclasses
21
Makefile
21
Makefile
@ -37,27 +37,6 @@ verify-tag-version:
|
||||
$(eval TAG_NAME = $(shell [ -n "$(DRONE_TAG)" ] && echo $(DRONE_TAG) || git describe --tags --exact-match))
|
||||
test "v$(shell poetry version | awk '{print $$2}')" = "$(TAG_NAME)"
|
||||
|
||||
.PHONY: bump-patch
|
||||
bump-patch:
|
||||
$(eval NEW_VERSION = $(shell poetry version patch | awk '{print $$6}'))
|
||||
git add pyproject.toml
|
||||
git commit -m "Bump version to $(NEW_VERSION)"
|
||||
git tag "v$(NEW_VERSION)"
|
||||
|
||||
.PHONY: bump-minor
|
||||
bump-minor:
|
||||
$(eval NEW_VERSION = $(shell poetry version minor | awk '{print $$6}'))
|
||||
git add pyproject.toml
|
||||
git commit -m "Bump version to $(NEW_VERSION)"
|
||||
git tag "v$(NEW_VERSION)"
|
||||
|
||||
.PHONY: bump-major
|
||||
bump-major:
|
||||
$(eval NEW_VERSION = $(shell poetry version major | awk '{print $$6}'))
|
||||
git add pyproject.toml
|
||||
git commit -m "Bump version to $(NEW_VERSION)"
|
||||
git tag "v$(NEW_VERSION)"
|
||||
|
||||
# Upload to pypi
|
||||
.PHONY: upload
|
||||
upload: verify-tag-version build
|
||||
|
26
README.md
26
README.md
@ -10,14 +10,13 @@ pipx install unhacs
|
||||
|
||||
## Usage
|
||||
|
||||
Unhacs provides several commands to manage your Home Assistant packages. It stores installed or requsted packages in a lock file called `unhacs.yaml`. This makes it possible to version control your packages and easily share them with others.
|
||||
Unhacs provides several commands to manage your Home Assistant packages:
|
||||
|
||||
### Add a package
|
||||
|
||||
To add a package, use the `add` command followed by the URL of the package. Optionally, you can specify the package name and version. If no version is specified, the latest version will be installed:
|
||||
To add a package, use the `add` command followed by the URL of the package. Optionally, you can specify the package name and version:
|
||||
|
||||
```bash
|
||||
unhacs add <package_url>
|
||||
unhacs add <package_url> --version <version>
|
||||
```
|
||||
|
||||
@ -27,25 +26,24 @@ If the package already exists, you can update it by adding the `--update` flag:
|
||||
unhacs add <package_url> --update
|
||||
```
|
||||
|
||||
If the package is a Lovelace plugins or theme, install it using the appropriate flags:
|
||||
If the package is a Lovelace plugin, you must specify it using the `--plugin` flag:
|
||||
|
||||
```bash
|
||||
unhacs add --plugin <package_url>
|
||||
unhacs add --theme <package_url>
|
||||
```
|
||||
|
||||
If you already have a list of packages in a file, you can add them all at once using the `--file` flag:
|
||||
|
||||
```bash
|
||||
unhacs add --file ./unhacs.yaml
|
||||
unhacs add --file <file_path>
|
||||
```
|
||||
|
||||
#### Add a component from a forked Home Assistant Core repository
|
||||
### Add a component from a forked Home Assistant Core repository
|
||||
|
||||
To add a component from a fork of home-assistant/core, use the `--fork-component` flag followed by the name ofthe component and then specify the branch with the `--fork-branch` flag:
|
||||
To add a component from a fork of home-assistant/core, use the `--forked-component` flag followed by the URL of the forked repository and then specify the branch with the `--branch` flag:
|
||||
|
||||
```bash
|
||||
unhacs add --fork-component <component_name> --fork-branch <branch_name> <forked_repo_url>
|
||||
unhacs add --forked-component <forked_repo_url> --branch <branch>
|
||||
```
|
||||
|
||||
### List packages
|
||||
@ -54,6 +52,11 @@ To list all installed packages, use the `list` command:
|
||||
|
||||
```bash
|
||||
unhacs list
|
||||
```
|
||||
|
||||
For a more detailed output, add the `--verbose` flag:
|
||||
|
||||
```bash
|
||||
unhacs list --verbose
|
||||
```
|
||||
|
||||
@ -63,6 +66,11 @@ To list all tags for a package, use the `tags` command followed by the name of t
|
||||
|
||||
```bash
|
||||
unhacs tags <package_url>
|
||||
```
|
||||
|
||||
The number or returned tags is limited to 10 by default. To change this, add the `--limit` flag:
|
||||
|
||||
```bash
|
||||
unhacs tags <package_url> --limit 20
|
||||
```
|
||||
|
||||
|
@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.poetry]
|
||||
name = "unhacs"
|
||||
version = "0.7.1"
|
||||
version = "0.6.2"
|
||||
description = "Command line interface to install Home Assistant Community Store packages"
|
||||
authors = ["Ian Fijolek <ian@iamthefij.com>"]
|
||||
license = "MIT"
|
||||
@ -17,7 +17,6 @@ pyyaml = "^6.0.0"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^24.4.2"
|
||||
isort = "^5.13.2"
|
||||
mypy = "^1.10.0"
|
||||
pre-commit = "^3.7.1"
|
||||
types-requests = "^2.32.0"
|
||||
|
@ -6,7 +6,6 @@ from pathlib import Path
|
||||
|
||||
from unhacs.main import main
|
||||
from unhacs.packages import get_installed_packages
|
||||
from unhacs.packages import read_lock_packages
|
||||
|
||||
INTEGRATION_URL = "https://github.com/simbaja/ha_gehome"
|
||||
INTEGRATION_VERSION = "v0.6.9"
|
||||
@ -125,30 +124,6 @@ class TestMainIntegrarion(unittest.TestCase):
|
||||
self.assertEqual(installed[0].url, INTEGRATION_URL)
|
||||
self.assertEqual(installed[0].version, INTEGRATION_VERSION)
|
||||
|
||||
# Delete the custom_components folder and re-install the integration using the lock file
|
||||
shutil.rmtree(os.path.join(self.test_dir, "custom_components"))
|
||||
self.run_itest(
|
||||
"Re-install integration using lock file",
|
||||
"add --file unhacs.yaml",
|
||||
expected_files=[
|
||||
"custom_components/ge_home/__init__.py",
|
||||
"custom_components/ge_home/manifest.json",
|
||||
"custom_components/ge_home/switch.py",
|
||||
],
|
||||
)
|
||||
|
||||
# Delete the lock file and then regenerate it
|
||||
os.remove(os.path.join(self.test_dir, "unhacs.yaml"))
|
||||
self.run_itest(
|
||||
"Regenerate lock file",
|
||||
"list --freeze",
|
||||
expected_files=[
|
||||
"unhacs.yaml",
|
||||
],
|
||||
)
|
||||
|
||||
self.assertGreater(len(read_lock_packages()), 0)
|
||||
|
||||
self.run_itest(
|
||||
"Remove integration",
|
||||
"remove ha_gehome --yes",
|
||||
|
@ -5,6 +5,7 @@ from pathlib import Path
|
||||
|
||||
from unhacs.git import get_repo_tags
|
||||
from unhacs.packages import Package
|
||||
from unhacs.packages import PackageType
|
||||
from unhacs.packages import get_installed_packages
|
||||
from unhacs.packages import read_lock_packages
|
||||
from unhacs.packages import write_lock_packages
|
||||
@ -54,12 +55,6 @@ def parse_args(argv: list[str]):
|
||||
# List installed packages
|
||||
list_parser = subparsers.add_parser("list", description="List installed packages.")
|
||||
list_parser.add_argument("--verbose", "-v", action="store_true")
|
||||
list_parser.add_argument(
|
||||
"--freeze",
|
||||
"-f",
|
||||
action="store_true",
|
||||
help="Regenerate unhacs.yaml with installed packages.",
|
||||
)
|
||||
|
||||
# List git tags for a given package
|
||||
list_tags_parser = subparsers.add_parser("tags", help="List tags for a package.")
|
||||
@ -238,15 +233,11 @@ class Unhacs:
|
||||
|
||||
self.write_lock_packages(packages)
|
||||
|
||||
def list_packages(self, verbose: bool = False, freeze: bool = False):
|
||||
def list_packages(self, verbose: bool = False):
|
||||
"""List installed packages and their versions."""
|
||||
installed_packages = get_installed_packages()
|
||||
for package in installed_packages:
|
||||
for package in get_installed_packages():
|
||||
print(package.verbose_str() if verbose else str(package))
|
||||
|
||||
if freeze:
|
||||
self.write_lock_packages(installed_packages)
|
||||
|
||||
def list_tags(self, url: str, limit: int = 10):
|
||||
print(f"Tags for {url}:")
|
||||
for tag in get_repo_tags(url)[-1 * limit :]:
|
||||
@ -352,7 +343,7 @@ def main(argv: list[str] | None = None) -> int:
|
||||
print("Either a file or a URL must be provided")
|
||||
return 1
|
||||
elif args.subcommand == "list":
|
||||
unhacs.list_packages(args.verbose, args.freeze)
|
||||
unhacs.list_packages(args.verbose)
|
||||
elif args.subcommand == "tags":
|
||||
unhacs.list_tags(args.url, limit=args.limit)
|
||||
elif args.subcommand == "remove":
|
||||
|
Loading…
Reference in New Issue
Block a user