yeoman / generator-angular

Yeoman generator for AngularJS
http://yeoman.io
5.73k stars 1.44k forks source link

Standardize filenames #463

Open eddiemonge opened 11 years ago

eddiemonge commented 11 years ago

Should all filenames be all lower cased? This is one of the last remaining naming issues I think. Lower casing all file names would solve a few problems.

sindresorhus commented 11 years ago

I prefer lower case names.

e-oz commented 10 years ago

It's so ugly... Why just don't let filenames be as they were submitted in CLI? If I want name all my files somethinglikethatandletthembeugly, I just will submit it in CLI... Can you please make it configurable?

eddiemonge commented 10 years ago

you could always rename them yourself and update the references. Having them be mixed case caused more problems. lower cased file names are better for web stuffs anyway since most servers are lower case/case insensitive and requiring people to remember mixed case urls is mean

e-oz commented 10 years ago

Of course I can, but automation tools should not require manual fixes... Having them be mixed case caused more problems. Non-declared breaking changes in tool, that's what cause problems. I had never experienced problems with filenames in this tool before. most servers are lower case/case insensitive wrong, most servers are on linux, so in most cases filesystems are case sensitive. and requiring people to remember mixed case urls is mean remember url of .js file? lol :) they are usually hidden at all, and names are minified to something like 5sdfd35.js, so I doubt somebody will require users to remember it.

In other words, it's really frustrating change and I'm going to fork and freeze 0.6 version for future usage.

reneolivo commented 10 years ago

Why enforce lower case? if I, as a developer, want to use lower case, I'd just declare them lower case.

I'm in total agreement with @jamm

passy commented 10 years ago

I think I agree with not touching the case. Could break existing workflows and if people that prefer lower case can still just pass it like that to the generator.

stephenplusplus commented 10 years ago

+1 to leaveMyCasingAlone.

For https://github.com/yeoman/generator-angular/issues/462, and yo angular:controller AuthWidget, shouldn't the generator be able to just append Ctrl to the controller name? When given yo angular:controller Auth-Widget-monkey-Man, does a helper not exist to morph that to "AuthWidgetmonkeyMan"?

And if not, writing one would be at least predictable - we can expect a filename to have dots or dashes. (Not an expert in legal file names, but I don't think we should cater to edge cases)

Yet another option would be displaying a prompt with a few suggestions, and letting the user decide.

Just some ideas. I think maintaining some casing, as it originally was, is less jarring/upsetting than turning CamelCase strings into camelcase.

eddiemonge commented 10 years ago

Reopening this and will add behavior so the file name follows the angular:xyz name. Lets see how many bugs that generates :8ball:

e-oz commented 10 years ago

@eddiemonge filenames shouldn't follows any hardcoded rules, developer should be able to declare name of file (and controller, directive, service) exactly as he wants. If user will create name pfxRemoteIP and your "behavior" will change it to PfxRemoteIp - it will be mistake (2 mistakes).

eddiemonge commented 10 years ago

The issue is that this is a scaffold generator. When you say yo angular:something someName, you aren't specifying a filename; you are specifying the name for that component. Since this is an opinionated tool, it is recommending what the component/filenames should be. You are free to change them after that. In the future (after the configuration milestone) we could look at passing flags to specify exactly what/where you want the file (name) to be.

e-oz commented 10 years ago

you aren't specifying a filename but it's exactly what I expect. Ok, so mine (and not only) opinion is different. Nothing wrong with it, people should be different. But please, make it at least configurable.

frapontillo commented 10 years ago

+1 for keeping the original userSpecifiedCase. I am okay with the yeoman defaults as a thumb rule, but every developer in an existing and consolidated workflow should be able to make his/her own decision.

addyosmani commented 10 years ago

I think I agree with not touching the case.

:+1:

antoinebrault commented 10 years ago

+1 for leaving the decision to the developer.

The lowercase commit introduced a bug too.. scripts declaration in my index.html were not lowercased. Just took me 30 mins to find why they weren't loading.

kevinsalter commented 10 years ago

+1 for leaving the decision to the developer.

The lowercase commit introduced a bug too.. scripts declaration in my index.html were not lowercased. Just took me 30 mins to find why they weren't loading.

I experienced this same problem, script references in index.html are still camel case, not good

agung-wete commented 10 years ago

+1 for leaving the decision to the developer +1 to leaveMyCasingAlone.

:smile:

eddiemonge commented 10 years ago

The bug for this in the current implementation is at #526

notbrain commented 10 years ago

This is of huge annoyance. Just piling on FWIW - it makes it difficult to add yeoman to a team when you have to mention intricacies like this; "Yeah it will do all this stuff for you but you have to edit it". It's an insipid bug too, since it typically will only surface when you publish to prod (linux) and go from a CI system (OSX) to a case-sensitive one. +1 to revert ASAP, not wait for the "configuration system" to be in place. This BUG was ADDED and is not a feature.

All that's needed is to revert this: https://github.com/yeoman/generator-angular/pull/504/files

reneolivo commented 10 years ago

I can't believe it's been months and they haven't reverted those changes back. It clearly is the source of many bugs.

eddiemonge commented 10 years ago

The source of the many bugs was the bug that the filename didn't get the same treatment. Thats been fixed in the latest release. Long term, choosing what casing you want to use will be a configuration option.

e-oz commented 10 years ago

yo angular:service h5mAnimation create app/scripts/services/h5manimation.js create test/spec/services/h5manimation.js

-->

angular.module('html5makerApp')
  .service('H5manimation', function H5manimation() {
    // AngularJS will instantiate a singleton by calling "new" on this function
  });

Bug returned after todays update to yeoman 1.2

ilovett commented 10 years ago

How about optionally providing the filename? When I have similar name service vs. controllers vs. directives vs. views, I like to have the type in the filename so I can quickly type it in and bring it up in my text editor rather than having to look at which subfolder a list of matching filenames are in...

yo angular:controller my-alerts my-alerts-controller.js
yo angular:factory my-alerts my-alerts-service.js
yo angular:factory my-alert my-alert-class.js
yo angular:directive my-alert my-alert-view.js
guy-mograbi-at-gigaspaces commented 10 years ago

Any news about this? I am eager to upgrade but reluctant due to this issue for over half a year now..

eddiemonge commented 10 years ago

this really isnt an upgrade blocking issue. nothing new yet. still slowly working on adding these things in

ghost commented 10 years ago

I'd like to see a way to specify a file naming pattern. We usually name things with "service" = .srv and "controller" = .ctrl, like this: data.srv.js = dataService home.ctrl.js = homeController.

Or at least consistent, like: yo angular:controller home yields "controllers/home.js" yet yo angular:service home yields "services/homeservice.js" (should be "services/home.js"?)

dancancro commented 10 years ago

My collection of file naming approaches is in the "Naming conventions" section of this spreadsheet , currently starting on row 195. If you would like to contribute just send me a request to share the doc.

GuyMograbi commented 10 years ago

I beg to differ - I have a project that used this generator when it supported camel case. if I upgrade now, half my files are all lower case and the other half are camel case.

I have to say I really don't understand this issue. After I run grunt build all the files are concatenated into modules.js and such.. the camel case is just for development and for convenience.

My IDE for example supports camel case search for file name.

perhaps the only files you should enforce lower case are the html files.. that I would get..

I would love to help speed up the process. what do I need to do in order to help?

I am visiting this page once a week at least just to check if something changed. I am very eager to see a change in the status.

BTW - I am pretty sure it created a bug. if I do yo angular:controller GuyTest it becomes GuytestCtrl. was this intentional? I have never seen a convention like this in any language.

This bug exists since 0.6.0 - I am forced to downgrade even more.

end-user commented 9 years ago

With the latest version, I'm still seeing this with the controller generator. Would very much like a way to specify the case pattern used.

guy-mograbi-at-gigaspaces commented 9 years ago

Hi, if anyone is still looking for a camel-case version, I have one on my fork. https://github.com/guy-mograbi-at-gigaspaces/generator-angular

70853n commented 9 years ago

As I see this the only problem here is the misleading documentation of generator-angular. It obviously shows an old example where myDirective resulted in myDirective.js

But the actual behavior of the subgenerators makes sense, i.e. the directive name is supposed to be entered in lowercase with hypens as delimiters (e.g. as we do within templates to declare an directive). That means yo angular:directive my-directive results in my-directive.js and .directive('myDirective', function () {}); which is completely fine.