YahooArchive / mojito

[archiving soon] Yahoo! Mojito Framework
BSD 3-Clause "New" or "Revised" License
1.57k stars 214 forks source link

[bz5667423] Add support for including files in a configuration bundle #238

Closed jlecomte closed 10 years ago

jlecomte commented 12 years ago

Use cases:

More specific use case applied to my project:

My team maintains a large number of independent apps (think 100+). Each app is a separate mojito application. Each app has some application level configuration which is a ycb bundle in a file named application.json. 90% of the content of that file is shared among all our apps. Therefore, it is not only stupid but dangerous to have 100+ copies of that file, each with their own sets of changes to support app-specific customizations.

Note: Yahoo!'s internal YCB library already supports "import_dimensions" to include dimensions files and "import_settings" to include settings files. See internal ticket #5667423

jlecomte commented 12 years ago

Additionally, it would be nice to extract the YCB library and make it its own independent npm package which mojito can depend on.

drewfish commented 12 years ago

This issue should probably move to https://github.com/yahoo/ycb/issues.

mridgway commented 12 years ago

ycb is currently not doing any file reading logic; data is inserted into the library by passing in a full javascript object. Do we need to move all filing reading logic into ycb in order to make this work? This would be an API shift from what I can tell.

jlecomte commented 12 years ago

I'm not sure what the final solution should be. Please, tell me if the use cases are clear enough though. I'd be more than happy to sit down and walk you through them.

drewfish commented 12 years ago

The current approach is nice because it allows the caller of YCB to deal with filesystem issues (sync vs. async, etc). However, it doesn't allow for the "include" feature that we'd like to add.

If we change YCB to read the files itself, the interface will have to be asychronous of course (perhaps optionally sync as well).

Using the object-oriented interface, we could perhaps get both approaches:

var ycbfile = new YCB({...options...});

ycbfile.loadJSON({...json...});
/// --- or ---
ycbfile.loadFile(path, callback);
/// --- or ---
ycbfile.loadFileSync(path);

/// --- then later
var config = ycbfile.read({...context...});
caridy commented 12 years ago

will a custom specs definition per mojit help in this case to get better organization/granularity?

drewfish commented 12 years ago

Even with specs-defined-in-the-mojit (which is possible today in fact), I think there might be a good usecase for splitting the application.json into parts.

caridy commented 11 years ago

PR #905 adds support for multi part application.json by using applicationConfigFiles in the master section of application.json to specify relative files that should be parsed. import_settings is still pending though.

caridy commented 10 years ago

this was solved a while ago.