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

feat: More config file options #383

Merged
merged 7 commits into from
Oct 1, 2019
Merged

feat: More config file options #383

merged 7 commits into from
Oct 1, 2019

Conversation

wwilsman
Copy link
Contributor

@wwilsman wwilsman commented Oct 1, 2019

Purpose

In part of making the configuration experience better by auto-loading .env files in percy-client, we can also expand .percy.yml support in agent to encompass more file types and use hierarchical priority!

Approach

Uses cosmiconfig to search for various .percy.* config files and auto-loads said configuration. The library will start its search for the filenames in the current working directory and recurse upwards until a match is found.

There is also an option to load a specific config file by passing in a filename to the loadSync method. So targeted configs can become possible by allowing a flag to provide a filepath. I added this option under a --config flag and removed the Circle step to manually rename the .ci.percy.yml file.

I noticed the previous configurations service mutated the DEFAULT_CONFIGURATION object which causes a false positive test. I took this as an opportunity to improve how configuration is handled, and made it into a pure functional util. For flags and args parsing: instead of a multitude of if statements, a map is used and undefined values are filtered out.

percy-client was updated to include .env support. Also of note is cosmiconfig was already a subdependency, so there was no overhead adding it as our own dependency.

@wwilsman wwilsman requested a review from Robdel12 October 1, 2019 21:50
@@ -43,9 +43,6 @@ jobs:
- run:
name: Upload command test
command: yarn test-upload-command
- run:
name: Setup integration test .percy.yml
command: mv .ci.percy.yml .percy.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹🎉

@wwilsman wwilsman changed the title feat: ✨ More config file options feat: More config file options Oct 1, 2019
Copy link
Contributor

@Robdel12 Robdel12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏁 Very nice, next task is to update the docs and reach out to the folks who asked for .env support 😃

config: flags.string({
char: 'c',
description: 'Path to percy config file',
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 🔥

@wwilsman wwilsman merged commit b9875a1 into master Oct 1, 2019
@delete-merged-branch delete-merged-branch bot deleted the ww/config branch October 1, 2019 22:05
djones pushed a commit that referenced this pull request Oct 1, 2019
# [0.17.0](v0.16.2...v0.17.0) (2019-10-01)

### Features

* ✨ More config file options ([#383](#383)) ([b9875a1](b9875a1))
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.

2 participants