Skip to content

Commit

Permalink
Configured dev tools
Browse files Browse the repository at this point in the history
  • Loading branch information
RhetTbull committed Feb 3, 2024
1 parent ea240eb commit 245d5fc
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[bumpversion]
current_version = 0.0.1
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)
serialize = {major}.{minor}.{patch}

[bumpversion:file:applecrate/version.py]
parse = __version__\s=\s\"(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\"
serialize = {major}.{minor}.{patch}
87 changes: 86 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,96 @@

Package your command line tools into a native macOS installer.

AppleCrate is a tool for creating native macOS installers for your command line tools. AppleCrate can be used as a command line interface (CLI) tool or as a library in your own Python code. It's useful for creating installers for command line tools written in any language. Tools written in interpreted languages like Python will need to be first processed with a tool like [pyinstaller](https://www.pyinstaller.org/) to create a standalone executable.
AppleCrate is a tool for creating native macOS installers for your command line tools. It's useful for creating installers for command line tools written in any language. Tools written in interpreted languages like Python will need to be first processed with a tool like [pyinstaller](https://www.pyinstaller.org/) to create a standalone executable.

## Installation

```bash
pip install applecrate
```

## Simple Example

```bash
applecrate build --app mytool --version 1.0.0 --license LICENSE --install dist/mytool "/usr/local/bin/{{ app }}-{{ version }}" --link /usr/local/bin/mytool "/usr/local/bin/{{ app }}-{{ version }}"
```

This will create a native macOS installer for the tool `dist/mytool` and install it to `/usr/local/bin/mytool-1.0.0`. It will create a symlink to the tool at `/usr/local/bin/mytool` and will also create an uninstaller to remove the tool.

## Usage

<!--[[[cog
from applecrate.cli import cli
from click.testing import CliRunner
runner = CliRunner()
result = runner.invoke(cli, ["build", "--help"])
help = result.output.replace("Usage: cli", "Usage: applecrate")
cog.out(
"```\n{}\n```".format(help)
)
]]] -->
```
Usage: applecrate build [OPTIONS]
applecrate: A Python package for creating macOS installer packages.
Options:
-a, --app TEXT App name
-v, --version TEXT App version
-l, --license FILE Path to license file
-w, --welcome PATH Path to welcome markdown or HTML file
-c, --conclusion PATH Path to conclusion markdown or HTML file
-u, --uninstall FILE Path to uninstall script; if not provided, an
uninstall script will be created for you.See
also '--no-uninstall'
-U, --no-uninstall Do not include an uninstall script in the
package
-L, --url NAME URL Links to additional resources to include in
conclusion HTML shown after installation. For
example, the project website or documentation.
-b, --banner FILE Path to optional PNG banner image for
installer package.
-i, --install FILE_OR_DIR DEST Install FILE_OR_DIR to destination DEST; DEST
must be an absolute path, for example
'/usr/local/bin/app'. DEST may include
template variables {{ app }} and {{ version
}}. For example: `--install dist/app
"/usr/local/bin/{{ app }}-{{ version }}"` will
install the file 'dist/app' to
'/usr/local/bin/app-1.0.0' if --app=app and
--version=1.0.0.
-k, --link SRC TARGET Create a symbolic link from SRC to DEST after
installation. SRC and TARGET must be absolute
paths and both may include template variables
{{ app }} and {{ version }}. For example:
`--link "/Library/Application Support/{{ app
}}/{{ version }}/app" "/usr/local/bin/{{ app
}}-{{ version }}"`
-p, --pre-install FILE Path to pre-install shell script; if not
provided, a pre-install script will be created
for you.
-P, --post-install FILE Path to post-install shell script; if not
provided, a post-install script will be
created for you.
--help Show this message and exit.
```
<!--[[[end]]] -->

## To Do

- [ ] Add support for signing the installer with a developer certificate
- [ ] Add support for notarizing the installer
- [ ] Add python API to create installers programmatically
- [ ] Add `applecrate init` command to create a TOML configuration via a wizard
- [ ] Add `applecrate check` command to check the configuration without building the installer
- [ ] Documentation
- [ ] Tests

## Credits

Heavily inspired by [macOS Installer Buidler](https://github.com/KosalaHerath/macos-installer-builder) by [Kosala Herath](https://github.com/KosalaHerath). AppleCrate is a complete rewrite in Python but borrows many ideas from macOS Installer Builder and is thus licensed under the same Apache License, Version 2.0.

## License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License.
8 changes: 8 additions & 0 deletions README_DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ Linting and formatting utilizes [ruff](https://github.com/astral-sh/ruff)
## Publishing

- `flit publish`

## Updating the README

- `cog -r README.md`

## Updating version

- `bump2version [patch|minor|major] --verbose [--dry-run]`
26 changes: 20 additions & 6 deletions applecrate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,22 @@ def cli():
@click.option(
"--welcome",
"-w",
type=click.Path(exists=True),
type=click.Path(dir_okay=False, exists=True),
help="Path to welcome markdown or HTML file",
)
@click.option(
"--conclusion",
"-c",
type=click.Path(exists=True),
type=click.Path(dir_okay=False, exists=True),
help="Path to conclusion markdown or HTML file",
)
@click.option(
"--uninstall",
"-u",
type=click.Path(dir_okay=False, exists=True),
help="Path to uninstall script; " "if not provided, an uninstall script will be created for you." "See also '--no-uninstall'",
help="Path to uninstall script; "
"if not provided, an uninstall script will be created for you."
"See also '--no-uninstall'",
)
@click.option(
"--no-uninstall",
Expand Down Expand Up @@ -182,9 +184,13 @@ def build(**kwargs):

# Render the welcome and conclusion templates
echo("Creating welcome.html")
create_html_file(welcome, BUILD_DIR / "Resources" / "welcome.html", data, "welcome.md")
create_html_file(
welcome, BUILD_DIR / "Resources" / "welcome.html", data, "welcome.md"
)
echo("Creating conclusion.html")
create_html_file(conclusion, BUILD_DIR / "Resources" / "conclusion.html", data, "conclusion.md")
create_html_file(
conclusion, BUILD_DIR / "Resources" / "conclusion.html", data, "conclusion.md"
)

echo("Copying license file")
copy_and_create_parents(license, BUILD_DIR / "Resources" / "LICENSE.txt")
Expand All @@ -196,7 +202,15 @@ def build(**kwargs):
# Render the uninstall script
if not no_uninstall:
echo("Creating uninstall script")
target = BUILD_DIR / "darwinpkg" / "Library" / "Application Support" / app / version / "uninstall.sh"
target = (
BUILD_DIR
/ "darwinpkg"
/ "Library"
/ "Application Support"
/ app
/ version
/ "uninstall.sh"
)
if uninstall:
copy_and_create_parents(uninstall, target)
else:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies = [
]

[project.optional-dependencies]
dev = ["bump2version>=1.0.1,<2.0.0", "cogapp>=3.3.0,<4.0.0"]
lint = ["ruff>=0.1.14"]

[project.urls]
Expand Down

0 comments on commit 245d5fc

Please sign in to comment.