atom / package-generator

Package to generate new packages
MIT License
92 stars 46 forks source link

Creating a package with a space in the name has odd behavior. #23

Closed MicahZoltu closed 9 years ago

MicahZoltu commented 9 years ago

Create a new package with a space in the name. Notice how throughout the project the name retains the space but the casing is normalized (lower) and a hyphen is added as a postfix after the space.

Example: Package name: Foo Bar Result: foo -bar

thomasjo commented 9 years ago

This is not supported. Words in package names should be separated with hyphens. None of the infrastructure (AFAIK) supports spaces the way the specified package name is used, including GitHub itself where the package name is used in an example repo URL. Package names are humanized in the places where it matters (almost nowhere); e.g. foo-bar would become "Foo Bar".

Not sure if this is documented anywhere, but seeing as we've never had any similar reports I can only guess it's either obvious, or that it's documented somewhere that I did not find right now.

thomasjo commented 9 years ago

This is also a duplicate of https://github.com/atom/package-generator/issues/17.

MicahZoltu commented 9 years ago

I believe there was a misunderstanding in my bug report. The space is left in, a hyphen is added (next to the space). In my example, foo -bar is foo<space><hyphen>bar. I provided my feedback on #17, but that is a separate discussion. Currently, name transformation is occurring but it is occurring incorrectly.

izuzak commented 9 years ago

@Zoltu The reason why you're seeing dashes in there is that names are dasherized, which means that capital letters are replaced with a lowercase letter + - prefix. See this.

For example:

> _.dasherize("AbCdEf")
> "ab-cd-ef"

In other words, you're seeing expected behavior here -- spaces are not the problem. Still, if you use spaces when generating a package, you will get a package.json which has name with spaces. And publishing such a package with apm will fail because apm will only accept packages with names a-zA-Z0-9_-. My opinion is that we should validate that in the input form and not allow creating packages with invalid names, and that's what issue #17 is about, I believe.

I hope that helps and I think we should keep this issue closed as a duplicate of #17. Let me know if I'm misunderstanding your report as well.

MicahZoltu commented 9 years ago

Ah, that makes sense. Thanks.