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

Add Models - RcCollectionRaw and RcCollection #131

Closed
wants to merge 11 commits into from
Closed

Add Models - RcCollectionRaw and RcCollection #131

wants to merge 11 commits into from

Conversation

anithri
Copy link
Collaborator

@anithri anithri commented Oct 5, 2017

This class creates an ordered list of rc files that will be read.
It uses the BLUEPRINT_CONFIG env variable to add files to the default
search paths.

WIP

@codecov-io
Copy link

codecov-io commented Oct 5, 2017

Codecov Report

Merging #131 into master will increase coverage by 4.34%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #131      +/-   ##
==========================================
+ Coverage   82.17%   86.51%   +4.34%     
==========================================
  Files          27       31       +4     
  Lines         387      445      +58     
==========================================
+ Hits          318      385      +67     
+ Misses         69       60       -9
Impacted Files Coverage Δ
lib/models/project-settings.js 57.14% <0%> (-42.86%) ⬇️
lib/tasks/git-pull.js 14.28% <0%> (-3.11%) ⬇️
lib/tasks/create-and-step-into-directory.js 14.28% <0%> (-0.72%) ⬇️
lib/cli/environment.js 100% <0%> (ø) ⬆️
lib/models/rc-collection-raw.js 100% <0%> (ø)
lib/models/rc-collection.js 100% <0%> (ø)
lib/models/rc-data.js 100% <0%> (ø)
lib/util/mergers.js 100% <0%> (ø)
lib/models/blueprint-collection.js 97.22% <0%> (+0.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00684d6...4eeff2e. Read the comment docs.

@anithri
Copy link
Collaborator Author

anithri commented Oct 15, 2017

RcCollectionRaw is a model that to get a list of paths with blueprintrc files that exist.

It processes files from:

  1. CLI arguments (maybe? needs wired to cli), parses it as a colon separated list of paths
  2. if BLUEPRINT_CONFIG exists, parses it as a colon separated list of paths
  3. Project files in the cwd and working up the filesystem until it finds a .blueprintrc file
  4. User files in home directory and other common config dirs for linux, osx, and windows
  5. System files in common config dirs for linux, osx, and windows. (Windows and OSX need review and testing)

The paths are tested to be sure that they exist and are files

@anithri anithri changed the title Add Model - RcCollectionRaw Add Models - RcCollectionRaw and RcCollection Oct 16, 2017
@anithri
Copy link
Collaborator Author

anithri commented Oct 16, 2017

collection = new RcCollection(files: ['/path/to/a','/path/to/b']);
collection.collection // {'/path/to/a': aData, '/path/to/b': bData}
data = collection.data(defaults);
data // data merged defaults, bData, aData
data.assembly.configFiles // ['/path/to/a','/path/to/b'])

@anithri
Copy link
Collaborator Author

anithri commented Oct 16, 2017

blueprintrc files may have

{
// single line comments
/* multi 
    line 
    column */
  "Data": /* inlineComment */ "Value",
  "other": "Data", /* another Inline */
  "again": "Data" /* another Inline */ ,
}

because I hate not being able to comment config files

This class creates an ordered list of rc files that will be read.
It uses the BLUEPRINT_CONFIG env variable to add files to the default
search paths.
Returns an object deep merged from all files.  Arrays are joined as well.
@jamesr73
Copy link
Contributor

Looks good.

The CLI is currently configured to look for BLUEPRINT_ environment variables to set command line arguments. So if we add a --config CLI option it would be set by BLUEPRINT_CONFIG and overridden by --config. Looks messy to handle BLUEPRINT_CONFIG both in the CLI and the RC mechanism, should we just pass in the value from the CLI?

Suspect we need platform specific path separators rather than just using colon:

C:\path\to\.blueprintrc:C:\other\path\to\.blueprintrc

@anithri
Copy link
Collaborator Author

anithri commented Oct 29, 2017

I'll leave it to the cli to deal with the ENV then. Is that true for other options passed via ENV as well? I'd be happy to just accept an obj containing the parsed structure and values, is that possible? I'll remove my code that deals with that. I've been assuming that the CLI had top priority, and that ENV had 2nd.

. Ahem, do we need a different path separator? It's not something the shell would use, so does it matter to us? Not sure.

@anithri
Copy link
Collaborator Author

anithri commented Nov 2, 2017

Refactored into #132. Closing this earlier draft unmerged.

@anithri anithri closed this Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants