Skip to content

Commit

Permalink
Added test for install via config
Browse files Browse the repository at this point in the history
  • Loading branch information
RhetTbull committed Feb 5, 2024
1 parent 5a215de commit 94a3162
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,35 @@ Options:
```
<!--[[[end]]] -->

## Configuration

The command line tool applecrate can be configured via `pyproject.toml` or `applecrate.toml` in the current working directory or via command line options. The command line arguments will always take precedence over the configuration files. If present, `applecrate.toml` will take precedence over `pyproject.toml`. The configuration file should be in the following format:

`pyproject.toml`:

```toml
[tool.applecrate]
app = "mytool"
version = "1.0.0"
license = "LICENSE"
install = [
["dist/mytool", "/usr/local/bin/{{ app }}-{{ version }}"],
]
```

`applecrate.toml`:

```toml
app = "mytool"
version = "1.0.0"
license = "LICENSE"
install = [
["dist/mytool", "/usr/local/bin/{{ app }}-{{ version }}"],
]
```

Any command line option is a valid key in the configuration file. For example, the `--app` option can be set in the configuration file as `app = "mytool"`. Command line options with a dash (`-`) should be converted to underscores (`_`) in the configuration file. For example, the `--pre-install` option should be set in the configuration file as `pre_install = "scripts/preinstall.sh"`.

## To Do

- [X] Add support for signing the installer with a developer certificate
Expand Down
4 changes: 4 additions & 0 deletions tests/test_applecrate_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from click.testing import CliRunner

from applecrate.cli import cli
from applecrate.pkg_utils import pkg_files


def test_cli_config_precedence():
Expand All @@ -17,6 +18,7 @@ def test_cli_config_precedence():
"""
output = "applecrate_output.pkg"
app = "applecrate"
install = [["applecrate.toml", "/usr/local/bin/applecrate.toml"],]
"""
)
with open("pyproject.toml", "w") as f:
Expand All @@ -39,3 +41,5 @@ def test_cli_config_precedence():
assert result.exit_code == 0
assert "applecrate-2.0.0-cli_output.pkg" in result.output
assert pathlib.Path("applecrate-2.0.0-cli_output.pkg").exists()
files = pkg_files("applecrate-2.0.0-cli_output.pkg")
assert "applecrate.pkg/usr/local/bin/applecrate.toml" in files

0 comments on commit 94a3162

Please sign in to comment.