Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.assetgraph configuration file (DISCUSSION) #74

Open
Munter opened this issue May 21, 2013 · 8 comments
Open

.assetgraph configuration file (DISCUSSION) #74

Munter opened this issue May 21, 2013 · 8 comments
Labels

Comments

@Munter
Copy link
Member

Munter commented May 21, 2013

I was thinking that it might make sense having assetgraph-builder able to retrieve configuration from a .assetgraph configuration file, working in the usual dotfile manner.

It might give some benefit to the developer being able to store all the build configuration in this file instead of having to write a *ake-file just to invoke buildProduction the same way each time.

Further more I think it might give some future possibilities having the configuration in a well defined file. For example if we want to build assetgraph into other parts of the workflow, like an editor plugin, so they can share the configuration or parts of it.

@papandreou
Copy link
Member

Looking into this a bit now as part of getting rid of buildDevelopment and creating a standalone "development mode" script, which means that settings like the default locale ID, the locale cookie name, and the set of supported locales have to be specified in the development version of the project -- previously they were provided to buildDevelopment as command line options. I've been thinking about several ways that can happen.

First take: inline in the HTML:

<html data-supportedlocaleids="en_us,da,de" data-localecookiename="MyLanguageCookie">

or on the devMode include:

<script src="devMode.js" data-supportedlocaleids="en_us,da,de" data-localecookiename="MyLanguageCookie></script>

Both would be annoying in projects that have more than one HTML file, because the config would have to be duplicated. So I thought it might be useful to put them in an explicitly linked configuration file residing in the document root:

<script src="devMode.js" data-config="myProject.json"></script>

With myProject.json containg something like:

{
    "localeCookieName": "MyLanguageCookie",
    "supportedLocaleIds": ["en_us", "da", "de"]
}

But there's no reason why that config file couldn't contain all those other config options as well -- in which case the data-config attribute should probably be moved to the <html> element and renamed to data-assetgraph-config or something.

I honestly can't figure out if adding a config file like this smells too much. But I can't really come up with a better idea of how to configure the development mode script in one place.

@Munter
Copy link
Member Author

Munter commented Aug 19, 2013

I'm not sure about the concept of having to relate the html to a config file. Is this to cater to several different setups within the same project?

Most other build tools get along fine with a config file pretty much following the unix dotfile concept.

I just ran into another use case today, where having the configuration in a file instead of having to type it into the command line is helpful. Windows compatibility. My default setup is just to create a Makefile, but that puts a bunch of requirements on the windows user, where a dotfile in the project would reduce the build to buildProduction.

Munter added a commit to Munter/assetgraph-builder that referenced this issue Sep 1, 2013
Munter added a commit to Munter/assetgraph-builder that referenced this issue Sep 1, 2013
@Munter
Copy link
Member Author

Munter commented Sep 1, 2013

I've implemented this at least partially. Current behavior is now this:

  • Create config object based on defaults.
  • Look for config file in ./.assetgraph.json, fail over to ~/.assetgraph.json, fail over to ~/.config/.assetgraph.json.
  • If config file found, extend config with the values set in it.
  • Extend config with command line options if command line options differ from defaults.

From here on out it runs the usual magic to translate configuration paths to file system paths etc.

The last point on the list is a problem. I want the behavior to be that any command line option overrides any default and anything set in the config file. However optimist fills in the defaults into commandLineOptions, which means I can't see if a value came from the command line or from a default. This needs to make the behavior intuitive.

Is the config file lookup to extensive? I've tried mimicking linux standard dotfile behavior, but I am not certain assetgraph configuration is reusable across projects in that way. Maybe it should be altered to only look for a config file in the current directory.

Possible more things to implement

  • Config variables from environment variables
  • Config file path as command line option

@papandreou Any inputs? And would you be able to test this?

@papandreou
Copy link
Member

I'm working on my own implementation that's tied closely to the bootstrapper script, which will become a static script of its own. For the reasons stated above the config file needs to be fetchable by the frontend code, so those config file locations you mention won't work, and for now I'm on the fence about introducing a second config file.

@Munter
Copy link
Member Author

Munter commented Sep 26, 2014

This seems to cover a lot of bases. Might be a nice way to go not only for configuration, but also for bootstrapping all out assetgraph command line tools

@papandreou
Copy link
Member

I don't fully understand -- what exactly do you mean by "This"?

@papandreou
Copy link
Member

Just for the record -- a while ago I mentioned to @Munter offline that my plans wrt. configuring that bootstrapper script have changed somewhat, so I'm no longer on the fence about introducing a config file for that reason :)

@Munter
Copy link
Member Author

Munter commented Sep 26, 2014

lol, forgot to paste the link :)
https://github.com/tkellen/node-liftoff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants