meanjs / generator-meanjs

MEAN.JS Official Yeoman Generator
http://meanjs.org/
473 stars 177 forks source link

Configurable Suffixes #247

Open TrentonAdams opened 7 years ago

TrentonAdams commented 7 years ago

I have made suffixes configurable for the various types of files like .client.view.html, .client.routes.js, etc.

I used the yeoman feature for storing configurations. If you put ".yo-rc.json" in the root of your MEAN.js project, the configurations in it will be automatically pulled in.

I did not provide unit tests for the yeoman storage API, as I presume we should trust that they've provided adequate unit tests for their own project.

http://yeoman.io/authoring/storage.html

A working .yo-rc.json is below...

{ "generator-meanjs": { "suffixes": { "client": { "config": ".config.js", "routes": ".routes.js", "controller": ".controller.js", "services": ".service.js", "module": ".module.js", "views": ".view.html", "controller_tests": ".js", "routes_tests": ".js" }, "server": { "config": ".config.js", "routes": ".routes.js", "controller": ".controller.js", "model": ".model.js", "policy": ".policy.js", "model_tests": ".tests.js", "routes_tests": ".tests.js" } } } }

I guess I should mention the risks and caveats, and we can think about how we want to mitigate them.

I can think of one risk. If you change all your suffixes to a simple '.js', they will somtimes conflict. i.e. testcruds.config.js and testcrudis.routes.js would both be testcruds.js. We could do a config validation of sorts on startup, and ensure there are no conflicts. It looks like app/index.js would be the appropriate location, yes?

TrentonAdams commented 7 years ago

Any thoughts on this as of yet?