Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@focusaurus
Copy link
Contributor

@focusaurus focusaurus commented Feb 21, 2019

  • Combine the main .env.example file with any .env.example
    files from custom plugins during setup
  • Also support ignoring commented-out lines in .env.example files
  • Also ignore blank lines
  • also format with shfmt
  • also fix one shellcheck lint error

Impact: minor
Type: feature

Issue

Sometimes reaction custom plugins need environment variable settings, and need to provide examples. Previously only the main reaction .env.example file was used to initially populate the user's .env file. Any settings from custom plugins would require a documented manual process to initially setup.

Solution

Search the imports/plugins/custom directory for any files named .env.example and incorporate those into the main .env.

Breaking changes

The script has always avoided overwriting any values that already exist in the file, and that behavior is retained.

Testing

I locally tested a few scenarios

  • no extra .env.example files
  • several custom plugins with .env.example files
  • a custom plugin with an .env.examplein a docs subdire

How to test this yourself

  • check out this feature branch
  • put a bunch of varying .env.example files in your directory tree including the reaction project directory and anywhere under imports/plugins/custom
  • Populate those files with a mix of KEY=value vars and commented out lines
  • Run bin/setup
  • Examine your project root .env file and make sure it has the values you expect

@focusaurus focusaurus added enhancement For issues that describe a feature that needs to be added, changed, or removed, but is not a bug solution-engineering labels Feb 21, 2019
@focusaurus focusaurus added this to the 🏔 Torreys milestone Feb 21, 2019
@focusaurus focusaurus self-assigned this Feb 21, 2019
@brent-hoover
Copy link
Collaborator

@focusaurus I think the "testing" portion of the PR template refers to how I would be able to test it to ensure it works

@focusaurus
Copy link
Contributor Author

OK @zenweasel I updated the description to have that info too

Copy link
Collaborator

@brent-hoover brent-hoover left a comment

Choose a reason for hiding this comment

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

When I run bin/setup on this branch on OSX I am getting the following error:

 »» ./bin/setup
xargs: illegal option -- -
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]

@focusaurus
Copy link
Contributor Author

Ah crap. That's a GNU xargs vs BSD xargs thing. BSD xargs doesn't support --no-run-if-empty. I think it can be eliminated though.

@focusaurus focusaurus force-pushed the feat-plugin-.env-files branch from 714392d to 09f1fc0 Compare February 25, 2019 15:58
@focusaurus
Copy link
Contributor Author

OK I removed the --no-run-if-empty. It was belt and suspenders anyway. Should be portable now.

@brent-hoover
Copy link
Collaborator

IMHO I think generally we want to avoid doing a --force-push as this means anybody else working on a branch (like a reviewer) cannot fast-forward.

@brent-hoover
Copy link
Collaborator

So I if I have a commented out line in one of my .env.example it adds a blank line, if I rerun it the other entries are fine but it continues to add blank lines for every time I run it.

@focusaurus
Copy link
Contributor Author

  • OK I can't reproduce the blank lines on linux. Will try on my mac.
  • Regarding amending commits and force pushing, this seems like a 1-commit change is what we want long term but sounds like a process we should define in Notion. Dunno, git seems like it's not giving us any great options in this scenario.

@focusaurus
Copy link
Contributor Author

Ah, OK it's not comment lines, it's blank lines which get carried forward.

- Combine the main .env.example file with any .env.example
  files from custom plugins during setup
- ignore blank lines
- also format with shfmt
- also fix one shellcheck lint error

Signed-off-by: Peter Lyons <[email protected]>
@focusaurus focusaurus force-pushed the feat-plugin-.env-files branch from 09f1fc0 to e0512ed Compare February 26, 2019 17:01
@focusaurus
Copy link
Contributor Author

OK @zenweasel I think the latest change should prevent blank line propagation. Sorry about the force pushes but I didn't want to change process mid-PR.

@brent-hoover
Copy link
Collaborator

Works great. Great work. 👍

@focusaurus focusaurus merged commit c10df2b into develop Feb 27, 2019
@focusaurus focusaurus deleted the feat-plugin-.env-files branch February 27, 2019 18:30
nnnnat pushed a commit that referenced this pull request Feb 28, 2019
feat: Use .env.example files from custom plugins
Signed-off-by: Nat Hamilton <[email protected]>
@jeffcorpuz jeffcorpuz mentioned this pull request Mar 1, 2019
@jeffcorpuz jeffcorpuz mentioned this pull request Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement For issues that describe a feature that needs to be added, changed, or removed, but is not a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants