Skip to content

Hooks#48

Merged
audreyfeldroy merged 11 commits intocookiecutter:masterfrom
raphigaziano:hooks
Sep 1, 2013
Merged

Hooks#48
audreyfeldroy merged 11 commits intocookiecutter:masterfrom
raphigaziano:hooks

Conversation

@raphigaziano
Copy link
Copy Markdown
Contributor

I started experimenting with running optional external scripts before and after a project generation, as i suggested in #33. I ignored the initial idea of hooks acting on the context, as this seemed harder to integrate with the current code. I'm thinking the run_hook function could do some dispatching to handle those. The two hooks implemented here could be used to create a virtualenv, initiate a git repo, pip install dependencies...

The way i'm avoiding copying the hooks directory is pretty ugly. This suggests that a more standardized way of ignoring some template files/directories could be handy.

I'm still having trouble running tox, so i hope this doesn't break things under 2.6 or 3.*. The whole suite ran fine under 2.7.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same when pulling 3791528 on raphigaziano:hooks into cf1fb09 on audreyr:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-1.36%) when pulling 19d56c8 on raphigaziano:hooks into cf1fb09 on audreyr:master.

@audreyfeldroy
Copy link
Copy Markdown
Member

@raphigaziano Just wanted to let you know that this is on my mind, and that I really appreciate the pull request. I will be reviewing this shortly...

This was referenced Aug 31, 2013
@audreyfeldroy
Copy link
Copy Markdown
Member

Currently working on this in https://github.com/audreyr/cookiecutter/tree/raphigaziano-hooks...just a partial checkin after merging with other changes. I'll continue to work on this in the morning.

@audreyfeldroy
Copy link
Copy Markdown
Member

Almost done. Overall this is all really, really good. I'm just trying to figure out where my merge broke test_run_hooks.

@audreyfeldroy
Copy link
Copy Markdown
Member

Done with the merge, now playing around with the hooks before bringing it into master. This is sooo cool!

I am so excited! I think a Cookiecutter plugin system will practically write itself based on this change. I can see it all coming together.

@raphigaziano
Copy link
Copy Markdown
Contributor Author

Cool =)

Not sure i understand how this could turn into a plugin system. Do you mean that a plugin would simply be a collection of various hooks ?

Also, regarding more "internal" hooks like the ones suggested by @pydanny in #29: Should those be run externally as well ? I'm thinking requiring those to be in python and to define a standardized function so that we could import and execute that function directly would be more efficient, but it feels a bit inconsistent to have two different ways to handle various kinds of hooks.

@audreyfeldroy
Copy link
Copy Markdown
Member

A plugin could be as simple as a Python module containing function definitions (I think like what you just described). Installation instructions for a plugin could say what function call(s) (and initialization steps if needed) should be added to your pre and/or post hook file.

About the more "internal"-style hooks in #29, looking at that again, that looks like an example of a pre-generate script which adds context. Let's not worry about implementing exactly that; I don't think it's necessary now with your hook system.

I'm not sure if this is what you mean, but yes, it would be good to have a standard best-practice way to:

  • inject context vars from the pre script
  • access context vars from the post script
    I'll create an issue for that.

@audreyfeldroy audreyfeldroy merged commit 19d56c8 into cookiecutter:master Sep 1, 2013
@audreyfeldroy
Copy link
Copy Markdown
Member

Merged into master, but not on PyPI yet

@audreyfeldroy
Copy link
Copy Markdown
Member

Also, just a heads up that I moved hooks/ to be at the same level as the template and cookiecutter.json. See http://cookiecutter.readthedocs.org/en/latest/advanced_usage.html#using-pre-post-generate-hooks

@raphigaziano raphigaziano deleted the hooks branch September 2, 2013 18:03
JosephGasiorekUSDS pushed a commit to JosephGasiorekUSDS/cookiecutter that referenced this pull request Jun 30, 2024
Revised questions based on our first user testing sesh
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.

3 participants