abelsiqueira / BestieTemplate.jl

Template for Julia Programming Language packages using the copier engine.
http://abelsiqueira.com/BestieTemplate.jl/
Mozilla Public License 2.0
38 stars 9 forks source link

[Bug] second `.jl` is added when package name is entered with `.jl` attached #373

Closed jhidding closed 1 month ago

jhidding commented 1 month ago

Description

When asked for the package name, a not too careful reader may enter a package name with .jl included, resulting in a double MyPackage.jl.jl. This could be easily caught.

Package Version

v0.9.0

Julia Version

1.10

Reproduction steps

run BestieTemplate.generate enter a package name with .jl

Relevant log output

Your package ModuleMixins.jl.jl has been created successfully! 🎉

Operating System

Linux

abelsiqueira commented 1 month ago

I could not reproduce, did you run BestieTemplate.generate("ModuleMixins.jl")?

In theory this shouldn't happen via the Julia interface because we run _sanitize_package_name on the path unless PackageName is manually set. You should see

[ Info: Using sanitized path ModuleMixins as package name

in the first line of log.

jhidding commented 1 month ago

No, I had the path already there, so I ran BestieTemplate.generate(".")

abelsiqueira commented 1 month ago

I can reproduce it, although it's not a bug.

The . is processed correctly as a lack of name, so the it moves on to the Copier side without a question. Then you get asked by Copier for the name, so it's out of ours hands.

There are a few ways to deal with this, though:

  1. Assume that . means that the package name is the name of the folder. I don't like it because it's not my business what happens in ...
  2. Assume that . is a mistake, and disallow it. I don't like it because it might be the case that people know what they're doing.
  3. Enforce rules on PackageName to disallow . in the name.

If you agree with the assessment, I will look into 3.

jhidding commented 1 month ago

Though a bit pedantic, I agree with the assessment. I think Copier lets you (at least) validate (https://copier.readthedocs.io/en/stable/configuring/#advanced-prompt-formatting) answers. Disallowing . in the name is the more fundamental approach.

abelsiqueira commented 1 month ago

Thanks, it's done in #377 now.

abelsiqueira commented 1 month ago

@allcontributors please add @jhidding for bug

allcontributors[bot] commented 1 month ago

@abelsiqueira

I've put up a pull request to add @jhidding! :tada: