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

Allow overriding or customizing the template files #111

Closed
scottanderson42 opened this issue Jun 1, 2023 · 4 comments · Fixed by #123
Closed

Allow overriding or customizing the template files #111

scottanderson42 opened this issue Jun 1, 2023 · 4 comments · Fixed by #123
Assignees
Labels
enhancement New feature or request released

Comments

@scottanderson42
Copy link

  • [x ] I'd be willing to implement this feature

Description

Allowing the generator files to be modified automatically to include or omit features.

Motivation

There are any number of customizations we'd like to make to the project generators, such as creating a SAM template.yaml, adding specific sections or configuration to pyproject.toml, adding or modifying tasks in project.json, and so on. We could create our own generator that calls the @nxlv generator, but that seems wasteful and somewhat difficult if all we need to do is, for example, change the pytest configuration.

Suggested Implementation

Passing in a simple --template-files-dir that overrides the location of the template files. Or somewhat more complicated, only overrides the files that are present in the additional directory. This would introduce a minimal maintenance burden.

Alternate Implementations

There may be nx conventions for generators of which I am unaware, but some other approaches are:

  • Add a features parameter to the generators that is used to toggle the presence of sections of the files or modify behavior, similar to addDevDependencies but generalized. Additional features would require code additions though.
  • Ensure that each of the functions used to perform actions in the current generator are exported and composable by another generator. An example would be the project configuration object, which is both created and directly used in the project generator function. An exported function that returns a default configuration suitable for modification would be useful to call from another generator.
@lucasvieirasilva
Copy link
Owner

Hey @scottanderson42, I agree, currently, the project generator is not customizable enough, let me research a little bit, look at how Nx does for their own generators, and discuss with you more about it.

I agree that could be not productive if you write your generator trying to remove or modify the current generator, another suggestion might be a light version of the project generator that only generates a minimal number of files, in this way, it is easy to extend the @nxlv generator to your uses cases without any workaround to change what the base generator created.

Sounds good?

@scottanderson42
Copy link
Author

Sounds good to me!

@lucasvieirasilva
Copy link
Owner

Hey @scottanderson42 sorry for the delay, I finally had the time to raise the PR that implements a new project generator, more flexible, I also used your suggestion to have the --templateDir CLI option to point for a custom template directory.

PR: #123

It also fixes #117 because I'm not installing the tomli anymore.

lucasvieirasilva added a commit that referenced this issue Jun 18, 2023
)

* feat(nx-python): add a new version of the poetry project generator

re #111
fix #117
github-actions bot pushed a commit that referenced this issue Jun 18, 2023
# [15.11.0](nx-python-v15.10.0...nx-python-v15.11.0) (2023-06-18)

### Features

* **nx-python:** add a new version of the poetry project generator ([#123](#123)) ([c793b0d](c793b0d)), closes [#111](#111) [#117](#117)
@github-actions
Copy link

🎉 This issue has been resolved in version 15.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lucasvieirasilva lucasvieirasilva removed the in-progress We are working on this Issue label Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants