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

More control over created brick contents #516

Open
seancorfield opened this issue Nov 29, 2024 · 7 comments
Open

More control over created brick contents #516

seancorfield opened this issue Nov 29, 2024 · 7 comments

Comments

@seancorfield
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I would like to be able to control the contents of newly-created bricks.

Specifically:

  • a way to specify/override the default version of Clojure used (it's currently hard-coded)
  • a way to suppress creation of resources (I very rarely need this, and I don't like it being created by default -- and the .keep file should probably be in resources/<brick-name>/ instead of just resources)
  • a way to provide a standard prelude in new src/test files (e.g., a copyright message)
  • a way to specify different requires in test files and a different default testing library

Describe the solution you'd like
Ideally, use Selmer templates for various files that need to be created, with a way for users to provide their own on a global or per-workspace basis.

Provide a way to configure (in workspace.edn and via the CLI) additional/overriding "variables" to be substituted into these templates.

Perhaps, when a workspace is created, Polylith could copy its default templates (or a user's global overrides?) into a folder, and those templates would be used for any brick creation from then on, simplifying any customization process?

@seancorfield
Copy link
Contributor Author

seancorfield commented Nov 29, 2024

Even if this is some ways off, a couple of changes should be made sooner:

  • update the shared/clojure-ver from 1.11.1 to 1.12.0 (note: 1.11.4 is the recommended version of 1.11 anyway)
  • add an additional .gitignore for Calva's new REPL window: .calva/repl.calva-repl (.calva/output-window/output.calva-repl should be kept as the old ignore too, I think)

I've submitted PRs for both of these.

@seancorfield
Copy link
Contributor Author

Weird, I thought I'd written a complete proposal of the template structure but I can't find it, so I'll add it again.

I'm proposing a structure like the following:

templates/
  .gitignore
  deps.edn
  readme.md
  workspace.edn
  bases/
    deps.edn
    main.clj
    test.clj
  components/
    deps.edn
    interface.clj
    impl.clj
    test.clj
  projects/
    deps.edn

If impl.clj is present, it is used as a template for components/<entity>/src/<top-ns>/<entity>/impl.clj so users can get started with a split interface/implementation component if they want.

The defaults would be in Polylith's creator brick under resources/creator/templates and users could have "global" overrides in {user.home}/.config/polylith/templates (alongside the user config.edn). Per-project overrides could be under .polylith/templates in the workspace.

@seancorfield
Copy link
Contributor Author

I don't think it's worth templating the Calva settings but I'm open to being persuaded...?

@seancorfield
Copy link
Contributor Author

I can work up a PR with docs for this new feature -- organizationally, where would you like this added in the documentation?

@seancorfield
Copy link
Contributor Author

From Joakim:

You can put it after Libraries (before Configuration). I don't know what the best name is, but maybe Templating or something (you may have a better suggestion!). In the Creating a component section, it could be helpful if we link to this (e.g.) Templating section, mentioning that the content of the files are configurable.

(and this may need to change once dialects are supported -- that needs some discussion because if you change the structure in a breaking way, anyone with existing overriding templates will have their local config broken)

seancorfield added a commit to seancorfield/polylith that referenced this issue Dec 28, 2024
Signed-off-by: Sean Corfield <[email protected]>
tengstrand pushed a commit that referenced this issue Dec 30, 2024
Signed-off-by: Sean Corfield <[email protected]>
@seancorfield
Copy link
Contributor Author

At this point, is there any additional work needed for this issue?

@tengstrand
Copy link
Collaborator

No, nothing that I'm aware of.

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

No branches or pull requests

2 participants