diff --git a/README.md b/README.md index 64cac00..4659bb4 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,35 @@ Options: ``` +## 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 diff --git a/tests/test_applecrate_cli.py b/tests/test_applecrate_cli.py index 457b841..11ea294 100644 --- a/tests/test_applecrate_cli.py +++ b/tests/test_applecrate_cli.py @@ -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(): @@ -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: @@ -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