A package manager build on top of hacs.
·
Report Bug
·
Request Feature
·
I use docker-containers to run home assistant. Since I am a big fan of configuration as code (CAC) and pushing everything to git is not the best idea, I was inspired to develop this package manager.
The package manager is build on top of hacs and its already established ecosystem and uses the hpm.json (Similar to package.json
and package-lock.json
in npm) file to manage the dependencies. It is a command line tool that allows you to add, remove and install dependencies to home assistant.
I decided to mostly follow the concepts of hacs but decided to teak some aspects to enable and enforce CAC concepts. The main difference here is that, no matter the configuration of the repository provided for hacs, the package manager always resolves the corresponding git reference and uses this to pin the version of the dependency. That way, the package manager ensures that the configuration is always reproducible.
The hpm.json
file is storing all installed dependencies.
The file is inspired by the package.json
file of npm
and yarn
.
I designed it with the following concepts in mind:
- Reproducible: The file should be able to reproduce the exact same installation on any machine.
- Local installation agnostic: Nothing in the file is specific to a particular local installation.
To archive this the package manager always resolves the corresponding git reference and uses this to pin the version of the dependency. That way, the package manager ensures that the configuration is always reproducible.
All other fields and values always base on top of that git reference.
The file should be able to reproduce the exact same installation on any machine. Therefore, the file does not contain any local installation specific information.
We never know where the user wants to install the dependencies. We only know what git reference to install and context about this reference.
brew install Beuterei/homebrew-tap/hpm
or without brew
curl -L https://github.com/Beuterei/hacs-package-manager/releases/latest/download/hpm-macos >/usr/local/bin/hpm
chmod +x /usr/local/bin/hpm
curl -L https://github.com/Beuterei/hacs-package-manager/releases/latest/download/hpm-linux >/usr/local/bin/hpm
chmod +x /usr/local/bin/hpm
curl -L https://github.com/Beuterei/hacs-package-manager/releases/latest/download/hpm-arm >/usr/local/bin/hpm
chmod +x /usr/local/bin/hpm
The API is inspired by the yarn
and npm
package manager. The following commands are available:
Adds a particular package or multiple packages to home assistant.
hpm add [DEPENDENCIES...] [OPTIONS]
DEPENDENCIES
: One or multiple packages to add to home assistant. Refs can be specified using a@
separator:repositorySlug@ref
.
-c, --configPath="hpm.json"
: Path to the hpm.json file relative to the current working directory.
Installs all dependencies defined in the hpm.json file. Before installing in removes all local dependencies files to ensure a clean install.
hpm ci [OPTIONS]
-c, --configPath="hpm.json"
: Path to the hpm.json file relative to the current working directory.-a, --haConfigPath="path/to/home-assistant"
: Path where to install dependencies relative to the current working directory.
Configure the CLI.
Currently following keys can be set and retrieved:
gitHubToken
: The GitHub token to use for the GitHub API.
The configuration is stored in the .npmrc
file of the users profile.
This can currently not be changed.
Set a configuration value.
hpm config set [OPTIONS] <KEY> <VALUE>
KEY
: The key to set.VALUE
: The value to set.
Get a configuration value
hpm config get [OPTIONS] [KEY]
or get the full configuration.
hpm config get [OPTIONS]
KEY
: The key to get
Removes a particular package or multiple packages from home assistant.
hpm remove [DEPENDENCIES...] [OPTIONS]
-c, --configPath="hpm.json"
: Path to the hpm.json file relative to the current working directory.-a, --haConfigPath="path/to/home-assistant"
: Path where to install dependencies relative to the current working directory.
Look at my own HA setup: https://github.com/Beuterei/home-assistant
The package manager caches default repositories of hacs to speed up the process. The cache is stored in the .hpm
directory of the users profile directory.
This can currently not be changed.
You can use the dev
commands to help you with local development.
Adds all dependencies of a category to home assistant.
hpm dev test add [OPTIONS] <TYPE>
TYPE
: The type of the dependencies to add. (appdaemon
,integration
,netdaemon
,plugin
,pythonScript
,template
,theme
)
--deleteHpm"
: Delete the hpm file before adding the dependencies.
- Add tests
- Add CI/CD