gleam-lang / gleam

⭐️ A friendly language for building type-safe, scalable systems!
https://gleam.run
Apache License 2.0
17.85k stars 745 forks source link

Restricted Project Naming #1728

Open coopbri opened 2 years ago

coopbri commented 2 years ago

Description

When creating a new Gleam project with gleam new, there are situations where the gleam CLI will respond with errors due to disallowed project naming patterns:

Context: based on this Twitter thread

Ideas

  1. Document this in the getting started guide/docs (may be a good temporary fix)
    • Mention reserved keywords situations (gleam prefix) as well as underscore convention
  2. Combine the error messages (though might be too much output to the user)
  3. Allow more project naming patterns; decouple Gleam project names from their parent folder name, allowing project directory names such as gleam-demo, gleam, and gleam_demo

    • I like this idea the most of the three proposed here; this is allowed in, for example, a new Rust/Cargo project. You can create projects with analogous name rust-demo, rust, and rust_demo:

Let me know if you have other ideas. I'm happy to take this on after a consensus is reached!

lpil commented 2 years ago

Thanks for the report, this must have been very annoying.

I would suggest that in these instances we could print something like this

"We were not able to create your project as gleam as etc etc....

Would you like is to create a project named my_gleam in a directory named gleam? (Y/n)"

decouple Gleam project names from their parent folder name, allowing project directory names such as gleam-demo, gleam, and gleam_demo

This is already the case! Unfortunately we take the project name as the argument here and use the director name as the same.

inoas commented 2 years ago

Maybe instead of saying what it should not be it should say what it should be:

Maybe fully formulating what the project name must be helps?

Like:

Project name must be lowercase, alphanumeric, may not start with a number and may not be named gleam or begin with gleam_.

coopbri commented 2 years ago

Thanks for the report, this must have been very annoying.

I would suggest that in these instances we could print something like this

"We were not able to create your project as gleam as etc etc....

Would you like is to create a project named my_gleam in a directory named gleam? (Y/n)"

decouple Gleam project names from their parent folder name, allowing project directory names such as gleam-demo, gleam, and gleam_demo

This is already the case! Unfortunately we take the project name as the argument here and use the director name as the same.

Not annoying at all! No worries.

I think coupling the solution from @inoas with the automated (Y/n) prompt suggested by @lpil might be a nice approach. Basically conveying all of the restrictions in one go while also automating a suggested project name.

lpil commented 2 years ago

Fab, I agree. Let's do it

lpil commented 1 year ago

The solution: make it suggest an alternative name. The full list of problems could be suggested in the text also, though the main problem would need to be presented first and foremost as today.

Davidjustice28 commented 7 months ago

@lpil Would be okay if I tackle this issue? I have been a developer for a over a year now, but for some reason, I have been intimidated in tackling a truly open source project. I am super excited about gleam and would like the language to be my first open source project to start contributing to. This would be a good first issue to stretch my legs.

lpil commented 7 months ago

Yes please! That'd be great. Do ask any questions if you have any while working on it.

Tar-Tarus commented 3 months ago

Hey @lpil , I've been working on #3395 and this issue here seemed close enough to tackle next. I've already started hacking around for a solution, would it be alright to take this up? I also have some initial questions but I guess it would be best to ask those in a PR when the code suggestion can be checked out in context as well...

lpil commented 3 months ago

Great! Yes please @Tar-Tarus !!