How to enforce the templ cli version to match the templ module version? #592
Unanswered
yardenshoham
asked this question in
Q&A
Replies: 1 comment 2 replies
-
One option for you would be to not use I believe that you can use So the command would just be:
I'm on my phone so haven't had chance to test it out, but I believe it is possible. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As far as I understand, templ is used in 2 ways in a project. The first is as a dependency of
github.com/a-h/templ
ingo.mod
, specifying the version ingo.mod
and thus making sure you cangit clone
thengo mod download
and you end up using the intended version of templ. This is needed as the generated code importsgithub.com/a-h/templ
.The second way is as a CLI tool, installed with
go install github.com/a-h/templ/cmd/templ@VERSION
. This is to allow runningtempl generate
. I don't see a builtin way to enforce the versions of these to match. The best thing I can think of isgo install github.com/a-h/templ/cmd/templ@$(go list -m -f '{{ .Version }}' github.com/a-h/templ)
but this is a one-time operation, not suitable in case of a templ version upgrade.go mod download
doesn't control the version of the templ CLI tool.I am looking for a development experience similar to that of NodeJS tools like typescript or prettier. I can enforce the typescript compiler version by specifying the typescript module version in
package.json
, then everyone usenpx tsc
ornpm run build
and the version is maintained inpackage.json
. With the templ CLI tool there is a different experience, there's no equivalent tonpm install
asgo mod download
doesn't handle the templ CLI tool version inference.Beta Was this translation helpful? Give feedback.
All reactions