Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for --template argument to wagtail start. Fix #10423 #10566

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

thibaudcolas
Copy link
Member

Fixes #10423. This is the "MVP" implementation which makes it possible to pass a --template to startproject, without any other niceties.

Potential improvements once we have a clearer idea of what to do with this:

  • Documentation. Currently there are only a few mentions of the wagtail CLI, no single source of truth.
  • Support for aliases / blessed template sources (Support for custom templates in wagtail start command #10423 (comment)). This would need building on top of startproject.
  • Support for custom extensions, name, and other startproject options.
  • Perhaps nicer CLI feedback or support for more startproject options
  • Unit tests? I couldn’t see any for start nor updatemodulepaths

  • Do the tests still pass?[^1]
  • Does the code comply with the style guide?
  • [ ] For Python changes: Have you added tests to cover the new/fixed behaviour? No, there are no tests for this code currently.
  • [ ] For front-end changes: Did you test on all of Wagtail’s supported environments?[^2]
  • [ ] For new features: Has the documentation been updated accordingly? No, there are no docs for this CLI

To test this, make sure start still works with the default, and make sure it works with a --template:

wagtail start mysite
wagtail start mysite --template=https://github.com/thibaudcolas/wagtail-tutorial-template/archive/main.zip
# Potentially compare to:
./wagtail/test/manage.py startproject mysite --template=https://github.com/thibaudcolas/wagtail-tutorial-template/archive/main.zip

@thibaudcolas thibaudcolas added this to the 5.1 milestone Jun 14, 2023
@thibaudcolas thibaudcolas added DX Developer eXperience type:Enhancement labels Jun 14, 2023
@squash-labs
Copy link

squash-labs bot commented Jun 17, 2023

Manage this branch in Squash

Test this branch here: https://thibaudcolasfeature10423-start-lca3z.squash.io

Copy link
Member

@laymonage laymonage left a comment

Choose a reason for hiding this comment

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

Tested with the provided examples, and also by downloading the template and passing the local file path. Yeah I'm not too sure about unit tests too.

Passing an incorrect template URL or file path seems to throw a descriptive error too (which I assume comes from Django's command).

Awesome work, thank you very much!

@@ -59,14 +59,24 @@ class CreateProject(Command):
description = "Creates the directory structure for a new Wagtail project."

def add_arguments(self, parser):
import wagtail
Copy link
Member

@laymonage laymonage Jul 7, 2023

Choose a reason for hiding this comment

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

I suppose we could also do something like __file__.parent().parent(), but I'm not sure that's a better approach in case we move this file around

(Just noticed: this is also in the original implementation, so all good!)

My suggestion would be to extract the logic to a separate method, e.g. get_default_template() maybe?

@laymonage laymonage force-pushed the feature/10423-start-template branch from 75bb7e8 to 354ea5d Compare July 12, 2023 12:17
@laymonage laymonage force-pushed the feature/10423-start-template branch from 354ea5d to 366e7f0 Compare July 12, 2023 12:18
@laymonage laymonage merged commit 366e7f0 into wagtail:main Jul 12, 2023
18 of 19 checks passed
@thibaudcolas thibaudcolas deleted the feature/10423-start-template branch July 12, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Developer eXperience type:Enhancement
Projects
Status: 🎉 Done
Status: Done
Development

Successfully merging this pull request may close these issues.

Support for custom templates in wagtail start command
2 participants