Skip to content

Conversation

@opeolluwa
Copy link
Owner

@opeolluwa opeolluwa commented Dec 21, 2025

Summary by Sourcery

Add a helper script to generate a standard Justfile for an Axum project with Docker and SeaORM workflow commands.

New Features:

  • Introduce a Python script that interactively creates a preconfigured Justfile in a specified directory for Axum-based projects.

Enhancements:

  • Provide a standardized set of just commands for development, linting, Docker lifecycle management, and SeaORM migrations/entities generation.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 21, 2025

Reviewer's Guide

Adds a standalone Python helper script that interactively writes a preconfigured Justfile for an Axum/Docker/SeaORM project into a user-specified directory, with basic validation and error handling.

Sequence diagram for the new Justfile creation script

sequenceDiagram
    actor User
    participant Script as create_axum_justfile_py
    participant OS
    participant FileSystem

    User->>Script: Run script
    Script->>User: Prompt for target directory
    User-->>Script: Enter target_dir

    Script->>OS: Validate target_dir is nonempty
    alt directory_not_provided
        Script->>User: Print error for missing directory
        Script->>OS: Exit with status 1
    else directory_provided
        Script->>OS: Check if target_dir is directory
        alt not_a_directory
            Script->>User: Print invalid directory error
            Script->>OS: Exit with status 1
        else is_directory
            Script->>FileSystem: Check if Justfile exists in target_dir
            alt justfile_exists
                Script->>User: Print Justfile already exists error
                Script->>OS: Exit with status 1
            else justfile_missing
                Script->>FileSystem: Create and write Justfile with template
                alt write_failed
                    Script->>User: Print write failure message
                    Script->>OS: Exit with status 1
                else write_succeeded
                    Script->>User: Print success message with path
                    Script->>OS: Exit with status 0
                end
            end
        end
    end
Loading

File-Level Changes

Change Details Files
Introduce a Python script that generates a standardized Justfile for Axum projects with Docker and SeaORM tooling.
  • Define JUSTFILE_CONTENT as a multiline string containing just aliases, dotenv configuration, Docker compose command, dev/rebuild/lint/logs/clean/install-deps/migration tasks, and SeaORM entity generation commands.
  • Implement a main() function that prompts for a target directory, validates that it exists and that a Justfile does not already exist there, and writes JUSTFILE_CONTENT to Justfile with UTF-8 encoding.
  • Add basic error handling for missing/invalid directories, existing Justfile conflicts, and I/O failures, exiting with non-zero status codes on errors and printing a success message on completion.
  • Wire main() to run when the script is executed as main.
scripts/create-axum-justfile.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@opeolluwa opeolluwa merged commit 7d313f8 into master Dec 21, 2025
7 of 8 checks passed
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • Consider allowing the target directory to be passed as a command-line argument (with a fallback to interactive input) so the script can be used more easily in non-interactive or scripted environments.
  • The Justfile content includes hard-coded values like the docker-compose file name and the MySQL connection URL; extracting these into clearly marked placeholders or script arguments would make the generated file safer and more reusable across projects.
  • There is a minor inconsistency in the Justfile aliases (e.g., alias config:= configure vs others with spaces around :=); normalizing this improves readability and reduces the chance of subtle parsing issues.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider allowing the target directory to be passed as a command-line argument (with a fallback to interactive input) so the script can be used more easily in non-interactive or scripted environments.
- The Justfile content includes hard-coded values like the docker-compose file name and the MySQL connection URL; extracting these into clearly marked placeholders or script arguments would make the generated file safer and more reusable across projects.
- There is a minor inconsistency in the Justfile aliases (e.g., `alias config:= configure` vs others with spaces around `:=`); normalizing this improves readability and reduces the chance of subtle parsing issues.

## Individual Comments

### Comment 1
<location> `scripts/create-axum-justfile.py:88` </location>
<code_context>
+    @sea-orm-cli migrate generate "{{target}}"
+
+@generate-entities:
+    sea-orm-cli generate entity --database-url=mysql://community:community@localhost:3307/community --with-serde both -o src/entities
+"""
+
</code_context>

<issue_to_address>
**🚨 issue (security):** Hard-coded DB credentials and connection string should be externalized

`--database-url=mysql://community:community@localhost:3307/community` embeds credentials and connection details directly in the Justfile, which is risky even for local use if the file is shared or checked in. Use an environment variable or `.env` value (e.g. `DATABASE_URL`) and reference it in the Justfile (e.g. `--database-url=${DATABASE_URL}`) instead of hard-coding secrets and host/port details.
</issue_to_address>

### Comment 2
<location> `scripts/create-axum-justfile.py:92-94` </location>
<code_context>
+"""
+
+def main():
+    target_dir = input("Enter directory to create Justfile in: ").strip()
+
+    if not target_dir:
+        print("Error: No directory provided")
+        sys.exit(1)
</code_context>

<issue_to_address>
**suggestion:** Using interactive input only may limit automation and scriptability

Because this is under `scripts/`, it may be used in automated flows (e.g. project bootstrap). Requiring interactive `input()` only makes that difficult. Please also accept the target directory as a CLI argument (e.g. via `sys.argv`/`argparse`), and only prompt with `input()` when no argument is given, so it remains usable both interactively and in automation.

Suggested implementation:

```python
def main():
    # Prefer CLI argument for automation; fall back to interactive prompt
    if len(sys.argv) > 1:
        target_dir = sys.argv[1].strip()
    else:
        target_dir = input("Enter directory to create Justfile in: ").strip()

    if not target_dir:
        print("Error: No directory provided")
        sys.exit(1)

```

1. Ensure `import sys` is present at the top of `scripts/create-axum-justfile.py` (and `import os` if not already imported), since `sys.argv` and `os.path` are used.
2. If this script is intended to be run as a module, confirm there is a `if __name__ == "__main__": main()` block so the new CLI behavior is used when executed directly.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@sea-orm-cli migrate generate "{{target}}"

@generate-entities:
sea-orm-cli generate entity --database-url=mysql://community:community@localhost:3307/community --with-serde both -o src/entities
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Hard-coded DB credentials and connection string should be externalized

--database-url=mysql://community:community@localhost:3307/community embeds credentials and connection details directly in the Justfile, which is risky even for local use if the file is shared or checked in. Use an environment variable or .env value (e.g. DATABASE_URL) and reference it in the Justfile (e.g. --database-url=${DATABASE_URL}) instead of hard-coding secrets and host/port details.

Comment on lines +92 to +94
target_dir = input("Enter directory to create Justfile in: ").strip()

if not target_dir:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Using interactive input only may limit automation and scriptability

Because this is under scripts/, it may be used in automated flows (e.g. project bootstrap). Requiring interactive input() only makes that difficult. Please also accept the target directory as a CLI argument (e.g. via sys.argv/argparse), and only prompt with input() when no argument is given, so it remains usable both interactively and in automation.

Suggested implementation:

def main():
    # Prefer CLI argument for automation; fall back to interactive prompt
    if len(sys.argv) > 1:
        target_dir = sys.argv[1].strip()
    else:
        target_dir = input("Enter directory to create Justfile in: ").strip()

    if not target_dir:
        print("Error: No directory provided")
        sys.exit(1)
  1. Ensure import sys is present at the top of scripts/create-axum-justfile.py (and import os if not already imported), since sys.argv and os.path are used.
  2. If this script is intended to be run as a module, confirm there is a if __name__ == "__main__": main() block so the new CLI behavior is used when executed directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants