Skip to content

feat: add 'make dev' task with auto-reload to project template #811

@hartym

Description

@hartym

Summary

Add a make dev task to the generated project template that provides auto-reload functionality during development. Uses watchfiles (Python-native, cross-platform) which is already used by HARP core.

Context

When developing HARP proxy applications, developers need to manually restart the server after each code or configuration change. A make dev task with file watching would significantly improve the development experience.

The cookiecutter template lives at harp/commandline/cookiecutters/project/{{cookiecutter.__dir_name}}/Makefile.

Proposed Implementation

Makefile addition

dev: install  ## Start HARP proxy with auto-reload on file changes
	$(call execute,$(UV) run watchfiles "$(UV) run harp-proxy server{% if cookiecutter.create_application %} --enable {{cookiecutter.__pkg_name}}{% endif %}{% if cookiecutter.create_config %} --file config.yml{% endif %} $(HARP_OPTIONS)"{% if cookiecutter.create_application %} {{cookiecutter.__pkg_name}}/{% endif %}{% if cookiecutter.create_config %} config.yml{% endif %})

pyproject.toml addition

Add watchfiles as a dev dependency:

[project.optional-dependencies]
dev = ["watchfiles"]

Features

  • File watching: Monitors config.yml (if enabled) and all files in the application directory (if enabled)
  • Cross-platform: Works on macOS, Linux, and Windows without external dependencies
  • Proven: Same approach used by HARP core development (harp/commandline/utils/manager.py)

Testing Scenarios

  1. Config-only project: Create project with create_application=false, create_config=true. make dev watches only config.yml
  2. App project: Create project with create_application=true. make dev watches the app directory
  3. Full project: Both config and app enabled, both are watched
  4. File change detection: Modify a .py file or config.yml, server should restart automatically

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions